Fixed problem with some special characters when opening files; renamed WebdavUtils...
authorDavid A. Velasco <dvelasco@solidgear.es>
Tue, 17 Jul 2012 12:26:18 +0000 (14:26 +0200)
committerDavid A. Velasco <dvelasco@solidgear.es>
Tue, 17 Jul 2012 12:26:18 +0000 (14:26 +0200)
AndroidManifest.xml
src/eu/alefzero/owncloud/syncadapter/FileSyncAdapter.java
src/eu/alefzero/owncloud/ui/adapter/FileListActionListAdapter.java
src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java
src/eu/alefzero/webdav/WebdavClient.java
src/eu/alefzero/webdav/WebdavUtils.java

index a547234..362a601 100644 (file)
@@ -18,7 +18,7 @@
  -->\r
 <manifest package="eu.alefzero.owncloud"\r
     android:versionCode="1"\r
  -->\r
 <manifest package="eu.alefzero.owncloud"\r
     android:versionCode="1"\r
-    android:versionName="0.1.161B" xmlns:android="http://schemas.android.com/apk/res/android">\r
+    android:versionName="0.1.162B" xmlns:android="http://schemas.android.com/apk/res/android">\r
 \r
     <uses-permission android:name="android.permission.GET_ACCOUNTS" />\r
     <uses-permission android:name="android.permission.USE_CREDENTIALS" />\r
 \r
     <uses-permission android:name="android.permission.GET_ACCOUNTS" />\r
     <uses-permission android:name="android.permission.USE_CREDENTIALS" />\r
index 61975dd..9dfa8f6 100644 (file)
@@ -220,7 +220,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
             for (int i=0; i < files.size() && !mCancellation; i++) {\r
                 OCFile newFile = files.get(i);\r
                 if (newFile.getMimetype().equals("DIR")) {\r
             for (int i=0; i < files.size() && !mCancellation; i++) {\r
                 OCFile newFile = files.get(i);\r
                 if (newFile.getMimetype().equals("DIR")) {\r
-                    fetchData(getUri().toString() + WebdavUtils.encode(newFile.getRemotePath()), syncResult, newFile.getFileId());\r
+                    fetchData(getUri().toString() + WebdavUtils.encodePath(newFile.getRemotePath()), syncResult, newFile.getFileId());\r
                 }\r
             }\r
             if (mCancellation) Log.d(TAG, "Leaving " + uri + " because cancellation request");\r
                 }\r
             }\r
             if (mCancellation) Log.d(TAG, "Leaving " + uri + " because cancellation request");\r
index d0d5b5f..1556e0d 100644 (file)
@@ -23,6 +23,7 @@ import java.io.File;
 import eu.alefzero.owncloud.R;
 import eu.alefzero.owncloud.authenticator.AccountAuthenticator;
 import eu.alefzero.owncloud.db.ProviderMeta.ProviderTableMeta;
 import eu.alefzero.owncloud.R;
 import eu.alefzero.owncloud.authenticator.AccountAuthenticator;
 import eu.alefzero.owncloud.db.ProviderMeta.ProviderTableMeta;
+import eu.alefzero.webdav.WebdavUtils;
 import android.accounts.Account;
 import android.accounts.AccountManager;
 import android.content.Context;
 import android.accounts.Account;
 import android.accounts.AccountManager;
 import android.content.Context;
@@ -84,7 +85,7 @@ public class FileListActionListAdapter implements ListAdapter {
                         .getSystemService(Context.ACCOUNT_SERVICE);
                 String ocurl = accm.getUserData(mAccount,
                         AccountAuthenticator.KEY_OC_URL);
                         .getSystemService(Context.ACCOUNT_SERVICE);
                 String ocurl = accm.getUserData(mAccount,
                         AccountAuthenticator.KEY_OC_URL);
-                ocurl += mFilePath + Uri.encode(mFilename);
+                ocurl += WebdavUtils.encodePath(mFilePath + mFilename);
                 intent.setData(Uri.parse(ocurl));
             } else {
                 intent.putExtra("toDownload", false);
                 intent.setData(Uri.parse(ocurl));
             } else {
                 intent.putExtra("toDownload", false);
index 7eb0c1b..63d11bf 100644 (file)
@@ -197,6 +197,7 @@ public class FileDetailFragment extends SherlockFragment implements
         IntentFilter filter = new IntentFilter(\r
                 FileDownloader.DOWNLOAD_FINISH_MESSAGE);\r
         getActivity().registerReceiver(mDownloadFinishReceiver, filter);\r
         IntentFilter filter = new IntentFilter(\r
                 FileDownloader.DOWNLOAD_FINISH_MESSAGE);\r
         getActivity().registerReceiver(mDownloadFinishReceiver, filter);\r
+        mPreview = (ImageView)mView.findViewById(R.id.fdPreview);\r
     }\r
 \r
     @Override\r
     }\r
 \r
     @Override\r
