fix some theming issues

This commit is contained in:
Helium314 2023-06-29 10:17:23 +02:00
parent 1799d618c5
commit c468732ca2
8 changed files with 59 additions and 19 deletions

View file

@ -43,8 +43,8 @@ Plan / to do:
* ~improve auto-space insertion, https://github.com/openboard-team/openboard/pull/576~ * ~improve auto-space insertion, https://github.com/openboard-team/openboard/pull/576~
* emoji prediction/search, either https://github.com/openboard-team/openboard/pull/749 (using emoji dictionaries already possible) * emoji prediction/search, either https://github.com/openboard-team/openboard/pull/749 (using emoji dictionaries already possible)
* ~theming, https://github.com/openboard-team/openboard/issues/124~ * ~theming, https://github.com/openboard-team/openboard/issues/124~
* fix emoji view not themed properly * ~fix emoji view not themed properly~
* fix ABC buttons in emoji and clipboard view have wrong text color * ~fix ABC buttons in emoji and clipboard view have wrong text color~
* fix buttons on long-press action key not themed * fix buttons on long-press action key not themed
* allow adjusting colors without requiring manual reload of keyboard * allow adjusting colors without requiring manual reload of keyboard
* ~delete suggestions, https://github.com/openboard-team/openboard/issues/106~ * ~delete suggestions, https://github.com/openboard-team/openboard/issues/106~

View file

@ -463,6 +463,8 @@ public class KeyboardView extends View {
// set key color only if not in emoji keyboard range // set key color only if not in emoji keyboard range
if (keyboard != null && (keyboard.mId.mElementId < 10 || keyboard.mId.mElementId > 26)) if (keyboard != null && (keyboard.mId.mElementId < 10 || keyboard.mId.mElementId > 26))
paint.setColorFilter(keyTextColorFilter); paint.setColorFilter(keyTextColorFilter);
else
paint.setColorFilter(null);
} }
// 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) {

View file

@ -1,5 +1,6 @@
package org.dslul.openboard.inputmethod.keyboard.clipboard package org.dslul.openboard.inputmethod.keyboard.clipboard
import android.graphics.ColorFilter
import android.graphics.Typeface import android.graphics.Typeface
import android.util.TypedValue import android.util.TypedValue
import android.view.LayoutInflater import android.view.LayoutInflater
@ -22,6 +23,7 @@ class ClipboardAdapter(
var pinnedIconResId = 0 var pinnedIconResId = 0
var itemBackgroundId = 0 var itemBackgroundId = 0
var itemBackgroundColorFilter: ColorFilter? = null
var itemTypeFace: Typeface? = null var itemTypeFace: Typeface? = null
var itemTextColor = 0 var itemTextColor = 0
var itemTextSize = 0f var itemTextSize = 0f
@ -53,6 +55,7 @@ class ClipboardAdapter(
setOnTouchListener(this@ViewHolder) setOnTouchListener(this@ViewHolder)
setOnLongClickListener(this@ViewHolder) setOnLongClickListener(this@ViewHolder)
setBackgroundResource(itemBackgroundId) setBackgroundResource(itemBackgroundId)
background.colorFilter = itemBackgroundColorFilter
} }
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

