Initial version of FileOperation to encapsulate all events regarding
[pub/Android/ownCloud.git] / src / eu / alefzero / owncloud / ui / fragment / FileDetailFragment.java
index 2badae1..9bcf9de 100644 (file)
@@ -152,6 +152,7 @@ public class FileDetailFragment extends SherlockFragment implements
         i.putExtra(FileDownloader.EXTRA_REMOTE_PATH, mFile.getRemotePath());\r
         i.putExtra(FileDownloader.EXTRA_FILE_PATH, mFile.getURLDecodedRemotePath());\r
         i.putExtra(FileDownloader.EXTRA_FILE_SIZE, mFile.getFileLength());\r
         i.putExtra(FileDownloader.EXTRA_REMOTE_PATH, mFile.getRemotePath());\r
         i.putExtra(FileDownloader.EXTRA_FILE_PATH, mFile.getURLDecodedRemotePath());\r
         i.putExtra(FileDownloader.EXTRA_FILE_SIZE, mFile.getFileLength());\r
+        v.setEnabled(false);\r
         getActivity().startService(i);\r
     }\r
 \r
         getActivity().startService(i);\r
     }\r
 \r
@@ -345,24 +346,24 @@ public class FileDetailFragment extends SherlockFragment implements
     }\r
     \r
     /**\r
     }\r
     \r
     /**\r
-     * In ownCloud 3.0.3 and 4.0.0 there is a bug that SabreDAV does not return\r
+     * In ownCloud 3.X.X and 4.X.X there is a bug that SabreDAV does not return\r
      * the time that the file was created. There is a chance that this will\r
      * be fixed in future versions. Use this method to check if this version of\r
      * ownCloud has this fix.\r
      * the time that the file was created. There is a chance that this will\r
      * be fixed in future versions. Use this method to check if this version of\r
      * ownCloud has this fix.\r
-     * @return True, if ownCloud the ownCloud version is > 3.0.4 and 4.0.4\r
+     * @return True, if ownCloud the ownCloud version is supporting creationg time\r
      */\r
     private boolean ocVersionSupportsTimeCreated(){\r
      */\r
     private boolean ocVersionSupportsTimeCreated(){\r
-        if(mIntent != null){\r
+       /* if(mIntent != null){\r
             Account ocAccount = mIntent.getParcelableExtra(FileDownloader.EXTRA_ACCOUNT);\r
             if(ocAccount != null){\r
                 AccountManager accManager = (AccountManager) getActivity().getSystemService(Context.ACCOUNT_SERVICE);\r
                 OwnCloudVersion ocVersion = new OwnCloudVersion(accManager\r
                         .getUserData(ocAccount, AccountAuthenticator.KEY_OC_VERSION));\r
             Account ocAccount = mIntent.getParcelableExtra(FileDownloader.EXTRA_ACCOUNT);\r
             if(ocAccount != null){\r
                 AccountManager accManager = (AccountManager) getActivity().getSystemService(Context.ACCOUNT_SERVICE);\r
                 OwnCloudVersion ocVersion = new OwnCloudVersion(accManager\r
                         .getUserData(ocAccount, AccountAuthenticator.KEY_OC_VERSION));\r
-                if(ocVersion.compareTo(new OwnCloudVersion(0x030004)) >= 0 || ocVersion.compareTo(new OwnCloudVersion(0x040004)) >= 0){\r
+                if(ocVersion.compareTo(new OwnCloudVersion(0x030000)) < 0) {\r
                     return true;\r
                 }\r
             }\r
                     return true;\r
                 }\r
             }\r
-        }\r
+        }*/\r
         return false;\r
     }\r
 \r
         return false;\r
     }\r
 \r
@@ -373,8 +374,14 @@ public class FileDetailFragment extends SherlockFragment implements
     private class DownloadFinishReceiver extends BroadcastReceiver {\r
         @Override\r
         public void onReceive(Context context, Intent intent) {\r
     private class DownloadFinishReceiver extends BroadcastReceiver {\r
         @Override\r
         public void onReceive(Context context, Intent intent) {\r
-            ((OCFile)mIntent.getParcelableExtra(EXTRA_FILE)).setStoragePath(intent.getStringExtra(FileDownloader.EXTRA_FILE_PATH));\r
-            updateFileDetails(mIntent);\r
+            getView().findViewById(R.id.fdDownloadBtn).setEnabled(true);\r
+            if (intent.getAction().equals(FileDownloader.BAD_DOWNLOAD_MESSAGE)) {\r
+                Toast.makeText(context, R.string.downloader_download_failed , Toast.LENGTH_SHORT).show();\r
+                \r
+            } else if (intent.getAction().equals(FileDownloader.DOWNLOAD_FINISH_MESSAGE)) {\r
+                ((OCFile)mIntent.getParcelableExtra(EXTRA_FILE)).setStoragePath(intent.getStringExtra(FileDownloader.EXTRA_FILE_PATH));\r
+                updateFileDetails(mIntent);\r
+            }\r
         }\r
         \r
     }\r
         }\r
         \r
     }\r