mirror of
https://github.com/twinksoftware/Gearslip.git
synced 2026-11-10 16:02:25 +01:00
setup guide shows what usage notes send
This commit is contained in:
1 parent
10cc17bb66
commit
3ac815eee4
2 files changed
+33
-35
No files matched your search
@@ -93,7 +93,7 @@ fun SettingsScreen(
|
|||||||
ConnectionSection()
|
ConnectionSection()
|
||||||
if (SHOW_RECOMMENDED_APPS) AppsSection(onOpenRecommendedApps)
|
if (SHOW_RECOMMENDED_APPS) AppsSection(onOpenRecommendedApps)
|
||||||
CertificateSection()
|
CertificateSection()
|
||||||
SettingsSection("Usage notes", header = USAGE_STATS_INTRO) { UsageStatsRows(showNote = true) }
|
SettingsSection("Usage notes", header = USAGE_STATS_INTRO) { UsageStatsRows() }
|
||||||
Spacer(Modifier.height(16.dp))
|
Spacer(Modifier.height(16.dp))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,18 +60,18 @@ internal val USAGE_STATS_INTRO: AnnotatedString = buildAnnotatedString {
|
|||||||
append(INTRO_END)
|
append(INTRO_END)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The usage notes card for the setup guide: the same rows Settings shows, minus the note. */
|
/** The usage notes card for the setup guide: the same rows Settings shows. */
|
||||||
@Composable
|
@Composable
|
||||||
internal fun UsageStatsChoices(modifier: Modifier = Modifier) {
|
internal fun UsageStatsChoices(modifier: Modifier = Modifier) {
|
||||||
SettingsCard(modifier) { UsageStatsRows(showNote = false) }
|
SettingsCard(modifier) { UsageStatsRows() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The on switch, what to share, and (with [showNote]) the note itself, saved as they change.
|
* The on switch, what to share, and the note itself, saved as they change.
|
||||||
* Rows only: the caller puts them in a card.
|
* Rows only: the caller puts them in a card.
|
||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
internal fun ColumnScope.UsageStatsRows(showNote: Boolean) {
|
internal fun ColumnScope.UsageStatsRows() {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
var on by remember { mutableStateOf(UsageStats.enabled(context)) }
|
var on by remember { mutableStateOf(UsageStats.enabled(context)) }
|
||||||
var choices by remember { mutableStateOf(UsageStats.choices(context)) }
|
var choices by remember { mutableStateOf(UsageStats.choices(context)) }
|
||||||
@@ -106,36 +106,34 @@ internal fun ColumnScope.UsageStatsRows(showNote: Boolean) {
|
|||||||
choices = choices.copy(cars = it)
|
choices = choices.copy(cars = it)
|
||||||
save()
|
save()
|
||||||
}
|
}
|
||||||
if (showNote) {
|
SettingsDivider()
|
||||||
SettingsDivider()
|
SettingsRow(
|
||||||
SettingsRow(
|
"What gets sent",
|
||||||
"What gets sent",
|
Modifier.clickable { noteOpen = !noteOpen },
|
||||||
Modifier.clickable { noteOpen = !noteOpen },
|
subtitle = "Each car goes after the drive ends. The Android version and phone model go only when they change, and once a month",
|
||||||
subtitle = "Each car goes after the drive ends. The Android version and phone model go only when they change, and once a month",
|
icon = Icons.Filled.Info,
|
||||||
icon = Icons.Filled.Info,
|
trailing = {
|
||||||
trailing = {
|
Icon(
|
||||||
Icon(
|
if (noteOpen) Icons.Filled.KeyboardArrowUp else Icons.Filled.KeyboardArrowDown,
|
||||||
if (noteOpen) Icons.Filled.KeyboardArrowUp else Icons.Filled.KeyboardArrowDown,
|
contentDescription = if (noteOpen) "Hide the note" else "Show the note",
|
||||||
contentDescription = if (noteOpen) "Hide the note" else "Show the note",
|
tint = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
tint = MaterialTheme.colorScheme.onSurfaceVariant,
|
)
|
||||||
)
|
},
|
||||||
},
|
)
|
||||||
)
|
AnimatedVisibility(noteOpen) {
|
||||||
AnimatedVisibility(noteOpen) {
|
// Rebuilt from the saved choices each time one changes, so it always matches.
|
||||||
// Rebuilt from the saved choices each time one changes, so it always matches.
|
val note = remember(choices) { UsageStats.preview(context, everything = true).toString(2) }
|
||||||
val note = remember(choices) { UsageStats.preview(context, everything = true).toString(2) }
|
Surface(
|
||||||
Surface(
|
color = MaterialTheme.colorScheme.surfaceContainerLowest,
|
||||||
color = MaterialTheme.colorScheme.surfaceContainerLowest,
|
shape = MaterialTheme.shapes.medium,
|
||||||
shape = MaterialTheme.shapes.medium,
|
modifier = Modifier.fillMaxWidth().padding(start = 16.dp, end = 16.dp, bottom = 16.dp),
|
||||||
modifier = Modifier.fillMaxWidth().padding(start = 16.dp, end = 16.dp, bottom = 16.dp),
|
) {
|
||||||
) {
|
Text(
|
||||||
Text(
|
note,
|
||||||
note,
|
style = MaterialTheme.typography.bodySmall,
|
||||||
style = MaterialTheme.typography.bodySmall,
|
fontFamily = FontFamily.Monospace,
|
||||||
fontFamily = FontFamily.Monospace,
|
modifier = Modifier.padding(12.dp),
|
||||||
modifier = Modifier.padding(12.dp),
|
)
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user