- recolor chip when background = list color

- auto update custom widget color preview
pull/3687/head
Samuel Born 4 months ago
parent b8a75f5938
commit d9e064d1b9
No known key found for this signature in database

@ -164,6 +164,7 @@ class WidgetSettings : InjectingPreferenceFragment() {
updateFilter()
updateTheme()
updateColor()
updateCustomThemeColor()
val customThemeColor = findPreference(R.string.p_widget_custom_theme_color)
customThemeColor.onPreferenceClickListener = Preference.OnPreferenceClickListener {

@ -64,6 +64,14 @@ internal class TasksWidgetViewFactory(
init {
chipProvider.isDark = settings.isDark
val widgetThemes = context.resources.getStringArray(R.array.widget_themes)
val customThemeName = context.getString(R.string.theme_custom)
val customThemeIndex = widgetThemes.indexOf(customThemeName)
if (widgetPreferences.themeIndex == customThemeIndex) {
chipProvider.customBackgroundColor = widgetPreferences.customThemeColor
}
}
override fun onCreate() {}

@ -32,6 +32,7 @@ class WidgetChipProvider @Inject constructor(
private val inventory: Inventory,
) {
var isDark = false
@ColorInt var customBackgroundColor: Int? = null
fun getSubtaskChip(task: TaskContainer): RemoteViews {
return newChip().apply {
@ -127,13 +128,18 @@ class WidgetChipProvider @Inject constructor(
}
private fun newChip(@ColorInt color: Int = 0) = RemoteViews(BuildConfig.APPLICATION_ID, R.layout.widget_chip).apply {
val tint = if (color == 0) {
var tint = if (color == 0) {
context.getColor(
if (isDark) R.color.icon_tint_dark_alpha else R.color.icon_tint_light_alpha
)
} else {
color
}
if (customBackgroundColor != null && tint == customBackgroundColor) {
tint = context.getColor(if (isDark) R.color.white_87 else R.color.black_87)
}
setColorFilter(R.id.chip_icon, tint)
setColorFilter(R.id.chip_background, tint)
setTextColor(R.id.chip_text, tint)

Loading…
Cancel
Save