Fixed button 'cancel' in automatic downloads into the images gallery
authorDavid A. Velasco <dvelasco@solidgear.es>
Tue, 26 Feb 2013 18:26:45 +0000 (19:26 +0100)
committerDavid A. Velasco <dvelasco@solidgear.es>
Tue, 26 Feb 2013 18:26:45 +0000 (19:26 +0100)
src/com/owncloud/android/ui/activity/FileDisplayActivity.java
src/com/owncloud/android/ui/preview/FileDownloadFragment.java

index 57667aa..8657e9b 100644 (file)
@@ -21,7 +21,6 @@ package com.owncloud.android.ui.activity;
 import java.io.File;\r
 \r
 import android.accounts.Account;\r
-import android.app.Activity;\r
 import android.app.AlertDialog;\r
 import android.app.ProgressDialog;\r
 import android.app.AlertDialog.Builder;\r
@@ -92,6 +91,7 @@ import com.owncloud.android.ui.fragment.FileDetailFragment;
 import com.owncloud.android.ui.fragment.FileFragment;\r
 import com.owncloud.android.ui.fragment.OCFileListFragment;\r
 import com.owncloud.android.ui.preview.PreviewImageActivity;\r
+import com.owncloud.android.ui.preview.PreviewImageFragment;\r
 import com.owncloud.android.ui.preview.PreviewMediaFragment;\r
 \r
 import com.owncloud.android.R;\r
@@ -1053,15 +1053,14 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
      */\r
     @Override\r
     public void onFileClick(OCFile file) {\r
-\r
-        if (file != null && PreviewMediaFragment.canBePreviewed(file)) {\r
-            if (file.isImage()) {\r
-                // preview image - it handles the download, if needed\r
-                startPreviewImage(file);\r
-                \r
-            } else if (file.isDown()) {\r
+        if (file != null && PreviewImageFragment.canBePreviewed(file)) {\r
+            // preview image - it handles the download, if needed\r
+            startPreviewImage(file);\r
+            \r
+        } else if (file != null && PreviewMediaFragment.canBePreviewed(file)) {\r
+            if (file.isDown()) {\r
                 // general preview\r
-                startOtherPreview(file);\r
+                startMediaPreview(file);\r
                 \r
             } else {\r
                 // automatic download, preview on finish\r
@@ -1081,7 +1080,7 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
         startActivity(showDetailsIntent);\r
     }\r
     \r
-    private void startOtherPreview(OCFile file) {\r
+    private void startMediaPreview(OCFile file) {\r
         if (mDualPane) {\r
             FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();\r
             transaction.replace(R.id.file_details_container, new PreviewMediaFragment(file, AccountUtils.getCurrentOwnCloudAccount(this)), FileDetailFragment.FTAG);\r
index e8e36ac..da43d11 100644 (file)
@@ -52,7 +52,7 @@ import eu.alefzero.webdav.OnDatatransferProgressListener;
  * 
  * @author David A. Velasco
  */
-public class FileDownloadFragment extends SherlockFragment implements OnClickListener,FileFragment {
+public class FileDownloadFragment extends SherlockFragment implements OnClickListener, FileFragment {
 
     public static final String EXTRA_FILE = "FILE";
     public static final String EXTRA_ACCOUNT = "ACCOUNT";
@@ -119,10 +119,6 @@ public class FileDownloadFragment extends SherlockFragment implements OnClickLis
             mAccount = savedInstanceState.getParcelable(FileDownloadFragment.EXTRA_ACCOUNT);
         }
         
-        if(mFile != null && mAccount != null) {
-            //mLayout = R.layout.file_details_fragment;
-        }
-        
         View view = null;
         view = inflater.inflate(R.layout.file_download_fragment, container, false);
         mView = view;
@@ -130,6 +126,8 @@ public class FileDownloadFragment extends SherlockFragment implements OnClickLis
         ProgressBar progressBar = (ProgressBar)mView.findViewById(R.id.progressBar);
         mProgressListener = new ProgressListener(progressBar);
         
+        ((Button)mView.findViewById(R.id.cancelBtn)).setOnClickListener(this);
+        
         return view;
     }
     
@@ -229,6 +227,7 @@ public class FileDownloadFragment extends SherlockFragment implements OnClickLis
                 FileDownloaderBinder downloaderBinder = mContainerActivity.getFileDownloaderBinder();
                 if (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, mFile)) {
                     downloaderBinder.cancel(mAccount, mFile);
+                    leaveTransferProgress();
                     if (mFile.isDown()) {
                         setButtonsForDown();
                     } else {