From 243979132230a33e300338d28c34e2f350ac7c62 Mon Sep 17 00:00:00 2001 From: Helium314 Date: Sat, 8 Jul 2023 08:03:57 +0200 Subject: [PATCH] fix issues with keys texts not using user-defined color --- .../openboard/inputmethod/keyboard/KeyboardView.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 b5b829a28..cbb2bcb0a 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 @@ -461,7 +461,9 @@ public class KeyboardView extends View { paint.setColor(key.selectTextColor(params)); if (mUserTheme) { // set key color only if not in emoji keyboard range - if (keyboard != null && !containsEmoji(key.getLabel())) + if (keyboard != null + && (keyboard.mId.mElementId < 10 || keyboard.mId.mElementId > 26) // not showing emoji keyboard + && !containsEmoji(key.getLabel())) // doesn't contain emoji, necessary for more suggestions view (but doesn't find all) paint.setColorFilter(keyTextColorFilter); else paint.setColorFilter(null); @@ -553,14 +555,16 @@ public class KeyboardView extends View { drawKeyPopupHint(key, canvas, paint, params); } } + private static boolean containsEmoji(String s) { for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); - if (!((c <= 174 && c >= 169) || (c <= 12953 && c >= 8205) || (c >= 126980 && c <=127569))) + if (!(c <= 0xD7FF || (c >= 0xE000 && c <= 0xFFFD) || (c >= 0x10000 && c <= 0x10FFFF))) return true; } return false; } + // Draw popup hint "..." at the bottom right corner of the key. protected void drawKeyPopupHint(@Nonnull final Key key, @Nonnull final Canvas canvas, @Nonnull final Paint paint, @Nonnull final KeyDrawParams params) {