From 34639f2a2e77ee9d863f50e555070782ef6b4866 Mon Sep 17 00:00:00 2001 From: Sylvia van Os Date: Tue, 29 Mar 2022 22:19:12 +0200 Subject: [PATCH] Don't render text sequences as single character --- app/src/main/java/protect/card_locker/LetterBitmap.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/protect/card_locker/LetterBitmap.java b/app/src/main/java/protect/card_locker/LetterBitmap.java index b36f98e90..3964ca0b0 100644 --- a/app/src/main/java/protect/card_locker/LetterBitmap.java +++ b/app/src/main/java/protect/card_locker/LetterBitmap.java @@ -73,9 +73,10 @@ class LetterBitmap { String firstChar = displayName.substring(0, 1).toUpperCase(); int firstCharEnd = 2; while (firstCharEnd <= displayName.length()) { - // test for the longest render-able string + // Test for the longest render-able string + // But ignore containing only a-Z0-9 to not render things like ffi as a single character String test = displayName.substring(0, firstCharEnd); - if (PaintCompat.hasGlyph(paint, test)) { + if (!isAlphabetical(test) && PaintCompat.hasGlyph(paint, test)) { firstChar = test; } firstCharEnd++; @@ -124,6 +125,10 @@ class LetterBitmap { return colors.getColor(color, Color.BLACK); } + private static boolean isAlphabetical(String string) { + return string.matches("[a-zA-Z0-9]*"); + } + /** * Determine the color which the letter tile will use if no default * color is provided.