From eb56c80ffb8521ac6076abf9319874b848a3df3c Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Sun, 6 Aug 2023 18:17:59 +0200 Subject: [PATCH] Elide custom keys labels Make the font smaller for custom keys with a length above 1. Draw up to 4 characters on keys. --- srcs/juloo.keyboard2/KeyValue.java | 2 +- srcs/juloo.keyboard2/Keyboard2View.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/srcs/juloo.keyboard2/KeyValue.java b/srcs/juloo.keyboard2/KeyValue.java index a394240..f15eb68 100644 --- a/srcs/juloo.keyboard2/KeyValue.java +++ b/srcs/juloo.keyboard2/KeyValue.java @@ -296,7 +296,7 @@ final class KeyValue if (str.length() == 1) return new KeyValue(str, Kind.Char, str.charAt(0), 0); else - return new KeyValue(str, Kind.String, 0, 0); + return new KeyValue(str, Kind.String, 0, FLAG_SMALLER_FONT); } public static KeyValue getKeyByName(String name) diff --git a/srcs/juloo.keyboard2/Keyboard2View.java b/srcs/juloo.keyboard2/Keyboard2View.java index f4053f2..1dfaa16 100644 --- a/srcs/juloo.keyboard2/Keyboard2View.java +++ b/srcs/juloo.keyboard2/Keyboard2View.java @@ -407,7 +407,8 @@ public class Keyboard2View extends View x += keyW / 2f; else x += (a == Paint.Align.LEFT) ? subPadding : keyW - subPadding; - canvas.drawText(kv.getString(), x, y, p); + String label = kv.getString(); + canvas.drawText(label, 0, Math.min(4, label.length()), x, y, p); } private void drawIndication(Canvas canvas, String indication, float x,