fix issues with keys texts not using user-defined color

This commit is contained in:
Helium314 2023-07-08 08:03:57 +02:00
parent 3f3a2c4230
commit 2439791322

View file

@ -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) {