Skip to content

Commit d7c83d2

Browse files
Merge pull request #16316 from nextcloud/fix/dismiss-upload-error-notification
fix(upload-notification): dismiss error notification
2 parents e2d43c9 + 53ec438 commit d7c83d2

File tree

4 files changed

+10
-19
lines changed

4 files changed

+10
-19
lines changed

app/src/main/java/com/nextcloud/client/jobs/notification/WorkerNotificationManager.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ open class WorkerNotificationManager(
5757
notificationManager.notify(id, notification)
5858
}
5959

60+
fun dismissNotification(id: Int) {
61+
notificationManager.cancel(id)
62+
}
63+
6064
@Suppress("MagicNumber")
6165
fun setProgress(percent: Int, progressText: String?, indeterminate: Boolean) {
6266
notificationBuilder.run {

app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,22 +116,11 @@ class UploadNotificationManager(private val context: Context, viewThemeUtils: Vi
116116
return
117117
}
118118

119-
dismissOldErrorNotification(operation.file.remotePath, operation.file.storagePath)
120-
121-
operation.oldFile?.let {
122-
dismissOldErrorNotification(it.remotePath, it.storagePath)
123-
}
119+
dismissNotification(operation.ocUploadId.toInt())
124120
}
125121

126122
fun dismissErrorNotification() = notificationManager.cancel(FileUploadWorker.NOTIFICATION_ERROR_ID)
127123

128-
fun dismissOldErrorNotification(remotePath: String, localPath: String) {
129-
notificationManager.cancel(
130-
NotificationUtils.createUploadNotificationTag(remotePath, localPath),
131-
FileUploadWorker.NOTIFICATION_ERROR_ID
132-
)
133-
}
134-
135124
fun notifyPaused(intent: PendingIntent) {
136125
notificationBuilder.run {
137126
setContentTitle(context.getString(R.string.upload_global_pause_title))

app/src/main/java/com/owncloud/android/ui/activity/ConflictsResolveActivity.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,13 @@ class ConflictsResolveActivity :
230230

231231
upload?.let {
232232
FileUploadHelper.instance().removeFileUpload(it.remotePath, it.accountName)
233-
234-
UploadNotificationManager(
233+
val id = it.uploadId.toInt()
234+
val nm = UploadNotificationManager(
235235
applicationContext,
236236
viewThemeUtils,
237-
upload.uploadId.toInt()
238-
).dismissOldErrorNotification(it.remotePath, it.localPath)
237+
id
238+
)
239+
nm.dismissNotification(id)
239240
}
240241
}
241242

app/src/main/java/com/owncloud/android/ui/notifications/NotificationUtils.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,4 @@ object NotificationUtils {
2222
const val NOTIFICATION_CHANNEL_BACKGROUND_OPERATIONS: String = "NOTIFICATION_CHANNEL_BACKGROUND_OPERATIONS"
2323
const val NOTIFICATION_CHANNEL_OFFLINE_OPERATIONS: String = "NOTIFICATION_CHANNEL_OFFLINE_OPERATIONS"
2424
const val NOTIFICATION_CHANNEL_CONTENT_OBSERVER: String = "NOTIFICATION_CHANNEL_CONTENT_OBSERVER"
25-
26-
@JvmStatic
27-
fun createUploadNotificationTag(remotePath: String?, localPath: String): String = remotePath + localPath
2825
}

0 commit comments

Comments
 (0)