mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-07 15:17:42 +00:00
move color filters for custom colors into "Colors" class
This commit is contained in:
parent
db3c39bfc5
commit
3c060ddfa5
17 changed files with 235 additions and 215 deletions
|
@ -1136,4 +1136,8 @@ public class Key implements Comparable<Key> {
|
||||||
height, params.mHorizontalGap, params.mVerticalGap);
|
height, params.mHorizontalGap, params.mVerticalGap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isPressed() {
|
||||||
|
return mPressed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ 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;
|
||||||
|
@ -555,9 +556,9 @@ 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 SettingsValues settingsValues = Settings.getInstance().getCurrent();
|
final Colors colors = Settings.getInstance().getCurrent().mColors;
|
||||||
if (settingsValues.mCustomTheme)
|
if (colors.isCustom)
|
||||||
mKeyboardViewWrapper.getBackground().setColorFilter(settingsValues.mCustomBackgroundColorFilter);
|
mKeyboardViewWrapper.getBackground().setColorFilter(colors.backgroundFilter);
|
||||||
|
|
||||||
return mCurrentInputView;
|
return mCurrentInputView;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ import android.content.res.TypedArray;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.ColorFilter;
|
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.Paint.Align;
|
import android.graphics.Paint.Align;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
|
@ -33,18 +32,14 @@ import android.text.TextUtils;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import androidx.core.graphics.BlendModeColorFilterCompat;
|
|
||||||
import androidx.core.graphics.BlendModeCompat;
|
|
||||||
|
|
||||||
import org.dslul.openboard.inputmethod.keyboard.internal.KeyDrawParams;
|
import org.dslul.openboard.inputmethod.keyboard.internal.KeyDrawParams;
|
||||||
import org.dslul.openboard.inputmethod.keyboard.internal.KeyVisualAttributes;
|
import org.dslul.openboard.inputmethod.keyboard.internal.KeyVisualAttributes;
|
||||||
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.Constants;
|
import org.dslul.openboard.inputmethod.latin.common.Constants;
|
||||||
import org.dslul.openboard.inputmethod.latin.common.StringUtils;
|
import org.dslul.openboard.inputmethod.latin.common.StringUtils;
|
||||||
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.suggestions.MoreSuggestionsView;
|
import org.dslul.openboard.inputmethod.latin.suggestions.MoreSuggestionsView;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.ColorUtils;
|
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.TypefaceUtils;
|
import org.dslul.openboard.inputmethod.latin.utils.TypefaceUtils;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -104,11 +99,7 @@ public class KeyboardView extends View {
|
||||||
private final float mSpacebarIconWidthRatio;
|
private final float mSpacebarIconWidthRatio;
|
||||||
private final Rect mKeyBackgroundPadding = new Rect();
|
private final Rect mKeyBackgroundPadding = new Rect();
|
||||||
private static final float KET_TEXT_SHADOW_RADIUS_DISABLED = -1.0f;
|
private static final float KET_TEXT_SHADOW_RADIUS_DISABLED = -1.0f;
|
||||||
private final ColorFilter keyHintTextColorFilter;
|
private final Colors mColors;
|
||||||
private final ColorFilter keyTextColorFilter;
|
|
||||||
private final ColorFilter keyBgFilter;
|
|
||||||
private final ColorFilter accentColorFilter;
|
|
||||||
private final boolean mCustomTheme;
|
|
||||||
|
|
||||||
// The maximum key label width in the proportion to the key width.
|
// The maximum key label width in the proportion to the key width.
|
||||||
private static final float MAX_LABEL_RATIO = 0.90f;
|
private static final float MAX_LABEL_RATIO = 0.90f;
|
||||||
|
@ -180,22 +171,11 @@ public class KeyboardView extends View {
|
||||||
|
|
||||||
mPaint.setAntiAlias(true);
|
mPaint.setAntiAlias(true);
|
||||||
|
|
||||||
final SettingsValues settingsValues = Settings.getInstance().getCurrent();
|
mColors = Settings.getInstance().getCurrent().mColors;
|
||||||
mCustomTheme = settingsValues.mCustomTheme;
|
if (mColors.isCustom) {
|
||||||
if (mCustomTheme) {
|
getBackground().setColorFilter(mColors.backgroundFilter);
|
||||||
getBackground().setColorFilter(settingsValues.mCustomBackgroundColorFilter);
|
mSpacebarBackground.setColorFilter(mColors.spaceBarFilter); // todo: consider pressed state
|
||||||
|
mFunctionalKeyBackground.setColorFilter(mColors.functionalKeyBackgroundFilter); // todo: consider pressed state
|
||||||
keyBgFilter = settingsValues.mCustomKeyBackgroundColorFilter;
|
|
||||||
keyHintTextColorFilter = settingsValues.mCustomHintTextColorFilter;
|
|
||||||
keyTextColorFilter = settingsValues.mCustomKeyTextColorFilter;
|
|
||||||
accentColorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(settingsValues.mCustomThemeColorAccent, BlendModeCompat.SRC_ATOP);
|
|
||||||
mSpacebarBackground.setColorFilter(settingsValues.mCustomSpaceBarBackgroundColorFilter);
|
|
||||||
mFunctionalKeyBackground.setColorFilter(settingsValues.mCustomFunctionalKeyBackgroundColorFilter);
|
|
||||||
} else {
|
|
||||||
keyHintTextColorFilter = null;
|
|
||||||
keyTextColorFilter = null;
|
|
||||||
keyBgFilter = null;
|
|
||||||
accentColorFilter = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,13 +381,13 @@ public class KeyboardView extends View {
|
||||||
bgX = -padding.left;
|
bgX = -padding.left;
|
||||||
bgY = -padding.top;
|
bgY = -padding.top;
|
||||||
}
|
}
|
||||||
if (mCustomTheme) {
|
if (mColors.isCustom) {
|
||||||
// color filter is applied to background, which is re-used
|
// color filter is applied to background, which is re-used
|
||||||
// action key and normal key share the same background drawable, so we need to select the correct color filter
|
// action key and normal key share the same background drawable, so we need to select the correct color filter
|
||||||
if (key.isActionKey())
|
if (key.isActionKey())
|
||||||
background.setColorFilter(accentColorFilter);
|
background.setColorFilter(mColors.accentColorFilter);
|
||||||
else if (key.getBackgroundType() == Key.BACKGROUND_TYPE_NORMAL)
|
else if (key.getBackgroundType() == Key.BACKGROUND_TYPE_NORMAL)
|
||||||
background.setColorFilter(keyBgFilter);
|
background.setColorFilter(mColors.keyBackgroundFilter);
|
||||||
}
|
}
|
||||||
background.setBounds(0, 0, bgWidth, bgHeight);
|
background.setBounds(0, 0, bgWidth, bgHeight);
|
||||||
canvas.translate(bgX, bgY);
|
canvas.translate(bgX, bgY);
|
||||||
|
@ -461,14 +441,14 @@ public class KeyboardView extends View {
|
||||||
|
|
||||||
if (key.isEnabled()) {
|
if (key.isEnabled()) {
|
||||||
paint.setColor(key.selectTextColor(params));
|
paint.setColor(key.selectTextColor(params));
|
||||||
if (mCustomTheme) {
|
if (mColors.isCustom) {
|
||||||
// set key color only if not in emoji keyboard range
|
// set key color only if not in emoji keyboard range
|
||||||
if (keyboard != null
|
if (keyboard != null
|
||||||
&& (this.getClass() == MoreSuggestionsView.class ?
|
&& (this.getClass() == MoreSuggestionsView.class
|
||||||
!StringUtils.probablyContainsEmoji(key.getLabel()) : // doesn't contain emoji (all can happen in MoreSuggestionsView)
|
? !StringUtils.probablyContainsEmoji(key.getLabel()) // doesn't contain emoji (MoreSuggestionsView can have letters and emojis)
|
||||||
(keyboard.mId.mElementId < 10 || keyboard.mId.mElementId > 26) // not showing emoji keyboard (no emojis visible on main keyboard otherwise)
|
: (keyboard.mId.mElementId < 10 || keyboard.mId.mElementId > 26) // not showing emoji keyboard (no emojis visible on main keyboard otherwise)
|
||||||
))
|
))
|
||||||
paint.setColorFilter(keyTextColorFilter);
|
paint.setColorFilter(mColors.keyTextFilter);
|
||||||
else
|
else
|
||||||
paint.setColorFilter(null);
|
paint.setColorFilter(null);
|
||||||
}
|
}
|
||||||
|
@ -495,8 +475,8 @@ public class KeyboardView extends View {
|
||||||
if (hintLabel != null && mShowsHints) {
|
if (hintLabel != null && mShowsHints) {
|
||||||
paint.setTextSize(key.selectHintTextSize(params));
|
paint.setTextSize(key.selectHintTextSize(params));
|
||||||
paint.setColor(key.selectHintTextColor(params));
|
paint.setColor(key.selectHintTextColor(params));
|
||||||
if (mCustomTheme)
|
if (mColors.isCustom)
|
||||||
paint.setColorFilter(keyHintTextColorFilter);
|
paint.setColorFilter(mColors.keyHintTextFilter);
|
||||||
// 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);
|
||||||
blendAlpha(paint, params.mAnimAlpha);
|
blendAlpha(paint, params.mAnimAlpha);
|
||||||
|
@ -549,24 +529,21 @@ 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 (mCustomTheme) {
|
if (mColors.isCustom) {
|
||||||
if (key.isActionKey()) {
|
if (key.isActionKey()) {
|
||||||
// the white icon may not have enough contrast, and can't be adjusted by the user
|
// the white icon may not have enough contrast, and can't be adjusted by the user
|
||||||
if (ColorUtils.isBrightColor(Settings.getInstance().getCurrent().mCustomThemeColorAccent))
|
icon.setColorFilter(mColors.actionKeyIconColorFilter);
|
||||||
icon.setColorFilter(Color.DKGRAY, PorterDuff.Mode.SRC_ATOP);
|
|
||||||
else
|
|
||||||
icon.clearColorFilter();
|
|
||||||
} else if (key.isShift()) {
|
} else if (key.isShift()) {
|
||||||
if (keyboard.mId.mElementId == KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED
|
if (keyboard.mId.mElementId == KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED
|
||||||
|| keyboard.mId.mElementId == KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCKED
|
|| keyboard.mId.mElementId == KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCKED
|
||||||
|| keyboard.mId.mElementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED
|
|| keyboard.mId.mElementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED
|
||||||
|| keyboard.mId.mElementId == KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED
|
|| keyboard.mId.mElementId == KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED
|
||||||
)
|
)
|
||||||
icon.setColorFilter(accentColorFilter);
|
icon.setColorFilter(mColors.accentColorFilter);
|
||||||
else
|
else
|
||||||
icon.setColorFilter(keyTextColorFilter);
|
icon.setColorFilter(mColors.keyTextFilter);
|
||||||
} else if (key.getBackgroundType() != Key.BACKGROUND_TYPE_NORMAL) {
|
} else if (key.getBackgroundType() != Key.BACKGROUND_TYPE_NORMAL) {
|
||||||
icon.setColorFilter(keyTextColorFilter);
|
icon.setColorFilter(mColors.keyTextFilter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
drawIcon(canvas, icon, iconX, iconY, iconWidth, iconHeight);
|
drawIcon(canvas, icon, iconX, iconY, iconWidth, iconHeight);
|
||||||
|
|
|
@ -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 settingsValues = Settings.getInstance().current
|
val colors = Settings.getInstance().current.mColors
|
||||||
if (settingsValues.mCustomTheme)
|
if (colors.isCustom)
|
||||||
paint.colorFilter = settingsValues.mCustomBackgroundColorFilter
|
paint.colorFilter = colors.backgroundFilter
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDrawOver(canvas: Canvas, parent: RecyclerView, state: State) {
|
override fun onDrawOver(canvas: Canvas, parent: RecyclerView, state: State) {
|
||||||
|
|
|
@ -90,7 +90,6 @@ class ClipboardHistoryView @JvmOverloads constructor(
|
||||||
findViewById<FrameLayout>(R.id.clipboard_action_bar)?.apply {
|
findViewById<FrameLayout>(R.id.clipboard_action_bar)?.apply {
|
||||||
clipboardLayoutParams.setActionBarProperties(this)
|
clipboardLayoutParams.setActionBarProperties(this)
|
||||||
}
|
}
|
||||||
val settingsValues = Settings.getInstance().current
|
|
||||||
alphabetKey = findViewById<TextView>(R.id.clipboard_keyboard_alphabet).apply {
|
alphabetKey = findViewById<TextView>(R.id.clipboard_keyboard_alphabet).apply {
|
||||||
tag = Constants.CODE_ALPHA_FROM_CLIPBOARD
|
tag = Constants.CODE_ALPHA_FROM_CLIPBOARD
|
||||||
setBackgroundResource(functionalKeyBackgroundId)
|
setBackgroundResource(functionalKeyBackgroundId)
|
||||||
|
@ -101,11 +100,12 @@ class ClipboardHistoryView @JvmOverloads constructor(
|
||||||
setOnTouchListener(this@ClipboardHistoryView)
|
setOnTouchListener(this@ClipboardHistoryView)
|
||||||
setOnClickListener(this@ClipboardHistoryView)
|
setOnClickListener(this@ClipboardHistoryView)
|
||||||
}
|
}
|
||||||
if (settingsValues.mCustomTheme) {
|
val colors = Settings.getInstance().current.mColors
|
||||||
alphabetKey.background.colorFilter = settingsValues.mCustomFunctionalKeyBackgroundColorFilter
|
if (colors.isCustom) {
|
||||||
alphabetKey.setTextColor(settingsValues.mCustomKeyTextColor)
|
alphabetKey.background.colorFilter = colors.functionalKeyBackgroundFilter
|
||||||
clearKey.colorFilter = settingsValues.mCustomKeyTextColorFilter
|
alphabetKey.setTextColor(colors.keyText)
|
||||||
background.colorFilter = settingsValues.mCustomBackgroundColorFilter
|
clearKey.colorFilter = colors.keyTextFilter
|
||||||
|
background.colorFilter = colors.backgroundFilter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,9 +113,9 @@ class ClipboardHistoryView @JvmOverloads constructor(
|
||||||
key?.apply {
|
key?.apply {
|
||||||
text = label
|
text = label
|
||||||
typeface = params.mTypeface
|
typeface = params.mTypeface
|
||||||
val settingsValues = Settings.getInstance().current
|
val colors = Settings.getInstance().current.mColors
|
||||||
if (settingsValues.mCustomTheme)
|
if (colors.isCustom)
|
||||||
setTextColor(settingsValues.mCustomKeyTextColor)
|
setTextColor(colors.keyText)
|
||||||
else
|
else
|
||||||
setTextColor(params.mFunctionalTextColor)
|
setTextColor(params.mFunctionalTextColor)
|
||||||
setTextSize(TypedValue.COMPLEX_UNIT_PX, params.mLabelSize.toFloat())
|
setTextSize(TypedValue.COMPLEX_UNIT_PX, params.mLabelSize.toFloat())
|
||||||
|
@ -126,10 +126,10 @@ class ClipboardHistoryView @JvmOverloads constructor(
|
||||||
clipboardAdapter.apply {
|
clipboardAdapter.apply {
|
||||||
itemBackgroundId = keyBackgroundId
|
itemBackgroundId = keyBackgroundId
|
||||||
itemTypeFace = params.mTypeface
|
itemTypeFace = params.mTypeface
|
||||||
val settingsValues = Settings.getInstance().current
|
val colors = Settings.getInstance().current.mColors
|
||||||
if (settingsValues.mCustomTheme) {
|
if (colors.isCustom) {
|
||||||
itemTextColor = settingsValues.mCustomKeyTextColor
|
itemTextColor = colors.keyText
|
||||||
itemBackgroundColorFilter = settingsValues.mCustomKeyBackgroundColorFilter
|
itemBackgroundColorFilter = colors.keyBackgroundFilter
|
||||||
} else
|
} else
|
||||||
itemTextColor = params.mTextColor
|
itemTextColor = params.mTextColor
|
||||||
itemTextSize = params.mLabelSize.toFloat()
|
itemTextSize = params.mLabelSize.toFloat()
|
||||||
|
|
|
@ -47,9 +47,9 @@ import org.dslul.openboard.inputmethod.keyboard.internal.KeyboardIconsSet;
|
||||||
import org.dslul.openboard.inputmethod.latin.AudioAndHapticFeedbackManager;
|
import org.dslul.openboard.inputmethod.latin.AudioAndHapticFeedbackManager;
|
||||||
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.common.Colors;
|
||||||
import org.dslul.openboard.inputmethod.latin.common.Constants;
|
import org.dslul.openboard.inputmethod.latin.common.Constants;
|
||||||
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.utils.DeviceProtectedUtils;
|
import org.dslul.openboard.inputmethod.latin.utils.DeviceProtectedUtils;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.ResourceUtils;
|
import org.dslul.openboard.inputmethod.latin.utils.ResourceUtils;
|
||||||
|
|
||||||
|
@ -163,10 +163,10 @@ 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 SettingsValues settingsValues = Settings.getInstance().getCurrent();
|
final Colors colors = Settings.getInstance().getCurrent().mColors;
|
||||||
if (settingsValues.mCustomTheme) {
|
if (colors.isCustom) {
|
||||||
iconView.getBackground().setColorFilter(settingsValues.mCustomBackgroundColorFilter);
|
iconView.getBackground().setColorFilter(colors.backgroundFilter);
|
||||||
iconView.setColorFilter(settingsValues.mCustomKeyTextColorFilter);
|
iconView.setColorFilter(colors.keyTextFilter);
|
||||||
}
|
}
|
||||||
iconView.setImageResource(mEmojiCategory.getCategoryTabIcon(categoryId));
|
iconView.setImageResource(mEmojiCategory.getCategoryTabIcon(categoryId));
|
||||||
iconView.setContentDescription(mEmojiCategory.getAccessibilityDescription(categoryId));
|
iconView.setContentDescription(mEmojiCategory.getAccessibilityDescription(categoryId));
|
||||||
|
@ -269,14 +269,14 @@ public final class EmojiPalettesView extends LinearLayout
|
||||||
mSpacebar.setTag(Constants.CODE_SPACE);
|
mSpacebar.setTag(Constants.CODE_SPACE);
|
||||||
mSpacebar.setOnTouchListener(this);
|
mSpacebar.setOnTouchListener(this);
|
||||||
mSpacebar.setOnClickListener(this);
|
mSpacebar.setOnClickListener(this);
|
||||||
final SettingsValues settingsValues = Settings.getInstance().getCurrent();
|
final Colors colors = Settings.getInstance().getCurrent().mColors;
|
||||||
if (settingsValues.mCustomTheme) {
|
if (colors.isCustom) {
|
||||||
mAlphabetKeyLeft.getBackground().setColorFilter(settingsValues.mCustomFunctionalKeyBackgroundColorFilter);
|
mAlphabetKeyLeft.getBackground().setColorFilter(colors.functionalKeyBackgroundFilter);
|
||||||
mSpacebar.getBackground().setColorFilter(settingsValues.mCustomSpaceBarBackgroundColorFilter);
|
mSpacebar.getBackground().setColorFilter(colors.spaceBarFilter);
|
||||||
mDeleteKey.getBackground().setColorFilter(settingsValues.mCustomFunctionalKeyBackgroundColorFilter);
|
mDeleteKey.getBackground().setColorFilter(colors.functionalKeyBackgroundFilter);
|
||||||
getBackground().setColorFilter(settingsValues.mCustomBackgroundColorFilter);
|
getBackground().setColorFilter(colors.backgroundFilter);
|
||||||
mEmojiCategoryPageIndicatorView.setColors(settingsValues.mCustomThemeColorAccent, settingsValues.mCustomBackgroundColor);
|
mEmojiCategoryPageIndicatorView.setColors(colors.accent, colors.background);
|
||||||
findViewById(R.id.emoji_tab_strip).getBackground().setColorFilter(settingsValues.mCustomBackgroundColorFilter);
|
findViewById(R.id.emoji_tab_strip).getBackground().setColorFilter(colors.backgroundFilter);
|
||||||
}
|
}
|
||||||
mEmojiLayoutParams.setKeyProperties(mSpacebar);
|
mEmojiLayoutParams.setKeyProperties(mSpacebar);
|
||||||
mSpacebarIcon = findViewById(R.id.emoji_keyboard_space_icon);
|
mSpacebarIcon = findViewById(R.id.emoji_keyboard_space_icon);
|
||||||
|
@ -299,12 +299,12 @@ public final class EmojiPalettesView extends LinearLayout
|
||||||
setCurrentCategoryAndPageId(categoryId, 0, false /* force */);
|
setCurrentCategoryAndPageId(categoryId, 0, false /* force */);
|
||||||
updateEmojiCategoryPageIdView();
|
updateEmojiCategoryPageIdView();
|
||||||
}
|
}
|
||||||
final SettingsValues settingsValues = Settings.getInstance().getCurrent();
|
final Colors colors = Settings.getInstance().getCurrent().mColors;
|
||||||
if (settingsValues.mCustomTheme) {
|
if (colors.isCustom) {
|
||||||
if (mCurrentTab != null)
|
if (mCurrentTab != null)
|
||||||
mCurrentTab.setColorFilter(settingsValues.mCustomKeyTextColorFilter);
|
mCurrentTab.setColorFilter(colors.keyTextFilter);
|
||||||
mCurrentTab = (ImageView) mTabHost.getCurrentTabView();
|
mCurrentTab = (ImageView) mTabHost.getCurrentTabView();
|
||||||
mCurrentTab.setColorFilter(settingsValues.mCustomThemeColorAccent);
|
mCurrentTab.setColorFilter(colors.accentColorFilter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,9 +389,9 @@ 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 SettingsValues settingsValues = Settings.getInstance().getCurrent();
|
final Colors colors = Settings.getInstance().getCurrent().mColors;
|
||||||
if (settingsValues.mCustomTheme)
|
if (colors.isCustom)
|
||||||
alphabetKey.setTextColor(settingsValues.mCustomKeyTextColor);
|
alphabetKey.setTextColor(colors.keyText);
|
||||||
else
|
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);
|
||||||
|
|
|
@ -27,9 +27,9 @@ import android.text.TextUtils;
|
||||||
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.SuggestedWords;
|
import org.dslul.openboard.inputmethod.latin.SuggestedWords;
|
||||||
|
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;
|
||||||
import org.dslul.openboard.inputmethod.latin.settings.SettingsValues;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
@ -62,15 +62,17 @@ public class GestureFloatingTextDrawingPreview extends AbstractDrawingPreview {
|
||||||
private static final char[] TEXT_HEIGHT_REFERENCE_CHAR = { 'M' };
|
private static final char[] TEXT_HEIGHT_REFERENCE_CHAR = { 'M' };
|
||||||
|
|
||||||
public GesturePreviewTextParams(final TypedArray mainKeyboardViewAttr) {
|
public GesturePreviewTextParams(final TypedArray mainKeyboardViewAttr) {
|
||||||
final SettingsValues sv = Settings.getInstance().getCurrent();
|
final Colors colors = Settings.getInstance().getCurrent().mColors;
|
||||||
mGesturePreviewTextSize = mainKeyboardViewAttr.getDimensionPixelSize(
|
mGesturePreviewTextSize = mainKeyboardViewAttr.getDimensionPixelSize(
|
||||||
R.styleable.MainKeyboardView_gestureFloatingPreviewTextSize, 0);
|
R.styleable.MainKeyboardView_gestureFloatingPreviewTextSize, 0);
|
||||||
mGesturePreviewTextColor = sv.mCustomTheme ? sv.mCustomKeyTextColor : mainKeyboardViewAttr.getColor(
|
mGesturePreviewTextColor = colors.isCustom
|
||||||
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 = sv.mCustomTheme ? sv.mCustomBackgroundColor : mainKeyboardViewAttr.getColor(
|
mGesturePreviewColor = colors.isCustom
|
||||||
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(
|
||||||
|
|
|
@ -19,8 +19,8 @@ package org.dslul.openboard.inputmethod.keyboard.internal;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
|
|
||||||
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.settings.Settings;
|
||||||
import org.dslul.openboard.inputmethod.latin.settings.SettingsValues;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class holds parameters to control how a gesture trail is drawn and animated on the screen.
|
* This class holds parameters to control how a gesture trail is drawn and animated on the screen.
|
||||||
|
@ -52,8 +52,8 @@ final class GestureTrailDrawingParams {
|
||||||
public final int mTrailLingerDuration;
|
public final int mTrailLingerDuration;
|
||||||
|
|
||||||
public GestureTrailDrawingParams(final TypedArray mainKeyboardViewAttr) {
|
public GestureTrailDrawingParams(final TypedArray mainKeyboardViewAttr) {
|
||||||
final SettingsValues sv = Settings.getInstance().getCurrent();
|
final Colors colors = Settings.getInstance().getCurrent().mColors;
|
||||||
mTrailColor = sv.mCustomTheme ? sv.mCustomThemeColorAccent : mainKeyboardViewAttr.getColor(
|
mTrailColor = colors.isCustom ? colors.accent : mainKeyboardViewAttr.getColor(
|
||||||
R.styleable.MainKeyboardView_gestureTrailColor, 0);
|
R.styleable.MainKeyboardView_gestureTrailColor, 0);
|
||||||
mTrailStartWidth = mainKeyboardViewAttr.getDimension(
|
mTrailStartWidth = mainKeyboardViewAttr.getDimension(
|
||||||
R.styleable.MainKeyboardView_gestureTrailStartWidth, 0.0f);
|
R.styleable.MainKeyboardView_gestureTrailStartWidth, 0.0f);
|
||||||
|
|
|
@ -21,9 +21,9 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import org.dslul.openboard.inputmethod.keyboard.Key;
|
import org.dslul.openboard.inputmethod.keyboard.Key;
|
||||||
|
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;
|
||||||
import org.dslul.openboard.inputmethod.latin.settings.SettingsValues;
|
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.ViewLayoutUtils;
|
import org.dslul.openboard.inputmethod.latin.utils.ViewLayoutUtils;
|
||||||
|
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
|
@ -119,10 +119,10 @@ 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 SettingsValues settingsValues = Settings.getInstance().getCurrent();
|
final Colors colors = Settings.getInstance().getCurrent().mColors;
|
||||||
if (settingsValues.mCustomTheme) {
|
if (colors.isCustom) {
|
||||||
keyPreviewView.getBackground().setColorFilter(settingsValues.mCustomBackgroundColorFilter);
|
keyPreviewView.getBackground().setColorFilter(colors.backgroundFilter);
|
||||||
keyPreviewView.setTextColor(settingsValues.mCustomKeyTextColor);
|
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.
|
||||||
|
|
|
@ -23,7 +23,9 @@ 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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw rubber band preview graphics during sliding key input.
|
* Draw rubber band preview graphics during sliding key input.
|
||||||
|
@ -45,8 +47,10 @@ 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 int previewColor = mainKeyboardViewAttr.getColor(
|
final Colors colors = Settings.getInstance().getCurrent().mColors;
|
||||||
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;
|
||||||
|
|
|
@ -64,6 +64,7 @@ import org.dslul.openboard.inputmethod.keyboard.KeyboardSwitcher;
|
||||||
import org.dslul.openboard.inputmethod.keyboard.MainKeyboardView;
|
import org.dslul.openboard.inputmethod.keyboard.MainKeyboardView;
|
||||||
import org.dslul.openboard.inputmethod.latin.Suggest.OnGetSuggestedWordsCallback;
|
import org.dslul.openboard.inputmethod.latin.Suggest.OnGetSuggestedWordsCallback;
|
||||||
import org.dslul.openboard.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
import org.dslul.openboard.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
||||||
|
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.common.InputPointers;
|
import org.dslul.openboard.inputmethod.latin.common.InputPointers;
|
||||||
|
@ -101,7 +102,6 @@ import javax.annotation.Nonnull;
|
||||||
import static org.dslul.openboard.inputmethod.latin.common.Constants.ImeOption.FORCE_ASCII;
|
import static org.dslul.openboard.inputmethod.latin.common.Constants.ImeOption.FORCE_ASCII;
|
||||||
import static org.dslul.openboard.inputmethod.latin.common.Constants.ImeOption.NO_MICROPHONE;
|
import static org.dslul.openboard.inputmethod.latin.common.Constants.ImeOption.NO_MICROPHONE;
|
||||||
import static org.dslul.openboard.inputmethod.latin.common.Constants.ImeOption.NO_MICROPHONE_COMPAT;
|
import static org.dslul.openboard.inputmethod.latin.common.Constants.ImeOption.NO_MICROPHONE_COMPAT;
|
||||||
import static org.dslul.openboard.inputmethod.latin.utils.ColorUtils.isBrightColor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Input method implementation for Qwerty'ish keyboard.
|
* Input method implementation for Qwerty'ish keyboard.
|
||||||
|
@ -2022,7 +2022,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
final SettingsValues settingsValues = mSettings.getCurrent();
|
final SettingsValues settingsValues = mSettings.getCurrent();
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP || !settingsValues.mCustomNavBarColor)
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP || !settingsValues.mCustomNavBarColor)
|
||||||
return;
|
return;
|
||||||
final int color = settingsValues.mNavBarColor;
|
final int color = settingsValues.mColors.navBar;
|
||||||
final Window window = getWindow().getWindow();
|
final Window window = getWindow().getWindow();
|
||||||
if (window == null)
|
if (window == null)
|
||||||
return;
|
return;
|
||||||
|
@ -2033,7 +2033,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
return;
|
return;
|
||||||
final View view = window.getDecorView();
|
final View view = window.getDecorView();
|
||||||
mOriginalNavBarFlags = view.getSystemUiVisibility();
|
mOriginalNavBarFlags = view.getSystemUiVisibility();
|
||||||
if (isBrightColor(color)) {
|
if (Colors.isBrightColor(color)) {
|
||||||
view.setSystemUiVisibility(mOriginalNavBarFlags | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
|
view.setSystemUiVisibility(mOriginalNavBarFlags | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
|
||||||
} else {
|
} else {
|
||||||
view.setSystemUiVisibility(mOriginalNavBarFlags & ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
|
view.setSystemUiVisibility(mOriginalNavBarFlags & ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
|
||||||
|
|
|
@ -0,0 +1,129 @@
|
||||||
|
package org.dslul.openboard.inputmethod.latin.common;
|
||||||
|
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.ColorFilter;
|
||||||
|
|
||||||
|
import androidx.core.graphics.BlendModeColorFilterCompat;
|
||||||
|
import androidx.core.graphics.BlendModeCompat;
|
||||||
|
|
||||||
|
import org.dslul.openboard.inputmethod.keyboard.KeyboardTheme;
|
||||||
|
import org.dslul.openboard.inputmethod.latin.settings.Settings;
|
||||||
|
|
||||||
|
public class Colors {
|
||||||
|
|
||||||
|
public final boolean isCustom; // todo: could be removed?
|
||||||
|
public final int navBar;
|
||||||
|
public final int accent;
|
||||||
|
public final int background;
|
||||||
|
public final int keyBackground;
|
||||||
|
public final int functionalKey;
|
||||||
|
public final int spaceBar;
|
||||||
|
public final int keyText;
|
||||||
|
public final int keyHintText;
|
||||||
|
public ColorFilter backgroundFilter;
|
||||||
|
public ColorFilter keyBackgroundFilter;
|
||||||
|
public ColorFilter keyPressedBackgroundFilter;
|
||||||
|
public ColorFilter functionalKeyBackgroundFilter;
|
||||||
|
public ColorFilter functionalKeyPressedBackgroundFilter;
|
||||||
|
public ColorFilter spaceBarFilter;
|
||||||
|
public ColorFilter spaceBarPressedFilter;
|
||||||
|
public ColorFilter keyTextFilter; // todo: really necessary?
|
||||||
|
public ColorFilter keyHintTextFilter; // todo: really? color alone should be sufficient i think... test!
|
||||||
|
public ColorFilter accentColorFilter; // todo: really necessary?
|
||||||
|
public ColorFilter actionKeyIconColorFilter;
|
||||||
|
|
||||||
|
public Colors(int acc, int bg, int k, int fun, int space, int kt, int kht) {
|
||||||
|
isCustom = true;
|
||||||
|
accent = acc;
|
||||||
|
background = bg;
|
||||||
|
keyBackground = k;
|
||||||
|
functionalKey = fun;
|
||||||
|
spaceBar = space;
|
||||||
|
keyText = kt;
|
||||||
|
keyHintText = kht;
|
||||||
|
navBar = background;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Colors(int themeId, int nightModeFlags) {
|
||||||
|
isCustom = false;
|
||||||
|
if (KeyboardTheme.getIsDayNight(themeId)) {
|
||||||
|
if (nightModeFlags == Configuration.UI_MODE_NIGHT_NO)
|
||||||
|
navBar = Color.rgb(236, 239, 241);
|
||||||
|
else if (themeId == KeyboardTheme.THEME_ID_LXX_DARK)
|
||||||
|
navBar = Color.rgb(38, 50, 56);
|
||||||
|
else
|
||||||
|
navBar = Color.BLACK;
|
||||||
|
} else if (KeyboardTheme.THEME_VARIANT_LIGHT.equals(KeyboardTheme.getThemeVariant(themeId))) {
|
||||||
|
navBar = Color.rgb(236, 239, 241);
|
||||||
|
} else if (themeId == KeyboardTheme.THEME_ID_LXX_DARK) {
|
||||||
|
navBar = Color.rgb(38, 50, 56);
|
||||||
|
} else {
|
||||||
|
// dark border is 13/13/13, but that's ok
|
||||||
|
navBar = Color.BLACK;
|
||||||
|
}
|
||||||
|
accent = 0;
|
||||||
|
background = 0;
|
||||||
|
keyBackground = 0;
|
||||||
|
functionalKey = 0;
|
||||||
|
spaceBar = 0;
|
||||||
|
keyText = 0;
|
||||||
|
keyHintText = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createColorFilters(final boolean hasKeyBorders) {
|
||||||
|
backgroundFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(background, BlendModeCompat.MODULATE);
|
||||||
|
if (hasKeyBorders) {
|
||||||
|
keyBackgroundFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(keyBackground, BlendModeCompat.MODULATE);
|
||||||
|
functionalKeyBackgroundFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(functionalKey, BlendModeCompat.MODULATE);
|
||||||
|
spaceBarFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(spaceBar, BlendModeCompat.MODULATE);
|
||||||
|
keyPressedBackgroundFilter = isDarkColor(keyBackground)
|
||||||
|
? BlendModeColorFilterCompat.createBlendModeColorFilterCompat(keyBackground, BlendModeCompat.SCREEN)
|
||||||
|
: keyBackgroundFilter;
|
||||||
|
functionalKeyPressedBackgroundFilter = isDarkColor(functionalKey)
|
||||||
|
? BlendModeColorFilterCompat.createBlendModeColorFilterCompat(functionalKey, BlendModeCompat.SCREEN)
|
||||||
|
: functionalKeyBackgroundFilter;
|
||||||
|
spaceBarPressedFilter = isDarkColor(spaceBar)
|
||||||
|
? BlendModeColorFilterCompat.createBlendModeColorFilterCompat(spaceBar, BlendModeCompat.SCREEN)
|
||||||
|
: spaceBarFilter;
|
||||||
|
} else {
|
||||||
|
// need to set color to background if key borders are disabled, or there will be ugly keys
|
||||||
|
keyBackgroundFilter = backgroundFilter;
|
||||||
|
functionalKeyBackgroundFilter = backgroundFilter;
|
||||||
|
spaceBarFilter = backgroundFilter;
|
||||||
|
keyPressedBackgroundFilter = isDarkColor(background)
|
||||||
|
? BlendModeColorFilterCompat.createBlendModeColorFilterCompat(background, BlendModeCompat.SCREEN)
|
||||||
|
: keyBackgroundFilter;
|
||||||
|
functionalKeyPressedBackgroundFilter = keyBackgroundFilter;
|
||||||
|
spaceBarPressedFilter = keyBackgroundFilter;
|
||||||
|
}
|
||||||
|
keyTextFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(keyText, BlendModeCompat.SRC_ATOP);
|
||||||
|
keyHintTextFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(keyHintText, BlendModeCompat.SRC_ATOP);
|
||||||
|
accentColorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(accent, BlendModeCompat.SRC_ATOP);
|
||||||
|
actionKeyIconColorFilter = isBrightColor(accent) // the white icon may not have enough contrast, and can't be adjusted by the user
|
||||||
|
? BlendModeColorFilterCompat.createBlendModeColorFilterCompat(Color.DKGRAY, BlendModeCompat.SRC_ATOP)
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isBrightColor(int color) {
|
||||||
|
if (android.R.color.transparent == color) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// See http://www.nbdtech.com/Blog/archive/2008/04/27/Calculating-the-Perceived-Brightness-of-a-Color.aspx
|
||||||
|
int[] rgb = {Color.red(color), Color.green(color), Color.blue(color)};
|
||||||
|
// we are only interested whether brightness is greater, so no need for sqrt
|
||||||
|
int brightnessSquared = (int) (rgb[0] * rgb[0] * .241 + rgb[1] * rgb[1] * .691 + rgb[2] * rgb[2] * .068);
|
||||||
|
return brightnessSquared >= 210*210;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isDarkColor(int color) {
|
||||||
|
if (android.R.color.transparent == color) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// See http://www.nbdtech.com/Blog/archive/2008/04/27/Calculating-the-Perceived-Brightness-of-a-Color.aspx
|
||||||
|
int[] rgb = {Color.red(color), Color.green(color), Color.blue(color)};
|
||||||
|
// we are only interested whether brightness is greater, so no need for sqrt
|
||||||
|
int brightnessSquared = (int) (rgb[0] * rgb[0] * .241 + rgb[1] * rgb[1] * .691 + rgb[2] * rgb[2] * .068);
|
||||||
|
return brightnessSquared < 50*50;
|
||||||
|
}
|
||||||
|
}
|
|
@ -31,6 +31,7 @@ import org.dslul.openboard.inputmethod.keyboard.KeyboardTheme;
|
||||||
import org.dslul.openboard.inputmethod.latin.AudioAndHapticFeedbackManager;
|
import org.dslul.openboard.inputmethod.latin.AudioAndHapticFeedbackManager;
|
||||||
import org.dslul.openboard.inputmethod.latin.InputAttributes;
|
import org.dslul.openboard.inputmethod.latin.InputAttributes;
|
||||||
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.LocaleUtils;
|
import org.dslul.openboard.inputmethod.latin.common.LocaleUtils;
|
||||||
import org.dslul.openboard.inputmethod.latin.common.StringUtils;
|
import org.dslul.openboard.inputmethod.latin.common.StringUtils;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.AdditionalSubtypeUtils;
|
import org.dslul.openboard.inputmethod.latin.utils.AdditionalSubtypeUtils;
|
||||||
|
@ -47,6 +48,7 @@ import java.util.Set;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public final class Settings implements SharedPreferences.OnSharedPreferenceChangeListener {
|
public final class Settings implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
private static final String TAG = Settings.class.getSimpleName();
|
private static final String TAG = Settings.class.getSimpleName();
|
||||||
|
@ -564,58 +566,3 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// class for forwarding custom colors to SettingsValues
|
|
||||||
// (kotlin data class could be 3 lines...)
|
|
||||||
// actually this could contain the color filters too, which would allow more flexibility (only do if needed)
|
|
||||||
class Colors {
|
|
||||||
boolean isCustom;
|
|
||||||
int navBar;
|
|
||||||
int accent;
|
|
||||||
int background;
|
|
||||||
int keyBackground;
|
|
||||||
int functionalKey; // this color will appear darker than set, as it is applied using a color filter in modulate mode
|
|
||||||
int spaceBar;
|
|
||||||
int keyText;
|
|
||||||
int keyHintText;
|
|
||||||
public Colors(int acc, int bg, int k, int fun, int space, int kt, int kht) {
|
|
||||||
isCustom = true;
|
|
||||||
accent = acc;
|
|
||||||
background = bg;
|
|
||||||
keyBackground = k;
|
|
||||||
functionalKey = fun;
|
|
||||||
spaceBar = space;
|
|
||||||
keyText = kt;
|
|
||||||
keyHintText = kht;
|
|
||||||
// slightly adjust color so it matches keyboard background (actually it's a little off)
|
|
||||||
// todo: remove this weird not-really-white? i.e. set actually white background
|
|
||||||
// then the default themes could simply be replaced by a set of colors...
|
|
||||||
// but: this needs to work for the auto-theme too!
|
|
||||||
navBar = Color.rgb((int) (Color.red(background) * 0.925), (int) (Color.green(background) * 0.9379), (int) (Color.blue(background) * 0.945));
|
|
||||||
}
|
|
||||||
public Colors(int themeId, int nightModeFlags) {
|
|
||||||
isCustom = false;
|
|
||||||
if (KeyboardTheme.getIsDayNight(themeId)) {
|
|
||||||
if (nightModeFlags == Configuration.UI_MODE_NIGHT_NO)
|
|
||||||
navBar = Color.rgb(236, 239, 241);
|
|
||||||
else if (themeId == KeyboardTheme.THEME_ID_LXX_DARK)
|
|
||||||
navBar = Color.rgb(38, 50, 56);
|
|
||||||
else
|
|
||||||
navBar = Color.BLACK;
|
|
||||||
} else if (KeyboardTheme.THEME_VARIANT_LIGHT.equals(KeyboardTheme.getThemeVariant(themeId))) {
|
|
||||||
navBar = Color.rgb(236, 239, 241);
|
|
||||||
} else if (themeId == KeyboardTheme.THEME_ID_LXX_DARK) {
|
|
||||||
navBar = Color.rgb(38, 50, 56);
|
|
||||||
} else {
|
|
||||||
// dark border is 13/13/13, but that's ok
|
|
||||||
navBar = Color.BLACK;
|
|
||||||
}
|
|
||||||
accent = 0;
|
|
||||||
background = 0;
|
|
||||||
keyBackground = 0;
|
|
||||||
functionalKey = 0;
|
|
||||||
spaceBar = 0;
|
|
||||||
keyText = 0;
|
|
||||||
keyHintText = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ import org.dslul.openboard.inputmethod.compat.AppWorkaroundsUtils;
|
||||||
import org.dslul.openboard.inputmethod.latin.InputAttributes;
|
import org.dslul.openboard.inputmethod.latin.InputAttributes;
|
||||||
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.common.Colors;
|
||||||
import org.dslul.openboard.inputmethod.latin.spellcheck.AndroidSpellCheckerService;
|
import org.dslul.openboard.inputmethod.latin.spellcheck.AndroidSpellCheckerService;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.AsyncResultHolder;
|
import org.dslul.openboard.inputmethod.latin.utils.AsyncResultHolder;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.ResourceUtils;
|
import org.dslul.openboard.inputmethod.latin.utils.ResourceUtils;
|
||||||
|
@ -127,17 +128,7 @@ public class SettingsValues {
|
||||||
private final AsyncResultHolder<AppWorkaroundsUtils> mAppWorkarounds;
|
private final AsyncResultHolder<AppWorkaroundsUtils> mAppWorkarounds;
|
||||||
|
|
||||||
// User-defined colors
|
// User-defined colors
|
||||||
public final boolean mCustomTheme;
|
public final Colors mColors;
|
||||||
public final ColorFilter mCustomKeyBackgroundColorFilter;
|
|
||||||
public final ColorFilter mCustomFunctionalKeyBackgroundColorFilter;
|
|
||||||
public final ColorFilter mCustomSpaceBarBackgroundColorFilter;
|
|
||||||
public final int mCustomBackgroundColor;
|
|
||||||
public final ColorFilter mCustomBackgroundColorFilter;
|
|
||||||
public final ColorFilter mCustomKeyTextColorFilter;
|
|
||||||
public final ColorFilter mCustomHintTextColorFilter;
|
|
||||||
public final int mCustomThemeColorAccent;
|
|
||||||
public final int mCustomKeyTextColor;
|
|
||||||
public final int mNavBarColor;
|
|
||||||
|
|
||||||
// Debug settings
|
// Debug settings
|
||||||
public final boolean mIsInternal;
|
public final boolean mIsInternal;
|
||||||
|
@ -265,25 +256,8 @@ public class SettingsValues {
|
||||||
mOneHandedModeGravity = Settings.readOneHandedModeGravity(prefs);
|
mOneHandedModeGravity = Settings.readOneHandedModeGravity(prefs);
|
||||||
mSecondaryLocale = Settings.getSecondaryLocale(prefs, RichInputMethodManager.getInstance().getCurrentSubtypeLocale().toString());
|
mSecondaryLocale = Settings.getSecondaryLocale(prefs, RichInputMethodManager.getInstance().getCurrentSubtypeLocale().toString());
|
||||||
|
|
||||||
final Colors colors = Settings.getColors(context.getResources().getConfiguration(), prefs);
|
mColors = Settings.getColors(context.getResources().getConfiguration(), prefs);
|
||||||
mNavBarColor = colors.navBar;
|
mColors.createColorFilters(prefs.getBoolean(Settings.PREF_THEME_KEY_BORDERS, false));
|
||||||
mCustomTheme = colors.isCustom;
|
|
||||||
mCustomThemeColorAccent = colors.accent;
|
|
||||||
mCustomKeyTextColor = colors.keyText;
|
|
||||||
mCustomBackgroundColor = colors.background;
|
|
||||||
mCustomBackgroundColorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(mCustomBackgroundColor, BlendModeCompat.MODULATE);
|
|
||||||
if (prefs.getBoolean(Settings.PREF_THEME_KEY_BORDERS, false)) {
|
|
||||||
mCustomKeyBackgroundColorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(colors.keyBackground, BlendModeCompat.MODULATE);
|
|
||||||
mCustomFunctionalKeyBackgroundColorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(colors.functionalKey, BlendModeCompat.MODULATE);
|
|
||||||
mCustomSpaceBarBackgroundColorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(colors.spaceBar, BlendModeCompat.MODULATE);
|
|
||||||
} else {
|
|
||||||
// need to set color to background if key borders are disabled, or there will be ugly keys
|
|
||||||
mCustomKeyBackgroundColorFilter = mCustomBackgroundColorFilter;
|
|
||||||
mCustomFunctionalKeyBackgroundColorFilter = mCustomBackgroundColorFilter;
|
|
||||||
mCustomSpaceBarBackgroundColorFilter = mCustomBackgroundColorFilter;
|
|
||||||
}
|
|
||||||
mCustomHintTextColorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(colors.keyHintText, BlendModeCompat.SRC_ATOP);
|
|
||||||
mCustomKeyTextColorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(mCustomKeyTextColor, BlendModeCompat.SRC_ATOP);
|
|
||||||
|
|
||||||
mAddToPersonalDictionary = prefs.getBoolean(Settings.PREF_ADD_TO_PERSONAL_DICTIONARY, false);
|
mAddToPersonalDictionary = prefs.getBoolean(Settings.PREF_ADD_TO_PERSONAL_DICTIONARY, false);
|
||||||
mUseContactsDictionary = prefs.getBoolean(AndroidSpellCheckerService.PREF_USE_CONTACTS_KEY, false);
|
mUseContactsDictionary = prefs.getBoolean(AndroidSpellCheckerService.PREF_USE_CONTACTS_KEY, false);
|
||||||
|
|
|
@ -49,6 +49,7 @@ import org.dslul.openboard.inputmethod.latin.PunctuationSuggestions;
|
||||||
import org.dslul.openboard.inputmethod.latin.R;
|
import org.dslul.openboard.inputmethod.latin.R;
|
||||||
import org.dslul.openboard.inputmethod.latin.SuggestedWords;
|
import org.dslul.openboard.inputmethod.latin.SuggestedWords;
|
||||||
import org.dslul.openboard.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
import org.dslul.openboard.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
||||||
|
import org.dslul.openboard.inputmethod.latin.common.Colors;
|
||||||
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;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.ResourceUtils;
|
import org.dslul.openboard.inputmethod.latin.utils.ResourceUtils;
|
||||||
|
@ -508,9 +509,9 @@ final class SuggestionStripLayoutHelper {
|
||||||
// {@link SuggestionStripView#onClick(View)}.
|
// {@link SuggestionStripView#onClick(View)}.
|
||||||
wordView.setTag(indexInSuggestedWords);
|
wordView.setTag(indexInSuggestedWords);
|
||||||
wordView.setText(getStyledSuggestedWord(suggestedWords, indexInSuggestedWords));
|
wordView.setText(getStyledSuggestedWord(suggestedWords, indexInSuggestedWords));
|
||||||
final SettingsValues settingsValues = Settings.getInstance().getCurrent();
|
final Colors colors = Settings.getInstance().getCurrent().mColors;
|
||||||
if (settingsValues.mCustomTheme)
|
if (colors.isCustom)
|
||||||
wordView.setTextColor(settingsValues.mCustomKeyTextColor);
|
wordView.setTextColor(colors.keyText);
|
||||||
else
|
else
|
||||||
wordView.setTextColor(getSuggestionTextColor(suggestedWords, indexInSuggestedWords));
|
wordView.setTextColor(getSuggestionTextColor(suggestedWords, indexInSuggestedWords));
|
||||||
if (SuggestionStripView.DBG) {
|
if (SuggestionStripView.DBG) {
|
||||||
|
|
|
@ -48,6 +48,7 @@ import org.dslul.openboard.inputmethod.latin.AudioAndHapticFeedbackManager;
|
||||||
import org.dslul.openboard.inputmethod.latin.R;
|
import org.dslul.openboard.inputmethod.latin.R;
|
||||||
import org.dslul.openboard.inputmethod.latin.SuggestedWords;
|
import org.dslul.openboard.inputmethod.latin.SuggestedWords;
|
||||||
import org.dslul.openboard.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
import org.dslul.openboard.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
||||||
|
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.define.DebugFlags;
|
import org.dslul.openboard.inputmethod.latin.define.DebugFlags;
|
||||||
import org.dslul.openboard.inputmethod.latin.settings.Settings;
|
import org.dslul.openboard.inputmethod.latin.settings.Settings;
|
||||||
|
@ -181,10 +182,10 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||||
|
|
||||||
mOtherKey.setImageDrawable(iconIncognito);
|
mOtherKey.setImageDrawable(iconIncognito);
|
||||||
|
|
||||||
final SettingsValues settingsValues = Settings.getInstance().getCurrent();
|
final Colors colors = Settings.getInstance().getCurrent().mColors;
|
||||||
if (settingsValues.mCustomTheme) {
|
if (colors.isCustom) {
|
||||||
mStripVisibilityGroup.mSuggestionStripView.getBackground().setColorFilter(settingsValues.mCustomBackgroundColorFilter);
|
mStripVisibilityGroup.mSuggestionStripView.getBackground().setColorFilter(colors.backgroundFilter);
|
||||||
mClipboardKey.setColorFilter(settingsValues.mCustomKeyTextColor);
|
mClipboardKey.setColorFilter(colors.keyText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
package org.dslul.openboard.inputmethod.latin.utils;
|
|
||||||
|
|
||||||
import android.graphics.Color;
|
|
||||||
|
|
||||||
public class ColorUtils {
|
|
||||||
public static boolean isBrightColor(int color) {
|
|
||||||
if (android.R.color.transparent == color) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// See http://www.nbdtech.com/Blog/archive/2008/04/27/Calculating-the-Perceived-Brightness-of-a-Color.aspx
|
|
||||||
boolean bright = false;
|
|
||||||
int[] rgb = {Color.red(color), Color.green(color), Color.blue(color)};
|
|
||||||
int brightness = (int) Math.sqrt(rgb[0] * rgb[0] * .241 + rgb[1] * rgb[1] * .691 + rgb[2] * rgb[2] * .068);
|
|
||||||
if (brightness >= 210) {
|
|
||||||
bright = true;
|
|
||||||
}
|
|
||||||
return bright;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue