Use proper method to clear notification actions

This commit is contained in:
arkon 2021-01-21 18:21:21 -05:00
parent db2dd4b6c6
commit cf7ec6aa76
3 changed files with 4 additions and 21 deletions

View File

@ -68,9 +68,7 @@ class BackupNotifier(private val context: Context) {
setContentText(unifile.filePath ?: unifile.name) setContentText(unifile.filePath ?: unifile.name)
// Clear old actions if they exist // Clear old actions if they exist
if (mActions.isNotEmpty()) { clearActions()
mActions.clear()
}
addAction( addAction(
R.drawable.ic_share_24dp, R.drawable.ic_share_24dp,
@ -94,9 +92,7 @@ class BackupNotifier(private val context: Context) {
setOnlyAlertOnce(true) setOnlyAlertOnce(true)
// Clear old actions if they exist // Clear old actions if they exist
if (mActions.isNotEmpty()) { clearActions()
mActions.clear()
}
addAction( addAction(
R.drawable.ic_close_24dp, R.drawable.ic_close_24dp,
@ -137,9 +133,7 @@ class BackupNotifier(private val context: Context) {
setContentText(context.resources.getQuantityString(R.plurals.restore_completed_message, errorCount, timeString, errorCount)) setContentText(context.resources.getQuantityString(R.plurals.restore_completed_message, errorCount, timeString, errorCount))
// Clear old actions if they exist // Clear old actions if they exist
if (mActions.isNotEmpty()) { clearActions()
mActions.clear()
}
if (errorCount > 0 && !path.isNullOrEmpty() && !file.isNullOrEmpty()) { if (errorCount > 0 && !path.isNullOrEmpty() && !file.isNullOrEmpty()) {
val destFile = File(path, file) val destFile = File(path, file)

View File

@ -66,15 +66,6 @@ internal class DownloadNotifier(private val context: Context) {
context.notificationManager.notify(id, build()) context.notificationManager.notify(id, build())
} }
/**
* Clear old actions if they exist.
*/
private fun NotificationCompat.Builder.clearActions() {
if (mActions.isNotEmpty()) {
mActions.clear()
}
}
/** /**
* Dismiss the downloader's notification. Downloader error notifications use a different id, so * Dismiss the downloader's notification. Downloader error notifications use a different id, so
* those can only be dismissed by the user. * those can only be dismissed by the user.

View File

@ -60,9 +60,7 @@ class SaveImageNotifier(private val context: Context) {
setAutoCancel(true) setAutoCancel(true)
// Clear old actions if they exist // Clear old actions if they exist
if (mActions.isNotEmpty()) { clearActions()
mActions.clear()
}
setContentIntent(NotificationHandler.openImagePendingActivity(context, file)) setContentIntent(NotificationHandler.openImagePendingActivity(context, file))
// Share action // Share action