From 6a547da17ba8f4ecb568f0b5382ed2bb1ca5a850 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 22 Nov 2019 11:36:49 +0100 Subject: [PATCH] Letter icons for non latin characters --- app/src/main/java/eu/faircode/email/Helper.java | 6 ++++++ app/src/main/java/eu/faircode/email/ImageHelper.java | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/Helper.java b/app/src/main/java/eu/faircode/email/Helper.java index 70754fea18..1aa8a05044 100644 --- a/app/src/main/java/eu/faircode/email/Helper.java +++ b/app/src/main/java/eu/faircode/email/Helper.java @@ -404,6 +404,12 @@ public class Helper { return df.format(bytes / Math.pow(unit, exp)) + " " + pre + "B"; } + static boolean isPrintableChar(char c) { + Character.UnicodeBlock block = Character.UnicodeBlock.of(c); + if (block == null || block == Character.UnicodeBlock.SPECIALS) + return false; + return !Character.isISOControl(c); + } // https://issuetracker.google.com/issues/37054851 static DateFormat getTimeInstance(Context context) { diff --git a/app/src/main/java/eu/faircode/email/ImageHelper.java b/app/src/main/java/eu/faircode/email/ImageHelper.java index 20ddd557b6..cbaef128d6 100644 --- a/app/src/main/java/eu/faircode/email/ImageHelper.java +++ b/app/src/main/java/eu/faircode/email/ImageHelper.java @@ -115,7 +115,7 @@ class ImageHelper { String letter = null; for (int i = 0; i < name.length(); i++) { char kar = name.charAt(i); - if (Character.isAlphabetic(kar)) { + if (Helper.isPrintableChar(kar)) { letter = name.substring(i, i + 1).toUpperCase(); break; }