From f85f26cd95aa01b2b25495bc05e785b637028367 Mon Sep 17 00:00:00 2001 From: hasibprince Date: Wed, 26 Oct 2022 11:11:56 +0600 Subject: [PATCH] ignore installation_issue to show update end notification --- .../e/apps/manager/workmanager/InstallAppWorker.kt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/manager/workmanager/InstallAppWorker.kt b/app/src/main/java/foundation/e/apps/manager/workmanager/InstallAppWorker.kt index 8d8135d4b..d354d4916 100644 --- a/app/src/main/java/foundation/e/apps/manager/workmanager/InstallAppWorker.kt +++ b/app/src/main/java/foundation/e/apps/manager/workmanager/InstallAppWorker.kt @@ -122,7 +122,7 @@ class InstallAppWorker @AssistedInject constructor( fusedManagerRepository.installationIssue(it) } } finally { - if (isItUpdateWork && databaseRepository.getDownloadList().isEmpty()) { // show notification for ended update + if (isItUpdateWork && isUpdateCompleted()) { // show notification for ended update showNotificationOnUpdateEnded() } @@ -131,6 +131,15 @@ class InstallAppWorker @AssistedInject constructor( } } + private suspend fun isUpdateCompleted(): Boolean { + val downloadListWithoutAnyIssue = + databaseRepository.getDownloadList() + .filter { !listOf(Status.INSTALLATION_ISSUE, Status.PURCHASE_NEEDED).contains(it.status) } + + return downloadListWithoutAnyIssue.isEmpty() + } + + private fun showNotificationOnUpdateEnded() { val date = Date(System.currentTimeMillis()) val dateFormat = @@ -250,7 +259,7 @@ class InstallAppWorker @AssistedInject constructor( val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as - NotificationManager + NotificationManager // Create a Notification channel if necessary if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { val mChannel = NotificationChannel( -- GitLab