diff options
| author | Jules Aguillon | 2024-02-17 19:31:52 +0100 |
|---|---|---|
| committer | Jules Aguillon | 2024-02-17 23:28:31 +0100 |
| commit | 146d5203254aff5fe19b502a922c60a84c31686a (patch) | |
| tree | c42662fbb6cb0e849694ce44be448ef2b1e1cadf /srcs/juloo.keyboard2 | |
| parent | 065d9520e571eccca21e28d0e4003ebd4b7079f4 (diff) | |
| download | unexpected-keyboard-146d5203254aff5fe19b502a922c60a84c31686a.tar.gz unexpected-keyboard-146d5203254aff5fe19b502a922c60a84c31686a.zip | |
compose: Grey out keys that are not in sequence
Keys that are not in the pending compose sequence are greyed out with
the new 'FLAG_GREYED' flag.
Diffstat (limited to 'srcs/juloo.keyboard2')
| -rw-r--r-- | srcs/juloo.keyboard2/ComposeKey.java | 4 | ||||
| -rw-r--r-- | srcs/juloo.keyboard2/KeyValue.java | 12 | ||||
| -rw-r--r-- | srcs/juloo.keyboard2/Keyboard2View.java | 12 | ||||
| -rw-r--r-- | srcs/juloo.keyboard2/Pointers.java | 2 | ||||
| -rw-r--r-- | srcs/juloo.keyboard2/Theme.java | 3 | ||||
| -rw-r--r-- | srcs/juloo.keyboard2/prefs/ExtraKeysPreference.java | 2 |
6 files changed, 22 insertions, 13 deletions
diff --git a/srcs/juloo.keyboard2/ComposeKey.java b/srcs/juloo.keyboard2/ComposeKey.java index 4a8cff7..dd805a5 100644 --- a/srcs/juloo.keyboard2/ComposeKey.java +++ b/srcs/juloo.keyboard2/ComposeKey.java @@ -14,7 +14,7 @@ public final class ComposeKey KeyValue res = apply(state, kv.getChar()); // Dim characters not part of any sequence instead of removing them. if (res == null) - return kv.withFlags(kv.getFlags() | KeyValue.FLAG_SECONDARY); + return kv.withFlags(kv.getFlags() | KeyValue.FLAG_GREYED); return res; /* These keys must not be removed. */ case Event: @@ -25,7 +25,7 @@ public final class ComposeKey case Keyevent: case Editing: case Placeholder: - return kv.withFlags(kv.getFlags() | KeyValue.FLAG_SECONDARY); + return kv.withFlags(kv.getFlags() | KeyValue.FLAG_GREYED); case Compose_pending: return null; } return null; diff --git a/srcs/juloo.keyboard2/KeyValue.java b/srcs/juloo.keyboard2/KeyValue.java index 4ccb9d3..1a0ed73 100644 --- a/srcs/juloo.keyboard2/KeyValue.java +++ b/srcs/juloo.keyboard2/KeyValue.java @@ -101,7 +101,9 @@ public final class KeyValue public static final int FLAG_LOCK = (1 << FLAGS_OFFSET << 1); // Special keys are not repeated and don't clear latched modifiers. public static final int FLAG_SPECIAL = (1 << FLAGS_OFFSET << 2); - // Free flag: (1 << FLAGS_OFFSET << 3); + // Whether the symbol should be greyed out. For example, keys that are not + // part of the pending compose sequence. + public static final int FLAG_GREYED = (1 << FLAGS_OFFSET << 3); // Rendering flags. public static final int FLAG_KEY_FONT = (1 << FLAGS_OFFSET << 4); // special font file public static final int FLAG_SMALLER_FONT = (1 << FLAGS_OFFSET << 5); // 25% smaller symbols @@ -112,8 +114,8 @@ public final class KeyValue // Ranges for the different components private static final int FLAGS_BITS = - FLAG_LATCH | FLAG_LOCK | FLAG_SPECIAL | FLAG_KEY_FONT | FLAG_SMALLER_FONT | - FLAG_SECONDARY | FLAG_LOCKED | FLAG_FAKE_PTR; + FLAG_LATCH | FLAG_LOCK | FLAG_SPECIAL | FLAG_GREYED | FLAG_KEY_FONT | + FLAG_SMALLER_FONT | FLAG_SECONDARY | FLAG_LOCKED | FLAG_FAKE_PTR; private static final int KIND_BITS = (0b1111 << KIND_OFFSET); // 4 bits wide private static final int VALUE_BITS = ~(FLAGS_BITS | KIND_BITS); // 20 bits wide @@ -140,9 +142,9 @@ public final class KeyValue return (_code & FLAGS_BITS); } - public boolean hasFlags(int has) + public boolean hasFlagsAny(int has) { - return ((_code & has) == has); + return ((_code & has) != 0); } /** The string to render on the keyboard. diff --git a/srcs/juloo.keyboard2/Keyboard2View.java b/srcs/juloo.keyboard2/Keyboard2View.java index 88b718c..bad75bb 100644 --- a/srcs/juloo.keyboard2/Keyboard2View.java +++ b/srcs/juloo.keyboard2/Keyboard2View.java @@ -411,8 +411,12 @@ public class Keyboard2View extends View return _theme.activatedColor; } } - if (k.hasFlags(KeyValue.FLAG_SECONDARY)) + if (k.hasFlagsAny(KeyValue.FLAG_SECONDARY | KeyValue.FLAG_GREYED)) + { + if (k.hasFlagsAny(KeyValue.FLAG_GREYED)) + return _theme.greyedLabelColor; return _theme.secondaryLabelColor; + } return sublabel ? _theme.subLabelColor : _theme.labelColor; } @@ -422,7 +426,7 @@ public class Keyboard2View extends View if (kv == null) return; float textSize = scaleTextSize(kv, _config.labelTextSize, keyH); - Paint p = _theme.labelPaint(kv.hasFlags(KeyValue.FLAG_KEY_FONT)); + Paint p = _theme.labelPaint(kv.hasFlagsAny(KeyValue.FLAG_KEY_FONT)); p.setColor(labelColor(kv, isKeyDown, false)); p.setAlpha(_config.labelBrightness); p.setTextSize(textSize); @@ -438,7 +442,7 @@ public class Keyboard2View extends View if (kv == null) return; float textSize = scaleTextSize(kv, _config.sublabelTextSize, keyH); - Paint p = _theme.subLabelPaint(kv.hasFlags(KeyValue.FLAG_KEY_FONT), a); + Paint p = _theme.subLabelPaint(kv.hasFlagsAny(KeyValue.FLAG_KEY_FONT), a); p.setColor(labelColor(kv, isKeyDown, true)); p.setAlpha(_config.labelBrightness); p.setTextSize(textSize); @@ -472,7 +476,7 @@ public class Keyboard2View extends View private float scaleTextSize(KeyValue k, float rel_size, float keyH) { - float smaller_font = k.hasFlags(KeyValue.FLAG_SMALLER_FONT) ? 0.75f : 1.f; + float smaller_font = k.hasFlagsAny(KeyValue.FLAG_SMALLER_FONT) ? 0.75f : 1.f; return keyH * rel_size * smaller_font * _config.characterSize; } } diff --git a/srcs/juloo.keyboard2/Pointers.java b/srcs/juloo.keyboard2/Pointers.java index 9f4bb6d..6591937 100644 --- a/srcs/juloo.keyboard2/Pointers.java +++ b/srcs/juloo.keyboard2/Pointers.java @@ -391,7 +391,7 @@ public final class Pointers implements Handler.Callback return true; } // Stop repeating: Special keys - if (kv.hasFlags(KeyValue.FLAG_SPECIAL)) + if (kv.hasFlagsAny(KeyValue.FLAG_SPECIAL)) return false; _handler.onPointerHold(kv, ptr.modifiers); return true; diff --git a/srcs/juloo.keyboard2/Theme.java b/srcs/juloo.keyboard2/Theme.java index 0319c99..aedf33a 100644 --- a/srcs/juloo.keyboard2/Theme.java +++ b/srcs/juloo.keyboard2/Theme.java @@ -17,6 +17,7 @@ public class Theme public final int labelColor; public final int subLabelColor; public final int secondaryLabelColor; + public final int greyedLabelColor; public final float keyBorderRadius; public final float keyBorderWidth; @@ -50,6 +51,8 @@ public class Theme subLabelColor = s.getColor(R.styleable.keyboard_colorSubLabel, 0); secondaryLabelColor = adjustLight(labelColor, s.getFloat(R.styleable.keyboard_secondaryDimming, 0.25f)); + greyedLabelColor = adjustLight(labelColor, + s.getFloat(R.styleable.keyboard_greyedDimming, 0.5f)); keyBorderRadius = s.getDimension(R.styleable.keyboard_keyBorderRadius, 0); keyBorderWidth = s.getDimension(R.styleable.keyboard_keyBorderWidth, 0); keyBorderWidthActivated = s.getDimension(R.styleable.keyboard_keyBorderWidthActivated, 0); diff --git a/srcs/juloo.keyboard2/prefs/ExtraKeysPreference.java b/srcs/juloo.keyboard2/prefs/ExtraKeysPreference.java index a99bbe9..6802d97 100644 --- a/srcs/juloo.keyboard2/prefs/ExtraKeysPreference.java +++ b/srcs/juloo.keyboard2/prefs/ExtraKeysPreference.java @@ -166,7 +166,7 @@ public class ExtraKeysPreference extends PreferenceCategory setKey(pref_key_of_key_name(key_name)); setDefaultValue(default_checked); setTitle(title); - _key_font = kv.hasFlags(KeyValue.FLAG_KEY_FONT); + _key_font = kv.hasFlagsAny(KeyValue.FLAG_KEY_FONT); } @Override |
