refactor: use consistent wording for the version compat check

This commit is contained in:
Ax333l 2024-01-20 17:48:08 +01:00
parent e186dfdaa9
commit 4acef776b2
No known key found for this signature in database
GPG key ID: D2B4D85271127D23
7 changed files with 16 additions and 20 deletions

View file

@ -13,7 +13,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 disablePatchVersionCompatCheck = booleanPreference("disable_patch_version_compatibility_check", false)
val keystoreCommonName = stringPreference("keystore_cn", KeystoreManager.DEFAULT)
val keystorePass = stringPreference("keystore_pass", KeystoreManager.DEFAULT)

View file

@ -257,7 +257,7 @@ fun PatchesSelectorScreen(
)
}
if (!vm.allowExperimental) return@LazyColumnWithScrollbar
if (!vm.allowIncompatiblePatches) return@LazyColumnWithScrollbar
patchList(
uid = bundle.uid,
patches = bundle.unsupported.searched(),
@ -366,7 +366,7 @@ fun PatchesSelectorScreen(
uid = bundle.uid,
patches = bundle.unsupported,
filterFlag = SHOW_UNSUPPORTED,
supported = vm.allowExperimental
supported = vm.allowIncompatiblePatches
) {
ListHeader(
title = stringResource(R.string.unsupported_patches),

View file

@ -56,10 +56,10 @@ fun SelectedAppInfoScreen(
vm.bundlesRepo.bundleInfoFlow(packageName, version)
}.collectAsStateWithLifecycle(initialValue = emptyList())
val allowExperimental by vm.prefs.allowExperimental.getAsState()
val allowIncompatiblePatches by vm.prefs.disablePatchVersionCompatCheck.getAsState()
val patches by remember {
derivedStateOf {
vm.getPatches(bundles, allowExperimental)
vm.getPatches(bundles, allowIncompatiblePatches)
}
}
val selectedPatchCount by remember {
@ -99,7 +99,7 @@ fun SelectedAppInfoScreen(
vm.selectedApp,
vm.getCustomPatches(
bundles,
allowExperimental
allowIncompatiblePatches
),
vm.options
)

View file

@ -87,10 +87,10 @@ fun AdvancedSettingsScreen(
GroupHeader(stringResource(R.string.patcher))
BooleanItem(
preference = vm.prefs.allowExperimental,
preference = vm.prefs.disablePatchVersionCompatCheck,
coroutineScope = vm.viewModelScope,
headline = R.string.experimental_patches,
description = R.string.experimental_patches_description
headline = R.string.patch_compat_check,
description = R.string.patch_compat_check_description
)
BooleanItem(
preference = vm.prefs.multithreadingDexFileWriter,

View file

@ -3,7 +3,6 @@ package app.revanced.manager.ui.viewmodel
import android.app.Application
import android.content.ActivityNotFoundException
import android.content.Intent
import android.os.Build
import android.util.Base64
import android.util.Log
import androidx.activity.ComponentActivity
@ -23,15 +22,12 @@ import app.revanced.manager.domain.repository.PatchBundleRepository
import app.revanced.manager.domain.repository.PatchSelectionRepository
import app.revanced.manager.domain.repository.SerializedSelection
import app.revanced.manager.network.api.ReVancedAPI
import app.revanced.manager.network.utils.getOrThrow
import app.revanced.manager.ui.theme.Theme
import app.revanced.manager.util.tag
import app.revanced.manager.util.toast
import app.revanced.manager.util.uiSafe
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.Json
@ -134,7 +130,7 @@ class MainViewModel(
prefs.api.update(api.removeSuffix("/"))
}
settings.experimentalPatchesEnabled?.let { allowExperimental ->
prefs.allowExperimental.update(allowExperimental)
prefs.disablePatchVersionCompatCheck.update(allowExperimental)
}
settings.patchesAutoUpdate?.let { autoUpdate ->
with(patchBundleRepository) {

View file

@ -52,7 +52,7 @@ class PatchesSelectorViewModel(input: Params) : ViewModel(), KoinComponent {
var selectionWarningEnabled by mutableStateOf(true)
private set
val allowExperimental = get<PreferencesManager>().allowExperimental.getBlocking()
val allowIncompatiblePatches = get<PreferencesManager>().disablePatchVersionCompatCheck.getBlocking()
val bundlesFlow =
get<PatchBundleRepository>().bundleInfoFlow(packageName, input.app.version)
@ -63,7 +63,7 @@ class PatchesSelectorViewModel(input: Params) : ViewModel(), KoinComponent {
return@launch
}
fun BundleInfo.hasDefaultPatches() = patchSequence(allowExperimental).any { it.include }
fun BundleInfo.hasDefaultPatches() = patchSequence(allowIncompatiblePatches).any { it.include }
// Don't show the warning if there are no default patches.
selectionWarningEnabled = bundlesFlow.first().any(BundleInfo::hasDefaultPatches)
@ -100,13 +100,13 @@ class PatchesSelectorViewModel(input: Params) : ViewModel(), KoinComponent {
private suspend fun generateDefaultSelection(): PersistentPatchSelection {
val bundles = bundlesFlow.first()
val generatedSelection =
bundles.toPatchSelection(allowExperimental) { _, patch -> patch.include }
bundles.toPatchSelection(allowIncompatiblePatches) { _, patch -> patch.include }
return generatedSelection.toPersistentPatchSelection()
}
fun selectionIsValid(bundles: List<BundleInfo>) = bundles.any { bundle ->
bundle.patchSequence(allowExperimental).any { patch ->
bundle.patchSequence(allowIncompatiblePatches).any { patch ->
isSelected(bundle.uid, patch)
}
}

View file

@ -67,8 +67,8 @@
<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="patch_compat_check">Disable version compatibility check</string>
<string name="patch_compat_check_description">The check restricts patches to supported app versions</string>
<string name="import_keystore">Import keystore</string>
<string name="import_keystore_description">Import a custom keystore</string>
<string name="import_keystore_dialog_title">Enter keystore credentials</string>