diff --git a/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploaderIntents.kt b/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploaderIntents.kt index b35fbd1e1d80..c068d7aa25cc 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploaderIntents.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploaderIntents.kt @@ -123,11 +123,11 @@ class FileUploaderIntents(private val context: Context) { ) return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { - PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_MUTABLE) + PendingIntent.getActivity(context, SecureRandom().nextInt(), intent, PendingIntent.FLAG_MUTABLE) } else { PendingIntent.getActivity( context, - 0, + SecureRandom().nextInt(), intent, PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE ) diff --git a/app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt b/app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt index 09d8580ad848..2c3a01f7f90b 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt @@ -175,19 +175,20 @@ class UploadNotificationManager(private val context: Context, private val viewTh return } - notificationManager.cancel( - NotificationUtils.createUploadNotificationTag(operation.file), - FileUploadWorker.NOTIFICATION_ERROR_ID - ) + dismissOldErrorNotification(operation.file.remotePath, operation.file.storagePath) operation.oldFile?.let { - notificationManager.cancel( - NotificationUtils.createUploadNotificationTag(it), - FileUploadWorker.NOTIFICATION_ERROR_ID - ) + dismissOldErrorNotification(it.remotePath, it.storagePath) } } + fun dismissOldErrorNotification(remotePath: String, localPath: String) { + notificationManager.cancel( + NotificationUtils.createUploadNotificationTag(remotePath, localPath), + FileUploadWorker.NOTIFICATION_ERROR_ID + ) + } + fun dismissWorkerNotifications() { notificationManager.cancel(ID) } diff --git a/app/src/main/java/com/owncloud/android/ui/activity/ConflictsResolveActivity.kt b/app/src/main/java/com/owncloud/android/ui/activity/ConflictsResolveActivity.kt index 3dc8aaf33f12..40b06108b050 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/ConflictsResolveActivity.kt +++ b/app/src/main/java/com/owncloud/android/ui/activity/ConflictsResolveActivity.kt @@ -24,6 +24,7 @@ import com.nextcloud.client.account.User import com.nextcloud.client.jobs.download.FileDownloadHelper import com.nextcloud.client.jobs.upload.FileUploadHelper import com.nextcloud.client.jobs.upload.FileUploadWorker +import com.nextcloud.client.jobs.upload.UploadNotificationManager import com.nextcloud.model.HTTPStatusCodes import com.nextcloud.utils.extensions.getParcelableArgument import com.owncloud.android.R @@ -92,36 +93,49 @@ class ConflictsResolveActivity : FileActivity(), OnConflictDecisionMadeListener when (decision) { Decision.CANCEL -> {} Decision.KEEP_LOCAL -> { + upload?.let { + FileUploadHelper.instance().cancelFileUpload(it.remotePath, it.accountName) + } FileUploadHelper.instance().uploadUpdatedFile( user, arrayOf(file), localBehaviour, NameCollisionPolicy.OVERWRITE ) - uploadsStorageManager?.removeUpload(upload) } Decision.KEEP_BOTH -> { + upload?.let { + FileUploadHelper.instance().cancelFileUpload(it.remotePath, it.accountName) + } FileUploadHelper.instance().uploadUpdatedFile( user, arrayOf(file), localBehaviour, NameCollisionPolicy.RENAME ) - uploadsStorageManager?.removeUpload(upload) } - Decision.KEEP_SERVER -> if (!shouldDeleteLocal()) { - // Overwrite local file - file?.let { - FileDownloadHelper.instance().downloadFile( - getUser().orElseThrow { RuntimeException() }, - file, - conflictUploadId = conflictUploadId - ) + Decision.KEEP_SERVER -> { + if (!shouldDeleteLocal()) { + // Overwrite local file + file?.let { + FileDownloadHelper.instance().downloadFile( + getUser().orElseThrow { RuntimeException() }, + file, + conflictUploadId = conflictUploadId + ) + } + } + + upload?.let { + FileUploadHelper.instance().cancelFileUpload(it.remotePath, it.accountName) + + UploadNotificationManager( + applicationContext, + viewThemeUtils + ).dismissOldErrorNotification(it.remotePath, it.localPath) } - } else { - uploadsStorageManager?.removeUpload(upload) } else -> {}