From ae6194ffee024b3267373b60f3baf81b3d8c4069 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Thu, 15 Oct 2015 14:04:56 +0200 Subject: [PATCH 1/4] fix for #1192 --- src/com/owncloud/android/utils/DisplayUtils.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/com/owncloud/android/utils/DisplayUtils.java b/src/com/owncloud/android/utils/DisplayUtils.java index 8a281e92c8..abbf44ee37 100644 --- a/src/com/owncloud/android/utils/DisplayUtils.java +++ b/src/com/owncloud/android/utils/DisplayUtils.java @@ -207,8 +207,17 @@ public class DisplayUtils { dateString = DateUtils.getRelativeDateTimeString(c, time, minResolution, transitionResolution, flags); } } - - return dateString.toString().split(",")[0]; + + String[] parts = dateString.toString().split(","); + if (parts.length == 2) { + if(parts[0].contains(":") && !parts[1].contains(":")) { + return parts[1]; + } else if(parts[1].contains(":") && !parts[0].contains(":")) { + return parts[0]; + } + } + //dateString contains unexpected format. use localized, absolute date. + return DisplayUtils.unixTimeToHumanReadable(time); } /** From e8eda963ae6aaf3ac73500c4b75a3c2d533b6176 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Fri, 16 Oct 2015 11:41:26 +0200 Subject: [PATCH 2/4] flipped the if/else for performance optimization --- src/com/owncloud/android/utils/DisplayUtils.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/com/owncloud/android/utils/DisplayUtils.java b/src/com/owncloud/android/utils/DisplayUtils.java index abbf44ee37..ff6cd8b0d8 100644 --- a/src/com/owncloud/android/utils/DisplayUtils.java +++ b/src/com/owncloud/android/utils/DisplayUtils.java @@ -210,10 +210,10 @@ public class DisplayUtils { String[] parts = dateString.toString().split(","); if (parts.length == 2) { - if(parts[0].contains(":") && !parts[1].contains(":")) { - return parts[1]; - } else if(parts[1].contains(":") && !parts[0].contains(":")) { + if (parts[1].contains(":") && !parts[0].contains(":")) { return parts[0]; + } else if (parts[0].contains(":") && !parts[1].contains(":")) { + return parts[1]; } } //dateString contains unexpected format. use localized, absolute date. From 448124cc7e404b56a6696d55889ffaa170782397 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Thu, 29 Oct 2015 10:24:15 +0100 Subject: [PATCH 3/4] return standard date string as fallback --- src/com/owncloud/android/utils/DisplayUtils.java | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/com/owncloud/android/utils/DisplayUtils.java b/src/com/owncloud/android/utils/DisplayUtils.java index ff6cd8b0d8..9fe9b48cc8 100644 --- a/src/com/owncloud/android/utils/DisplayUtils.java +++ b/src/com/owncloud/android/utils/DisplayUtils.java @@ -193,19 +193,7 @@ public class DisplayUtils { else if ((System.currentTimeMillis() - time) < 60 * 1000) { return c.getString(R.string.file_list_seconds_ago); } else { - // Workaround 2.x bug (see https://github.com/owncloud/android/issues/716) - if ( Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB && - (System.currentTimeMillis() - time) > 24 * 60 * 60 * 1000 ) { - Date date = new Date(time); - date.setHours(0); - date.setMinutes(0); - date.setSeconds(0); - dateString = DateUtils.getRelativeDateTimeString( - c, date.getTime(), minResolution, transitionResolution, flags - ); - } else { - dateString = DateUtils.getRelativeDateTimeString(c, time, minResolution, transitionResolution, flags); - } + dateString = DateUtils.getRelativeDateTimeString(c, time, minResolution, transitionResolution, flags); } String[] parts = dateString.toString().split(","); @@ -217,7 +205,7 @@ public class DisplayUtils { } } //dateString contains unexpected format. use localized, absolute date. - return DisplayUtils.unixTimeToHumanReadable(time); + return dateString.toString(); } /** From 9d4ce6becd3973fb8aff57a2ac2c8b9c9df8a2ec Mon Sep 17 00:00:00 2001 From: LukeOwncloud Date: Thu, 29 Oct 2015 21:03:32 +0100 Subject: [PATCH 4/4] MC: Updated comment only Comment did not reflect last commit change. --- src/com/owncloud/android/utils/DisplayUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/owncloud/android/utils/DisplayUtils.java b/src/com/owncloud/android/utils/DisplayUtils.java index 9fe9b48cc8..a30595c3a4 100644 --- a/src/com/owncloud/android/utils/DisplayUtils.java +++ b/src/com/owncloud/android/utils/DisplayUtils.java @@ -204,7 +204,7 @@ public class DisplayUtils { return parts[1]; } } - //dateString contains unexpected format. use localized, absolute date. + //dateString contains unexpected format. fallback: use relative date time string from android api as is. return dateString.toString(); }