mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
feat: experimental patches setting
This commit is contained in:
parent
923ce74735
commit
9dd74f1f22
@ -12,7 +12,8 @@ class PreferencesManager(
|
|||||||
) : BasePreferenceManager(sharedPreferences) {
|
) : BasePreferenceManager(sharedPreferences) {
|
||||||
var dynamicColor by booleanPreference("dynamic_color", true)
|
var dynamicColor by booleanPreference("dynamic_color", true)
|
||||||
var theme by enumPreference("theme", Theme.SYSTEM)
|
var theme by enumPreference("theme", Theme.SYSTEM)
|
||||||
//var sentry by booleanPreference("sentry", true)
|
|
||||||
|
var allowExperimental by booleanPreference("allow_experimental", false)
|
||||||
|
|
||||||
var keystoreCommonName by stringPreference("keystore_cn", KeystoreManager.DEFAULT)
|
var keystoreCommonName by stringPreference("keystore_cn", KeystoreManager.DEFAULT)
|
||||||
var keystorePass by stringPreference("keystore_pass", KeystoreManager.DEFAULT)
|
var keystorePass by stringPreference("keystore_pass", KeystoreManager.DEFAULT)
|
||||||
|
@ -51,8 +51,6 @@ import app.revanced.manager.ui.viewmodel.PatchesSelectorViewModel.Companion.SHOW
|
|||||||
import app.revanced.manager.util.PatchesSelection
|
import app.revanced.manager.util.PatchesSelection
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
const val allowUnsupported = false
|
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class)
|
@OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun PatchesSelectorScreen(
|
fun PatchesSelectorScreen(
|
||||||
@ -206,7 +204,7 @@ fun PatchesSelectorScreen(
|
|||||||
patchList(
|
patchList(
|
||||||
patches = bundle.unsupported,
|
patches = bundle.unsupported,
|
||||||
filterFlag = SHOW_UNSUPPORTED,
|
filterFlag = SHOW_UNSUPPORTED,
|
||||||
supported = allowUnsupported
|
supported = vm.allowExperimental
|
||||||
) {
|
) {
|
||||||
ListHeader(
|
ListHeader(
|
||||||
title = stringResource(R.string.unsupported_patches),
|
title = stringResource(R.string.unsupported_patches),
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package app.revanced.manager.ui.screen.settings
|
package app.revanced.manager.ui.screen.settings
|
||||||
|
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
import androidx.annotation.StringRes
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
@ -65,24 +66,27 @@ fun GeneralSettingsScreen(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||||
ListItem(
|
BooleanItem(
|
||||||
modifier = Modifier.clickable { prefs.dynamicColor = !prefs.dynamicColor },
|
value = prefs.dynamicColor,
|
||||||
headlineContent = { Text(stringResource(R.string.dynamic_color)) },
|
onValueChange = { prefs.dynamicColor = it },
|
||||||
supportingContent = { Text(stringResource(R.string.dynamic_color_description)) },
|
headline = R.string.dynamic_color,
|
||||||
trailingContent = {
|
description = R.string.dynamic_color_description
|
||||||
Switch(
|
|
||||||
checked = prefs.dynamicColor,
|
|
||||||
onCheckedChange = { prefs.dynamicColor = it })
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GroupHeader(stringResource(R.string.patcher))
|
||||||
|
BooleanItem(
|
||||||
|
value = prefs.allowExperimental,
|
||||||
|
onValueChange = { prefs.allowExperimental = it },
|
||||||
|
headline = R.string.experimental_patches,
|
||||||
|
description = R.string.experimental_patches_description
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ThemePicker(
|
private fun ThemePicker(
|
||||||
onDismiss: () -> Unit,
|
onDismiss: () -> Unit,
|
||||||
onConfirm: (Theme) -> Unit,
|
onConfirm: (Theme) -> Unit,
|
||||||
prefs: PreferencesManager = koinInject()
|
prefs: PreferencesManager = koinInject()
|
||||||
@ -96,10 +100,14 @@ fun ThemePicker(
|
|||||||
Column {
|
Column {
|
||||||
Theme.values().forEach {
|
Theme.values().forEach {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.fillMaxWidth().clickable { selectedTheme = it },
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.clickable { selectedTheme = it },
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
RadioButton(selected = selectedTheme == it, onClick = { selectedTheme = it })
|
RadioButton(
|
||||||
|
selected = selectedTheme == it,
|
||||||
|
onClick = { selectedTheme = it })
|
||||||
Text(stringResource(it.displayName))
|
Text(stringResource(it.displayName))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -114,4 +122,22 @@ fun ThemePicker(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun BooleanItem(
|
||||||
|
value: Boolean,
|
||||||
|
onValueChange: (Boolean) -> Unit,
|
||||||
|
@StringRes headline: Int,
|
||||||
|
@StringRes description: Int
|
||||||
|
) = ListItem(
|
||||||
|
modifier = Modifier.clickable { onValueChange(!value) },
|
||||||
|
headlineContent = { Text(stringResource(headline)) },
|
||||||
|
supportingContent = { Text(stringResource(description)) },
|
||||||
|
trailingContent = {
|
||||||
|
Switch(
|
||||||
|
checked = value,
|
||||||
|
onCheckedChange = onValueChange,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
@ -8,10 +8,10 @@ import androidx.compose.runtime.mutableStateOf
|
|||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import app.revanced.manager.domain.manager.PreferencesManager
|
||||||
import app.revanced.manager.domain.repository.PatchSelectionRepository
|
import app.revanced.manager.domain.repository.PatchSelectionRepository
|
||||||
import app.revanced.manager.domain.repository.SourceRepository
|
import app.revanced.manager.domain.repository.SourceRepository
|
||||||
import app.revanced.manager.patcher.patch.PatchInfo
|
import app.revanced.manager.patcher.patch.PatchInfo
|
||||||
import app.revanced.manager.ui.screen.allowUnsupported
|
|
||||||
import app.revanced.manager.util.AppInfo
|
import app.revanced.manager.util.AppInfo
|
||||||
import app.revanced.manager.util.PatchesSelection
|
import app.revanced.manager.util.PatchesSelection
|
||||||
import app.revanced.manager.util.SnapshotStateSet
|
import app.revanced.manager.util.SnapshotStateSet
|
||||||
@ -31,6 +31,8 @@ class PatchesSelectorViewModel(
|
|||||||
val appInfo: AppInfo
|
val appInfo: AppInfo
|
||||||
) : ViewModel(), KoinComponent {
|
) : ViewModel(), KoinComponent {
|
||||||
private val selectionRepository: PatchSelectionRepository = get()
|
private val selectionRepository: PatchSelectionRepository = get()
|
||||||
|
private val prefs: PreferencesManager = get()
|
||||||
|
val allowExperimental get() = prefs.allowExperimental
|
||||||
|
|
||||||
val bundlesFlow = get<SourceRepository>().sources.flatMapLatestAndCombine(
|
val bundlesFlow = get<SourceRepository>().sources.flatMapLatestAndCombine(
|
||||||
combiner = { it }
|
combiner = { it }
|
||||||
@ -82,7 +84,7 @@ class PatchesSelectorViewModel(
|
|||||||
selectedPatches.also {
|
selectedPatches.also {
|
||||||
selectionRepository.updateSelection(appInfo.packageName, it)
|
selectionRepository.updateSelection(appInfo.packageName, it)
|
||||||
}.mapValues { it.value.toMutableList() }.apply {
|
}.mapValues { it.value.toMutableList() }.apply {
|
||||||
if (allowUnsupported) {
|
if (allowExperimental) {
|
||||||
return@apply
|
return@apply
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
<string name="dynamic_color_description">Adapt colors to the wallpaper</string>
|
<string name="dynamic_color_description">Adapt colors to the wallpaper</string>
|
||||||
<string name="theme">Theme</string>
|
<string name="theme">Theme</string>
|
||||||
<string name="theme_description">Choose between light or dark theme</string>
|
<string name="theme_description">Choose between light or dark theme</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>
|
<string name="import_keystore">Import keystore</string>
|
||||||
<string name="import_keystore_descripion">Import a custom keystore</string>
|
<string name="import_keystore_descripion">Import a custom keystore</string>
|
||||||
<string name="import_keystore_preset_default">Default</string>
|
<string name="import_keystore_preset_default">Default</string>
|
||||||
@ -65,6 +67,7 @@
|
|||||||
<string name="light">Light</string>
|
<string name="light">Light</string>
|
||||||
<string name="dark">Dark</string>
|
<string name="dark">Dark</string>
|
||||||
<string name="appearance">Appearance</string>
|
<string name="appearance">Appearance</string>
|
||||||
|
<string name="patching">Patching</string>
|
||||||
<string name="signing">Signing</string>
|
<string name="signing">Signing</string>
|
||||||
<string name="storage">Storage</string>
|
<string name="storage">Storage</string>
|
||||||
<string name="tab_apps">Apps</string>
|
<string name="tab_apps">Apps</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user