Allow setting default accent color from config.xml

Co-authored-by: Daria Hamrah Paytakht <info@dariarnd.ir>
This commit is contained in:
Yasan Ghaffarian
2022-06-08 11:11:45 +04:30
parent 4e0804bd59
commit e9b37ffb3f
3 changed files with 9 additions and 6 deletions

View File

@@ -47,6 +47,9 @@
<!-- Which calendar to use on smartspace by default -->
<string name="config_default_smart_space_calendar" translatable="false">gregorian</string>
<!-- which accent color to use by default -->
<string name="config_default_accent_color" translatable="false"></string>
<bool name="config_default_dark_status_bar">false</bool>
<bool name="config_default_dock_search_bar">true</bool>
<bool name="config_default_show_notification_count">false</bool>

View File

@@ -114,11 +114,7 @@ class PreferenceManager2(private val context: Context) : PreferenceManager {
parse = ColorOption::fromString,
save = ColorOption::toString,
onSet = { reloadHelper.recreate() },
defaultValue = when {
Utilities.ATLEAST_S -> ColorOption.SystemAccent
Utilities.ATLEAST_O_MR1 -> ColorOption.WallpaperPrimary
else -> ColorOption.LawnchairBlue
},
defaultValue = ColorOption.fromString(context.getString(R.string.config_default_accent_color)),
)
val hiddenApps = preference(

View File

@@ -80,7 +80,11 @@ sealed class ColorOption {
} catch (e: IllegalArgumentException) {
// ignore
}
return SystemAccent
return when {
Utilities.ATLEAST_S -> SystemAccent
Utilities.ATLEAST_O_MR1 -> WallpaperPrimary
else -> LawnchairBlue
}
}
}
}