fix issies with holo colors

This commit is contained in:
Helium314 2023-09-06 13:23:26 +02:00
parent efffc02fed
commit 9650c7a85c
4 changed files with 16 additions and 15 deletions

View file

@ -547,10 +547,8 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
mKeyboardView.closing(); mKeyboardView.closing();
} }
updateKeyboardThemeAndContextThemeWrapper( updateKeyboardThemeAndContextThemeWrapper(displayContext, KeyboardTheme.getKeyboardTheme(displayContext));
displayContext, KeyboardTheme.getKeyboardTheme(displayContext /* context */)); mCurrentInputView = (InputView)LayoutInflater.from(mThemeContext).inflate(R.layout.input_view, null);
mCurrentInputView = (InputView)LayoutInflater.from(mThemeContext).inflate(
R.layout.input_view, null);
mMainKeyboardFrame = mCurrentInputView.findViewById(R.id.main_keyboard_frame); mMainKeyboardFrame = mCurrentInputView.findViewById(R.id.main_keyboard_frame);
mEmojiPalettesView = mCurrentInputView.findViewById(R.id.emoji_palettes_view); mEmojiPalettesView = mCurrentInputView.findViewById(R.id.emoji_palettes_view);
mClipboardHistoryView = mCurrentInputView.findViewById(R.id.clipboard_history_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 = mCurrentInputView.findViewById(R.id.keyboard_view);
mKeyboardView.setHardwareAcceleratedDrawingEnabled(isHardwareAcceleratedDrawingEnabled); mKeyboardView.setHardwareAcceleratedDrawingEnabled(isHardwareAcceleratedDrawingEnabled);
mKeyboardView.setKeyboardActionListener(mLatinIME); mKeyboardView.setKeyboardActionListener(mLatinIME);
mEmojiPalettesView.setHardwareAcceleratedDrawingEnabled( mEmojiPalettesView.setHardwareAcceleratedDrawingEnabled(isHardwareAcceleratedDrawingEnabled);
isHardwareAcceleratedDrawingEnabled);
mEmojiPalettesView.setKeyboardActionListener(mLatinIME); mEmojiPalettesView.setKeyboardActionListener(mLatinIME);
mClipboardHistoryView.setHardwareAcceleratedDrawingEnabled( mClipboardHistoryView.setHardwareAcceleratedDrawingEnabled(isHardwareAcceleratedDrawingEnabled);
isHardwareAcceleratedDrawingEnabled);
mClipboardHistoryView.setKeyboardActionListener(mLatinIME); mClipboardHistoryView.setKeyboardActionListener(mLatinIME);
return mCurrentInputView; return mCurrentInputView;

View file

@ -273,7 +273,7 @@ public final class EmojiPalettesView extends LinearLayout
colors.setBackgroundColor(mAlphabetKeyLeft.getBackground(), BackgroundType.FUNCTIONAL); colors.setBackgroundColor(mAlphabetKeyLeft.getBackground(), BackgroundType.FUNCTIONAL);
colors.setBackgroundColor(mDeleteKey.getBackground(), BackgroundType.FUNCTIONAL); colors.setBackgroundColor(mDeleteKey.getBackground(), BackgroundType.FUNCTIONAL);
colors.setBackgroundColor(mSpacebar.getBackground(), BackgroundType.SPACE); 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()); mEmojiCategoryPageIndicatorView.setColors(colors.getAccent(), colors.getAdjustedBackground());
} }

View file