@ -6,6 +6,7 @@ import android.graphics.Paint
import android.util.AttributeSet import android.util.AttributeSet
import android.view.View import android.view.View
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import org.dslul.openboard.inputmethod.latin.settings.Settings
class ClipboardHistoryRecyclerView @JvmOverloads constructor( class ClipboardHistoryRecyclerView @JvmOverloads constructor(
context: Context, context: Context,
@ -62,6 +63,9 @@ class ClipboardHistoryRecyclerView @JvmOverloads constructor(
init { init {
paint.color = dividerColor paint.color = dividerColor
paint.strokeWidth = dividerHeight.toFloat() paint.strokeWidth = dividerHeight.toFloat()
val sv = Settings.getInstance().current
if (sv.mUserTheme)
paint.colorFilter = sv.mBackgroundColorFilter
} }
override fun onDrawOver(canvas: Canvas, parent: RecyclerView, state: State) { override fun onDrawOver(canvas: Canvas, parent: RecyclerView, state: State) {

View file

@ -1,7 +1,6 @@
package org.dslul.openboard.inputmethod.keyboard.clipboard package org.dslul.openboard.inputmethod.keyboard.clipboard
import android.content.Context import android.content.Context
import android.graphics.Color
import android.util.AttributeSet import android.util.AttributeSet
import android.util.TypedValue import android.util.TypedValue
import android.view.MotionEvent import android.view.MotionEvent
@ -10,8 +9,6 @@ import android.widget.FrameLayout
import android.widget.ImageButton import android.widget.ImageButton
import android.widget.LinearLayout import android.widget.LinearLayout
import android.widget.TextView import android.widget.TextView
import androidx.core.graphics.BlendModeColorFilterCompat
import androidx.core.graphics.BlendModeCompat
import androidx.recyclerview.widget.StaggeredGridLayoutManager import androidx.recyclerview.widget.StaggeredGridLayoutManager
import org.dslul.openboard.inputmethod.keyboard.KeyboardActionListener import org.dslul.openboard.inputmethod.keyboard.KeyboardActionListener
import org.dslul.openboard.inputmethod.keyboard.internal.KeyDrawParams import org.dslul.openboard.inputmethod.keyboard.internal.KeyDrawParams
@ -93,29 +90,34 @@ 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 cf = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(Color.CYAN, BlendModeCompat.MODULATE)
val settingsValues = Settings.getInstance().current 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)
setOnTouchListener(this@ClipboardHistoryView) setOnTouchListener(this@ClipboardHistoryView)
setOnClickListener(this@ClipboardHistoryView) setOnClickListener(this@ClipboardHistoryView)
background.colorFilter = settingsValues.mKeyBackgroundColorFilter
setTextColor(settingsValues.mKeyTextColor)
} }
clearKey = findViewById<ImageButton>(R.id.clipboard_clear).apply { clearKey = findViewById<ImageButton>(R.id.clipboard_clear).apply {
setOnTouchListener(this@ClipboardHistoryView) setOnTouchListener(this@ClipboardHistoryView)
setOnClickListener(this@ClipboardHistoryView) setOnClickListener(this@ClipboardHistoryView)
colorFilter = settingsValues.mKeyTextColorFilter
} }
background.colorFilter = settingsValues.mBackgroundColorFilter if (settingsValues.mUserTheme) {
alphabetKey.background.colorFilter = settingsValues.mKeyBackgroundColorFilter
alphabetKey.setTextColor(settingsValues.mKeyTextColor)
clearKey.colorFilter = settingsValues.mKeyTextColorFilter
background.colorFilter = settingsValues.mBackgroundColorFilter
}
} }
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
setTextColor(params.mFunctionalTextColor) val settingsValues = Settings.getInstance().current
if (settingsValues.mUserTheme)
setTextColor(settingsValues.mKeyTextColor)
else
setTextColor(params.mFunctionalTextColor)
setTextSize(TypedValue.COMPLEX_UNIT_PX, params.mLabelSize.toFloat()) setTextSize(TypedValue.COMPLEX_UNIT_PX, params.mLabelSize.toFloat())
} }
} }
@ -124,7 +126,12 @@ class ClipboardHistoryView @JvmOverloads constructor(
clipboardAdapter.apply { clipboardAdapter.apply {
itemBackgroundId = keyBackgroundId itemBackgroundId = keyBackgroundId
itemTypeFace = params.mTypeface itemTypeFace = params.mTypeface
itemTextColor = params.mTextColor val sv = Settings.getInstance().current
if (sv.mUserTheme) {
itemTextColor = sv.mKeyTextColor
itemBackgroundColorFilter = sv.mKeyBackgroundColorFilter
} else
itemTextColor = params.mTextColor
itemTextSize = params.mLabelSize.toFloat() itemTextSize = params.mLabelSize.toFloat()
} }
} }

View file

