mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-14 14:02:44 +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";
|
||||
|
|
|
@ -697,6 +697,8 @@ New dictionary:
|
|||
<string name="user_dict_add_word_button">Add a word</string>
|
||||
<!-- Option for choosing theme style [CHAR LIMIT=33] -->
|
||||
<string name="theme_style">Style</string>
|
||||
<!-- Option for choosing icon style (same options as theme_style) -->
|
||||
<string name="icon_style">Icon style</string>
|
||||
<!-- Style name for Rounded style -->
|
||||
<string name="style_name_Rounded" tools:keep="@string/style_name_Rounded">Rounded</string>
|
||||
<!-- Option for choosing colors [CHAR LIMIT=33] -->
|
||||
|
|
|
@ -19,6 +19,12 @@
|
|||
android:defaultValue="Material"
|
||||
latin:singleLineTitle="false" />
|
||||
|
||||
<ListPreference
|
||||
android:key="icon_style"
|
||||
android:title="@string/icon_style"
|
||||
android:defaultValue="Material"
|
||||
latin:singleLineTitle="false" />
|
||||
|
||||
<ListPreference
|
||||
android:key="theme_colors"
|
||||
android:title="@string/theme_colors"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue