use first letter to draw tiles for avatars
some users or conferences might have emojis in their names
This commit is contained in:
parent
44833c1499
commit
f70fcc7bb8
|
@ -370,7 +370,7 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded {
|
||||||
|
|
||||||
private boolean drawTile(Canvas canvas, String name, int left, int top, int right, int bottom) {
|
private boolean drawTile(Canvas canvas, String name, int left, int top, int right, int bottom) {
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
final String letter = name.isEmpty() ? "X" : name.substring(0, 1);
|
final String letter = getFirstLetter(name);
|
||||||
final int color = UIHelper.getColorForName(name);
|
final int color = UIHelper.getColorForName(name);
|
||||||
drawTile(canvas, letter, color, left, top, right, bottom);
|
drawTile(canvas, letter, color, left, top, right, bottom);
|
||||||
return true;
|
return true;
|
||||||
|
@ -378,6 +378,15 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded {
|
||||||
return false;
|
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) {
|
private boolean drawTile(Canvas canvas, Uri uri, int left, int top, int right, int bottom) {
|
||||||
if (uri != null) {
|
if (uri != null) {
|
||||||
Bitmap bitmap = mXmppConnectionService.getFileBackend()
|
Bitmap bitmap = mXmppConnectionService.getFileBackend()
|
||||||
|
|
Loading…
Reference in a new issue