From 9650c7a85cdc9922afcb09c9f0a3e03b8106cd0f Mon Sep 17 00:00:00 2001 From: Helium314 Date: Wed, 6 Sep 2023 13:23:26 +0200 Subject: [PATCH] fix issies with holo colors --- .../inputmethod/keyboard/KeyboardSwitcher.java | 12 ++++-------- .../keyboard/emoji/EmojiPalettesView.java | 2 +- .../inputmethod/latin/KeyboardWrapperView.kt | 4 ++-- .../openboard/inputmethod/latin/common/Colors.kt | 13 +++++++++---- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/KeyboardSwitcher.java b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/KeyboardSwitcher.java index e6939ac92..ee2730816 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/KeyboardSwitcher.java +++ b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/KeyboardSwitcher.java @@ -547,10 +547,8 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { mKeyboardView.closing(); } - updateKeyboardThemeAndContextThemeWrapper( - displayContext, KeyboardTheme.getKeyboardTheme(displayContext /* context */)); - mCurrentInputView = (InputView)LayoutInflater.from(mThemeContext).inflate( - R.layout.input_view, null); + updateKeyboardThemeAndContextThemeWrapper(displayContext, KeyboardTheme.getKeyboardTheme(displayContext)); + mCurrentInputView = (InputView)LayoutInflater.from(mThemeContext).inflate(R.layout.input_view, null); mMainKeyboardFrame = mCurrentInputView.findViewById(R.id.main_keyboard_frame); mEmojiPalettesView = mCurrentInputView.findViewById(R.id.emoji_palettes_view); mClipboardHistoryView = mCurrentInputView.findViewById(R.id.clipboard_history_view); @@ -560,11 +558,9 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { mKeyboardView = mCurrentInputView.findViewById(R.id.keyboard_view); mKeyboardView.setHardwareAcceleratedDrawingEnabled(isHardwareAcceleratedDrawingEnabled); mKeyboardView.setKeyboardActionListener(mLatinIME); - mEmojiPalettesView.setHardwareAcceleratedDrawingEnabled( - isHardwareAcceleratedDrawingEnabled); + mEmojiPalettesView.setHardwareAcceleratedDrawingEnabled(isHardwareAcceleratedDrawingEnabled); mEmojiPalettesView.setKeyboardActionListener(mLatinIME); - mClipboardHistoryView.setHardwareAcceleratedDrawingEnabled( - isHardwareAcceleratedDrawingEnabled); + mClipboardHistoryView.setHardwareAcceleratedDrawingEnabled(isHardwareAcceleratedDrawingEnabled); mClipboardHistoryView.setKeyboardActionListener(mLatinIME); return mCurrentInputView; diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/emoji/EmojiPalettesView.java b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/emoji/EmojiPalettesView.java index 796b470ff..f258b1c48 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/emoji/EmojiPalettesView.java +++ b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/emoji/EmojiPalettesView.java @@ -273,7 +273,7 @@ public final class EmojiPalettesView extends LinearLayout colors.setBackgroundColor(mAlphabetKeyLeft.getBackground(), BackgroundType.FUNCTIONAL); colors.setBackgroundColor(mDeleteKey.getBackground(), BackgroundType.FUNCTIONAL); colors.setBackgroundColor(mSpacebar.getBackground(), BackgroundType.SPACE); - colors.setBackgroundColor(getBackground(), BackgroundType.BACKGROUND); // only set color, not drawable (issues in keyboardWrapper otherwise) + colors.setKeyboardBackground(this); // todo: color on top appears a little darker than on normal keyboard, what is wrong? mEmojiCategoryPageIndicatorView.setColors(colors.getAccent(), colors.getAdjustedBackground()); } diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/latin/KeyboardWrapperView.kt b/app/src/main/java/org/dslul/openboard/inputmethod/latin/KeyboardWrapperView.kt index 166ad86f9..9135c9d88 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/latin/KeyboardWrapperView.kt +++ b/app/src/main/java/org/dslul/openboard/inputmethod/latin/KeyboardWrapperView.kt @@ -126,8 +126,8 @@ class KeyboardWrapperView @JvmOverloads constructor( } init { - val keyboardAttr = context.obtainStyledAttributes(attrs, - R.styleable.Keyboard, defStyle, R.style.Keyboard) + @SuppressLint("CustomViewStyleable") + val keyboardAttr = context.obtainStyledAttributes(attrs, R.styleable.Keyboard, defStyle, R.style.Keyboard) iconStopOneHandedModeId = keyboardAttr.getResourceId(R.styleable.Keyboard_iconStopOneHandedMode, 0) iconSwitchOneHandedModeId = keyboardAttr.getResourceId(R.styleable.Keyboard_iconSwitchOneHandedMode, 0) keyboardAttr.recycle() diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/latin/common/Colors.kt b/app/src/main/java/org/dslul/openboard/inputmethod/latin/common/Colors.kt index 689d3ce23..fcef79861 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/latin/common/Colors.kt +++ b/app/src/main/java/org/dslul/openboard/inputmethod/latin/common/Colors.kt @@ -13,6 +13,8 @@ import androidx.core.graphics.BlendModeCompat import androidx.core.graphics.drawable.DrawableCompat import org.dslul.openboard.inputmethod.keyboard.KeyboardTheme import org.dslul.openboard.inputmethod.keyboard.MoreKeysKeyboardView +import org.dslul.openboard.inputmethod.keyboard.emoji.EmojiPageKeyboardView +import org.dslul.openboard.inputmethod.keyboard.emoji.EmojiPalettesView import org.dslul.openboard.inputmethod.latin.R import org.dslul.openboard.inputmethod.latin.suggestions.MoreSuggestionsView import org.dslul.openboard.inputmethod.latin.utils.* @@ -90,11 +92,13 @@ class Colors ( functionalKeyBackgroundFilter = colorFilter(functionalKey) spaceBarFilter = colorFilter(spaceBar) backgroundStateList = stateList(brightenOrDarken(background, true), background) - keyStateList = stateList(brightenOrDarken(keyBackground, true), keyBackground) + keyStateList = if (themeStyle == KeyboardTheme.THEME_STYLE_HOLO) stateList(keyBackground, keyBackground) + else stateList(brightenOrDarken(keyBackground, true), keyBackground) functionalKeyStateList = stateList(brightenOrDarken(functionalKey, true), functionalKey) actionKeyStateList = if (themeStyle == KeyboardTheme.THEME_STYLE_HOLO) functionalKeyStateList else stateList(brightenOrDarken(accent, true), accent) - spaceBarStateList = stateList(brightenOrDarken(spaceBar, true), spaceBar) + spaceBarStateList = if (themeStyle == KeyboardTheme.THEME_STYLE_HOLO) stateList(spaceBar, spaceBar) + else stateList(brightenOrDarken(spaceBar, true), spaceBar) } else { // need to set color to background if key borders are disabled, or there will be ugly keys keyBackgroundFilter = backgroundFilter @@ -139,8 +143,8 @@ class Colors ( attr.getDrawable(R.styleable.KeyboardView_keyBackground)?.mutate() BackgroundType.FUNCTIONAL -> attr.getDrawable(R.styleable.KeyboardView_functionalKeyBackground)?.mutate() BackgroundType.SPACE -> attr.getDrawable(R.styleable.KeyboardView_spacebarBackground)?.mutate() - BackgroundType.ACTION -> if (themeStyle == KeyboardTheme.THEME_STYLE_HOLO) - attr.getDrawable(R.styleable.KeyboardView_functionalKeyBackground)?.mutate() + BackgroundType.ACTION -> if (themeStyle == KeyboardTheme.THEME_STYLE_HOLO && hasKeyBorders) // no borders has a very small pressed drawable otherwise + attr.getDrawable(R.styleable.KeyboardView_functionalKeyBackground)?.mutate() else attr.getDrawable(R.styleable.KeyboardView_keyBackground)?.mutate() } ?: attr.getDrawable(R.styleable.KeyboardView_keyBackground)?.mutate()!! // keyBackground always exists @@ -152,6 +156,7 @@ class Colors ( when (view) { is MoreSuggestionsView -> view.background.colorFilter = backgroundFilter is MoreKeysKeyboardView -> view.background.colorFilter = adjustedBackgroundFilter + is EmojiPageKeyboardView -> view.setBackgroundColor(Color.TRANSPARENT) // to make EmojiPalettesView background visible, which does not scroll else -> if (keyboardBackground != null) view.background = keyboardBackground else view.background.colorFilter = backgroundFilter }