mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 13:45:35 +03:00
OC-1580: Cancel upload
This commit is contained in:
parent
2694ac00c6
commit
10d1efa18d
5 changed files with 31 additions and 18 deletions
|
@ -717,12 +717,7 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
|
||||||
mNotification.contentView.setImageViewResource(R.id.status_icon, R.drawable.icon);
|
mNotification.contentView.setImageViewResource(R.id.status_icon, R.drawable.icon);
|
||||||
|
|
||||||
/// includes a pending intent in the notification showing the details view of the file
|
/// includes a pending intent in the notification showing the details view of the file
|
||||||
Intent showDetailsIntent = null;
|
Intent showDetailsIntent = new Intent(this, FileDisplayActivity.class);
|
||||||
if (PreviewImageFragment.canBePreviewed(upload.getFile())) {
|
|
||||||
showDetailsIntent = new Intent(this, PreviewImageActivity.class);
|
|
||||||
} else {
|
|
||||||
showDetailsIntent = new Intent(this, FileDisplayActivity.class);
|
|
||||||
}
|
|
||||||
showDetailsIntent.putExtra(FileActivity.EXTRA_FILE, upload.getFile());
|
showDetailsIntent.putExtra(FileActivity.EXTRA_FILE, upload.getFile());
|
||||||
showDetailsIntent.putExtra(FileActivity.EXTRA_ACCOUNT, upload.getAccount());
|
showDetailsIntent.putExtra(FileActivity.EXTRA_ACCOUNT, upload.getAccount());
|
||||||
showDetailsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
showDetailsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
|
|
|
@ -86,6 +86,7 @@ import com.owncloud.android.ui.fragment.FileDetailFragment;
|
||||||
import com.owncloud.android.ui.fragment.FileFragment;
|
import com.owncloud.android.ui.fragment.FileFragment;
|
||||||
import com.owncloud.android.ui.fragment.OCFileListFragment;
|
import com.owncloud.android.ui.fragment.OCFileListFragment;
|
||||||
import com.owncloud.android.ui.preview.PreviewImageActivity;
|
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.ui.preview.PreviewMediaFragment;
|
||||||
import com.owncloud.android.ui.preview.PreviewVideoActivity;
|
import com.owncloud.android.ui.preview.PreviewVideoActivity;
|
||||||
|
|
||||||
|
@ -211,12 +212,15 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
|
||||||
|
|
||||||
/// Check whether the 'main' OCFile handled by the Activity is contained in the current Account
|
/// Check whether the 'main' OCFile handled by the Activity is contained in the current Account
|
||||||
OCFile file = getFile();
|
OCFile file = getFile();
|
||||||
|
// get parent from path
|
||||||
|
String parentPath = "";
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
if (file.isDown() && file.getLastSyncDateForProperties() == 0) {
|
if (file.isDown() && file.getLastSyncDateForProperties() == 0) {
|
||||||
// upload in progress - right now, files are not inserted in the local cache until the upload is successful
|
// upload in progress - right now, files are not inserted in the local cache until the upload is successful
|
||||||
if (mStorageManager.getFileById(file.getParentId()) == null) {
|
// get parent from path
|
||||||
file = null; // not able to know the directory where the file is uploading
|
parentPath = file.getRemotePath().substring(0, file.getRemotePath().lastIndexOf(file.getFileName()));
|
||||||
}
|
if (mStorageManager.getFileByPath(parentPath) == null)
|
||||||
|
file = null; // not able to know the directory where the file is uploading
|
||||||
} else {
|
} else {
|
||||||
file = mStorageManager.getFileByPath(file.getRemotePath()); // currentDir = null if not in the current Account
|
file = mStorageManager.getFileByPath(file.getRemotePath()); // currentDir = null if not in the current Account
|
||||||
}
|
}
|
||||||
|
@ -232,7 +236,9 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
|
||||||
if (fileIt.isDirectory()) {
|
if (fileIt.isDirectory()) {
|
||||||
mDirectories.add(fileIt.getFileName());
|
mDirectories.add(fileIt.getFileName());
|
||||||
}
|
}
|
||||||
fileIt = mStorageManager.getFileById(fileIt.getParentId());
|
// get parent from path
|
||||||
|
parentPath = fileIt.getRemotePath().substring(0, fileIt.getRemotePath().lastIndexOf(fileIt.getFileName()));
|
||||||
|
fileIt = mStorageManager.getFileByPath(parentPath);
|
||||||
}
|
}
|
||||||
mDirectories.add(OCFile.PATH_SEPARATOR);
|
mDirectories.add(OCFile.PATH_SEPARATOR);
|
||||||
if (!stateWasRecovered) {
|
if (!stateWasRecovered) {
|
||||||
|
@ -1360,7 +1366,8 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
|
||||||
if (file.isDirectory()) {
|
if (file.isDirectory()) {
|
||||||
return file;
|
return file;
|
||||||
} else if (mStorageManager != null) {
|
} else if (mStorageManager != null) {
|
||||||
return mStorageManager.getFileById(file.getParentId());
|
String parentPath = file.getRemotePath().substring(0, file.getRemotePath().lastIndexOf(file.getFileName()));
|
||||||
|
return mStorageManager.getFileByPath(parentPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -64,6 +64,7 @@ import com.owncloud.android.ui.activity.FileActivity;
|
||||||
import com.owncloud.android.ui.activity.FileDisplayActivity;
|
import com.owncloud.android.ui.activity.FileDisplayActivity;
|
||||||
import com.owncloud.android.ui.dialog.EditNameDialog;
|
import com.owncloud.android.ui.dialog.EditNameDialog;
|
||||||
import com.owncloud.android.ui.dialog.EditNameDialog.EditNameDialogListener;
|
import com.owncloud.android.ui.dialog.EditNameDialog.EditNameDialogListener;
|
||||||
|
import com.owncloud.android.ui.preview.PreviewImageFragment;
|
||||||
|
|
||||||
import eu.alefzero.webdav.OnDatatransferProgressListener;
|
import eu.alefzero.webdav.OnDatatransferProgressListener;
|
||||||
|
|
||||||
|
@ -741,7 +742,13 @@ public class FileDetailFragment extends FileFragment implements
|
||||||
msg.show();
|
msg.show();
|
||||||
}
|
}
|
||||||
getSherlockActivity().removeStickyBroadcast(intent); // not the best place to do this; a small refactorization of BroadcastReceivers should be done
|
getSherlockActivity().removeStickyBroadcast(intent); // not the best place to do this; a small refactorization of BroadcastReceivers should be done
|
||||||
|
|
||||||
updateFileDetails(false, false); // it updates the buttons; must be called although !uploadWasFine; interrupted uploads still leave an incomplete file in the server
|
updateFileDetails(false, false); // it updates the buttons; must be called although !uploadWasFine; interrupted uploads still leave an incomplete file in the server
|
||||||
|
|
||||||
|
// Force the preview if the file is an image
|
||||||
|
if (uploadWasFine && PreviewImageFragment.canBePreviewed(getFile())) {
|
||||||
|
((FileDisplayActivity) mContainerActivity).startImagePreview(getFile());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
*/
|
*/
|
||||||
package com.owncloud.android.ui.preview;
|
package com.owncloud.android.ui.preview;
|
||||||
|
|
||||||
import android.app.Dialog;
|
|
||||||
import android.app.ProgressDialog;
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
@ -105,7 +103,10 @@ public class PreviewImageActivity extends FileActivity implements FileFragment.C
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initViewPager() {
|
private void initViewPager() {
|
||||||
OCFile parentFolder = mStorageManager.getFileById(getFile().getParentId());
|
// get parent from path
|
||||||
|
String parentPath = getFile().getRemotePath().substring(0, getFile().getRemotePath().lastIndexOf(getFile().getFileName()));
|
||||||
|
OCFile parentFolder = mStorageManager.getFileByPath(parentPath);
|
||||||
|
//OCFile parentFolder = mStorageManager.getFileById(getFile().getParentId());
|
||||||
if (parentFolder == null) {
|
if (parentFolder == null) {
|
||||||
// should not be necessary
|
// should not be necessary
|
||||||
parentFolder = mStorageManager.getFileByPath(OCFile.PATH_SEPARATOR);
|
parentFolder = mStorageManager.getFileByPath(OCFile.PATH_SEPARATOR);
|
||||||
|
@ -431,7 +432,11 @@ public class PreviewImageActivity extends FileActivity implements FileFragment.C
|
||||||
throw new IllegalArgumentException("Non-image file passed as argument");
|
throw new IllegalArgumentException("Non-image file passed as argument");
|
||||||
}
|
}
|
||||||
mStorageManager = new FileDataStorageManager(getAccount(), getContentResolver());
|
mStorageManager = new FileDataStorageManager(getAccount(), getContentResolver());
|
||||||
file = mStorageManager.getFileById(file.getFileId());
|
|
||||||
|
// Update file according to DB file, if it is possible
|
||||||
|
if (file.getFileId() > DataStorageManager.ROOT_PARENT_ID)
|
||||||
|
file = mStorageManager.getFileById(file.getFileId());
|
||||||
|
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
/// Refresh the activity according to the Account and OCFile set
|
/// Refresh the activity according to the Account and OCFile set
|
||||||
setFile(file); // reset after getting it fresh from mStorageManager
|
setFile(file); // reset after getting it fresh from mStorageManager
|
||||||
|
|
|
@ -56,7 +56,6 @@ import com.owncloud.android.operations.OnRemoteOperationListener;
|
||||||
import com.owncloud.android.operations.RemoteOperation;
|
import com.owncloud.android.operations.RemoteOperation;
|
||||||
import com.owncloud.android.operations.RemoteOperationResult;
|
import com.owncloud.android.operations.RemoteOperationResult;
|
||||||
import com.owncloud.android.operations.RemoveFileOperation;
|
import com.owncloud.android.operations.RemoveFileOperation;
|
||||||
import com.owncloud.android.ui.activity.FileDisplayActivity;
|
|
||||||
import com.owncloud.android.ui.fragment.ConfirmationDialogFragment;
|
import com.owncloud.android.ui.fragment.ConfirmationDialogFragment;
|
||||||
import com.owncloud.android.ui.fragment.FileFragment;
|
import com.owncloud.android.ui.fragment.FileFragment;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue