cleanup keyboardThemes, remove holo blue (but keep the file for now)

This commit is contained in:
Helium314 2023-09-01 23:01:47 +02:00
parent 529839b6c8
commit ba70be8b65
12 changed files with 71 additions and 112 deletions

View file

@ -57,37 +57,18 @@ public final class KeyboardTheme implements Comparable<KeyboardTheme> {
// 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<KeyboardTheme> {
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<KeyboardTheme> {
}
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) {

View file

@ -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)
}
}

View file

@ -235,13 +235,9 @@
<attr name="themeId" format="enum">
<!-- This should be aligned with
{@link org.dslul.openboard.inputmethod.keyboard.KeyboardTheme#THEME_ID_HOLO_BLUE} etc. -->
<enum name="HoloBlue" value="0" />
<enum name="HoloWhite" value="1" />
<enum name="HoloCustom" value="2" />
<enum name="LXXBase" value="3" />
<enum name="LXXBaseBorder" value="4" />
<enum name="LXXCustom" value="5" />
<enum name="LXXCustomBorder" value="6" />
<enum name="HoloBase" value="0" />
<enum name="LXXBase" value="1" />
<enum name="LXXBaseBorder" value="2" />
</attr>
<!-- Touch position correction -->
<attr name="touchPositionCorrectionData" format="reference" />
@ -496,13 +492,9 @@
<!-- This should be aligned with Keyboard.themeId and
{@link org.dslul.openboard.inputmethod.keyboard.KeyboardTheme#THEME_ID_HOLO_BLUE} etc. -->
<attr name="keyboardTheme" format="enum|string">
<enum name="HoloBlue" value="0" />
<enum name="HoloWhite" value="1" />
<enum name="HoloCustom" value="2" />
<enum name="LXXBase" value="3" />
<enum name="LXXBaseBorder" value="4" />
<enum name="LXXCustom" value="5" />
<enum name="LXXCustomBorder" value="6" />
<enum name="HoloBase" value="0" />
<enum name="LXXBase" value="1" />
<enum name="LXXBaseBorder" value="2" />
</attr>
<!-- This should be aligned with
{@link org.dslul.openboard.inputmethod.keyboard.KeyboardId#MODE_TEXT} etc. -->

View file

@ -23,7 +23,7 @@
name="InputView.Holo"
parent="InputView"
/>
<!-- Holo KeyboardView theme (HoloBlue and HoloWhite) -->
<!-- Holo KeyboardView theme (HoloBase) -->
<style
name="KeyboardView.Holo"
parent="KeyboardView"

View file

@ -19,29 +19,29 @@
-->
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="KeyboardTheme.HoloWhite" parent="KeyboardIcons.Holo">
<style name="KeyboardTheme.HoloBase" parent="KeyboardIcons.Holo">
<item name="inputViewStyle">@style/InputView.Holo</item>
<item name="keyboardStyle">@style/Keyboard.HoloWhite</item>
<item name="keyboardViewStyle">@style/KeyboardView.HoloWhite</item>
<item name="mainKeyboardViewStyle">@style/MainKeyboardView.HoloWhite</item>
<item name="emojiPalettesViewStyle">@style/EmojiPalettesView.HoloWhite</item>
<item name="clipboardHistoryViewStyle">@style/ClipboardHistoryView.HoloWhite</item>
<item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard.HoloWhite</item>
<!-- Note: HoloWhite theme uses the same style for both general more keys and action more keys. -->
<item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.HoloWhite</item>
<item name="moreKeysKeyboardViewForActionStyle">@style/MoreKeysKeyboardView.HoloWhite</item>
<item name="suggestionStripViewStyle">@style/SuggestionStripView.HoloWhite</item>
<item name="suggestionWordStyle">@style/SuggestionWord.HoloWhite</item>
<item name="keyboardStyle">@style/Keyboard.HoloBase</item>
<item name="keyboardViewStyle">@style/KeyboardView.HoloBase</item>
<item name="mainKeyboardViewStyle">@style/MainKeyboardView.HoloBase</item>
<item name="emojiPalettesViewStyle">@style/EmojiPalettesView.HoloBase</item>
<item name="clipboardHistoryViewStyle">@style/ClipboardHistoryView.HoloBase</item>
<item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard.HoloBase</item>
<!-- Note: HoloBase theme uses the same style for both general more keys and action more keys. -->
<item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.HoloBase</item>
<item name="moreKeysKeyboardViewForActionStyle">@style/MoreKeysKeyboardView.HoloBase</item>
<item name="suggestionStripViewStyle">@style/SuggestionStripView.HoloBase</item>
<item name="suggestionWordStyle">@style/SuggestionWord.HoloBase</item>
</style>
<style
name="Keyboard.HoloWhite"
name="Keyboard.HoloBase"
parent="Keyboard"
>
<!-- This should be aligned with KeyboardTheme.THEME_ID_* -->
<item name="themeId">HoloWhite</item>
<item name="themeId">HoloBase</item>
</style>
<style
name="KeyboardView.HoloWhite"
name="KeyboardView.HoloBase"
parent="KeyboardView.Holo"
>
<item name="android:background">@android:color/white</item>
@ -58,8 +58,8 @@
<item name="keyPreviewTextColor">@color/key_text_color_blue</item>
</style>
<style
name="MainKeyboardView.HoloWhite"
parent="KeyboardView.HoloWhite"
name="MainKeyboardView.HoloBase"
parent="KeyboardView.HoloBase"
>
<item name="keyPreviewBackground">@drawable/keyboard_key_feedback_holo_white</item>
<item name="keyPreviewHeight">@dimen/config_key_preview_height_holo</item>
@ -79,8 +79,8 @@
delete button, need themed {@link org.dslul.openboard.inputmethod.keyboard.KeyboardView}
attributes. -->
<style
name="EmojiPalettesView.HoloWhite"
parent="MainKeyboardView.HoloWhite"
name="EmojiPalettesView.HoloBase"
parent="MainKeyboardView.HoloBase"
>
<item name="categoryIndicatorEnabled">true</item>
<item name="categoryIndicatorDrawable">@drawable/emoji_category_tab_selected_holo_white</item>
@ -100,13 +100,15 @@
<item name="iconEmojiCategory10Tab">@drawable/ic_emoji_emoticons_holo_dark</item>
</style>
<style
name="ClipboardHistoryView.HoloWhite"
parent="ClipboardHistoryView.HoloBlue"
name="ClipboardHistoryView.HoloBase"
parent="MainKeyboardView.HoloBase"
>
<item name="iconPinnedClip">@drawable/ic_clipboard_pin_holo_dark</item>
<item name="dividerBackground">@color/emoji_tab_page_indicator_background_holo</item>
</style>
<style
name="MoreKeysKeyboard.HoloWhite"
parent="Keyboard.HoloWhite"
name="MoreKeysKeyboard.HoloBase"
parent="Keyboard.HoloBase"
>
<item name="keyboardTopPadding">0%p</item>
<item name="keyboardBottomPadding">0%p</item>
@ -115,8 +117,8 @@
<item name="touchPositionCorrectionData">@null</item>
</style>
<style
name="MoreKeysKeyboardView.HoloWhite"
parent="KeyboardView.HoloWhite"
name="MoreKeysKeyboardView.HoloBase"
parent="KeyboardView.HoloBase"
>
<item name="android:background">@drawable/keyboard_popup_panel_background_holo_white</item>
<item name="keyBackground">@drawable/btn_keyboard_key_popup_holo_white</item>
@ -125,8 +127,8 @@
<item name="verticalCorrection">@dimen/config_more_keys_keyboard_vertical_correction_holo</item>
</style>
<style
name="SuggestionStripView.HoloWhite"
parent="KeyboardView.HoloWhite"
name="SuggestionStripView.HoloBase"
parent="KeyboardView.HoloBase"
>
<item name="suggestionsCountInStrip">@integer/config_suggestions_count_in_strip</item>
<item name="centerSuggestionPercentile">@fraction/config_center_suggestion_percentile</item>
@ -142,7 +144,7 @@
<item name="alphaObsoleted">70%</item>
</style>
<style
name="SuggestionWord.HoloWhite"
name="SuggestionWord.HoloBase"
parent="SuggestionWord"
>
<item name="android:background">@drawable/btn_suggestion_holo_white</item>

View file

@ -19,6 +19,7 @@
-->
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!--
<style name="KeyboardTheme.HoloBlue" parent="KeyboardIcons.Holo">
<item name="inputViewStyle">@style/InputView.Holo</item>
<item name="keyboardStyle">@style/Keyboard.HoloBlue</item>
@ -27,8 +28,8 @@
<item name="emojiPalettesViewStyle">@style/EmojiPalettesView.HoloBlue</item>
<item name="clipboardHistoryViewStyle">@style/ClipboardHistoryView.HoloBlue</item>
<item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard.HoloBlue</item>
<!-- Note: HoloBlue theme uses the same style for both general more keys and action more keys. -->
<item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.HoloBlue</item>
<!- - Note: HoloBlue theme uses the same style for both general more keys and action more keys. -->
<!-- <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.HoloBlue</item>
<item name="moreKeysKeyboardViewForActionStyle">@style/MoreKeysKeyboardView.HoloBlue</item>
<item name="suggestionStripViewStyle">@style/SuggestionStripView.HoloBlue</item>
<item name="suggestionWordStyle">@style/SuggestionWord.HoloBlue</item>
@ -37,8 +38,8 @@
name="Keyboard.HoloBlue"
parent="Keyboard"
>
<!-- This should be aligned with KeyboardTheme.THEME_ID_* -->
<item name="themeId">HoloBlue</item>
<!- - This should be aligned with KeyboardTheme.THEME_ID_* -->
<!-- <item name="themeId">HoloBlue</item>
</style>
<style
name="KeyboardView.HoloBlue"
@ -74,11 +75,11 @@
<item name="languageOnSpacebarTextShadowRadius">1.0</item>
<item name="languageOnSpacebarTextShadowColor">@color/spacebar_text_shadow_color_holo</item>
</style>
<!-- Though {@link org.dslul.openboard.inputmethod.keyboard.emoji.EmojiPalettesView} doesn't extend
<!- - Though {@link org.dslul.openboard.inputmethod.keyboard.emoji.EmojiPalettesView} doesn't extend
{@link org.dslul.openboard.inputmethod.keyboard.KeyboardView}, some views inside it, for instance
delete button, need themed {@link org.dslul.openboard.inputmethod.keyboard.KeyboardView}
attributes. -->
<style
<!-- <style
name="EmojiPalettesView.HoloBlue"
parent="MainKeyboardView.HoloBlue"
>
@ -150,4 +151,5 @@
<item name="android:background">@drawable/btn_suggestion_holo_blue</item>
<item name="android:textColor">@color/highlight_color_holo_blue</item>
</style>
-->
</resources>

View file

@ -73,7 +73,7 @@
</switch>
<!-- numpadKeyStyle -->
<switch>
<case latin:keyboardTheme="HoloBlue|HoloWhite|LXXBaseBorder|LXXBase">
<case latin:keyboardTheme="HoloBase|LXXBaseBorder|LXXBase">
<key-style
latin:styleName="numpadKeyStyle"
latin:keySpec="!icon/numpad_key|!code/key_numpad"
@ -91,7 +91,7 @@
</switch>
<!-- alphaNumpadKeyStyle -->
<switch>
<case latin:keyboardTheme="HoloBlue|HoloWhite|LXXBaseBorder|LXXBase">
<case latin:keyboardTheme="HoloBase|LXXBaseBorder|LXXBase">
<key-style
latin:styleName="alphaNumpadKeyStyle"
latin:keySpec="!text/keylabel_to_alpha|!code/key_alphaNumpad"
@ -109,7 +109,7 @@
</switch>
<!-- symbolNumpadKeyStyle -->
<switch>
<case latin:keyboardTheme="HoloBlue|HoloWhite|LXXBaseBorder|LXXBase">
<case latin:keyboardTheme="HoloBase|LXXBaseBorder|LXXBase">
<key-style
latin:styleName="symbolNumpadKeyStyle"
latin:keySpec="!text/keylabel_to_symbol|!code/key_symbolNumpad"

View file

@ -81,7 +81,7 @@
</switch>
<!-- Enter key style -->
<switch>
<case latin:keyboardTheme="HoloBlue|HoloWhite|LXXBaseBorder">
<case latin:keyboardTheme="HoloBase|LXXBaseBorder">
<key-style
latin:styleName="defaultEnterKeyStyle"
latin:keySpec="!icon/enter_key|!code/key_enter"

View file

@ -78,7 +78,7 @@
latin:backgroundType="functional" />
<!-- emojiKeyStyle must be defined before including @xml/key_syles_enter. -->
<switch>
<case latin:keyboardTheme="HoloBlue|HoloWhite|LXXBaseBorder">
<case latin:keyboardTheme="HoloBase|LXXBaseBorder">
<key-style
latin:styleName="emojiKeyStyle"
latin:keySpec="!icon/emoji_normal_key|!code/key_emoji"
@ -97,7 +97,7 @@
</switch>
<!-- numpadKeyStyle -->
<switch>
<case latin:keyboardTheme="HoloBlue|HoloWhite|LXXBaseBorder|LXXBase">
<case latin:keyboardTheme="HoloBase|LXXBaseBorder|LXXBase">
<key-style
latin:styleName="numpadKeyStyle"
latin:keySpec="!icon/numpad_key|!code/key_numpad"
@ -115,7 +115,7 @@
</switch>
<!-- alphaNumpadKeyStyle -->
<switch>
<case latin:keyboardTheme="HoloBlue|HoloWhite|LXXBaseBorder|LXXBase">
<case latin:keyboardTheme="HoloBase|LXXBaseBorder|LXXBase">
<key-style
latin:styleName="alphaNumpadKeyStyle"
latin:keySpec="!text/keylabel_to_alpha|!code/key_alphaNumpad"
@ -133,7 +133,7 @@
</switch>
<!-- symbolNumpadKeyStyle -->
<switch>
<case latin:keyboardTheme="HoloBlue|HoloWhite|LXXBaseBorder|LXXBase">
<case latin:keyboardTheme="HoloBase|LXXBaseBorder|LXXBase">
<key-style
latin:styleName="symbolNumpadKeyStyle"
latin:keySpec="!text/keylabel_to_symbol|!code/key_symbolNumpad"

View file

@ -213,7 +213,7 @@
</switch>
<!-- Enter key style -->
<switch>
<case latin:keyboardTheme="HoloBlue|HoloWhite|LXXBaseBorder">
<case latin:keyboardTheme="HoloBase|LXXBaseBorder">
<key-style
latin:styleName="defaultEnterKeyStyle"
latin:keySpec="!icon/enter_key|!code/key_enter"

View file

@ -22,7 +22,7 @@
xmlns:latin="http://schemas.android.com/apk/res-auto"
>
<switch>
<case latin:keyboardTheme="HoloBlue|HoloWhite">
<case latin:keyboardTheme="HoloBase">
<key-style
latin:styleName="navigateNextMoreKeysStyle"
latin:keyLabelFlags="hasPopupHint|preserveCase"

View file

@ -109,7 +109,7 @@
<!-- TODO: Consolidate these space key styles with numSpaceKeyStyle above by introducing <case>
predicator that checks device form-factor. -->
<switch>
<case latin:keyboardTheme="HoloBlue|HoloWhite">
<case latin:keyboardTheme="HoloBase">
<key-style
latin:styleName="tabletNumSpaceKeyStyle"
latin:keySpec="!icon/space_key|!code/key_space"