@ -44,6 +44,7 @@ class WidgetSettings : InjectingPreferenceFragment() {
companion object {
companion object {
private const val REQUEST _THEME _SELECTION = 1006
private const val REQUEST _THEME _SELECTION = 1006
private const val REQUEST _COLOR _SELECTION = 1007
private const val REQUEST _COLOR _SELECTION = 1007
private const val REQUEST _CUSTOM _THEME _COLOR _SELECTION = 1009
private const val REQUEST _SORT = 1008
private const val REQUEST _SORT = 1008
const val EXTRA _WIDGET _ID = " extra_widget_id "
const val EXTRA _WIDGET _ID = " extra_widget_id "
@ -163,6 +164,13 @@ class WidgetSettings : InjectingPreferenceFragment() {
updateFilter ( )
updateFilter ( )
updateTheme ( )
updateTheme ( )
updateColor ( )
updateColor ( )
val customThemeColor = findPreference ( R . string . p _widget _custom _theme _color )
customThemeColor . onPreferenceClickListener = Preference . OnPreferenceClickListener {
newColorPalette ( this , REQUEST _CUSTOM _THEME _COLOR _SELECTION , widgetPreferences . customThemeColor , Palette . WIDGET )
. show ( parentFragmentManager , FRAG _TAG _COLOR _PICKER )
false
}
}
}
override fun onActivityResult ( requestCode : Int , resultCode : Int , data : Intent ? ) {
override fun onActivityResult ( requestCode : Int , resultCode : Int , data : Intent ? ) {
@ -182,6 +190,12 @@ class WidgetSettings : InjectingPreferenceFragment() {
)
)
updateColor ( )
updateColor ( )
}
}
REQUEST _CUSTOM _THEME _COLOR _SELECTION -> if ( resultCode == Activity . RESULT _OK ) {
widgetPreferences . setCustomThemeColor (
data !! . getIntExtra ( ColorWheelPicker . EXTRA _SELECTED , 0 )
)
updateCustomThemeColor ( )
}
REQUEST _SORT -> if ( resultCode == Activity . RESULT _OK ) updateSort ( )
REQUEST _SORT -> if ( resultCode == Activity . RESULT _OK ) updateSort ( )
else -> super . onActivityResult ( requestCode , resultCode , data )
else -> super . onActivityResult ( requestCode , resultCode , data )
}
}
@ -198,12 +212,17 @@ class WidgetSettings : InjectingPreferenceFragment() {
val widgetNames = resources . getStringArray ( R . array . widget _themes )
val widgetNames = resources . getStringArray ( R . array . widget _themes )
findPreference ( R . string . p _widget _theme ) . summary = widgetNames [ index ]
findPreference ( R . string . p _widget _theme ) . summary = widgetNames [ index ]
findPreference ( R . string . p _widget _color _v2 ) . isVisible = index != 4
findPreference ( R . string . p _widget _color _v2 ) . isVisible = index != 4
findPreference ( R . string . p _widget _custom _theme _color ) . isVisible = index == 5
}
}
private fun updateColor ( ) {
private fun updateColor ( ) {
tintColorPreference ( R . string . p _widget _color _v2 , widgetPreferences . color )
tintColorPreference ( R . string . p _widget _color _v2 , widgetPreferences . color )
}
}
private fun updateCustomThemeColor ( ) {
tintColorPreference ( R . string . p _widget _custom _theme _color , widgetPreferences . customThemeColor )
}
private fun updateFilter ( ) = lifecycleScope . launch {
private fun updateFilter ( ) = lifecycleScope . launch {
findPreference ( R . string . p _widget _filter ) . summary = getFilter ( ) . title
findPreference ( R . string . p _widget _filter ) . summary = getFilter ( ) . title
updateSort ( )
updateSort ( )