From c97e80432f7d061680417532351d2e69d1337851 Mon Sep 17 00:00:00 2001 From: Branden Archer Date: Sun, 28 Jan 2018 09:49:21 -0500 Subject: [PATCH] Support non-English letters for default card thumbnail --- .../protect/card_locker/LetterBitmap.java | 20 ++----------------- 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/protect/card_locker/LetterBitmap.java b/app/src/main/java/protect/card_locker/LetterBitmap.java index 44c65d087..1da85720d 100644 --- a/app/src/main/java/protect/card_locker/LetterBitmap.java +++ b/app/src/main/java/protect/card_locker/LetterBitmap.java @@ -18,8 +18,6 @@ import android.text.TextPaint; * Used to create a {@link Bitmap} that contains a letter used in the English * alphabet or digit, if there is no letter or digit available, a default image * is shown instead. - * - * Only English language supported. */ class LetterBitmap { @@ -91,17 +89,13 @@ class LetterBitmap public Bitmap getLetterTile(String displayName, String key, int width, int height) { final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); - char firstChar = displayName.charAt(0); + String firstChar = displayName.substring(0, 1); final Canvas c = mCanvas; c.setBitmap(bitmap); c.drawColor(pickColor(key)); - if (!isEnglishLetterOrDigit(firstChar)) - { - firstChar = 'A'; - } - mFirstChar[0] = Character.toUpperCase(firstChar); + mFirstChar[0] = firstChar.toUpperCase().charAt(0); mPaint.setTextSize(mTileLetterFontSize); mPaint.getTextBounds(mFirstChar, 0, 1, mBounds); c.drawText(mFirstChar, 0, 1, width / 2, height / 2 @@ -109,16 +103,6 @@ class LetterBitmap return bitmap; } - /** - * @param c The char to check - * @return True if c is in the English alphabet or is a digit, - * false otherwise - */ - private static boolean isEnglishLetterOrDigit(char c) - { - return 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' || '0' <= c && c <= '9'; - } - /** * @param key The key used to generate the tile color * @return A new or previously chosen color for key used as the