Fixed work app drawable not adjusting to color upon selection.

This commit is contained in:
ottoptj 2024-08-15 02:22:07 +03:00
commit 32bbcd0ef9
2 changed files with 9 additions and 3 deletions

View file

@ -6,6 +6,8 @@ import android.content.Intent
import android.content.SharedPreferences
import android.content.pm.LauncherActivityInfo
import android.content.pm.LauncherApps
import android.graphics.BlendMode
import android.graphics.BlendModeColorFilter
import android.os.Build
import android.os.Bundle
import android.os.Handler
@ -645,6 +647,10 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
) {
if (userProfile != 0) {
shortcutView.setCompoundDrawablesWithIntrinsicBounds(ResourcesCompat.getDrawable(resources, R.drawable.ic_work_app, null),null,null,null)
shortcutView.compoundDrawables[0]?.colorFilter =
BlendModeColorFilter(sharedPreferenceManager.getTextColor(), BlendMode.SRC_ATOP)
shortcutView.compoundDrawables[2]?.colorFilter =
BlendModeColorFilter(sharedPreferenceManager.getTextColor(), BlendMode.SRC_ATOP)
}
else {
shortcutView.setCompoundDrawablesWithIntrinsicBounds(ResourcesCompat.getDrawable(resources, R.drawable.ic_empty, null),null,null,null)

View file

@ -73,9 +73,9 @@ class UIUtils(context: Context) {
val color = sharedPreferenceManager.getTextColor()
view.setTextColor(setAlpha(color, alphaHex))
view.setHintTextColor(setAlpha(color, "A9"))
if (view.compoundDrawables[0] != null) {
view.compoundDrawables[0].mutate().colorFilter = BlendModeColorFilter(color, BlendMode.SRC_ATOP)
}
view.compoundDrawables[0]?.mutate()?.colorFilter = BlendModeColorFilter(color, BlendMode.SRC_ATOP)
}
}