mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-08 07:37:41 +00:00
fix suggestion stip color for material no border theme
This commit is contained in:
parent
9223c4c1f2
commit
ed7e6cff04
2 changed files with 10 additions and 7 deletions
|
@ -14,9 +14,9 @@ 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.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.suggestions.SuggestionStripView
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.*
|
import org.dslul.openboard.inputmethod.latin.utils.*
|
||||||
|
|
||||||
class Colors (
|
class Colors (
|
||||||
|
@ -128,6 +128,9 @@ class Colors (
|
||||||
BackgroundType.ACTION -> actionKeyStateList
|
BackgroundType.ACTION -> actionKeyStateList
|
||||||
BackgroundType.SPACE -> spaceBarStateList
|
BackgroundType.SPACE -> spaceBarStateList
|
||||||
BackgroundType.ADJUSTED_BACKGROUND -> adjustedBackgroundStateList
|
BackgroundType.ADJUSTED_BACKGROUND -> adjustedBackgroundStateList
|
||||||
|
BackgroundType.SUGGESTION -> if (!hasKeyBorders && themeStyle == KeyboardTheme.THEME_STYLE_MATERIAL)
|
||||||
|
adjustedBackgroundStateList
|
||||||
|
else backgroundStateList
|
||||||
}
|
}
|
||||||
DrawableCompat.setTintMode(background, PorterDuff.Mode.MULTIPLY)
|
DrawableCompat.setTintMode(background, PorterDuff.Mode.MULTIPLY)
|
||||||
DrawableCompat.setTintList(background, colorStateList)
|
DrawableCompat.setTintList(background, colorStateList)
|
||||||
|
@ -139,7 +142,7 @@ class Colors (
|
||||||
|
|
||||||
fun getDrawable(type: BackgroundType, attr: TypedArray): Drawable {
|
fun getDrawable(type: BackgroundType, attr: TypedArray): Drawable {
|
||||||
val drawable = when (type) {
|
val drawable = when (type) {
|
||||||
BackgroundType.KEY, BackgroundType.ADJUSTED_BACKGROUND, BackgroundType.BACKGROUND ->
|
BackgroundType.KEY, BackgroundType.ADJUSTED_BACKGROUND, BackgroundType.BACKGROUND, BackgroundType.SUGGESTION ->
|
||||||
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()
|
||||||
|
@ -157,6 +160,7 @@ class Colors (
|
||||||
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 EmojiPageKeyboardView -> view.setBackgroundColor(Color.TRANSPARENT) // to make EmojiPalettesView background visible, which does not scroll
|
||||||
|
is SuggestionStripView -> setBackgroundColor(view.background, BackgroundType.SUGGESTION)
|
||||||
else -> if (keyboardBackground != null) view.background = keyboardBackground
|
else -> if (keyboardBackground != null) view.background = keyboardBackground
|
||||||
else view.background.colorFilter = backgroundFilter
|
else view.background.colorFilter = backgroundFilter
|
||||||
}
|
}
|
||||||
|
@ -165,5 +169,5 @@ class Colors (
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class BackgroundType {
|
enum class BackgroundType {
|
||||||
BACKGROUND, KEY, FUNCTIONAL, ACTION, SPACE, ADJUSTED_BACKGROUND
|
BACKGROUND, KEY, FUNCTIONAL, ACTION, SPACE, ADJUSTED_BACKGROUND, SUGGESTION
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||||
word.setContentDescription(getResources().getString(R.string.spoken_empty_suggestion));
|
word.setContentDescription(getResources().getString(R.string.spoken_empty_suggestion));
|
||||||
word.setOnClickListener(this);
|
word.setOnClickListener(this);
|
||||||
word.setOnLongClickListener(this);
|
word.setOnLongClickListener(this);
|
||||||
colors.setBackgroundColor(word.getBackground(), BackgroundType.BACKGROUND);
|
colors.setBackgroundColor(word.getBackground(), BackgroundType.SUGGESTION);
|
||||||
mWordViews.add(word);
|
mWordViews.add(word);
|
||||||
final View divider = inflater.inflate(R.layout.suggestion_divider, null);
|
final View divider = inflater.inflate(R.layout.suggestion_divider, null);
|
||||||
mDividerViews.add(divider);
|
mDividerViews.add(divider);
|
||||||
|
@ -186,7 +186,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||||
|
|
||||||
mOtherKey.setImageDrawable(iconIncognito);
|
mOtherKey.setImageDrawable(iconIncognito);
|
||||||
|
|
||||||
colors.setBackgroundColor(getBackground(), BackgroundType.BACKGROUND);
|
colors.setKeyboardBackground(this);
|
||||||
mClipboardKey.setColorFilter(colors.getKeyText());
|
mClipboardKey.setColorFilter(colors.getKeyText());
|
||||||
mVoiceKey.setColorFilter(colors.getKeyText());
|
mVoiceKey.setColorFilter(colors.getKeyText());
|
||||||
mOtherKey.setColorFilter(colors.getKeyText());
|
mOtherKey.setColorFilter(colors.getKeyText());
|
||||||
|
@ -386,10 +386,9 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||||
mMoreSuggestionsView.setKeyboard(builder.build());
|
mMoreSuggestionsView.setKeyboard(builder.build());
|
||||||
container.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
container.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||||
|
|
||||||
final MoreKeysPanel moreKeysPanel = mMoreSuggestionsView;
|
|
||||||
final int pointX = stripWidth / 2;
|
final int pointX = stripWidth / 2;
|
||||||
final int pointY = -layoutHelper.mMoreSuggestionsBottomGap;
|
final int pointY = -layoutHelper.mMoreSuggestionsBottomGap;
|
||||||
moreKeysPanel.showMoreKeysPanel(this, mMoreSuggestionsController, pointX, pointY,
|
mMoreSuggestionsView.showMoreKeysPanel(this, mMoreSuggestionsController, pointX, pointY,
|
||||||
mMoreSuggestionsListener);
|
mMoreSuggestionsListener);
|
||||||
mOriginX = mLastX;
|
mOriginX = mLastX;
|
||||||
mOriginY = mLastY;
|
mOriginY = mLastY;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue