allow setting functional and space key colors separately

not exposed to user
also fixes minor inconsistencies
This commit is contained in:
Helium314 2023-07-20 10:55:22 +02:00
parent f61c76195d
commit c6411777ab
7 changed files with 25 additions and 21 deletions

View file

@ -1108,7 +1108,7 @@ public class Key implements Comparable<Key> {
@Nonnull final Drawable functionalKeyBackground, @Nonnull final Drawable functionalKeyBackground,
@Nonnull final Drawable spacebarBackground) { @Nonnull final Drawable spacebarBackground) {
final Drawable background; final Drawable background;
if (mBackgroundType == BACKGROUND_TYPE_FUNCTIONAL) { if (mBackgroundType == BACKGROUND_TYPE_FUNCTIONAL || mBackgroundType == BACKGROUND_TYPE_STICKY_OFF || mBackgroundType == BACKGROUND_TYPE_STICKY_ON) {
background = functionalKeyBackground; background = functionalKeyBackground;
} else if (mBackgroundType == BACKGROUND_TYPE_SPACEBAR) { } else if (mBackgroundType == BACKGROUND_TYPE_SPACEBAR) {
background = spacebarBackground; background = spacebarBackground;

View file

@ -188,6 +188,8 @@ public class KeyboardView extends View {
keyHintTextColorFilter = settingsValues.mCustomHintTextColorFilter; keyHintTextColorFilter = settingsValues.mCustomHintTextColorFilter;
keyTextColorFilter = settingsValues.mCustomKeyTextColorFilter; keyTextColorFilter = settingsValues.mCustomKeyTextColorFilter;
accentColorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(settingsValues.mCustomThemeColorAccent, BlendModeCompat.SRC_ATOP); accentColorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(settingsValues.mCustomThemeColorAccent, BlendModeCompat.SRC_ATOP);
mSpacebarBackground.setColorFilter(settingsValues.mCustomSpaceBarBackgroundColorFilter);
mFunctionalKeyBackground.setColorFilter(settingsValues.mCustomFunctionalKeyBackgroundColorFilter);
} else { } else {
keyHintTextColorFilter = null; keyHintTextColorFilter = null;
keyTextColorFilter = null; keyTextColorFilter = null;
@ -400,13 +402,10 @@ public class KeyboardView extends View {
} }
if (mCustomTheme) { if (mCustomTheme) {
// color filter is applied to background, which is re-used // color filter is applied to background, which is re-used
// but we don't want it applied to "blue" keys // action key and normal key share the same background drawable, so we need to select the correct color filter
// so we always need to select the color filter dependent on the current key
if (key.isActionKey()) if (key.isActionKey())
background.setColorFilter(accentColorFilter); background.setColorFilter(accentColorFilter);
else if (key.getBackgroundType() == Key.BACKGROUND_TYPE_NORMAL && key.getCode() < 0 && key.getCode() != Constants.CODE_SWITCH_ALPHA_SYMBOL && key.getCode() != Constants.CODE_OUTPUT_TEXT) else if (key.getBackgroundType() == Key.BACKGROUND_TYPE_NORMAL)
background.clearColorFilter();
else
background.setColorFilter(keyBgFilter); background.setColorFilter(keyBgFilter);
} }
background.setBounds(0, 0, bgWidth, bgHeight); background.setBounds(0, 0, bgWidth, bgHeight);

View file

@ -63,9 +63,9 @@ class ClipboardHistoryRecyclerView @JvmOverloads constructor(
init { init {
paint.color = dividerColor paint.color = dividerColor
paint.strokeWidth = dividerHeight.toFloat() paint.strokeWidth = dividerHeight.toFloat()
val sv = Settings.getInstance().current val settingsValues = Settings.getInstance().current
if (sv.mCustomTheme) if (settingsValues.mCustomTheme)
paint.colorFilter = sv.mBackgroundColorFilter paint.colorFilter = settingsValues.mBackgroundColorFilter
} }
override fun onDrawOver(canvas: Canvas, parent: RecyclerView, state: State) { override fun onDrawOver(canvas: Canvas, parent: RecyclerView, state: State) {

View file

@ -102,7 +102,7 @@ class ClipboardHistoryView @JvmOverloads constructor(
setOnClickListener(this@ClipboardHistoryView) setOnClickListener(this@ClipboardHistoryView)
} }
if (settingsValues.mCustomTheme) { if (settingsValues.mCustomTheme) {
alphabetKey.background.colorFilter = settingsValues.mCustomKeyBackgroundColorFilter alphabetKey.background.colorFilter = settingsValues.mCustomFunctionalKeyBackgroundColorFilter
alphabetKey.setTextColor(settingsValues.mCustomKeyTextColor) alphabetKey.setTextColor(settingsValues.mCustomKeyTextColor)
clearKey.colorFilter = settingsValues.mCustomKeyTextColorFilter clearKey.colorFilter = settingsValues.mCustomKeyTextColorFilter
background.colorFilter = settingsValues.mBackgroundColorFilter background.colorFilter = settingsValues.mBackgroundColorFilter
@ -126,10 +126,10 @@ class ClipboardHistoryView @JvmOverloads constructor(
clipboardAdapter.apply { clipboardAdapter.apply {
itemBackgroundId = keyBackgroundId itemBackgroundId = keyBackgroundId
itemTypeFace = params.mTypeface itemTypeFace = params.mTypeface
val sv = Settings.getInstance().current val settingsValues = Settings.getInstance().current
if (sv.mCustomTheme) { if (settingsValues.mCustomTheme) {
itemTextColor = sv.mCustomKeyTextColor itemTextColor = settingsValues.mCustomKeyTextColor
itemBackgroundColorFilter = sv.mCustomKeyBackgroundColorFilter itemBackgroundColorFilter = settingsValues.mCustomKeyBackgroundColorFilter
} else } else
itemTextColor = params.mTextColor itemTextColor = params.mTextColor
itemTextSize = params.mLabelSize.toFloat() itemTextSize = params.mLabelSize.toFloat()

View file

@ -272,13 +272,12 @@ public final class EmojiPalettesView extends LinearLayout
mSpacebar.setOnClickListener(this); mSpacebar.setOnClickListener(this);
final SettingsValues settingsValues = Settings.getInstance().getCurrent(); final SettingsValues settingsValues = Settings.getInstance().getCurrent();
if (settingsValues.mCustomTheme) { if (settingsValues.mCustomTheme) {
final ColorFilter cf = settingsValues.mCustomKeyBackgroundColorFilter; mAlphabetKeyLeft.getBackground().setColorFilter(settingsValues.mCustomFunctionalKeyBackgroundColorFilter);
mAlphabetKeyLeft.getBackground().setColorFilter(cf); mSpacebar.getBackground().setColorFilter(settingsValues.mCustomSpaceBarBackgroundColorFilter);
mSpacebar.getBackground().setColorFilter(cf); mDeleteKey.getBackground().setColorFilter(settingsValues.mCustomFunctionalKeyBackgroundColorFilter);
mDeleteKey.getBackground().setColorFilter(cf); getBackground().setColorFilter(settingsValues.mBackgroundColorFilter);
getBackground().setColorFilter(cf);
mEmojiCategoryPageIndicatorView.setColors(settingsValues.mCustomThemeColorAccent, settingsValues.mBackgroundColor); mEmojiCategoryPageIndicatorView.setColors(settingsValues.mCustomThemeColorAccent, settingsValues.mBackgroundColor);
findViewById(R.id.emoji_tab_strip).getBackground().setColorFilter(cf); findViewById(R.id.emoji_tab_strip).getBackground().setColorFilter(settingsValues.mBackgroundColorFilter);
} }
mEmojiLayoutParams.setKeyProperties(mSpacebar); mEmojiLayoutParams.setKeyProperties(mSpacebar);
mSpacebarIcon = findViewById(R.id.emoji_keyboard_space_icon); mSpacebarIcon = findViewById(R.id.emoji_keyboard_space_icon);

View file

@ -131,6 +131,8 @@ public class SettingsValues {
// User-defined colors // User-defined colors
public final boolean mCustomTheme; public final boolean mCustomTheme;
public final ColorFilter mCustomKeyBackgroundColorFilter; public final ColorFilter mCustomKeyBackgroundColorFilter;
public final ColorFilter mCustomFunctionalKeyBackgroundColorFilter;
public final ColorFilter mCustomSpaceBarBackgroundColorFilter;
public final int mBackgroundColor; public final int mBackgroundColor;
public final ColorFilter mBackgroundColorFilter; public final ColorFilter mBackgroundColorFilter;
public final ColorFilter mCustomKeyTextColorFilter; public final ColorFilter mCustomKeyTextColorFilter;
@ -280,6 +282,8 @@ public class SettingsValues {
keyBgColor = prefs.getInt(Settings.PREF_THEME_USER_COLOR_BACKGROUND, Color.DKGRAY); keyBgColor = prefs.getInt(Settings.PREF_THEME_USER_COLOR_BACKGROUND, Color.DKGRAY);
mCustomKeyBackgroundColorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(keyBgColor, BlendModeCompat.MODULATE); mCustomKeyBackgroundColorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(keyBgColor, BlendModeCompat.MODULATE);
mCustomHintTextColorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(prefs.getInt(Settings.PREF_THEME_USER_COLOR_HINT_TEXT, Color.WHITE), BlendModeCompat.SRC_ATOP); mCustomHintTextColorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(prefs.getInt(Settings.PREF_THEME_USER_COLOR_HINT_TEXT, Color.WHITE), BlendModeCompat.SRC_ATOP);
mCustomFunctionalKeyBackgroundColorFilter = mCustomKeyBackgroundColorFilter;
mCustomSpaceBarBackgroundColorFilter = mCustomKeyBackgroundColorFilter;
mCustomKeyTextColor = prefs.getInt(Settings.PREF_THEME_USER_COLOR_TEXT, Color.WHITE); mCustomKeyTextColor = prefs.getInt(Settings.PREF_THEME_USER_COLOR_TEXT, Color.WHITE);
mCustomKeyTextColorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(mCustomKeyTextColor, BlendModeCompat.SRC_ATOP); mCustomKeyTextColorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(mCustomKeyTextColor, BlendModeCompat.SRC_ATOP);
if (mCustomTheme) { if (mCustomTheme) {

View file

@ -182,8 +182,10 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
mOtherKey.setImageDrawable(iconIncognito); mOtherKey.setImageDrawable(iconIncognito);
final SettingsValues settingsValues = Settings.getInstance().getCurrent(); final SettingsValues settingsValues = Settings.getInstance().getCurrent();
if (settingsValues.mCustomTheme) if (settingsValues.mCustomTheme) {
mStripVisibilityGroup.mSuggestionStripView.getBackground().setColorFilter(settingsValues.mBackgroundColorFilter); mStripVisibilityGroup.mSuggestionStripView.getBackground().setColorFilter(settingsValues.mBackgroundColorFilter);
mClipboardKey.setColorFilter(settingsValues.mCustomKeyTextColor);
}
} }
/** /**