fixed #617
This commit is contained in:
parent
f8d5d6b2b5
commit
6a43bda4d7
|
@ -1,5 +1,12 @@
|
||||||
package eu.siacs.conversations.services;
|
package eu.siacs.conversations.services;
|
||||||
|
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Paint;
|
||||||
|
import android.graphics.Rect;
|
||||||
|
import android.graphics.Typeface;
|
||||||
|
import android.net.Uri;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -10,12 +17,6 @@ import eu.siacs.conversations.entities.Contact;
|
||||||
import eu.siacs.conversations.entities.Conversation;
|
import eu.siacs.conversations.entities.Conversation;
|
||||||
import eu.siacs.conversations.entities.ListItem;
|
import eu.siacs.conversations.entities.ListItem;
|
||||||
import eu.siacs.conversations.entities.MucOptions;
|
import eu.siacs.conversations.entities.MucOptions;
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.graphics.Paint;
|
|
||||||
import android.graphics.Rect;
|
|
||||||
import android.graphics.Typeface;
|
|
||||||
import android.net.Uri;
|
|
||||||
|
|
||||||
public class AvatarService {
|
public class AvatarService {
|
||||||
|
|
||||||
|
@ -41,20 +42,15 @@ public class AvatarService {
|
||||||
if (avatar != null) {
|
if (avatar != null) {
|
||||||
return avatar;
|
return avatar;
|
||||||
}
|
}
|
||||||
avatar = mXmppConnectionService.getFileBackend().getAvatar(
|
|
||||||
contact.getAvatar(), size);
|
|
||||||
if (avatar == null) {
|
|
||||||
if (contact.getProfilePhoto() != null) {
|
if (contact.getProfilePhoto() != null) {
|
||||||
avatar = mXmppConnectionService.getFileBackend()
|
avatar = mXmppConnectionService.getFileBackend().cropCenterSquare(Uri.parse(contact.getProfilePhoto()), size);
|
||||||
.cropCenterSquare(Uri.parse(contact.getProfilePhoto()),
|
}
|
||||||
size);
|
if (avatar == null && contact.getAvatar() != null) {
|
||||||
|
avatar = mXmppConnectionService.getFileBackend().getAvatar(contact.getAvatar(), size);
|
||||||
|
}
|
||||||
if (avatar == null) {
|
if (avatar == null) {
|
||||||
avatar = get(contact.getDisplayName(), size);
|
avatar = get(contact.getDisplayName(), size);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
avatar = get(contact.getDisplayName(), size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.mXmppConnectionService.getBitmapCache().put(KEY, avatar);
|
this.mXmppConnectionService.getBitmapCache().put(KEY, avatar);
|
||||||
return avatar;
|
return avatar;
|
||||||
}
|
}
|
||||||
|
@ -248,11 +244,11 @@ public class AvatarService {
|
||||||
Contact contact = user.getContact();
|
Contact contact = user.getContact();
|
||||||
if (contact != null) {
|
if (contact != null) {
|
||||||
Uri uri = null;
|
Uri uri = null;
|
||||||
if (contact.getAvatar() != null) {
|
if (contact.getProfilePhoto() != null) {
|
||||||
|
uri = Uri.parse(contact.getProfilePhoto());
|
||||||
|
} else if (contact.getAvatar() != null) {
|
||||||
uri = mXmppConnectionService.getFileBackend().getAvatarUri(
|
uri = mXmppConnectionService.getFileBackend().getAvatarUri(
|
||||||
contact.getAvatar());
|
contact.getAvatar());
|
||||||
} else if (contact.getProfilePhoto() != null) {
|
|
||||||
uri = Uri.parse(contact.getProfilePhoto());
|
|
||||||
}
|
}
|
||||||
if (uri != null) {
|
if (uri != null) {
|
||||||
Bitmap bitmap = mXmppConnectionService.getFileBackend()
|
Bitmap bitmap = mXmppConnectionService.getFileBackend()
|
||||||
|
@ -283,9 +279,9 @@ public class AvatarService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getColorForName(String name) {
|
private int getColorForName(String name) {
|
||||||
int holoColors[] = { 0xFFe91e63, 0xFF9c27b0, 0xFF673ab7, 0xFF3f51b5,
|
int holoColors[] = {0xFFe91e63, 0xFF9c27b0, 0xFF673ab7, 0xFF3f51b5,
|
||||||
0xFF5677fc, 0xFF03a9f4, 0xFF00bcd4, 0xFF009688, 0xFFff5722,
|
0xFF5677fc, 0xFF03a9f4, 0xFF00bcd4, 0xFF009688, 0xFFff5722,
|
||||||
0xFF795548, 0xFF607d8b };
|
0xFF795548, 0xFF607d8b};
|
||||||
return holoColors[(int) ((name.hashCode() & 0xffffffffl) % holoColors.length)];
|
return holoColors[(int) ((name.hashCode() & 0xffffffffl) % holoColors.length)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue