better fix for issues with wrapper view

This commit is contained in:
Helium314 2023-09-13 21:42:01 +02:00
parent 81d422fdc6
commit 217749857d
2 changed files with 12 additions and 7 deletions

View file

@ -60,6 +60,8 @@ class KeyboardWrapperView @JvmOverloads constructor(
switchOneHandedModeBtn.colorFilter = colors.keyTextFilter switchOneHandedModeBtn.colorFilter = colors.keyTextFilter
colors.setBackgroundColor(stopOneHandedModeBtn.background, BackgroundType.BACKGROUND) colors.setBackgroundColor(stopOneHandedModeBtn.background, BackgroundType.BACKGROUND)
colors.setBackgroundColor(switchOneHandedModeBtn.background, BackgroundType.BACKGROUND) colors.setBackgroundColor(switchOneHandedModeBtn.background, BackgroundType.BACKGROUND)
setBackgroundColor(Color.WHITE) // otherwise background might be null
colors.setKeyboardBackground(this)
} }
@SuppressLint("RtlHardcoded") @SuppressLint("RtlHardcoded")
@ -93,7 +95,6 @@ class KeyboardWrapperView @JvmOverloads constructor(
override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) { override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
if (!oneHandedModeEnabled) { if (!oneHandedModeEnabled) {
super.onLayout(changed, left, top, right, bottom) super.onLayout(changed, left, top, right, bottom)
Settings.getInstance().current.mColors.setKeyboardBackground(keyboardView) // otherwise issue in clipboard view after switching oneHandedMode
return return
} }
@ -122,7 +123,6 @@ class KeyboardWrapperView @JvmOverloads constructor(
buttonsLeft + (spareWidth + switchOneHandedModeBtn.measuredWidth) / 2, buttonsLeft + (spareWidth + switchOneHandedModeBtn.measuredWidth) / 2,
2 * stopOneHandedModeBtn.measuredHeight + switchOneHandedModeBtn.measuredHeight 2 * stopOneHandedModeBtn.measuredHeight + switchOneHandedModeBtn.measuredHeight
) )
Settings.getInstance().current.mColors.setKeyboardBackground(this)
} }
init { init {
@ -131,8 +131,5 @@ class KeyboardWrapperView @JvmOverloads constructor(
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()
setBackgroundColor(Color.WHITE)
Settings.getInstance().current.mColors.setKeyboardBackground(this)
} }
} }

View file

@ -13,8 +13,12 @@ import androidx.core.graphics.BlendModeCompat
import androidx.core.graphics.drawable.DrawableCompat import androidx.core.graphics.drawable.DrawableCompat
import org.dslul.openboard.inputmethod.keyboard.KeyboardTheme.THEME_STYLE_HOLO import org.dslul.openboard.inputmethod.keyboard.KeyboardTheme.THEME_STYLE_HOLO
import org.dslul.openboard.inputmethod.keyboard.KeyboardTheme.THEME_STYLE_MATERIAL import org.dslul.openboard.inputmethod.keyboard.KeyboardTheme.THEME_STYLE_MATERIAL
import org.dslul.openboard.inputmethod.keyboard.MainKeyboardView
import org.dslul.openboard.inputmethod.keyboard.MoreKeysKeyboardView import org.dslul.openboard.inputmethod.keyboard.MoreKeysKeyboardView
import org.dslul.openboard.inputmethod.keyboard.clipboard.ClipboardHistoryView
import org.dslul.openboard.inputmethod.keyboard.emoji.EmojiPageKeyboardView import org.dslul.openboard.inputmethod.keyboard.emoji.EmojiPageKeyboardView
import org.dslul.openboard.inputmethod.keyboard.emoji.EmojiPalettesView
import org.dslul.openboard.inputmethod.latin.KeyboardWrapperView
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.suggestions.SuggestionStripView import org.dslul.openboard.inputmethod.latin.suggestions.SuggestionStripView
@ -171,10 +175,14 @@ 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
is SuggestionStripView -> setBackgroundColor(view.background, BackgroundType.SUGGESTION) is SuggestionStripView -> setBackgroundColor(view.background, BackgroundType.SUGGESTION)
else -> if (keyboardBackground != null) view.background = keyboardBackground is EmojiPageKeyboardView, // to make EmojiPalettesView background visible, which does not scroll
is MainKeyboardView -> view.setBackgroundColor(Color.TRANSPARENT) // otherwise causes issues with wrapper view when using one-handed mode
is KeyboardWrapperView, is EmojiPalettesView, is ClipboardHistoryView -> {
if (keyboardBackground != null) view.background = keyboardBackground
else view.background.colorFilter = backgroundFilter else view.background.colorFilter = backgroundFilter
}
else -> view.background.colorFilter = backgroundFilter
} }
} }