Skip to content

Commit

Permalink
feat: advanced settings page with device info (ReVanced#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
Axelen123 authored Jul 7, 2023
1 parent 400163b commit 453f4da
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ sealed interface SettingsDestination : Parcelable {
@Parcelize
object General : SettingsDestination

@Parcelize
object Advanced : SettingsDestination

@Parcelize
object Updates : SettingsDestination

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) },
Expand Down
Original file line number Diff line number Diff line change
@@ -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) }
)
}
}
}
2 changes: 2 additions & 0 deletions app/src/main/java/app/revanced/manager/util/Util.kt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit 453f4da

Please sign in to comment.