aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/utils/UIHelper.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/eu/siacs/conversations/utils/UIHelper.java')
-rw-r--r--src/eu/siacs/conversations/utils/UIHelper.java28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/eu/siacs/conversations/utils/UIHelper.java b/src/eu/siacs/conversations/utils/UIHelper.java
index 3571bc3a..faed21de 100644
--- a/src/eu/siacs/conversations/utils/UIHelper.java
+++ b/src/eu/siacs/conversations/utils/UIHelper.java
@@ -1,9 +1,11 @@
package eu.siacs.conversations.utils;
+import java.io.FileNotFoundException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
+import java.util.Locale;
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Account;
@@ -24,6 +26,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
@@ -53,16 +56,16 @@ public class UIHelper {
} else if (difference < 60 * 10) {
return difference / 60 + " min ago";
} else if (difference < 60 * 60 * 24) {
- SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
+ SimpleDateFormat sdf = new SimpleDateFormat("HH:mm",Locale.US);
return sdf.format(date);
} else {
- SimpleDateFormat sdf = new SimpleDateFormat("MM/dd");
+ SimpleDateFormat sdf = new SimpleDateFormat("MM/dd",Locale.US);
return sdf.format(date);
}
}
public static Bitmap getUnknownContactPicture(String name, int size) {
- String firstLetter = name.substring(0, 1).toUpperCase();
+ String firstLetter = name.substring(0, 1).toUpperCase(Locale.US);
int holoColors[] = { 0xFF1da9da, 0xFFb368d9, 0xFF83b600, 0xFFffa713,
0xFFe92727 };
@@ -87,6 +90,19 @@ public class UIHelper {
return bitmap;
}
+
+ public static Bitmap getContactPicture(Contact contact, int size, Context context) {
+ String uri = contact.getProfilePhoto();
+ if (uri==null) {
+ return getUnknownContactPicture(contact.getDisplayName(), size);
+ }
+ try {
+ Bitmap bm = BitmapFactory.decodeStream(context.getContentResolver().openInputStream(Uri.parse(uri)));
+ return Bitmap.createScaledBitmap(bm, size, size, false);
+ } catch (FileNotFoundException e) {
+ return getUnknownContactPicture(contact.getDisplayName(), size);
+ }
+ }
public static Bitmap getErrorPicture(int size) {
Bitmap bitmap = Bitmap
@@ -134,10 +150,12 @@ public class UIHelper {
} else if (unread.size() == 1) {
Conversation conversation = unread.get(0);
targetUuid = conversation.getUuid();
- mBuilder.setLargeIcon(UIHelper.getUnknownContactPicture(
+ /*mBuilder.setLargeIcon(UIHelper.getUnknownContactPicture(
conversation.getName(),
(int) res
- .getDimension(android.R.dimen.notification_large_icon_width)));
+ .getDimension(android.R.dimen.notification_large_icon_width)));*/
+ mBuilder.setLargeIcon(UIHelper.getContactPicture(conversation.getContact(), (int) res
+ .getDimension(android.R.dimen.notification_large_icon_width), context));
mBuilder.setContentTitle(conversation.getName());
if (notify) {
mBuilder.setTicker(conversation.getLatestMessage().getBody().trim());