From 5fe926b64586f5ac7d3eba7a64de81a710437a14 Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Fri, 6 Jun 2014 11:39:17 +0200 Subject: basic last seen feature. no peristancy just yet. no polish --- src/eu/siacs/conversations/utils/UIHelper.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/eu/siacs/conversations/utils') diff --git a/src/eu/siacs/conversations/utils/UIHelper.java b/src/eu/siacs/conversations/utils/UIHelper.java index 9737040b..15d98d85 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(); -- cgit v1.2.3