OCFile stores again decoded remote paths; WebdavUtils.encode(...) added; fixed space...
[pub/Android/ownCloud.git] / src / eu / alefzero / owncloud / ui / fragment / FileDetailFragment.java
index db91641..7eb0c1b 100644 (file)
@@ -95,6 +95,7 @@ import eu.alefzero.owncloud.files.services.FileDownloader;
 import eu.alefzero.owncloud.ui.activity.FileDisplayActivity;\r
 import eu.alefzero.owncloud.utils.OwnCloudVersion;\r
 import eu.alefzero.webdav.WebdavClient;\r
 import eu.alefzero.owncloud.ui.activity.FileDisplayActivity;\r
 import eu.alefzero.owncloud.utils.OwnCloudVersion;\r
 import eu.alefzero.webdav.WebdavClient;\r
+import eu.alefzero.webdav.WebdavUtils;\r
 \r
 /**\r
  * This Fragment is used to display the details about a file.\r
 \r
 /**\r
  * This Fragment is used to display the details about a file.\r
@@ -205,7 +206,6 @@ public class FileDetailFragment extends SherlockFragment implements
         mDownloadFinishReceiver = null;\r
         if (mPreview != null) {\r
             mPreview = null;\r
         mDownloadFinishReceiver = null;\r
         if (mPreview != null) {\r
             mPreview = null;\r
-            System.gc();\r
         }\r
     }\r
 \r
         }\r
     }\r
 \r
@@ -224,7 +224,7 @@ public class FileDetailFragment extends SherlockFragment implements
                 Intent i = new Intent(getActivity(), FileDownloader.class);\r
                 i.putExtra(FileDownloader.EXTRA_ACCOUNT, mAccount);\r
                 i.putExtra(FileDownloader.EXTRA_REMOTE_PATH, mFile.getRemotePath());\r
                 Intent i = new Intent(getActivity(), FileDownloader.class);\r
                 i.putExtra(FileDownloader.EXTRA_ACCOUNT, mAccount);\r
                 i.putExtra(FileDownloader.EXTRA_REMOTE_PATH, mFile.getRemotePath());\r
-                i.putExtra(FileDownloader.EXTRA_FILE_PATH, mFile.getURLDecodedRemotePath());\r
+                i.putExtra(FileDownloader.EXTRA_FILE_PATH, mFile.getRemotePath());\r
                 i.putExtra(FileDownloader.EXTRA_FILE_SIZE, mFile.getFileLength());\r
                 v.setEnabled(false);\r
                 getActivity().startService(i);\r
                 i.putExtra(FileDownloader.EXTRA_FILE_SIZE, mFile.getFileLength());\r
                 v.setEnabled(false);\r
                 getActivity().startService(i);\r
@@ -603,7 +603,7 @@ public class FileDetailFragment extends SherlockFragment implements
                 if (!newFilename.equals(mFile.getFileName())) {\r
                     FileDataStorageManager fdsm = new FileDataStorageManager(mAccount, getActivity().getContentResolver());\r
                     if (fdsm.getFileById(mFile.getFileId()) != null) {\r
                 if (!newFilename.equals(mFile.getFileName())) {\r
                     FileDataStorageManager fdsm = new FileDataStorageManager(mAccount, getActivity().getContentResolver());\r
                     if (fdsm.getFileById(mFile.getFileId()) != null) {\r
-                        OCFile newFile = new OCFile(fdsm.getFileById(mFile.getParentId()).getRemotePath()+"/"+newFilename);\r
+                        OCFile newFile = new OCFile(fdsm.getFileById(mFile.getParentId()).getRemotePath() + OCFile.PATH_SEPARATOR + newFilename);\r
                         newFile.setCreationTimestamp(mFile.getCreationTimestamp());\r
                         newFile.setFileId(mFile.getFileId());\r
                         newFile.setFileLength(mFile.getFileLength());\r
                         newFile.setCreationTimestamp(mFile.getCreationTimestamp());\r
                         newFile.setFileId(mFile.getFileId());\r
                         newFile.setFileLength(mFile.getFileLength());\r
@@ -644,11 +644,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 + mOld.getRemotePath());\r
+            Log.d("ASD", ""+baseUrl + webdav_path + WebdavUtils.encode(mOld.getRemotePath()));\r
 \r
 \r
-            Log.e("ASD", Uri.parse(baseUrl).getPath() == null ? "" : Uri.parse(baseUrl).getPath() + webdav_path + mNew.getRemotePath());\r
-            LocalMoveMethod move = new LocalMoveMethod(baseUrl + webdav_path + mOld.getRemotePath(),\r
-                                             Uri.parse(baseUrl).getPath() == null ? "" : Uri.parse(baseUrl).getPath() + webdav_path + mNew.getRemotePath());\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
             \r
             try {\r
                 int status = wc.executeMethod(move);\r
             \r
             try {\r
                 int status = wc.executeMethod(move);\r
@@ -772,9 +772,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 + mFileToRemove.getRemotePath());\r
+            Log.d("ASD", ""+baseUrl + webdav_path + WebdavUtils.encode(mFileToRemove.getRemotePath()));\r
 \r
 \r
-            DeleteMethod delete = new DeleteMethod(baseUrl + webdav_path + mFileToRemove.getRemotePath());\r
+            DeleteMethod delete = new DeleteMethod(baseUrl + webdav_path + WebdavUtils.encode(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
@@ -848,6 +848,7 @@ public class FileDetailFragment extends SherlockFragment implements
                 BitmapFactory.Options options = new Options();\r
                 options.inScaled = true;\r
                 options.inPurgeable = true;\r
                 BitmapFactory.Options options = new Options();\r
                 options.inScaled = true;\r
                 options.inPurgeable = true;\r
+                options.inJustDecodeBounds = true;\r
                 if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD_MR1) {\r
                     options.inPreferQualityOverSpeed = false;\r
                 }\r
                 if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD_MR1) {\r
                     options.inPreferQualityOverSpeed = false;\r
                 }\r
@@ -856,39 +857,36 @@ public class FileDetailFragment extends SherlockFragment implements
                 }\r
 \r
                 result = BitmapFactory.decodeFile(storagePath, options);\r
                 }\r
 \r
                 result = BitmapFactory.decodeFile(storagePath, options);\r
+                options.inJustDecodeBounds = false;\r
+\r
+                int width = options.outWidth;\r
+                int height = options.outHeight;\r
+                int scale = 1;\r
+                boolean recycle = false;\r
+                if (width >= 2048 || height >= 2048) {\r
+                    scale = (int) Math.ceil((Math.ceil(Math.max(height, width) / 2048.)));\r
+                    options.inSampleSize = scale;\r
+                }\r
+                Display display = getActivity().getWindowManager().getDefaultDisplay();\r
+                Point size = new Point();\r
+                int screenwidth;\r
+                if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB_MR2) {\r
+                    display.getSize(size);\r
+                    screenwidth = size.x;\r
+                } else {\r
+                    screenwidth = display.getWidth();\r
+                }\r
 \r
 \r
-                if (result != null) {\r
-                    int width = options.outWidth;\r
-                    int height = options.outHeight;\r
-                    int scale = 1;\r
-                    boolean recycle = false;\r
-                    if (width >= 2048 || height >= 2048) {\r
-                        scale = (int) (Math.ceil(Math.max(height, width) / 2048.));\r
-                        options.inSampleSize = scale;\r
-                        recycle = true;\r
-                    }\r
-                    Display display = getActivity().getWindowManager().getDefaultDisplay();\r
-                    Point size = new Point();\r
-                    int screenwidth;\r
-                    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB_MR2) {\r
-                        display.getSize(size);\r
-                        screenwidth = size.x;\r
-                    } else {\r
-                        screenwidth = display.getWidth();\r
-                    }\r
+                Log.e("ASD", "W " + width + " SW " + screenwidth);\r
 \r
 \r
-                    Log.e("ASD", "W " + width + " SW " + screenwidth);\r
+                if (width > screenwidth) {\r
+                    scale = (int) Math.ceil((float)width / screenwidth);\r
+                    options.inSampleSize = scale;\r
+                }\r
 \r
 \r
-                    if (width > screenwidth) {\r
-                        scale = (int) (Math.ceil(Math.max(height, width) / screenwidth));\r
-                        options.inSampleSize = scale;\r
-                        recycle = true;\r
-                    }\r
+                result = BitmapFactory.decodeFile(storagePath, options);\r
 \r
 \r
-                    if (recycle)\r
-                        result.recycle();\r
-                    result = BitmapFactory.decodeFile(storagePath, options);\r
-                }\r
+                Log.e("ASD", "W " + options.outWidth + " SW " + options.outHeight);\r
 \r
             } catch (OutOfMemoryError e) {\r
                 result = null;\r
 \r
             } catch (OutOfMemoryError e) {\r
                 result = null;\r