Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ dependencies {
implementation 'com.squareup.okhttp3:okhttp:5.3.2'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2'
implementation project(':shared:polaris:model')
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3'
implementation 'org.jmdns:jmdns:3.6.3'
implementation 'com.github.cgutman:ShieldControllerExtensions:1.0.1'
implementation 'com.google.code.gson:gson:2.13.2'
Expand Down
30 changes: 0 additions & 30 deletions app/lint-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6052,16 +6052,6 @@
column="25"/>
</issue>

<issue
id="UseKtx"
message="Use the KTX extension function `ViewGroup.isNotEmpty` instead?"
errorLine1=" if (genreContainer.childCount > 0) params.marginStart = 8"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/com/papi/nova/ui/NovaGameDetailSheet.kt"
line="102"
column="21"/>
</issue>

<issue
id="UseKtx"
Expand Down Expand Up @@ -6228,27 +6218,7 @@
column="25"/>
</issue>

<issue
id="SetTextI18n"
message="Do not concatenate text displayed with `setText`. Use resource string with placeholders."
errorLine1=" lastPlayed.text = &quot;Last played: ${fmt.format(date)}&quot;"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/com/papi/nova/ui/NovaGameDetailSheet.kt"
line="112"
column="31"/>
</issue>

<issue
id="SetTextI18n"
message="String literal in `setText` can not be translated. Use Android resources instead."
errorLine1=" lastPlayed.text = &quot;Last played: ${fmt.format(date)}&quot;"
errorLine2=" ~~~~~~~~~~~~~">
<location
file="src/main/java/com/papi/nova/ui/NovaGameDetailSheet.kt"
line="112"
column="32"/>
</issue>

<issue
id="SetTextI18n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import org.junit.runner.RunWith
import java.util.concurrent.atomic.AtomicReference

@RunWith(AndroidJUnit4::class)
class NovaGameDetailSheetComposeTest {
class NovaGameDetailComposeTest {
@get:Rule
val activityRule = ActivityScenarioRule(ComponentActivity::class.java)

Expand Down Expand Up @@ -57,7 +57,7 @@ class NovaGameDetailSheetComposeTest {
composeViewRef.set(composeView)
composeView.setContent {
NovaComposeTheme {
NovaGameDetailSheetContent(
NovaGameDetailContent(
uiState = uiState,
launchIntro = "Virtual Display is currently the default for this Polaris server.",
recommendedBadge = "Rec. Virtual",
Expand All @@ -81,7 +81,6 @@ class NovaGameDetailSheetComposeTest {
headlessModeLabel = "Headless",
virtualDisplayModeLabel = "Virtual Display",
coverContentDescription = "Game cover art",
onSheetHandleDismiss = {},
onPrimaryLaunch = {},
onLaunchOptions = {},
onLaunchModeSelected = {},
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,11 @@
android:theme="@style/AppTheme"
android:exported="false" />

<activity
android:name="com.papi.nova.ui.NovaGameDetailActivity"
android:theme="@style/AppTheme"
android:exported="false" />

<activity
android:name="com.papi.nova.ui.NovaQrScanActivity"
android:theme="@style/AppTheme"
Expand Down
28 changes: 28 additions & 0 deletions app/src/main/java/com/papi/nova/api/PolarisGameJson.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.papi.nova.api

import com.papi.nova.shared.polaris.model.PolarisGame
import kotlinx.serialization.json.Json

/**
* Round-trips a [PolarisGame] through JSON so it can travel in an Intent.
*
* [PolarisGameJsonAdapter] only reads, because until now games only ever arrived from the
* Polaris API. Handing one to another Activity needs the other direction, and the model is
* already `@Serializable`, so its generated serializer does the work rather than a
* hand-written mirror of the adapter that could drift away from it.
*/
object PolarisGameJson {
private val json = Json {
ignoreUnknownKeys = true
encodeDefaults = true
}

fun encode(game: PolarisGame): String = json.encodeToString(PolarisGame.serializer(), game)

/** Returns null rather than throwing: a malformed extra should close the window, not crash it. */
fun decode(raw: String): PolarisGame? = try {
json.decodeFromString(PolarisGame.serializer(), raw)
} catch (_: Exception) {
null
}
}
Loading
Loading