Minor cleanup

This commit is contained in:
arkon 2023-07-30 10:08:51 -04:00
parent d65f9c2916
commit 0f21d16263
5 changed files with 13 additions and 19 deletions

View File

@ -40,7 +40,6 @@ import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.data.track.TrackManager
import eu.kanade.tachiyomi.ui.category.CategoryScreen import eu.kanade.tachiyomi.ui.category.CategoryScreen
import eu.kanade.tachiyomi.util.system.isDevFlavor
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import tachiyomi.domain.category.interactor.GetCategories import tachiyomi.domain.category.interactor.GetCategories
@ -258,10 +257,10 @@ object SettingsLibraryScreen : SearchableSettings {
pluralStringResource(R.plurals.pref_update_release_following_days, followRange, followRange), pluralStringResource(R.plurals.pref_update_release_following_days, followRange, followRange),
).joinToString(), ).joinToString(),
onClick = { showFetchRangesDialog = true }, onClick = { showFetchRangesDialog = true },
).takeIf { MANGA_OUTSIDE_RELEASE_PERIOD in libraryUpdateMangaRestriction && isDevFlavor }, ).takeIf { MANGA_OUTSIDE_RELEASE_PERIOD in libraryUpdateMangaRestriction },
Preference.PreferenceItem.InfoPreference( Preference.PreferenceItem.InfoPreference(
title = stringResource(R.string.pref_update_release_grace_period_info), 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( Preference.PreferenceItem.SwitchPreference(
pref = libraryPreferences.newShowUpdatesCount(), pref = libraryPreferences.newShowUpdatesCount(),
title = stringResource(R.string.pref_library_update_show_tab_badge), title = stringResource(R.string.pref_library_update_show_tab_badge),

View File

@ -238,10 +238,10 @@ class ExtensionManager(
/** /**
* Uninstalls the extension that matches the given package name. * 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) { fun uninstallExtension(extension: Extension) {
installer.uninstallApk(pkgName) installer.uninstallApk(extension.pkgName)
} }
/** /**
@ -260,18 +260,13 @@ class ExtensionManager(
val nowTrustedExtensions = _untrustedExtensionsFlow.value.filter { it.signatureHash == signature } val nowTrustedExtensions = _untrustedExtensionsFlow.value.filter { it.signatureHash == signature }
_untrustedExtensionsFlow.value -= nowTrustedExtensions _untrustedExtensionsFlow.value -= nowTrustedExtensions
val ctx = context
launchNow { launchNow {
nowTrustedExtensions nowTrustedExtensions
.map { extension -> .map { extension ->
async { ExtensionLoader.loadExtensionFromPkgName(ctx, extension.pkgName) } async { ExtensionLoader.loadExtensionFromPkgName(context, extension.pkgName) }.await()
}
.map { it.await() }
.forEach { result ->
if (result is LoadResult.Success) {
registerNewExtension(result.extension)
}
} }
.filterIsInstance<LoadResult.Success>()
.forEach { registerNewExtension(it.extension) }
} }
} }

View File

@ -171,8 +171,8 @@ class ExtensionsScreenModel(
.onCompletion { removeDownloadState(extension) } .onCompletion { removeDownloadState(extension) }
.collect() .collect()
fun uninstallExtension(pkgName: String) { fun uninstallExtension(extension: Extension) {
extensionManager.uninstallExtension(pkgName) extensionManager.uninstallExtension(extension)
} }
fun findAvailableExtensions() { fun findAvailableExtensions() {

View File

@ -41,7 +41,7 @@ fun extensionsTab(
onLongClickItem = { extension -> onLongClickItem = { extension ->
when (extension) { when (extension) {
is Extension.Available -> extensionsScreenModel.installExtension(extension) is Extension.Available -> extensionsScreenModel.installExtension(extension)
else -> extensionsScreenModel.uninstallExtension(extension.pkgName) else -> extensionsScreenModel.uninstallExtension(extension)
} }
}, },
onClickItemCancel = extensionsScreenModel::cancelInstallUpdateExtension, onClickItemCancel = extensionsScreenModel::cancelInstallUpdateExtension,
@ -49,7 +49,7 @@ fun extensionsTab(
onInstallExtension = extensionsScreenModel::installExtension, onInstallExtension = extensionsScreenModel::installExtension,
onOpenExtension = { navigator.push(ExtensionDetailsScreen(it.pkgName)) }, onOpenExtension = { navigator.push(ExtensionDetailsScreen(it.pkgName)) },
onTrustExtension = { extensionsScreenModel.trustSignature(it.signatureHash) }, onTrustExtension = { extensionsScreenModel.trustSignature(it.signatureHash) },
onUninstallExtension = { extensionsScreenModel.uninstallExtension(it.pkgName) }, onUninstallExtension = { extensionsScreenModel.uninstallExtension(it) },
onUpdateExtension = extensionsScreenModel::updateExtension, onUpdateExtension = extensionsScreenModel::updateExtension,
onRefresh = extensionsScreenModel::findAvailableExtensions, onRefresh = extensionsScreenModel::findAvailableExtensions,
) )

View File

@ -132,7 +132,7 @@ class ExtensionDetailsScreenModel(
fun uninstallExtension() { fun uninstallExtension() {
val extension = state.value.extension ?: return val extension = state.value.extension ?: return
extensionManager.uninstallExtension(extension.pkgName) extensionManager.uninstallExtension(extension)
} }
fun toggleSource(sourceId: Long) { fun toggleSource(sourceId: Long) {