@ -100,6 +100,8 @@ public final class EmojiPalettesView extends LinearLayout
private final EmojiCategory mEmojiCategory; private final EmojiCategory mEmojiCategory;
private ImageView mCurrentTab = null;
public EmojiPalettesView(final Context context, final AttributeSet attrs) { public EmojiPalettesView(final Context context, final AttributeSet attrs) {
this(context, attrs, R.attr.emojiPalettesViewStyle); this(context, attrs, R.attr.emojiPalettesViewStyle);
} }
@ -164,6 +166,11 @@ 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();
if (settingsValues.mUserTheme) {
iconView.getBackground().setColorFilter(settingsValues.mBackgroundColorFilter);
iconView.setColorFilter(settingsValues.mKeyTextColorFilter);
}
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);
@ -265,11 +272,16 @@ 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 ColorFilter cf = Settings.getInstance().getCurrent().mKeyBackgroundColorFilter; final SettingsValues settingsValues = Settings.getInstance().getCurrent();
mAlphabetKeyLeft.getBackground().setColorFilter(cf); if (settingsValues.mUserTheme) {
mAlphabetKeyLeft.setTextColor(Settings.getInstance().getCurrent().mKeyTextColor); final ColorFilter cf = settingsValues.mKeyBackgroundColorFilter;
mSpacebar.getBackground().setColorFilter(cf); mAlphabetKeyLeft.getBackground().setColorFilter(cf);
mDeleteKey.getBackground().setColorFilter(cf); mSpacebar.getBackground().setColorFilter(cf);
mDeleteKey.getBackground().setColorFilter(cf);
getBackground().setColorFilter(cf);
mEmojiCategoryPageIndicatorView.setColors(settingsValues.mUserThemeColorAccent, settingsValues.mBackgroundColor);
findViewById(R.id.emoji_tab_strip).getBackground().setColorFilter(cf);
}
mEmojiLayoutParams.setKeyProperties(mSpacebar); mEmojiLayoutParams.setKeyProperties(mSpacebar);
mSpacebarIcon = findViewById(R.id.emoji_keyboard_space_icon); mSpacebarIcon = findViewById(R.id.emoji_keyboard_space_icon);
} }
@ -291,6 +303,13 @@ public final class EmojiPalettesView extends LinearLayout
setCurrentCategoryAndPageId(categoryId, 0, false /* force */); setCurrentCategoryAndPageId(categoryId, 0, false /* force */);
updateEmojiCategoryPageIdView(); updateEmojiCategoryPageIdView();
} }
final SettingsValues settingsValues = Settings.getInstance().getCurrent();
if (settingsValues.mUserTheme) {
if (mCurrentTab != null)
mCurrentTab.setColorFilter(settingsValues.mKeyTextColorFilter);
mCurrentTab = (ImageView) mTabHost.getCurrentTabView();
mCurrentTab.setColorFilter(settingsValues.mUserThemeColorAccent);
}
} }
/** /**
@ -374,7 +393,11 @@ 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);
alphabetKey.setTextColor(params.mFunctionalTextColor); final SettingsValues settingsValues = Settings.getInstance().getCurrent();
if (settingsValues.mUserTheme)
alphabetKey.setTextColor(settingsValues.mKeyTextColor);
else
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

@ -126,7 +126,7 @@ public class SettingsValues {
private final AsyncResultHolder<AppWorkaroundsUtils> mAppWorkarounds; private final AsyncResultHolder<AppWorkaroundsUtils> mAppWorkarounds;
// User-defined colors // User-defined colors
public boolean mUserTheme; public final boolean mUserTheme;
public final ColorFilter mKeyBackgroundColorFilter; public final ColorFilter mKeyBackgroundColorFilter;
public final int mBackgroundColor; public final int mBackgroundColor;
public final ColorFilter mBackgroundColorFilter; public final ColorFilter mBackgroundColorFilter;

View file

@ -27,6 +27,7 @@
style="?attr/emojiPalettesViewStyle" style="?attr/emojiPalettesViewStyle"
> >
<LinearLayout <LinearLayout
android:id="@+id/emoji_tab_strip"
android:orientation="horizontal" android:orientation="horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/config_suggestions_strip_height" android:layout_height="@dimen/config_suggestions_strip_height"