@ -126,8 +126,8 @@ class KeyboardWrapperView @JvmOverloads constructor(
} }
init { init {
val keyboardAttr = context.obtainStyledAttributes(attrs, @SuppressLint("CustomViewStyleable")
R.styleable.Keyboard, defStyle, R.style.Keyboard) val keyboardAttr = context.obtainStyledAttributes(attrs, R.styleable.Keyboard, defStyle, R.style.Keyboard)
iconStopOneHandedModeId = keyboardAttr.getResourceId(R.styleable.Keyboard_iconStopOneHandedMode, 0) iconStopOneHandedModeId = keyboardAttr.getResourceId(R.styleable.Keyboard_iconStopOneHandedMode, 0)
iconSwitchOneHandedModeId = keyboardAttr.getResourceId(R.styleable.Keyboard_iconSwitchOneHandedMode, 0) iconSwitchOneHandedModeId = keyboardAttr.getResourceId(R.styleable.Keyboard_iconSwitchOneHandedMode, 0)
keyboardAttr.recycle() keyboardAttr.recycle()

View file

@ -13,6 +13,8 @@ import androidx.core.graphics.BlendModeCompat
import androidx.core.graphics.drawable.DrawableCompat import androidx.core.graphics.drawable.DrawableCompat
import org.dslul.openboard.inputmethod.keyboard.KeyboardTheme import org.dslul.openboard.inputmethod.keyboard.KeyboardTheme
import org.dslul.openboard.inputmethod.keyboard.MoreKeysKeyboardView 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.R
import org.dslul.openboard.inputmethod.latin.suggestions.MoreSuggestionsView import org.dslul.openboard.inputmethod.latin.suggestions.MoreSuggestionsView
import org.dslul.openboard.inputmethod.latin.utils.* import org.dslul.openboard.inputmethod.latin.utils.*
@ -90,11 +92,13 @@ class Colors (
functionalKeyBackgroundFilter = colorFilter(functionalKey) functionalKeyBackgroundFilter = colorFilter(functionalKey)
spaceBarFilter = colorFilter(spaceBar) spaceBarFilter = colorFilter(spaceBar)
backgroundStateList = stateList(brightenOrDarken(background, true), background) 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) functionalKeyStateList = stateList(brightenOrDarken(functionalKey, true), functionalKey)
actionKeyStateList = if (themeStyle == KeyboardTheme.THEME_STYLE_HOLO) functionalKeyStateList actionKeyStateList = if (themeStyle == KeyboardTheme.THEME_STYLE_HOLO) functionalKeyStateList
else stateList(brightenOrDarken(accent, true), accent) 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 { } else {
// need to set color to background if key borders are disabled, or there will be ugly keys // need to set color to background if key borders are disabled, or there will be ugly keys
keyBackgroundFilter = backgroundFilter keyBackgroundFilter = backgroundFilter
@ -139,8 +143,8 @@ class Colors (
attr.getDrawable(R.styleable.KeyboardView_keyBackground)?.mutate() attr.getDrawable(R.styleable.KeyboardView_keyBackground)?.mutate()
BackgroundType.FUNCTIONAL -> attr.getDrawable(R.styleable.KeyboardView_functionalKeyBackground)?.mutate() BackgroundType.FUNCTIONAL -> attr.getDrawable(R.styleable.KeyboardView_functionalKeyBackground)?.mutate()
BackgroundType.SPACE -> attr.getDrawable(R.styleable.KeyboardView_spacebarBackground)?.mutate() BackgroundType.SPACE -> attr.getDrawable(R.styleable.KeyboardView_spacebarBackground)?.mutate()
BackgroundType.ACTION -> if (themeStyle == KeyboardTheme.THEME_STYLE_HOLO) 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() attr.getDrawable(R.styleable.KeyboardView_functionalKeyBackground)?.mutate()
else attr.getDrawable(R.styleable.KeyboardView_keyBackground)?.mutate() else attr.getDrawable(R.styleable.KeyboardView_keyBackground)?.mutate()
} ?: attr.getDrawable(R.styleable.KeyboardView_keyBackground)?.mutate()!! // keyBackground always exists } ?: attr.getDrawable(R.styleable.KeyboardView_keyBackground)?.mutate()!! // keyBackground always exists
@ -152,6 +156,7 @@ class Colors (
when (view) { when (view) {
is MoreSuggestionsView -> view.background.colorFilter = backgroundFilter is MoreSuggestionsView -> view.background.colorFilter = backgroundFilter
is MoreKeysKeyboardView -> view.background.colorFilter = adjustedBackgroundFilter 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 -> if (keyboardBackground != null) view.background = keyboardBackground
else view.background.colorFilter = backgroundFilter else view.background.colorFilter = backgroundFilter
} }