import android.annotation.TargetApi;\r
import android.content.Context;\r
import android.os.Build;\r
-import android.text.format.DateFormat;\r
import android.text.format.DateUtils;\r
\r
import com.owncloud.android.MainApp;\r
import com.owncloud.android.R;\r
+import com.owncloud.android.datamodel.OCFile;\r
\r
/**\r
* A helper class for some string operations.\r
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
}\r
}\r
\r
- return dateString.toString().split(",")[0];\r
+ return dateString.toString().split(",")[0];
+ }\r
+\r
+ /**\r
+ * Update the passed path removing the last "/" if it is not the root folder\r
+ * @param path\r
+ */\r
+ public static String getPathWithoutLastSlash(String path) {\r
+\r
+ // Remove last slash from path\r
+ if (path.length() > 1 && path.charAt(path.length()-1) == OCFile.PATH_SEPARATOR.charAt(0)) {\r
+ path = path.substring(0, path.length()-1);\r
+ }\r
+ return path;\r
}\r
}\r