From 2e598a4d476fde86484cb551c4be77dc5298e7b0 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Mon, 24 Oct 2022 00:27:49 +0200 Subject: Draw letter indication on the pin layout There is no way to type letters on the pin layout, the indication are decoration only. Use the E.161 standard. --- srcs/juloo.keyboard2/Keyboard2View.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'srcs/juloo.keyboard2/Keyboard2View.java') diff --git a/srcs/juloo.keyboard2/Keyboard2View.java b/srcs/juloo.keyboard2/Keyboard2View.java index 7955aca..d82b58a 100644 --- a/srcs/juloo.keyboard2/Keyboard2View.java +++ b/srcs/juloo.keyboard2/Keyboard2View.java @@ -267,6 +267,10 @@ public class Keyboard2View extends View drawSubLabel(canvas, k.key2, x, y, keyW, keyH, Paint.Align.RIGHT, Vertical.TOP, isKeyDown); drawSubLabel(canvas, k.key4, x, y, keyW, keyH, Paint.Align.RIGHT, Vertical.BOTTOM, isKeyDown); } + if (k.indication != null) + { + drawIndication(canvas, k.indication, keyW / 2f + x, y, keyH); + } x += _keyWidth * k.width; } y += row.height * _config.keyHeight; @@ -309,7 +313,9 @@ public class Keyboard2View extends View canvas.drawText(kv.getString(), x, (keyH - p.ascent() - p.descent()) / 2f + y, p); } - private void drawSubLabel(Canvas canvas, KeyboardData.Corner 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) { if (k == null) return; @@ -332,6 +338,17 @@ public class Keyboard2View extends View canvas.drawText(kv.getString(), x, y, p); } + private void drawIndication(Canvas canvas, String indication, float x, + float y, float keyH) + { + float textSize = keyH * _config.sublabelTextSize * _config.characterSize; + Paint p = _theme.indicationPaint(); + p.setColor(_theme.subLabelColor); + p.setTextSize(textSize); + canvas.drawText(indication, x, + (keyH - p.ascent() - p.descent()) * 4/5 + y, p); + } + private float scaleTextSize(KeyValue k, float rel_size, float keyH) { float smaller_font = k.hasFlags(KeyValue.FLAG_SMALLER_FONT) ? 0.75f : 1.f; -- cgit v1.2.3