mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-04-30 05:54:26 +02:00
Remove unnecessary changes and deprecated code
This commit is contained in:
parent
bbfd625ac1
commit
f4a2b06276
@ -47,6 +47,7 @@ android {
|
||||
|
||||
isPseudoLocalesEnabled = true
|
||||
}
|
||||
|
||||
buildConfigField("long", "BUILD_ID", "0L")
|
||||
}
|
||||
}
|
||||
|
@ -44,11 +44,11 @@ import app.revanced.manager.ui.screen.SettingsScreen
|
||||
import app.revanced.manager.ui.screen.UpdateScreen
|
||||
import app.revanced.manager.ui.screen.settings.AboutSettingsScreen
|
||||
import app.revanced.manager.ui.screen.settings.AdvancedSettingsScreen
|
||||
import app.revanced.manager.ui.screen.settings.BackupRestoreSettingsScreen
|
||||
import app.revanced.manager.ui.screen.settings.ContributorScreen
|
||||
import app.revanced.manager.ui.screen.settings.DeveloperOptionsScreen
|
||||
import app.revanced.manager.ui.screen.settings.DownloadsSettingsScreen
|
||||
import app.revanced.manager.ui.screen.settings.GeneralSettingsScreen
|
||||
import app.revanced.manager.ui.screen.settings.BackupRestoreSettingsScreen
|
||||
import app.revanced.manager.ui.screen.settings.LicensesScreen
|
||||
import app.revanced.manager.ui.screen.settings.update.ChangelogsScreen
|
||||
import app.revanced.manager.ui.theme.ReVancedManagerTheme
|
||||
@ -279,7 +279,6 @@ private fun ReVancedManager(vm: MainViewModel) {
|
||||
AdvancedSettingsScreen(onBackClick = navController::popBackStack)
|
||||
}
|
||||
|
||||
|
||||
composable<Settings.Downloads> {
|
||||
DownloadsSettingsScreen(onBackClick = navController::popBackStack)
|
||||
}
|
||||
|
@ -22,9 +22,10 @@ class PreferencesManager(
|
||||
val managerAutoUpdates = booleanPreference("manager_auto_updates", false)
|
||||
val showManagerUpdateDialogOnLaunch = booleanPreference("show_manager_update_dialog_on_launch", true)
|
||||
|
||||
val allowIncompatibleMixing = booleanPreference("allow_incompatible_mixing", false)
|
||||
val allowChangingPatchSelection = booleanPreference("allow_changing_patch_selection", false)
|
||||
val allowUniversalPatch = booleanPreference("allow_universal_patch", false)
|
||||
val disablePatchVersionCompatCheck = booleanPreference("disable_patch_version_compatibility_check", false)
|
||||
val disableSelectionWarning = booleanPreference("disable_selection_warning", false)
|
||||
val disableUniversalPatchWarning = booleanPreference("disable_universal_patch_warning", false)
|
||||
val suggestedVersionSafeguard = booleanPreference("suggested_version_safeguard", true)
|
||||
|
||||
val acknowledgedDownloaderPlugins = stringSetPreference("acknowledged_downloader_plugins", emptySet())
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ class PatchBundleRepository(
|
||||
|
||||
suspend fun isVersionAllowed(packageName: String, version: String) =
|
||||
withContext(Dispatchers.Default) {
|
||||
if (!prefs.allowIncompatibleMixing.get()) return@withContext true
|
||||
if (!prefs.suggestedVersionSafeguard.get()) return@withContext true
|
||||
|
||||
val suggestedVersion = suggestedVersions.first()[packageName] ?: return@withContext true
|
||||
suggestedVersion == version
|
||||
|
@ -70,9 +70,6 @@ object Settings {
|
||||
@Serializable
|
||||
data object Advanced : Destination
|
||||
|
||||
@Serializable
|
||||
data object Updates : Destination
|
||||
|
||||
@Serializable
|
||||
data object Downloads : Destination
|
||||
|
||||
|
@ -66,7 +66,7 @@ fun SelectedAppInfoScreen(
|
||||
val version = vm.selectedApp.version
|
||||
val bundles by vm.bundleInfoFlow.collectAsStateWithLifecycle(emptyList())
|
||||
|
||||
val allowIncompatiblePatches by vm.prefs.allowIncompatibleMixing.getAsState()
|
||||
val allowIncompatiblePatches by vm.prefs.disablePatchVersionCompatCheck.getAsState()
|
||||
val patches = remember(bundles, allowIncompatiblePatches) {
|
||||
vm.getPatches(bundles, allowIncompatiblePatches)
|
||||
}
|
||||
|
@ -4,8 +4,14 @@ import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.*
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.material.icons.outlined.Download
|
||||
import androidx.compose.material.icons.outlined.Info
|
||||
import androidx.compose.material.icons.outlined.Settings
|
||||
import androidx.compose.material.icons.outlined.SwapVert
|
||||
import androidx.compose.material.icons.outlined.Tune
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
|
@ -53,7 +53,7 @@ fun AboutSettingsScreen(
|
||||
onBackClick: () -> Unit,
|
||||
onChangelogClick: () -> Unit,
|
||||
navigate: (Settings.Destination) -> Unit,
|
||||
vm: AboutViewModel = koinViewModel()
|
||||
viewModel: AboutViewModel = koinViewModel()
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
// painterResource() is broken on release builds for some reason.
|
||||
@ -61,11 +61,11 @@ fun AboutSettingsScreen(
|
||||
AppCompatResources.getDrawable(context, R.drawable.ic_logo_ring)
|
||||
})
|
||||
|
||||
val (preferredSocials, socials) = remember(vm.socials) {
|
||||
vm.socials.partition(ReVancedSocial::preferred)
|
||||
val (preferredSocials, socials) = remember(viewModel.socials) {
|
||||
viewModel.socials.partition(ReVancedSocial::preferred)
|
||||
}
|
||||
|
||||
val preferredSocialButtons = remember(preferredSocials, vm.donate, vm.contact) {
|
||||
val preferredSocialButtons = remember(preferredSocials, viewModel.donate, viewModel.contact) {
|
||||
preferredSocials.map {
|
||||
Triple(
|
||||
getSocialIcon(it.name),
|
||||
@ -75,7 +75,7 @@ fun AboutSettingsScreen(
|
||||
}
|
||||
)
|
||||
} + listOfNotNull(
|
||||
vm.donate?.let {
|
||||
viewModel.donate?.let {
|
||||
Triple(
|
||||
Icons.Outlined.FavoriteBorder,
|
||||
context.getString(R.string.donate),
|
||||
@ -84,7 +84,7 @@ fun AboutSettingsScreen(
|
||||
}
|
||||
)
|
||||
},
|
||||
vm.contact?.let {
|
||||
viewModel.contact?.let {
|
||||
Triple(
|
||||
Icons.Outlined.MailOutline,
|
||||
context.getString(R.string.contact),
|
||||
@ -114,13 +114,11 @@ fun AboutSettingsScreen(
|
||||
stringResource(R.string.changelog_description),
|
||||
third = { onChangelogClick }
|
||||
),
|
||||
Triple(
|
||||
stringResource(R.string.submit_feedback),
|
||||
Triple(stringResource(R.string.submit_feedback),
|
||||
stringResource(R.string.submit_feedback_description),
|
||||
third = {
|
||||
context.openUrl("https://github.com/ReVanced/revanced-manager/issues/new/choose")
|
||||
},
|
||||
),
|
||||
}),
|
||||
Triple(
|
||||
stringResource(R.string.contributors),
|
||||
stringResource(R.string.contributors_description),
|
||||
|
@ -90,37 +90,45 @@ fun AdvancedSettingsScreen(
|
||||
.fillMaxSize()
|
||||
.padding(paddingValues)
|
||||
) {
|
||||
val apiSource by vm.prefs.api.getAsState()
|
||||
var showApiSourceDialog by rememberSaveable { mutableStateOf(false) }
|
||||
GroupHeader(stringResource(R.string.manager))
|
||||
|
||||
if (showApiSourceDialog) {
|
||||
APISourceDialog(
|
||||
currentUrl = apiSource,
|
||||
val apiUrl by vm.prefs.api.getAsState()
|
||||
var showApiUrlDialog by rememberSaveable { mutableStateOf(false) }
|
||||
|
||||
if (showApiUrlDialog) {
|
||||
APIUrlDialog(
|
||||
currentUrl = apiUrl,
|
||||
defaultUrl = vm.prefs.api.default,
|
||||
onSubmit = {
|
||||
showApiSourceDialog = false
|
||||
showApiUrlDialog = false
|
||||
it?.let(vm::setApiSource)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
GroupHeader(stringResource(R.string.revanced_patcher))
|
||||
GroupHeader(stringResource(R.string.patcher))
|
||||
BooleanItem(
|
||||
preference = vm.prefs.useProcessRuntime,
|
||||
coroutineScope = vm.viewModelScope,
|
||||
headline = R.string.process_runtime,
|
||||
description = R.string.process_runtime_description,
|
||||
)
|
||||
IntegerItem(
|
||||
preference = vm.prefs.patcherProcessMemoryLimit,
|
||||
coroutineScope = vm.viewModelScope,
|
||||
headline = R.string.process_runtime_memory_limit,
|
||||
description = vm.prefs.patcherProcessMemoryLimit.getAsState().value,
|
||||
description = R.string.process_runtime_memory_limit_description,
|
||||
)
|
||||
|
||||
GroupHeader(stringResource(R.string.manager))
|
||||
SettingsListItem(
|
||||
headlineContent = stringResource(R.string.api_source),
|
||||
supportingContent = apiSource,
|
||||
supportingContent = apiUrl,
|
||||
modifier = Modifier.clickable {
|
||||
showApiSourceDialog = true
|
||||
showApiUrlDialog = true
|
||||
},
|
||||
trailingContent = {
|
||||
IconButton(onClick = { showApiSourceDialog = true }) {
|
||||
IconButton(onClick = { showApiUrlDialog = true }) {
|
||||
Icon(
|
||||
Icons.Outlined.Edit,
|
||||
contentDescription = stringResource(R.string.edit)
|
||||
@ -129,21 +137,21 @@ fun AdvancedSettingsScreen(
|
||||
}
|
||||
)
|
||||
SafeguardBooleanItem(
|
||||
preference = vm.prefs.allowIncompatibleMixing,
|
||||
preference = vm.prefs.disablePatchVersionCompatCheck,
|
||||
coroutineScope = vm.viewModelScope,
|
||||
headline = R.string.allow_compatibility_mixing,
|
||||
description = R.string.allow_compatibility_mixing_description,
|
||||
confirmationText = R.string.allow_compatibility_mixing_confirmation
|
||||
)
|
||||
SafeguardBooleanItem(
|
||||
preference = vm.prefs.allowUniversalPatch,
|
||||
preference = vm.prefs.disableUniversalPatchWarning,
|
||||
coroutineScope = vm.viewModelScope,
|
||||
headline = R.string.universal_patches_safeguard,
|
||||
description = R.string.universal_patches_safeguard_description,
|
||||
confirmationText = R.string.universal_patches_safeguard_confirmation
|
||||
)
|
||||
SafeguardBooleanItem(
|
||||
preference = vm.prefs.allowChangingPatchSelection,
|
||||
preference = vm.prefs.disableSelectionWarning,
|
||||
coroutineScope = vm.viewModelScope,
|
||||
headline = R.string.patch_selection_safeguard,
|
||||
description = R.string.patch_selection_safeguard_description,
|
||||
@ -152,7 +160,7 @@ fun AdvancedSettingsScreen(
|
||||
|
||||
GroupHeader(stringResource(R.string.update))
|
||||
BooleanItem(
|
||||
preference = vm.showManagerUpdateDialogOnLaunch,
|
||||
preference = vm.prefs.showManagerUpdateDialogOnLaunch,
|
||||
headline = R.string.show_manager_update_dialog_on_launch,
|
||||
description = R.string.check_for_update_auto_description
|
||||
)
|
||||
@ -176,10 +184,11 @@ fun AdvancedSettingsScreen(
|
||||
)
|
||||
val clipboard = remember { context.getSystemService<ClipboardManager>()!! }
|
||||
val deviceContent = """
|
||||
Version: ${BuildConfig.VERSION_NAME}, ${BuildConfig.BUILD_TYPE} (${BuildConfig.VERSION_CODE})
|
||||
Version: ${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})
|
||||
Build type: ${BuildConfig.BUILD_TYPE}
|
||||
Model: ${Build.MODEL}
|
||||
Android version: ${Build.VERSION.RELEASE} (${Build.VERSION.SDK_INT})
|
||||
Preferred Architectures: ${Build.SUPPORTED_ABIS.joinToString(", ")}
|
||||
Supported Archs: ${Build.SUPPORTED_ABIS.joinToString(", ")}
|
||||
Memory limit: $memoryLimit
|
||||
""".trimIndent()
|
||||
SettingsListItem(
|
||||
@ -202,15 +211,15 @@ fun AdvancedSettingsScreen(
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun APISourceDialog(currentUrl: String, defaultUrl: String, onSubmit: (String?) -> Unit) {
|
||||
var source by rememberSaveable(currentUrl) { mutableStateOf(currentUrl) }
|
||||
private fun APIUrlDialog(currentUrl: String, defaultUrl: String, onSubmit: (String?) -> Unit) {
|
||||
var url by rememberSaveable(currentUrl) { mutableStateOf(currentUrl) }
|
||||
|
||||
AlertDialog(
|
||||
onDismissRequest = { onSubmit(null) },
|
||||
confirmButton = {
|
||||
TextButton(
|
||||
onClick = {
|
||||
onSubmit(source)
|
||||
onSubmit(url)
|
||||
}
|
||||
) {
|
||||
Text(stringResource(R.string.api_source_dialog_save))
|
||||
@ -247,11 +256,11 @@ private fun APISourceDialog(currentUrl: String, defaultUrl: String, onSubmit: (S
|
||||
)
|
||||
OutlinedTextField(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
value = source,
|
||||
onValueChange = { source = it },
|
||||
value = url,
|
||||
onValueChange = { url = it },
|
||||
label = { Text(stringResource(R.string.api_source)) },
|
||||
trailingIcon = {
|
||||
IconButton(onClick = { source = defaultUrl }) {
|
||||
IconButton(onClick = { url = defaultUrl }) {
|
||||
Icon(Icons.Outlined.Restore, stringResource(R.string.api_source_dialog_reset))
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,6 @@ import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
@ -57,50 +56,50 @@ import org.koin.androidx.compose.koinViewModel
|
||||
@Composable
|
||||
fun BackupRestoreSettingsScreen(
|
||||
onBackClick: () -> Unit,
|
||||
vm: ImportExportViewModel = koinViewModel()
|
||||
viewModel: ImportExportViewModel = koinViewModel()
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
|
||||
val importKeystoreLauncher =
|
||||
rememberLauncherForActivityResult(contract = ActivityResultContracts.GetContent()) {
|
||||
it?.let { uri -> vm.startKeystoreImport(uri) }
|
||||
it?.let { uri -> viewModel.startKeystoreImport(uri) }
|
||||
}
|
||||
val exportKeystoreLauncher =
|
||||
rememberLauncherForActivityResult(ActivityResultContracts.CreateDocument("*/*")) {
|
||||
it?.let(vm::exportKeystore)
|
||||
it?.let(viewModel::exportKeystore)
|
||||
}
|
||||
|
||||
val patchBundles by vm.patchBundles.collectAsStateWithLifecycle(initialValue = emptyList())
|
||||
val packagesWithOptions by vm.packagesWithOptions.collectAsStateWithLifecycle(initialValue = emptySet())
|
||||
val patchBundles by viewModel.patchBundles.collectAsStateWithLifecycle(initialValue = emptyList())
|
||||
val packagesWithOptions by viewModel.packagesWithOptions.collectAsStateWithLifecycle(initialValue = emptySet())
|
||||
|
||||
vm.selectionAction?.let { action ->
|
||||
viewModel.selectionAction?.let { action ->
|
||||
val launcher = rememberLauncherForActivityResult(action.activityContract) { uri ->
|
||||
if (uri == null) {
|
||||
vm.clearSelectionAction()
|
||||
viewModel.clearSelectionAction()
|
||||
} else {
|
||||
vm.executeSelectionAction(uri)
|
||||
viewModel.executeSelectionAction(uri)
|
||||
}
|
||||
}
|
||||
|
||||
if (vm.selectedBundle == null) {
|
||||
if (viewModel.selectedBundle == null) {
|
||||
BundleSelector(patchBundles) {
|
||||
if (it == null) {
|
||||
vm.clearSelectionAction()
|
||||
viewModel.clearSelectionAction()
|
||||
} else {
|
||||
vm.selectBundle(it)
|
||||
viewModel.selectBundle(it)
|
||||
launcher.launch(action.activityArg)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (vm.showCredentialsDialog) {
|
||||
if (viewModel.showCredentialsDialog) {
|
||||
KeystoreCredentialsDialog(
|
||||
onDismissRequest = vm::cancelKeystoreImport,
|
||||
onDismissRequest = viewModel::cancelKeystoreImport,
|
||||
onSubmit = { cn, pass ->
|
||||
vm.viewModelScope.launch {
|
||||
viewModel.viewModelScope.launch {
|
||||
uiSafe(context, R.string.failed_to_import_keystore, "Failed to import keystore") {
|
||||
val result = vm.tryKeystoreImport(cn, pass)
|
||||
val result = viewModel.tryKeystoreImport(cn, pass)
|
||||
if (!result) context.toast(context.getString(R.string.restore_keystore_wrong_credentials))
|
||||
}
|
||||
}
|
||||
@ -134,7 +133,7 @@ fun BackupRestoreSettingsScreen(
|
||||
|
||||
if (showPackageSelector) {
|
||||
PackageSelector(packages = packagesWithOptions) { selected ->
|
||||
selected?.let(vm::resetOptionsForPackage)
|
||||
selected?.let(viewModel::resetOptionsForPackage)
|
||||
|
||||
showPackageSelector = false
|
||||
}
|
||||
@ -142,7 +141,7 @@ fun BackupRestoreSettingsScreen(
|
||||
|
||||
if (showBundleSelector) {
|
||||
BundleSelector(bundles = patchBundles) { bundle ->
|
||||
bundle?.let(vm::clearOptionsForBundle)
|
||||
bundle?.let(viewModel::clearOptionsForBundle)
|
||||
|
||||
showBundleSelector = false
|
||||
}
|
||||
@ -151,7 +150,7 @@ fun BackupRestoreSettingsScreen(
|
||||
GroupHeader(stringResource(R.string.keystore))
|
||||
GroupItem(
|
||||
onClick = {
|
||||
if (!vm.canExport()) {
|
||||
if (!viewModel.canExport()) {
|
||||
context.toast(context.getString(R.string.backup_keystore_unavailable))
|
||||
return@GroupItem
|
||||
}
|
||||
@ -168,7 +167,7 @@ fun BackupRestoreSettingsScreen(
|
||||
description = R.string.restore_keystore_description
|
||||
)
|
||||
GroupItem(
|
||||
onClick = vm::regenerateKeystore,
|
||||
onClick = viewModel::regenerateKeystore,
|
||||
headline = {
|
||||
Text(
|
||||
stringResource(R.string.regenerate_keystore),
|
||||
@ -180,17 +179,17 @@ fun BackupRestoreSettingsScreen(
|
||||
|
||||
GroupHeader(stringResource(R.string.patch_selection))
|
||||
GroupItem(
|
||||
onClick = vm::exportSelection,
|
||||
onClick = viewModel::exportSelection,
|
||||
headline = R.string.backup,
|
||||
description = R.string.restore_patch_selection_description
|
||||
)
|
||||
GroupItem(
|
||||
onClick = vm::importSelection,
|
||||
onClick = viewModel::importSelection,
|
||||
headline = R.string.restore,
|
||||
description = R.string.backup_patch_selection_description
|
||||
)
|
||||
GroupItem(
|
||||
onClick = vm::resetSelection, // TODO: allow resetting selection for specific bundle or package name.
|
||||
onClick = viewModel::resetSelection, // TODO: allow resetting selection for specific bundle or package name.
|
||||
headline = {
|
||||
Text(
|
||||
stringResource(R.string.reset),
|
||||
@ -203,7 +202,7 @@ fun BackupRestoreSettingsScreen(
|
||||
GroupHeader(stringResource(R.string.patch_options))
|
||||
// TODO: patch options import/export.
|
||||
GroupItem(
|
||||
onClick = vm::resetOptions,
|
||||
onClick = viewModel::resetOptions,
|
||||
headline = {
|
||||
Text(
|
||||
stringResource(R.string.reset),
|
||||
|
@ -53,9 +53,9 @@ import org.koin.androidx.compose.koinViewModel
|
||||
@Composable
|
||||
fun ContributorScreen(
|
||||
onBackClick: () -> Unit,
|
||||
vm: ContributorViewModel = koinViewModel()
|
||||
viewModel: ContributorViewModel = koinViewModel()
|
||||
) {
|
||||
val repositories = vm.repositories
|
||||
val repositories = viewModel.repositories
|
||||
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
|
||||
|
||||
Scaffold(
|
||||
|
@ -53,11 +53,11 @@ import java.security.MessageDigest
|
||||
@Composable
|
||||
fun DownloadsSettingsScreen(
|
||||
onBackClick: () -> Unit,
|
||||
vm: DownloadsViewModel = koinViewModel()
|
||||
viewModel: DownloadsViewModel = koinViewModel()
|
||||
) {
|
||||
val pullRefreshState = rememberPullToRefreshState()
|
||||
val downloadedApps by vm.downloadedApps.collectAsStateWithLifecycle(emptyList())
|
||||
val pluginStates by vm.downloaderPluginStates.collectAsStateWithLifecycle()
|
||||
val downloadedApps by viewModel.downloadedApps.collectAsStateWithLifecycle(emptyList())
|
||||
val pluginStates by viewModel.downloaderPluginStates.collectAsStateWithLifecycle()
|
||||
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
|
||||
|
||||
Scaffold(
|
||||
@ -67,8 +67,8 @@ fun DownloadsSettingsScreen(
|
||||
scrollBehavior = scrollBehavior,
|
||||
onBackClick = onBackClick,
|
||||
actions = {
|
||||
if (vm.appSelection.isNotEmpty()) {
|
||||
IconButton(onClick = { vm.deleteApps() }) {
|
||||
if (viewModel.appSelection.isNotEmpty()) {
|
||||
IconButton(onClick = { viewModel.deleteApps() }) {
|
||||
Icon(Icons.Default.Delete, stringResource(R.string.delete))
|
||||
}
|
||||
}
|
||||
@ -86,7 +86,7 @@ fun DownloadsSettingsScreen(
|
||||
) {
|
||||
PullToRefreshDefaults.Indicator(
|
||||
state = pullRefreshState,
|
||||
isRefreshing = vm.isRefreshingPlugins
|
||||
isRefreshing = viewModel.isRefreshingPlugins
|
||||
)
|
||||
}
|
||||
|
||||
@ -95,9 +95,9 @@ fun DownloadsSettingsScreen(
|
||||
.fillMaxSize()
|
||||
.padding(paddingValues)
|
||||
.pullToRefresh(
|
||||
isRefreshing = vm.isRefreshingPlugins,
|
||||
isRefreshing = viewModel.isRefreshingPlugins,
|
||||
state = pullRefreshState,
|
||||
onRefresh = vm::refreshPlugins
|
||||
onRefresh = viewModel::refreshPlugins
|
||||
)
|
||||
) {
|
||||
item {
|
||||
@ -115,7 +115,7 @@ fun DownloadsSettingsScreen(
|
||||
|
||||
val packageInfo =
|
||||
remember(packageName) {
|
||||
vm.pm.getPackageInfo(
|
||||
viewModel.pm.getPackageInfo(
|
||||
packageName
|
||||
)
|
||||
} ?: return@item
|
||||
@ -124,7 +124,7 @@ fun DownloadsSettingsScreen(
|
||||
val signature =
|
||||
remember(packageName) {
|
||||
val androidSignature =
|
||||
vm.pm.getSignature(packageName)
|
||||
viewModel.pm.getSignature(packageName)
|
||||
val hash = MessageDigest.getInstance("SHA-256")
|
||||
.digest(androidSignature.toByteArray())
|
||||
hash.toHexString(format = HexFormat.UpperCase)
|
||||
@ -140,7 +140,7 @@ fun DownloadsSettingsScreen(
|
||||
),
|
||||
onDismiss = ::dismiss,
|
||||
onConfirm = {
|
||||
vm.revokePluginTrust(packageName)
|
||||
viewModel.revokePluginTrust(packageName)
|
||||
dismiss()
|
||||
}
|
||||
)
|
||||
@ -161,7 +161,7 @@ fun DownloadsSettingsScreen(
|
||||
),
|
||||
onDismiss = ::dismiss,
|
||||
onConfirm = {
|
||||
vm.trustPlugin(packageName)
|
||||
viewModel.trustPlugin(packageName)
|
||||
dismiss()
|
||||
}
|
||||
)
|
||||
@ -201,17 +201,17 @@ fun DownloadsSettingsScreen(
|
||||
GroupHeader(stringResource(R.string.downloaded_apps))
|
||||
}
|
||||
items(downloadedApps, key = { it.packageName to it.version }) { app ->
|
||||
val selected = app in vm.appSelection
|
||||
val selected = app in viewModel.appSelection
|
||||
|
||||
SettingsListItem(
|
||||
modifier = Modifier.clickable { vm.toggleApp(app) },
|
||||
modifier = Modifier.clickable { viewModel.toggleApp(app) },
|
||||
headlineContent = app.packageName,
|
||||
leadingContent = (@Composable {
|
||||
HapticCheckbox(
|
||||
checked = selected,
|
||||
onCheckedChange = { vm.toggleApp(app) }
|
||||
onCheckedChange = { viewModel.toggleApp(app) }
|
||||
)
|
||||
}).takeIf { vm.appSelection.isNotEmpty() },
|
||||
}).takeIf { viewModel.appSelection.isNotEmpty() },
|
||||
supportingContent = app.version,
|
||||
tonalElevation = if (selected) 8.dp else 0.dp
|
||||
)
|
||||
|
@ -36,7 +36,6 @@ import app.revanced.manager.ui.component.settings.BooleanItem
|
||||
import app.revanced.manager.ui.component.settings.SettingsListItem
|
||||
import app.revanced.manager.ui.theme.Theme
|
||||
import app.revanced.manager.ui.viewmodel.GeneralSettingsViewModel
|
||||
import kotlinx.coroutines.launch
|
||||
import org.koin.androidx.compose.koinViewModel
|
||||
import org.koin.compose.koinInject
|
||||
|
||||
@ -44,17 +43,17 @@ import org.koin.compose.koinInject
|
||||
@Composable
|
||||
fun GeneralSettingsScreen(
|
||||
onBackClick: () -> Unit,
|
||||
vm: GeneralSettingsViewModel = koinViewModel(),
|
||||
onUpdateClick: () -> Unit,
|
||||
viewModel: GeneralSettingsViewModel = koinViewModel()
|
||||
) {
|
||||
val prefs = vm.prefs
|
||||
val coroutineScope = vm.viewModelScope
|
||||
val prefs = viewModel.prefs
|
||||
val coroutineScope = viewModel.viewModelScope
|
||||
var showThemePicker by rememberSaveable { mutableStateOf(false) }
|
||||
|
||||
if (showThemePicker) {
|
||||
ThemePicker(
|
||||
onDismiss = { showThemePicker = false },
|
||||
onConfirm = { vm.setTheme(it) }
|
||||
onConfirm = { viewModel.setTheme(it) }
|
||||
)
|
||||
}
|
||||
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
|
||||
@ -99,10 +98,11 @@ fun GeneralSettingsScreen(
|
||||
description = R.string.personalized_color_description
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
GroupHeader(stringResource(R.string.update))
|
||||
BooleanItem(
|
||||
preference = vm.managerAutoUpdates,
|
||||
preference = prefs.managerAutoUpdates,
|
||||
headline = R.string.check_for_update,
|
||||
description = R.string.check_for_update_auto_description
|
||||
)
|
||||
@ -114,7 +114,6 @@ fun GeneralSettingsScreen(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ThemePicker(
|
||||
|
@ -27,7 +27,6 @@ class AdvancedSettingsViewModel(
|
||||
private val app: Application,
|
||||
private val patchBundleRepository: PatchBundleRepository
|
||||
) : ViewModel() {
|
||||
val showManagerUpdateDialogOnLaunch = prefs.showManagerUpdateDialogOnLaunch
|
||||
val debugLogFileName: String
|
||||
get() {
|
||||
val time = DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(LocalDateTime.now())
|
||||
|
@ -26,8 +26,8 @@ class DeveloperOptionsViewModel(
|
||||
}
|
||||
|
||||
fun disableSafeguard() = viewModelScope.launch {
|
||||
prefs.allowIncompatibleMixing.update(true)
|
||||
prefs.allowChangingPatchSelection.update(true)
|
||||
prefs.allowUniversalPatch.update(true)
|
||||
prefs.disablePatchVersionCompatCheck.update(true)
|
||||
prefs.disableSelectionWarning.update(true)
|
||||
prefs.disableUniversalPatchWarning.update(true)
|
||||
}
|
||||
}
|
@ -1,38 +1,15 @@
|
||||
package app.revanced.manager.ui.viewmodel
|
||||
|
||||
import android.app.Application
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import app.revanced.manager.R
|
||||
import app.revanced.manager.domain.manager.PreferencesManager
|
||||
import app.revanced.manager.network.api.ReVancedAPI
|
||||
import app.revanced.manager.ui.theme.Theme
|
||||
import app.revanced.manager.util.toast
|
||||
import app.revanced.manager.util.uiSafe
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class GeneralSettingsViewModel(
|
||||
val prefs: PreferencesManager,
|
||||
private val app: Application,
|
||||
private val reVancedAPI: ReVancedAPI,
|
||||
val prefs: PreferencesManager
|
||||
) : ViewModel() {
|
||||
fun setTheme(theme: Theme) = viewModelScope.launch {
|
||||
prefs.theme.update(theme)
|
||||
}
|
||||
|
||||
val managerAutoUpdates = prefs.managerAutoUpdates
|
||||
val showManagerUpdateDialogOnLaunch = prefs.showManagerUpdateDialogOnLaunch
|
||||
|
||||
suspend fun checkForUpdates(): Boolean {
|
||||
uiSafe(app, R.string.failed_to_check_updates, "Failed to check for updates") {
|
||||
app.toast(app.getString(R.string.update_check))
|
||||
|
||||
if (reVancedAPI.getAppUpdate() == null)
|
||||
app.toast(app.getString(R.string.no_update_available))
|
||||
else
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
@ -124,7 +124,7 @@ class MainViewModel(
|
||||
prefs.api.update(api.removeSuffix("/"))
|
||||
}
|
||||
settings.experimentalPatchesEnabled?.let { allowExperimental ->
|
||||
prefs.allowIncompatibleMixing.update(allowExperimental)
|
||||
prefs.disablePatchVersionCompatCheck.update(allowExperimental)
|
||||
}
|
||||
settings.patchesAutoUpdate?.let { autoUpdate ->
|
||||
with(patchBundleRepository) {
|
||||
|
@ -58,13 +58,13 @@ class PatchesSelectorViewModel(input: SelectedApplicationInfo.PatchesSelector.Vi
|
||||
private set
|
||||
|
||||
val allowIncompatiblePatches =
|
||||
get<PreferencesManager>().allowIncompatibleMixing.getBlocking()
|
||||
get<PreferencesManager>().disablePatchVersionCompatCheck.getBlocking()
|
||||
val bundlesFlow =
|
||||
get<PatchBundleRepository>().bundleInfoFlow(packageName, input.app.version)
|
||||
|
||||
init {
|
||||
viewModelScope.launch {
|
||||
universalPatchWarningEnabled = !prefs.allowUniversalPatch.get()
|
||||
universalPatchWarningEnabled = !prefs.disableUniversalPatchWarning.get()
|
||||
|
||||
if (prefs.allowChangingPatchSelection.get()) {
|
||||
selectionWarningEnabled = false
|
||||
|
@ -30,6 +30,7 @@ import app.revanced.manager.domain.repository.PatchOptionsRepository
|
||||
import app.revanced.manager.domain.repository.PatchSelectionRepository
|
||||
import app.revanced.manager.network.downloader.LoadedDownloaderPlugin
|
||||
import app.revanced.manager.network.downloader.ParceledDownloaderData
|
||||
import app.revanced.manager.patcher.patch.PatchInfo
|
||||
import app.revanced.manager.plugin.downloader.GetScope
|
||||
import app.revanced.manager.plugin.downloader.PluginHostApi
|
||||
import app.revanced.manager.plugin.downloader.UserInteractionException
|
||||
@ -117,7 +118,7 @@ class SelectedAppInfoViewModel(
|
||||
}
|
||||
|
||||
val requiredVersion = combine(
|
||||
prefs.allowIncompatibleMixing.flow,
|
||||
prefs.suggestedVersionSafeguard.flow,
|
||||
bundleRepository.suggestedVersions
|
||||
) { suggestedVersionSafeguard, suggestedVersions ->
|
||||
if (!suggestedVersionSafeguard) return@combine null
|
||||
@ -274,7 +275,7 @@ class SelectedAppInfoViewModel(
|
||||
)
|
||||
|
||||
suspend fun getPatcherParams(): Patcher.ViewModelParams {
|
||||
val allowUnsupported = prefs.allowIncompatibleMixing.get()
|
||||
val allowUnsupported = prefs.disablePatchVersionCompatCheck.get()
|
||||
val bundles = bundleInfoFlow.first()
|
||||
return Patcher.ViewModelParams(
|
||||
selectedApp,
|
||||
|
Loading…
x
Reference in New Issue
Block a user