Update submodule to version with updated .gitignore
[pub/Android/ownCloud.git] / src / com / owncloud / android / utils / DisplayUtils.java
index 544a923..da81f53 100644 (file)
@@ -277,7 +277,24 @@ public class DisplayUtils {
             return url;\r
         }\r
     }\r
-    \r
+\r
+    /**\r
+     * Get the file extension if it is on path as type "content://.../DocInfo.doc"\r
+     * @param filepath: Content Uri converted to string format\r
+     * @return String: fileExtension (type '.pdf'). Empty if no extension\r
+     */\r
+    public static String getComposedFileExtension(String filepath) {\r
+        String fileExtension = "";\r
+        String fileNameInContentUri = filepath.substring(filepath.lastIndexOf("/"));\r
+\r
+        // Check if extension is included in uri\r
+        int pos = fileNameInContentUri.lastIndexOf('.');\r
+        if (pos >= 0) {\r
+            fileExtension = fileNameInContentUri.substring(pos);\r
+        }\r
+        return fileExtension;\r
+    }\r
+\r
     public static CharSequence getRelativeDateTimeString(Context c, long time, long minResolution, long transitionResolution, int flags){\r
         CharSequence dateString = "";\r
         \r
@@ -289,7 +306,7 @@ public class DisplayUtils {
         else if ((System.currentTimeMillis() - time) < 60 * 1000) {\r
             return c.getString(R.string.file_list_seconds_ago);\r
         } else {\r
-            // Workaround 2.x bug\r
+            // Workaround 2.x bug (see https://github.com/owncloud/android/issues/716)\r
             if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB && (System.currentTimeMillis() - time) > 24 * 60 * 60 * 1000){\r
                 Date date = new Date(time);\r
                 date.setHours(0);\r
@@ -301,6 +318,6 @@ public class DisplayUtils {
             }\r
         }\r
         \r
-        return dateString.toString().split(",")[0];\r
+        return dateString.toString().split(",")[0];
     }\r
 }\r