diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-11-09 17:02:49 +0100 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-11-09 17:02:49 +0100 |
commit | e9af0d4ca70dc01e1e7815261c098cf58cfc2fde (patch) | |
tree | 8d9c6f334f22f5eba19dab187cac3963edcac7b0 /src/main/java/eu | |
parent | ad6fef063ba152d19c1a08590da7996051bcd836 (diff) | |
parent | 61f046a675978fa53b725e6da18ed27c9f312015 (diff) |
Merge branch 'master' into development
Diffstat (limited to 'src/main/java/eu')
-rw-r--r-- | src/main/java/eu/siacs/conversations/services/AvatarService.java | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/AvatarService.java b/src/main/java/eu/siacs/conversations/services/AvatarService.java index 6f199807..7f76265e 100644 --- a/src/main/java/eu/siacs/conversations/services/AvatarService.java +++ b/src/main/java/eu/siacs/conversations/services/AvatarService.java @@ -22,6 +22,7 @@ public class AvatarService { private static final int FG_COLOR = 0xFFFAFAFA; private static final int TRANSPARENT = 0x00000000; + private static final int PLACEHOLDER_COLOR = 0xFF202020; private static final String PREFIX_CONTACT = "contact"; private static final String PREFIX_CONVERSATION = "conversation"; @@ -140,7 +141,7 @@ public class AvatarService { drawTile(canvas, users.get(0), 0, 0, size / 2 - 1, size / 2 - 1); drawTile(canvas, users.get(1), 0, size / 2 + 1, size / 2 - 1, size); drawTile(canvas, users.get(2), size / 2 + 1, 0, size, size / 2 - 1); - drawTile(canvas, "\u2026", 0xFF202020, size / 2 + 1, size / 2 + 1, + drawTile(canvas, "\u2026", PLACEHOLDER_COLOR, size / 2 + 1, size / 2 + 1, size, size); } this.mXmppConnectionService.getBitmapCache().put(KEY, bitmap); @@ -204,8 +205,15 @@ public class AvatarService { } bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); - String letter = name.substring(0, 1); - int color = this.getColorForName(name); + String letter; + int color; + if (name.length() > 0) { + letter = name.substring(0, 1); + color = this.getColorForName(name); + } else { + letter = "X"; + color = PLACEHOLDER_COLOR; + } drawTile(canvas, letter, color, 0, 0, size, size); mXmppConnectionService.getBitmapCache().put(KEY, bitmap); return bitmap; @@ -255,21 +263,21 @@ public class AvatarService { .cropCenter(uri, bottom - top, right - left); if (bitmap != null) { drawTile(canvas, bitmap, left, top, right, bottom); - } else { - String letter = user.getName().substring(0, 1); - int color = this.getColorForName(user.getName()); - drawTile(canvas, letter, color, left, top, right, bottom); + return; } - } else { - String letter = user.getName().substring(0, 1); - int color = this.getColorForName(user.getName()); - drawTile(canvas, letter, color, left, top, right, bottom); } + } + String name = user.getName(); + String letter; + int color; + if (name.length() > 0) { + letter = name.substring(0, 1); + color = this.getColorForName(name); } else { - String letter = user.getName().substring(0, 1); - int color = this.getColorForName(user.getName()); - drawTile(canvas, letter, color, left, top, right, bottom); + letter = "X"; + color = PLACEHOLDER_COLOR; } + drawTile(canvas, letter, color, left, top, right, bottom); } private void drawTile(Canvas canvas, Bitmap bm, int dstleft, int dsttop, |