From: jabarros Date: Mon, 17 Nov 2014 12:49:17 +0000 (+0100) Subject: Merge branch 'develop' into nea_upload_files X-Git-Tag: oc-android-1.7.0_signed~101^2~5 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/a7c4814e282520936a6e22055e66ac05438689dc?ds=inline Merge branch 'develop' into nea_upload_files --- a7c4814e282520936a6e22055e66ac05438689dc diff --cc src/com/owncloud/android/utils/DisplayUtils.java index f8e1accb,d8bf88f3..da81f539 --- a/src/com/owncloud/android/utils/DisplayUtils.java +++ b/src/com/owncloud/android/utils/DisplayUtils.java @@@ -274,21 -277,30 +277,47 @@@ public class DisplayUtils return url; } } - + + /** + * Get the file extension if it is on path as type "content://.../DocInfo.doc" + * @param filepath: Content Uri converted to string format + * @return String: fileExtension (type '.pdf'). Empty if no extension + */ + public static String getComposedFileExtension(String filepath) { + String fileExtension = ""; + String fileNameInContentUri = filepath.substring(filepath.lastIndexOf("/")); + + // Check if extension is included in uri + int pos = fileNameInContentUri.lastIndexOf('.'); + if (pos >= 0) { + fileExtension = fileNameInContentUri.substring(pos); + } + return fileExtension; + } ++ + public static CharSequence getRelativeDateTimeString(Context c, long time, long minResolution, long transitionResolution, int flags){ + CharSequence dateString = ""; + + // in Future + if (time > System.currentTimeMillis()){ + return DisplayUtils.unixTimeToHumanReadable(time); + } + // < 60 seconds -> seconds ago + 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); + } + } + - return dateString.toString().split(",")[0]; ++ return dateString.toString().split(",")[0]; + } }