diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2010-10-03 04:15:16 +0100 |
---|---|---|
committer | Kenny Root <kenny@the-b.org> | 2015-04-14 16:22:48 -0700 |
commit | 666188f538a8f7e0f1a71a30cc5c07daa0f2f240 (patch) | |
tree | 5e1262c712566bd7f8961a3af90d892292e37046 /src/org | |
parent | 28b8406580e9c0565fc2090117bc06d5c28b79c2 (diff) | |
download | connectbot-666188f538a8f7e0f1a71a30cc5c07daa0f2f240.tar.gz connectbot-666188f538a8f7e0f1a71a30cc5c07daa0f2f240.tar.bz2 connectbot-666188f538a8f7e0f1a71a30cc5c07daa0f2f240.zip |
Use DateUtils.getRelativeTimeSpanString
Closes #2
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/connectbot/HostListActivity.java | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/src/org/connectbot/HostListActivity.java b/src/org/connectbot/HostListActivity.java index de2b5f1..265dd08 100644 --- a/src/org/connectbot/HostListActivity.java +++ b/src/org/connectbot/HostListActivity.java @@ -45,6 +45,7 @@ import android.os.Handler; import android.os.IBinder; import android.os.Message; import android.preference.PreferenceManager; +import android.text.format.DateUtils; import android.util.Log; import android.view.ContextMenu; import android.view.KeyEvent; @@ -558,20 +559,9 @@ public class HostListActivity extends ListActivity { holder.caption.setTextAppearance(context, android.R.attr.textAppearanceSmall); } - long now = System.currentTimeMillis() / 1000; - - String nice = context.getString(R.string.bind_never); + CharSequence nice = context.getString(R.string.bind_never); if (host.getLastConnect() > 0) { - int minutes = (int)((now - host.getLastConnect()) / 60); - if (minutes >= 60) { - int hours = (minutes / 60); - if (hours >= 24) { - int days = (hours / 24); - nice = context.getString(R.string.bind_days, days); - } else - nice = context.getString(R.string.bind_hours, hours); - } else - nice = context.getString(R.string.bind_minutes, minutes); + nice = DateUtils.getRelativeTimeSpanString(host.getLastConnect() * 1000); } holder.caption.setText(nice); |