make custom colors always active

This commit is contained in:
Helium314 2023-08-31 20:49:43 +02:00
parent 61a73572b8
commit ede5bf8f4f
17 changed files with 75 additions and 174 deletions

View file

@ -40,7 +40,6 @@ import org.dslul.openboard.inputmethod.latin.LatinIME;
import org.dslul.openboard.inputmethod.latin.R; import org.dslul.openboard.inputmethod.latin.R;
import org.dslul.openboard.inputmethod.latin.RichInputMethodManager; import org.dslul.openboard.inputmethod.latin.RichInputMethodManager;
import org.dslul.openboard.inputmethod.latin.WordComposer; import org.dslul.openboard.inputmethod.latin.WordComposer;
import org.dslul.openboard.inputmethod.latin.common.Colors;
import org.dslul.openboard.inputmethod.latin.define.ProductionFlags; import org.dslul.openboard.inputmethod.latin.define.ProductionFlags;
import org.dslul.openboard.inputmethod.latin.settings.Settings; import org.dslul.openboard.inputmethod.latin.settings.Settings;
import org.dslul.openboard.inputmethod.latin.settings.SettingsValues; import org.dslul.openboard.inputmethod.latin.settings.SettingsValues;
@ -571,9 +570,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
mClipboardHistoryView.setKeyboardActionListener(mLatinIME); mClipboardHistoryView.setKeyboardActionListener(mLatinIME);
// set background color here, otherwise there is a narrow white line between keyboard and suggestion strip // set background color here, otherwise there is a narrow white line between keyboard and suggestion strip
final Colors colors = Settings.getInstance().getCurrent().mColors; mKeyboardViewWrapper.getBackground().setColorFilter(Settings.getInstance().getCurrent().mColors.backgroundFilter);
if (colors.isCustom)
mKeyboardViewWrapper.getBackground().setColorFilter(colors.backgroundFilter);
return mCurrentInputView; return mCurrentInputView;
} }

View file

