Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
5e7ce25
Add Steam achievements viewer
VinceBT Jul 12, 2026
5fab9f7
Show achievement progress bars in the achievements dialog
VinceBT Jul 13, 2026
2dab467
Bump JavaSteam to 1.8.0.1-23-SNAPSHOT for achievement progress
VinceBT Jul 13, 2026
f8e6d54
Collapse secret achievements and add achievement detail dialog
VinceBT Jul 13, 2026
99caba3
Address PR feedback: pluralize hidden-achievement count, skip failed …
VinceBT Jul 13, 2026
182119f
Make steamLanguageForAppLocale locale-injectable and unit-test the ma…
VinceBT Jul 14, 2026
e303269
Merge remote-tracking branch 'upstream/master' into feat/steam-achiev…
VinceBT Jul 14, 2026
d254721
Merge branch 'master' into feat/steam-achievements
VinceBT Jul 17, 2026
150ab67
Bump JavaSteam to 1.8.0.1-24-SNAPSHOT for achievement progress
VinceBT Jul 17, 2026
0288ff6
Merge branch 'master' into feat/steam-achievements
VinceBT Jul 30, 2026
96a9ba3
Merge branch 'master' into feat/steam-achievements
VinceBT Aug 16, 2026
308429b
Merge branch 'master' into feat/steam-achievements
VinceBT Aug 26, 2026
88b6e38
:recycle: Move achievement fetching behind storefront hooks
VinceBT Aug 26, 2026
1bca205
:sparkles: Show achievement progress as a bar on the game page
VinceBT Aug 26, 2026
36fb0e4
:bug: Restore the narrower focus ring on info cards
VinceBT Aug 26, 2026
a371711
:bug: Ignore nameless blocks in the English achievement fallback
VinceBT Aug 26, 2026
2fb880e
:bug: Keep an empty gradient color list from crashing the progress bar
VinceBT Aug 31, 2026
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
57 changes: 57 additions & 0 deletions app/src/main/java/app/gamenative/service/SteamService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.net.NetworkCapabilities
import android.net.NetworkRequest
import android.os.IBinder
import android.util.Base64
import app.gamenative.ui.data.Achievement
import app.gamenative.ui.util.GameInviteNotificationManager
import app.gamenative.ui.util.SnackbarManager
import app.gamenative.service.callback.GameInviteCallback
Expand Down Expand Up @@ -168,6 +169,7 @@ import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import kotlinx.coroutines.TimeoutCancellationException
import kotlinx.coroutines.withTimeout
import timber.log.Timber
import app.gamenative.data.DownloadingAppInfo
Expand Down Expand Up @@ -3195,6 +3197,61 @@ class SteamService : Service(), IChallengeUrlChanged {
}
}

suspend fun fetchAchievementsForDisplay(appId: Int): List<Achievement>? {
Comment thread
VinceBT marked this conversation as resolved.
if (!isConnected) return null
return try {
withTimeout(15_000) {
val steamUser = instance?._steamUser ?: return@withTimeout null
val userStats = instance?._steamUserStats?.getUserStats(appId, steamUser.steamID!!)?.await() ?: return@withTimeout null
// Failed fetch (e.g. transient CM error): return null so the caller can retry.
if (userStats.result != EResult.OK) return@withTimeout null
val baseIconUrl = SteamUtils.getBaseAchievementIconUrl(appId)
val appLanguage = SteamUtils.steamLanguageForAppLocale()
val localized = userStats.getExpandedAchievements(appLanguage)
// Parse the English schema lazily: only achievements missing a localized name or
// description need it, so fully-localized games never pay for the extra parse.
val englishByName by lazy {
if (appLanguage == "english") {
emptyMap()
} else {
// A nameless block can't be matched, and its null key would swallow
// every lookup.
userStats.getExpandedAchievements("english")
.associateBy { it.name }
.filterKeys { it != null }
}
}
localized.map { block ->
fun english() = englishByName[block.name]
Achievement(
displayName = block.displayName?.takeIf { it.isNotBlank() }
?: english()?.displayName?.takeIf { it.isNotBlank() }
?: block.name ?: "",
name = block.name,
isUnlocked = block.isUnlocked,
description = block.description?.takeIf { it.isNotBlank() }
?: english()?.description?.takeIf { it.isNotBlank() }
?: "",
unlockTimestamp = block.unlockTimestamp,
hidden = block.hidden,
icon = if (!block.icon.isNullOrEmpty()) "$baseIconUrl${block.icon}" else "",
iconGray = if (!block.iconGray.isNullOrEmpty()) "$baseIconUrl${block.iconGray}" else null,
progressCurrent = block.progressCurrent,
progressMax = block.progressMax,
)
}
}
} catch (e: TimeoutCancellationException) {
Timber.w("fetchAchievementsForDisplay timed out for appId=$appId")
null
} catch (e: CancellationException) {
throw e
} catch (e: Exception) {
Timber.e(e, "fetchAchievementsForDisplay failed for appId=$appId")
null
}
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
}
Comment thread
VinceBT marked this conversation as resolved.

