Fix app update install notification disappearing
This commit is contained in:
parent
7b294478e4
commit
4ca0fc7a4d
@ -79,6 +79,7 @@ object Notifications {
|
||||
private const val GROUP_APK_UPDATES = "group_apk_updates"
|
||||
const val CHANNEL_APP_UPDATE = "app_apk_update_channel"
|
||||
const val ID_APP_UPDATER = 1
|
||||
const val ID_APP_UPDATE_PROMPT = 2
|
||||
const val CHANNEL_EXTENSIONS_UPDATE = "ext_apk_update_channel"
|
||||
const val ID_UPDATES_TO_EXTS = -401
|
||||
const val ID_EXTENSION_INSTALLER = -402
|
||||
|
@ -61,22 +61,6 @@ internal class AppUpdateNotifier(private val context: Context) {
|
||||
notificationBuilder.show()
|
||||
}
|
||||
|
||||
/**
|
||||
* Some people are still installing the app from F-Droid, so we avoid prompting GitHub-based
|
||||
* updates.
|
||||
*
|
||||
* We can prompt them to migrate to the GitHub version though.
|
||||
*/
|
||||
fun promptFdroidUpdate() {
|
||||
with(notificationBuilder) {
|
||||
setContentTitle(context.getString(R.string.update_check_notification_update_available))
|
||||
setContentText(context.getString(R.string.update_check_fdroid_migration_info))
|
||||
setSmallIcon(R.drawable.ic_tachi)
|
||||
setContentIntent(NotificationHandler.openUrl(context, "https://tachiyomi.org/help/faq/#how-do-i-migrate-from-the-f-droid-version"))
|
||||
}
|
||||
notificationBuilder.show()
|
||||
}
|
||||
|
||||
/**
|
||||
* Call when apk download starts.
|
||||
*
|
||||
@ -118,7 +102,7 @@ internal class AppUpdateNotifier(private val context: Context) {
|
||||
*
|
||||
* @param uri path location of apk.
|
||||
*/
|
||||
fun onDownloadFinished(uri: Uri) {
|
||||
fun promptInstall(uri: Uri) {
|
||||
val installIntent = NotificationHandler.installApkPendingActivity(context, uri)
|
||||
with(notificationBuilder) {
|
||||
setContentText(context.getString(R.string.update_check_notification_download_complete))
|
||||
@ -137,10 +121,26 @@ internal class AppUpdateNotifier(private val context: Context) {
|
||||
addAction(
|
||||
R.drawable.ic_close_24dp,
|
||||
context.getString(R.string.action_cancel),
|
||||
NotificationReceiver.dismissNotificationPendingBroadcast(context, Notifications.ID_APP_UPDATER),
|
||||
NotificationReceiver.dismissNotificationPendingBroadcast(context, Notifications.ID_APP_UPDATE_PROMPT),
|
||||
)
|
||||
}
|
||||
notificationBuilder.show()
|
||||
notificationBuilder.show(Notifications.ID_APP_UPDATE_PROMPT)
|
||||
}
|
||||
|
||||
/**
|
||||
* Some people are still installing the app from F-Droid, so we avoid prompting GitHub-based
|
||||
* updates.
|
||||
*
|
||||
* We can prompt them to migrate to the GitHub version though.
|
||||
*/
|
||||
fun promptFdroidUpdate() {
|
||||
with(notificationBuilder) {
|
||||
setContentTitle(context.getString(R.string.update_check_notification_update_available))
|
||||
setContentText(context.getString(R.string.update_check_fdroid_migration_info))
|
||||
setSmallIcon(R.drawable.ic_tachi)
|
||||
setContentIntent(NotificationHandler.openUrl(context, "https://tachiyomi.org/help/faq/#how-do-i-migrate-from-the-f-droid-version"))
|
||||
}
|
||||
notificationBuilder.show(Notifications.ID_APP_UPDATE_PROMPT)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -42,7 +42,6 @@ class AppUpdateService : Service() {
|
||||
private lateinit var notifier: AppUpdateNotifier
|
||||
|
||||
private var runningJob: Job? = null
|
||||
|
||||
private var runningCall: Call? = null
|
||||
|
||||
override fun onCreate() {
|
||||
@ -133,7 +132,7 @@ class AppUpdateService : Service() {
|
||||
response.close()
|
||||
throw Exception("Unsuccessful response")
|
||||
}
|
||||
notifier.onDownloadFinished(apkFile.getUriCompat(this))
|
||||
notifier.promptInstall(apkFile.getUriCompat(this))
|
||||
} catch (error: Exception) {
|
||||
logcat(LogPriority.ERROR, error)
|
||||
if (error is CancellationException ||
|
||||
@ -195,7 +194,7 @@ class AppUpdateService : Service() {
|
||||
val intent = Intent(context, AppUpdateService::class.java).apply {
|
||||
putExtra(EXTRA_DOWNLOAD_URL, url)
|
||||
}
|
||||
return PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
return PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user