@ -176,7 +176,6 @@ public class KeyboardView extends View {
mPaint.setAntiAlias(true); mPaint.setAntiAlias(true);
mColors = Settings.getInstance().getCurrent().mColors; mColors = Settings.getInstance().getCurrent().mColors;
if (mColors.isCustom) {
final Class<?> c = this.getClass(); final Class<?> c = this.getClass();
if (c == MoreKeysKeyboardView.class) { if (c == MoreKeysKeyboardView.class) {
mColors.setBackgroundColor(mKeyBackground, Colors.TYPE_ADJUSTED_BACKGROUND); mColors.setBackgroundColor(mKeyBackground, Colors.TYPE_ADJUSTED_BACKGROUND);
@ -193,7 +192,6 @@ public class KeyboardView extends View {
else else
getBackground().setColorFilter(mColors.backgroundFilter); getBackground().setColorFilter(mColors.backgroundFilter);
} }
}
@Nullable @Nullable
public KeyVisualAttributes getKeyVisualAttribute() { public KeyVisualAttributes getKeyVisualAttribute() {
@ -446,9 +444,6 @@ public class KeyboardView extends View {
} }
if (key.isEnabled()) { if (key.isEnabled()) {
if (mColors.isCustom)
paint.setColor(mColors.keyText);
else
paint.setColor(key.selectTextColor(params)); paint.setColor(key.selectTextColor(params));
// Set a drop shadow for the text if the shadow radius is positive value. // Set a drop shadow for the text if the shadow radius is positive value.
if (mKeyTextShadowRadius > 0.0f) { if (mKeyTextShadowRadius > 0.0f) {
@ -472,9 +467,6 @@ public class KeyboardView extends View {
final String hintLabel = key.getHintLabel(); final String hintLabel = key.getHintLabel();
if (hintLabel != null && mShowsHints) { if (hintLabel != null && mShowsHints) {
paint.setTextSize(key.selectHintTextSize(params)); paint.setTextSize(key.selectHintTextSize(params));
if (mColors.isCustom)
paint.setColor(mColors.keyHintText);
else
paint.setColor(key.selectHintTextColor(params)); paint.setColor(key.selectHintTextColor(params));
// TODO: Should add a way to specify type face for hint letters // TODO: Should add a way to specify type face for hint letters
paint.setTypeface(Typeface.DEFAULT_BOLD); paint.setTypeface(Typeface.DEFAULT_BOLD);
@ -528,10 +520,7 @@ public class KeyboardView extends View {
iconY = (keyHeight - iconHeight) / 2; // Align vertically center. iconY = (keyHeight - iconHeight) / 2; // Align vertically center.
} }
final int iconX = (keyWidth - iconWidth) / 2; // Align horizontally center. final int iconX = (keyWidth - iconWidth) / 2; // Align horizontally center.
if (mColors.isCustom) setKeyIconColor(key, icon, keyboard);
setCustomKeyIconColor(key, icon, keyboard);
else
icon.clearColorFilter();
drawIcon(canvas, icon, iconX, iconY, iconWidth, iconHeight); drawIcon(canvas, icon, iconX, iconY, iconWidth, iconHeight);
} }
@ -620,7 +609,7 @@ public class KeyboardView extends View {
freeOffscreenBuffer(); freeOffscreenBuffer();
} }
private void setCustomKeyIconColor(Key key, Drawable icon, Keyboard keyboard) { private void setKeyIconColor(Key key, Drawable icon, Keyboard keyboard) {
if (key.isAccentColored()) { if (key.isAccentColored()) {
icon.setColorFilter(mColors.actionKeyIconColorFilter); icon.setColorFilter(mColors.actionKeyIconColorFilter);
} else if (key.isShift() && keyboard != null) { } else if (key.isShift() && keyboard != null) {

View file

@ -52,7 +52,6 @@ import org.dslul.openboard.inputmethod.keyboard.internal.TimerHandler;
import org.dslul.openboard.inputmethod.latin.R; import org.dslul.openboard.inputmethod.latin.R;
import org.dslul.openboard.inputmethod.latin.RichInputMethodSubtype; import org.dslul.openboard.inputmethod.latin.RichInputMethodSubtype;
import org.dslul.openboard.inputmethod.latin.SuggestedWords; import org.dslul.openboard.inputmethod.latin.SuggestedWords;
import org.dslul.openboard.inputmethod.latin.common.Colors;
import org.dslul.openboard.inputmethod.latin.common.Constants; import org.dslul.openboard.inputmethod.latin.common.Constants;
import org.dslul.openboard.inputmethod.latin.common.CoordinateUtils; import org.dslul.openboard.inputmethod.latin.common.CoordinateUtils;
import org.dslul.openboard.inputmethod.latin.settings.DebugSettings; import org.dslul.openboard.inputmethod.latin.settings.DebugSettings;
@ -217,10 +216,7 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
mBackgroundDimAlphaPaint.setAlpha(backgroundDimAlpha); mBackgroundDimAlphaPaint.setAlpha(backgroundDimAlpha);
mLanguageOnSpacebarTextRatio = mainKeyboardViewAttr.getFraction( mLanguageOnSpacebarTextRatio = mainKeyboardViewAttr.getFraction(
R.styleable.MainKeyboardView_languageOnSpacebarTextRatio, 1, 1, 1.0f); R.styleable.MainKeyboardView_languageOnSpacebarTextRatio, 1, 1, 1.0f);
final Colors colors = Settings.getInstance().getCurrent().mColors; mLanguageOnSpacebarTextColor = Settings.getInstance().getCurrent().mColors.keyHintText; //mainKeyboardViewAttr.getColor(R.styleable.MainKeyboardView_languageOnSpacebarTextColor, 0);
mLanguageOnSpacebarTextColor = colors.isCustom
? colors.keyHintText
: mainKeyboardViewAttr.getColor(R.styleable.MainKeyboardView_languageOnSpacebarTextColor, 0);
mLanguageOnSpacebarTextShadowRadius = mainKeyboardViewAttr.getFloat( mLanguageOnSpacebarTextShadowRadius = mainKeyboardViewAttr.getFloat(
R.styleable.MainKeyboardView_languageOnSpacebarTextShadowRadius, R.styleable.MainKeyboardView_languageOnSpacebarTextShadowRadius,
LANGUAGE_ON_SPACEBAR_TEXT_SHADOW_RADIUS_DISABLED); LANGUAGE_ON_SPACEBAR_TEXT_SHADOW_RADIUS_DISABLED);

View file

@ -55,10 +55,7 @@ class ClipboardAdapter(
setOnTouchListener(this@ViewHolder) setOnTouchListener(this@ViewHolder)
setOnLongClickListener(this@ViewHolder) setOnLongClickListener(this@ViewHolder)
setBackgroundResource(itemBackgroundId) setBackgroundResource(itemBackgroundId)
val colors = Settings.getInstance().current.mColors Settings.getInstance().current.mColors.setBackgroundColor(background, Colors.TYPE_KEY)
if (colors.isCustom) {
colors.setBackgroundColor(background, Colors.TYPE_KEY)
}
} }
pinnedIconView = view.findViewById<ImageView>(R.id.clipboard_entry_pinned_icon).apply { pinnedIconView = view.findViewById<ImageView>(R.id.clipboard_entry_pinned_icon).apply {
visibility = View.GONE visibility = View.GONE

View file

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

View file

@ -102,23 +102,15 @@ class ClipboardHistoryView @JvmOverloads constructor(
setOnClickListener(this@ClipboardHistoryView) setOnClickListener(this@ClipboardHistoryView)
} }
val colors = Settings.getInstance().current.mColors val colors = Settings.getInstance().current.mColors
if (colors.isCustom) {
alphabetKey.background.colorFilter = colors.functionalKeyBackgroundFilter
alphabetKey.setTextColor(colors.keyText)
clearKey.colorFilter = colors.keyTextFilter clearKey.colorFilter = colors.keyTextFilter
background.colorFilter = colors.backgroundFilter background.colorFilter = colors.backgroundFilter
} }
}
private fun setupAlphabetKey(key: TextView?, label: String, params: KeyDrawParams) { private fun setupAlphabetKey(key: TextView?, label: String, params: KeyDrawParams) {
key?.apply { key?.apply {
text = label text = label
typeface = params.mTypeface typeface = params.mTypeface
val colors = Settings.getInstance().current.mColors Settings.getInstance().current.mColors.setBackgroundColor(this.background, Colors.TYPE_FUNCTIONAL)
if (colors.isCustom) {
setTextColor(colors.keyText)
colors.setBackgroundColor(this.background, Colors.TYPE_FUNCTIONAL)
} else
setTextColor(params.mFunctionalTextColor) setTextColor(params.mFunctionalTextColor)
setTextSize(TypedValue.COMPLEX_UNIT_PX, params.mLabelSize.toFloat()) setTextSize(TypedValue.COMPLEX_UNIT_PX, params.mLabelSize.toFloat())
} }
@ -128,11 +120,7 @@ class ClipboardHistoryView @JvmOverloads constructor(
clipboardAdapter.apply { clipboardAdapter.apply {
itemBackgroundId = keyBackgroundId itemBackgroundId = keyBackgroundId
itemTypeFace = params.mTypeface itemTypeFace = params.mTypeface
val colors = Settings.getInstance().current.mColors itemTextColor = params.mTextColor
itemTextColor = if (colors.isCustom)
colors.keyText
else
params.mTextColor
itemTextSize = params.mLabelSize.toFloat() itemTextSize = params.mLabelSize.toFloat()
} }
} }

View file

@ -33,7 +33,6 @@ import android.widget.TabWidget;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.core.graphics.drawable.DrawableCompat;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import org.dslul.openboard.inputmethod.compat.TabHostCompat; import org.dslul.openboard.inputmethod.compat.TabHostCompat;
@ -134,8 +133,7 @@ public final class EmojiPalettesView extends LinearLayout
R.styleable.EmojiPalettesView_categoryIndicatorBackground, 0); R.styleable.EmojiPalettesView_categoryIndicatorBackground, 0);
mCategoryPageIndicatorColor = emojiPalettesViewAttr.getColor( mCategoryPageIndicatorColor = emojiPalettesViewAttr.getColor(
R.styleable.EmojiPalettesView_categoryPageIndicatorColor, 0); R.styleable.EmojiPalettesView_categoryPageIndicatorColor, 0);
mCategoryPageIndicatorBackground = emojiPalettesViewAttr.getColor( mCategoryPageIndicatorBackground = Settings.getInstance().getCurrent().mColors.adjustedBackground; //emojiPalettesViewAttr.getColor(R.styleable.EmojiPalettesView_categoryPageIndicatorBackground, 0);
R.styleable.EmojiPalettesView_categoryPageIndicatorBackground, 0);
emojiPalettesViewAttr.recycle(); emojiPalettesViewAttr.recycle();
mDeleteKeyOnTouchListener = new DeleteKeyOnTouchListener(); mDeleteKeyOnTouchListener = new DeleteKeyOnTouchListener();
mEmojiLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false); mEmojiLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false);
@ -163,11 +161,7 @@ public final class EmojiPalettesView extends LinearLayout
// TODO: Replace background color with its own setting rather than using the // TODO: Replace background color with its own setting rather than using the
// category page indicator background as a workaround. // category page indicator background as a workaround.
iconView.setBackgroundColor(mCategoryPageIndicatorBackground); iconView.setBackgroundColor(mCategoryPageIndicatorBackground);
final Colors colors = Settings.getInstance().getCurrent().mColors; iconView.setColorFilter(Settings.getInstance().getCurrent().mColors.keyTextFilter);
if (colors.isCustom) {
iconView.getBackground().setColorFilter(colors.adjustedBackgroundFilter);
iconView.setColorFilter(colors.keyTextFilter);
}
iconView.setImageResource(mEmojiCategory.getCategoryTabIcon(categoryId)); iconView.setImageResource(mEmojiCategory.getCategoryTabIcon(categoryId));
iconView.setContentDescription(mEmojiCategory.getAccessibilityDescription(categoryId)); iconView.setContentDescription(mEmojiCategory.getAccessibilityDescription(categoryId));
tspec.setIndicator(iconView); tspec.setIndicator(iconView);
@ -274,14 +268,12 @@ public final class EmojiPalettesView extends LinearLayout
mSpacebarIcon = findViewById(R.id.emoji_keyboard_space_icon); mSpacebarIcon = findViewById(R.id.emoji_keyboard_space_icon);
final Colors colors = Settings.getInstance().getCurrent().mColors; final Colors colors = Settings.getInstance().getCurrent().mColors;
if (colors.isCustom) {
colors.setBackgroundColor(mAlphabetKeyLeft.getBackground(), Colors.TYPE_FUNCTIONAL); colors.setBackgroundColor(mAlphabetKeyLeft.getBackground(), Colors.TYPE_FUNCTIONAL);
colors.setBackgroundColor(mDeleteKey.getBackground(), Colors.TYPE_FUNCTIONAL); colors.setBackgroundColor(mDeleteKey.getBackground(), Colors.TYPE_FUNCTIONAL);
colors.setBackgroundColor(mSpacebar.getBackground(), Colors.TYPE_SPACE); colors.setBackgroundColor(mSpacebar.getBackground(), Colors.TYPE_SPACE);
getBackground().setColorFilter(colors.backgroundFilter); getBackground().setColorFilter(colors.backgroundFilter);
mEmojiCategoryPageIndicatorView.setColors(colors.accent, colors.adjustedBackground); mEmojiCategoryPageIndicatorView.setColors(colors.accent, colors.adjustedBackground);
} }
}
@Override @Override
public boolean dispatchTouchEvent(final MotionEvent ev) { public boolean dispatchTouchEvent(final MotionEvent ev) {
@ -301,14 +293,12 @@ public final class EmojiPalettesView extends LinearLayout
updateEmojiCategoryPageIdView(); updateEmojiCategoryPageIdView();
} }
final Colors colors = Settings.getInstance().getCurrent().mColors; final Colors colors = Settings.getInstance().getCurrent().mColors;
if (colors.isCustom) {
if (mCurrentTab != null) if (mCurrentTab != null)
mCurrentTab.setColorFilter(colors.keyTextFilter); mCurrentTab.setColorFilter(colors.keyTextFilter);
mCurrentTab = (ImageView) mTabHost.getCurrentTabView(); mCurrentTab = (ImageView) mTabHost.getCurrentTabView();
// mCurrentTab.setColorFilter(colors.accentColorFilter); // todo (later): doesn't work properly, because enabled drawable is blue -> adjust // mCurrentTab.setColorFilter(colors.accentColorFilter); // todo (later): doesn't work properly, because enabled drawable is blue -> adjust
mCurrentTab.setColorFilter(colors.accent); mCurrentTab.setColorFilter(colors.accent);
} }
}
/** /**
* Called from {@link EmojiPageKeyboardView} through {@link android.view.View.OnTouchListener} * Called from {@link EmojiPageKeyboardView} through {@link android.view.View.OnTouchListener}
@ -391,10 +381,6 @@ public final class EmojiPalettesView extends LinearLayout
private static void setupAlphabetKey(final TextView alphabetKey, final String label, private static void setupAlphabetKey(final TextView alphabetKey, final String label,
final KeyDrawParams params) { final KeyDrawParams params) {
alphabetKey.setText(label); alphabetKey.setText(label);
final Colors colors = Settings.getInstance().getCurrent().mColors;
if (colors.isCustom)
alphabetKey.setTextColor(colors.keyText);
else
alphabetKey.setTextColor(params.mFunctionalTextColor); alphabetKey.setTextColor(params.mFunctionalTextColor);
alphabetKey.setTextSize(TypedValue.COMPLEX_UNIT_PX, params.mLabelSize); alphabetKey.setTextSize(TypedValue.COMPLEX_UNIT_PX, params.mLabelSize);
alphabetKey.setTypeface(params.mTypeface); alphabetKey.setTypeface(params.mTypeface);

View file

@ -65,14 +65,10 @@ public class GestureFloatingTextDrawingPreview extends AbstractDrawingPreview {
final Colors colors = Settings.getInstance().getCurrent().mColors; final Colors colors = Settings.getInstance().getCurrent().mColors;
mGesturePreviewTextSize = mainKeyboardViewAttr.getDimensionPixelSize( mGesturePreviewTextSize = mainKeyboardViewAttr.getDimensionPixelSize(
R.styleable.MainKeyboardView_gestureFloatingPreviewTextSize, 0); R.styleable.MainKeyboardView_gestureFloatingPreviewTextSize, 0);
mGesturePreviewTextColor = colors.isCustom mGesturePreviewTextColor = colors.keyText; //mainKeyboardViewAttr.getColor(R.styleable.MainKeyboardView_gestureFloatingPreviewTextColor, 0);
? colors.keyText
: mainKeyboardViewAttr.getColor(R.styleable.MainKeyboardView_gestureFloatingPreviewTextColor, 0);
mGesturePreviewTextOffset = mainKeyboardViewAttr.getDimensionPixelOffset( mGesturePreviewTextOffset = mainKeyboardViewAttr.getDimensionPixelOffset(
R.styleable.MainKeyboardView_gestureFloatingPreviewTextOffset, 0); R.styleable.MainKeyboardView_gestureFloatingPreviewTextOffset, 0);
mGesturePreviewColor = colors.isCustom mGesturePreviewColor = colors.adjustedBackground; //mainKeyboardViewAttr.getColor(R.styleable.MainKeyboardView_gestureFloatingPreviewColor, 0);
? colors.background
: mainKeyboardViewAttr.getColor(R.styleable.MainKeyboardView_gestureFloatingPreviewColor, 0);
mGesturePreviewHorizontalPadding = mainKeyboardViewAttr.getDimension( mGesturePreviewHorizontalPadding = mainKeyboardViewAttr.getDimension(
R.styleable.MainKeyboardView_gestureFloatingPreviewHorizontalPadding, 0.0f); R.styleable.MainKeyboardView_gestureFloatingPreviewHorizontalPadding, 0.0f);
mGesturePreviewVerticalPadding = mainKeyboardViewAttr.getDimension( mGesturePreviewVerticalPadding = mainKeyboardViewAttr.getDimension(

View file

@ -52,9 +52,7 @@ final class GestureTrailDrawingParams {
public final int mTrailLingerDuration; public final int mTrailLingerDuration;
public GestureTrailDrawingParams(final TypedArray mainKeyboardViewAttr) { public GestureTrailDrawingParams(final TypedArray mainKeyboardViewAttr) {
final Colors colors = Settings.getInstance().getCurrent().mColors; mTrailColor = Settings.getInstance().getCurrent().mColors.accent; //mainKeyboardViewAttr.getColor(R.styleable.MainKeyboardView_gestureTrailColor, 0);
mTrailColor = colors.isCustom ? colors.accent : mainKeyboardViewAttr.getColor(
R.styleable.MainKeyboardView_gestureTrailColor, 0);
mTrailStartWidth = mainKeyboardViewAttr.getDimension( mTrailStartWidth = mainKeyboardViewAttr.getDimension(
R.styleable.MainKeyboardView_gestureTrailStartWidth, 0.0f); R.styleable.MainKeyboardView_gestureTrailStartWidth, 0.0f);
mTrailEndWidth = mainKeyboardViewAttr.getDimension( mTrailEndWidth = mainKeyboardViewAttr.getDimension(

View file

@ -87,8 +87,7 @@ public final class KeyPreviewChoreographer {
final KeyDrawParams drawParams, final int keyboardViewWidth, final int[] keyboardOrigin, final KeyDrawParams drawParams, final int keyboardViewWidth, final int[] keyboardOrigin,
final ViewGroup placerView) { final ViewGroup placerView) {
final KeyPreviewView keyPreviewView = getKeyPreviewView(key, placerView); final KeyPreviewView keyPreviewView = getKeyPreviewView(key, placerView);
placeKeyPreview( placeKeyPreview(key, keyPreviewView, iconsSet, drawParams, keyboardViewWidth, keyboardOrigin);
key, keyPreviewView, iconsSet, drawParams, keyboardViewWidth, keyboardOrigin);
showKeyPreview(key, keyPreviewView); showKeyPreview(key, keyPreviewView);
} }
@ -96,8 +95,7 @@ public final class KeyPreviewChoreographer {
final KeyboardIconsSet iconsSet, final KeyDrawParams drawParams, final KeyboardIconsSet iconsSet, final KeyDrawParams drawParams,
final int keyboardViewWidth, final int[] originCoords) { final int keyboardViewWidth, final int[] originCoords) {
keyPreviewView.setPreviewVisual(key, iconsSet, drawParams); keyPreviewView.setPreviewVisual(key, iconsSet, drawParams);
keyPreviewView.measure( keyPreviewView.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
mParams.setGeometry(keyPreviewView); mParams.setGeometry(keyPreviewView);
final int previewWidth = keyPreviewView.getMeasuredWidth(); final int previewWidth = keyPreviewView.getMeasuredWidth();
final int previewHeight = mParams.mPreviewHeight; final int previewHeight = mParams.mPreviewHeight;
@ -120,10 +118,7 @@ public final class KeyPreviewChoreographer {
final boolean hasMoreKeys = (key.getMoreKeys() != null); final boolean hasMoreKeys = (key.getMoreKeys() != null);
keyPreviewView.setPreviewBackground(hasMoreKeys, keyPreviewPosition); keyPreviewView.setPreviewBackground(hasMoreKeys, keyPreviewPosition);
final Colors colors = Settings.getInstance().getCurrent().mColors; final Colors colors = Settings.getInstance().getCurrent().mColors;
if (colors.isCustom) { keyPreviewView.getBackground().setColorFilter(colors.adjustedBackgroundFilter);
keyPreviewView.getBackground().setColorFilter(colors.backgroundFilter);
keyPreviewView.setTextColor(colors.keyText);
}
// The key preview is placed vertically above the top edge of the parent key with an // The key preview is placed vertically above the top edge of the parent key with an
// arbitrary offset. // arbitrary offset.
final int previewY = key.getY() - previewHeight + key.getHeight() - mParams.mPreviewOffset final int previewY = key.getY() - previewHeight + key.getHeight() - mParams.mPreviewOffset

View file

@ -21,6 +21,8 @@ import android.graphics.Typeface;
import android.util.SparseIntArray; import android.util.SparseIntArray;
import org.dslul.openboard.inputmethod.latin.R; import org.dslul.openboard.inputmethod.latin.R;
import org.dslul.openboard.inputmethod.latin.common.Colors;
import org.dslul.openboard.inputmethod.latin.settings.Settings;
import org.dslul.openboard.inputmethod.latin.utils.ResourceUtils; import org.dslul.openboard.inputmethod.latin.utils.ResourceUtils;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@ -125,18 +127,20 @@ public final class KeyVisualAttributes {
mPreviewTextRatio = ResourceUtils.getFraction(keyAttr, mPreviewTextRatio = ResourceUtils.getFraction(keyAttr,
R.styleable.Keyboard_Key_keyPreviewTextRatio); R.styleable.Keyboard_Key_keyPreviewTextRatio);
mTextColor = keyAttr.getColor(R.styleable.Keyboard_Key_keyTextColor, 0); final Colors colors = Settings.getInstance().getCurrent().mColors;
mTextInactivatedColor = keyAttr.getColor( mTextColor = colors.keyText; //keyAttr.getColor(R.styleable.Keyboard_Key_keyTextColor, 0);
R.styleable.Keyboard_Key_keyTextInactivatedColor, 0); mTextInactivatedColor = keyAttr.getColor(R.styleable.Keyboard_Key_keyTextInactivatedColor, 0);
mTextShadowColor = keyAttr.getColor(R.styleable.Keyboard_Key_keyTextShadowColor, 0); mTextShadowColor = keyAttr.getColor(R.styleable.Keyboard_Key_keyTextShadowColor, 0);
mFunctionalTextColor = keyAttr.getColor(R.styleable.Keyboard_Key_functionalTextColor, 0); // todo: maybe a separate color?
mHintLetterColor = keyAttr.getColor(R.styleable.Keyboard_Key_keyHintLetterColor, 0); mFunctionalTextColor = colors.keyText; //keyAttr.getColor(R.styleable.Keyboard_Key_functionalTextColor, 0);
mHintLabelColor = keyAttr.getColor(R.styleable.Keyboard_Key_keyHintLabelColor, 0); mHintLetterColor = colors.keyHintText; //keyAttr.getColor(R.styleable.Keyboard_Key_keyHintLetterColor, 0);
mHintLabelColor = colors.keyHintText; //keyAttr.getColor(R.styleable.Keyboard_Key_keyHintLabelColor, 0);
mShiftedLetterHintInactivatedColor = keyAttr.getColor( mShiftedLetterHintInactivatedColor = keyAttr.getColor(
R.styleable.Keyboard_Key_keyShiftedLetterHintInactivatedColor, 0); R.styleable.Keyboard_Key_keyShiftedLetterHintInactivatedColor, 0);
mShiftedLetterHintActivatedColor = keyAttr.getColor( mShiftedLetterHintActivatedColor = keyAttr.getColor(
R.styleable.Keyboard_Key_keyShiftedLetterHintActivatedColor, 0); R.styleable.Keyboard_Key_keyShiftedLetterHintActivatedColor, 0);
mPreviewTextColor = keyAttr.getColor(R.styleable.Keyboard_Key_keyPreviewTextColor, 0); // todo: maybe a separate color?
mPreviewTextColor = colors.keyText; //keyAttr.getColor(R.styleable.Keyboard_Key_keyPreviewTextColor, 0);
mHintLabelVerticalAdjustment = ResourceUtils.getFraction(keyAttr, mHintLabelVerticalAdjustment = ResourceUtils.getFraction(keyAttr,
R.styleable.Keyboard_Key_keyHintLabelVerticalAdjustment, 0.0f); R.styleable.Keyboard_Key_keyHintLabelVerticalAdjustment, 0.0f);

View file

@ -23,7 +23,6 @@ import android.graphics.Path;
import org.dslul.openboard.inputmethod.keyboard.PointerTracker; import org.dslul.openboard.inputmethod.keyboard.PointerTracker;
import org.dslul.openboard.inputmethod.latin.R; import org.dslul.openboard.inputmethod.latin.R;
import org.dslul.openboard.inputmethod.latin.common.Colors;
import org.dslul.openboard.inputmethod.latin.common.CoordinateUtils; import org.dslul.openboard.inputmethod.latin.common.CoordinateUtils;
import org.dslul.openboard.inputmethod.latin.settings.Settings; import org.dslul.openboard.inputmethod.latin.settings.Settings;
@ -47,10 +46,7 @@ public final class SlidingKeyInputDrawingPreview extends AbstractDrawingPreview
private final Paint mPaint = new Paint(); private final Paint mPaint = new Paint();
public SlidingKeyInputDrawingPreview(final TypedArray mainKeyboardViewAttr) { public SlidingKeyInputDrawingPreview(final TypedArray mainKeyboardViewAttr) {
final Colors colors = Settings.getInstance().getCurrent().mColors; final int previewColor = Settings.getInstance().getCurrent().mColors.accent; //mainKeyboardViewAttr.getColor(R.styleable.MainKeyboardView_slidingKeyInputPreviewColor, 0);
final int previewColor = colors.isCustom
? colors.accent
: mainKeyboardViewAttr.getColor(R.styleable.MainKeyboardView_slidingKeyInputPreviewColor, 0);
final float previewRadius = mainKeyboardViewAttr.getDimension( final float previewRadius = mainKeyboardViewAttr.getDimension(
R.styleable.MainKeyboardView_slidingKeyInputPreviewWidth, 0) / 2.0f; R.styleable.MainKeyboardView_slidingKeyInputPreviewWidth, 0) / 2.0f;
final int PERCENTAGE_INT = 100; final int PERCENTAGE_INT = 100;

View file

@ -54,11 +54,9 @@ class KeyboardWrapperView @JvmOverloads constructor(
switchOneHandedModeBtn.setOnClickListener(this) switchOneHandedModeBtn.setOnClickListener(this)
val colors = Settings.getInstance().current.mColors val colors = Settings.getInstance().current.mColors
if (colors.isCustom) {
stopOneHandedModeBtn.colorFilter = colors.keyTextFilter stopOneHandedModeBtn.colorFilter = colors.keyTextFilter
switchOneHandedModeBtn.colorFilter = colors.keyTextFilter switchOneHandedModeBtn.colorFilter = colors.keyTextFilter
} }
}
@SuppressLint("RtlHardcoded") @SuppressLint("RtlHardcoded")
fun switchOneHandedModeSide() { fun switchOneHandedModeSide() {

View file

@ -15,7 +15,6 @@ import androidx.core.graphics.drawable.DrawableCompat;
// todo: maybe kotlin? would make it much shorter and more readable // todo: maybe kotlin? would make it much shorter and more readable
public class Colors { public class Colors {
public final boolean isCustom;
public final int navBar; public final int navBar;
public final int accent; public final int accent;
public final int background; public final int background;
@ -44,7 +43,6 @@ public class Colors {
private ColorStateList adjustedBackgroundStateList; private ColorStateList adjustedBackgroundStateList;
public Colors(int _accent, int _background, int _keyBackground, int _functionalKey, int _spaceBar, int _keyText, int _keyHintText) { public Colors(int _accent, int _background, int _keyBackground, int _functionalKey, int _spaceBar, int _keyText, int _keyHintText) {
isCustom = true;
accent = _accent; accent = _accent;
background = _background; background = _background;
keyBackground = _keyBackground; keyBackground = _keyBackground;
@ -55,20 +53,6 @@ public class Colors {
navBar = background; navBar = background;
} }
// todo (later): remove this and isCustom, once the old themes can be completely replaced
// for now there are the holo themes left, which don't require any of themeId and isNight
public Colors(int themeId, final boolean isNight) {
isCustom = false;
navBar = Color.BLACK;
accent = 0;
background = 0;
keyBackground = 0;
functionalKey = 0;
spaceBar = 0;
keyText = 0;
keyHintText = 0;
}
/** set background colors including state list to the drawable */ /** set background colors including state list to the drawable */
// todo: this can be used for setting more complicated filters // todo: this can be used for setting more complicated filters
// may be necessary for reproducing holo theme (extend Colors and override this in sth like HoloColors?) // may be necessary for reproducing holo theme (extend Colors and override this in sth like HoloColors?)

View file

@ -574,15 +574,8 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
} }
public static Colors getColors(final Context context, final SharedPreferences prefs) { public static Colors getColors(final Context context, final SharedPreferences prefs) {
final int keyboardThemeId = KeyboardTheme.getThemeForParameters(
prefs.getString(Settings.PREF_THEME_FAMILY, ""),
prefs.getString(Settings.PREF_THEME_VARIANT, ""),
prefs.getBoolean(Settings.PREF_THEME_KEY_BORDERS, false)
);
// todo: night mode can be unspecified -> maybe need to adjust for correct behavior on some devices? // todo: night mode can be unspecified -> maybe need to adjust for correct behavior on some devices?
final boolean isNight = (context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES; final boolean isNight = (context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES;
if (!KeyboardTheme.getIsCustom(keyboardThemeId))
return new Colors(keyboardThemeId, isNight);
if (isNight && prefs.getBoolean(Settings.PREF_THEME_DAY_NIGHT, false)) if (isNight && prefs.getBoolean(Settings.PREF_THEME_DAY_NIGHT, false))
return KeyboardTheme.getCustomTheme(prefs.getString(Settings.PREF_CUSTOM_THEME_VARIANT_NIGHT, KeyboardTheme.THEME_DARKER), context, prefs); return KeyboardTheme.getCustomTheme(prefs.getString(Settings.PREF_CUSTOM_THEME_VARIANT_NIGHT, KeyboardTheme.THEME_DARKER), context, prefs);

View file

@ -131,17 +131,10 @@ final class SuggestionStripLayoutHelper {
R.styleable.SuggestionStripView_alphaObsoleted, 1.0f); R.styleable.SuggestionStripView_alphaObsoleted, 1.0f);
final Colors colors = Settings.getInstance().getCurrent().mColors; final Colors colors = Settings.getInstance().getCurrent().mColors;
if (colors.isCustom) { mColorValidTypedWord = colors.adjustedKeyText; //a.getColor(R.styleable.SuggestionStripView_colorValidTypedWord, 0);
mColorValidTypedWord = colors.adjustedKeyText; mColorTypedWord = colors.adjustedKeyText; //a.getColor(R.styleable.SuggestionStripView_colorTypedWord, 0);
mColorTypedWord = colors.adjustedKeyText; mColorAutoCorrect = colors.keyText; //a.getColor(R.styleable.SuggestionStripView_colorAutoCorrect, 0);
mColorAutoCorrect = colors.keyText; mColorSuggested = colors.adjustedKeyText; //a.getColor(R.styleable.SuggestionStripView_colorSuggested, 0);
mColorSuggested = colors.adjustedKeyText;
} else {
mColorValidTypedWord = a.getColor(R.styleable.SuggestionStripView_colorValidTypedWord, 0);
mColorTypedWord = a.getColor(R.styleable.SuggestionStripView_colorTypedWord, 0);
mColorAutoCorrect = a.getColor(R.styleable.SuggestionStripView_colorAutoCorrect, 0);
mColorSuggested = a.getColor(R.styleable.SuggestionStripView_colorSuggested, 0);
}
mSuggestionsCountInStrip = a.getInt( mSuggestionsCountInStrip = a.getInt(
R.styleable.SuggestionStripView_suggestionsCountInStrip, R.styleable.SuggestionStripView_suggestionsCountInStrip,

View file

@ -59,7 +59,6 @@ import org.dslul.openboard.inputmethod.latin.utils.DialogUtils;
import java.util.ArrayList; import java.util.ArrayList;
import androidx.core.graphics.drawable.DrawableCompat;
import androidx.core.view.ViewCompat; import androidx.core.view.ViewCompat;
public final class SuggestionStripView extends RelativeLayout implements OnClickListener, public final class SuggestionStripView extends RelativeLayout implements OnClickListener,
@ -185,9 +184,8 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
mOtherKey.setImageDrawable(iconIncognito); mOtherKey.setImageDrawable(iconIncognito);
final Colors colors = Settings.getInstance().getCurrent().mColors; final Colors colors = Settings.getInstance().getCurrent().mColors;
if (colors.isCustom) { // this only works when backgrounds of SuggestionStripView.LXX_Base and SuggestionWord.LXX_Base
// this only works with backgrounds of SuggestionStripView.LXX_Base and SuggestionWord.LXX_Base // are set to keyboard_background_lxx_base (just white drawable), but NOT when set to
// set to keyboard_background_lxx_base (just white drawable), but NOT when set to
// btn_suggestion_lxx_base (state drawable with selector) or keyboard_suggest_strip_lxx_base_border (layer-list) // btn_suggestion_lxx_base (state drawable with selector) or keyboard_suggest_strip_lxx_base_border (layer-list)
// why is this? then it's necessary to set tint list for voice/clipboard/other keys and all word views separately // why is this? then it's necessary to set tint list for voice/clipboard/other keys and all word views separately
// it seems to work in other places, e.g. for btn_keyboard_spacebar_lxx_base... though maybe that's the weirdly nested layer list? // it seems to work in other places, e.g. for btn_keyboard_spacebar_lxx_base... though maybe that's the weirdly nested layer list?
@ -198,11 +196,6 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
mClipboardKey.setColorFilter(colors.keyText); mClipboardKey.setColorFilter(colors.keyText);
mVoiceKey.setColorFilter(colors.keyText); mVoiceKey.setColorFilter(colors.keyText);
mOtherKey.setColorFilter(colors.keyText); mOtherKey.setColorFilter(colors.keyText);
} else {
mClipboardKey.clearColorFilter();
mVoiceKey.clearColorFilter();
mOtherKey.clearColorFilter();
}
} }
/** /**