diff --git a/java/src/org/futo/inputmethod/latin/LatinIME.kt b/java/src/org/futo/inputmethod/latin/LatinIME.kt index b4feefc43..13b16f64f 100644 --- a/java/src/org/futo/inputmethod/latin/LatinIME.kt +++ b/java/src/org/futo/inputmethod/latin/LatinIME.kt @@ -53,9 +53,6 @@ import org.futo.inputmethod.latin.uix.DynamicThemeProvider import org.futo.inputmethod.latin.uix.DynamicThemeProviderOwner import org.futo.inputmethod.latin.uix.EmojiTracker.unuseEmoji import org.futo.inputmethod.latin.uix.EmojiTracker.useEmoji -import org.futo.inputmethod.latin.uix.HiddenKeysSetting -import org.futo.inputmethod.latin.uix.KeyBordersSetting -import org.futo.inputmethod.latin.uix.KeyHintsSetting import org.futo.inputmethod.latin.uix.KeyboardBottomOffsetSetting import org.futo.inputmethod.latin.uix.SUGGESTION_BLACKLIST import org.futo.inputmethod.latin.uix.THEME_KEY diff --git a/java/src/org/futo/inputmethod/latin/uix/BasicThemeProvider.kt b/java/src/org/futo/inputmethod/latin/uix/BasicThemeProvider.kt index 680e3f378..acdf44c61 100644 --- a/java/src/org/futo/inputmethod/latin/uix/BasicThemeProvider.kt +++ b/java/src/org/futo/inputmethod/latin/uix/BasicThemeProvider.kt @@ -56,6 +56,10 @@ fun adjustColorBrightnessForContrast(bgColor: Int, fgColor: Int, desiredContrast return ColorUtils.HSLToColor(bgHSL) } +fun Preferences.get(key: SettingsKey): T { + return this[key.key] ?: key.default +} + class BasicThemeProvider(val context: Context, val overrideColorScheme: ColorScheme? = null) : DynamicThemeProvider { override val primaryKeyboardColor: Int @@ -133,16 +137,11 @@ class BasicThemeProvider(val context: Context, val overrideColorScheme: ColorSch val keyboardHeight: Float - fun hasUpdated(newPreferences: Preferences): Boolean { - return when { - newPreferences[HiddenKeysSetting.key] != expertMode -> true - newPreferences[KeyBordersSetting.key] != keyBorders -> true - newPreferences[KeyHintsSetting.key] != showKeyHints -> true - - newPreferences[KeyboardHeightMultiplierSetting.key] != keyboardHeight -> true - - else -> false - } + fun hasUpdated(np: Preferences): Boolean { + return np.get(HiddenKeysSetting) != expertMode + || np.get(KeyBordersSetting) != keyBorders + || np.get(KeyHintsSetting) != showKeyHints + || np.get(KeyboardHeightMultiplierSetting) != keyboardHeight } init { @@ -159,8 +158,7 @@ class BasicThemeProvider(val context: Context, val overrideColorScheme: ColorSch expertMode = context.getSettingBlocking(HiddenKeysSetting) keyBorders = context.getSettingBlocking(KeyBordersSetting) showKeyHints = context.getSettingBlocking(KeyHintsSetting) - - keyboardHeight = context.getSettingBlocking(KeyboardHeightMultiplierSetting.key, KeyboardHeightMultiplierSetting.default) + keyboardHeight = context.getSettingBlocking(KeyboardHeightMultiplierSetting) val primary = colorScheme.primary.toArgb() val secondary = colorScheme.secondary.toArgb()