Quick patch to fix operations not ready for HTTPS
[pub/Android/ownCloud.git] / src / eu / alefzero / owncloud / ui / fragment / FileDetailFragment.java
index 6a34c6d..ad6f604 100644 (file)
@@ -79,6 +79,7 @@ import eu.alefzero.owncloud.authenticator.AccountAuthenticator;
 import eu.alefzero.owncloud.datamodel.FileDataStorageManager;\r
 import eu.alefzero.owncloud.datamodel.OCFile;\r
 import eu.alefzero.owncloud.files.services.FileDownloader;\r
+import eu.alefzero.owncloud.files.services.FileUploader;\r
 import eu.alefzero.owncloud.ui.activity.FileDisplayActivity;\r
 import eu.alefzero.owncloud.utils.OwnCloudVersion;\r
 import eu.alefzero.webdav.WebdavClient;\r
@@ -217,7 +218,6 @@ public class FileDetailFragment extends SherlockFragment implements
                 i.putExtra(FileDownloader.EXTRA_FILE_SIZE, mFile.getFileLength());\r
                 \r
                 // update ui \r
-                Toast.makeText(getActivity(), "Downloading", Toast.LENGTH_LONG).show();\r
                 setButtonsForDownloading();\r
                 \r
                 getActivity().startService(i);\r
@@ -240,7 +240,7 @@ public class FileDetailFragment extends SherlockFragment implements
                 break;\r
             }   \r
             case R.id.fdRemoveBtn: {\r
-                ConfirmationDialogFragment confDialog = ConfirmationDialogFragment.newInstance("to remove " + mFile.getFileName());\r
+                ConfirmationDialogFragment confDialog = ConfirmationDialogFragment.newInstance(R.string.confirmation_remove_alert, new String[]{mFile.getFileName()});\r
                 confDialog.setOnConfirmationListener(this);\r
                 confDialog.show(getFragmentManager(), FTAG_CONFIRMATION);\r
                 break;\r
@@ -361,7 +361,7 @@ public class FileDetailFragment extends SherlockFragment implements
             cb.setChecked(mFile.keepInSync());\r
 \r
             // configure UI for depending upon local state of the file\r
-            if (mFile.isDownloading()) {\r
+            if (FileDownloader.isDownloading(mAccount, mFile.getRemotePath())) {\r
                 setButtonsForDownloading();\r
                 \r
             } else if (mFile.isDown()) {\r
@@ -553,7 +553,9 @@ public class FileDetailFragment extends SherlockFragment implements
     private class DownloadFinishReceiver extends BroadcastReceiver {\r
         @Override\r
         public void onReceive(Context context, Intent intent) {\r
-            if (mFile != null) {\r
+            String accountName = intent.getStringExtra(FileDownloader.ACCOUNT_NAME);\r
+\r
+            if (!isEmpty() && accountName.equals(mAccount.name)) {\r
                 boolean downloadWasFine = intent.getBooleanExtra(FileDownloader.EXTRA_DOWNLOAD_RESULT, false);\r
                 String downloadedRemotePath = intent.getStringExtra(FileDownloader.EXTRA_REMOTE_PATH);\r
                 if (mFile.getRemotePath().equals(downloadedRemotePath)) {\r
@@ -688,7 +690,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
-                        OCFile newFile = new OCFile(fdsm.getFileById(mFile.getParentId()).getRemotePath() + OCFile.PATH_SEPARATOR + newFilename);\r
+                        OCFile newFile = new OCFile(fdsm.getFileById(mFile.getParentId()).getRemotePath() + newFilename);\r
                         newFile.setCreationTimestamp(mFile.getCreationTimestamp());\r
                         newFile.setFileId(mFile.getFileId());\r
                         newFile.setFileLength(mFile.getFileLength());\r
@@ -700,9 +702,9 @@ public class FileDetailFragment extends SherlockFragment implements
                         if (mFile.isDown()) {\r
                             File f = new File(mFile.getStoragePath());\r
                             Log.e(TAG, f.getAbsolutePath());\r
-                            f.renameTo(new File(f.getParent()+"/"+newFilename));\r
-                            Log.e(TAG, f.getAbsolutePath());\r
-                            newFile.setStoragePath(f.getAbsolutePath());\r
+                            f.renameTo(new File(f.getParent() + File.separator + newFilename)); // TODO check if fails\r
+                            Log.e(TAG, f.getParent() + File.separator + newFilename);\r
+                            newFile.setStoragePath(f.getParent() + File.separator + newFilename);\r
                         }\r
                         \r
                         new Thread(new RenameRunnable(mFile, newFile, mAccount, new Handler())).start();\r
@@ -731,6 +733,7 @@ public class FileDetailFragment extends SherlockFragment implements
         \r
         public void run() {\r
             WebdavClient wc = new WebdavClient(mAccount, getSherlockActivity().getApplicationContext());\r
+            wc.allowSelfsignedCertificates();\r
             AccountManager am = AccountManager.get(getSherlockActivity());\r
             String baseUrl = am.getUserData(mAccount, AccountAuthenticator.KEY_OC_BASE_URL);\r
             OwnCloudVersion ocv = new OwnCloudVersion(am.getUserData(mAccount, AccountAuthenticator.KEY_OC_VERSION));\r
@@ -861,6 +864,7 @@ public class FileDetailFragment extends SherlockFragment implements
         \r
         public void run() {\r
             WebdavClient wc = new WebdavClient(mAccount, getSherlockActivity().getApplicationContext());\r
+            wc.allowSelfsignedCertificates();\r
             AccountManager am = AccountManager.get(getSherlockActivity());\r
             String baseUrl = am.getUserData(mAccount, AccountAuthenticator.KEY_OC_BASE_URL);\r
             OwnCloudVersion ocv = new OwnCloudVersion(am.getUserData(mAccount, AccountAuthenticator.KEY_OC_VERSION));\r