adjust colors, so the three main view have a common background

also slightly changes appearance of top strip, now all views use the same background
This commit is contained in:
Helium314 2024-01-26 09:01:39 +01:00
parent ac71f8724f
commit 171c1f451b
8 changed files with 60 additions and 49 deletions

View file

@ -122,9 +122,8 @@ class ClipboardHistoryView @JvmOverloads constructor(
it.setOnTouchListener(this@ClipboardHistoryView)
it.setOnClickListener(this@ClipboardHistoryView)
colors.setColor(it, ColorType.TOOL_BAR_KEY)
colors.setBackground(it, ColorType.BACKGROUND)
colors.setBackground(it, ColorType.STRIP_BACKGROUND)
}
colors.setBackground(clipboardStrip, ColorType.BACKGROUND)
initialized = true
}
@ -198,7 +197,6 @@ class ClipboardHistoryView @JvmOverloads constructor(
adapter = clipboardAdapter
layoutParams.width = ResourceUtils.getKeyboardWidth(context.resources, Settings.getInstance().current)
}
Settings.getInstance().current.mColors.setBackground(this, ColorType.CLIPBOARD_BACKGROUND)
}
fun stopClipboardHistory() {

View file

@ -146,7 +146,7 @@ public final class EmojiPalettesView extends LinearLayout
// and the attrs categoryIndicatorDrawable, categoryIndicatorEnabled, categoryIndicatorBackground (and the connected drawables)
private void addTab(final LinearLayout host, final int categoryId) {
final ImageView iconView = new ImageView(getContext());
mColors.setBackground(iconView, ColorType.EMOJI_CATEGORY_BACKGROUND);
mColors.setBackground(iconView, ColorType.STRIP_BACKGROUND);
mColors.setColor(iconView, ColorType.EMOJI_CATEGORY);
iconView.setScaleType(ImageView.ScaleType.CENTER);
iconView.setImageResource(mEmojiCategory.getCategoryTabIcon(categoryId));
@ -249,7 +249,7 @@ public final class EmojiPalettesView extends LinearLayout
mColors.setBackground(mAlphabetKeyLeft, ColorType.FUNCTIONAL_KEY_BACKGROUND);
mColors.setBackground(mDeleteKey, ColorType.FUNCTIONAL_KEY_BACKGROUND);
mColors.setBackground(mSpacebar, ColorType.SPACE_BAR_BACKGROUND);
mEmojiCategoryPageIndicatorView.setColors(mColors.get(ColorType.EMOJI_CATEGORY_SELECTED), mColors.get(ColorType.EMOJI_CATEGORY_BACKGROUND));
mEmojiCategoryPageIndicatorView.setColors(mColors.get(ColorType.EMOJI_CATEGORY_SELECTED), mColors.get(ColorType.STRIP_BACKGROUND));
initialized = true;
}
@ -368,7 +368,6 @@ public final class EmojiPalettesView extends LinearLayout
mEmojiRecyclerView.setAdapter(mEmojiPalettesAdapter);
setCurrentCategoryAndPageId(mEmojiCategory.getCurrentCategoryId(), mEmojiCategory.getCurrentCategoryPageId(), true);
}
mColors.setBackground(this, ColorType.EMOJI_BACKGROUND);
}
public void stopEmojiPalettes() {

View file

@ -13,8 +13,12 @@ import android.view.MotionEvent;
import android.view.View;
import android.widget.FrameLayout;
import androidx.core.view.ViewKt;
import org.dslul.openboard.inputmethod.accessibility.AccessibilityUtils;
import org.dslul.openboard.inputmethod.keyboard.MainKeyboardView;
import org.dslul.openboard.inputmethod.latin.common.ColorType;
import org.dslul.openboard.inputmethod.latin.settings.Settings;
import org.dslul.openboard.inputmethod.latin.suggestions.MoreSuggestionsView;
import org.dslul.openboard.inputmethod.latin.suggestions.SuggestionStripView;
@ -39,6 +43,10 @@ public final class InputView extends FrameLayout {
mMainKeyboardView, suggestionStripView);
mMoreSuggestionsViewCanceler = new MoreSuggestionsViewCanceler(
mMainKeyboardView, suggestionStripView);
ViewKt.doOnNextLayout(this, v -> {
Settings.getInstance().getCurrent().mColors.setBackground(findViewById(R.id.main_keyboard_frame), ColorType.MAIN_BACKGROUND);
return null;
});
}
public void setKeyboardTopPadding(final int keyboardTopPadding) {

View file

@ -95,10 +95,9 @@ class KeyboardWrapperView @JvmOverloads constructor(
colors.setColor(stopOneHandedModeBtn, ColorType.ONE_HANDED_MODE_BUTTON)
colors.setColor(switchOneHandedModeBtn, ColorType.ONE_HANDED_MODE_BUTTON)
colors.setColor(resizeOneHandedModeBtn, ColorType.ONE_HANDED_MODE_BUTTON)
colors.setBackground(stopOneHandedModeBtn, ColorType.BACKGROUND)
colors.setBackground(switchOneHandedModeBtn, ColorType.BACKGROUND)
colors.setBackground(resizeOneHandedModeBtn, ColorType.BACKGROUND)
colors.setBackground(this, ColorType.KEYBOARD_WRAPPER_BACKGROUND)
colors.setBackground(stopOneHandedModeBtn, ColorType.ONE_HANDED_MODE_BUTTON)
colors.setBackground(switchOneHandedModeBtn, ColorType.ONE_HANDED_MODE_BUTTON)
colors.setBackground(resizeOneHandedModeBtn, ColorType.ONE_HANDED_MODE_BUTTON)
}
@SuppressLint("RtlHardcoded")

View file

@ -123,7 +123,7 @@ class DynamicColors(context: Context, override val themeStyle: String, override
private val actionKeyStateList: ColorStateList
private val spaceBarStateList: ColorStateList
private val adjustedBackgroundStateList: ColorStateList
private val suggestionBackgroundList: ColorStateList
private val stripBackgroundList: ColorStateList
private val toolbarKeyStateList = activatedStateList(keyText, darken(darken(keyText)))
/** custom drawable used for keyboard background */
@ -179,10 +179,14 @@ class DynamicColors(context: Context, override val themeStyle: String, override
stateList(accent, Color.WHITE)
}
suggestionBackgroundList = if (!hasKeyBorders && themeStyle == STYLE_MATERIAL)
stateList(doubleAdjustedBackground, Color.TRANSPARENT)
else
stateList(adjustedBackground, Color.TRANSPARENT)
val stripBackground = if (keyboardBackground == null && !hasKeyBorders) {
if (isDarkColor(background)) 0x16ffffff else 0x11000000
} else {
Color.TRANSPARENT
}
val pressedStripElementBackground = if (keyboardBackground == null) adjustedBackground
else if (isDarkColor(background)) 0x22ffffff else 0x11000000
stripBackgroundList = stateList(pressedStripElementBackground, stripBackground)
adjustedBackgroundFilter =
if (themeStyle == STYLE_HOLO) colorFilter(adjustedBackground)
@ -245,7 +249,7 @@ class DynamicColors(context: Context, override val themeStyle: String, override
override fun get(color: ColorType): Int = when (color) {
TOOL_BAR_KEY_ENABLED_BACKGROUND, EMOJI_CATEGORY_SELECTED, ACTION_KEY_BACKGROUND,
CLIPBOARD_PIN, SHIFT_KEY_ICON -> accent
AUTOFILL_BACKGROUND_CHIP, EMOJI_CATEGORY_BACKGROUND, GESTURE_PREVIEW, MORE_KEYS_BACKGROUND, MORE_SUGGESTIONS_BACKGROUND, KEY_PREVIEW -> adjustedBackground
AUTOFILL_BACKGROUND_CHIP, GESTURE_PREVIEW, MORE_KEYS_BACKGROUND, MORE_SUGGESTIONS_BACKGROUND, KEY_PREVIEW -> adjustedBackground
TOOL_BAR_EXPAND_KEY_BACKGROUND -> if (!isNight) accent else doubleAdjustedBackground
GESTURE_TRAIL -> gesture
KEY_TEXT, SUGGESTION_AUTO_CORRECT, REMOVE_SUGGESTION_ICON,
@ -254,10 +258,10 @@ class DynamicColors(context: Context, override val themeStyle: String, override
SPACE_BAR_TEXT -> spaceBarText
FUNCTIONAL_KEY_BACKGROUND -> functionalKey
SPACE_BAR_BACKGROUND -> spaceBar
BACKGROUND, KEYBOARD_WRAPPER_BACKGROUND, CLIPBOARD_BACKGROUND, EMOJI_BACKGROUND, KEYBOARD_BACKGROUND -> background
BACKGROUND, KEYBOARD_BACKGROUND, MAIN_BACKGROUND -> background
KEY_BACKGROUND -> keyBackground
ACTION_KEY_MORE_KEYS_BACKGROUND -> if (themeStyle == STYLE_HOLO) adjustedBackground else accent
SUGGESTION_BACKGROUND -> if (!hasKeyBorders && themeStyle == STYLE_MATERIAL) adjustedBackground else background
STRIP_BACKGROUND -> if (!hasKeyBorders && themeStyle == STYLE_MATERIAL) adjustedBackground else background
NAVIGATION_BAR -> navBar
MORE_SUGGESTIONS_HINT, SUGGESTED_WORD, SUGGESTION_TYPED_WORD, SUGGESTION_VALID_WORD -> adjustedKeyText
ACTION_KEY_ICON, TOOL_BAR_EXPAND_KEY -> Color.WHITE
@ -271,7 +275,7 @@ class DynamicColors(context: Context, override val themeStyle: String, override
ACTION_KEY_BACKGROUND -> actionKeyStateList
SPACE_BAR_BACKGROUND -> spaceBarStateList
MORE_KEYS_BACKGROUND -> adjustedBackgroundStateList
SUGGESTION_BACKGROUND -> backgroundStateList
STRIP_BACKGROUND -> stripBackgroundList
ACTION_KEY_MORE_KEYS_BACKGROUND -> if (themeStyle == STYLE_HOLO) adjustedBackgroundStateList
else actionKeyStateList
TOOL_BAR_KEY -> toolbarKeyStateList
@ -304,7 +308,7 @@ class DynamicColors(context: Context, override val themeStyle: String, override
override fun selectAndColorDrawable(attr: TypedArray, color: ColorType): Drawable {
val drawable = when (color) {
KEY_BACKGROUND, BACKGROUND, SUGGESTION_BACKGROUND, ACTION_KEY_MORE_KEYS_BACKGROUND, MORE_KEYS_BACKGROUND ->
KEY_BACKGROUND, BACKGROUND, ACTION_KEY_MORE_KEYS_BACKGROUND, MORE_KEYS_BACKGROUND ->
attr.getDrawable(R.styleable.KeyboardView_keyBackground)
FUNCTIONAL_KEY_BACKGROUND -> attr.getDrawable(R.styleable.KeyboardView_functionalKeyBackground)
SPACE_BAR_BACKGROUND -> {
@ -326,18 +330,18 @@ class DynamicColors(context: Context, override val themeStyle: String, override
override fun setBackground(view: View, color: ColorType) {
if (view.background == null)
view.setBackgroundColor(Color.WHITE) // set white to make the color filters word
view.setBackgroundColor(Color.WHITE) // set white to make the color filters work
when (color) {
EMOJI_CATEGORY_BACKGROUND -> view.setBackgroundColor(get(color))
KEY_PREVIEW -> view.background.colorFilter = adjustedBackgroundFilter
FUNCTIONAL_KEY_BACKGROUND, KEY_BACKGROUND, BACKGROUND, SPACE_BAR_BACKGROUND, SUGGESTION_BACKGROUND -> setColor(view.background, color)
FUNCTIONAL_KEY_BACKGROUND, KEY_BACKGROUND, BACKGROUND, SPACE_BAR_BACKGROUND, STRIP_BACKGROUND -> setColor(view.background, color)
ONE_HANDED_MODE_BUTTON -> setColor(view.background, if (keyboardBackground == null) BACKGROUND else STRIP_BACKGROUND)
MORE_SUGGESTIONS_BACKGROUND -> view.background.colorFilter = backgroundFilter
MORE_KEYS_BACKGROUND ->
if (themeStyle != STYLE_HOLO)
setColor(view.background, MORE_KEYS_BACKGROUND)
else view.background.colorFilter = adjustedBackgroundFilter
KEYBOARD_BACKGROUND -> view.setBackgroundColor(Color.TRANSPARENT)
EMOJI_BACKGROUND, CLIPBOARD_BACKGROUND, KEYBOARD_WRAPPER_BACKGROUND -> {
MAIN_BACKGROUND -> {
if (keyboardBackground != null) view.background = keyboardBackground
else view.background.colorFilter = backgroundFilter
}
@ -383,7 +387,7 @@ class DefaultColors (
private val actionKeyStateList: ColorStateList
private val spaceBarStateList: ColorStateList
private val adjustedBackgroundStateList: ColorStateList
private val suggestionBackgroundList: ColorStateList
private val stripBackgroundList: ColorStateList
private val toolbarKeyStateList = activatedStateList(suggestionText, darken(darken(suggestionText)))
/** custom drawable used for keyboard background */
@ -409,10 +413,15 @@ class DefaultColors (
doubleAdjustedBackground = darken(adjustedBackground)
}
adjustedBackgroundStateList = stateList(doubleAdjustedBackground, adjustedBackground)
suggestionBackgroundList = if (!hasKeyBorders && themeStyle == STYLE_MATERIAL)
stateList(doubleAdjustedBackground, Color.TRANSPARENT)
else
stateList(adjustedBackground, Color.TRANSPARENT)
val stripBackground = if (keyboardBackground == null && !hasKeyBorders) {
if (isDarkColor(background)) 0x16ffffff else 0x11000000
} else {
Color.TRANSPARENT
}
val pressedStripElementBackground = if (keyboardBackground == null) adjustedBackground
else if (isDarkColor(background)) 0x22ffffff else 0x11000000
stripBackgroundList = stateList(pressedStripElementBackground, stripBackground)
adjustedBackgroundFilter = colorFilter(adjustedBackground)
if (hasKeyBorders) {
@ -446,7 +455,7 @@ class DefaultColors (
TOOL_BAR_KEY_ENABLED_BACKGROUND, EMOJI_CATEGORY_SELECTED, ACTION_KEY_BACKGROUND,
CLIPBOARD_PIN, SHIFT_KEY_ICON -> accent
AUTOFILL_BACKGROUND_CHIP -> if (themeStyle == STYLE_MATERIAL && !hasKeyBorders) background else adjustedBackground
EMOJI_CATEGORY_BACKGROUND, GESTURE_PREVIEW, MORE_KEYS_BACKGROUND, MORE_SUGGESTIONS_BACKGROUND, KEY_PREVIEW -> adjustedBackground
GESTURE_PREVIEW, MORE_KEYS_BACKGROUND, MORE_SUGGESTIONS_BACKGROUND, KEY_PREVIEW -> adjustedBackground
TOOL_BAR_EXPAND_KEY_BACKGROUND -> doubleAdjustedBackground
GESTURE_TRAIL -> gesture
KEY_TEXT, REMOVE_SUGGESTION_ICON, FUNCTIONAL_KEY_TEXT, KEY_ICON -> keyText
@ -454,10 +463,10 @@ class DefaultColors (
SPACE_BAR_TEXT -> spaceBarText
FUNCTIONAL_KEY_BACKGROUND -> functionalKey
SPACE_BAR_BACKGROUND -> spaceBar
BACKGROUND, KEYBOARD_WRAPPER_BACKGROUND, CLIPBOARD_BACKGROUND, EMOJI_BACKGROUND, KEYBOARD_BACKGROUND -> background
BACKGROUND, KEYBOARD_BACKGROUND, MAIN_BACKGROUND -> background
KEY_BACKGROUND -> keyBackground
ACTION_KEY_MORE_KEYS_BACKGROUND -> if (themeStyle == STYLE_HOLO) adjustedBackground else accent
SUGGESTION_BACKGROUND -> if (!hasKeyBorders && themeStyle == STYLE_MATERIAL) adjustedBackground else background
STRIP_BACKGROUND -> if (!hasKeyBorders && themeStyle == STYLE_MATERIAL) adjustedBackground else background
NAVIGATION_BAR -> navBar
SUGGESTION_AUTO_CORRECT, EMOJI_CATEGORY, TOOL_BAR_KEY, TOOL_BAR_EXPAND_KEY, ONE_HANDED_MODE_BUTTON -> suggestionText
MORE_SUGGESTIONS_HINT, SUGGESTED_WORD, SUGGESTION_TYPED_WORD, SUGGESTION_VALID_WORD -> adjustedSuggestionText
@ -472,8 +481,7 @@ class DefaultColors (
ACTION_KEY_BACKGROUND -> actionKeyStateList
SPACE_BAR_BACKGROUND -> spaceBarStateList
MORE_KEYS_BACKGROUND -> adjustedBackgroundStateList
SUGGESTION_BACKGROUND -> if (!hasKeyBorders && themeStyle == STYLE_MATERIAL) adjustedBackgroundStateList
else backgroundStateList
STRIP_BACKGROUND -> stripBackgroundList
ACTION_KEY_MORE_KEYS_BACKGROUND -> if (themeStyle == STYLE_HOLO) adjustedBackgroundStateList
else actionKeyStateList
TOOL_BAR_KEY -> toolbarKeyStateList
@ -497,14 +505,14 @@ class DefaultColors (
override fun setBackground(view: View, color: ColorType) {
if (view.background == null)
view.setBackgroundColor(Color.WHITE) // set white to make the color filters word
view.setBackgroundColor(Color.WHITE) // set white to make the color filters work
when (color) {
EMOJI_CATEGORY_BACKGROUND -> view.setBackgroundColor(get(color))
KEY_PREVIEW, MORE_KEYS_BACKGROUND -> view.background.colorFilter = adjustedBackgroundFilter
FUNCTIONAL_KEY_BACKGROUND, KEY_BACKGROUND, BACKGROUND, SPACE_BAR_BACKGROUND, SUGGESTION_BACKGROUND -> setColor(view.background, color)
KEYBOARD_BACKGROUND -> view.setBackgroundColor(Color.TRANSPARENT)
FUNCTIONAL_KEY_BACKGROUND, KEY_BACKGROUND, BACKGROUND, SPACE_BAR_BACKGROUND, STRIP_BACKGROUND -> setColor(view.background, color)
ONE_HANDED_MODE_BUTTON -> setColor(view.background, if (keyboardBackground == null) BACKGROUND else STRIP_BACKGROUND)
MORE_SUGGESTIONS_BACKGROUND -> view.background.colorFilter = backgroundFilter
EMOJI_BACKGROUND, CLIPBOARD_BACKGROUND, KEYBOARD_WRAPPER_BACKGROUND -> {
KEYBOARD_BACKGROUND -> view.setBackgroundColor(Color.TRANSPARENT)
MAIN_BACKGROUND -> {
if (keyboardBackground != null) view.background = keyboardBackground
else view.background.colorFilter = backgroundFilter
}
@ -523,7 +531,7 @@ class DefaultColors (
override fun selectAndColorDrawable(attr: TypedArray, color: ColorType): Drawable {
val drawable = when (color) {
KEY_BACKGROUND, BACKGROUND, SUGGESTION_BACKGROUND, ACTION_KEY_MORE_KEYS_BACKGROUND, MORE_KEYS_BACKGROUND ->
KEY_BACKGROUND, BACKGROUND, ACTION_KEY_MORE_KEYS_BACKGROUND, MORE_KEYS_BACKGROUND ->
attr.getDrawable(R.styleable.KeyboardView_keyBackground)
FUNCTIONAL_KEY_BACKGROUND -> attr.getDrawable(R.styleable.KeyboardView_functionalKeyBackground)
SPACE_BAR_BACKGROUND -> {
@ -566,10 +574,7 @@ enum class ColorType {
AUTOFILL_BACKGROUND_CHIP,
BACKGROUND,
CLIPBOARD_PIN,
CLIPBOARD_BACKGROUND,
EMOJI_BACKGROUND,
EMOJI_CATEGORY,
EMOJI_CATEGORY_BACKGROUND,
EMOJI_CATEGORY_SELECTED,
FUNCTIONAL_KEY_TEXT,
FUNCTIONAL_KEY_BACKGROUND,
@ -581,7 +586,6 @@ enum class ColorType {
KEY_HINT_TEXT,
KEY_PREVIEW,
KEYBOARD_BACKGROUND,
KEYBOARD_WRAPPER_BACKGROUND,
MORE_SUGGESTIONS_HINT,
MORE_SUGGESTIONS_BACKGROUND,
MORE_KEYS_BACKGROUND,
@ -591,13 +595,14 @@ enum class ColorType {
SPACE_BAR_TEXT,
ONE_HANDED_MODE_BUTTON,
REMOVE_SUGGESTION_ICON,
STRIP_BACKGROUND,
SUGGESTED_WORD,
SUGGESTION_AUTO_CORRECT,
SUGGESTION_BACKGROUND,
SUGGESTION_TYPED_WORD,
SUGGESTION_VALID_WORD,
TOOL_BAR_EXPAND_KEY,
TOOL_BAR_EXPAND_KEY_BACKGROUND,
TOOL_BAR_KEY,
TOOL_BAR_KEY_ENABLED_BACKGROUND,
MAIN_BACKGROUND,
}

View file

@ -164,7 +164,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
word.setContentDescription(getResources().getString(R.string.spoken_empty_suggestion));
word.setOnClickListener(this);
word.setOnLongClickListener(this);
colors.setBackground(word, ColorType.SUGGESTION_BACKGROUND);
colors.setBackground(word, ColorType.STRIP_BACKGROUND);
mWordViews.add(word);
final View divider = inflater.inflate(R.layout.suggestion_divider, null);
mDividerViews.add(divider);
@ -204,7 +204,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
final int toolbarHeight = Math.min(mToolbarExpandKey.getLayoutParams().height, (int) getResources().getDimension(R.dimen.config_suggestions_strip_height));
mToolbarExpandKey.getLayoutParams().height = toolbarHeight;
mToolbarExpandKey.getLayoutParams().width = toolbarHeight; // we want it square
colors.setBackground(mToolbarExpandKey, ColorType.SUGGESTION_BACKGROUND);
colors.setBackground(mToolbarExpandKey, ColorType.STRIP_BACKGROUND);
mDefaultBackground = mToolbarExpandKey.getBackground();
mEnabledToolKeyBackground.setColors(new int[] {colors.get(ColorType.TOOL_BAR_KEY_ENABLED_BACKGROUND) | 0xFF000000, Color.TRANSPARENT}); // ignore alpha on accent color
mEnabledToolKeyBackground.setGradientType(GradientDrawable.RADIAL_GRADIENT);
@ -228,7 +228,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
pinnedKeyInToolbar.setBackground(mEnabledToolKeyBackground);
}
colors.setBackground(this, ColorType.SUGGESTION_BACKGROUND);
colors.setBackground(this, ColorType.STRIP_BACKGROUND);
keyboardAttr.recycle();
}
@ -714,6 +714,6 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
view.setOnClickListener(this);
view.setOnLongClickListener(this);
colors.setColor(view, ColorType.TOOL_BAR_KEY);
colors.setBackground(view, ColorType.SUGGESTION_BACKGROUND);
colors.setBackground(view, ColorType.STRIP_BACKGROUND);
}
}

View file

@ -9,6 +9,7 @@
android:layout_gravity="bottom"
android:orientation="vertical"
android:visibility="gone"
android:background="@android:color/transparent"
style="?attr/clipboardHistoryViewStyle">
<FrameLayout

View file

@ -12,6 +12,7 @@
android:layout_gravity="bottom"
android:orientation="vertical"
android:visibility="gone"
android:background="@android:color/transparent"
style="?attr/emojiPalettesViewStyle"
>
<androidx.recyclerview.widget.RecyclerView