feat: advanced settings page with device info (#51)

This commit is contained in:
Ax333l 2023-07-07 17:35:36 +02:00 committed by GitHub
parent 400163b820
commit 453f4da8ec
5 changed files with 87 additions and 0 deletions

View file

@ -11,6 +11,9 @@ sealed interface SettingsDestination : Parcelable {
@Parcelize
object General : SettingsDestination
@Parcelize
object Advanced : SettingsDestination
@Parcelize
object Updates : SettingsDestination

View file

@ -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) },

View file

@ -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) }
)
}
}
}

View file

@ -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

View file

@ -13,6 +13,8 @@
<string name="general">General</string>
<string name="general_description">General settings</string>
<string name="advanced">Advanced</string>
<string name="advanced_description">Advanced settings</string>
<string name="updates">Updates</string>
<string name="updates_description">Updates for ReVanced Manager</string>
<string name="opensource_licenses">Open source licenses</string>
@ -69,6 +71,12 @@
<string name="light">Light</string>
<string name="dark">Dark</string>
<string name="appearance">Appearance</string>
<string name="device">Device</string>
<string name="device_android_version">Android version</string>
<string name="device_model">Model</string>
<string name="device_architectures">CPU Architectures</string>
<string name="device_memory_limit">Memory limits</string>
<string name="device_memory_limit_format">Normal: %1$d MB, Large: %2$d MB</string>
<string name="patching">Patching</string>
<string name="signing">Signing</string>
<string name="storage">Storage</string>