Skip to content

Commit

Permalink
fix: specify multithreadingDexFileWriter in PatcherOptions (ReVan…
Browse files Browse the repository at this point in the history
…ced#1402)

Co-authored-by: Ax333l <[email protected]>
  • Loading branch information
BenjaminHalko and Axelen123 authored Nov 29, 2023
1 parent 9cab919 commit 12b00e5
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/app/revanced/manager/patcher/Session.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,7 +31,8 @@ class Session(
inputFile = input,
resourceCachePath = tempDir.resolve("aapt-resources"),
frameworkFileDirectory = frameworkDir,
aaptBinaryPath = aaptPath
aaptBinaryPath = aaptPath,
multithreadingDexFileWriter = multithreadingDexFileWriter,
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ class PatcherWorker(
fs.tempDir.absolutePath,
frameworkPath,
aaptPath,
prefs.multithreadingDexFileWriter.get(),
args.logger,
inputFile,
onStepSucceeded = ::updateProgress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
<string name="dynamic_color_description">Adapt colors to the wallpaper</string>
<string name="theme">Theme</string>
<string name="theme_description">Choose between light or dark theme</string>
<string name="multithreaded_dex_file_writer">Multi-threaded DEX file writer</string>
<string name="multithreaded_dex_file_writer_description">Use multiple cores to write DEX files. This is faster, but uses more memory</string>
<string name="experimental_patches">Allow experimental patches</string>
<string name="experimental_patches_description">Allow patching incompatible patches with experimental versions, something may break</string>
<string name="import_keystore">Import keystore</string>
Expand Down

0 comments on commit 12b00e5

Please sign in to comment.