games-kart: fix all lint findings
- Commit
fb24ffcbc1c8f3f1a4bc754a5d813e91a3c31e6c- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-17 04:48 UTC (19 days ago)
- Parents
a917eae
Fix the six own-module lint warnings in games/kart (0 errors / 0 warnings for games/kart/** after; remaining report warnings are in library/** and ignored per scope): - NotificationPermission (AndroidManifest): add POST_NOTIFICATIONS, as the library MaNotifications usage requires it when targeting Android 13+. - LeanbackUsesWifi (AndroidManifest:12): add <uses-feature android:name="android.hardware.wifi" android:required="false" />, exactly as the lint explanation prescribes and as cast/tv already does. Kart only inspects wifi state; Ethernet-only TVs must stay installable. No suppression: wifi is genuinely not required. - VectorRaster (drawable/banner.xml:6): cap intrinsic size from 320x180dp to 200x112.5dp (<=200dp limit, 16:9 aspect preserved) while keeping viewportWidth/Height 320x180, so glyph geometry and TV-row rendering scale identically and no raster generation regression is introduced. No suppression: the smaller intrinsic size is the real fix; the banner is a vector, not a fixed 320x180 bitmap. - PluralsCandidate (values/strings.xml:9,11,19): convert cup_tracks, races_won and lobby_seats from string to plurals (one/other), update KartGameScreen to pluralStringResource(R.plurals.*, count, count), and update KartGameScreenTest to getQuantityString via a plural() helper. lobby_seats also drops the "(s)" wording. Verification: - Baseline: 6 own warnings (NotificationPermission, LeanbackUsesWifi, VectorRaster, 3x PluralsCandidate). - /tmp/run-gradle-f-kart.sh :games:kart:lintDev :games:kart:testDevUnitTest: BUILD SUCCESSFUL. - Lint SARIF parsed: 0 results under games/kart/** (report total 0 errors, 75 warnings, all in library/**). - Unit tests: 71 tests, 0 failures/errors, 0 skipped. No lint config, baseline or suppression was added; all fixes are in code/manifest/resources under games/kart only.
Diff
games/kart/src/main/AndroidManifest.xml
diff --git a/games/kart/src/main/AndroidManifest.xml b/games/kart/src/main/AndroidManifest.xmlindex 8e1371d799..da9cfb734d 100644--- a/games/kart/src/main/AndroidManifest.xml+++ b/games/kart/src/main/AndroidManifest.xml@@ -11,6 +11,7 @@ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.ACCESS_LOCAL_NETWORK" />+ <uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> <!-- TV launcher presence: leanback declares this a TV app, touchscreen is optional (D-pad + phones-as-controllers are the inputs). Mirrors cast/tv. -->@@ -20,6 +21,11 @@ <uses-feature android:name="android.hardware.touchscreen" android:required="false" />+ <!-- Wifi is only inspected (ACCESS_WIFI_STATE), not required: Ethernet-only+ TVs must stay installable. Mirrors cast/tv. -->+ <uses-feature+ android:name="android.hardware.wifi"+ android:required="false" /> <application android:allowBackup="true"
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 59e6e45916..cadf1a25b6 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@@ -12,6 +12,7 @@ import androidx.compose.foundation.verticalScroll import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier+import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp@@ -88,13 +89,13 @@ private fun LobbyBody( } } else { Text(- stringResource(R.string.cup_tracks, cup.trackCount),+ pluralStringResource(R.plurals.cup_tracks, cup.trackCount, cup.trackCount), style = MaterialTheme.typography.titleLarge, color = MaterialTheme.colorScheme.primary, ) if (state.progress.racesWon > 0) { Text(- stringResource(R.string.races_won, state.progress.racesWon),+ pluralStringResource(R.plurals.races_won, state.progress.racesWon, state.progress.racesWon), style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant, )@@ -102,7 +103,7 @@ private fun LobbyBody( val seats = phase.lobby.slots.size if (seats > 0) { Text(- stringResource(R.string.lobby_seats, seats),+ pluralStringResource(R.plurals.lobby_seats, seats, seats), style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant, )
games/kart/src/main/res/drawable/banner.xml
diff --git a/games/kart/src/main/res/drawable/banner.xml b/games/kart/src/main/res/drawable/banner.xmlindex 0751032928..1151c7b6ac 100644--- a/games/kart/src/main/res/drawable/banner.xml+++ b/games/kart/src/main/res/drawable/banner.xml@@ -1,10 +1,12 @@ <?xml version="1.0" encoding="utf-8"?>-<!-- TV launcher banner (320x180, xhdpi baseline): dark backdrop with the same- directions_car glyph the adaptive launcher icon uses, so the TV row matches- the phone icon. cast/tv banner.xml is the shape precedent. -->+<!-- TV launcher banner: dark backdrop with the same directions_car glyph the+ adaptive launcher icon uses, so the TV row matches the phone icon.+ cast/tv banner.xml is the shape precedent. Intrinsic size is capped at+ 200x112.5dp (VectorRaster limit, 16:9 preserved); the 320x180 viewport is+ unchanged, so the glyph geometry and TV-row rendering scale identically. --> <vector xmlns:android="http://schemas.android.com/apk/res/android"- android:width="320dp"- android:height="180dp"+ android:width="200dp"+ android:height="112.5dp" android:viewportWidth="320" android:viewportHeight="180"> <path
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 11cbfe910f..fc586c48da 100644--- a/games/kart/src/main/res/values/strings.xml+++ b/games/kart/src/main/res/values/strings.xml@@ -6,9 +6,15 @@ <!-- 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 -->- <string name="cup_tracks"><xliff:g id="count" example="4">%1$d</xliff:g> tracks</string>+ <plurals name="cup_tracks">+ <item quantity="one"><xliff:g id="count" example="1">%1$d</xliff:g> track</item>+ <item quantity="other"><xliff:g id="count" example="4">%1$d</xliff:g> tracks</item>+ </plurals> <!-- KartGameScreen: Lifetime race wins. %1$d = win count, e.g. 6 -->- <string name="races_won"><xliff:g id="count" example="6">%1$d</xliff:g> race wins</string>+ <plurals name="races_won">+ <item quantity="one"><xliff:g id="count" example="1">%1$d</xliff:g> race win</item>+ <item quantity="other"><xliff:g id="count" example="6">%1$d</xliff:g> race wins</item>+ </plurals> <!-- KartGameScreen: Starts the race flow. Verb phrase --> <string name="start_race">Start Race</string> <!-- KartGameScreen: Shown while the cup has not loaded yet. Sentence -->@@ -16,7 +22,10 @@ <!-- 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 -->- <string name="lobby_seats"><xliff:g id="count" example="2">%1$d</xliff:g> driver(s) in the lobby</string>+ <plurals name="lobby_seats">+ <item quantity="one"><xliff:g id="count" example="1">%1$d</xliff:g> driver in the lobby</item>+ <item quantity="other"><xliff:g id="count" example="2">%1$d</xliff:g> drivers in the lobby</item>+ </plurals> <!-- KartGameScreen: Shown during the countdown. Sentence --> <string name="countdown_hint">Get ready… controls go live at GO</string> <!-- KartGameScreen: Current lap in the race. %1$d = current lap, e.g. 2. %2$d = total laps, e.g. 3 -->
games/kart/src/test/java/com/vayunmathur/games/kart/ui/KartGameScreenTest.kt
diff --git a/games/kart/src/test/java/com/vayunmathur/games/kart/ui/KartGameScreenTest.kt b/games/kart/src/test/java/com/vayunmathur/games/kart/ui/KartGameScreenTest.ktindex 3f0101d707..98de4ef567 100644--- a/games/kart/src/test/java/com/vayunmathur/games/kart/ui/KartGameScreenTest.kt+++ b/games/kart/src/test/java/com/vayunmathur/games/kart/ui/KartGameScreenTest.kt@@ -25,6 +25,7 @@ class KartGameScreenTest { @get:Rule val rule = createComposeRule() private val ctx get() = ApplicationProvider.getApplicationContext<android.content.Context>() private fun str(id: Int, vararg args: Any) = ctx.getString(id, *args)+ private fun plural(id: Int, count: Int) = ctx.resources.getQuantityString(id, count, count) private class RecordingActions : KartGameActions { var starts = 0@@ -57,9 +58,9 @@ class KartGameScreenTest { ) } rule.onNodeWithText(str(R.string.cup_title, "Flower Cup")).assertIsDisplayed()- rule.onNodeWithText(str(R.string.cup_tracks, 4)).assertIsDisplayed()- rule.onNodeWithText(str(R.string.races_won, 3)).assertIsDisplayed()- rule.onNodeWithText(str(R.string.lobby_seats, 2)).assertIsDisplayed()+ rule.onNodeWithText(plural(R.plurals.cup_tracks, 4)).assertIsDisplayed()+ rule.onNodeWithText(plural(R.plurals.races_won, 3)).assertIsDisplayed()+ rule.onNodeWithText(plural(R.plurals.lobby_seats, 2)).assertIsDisplayed() rule.onNodeWithText(str(R.string.how_to_play)).assertIsDisplayed() rule.onNodeWithText(str(R.string.start_race)).performClick() assertEquals(1, actions.starts)@@ -75,7 +76,7 @@ class KartGameScreenTest { ) } rule.onNodeWithText(str(R.string.start_race)).assertIsDisplayed()- rule.onNodeWithText(str(R.string.races_won, 0)).assertDoesNotExist()+ rule.onNodeWithText(plural(R.plurals.races_won, 0)).assertDoesNotExist() } @Test fun countdownShowsNumberAndHint() {