From 21259dddf5403f7de0ca02d20ea5eb1006c317f5 Mon Sep 17 00:00:00 2001 From: darken Date: Thu, 28 Nov 2024 18:32:09 +0100 Subject: [PATCH] AppCleaner: Better deletion progress feedback --- .../eu/darken/sdmse/appcleaner/core/AppCleaner.kt | 12 +++++++++--- .../core/forensics/BaseExpendablesFilter.kt | 3 +++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/darken/sdmse/appcleaner/core/AppCleaner.kt b/app/src/main/java/eu/darken/sdmse/appcleaner/core/AppCleaner.kt index aaa270626..0dc11fa45 100644 --- a/app/src/main/java/eu/darken/sdmse/appcleaner/core/AppCleaner.kt +++ b/app/src/main/java/eu/darken/sdmse/appcleaner/core/AppCleaner.kt @@ -52,6 +52,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.combine +import kotlinx.coroutines.flow.first import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock import javax.inject.Inject @@ -231,11 +232,16 @@ class AppCleaner @Inject constructor( ?: throw IllegalStateException("Can't find filter for $filterIdentifier") updateProgressSecondary(eu.darken.sdmse.common.R.string.general_progress_loading) - + val currentProgress = progress.first() filter.withProgress( client = this, - onUpdate = { old, new -> old?.copy(secondary = new?.primary ?: CaString.EMPTY) }, - onCompletion = { it } + onUpdate = { old, new -> + old?.copy( + secondary = new?.primary ?: CaString.EMPTY, + count = new?.count ?: Progress.Count.Indeterminate(), + ) + }, + onCompletion = { currentProgress } ) { val result = process(targets, allMatches) log(TAG, INFO) { diff --git a/app/src/main/java/eu/darken/sdmse/appcleaner/core/forensics/BaseExpendablesFilter.kt b/app/src/main/java/eu/darken/sdmse/appcleaner/core/forensics/BaseExpendablesFilter.kt index 2589d8c6d..e70262572 100644 --- a/app/src/main/java/eu/darken/sdmse/appcleaner/core/forensics/BaseExpendablesFilter.kt +++ b/app/src/main/java/eu/darken/sdmse/appcleaner/core/forensics/BaseExpendablesFilter.kt @@ -41,6 +41,7 @@ abstract class BaseExpendablesFilter : ExpendablesFilter { val successful = mutableSetOf() val failed = mutableSetOf>() + log(TAG, VERBOSE) { "Checking distinct roots..." } val distinctRoots = targets.map { it.lookup }.filterDistinctRoots() if (distinctRoots.size != targets.size) { @@ -52,9 +53,11 @@ abstract class BaseExpendablesFilter : ExpendablesFilter { } } + log(TAG) { "Got ${distinctRoots.size} distinct roots" } updateProgressCount(Progress.Count.Percent(distinctRoots.size)) distinctRoots.forEach { targetRoot -> + log(TAG) { "Processing root: $targetRoot" } updateProgressPrimary(targetRoot.userReadablePath) val main = targets.first { it.lookup == targetRoot }