feat(library): fold not-installed games under one row, link stores' owned games, and fix card sizes and streaming progress (#2894)

* feat(library): fold not-installed games under one row, link a store's owned games, and make card sizes step

The Library shows installed games first and folds every owned-but-not-installed game
under a "Not installed · N" row that a tap or the A button opens and closes; it replaces
the installed/all-owned choice that sat in the Filter menu, which now only appears for
Xbox's access filters. Controller focus stops on the row between the two sections and
stays on it across a toggle.

A store's profile card turns its "<store> · N games" line into the link to those games
in the Library, replacing the separate text button.

Card sizes pick a column count from the pane width, one column per step, so every
Larger/Smaller step changes the grid; before, several steps landed on the same count
and only stretched the cards.

GOG streams download and install together, and each byte update and each install
update used to flip the entry's stage and reset the install count. The install count
now survives those swaps and the detail page shows both: "Downloading 9% · Installing
25%", with the download as the fill and the install as a thin bar.

The store accounts button uses an accounts icon instead of a second "+", and the
Library tab uses a game controller instead of the video library icon.

* fix(library): a store with nothing installed folds to its Not installed row instead of an empty-state button

With no installed games to show, collapsing used to swap the grid for "No installed games
match these filters" and a Browse owned games button. It now leaves only the Not installed
row, which reopens the list the same way, by tap or by A.

* feat(library): count every owned game in the header and nudge the Not installed arrow

The "N games" next to the Library title counts the games folded under Not installed
too, so a store with nothing installed reads "316 games" instead of "0 games". The
row's arrow hops twice every few seconds toward the way it opens, and at once when the
row takes controller focus; it stays still when animations are off.

* feat(rail): draw the Library tab as game cases on a shelf

Material's video library icon read as a photo or video gallery.

* feat(library): the header counts the whole library, whichever store or filter is picked

* fix(downloads): keep a streaming install's two bars until the download reaches 100%

A download at 99.95% counted as finished, so the install bar disappeared and the fill
swapped between download and install progress for the last stretch.

* fix(downloads): decide a streaming download is finished from its byte counts

A float fraction rounds 99,999,999 of 100,000,000 bytes up to 1.

* feat(downloads): show a streaming install as one bar, downloaded behind installed

Two bars that moved almost together, under a label with both percentages, read as a
glitch. The chip now shows "Installing 61%" with a light fill for what has downloaded and
a solid fill for what has installed, like a video's buffer.

* feat(downloads): the game page shows one steady bar that only fills up

The detail page's chip shows "Installing 62%" from one overall value: the download fills
the first 90% and the install the rest, also when they stream together. The fill never
steps back across stage changes, keeps one animation key per download, and the chip
keeps a minimum width with tabular digits so it does not resize as the number grows. The
Downloads tab keeps its per-stage detail.

* feat(downloads): a full-size progress button on the game page that opens Downloads

The progress chip was a 24 dp pill beside 48 dp buttons. It is now a button the size of
Pause and Cancel, filled as the job advances, with a › that opens the Downloads tab and
sends the fly-in ball to the rail's Downloads item, by touch or A.

The Library card's percent and the bottom-screen download row use the same steady value,
so every place shows one bar that only grows. The overall value keeps the install part
when the last bytes arrive while the stage still reads Download.
This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-11-19 14:57:11 -05:00
1 parent cc93ab51c5
commit 13a6e0606a
13 files changed
+398 -82

No files matched your search

