From ab987c776c7ddc0fab594f20f4ddf49d98848ccd Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Fri, 24 Jun 2022 20:26:27 +0200 Subject: 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. --- srcs/juloo.keyboard2/Keyboard2View.java | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'srcs/juloo.keyboard2/Keyboard2View.java') 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) -- cgit v1.2.3