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.java13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/eu/siacs/conversations/utils/UIHelper.java b/src/eu/siacs/conversations/utils/UIHelper.java
index 9737040bb..15d98d85e 100644
--- a/src/eu/siacs/conversations/utils/UIHelper.java
+++ b/src/eu/siacs/conversations/utils/UIHelper.java
@@ -70,6 +70,19 @@ public class UIHelper {
return sdf.format(date);
}
}
+
+ public static String lastseen(Context context, long time) {
+ long difference = (System.currentTimeMillis() - time) / 1000;
+ if (difference < 60) {
+ return context.getString(R.string.just_now);
+ } else if (difference < 60 * 60) {
+ return difference / 60 + " " + context.getString(R.string.mins);
+ } else if (difference < 60 * 60 * 24) {
+ return difference / (60 * 60)+ " " + context.getString(R.string.hours);
+ } else {
+ return "days";
+ }
+ }
public static int getRealPx(int dp, Context context) {
final DisplayMetrics metrics = context.getResources().getDisplayMetrics();