mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-14 05:52:47 +00:00
allow independent selection of icon style and theme style
This commit is contained in:
parent
aed5704582
commit
48b0bb1cbf
5 changed files with 24 additions and 2 deletions
|
@ -18,8 +18,8 @@ class KeyboardIconsSet private constructor() {
|
|||
|
||||
fun loadIcons(context: Context) {
|
||||
val prefs = DeviceProtectedUtils.getSharedPreferences(context)
|
||||
val theme = prefs.getString(Settings.PREF_THEME_STYLE, KeyboardTheme.STYLE_MATERIAL)
|
||||
val ids = when (theme) {
|
||||
val iconStyle = prefs.getString(Settings.PREF_ICON_STYLE, KeyboardTheme.STYLE_MATERIAL)
|
||||
val ids = when (iconStyle) {
|
||||
KeyboardTheme.STYLE_HOLO -> keyboardIconsHolo
|
||||
KeyboardTheme.STYLE_ROUNDED -> keyboardIconsRounded
|
||||
else -> keyboardIconsMaterial
|
||||
|
|
|
@ -33,6 +33,7 @@ class AppearanceSettingsFragment : SubScreenFragment() {
|
|||
private var needsReload = false
|
||||
|
||||
private val stylePref: ListPreference by lazy { preferenceScreen.findPreference(Settings.PREF_THEME_STYLE)!! }
|
||||
private val iconStylePref: ListPreference by lazy { preferenceScreen.findPreference(Settings.PREF_ICON_STYLE)!! }
|
||||
private val colorsPref: ListPreference by lazy { preferenceScreen.findPreference(Settings.PREF_THEME_COLORS)!! }
|
||||
private val colorsNightPref: ListPreference? by lazy { preferenceScreen.findPreference(Settings.PREF_THEME_COLORS_NIGHT) }
|
||||
private val dayNightPref: TwoStatePreference? by lazy { preferenceScreen.findPreference(Settings.PREF_THEME_DAY_NIGHT) }
|
||||
|
@ -155,6 +156,18 @@ class AppearanceSettingsFragment : SubScreenFragment() {
|
|||
}
|
||||
summary = entries[entryValues.indexOfFirst { it == value }]
|
||||
}
|
||||
iconStylePref.apply {
|
||||
entryValues = KeyboardTheme.STYLES
|
||||
entries = entryValues.getNamesFromResourcesIfAvailable("style_name_")
|
||||
if (value !in entryValues)
|
||||
value = entryValues.first().toString()
|
||||
|
||||
onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, value ->
|
||||
summary = entries[entryValues.indexOfFirst { it == value }]
|
||||
true
|
||||
}
|
||||
summary = entries[entryValues.indexOfFirst { it == value }]
|
||||
}
|
||||
dayNightPref?.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, value ->
|
||||
val yesThisIsBoolean = value as Boolean // apparently kotlin smartcast got less smart with 2.0.0
|
||||
colorsNightPref?.isVisible = yesThisIsBoolean
|
||||
|
|
|
@ -60,6 +60,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
|||
|
||||
// theme-related stuff
|
||||
public static final String PREF_THEME_STYLE = "theme_style";
|
||||
public static final String PREF_ICON_STYLE = "icon_style";
|
||||
public static final String PREF_THEME_COLORS = "theme_colors";
|
||||
public static final String PREF_THEME_COLORS_NIGHT = "theme_colors_night";
|
||||
public static final String PREF_THEME_KEY_BORDERS = "theme_key_borders";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue