Merge pull request 'Fixed work app drawable not adjusting to color upon selection.' (#5) from 0.6-test into main

Reviewed-on: https://codeberg.org/ottoptj/yamlauncher/pulls/5
This commit is contained in:
Otto Petäjä 2024-08-14 23:29:43 +00:00
commit 694447a9fd
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.SharedPreferences
import android.content.pm.LauncherActivityInfo import android.content.pm.LauncherActivityInfo
import android.content.pm.LauncherApps import android.content.pm.LauncherApps
import android.graphics.BlendMode
import android.graphics.BlendModeColorFilter
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.os.Handler import android.os.Handler
@ -645,6 +647,10 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
) { ) {
if (userProfile != 0) { if (userProfile != 0) {
shortcutView.setCompoundDrawablesWithIntrinsicBounds(ResourcesCompat.getDrawable(resources, R.drawable.ic_work_app, null),null,null,null) 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 { else {
shortcutView.setCompoundDrawablesWithIntrinsicBounds(ResourcesCompat.getDrawable(resources, R.drawable.ic_empty, null),null,null,null) 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() val color = sharedPreferenceManager.getTextColor()
view.setTextColor(setAlpha(color, alphaHex)) view.setTextColor(setAlpha(color, alphaHex))
view.setHintTextColor(setAlpha(color, "A9")) 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)
}
} }
} }