-
-
Notifications
You must be signed in to change notification settings - Fork 270
feat: add How Long To Beat stats strip to game pages #1282
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
xXJSONDeruloXx
wants to merge
15
commits into
utkarshdalal:master
Choose a base branch
from
xXJSONDeruloXx:feat/hltb-stats
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.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
34a1c2d
feat: add How Long To Beat stats to game pages
xXJSONDeruloXx 3e3a69d
fix: use HttpURLConnection for HLTB search POST to avoid CDN 404
xXJSONDeruloXx 2dbb586
refactor: shrink HLTB implementation to ~260 lines
xXJSONDeruloXx 0450dd8
feat: move HLTB stats to hero strip above play button
xXJSONDeruloXx c2271db
feat: add HLTB link button to hero strip
xXJSONDeruloXx a84cb06
fix: hltb service robustness — IO dispatcher, timeouts, CancellationE…
xXJSONDeruloXx 35d059b
refactor: address phobos review — thread-safe cache, naming, tests, t…
xXJSONDeruloXx def120d
fix: address follow-up hltb review comments
xXJSONDeruloXx 0c99c2f
fix: address remaining hltb review feedback
xXJSONDeruloXx c5f1bfa
test: reduce HLTB test boilerplate
xXJSONDeruloXx 9b78bec
Merge remote-tracking branch 'upstream/master' into feat/hltb-stats
xXJSONDeruloXx a4e9abb
merge: resolve conflicts with upstream/master
xXJSONDeruloXx a57235e
fix: resolve hltb stats conflicts with upstream
xXJSONDeruloXx 2fd6930
chore: merge upstream/master into feat/hltb-stats
xXJSONDeruloXx 36175d6
Merge remote-tracking branch 'upstream/master' into feat/hltb-stats
xXJSONDeruloXx 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
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
88 changes: 88 additions & 0 deletions
88
app/src/main/java/app/gamenative/ui/screen/library/components/HltbHeroStrip.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,88 @@ | ||
| package app.gamenative.ui.screen.library.components | ||
|
|
||
| import android.content.ActivityNotFoundException | ||
| import android.content.Intent | ||
| import android.net.Uri | ||
| import androidx.compose.foundation.background | ||
| import androidx.compose.foundation.layout.Arrangement | ||
| import androidx.compose.foundation.layout.Column | ||
| import androidx.compose.foundation.layout.Row | ||
| import androidx.compose.foundation.layout.fillMaxWidth | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.foundation.layout.size | ||
| import androidx.compose.foundation.shape.RoundedCornerShape | ||
| import androidx.compose.material.icons.Icons | ||
| import androidx.compose.material.icons.automirrored.filled.OpenInNew | ||
| import androidx.compose.material3.Icon | ||
| import androidx.compose.material3.IconButton | ||
| import androidx.compose.material3.MaterialTheme | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.draw.clip | ||
| import androidx.compose.ui.graphics.Color | ||
| import androidx.compose.ui.platform.LocalContext | ||
| import androidx.compose.ui.res.stringResource | ||
| import androidx.compose.ui.text.font.FontWeight | ||
| import androidx.compose.ui.text.style.TextAlign | ||
| import androidx.compose.ui.unit.dp | ||
| import app.gamenative.R | ||
| import app.gamenative.utils.HltbService | ||
| import timber.log.Timber | ||
|
|
||
| @Composable | ||
| fun HltbHeroStrip(stats: HltbService.Stats) { | ||
| val context = LocalContext.current | ||
| Row( | ||
| modifier = Modifier | ||
| .fillMaxWidth() | ||
| .clip(RoundedCornerShape(12.dp)) | ||
| .background(Color.Black.copy(alpha = 0.45f)) | ||
| .padding(horizontal = 8.dp, vertical = 6.dp), | ||
| horizontalArrangement = Arrangement.SpaceEvenly, | ||
| verticalAlignment = Alignment.CenterVertically, | ||
| ) { | ||
| listOf( | ||
| stringResource(R.string.hltb_main_story) to stats.mainHours, | ||
| stringResource(R.string.hltb_main_plus_extras) to stats.mainPlusHours, | ||
| stringResource(R.string.hltb_completionist) to stats.completeHours, | ||
| stringResource(R.string.hltb_all_styles) to stats.allStylesHours, | ||
| ).forEach { (label, hours) -> | ||
| Column(horizontalAlignment = Alignment.CenterHorizontally) { | ||
| Text( | ||
| text = if (hours == "--") "--" else "${hours}h", | ||
| style = MaterialTheme.typography.titleSmall.copy(fontWeight = FontWeight.Bold), | ||
| color = Color.White, | ||
| ) | ||
| Text( | ||
| text = label, | ||
| style = MaterialTheme.typography.labelSmall, | ||
| color = Color.White.copy(alpha = 0.7f), | ||
| textAlign = TextAlign.Center, | ||
| ) | ||
| } | ||
| } | ||
| if (stats.gameId > 0) { | ||
| IconButton( | ||
| onClick = { | ||
| try { | ||
| context.startActivity( | ||
| Intent(Intent.ACTION_VIEW, Uri.parse("${HltbService.GAME_URL}${stats.gameId}")) | ||
| ) | ||
| } catch (e: ActivityNotFoundException) { | ||
| Timber.tag("HLTB").w(e, "No handler for HLTB game URL") | ||
| } | ||
| }, | ||
| modifier = Modifier.size(48.dp), | ||
| ) { | ||
| Icon( | ||
| imageVector = Icons.AutoMirrored.Filled.OpenInNew, | ||
| contentDescription = stringResource(R.string.hltb_view_on_hltb), | ||
| tint = Color.White.copy(alpha = 0.7f), | ||
| modifier = Modifier.size(18.dp), | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| } | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Icon click risks crash and has an undersized touch target.
Two concerns on the external-link icon:
context.startActivity(Intent.ACTION_VIEW, …)can throwActivityNotFoundExceptionon devices without a browser/handler (e.g., stripped-down Android TV images). Wrap the call in a try/catch so a missing handler doesn't crash the app.minimumInteractiveComponentSize()/IconButton, or wrapping in a 48dp clickableBox) and adding aRole.Buttonsemantic for accessibility.♻️ Proposed refactor
📝 Committable suggestion
🤖 Prompt for AI Agents