From 23536be206be0f58fc70f31249f95c2c530da2d1 Mon Sep 17 00:00:00 2001 From: Chris Narkiewicz Date: Tue, 19 Jan 2021 00:43:12 +0000 Subject: [PATCH] Migrate UriUploader to User model Signed-off-by: Chris Narkiewicz --- .../ui/activity/FileDisplayActivity.java | 2 +- .../ReceiveExternalFilesActivity.java | 2 +- .../CopyAndUploadContentUrisTask.java | 15 +++++++------- .../android/ui/helpers/UriUploader.java | 20 +++++++++---------- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java index 4bb0aa6fe8..e8444bf87c 100644 --- a/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -1025,7 +1025,7 @@ public class FileDisplayActivity extends FileActivity this, streamsToUpload, remotePath, - getAccount(), + getUser().orElseThrow(RuntimeException::new), behaviour, false, // Not show waiting dialog while file is being copied from private storage null // Not needed copy temp task listener diff --git a/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java b/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java index dbc656b28a..bc4d81d0d1 100755 --- a/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java @@ -916,7 +916,7 @@ public class ReceiveExternalFilesActivity extends FileActivity this, mStreamsToUpload, mUploadPath, - getAccount(), + getUser().orElseThrow(RuntimeException::new), FileUploader.LOCAL_BEHAVIOUR_DELETE, true, // Show waiting dialog while file is being copied from private storage this // Copy temp task listener diff --git a/src/main/java/com/owncloud/android/ui/asynctasks/CopyAndUploadContentUrisTask.java b/src/main/java/com/owncloud/android/ui/asynctasks/CopyAndUploadContentUrisTask.java index 270923007d..0091cdd498 100644 --- a/src/main/java/com/owncloud/android/ui/asynctasks/CopyAndUploadContentUrisTask.java +++ b/src/main/java/com/owncloud/android/ui/asynctasks/CopyAndUploadContentUrisTask.java @@ -30,6 +30,7 @@ import android.os.AsyncTask; import android.provider.DocumentsContract; import android.widget.Toast; +import com.nextcloud.client.account.User; import com.owncloud.android.R; import com.owncloud.android.files.services.FileUploader; import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode; @@ -69,7 +70,7 @@ public class CopyAndUploadContentUrisTask extends AsyncTask uris, String uploadPath, - Account account, + User user, int behaviour, boolean showWaitingDialog, CopyAndUploadContentUrisTask.OnCopyTmpFilesTaskListener copyTmpTaskListener @@ -82,7 +82,7 @@ public class UriUploader { mActivity = activity; mUrisToUpload = uris; mUploadPath = uploadPath; - mAccount = account; + this.user = user; mBehaviour = behaviour; mShowWaitingDialog = showWaitingDialog; mCopyTmpTaskListener = copyTmpTaskListener; @@ -156,7 +156,7 @@ public class UriUploader { private void requestUpload(String localPath, String remotePath) { FileUploader.uploadNewFile( mActivity, - mAccount, + user.toPlatformAccount(), localPath, remotePath, mBehaviour, @@ -195,11 +195,11 @@ public class UriUploader { copyTask.execute( CopyAndUploadContentUrisTask.makeParamsToExecute( - mAccount, - sourceUris, - remotePaths, - mBehaviour, - mActivity.getContentResolver() + user, + sourceUris, + remotePaths, + mBehaviour, + mActivity.getContentResolver() ) ); }