From 12b00e5c8d796a6043bac209264342874786e9da Mon Sep 17 00:00:00 2001 From: Benjamin <73490201+BenjaminHalko@users.noreply.github.com> Date: Wed, 29 Nov 2023 13:33:00 -0800 Subject: [PATCH] fix: specify `multithreadingDexFileWriter` in `PatcherOptions` (#1402) Co-authored-by: Ax333l --- .../manager/domain/manager/PreferencesManager.kt | 1 + .../main/java/app/revanced/manager/patcher/Session.kt | 4 +++- .../revanced/manager/patcher/worker/PatcherWorker.kt | 1 + .../ui/screen/settings/AdvancedSettingsScreen.kt | 10 ++++++++-- .../manager/ui/viewmodel/AdvancedSettingsViewModel.kt | 9 +++------ app/src/main/res/values/strings.xml | 2 ++ 6 files changed, 18 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/app/revanced/manager/domain/manager/PreferencesManager.kt b/app/src/main/java/app/revanced/manager/domain/manager/PreferencesManager.kt index 44f61794..34a41ab8 100644 --- a/app/src/main/java/app/revanced/manager/domain/manager/PreferencesManager.kt +++ b/app/src/main/java/app/revanced/manager/domain/manager/PreferencesManager.kt @@ -12,6 +12,7 @@ class PreferencesManager( val api = stringPreference("api_url", "https://api.revanced.app") + val multithreadingDexFileWriter = booleanPreference("multithreading_dex_file_writer", true) val allowExperimental = booleanPreference("allow_experimental", false) val keystoreCommonName = stringPreference("keystore_cn", KeystoreManager.DEFAULT) diff --git a/app/src/main/java/app/revanced/manager/patcher/Session.kt b/app/src/main/java/app/revanced/manager/patcher/Session.kt index 35b80e5e..337bd195 100644 --- a/app/src/main/java/app/revanced/manager/patcher/Session.kt +++ b/app/src/main/java/app/revanced/manager/patcher/Session.kt @@ -20,6 +20,7 @@ class Session( cacheDir: String, frameworkDir: String, aaptPath: String, + multithreadingDexFileWriter: Boolean, private val logger: ManagerLogger, private val input: File, private val onStepSucceeded: suspend () -> Unit @@ -30,7 +31,8 @@ class Session( inputFile = input, resourceCachePath = tempDir.resolve("aapt-resources"), frameworkFileDirectory = frameworkDir, - aaptBinaryPath = aaptPath + aaptBinaryPath = aaptPath, + multithreadingDexFileWriter = multithreadingDexFileWriter, ) ) diff --git a/app/src/main/java/app/revanced/manager/patcher/worker/PatcherWorker.kt b/app/src/main/java/app/revanced/manager/patcher/worker/PatcherWorker.kt index ba6e3afe..4779677a 100644 --- a/app/src/main/java/app/revanced/manager/patcher/worker/PatcherWorker.kt +++ b/app/src/main/java/app/revanced/manager/patcher/worker/PatcherWorker.kt @@ -219,6 +219,7 @@ class PatcherWorker( fs.tempDir.absolutePath, frameworkPath, aaptPath, + prefs.multithreadingDexFileWriter.get(), args.logger, inputFile, onStepSucceeded = ::updateProgress diff --git a/app/src/main/java/app/revanced/manager/ui/screen/settings/AdvancedSettingsScreen.kt b/app/src/main/java/app/revanced/manager/ui/screen/settings/AdvancedSettingsScreen.kt index 0923ce04..f1dc35b1 100644 --- a/app/src/main/java/app/revanced/manager/ui/screen/settings/AdvancedSettingsScreen.kt +++ b/app/src/main/java/app/revanced/manager/ui/screen/settings/AdvancedSettingsScreen.kt @@ -70,7 +70,7 @@ fun AdvancedSettingsScreen( .padding(paddingValues) .verticalScroll(rememberScrollState()) ) { - val apiUrl by vm.apiUrl.getAsState() + val apiUrl by vm.prefs.api.getAsState() var showApiUrlDialog by rememberSaveable { mutableStateOf(false) } if (showApiUrlDialog) { @@ -89,11 +89,17 @@ fun AdvancedSettingsScreen( GroupHeader(stringResource(R.string.patcher)) BooleanItem( - preference = vm.allowExperimental, + preference = vm.prefs.allowExperimental, coroutineScope = vm.viewModelScope, headline = R.string.experimental_patches, description = R.string.experimental_patches_description ) + BooleanItem( + preference = vm.prefs.multithreadingDexFileWriter, + coroutineScope = vm.viewModelScope, + headline = R.string.multithreaded_dex_file_writer, + description = R.string.multithreaded_dex_file_writer_description, + ) GroupHeader(stringResource(R.string.patch_bundles_section)) SettingsListItem( diff --git a/app/src/main/java/app/revanced/manager/ui/viewmodel/AdvancedSettingsViewModel.kt b/app/src/main/java/app/revanced/manager/ui/viewmodel/AdvancedSettingsViewModel.kt index 6d7d79b8..9efed1dd 100644 --- a/app/src/main/java/app/revanced/manager/ui/viewmodel/AdvancedSettingsViewModel.kt +++ b/app/src/main/java/app/revanced/manager/ui/viewmodel/AdvancedSettingsViewModel.kt @@ -12,17 +12,14 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch class AdvancedSettingsViewModel( - prefs: PreferencesManager, + val prefs: PreferencesManager, private val app: Application, private val patchBundleRepository: PatchBundleRepository ) : ViewModel() { - val apiUrl = prefs.api - val allowExperimental = prefs.allowExperimental - fun setApiUrl(value: String) = viewModelScope.launch(Dispatchers.Default) { - if (value == apiUrl.get()) return@launch + if (value == prefs.api.get()) return@launch - apiUrl.update(value) + prefs.api.update(value) patchBundleRepository.reloadApiBundles() } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 37f33002..e1cdfaf2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -65,6 +65,8 @@ Adapt colors to the wallpaper Theme Choose between light or dark theme + Multi-threaded DEX file writer + Use multiple cores to write DEX files. This is faster, but uses more memory Allow experimental patches Allow patching incompatible patches with experimental versions, something may break Import keystore