Skip to content

Commit

Permalink
use new builder for failure notification
Browse files Browse the repository at this point in the history
Signed-off-by: parneet-guraya <[email protected]>
  • Loading branch information
parneet-guraya committed Jan 9, 2024
1 parent ecbb19f commit 8cede68
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa
mNotifyManager?.cancel(notificationId)
// summary notification would not get dismissed automatically if child notifications are cancelled programmatically
// so check if only 1 notification left if yes then cancel it because that would be summary notification
if(getActiveUploadNotifications() == 1){
if (getActiveUploadNotifications() == 1) {
mNotifyManager?.cancel(NotificationUtils.GROUP_SUMMARY_NOTIFICATION_ID)
}
}
Expand Down Expand Up @@ -294,17 +294,20 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa
context.resources.getString(R.string.nc_upload_failed_notification_text),
fileName
)
notification = mBuilder!!
val failureNotification = NotificationCompat.Builder(
context, NotificationUtils.NotificationChannels
.NOTIFICATION_CHANNEL_UPLOADS.name
)
.setContentTitle(failureTitle)
.setContentText(failureText)
.setSmallIcon(R.drawable.baseline_error_24)
.setGroup(NotificationUtils.KEY_UPLOAD_GROUP)
.setOngoing(false)
.build()

// Cancel original notification
mNotifyManager?.cancel(notificationId)
// Then show information about failure
mNotifyManager!!.notify(SystemClock.uptimeMillis().toInt(), notification)
// update current notification with failure info
mNotifyManager!!.notify(SystemClock.uptimeMillis().toInt(), failureNotification)
}

companion object {
Expand Down

0 comments on commit 8cede68

Please sign in to comment.