From: David A. Velasco Date: Tue, 26 Feb 2013 18:26:45 +0000 (+0100) Subject: Fixed button 'cancel' in automatic downloads into the images gallery X-Git-Tag: oc-android-1.4.3~39^2~37 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/25e342e945c9f60c0ab14ccc5f67f5a06ac663a3 Fixed button 'cancel' in automatic downloads into the images gallery --- diff --git a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java index 57667aa1..8657e9bd 100644 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -21,7 +21,6 @@ package com.owncloud.android.ui.activity; import java.io.File; import android.accounts.Account; -import android.app.Activity; import android.app.AlertDialog; import android.app.ProgressDialog; import android.app.AlertDialog.Builder; @@ -92,6 +91,7 @@ import com.owncloud.android.ui.fragment.FileDetailFragment; import com.owncloud.android.ui.fragment.FileFragment; import com.owncloud.android.ui.fragment.OCFileListFragment; import com.owncloud.android.ui.preview.PreviewImageActivity; +import com.owncloud.android.ui.preview.PreviewImageFragment; import com.owncloud.android.ui.preview.PreviewMediaFragment; import com.owncloud.android.R; @@ -1053,15 +1053,14 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements */ @Override public void onFileClick(OCFile file) { - - if (file != null && PreviewMediaFragment.canBePreviewed(file)) { - if (file.isImage()) { - // preview image - it handles the download, if needed - startPreviewImage(file); - - } else if (file.isDown()) { + if (file != null && PreviewImageFragment.canBePreviewed(file)) { + // preview image - it handles the download, if needed + startPreviewImage(file); + + } else if (file != null && PreviewMediaFragment.canBePreviewed(file)) { + if (file.isDown()) { // general preview - startOtherPreview(file); + startMediaPreview(file); } else { // automatic download, preview on finish @@ -1081,7 +1080,7 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements startActivity(showDetailsIntent); } - private void startOtherPreview(OCFile file) { + private void startMediaPreview(OCFile file) { if (mDualPane) { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.file_details_container, new PreviewMediaFragment(file, AccountUtils.getCurrentOwnCloudAccount(this)), FileDetailFragment.FTAG); diff --git a/src/com/owncloud/android/ui/preview/FileDownloadFragment.java b/src/com/owncloud/android/ui/preview/FileDownloadFragment.java index e8e36ac2..da43d119 100644 --- a/src/com/owncloud/android/ui/preview/FileDownloadFragment.java +++ b/src/com/owncloud/android/ui/preview/FileDownloadFragment.java @@ -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 {