diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml
index 77dfb46b8..0a75fa796 100644
--- a/res/values-de/strings.xml
+++ b/res/values-de/strings.xml
@@ -15,6 +15,7 @@
Aus Kontaktliste entfernen
Kontakte
gerade
+ vor %d Minuten
senden…
PGP Ankündigung erneuern
Entschlüssle Nachricht. Bitte warten…
diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml
index af56a2a94..d2088860d 100644
--- a/res/values-es/strings.xml
+++ b/res/values-es/strings.xml
@@ -22,7 +22,7 @@
Conversations
Compartir con Conversación
ahora
- min
+ %d min
conversaciones por leer
enviando…
Renovar anuncio PGP
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 11c5224e6..e960bee33 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -22,7 +22,7 @@
Conversations
Share with Conversation
just now
- min ago
+ %d mins ago
unread Conversations
sending…
Renew PGP announcement
diff --git a/src/eu/siacs/conversations/utils/UIHelper.java b/src/eu/siacs/conversations/utils/UIHelper.java
index d0ea4828b..8ab643df2 100644
--- a/src/eu/siacs/conversations/utils/UIHelper.java
+++ b/src/eu/siacs/conversations/utils/UIHelper.java
@@ -1,8 +1,8 @@
package eu.siacs.conversations.utils;
import java.io.FileNotFoundException;
-import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
@@ -39,6 +39,7 @@ import android.preference.PreferenceManager;
import android.provider.ContactsContract.Contacts;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.TaskStackBuilder;
+import android.text.format.DateFormat;
import android.text.format.DateUtils;
import android.text.Html;
import android.util.DisplayMetrics;
@@ -60,31 +61,40 @@ public class UIHelper {
}
Date date = new Date(time);
long difference = (System.currentTimeMillis() - time) / 1000;
- if (difference < 60) {
+ if (difference < 90) {
return context.getString(R.string.just_now);
- } else if (difference < 60 * 10) {
- return difference / 60 + " " + context.getString(R.string.minutes_ago);
- } else if (difference < 60 * 60 * 24) {
- SimpleDateFormat sdf = new SimpleDateFormat("HH:mm",Locale.US);
- return sdf.format(date);
+ } else if (difference < 60 * 15) {
+ return context.getString(R.string.minutes_ago,Math.round(difference/60.0));
+ } else if (today(date)) {
+ java.text.DateFormat df = DateFormat.getTimeFormat(context);
+ return df.format(date);
} else {
return DateUtils.formatDateTime(context, date.getTime(), DATE_NO_YEAR_FLAGS);
}
}
+ private static boolean today(Date date) {
+ Calendar cal1 = Calendar.getInstance();
+ Calendar cal2 = Calendar.getInstance();
+ cal1.setTime(date);
+ cal2.setTimeInMillis(System.currentTimeMillis());
+ return cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) &&
+ cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR);
+ }
+
public static String lastseen(Context context, long time) {
if (time==0) {
return context.getString(R.string.never_seen);
}
long difference = (System.currentTimeMillis() - time) / 1000;
- if (difference < 60) {
+ if (difference < 90) {
return context.getString(R.string.last_seen_now);
} else if (difference < 60 * 90) {
- return context.getString(R.string.last_seen_mins,difference/60);
+ return context.getString(R.string.last_seen_mins,Math.round(difference/60.0));
} else if (difference < 60 * 60 * 36) {
- return context.getString(R.string.last_seen_hours,difference/(60*60));
+ return context.getString(R.string.last_seen_hours,Math.round(difference/(60.0*60.0)));
} else {
- return context.getString(R.string.last_seen_days,difference/(60*60*24));
+ return context.getString(R.string.last_seen_days,Math.round(difference/(60.0*60.0*24.0)));
}
}
@@ -101,7 +111,6 @@ public class UIHelper {
}
private static void drawTile(Canvas canvas, String letter, int tileColor, int textColor, int left, int top, int right, int bottom) {
- int size = canvas.getWidth();
Paint tilePaint = new Paint(), textPaint = new Paint();
tilePaint.setColor(tileColor);
textPaint.setColor(textColor);