diff --git a/res/values/strings.xml b/res/values/strings.xml index af5a684d7f..65ffc63d8b 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -60,6 +60,7 @@ No content was received. Nothing to upload. %1$s is not allowed to access the shared content Uploading + seconds ago Nothing in here. Upload something! Loading... There are no files in this folder. diff --git a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java index 36da6effa2..8283f366e5 100644 --- a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java +++ b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java @@ -516,12 +516,7 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter { } private CharSequence showRelativeTimestamp(OCFile file){ - Log_OC.d("Timestamp", "File: " + file.getModificationTimestamp() + " system: " + System.currentTimeMillis()); - if (file.getModificationTimestamp() > System.currentTimeMillis()){ - return DisplayUtils.unixTimeToHumanReadable(file.getModificationTimestamp()); - } else { - return DateUtils.getRelativeDateTimeString(mContext, file.getModificationTimestamp(), - DateUtils.SECOND_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, 0); - } + return DisplayUtils.getRelativeDateTimeString(mContext, file.getModificationTimestamp(), + DateUtils.SECOND_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, 0); } } diff --git a/src/com/owncloud/android/utils/DisplayUtils.java b/src/com/owncloud/android/utils/DisplayUtils.java index 682d2be09b..3d51f1f6b2 100644 --- a/src/com/owncloud/android/utils/DisplayUtils.java +++ b/src/com/owncloud/android/utils/DisplayUtils.java @@ -18,6 +18,8 @@ package com.owncloud.android.utils; +import java.sql.Time; +import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Calendar; import java.util.Date; @@ -25,7 +27,12 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Set; +import android.content.Context; +import android.text.format.DateFormat; +import android.text.format.DateUtils; + import com.owncloud.android.R; +import com.owncloud.android.lib.common.utils.Log_OC; /** * A helper class for some string operations. @@ -235,4 +242,15 @@ public class DisplayUtils { return R.drawable.icon; } } + + public static CharSequence getRelativeDateTimeString(Context c, long time, long minResolution, long transitionResolution, int flags){ + if (time > System.currentTimeMillis()){ + return DisplayUtils.unixTimeToHumanReadable(time); + } else if ((System.currentTimeMillis() - time) < 60000) { + return c.getString(R.string.file_list_seconds_ago) + ", " + + DateFormat.getTimeFormat(c).format(new Date(time)); + } else { + return DateUtils.getRelativeDateTimeString(c, time, minResolution, transitionResolution, flags); + } + } }