diff --git a/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadHelper.kt b/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadHelper.kt index c97fe56641..05d9bd1d55 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadHelper.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadHelper.kt @@ -64,6 +64,9 @@ class FileUploadHelper { companion object { private val TAG = FileUploadWorker::class.java.simpleName + @Suppress("MagicNumber") + const val MAX_FILE_COUNT = 500 + val mBoundListeners = HashMap() private var instance: FileUploadHelper? = null diff --git a/app/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java index aab5490acf..60d8c944a7 100755 --- a/app/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java @@ -880,7 +880,7 @@ public class ReceiveExternalFilesActivity extends FileActivity } private boolean somethingToUpload() { - return (mStreamsToUpload != null && mStreamsToUpload.size() > 0 && mStreamsToUpload.get(0) != null || + return (mStreamsToUpload != null && !mStreamsToUpload.isEmpty() && mStreamsToUpload.get(0) != null || mUploadFromTmpFile); } @@ -904,6 +904,11 @@ public class ReceiveExternalFilesActivity extends FileActivity return; } + if (mStreamsToUpload.size() > FileUploadHelper.MAX_FILE_COUNT) { + DisplayUtils.showSnackMessage(this, R.string.max_file_count_warning_message); + return; + } + UriUploader uploader = new UriUploader( this, mStreamsToUpload, diff --git a/app/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java index da59551317..3bbdfe7752 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java @@ -30,6 +30,7 @@ import android.widget.TextView; import com.nextcloud.client.account.User; import com.nextcloud.client.di.Injectable; +import com.nextcloud.client.jobs.upload.FileUploadHelper; import com.nextcloud.client.jobs.upload.FileUploadWorker; import com.nextcloud.client.preferences.AppPreferences; import com.nextcloud.utils.extensions.ActivityExtensionsKt; @@ -653,6 +654,11 @@ public class UploadFilesActivity extends DrawerActivity implements LocalFileList @Override public void onConfirmation(String callerTag) { Log_OC.d(TAG, "Positive button in dialog was clicked; dialog tag is " + callerTag); + if (mFileListFragment.getCheckedFilePaths().length > FileUploadHelper.MAX_FILE_COUNT) { + DisplayUtils.showSnackMessage(this, R.string.max_file_count_warning_message); + return; + } + if (QUERY_TO_MOVE_DIALOG_TAG.equals(callerTag)) { // return the list of selected files to the caller activity (success), // signaling that they should be moved to the ownCloud folder, instead of copied diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 765d842628..3c3df08a91 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -129,6 +129,7 @@ File selected for upload not found. Please check whether the file exists. Could not copy file to a temporary folder. Try to resend it. Upload option: + You have reached the maximum file upload limit. Please upload fewer than 500 files at a time. Move file to %1$s folder Keep file in source folder Delete file from source folder