intro: tell updates from new installs by setup having been done, so clearing data counts as new

This commit is contained in:
Seb3thehacker committed 2026-10-13 19:11:33 -07:00
1 parent daa6f24289
commit e587ea97e1
1 file changed
+9 -4
@@ -68,6 +68,8 @@ import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.dp
import app.seb3thehacker.gearslip.BuildConfig
import app.seb3thehacker.gearslip.CertProvider
import app.seb3thehacker.gearslip.AppSettings
import androidx.compose.runtime.collectAsState
import androidx.compose.ui.draw.clipToBounds
import androidx.compose.ui.draw.drawWithContent
@@ -110,13 +112,16 @@ object Intro {
val release: String = BuildConfig.VERSION_NAME.split('.').take(2).joinToString(".")
/**
* True once per release for people who updated. A new install gets the setup guide instead:
* there's nothing "new" yet, so this release counts as seen and the next one shows.
* True once per release for people who used Gearslip before. A new install, or one with its
* data cleared, gets the setup guide instead: there's nothing "new" yet, so this release
* counts as seen and the next one shows. Install dates can't tell those apart, since
* clearing data keeps them, so this goes by what setup left behind; 0.2 saved the same.
*/
fun due(context: Context): Boolean {
if (context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).getString(KEY_SEEN, null) == release) return false
val info = runCatching { context.packageManager.getPackageInfo(context.packageName, 0) }.getOrNull()
if (info != null && info.firstInstallTime == info.lastUpdateTime) {
val usedBefore = AppSettings.hasSeenPermissionsSetup(context) ||
AppSettings.hasSkippedCertSetup(context) || CertProvider.hasAnyCert(context)
if (!usedBefore) {
markSeen(context)
return false
}