aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/utils/UIHelper.java
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2014-03-13 03:52:41 +0100
committerDaniel Gultsch <daniel@gultsch.de>2014-03-13 03:52:41 +0100
commita80e3131be975e35c85b3f746cef233fafebaae0 (patch)
treec5997e923a0d32527719546067429e78af7f33e2 /src/eu/siacs/conversations/utils/UIHelper.java
parenteadebeb77cbc4f5b49d484b8a64058630385afe6 (diff)
contact picture generation centralized + basic registry stuff
Diffstat (limited to '')
-rw-r--r--src/eu/siacs/conversations/utils/UIHelper.java22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/eu/siacs/conversations/utils/UIHelper.java b/src/eu/siacs/conversations/utils/UIHelper.java
index b0f79c3a..528a0bb2 100644
--- a/src/eu/siacs/conversations/utils/UIHelper.java
+++ b/src/eu/siacs/conversations/utils/UIHelper.java
@@ -64,7 +64,7 @@ public class UIHelper {
}
}
- public static Bitmap getUnknownContactPicture(String name, int size) {
+ private static Bitmap getUnknownContactPicture(String name, int size) {
String firstLetter = name.substring(0, 1).toUpperCase(Locale.US);
int holoColors[] = { 0xFF1da9da, 0xFFb368d9, 0xFF83b600, 0xFFffa713,
@@ -92,6 +92,9 @@ public class UIHelper {
}
public static Bitmap getContactPicture(Contact contact, int size, Context context) {
+ if (contact==null) {
+ return getUnknownContactPicture(contact.getDisplayName(), size);
+ }
String uri = contact.getProfilePhoto();
if (uri==null) {
return getUnknownContactPicture(contact.getDisplayName(), size);
@@ -299,4 +302,21 @@ public class UIHelper {
builder.setView(view);
return builder.create();
}
+
+ public static Bitmap getSelfContactPicture(Account account, int size, boolean showPhoneSelfContactPicture, Activity activity) {
+ Uri selfiUri = PhoneHelper.getSefliUri(activity);
+ if (selfiUri != null) {
+ try {
+ return BitmapFactory.decodeStream(activity
+ .getContentResolver().openInputStream(selfiUri));
+ } catch (FileNotFoundException e) {
+ return getUnknownContactPicture(account.getJid(), size);
+ }
+ }
+ return getUnknownContactPicture(account.getJid(), size);
+ }
+
+ public static Bitmap getContactPictureByName(String name, int size) {
+ return getUnknownContactPicture(name, size);
+ }
}