diff options
| author | Jules Aguillon | 2022-06-05 17:26:34 +0200 |
|---|---|---|
| committer | Jules Aguillon | 2022-06-05 17:46:22 +0200 |
| commit | e10c587dc5286db64a6f55010637f0c3f9f62d59 (patch) | |
| tree | 2c39dd330f1915e3c1f8bb353c5db13c3a6c3bd4 /srcs/juloo.keyboard2/Keyboard2View.java | |
| parent | d03e96da3e99e1e0edb78367499c22f574079583 (diff) | |
| download | unexpected-keyboard-e10c587dc5286db64a6f55010637f0c3f9f62d59.tar.gz unexpected-keyboard-e10c587dc5286db64a6f55010637f0c3f9f62d59.zip | |
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.
Diffstat (limited to 'srcs/juloo.keyboard2/Keyboard2View.java')
| -rw-r--r-- | srcs/juloo.keyboard2/Keyboard2View.java | 12 |
1 files changed, 6 insertions, 6 deletions
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; } } |
