From 453f4da8ece5fbc0772eaf9aa988199e3d5fef87 Mon Sep 17 00:00:00 2001 From: Ax333l Date: Fri, 7 Jul 2023 17:35:36 +0200 Subject: [PATCH] feat: advanced settings page with device info (#51) --- .../ui/destination/SettingsDestination.kt | 3 + .../manager/ui/screen/SettingsScreen.kt | 9 +++ .../screen/settings/AdvancedSettingsScreen.kt | 65 +++++++++++++++++++ .../java/app/revanced/manager/util/Util.kt | 2 + app/src/main/res/values/strings.xml | 8 +++ 5 files changed, 87 insertions(+) create mode 100644 app/src/main/java/app/revanced/manager/ui/screen/settings/AdvancedSettingsScreen.kt diff --git a/app/src/main/java/app/revanced/manager/ui/destination/SettingsDestination.kt b/app/src/main/java/app/revanced/manager/ui/destination/SettingsDestination.kt index 707218339d..ffdf20bca2 100644 --- a/app/src/main/java/app/revanced/manager/ui/destination/SettingsDestination.kt +++ b/app/src/main/java/app/revanced/manager/ui/destination/SettingsDestination.kt @@ -11,6 +11,9 @@ sealed interface SettingsDestination : Parcelable { @Parcelize object General : SettingsDestination + @Parcelize + object Advanced : SettingsDestination + @Parcelize object Updates : SettingsDestination diff --git a/app/src/main/java/app/revanced/manager/ui/screen/SettingsScreen.kt b/app/src/main/java/app/revanced/manager/ui/screen/SettingsScreen.kt index 12686322ae..59e3ffb022 100644 --- a/app/src/main/java/app/revanced/manager/ui/screen/SettingsScreen.kt +++ b/app/src/main/java/app/revanced/manager/ui/screen/SettingsScreen.kt @@ -81,6 +81,11 @@ fun SettingsScreen( R.string.import_export_description, Icons.Outlined.SwapVert ) to SettingsDestination.ImportExport, + Triple( + R.string.advanced, + R.string.advanced_description, + Icons.Outlined.Tune + ) to SettingsDestination.Advanced, Triple( R.string.about, R.string.about_description, @@ -99,6 +104,10 @@ fun SettingsScreen( viewModel = viewModel ) + is SettingsDestination.Advanced -> AdvancedSettingsScreen( + onBackClick = { navController.pop() } + ) + is SettingsDestination.Updates -> UpdatesSettingsScreen( onBackClick = { navController.pop() }, onChangelogClick = { navController.navigate(SettingsDestination.UpdateChangelog) }, diff --git a/app/src/main/java/app/revanced/manager/ui/screen/settings/AdvancedSettingsScreen.kt b/app/src/main/java/app/revanced/manager/ui/screen/settings/AdvancedSettingsScreen.kt new file mode 100644 index 0000000000..79151301ef --- /dev/null +++ b/app/src/main/java/app/revanced/manager/ui/screen/settings/AdvancedSettingsScreen.kt @@ -0,0 +1,65 @@ +package app.revanced.manager.ui.screen.settings + +import android.app.ActivityManager +import android.content.Context +import android.os.Build +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.ListItem +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember +import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext +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 + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun AdvancedSettingsScreen(onBackClick: () -> Unit) { + val context = LocalContext.current + val memoryLimit = remember { + val activityManager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager + context.getString(R.string.device_memory_limit_format, activityManager.memoryClass, activityManager.largeMemoryClass) + } + Scaffold( + topBar = { + AppTopBar( + title = stringResource(R.string.advanced), + onBackClick = onBackClick + ) + } + ) { paddingValues -> + Column( + modifier = Modifier + .fillMaxSize() + .padding(paddingValues) + .verticalScroll(rememberScrollState()) + ) { + GroupHeader(stringResource(R.string.device)) + ListItem( + headlineContent = { Text(stringResource(R.string.device_model)) }, + supportingContent = { Text(Build.MODEL) } + ) + ListItem( + headlineContent = { Text(stringResource(R.string.device_android_version)) }, + supportingContent = { Text(Build.VERSION.RELEASE) } + ) + ListItem( + headlineContent = { Text(stringResource(R.string.device_architectures)) }, + supportingContent = { Text(Build.SUPPORTED_ABIS.joinToString(", ")) } + ) + ListItem( + headlineContent = { Text(stringResource(R.string.device_memory_limit)) }, + supportingContent = { Text(memoryLimit) } + ) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/app/revanced/manager/util/Util.kt b/app/src/main/java/app/revanced/manager/util/Util.kt index aeabbecda6..07f52a02bd 100644 --- a/app/src/main/java/app/revanced/manager/util/Util.kt +++ b/app/src/main/java/app/revanced/manager/util/Util.kt @@ -1,6 +1,8 @@ package app.revanced.manager.util +import android.app.Activity import android.content.Context +import android.content.ContextWrapper import android.content.Intent import android.content.pm.PackageManager.NameNotFoundException import android.graphics.drawable.Drawable diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 44f72b095b..a5ae69b9dc 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -13,6 +13,8 @@ General General settings + Advanced + Advanced settings Updates Updates for ReVanced Manager Open source licenses @@ -69,6 +71,12 @@ Light Dark Appearance + Device + Android version + Model + CPU Architectures + Memory limits + Normal: %1$d MB, Large: %2$d MB Patching Signing Storage