diff options
Diffstat (limited to '')
-rw-r--r-- | res/values-de/strings.xml | 1 | ||||
-rw-r--r-- | res/values-es/strings.xml | 2 | ||||
-rw-r--r-- | res/values/strings.xml | 2 | ||||
-rw-r--r-- | src/eu/siacs/conversations/utils/UIHelper.java | 33 |
4 files changed, 24 insertions, 14 deletions
diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index 77dfb46b..0a75fa79 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -15,6 +15,7 @@ <string name="action_delete_contact">Aus Kontaktliste entfernen</string> <string name="title_activity_contacts">Kontakte</string> <string name="just_now">gerade</string> + <string name="minutes_ago">vor %d Minuten</string> <string name="sending">senden…</string> <string name="announce_pgp">PGP Ankündigung erneuern</string> <string name="encrypted_message">Entschlüssle Nachricht. Bitte warten…</string> diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index af56a2a9..d2088860 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -22,7 +22,7 @@ <string name="title_activity_conversations">Conversations</string> <string name="title_activity_sharewith">Compartir con Conversación</string> <string name="just_now">ahora</string> - <string name="minutes_ago">min</string> + <string name="minutes_ago">%d min</string> <string name="unread_conversations">conversaciones por leer</string> <string name="sending">enviando…</string> <string name="announce_pgp">Renovar anuncio PGP</string> diff --git a/res/values/strings.xml b/res/values/strings.xml index 11c5224e..e960bee3 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -22,7 +22,7 @@ <string name="title_activity_conversations">Conversations</string> <string name="title_activity_sharewith">Share with Conversation</string> <string name="just_now">just now</string> - <string name="minutes_ago">min ago</string> + <string name="minutes_ago">%d mins ago</string> <string name="unread_conversations">unread Conversations</string> <string name="sending">sending…</string> <string name="announce_pgp">Renew PGP announcement</string> diff --git a/src/eu/siacs/conversations/utils/UIHelper.java b/src/eu/siacs/conversations/utils/UIHelper.java index d0ea4828..8ab643df 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); |