@@ -46,6 +46,26 @@ data class DownloadEntry(
stageItemsTotal > 0 -> (stageItems.toFloat() / stageItemsTotal).coerceIn(0f, 1f)
else -> -1f
}
val downloadFraction: Float get() = if (bytesTotal > 0L) (bytesDone.toDouble() / bytesTotal).toFloat().coerceIn(0f, 1f) else -1f
val installFraction: Float get() = when {
stage != DownloadStage.DOWNLOAD && stage != DownloadStage.INSTALL -> -1f
stageTotal > 0L -> (stageDone.toDouble() / stageTotal).toFloat().coerceIn(0f, 1f)
stageItemsTotal > 0 -> (stageItems.toFloat() / stageItemsTotal).coerceIn(0f, 1f)
else -> -1f
}
val streaming: Boolean get() = state == DownloadState.RUNNING && bytesTotal > 0L && bytesDone < bytesTotal && installFraction >= 0f &&
(stage == DownloadStage.INSTALL || (stage == DownloadStage.DOWNLOAD && passed(DownloadStage.INSTALL)))
/** Whole job as one bar: downloading fills the first 90%, installing the rest, also when they run together. */
val overallFraction: Float get() {
if (state == DownloadState.INSTALLED || stage == DownloadStage.DONE) return 1f
val downloaded = when {
bytesTotal > 0L -> downloadFraction
passed(DownloadStage.DOWNLOAD) -> 1f
else -> 0f
}
val installed = if (stage == DownloadStage.INSTALL || (stage == DownloadStage.DOWNLOAD && passed(DownloadStage.INSTALL))) installFraction.coerceAtLeast(0f) else 0f
return (0.9f * downloaded + 0.1f * installed).coerceIn(0f, 1f)
}
val fraction: Float get() = stageFraction.coerceAtLeast(0f)
val percent: Int get() = (fraction * 100).toInt()
}
@@ -45,13 +45,18 @@ object DownloadQueue {
val e = item.entry
if (e.stage == stage) return
item.speedAt = 0L; item.speedBytes = 0L; item.speedEwma = 0.0
item.entry = e.copy(
stage = stage, stagesPassed = e.stagesPassed or (1 shl e.stage.ordinal), speedBps = 0, etaSeconds = -1,
val passed = e.stagesPassed or (1 shl e.stage.ordinal)
// Streaming installers (GOG) alternate between DOWNLOAD and INSTALL; the install count lives on across the swaps.
val streaming = e.stage in STREAMED && stage in STREAMED && (passed and (1 shl DownloadStage.INSTALL.ordinal)) != 0
item.entry = if (streaming) e.copy(stage = stage, stagesPassed = passed, speedBps = 0, etaSeconds = -1)
else e.copy(
stage = stage, stagesPassed = passed, speedBps = 0, etaSeconds = -1,
stageDone = 0, stageTotal = 0, stageItems = 0, stageItemsTotal = 0,
)
}
private const val SPEED_WINDOW_MS = 3000.0
private val STREAMED = setOf(DownloadStage.DOWNLOAD, DownloadStage.INSTALL)
private fun stageCount(key: String, done: Long, total: Long, files: Int, filesTotal: Int, bytes: Boolean) {
synchronized(lock) {
@@ -100,7 +100,7 @@ fun BottomDownloadsPage() {
formatSpeed(e.speedBps),
).filter { it.isNotEmpty() }.joinToString(" · ")
}
BottomDownloadRow(e.name, e.store.label, detail, e.stageFraction.takeIf { it >= 0f })
BottomDownloadRow(e.name, e.store.label, detail, steadyProgress(e))
}
}
}
@@ -60,7 +60,6 @@ import androidx.compose.material.icons.outlined.SportsEsports
import androidx.compose.material.icons.outlined.Storefront
import androidx.compose.material.icons.outlined.SystemUpdate
import androidx.compose.material.icons.outlined.Tune
import androidx.compose.material.icons.outlined.VideoLibrary
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
@@ -196,7 +195,7 @@ internal fun SideRail(
internal fun railLabelIcon(key: String): Pair<Int, ImageVector> = when (key) {
"steam" -> R.string.rail_steam to Icons.Outlined.SportsEsports
"games" -> R.string.rail_games to Icons.Outlined.VideoLibrary
"games" -> R.string.rail_games to GameShelfIcon
"soundtracks" -> R.string.rail_music to SoundtrackIcon
"stores" -> R.string.rail_stores to Icons.Outlined.LocalMall
"downloads" -> R.string.stores_tab_downloads to Icons.Outlined.Download
@@ -27,6 +27,7 @@ import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
@@ -113,8 +114,8 @@ internal fun Actions(content: @Composable () -> Unit) = FlowRow(
) { content() }
@Composable
internal fun ActionChip(t: String, ok: Boolean, fraction: Float? = null, key: Any? = null) =
Box(contentAlignment = Alignment.Center, modifier = Modifier.heightIn(min = 44.dp)) { Chip(t, ok, fraction, key) }
internal fun ActionChip(t: String, ok: Boolean, fraction: Float? = null, key: Any? = null, minWidth: androidx.compose.ui.unit.Dp = 0.dp) =
Box(contentAlignment = Alignment.Center, modifier = Modifier.heightIn(min = 44.dp)) { Chip(t, ok, fraction, key, minWidth) }
internal val Shape16 = RoundedCornerShape(16.dp)
@@ -141,15 +142,16 @@ internal fun BackLink(label: String, compact: Boolean = false, onClick: () -> Un
}
@Composable
internal fun Chip(t: String, ok: Boolean, fraction: Float? = null, key: Any? = null) {
internal fun Chip(t: String, ok: Boolean, fraction: Float? = null, key: Any? = null, minWidth: androidx.compose.ui.unit.Dp = 0.dp) {
val colors = MaterialTheme.colorScheme
val pal = LocalPalette.current
val shape = RoundedCornerShape(99.dp)
val ink = if (ok) pal.good else colors.onSurfaceVariant
Box(Modifier.clip(shape).background(colors.surfaceVariant).border(1.dp, if (ok) pal.good.copy(alpha = 0.3f) else pal.line, shape)) {
Box(Modifier.widthIn(min = minWidth).clip(shape).background(colors.surfaceVariant).border(1.dp, if (ok) pal.good.copy(alpha = 0.3f) else pal.line, shape), contentAlignment = Alignment.CenterStart) {
if (fraction != null) ChipFill(fraction, key, pal.signal.copy(alpha = 0.3f))
Text(
t, fontSize = 12.sp, color = ink, maxLines = 1, overflow = TextOverflow.Ellipsis,
style = androidx.compose.ui.text.TextStyle(fontFeatureSettings = "tnum"),
modifier = Modifier.padding(horizontal = 9.dp, vertical = 4.dp),
)
}
@@ -1,5 +1,7 @@
package com.droiddeck.launcher.ui
import androidx.compose.foundation.interaction.collectIsPressedAsState
import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight
import android.widget.Toast
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.LocalIndication
@@ -482,7 +484,7 @@ internal fun GameActions(
if (installed != null && id != null) {
LaunchedEffect(id) { BattleNetInstall.checkUpdate(ctx, installed) }
if (download != null) {
ActionChip(downloadLabel(download), ok = false, fraction = download.stageFraction.takeIf { it >= 0f }, key = download.stage)
SteadyDownloadChip(download)
if (download.state != DownloadState.PAUSED) SecondaryButton(stringResource(R.string.stores_dl_pause)) { DownloadQueue.pause(download.key) }
else SecondaryButton(stringResource(R.string.stores_dl_resume)) { DownloadQueue.resume(ctx, download.key) }
} else if (BattleNetInstall.updates[id] == true) {
@@ -497,7 +499,7 @@ internal fun GameActions(
}
}
download != null -> {
ActionChip(downloadLabel(download), ok = false, fraction = download.stageFraction.takeIf { it >= 0f }, key = download.stage)
SteadyDownloadChip(download)
if (download.state != DownloadState.PAUSED) SecondaryButton(stringResource(R.string.stores_dl_pause), modifier = leadOn) { DownloadQueue.pause(download.key) }
else PrimaryButton(stringResource(R.string.stores_dl_resume), main = true, modifier = leadOn) { DownloadQueue.resume(ctx, download.key) }
ConfirmButton(stringResource(R.string.stores_dl_cancel), stringResource(R.string.stores_dl_cancel_confirm)) { DownloadQueue.cancel(ctx, download.key) }
@@ -1146,3 +1148,47 @@ internal object FolderSizes {
}, "folder-size").start()
}
}
@Composable
private fun SteadyDownloadChip(download: com.droiddeck.launcher.stores.download.DownloadEntry) {
val progress = steadyProgress(download)
val label = steadyLabel(download, progress)
val show = LocalShowSection.current
val colors = MaterialTheme.colorScheme
val pal = LocalPalette.current
val shape = if (LocalPillButtons.current) androidx.compose.foundation.shape.CircleShape else Shape12
val src = remember { androidx.compose.foundation.interaction.MutableInteractionSource() }
val hot = rememberHot(src)
val pressed by src.collectIsPressedAsState()
val scale by androidx.compose.animation.core.animateFloatAsState(if (pressed) 0.955f else if (hot) 1.02f else 1f, Motion.sp(0.5f, androidx.compose.animation.core.Spring.StiffnessMedium), label = "dlScale")
val placed = remember { arrayOfNulls<androidx.compose.ui.layout.LayoutCoordinates>(1) }
val description = stringResource(R.string.stores_tab_downloads)
val open = {
placed[0]?.takeIf { it.isAttached }?.boundsInRoot()?.let { StoresMotion.fly(it) }
show("downloads")
}
Box(
contentAlignment = Alignment.CenterStart,
modifier = Modifier.paneItem("detail-download").testTag("detail-download")
.onGloballyPositioned { placed[0] = it }
.widthIn(min = 200.dp).heightIn(min = 48.dp)
.graphicsLayer { scaleX = scale; scaleY = scale }.clip(shape)
.background(Color.White.copy(alpha = 0.04f))
.glideBorder(hot, shape, pal.signal, pal.line2)
.hoverable(src)
.clickable(interactionSource = src, indication = androidx.compose.foundation.LocalIndication.current, role = androidx.compose.ui.semantics.Role.Button, onClickLabel = description, onClick = open)
.controllerConfirm(onClick = open),
) {
ChipFill(progress, download.key, pal.signal.copy(alpha = 0.42f))
Row(
verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier.widthIn(min = 200.dp).padding(start = 16.dp, end = 10.dp),
) {
Text(
label, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 0.5.sp, color = colors.onBackground, maxLines = 1,
style = androidx.compose.ui.text.TextStyle(fontFeatureSettings = "tnum"), modifier = Modifier.padding(end = 8.dp),
)
Icon(androidx.compose.material.icons.Icons.AutoMirrored.Filled.KeyboardArrowRight, description, tint = if (hot) colors.onBackground else colors.onSurfaceVariant, modifier = Modifier.size(20.dp))
}
}
}
@@ -0,0 +1,17 @@
package com.droiddeck.launcher.ui
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.PathFillType
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.addPathNodes
import androidx.compose.ui.unit.dp
internal val GameShelfIcon: ImageVector = ImageVector.Builder("GameShelf", 24.dp, 24.dp, 24f, 24f).apply {
for (d in listOf(
"M3,4H7V20H3ZM4.4,5.4V18.6H5.6V5.4Z",
"M8.5,4H12.5V20H8.5ZM9.9,5.4V18.6H11.1V5.4Z",
"M14.2,5.1L18.1,4.2L21.4,19.8L17.5,20.7ZM15.9,6.2L18.6,18.9L19.8,18.6L17.1,5.9Z",
"M2,21H22V22.5H2Z",
)) addPath(addPathNodes(d), fill = SolidColor(Color.Black), pathFillType = PathFillType.EvenOdd)
}.build()
@@ -19,7 +19,7 @@ import androidx.compose.foundation.verticalScroll
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.ManageAccounts
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
@@ -66,7 +66,7 @@ internal fun StoreAccountsButton() {
placed[0]?.takeIf { it.isAttached }?.boundsInRoot()?.let { at ->
Steps.ask(StepAsk(
anchor = at, side = StepSide.Left, accent = pal.signal, items = storesWithSignIn().size + 1, pillCorner = 20.dp, maxWidth = 380.dp,
handle = { Icon(Icons.Filled.Add, null, tint = pal.signal, modifier = Modifier.size(20.dp)) },
handle = { Icon(Icons.Filled.ManageAccounts, null, tint = pal.signal, modifier = Modifier.size(20.dp)) },
) {
StoreAccountsStep(onSignIn = { store, row ->
Steps.fold()
@@ -92,7 +92,7 @@ internal fun StoreAccountsButton() {
.hoverable(src)
.clickable(interactionSource = src, indication = LocalIndication.current, role = Role.Button, onClickLabel = label, onClick = open)
.controllerConfirm(onClick = open),
) { Icon(Icons.Filled.Add, label, tint = if (hot) colors.onBackground else colors.onSurfaceVariant, modifier = Modifier.size(20.dp)) }
) { Icon(Icons.Filled.ManageAccounts, label, tint = if (hot) colors.onBackground else colors.onSurfaceVariant, modifier = Modifier.size(20.dp)) }
}
}
@@ -41,6 +41,8 @@ import androidx.compose.foundation.selection.selectable
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ExpandLess
import androidx.compose.material.icons.filled.ExpandMore
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.BookmarkBorder
import androidx.compose.material.icons.filled.FilterAlt
@@ -177,8 +179,9 @@ internal fun librarySources(
}
internal object LibraryDisplay {
const val DEFAULT_LEVEL = 2
val scales = listOf(0.75f, 0.875f, 1f, 1.2f, 1.45f)
var level by mutableIntStateOf(2)
var level by mutableIntStateOf(DEFAULT_LEVEL)
private set
var title by mutableStateOf(true)
private set
@@ -215,6 +218,68 @@ internal object LibraryDisplay {
}
}
private enum class ToggleAt { NONE, TOP, SPLIT, BOTTOM }
private const val NOT_INSTALLED_ROW = "library-not-installed"
@Composable
private fun NotInstalledRow(count: Int, expanded: Boolean, keys: Modifier, onFocus: (Boolean) -> Unit, onToggle: () -> Unit) {
val colors = MaterialTheme.colorScheme
val pal = LocalPalette.current
val src = remember { MutableInteractionSource() }
val hot = rememberHot(src)
val shape = RoundedCornerShape(12.dp)
Row(
verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp),
modifier = Modifier.fillMaxWidth().padding(top = 6.dp, bottom = 2.dp).then(keys).paneItem(NOT_INSTALLED_ROW).onFocusChanged { onFocus(it.isFocused) }.testTag(NOT_INSTALLED_ROW)
.heightIn(min = 44.dp).clip(shape)
.background(if (hot) pal.signal.copy(alpha = 0.12f) else Color.Transparent)
.glideBorder(hot, shape, pal.signal, Color.Transparent)
.hoverable(src).clickable(interactionSource = src, indication = LocalIndication.current, role = Role.Button, onClick = onToggle)
.controllerConfirm(onClick = onToggle)
.padding(horizontal = 4.dp, vertical = 8.dp),
) {
Text(
stringResource(R.string.stores_section_not_installed).uppercase() + " · " + count,
fontSize = 12.sp, fontWeight = FontWeight.Bold, letterSpacing = 1.2.sp, color = if (hot) colors.onBackground else colors.onSurfaceVariant, maxLines = 1,
)
Box(Modifier.weight(1f).height(1.dp).background(pal.line))
val hop = remember { androidx.compose.animation.core.Animatable(0f) }
LaunchedEffect(expanded, hot, Motion.scale) {
hop.snapTo(0f)
if (Motion.scale == 0f) return@LaunchedEffect
val toward = if (expanded) -3.5f else 3.5f
kotlinx.coroutines.delay(if (hot) 0L else 1_200L)
while (true) {
repeat(2) {
hop.animateTo(toward, androidx.compose.animation.core.tween(150, easing = androidx.compose.animation.core.FastOutSlowInEasing))
hop.animateTo(0f, androidx.compose.animation.core.spring(dampingRatio = 0.45f, stiffness = androidx.compose.animation.core.Spring.StiffnessMedium))
}
kotlinx.coroutines.delay(3_500L)
}
}
Icon(
if (expanded) Icons.Filled.ExpandLess else Icons.Filled.ExpandMore, stringResource(if (expanded) R.string.library_filter_installed else R.string.library_browse_owned),
tint = if (hot) colors.onBackground else colors.onSurfaceVariant,
modifier = Modifier.size(22.dp).graphicsLayer { translationY = hop.value.dp.toPx() },
)
}
}
internal fun libraryColumns(width: Int, base: Int, gap: Int, level: Int): Int =
(((width + gap) / (base + gap)).coerceAtLeast(1) + LibraryDisplay.DEFAULT_LEVEL - level).coerceAtLeast(1)
private class LevelCells(private val base: androidx.compose.ui.unit.Dp, private val level: Int) : GridCells {
override fun androidx.compose.ui.unit.Density.calculateCrossAxisCellSizes(availableSize: Int, spacing: Int): List<Int> {
val count = libraryColumns(availableSize, base.roundToPx(), spacing, level)
val usable = (availableSize - spacing * (count - 1)).coerceAtLeast(0)
return List(count) { usable / count + if (it < usable % count) 1 else 0 }
}
override fun equals(other: Any?): Boolean = other is LevelCells && other.base == base && other.level == level
override fun hashCode(): Int = 31 * base.hashCode() + level
}
internal object LibraryView {
var source by mutableStateOf(LIBRARY_ALL)
var query by mutableStateOf("")
@@ -305,6 +370,7 @@ internal fun LibraryPage(s: FrontEndState, a: FrontEndActions, selected: String,
}
val collectionItems = collectionId?.let { if (source == Store.GAMEJOLT.id) GameJoltCollections.gamesOf(it) else ItchCollections.gamesOf(it) }
val pool = if (collectionId == null) all else collectionEntries(all, collectionItems.orEmpty(), Store.byId(source) ?: Store.ITCH)
val libraryTotal = if (soundMode) 0 else all.count { inLibrarySource(LIBRARY_ALL, it, favorites, concealed) }
val matching = pool.filter {
inLibrarySource(source, it, favorites, concealed) && (q.isEmpty() || it.title.lowercase().contains(q)) && keepsXbox(xboxFilter, it)
}
@@ -433,7 +499,7 @@ internal fun LibraryPage(s: FrontEndState, a: FrontEndActions, selected: String,
val detailScroll = rememberScrollState()
var cycled by remember { mutableIntStateOf(0) }
var gridFocused by remember { mutableStateOf(false) }
LaunchedEffect(source, sort, listUninstalled) { grid.scrollToItem(0) }
LaunchedEffect(source, sort) { grid.scrollToItem(0) }
LaunchedEffect(cycled) {
if (cycled == 0 || ff == null || inputMode.inputMode != androidx.compose.ui.input.InputMode.Keyboard) return@LaunchedEffect
focusWithinFrames({ gridFocused }) {
@@ -449,7 +515,7 @@ internal fun LibraryPage(s: FrontEndState, a: FrontEndActions, selected: String,
wrap = { key, content -> StoreTheme(GameRef.parse(key).let { r -> r.store ?: r.game(s.steamGames)?.source?.let { Store.byId(it) } }) { content() } },
grid = {
LibraryGrid(
s, a, grid, visible, split, visible.size, sources, source, sizesPending, syncing,
s, a, grid, visible, split, if (soundMode) visible.size else libraryTotal, sources, source, sizesPending, syncing,
showUninstalled = listUninstalled.takeIf { !s.shortcutPicker },onShowUninstalled = setShowUninstalled,
hiddenUninstalled = hiddenUninstalled,
onSource = { LibraryView.source = it },
@@ -517,12 +583,43 @@ private fun LibraryGrid(
) {
val listMode = s.storesView == "list"
val capsules = s.storesView == "capsules"
val tileWidth = (if (capsules) CapsuleWidth else if (listMode) CardWidth else LibraryCardWidth) * LibraryDisplay.scales[LibraryDisplay.level]
val baseWidth = if (capsules) CapsuleWidth else LibraryCardWidth
val level = LibraryDisplay.level
val focus = LocalFrontFocus.current
val scope = rememberCoroutineScope()
val density = androidx.compose.ui.platform.LocalDensity.current
var columns by remember { mutableIntStateOf(1) }
val headerItems = 2 + (if (sizesPending) 1 else 0) + syncing.size
val expanded = showUninstalled == true
val notInstalled = if (expanded) visible.count { !it.installed } else hiddenUninstalled
val toggleAt = when {
showUninstalled == null || soundMode || notInstalled == 0 || (expanded && visible.isEmpty()) -> ToggleAt.NONE
!expanded -> ToggleAt.BOTTOM
split > 0 -> ToggleAt.SPLIT
else -> ToggleAt.TOP
}
val itemIndex: (Int) -> Int = { i ->
headerItems + i + when {
split > 0 -> if (i < split) 1 else 2
toggleAt == ToggleAt.TOP -> 1
else -> 0
}
}
val toggleIndex = when (toggleAt) {
ToggleAt.TOP -> headerItems
ToggleAt.SPLIT -> headerItems + split + 1
else -> headerItems + visible.size
}
val gapPx = with(density) { 10.dp.toPx() }
val moveFocus: (String, Int, Int, Int) -> Unit = { target, targetIndex, currentIndex, direction ->
val shown = grid.layoutInfo.visibleItemsInfo.any { it.index == targetIndex }
if (focus != null && (!shown || (focus.attached[target] ?: 0) == 0 ||
runCatching { focus.items.getValue(target).requestFocus() }.isFailure)) scope.launch {
launch { grid.revealRow(currentIndex, targetIndex, direction, gapPx) }
focusWithinFrames({ focus.last == target }) { focus.items[target] ?: FocusRequester.Default }
}
}
val rowStart: (Int) -> Int? = { i -> if (i < 0) null else if (listMode) i else i - i % columns.coerceAtLeast(1) }
val tile: @Composable (LibraryEntry) -> Unit = { e ->
val first = e.key == visible.firstOrNull()?.key
val navigation = if (focus == null) Modifier else Modifier.onPreviewKeyEvent { event ->
@@ -534,21 +631,21 @@ private fun LibraryGrid(
}
val index = visible.indexOfFirst { it.key == e.key }
val next = storeGridNeighbor(index, visible.size, if (listMode) 1 else columns, direction, split)
val toToggle = index >= 0 && when (toggleAt) {
ToggleAt.BOTTOM -> next == null && direction > 0
ToggleAt.TOP -> next == null && direction < 0
ToggleAt.SPLIT -> next != null && (index < split) != (next < split)
ToggleAt.NONE -> false
}
when {
direction == 0 || index < 0 -> false
toToggle -> {
if (key.action == KeyEvent.ACTION_DOWN) moveFocus(NOT_INSTALLED_ROW, toggleIndex, itemIndex(index), direction)
true
}
next == null -> direction > 0 && trackHits.isEmpty()
else -> {
if (key.action == KeyEvent.ACTION_DOWN) {
val target = "card:${visible[next].key}"
val targetIndex = headerItems + next + if (split == 0) 0 else if (next < split) 1 else 2
val currentIndex = headerItems + index + if (split == 0) 0 else if (index < split) 1 else 2
val shown = grid.layoutInfo.visibleItemsInfo.any { it.index == targetIndex }
if (!shown || (focus.attached[target] ?: 0) == 0 ||
runCatching { focus.items.getValue(target).requestFocus() }.isFailure) scope.launch {
launch { grid.revealRow(currentIndex, targetIndex, direction, with(density) { 10.dp.toPx() }) }
focusWithinFrames({ focus.last == target }) { focus.items[target] ?: FocusRequester.Default }
}
}
if (key.action == KeyEvent.ACTION_DOWN) moveFocus("card:${visible[next].key}", itemIndex(next), itemIndex(index), direction)
true
}
}
@@ -557,12 +654,51 @@ private fun LibraryGrid(
val choose = if (picker) ({ a.onSteamGame(e.game!!) }) else null
if (listMode) LibraryRow(e, first, navigation, choose, onOpen) else LibraryTile(e, capsules, first, navigation, choose, onOpen, showSource = source == LIBRARY_ALL || source == LIBRARY_FAVORITES || source == LIBRARY_HIDDEN)
}
var rowFocused by remember { mutableStateOf(false) }
val toggleRow: @Composable () -> Unit = {
val keys = if (focus == null) Modifier else Modifier.onPreviewKeyEvent { event ->
val key = event.nativeKeyEvent
val direction = when (key.keyCode) {
KeyEvent.KEYCODE_DPAD_DOWN -> 1
KeyEvent.KEYCODE_DPAD_UP -> -1
else -> 0
}
val target = when {
direction > 0 && toggleAt == ToggleAt.TOP -> 0
direction > 0 && toggleAt == ToggleAt.SPLIT -> split
direction < 0 && toggleAt == ToggleAt.SPLIT -> rowStart(split - 1)
direction < 0 && toggleAt == ToggleAt.BOTTOM -> rowStart(visible.lastIndex)
else -> null
}
when {
direction == 0 -> false
target == null -> direction > 0 && toggleAt == ToggleAt.BOTTOM && trackHits.isEmpty()
else -> {
if (key.action == KeyEvent.ACTION_DOWN) moveFocus("card:${visible[target].key}", itemIndex(target), toggleIndex, direction)
true
}
}
}
NotInstalledRow(notInstalled, expanded, keys, onFocus = { rowFocused = it }) {
rowFocused = false
val landing = if (expanded) headerItems + split else headerItems + visible.size + 1
onShowUninstalled(!expanded)
if (focus != null && focus.last == NOT_INSTALLED_ROW) scope.launch {
androidx.compose.runtime.withFrameNanos { }
if (grid.layoutInfo.visibleItemsInfo.none { it.key == NOT_INSTALLED_ROW }) grid.scrollToItem((landing - 1).coerceAtLeast(0))
repeat(30) {
androidx.compose.runtime.withFrameNanos { }
if (rowFocused) return@launch
runCatching { focus.items[NOT_INSTALLED_ROW]?.requestFocus() }
}
}
}
}
LazyVerticalGrid(
columns = if (listMode) GridCells.Fixed(1) else GridCells.Adaptive(tileWidth), state = grid,
columns = if (listMode) GridCells.Fixed(1) else remember(baseWidth, level) { LevelCells(baseWidth, level) }, state = grid,
modifier = Modifier.fillMaxSize().onFocusChanged { onFocus(it.hasFocus) }.focusGroup().bumpers(onPrevious = { onCycle(-1) }, onNext = { onCycle(1) }).onSizeChanged {
val gap = with(density) { 10.dp.roundToPx() }
val minimum = with(density) { (if (listMode) CardWidth * 2 else tileWidth).roundToPx() }
columns = ((it.width + gap) / (minimum + gap)).coerceAtLeast(1)
columns = if (listMode) 1 else libraryColumns(it.width, with(density) { baseWidth.roundToPx() }, gap, level)
},
horizontalArrangement = Arrangement.spacedBy(10.dp), verticalArrangement = Arrangement.spacedBy(10.dp),
contentPadding = PaddingValues(top = 4.dp, bottom = 16.dp),
@@ -587,17 +723,17 @@ private fun LibraryGrid(
}
}
val empty = emptyText
if (visible.isEmpty() && hiddenUninstalled > 0) item(key = "browse-owned", span = { GridItemSpan(maxLineSpan) }) {
Column(horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(12.dp), modifier = Modifier.fillMaxWidth().padding(vertical = 32.dp)) {
Text(stringResource(R.string.library_no_installed_matches), fontSize = 13.sp, color = MaterialTheme.colorScheme.onSurfaceVariant)
SecondaryButton(stringResource(R.string.library_browse_owned), modifier = Modifier.testTag("library-browse-owned")) { onShowUninstalled(true) }
}
if (split == 0) {
if (toggleAt == ToggleAt.TOP) item(key = NOT_INSTALLED_ROW, span = { GridItemSpan(maxLineSpan) }) { toggleRow() }
if (visible.isNotEmpty() || toggleAt == ToggleAt.NONE) libraryGrid(visible, empty, tile)
if (toggleAt == ToggleAt.BOTTOM) item(key = NOT_INSTALLED_ROW, span = { GridItemSpan(maxLineSpan) }) { toggleRow() }
}
else if (split == 0) libraryGrid(visible, empty, tile)
else {
item(key = "installed-label", span = { GridItemSpan(maxLineSpan) }) { SectionLabel(stringResource(R.string.stores_section_installed)) }
libraryGrid(visible.take(split), empty, tile)
item(key = "not-installed-label", span = { GridItemSpan(maxLineSpan) }) { SectionLabel(stringResource(R.string.stores_section_not_installed)) }
item(key = NOT_INSTALLED_ROW, span = { GridItemSpan(maxLineSpan) }) {
if (toggleAt == ToggleAt.SPLIT) toggleRow() else SectionLabel(stringResource(R.string.stores_section_not_installed))
}
libraryGrid(visible.drop(split), empty, tile)
}
if (trackHits.isNotEmpty()) {
@@ -683,7 +819,7 @@ private fun LibraryHeader(
) {
if (soundMode) HeaderIconButton(stringResource(R.string.soundtracks_saved), Icons.Filled.BookmarkBorder, "collections", onClick = onCollections)
DisplayButton()
if (!soundMode && (showUninstalled != null || xbox)) LibraryFilterButton(showUninstalled, onShowUninstalled, xbox)
if (!soundMode && xbox) LibraryFilterButton(null, onShowUninstalled, xbox)
if (collections != null) CollectionsButton(collections)
SortButton(s, a)
ViewButton(s, a)
@@ -792,7 +928,7 @@ internal fun libraryTileWidth() = LibraryCardWidth * LibraryDisplay.scales[Libra
@Composable
private fun LibraryArt(e: LibraryEntry, wide: Any?, tall: Any?, download: DownloadEntry?, hot: Boolean, capsule: Boolean, showSource: Boolean) {
val chip = when {
download != null -> "${download.percent}%"
download != null -> "${(steadyProgress(download) * 100).toInt()}%"
e.item != null && StoresState.isUnfinished(e.item) -> stringResource(R.string.stores_resume)
e.installed && libraryUpdateAvailable(e) -> stringResource(R.string.common_update)
else -> null
@@ -835,7 +971,7 @@ internal fun ArtCard(
)
badge?.invoke(this)
if (chip != null) Box(Modifier.align(Alignment.TopEnd).padding(6.dp)) {
StateChip(chip, ChipTone.BUSY, small = true, fraction = download?.stageFraction?.takeIf { it >= 0f }, key = download?.stage)
StateChip(chip, ChipTone.BUSY, small = true, fraction = download?.let { steadyProgress(it) }, key = download?.key)
}
val showName = LibraryDisplay.title || hot
val showDetail = LibraryDisplay.size || hot
@@ -92,6 +92,7 @@ import androidx.compose.material.icons.filled.Check
import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.Search
import androidx.compose.material.icons.automirrored.filled.Login
import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight
import androidx.compose.foundation.basicMarquee
import androidx.compose.material.icons.filled.Settings
import androidx.compose.material.icons.outlined.Download
@@ -927,16 +928,13 @@ private fun ProfileStrip(store: Store, owned: Int, loaded: Boolean, s: FrontEndS
}
Column(Modifier.weight(1f)) {
Text(name.ifEmpty { store.label }, fontSize = 15.sp, fontWeight = FontWeight.Bold, color = colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis)
Text(
if (loaded) store.shortLabel + " · " + androidx.compose.ui.res.pluralStringResource(R.plurals.mode_added_count, owned, owned) else store.label,
fontSize = 12.sp, color = colors.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis,
)
}
Actions {
SmallTextButton(stringResource(R.string.stores_owned_in_library), key = "owned-in-library") {
if (loaded) OwnedLink(store.shortLabel + " · " + androidx.compose.ui.res.pluralStringResource(R.plurals.mode_added_count, owned, owned)) {
LibraryView.showOwned(ctx, store)
show("games")
}
else Text(store.label, fontSize = 12.sp, color = colors.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis)
}
Actions {
SmallTextButton(stringResource(R.string.stores_refresh)) { StoresState.open(ctx, store, force = true) }
if (store == Store.XBOX) SmallTextButton(stringResource(R.string.stores_xbox_cloud_settings), key = "xbox-cloud-settings") {
ctx.startActivity(android.content.Intent(ctx, com.droiddeck.launcher.stores.xbox.XboxCloudSettingsActivity::class.java))
@@ -949,6 +947,28 @@ private fun ProfileStrip(store: Store, owned: Int, loaded: Boolean, s: FrontEndS
}
}
@Composable
private fun OwnedLink(label: String, onClick: () -> Unit) {
val colors = MaterialTheme.colorScheme
val pal = LocalPalette.current
val src = remember { MutableInteractionSource() }
val hot = rememberHot(src)
val shape = RoundedCornerShape(8.dp)
val description = stringResource(R.string.stores_owned_in_library)
Row(
verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(2.dp),
modifier = Modifier.paneItem("owned-in-library").testTag("owned-in-library").clip(shape)
.background(if (hot) pal.signal.copy(alpha = 0.14f) else Color.Transparent)
.glideBorder(hot, shape, pal.signal, Color.Transparent)
.hoverable(src).clickable(interactionSource = src, indication = LocalIndication.current, role = Role.Button, onClickLabel = description, onClick = onClick)
.controllerConfirm(onClick = onClick)
.padding(start = 2.dp, end = 4.dp, top = 2.dp, bottom = 2.dp),
) {
Text(label, fontSize = 12.sp, color = if (hot) colors.onBackground else colors.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis)
Icon(Icons.AutoMirrored.Filled.KeyboardArrowRight, description, tint = if (hot) pal.signal else colors.onSurfaceVariant, modifier = Modifier.size(16.dp))
}
}
@Composable
private fun BattleNetLauncherRow(s: FrontEndState, a: FrontEndActions) {
val ctx = LocalContext.current
@@ -1385,7 +1405,25 @@ internal fun ProgressBarThin(fraction: Float, paused: Boolean = false, verify: B
internal fun downloadLabel(d: com.droiddeck.launcher.stores.download.DownloadEntry): String = when (d.state) {
DownloadState.PAUSED -> stringResource(R.string.stores_dl_paused)
DownloadState.QUEUED -> stringResource(R.string.stores_dl_queued)
else -> if (d.stageFraction >= 0f) stringResource(R.string.stores_dl_active_percent, activeStageLabel(d), d.percent) else activeStageLabel(d)
else -> when {
d.streaming -> stringResource(R.string.stores_dl_active_percent, stringResource(R.string.stores_stage_installing), (d.installFraction * 100).toInt())
d.stageFraction >= 0f -> stringResource(R.string.stores_dl_active_percent, activeStageLabel(d), d.percent)
else -> activeStageLabel(d)
}
}
@Composable
internal fun steadyProgress(d: com.droiddeck.launcher.stores.download.DownloadEntry): Float {
val best = androidx.compose.runtime.remember(d.key) { floatArrayOf(0f) }
best[0] = maxOf(best[0], d.overallFraction)
return best[0]
}
@Composable
internal fun steadyLabel(d: com.droiddeck.launcher.stores.download.DownloadEntry, progress: Float): String = when (d.state) {
DownloadState.QUEUED -> stringResource(R.string.stores_dl_queued)
DownloadState.PAUSED -> stringResource(R.string.stores_dl_active_percent, stringResource(R.string.stores_dl_paused), (progress * 100).toInt())
else -> stringResource(R.string.stores_dl_active_percent, stringResource(R.string.stores_stage_installing), (progress * 100).toInt())
}
@Composable
@@ -24,4 +24,45 @@ class DownloadEntryTest {
assertFalse(e.passed(DownloadStage.INSTALL))
assertTrue(e.copy(state = DownloadState.INSTALLED).passed(DownloadStage.INSTALL))
}
@Test fun streamingInstallKeepsDownloadAndInstallProgressApart() {
val installBit = 1 shl DownloadStage.INSTALL.ordinal
val installing = base.copy(stage = DownloadStage.INSTALL, bytesDone = 10, bytesTotal = 100, stageDone = 25, stageTotal = 100)
assertTrue(installing.streaming)
assertEquals(0.10f, installing.downloadFraction, 0.001f)
assertEquals(0.25f, installing.installFraction, 0.001f)
val backToDownload = installing.copy(stage = DownloadStage.DOWNLOAD, stagesPassed = installBit)
assertTrue(backToDownload.streaming)
assertEquals(0.25f, backToDownload.installFraction, 0.001f)
assertFalse(base.copy(stage = DownloadStage.DOWNLOAD, bytesDone = 10, bytesTotal = 100).streaming)
assertTrue(installing.copy(bytesDone = 99_950, bytesTotal = 100_000).streaming)
assertTrue(installing.copy(bytesDone = 99_999_999, bytesTotal = 100_000_000).streaming)
assertFalse(installing.copy(bytesDone = 100).streaming)
assertFalse(installing.copy(state = DownloadState.PAUSED).streaming)
}
@Test fun overallProgressOnlyGrowsAcrossSequentialAndStreamingStages() {
val installBit = 1 shl DownloadStage.INSTALL.ordinal
val downloadBit = 1 shl DownloadStage.DOWNLOAD.ordinal
val sequential = listOf(
base.copy(stage = DownloadStage.MANIFEST),
base.copy(stage = DownloadStage.DOWNLOAD, bytesDone = 50, bytesTotal = 100),
base.copy(stage = DownloadStage.DOWNLOAD, bytesDone = 100, bytesTotal = 100),
base.copy(stage = DownloadStage.INSTALL, bytesDone = 100, bytesTotal = 100, stagesPassed = downloadBit, stageDone = 0, stageTotal = 10),
base.copy(stage = DownloadStage.INSTALL, bytesDone = 100, bytesTotal = 100, stagesPassed = downloadBit, stageDone = 10, stageTotal = 10),
base.copy(state = DownloadState.INSTALLED),
).map { it.overallFraction }
assertEquals(sequential, sequential.sorted())
assertEquals(1f, sequential.last(), 0f)
val streaming = listOf(
base.copy(stage = DownloadStage.DOWNLOAD, bytesDone = 10, bytesTotal = 100),
base.copy(stage = DownloadStage.INSTALL, bytesDone = 20, bytesTotal = 100, stageDone = 15, stageTotal = 100),
base.copy(stage = DownloadStage.DOWNLOAD, bytesDone = 40, bytesTotal = 100, stageDone = 15, stageTotal = 100, stagesPassed = installBit),
base.copy(stage = DownloadStage.INSTALL, bytesDone = 60, bytesTotal = 100, stageDone = 55, stageTotal = 100, stagesPassed = installBit),
base.copy(stage = DownloadStage.DOWNLOAD, bytesDone = 100, bytesTotal = 100, stageDone = 60, stageTotal = 100, stagesPassed = installBit),
base.copy(stage = DownloadStage.INSTALL, bytesDone = 100, bytesTotal = 100, stageDone = 80, stageTotal = 100, stagesPassed = installBit or downloadBit),
).map { it.overallFraction }
assertEquals(streaming, streaming.sorted())
}
}
@@ -0,0 +1,13 @@
package com.droiddeck.launcher.ui
import org.junit.Assert.assertEquals
import org.junit.Test
class LibraryColumnsTest {
@Test fun everySizeStepChangesTheColumnCountUntilOne() {
val phone = (0..4).map { libraryColumns(width = 1080, base = 450, gap = 30, level = it) }
assertEquals(listOf(4, 3, 2, 1, 1), phone)
val tablet = (0..4).map { libraryColumns(width = 2400, base = 450, gap = 30, level = it) }
assertEquals(listOf(7, 6, 5, 4, 3), tablet)
}
}
@@ -76,52 +76,43 @@ class LibraryVisibilityTest {
LibraryView.focusFirst = false
}
@Test fun uninstalledGamesAreHiddenUntilSelectedInTheFilterAndTheChoiceSurvivesReopeningLibrary() {
@Test fun uninstalledGamesStayFoldedUnderTheirRowAndTheChoiceSurvivesReopeningLibrary() {
show()
compose.onNodeWithText("Installed Steam game").assertExists()
compose.onNodeWithText("Uninstalled GOG").assertDoesNotExist()
chooseVisibility(true)
compose.onNodeWithText("NOT INSTALLED · 2").assertExists()
compose.onNodeWithText("3 games").assertExists()
toggleNotInstalled(true)
compose.onNodeWithText("3 games").assertExists()
compose.onNodeWithText("Uninstalled GOG").assertExists()
assertTrue(SessionPrefs.libraryShowUninstalled(ctx))
compose.runOnIdle { generation++; Snapshot.sendApplyNotifications() }
compose.mainClock.advanceTimeBy(2_000)
compose.onNodeWithText("Uninstalled GOG").assertExists()
chooseVisibility(false)
toggleNotInstalled(false)
compose.onNodeWithText("Uninstalled GOG").assertDoesNotExist()
assertFalse(SessionPrefs.libraryShowUninstalled(ctx))
}
@Test fun theFilterExpandsBesideSortWithoutChangingTheSelectionOnOpen() {
@Test fun theNotInstalledRowReplacesTheFilterButtonAndSortStillOpens() {
show()
val filter = compose.onNodeWithContentDescription("Filter · Installed only")
val sort = compose.onNodeWithContentDescription("Sort")
assertTrue(filter.fetchSemanticsNode().boundsInRoot.right <= sort.fetchSemanticsNode().boundsInRoot.left)
filter.performClick()
compose.mainClock.advanceTimeBy(2_000)
compose.onNodeWithText("Installed only").assertIsDisplayed()
compose.onNodeWithText("All owned games").assertIsDisplayed()
compose.onAllNodesWithText("Filter").assertCountEquals(1)
compose.onNodeWithText("Uninstalled GOG").assertDoesNotExist()
compose.onNodeWithContentDescription("Filter · Installed only").assertDoesNotExist()
compose.onNodeWithTag("library-not-installed").assertExists()
assertFalse(SessionPrefs.libraryShowUninstalled(ctx))
compose.runOnIdle { Steps.fold(); Snapshot.sendApplyNotifications() }
compose.mainClock.advanceTimeBy(1_000)
sort.performClick()
compose.onNodeWithContentDescription("Sort").performClick()
compose.mainClock.advanceTimeBy(2_000)
compose.onAllNodesWithText("Sort").assertCountEquals(1)
compose.onNodeWithText("Recently played").assertIsDisplayed()
}
@Test fun theXboxAccessChoicesShareTheLibraryFilter() {
@Test fun theXboxFilterOnlyOffersTheXboxAccessChoices() {
StoreAccounts.write(ctx, Store.XBOX, JSONObject().put("username", "Library test"))
StoresState.accounts[Store.XBOX] = "Library test"
StoresState.library[Store.XBOX] = listOf(CatalogItem(Store.XBOX, "owned", "Uninstalled Xbox", null, owned = true))
LibraryView.source = Store.XBOX.id
try {
show()
compose.onNodeWithContentDescription("Filter · Installed only").performClick()
compose.onNodeWithContentDescription("Filter · All").performClick()
compose.mainClock.advanceTimeBy(2_000)
compose.onNodeWithText("Installed only").assertIsDisplayed()
compose.onNodeWithText("All owned games").assertIsDisplayed()
compose.onNodeWithText("Installed only").assertDoesNotExist()
compose.onNodeWithText("Game Pass").assertIsDisplayed().performClick()
compose.mainClock.advanceTimeBy(1_000)
assertEquals(XboxLibraryFilter.GAME_PASS, XboxLibraryFilter.current)
@@ -131,14 +122,19 @@ class LibraryVisibilityTest {
}
}
@Test fun aSearchWithOnlyUninstalledMatchesOffersToRevealThem() {
@Test fun aSearchWithOnlyUninstalledMatchesShowsTheFoldedRowToRevealThem() {
LibraryView.query = "Uninstalled GOG"
show()
compose.onNodeWithText("Uninstalled GOG").assertDoesNotExist()
compose.onNodeWithTag("library-browse-owned").performClick()
compose.onNodeWithText("No installed games match these filters", substring = true).assertDoesNotExist()
compose.onNodeWithTag("library-not-installed").performClick()
compose.mainClock.advanceTimeBy(1_000)
compose.onNodeWithText("Uninstalled GOG").assertExists()
assertEquals("Uninstalled GOG", LibraryView.query)
compose.onNodeWithTag("library-not-installed").performClick()
compose.mainClock.advanceTimeBy(1_000)
compose.onNodeWithText("Uninstalled GOG").assertDoesNotExist()
compose.onNodeWithTag("library-not-installed").assertExists()
}
@Test fun aHiddenStoreRemainsReachableInLibraryInItsConfiguredOrder() {
@@ -151,11 +147,19 @@ class LibraryVisibilityTest {
assertTrue(steam < epic && epic < gog)
compose.onNodeWithTag("library-source-gog").performClick()
compose.mainClock.advanceTimeBy(1_000)
compose.onNodeWithTag("library-browse-owned").assertIsDisplayed().performClick()
compose.onNodeWithTag("library-not-installed").assertIsDisplayed().performClick()
compose.mainClock.advanceTimeBy(1_000)
compose.onNodeWithText("Uninstalled GOG").assertExists()
}
@Test fun theHeaderCountsTheWholeLibraryWhicheverStoreIsPicked() {
show()
compose.onNodeWithText("3 games").assertExists()
compose.onNodeWithTag("library-source-gog").performClick()
compose.mainClock.advanceTimeBy(1_000)
compose.onNodeWithText("3 games").assertExists()
}
@Test fun theStoresOwnedGamesLinkRevealsOwnedGamesDespiteTheSavedInstalledOnlyView() {
assertFalse(SessionPrefs.libraryShowUninstalled(ctx))
LibraryView.showOwned(ctx, Store.GOG)
@@ -188,13 +192,8 @@ class LibraryVisibilityTest {
compose.mainClock.advanceTimeBy(2_000)
}
private fun chooseVisibility(show: Boolean) {
compose.onNodeWithContentDescription("Filter · " + if (SessionPrefs.libraryShowUninstalled(ctx)) "All owned games" else "Installed only")
.performClick()
compose.mainClock.advanceTimeBy(2_000)
assertTrue(Steps.open)
compose.onNodeWithText(if (show) "All owned games" else "Installed only")
.performClick()
private fun toggleNotInstalled(show: Boolean) {
compose.onNodeWithTag("library-not-installed").performClick()
compose.mainClock.advanceTimeBy(1_000)
assertEquals(show, SessionPrefs.libraryShowUninstalled(ctx))
}