Update widget preferences screen

* Add widget color indicator
* Add submenu arrow indicator
pull/1818/head
Alex Baker 3 years ago
parent 5e9d97e06f
commit a27047b6f8

@ -61,8 +61,10 @@ abstract class InjectingPreferenceFragment : PreferenceFragmentCompat() {
kotlin.system.exitProcess(0) kotlin.system.exitProcess(0)
} }
protected fun tintColorPreference(resId: Int, tint: Int) { protected fun tintColorPreference(resId: Int, tint: Int) =
val pref = findPreference(resId) tintColorPreference(findPreference(resId), tint)
protected fun tintColorPreference(pref: Preference, tint: Int) {
pref.icon = DrawableUtil.getWrapped(requireContext(), R.drawable.color_picker) pref.icon = DrawableUtil.getWrapped(requireContext(), R.drawable.color_picker)
DrawableUtil.setTint(pref.icon, tint) DrawableUtil.setTint(pref.icon, tint)
} }

@ -2,13 +2,14 @@ package org.tasks.preferences.fragments
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import androidx.appcompat.content.res.AppCompatResources
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.preference.Preference
import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import org.tasks.R import org.tasks.R
import org.tasks.injection.InjectingPreferenceFragment import org.tasks.injection.InjectingPreferenceFragment
import org.tasks.preferences.DefaultFilterProvider import org.tasks.preferences.DefaultFilterProvider
import org.tasks.preferences.IconPreference
import org.tasks.preferences.Preferences import org.tasks.preferences.Preferences
import org.tasks.widget.AppWidgetManager import org.tasks.widget.AppWidgetManager
import org.tasks.widget.WidgetConfigActivity import org.tasks.widget.WidgetConfigActivity
@ -33,7 +34,14 @@ class Widgets : InjectingPreferenceFragment() {
preferenceScreen.removeAll() preferenceScreen.removeAll()
appWidgetManager.widgetIds.forEach { appWidgetManager.widgetIds.forEach {
val widgetPrefs = WidgetPreferences(context, preferences, it) val widgetPrefs = WidgetPreferences(context, preferences, it)
val pref = Preference(context) val pref = IconPreference(context)
tintColorPreference(pref, widgetPrefs.color)
pref.drawable = AppCompatResources.getDrawable(
requireContext(),
R.drawable.ic_keyboard_arrow_right_24px
)?.mutate()
pref.tint = context?.getColor(R.color.icon_tint_with_alpha)
pref.iconVisible = true
val filter = defaultFilterProvider.getFilterFromPreference(widgetPrefs.filterId) val filter = defaultFilterProvider.getFilterFromPreference(widgetPrefs.filterId)
pref.title = filter.listingTitle pref.title = filter.listingTitle
pref.summary = getString(R.string.widget_id, it) pref.summary = getString(R.string.widget_id, it)

Loading…
Cancel
Save