diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2016-05-27 11:34:12 +0200 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2016-05-27 11:34:12 +0200 |
commit | f70fcc7bb8aa02374f664b95d44a9edc38bfdb39 (patch) | |
tree | 0e55d46d8d9eec9b822c3c880166b6022f36059d /src | |
parent | 44833c1499caf41e6433d76a90fa42ab60a5dec1 (diff) |
use first letter to draw tiles for avatars
some users or conferences might have emojis in their names
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/eu/siacs/conversations/services/AvatarService.java | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/AvatarService.java b/src/main/java/eu/siacs/conversations/services/AvatarService.java index 5a58660d4..9e8e6970a 100644 --- a/src/main/java/eu/siacs/conversations/services/AvatarService.java +++ b/src/main/java/eu/siacs/conversations/services/AvatarService.java @@ -370,7 +370,7 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded { private boolean drawTile(Canvas canvas, String name, int left, int top, int right, int bottom) { if (name != null) { - final String letter = name.isEmpty() ? "X" : name.substring(0, 1); + final String letter = getFirstLetter(name); final int color = UIHelper.getColorForName(name); drawTile(canvas, letter, color, left, top, right, bottom); return true; @@ -378,6 +378,15 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded { return false; } + private static String getFirstLetter(String name) { + for(Character c : name.toCharArray()) { + if (Character.isLetterOrDigit(c)) { + return c.toString(); + } + } + return "X"; + } + private boolean drawTile(Canvas canvas, Uri uri, int left, int top, int right, int bottom) { if (uri != null) { Bitmap bitmap = mXmppConnectionService.getFileBackend() |