Comment thread
coderabbitai[bot] marked this conversation as resolved.
suspend fun generateAchievements(appId: Int, configDirectory: String) {
val steamUser = instance!!._steamUser!!
val userStats = instance?._steamUserStats!!.getUserStats(appId, steamUser.steamID!!).await()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package app.gamenative.ui.component

import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.CornerRadius
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import app.gamenative.ui.theme.BrandGradient

/**
* Rounded progress bar drawn as one continuous track with the fill over it, so the unfilled part
* reads as the same bar. The gradient spans the whole bar, so its colors hold still as the fill
* grows. A single entry in [colors] gives a flat fill.
*/
@Composable
fun GradientProgressBar(
progress: Float,
modifier: Modifier = Modifier,
height: Dp = 6.dp,
colors: List<Color> = BrandGradient,
trackColor: Color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.15f),
) {
val fraction = progress.coerceIn(0f, 1f)
Canvas(
modifier = modifier
.fillMaxWidth()
.height(height),
) {
val radius = CornerRadius(size.height / 2f)
drawRoundRect(color = trackColor, cornerRadius = radius)
if (fraction > 0f) {
// Keep a barely-started fill from collapsing into a lens shape.
val fillWidth = (size.width * fraction).coerceAtLeast(size.height)
drawRoundRect(
brush = if (colors.size > 1) {
Brush.horizontalGradient(colors = colors, startX = 0f, endX = size.width)
} else {
SolidColor(colors.firstOrNull() ?: trackColor)
},
size = Size(fillWidth, size.height),
cornerRadius = radius,
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
)
}
}
}
139 changes: 139 additions & 0 deletions app/src/main/java/app/gamenative/ui/component/InfoCard.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
@file:OptIn(ExperimentalFoundationApi::class)

package app.gamenative.ui.component

import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.focusable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsFocusedAsState
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.relocation.BringIntoViewRequester
import androidx.compose.foundation.relocation.bringIntoViewRequester
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp

/**
* Labelled card showing [label] over either a [value] string or arbitrary [content].
* [focusableForNavigation] makes it a D-pad focus stop; [onClick] makes it clickable. Either adds the [focusRing].
*/
@Composable
fun InfoCard(
label: String,
modifier: Modifier = Modifier,
value: String? = null,
statusColor: Color? = null,
isCompact: Boolean = false,
focusableForNavigation: Boolean = false,
onClick: (() -> Unit)? = null,
content: (@Composable ColumnScope.() -> Unit)? = null,
) {
val shape = RoundedCornerShape(16.dp)
val interactionSource = remember { MutableInteractionSource() }
val isFocused by interactionSource.collectIsFocusedAsState()
val bringIntoViewRequester = remember { BringIntoViewRequester() }

LaunchedEffect(isFocused) {
if (isFocused) bringIntoViewRequester.bringIntoView()
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

val interactive = when {
// No ripple; the focusRing shows focus and a ripple would bleed past the rounded shape.
onClick != null -> Modifier.clickable(
interactionSource = interactionSource,
indication = null,
onClick = onClick,
)
focusableForNavigation -> Modifier.focusable(interactionSource = interactionSource)
else -> Modifier
}

Surface(
modifier = modifier
.bringIntoViewRequester(bringIntoViewRequester)
.then(interactive)
.focusRing(interactionSource, shape, width = 2.dp),
shape = shape,
color = MaterialTheme.colorScheme.surfaceContainerHigh,
shadowElevation = 2.dp,
) {
Column(
modifier = Modifier.padding(if (isCompact) 14.dp else 18.dp),
) {
Row(verticalAlignment = Alignment.CenterVertically) {
// Only constrain the label when the chevron shares the row; otherwise let it wrap.
val hasChevron = onClick != null
Text(
text = label,
style = MaterialTheme.typography.labelMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant,
fontWeight = FontWeight.Medium,
maxLines = if (hasChevron) 1 else Int.MAX_VALUE,
overflow = if (hasChevron) TextOverflow.Ellipsis else TextOverflow.Clip,
modifier = if (hasChevron) Modifier.weight(1f, fill = false) else Modifier,
)
// Chevron hints the card is tappable.
if (onClick != null) {
Spacer(modifier = Modifier.width(2.dp))
Icon(
imageVector = Icons.AutoMirrored.Filled.KeyboardArrowRight,
contentDescription = null,
tint = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier.size(16.dp),
)
}
}
Spacer(modifier = Modifier.height(6.dp))
if (content != null) {
content()
} else if (value != null) {
Row(verticalAlignment = Alignment.CenterVertically) {
if (statusColor != null) {
Box(
modifier = Modifier
.size(10.dp)
.background(statusColor, CircleShape),
)
Spacer(modifier = Modifier.width(10.dp))
}
Text(
text = value,
style = if (isCompact) {
MaterialTheme.typography.bodyLarge.copy(fontWeight = FontWeight.SemiBold)
} else {
MaterialTheme.typography.titleMedium.copy(fontWeight = FontWeight.SemiBold)
},
color = if (statusColor != null) statusColor else MaterialTheme.colorScheme.onSurface,
maxLines = 2,
overflow = TextOverflow.Ellipsis,
)
}
}
}
}
}
28 changes: 28 additions & 0 deletions app/src/main/java/app/gamenative/ui/data/Achievement.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package app.gamenative.ui.data

data class Achievement(
val displayName: String,
val name: String?,
val isUnlocked: Boolean,
val description: String,
val unlockTimestamp: Int,
val hidden: Boolean,
val icon: String,
val iconGray: String?,
val progressCurrent: Float? = null,
val progressMax: Float? = null,
){
/** True when this achievement tracks partial progress (e.g. 45 / 100). */
val hasProgress: Boolean
get() = progressMax != null && progressMax > 0f

/** (date, time-of-day) of the unlock, both localized; null if never unlocked. */
fun getFormattedUnlockDateTime(): Pair<String, String>? {
if (unlockTimestamp == 0) return null
val locale = java.util.Locale.getDefault()
val millis = java.util.Date(unlockTimestamp * 1000L)
val date = java.text.DateFormat.getDateInstance(java.text.DateFormat.MEDIUM, locale).format(millis)
val time = java.text.DateFormat.getTimeInstance(java.text.DateFormat.SHORT, locale).format(millis)
return date to time
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package app.gamenative.ui.data

/**
* Bundles the download/install flags passed to AppScreenContent. Grouping them keeps the composable's
* parameter count low enough to avoid the ART verifier rejecting the generated method (VerifyError).
*/
data class DownloadDisplayDetails(
val isInstalled: Boolean,
val isValidToDownload: Boolean,
val isDownloading: Boolean,
val downloadProgress: Float,
val hasPartialDownload: Boolean,
val isUpdatePending: Boolean,
val hasLeftoverInstall: Boolean = false,
)
Loading
Loading