diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/KeyboardSwitcher.java b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/KeyboardSwitcher.java index 071bab618..8112f1cb0 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/KeyboardSwitcher.java +++ b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/KeyboardSwitcher.java @@ -40,7 +40,6 @@ import org.dslul.openboard.inputmethod.latin.LatinIME; import org.dslul.openboard.inputmethod.latin.R; import org.dslul.openboard.inputmethod.latin.RichInputMethodManager; 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.settings.Settings; import org.dslul.openboard.inputmethod.latin.settings.SettingsValues; @@ -571,9 +570,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { mClipboardHistoryView.setKeyboardActionListener(mLatinIME); // set background color here, otherwise there is a narrow white line between keyboard and suggestion strip - final Colors colors = Settings.getInstance().getCurrent().mColors; - if (colors.isCustom) - mKeyboardViewWrapper.getBackground().setColorFilter(colors.backgroundFilter); + mKeyboardViewWrapper.getBackground().setColorFilter(Settings.getInstance().getCurrent().mColors.backgroundFilter); return mCurrentInputView; } diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/KeyboardView.java b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/KeyboardView.java index e0046e127..dd666cd58 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/KeyboardView.java +++ b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/KeyboardView.java @@ -176,23 +176,21 @@ public class KeyboardView extends View { mPaint.setAntiAlias(true); mColors = Settings.getInstance().getCurrent().mColors; - if (mColors.isCustom) { - final Class c = this.getClass(); - if (c == MoreKeysKeyboardView.class) { - mColors.setBackgroundColor(mKeyBackground, Colors.TYPE_ADJUSTED_BACKGROUND); - } else if (c == EmojiPageKeyboardView.class || c == MoreSuggestionsView.class) { - mColors.setBackgroundColor(mKeyBackground, Colors.TYPE_BACKGROUND); - } else { - mColors.setBackgroundColor(mKeyBackground, Colors.TYPE_KEY); - } - mColors.setBackgroundColor(mActionKeyBackground, Colors.TYPE_ACTION); - mColors.setBackgroundColor(mSpacebarBackground, Colors.TYPE_SPACE); - mColors.setBackgroundColor(mFunctionalKeyBackground, Colors.TYPE_FUNCTIONAL); - if (this.getClass() == MoreKeysKeyboardView.class) - getBackground().setColorFilter(mColors.adjustedBackgroundFilter); - else - getBackground().setColorFilter(mColors.backgroundFilter); + final Class c = this.getClass(); + if (c == MoreKeysKeyboardView.class) { + mColors.setBackgroundColor(mKeyBackground, Colors.TYPE_ADJUSTED_BACKGROUND); + } else if (c == EmojiPageKeyboardView.class || c == MoreSuggestionsView.class) { + mColors.setBackgroundColor(mKeyBackground, Colors.TYPE_BACKGROUND); + } else { + mColors.setBackgroundColor(mKeyBackground, Colors.TYPE_KEY); } + mColors.setBackgroundColor(mActionKeyBackground, Colors.TYPE_ACTION); + mColors.setBackgroundColor(mSpacebarBackground, Colors.TYPE_SPACE); + mColors.setBackgroundColor(mFunctionalKeyBackground, Colors.TYPE_FUNCTIONAL); + if (this.getClass() == MoreKeysKeyboardView.class) + getBackground().setColorFilter(mColors.adjustedBackgroundFilter); + else + getBackground().setColorFilter(mColors.backgroundFilter); } @Nullable @@ -446,10 +444,7 @@ public class KeyboardView extends View { } 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. if (mKeyTextShadowRadius > 0.0f) { paint.setShadowLayer(mKeyTextShadowRadius, 0.0f, 0.0f, params.mTextShadowColor); @@ -472,10 +467,7 @@ public class KeyboardView extends View { final String hintLabel = key.getHintLabel(); if (hintLabel != null && mShowsHints) { 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 paint.setTypeface(Typeface.DEFAULT_BOLD); blendAlpha(paint, params.mAnimAlpha); @@ -528,10 +520,7 @@ public class KeyboardView extends View { iconY = (keyHeight - iconHeight) / 2; // Align vertically center. } final int iconX = (keyWidth - iconWidth) / 2; // Align horizontally center. - if (mColors.isCustom) - setCustomKeyIconColor(key, icon, keyboard); - else - icon.clearColorFilter(); + setKeyIconColor(key, icon, keyboard); drawIcon(canvas, icon, iconX, iconY, iconWidth, iconHeight); } @@ -620,7 +609,7 @@ public class KeyboardView extends View { freeOffscreenBuffer(); } - private void setCustomKeyIconColor(Key key, Drawable icon, Keyboard keyboard) { + private void setKeyIconColor(Key key, Drawable icon, Keyboard keyboard) { if (key.isAccentColored()) { icon.setColorFilter(mColors.actionKeyIconColorFilter); } else if (key.isShift() && keyboard != null) { diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/MainKeyboardView.java b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/MainKeyboardView.java index 63c90cdc7..a646b70fd 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/MainKeyboardView.java +++ b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/MainKeyboardView.java @@ -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.RichInputMethodSubtype; 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.CoordinateUtils; import org.dslul.openboard.inputmethod.latin.settings.DebugSettings; @@ -217,10 +216,7 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy mBackgroundDimAlphaPaint.setAlpha(backgroundDimAlpha); mLanguageOnSpacebarTextRatio = mainKeyboardViewAttr.getFraction( R.styleable.MainKeyboardView_languageOnSpacebarTextRatio, 1, 1, 1.0f); - final Colors colors = Settings.getInstance().getCurrent().mColors; - mLanguageOnSpacebarTextColor = colors.isCustom - ? colors.keyHintText - : mainKeyboardViewAttr.getColor(R.styleable.MainKeyboardView_languageOnSpacebarTextColor, 0); + mLanguageOnSpacebarTextColor = Settings.getInstance().getCurrent().mColors.keyHintText; //mainKeyboardViewAttr.getColor(R.styleable.MainKeyboardView_languageOnSpacebarTextColor, 0); mLanguageOnSpacebarTextShadowRadius = mainKeyboardViewAttr.getFloat( R.styleable.MainKeyboardView_languageOnSpacebarTextShadowRadius, LANGUAGE_ON_SPACEBAR_TEXT_SHADOW_RADIUS_DISABLED); diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/clipboard/ClipboardAdapter.kt b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/clipboard/ClipboardAdapter.kt index 52b5f69b7..7bd0017f6 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/clipboard/ClipboardAdapter.kt +++ b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/clipboard/ClipboardAdapter.kt @@ -55,10 +55,7 @@ class ClipboardAdapter( setOnTouchListener(this@ViewHolder) setOnLongClickListener(this@ViewHolder) setBackgroundResource(itemBackgroundId) - val colors = Settings.getInstance().current.mColors - if (colors.isCustom) { - colors.setBackgroundColor(background, Colors.TYPE_KEY) - } + Settings.getInstance().current.mColors.setBackgroundColor(background, Colors.TYPE_KEY) } pinnedIconView = view.findViewById(R.id.clipboard_entry_pinned_icon).apply { visibility = View.GONE diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/clipboard/ClipboardHistoryRecyclerView.kt b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/clipboard/ClipboardHistoryRecyclerView.kt index 1517276a6..150fc31ad 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/clipboard/ClipboardHistoryRecyclerView.kt +++ b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/clipboard/ClipboardHistoryRecyclerView.kt @@ -63,9 +63,7 @@ class ClipboardHistoryRecyclerView @JvmOverloads constructor( init { paint.color = dividerColor paint.strokeWidth = dividerHeight.toFloat() - val colors = Settings.getInstance().current.mColors - if (colors.isCustom) - paint.colorFilter = colors.backgroundFilter + paint.colorFilter = Settings.getInstance().current.mColors.backgroundFilter } override fun onDrawOver(canvas: Canvas, parent: RecyclerView, state: State) { diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/clipboard/ClipboardHistoryView.kt b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/clipboard/ClipboardHistoryView.kt index 1ebb47aff..4579b3d6a 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/clipboard/ClipboardHistoryView.kt +++ b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/clipboard/ClipboardHistoryView.kt @@ -102,24 +102,16 @@ class ClipboardHistoryView @JvmOverloads constructor( setOnClickListener(this@ClipboardHistoryView) } val colors = Settings.getInstance().current.mColors - if (colors.isCustom) { - alphabetKey.background.colorFilter = colors.functionalKeyBackgroundFilter - alphabetKey.setTextColor(colors.keyText) - clearKey.colorFilter = colors.keyTextFilter - background.colorFilter = colors.backgroundFilter - } + clearKey.colorFilter = colors.keyTextFilter + background.colorFilter = colors.backgroundFilter } private fun setupAlphabetKey(key: TextView?, label: String, params: KeyDrawParams) { key?.apply { text = label typeface = params.mTypeface - val colors = Settings.getInstance().current.mColors - if (colors.isCustom) { - setTextColor(colors.keyText) - colors.setBackgroundColor(this.background, Colors.TYPE_FUNCTIONAL) - } else - setTextColor(params.mFunctionalTextColor) + Settings.getInstance().current.mColors.setBackgroundColor(this.background, Colors.TYPE_FUNCTIONAL) + setTextColor(params.mFunctionalTextColor) setTextSize(TypedValue.COMPLEX_UNIT_PX, params.mLabelSize.toFloat()) } } @@ -128,11 +120,7 @@ class ClipboardHistoryView @JvmOverloads constructor( clipboardAdapter.apply { itemBackgroundId = keyBackgroundId itemTypeFace = params.mTypeface - val colors = Settings.getInstance().current.mColors - itemTextColor = if (colors.isCustom) - colors.keyText - else - params.mTextColor + itemTextColor = params.mTextColor itemTextSize = params.mLabelSize.toFloat() } } diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/emoji/EmojiPalettesView.java b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/emoji/EmojiPalettesView.java index 57d4978d4..3ccdf062d 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/emoji/EmojiPalettesView.java +++ b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/emoji/EmojiPalettesView.java @@ -33,7 +33,6 @@ import android.widget.TabWidget; import android.widget.TextView; import androidx.annotation.NonNull; -import androidx.core.graphics.drawable.DrawableCompat; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import org.dslul.openboard.inputmethod.compat.TabHostCompat; @@ -134,8 +133,7 @@ public final class EmojiPalettesView extends LinearLayout R.styleable.EmojiPalettesView_categoryIndicatorBackground, 0); mCategoryPageIndicatorColor = emojiPalettesViewAttr.getColor( R.styleable.EmojiPalettesView_categoryPageIndicatorColor, 0); - mCategoryPageIndicatorBackground = emojiPalettesViewAttr.getColor( - R.styleable.EmojiPalettesView_categoryPageIndicatorBackground, 0); + mCategoryPageIndicatorBackground = Settings.getInstance().getCurrent().mColors.adjustedBackground; //emojiPalettesViewAttr.getColor(R.styleable.EmojiPalettesView_categoryPageIndicatorBackground, 0); emojiPalettesViewAttr.recycle(); mDeleteKeyOnTouchListener = new DeleteKeyOnTouchListener(); 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 // category page indicator background as a workaround. iconView.setBackgroundColor(mCategoryPageIndicatorBackground); - final Colors colors = Settings.getInstance().getCurrent().mColors; - if (colors.isCustom) { - iconView.getBackground().setColorFilter(colors.adjustedBackgroundFilter); - iconView.setColorFilter(colors.keyTextFilter); - } + iconView.setColorFilter(Settings.getInstance().getCurrent().mColors.keyTextFilter); iconView.setImageResource(mEmojiCategory.getCategoryTabIcon(categoryId)); iconView.setContentDescription(mEmojiCategory.getAccessibilityDescription(categoryId)); tspec.setIndicator(iconView); @@ -274,13 +268,11 @@ public final class EmojiPalettesView extends LinearLayout mSpacebarIcon = findViewById(R.id.emoji_keyboard_space_icon); final Colors colors = Settings.getInstance().getCurrent().mColors; - if (colors.isCustom) { - colors.setBackgroundColor(mAlphabetKeyLeft.getBackground(), Colors.TYPE_FUNCTIONAL); - colors.setBackgroundColor(mDeleteKey.getBackground(), Colors.TYPE_FUNCTIONAL); - colors.setBackgroundColor(mSpacebar.getBackground(), Colors.TYPE_SPACE); - getBackground().setColorFilter(colors.backgroundFilter); - mEmojiCategoryPageIndicatorView.setColors(colors.accent, colors.adjustedBackground); - } + colors.setBackgroundColor(mAlphabetKeyLeft.getBackground(), Colors.TYPE_FUNCTIONAL); + colors.setBackgroundColor(mDeleteKey.getBackground(), Colors.TYPE_FUNCTIONAL); + colors.setBackgroundColor(mSpacebar.getBackground(), Colors.TYPE_SPACE); + getBackground().setColorFilter(colors.backgroundFilter); + mEmojiCategoryPageIndicatorView.setColors(colors.accent, colors.adjustedBackground); } @Override @@ -301,13 +293,11 @@ public final class EmojiPalettesView extends LinearLayout updateEmojiCategoryPageIdView(); } final Colors colors = Settings.getInstance().getCurrent().mColors; - if (colors.isCustom) { - if (mCurrentTab != null) - mCurrentTab.setColorFilter(colors.keyTextFilter); - mCurrentTab = (ImageView) mTabHost.getCurrentTabView(); -// mCurrentTab.setColorFilter(colors.accentColorFilter); // todo (later): doesn't work properly, because enabled drawable is blue -> adjust - mCurrentTab.setColorFilter(colors.accent); - } + if (mCurrentTab != null) + mCurrentTab.setColorFilter(colors.keyTextFilter); + mCurrentTab = (ImageView) mTabHost.getCurrentTabView(); +// mCurrentTab.setColorFilter(colors.accentColorFilter); // todo (later): doesn't work properly, because enabled drawable is blue -> adjust + mCurrentTab.setColorFilter(colors.accent); } /** @@ -391,11 +381,7 @@ public final class EmojiPalettesView extends LinearLayout private static void setupAlphabetKey(final TextView alphabetKey, final String label, final KeyDrawParams params) { 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.setTypeface(params.mTypeface); } diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/GestureFloatingTextDrawingPreview.java b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/GestureFloatingTextDrawingPreview.java index e9ef35c6a..83321ed47 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/GestureFloatingTextDrawingPreview.java +++ b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/GestureFloatingTextDrawingPreview.java @@ -65,14 +65,10 @@ public class GestureFloatingTextDrawingPreview extends AbstractDrawingPreview { final Colors colors = Settings.getInstance().getCurrent().mColors; mGesturePreviewTextSize = mainKeyboardViewAttr.getDimensionPixelSize( R.styleable.MainKeyboardView_gestureFloatingPreviewTextSize, 0); - mGesturePreviewTextColor = colors.isCustom - ? colors.keyText - : mainKeyboardViewAttr.getColor(R.styleable.MainKeyboardView_gestureFloatingPreviewTextColor, 0); + mGesturePreviewTextColor = colors.keyText; //mainKeyboardViewAttr.getColor(R.styleable.MainKeyboardView_gestureFloatingPreviewTextColor, 0); mGesturePreviewTextOffset = mainKeyboardViewAttr.getDimensionPixelOffset( R.styleable.MainKeyboardView_gestureFloatingPreviewTextOffset, 0); - mGesturePreviewColor = colors.isCustom - ? colors.background - : mainKeyboardViewAttr.getColor(R.styleable.MainKeyboardView_gestureFloatingPreviewColor, 0); + mGesturePreviewColor = colors.adjustedBackground; //mainKeyboardViewAttr.getColor(R.styleable.MainKeyboardView_gestureFloatingPreviewColor, 0); mGesturePreviewHorizontalPadding = mainKeyboardViewAttr.getDimension( R.styleable.MainKeyboardView_gestureFloatingPreviewHorizontalPadding, 0.0f); mGesturePreviewVerticalPadding = mainKeyboardViewAttr.getDimension( diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/GestureTrailDrawingParams.java b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/GestureTrailDrawingParams.java index ff5c06f8f..7ae5401fe 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/GestureTrailDrawingParams.java +++ b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/GestureTrailDrawingParams.java @@ -52,9 +52,7 @@ final class GestureTrailDrawingParams { public final int mTrailLingerDuration; public GestureTrailDrawingParams(final TypedArray mainKeyboardViewAttr) { - final Colors colors = Settings.getInstance().getCurrent().mColors; - mTrailColor = colors.isCustom ? colors.accent : mainKeyboardViewAttr.getColor( - R.styleable.MainKeyboardView_gestureTrailColor, 0); + mTrailColor = Settings.getInstance().getCurrent().mColors.accent; //mainKeyboardViewAttr.getColor(R.styleable.MainKeyboardView_gestureTrailColor, 0); mTrailStartWidth = mainKeyboardViewAttr.getDimension( R.styleable.MainKeyboardView_gestureTrailStartWidth, 0.0f); mTrailEndWidth = mainKeyboardViewAttr.getDimension( diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/KeyPreviewChoreographer.java b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/KeyPreviewChoreographer.java index 4ecaa0495..6a6afd4ea 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/KeyPreviewChoreographer.java +++ b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/KeyPreviewChoreographer.java @@ -87,8 +87,7 @@ public final class KeyPreviewChoreographer { final KeyDrawParams drawParams, final int keyboardViewWidth, final int[] keyboardOrigin, final ViewGroup placerView) { final KeyPreviewView keyPreviewView = getKeyPreviewView(key, placerView); - placeKeyPreview( - key, keyPreviewView, iconsSet, drawParams, keyboardViewWidth, keyboardOrigin); + placeKeyPreview(key, keyPreviewView, iconsSet, drawParams, keyboardViewWidth, keyboardOrigin); showKeyPreview(key, keyPreviewView); } @@ -96,8 +95,7 @@ public final class KeyPreviewChoreographer { final KeyboardIconsSet iconsSet, final KeyDrawParams drawParams, final int keyboardViewWidth, final int[] originCoords) { keyPreviewView.setPreviewVisual(key, iconsSet, drawParams); - keyPreviewView.measure( - ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); + keyPreviewView.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); mParams.setGeometry(keyPreviewView); final int previewWidth = keyPreviewView.getMeasuredWidth(); final int previewHeight = mParams.mPreviewHeight; @@ -120,10 +118,7 @@ public final class KeyPreviewChoreographer { final boolean hasMoreKeys = (key.getMoreKeys() != null); keyPreviewView.setPreviewBackground(hasMoreKeys, keyPreviewPosition); final Colors colors = Settings.getInstance().getCurrent().mColors; - if (colors.isCustom) { - keyPreviewView.getBackground().setColorFilter(colors.backgroundFilter); - keyPreviewView.setTextColor(colors.keyText); - } + keyPreviewView.getBackground().setColorFilter(colors.adjustedBackgroundFilter); // The key preview is placed vertically above the top edge of the parent key with an // arbitrary offset. final int previewY = key.getY() - previewHeight + key.getHeight() - mParams.mPreviewOffset diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/KeyVisualAttributes.java b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/KeyVisualAttributes.java index 9f51ae723..781940962 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/KeyVisualAttributes.java +++ b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/KeyVisualAttributes.java @@ -21,6 +21,8 @@ import android.graphics.Typeface; import android.util.SparseIntArray; 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 javax.annotation.Nonnull; @@ -125,18 +127,20 @@ public final class KeyVisualAttributes { mPreviewTextRatio = ResourceUtils.getFraction(keyAttr, R.styleable.Keyboard_Key_keyPreviewTextRatio); - mTextColor = keyAttr.getColor(R.styleable.Keyboard_Key_keyTextColor, 0); - mTextInactivatedColor = keyAttr.getColor( - R.styleable.Keyboard_Key_keyTextInactivatedColor, 0); + final Colors colors = Settings.getInstance().getCurrent().mColors; + mTextColor = colors.keyText; //keyAttr.getColor(R.styleable.Keyboard_Key_keyTextColor, 0); + mTextInactivatedColor = keyAttr.getColor(R.styleable.Keyboard_Key_keyTextInactivatedColor, 0); mTextShadowColor = keyAttr.getColor(R.styleable.Keyboard_Key_keyTextShadowColor, 0); - mFunctionalTextColor = keyAttr.getColor(R.styleable.Keyboard_Key_functionalTextColor, 0); - mHintLetterColor = keyAttr.getColor(R.styleable.Keyboard_Key_keyHintLetterColor, 0); - mHintLabelColor = keyAttr.getColor(R.styleable.Keyboard_Key_keyHintLabelColor, 0); + // todo: maybe a separate color? + mFunctionalTextColor = colors.keyText; //keyAttr.getColor(R.styleable.Keyboard_Key_functionalTextColor, 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( R.styleable.Keyboard_Key_keyShiftedLetterHintInactivatedColor, 0); mShiftedLetterHintActivatedColor = keyAttr.getColor( 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, R.styleable.Keyboard_Key_keyHintLabelVerticalAdjustment, 0.0f); diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/SlidingKeyInputDrawingPreview.java b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/SlidingKeyInputDrawingPreview.java index 1c1ace1e4..e62130a1c 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/SlidingKeyInputDrawingPreview.java +++ b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/SlidingKeyInputDrawingPreview.java @@ -23,7 +23,6 @@ import android.graphics.Path; import org.dslul.openboard.inputmethod.keyboard.PointerTracker; 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.settings.Settings; @@ -47,10 +46,7 @@ public final class SlidingKeyInputDrawingPreview extends AbstractDrawingPreview private final Paint mPaint = new Paint(); public SlidingKeyInputDrawingPreview(final TypedArray mainKeyboardViewAttr) { - final Colors colors = Settings.getInstance().getCurrent().mColors; - final int previewColor = colors.isCustom - ? colors.accent - : mainKeyboardViewAttr.getColor(R.styleable.MainKeyboardView_slidingKeyInputPreviewColor, 0); + final int previewColor = Settings.getInstance().getCurrent().mColors.accent; //mainKeyboardViewAttr.getColor(R.styleable.MainKeyboardView_slidingKeyInputPreviewColor, 0); final float previewRadius = mainKeyboardViewAttr.getDimension( R.styleable.MainKeyboardView_slidingKeyInputPreviewWidth, 0) / 2.0f; final int PERCENTAGE_INT = 100; diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/latin/KeyboardWrapperView.kt b/app/src/main/java/org/dslul/openboard/inputmethod/latin/KeyboardWrapperView.kt index a3c3cb87a..444fb1351 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/latin/KeyboardWrapperView.kt +++ b/app/src/main/java/org/dslul/openboard/inputmethod/latin/KeyboardWrapperView.kt @@ -54,10 +54,8 @@ class KeyboardWrapperView @JvmOverloads constructor( switchOneHandedModeBtn.setOnClickListener(this) val colors = Settings.getInstance().current.mColors - if (colors.isCustom) { - stopOneHandedModeBtn.colorFilter = colors.keyTextFilter - switchOneHandedModeBtn.colorFilter = colors.keyTextFilter - } + stopOneHandedModeBtn.colorFilter = colors.keyTextFilter + switchOneHandedModeBtn.colorFilter = colors.keyTextFilter } @SuppressLint("RtlHardcoded") diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/latin/common/Colors.java b/app/src/main/java/org/dslul/openboard/inputmethod/latin/common/Colors.java index a956a4f21..bd071e208 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/latin/common/Colors.java +++ b/app/src/main/java/org/dslul/openboard/inputmethod/latin/common/Colors.java @@ -15,7 +15,6 @@ import androidx.core.graphics.drawable.DrawableCompat; // todo: maybe kotlin? would make it much shorter and more readable public class Colors { - public final boolean isCustom; public final int navBar; public final int accent; public final int background; @@ -44,7 +43,6 @@ public class Colors { private ColorStateList adjustedBackgroundStateList; public Colors(int _accent, int _background, int _keyBackground, int _functionalKey, int _spaceBar, int _keyText, int _keyHintText) { - isCustom = true; accent = _accent; background = _background; keyBackground = _keyBackground; @@ -55,20 +53,6 @@ public class Colors { 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 */ // 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?) diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/latin/settings/Settings.java b/app/src/main/java/org/dslul/openboard/inputmethod/latin/settings/Settings.java index d07289a5c..80193e75f 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/latin/settings/Settings.java +++ b/app/src/main/java/org/dslul/openboard/inputmethod/latin/settings/Settings.java @@ -574,15 +574,8 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang } 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? 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)) return KeyboardTheme.getCustomTheme(prefs.getString(Settings.PREF_CUSTOM_THEME_VARIANT_NIGHT, KeyboardTheme.THEME_DARKER), context, prefs); diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java b/app/src/main/java/org/dslul/openboard/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java index 85c5a615a..0d6bfaa99 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java +++ b/app/src/main/java/org/dslul/openboard/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java @@ -131,17 +131,10 @@ final class SuggestionStripLayoutHelper { R.styleable.SuggestionStripView_alphaObsoleted, 1.0f); final Colors colors = Settings.getInstance().getCurrent().mColors; - if (colors.isCustom) { - mColorValidTypedWord = colors.adjustedKeyText; - mColorTypedWord = colors.adjustedKeyText; - mColorAutoCorrect = colors.keyText; - 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); - } + mColorValidTypedWord = colors.adjustedKeyText; //a.getColor(R.styleable.SuggestionStripView_colorValidTypedWord, 0); + mColorTypedWord = colors.adjustedKeyText; //a.getColor(R.styleable.SuggestionStripView_colorTypedWord, 0); + mColorAutoCorrect = colors.keyText; //a.getColor(R.styleable.SuggestionStripView_colorAutoCorrect, 0); + mColorSuggested = colors.adjustedKeyText; //a.getColor(R.styleable.SuggestionStripView_colorSuggested, 0); mSuggestionsCountInStrip = a.getInt( R.styleable.SuggestionStripView_suggestionsCountInStrip, diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/latin/suggestions/SuggestionStripView.java b/app/src/main/java/org/dslul/openboard/inputmethod/latin/suggestions/SuggestionStripView.java index 6d382315f..9a19a2693 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/latin/suggestions/SuggestionStripView.java +++ b/app/src/main/java/org/dslul/openboard/inputmethod/latin/suggestions/SuggestionStripView.java @@ -59,7 +59,6 @@ import org.dslul.openboard.inputmethod.latin.utils.DialogUtils; import java.util.ArrayList; -import androidx.core.graphics.drawable.DrawableCompat; import androidx.core.view.ViewCompat; public final class SuggestionStripView extends RelativeLayout implements OnClickListener, @@ -185,24 +184,18 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick mOtherKey.setImageDrawable(iconIncognito); final Colors colors = Settings.getInstance().getCurrent().mColors; - if (colors.isCustom) { - // this only works with backgrounds of SuggestionStripView.LXX_Base and SuggestionWord.LXX_Base - // 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) - // 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? - // todo (later): when fixing this, revert changes in themes-lxx-base[-border] (in todo) - // this would allow having a different background shape in pressed state - colors.setBackgroundColor(getBackground(), Colors.TYPE_BACKGROUND); + // this only works when backgrounds of SuggestionStripView.LXX_Base and SuggestionWord.LXX_Base + // are 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) + // 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? + // todo (later): when fixing this, revert changes in themes-lxx-base[-border] (in todo) + // this would allow having a different background shape in pressed state + colors.setBackgroundColor(getBackground(), Colors.TYPE_BACKGROUND); - mClipboardKey.setColorFilter(colors.keyText); - mVoiceKey.setColorFilter(colors.keyText); - mOtherKey.setColorFilter(colors.keyText); - } else { - mClipboardKey.clearColorFilter(); - mVoiceKey.clearColorFilter(); - mOtherKey.clearColorFilter(); - } + mClipboardKey.setColorFilter(colors.keyText); + mVoiceKey.setColorFilter(colors.keyText); + mOtherKey.setColorFilter(colors.keyText); } /**