rename user theme to custom theme

This commit is contained in:
Helium314 2023-07-20 09:47:02 +02:00
parent 6c75203dfc
commit f61c76195d
12 changed files with 54 additions and 59 deletions

View file

@ -552,7 +552,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
// set background color here, otherwise there is a narrow white line between keyboard and suggestion strip
final SettingsValues settingsValues = Settings.getInstance().getCurrent();
if (settingsValues.mUserTheme)
if (settingsValues.mCustomTheme)
mKeyboardViewWrapper.getBackground().setColorFilter(settingsValues.mBackgroundColorFilter);
return mCurrentInputView;

View file

@ -107,7 +107,7 @@ public class KeyboardView extends View {
private final ColorFilter keyTextColorFilter;
private final ColorFilter keyBgFilter;
private final ColorFilter accentColorFilter;
private final boolean mUserTheme;
private final boolean mCustomTheme;
// The maximum key label width in the proportion to the key width.
private static final float MAX_LABEL_RATIO = 0.90f;
@ -180,14 +180,14 @@ public class KeyboardView extends View {
mPaint.setAntiAlias(true);
final SettingsValues settingsValues = Settings.getInstance().getCurrent();
mUserTheme = settingsValues.mUserTheme;
if (mUserTheme) {
mCustomTheme = settingsValues.mCustomTheme;
if (mCustomTheme) {
getBackground().setColorFilter(settingsValues.mBackgroundColorFilter);
keyBgFilter = settingsValues.mKeyBackgroundColorFilter;
keyHintTextColorFilter = settingsValues.mHintTextColorFilter;
keyTextColorFilter = settingsValues.mKeyTextColorFilter;
accentColorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(settingsValues.mUserThemeColorAccent, BlendModeCompat.SRC_ATOP);
keyBgFilter = settingsValues.mCustomKeyBackgroundColorFilter;
keyHintTextColorFilter = settingsValues.mCustomHintTextColorFilter;
keyTextColorFilter = settingsValues.mCustomKeyTextColorFilter;
accentColorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(settingsValues.mCustomThemeColorAccent, BlendModeCompat.SRC_ATOP);
} else {
keyHintTextColorFilter = null;
keyTextColorFilter = null;
@ -398,7 +398,7 @@ public class KeyboardView extends View {
bgX = -padding.left;
bgY = -padding.top;
}
if (mUserTheme) {
if (mCustomTheme) {
// color filter is applied to background, which is re-used
// but we don't want it applied to "blue" keys
// so we always need to select the color filter dependent on the current key
@ -461,7 +461,7 @@ public class KeyboardView extends View {
if (key.isEnabled()) {
paint.setColor(key.selectTextColor(params));
if (mUserTheme) {
if (mCustomTheme) {
// set key color only if not in emoji keyboard range
if (keyboard != null
&& (this.getClass() == MoreSuggestionsView.class ?
@ -495,7 +495,7 @@ public class KeyboardView extends View {
if (hintLabel != null && mShowsHints) {
paint.setTextSize(key.selectHintTextSize(params));
paint.setColor(key.selectHintTextColor(params));
if (mUserTheme)
if (mCustomTheme)
paint.setColorFilter(keyHintTextColorFilter);
// TODO: Should add a way to specify type face for hint letters
paint.setTypeface(Typeface.DEFAULT_BOLD);
@ -549,7 +549,7 @@ public class KeyboardView extends View {
iconY = (keyHeight - iconHeight) / 2; // Align vertically center.
}
final int iconX = (keyWidth - iconWidth) / 2; // Align horizontally center.
if (mUserTheme && key.getBackgroundType() != Key.BACKGROUND_TYPE_NORMAL && !key.isActionKey() && !key.isShift())
if (mCustomTheme && key.getBackgroundType() != Key.BACKGROUND_TYPE_NORMAL && !key.isActionKey() && !key.isShift())
// no color for shift (because of state indicator) and accent color keys (action and popup)
icon.setColorFilter(keyTextColorFilter);
drawIcon(canvas, icon, iconX, iconY, iconWidth, iconHeight);

View file

@ -64,7 +64,7 @@ class ClipboardHistoryRecyclerView @JvmOverloads constructor(
paint.color = dividerColor
paint.strokeWidth = dividerHeight.toFloat()
val sv = Settings.getInstance().current
if (sv.mUserTheme)
if (sv.mCustomTheme)
paint.colorFilter = sv.mBackgroundColorFilter
}

View file

@ -101,10 +101,10 @@ class ClipboardHistoryView @JvmOverloads constructor(
setOnTouchListener(this@ClipboardHistoryView)
setOnClickListener(this@ClipboardHistoryView)
}
if (settingsValues.mUserTheme) {
alphabetKey.background.colorFilter = settingsValues.mKeyBackgroundColorFilter
alphabetKey.setTextColor(settingsValues.mKeyTextColor)
clearKey.colorFilter = settingsValues.mKeyTextColorFilter
if (settingsValues.mCustomTheme) {
alphabetKey.background.colorFilter = settingsValues.mCustomKeyBackgroundColorFilter
alphabetKey.setTextColor(settingsValues.mCustomKeyTextColor)
clearKey.colorFilter = settingsValues.mCustomKeyTextColorFilter
background.colorFilter = settingsValues.mBackgroundColorFilter
}
}
@ -114,8 +114,8 @@ class ClipboardHistoryView @JvmOverloads constructor(
text = label
typeface = params.mTypeface
val settingsValues = Settings.getInstance().current
if (settingsValues.mUserTheme)
setTextColor(settingsValues.mKeyTextColor)
if (settingsValues.mCustomTheme)
setTextColor(settingsValues.mCustomKeyTextColor)
else
setTextColor(params.mFunctionalTextColor)
setTextSize(TypedValue.COMPLEX_UNIT_PX, params.mLabelSize.toFloat())
@ -127,9 +127,9 @@ class ClipboardHistoryView @JvmOverloads constructor(
itemBackgroundId = keyBackgroundId
itemTypeFace = params.mTypeface
val sv = Settings.getInstance().current
if (sv.mUserTheme) {
itemTextColor = sv.mKeyTextColor
itemBackgroundColorFilter = sv.mKeyBackgroundColorFilter
if (sv.mCustomTheme) {
itemTextColor = sv.mCustomKeyTextColor
itemBackgroundColorFilter = sv.mCustomKeyBackgroundColorFilter
} else
itemTextColor = params.mTextColor
itemTextSize = params.mLabelSize.toFloat()

View file

@ -35,8 +35,6 @@ import android.widget.TabWidget;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.core.graphics.BlendModeColorFilterCompat;
import androidx.core.graphics.BlendModeCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import org.dslul.openboard.inputmethod.compat.TabHostCompat;
@ -167,9 +165,9 @@ public final class EmojiPalettesView extends LinearLayout
// category page indicator background as a workaround.
iconView.setBackgroundColor(mCategoryPageIndicatorBackground);
final SettingsValues settingsValues = Settings.getInstance().getCurrent();
if (settingsValues.mUserTheme) {
if (settingsValues.mCustomTheme) {
iconView.getBackground().setColorFilter(settingsValues.mBackgroundColorFilter);
iconView.setColorFilter(settingsValues.mKeyTextColorFilter);
iconView.setColorFilter(settingsValues.mCustomKeyTextColorFilter);
}
iconView.setImageResource(mEmojiCategory.getCategoryTabIcon(categoryId));
iconView.setContentDescription(mEmojiCategory.getAccessibilityDescription(categoryId));
@ -273,13 +271,13 @@ public final class EmojiPalettesView extends LinearLayout
mSpacebar.setOnTouchListener(this);
mSpacebar.setOnClickListener(this);
final SettingsValues settingsValues = Settings.getInstance().getCurrent();
if (settingsValues.mUserTheme) {
final ColorFilter cf = settingsValues.mKeyBackgroundColorFilter;
if (settingsValues.mCustomTheme) {
final ColorFilter cf = settingsValues.mCustomKeyBackgroundColorFilter;
mAlphabetKeyLeft.getBackground().setColorFilter(cf);
mSpacebar.getBackground().setColorFilter(cf);
mDeleteKey.getBackground().setColorFilter(cf);
getBackground().setColorFilter(cf);
mEmojiCategoryPageIndicatorView.setColors(settingsValues.mUserThemeColorAccent, settingsValues.mBackgroundColor);
mEmojiCategoryPageIndicatorView.setColors(settingsValues.mCustomThemeColorAccent, settingsValues.mBackgroundColor);
findViewById(R.id.emoji_tab_strip).getBackground().setColorFilter(cf);
}
mEmojiLayoutParams.setKeyProperties(mSpacebar);
@ -304,11 +302,11 @@ public final class EmojiPalettesView extends LinearLayout
updateEmojiCategoryPageIdView();
}
final SettingsValues settingsValues = Settings.getInstance().getCurrent();
if (settingsValues.mUserTheme) {
if (settingsValues.mCustomTheme) {
if (mCurrentTab != null)
mCurrentTab.setColorFilter(settingsValues.mKeyTextColorFilter);
mCurrentTab.setColorFilter(settingsValues.mCustomKeyTextColorFilter);
mCurrentTab = (ImageView) mTabHost.getCurrentTabView();
mCurrentTab.setColorFilter(settingsValues.mUserThemeColorAccent);
mCurrentTab.setColorFilter(settingsValues.mCustomThemeColorAccent);
}
}
@ -394,8 +392,8 @@ public final class EmojiPalettesView extends LinearLayout
final KeyDrawParams params) {
alphabetKey.setText(label);
final SettingsValues settingsValues = Settings.getInstance().getCurrent();
if (settingsValues.mUserTheme)
alphabetKey.setTextColor(settingsValues.mKeyTextColor);
if (settingsValues.mCustomTheme)
alphabetKey.setTextColor(settingsValues.mCustomKeyTextColor);
else
alphabetKey.setTextColor(params.mFunctionalTextColor);
alphabetKey.setTextSize(TypedValue.COMPLEX_UNIT_PX, params.mLabelSize);

View file

@ -65,11 +65,11 @@ public class GestureFloatingTextDrawingPreview extends AbstractDrawingPreview {
final SettingsValues sv = Settings.getInstance().getCurrent();
mGesturePreviewTextSize = mainKeyboardViewAttr.getDimensionPixelSize(
R.styleable.MainKeyboardView_gestureFloatingPreviewTextSize, 0);
mGesturePreviewTextColor = sv.mUserTheme ? sv.mKeyTextColor : mainKeyboardViewAttr.getColor(
mGesturePreviewTextColor = sv.mCustomTheme ? sv.mCustomKeyTextColor : mainKeyboardViewAttr.getColor(
R.styleable.MainKeyboardView_gestureFloatingPreviewTextColor, 0);
mGesturePreviewTextOffset = mainKeyboardViewAttr.getDimensionPixelOffset(
R.styleable.MainKeyboardView_gestureFloatingPreviewTextOffset, 0);
mGesturePreviewColor = sv.mUserTheme ? sv.mBackgroundColor : mainKeyboardViewAttr.getColor(
mGesturePreviewColor = sv.mCustomTheme ? sv.mBackgroundColor : mainKeyboardViewAttr.getColor(
R.styleable.MainKeyboardView_gestureFloatingPreviewColor, 0);
mGesturePreviewHorizontalPadding = mainKeyboardViewAttr.getDimension(
R.styleable.MainKeyboardView_gestureFloatingPreviewHorizontalPadding, 0.0f);

View file

@ -53,7 +53,7 @@ final class GestureTrailDrawingParams {
public GestureTrailDrawingParams(final TypedArray mainKeyboardViewAttr) {
final SettingsValues sv = Settings.getInstance().getCurrent();
mTrailColor = sv.mUserTheme ? sv.mUserThemeColorAccent : mainKeyboardViewAttr.getColor(
mTrailColor = sv.mCustomTheme ? sv.mCustomThemeColorAccent : mainKeyboardViewAttr.getColor(
R.styleable.MainKeyboardView_gestureTrailColor, 0);
mTrailStartWidth = mainKeyboardViewAttr.getDimension(
R.styleable.MainKeyboardView_gestureTrailStartWidth, 0.0f);

View file

@ -20,9 +20,6 @@ import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import androidx.core.graphics.BlendModeColorFilterCompat;
import androidx.core.graphics.BlendModeCompat;
import org.dslul.openboard.inputmethod.keyboard.Key;
import org.dslul.openboard.inputmethod.latin.common.CoordinateUtils;
import org.dslul.openboard.inputmethod.latin.settings.Settings;
@ -123,9 +120,9 @@ public final class KeyPreviewChoreographer {
final boolean hasMoreKeys = (key.getMoreKeys() != null);
keyPreviewView.setPreviewBackground(hasMoreKeys, keyPreviewPosition);
final SettingsValues settingsValues = Settings.getInstance().getCurrent();
if (settingsValues.mUserTheme) {
if (settingsValues.mCustomTheme) {
keyPreviewView.getBackground().setColorFilter(settingsValues.mBackgroundColorFilter);
keyPreviewView.setTextColor(settingsValues.mKeyTextColor);
keyPreviewView.setTextColor(settingsValues.mCustomKeyTextColor);
}
// The key preview is placed vertically above the top edge of the parent key with an
// arbitrary offset.

View file

@ -2023,7 +2023,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP || !settingsValues.mNavBarColor)
return;
final int color;
if (settingsValues.mUserTheme) {
if (settingsValues.mCustomTheme) {
final int c = settingsValues.mBackgroundColor;
// slightly adjust so color is same as keyboard background
color = Color.rgb((int) (Color.red(c) * 0.925), (int) (Color.green(c) * 0.9379), (int) (Color.blue(c) * 0.945));

View file

@ -129,14 +129,14 @@ public class SettingsValues {
private final AsyncResultHolder<AppWorkaroundsUtils> mAppWorkarounds;
// User-defined colors
public final boolean mUserTheme;
public final ColorFilter mKeyBackgroundColorFilter;
public final boolean mCustomTheme;
public final ColorFilter mCustomKeyBackgroundColorFilter;
public final int mBackgroundColor;
public final ColorFilter mBackgroundColorFilter;
public final ColorFilter mKeyTextColorFilter;
public final ColorFilter mHintTextColorFilter;
public final int mUserThemeColorAccent;
public final int mKeyTextColor;
public final ColorFilter mCustomKeyTextColorFilter;
public final ColorFilter mCustomHintTextColorFilter;
public final int mCustomThemeColorAccent;
public final int mCustomKeyTextColor;
// Debug settings
public final boolean mIsInternal;
@ -271,18 +271,18 @@ public class SettingsValues {
prefs.getBoolean(Settings.PREF_THEME_DAY_NIGHT, false),
prefs.getBoolean(Settings.PREF_THEME_AMOLED_MODE, false)
);
mUserTheme = KeyboardTheme.getIsUser(keyboardThemeId);
mUserThemeColorAccent = prefs.getInt(Settings.PREF_THEME_USER_COLOR_ACCENT, Color.BLUE);
mCustomTheme = KeyboardTheme.getIsUser(keyboardThemeId);
mCustomThemeColorAccent = prefs.getInt(Settings.PREF_THEME_USER_COLOR_ACCENT, Color.BLUE);
final int keyBgColor;
if (prefs.getBoolean(Settings.PREF_THEME_KEY_BORDERS, false))
keyBgColor = prefs.getInt(Settings.PREF_THEME_USER_COLOR_KEYS, Color.LTGRAY);
else
keyBgColor = prefs.getInt(Settings.PREF_THEME_USER_COLOR_BACKGROUND, Color.DKGRAY);
mKeyBackgroundColorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(keyBgColor, BlendModeCompat.MODULATE);
mHintTextColorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(prefs.getInt(Settings.PREF_THEME_USER_COLOR_HINT_TEXT, Color.WHITE), BlendModeCompat.SRC_ATOP);
mKeyTextColor = prefs.getInt(Settings.PREF_THEME_USER_COLOR_TEXT, Color.WHITE);
mKeyTextColorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(mKeyTextColor, BlendModeCompat.SRC_ATOP);
if (mUserTheme) {
mCustomKeyBackgroundColorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(keyBgColor, BlendModeCompat.MODULATE);
mCustomHintTextColorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(prefs.getInt(Settings.PREF_THEME_USER_COLOR_HINT_TEXT, Color.WHITE), BlendModeCompat.SRC_ATOP);
mCustomKeyTextColor = prefs.getInt(Settings.PREF_THEME_USER_COLOR_TEXT, Color.WHITE);
mCustomKeyTextColorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(mCustomKeyTextColor, BlendModeCompat.SRC_ATOP);
if (mCustomTheme) {
mBackgroundColor = prefs.getInt(Settings.PREF_THEME_USER_COLOR_BACKGROUND, Color.DKGRAY);
} else if (KeyboardTheme.THEME_VARIANT_LIGHT.equals(KeyboardTheme.getThemeVariant(keyboardThemeId))) {
mBackgroundColor = Color.rgb(236, 239, 241);

View file

@ -509,8 +509,8 @@ final class SuggestionStripLayoutHelper {
wordView.setTag(indexInSuggestedWords);
wordView.setText(getStyledSuggestedWord(suggestedWords, indexInSuggestedWords));
final SettingsValues settingsValues = Settings.getInstance().getCurrent();
if (settingsValues.mUserTheme)
wordView.setTextColor(settingsValues.mKeyTextColor);
if (settingsValues.mCustomTheme)
wordView.setTextColor(settingsValues.mCustomKeyTextColor);
else
wordView.setTextColor(getSuggestionTextColor(suggestedWords, indexInSuggestedWords));
if (SuggestionStripView.DBG) {

View file

@ -182,7 +182,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
mOtherKey.setImageDrawable(iconIncognito);
final SettingsValues settingsValues = Settings.getInstance().getCurrent();
if (settingsValues.mUserTheme)
if (settingsValues.mCustomTheme)
mStripVisibilityGroup.mSuggestionStripView.getBackground().setColorFilter(settingsValues.mBackgroundColorFilter);
}