Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Improve Settings order #2060

Merged
merged 20 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fun SettingsScreen(
) to SettingsDestination.Advanced,
Triple(
R.string.about,
R.string.about_description,
R.string.app_name,
Icons.Outlined.Info
) to SettingsDestination.About,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package app.revanced.manager.ui.screen.settings

import android.app.ActivityManager
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context.CLIPBOARD_SERVICE
validcube marked this conversation as resolved.
Show resolved Hide resolved
import android.os.Build
import android.widget.Toast
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.material.icons.Icons
Expand All @@ -13,7 +18,9 @@ import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Modifier
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalHapticFeedback
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
Expand All @@ -30,7 +37,7 @@ import app.revanced.manager.ui.component.settings.SettingsListItem
import app.revanced.manager.ui.viewmodel.AdvancedSettingsViewModel
import org.koin.androidx.compose.koinViewModel

@OptIn(ExperimentalMaterial3Api::class)
@OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class)
@Composable
fun AdvancedSettingsScreen(
onBackClick: () -> Unit,
Expand All @@ -45,6 +52,7 @@ fun AdvancedSettingsScreen(
activityManager.largeMemoryClass
)
}
val haptics = LocalHapticFeedback.current

Scaffold(
topBar = {
Expand Down Expand Up @@ -82,15 +90,6 @@ fun AdvancedSettingsScreen(
}
)

val exportDebugLogsLauncher =
rememberLauncherForActivityResult(ActivityResultContracts.CreateDocument("text/plain")) {
it?.let(vm::exportDebugLogs)
}
SettingsListItem(
headlineContent = stringResource(R.string.debug_logs_export),
modifier = Modifier.clickable { exportDebugLogsLauncher.launch(vm.debugLogFileName) }
)
validcube marked this conversation as resolved.
Show resolved Hide resolved

GroupHeader(stringResource(R.string.patcher))
BooleanItem(
preference = vm.prefs.useProcessRuntime,
Expand Down Expand Up @@ -138,16 +137,39 @@ fun AdvancedSettingsScreen(
)

GroupHeader(stringResource(R.string.debugging))
val exportDebugLogsLauncher =
rememberLauncherForActivityResult(ActivityResultContracts.CreateDocument("text/plain")) {
it?.let(vm::exportDebugLogs)
}
SettingsListItem(
headlineContent = stringResource(R.string.about_device),
supportingContent = """
**Version**: ${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})
**Build type**: ${BuildConfig.BUILD_TYPE}
**Model**: ${Build.MODEL}
**Android version**: ${Build.VERSION.RELEASE} (${Build.VERSION.SDK_INT})
**Supported Archs**: ${Build.SUPPORTED_ABIS.joinToString(", ")}
**Memory limit**: $memoryLimit
headlineContent = stringResource(R.string.debug_logs_export),
modifier = Modifier.clickable { exportDebugLogsLauncher.launch(vm.debugLogFileName) }
)
val clipboard = context.getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
validcube marked this conversation as resolved.
Show resolved Hide resolved
val deviceContent = """
Version: ${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})
Build type: ${BuildConfig.BUILD_TYPE}
Model: ${Build.MODEL}
Android version: ${Build.VERSION.RELEASE} (${Build.VERSION.SDK_INT})
Supported Archs: ${Build.SUPPORTED_ABIS.joinToString(", ")}
Memory limit: $memoryLimit
""".trimIndent()
SettingsListItem(
modifier = Modifier.combinedClickable(
onLongClickLabel = stringResource(R.string.copy_to_clipboard),
onLongClick = {
haptics.performHapticFeedback(HapticFeedbackType.LongPress)
clipboard.setPrimaryClip(
ClipData.newPlainText("Device Information", deviceContent)
)

Toast.makeText(context, R.string.toast_copied_to_clipboard, Toast.LENGTH_SHORT).show()
validcube marked this conversation as resolved.
Show resolved Hide resolved
}
) {

},
validcube marked this conversation as resolved.
Show resolved Hide resolved
headlineContent = stringResource(R.string.about_device),
supportingContent = deviceContent
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,20 @@ package app.revanced.manager.ui.screen.settings

import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.pager.HorizontalPager
import androidx.compose.foundation.pager.rememberPagerState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fun DeveloperOptionsScreen(
Column(modifier = Modifier.padding(paddingValues)) {
GroupHeader(stringResource(R.string.patch_bundles_section))
SettingsListItem(
headlineContent = stringResource(R.string.patch_bundles_redownload),
headlineContent = stringResource(R.string.patch_bundles_force_download),
modifier = Modifier.clickable(onClick = vm::redownloadBundles)
)
SettingsListItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,18 @@ package app.revanced.manager.ui.screen.settings

import android.os.Build
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.material3.*
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FilledTonalButton
import androidx.compose.material3.RadioButton
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand Down Expand Up @@ -96,7 +106,7 @@ private fun ThemePicker(
title = { Text(stringResource(R.string.theme)) },
text = {
Column {
Theme.values().forEach {
Theme.entries.forEach {
Row(
modifier = Modifier
.fillMaxWidth()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,17 @@ private fun PackageSelector(packages: Set<String>, onFinish: (String?) -> Unit)
}

@Composable
private fun GroupItem(onClick: () -> Unit, @StringRes headline: Int, @StringRes description: Int) =
private fun GroupItem(
onClick: () -> Unit,
@StringRes headline: Int,
@StringRes description: Int? = null
) {
SettingsListItem(
modifier = Modifier.clickable { onClick() },
headlineContent = stringResource(headline),
supportingContent = stringResource(description)
supportingContent = description?.let { stringResource(it) }
)
}

@Composable
fun KeystoreCredentialsDialog(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package app.revanced.manager.ui.screen.settings

import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material3.*
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
Expand Down
22 changes: 12 additions & 10 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<string name="cli">CLI</string>
<string name="manager">Manager</string>

<string name="toast_copied_to_clipboard">Copied!</string>
<string name="copy_to_clipboard">Copy to clipboard</string>

<string name="dashboard">Dashboard</string>
<string name="settings">Settings</string>
<string name="select_app">Select an app</string>
Expand Down Expand Up @@ -49,19 +52,18 @@
<string name="auto_updates_dialog_note">These settings can be changed later.</string>

<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="general_description">Theme, dynamic color</string>
<string name="updates">Updates</string>
<string name="updates_description">Updates for ReVanced Manager</string>
<string name="opensource_licenses">Open source licenses</string>
<string name="opensource_licenses_description">View all the libraries used to make this application</string>
<string name="updates_description">Check for updates and view changelogs</string>
<string name="downloads">Downloads</string>
<string name="downloads_description">Manage downloaded content</string>
<string name="downloads_description">Downloader plugins and downloaded apps</string>
<string name="import_export">Import &amp; export</string>
<string name="import_export_description">Import and export settings</string>
<string name="import_export_description">Keystore, patch option &amp; selection</string>
validcube marked this conversation as resolved.
Show resolved Hide resolved
<string name="advanced">Advanced</string>
<string name="advanced_description">API URL, memory limit, debug</string>
validcube marked this conversation as resolved.
Show resolved Hide resolved
<string name="about">About</string>
<string name="about_description">About ReVanced</string>
<string name="opensource_licenses">Open source licenses</string>
<string name="opensource_licenses_description">View all the libraries used to make this application</string>

<string name="contributors">Contributors</string>
<string name="contributors_description">View the contributors of ReVanced</string>
Expand Down Expand Up @@ -169,7 +171,7 @@
<string name="device_memory_limit">Memory limits</string>
<string name="device_memory_limit_format">%1$dMB (Normal) - %2$dMB (Large)</string>
<string name="patch_bundles_section">Patch bundles</string>
<string name="patch_bundles_redownload">Redownload all patch bundles</string>
<string name="patch_bundles_force_download">Force download all patch bundles</string>
<string name="patch_bundles_reset">Reset patch bundles</string>
<string name="patching">Patching</string>
<string name="signing">Signing</string>
Expand Down
Loading