From dfd858034f3b6c023774f915a08150e50f702665 Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 17 Apr 2021 12:58:14 -0400 Subject: [PATCH] Avoid duplicate actions in update notifications --- .../tachiyomi/data/updater/UpdaterNotifier.kt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/updater/UpdaterNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/data/updater/UpdaterNotifier.kt index 2d8d27803..6dc4bec8c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/updater/UpdaterNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/updater/UpdaterNotifier.kt @@ -40,7 +40,8 @@ internal class UpdaterNotifier(private val context: Context) { setContentText(context.getString(R.string.update_check_notification_update_available)) setSmallIcon(android.R.drawable.stat_sys_download_done) setContentIntent(pendingIntent) - // Download action + + clearActions() addAction( android.R.drawable.stat_sys_download_done, context.getString(R.string.action_download), @@ -85,19 +86,20 @@ internal class UpdaterNotifier(private val context: Context) { * @param uri path location of apk. */ fun onDownloadFinished(uri: Uri) { + val installIntent = NotificationHandler.installApkPendingActivity(context, uri) with(notificationBuilder) { setContentText(context.getString(R.string.update_check_notification_download_complete)) setSmallIcon(android.R.drawable.stat_sys_download_done) setOnlyAlertOnce(false) setProgress(0, 0, false) - // Install action - setContentIntent(NotificationHandler.installApkPendingActivity(context, uri)) + setContentIntent(installIntent) + + clearActions() addAction( R.drawable.ic_system_update_alt_white_24dp, context.getString(R.string.action_install), - NotificationHandler.installApkPendingActivity(context, uri) + installIntent ) - // Cancel action addAction( R.drawable.ic_close_24dp, context.getString(R.string.action_cancel), @@ -118,13 +120,13 @@ internal class UpdaterNotifier(private val context: Context) { setSmallIcon(android.R.drawable.stat_sys_warning) setOnlyAlertOnce(false) setProgress(0, 0, false) - // Retry action + + clearActions() addAction( R.drawable.ic_refresh_24dp, context.getString(R.string.action_retry), UpdaterService.downloadApkPendingService(context, url) ) - // Cancel action addAction( R.drawable.ic_close_24dp, context.getString(R.string.action_cancel),