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 8d8135d4b3cd8e6f333abb3ee35f0c9d0b73f811..d354d491688ec0f930bc25c7afffe274a0bd9a13 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(