From 85ef40d0ffa3c3759d88f800d471fd24db8879de Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 7 May 2022 11:04:55 -0400 Subject: [PATCH] Don't allow swiping away app update install notification Also show the new version number in the notifications. --- .../eu/kanade/tachiyomi/data/updater/AppUpdateNotifier.kt | 2 ++ .../eu/kanade/tachiyomi/data/updater/AppUpdateService.kt | 2 +- .../eu/kanade/tachiyomi/ui/more/NewUpdateDialogController.kt | 5 ++++- app/src/main/res/values/strings.xml | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateNotifier.kt index 242835f38..8d13b8928 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateNotifier.kt @@ -29,6 +29,7 @@ internal class AppUpdateNotifier(private val context: Context) { fun promptUpdate(release: GithubRelease) { val intent = Intent(context, AppUpdateService::class.java).apply { putExtra(AppUpdateService.EXTRA_DOWNLOAD_URL, release.getDownloadLink()) + putExtra(AppUpdateService.EXTRA_DOWNLOAD_TITLE, release.version) } val updateIntent = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT) @@ -116,6 +117,7 @@ internal class AppUpdateNotifier(private val context: Context) { setOnlyAlertOnce(false) setProgress(0, 0, false) setContentIntent(installIntent) + setOngoing(true) clearActions() addAction( diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateService.kt index 470151116..5a8808fcc 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateService.kt @@ -147,7 +147,7 @@ class AppUpdateService : Service() { * @param context the application context. * @param url the url to the new update. */ - fun start(context: Context, url: String, title: String = context.getString(R.string.app_name)) { + fun start(context: Context, url: String, title: String? = context.getString(R.string.app_name)) { if (!isRunning(context)) { val intent = Intent(context, AppUpdateService::class.java).apply { putExtra(EXTRA_DOWNLOAD_TITLE, title) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/more/NewUpdateDialogController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/more/NewUpdateDialogController.kt index 01053d5de..b7bca75a7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/more/NewUpdateDialogController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/more/NewUpdateDialogController.kt @@ -19,6 +19,7 @@ class NewUpdateDialogController(bundle: Bundle? = null) : DialogController(bundl constructor(update: AppUpdateResult.NewUpdate) : this( bundleOf( BODY_KEY to update.release.info, + VERSION_KEY to update.release.version, RELEASE_URL_KEY to update.release.releaseLink, DOWNLOAD_URL_KEY to update.release.getDownloadLink(), ), @@ -36,7 +37,8 @@ class NewUpdateDialogController(bundle: Bundle? = null) : DialogController(bundl applicationContext?.let { context -> // Start download val url = args.getString(DOWNLOAD_URL_KEY)!! - AppUpdateService.start(context, url) + val version = args.getString(VERSION_KEY) + AppUpdateService.start(context, url, version) } } .setNeutralButton(R.string.update_check_open) { _, _ -> @@ -55,5 +57,6 @@ class NewUpdateDialogController(bundle: Bundle? = null) : DialogController(bundl } private const val BODY_KEY = "NewUpdateDialogController.body" +private const val VERSION_KEY = "NewUpdateDialogController.version" private const val RELEASE_URL_KEY = "NewUpdateDialogController.release_url" private const val DOWNLOAD_URL_KEY = "NewUpdateDialogController.download_url" diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d7cbf7690..4a8290573 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -777,7 +777,7 @@ Downloading… - Download complete + Tap to install Download error New version available! A new version is available from the official releases. Tap to learn how to migrate from unofficial F-Droid releases.