Replace color pref summaries with tinted icons

pull/935/head
Alex Baker 6 years ago
parent ff33d5821c
commit 5f466e041c

@ -79,15 +79,6 @@ class LookAndFeel : InjectingPreferenceFragment(), Preference.OnPreferenceChange
override fun getPreferenceXml() = R.xml.preferences_look_and_feel override fun getPreferenceXml() = R.xml.preferences_look_and_feel
override fun setupPreferences(savedInstanceState: Bundle?) { override fun setupPreferences(savedInstanceState: Bundle?) {
setupColorPreference(R.string.p_theme_color, themeColor.name, COLORS, REQUEST_COLOR_PICKER)
setupColorPreference(
R.string.p_theme_accent,
themeAccent.name,
ACCENTS,
REQUEST_ACCENT_PICKER
)
updateLauncherPreference()
findPreference(R.string.p_show_subtasks) findPreference(R.string.p_show_subtasks)
.setOnPreferenceChangeListener { _: Preference?, _: Any? -> .setOnPreferenceChangeListener { _: Preference?, _: Any? ->
localBroadcastManager.broadcastRefresh() localBroadcastManager.broadcastRefresh()
@ -149,19 +140,27 @@ class LookAndFeel : InjectingPreferenceFragment(), Preference.OnPreferenceChange
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
setupColorPreference(R.string.p_theme_color, themeColor.pickerColor, COLORS, REQUEST_COLOR_PICKER)
setupColorPreference(
R.string.p_theme_accent,
themeAccent.pickerColor,
ACCENTS,
REQUEST_ACCENT_PICKER
)
updateLauncherPreference()
@Suppress("ConstantConditionIf") @Suppress("ConstantConditionIf")
if (BuildConfig.FLAVOR == "googleplay") { if (BuildConfig.FLAVOR == "googleplay") {
setupLocationPickers() setupLocationPickers()
} }
} }
private fun updateLauncherPreference() = private fun updateLauncherPreference() {
val launcher = themeCache.getThemeColor(preferences.getInt(R.string.p_theme_launcher, 7))
setupColorPreference( setupColorPreference(
R.string.p_theme_launcher, R.string.p_theme_launcher, launcher.pickerColor, LAUNCHER, REQUEST_LAUNCHER_PICKER
themeCache.getThemeColor(preferences.getInt(R.string.p_theme_launcher, 7)).name,
LAUNCHER,
REQUEST_LAUNCHER_PICKER
) )
}
private fun setupLocationPickers() { private fun setupLocationPickers() {
val choices = val choices =
@ -362,12 +361,14 @@ class LookAndFeel : InjectingPreferenceFragment(), Preference.OnPreferenceChange
} }
private fun setupColorPreference( private fun setupColorPreference(
@StringRes prefId: Int, summary: String?, @StringRes prefId: Int, color: Int,
palette: ColorPickerActivity.ColorPalette, palette: ColorPickerActivity.ColorPalette,
requestCode: Int requestCode: Int
) { ) {
val themePref: Preference = findPreference(prefId) val themePref: Preference = findPreference(prefId)
themePref.summary = summary val original = ContextCompat.getDrawable(context!!, R.drawable.ic_baseline_lens_24px)
themePref.icon = DrawableCompat.wrap(original!!.mutate())
DrawableCompat.setTint(themePref.icon, color)
themePref.setOnPreferenceClickListener { themePref.setOnPreferenceClickListener {
val intent = Intent(context, ColorPickerActivity::class.java) val intent = Intent(context, ColorPickerActivity::class.java)
intent.putExtra(ColorPickerActivity.EXTRA_PALETTE, palette) intent.putExtra(ColorPickerActivity.EXTRA_PALETTE, palette)

Loading…
Cancel
Save