Modern Apps git

← Modern-Apps.git

kart: remove achievements, GameCenter, settings, daily mode

Commit
3edc069dcc7841b74814aa122bdde3c772cd4500
Author
vayun-mathur <[email protected]>
When
2026-10-18 19:59 UTC (1 month ago)
Parents
4268678

Diff

games/kart/build.gradle.kts
diff --git a/games/kart/build.gradle.kts b/games/kart/build.gradle.ktsindex e1d798e2a7..2df014e4f9 100644--- a/games/kart/build.gradle.kts+++ b/games/kart/build.gradle.kts@@ -41,9 +41,7 @@ androidComponents { rustNativeLib("kart_engine", "kart", extraAbis = listOf(ABI_ARMV7))  dependencies {-    implementation(project(":sdk:games"))     implementation(project(":sdk:controller"))-    implementation(project(":library:work"))     implementation(project(":library:e2ee-p2p"))     implementation(libs.androidx.datastore.preferences) }
games/kart/src/main/AndroidManifest.xml
diff --git a/games/kart/src/main/AndroidManifest.xml b/games/kart/src/main/AndroidManifest.xmlindex f495c94f67..b52ad5ab42 100644--- a/games/kart/src/main/AndroidManifest.xml+++ b/games/kart/src/main/AndroidManifest.xml@@ -1,9 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"> -    <uses-permission android:name="com.vayunmathur.games.hub.permission.READ_GAME_DATA" />-    <uses-permission android:name="com.vayunmathur.games.hub.permission.WRITE_GAME_DATA" />-    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />     <!-- TV lobby: TCP accept + mDNS advertise/register for the phone controllers. -->     <uses-permission android:name="android.permission.INTERNET" />     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />@@ -40,11 +37,6 @@                 <!-- TV launcher row: without this the app is invisible on Google TV. -->                 <category android:name="android.intent.category.LEANBACK_LAUNCHER" />             </intent-filter>-            <!-- Pairs with openSettingsIfRequested, so App Info's settings cog deep-links there. -->-            <intent-filter>-                <action android:name="android.intent.action.APPLICATION_PREFERENCES" />-                <category android:name="android.intent.category.DEFAULT" />-            </intent-filter>         </activity>     </application> 
games/kart/src/main/assets/achievements.json
diff --git a/games/kart/src/main/assets/achievements.json b/games/kart/src/main/assets/achievements.jsondeleted file mode 100644index cd101beb4c..0000000000--- a/games/kart/src/main/assets/achievements.json+++ /dev/null@@ -1,41 +0,0 @@-[-  {-    "id": "first_race",-    "name": "Green Light",-    "description": "Finish your first race!"-  },-  {-    "id": "first_win",-    "name": "Photo Finish",-    "description": "Win your first race."-  },-  {-    "id": "first_daily",-    "name": "Daily Habit",-    "description": "Finish a daily event."-  },-  {-    "id": "cups_3",-    "name": "Podium Tour",-    "description": "Clear 3 cups.",-    "targetProgress": 3-  },-  {-    "id": "cups_10",-    "name": "Grand Tour",-    "description": "Clear 10 cups.",-    "targetProgress": 10-  },-  {-    "id": "daily_streak_7",-    "name": "Week Streak",-    "description": "Finish the daily event 7 days in a row.",-    "targetProgress": 7-  },-  {-    "id": "daily_streak_30",-    "name": "Month Streak",-    "description": "Finish the daily event 30 days in a row.",-    "targetProgress": 30-  }-]
games/kart/src/main/java/com/vayunmathur/games/kart/Navigation.kt
diff --git a/games/kart/src/main/java/com/vayunmathur/games/kart/Navigation.kt b/games/kart/src/main/java/com/vayunmathur/games/kart/Navigation.ktindex 7d2e05c875..4332590fad 100644--- a/games/kart/src/main/java/com/vayunmathur/games/kart/Navigation.kt+++ b/games/kart/src/main/java/com/vayunmathur/games/kart/Navigation.kt@@ -1,44 +1,16 @@ package com.vayunmathur.games.kart -import androidx.compose.foundation.layout.Box-import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable-import androidx.compose.runtime.collectAsState-import androidx.compose.runtime.getValue-import androidx.compose.ui.Modifier import com.vayunmathur.games.kart.platform.KartViewModel import com.vayunmathur.games.kart.ui.KartGamePage-import com.vayunmathur.games.kart.ui.SettingsPage-import com.vayunmathur.library.ui.AchievementNotification-import com.vayunmathur.library.ui.GameCenterScreen-import com.vayunmathur.library.util.GameHubComposeHook import com.vayunmathur.library.util.FullscreenPage import com.vayunmathur.library.util.MainNavigation-import com.vayunmathur.library.util.openSettingsIfRequested import com.vayunmathur.library.util.rememberNavBackStack  @Composable fun Navigation(viewModel: KartViewModel) {     val backStack = rememberNavBackStack<Route>(Route.Game)-    // Launching from App Info's settings cog deep-links straight to Settings.-    backStack.openSettingsIfRequested(Route.Settings)-    val newAchievement by viewModel.achievementsManager.newAchievement.collectAsState()-    GameHubComposeHook("kart", viewModel.achievementsManager)-    Box(Modifier.fillMaxSize()) {-        MainNavigation(backStack) {-            entry<Route.Game>(metadata = FullscreenPage()) { KartGamePage(backStack, viewModel) }-            entry<Route.GameCenter> {-                GameCenterScreen(-                    manager = viewModel.achievementsManager,-                    onBack = { backStack.pop() },-                )-            }-            entry<Route.Settings> {-                SettingsPage(viewModel = viewModel, onBack = { backStack.pop() })-            }-        }-        newAchievement?.let {-            AchievementNotification(it) { viewModel.dismissAchievementNotification() }-        }+    MainNavigation(backStack) {+        entry<Route.Game>(metadata = FullscreenPage()) { KartGamePage(viewModel) }     } }
games/kart/src/main/java/com/vayunmathur/games/kart/Route.kt
diff --git a/games/kart/src/main/java/com/vayunmathur/games/kart/Route.kt b/games/kart/src/main/java/com/vayunmathur/games/kart/Route.ktindex 72a44fe24b..74cc353a95 100644--- a/games/kart/src/main/java/com/vayunmathur/games/kart/Route.kt+++ b/games/kart/src/main/java/com/vayunmathur/games/kart/Route.kt@@ -8,10 +8,4 @@ sealed interface Route : NavKey {     /** The garage screen: which karts/tracks are unlocked and what the next race looks like. */     @Serializable     data object Game : Route--    @Serializable-    data object GameCenter : Route--    @Serializable-    data object Settings : Route }
games/kart/src/main/java/com/vayunmathur/games/kart/data/KartDataStore.kt
diff --git a/games/kart/src/main/java/com/vayunmathur/games/kart/data/KartDataStore.kt b/games/kart/src/main/java/com/vayunmathur/games/kart/data/KartDataStore.ktindex 412559972f..e4040ff2ba 100644--- a/games/kart/src/main/java/com/vayunmathur/games/kart/data/KartDataStore.kt+++ b/games/kart/src/main/java/com/vayunmathur/games/kart/data/KartDataStore.kt@@ -4,7 +4,6 @@ import android.content.Context import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.intPreferencesKey import androidx.datastore.preferences.core.longPreferencesKey-import androidx.datastore.preferences.core.stringPreferencesKey import androidx.datastore.preferences.preferencesDataStore import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map@@ -14,73 +13,26 @@ private val Context.dataStore by preferencesDataStore(name = "settings") /**  * Everything the game remembers.  *- * Casual progress is a single cup number plus lifetime counters; advancing clears nothing, it- * just moves the pointer. Daily progress is stamped with the day it belongs to, so yesterday's- * result can never bleed into today's.+ * A single cup pointer plus lifetime counters; advancing moves the pointer, it clears nothing.  */ class KartDataStore(private val context: Context) {      val currentCup: Flow<Int> = context.dataStore.data.map { it[CUP_KEY] ?: 0 } -    /** Lifetime count of cleared cups, which survives [saveCup] moving the pointer on. */-    val cupsCleared: Flow<Int> = context.dataStore.data.map { it[CLEARED_KEY] ?: 0 }-     /** Lifetime race wins, counted by the race flow once it exists. */     val racesWon: Flow<Int> = context.dataStore.data.map { it[RACES_WON_KEY] ?: 0 }      /** Best lap in milliseconds; zero means no lap has been timed yet. */     val bestLapMs: Flow<Long> = context.dataStore.data.map { it[BEST_LAP_KEY] ?: 0L } -    val gameMode: Flow<GameMode> = context.dataStore.data.map { prefs ->-        prefs[GAME_MODE_KEY]?.let { runCatching { GameMode.valueOf(it) }.getOrNull() }-            ?: GameMode.CASUAL-    }--    // ---- Daily ------    val dailyDay: Flow<Long> = context.dataStore.data.map { it[DAILY_DAY_KEY] ?: NO_DAY }--    suspend fun setGameMode(mode: GameMode) {-        context.dataStore.edit { it[GAME_MODE_KEY] = mode.name }-    }-     /** Moves to [cup] without touching the lifetime counters. */     suspend fun saveCup(cup: Int) {         context.dataStore.edit { prefs -> prefs[CUP_KEY] = cup }     } -    /** Bumps and returns the lifetime cleared count. */-    suspend fun recordCleared(): Int {-        var total = 0-        context.dataStore.edit { prefs ->-            total = (prefs[CLEARED_KEY] ?: 0) + 1-            prefs[CLEARED_KEY] = total-        }-        return total-    }--    /**-     * Rolls the daily board over to [day] if it is not already there.-     *-     * The early return keeps re-entering daily mode from wiping work in progress.-     */-    suspend fun ensureDailyDay(day: Long) {-        context.dataStore.edit { prefs ->-            if (prefs[DAILY_DAY_KEY] == day) return@edit-            prefs[DAILY_DAY_KEY] = day-        }-    }-     private companion object {         val CUP_KEY = intPreferencesKey("current_cup")-        val CLEARED_KEY = intPreferencesKey("cups_cleared")         val RACES_WON_KEY = intPreferencesKey("races_won")         val BEST_LAP_KEY = longPreferencesKey("best_lap_ms")-        val GAME_MODE_KEY = stringPreferencesKey("game_mode")--        val DAILY_DAY_KEY = longPreferencesKey("daily_day")--        /** Sentinel for "no daily played yet"; distinct from epoch day 0, which is a real date. */-        const val NO_DAY = Long.MIN_VALUE     } }
games/kart/src/main/java/com/vayunmathur/games/kart/data/KartModels.kt
diff --git a/games/kart/src/main/java/com/vayunmathur/games/kart/data/KartModels.kt b/games/kart/src/main/java/com/vayunmathur/games/kart/data/KartModels.ktindex 86b13e4bd2..b818241dfe 100644--- a/games/kart/src/main/java/com/vayunmathur/games/kart/data/KartModels.kt+++ b/games/kart/src/main/java/com/vayunmathur/games/kart/data/KartModels.kt@@ -1,17 +1,10 @@ package com.vayunmathur.games.kart.data -import kotlinx.serialization.Serializable--/** Which garage the player is looking at. Mirrors the arrows split: a ladder, plus one a day. */-@Serializable-enum class GameMode { CASUAL, DAILY }- /**  * A single grand-prix event.  *  * The scaffold ships no tracks yet: the cup is a named slot the race flow will fill in once the- * engine lands. Keeping the model in place now means the GameCenter progress lines already have- * something to count.+ * engine lands.  */ data class KartCup(     val id: Int,@@ -29,13 +22,11 @@ val CUPS = listOf( /**  * Where the player stands.  *- * [cupsCleared] is the lifetime count the achievements count against; [bestLapMs] and- * [racesWon] feed the GameCenter rows once races exist. All three start empty: nothing here- * pretends a race has happened.+ * [currentCup] is the cup on screen; [racesWon] and [bestLapMs] feed the garage rows.+ * All start empty: nothing here pretends a race has happened.  */ data class KartProgress(     val currentCup: Int = 0,-    val cupsCleared: Int = 0,     val racesWon: Int = 0,     val bestLapMs: Long = 0L, )
games/kart/src/main/java/com/vayunmathur/games/kart/platform/AppBackupAgent.kt
diff --git a/games/kart/src/main/java/com/vayunmathur/games/kart/platform/AppBackupAgent.kt b/games/kart/src/main/java/com/vayunmathur/games/kart/platform/AppBackupAgent.ktindex edc4bc195e..08b9da3490 100644--- a/games/kart/src/main/java/com/vayunmathur/games/kart/platform/AppBackupAgent.kt+++ b/games/kart/src/main/java/com/vayunmathur/games/kart/platform/AppBackupAgent.kt@@ -4,9 +4,10 @@ import com.vayunmathur.library.util.BaseBackupAgent  class AppBackupAgent : BaseBackupAgent() {     /**-     * Both files, or a restore silently wipes half the player's history: "settings" holds the cup-     * pointer and the lifetime counters, while the shared DataStoreUtils file holds the daily streak-     * and the achievement unlocks.+     * The "settings" file alone: it holds the cup pointer and the lifetime+     * counters. The pairing identity lives in its own `kart_identity` file,+     * deliberately off this list — restoring identity keys onto a different+     * TV would let that TV impersonate this one to an already-paired phone.      */-    override val datastoreNames: List<String> get() = listOf("settings", "datastore_default")+    override val datastoreNames: List<String> get() = listOf("settings") }
games/kart/src/main/java/com/vayunmathur/games/kart/platform/KartAchievementsManager.kt
diff --git a/games/kart/src/main/java/com/vayunmathur/games/kart/platform/KartAchievementsManager.kt b/games/kart/src/main/java/com/vayunmathur/games/kart/platform/KartAchievementsManager.ktdeleted file mode 100644index fc86bcf522..0000000000--- a/games/kart/src/main/java/com/vayunmathur/games/kart/platform/KartAchievementsManager.kt+++ /dev/null@@ -1,39 +0,0 @@-package com.vayunmathur.games.kart.platform--import android.content.Context-import com.vayunmathur.games.kart.data.KartDataStore-import com.vayunmathur.library.util.AchievementsManager-import com.vayunmathur.library.util.DailyChallengeStore-import kotlinx.coroutines.CoroutineScope-import kotlinx.coroutines.Dispatchers-import kotlinx.coroutines.flow.first-import kotlinx.coroutines.launch--class KartAchievementsManager(-    context: Context,-    json: String,-    private val dataStore: KartDataStore,-    private val dailyStore: DailyChallengeStore,-) : AchievementsManager(context, json) {--    /**-     * Back-fills from stored progress on launch, so an achievement added in a later release is awarded-     * for work the player has already done rather than only for the next race they finish.-     *-     * The reads are suspending, so this hands off to a coroutine rather than blocking.-     */-    override fun checkExistingAchievements() {-        CoroutineScope(Dispatchers.IO).launch {-            val total = dataStore.cupsCleared.first()-            if (total > 0) onAchievementUnlocked("first_race")-            onProgressUpdated("cups_3", total)--            if (dailyStore.lastCompletedDay() != DailyChallengeStore.NO_DAY) {-                onAchievementUnlocked("first_daily")-            }-            val best = dailyStore.bestStreak().toInt()-            onProgressUpdated("daily_streak_7", best)-            onProgressUpdated("daily_streak_30", best)-        }-    }-}
games/kart/src/main/java/com/vayunmathur/games/kart/platform/KartUiContract.kt
diff --git a/games/kart/src/main/java/com/vayunmathur/games/kart/platform/KartUiContract.kt b/games/kart/src/main/java/com/vayunmathur/games/kart/platform/KartUiContract.ktindex da2641c55e..ab343c79e1 100644--- a/games/kart/src/main/java/com/vayunmathur/games/kart/platform/KartUiContract.kt+++ b/games/kart/src/main/java/com/vayunmathur/games/kart/platform/KartUiContract.kt@@ -1,6 +1,5 @@ package com.vayunmathur.games.kart.platform -import com.vayunmathur.games.kart.data.GameMode import com.vayunmathur.games.kart.data.KartCup import com.vayunmathur.games.kart.data.KartProgress @@ -18,9 +17,6 @@ interface KartGameActions {     /** Starts the lobby countdown; the tick loop banks the cup clear when the race finishes. */     fun startRace() {} -    fun nextCup() {}-    fun setGameMode(mode: GameMode) {}-     /** Back to the lobby from the results screen. */     fun backToLobby() {} @@ -31,21 +27,4 @@ interface KartGameActions { data class KartUiState(     val cup: KartCup? = null,     val progress: KartProgress = KartProgress(),-    val mode: GameMode = GameMode.CASUAL,-    val dailyStreak: Long = 0,-    /** True once today's daily has been cleared, which swaps the race button for a note. */-    val dailyDone: Boolean = false,-)--interface SettingsActions {-    fun setReminderEnabled(enabled: Boolean) {}-    fun setReminderTime(hour: Int, minute: Int) {}--    companion object { val Noop: SettingsActions = object : SettingsActions {} }-}--data class SettingsUiState(-    val reminderEnabled: Boolean = false,-    val reminderHour: Int = 20,-    val reminderMinute: Int = 0, )
games/kart/src/main/java/com/vayunmathur/games/kart/platform/KartViewModel.kt
diff --git a/games/kart/src/main/java/com/vayunmathur/games/kart/platform/KartViewModel.kt b/games/kart/src/main/java/com/vayunmathur/games/kart/platform/KartViewModel.ktindex bb50a0806a..42e65d92f5 100644--- a/games/kart/src/main/java/com/vayunmathur/games/kart/platform/KartViewModel.kt+++ b/games/kart/src/main/java/com/vayunmathur/games/kart/platform/KartViewModel.kt@@ -3,7 +3,6 @@ package com.vayunmathur.games.kart.platform import android.app.Application import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.viewModelScope-import com.vayunmathur.games.kart.data.GameMode import com.vayunmathur.games.kart.data.KartDataStore import com.vayunmathur.games.kart.data.KartProgress import com.vayunmathur.games.kart.domain.GameInputLoop@@ -12,56 +11,31 @@ import com.vayunmathur.games.kart.domain.LapTracker import com.vayunmathur.games.kart.domain.PlaceholderRace import com.vayunmathur.games.kart.domain.RumbleDecider import com.vayunmathur.games.kart.util.KartNative-import com.vayunmathur.library.util.AchievementsManager-import com.vayunmathur.library.util.DailyChallengeStore-import com.vayunmathur.library.util.DailyStreakReporter-import com.vayunmathur.library.work.DailyPuzzleReminder-import com.vayunmathur.library.work.DailyReminderSettings import com.vayunmathur.sdk.controller.RumbleFeedback import kotlinx.coroutines.Job import kotlinx.coroutines.delay import kotlinx.coroutines.flow.MutableStateFlow-import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.combine-import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.isActive import kotlinx.coroutines.launch  /**  * Owns the garage screen and the progress behind it.  *- * Casual mode is a single cup pointer: advancing writes `cup + 1` and leaves the lifetime- * counters alone, so there is no cup list and no way back. Daily mode is one event per calendar- * day, with its progress stamped with the day it belongs to.+ * A single cup pointer: advancing writes `cup + 1` and leaves the lifetime+ * counters alone, so there is no cup list and no way back.  */ class KartViewModel(application: Application) : AndroidViewModel(application),-    KartGameActions, SettingsActions {+    KartGameActions {      val dataStore = KartDataStore(application)-    private val dailyStore = DailyChallengeStore(application, DAILY_KEY_PREFIX)-    private val reminderSettings = DailyReminderSettings(application, DAILY_KEY_PREFIX)      private val _uiState = MutableStateFlow(KartUiState())     val uiState: StateFlow<KartUiState> = _uiState.asStateFlow() -    val reminderEnabled: StateFlow<Boolean> = reminderSettings.enabled-        .stateIn(viewModelScope, SharingStarted.WhileSubscribed(5_000), false)--    val reminderMinutesOfDay: StateFlow<Long> = reminderSettings.minutesOfDay-        .stateIn(-            viewModelScope,-            SharingStarted.WhileSubscribed(5_000),-            DailyPuzzleReminder.DEFAULT_MINUTES_OF_DAY,-        )--    val achievementsManager: AchievementsManager = run {-        val json = application.assets.open("achievements.json").bufferedReader().readText()-        KartAchievementsManager(application, json, dataStore, dailyStore)-    }-     /**      * The TV lobby, backed by a real post-quantum identity.      *@@ -101,8 +75,6 @@ class KartViewModel(application: Application) : AndroidViewModel(application),         private set      init {-        achievementsManager.checkExistingAchievements()-         // Load (or mint) the PQC identity off the main thread, then open the         // lobby. First run pays keygen; every later start reads persisted keys.         viewModelScope.launch {@@ -122,64 +94,36 @@ class KartViewModel(application: Application) : AndroidViewModel(application),          viewModelScope.launch {             combine(-                dataStore.gameMode,                 dataStore.currentCup,-                dataStore.cupsCleared,                 dataStore.racesWon,                 dataStore.bestLapMs,-            ) { mode, cup, cleared, won, bestLap ->-                Progress(mode, cup, cleared, won, bestLap)-            }.combine(dailyStore.currentStreak) { progress, streak ->-                Session(progress.mode, progress.cup, progress.cleared, progress.won, progress.bestLap, streak)+            ) { cup, won, bestLap ->+                Session(cup, won, bestLap)             }.collectLatest { session -> load(session) }         }     } -    private data class Progress(-        val mode: GameMode,-        val cup: Int,-        val cleared: Int,-        val won: Int,-        val bestLap: Long,-    )-     /** The stored inputs that decide which cup is on screen. */     private data class Session(-        val mode: GameMode,         val cup: Int,-        val cleared: Int,         val won: Int,         val bestLap: Long,-        val streak: Long,     )      private suspend fun load(session: Session) {-        val daily = session.mode == GameMode.DAILY-        val day = dailyStore.todayEpochDay()-        if (daily) dataStore.ensureDailyDay(day)-         _uiState.value = KartUiState(             cup = KartRules.cupAt(session.cup),             progress = KartProgress(                 currentCup = session.cup,-                cupsCleared = session.cleared,                 racesWon = session.won,                 bestLapMs = session.bestLap,             ),-            mode = session.mode,-            dailyStreak = session.streak,-            dailyDone = daily && dailyStore.lastCompletedDay() == day,         )     }      override fun startRace() {         // The garage button starts the lobby countdown; the tick loop banks the cup clear when-        // the race finishes. Daily mode keeps the old instant-clear until daily events race.-        val state = _uiState.value-        if (state.mode == GameMode.DAILY) {-            onDailyCleared()-            return-        }+        // the race finishes.         if (_racePhase.value !is RacePhase.Lobby) return         // Solo seat for the scaffold: this device drives kart one until phones join.         localPlayerId = localPlayerId ?: "local-${System.currentTimeMillis()}"@@ -363,14 +307,6 @@ class KartViewModel(application: Application) : AndroidViewModel(application),         _racePhase.value = RacePhase.Results(winner = winner, order = order)         val state = _uiState.value         viewModelScope.launch {-            val manager = achievementsManager-            manager.onAchievementUnlocked("first_race")-            if (winner == localPlayerId) {-                manager.onAchievementUnlocked("first_win")-            }-            val total = dataStore.recordCleared()-            manager.onProgressUpdated("cups_3", total)-            manager.onProgressUpdated("cups_10", total)             KartRules.nextCup(state.progress.currentCup)?.let { dataStore.saveCup(it) }         }         race = null@@ -462,73 +398,7 @@ class KartViewModel(application: Application) : AndroidViewModel(application),         kartHost.stop()     } -    override fun nextCup() {-        val cup = _uiState.value.progress.currentCup-        viewModelScope.launch {-            KartRules.nextCup(cup)?.let { dataStore.saveCup(it) }-        }-    }--    override fun setGameMode(mode: GameMode) {-        viewModelScope.launch { dataStore.setGameMode(mode) }-    }--    override fun setReminderEnabled(enabled: Boolean) {-        viewModelScope.launch {-            reminderSettings.setEnabled(enabled)-            rescheduleReminder(enabled, reminderMinutesOfDay.value)-        }-    }--    override fun setReminderTime(hour: Int, minute: Int) {-        viewModelScope.launch {-            val minutes = (hour * 60 + minute).toLong()-            reminderSettings.setMinutesOfDay(minutes)-            rescheduleReminder(reminderEnabled.value, minutes)-        }-    }--    private fun rescheduleReminder(enabled: Boolean, minutesOfDay: Long) {-        DailyPuzzleReminder.update(-            context = getApplication(),-            keyPrefix = DAILY_KEY_PREFIX,-            notificationId = REMINDER_NOTIFICATION_ID,-            enabled = enabled,-            hour = (minutesOfDay / 60).toInt(),-            minute = (minutesOfDay % 60).toInt(),-        )-    }--    fun dismissAchievementNotification() = achievementsManager.dismissNotification()--    private fun onDailyCleared() {-        viewModelScope.launch {-            val day = dailyStore.todayEpochDay()-            val manager = achievementsManager-            manager.onAchievementUnlocked("first_daily")-            val streak = dailyStore.recordDayCompleted(day)-            DailyStreakReporter.report(getApplication(), "kart", streak, day)-            manager.onProgressUpdated("daily_streak_7", streak.current.toInt())-            manager.onProgressUpdated("daily_streak_30", streak.current.toInt())-            load(uiState.value.toSession())-        }-    }--    private fun KartUiState.toSession() = Session(-        mode = mode,-        cup = progress.currentCup,-        cleared = progress.cupsCleared,-        won = progress.racesWon,-        bestLap = progress.bestLapMs,-        streak = dailyStreak,-    )-     companion object {-        /** Namespace shared by the daily-challenge store and its reminder. */-        const val DAILY_KEY_PREFIX = "kart_daily"--        private const val REMINDER_NOTIFICATION_ID = 5106-         /** Ticks per second for the placeholder race loop. */         private const val TICK_MS = 50L @@ -543,12 +413,5 @@ class KartViewModel(application: Application) : AndroidViewModel(application),          /** Seconds of 3-2-1 before controls go live. */         private const val COUNTDOWN_SECONDS = 3--        /**-         * Keeps date-derived daily seeds away from the cup indexes casual mode uses, and away-         * from the offsets the other games picked (500M pipes, 700M wordmaker, 900M unblockjam,-         * 1.1B nonogram, 1.3B arrows).-         */-        const val DAILY_SEED_OFFSET = 1_500_000_000L     } }
games/kart/src/main/java/com/vayunmathur/games/kart/ui/KartGamePage.kt
diff --git a/games/kart/src/main/java/com/vayunmathur/games/kart/ui/KartGamePage.kt b/games/kart/src/main/java/com/vayunmathur/games/kart/ui/KartGamePage.ktindex 005bfd1c62..a77971f608 100644--- a/games/kart/src/main/java/com/vayunmathur/games/kart/ui/KartGamePage.kt+++ b/games/kart/src/main/java/com/vayunmathur/games/kart/ui/KartGamePage.kt@@ -3,19 +3,15 @@ package com.vayunmathur.games.kart.ui import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue-import com.vayunmathur.games.kart.Route import com.vayunmathur.games.kart.platform.KartViewModel-import com.vayunmathur.library.util.NavBackStack  /**  * Binds [KartViewModel] to the stateless [KartGameScreen].  *- * The ViewModel already implements the actions contract, so this only has to collect state and supply- * the two navigation callbacks the garage cannot know about.+ * The ViewModel already implements the actions contract, so this only has to collect state.  */ @Composable fun KartGamePage(-    backStack: NavBackStack<Route>,     viewModel: KartViewModel, ) {     val uiState by viewModel.uiState.collectAsState()@@ -24,7 +20,5 @@ fun KartGamePage(         state = uiState,         phase = racePhase,         actions = viewModel,-        onOpenSettings = { backStack.add(Route.Settings) },-        onOpenGameCenter = { backStack.add(Route.GameCenter) },     ) }
games/kart/src/main/java/com/vayunmathur/games/kart/ui/KartGameScreen.kt
diff --git a/games/kart/src/main/java/com/vayunmathur/games/kart/ui/KartGameScreen.kt b/games/kart/src/main/java/com/vayunmathur/games/kart/ui/KartGameScreen.ktindex 338f69fc95..59e6e45916 100644--- a/games/kart/src/main/java/com/vayunmathur/games/kart/ui/KartGameScreen.kt+++ b/games/kart/src/main/java/com/vayunmathur/games/kart/ui/KartGameScreen.kt@@ -17,7 +17,6 @@ import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.compose.ui.viewinterop.AndroidView import com.vayunmathur.games.kart.R-import com.vayunmathur.games.kart.data.GameMode import com.vayunmathur.games.kart.platform.KartGameActions import com.vayunmathur.games.kart.platform.KartUiState import com.vayunmathur.games.kart.platform.RacePhase@@ -30,9 +29,6 @@ import com.vayunmathur.library.ui.OutlinedButton import com.vayunmathur.library.ui.Spacing import com.vayunmathur.library.ui.Text import com.vayunmathur.library.ui.appBarScrollBehavior-import com.vayunmathur.library.ui.game.DailyStreakText-import com.vayunmathur.library.ui.game.GameModeChooser-import com.vayunmathur.library.ui.game.GameTopBarActions  /**  * The garage and the race, with no dependency on the ViewModel so it can be rendered from a@@ -43,43 +39,11 @@ fun KartGameScreen(     state: KartUiState,     phase: RacePhase,     actions: KartGameActions,-    onOpenSettings: () -> Unit,-    onOpenGameCenter: () -> Unit, ) {-    val daily = state.mode == GameMode.DAILY     AppScaffold(-        title = {-            GameModeChooser(-                selected = state.mode,-                options = GameMode.entries,-                // The ladder mode folds the cup into its label, so the bar needs no second title.-                label = { mode ->-                    when (mode) {-                        GameMode.CASUAL -> state.cup?.let {-                            stringResource(R.string.cup_title, it.name)-                        } ?: stringResource(R.string.app_name)--                        GameMode.DAILY -> stringResource(R.string.mode_daily)-                    }-                },-                menuLabel = { mode ->-                    stringResource(-                        when (mode) {-                            GameMode.CASUAL -> R.string.mode_casual-                            GameMode.DAILY -> R.string.mode_daily-                        },-                    )-                },-                onSelect = actions::setGameMode,-            )-        },+        title = state.cup?.let { stringResource(R.string.cup_title, it.name) }+            ?: stringResource(R.string.app_name),         alignment = AppBarAlignment.Center,-        actions = {-            GameTopBarActions(-                onOpenGameCenter = onOpenGameCenter,-                onOpenSettings = onOpenSettings,-            )-        },         scrollBehavior = appBarScrollBehavior(),     ) { padding ->         Column(@@ -91,12 +55,8 @@ fun KartGameScreen(             horizontalAlignment = Alignment.CenterHorizontally,             verticalArrangement = Arrangement.spacedBy(Spacing.md),         ) {-            if (daily) {-                DailyStreakText(state.dailyStreak)-            }-             when (val p = phase) {-                is RacePhase.Lobby -> LobbyBody(state, p, daily, actions)+                is RacePhase.Lobby -> LobbyBody(state, p, actions)                 is RacePhase.Countdown -> CountdownBody(p)                 is RacePhase.Racing -> RacingBody(p)                 is RacePhase.Results -> ResultsBody(p, actions)@@ -109,7 +69,6 @@ fun KartGameScreen( private fun LobbyBody(     state: KartUiState,     phase: RacePhase.Lobby,-    daily: Boolean,     actions: KartGameActions, ) {     val cup = state.cup@@ -148,26 +107,16 @@ private fun LobbyBody(                 color = MaterialTheme.colorScheme.onSurfaceVariant,             )         }-        if (daily && state.dailyDone) {-            Text(-                stringResource(R.string.daily_come_back_tomorrow),-                style = MaterialTheme.typography.bodyMedium,-                textAlign = TextAlign.Center,-            )-        } else {-            Button(-                onClick = { actions.startRace() },-                modifier = Modifier.fillMaxWidth(),-            ) { Text(stringResource(R.string.start_race)) }-            if (!daily) {-                Text(-                    stringResource(R.string.how_to_play),-                    style = MaterialTheme.typography.bodySmall,-                    color = MaterialTheme.colorScheme.onSurfaceVariant,-                    textAlign = TextAlign.Center,-                )-            }-        }+        Button(+            onClick = { actions.startRace() },+            modifier = Modifier.fillMaxWidth(),+        ) { Text(stringResource(R.string.start_race)) }+        Text(+            stringResource(R.string.how_to_play),+            style = MaterialTheme.typography.bodySmall,+            color = MaterialTheme.colorScheme.onSurfaceVariant,+            textAlign = TextAlign.Center,+        )     } } 
games/kart/src/main/java/com/vayunmathur/games/kart/ui/SettingsPage.kt
diff --git a/games/kart/src/main/java/com/vayunmathur/games/kart/ui/SettingsPage.kt b/games/kart/src/main/java/com/vayunmathur/games/kart/ui/SettingsPage.ktdeleted file mode 100644index 40c35ec459..0000000000--- a/games/kart/src/main/java/com/vayunmathur/games/kart/ui/SettingsPage.kt+++ /dev/null@@ -1,65 +0,0 @@-package com.vayunmathur.games.kart.ui--import android.Manifest-import android.os.Build-import androidx.compose.runtime.Composable-import androidx.compose.runtime.collectAsState-import androidx.compose.runtime.getValue-import androidx.compose.ui.res.stringResource-import com.vayunmathur.games.kart.platform.KartViewModel-import com.vayunmathur.games.kart.platform.SettingsActions-import com.vayunmathur.games.kart.platform.SettingsUiState-import com.vayunmathur.library.ui.DailyReminderSettingsSection-import com.vayunmathur.library.ui.DetailScaffold-import com.vayunmathur.library.ui.ExperimentalMaterial3Api-import com.vayunmathur.library.ui.R as UiR-import com.vayunmathur.library.ui.appBarScrollBehavior-import com.vayunmathur.library.ui.rememberPermissionRequest--/** Binds [KartViewModel] to the stateless [SettingsScreen]. */-@Composable-fun SettingsPage(viewModel: KartViewModel, onBack: () -> Unit) {-    val reminderEnabled by viewModel.reminderEnabled.collectAsState()-    val reminderMinutes by viewModel.reminderMinutesOfDay.collectAsState()-    val requestNotifications = rememberPermissionRequest(Manifest.permission.POST_NOTIFICATIONS)--    SettingsScreen(-        state = SettingsUiState(-            reminderEnabled = reminderEnabled,-            reminderHour = (reminderMinutes / 60).toInt(),-            reminderMinute = (reminderMinutes % 60).toInt(),-        ),-        actions = object : SettingsActions {-            override fun setReminderEnabled(enabled: Boolean) {-                // Asked for lazily, on opt-in only, so the screen never blocks on a prompt.-                if (enabled && Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {-                    requestNotifications()-                }-                viewModel.setReminderEnabled(enabled)-            }--            override fun setReminderTime(hour: Int, minute: Int) =-                viewModel.setReminderTime(hour, minute)-        },-        onBack = onBack,-    )-}--/** The settings screen, ViewModel-free so a preview can render it. */-@OptIn(ExperimentalMaterial3Api::class)-@Composable-fun SettingsScreen(state: SettingsUiState, actions: SettingsActions, onBack: () -> Unit) {-    DetailScaffold(-        title = stringResource(UiR.string.settings),-        onNavigateBack = onBack,-        scrollBehavior = appBarScrollBehavior(),-    ) {-        DailyReminderSettingsSection(-            enabled = state.reminderEnabled,-            hour = state.reminderHour,-            minute = state.reminderMinute,-            onEnabledChange = { actions.setReminderEnabled(it) },-            onTimeChange = { hour, minute -> actions.setReminderTime(hour, minute) },-        )-    }-}
games/kart/src/main/res/values/strings.xml
diff --git a/games/kart/src/main/res/values/strings.xml b/games/kart/src/main/res/values/strings.xmlindex db38c34e5f..11cbfe910f 100644--- a/games/kart/src/main/res/values/strings.xml+++ b/games/kart/src/main/res/values/strings.xml@@ -3,11 +3,6 @@     <!-- Manifest / TopAppBar: App name. Noun, singular -->     <string name="app_name" translatable="false">Kart</string> -    <!-- GameModeDropdown: Mode playing the cup progression. Noun plural -->-    <string name="mode_casual">Cups</string>-    <!-- GameModeDropdown: Mode playing today's shared event. Adjective -->-    <string name="mode_daily">Daily</string>-     <!-- KartGameScreen TopAppBar: Current cup in the progression. %1$s = cup name, e.g. Mushroom Cup -->     <string name="cup_title"><xliff:g id="cup" example="Mushroom Cup">%1$s</xliff:g></string>     <!-- KartGameScreen: How many tracks this cup holds. %1$d = track count, e.g. 4 -->@@ -18,8 +13,6 @@     <string name="start_race">Start Race</string>     <!-- KartGameScreen: Shown while the cup has not loaded yet. Sentence -->     <string name="garage_loading">Warming up the engines…</string>-    <!-- KartGameScreen: Shown after clearing the daily, since there is only one per day. Sentence -->-    <string name="daily_come_back_tomorrow">Finished! Come back tomorrow for a new event.</string>     <!-- KartGameScreen: Hint under the race button explaining what is coming. Sentence -->     <string name="how_to_play">Connect a phone as a controller, or plug in a gamepad</string>     <!-- KartGameScreen: Seats taken in the lobby. %1$d = seat count, e.g. 2 -->
games/kart/src/main/res/xml/data_extraction_rules.xml
diff --git a/games/kart/src/main/res/xml/data_extraction_rules.xml b/games/kart/src/main/res/xml/data_extraction_rules.xmlindex d137deb223..54d0ee53aa 100644--- a/games/kart/src/main/res/xml/data_extraction_rules.xml+++ b/games/kart/src/main/res/xml/data_extraction_rules.xml@@ -1,17 +1,13 @@ <?xml version="1.0" encoding="utf-8"?> <!--   Kart. Audited state: filesDir/datastore/settings.preferences_pb, holding the-  current cup, the lifetime cleared/won counters, the best lap, and the daily-  day it belongs to; plus filesDir/datastore_default.preferences_pb, the shared-  DataStoreUtils file holding the DailyChallengeStore("kart_daily") streak, the-  daily reminder settings and the AchievementsManager unlocks. No-  SharedPreferences, no Room database, nothing written to external storage --  achievements.json is a read-only APK asset. Back everything up; it is a few-  KB of pure user progress.+  current cup, the lifetime won counter and the best lap. No+  SharedPreferences, no Room database, nothing written to external storage.+  Back everything up; it is a few KB of pure user progress.   SCOPE: kart declares android:backupAgent=".platform.AppBackupAgent" and does   NOT set android:fullBackupOnly, so Android uses key/value backup and the   <cloud-backup> section below is NOT consulted. Cloud content is exactly-  AppBackupAgent's datastoreNames = ["settings", "datastore_default"], which is+  AppBackupAgent's datastoreNames = ["settings"], which is   the same data this file would have sent. <device-transfer> IS governed here,   and these rules become the cloud control too if the backupAgent is ever   removed.
games/kart/src/screenshotTest/kotlin/com/vayunmathur/games/kart/MetadataPreviews.kt
diff --git a/games/kart/src/screenshotTest/kotlin/com/vayunmathur/games/kart/MetadataPreviews.kt b/games/kart/src/screenshotTest/kotlin/com/vayunmathur/games/kart/MetadataPreviews.ktindex 2485a5c8c5..212dd53484 100644--- a/games/kart/src/screenshotTest/kotlin/com/vayunmathur/games/kart/MetadataPreviews.kt+++ b/games/kart/src/screenshotTest/kotlin/com/vayunmathur/games/kart/MetadataPreviews.kt@@ -4,7 +4,6 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.tooling.preview.Preview import com.android.tools.screenshot.PreviewTest import com.vayunmathur.games.kart.data.CUPS-import com.vayunmathur.games.kart.data.GameMode import com.vayunmathur.games.kart.data.KartProgress import com.vayunmathur.games.kart.platform.KartGameActions import com.vayunmathur.games.kart.platform.KartUiState@@ -68,7 +67,7 @@ class MetadataPreviews {         Garage(             KartUiState(                 cup = CUPS[2],-                progress = KartProgress(currentCup = 2, cupsCleared = 2, racesWon = 11),+                progress = KartProgress(currentCup = 2, racesWon = 11),             ),             RacePhase.Lobby(                 LobbyState(@@ -79,30 +78,14 @@ class MetadataPreviews {         )     } -    @PreviewTest-    @Preview(name = "4-daily", device = PHONE, showSystemUi = true)-    @Composable-    fun Preview4Daily() {-        Garage(-            KartUiState(-                cup = CUPS[1],-                mode = GameMode.DAILY,-            ),-            RacePhase.Lobby(LobbyState(gameId = "kart")),-            streak = 4,-        )-    }-     @Composable-    private fun Garage(state: KartUiState, phase: RacePhase, streak: Long = 0) {+    private fun Garage(state: KartUiState, phase: RacePhase) {         // Layoutlib has no wallpaper to sample, so Material You falls back to the default palette.         DynamicTheme(darkTheme = true) {             KartGameScreen(-                state = state.copy(dailyStreak = streak),+                state = state,                 phase = phase,                 actions = KartGameActions.Noop,-                onOpenSettings = {},-                onOpenGameCenter = {},             )         }     }