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 api = stringPreference("api_url", "https://api.revanced.app")
val multithreadingDexFileWriter = booleanPreference("multithreading_dex_file_writer", true) 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 keystoreCommonName = stringPreference("keystore_cn", KeystoreManager.DEFAULT)
val keystorePass = stringPreference("keystore_pass", 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( patchList(
uid = bundle.uid, uid = bundle.uid,
patches = bundle.unsupported.searched(), patches = bundle.unsupported.searched(),
@ -366,7 +366,7 @@ fun PatchesSelectorScreen(
uid = bundle.uid, uid = bundle.uid,
patches = bundle.unsupported, patches = bundle.unsupported,
filterFlag = SHOW_UNSUPPORTED, filterFlag = SHOW_UNSUPPORTED,
supported = vm.allowExperimental supported = vm.allowIncompatiblePatches
) { ) {
ListHeader( ListHeader(
title = stringResource(R.string.unsupported_patches), title = stringResource(R.string.unsupported_patches),

View File

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

View File

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

View File

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

View File

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

View File

@ -67,8 +67,8 @@
<string name="theme_description">Choose between light or dark 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">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="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="patch_compat_check">Disable version compatibility check</string>
<string name="experimental_patches_description">Allow patching incompatible patches with experimental versions, something may break</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">Import keystore</string>
<string name="import_keystore_description">Import a custom keystore</string> <string name="import_keystore_description">Import a custom keystore</string>
<string name="import_keystore_dialog_title">Enter keystore credentials</string> <string name="import_keystore_dialog_title">Enter keystore credentials</string>