Link help pages in settings

This commit is contained in:
MM20 2022-10-16 16:06:46 +02:00
parent a4b9a7260a
commit cd70daba24
No known key found for this signature in database
GPG Key ID: 0B61A8F2DEAFA389
8 changed files with 54 additions and 8 deletions

View File

@ -1,6 +1,9 @@
package de.mm20.launcher2.ui.component.preferences
import android.net.Uri
import androidx.appcompat.app.AppCompatActivity
import androidx.browser.customtabs.CustomTabColorSchemeParams
import androidx.browser.customtabs.CustomTabsIntent
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
@ -8,10 +11,17 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.ArrowBack
import androidx.compose.material3.*
import androidx.compose.material.icons.rounded.HelpOutline
import androidx.compose.material3.CenterAlignedTopAppBar
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
@ -24,6 +34,7 @@ fun PreferenceScreen(
title: String,
floatingActionButton: @Composable () -> Unit = {},
topBarActions: @Composable RowScope.() -> Unit = {},
helpUrl: String? = null,
content: LazyListScope.() -> Unit,
) {
val navController = LocalNavController.current
@ -31,6 +42,10 @@ fun PreferenceScreen(
systemUiController.setStatusBarColor(MaterialTheme.colorScheme.surface)
systemUiController.setNavigationBarColor(Color.Black)
val context = LocalContext.current
val colorScheme = MaterialTheme.colorScheme
val activity = LocalContext.current as? AppCompatActivity
Scaffold(
floatingActionButton = floatingActionButton,
@ -53,7 +68,25 @@ fun PreferenceScreen(
Icon(imageVector = Icons.Rounded.ArrowBack, contentDescription = "Back")
}
},
actions = topBarActions
actions = {
if (helpUrl != null) {
IconButton(onClick = {
CustomTabsIntent.Builder()
.setDefaultColorSchemeParams(CustomTabColorSchemeParams.Builder()
.setToolbarColor(colorScheme.primaryContainer.toArgb())
.setSecondaryToolbarColor(colorScheme.secondaryContainer.toArgb())
.build()
)
.build().launchUrl(context, Uri.parse(helpUrl))
}) {
Icon(
imageVector = Icons.Rounded.HelpOutline,
contentDescription = "Help"
)
}
}
topBarActions()
}
)
}) {
LazyColumn(

View File

@ -32,7 +32,10 @@ import de.mm20.launcher2.ui.component.preferences.SwitchPreference
fun CalendarWidgetSettingsScreen() {
val viewModel: CalendarWidgetSettingsScreenVM = viewModel()
val context = LocalContext.current
PreferenceScreen(title = stringResource(R.string.preference_screen_calendarwidget)) {
PreferenceScreen(
title = stringResource(R.string.preference_screen_calendarwidget),
helpUrl = "https://kvaesitso.mm20.de/docs/user-guide/widgets/calendar-widget"
) {
item {
val excludeAllDayEvents by viewModel.excludeAllDayEvents.observeAsState()
PreferenceCategory {

View File

@ -28,7 +28,8 @@ import de.mm20.launcher2.ui.component.preferences.*
fun ClockWidgetSettingsScreen() {
val viewModel: ClockWidgetSettingsScreenVM = viewModel()
PreferenceScreen(
title = stringResource(R.string.preference_screen_clockwidget)
title = stringResource(R.string.preference_screen_clockwidget),
helpUrl = "https://kvaesitso.mm20.de/docs/user-guide/widgets/clock"
) {
item {
PreferenceCategory {

View File

@ -22,6 +22,7 @@ fun CustomColorSchemeSettingsScreen() {
PreferenceScreen(
title = stringResource(R.string.preference_screen_colors),
helpUrl = "https://kvaesitso.mm20.de/docs/user-guide/customization/color-schemes",
topBarActions = {
var showOverflowMenu by remember { mutableStateOf(false) }
IconButton(onClick = { showOverflowMenu = true }) {

View File

@ -35,7 +35,10 @@ fun CrashReporterScreen() {
val reports by viewModel.reports.observeAsState()
val showExceptions by viewModel.showExceptions.observeAsState(true)
val showCrashes by viewModel.showCrashes.observeAsState(true)
PreferenceScreen(title = stringResource(R.string.preference_crash_reporter)) {
PreferenceScreen(
title = stringResource(R.string.preference_crash_reporter),
helpUrl = "https://kvaesitso.mm20.de/docs/user-guide/troubleshooting/crashreporter"
) {
reports?.let {
item {
Row(

View File

@ -25,7 +25,8 @@ fun MusicWidgetSettingsScreen() {
val viewModel: MusicWidgetSettingsScreenVM = viewModel()
val hasPermission by viewModel.hasPermission.observeAsState()
PreferenceScreen(
stringResource(R.string.preference_screen_musicwidget)
stringResource(R.string.preference_screen_musicwidget),
helpUrl = "https://kvaesitso.mm20.de/docs/user-guide/widgets/clock"
) {
item {
PreferenceCategory {

View File

@ -23,7 +23,10 @@ fun WeatherWidgetSettingsScreen() {
val viewModel: WeatherWidgetSettingsScreenVM = viewModel()
val context = LocalContext.current
PreferenceScreen(title = stringResource(R.string.preference_screen_weatherwidget)) {
PreferenceScreen(
title = stringResource(R.string.preference_screen_weatherwidget),
helpUrl = "https://kvaesitso.mm20.de/docs/user-guide/widgets/weather-widget"
) {
item {
PreferenceCategory {
val weatherProvider by viewModel.weatherProvider.observeAsState()

View File

@ -91,7 +91,8 @@ fun WebSearchSettingsScreen() {
FloatingActionButton(onClick = { showNewDialog = true }) {
Icon(imageVector = Icons.Rounded.Add, contentDescription = null)
}
}
},
helpUrl = "https://kvaesitso.mm20.de/docs/user-guide/search/websearches"
) {
item {
PreferenceCategory {