-
-
Notifications
You must be signed in to change notification settings - Fork 357
feat: steam achievements viewer (updated #1511) #1695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
VinceBT
wants to merge
10
commits into
utkarshdalal:master
Choose a base branch
from
VinceBT:feat/steam-achievements
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,144
−96
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5e7ce25
Add Steam achievements viewer
VinceBT 5fab9f7
Show achievement progress bars in the achievements dialog
VinceBT 2dab467
Bump JavaSteam to 1.8.0.1-23-SNAPSHOT for achievement progress
VinceBT f8e6d54
Collapse secret achievements and add achievement detail dialog
VinceBT 99caba3
Address PR feedback: pluralize hidden-achievement count, skip failed …
VinceBT 182119f
Make steamLanguageForAppLocale locale-injectable and unit-test the ma…
VinceBT e303269
Merge remote-tracking branch 'upstream/master' into feat/steam-achiev…
VinceBT d254721
Merge branch 'master' into feat/steam-achievements
VinceBT 150ab67
Bump JavaSteam to 1.8.0.1-24-SNAPSHOT for achievement progress
VinceBT 0288ff6
Merge branch 'master' into feat/steam-achievements
VinceBT File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
139 changes: 139 additions & 0 deletions
139
app/src/main/java/app/gamenative/ui/component/InfoCard.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() | ||
| } | ||
|
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), | ||
| 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, | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } | ||
| } |
15 changes: 15 additions & 0 deletions
15
app/src/main/java/app/gamenative/ui/data/DownloadDisplayDetails.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, | ||
| ) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.