@@ -340,9 +341,10 @@ public class FileDetailFragment extends SherlockFragment implements
                     @Override\r
                     public void onClick(View v) {\r
                         String storagePath = mFile.getStoragePath();\r
                     @Override\r
                     public void onClick(View v) {\r
                         String storagePath = mFile.getStoragePath();\r
+                        String encodedStoragePath = WebdavUtils.encodePath(storagePath);\r
                         try {\r
                             Intent i = new Intent(Intent.ACTION_VIEW);\r
                         try {\r
                             Intent i = new Intent(Intent.ACTION_VIEW);\r
-                            i.setDataAndType(Uri.parse("file://"+ storagePath), mFile.getMimetype());\r
+                            i.setDataAndType(Uri.parse("file://"+ encodedStoragePath), mFile.getMimetype());\r
                             i.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);\r
                             startActivity(i);\r
                             \r
                             i.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);\r
                             startActivity(i);\r
                             \r
@@ -354,7 +356,7 @@ public class FileDetailFragment extends SherlockFragment implements
                                 Intent i = new Intent(Intent.ACTION_VIEW);\r
                                 mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(storagePath.substring(storagePath.lastIndexOf('.') + 1));\r
                                 if (mimeType != null && !mimeType.equals(mFile.getMimetype())) {\r
                                 Intent i = new Intent(Intent.ACTION_VIEW);\r
                                 mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(storagePath.substring(storagePath.lastIndexOf('.') + 1));\r
                                 if (mimeType != null && !mimeType.equals(mFile.getMimetype())) {\r
-                                    i.setDataAndType(Uri.parse("file://"+mFile.getStoragePath()), mimeType);\r
+                                    i.setDataAndType(Uri.parse("file://"+ encodedStoragePath), mimeType);\r
                                     i.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);\r
                                     startActivity(i);\r
                                     toastIt = false;\r
                                     i.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);\r
                                     startActivity(i);\r
                                     toastIt = false;\r
@@ -644,11 +646,11 @@ public class FileDetailFragment extends SherlockFragment implements
             String baseUrl = am.getUserData(mAccount, AccountAuthenticator.KEY_OC_BASE_URL);\r
             OwnCloudVersion ocv = new OwnCloudVersion(am.getUserData(mAccount, AccountAuthenticator.KEY_OC_VERSION));\r
             String webdav_path = AccountUtils.getWebdavPath(ocv);\r
             String baseUrl = am.getUserData(mAccount, AccountAuthenticator.KEY_OC_BASE_URL);\r
             OwnCloudVersion ocv = new OwnCloudVersion(am.getUserData(mAccount, AccountAuthenticator.KEY_OC_VERSION));\r
             String webdav_path = AccountUtils.getWebdavPath(ocv);\r
-            Log.d("ASD", ""+baseUrl + webdav_path + WebdavUtils.encode(mOld.getRemotePath()));\r
+            Log.d("ASD", ""+baseUrl + webdav_path + WebdavUtils.encodePath(mOld.getRemotePath()));\r
 \r
 \r
-            Log.e("ASD", Uri.parse(baseUrl).getPath() == null ? "" : Uri.parse(baseUrl).getPath() + webdav_path + WebdavUtils.encode(mNew.getRemotePath()));\r
-            LocalMoveMethod move = new LocalMoveMethod(baseUrl + webdav_path + WebdavUtils.encode(mOld.getRemotePath()),\r
-                                             Uri.parse(baseUrl).getPath() == null ? "" : Uri.parse(baseUrl).getPath() + webdav_path + WebdavUtils.encode(mNew.getRemotePath()));\r
+            Log.e("ASD", Uri.parse(baseUrl).getPath() == null ? "" : Uri.parse(baseUrl).getPath() + webdav_path + WebdavUtils.encodePath(mNew.getRemotePath()));\r
+            LocalMoveMethod move = new LocalMoveMethod(baseUrl + webdav_path + WebdavUtils.encodePath(mOld.getRemotePath()),\r
+                                             Uri.parse(baseUrl).getPath() == null ? "" : Uri.parse(baseUrl).getPath() + webdav_path + WebdavUtils.encodePath(mNew.getRemotePath()));\r
             \r
             try {\r
                 int status = wc.executeMethod(move);\r
             \r
             try {\r
                 int status = wc.executeMethod(move);\r
@@ -772,9 +774,9 @@ public class FileDetailFragment extends SherlockFragment implements
             String baseUrl = am.getUserData(mAccount, AccountAuthenticator.KEY_OC_BASE_URL);\r
             OwnCloudVersion ocv = new OwnCloudVersion(am.getUserData(mAccount, AccountAuthenticator.KEY_OC_VERSION));\r
             String webdav_path = AccountUtils.getWebdavPath(ocv);\r
             String baseUrl = am.getUserData(mAccount, AccountAuthenticator.KEY_OC_BASE_URL);\r
             OwnCloudVersion ocv = new OwnCloudVersion(am.getUserData(mAccount, AccountAuthenticator.KEY_OC_VERSION));\r
             String webdav_path = AccountUtils.getWebdavPath(ocv);\r
-            Log.d("ASD", ""+baseUrl + webdav_path + WebdavUtils.encode(mFileToRemove.getRemotePath()));\r
+            Log.d("ASD", ""+baseUrl + webdav_path + WebdavUtils.encodePath(mFileToRemove.getRemotePath()));\r
 \r
 \r
-            DeleteMethod delete = new DeleteMethod(baseUrl + webdav_path + WebdavUtils.encode(mFileToRemove.getRemotePath()));\r
+            DeleteMethod delete = new DeleteMethod(baseUrl + webdav_path + WebdavUtils.encodePath(mFileToRemove.getRemotePath()));\r
             HttpMethodParams params = delete.getParams();\r
             params.setSoTimeout(1000);\r
             delete.setParams(params);\r
             HttpMethodParams params = delete.getParams();\r
             params.setSoTimeout(1000);\r
             delete.setParams(params);\r
index 9eafddc..e248eb8 100644 (file)
@@ -122,7 +122,7 @@ public class WebdavClient extends HttpClient {
      */\r
     public boolean downloadFile(String remoteFilepath, File targetPath) {\r
         boolean ret = false;\r
      */\r
     public boolean downloadFile(String remoteFilepath, File targetPath) {\r
         boolean ret = false;\r
-        GetMethod get = new GetMethod(mUri.toString() + WebdavUtils.encode(remoteFilepath));\r
+        GetMethod get = new GetMethod(mUri.toString() + WebdavUtils.encodePath(remoteFilepath));\r
         HttpMethodParams params = get.getParams();\r
         params.setSoTimeout(0); // that means "infinite timeout"; it's the default value, but let's make it explicit\r
         get.setParams(params);\r
         HttpMethodParams params = get.getParams();\r
         params.setSoTimeout(0); // that means "infinite timeout"; it's the default value, but let's make it explicit\r
         get.setParams(params);\r
@@ -163,7 +163,7 @@ public class WebdavClient extends HttpClient {
      * @return\r
      */\r
     public boolean deleteFile(String remoteFilePath){\r
      * @return\r
      */\r
     public boolean deleteFile(String remoteFilePath){\r
-        DavMethod delete = new DeleteMethod(mUri.toString() + WebdavUtils.encode(remoteFilePath));\r
+        DavMethod delete = new DeleteMethod(mUri.toString() + WebdavUtils.encodePath(remoteFilePath));\r
         try {\r
             executeMethod(delete);\r
         }  catch (Throwable e) {\r
         try {\r
             executeMethod(delete);\r
         }  catch (Throwable e) {\r
@@ -196,7 +196,7 @@ public class WebdavClient extends HttpClient {
             FileRequestEntity entity = new FileRequestEntity(f, contentType);\r
             entity.setOnDatatransferProgressListener(mDataTransferListener);\r
             Log.e("ASD", f.exists() + " " + entity.getContentLength());\r
             FileRequestEntity entity = new FileRequestEntity(f, contentType);\r
             entity.setOnDatatransferProgressListener(mDataTransferListener);\r
             Log.e("ASD", f.exists() + " " + entity.getContentLength());\r
-            PutMethod put = new PutMethod(mUri.toString() + WebdavUtils.encode(remoteTarget));\r
+            PutMethod put = new PutMethod(mUri.toString() + WebdavUtils.encodePath(remoteTarget));\r
             HttpMethodParams params = put.getParams();\r
             params.setSoTimeout(0); // that means "infinite timeout"; it's the default value, but let's make it explicit\r
             put.setParams(params);\r
             HttpMethodParams params = put.getParams();\r
             params.setSoTimeout(0); // that means "infinite timeout"; it's the default value, but let's make it explicit\r
             put.setParams(params);\r
@@ -242,7 +242,7 @@ public class WebdavClient extends HttpClient {
      */\r
     public boolean createDirectory(String path) {\r
         try {\r
      */\r
     public boolean createDirectory(String path) {\r
         try {\r
-            MkColMethod mkcol = new MkColMethod(mUri.toString() + WebdavUtils.encode(path));\r
+            MkColMethod mkcol = new MkColMethod(mUri.toString() + WebdavUtils.encodePath(path));\r
             int status = executeMethod(mkcol);\r
             Log.d(TAG, "Status returned " + status);\r
             Log.d(TAG, "uri: " + mkcol.getURI().toString());\r
             int status = executeMethod(mkcol);\r
             Log.d(TAG, "Status returned " + status);\r
             Log.d(TAG, "uri: " + mkcol.getURI().toString());\r
index 8e7c07b..b6c0f2e 100644 (file)
@@ -68,7 +68,7 @@ public class WebdavUtils {
      * @param remoteFilePath    Path
      * @return                  Encoded path according to RFC 2396, always starting with "/"
      */
      * @param remoteFilePath    Path
      * @return                  Encoded path according to RFC 2396, always starting with "/"
      */
-    public static String encode(String remoteFilePath) {
+    public static String encodePath(String remoteFilePath) {
         String encodedPath = Uri.encode(remoteFilePath, "/");
         if (!encodedPath.startsWith("/"))
             encodedPath = "/" + encodedPath;
         String encodedPath = Uri.encode(remoteFilePath, "/");
         if (!encodedPath.startsWith("/"))
             encodedPath = "/" + encodedPath;