mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-05-11 18:34:25 +02:00
fix: cleanup advanced settings screen
This commit is contained in:
parent
7c7fb7b343
commit
e6e043f168
@ -18,6 +18,7 @@ val viewModelModule = module {
|
|||||||
viewModelOf(::ChangelogsViewModel)
|
viewModelOf(::ChangelogsViewModel)
|
||||||
viewModelOf(::ImportExportViewModel)
|
viewModelOf(::ImportExportViewModel)
|
||||||
viewModelOf(::AboutViewModel)
|
viewModelOf(::AboutViewModel)
|
||||||
|
viewModelOf(::DeveloperOptionsViewModel)
|
||||||
viewModelOf(::ContributorViewModel)
|
viewModelOf(::ContributorViewModel)
|
||||||
viewModelOf(::DownloadsViewModel)
|
viewModelOf(::DownloadsViewModel)
|
||||||
viewModelOf(::InstalledAppsViewModel)
|
viewModelOf(::InstalledAppsViewModel)
|
||||||
|
@ -6,35 +6,38 @@ import kotlinx.parcelize.Parcelize
|
|||||||
sealed interface SettingsDestination : Parcelable {
|
sealed interface SettingsDestination : Parcelable {
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
object Settings : SettingsDestination
|
data object Settings : SettingsDestination
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
object General : SettingsDestination
|
data object General : SettingsDestination
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
object Advanced : SettingsDestination
|
data object Advanced : SettingsDestination
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
object Updates : SettingsDestination
|
data object Updates : SettingsDestination
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
object Downloads : SettingsDestination
|
data object Downloads : SettingsDestination
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
object ImportExport : SettingsDestination
|
data object ImportExport : SettingsDestination
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
object About : SettingsDestination
|
data object About : SettingsDestination
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
data class Update(val downloadOnScreenEntry: Boolean = false) : SettingsDestination
|
data class Update(val downloadOnScreenEntry: Boolean = false) : SettingsDestination
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
object Changelogs : SettingsDestination
|
data object Changelogs : SettingsDestination
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
object Contributors: SettingsDestination
|
data object Contributors: SettingsDestination
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
object Licenses: SettingsDestination
|
data object Licenses: SettingsDestination
|
||||||
|
|
||||||
|
@Parcelize
|
||||||
|
data object DeveloperOptions: SettingsDestination
|
||||||
}
|
}
|
@ -122,7 +122,8 @@ fun SettingsScreen(
|
|||||||
is SettingsDestination.About -> AboutSettingsScreen(
|
is SettingsDestination.About -> AboutSettingsScreen(
|
||||||
onBackClick = backClick,
|
onBackClick = backClick,
|
||||||
onContributorsClick = { navController.navigate(SettingsDestination.Contributors) },
|
onContributorsClick = { navController.navigate(SettingsDestination.Contributors) },
|
||||||
onLicensesClick = { navController.navigate(SettingsDestination.Licenses) }
|
onDeveloperOptionsClick = { navController.navigate(SettingsDestination.DeveloperOptions) },
|
||||||
|
onLicensesClick = { navController.navigate(SettingsDestination.Licenses) },
|
||||||
)
|
)
|
||||||
|
|
||||||
is SettingsDestination.Update -> UpdateScreen(
|
is SettingsDestination.Update -> UpdateScreen(
|
||||||
@ -146,6 +147,8 @@ fun SettingsScreen(
|
|||||||
onBackClick = backClick,
|
onBackClick = backClick,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
is SettingsDestination.DeveloperOptions -> DeveloperOptionsScreen(onBackClick = backClick)
|
||||||
|
|
||||||
is SettingsDestination.Settings -> {
|
is SettingsDestination.Settings -> {
|
||||||
Scaffold(
|
Scaffold(
|
||||||
topBar = {
|
topBar = {
|
||||||
|
@ -39,7 +39,6 @@ import app.revanced.manager.ui.component.ColumnWithScrollbar
|
|||||||
import app.revanced.manager.ui.component.settings.SettingsListItem
|
import app.revanced.manager.ui.component.settings.SettingsListItem
|
||||||
import app.revanced.manager.ui.viewmodel.AboutViewModel
|
import app.revanced.manager.ui.viewmodel.AboutViewModel
|
||||||
import app.revanced.manager.ui.viewmodel.AboutViewModel.Companion.getSocialIcon
|
import app.revanced.manager.ui.viewmodel.AboutViewModel.Companion.getSocialIcon
|
||||||
import app.revanced.manager.util.isDebuggable
|
|
||||||
import app.revanced.manager.util.openUrl
|
import app.revanced.manager.util.openUrl
|
||||||
import com.google.accompanist.drawablepainter.rememberDrawablePainter
|
import com.google.accompanist.drawablepainter.rememberDrawablePainter
|
||||||
import org.koin.androidx.compose.koinViewModel
|
import org.koin.androidx.compose.koinViewModel
|
||||||
@ -50,6 +49,7 @@ fun AboutSettingsScreen(
|
|||||||
onBackClick: () -> Unit,
|
onBackClick: () -> Unit,
|
||||||
onContributorsClick: () -> Unit,
|
onContributorsClick: () -> Unit,
|
||||||
onLicensesClick: () -> Unit,
|
onLicensesClick: () -> Unit,
|
||||||
|
onDeveloperOptionsClick: () -> Unit,
|
||||||
viewModel: AboutViewModel = koinViewModel()
|
viewModel: AboutViewModel = koinViewModel()
|
||||||
) {
|
) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
@ -116,9 +116,11 @@ fun AboutSettingsScreen(
|
|||||||
stringResource(R.string.contributors_description),
|
stringResource(R.string.contributors_description),
|
||||||
third = onContributorsClick
|
third = onContributorsClick
|
||||||
),
|
),
|
||||||
Triple(stringResource(R.string.developer_options),
|
Triple(
|
||||||
|
stringResource(R.string.developer_options),
|
||||||
stringResource(R.string.developer_options_description),
|
stringResource(R.string.developer_options_description),
|
||||||
third = { /*TODO*/ }).takeIf { context.isDebuggable },
|
third = onDeveloperOptionsClick
|
||||||
|
),
|
||||||
Triple(
|
Triple(
|
||||||
stringResource(R.string.opensource_licenses),
|
stringResource(R.string.opensource_licenses),
|
||||||
stringResource(R.string.opensource_licenses_description),
|
stringResource(R.string.opensource_licenses_description),
|
||||||
|
@ -71,6 +71,8 @@ fun AdvancedSettingsScreen(
|
|||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.padding(paddingValues)
|
.padding(paddingValues)
|
||||||
) {
|
) {
|
||||||
|
GroupHeader(stringResource(R.string.manager))
|
||||||
|
|
||||||
val apiUrl by vm.prefs.api.getAsState()
|
val apiUrl by vm.prefs.api.getAsState()
|
||||||
var showApiUrlDialog by rememberSaveable { mutableStateOf(false) }
|
var showApiUrlDialog by rememberSaveable { mutableStateOf(false) }
|
||||||
|
|
||||||
@ -110,6 +112,14 @@ fun AdvancedSettingsScreen(
|
|||||||
headline = R.string.process_runtime_memory_limit,
|
headline = R.string.process_runtime_memory_limit,
|
||||||
description = R.string.process_runtime_memory_limit_description,
|
description = R.string.process_runtime_memory_limit_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.safeguards))
|
||||||
BooleanItem(
|
BooleanItem(
|
||||||
preference = vm.prefs.disablePatchVersionCompatCheck,
|
preference = vm.prefs.disablePatchVersionCompatCheck,
|
||||||
coroutineScope = vm.viewModelScope,
|
coroutineScope = vm.viewModelScope,
|
||||||
@ -122,26 +132,6 @@ fun AdvancedSettingsScreen(
|
|||||||
headline = R.string.suggested_version_safeguard,
|
headline = R.string.suggested_version_safeguard,
|
||||||
description = R.string.suggested_version_safeguard_description
|
description = R.string.suggested_version_safeguard_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(
|
|
||||||
headlineContent = stringResource(R.string.patch_bundles_redownload),
|
|
||||||
modifier = Modifier.clickable {
|
|
||||||
vm.redownloadBundles()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
SettingsListItem(
|
|
||||||
headlineContent = stringResource(R.string.patch_bundles_reset),
|
|
||||||
modifier = Modifier.clickable {
|
|
||||||
vm.resetBundles()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
GroupHeader(stringResource(R.string.device))
|
GroupHeader(stringResource(R.string.device))
|
||||||
SettingsListItem(
|
SettingsListItem(
|
||||||
|
@ -0,0 +1,44 @@
|
|||||||
|
package app.revanced.manager.ui.screen.settings
|
||||||
|
|
||||||
|
import androidx.compose.foundation.clickable
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
|
import androidx.compose.material3.Scaffold
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import app.revanced.manager.R
|
||||||
|
import app.revanced.manager.ui.component.AppTopBar
|
||||||
|
import app.revanced.manager.ui.component.GroupHeader
|
||||||
|
import app.revanced.manager.ui.component.settings.SettingsListItem
|
||||||
|
import app.revanced.manager.ui.viewmodel.DeveloperOptionsViewModel
|
||||||
|
import org.koin.androidx.compose.koinViewModel
|
||||||
|
|
||||||
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
|
@Composable
|
||||||
|
fun DeveloperOptionsScreen(
|
||||||
|
onBackClick: () -> Unit,
|
||||||
|
vm: DeveloperOptionsViewModel = koinViewModel()
|
||||||
|
) {
|
||||||
|
Scaffold(
|
||||||
|
topBar = {
|
||||||
|
AppTopBar(
|
||||||
|
title = stringResource(R.string.developer_options),
|
||||||
|
onBackClick = onBackClick
|
||||||
|
)
|
||||||
|
}
|
||||||
|
) { paddingValues ->
|
||||||
|
Column(modifier = Modifier.padding(paddingValues)) {
|
||||||
|
GroupHeader(stringResource(R.string.patch_bundles_section))
|
||||||
|
SettingsListItem(
|
||||||
|
headlineContent = stringResource(R.string.patch_bundles_redownload),
|
||||||
|
modifier = Modifier.clickable(onClick = vm::redownloadBundles)
|
||||||
|
)
|
||||||
|
SettingsListItem(
|
||||||
|
headlineContent = stringResource(R.string.patch_bundles_reset),
|
||||||
|
modifier = Modifier.clickable(onClick = vm::redownloadBundles)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6,12 +6,10 @@ import android.util.Log
|
|||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import app.revanced.manager.R
|
import app.revanced.manager.R
|
||||||
import app.revanced.manager.domain.bundles.RemotePatchBundle
|
|
||||||
import app.revanced.manager.domain.manager.PreferencesManager
|
import app.revanced.manager.domain.manager.PreferencesManager
|
||||||
import app.revanced.manager.domain.repository.PatchBundleRepository
|
import app.revanced.manager.domain.repository.PatchBundleRepository
|
||||||
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 com.github.pgreze.process.Redirect
|
import com.github.pgreze.process.Redirect
|
||||||
import com.github.pgreze.process.process
|
import com.github.pgreze.process.process
|
||||||
import kotlinx.coroutines.CancellationException
|
import kotlinx.coroutines.CancellationException
|
||||||
@ -43,16 +41,6 @@ class AdvancedSettingsViewModel(
|
|||||||
patchBundleRepository.reloadApiBundles()
|
patchBundleRepository.reloadApiBundles()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun redownloadBundles() = viewModelScope.launch {
|
|
||||||
uiSafe(app, R.string.source_download_fail, RemotePatchBundle.updateFailMsg) {
|
|
||||||
patchBundleRepository.redownloadRemoteBundles()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun resetBundles() = viewModelScope.launch {
|
|
||||||
patchBundleRepository.reset()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun exportDebugLogs(target: Uri) = viewModelScope.launch {
|
fun exportDebugLogs(target: Uri) = viewModelScope.launch {
|
||||||
val exitCode = try {
|
val exitCode = try {
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
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.bundles.RemotePatchBundle
|
||||||
|
import app.revanced.manager.domain.manager.PreferencesManager
|
||||||
|
import app.revanced.manager.domain.repository.PatchBundleRepository
|
||||||
|
import app.revanced.manager.util.uiSafe
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
|
class DeveloperOptionsViewModel(
|
||||||
|
val prefs: PreferencesManager,
|
||||||
|
private val app: Application,
|
||||||
|
private val patchBundleRepository: PatchBundleRepository
|
||||||
|
) : ViewModel() {
|
||||||
|
fun redownloadBundles() = viewModelScope.launch {
|
||||||
|
uiSafe(app, R.string.source_download_fail, RemotePatchBundle.updateFailMsg) {
|
||||||
|
patchBundleRepository.redownloadRemoteBundles()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun resetBundles() = viewModelScope.launch {
|
||||||
|
patchBundleRepository.reset()
|
||||||
|
}
|
||||||
|
}
|
@ -71,6 +71,7 @@
|
|||||||
<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="safeguards">Safeguards</string>
|
||||||
<string name="patch_compat_check">Disable version compatibility check</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="patch_compat_check_description">The check restricts patches to supported app versions</string>
|
||||||
<string name="suggested_version_safeguard">Require suggested app version</string>
|
<string name="suggested_version_safeguard">Require suggested app version</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user