From e10c587dc5286db64a6f55010637f0c3f9f62d59 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Sun, 5 Jun 2022 17:26:34 +0200 Subject: Refactor: Abstract KeyValue fields The meaning of the public fields of KeyValue was quite complicated and not handled consistently accross the app. Make these fields private and add a more abstract API on top. The meaning of these fields changed recently and it wasn't an easy change. I plan on making more changes in the future. --- srcs/juloo.keyboard2/Keyboard2View.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'srcs/juloo.keyboard2/Keyboard2View.java') diff --git a/srcs/juloo.keyboard2/Keyboard2View.java b/srcs/juloo.keyboard2/Keyboard2View.java index 4863600..0aa911b 100644 --- a/srcs/juloo.keyboard2/Keyboard2View.java +++ b/srcs/juloo.keyboard2/Keyboard2View.java @@ -268,7 +268,7 @@ public class Keyboard2View extends View private int labelColor(KeyValue k, boolean isKeyDown, int defaultColor) { - if (isKeyDown && (k.flags & KeyValue.FLAG_LATCH) != 0) + if (isKeyDown && k.hasFlags(KeyValue.FLAG_LATCH)) { int flags = _pointers.getKeyFlags(k); if (flags != -1) @@ -288,10 +288,10 @@ public class Keyboard2View extends View if (k == null) return; float textSize = scaleTextSize(k, _config.labelTextSize, keyH); - Paint p = _theme.labelPaint(((k.flags & KeyValue.FLAG_KEY_FONT) != 0)); + Paint p = _theme.labelPaint(k.hasFlags(KeyValue.FLAG_KEY_FONT)); p.setColor(labelColor(k, isKeyDown, _theme.labelColor)); p.setTextSize(textSize); - canvas.drawText(k.symbol, x, (keyH - p.ascent() - p.descent()) / 2f + y, p); + canvas.drawText(k.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) @@ -300,7 +300,7 @@ public class Keyboard2View extends View if (k == null) return; float textSize = scaleTextSize(k, _config.sublabelTextSize, keyH); - Paint p = _theme.subLabelPaint(((k.flags & KeyValue.FLAG_KEY_FONT) != 0), a); + Paint p = _theme.subLabelPaint(k.hasFlags(KeyValue.FLAG_KEY_FONT), a); p.setColor(labelColor(k, isKeyDown, _theme.subLabelColor)); p.setTextSize(textSize); float subPadding = _config.keyPadding; @@ -312,12 +312,12 @@ public class Keyboard2View extends View x += keyW / 2f; else x += (a == Paint.Align.LEFT) ? subPadding : keyW - subPadding; - canvas.drawText(k.symbol, x, y, p); + canvas.drawText(k.getString(), x, y, p); } private float scaleTextSize(KeyValue k, float rel_size, float keyH) { - float smaller_font = ((k.flags & KeyValue.FLAG_SMALLER_FONT) == 0) ? 1.f : 0.75f; + float smaller_font = k.hasFlags(KeyValue.FLAG_SMALLER_FONT) ? 0.75f : 1.f; return keyH * rel_size * smaller_font * _config.characterSize; } } -- cgit v1.2.3