From 0f21d16263b1532953dea61ce1169e0e2a403569 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 30 Jul 2023 10:08:51 -0400 Subject: [PATCH] Minor cleanup --- .../settings/screen/SettingsLibraryScreen.kt | 5 ++--- .../tachiyomi/extension/ExtensionManager.kt | 17 ++++++----------- .../browse/extension/ExtensionsScreenModel.kt | 4 ++-- .../ui/browse/extension/ExtensionsTab.kt | 4 ++-- .../details/ExtensionDetailsScreenModel.kt | 2 +- 5 files changed, 13 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsLibraryScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsLibraryScreen.kt index 84bd7deb1..1af6636df 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsLibraryScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsLibraryScreen.kt @@ -40,7 +40,6 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.library.LibraryUpdateJob import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.ui.category.CategoryScreen -import eu.kanade.tachiyomi.util.system.isDevFlavor import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking import tachiyomi.domain.category.interactor.GetCategories @@ -258,10 +257,10 @@ object SettingsLibraryScreen : SearchableSettings { pluralStringResource(R.plurals.pref_update_release_following_days, followRange, followRange), ).joinToString(), onClick = { showFetchRangesDialog = true }, - ).takeIf { MANGA_OUTSIDE_RELEASE_PERIOD in libraryUpdateMangaRestriction && isDevFlavor }, + ).takeIf { MANGA_OUTSIDE_RELEASE_PERIOD in libraryUpdateMangaRestriction }, Preference.PreferenceItem.InfoPreference( title = stringResource(R.string.pref_update_release_grace_period_info), - ).takeIf { MANGA_OUTSIDE_RELEASE_PERIOD in libraryUpdateMangaRestriction && isDevFlavor }, + ).takeIf { MANGA_OUTSIDE_RELEASE_PERIOD in libraryUpdateMangaRestriction }, Preference.PreferenceItem.SwitchPreference( pref = libraryPreferences.newShowUpdatesCount(), title = stringResource(R.string.pref_library_update_show_tab_badge), diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/ExtensionManager.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/ExtensionManager.kt index b22da0780..7d3ddd198 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/ExtensionManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/ExtensionManager.kt @@ -238,10 +238,10 @@ class ExtensionManager( /** * Uninstalls the extension that matches the given package name. * - * @param pkgName The package name of the application to uninstall. + * @param extension The extension to uninstall. */ - fun uninstallExtension(pkgName: String) { - installer.uninstallApk(pkgName) + fun uninstallExtension(extension: Extension) { + installer.uninstallApk(extension.pkgName) } /** @@ -260,18 +260,13 @@ class ExtensionManager( val nowTrustedExtensions = _untrustedExtensionsFlow.value.filter { it.signatureHash == signature } _untrustedExtensionsFlow.value -= nowTrustedExtensions - val ctx = context launchNow { nowTrustedExtensions .map { extension -> - async { ExtensionLoader.loadExtensionFromPkgName(ctx, extension.pkgName) } - } - .map { it.await() } - .forEach { result -> - if (result is LoadResult.Success) { - registerNewExtension(result.extension) - } + async { ExtensionLoader.loadExtensionFromPkgName(context, extension.pkgName) }.await() } + .filterIsInstance() + .forEach { registerNewExtension(it.extension) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsScreenModel.kt index ca3a01745..2edd8f721 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsScreenModel.kt @@ -171,8 +171,8 @@ class ExtensionsScreenModel( .onCompletion { removeDownloadState(extension) } .collect() - fun uninstallExtension(pkgName: String) { - extensionManager.uninstallExtension(pkgName) + fun uninstallExtension(extension: Extension) { + extensionManager.uninstallExtension(extension) } fun findAvailableExtensions() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsTab.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsTab.kt index 7e4075176..b327b82e9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsTab.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsTab.kt @@ -41,7 +41,7 @@ fun extensionsTab( onLongClickItem = { extension -> when (extension) { is Extension.Available -> extensionsScreenModel.installExtension(extension) - else -> extensionsScreenModel.uninstallExtension(extension.pkgName) + else -> extensionsScreenModel.uninstallExtension(extension) } }, onClickItemCancel = extensionsScreenModel::cancelInstallUpdateExtension, @@ -49,7 +49,7 @@ fun extensionsTab( onInstallExtension = extensionsScreenModel::installExtension, onOpenExtension = { navigator.push(ExtensionDetailsScreen(it.pkgName)) }, onTrustExtension = { extensionsScreenModel.trustSignature(it.signatureHash) }, - onUninstallExtension = { extensionsScreenModel.uninstallExtension(it.pkgName) }, + onUninstallExtension = { extensionsScreenModel.uninstallExtension(it) }, onUpdateExtension = extensionsScreenModel::updateExtension, onRefresh = extensionsScreenModel::findAvailableExtensions, ) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsScreenModel.kt index 60247d244..1ad0faec4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsScreenModel.kt @@ -132,7 +132,7 @@ class ExtensionDetailsScreenModel( fun uninstallExtension() { val extension = state.value.extension ?: return - extensionManager.uninstallExtension(extension.pkgName) + extensionManager.uninstallExtension(extension) } fun toggleSource(sourceId: Long) {