From 2ddfec4acdf16b5d8f5e3ac1f8d7c46b0b773d57 Mon Sep 17 00:00:00 2001 From: machiav3lli Date: Tue, 9 Jul 2024 10:42:26 +0200 Subject: [PATCH] Clean up --- .../fdroid/service/worker/DownloadWorker.kt | 39 ++++++++++--------- .../ui/components/appsheet/PrivacyPanel.kt | 2 - 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/main/kotlin/com/machiav3lli/fdroid/service/worker/DownloadWorker.kt b/src/main/kotlin/com/machiav3lli/fdroid/service/worker/DownloadWorker.kt index 909bfd53ca..aa830f4826 100644 --- a/src/main/kotlin/com/machiav3lli/fdroid/service/worker/DownloadWorker.kt +++ b/src/main/kotlin/com/machiav3lli/fdroid/service/worker/DownloadWorker.kt @@ -165,26 +165,27 @@ class DownloadWorker( val partialRelease = Cache.getPartialReleaseFile(applicationContext, task.release.cacheFileName) - val callback: suspend (read: Long, total: Long?, downloadID: Long) -> Unit = { read, total, downloadID -> - val progress = if (total != null) { - workDataOf( - ARG_PROGRESS to (100f * read / total).roundToInt(), - ARG_READ to read, - ARG_TOTAL to total - ) - } else { - workDataOf( - ARG_PROGRESS to -1, - ARG_READ to read, - ARG_TOTAL to 0, - ) - } - if (!isStopped) setProgress(progress) - else if (downloadID != -1L) { - ContextCompat.getSystemService(context, DownloadManager::class.java) - ?.remove(downloadID) + val callback: suspend (read: Long, total: Long?, downloadID: Long) -> Unit = + { read, total, downloadID -> + val progress = if (total != null) { + workDataOf( + ARG_PROGRESS to (100f * read / total).roundToInt(), + ARG_READ to read, + ARG_TOTAL to total + ) + } else { + workDataOf( + ARG_PROGRESS to -1, + ARG_READ to read, + ARG_TOTAL to 0, + ) + } + if (!isStopped) setProgress(progress) + else if (downloadID != -1L) { + ContextCompat.getSystemService(context, DownloadManager::class.java) + ?.remove(downloadID) + } } - } (if (Preferences[Preferences.Key.DownloadManager]) Downloader.dmDownload(context, task, partialRelease, callback) diff --git a/src/main/kotlin/com/machiav3lli/fdroid/ui/components/appsheet/PrivacyPanel.kt b/src/main/kotlin/com/machiav3lli/fdroid/ui/components/appsheet/PrivacyPanel.kt index 3dc09e82b2..51769b754d 100644 --- a/src/main/kotlin/com/machiav3lli/fdroid/ui/components/appsheet/PrivacyPanel.kt +++ b/src/main/kotlin/com/machiav3lli/fdroid/ui/components/appsheet/PrivacyPanel.kt @@ -25,7 +25,6 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp -import com.afollestad.materialdialogs.ModalDialog import com.machiav3lli.fdroid.ANTIFEATURES_WEBSITE import com.machiav3lli.fdroid.EXODUS_TRACKER_WEBSITE import com.machiav3lli.fdroid.NeoActivity @@ -272,7 +271,6 @@ fun PrivacyPanel( Uri.parse("market://search?q=$TC_PACKAGENAME") ) ) - ModalDialog.onDismiss() } else context.startActivity( tcIntent.putExtra( TC_INTENT_EXTRA_SEARCH,