aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/eu/siacs/conversations/services/AvatarService.java26
-rw-r--r--src/main/java/eu/siacs/conversations/utils/UIHelper.java3
2 files changed, 9 insertions, 20 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/AvatarService.java b/src/main/java/eu/siacs/conversations/services/AvatarService.java
index 70c1d4dd..3ac4462d 100644
--- a/src/main/java/eu/siacs/conversations/services/AvatarService.java
+++ b/src/main/java/eu/siacs/conversations/services/AvatarService.java
@@ -121,8 +121,8 @@ public class AvatarService {
if (count == 0) {
String name = mucOptions.getConversation().getName();
- String letter = name.substring(0, 1);
- int color = UIHelper.getColorForName(name);
+ final String letter = name.isEmpty() ? "X" : name.substring(0,1);
+ final int color = UIHelper.getColorForName(name);
drawTile(canvas, letter, color, 0, 0, size, size);
} else if (count == 1) {
drawTile(canvas, users.get(0), 0, 0, size, size);
@@ -212,15 +212,8 @@ public class AvatarService {
}
bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
- String letter;
- int color;
- if (name.length() > 0) {
- letter = name.substring(0, 1);
- color = UIHelper.getColorForName(name);
- } else {
- letter = "X";
- color = PLACEHOLDER_COLOR;
- }
+ final String letter = name.isEmpty() ? "X" : name.substring(0,1);
+ final int color = UIHelper.getColorForName(name);
drawTile(canvas, letter, color, 0, 0, size, size);
mXmppConnectionService.getBitmapCache().put(KEY, bitmap);
return bitmap;
@@ -275,15 +268,8 @@ public class AvatarService {
}
}
String name = contact != null ? contact.getDisplayName() : user.getName();
- String letter;
- int color;
- if (name.length() > 0) {
- letter = name.substring(0, 1);
- color = UIHelper.getColorForName(name);
- } else {
- letter = "X";
- color = PLACEHOLDER_COLOR;
- }
+ final String letter = name.isEmpty() ? "X" : name.substring(0,1);
+ final int color = UIHelper.getColorForName(name);
drawTile(canvas, letter, color, left, top, right, bottom);
}
diff --git a/src/main/java/eu/siacs/conversations/utils/UIHelper.java b/src/main/java/eu/siacs/conversations/utils/UIHelper.java
index 341b3d77..28a2bb4c 100644
--- a/src/main/java/eu/siacs/conversations/utils/UIHelper.java
+++ b/src/main/java/eu/siacs/conversations/utils/UIHelper.java
@@ -128,6 +128,9 @@ public class UIHelper {
}
public static int getColorForName(String name) {
+ if (name.isEmpty()) {
+ return 0xFF202020;
+ }
int colors[] = {0xFFe91e63, 0xFF9c27b0, 0xFF673ab7, 0xFF3f51b5,
0xFF5677fc, 0xFF03a9f4, 0xFF00bcd4, 0xFF009688, 0xFFff5722,
0xFF795548, 0xFF607d8b};