Cancellation of current download in details view - UI changes
[pub/Android/ownCloud.git] / src / eu / alefzero / webdav / WebdavUtils.java
index dc407b0..a42b902 100644 (file)
@@ -23,6 +23,8 @@ import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Locale;
 
+import android.net.Uri;
+
 public class WebdavUtils {
     public static final SimpleDateFormat DISPLAY_DATE_FORMAT = new SimpleDateFormat(
             "dd.MM.yyyy hh:mm");
@@ -55,4 +57,20 @@ public class WebdavUtils {
         }
         return null;
     }
+
+    /**
+     * Encodes a path according to URI RFC 2396. 
+     * 
+     * If the received path doesn't start with "/", the method adds it.
+     * 
+     * @param remoteFilePath    Path
+     * @return                  Encoded path according to RFC 2396, always starting with "/"
+     */
+    public static String encodePath(String remoteFilePath) {
+        String encodedPath = Uri.encode(remoteFilePath, "/");
+        if (!encodedPath.startsWith("/"))
+            encodedPath = "/" + encodedPath;
+        return encodedPath;
+    }
+    
 }