ask existing users about usage notes once

This commit is contained in:
Seb3thehacker committed 2026-10-05 01:27:49 -07:00
1 parent fe44576b06
commit 62fb8babad
2 files changed
+38 -1

No files matched your search

@@ -127,6 +127,8 @@ fun GearslipApp(onDisconnect: () -> Unit, onRequestCallScreening: () -> Unit) {
}
CompatWarning()
// Anyone who set up before usage notes existed gets asked once, on Home.
if (screen == Screen.HOME) UsageStatsPrompt()
}
/**
@@ -2,23 +2,28 @@ package app.seb3thehacker.gearslip.ui
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.selection.toggleable
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Info
import androidx.compose.material.icons.filled.KeyboardArrowDown
import androidx.compose.material.icons.filled.KeyboardArrowUp
import androidx.compose.material.icons.filled.Send
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Checkbox
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Switch
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
@@ -43,7 +48,7 @@ internal const val USAGE_STATS_TITLE = "Help show which cars work"
private const val INTRO_START =
"Gearslip can't tell which cars it works in unless drivers say so. Turn this on, and Gearslip " +
"sends a short note when you open it and after each drive, never in the background. The " +
"note carries the Gearslip version and whatever you tick below. "
"note carries the Gearslip version and whatever you choose to share. "
private const val INTRO_PRIVACY =
"It holds no name, account, or location, only a random number so your phone counts once. " +
"Cloudflare carries the note, and the server keeps no IP address."
@@ -146,3 +151,33 @@ private fun Choice(label: String, checked: Boolean, onChange: (Boolean) -> Unit)
Checkbox(checked = checked, onCheckedChange = null, modifier = Modifier.padding(vertical = 8.dp))
}
}
/**
* Asks once, for people who set Gearslip up before usage notes existed and so never saw the
* setup page. Either answer is final; Settings changes it later. Release builds only.
*/
@Composable
internal fun UsageStatsPrompt() {
if (!UsageStats.choosable) return
val context = LocalContext.current
var show by remember { mutableStateOf(!UsageStats.asked(context)) }
if (!show) return
AlertDialog(
// An answer is needed: tapping outside would just bring it back next time.
onDismissRequest = {},
title = { Text(USAGE_STATS_TITLE) },
text = {
Column(Modifier.verticalScroll(rememberScrollState()), verticalArrangement = Arrangement.spacedBy(12.dp)) {
Text(USAGE_STATS_INTRO)
Text(
"Turning this on also shares the Android version, the phone model, and the cars you " +
"connect to. You can untick any of them in Settings.",
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
}
},
confirmButton = { TextButton(onClick = { UsageStats.set(context, true); show = false }) { Text("Turn on") } },
dismissButton = { TextButton(onClick = { UsageStats.set(context, false); show = false }) { Text("No thanks") } },
)
}