From ba70be8b653b2f9668b9018d0422e5924b592204 Mon Sep 17 00:00:00 2001 From: Helium314 Date: Fri, 1 Sep 2023 23:01:47 +0200 Subject: [PATCH] cleanup keyboardThemes, remove holo blue (but keep the file for now) --- .../inputmethod/keyboard/KeyboardTheme.java | 61 ++++--------------- .../settings/AppearanceSettingsFragment.kt | 6 +- app/src/main/res/values/attrs.xml | 20 ++---- app/src/main/res/values/themes-holo.xml | 2 +- ...es-holo_white.xml => themes-holo_base.xml} | 58 +++++++++--------- app/src/main/res/values/themes-holo_blue.xml | 14 +++-- .../res/xml-sw600dp/key_styles_common.xml | 6 +- .../main/res/xml-sw600dp/key_styles_enter.xml | 2 +- app/src/main/res/xml/key_styles_common.xml | 8 +-- app/src/main/res/xml/key_styles_enter.xml | 2 +- .../res/xml/key_styles_navigate_more_keys.xml | 2 +- app/src/main/res/xml/key_styles_number.xml | 2 +- 12 files changed, 71 insertions(+), 112 deletions(-) rename app/src/main/res/values/{themes-holo_white.xml => themes-holo_base.xml} (84%) diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/KeyboardTheme.java b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/KeyboardTheme.java index 8cbf9ddf1..aa6a55534 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/KeyboardTheme.java +++ b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/KeyboardTheme.java @@ -57,37 +57,18 @@ public final class KeyboardTheme implements Comparable { // These should be aligned with Keyboard.themeId and Keyboard.Case.keyboardTheme // attributes' values in attrs.xml. - public static final int THEME_ID_HOLO_BLUE = 0; - public static final int THEME_ID_HOLO_WHITE = 1; - public static final int THEME_ID_HOLO_CUSTOM = 2; // todo: custom <-> white? - public static final int THEME_ID_LXX_BASE = 3; - public static final int THEME_ID_LXX_BASE_BORDER = 4; - public static final int THEME_ID_LXX_CUSTOM = 5; // todo: custom <-> base? - public static final int THEME_ID_LXX_CUSTOM_BORDER = 6; - public static final int DEFAULT_THEME_ID = THEME_ID_LXX_CUSTOM; + public static final int THEME_ID_HOLO_BASE = 0; + public static final int THEME_ID_LXX_BASE = 1; + public static final int THEME_ID_LXX_BASE_BORDER = 2; + public static final int DEFAULT_THEME_ID = THEME_ID_LXX_BASE; /* package private for testing */ static final KeyboardTheme[] KEYBOARD_THEMES = { - new KeyboardTheme(THEME_ID_HOLO_BLUE, "HoloBlue", R.style.KeyboardTheme_HoloBlue, - // This has never been selected because we support ICS or later. - VERSION_CODES.BASE), - new KeyboardTheme(THEME_ID_HOLO_WHITE, "HoloWhite", R.style.KeyboardTheme_HoloWhite, - // Default theme for ICS, JB, and KLP. - VERSION_CODES.ICE_CREAM_SANDWICH), - new KeyboardTheme(THEME_ID_LXX_CUSTOM, "LXXCustom", R.style.KeyboardTheme_LXX_Base, - // This has never been selected as default theme. - VERSION_CODES.LOLLIPOP), - new KeyboardTheme(THEME_ID_LXX_CUSTOM_BORDER, "LXXCustomBorder", R.style.KeyboardTheme_LXX_Base_Border, - // This has never been selected as default theme. - VERSION_CODES.LOLLIPOP), - new KeyboardTheme(THEME_ID_HOLO_CUSTOM, "HoloCustom", R.style.KeyboardTheme_HoloWhite, - // This has never been selected as default theme. + new KeyboardTheme(THEME_ID_HOLO_BASE, "HoloBase", R.style.KeyboardTheme_HoloBase, VERSION_CODES.BASE), new KeyboardTheme(THEME_ID_LXX_BASE, "LXXBase", R.style.KeyboardTheme_LXX_Base, - // This has never been selected as default theme. VERSION_CODES.LOLLIPOP), new KeyboardTheme(THEME_ID_LXX_BASE_BORDER, "LXXBaseBorder", R.style.KeyboardTheme_LXX_Base_Border, - // This has never been selected as default theme. VERSION_CODES.LOLLIPOP), }; @@ -183,13 +164,12 @@ public final class KeyboardTheme implements Comparable { final SharedPreferences prefs = DeviceProtectedUtils.getSharedPreferences(context); final String style = prefs.getString(Settings.PREF_THEME_STYLE, THEME_STYLE_MATERIAL); final boolean borders = prefs.getBoolean(Settings.PREF_THEME_KEY_BORDERS, false); - final int matchingId = style.equals(THEME_STYLE_HOLO) ? THEME_ID_HOLO_CUSTOM : (borders ? THEME_ID_LXX_CUSTOM_BORDER : THEME_ID_LXX_CUSTOM); - for (int i = 0; i < KEYBOARD_THEMES.length; i++) { - if (KEYBOARD_THEMES[i].mThemeId == matchingId) - return KEYBOARD_THEMES[i]; + final int matchingId = style.equals(THEME_STYLE_HOLO) ? THEME_ID_HOLO_BASE : (borders ? THEME_ID_LXX_BASE_BORDER : THEME_ID_LXX_BASE); + for (KeyboardTheme keyboardTheme : KEYBOARD_THEMES) { + if (keyboardTheme.mThemeId == matchingId) + return keyboardTheme; } - return KEYBOARD_THEMES[2]; // custom no border -// return getKeyboardTheme(prefs, Build.VERSION.SDK_INT, KEYBOARD_THEMES); + return KEYBOARD_THEMES[2]; // base no border as default } /* package private for testing */ @@ -215,31 +195,14 @@ public final class KeyboardTheme implements Comparable { } public static String getThemeFamily(int themeId) { - if (themeId == THEME_ID_HOLO_BLUE || themeId == THEME_ID_HOLO_WHITE || themeId == THEME_ID_HOLO_CUSTOM) return THEME_STYLE_HOLO; + if (themeId == THEME_ID_HOLO_BASE) return THEME_STYLE_HOLO; return THEME_STYLE_MATERIAL; } public static boolean getHasKeyBorders(int themeId) { - switch (themeId) { - case THEME_ID_LXX_CUSTOM_BORDER: - case THEME_ID_HOLO_BLUE: - case THEME_ID_HOLO_WHITE: - return true; - default: - return false; - } + return themeId != THEME_ID_LXX_BASE; // THEME_ID_LXX_BASE is the only without borders } - public static boolean getIsCustom(int themeId) { - switch (themeId) { - case THEME_ID_LXX_CUSTOM: - case THEME_ID_LXX_CUSTOM_BORDER: - case THEME_ID_HOLO_CUSTOM: - return true; - default: - return false; - } - } // todo (later): material you, system accent, ... public static Colors getThemeColors(final String themeColors, final String themeStyle, final Context context, final SharedPreferences prefs) { diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/latin/settings/AppearanceSettingsFragment.kt b/app/src/main/java/org/dslul/openboard/inputmethod/latin/settings/AppearanceSettingsFragment.kt index cca9a4c71..dfce4f491 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/latin/settings/AppearanceSettingsFragment.kt +++ b/app/src/main/java/org/dslul/openboard/inputmethod/latin/settings/AppearanceSettingsFragment.kt @@ -130,7 +130,7 @@ class AppearanceSettingsFragment : SubScreenFragment(), Preference.OnPreferenceC // doing things on changing, but with the old values is not good, this is at least a little better private fun updateAfterPreferenceChanged() { customThemeVariantNightPref?.apply { - if (KeyboardTheme.getIsCustom(selectedThemeId)) { + if (true) { //KeyboardTheme.getIsCustom(selectedThemeId)) { // show preference to allow choosing a night theme // can't hide a preference, at least not without category or maybe some androidx things // -> just disable it instead (for now...) @@ -153,7 +153,7 @@ class AppearanceSettingsFragment : SubScreenFragment(), Preference.OnPreferenceC summary = if (resId == 0) variant else getString(resId) } userColorsPref.apply { - isEnabled = KeyboardTheme.getIsCustom(selectedThemeId) + isEnabled = true //KeyboardTheme.getIsCustom(selectedThemeId) && (sharedPreferences!!.getString(Settings.PREF_THEME_VARIANT, KeyboardTheme.THEME_LIGHT) == KeyboardTheme.THEME_USER || (sharedPreferences!!.getString(Settings.PREF_THEME_VARIANT_NIGHT, KeyboardTheme.THEME_DARKER) == KeyboardTheme.THEME_USER_DARK && sharedPreferences!!.getBoolean(Settings.PREF_THEME_DAY_NIGHT, false) @@ -204,7 +204,7 @@ class AppearanceSettingsFragment : SubScreenFragment(), Preference.OnPreferenceC } dayNightPref?.apply { isEnabled = !isLegacyFamily - isChecked = !isLegacyFamily && KeyboardTheme.getIsCustom(selectedThemeId) && sharedPreferences!!.getBoolean(Settings.PREF_THEME_DAY_NIGHT, false) + isChecked = !isLegacyFamily && /*KeyboardTheme.getIsCustom(selectedThemeId) &&*/ sharedPreferences!!.getBoolean(Settings.PREF_THEME_DAY_NIGHT, false) } } diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index 3afc9c237..283970a4b 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -235,13 +235,9 @@ - - - - - - - + + + @@ -496,13 +492,9 @@ - - - - - - - + + + diff --git a/app/src/main/res/values/themes-holo.xml b/app/src/main/res/values/themes-holo.xml index 0c7d27c1a..d803334dc 100644 --- a/app/src/main/res/values/themes-holo.xml +++ b/app/src/main/res/values/themes-holo.xml @@ -23,7 +23,7 @@ name="InputView.Holo" parent="InputView" /> - + - - +--> diff --git a/app/src/main/res/xml-sw600dp/key_styles_common.xml b/app/src/main/res/xml-sw600dp/key_styles_common.xml index 06eb56ba9..ab60299e4 100644 --- a/app/src/main/res/xml-sw600dp/key_styles_common.xml +++ b/app/src/main/res/xml-sw600dp/key_styles_common.xml @@ -73,7 +73,7 @@ - + - + - + - + - + - + - + - + - + - + predicator that checks device form-factor. --> - +