diff options
| author | Jules Aguillon | 2022-06-24 20:26:27 +0200 |
|---|---|---|
| committer | Jules Aguillon | 2022-06-24 20:26:27 +0200 |
| commit | ab987c776c7ddc0fab594f20f4ddf49d98848ccd (patch) | |
| tree | abf1c5cbeaecbb30bb67e57db6044117a7260a4a /srcs/juloo.keyboard2/Keyboard2View.java | |
| parent | 6e5be63e25bf2ff2de5c9de5ccd4bc581c639155 (diff) | |
| download | unexpected-keyboard-ab987c776c7ddc0fab594f20f4ddf49d98848ccd.tar.gz unexpected-keyboard-ab987c776c7ddc0fab594f20f4ddf49d98848ccd.zip | |
Fix localized key not in predefined position
The "loc " prefix for predefining a place for an "extra key" was broken
since 31d6a70.
The FLAG_LOCALIZED flag cannot be used anymore, as adding it to any key
would turn it into a different key that wouldn't be recognized by parts
of the code comparing the keys (placing the extra keys).
Add an other layer in KeyboardData to store such informations.
Diffstat (limited to 'srcs/juloo.keyboard2/Keyboard2View.java')
| -rw-r--r-- | srcs/juloo.keyboard2/Keyboard2View.java | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/srcs/juloo.keyboard2/Keyboard2View.java b/srcs/juloo.keyboard2/Keyboard2View.java index 71f05a7..25edd00 100644 --- a/srcs/juloo.keyboard2/Keyboard2View.java +++ b/srcs/juloo.keyboard2/Keyboard2View.java @@ -266,26 +266,30 @@ public class Keyboard2View extends View return defaultColor; } - private void drawLabel(Canvas canvas, KeyValue k, float x, float y, float keyH, boolean isKeyDown) + private void drawLabel(Canvas canvas, KeyboardData.Corner k, float x, float y, float keyH, boolean isKeyDown) { - k = KeyModifier.modify(k, _mods); if (k == null) return; - float textSize = scaleTextSize(k, _config.labelTextSize, keyH); - Paint p = _theme.labelPaint(k.hasFlags(KeyValue.FLAG_KEY_FONT)); - p.setColor(labelColor(k, isKeyDown, _theme.labelColor)); + KeyValue kv = KeyModifier.modify(k.kv, _mods); + if (kv == null) + return; + float textSize = scaleTextSize(kv, _config.labelTextSize, keyH); + Paint p = _theme.labelPaint(kv.hasFlags(KeyValue.FLAG_KEY_FONT)); + p.setColor(labelColor(kv, isKeyDown, _theme.labelColor)); p.setTextSize(textSize); - canvas.drawText(k.getString(), x, (keyH - p.ascent() - p.descent()) / 2f + y, p); + canvas.drawText(kv.getString(), x, (keyH - p.ascent() - p.descent()) / 2f + y, p); } - private void drawSubLabel(Canvas canvas, KeyValue k, float x, float y, float keyW, float keyH, Paint.Align a, Vertical v, boolean isKeyDown) + private void drawSubLabel(Canvas canvas, KeyboardData.Corner k, float x, float y, float keyW, float keyH, Paint.Align a, Vertical v, boolean isKeyDown) { - k = KeyModifier.modify(k, _mods); if (k == null) return; - float textSize = scaleTextSize(k, _config.sublabelTextSize, keyH); - Paint p = _theme.subLabelPaint(k.hasFlags(KeyValue.FLAG_KEY_FONT), a); - p.setColor(labelColor(k, isKeyDown, _theme.subLabelColor)); + KeyValue kv = KeyModifier.modify(k.kv, _mods); + if (kv == null) + return; + float textSize = scaleTextSize(kv, _config.sublabelTextSize, keyH); + Paint p = _theme.subLabelPaint(kv.hasFlags(KeyValue.FLAG_KEY_FONT), a); + p.setColor(labelColor(kv, isKeyDown, _theme.subLabelColor)); p.setTextSize(textSize); float subPadding = _config.keyPadding; if (v == Vertical.CENTER) @@ -296,7 +300,7 @@ public class Keyboard2View extends View x += keyW / 2f; else x += (a == Paint.Align.LEFT) ? subPadding : keyW - subPadding; - canvas.drawText(k.getString(), x, y, p); + canvas.drawText(kv.getString(), x, y, p); } private float scaleTextSize(KeyValue k, float rel_size, float keyH) |
