mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 13:05:47 +00:00
Compare commits
25
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5a35700ebb | ||
|
|
26b11c6838 | ||
|
|
a9f2017aa3 | ||
|
|
bc8a970520 | ||
|
|
eefd8088dc | ||
|
|
442f1f83bf | ||
|
|
1d1c29517a | ||
|
|
be98982cfc | ||
|
|
ed763ecb9b | ||
|
|
ecbda604e2 | ||
|
|
c514c59018 | ||
|
|
b6efc4d44a | ||
|
|
b61f766b66 | ||
|
|
2f16ea63aa | ||
|
|
151b2c304f | ||
|
|
b3e9ea5620 | ||
|
|
a4a5a88ab2 | ||
|
|
839a00a8aa | ||
|
|
a7f7a17a69 | ||
|
|
74a77c1402 | ||
|
|
673c9869f8 | ||
|
|
215ed5aaed | ||
|
|
7b91aea0fc | ||
|
|
2b424bdfe7 | ||
|
|
a4e6279a8d |
No files matched your search
@@ -178,8 +178,10 @@ jobs:
|
||||
PY
|
||||
after=$(find "$GITHUB_WORKSPACE/../robolectric-jars" -name '*.jar' | wc -l)
|
||||
[ "$after" -gt "${ROBOLECTRIC_JARS_BEFORE:-0}" ] && echo "save=true" >> "$GITHUB_OUTPUT" || true
|
||||
# A pull request's cache is visible only to that pull request, and each copy is hundreds of megabytes against the
|
||||
# repository's 10 GB cache limit. Only main saves, so every pull request restores main's set.
|
||||
- name: Store Robolectric's Android jars
|
||||
if: always() && steps.robolectric-jars-final.outputs.save == 'true'
|
||||
if: always() && github.event_name != 'pull_request' && steps.robolectric-jars-final.outputs.save == 'true'
|
||||
uses: actions/cache/save@v4
|
||||
with:
|
||||
path: ${{ steps.robolectric-jars.outputs.path }}
|
||||
|
||||
@@ -15,6 +15,7 @@ import androidx.compose.ui.graphics.Brush
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.input.SecondScreenMode
|
||||
import com.droiddeck.launcher.session.SessionPrefs
|
||||
|
||||
/** The launcher as a whole: rail and page, opened on each tab through FrontEndState.navigate. */
|
||||
@Composable
|
||||
@@ -25,6 +26,23 @@ private fun Launcher(tab: String, games: List<com.droiddeck.launcher.frontend.Li
|
||||
@DroidDeckPreviews @Composable private fun SteamEmptyPreview() = Launcher("steam", games = emptyList())
|
||||
@DroidDeckPreviews @Composable private fun LibraryPreview() = Launcher("games")
|
||||
@DroidDeckPreviews @Composable private fun LibraryEmptyPreview() = Launcher("games", games = emptyList())
|
||||
|
||||
/** The Library in [view] with its display options set as given, the way the eye menu saves them. */
|
||||
@Composable
|
||||
private fun LibraryShown(view: String, title: Boolean, size: Boolean, store: Boolean = true) {
|
||||
val ctx = androidx.compose.ui.platform.LocalContext.current
|
||||
androidx.compose.runtime.remember {
|
||||
SessionPrefs.setLibraryShowTitle(ctx, title)
|
||||
SessionPrefs.setLibraryShowSize(ctx, size)
|
||||
SessionPrefs.setLibraryShowStore(ctx, store)
|
||||
}
|
||||
PreviewHost { FrontEndScreen(sampleState(navigate = "games", storesView = view), sampleActions) }
|
||||
}
|
||||
|
||||
@DroidDeckPreviews @Composable private fun LibraryCapsulesPreview() = LibraryShown("capsules", title = true, size = true)
|
||||
@DroidDeckPreviews @Composable private fun LibraryCardsTitlePreview() = LibraryShown("cards", title = true, size = false)
|
||||
@DroidDeckPreviews @Composable private fun LibraryCapsulesNoStorePreview() = LibraryShown("capsules", title = false, size = false, store = false)
|
||||
|
||||
@DroidDeckPreviews @Composable private fun StoresPreview() = Launcher("stores")
|
||||
@DroidDeckPreviews @Composable private fun DownloadsPreview() = Launcher("downloads")
|
||||
@DroidDeckPreviews @Composable private fun SettingsPreview() = Launcher("setup")
|
||||
@@ -115,6 +133,11 @@ private val storesLoaded = { com.droiddeck.launcher.stores.StoresState.accountsL
|
||||
internal val previewCases: List<PreviewCase> = listOf(
|
||||
PreviewCase("steam-tab") { Launcher("steam") },
|
||||
PreviewCase("library", storesLoaded) { Launcher("games") },
|
||||
PreviewCase("library-capsules-title-size", storesLoaded) { LibraryShown("capsules", title = true, size = true) },
|
||||
PreviewCase("library-cards-title", storesLoaded) { LibraryShown("cards", title = true, size = false) },
|
||||
PreviewCase("library-cards-size", storesLoaded) { LibraryShown("cards", title = false, size = true) },
|
||||
PreviewCase("library-capsules-bare", storesLoaded) { LibraryShown("capsules", title = false, size = false, store = false) },
|
||||
PreviewCase("library-capsules-store-title-off", storesLoaded) { LibraryShown("capsules", title = true, size = false, store = false) },
|
||||
PreviewCase("library-empty", storesLoaded) { Launcher("games", games = emptyList()) },
|
||||
PreviewCase("stores", storesLoaded) { Launcher("stores") },
|
||||
PreviewCase("downloads") { Launcher("downloads") },
|
||||
|
||||
@@ -50,10 +50,11 @@ internal fun sampleState(
|
||||
games: List<Library.SteamGame> = sampleGames,
|
||||
navigate: String? = null,
|
||||
ready: Boolean = true,
|
||||
storesView: String = SessionPrefs.DEFAULT_STORES_VIEW,
|
||||
): FrontEndState = FrontEndState(
|
||||
installed = "ubuntu-r1", ready = ready, available = "ubuntu-r1", busy = false, stage = "", percent = 0,
|
||||
desktopInstalled = true, offlineAccount = null, offline = false, frameGenLabel = "Off", romsDir = null, logsEnabled = true,
|
||||
steamGames = games, emulators = emptyList(), running = null, navigate = navigate,
|
||||
steamGames = games, emulators = emptyList(), running = null, navigate = navigate, storesView = storesView,
|
||||
)
|
||||
|
||||
internal val sampleActions: FrontEndActions = FrontEndActions(
|
||||
|
||||
@@ -79,6 +79,24 @@ static int format_refused(VkFormat f) {
|
||||
|
||||
static _Atomic unsigned g_stat_generated;
|
||||
static uint64_t g_total_generated;
|
||||
|
||||
#define FG_PROVEN_FRAMES 120
|
||||
#define FG_HANG_STRIKES 2
|
||||
static _Atomic int g_hang_strikes;
|
||||
static int g_submitted_since_ready;
|
||||
static uint64_t g_generated_at_ready;
|
||||
|
||||
// A driver that hangs on the engine's shaders loses the device on its first generated frame after every
|
||||
// recovery, so the compositor would recover and hang again for as long as frame generation stays armed.
|
||||
static int framegen_loss_strike(int submitted, uint64_t completed_since_ready) {
|
||||
if (!submitted || completed_since_ready >= FG_PROVEN_FRAMES) {
|
||||
atomic_store(&g_hang_strikes, 0);
|
||||
return 0;
|
||||
}
|
||||
if (atomic_fetch_add(&g_hang_strikes, 1) + 1 < FG_HANG_STRIKES) return 0;
|
||||
atomic_store(&g_hang_strikes, 0);
|
||||
return 1;
|
||||
}
|
||||
static float g_presented_rate, g_source_rate;
|
||||
static uint32_t g_present_accum, g_source_accum;
|
||||
static int64_t g_window_start_ns;
|
||||
@@ -129,6 +147,7 @@ void vkp_framegen_set_engine(int kind) {
|
||||
atomic_store(&g_kind, kind);
|
||||
atomic_store(&g_failed_kind, -1);
|
||||
atomic_store(&g_cfg_dirty, 1);
|
||||
atomic_store(&g_hang_strikes, 0);
|
||||
}
|
||||
|
||||
void vkp_framegen_set_armed(int armed, int multiplier, int target_fps) {
|
||||
@@ -230,6 +249,8 @@ void vkp_framegen_device_ready(VkDevice dev, VkQueue queue, uint32_t qfam, int f
|
||||
atomic_store(&g_caps_ddfg_ok, fge_caps_ok(VKP_FG_ENGINE_DDFG));
|
||||
atomic_store(&g_caps_zero_ok, fge_caps_ok(VKP_FG_ENGINE_ZEROFG));
|
||||
atomic_store(&g_dev_lost, 0);
|
||||
g_submitted_since_ready = 0;
|
||||
g_generated_at_ready = g_total_generated;
|
||||
atomic_store(&g_dev_ready,
|
||||
vk.CreateImage && vk.CreateImageView && vk.CmdPipelineBarrier);
|
||||
FGLOG("engines ready on compositor device: LSFG %s, DD-FG %s, ZeroFG %s",
|
||||
@@ -238,8 +259,21 @@ void vkp_framegen_device_ready(VkDevice dev, VkQueue queue, uint32_t qfam, int f
|
||||
fge_caps_ok(VKP_FG_ENGINE_ZEROFG) ? "available" : "unavailable");
|
||||
}
|
||||
|
||||
// The compositor reports one loss twice: when it happens and again while releasing the lost device.
|
||||
static int framegen_count_loss(void) {
|
||||
if (atomic_exchange(&g_dev_lost, 1)) return 0;
|
||||
int failed = framegen_loss_strike(g_submitted_since_ready, g_total_generated - g_generated_at_ready);
|
||||
g_submitted_since_ready = 0;
|
||||
return failed;
|
||||
}
|
||||
|
||||
void vkp_framegen_device_lost(void) {
|
||||
atomic_store(&g_dev_lost, 1);
|
||||
if (framegen_count_loss()) {
|
||||
int kind = atomic_load(&g_kind);
|
||||
mark_failed(kind);
|
||||
FGLOG("%s lost the GPU %d times in a row before its frames completed; frame generation stays off "
|
||||
"until it is set again", fge_engine_name(kind), FG_HANG_STRIKES);
|
||||
}
|
||||
atomic_store(&g_dev_ready, 0);
|
||||
fge_device_lost();
|
||||
if (g_dev) {
|
||||
@@ -523,6 +557,7 @@ int vkp_framegen_run(VkCommandBuffer cmd, VkImage scene, VkImageView scene_view,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
0, 0, NULL, 0, NULL, nb, bars);
|
||||
|
||||
if (n_gen) g_submitted_since_ready = 1;
|
||||
fge_process(cmd, scene, scene_view, (uint32_t)w, (uint32_t)h, fmt, planning_sequence, n_gen);
|
||||
for (uint32_t g = 0; g < n_gen; g++) {
|
||||
fge_generate(cmd, g, n_gen, g_ring[g].img, g_ring[g].view, (uint32_t)w, (uint32_t)h);
|
||||
|
||||
@@ -6495,7 +6495,13 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
displayManager.unregisterDisplayListener(displayListener)
|
||||
com.droiddeck.launcher.input.DualScreen.unwatchTaken(bottomScreenListener)
|
||||
contentResolver.unregisterContentObserver(refreshSettingObserver)
|
||||
if (!screenIsOff()) closeSecondScreen(reset = false)
|
||||
// Closing the presentation removes the docked Agent page and unregisters its picker.
|
||||
if (com.droiddeck.launcher.session.SessionVisibilityPolicy.shouldCloseSecondScreenOnStop(
|
||||
screenOff = screenIsOff(),
|
||||
dockedDrawerOpen = menuShownOnBottom(),
|
||||
attachmentPickerOpen = com.droiddeck.launcher.agent.AgentAttachments.picking,
|
||||
)
|
||||
) closeSecondScreen(reset = false)
|
||||
sessionTextInput.stop()
|
||||
startedScreens = (startedScreens - 1).coerceAtLeast(0)
|
||||
updateGlassesScreen()
|
||||
@@ -6532,6 +6538,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
com.droiddeck.launcher.agent.AgentAttachments.picking = false
|
||||
drawerGameInventoryRevision++
|
||||
com.droiddeck.launcher.input.SystemKeyCapture.attach(this, { hasWindowFocus() && !appUiOwnsPointer() && CompositorHost.isStarted }) { event ->
|
||||
com.droiddeck.launcher.input.GuestKeys.send(event) { code, down -> sendGuestKey(code, down, 8) }
|
||||
@@ -6645,7 +6652,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
heldButtons.clear()
|
||||
if (!screenOff) {
|
||||
val menuUp = menuShownOnBottom()
|
||||
drawerOpen = false
|
||||
if (!com.droiddeck.launcher.agent.AgentAttachments.picking) drawerOpen = false
|
||||
if (menuUp) SessionState.bottomMenu = true
|
||||
pcKeyboardOpen = false
|
||||
achievementsOpen = false
|
||||
|
||||
@@ -19,6 +19,9 @@ object AgentAttachments {
|
||||
/** Guest paths waiting to go with the next message. */
|
||||
val pending = mutableStateListOf<String>()
|
||||
|
||||
/** True while the file picker is open over a session: it answers the drawer's agent page, so the drawer must stay. */
|
||||
@Volatile var picking = false
|
||||
|
||||
private const val NEW = "new"
|
||||
private const val GUEST_DIR = "/root/.cache/droiddeck/attachments"
|
||||
private val IMAGE = setOf("png", "jpg", "jpeg", "webp", "gif", "bmp")
|
||||
|
||||
@@ -376,6 +376,12 @@ object SessionPrefs {
|
||||
prefs(context).edit().putBoolean("libraryShowSize", show).apply()
|
||||
}
|
||||
|
||||
fun libraryShowStore(context: Context): Boolean = prefs(context).getBoolean("libraryShowStore", true)
|
||||
|
||||
fun setLibraryShowStore(context: Context, show: Boolean) {
|
||||
prefs(context).edit().putBoolean("libraryShowStore", show).apply()
|
||||
}
|
||||
|
||||
fun libraryShowHidden(context: Context): Boolean = prefs(context).getBoolean("libraryShowHidden", false)
|
||||
|
||||
fun setLibraryShowHidden(context: Context, show: Boolean) {
|
||||
|
||||
@@ -945,11 +945,15 @@ class SessionService : Service() {
|
||||
return
|
||||
}
|
||||
if (gen == sessionGen && SessionState.running) {
|
||||
val workers = ownWorkers
|
||||
suspendController = SessionSuspendController(
|
||||
sessionRoot = { sessionPid },
|
||||
// Programs handed off to worker processes are not descendants of the session root, and
|
||||
// the clock shift applied at resume would move their monotonic time backwards.
|
||||
helperRoots = {
|
||||
components.mapNotNull { it.suspendPid().takeIf { pid -> pid > 1 } } +
|
||||
listOfNotNull(BottomDesktop.suspendPid.takeIf { it > 1 })
|
||||
listOfNotNull(BottomDesktop.suspendPid.takeIf { it > 1 }) +
|
||||
(if (workers > 0) com.droiddeck.launcher.runtime.GuestWorkers.guestPids(workers) else emptyList())
|
||||
},
|
||||
suspendAudio = {
|
||||
if (!pulse.setSinkSuspended(true)) Log.w(TAG, "could not suspend audio sink")
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
internal object SessionVisibilityPolicy {
|
||||
fun shouldCloseSecondScreenOnStop(
|
||||
screenOff: Boolean,
|
||||
dockedDrawerOpen: Boolean,
|
||||
attachmentPickerOpen: Boolean,
|
||||
): Boolean = !screenOff && !(dockedDrawerOpen && attachmentPickerOpen)
|
||||
|
||||
fun isHidden(
|
||||
activityStarted: Boolean,
|
||||
defaultDisplayOn: Boolean,
|
||||
|
||||
@@ -1007,6 +1007,7 @@ private fun AttachButton() {
|
||||
val context = LocalContext.current
|
||||
val pal = LocalPalette.current
|
||||
val picker = rememberLauncherForActivityResult(ActivityResultContracts.OpenMultipleDocuments()) { uris ->
|
||||
AgentAttachments.picking = false
|
||||
if (uris.isEmpty()) return@rememberLauncherForActivityResult
|
||||
val chat = AgentHost.chat
|
||||
Thread({
|
||||
@@ -1017,7 +1018,8 @@ private fun AttachButton() {
|
||||
}, "agent-attach").start()
|
||||
}
|
||||
RoundButton(Icons.Outlined.AttachFile, stringResource(R.string.agent_attach), pal.surfaceVariant, pal.onBackground, "agent-attach") {
|
||||
runCatching { picker.launch(arrayOf("*/*")) }
|
||||
AgentAttachments.picking = true
|
||||
if (runCatching { picker.launch(arrayOf("*/*")) }.isFailure) AgentAttachments.picking = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -308,7 +308,8 @@ internal fun SecondaryButton(text: String, enabled: Boolean = true, compact: Boo
|
||||
Box(
|
||||
contentAlignment = Alignment.Center,
|
||||
modifier = modifier.paneItem("btn:$text").downToFirstTile().heightIn(min = if (pill) 40.dp else if (compact) 44.dp else 48.dp).graphicsLayer { scaleX = scale; scaleY = scale }.clip(shape).background(fill).glideBorder(hot, shape, pal.signal, if (pill) Color.White.copy(alpha = 0.14f) else pal.line2)
|
||||
.alpha(if (enabled) 1f else 0.5f)
|
||||
// The label always gets a layer of its own: sharing one with the fill and outline, they did not draw under the agent's latest reply.
|
||||
.graphicsLayer { alpha = if (enabled) 1f else 0.5f }
|
||||
.hoverable(src).clickable(role = androidx.compose.ui.semantics.Role.Button, interactionSource = src, indication = LocalIndication.current, enabled = enabled, onClick = onClick)
|
||||
.controllerConfirm(enabled = enabled, onClick = onClick)
|
||||
.padding(horizontal = if (pill) 16.dp else if (compact) 10.dp else 16.dp, vertical = if (pill) 8.dp else if (compact) 7.dp else 11.dp),
|
||||
|
||||
@@ -3,6 +3,9 @@ package com.droiddeck.launcher.ui
|
||||
import android.text.format.DateUtils
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.hoverable
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
@@ -26,8 +29,11 @@ import androidx.compose.runtime.setValue
|
||||
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.pluralStringResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.Role
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
@@ -41,7 +47,7 @@ import com.droiddeck.launcher.lab.LabOverlay
|
||||
* [onRebuild] offers to build a kept one again for this install, when something can.
|
||||
*/
|
||||
@Composable
|
||||
internal fun LabBuilds(sessionRunning: Boolean = false, onRebuild: ((LabOverlay.Info) -> Unit)? = null) {
|
||||
internal fun LabBuilds(sessionRunning: Boolean = false, header: (@Composable () -> Unit)? = null, onRebuild: ((LabOverlay.Info) -> Unit)? = null) {
|
||||
val context = LocalContext.current
|
||||
var version by remember { mutableIntStateOf(0) }
|
||||
var busy by remember { mutableStateOf(false) }
|
||||
@@ -54,6 +60,7 @@ internal fun LabBuilds(sessionRunning: Boolean = false, onRebuild: ((LabOverlay.
|
||||
val paused = active == null && current != null && LabOverlay.skipped == LabOverlay.SKIPPED_APP_IMAGE
|
||||
val restartFailed = stringResource(R.string.lab_restart_failed)
|
||||
val canRestart = !busy && !sessionRunning
|
||||
var showKept by androidx.compose.runtime.saveable.rememberSaveable { mutableStateOf(false) }
|
||||
|
||||
/** Android may have given the APK an app image again, which a Lab build cannot load over. */
|
||||
fun restart() {
|
||||
@@ -73,8 +80,8 @@ internal fun LabBuilds(sessionRunning: Boolean = false, onRebuild: ((LabOverlay.
|
||||
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
Column(Modifier.fillMaxWidth().padding(top = 18.dp)) {
|
||||
Text(
|
||||
Column(Modifier.fillMaxWidth().padding(top = if (header == null) 18.dp else 0.dp)) {
|
||||
if (header != null) header() else Text(
|
||||
stringResource(R.string.lab_builds).uppercase(), fontSize = 12.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 1.5.sp,
|
||||
color = colors.onSurfaceVariant, modifier = Modifier.padding(start = 2.dp, top = 2.dp, bottom = 10.dp),
|
||||
)
|
||||
@@ -99,7 +106,29 @@ internal fun LabBuilds(sessionRunning: Boolean = false, onRebuild: ((LabOverlay.
|
||||
PrimaryButton(stringResource(R.string.lab_restart), compact = true, enabled = canRestart) { restart() }
|
||||
}
|
||||
}
|
||||
for (build in saved) rows += {
|
||||
val foldKept = (current != null || pending != null) && saved.isNotEmpty()
|
||||
if (foldKept) rows += {
|
||||
val src = remember { MutableInteractionSource() }
|
||||
val toggle = { showKept = !showKept }
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.fillMaxWidth().paneItem("lab:kept")
|
||||
.background(if (rememberHot(src)) pal.signal.copy(alpha = 0.14f) else Color.Transparent)
|
||||
.hoverable(src).clickable(interactionSource = src, indication = null, role = Role.Button, onClick = toggle)
|
||||
.controllerConfirm(onClick = toggle)
|
||||
.padding(horizontal = 14.dp, vertical = 12.dp),
|
||||
) {
|
||||
Text(
|
||||
pluralStringResource(R.plurals.lab_kept_count, saved.size, saved.size), fontSize = 14.sp,
|
||||
color = colors.onSurfaceVariant, modifier = Modifier.weight(1f),
|
||||
)
|
||||
Text(
|
||||
stringResource(if (showKept) R.string.common_hide else R.string.common_show), fontSize = 13.5.sp,
|
||||
fontWeight = FontWeight.SemiBold, color = pal.signal,
|
||||
)
|
||||
}
|
||||
}
|
||||
if (!foldKept || showKept) for (build in saved) rows += {
|
||||
var armed by remember(build.dir) { mutableStateOf(false) }
|
||||
val info = build.info
|
||||
BuildRow(
|
||||
|
||||
@@ -66,9 +66,11 @@ import androidx.compose.material.icons.filled.ViewModule
|
||||
import androidx.compose.material.icons.filled.Visibility
|
||||
import androidx.compose.material.icons.outlined.Download
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.LocalContentColor
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.SideEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
@@ -209,11 +211,14 @@ internal object LibraryDisplay {
|
||||
private set
|
||||
var size by mutableStateOf(false)
|
||||
private set
|
||||
var store by mutableStateOf(true)
|
||||
private set
|
||||
|
||||
fun load(context: android.content.Context) {
|
||||
level = SessionPrefs.libraryCardLevel(context).coerceIn(0, scales.lastIndex)
|
||||
title = SessionPrefs.libraryShowTitle(context)
|
||||
size = SessionPrefs.libraryShowSize(context)
|
||||
store = SessionPrefs.libraryShowStore(context)
|
||||
}
|
||||
|
||||
fun step(context: android.content.Context, by: Int) {
|
||||
@@ -230,8 +235,16 @@ internal object LibraryDisplay {
|
||||
size = !size
|
||||
SessionPrefs.setLibraryShowSize(context, size)
|
||||
}
|
||||
|
||||
fun toggleStore(context: android.content.Context) {
|
||||
store = !store
|
||||
SessionPrefs.setLibraryShowStore(context, store)
|
||||
}
|
||||
}
|
||||
|
||||
/** Views that mix stores, where each card says which store it comes from. */
|
||||
private fun showsSource(source: String) = source == LIBRARY_ALL || source == LIBRARY_FAVORITES || source == LIBRARY_HIDDEN
|
||||
|
||||
private enum class ToggleAt { NONE, TOP, SPLIT, BOTTOM }
|
||||
|
||||
private const val NOT_INSTALLED_ROW = "library-not-installed"
|
||||
@@ -709,7 +722,7 @@ private fun LibraryGrid(
|
||||
enter.animateTo(1f, Motion.tw(320))
|
||||
}
|
||||
Box(Modifier.graphicsLayer { alpha = enter.value; translationY = (1f - enter.value) * 18.dp.toPx() }) {
|
||||
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)
|
||||
if (listMode) LibraryRow(e, first, navigation, choose, onOpen) else LibraryTile(e, capsules, first, navigation, choose, onOpen, showSource = showsSource(source))
|
||||
}
|
||||
}
|
||||
var rowFocused by remember { mutableStateOf(false) }
|
||||
@@ -897,7 +910,7 @@ private fun LibraryHeader(
|
||||
}
|
||||
if (soundMode) HeaderIconButton(stringResource(R.string.soundtracks_saved), Icons.Filled.BookmarkBorder, "collections", onClick = onCollections)
|
||||
if (!soundMode && DeveloperTools.on && DevPreview.shortcuts) LibraryPreviewButton()
|
||||
DisplayButton()
|
||||
DisplayButton(storeOption = !soundMode && showsSource(source))
|
||||
if (!soundMode && xbox) LibraryFilterButton(null, onShowUninstalled, xbox)
|
||||
if (collections != null) CollectionsButton(collections)
|
||||
SortButton(s, a)
|
||||
@@ -1088,13 +1101,13 @@ private fun LibraryTile(e: LibraryEntry, capsule: Boolean, first: Boolean, navig
|
||||
onOpen(e.key)
|
||||
}
|
||||
Column(
|
||||
modifier = Modifier.fillMaxWidth().onGloballyPositioned { placed[0] = it }
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
.then(navigation).paneItem("card:${e.key}").then(if (first) Modifier.firstTile().paneEntry() else Modifier).graphicsLayer { scaleX = scale; scaleY = scale }
|
||||
.clip(RoundedCornerShape(10.dp)).glideBorder(hot, RoundedCornerShape(10.dp), pal.signal, pal.line)
|
||||
.hoverable(src).clickable(role = Role.Button, interactionSource = src, indication = LocalIndication.current, onClick = open)
|
||||
.controllerConfirm(onClick = choose ?: open),
|
||||
) {
|
||||
LibraryArt(e, wide, tall, download, hot, capsule, showSource)
|
||||
LibraryArt(e, wide, tall, download, hot, capsule, showSource) { placed[0] = it }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1103,7 +1116,10 @@ internal val LibraryCardWidth = 150.dp
|
||||
internal fun libraryTileWidth() = LibraryCardWidth * LibraryDisplay.scales[LibraryDisplay.level]
|
||||
|
||||
@Composable
|
||||
private fun LibraryArt(e: LibraryEntry, wide: Any?, tall: Any?, download: DownloadEntry?, hot: Boolean, capsule: Boolean, showSource: Boolean) {
|
||||
private fun LibraryArt(
|
||||
e: LibraryEntry, wide: Any?, tall: Any?, download: DownloadEntry?, hot: Boolean, capsule: Boolean, showSource: Boolean,
|
||||
onArtPlaced: (androidx.compose.ui.layout.LayoutCoordinates) -> Unit,
|
||||
) {
|
||||
val chip = when {
|
||||
download != null -> "${(steadyProgress(download) * 100).toInt()}%"
|
||||
e.item != null && StoresState.isUnfinished(e.item) -> stringResource(R.string.stores_resume)
|
||||
@@ -1112,65 +1128,86 @@ private fun LibraryArt(e: LibraryEntry, wide: Any?, tall: Any?, download: Downlo
|
||||
}
|
||||
ArtCard(
|
||||
e.title, wide, tall, download, hot, capsule, chip,
|
||||
badge = if (showSource) ({ SourceChip(e.source, small = true, modifier = Modifier.align(Alignment.TopStart).padding(6.dp), label = favoritesBadge(e), colours = favoritesColours(e)) }) else null,
|
||||
banner = if (showSource && LibraryDisplay.store) ({ SourceBanner(e.source, label = favoritesBadge(e), colours = favoritesColours(e)) }) else null,
|
||||
onArtPlaced = onArtPlaced,
|
||||
) { LibrarySize(e) }
|
||||
}
|
||||
|
||||
/**
|
||||
* A game's art with an optional [banner] above it. The title and [detail] the display options turn on sit in a caption
|
||||
* below the art; a focused card shows the ones that are off over the bottom of the art instead, so its height never changes.
|
||||
*/
|
||||
@Composable
|
||||
internal fun ArtCard(
|
||||
title: String, wide: Any?, tall: Any?, download: DownloadEntry?, hot: Boolean, capsule: Boolean, chip: String?,
|
||||
badge: (@Composable BoxScope.() -> Unit)? = null, detail: @Composable () -> Unit,
|
||||
badge: (@Composable BoxScope.() -> Unit)? = null, banner: (@Composable () -> Unit)? = null,
|
||||
onArtPlaced: (androidx.compose.ui.layout.LayoutCoordinates) -> Unit = {}, detail: @Composable () -> Unit,
|
||||
) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val url = if (capsule) tall ?: wide else wide ?: tall
|
||||
val art = cardArtRequest(url, tall)
|
||||
val ratio = if (capsule) 5f / 7f else 16f / 9f
|
||||
var offRatio by remember(url) { mutableStateOf(false) }
|
||||
var trim by remember(url) { mutableStateOf(false) }
|
||||
val blurs = android.os.Build.VERSION.SDK_INT >= 31
|
||||
Box(
|
||||
Modifier.fillMaxWidth().aspectRatio(ratio).background(Color(0xFF101318))
|
||||
.then(if (url == null) Modifier.background(artBrush(hueOf(title))) else Modifier),
|
||||
) {
|
||||
if (art != null && offRatio) {
|
||||
AsyncImage(model = art, contentDescription = null, contentScale = ContentScale.Crop, modifier = Modifier.matchParentSize().blur(32.dp))
|
||||
Spacer(Modifier.matchParentSize().background(Color.Black.copy(alpha = if (blurs) 0.18f else 0.6f)))
|
||||
}
|
||||
if (art != null) AsyncImage(
|
||||
model = art, contentDescription = null, contentScale = if (trim) ContentScale.Crop else ContentScale.Fit, modifier = Modifier.matchParentSize(),
|
||||
onSuccess = { r ->
|
||||
val d = r.result.drawable
|
||||
if (d.intrinsicWidth > 0 && d.intrinsicHeight > 0) {
|
||||
val shape = d.intrinsicWidth.toFloat() / d.intrinsicHeight
|
||||
trim = !capsule && shape > ratio * 1.25f
|
||||
offRatio = !trim && kotlin.math.abs(shape / ratio - 1f) > 0.03f
|
||||
}
|
||||
},
|
||||
)
|
||||
badge?.invoke(this)
|
||||
if (chip != null) Box(Modifier.align(Alignment.TopEnd).padding(6.dp)) {
|
||||
StateChip(chip, ChipTone.BUSY, small = true, fraction = download?.let { steadyProgress(it) }, key = download?.key)
|
||||
}
|
||||
val showName = LibraryDisplay.title || hot
|
||||
val showDetail = LibraryDisplay.size || hot
|
||||
if (showName || showDetail) {
|
||||
val top = with(androidx.compose.ui.platform.LocalDensity.current) { 20.dp.roundToPx() }
|
||||
val bottom = with(androidx.compose.ui.platform.LocalDensity.current) { (if (download != null) 14.dp else 6.dp).roundToPx() }
|
||||
Column(
|
||||
verticalArrangement = Arrangement.spacedBy(1.dp),
|
||||
modifier = Modifier.align(Alignment.BottomCenter).fillMaxWidth()
|
||||
.background(Brush.verticalGradient(0f to Color.Transparent, 0.6f to Color.Black.copy(alpha = 0.78f), 1f to Color.Black.copy(alpha = 0.92f)))
|
||||
.layout { measurable, constraints ->
|
||||
val inner = measurable.measure(constraints)
|
||||
if (inner.height == 0) layout(inner.width, 0) {} else layout(inner.width, inner.height + top + bottom) { inner.place(0, top) }
|
||||
val captionName = LibraryDisplay.title
|
||||
val captionDetail = LibraryDisplay.size
|
||||
Column(Modifier.fillMaxWidth()) {
|
||||
banner?.invoke()
|
||||
Box(
|
||||
Modifier.fillMaxWidth().aspectRatio(ratio).onGloballyPositioned(onArtPlaced).background(Color(0xFF101318))
|
||||
.then(if (url == null) Modifier.background(artBrush(hueOf(title))) else Modifier),
|
||||
) {
|
||||
if (art != null && offRatio) {
|
||||
AsyncImage(model = art, contentDescription = null, contentScale = ContentScale.Crop, modifier = Modifier.matchParentSize().blur(32.dp))
|
||||
Spacer(Modifier.matchParentSize().background(Color.Black.copy(alpha = if (blurs) 0.18f else 0.6f)))
|
||||
}
|
||||
if (art != null) AsyncImage(
|
||||
model = art, contentDescription = null, contentScale = if (trim) ContentScale.Crop else ContentScale.Fit, modifier = Modifier.matchParentSize(),
|
||||
onSuccess = { r ->
|
||||
val d = r.result.drawable
|
||||
if (d.intrinsicWidth > 0 && d.intrinsicHeight > 0) {
|
||||
val shape = d.intrinsicWidth.toFloat() / d.intrinsicHeight
|
||||
trim = !capsule && shape > ratio * 1.25f
|
||||
offRatio = !trim && kotlin.math.abs(shape / ratio - 1f) > 0.03f
|
||||
}
|
||||
.padding(horizontal = 8.dp),
|
||||
) {
|
||||
if (showName) Text(title, fontSize = 11.sp, fontWeight = FontWeight.Bold, color = Color.White, maxLines = if (hot) 2 else 1, overflow = TextOverflow.Ellipsis, lineHeight = 13.sp)
|
||||
if (showDetail) detail()
|
||||
},
|
||||
)
|
||||
badge?.invoke(this)
|
||||
if (chip != null) Box(Modifier.align(Alignment.TopEnd).padding(6.dp)) {
|
||||
StateChip(chip, ChipTone.BUSY, small = true, fraction = download?.let { steadyProgress(it) }, key = download?.key)
|
||||
}
|
||||
val overlayName = hot && !captionName
|
||||
val overlayDetail = hot && !captionDetail
|
||||
if (overlayName || overlayDetail) {
|
||||
val top = with(androidx.compose.ui.platform.LocalDensity.current) { 20.dp.roundToPx() }
|
||||
val bottom = with(androidx.compose.ui.platform.LocalDensity.current) { (if (download != null) 14.dp else 6.dp).roundToPx() }
|
||||
Column(
|
||||
verticalArrangement = Arrangement.spacedBy(1.dp),
|
||||
modifier = Modifier.align(Alignment.BottomCenter).fillMaxWidth()
|
||||
.background(Brush.verticalGradient(0f to Color.Transparent, 0.6f to Color.Black.copy(alpha = 0.78f), 1f to Color.Black.copy(alpha = 0.92f)))
|
||||
.layout { measurable, constraints ->
|
||||
val inner = measurable.measure(constraints)
|
||||
if (inner.height == 0) layout(inner.width, 0) {} else layout(inner.width, inner.height + top + bottom) { inner.place(0, top) }
|
||||
}
|
||||
.padding(horizontal = 8.dp),
|
||||
) {
|
||||
if (overlayName) Text(title, fontSize = 11.sp, fontWeight = FontWeight.Bold, color = Color.White, maxLines = 2, overflow = TextOverflow.Ellipsis, lineHeight = 13.sp)
|
||||
if (overlayDetail) CompositionLocalProvider(LocalContentColor provides Color.White) { detail() }
|
||||
}
|
||||
}
|
||||
if (download != null) Box(Modifier.align(Alignment.BottomCenter).padding(start = 6.dp, end = 6.dp, bottom = 5.dp)) {
|
||||
ProgressBarThin(download.fraction, paused = download.state == DownloadState.PAUSED, verify = download.stage == DownloadStage.VERIFY)
|
||||
}
|
||||
}
|
||||
if (download != null) Box(Modifier.align(Alignment.BottomCenter).padding(start = 6.dp, end = 6.dp, bottom = 5.dp)) {
|
||||
ProgressBarThin(download.fraction, paused = download.state == DownloadState.PAUSED, verify = download.stage == DownloadStage.VERIFY)
|
||||
if (captionName || captionDetail) Column(
|
||||
verticalArrangement = Arrangement.spacedBy(1.dp),
|
||||
modifier = Modifier.fillMaxWidth().background(colors.surface).padding(horizontal = 8.dp, vertical = 6.dp),
|
||||
) {
|
||||
if (captionName) Text(title, fontSize = 12.sp, fontWeight = FontWeight.Bold, color = colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis, lineHeight = 15.sp)
|
||||
if (captionDetail) Box(Modifier.fillMaxWidth().height(15.dp), contentAlignment = Alignment.CenterStart) {
|
||||
CompositionLocalProvider(LocalContentColor provides colors.onSurfaceVariant) { detail() }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1197,7 +1234,7 @@ private fun librarySize(e: LibraryEntry): Long? = if (e.installed) e.storeKey?.l
|
||||
@Composable
|
||||
private fun LibrarySize(e: LibraryEntry) {
|
||||
val size = librarySize(e)?.takeIf { it > 0 } ?: return
|
||||
Text(formatBytes(size), fontSize = 11.sp, fontWeight = FontWeight.Bold, color = Color.White, maxLines = 1)
|
||||
Text(formatBytes(size), fontSize = 11.sp, fontWeight = FontWeight.Bold, color = LocalContentColor.current, maxLines = 1)
|
||||
}
|
||||
|
||||
@Composable
|
||||
@@ -1391,7 +1428,7 @@ private fun CollectionsButton(store: Store) {
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun DisplayButton() {
|
||||
internal fun DisplayButton(storeOption: Boolean = false) {
|
||||
val pal = LocalPalette.current
|
||||
val ctx = LocalContext.current
|
||||
val title = stringResource(R.string.library_display)
|
||||
@@ -1400,7 +1437,7 @@ internal fun DisplayButton() {
|
||||
HeaderIconButton(title, Icons.Filled.Visibility, "display") {
|
||||
val from = at ?: return@HeaderIconButton
|
||||
Steps.ask(StepAsk(
|
||||
anchor = from, side = StepSide.Left, accent = pal.signal, pillCorner = 8.dp, items = 4,
|
||||
anchor = from, side = StepSide.Left, accent = pal.signal, pillCorner = 8.dp, items = if (storeOption) 5 else 4,
|
||||
handle = { Icon(Icons.Filled.Visibility, null, tint = pal.signal, modifier = Modifier.size(18.dp)) },
|
||||
) {
|
||||
StepTitle(title)
|
||||
@@ -1423,6 +1460,10 @@ internal fun DisplayButton() {
|
||||
stringResource(R.string.library_display_size), selected = LibraryDisplay.size, enabled = open,
|
||||
modifier = Modifier.fillMaxWidth().stepItem(3),
|
||||
) { LibraryDisplay.toggleSize(ctx) }
|
||||
if (storeOption) StepChoice(
|
||||
stringResource(R.string.library_display_store), selected = LibraryDisplay.store, enabled = open,
|
||||
modifier = Modifier.fillMaxWidth().stepItem(4),
|
||||
) { LibraryDisplay.toggleStore(ctx) }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -84,6 +84,7 @@ 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.systemGestureExclusion
|
||||
import androidx.compose.foundation.ScrollState
|
||||
import androidx.compose.foundation.horizontalScroll
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
@@ -548,8 +549,8 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
|
||||
}
|
||||
androidx.compose.foundation.layout.BoxWithConstraints(modifier = Modifier.fillMaxSize().exposeTestTags(), contentAlignment = Alignment.CenterEnd) {
|
||||
val short = maxHeight < 440.dp
|
||||
// The handle keeps a strip on the left free, so a sheet dragged wide can always be dragged back.
|
||||
val maxSheet = (maxWidth - DRAWER_EDGE_GAP).coerceAtLeast(0.dp)
|
||||
// At full width the handle's strip sits on the screen's left edge, so the sheet can still be dragged back.
|
||||
val maxSheet = (maxWidth - DRAWER_HANDLE_STRIP).coerceAtLeast(0.dp)
|
||||
val minSheet = minOf(DRAWER_MIN_WIDTH, maxSheet)
|
||||
val defaultSheet = minOf(420.dp, maxWidth * 0.92f)
|
||||
val sheetWidth = if (docked) maxWidth else (savedWidth?.dp ?: defaultSheet).coerceIn(minSheet, maxSheet)
|
||||
@@ -1556,7 +1557,6 @@ internal fun secondScreenModes(none: Boolean, deckPad: Boolean, dashboard: Boole
|
||||
|
||||
private val DRAWER_MIN_WIDTH = 300.dp
|
||||
private val DRAWER_HANDLE_STRIP = 24.dp
|
||||
private val DRAWER_EDGE_GAP = 80.dp
|
||||
|
||||
/** A grip on the sheet's left edge: dragging it, or pressing left and right on a controller, resizes the sheet. */
|
||||
@Composable
|
||||
@@ -1578,6 +1578,8 @@ private fun DrawerResizeHandle(width: Dp, min: Dp, max: Dp, onWidth: (Dp) -> Uni
|
||||
contentAlignment = Alignment.Center,
|
||||
modifier = modifier.width(24.dp).height(96.dp)
|
||||
.onGloballyPositioned { coords = it }
|
||||
// On the screen's edge, Android's back swipe would take the drag.
|
||||
.systemGestureExclusion()
|
||||
.focusable(true, source)
|
||||
.onPreviewKeyEvent { event ->
|
||||
val key = event.nativeKeyEvent
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import android.os.SystemClock
|
||||
import androidx.compose.animation.core.Animatable
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.foundation.relocation.BringIntoViewRequester
|
||||
import androidx.compose.foundation.relocation.bringIntoViewRequester
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.SideEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.staticCompositionLocalOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.runtime.withFrameNanos
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.drawBehind
|
||||
|
||||
/** The row a settings search result opens, so the page it lands on can scroll to it and flash it. */
|
||||
internal object SettingsJump {
|
||||
class Target(val label: String, val at: Long = SystemClock.uptimeMillis())
|
||||
|
||||
var target: Target? by mutableStateOf(null)
|
||||
|
||||
fun to(label: String) { target = Target(label) }
|
||||
}
|
||||
|
||||
private const val JUMP_WINDOW_MS = 5_000L
|
||||
|
||||
/** False in the search results, whose rows carry the same labels as the rows they open. */
|
||||
internal val LocalSearchTargets = staticCompositionLocalOf { true }
|
||||
|
||||
@OptIn(androidx.compose.foundation.ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
internal fun Modifier.searchTarget(label: String): Modifier {
|
||||
val pal = LocalPalette.current
|
||||
val flash = remember { Animatable(0f) }
|
||||
val reveal = remember { BringIntoViewRequester() }
|
||||
var claimed by remember { mutableStateOf<SettingsJump.Target?>(null) }
|
||||
val target = SettingsJump.target.takeIf { LocalSearchTargets.current }
|
||||
if (target != null && target.label == label) SideEffect {
|
||||
if (SettingsJump.target === target) {
|
||||
SettingsJump.target = null
|
||||
if (SystemClock.uptimeMillis() - target.at <= JUMP_WINDOW_MS) claimed = target
|
||||
}
|
||||
}
|
||||
claimed?.let { mine ->
|
||||
LaunchedEffect(mine) {
|
||||
withFrameNanos { }
|
||||
reveal.bringIntoView()
|
||||
repeat(2) {
|
||||
flash.animateTo(1f, tween(220))
|
||||
flash.animateTo(0f, tween(420))
|
||||
}
|
||||
claimed = null
|
||||
}
|
||||
}
|
||||
return bringIntoViewRequester(reveal).drawBehind {
|
||||
if (flash.value > 0f) drawRect(pal.signal.copy(alpha = 0.28f * flash.value))
|
||||
}
|
||||
}
|
||||
@@ -103,7 +103,7 @@ internal fun SettingsSearchResults(query: String, frost: Boolean, onOpen: (Setti
|
||||
Note(stringResource(R.string.settings_search_none, query.trim()))
|
||||
return
|
||||
}
|
||||
Column {
|
||||
androidx.compose.runtime.CompositionLocalProvider(LocalSearchTargets provides false) { Column {
|
||||
found.groupBy { it.place }.forEach { (place, entries) ->
|
||||
SettingsGroup(stringResource(place.title)) {
|
||||
entries.forEach { entry ->
|
||||
@@ -112,9 +112,10 @@ internal fun SettingsSearchResults(query: String, frost: Boolean, onOpen: (Setti
|
||||
val section = entry.section
|
||||
val tab = entry.tab
|
||||
if (section != null) {
|
||||
ActionRow(title, within, stringResource(R.string.store_open), onClick = { onOpen(section) })
|
||||
ActionRow(title, within, stringResource(R.string.store_open), onClick = { SettingsJump.to(title); onOpen(section) })
|
||||
} else if (tab != null) {
|
||||
ActionRow(title, within, stringResource(R.string.store_open), onClick = {
|
||||
SettingsJump.to(title)
|
||||
if (tab == NavTabs.MORE) MoreTabs.editing = true
|
||||
if (tab == "downloads") DownloadsNav.showSettings = true
|
||||
RailRequest.key = tab
|
||||
@@ -125,5 +126,5 @@ internal fun SettingsSearchResults(query: String, frost: Boolean, onOpen: (Setti
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} }
|
||||
}
|
||||
@@ -536,7 +536,7 @@ fun SettingsRow(label: String, hint: String?, highlighted: Boolean = false, hint
|
||||
minLines = hintLines ?: 1, maxLines = hintLines ?: Int.MAX_VALUE, overflow = TextOverflow.Ellipsis)
|
||||
}
|
||||
if (compact && !stacked) Column(
|
||||
modifier = Modifier.fillMaxWidth().background(bg).padding(horizontal = 10.dp, vertical = 6.dp),
|
||||
modifier = Modifier.searchTarget(label).fillMaxWidth().background(bg).padding(horizontal = 10.dp, vertical = 6.dp),
|
||||
) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Text(label, fontSize = 13.sp, lineHeight = 16.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground,
|
||||
@@ -545,7 +545,7 @@ fun SettingsRow(label: String, hint: String?, highlighted: Boolean = false, hint
|
||||
}
|
||||
if (hint != null || hintLines != null) hintText(11.sp)
|
||||
} else if (stacked || LocalNarrowPane.current) Column(
|
||||
modifier = Modifier.fillMaxWidth().background(bg).padding(
|
||||
modifier = Modifier.searchTarget(label).fillMaxWidth().background(bg).padding(
|
||||
horizontal = if (compact) 10.dp else 14.dp,
|
||||
vertical = if (tightControlSpacing) 2.dp else if (compact) 6.dp else 12.dp),
|
||||
) {
|
||||
@@ -556,7 +556,7 @@ fun SettingsRow(label: String, hint: String?, highlighted: Boolean = false, hint
|
||||
Box(Modifier.padding(top = if (tightControlSpacing) 2.dp else if (compact) 6.dp else 8.dp)) { control() }
|
||||
} else Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.fillMaxWidth().background(bg).padding(horizontal = 14.dp, vertical = 11.dp),
|
||||
modifier = Modifier.searchTarget(label).fillMaxWidth().background(bg).padding(horizontal = 14.dp, vertical = 11.dp),
|
||||
) {
|
||||
Column(modifier = Modifier.weight(1f).padding(end = 12.dp)) {
|
||||
Text(label, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground)
|
||||
@@ -660,7 +660,7 @@ fun SliderRow(
|
||||
) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
Column(Modifier.fillMaxWidth()) {
|
||||
Column(Modifier.searchTarget(label).fillMaxWidth()) {
|
||||
ValueSlider(value, range, step, enabled, label, format,
|
||||
modifier = modifier.padding(horizontal = 6.dp, vertical = 3.dp), onChange = onChange)
|
||||
if (hint != null) Text(hint, fontSize = 12.5.sp, color = colors.onSurfaceVariant,
|
||||
|
||||
@@ -2,16 +2,20 @@ package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.heightIn
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
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.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.droiddeck.launcher.R
|
||||
@@ -73,6 +77,18 @@ internal fun SourceChip(source: String, small: Boolean = false, modifier: Modifi
|
||||
)
|
||||
}
|
||||
|
||||
/** The store a card comes from, as a full-width band above its art. */
|
||||
@Composable
|
||||
internal fun SourceBanner(source: String, modifier: Modifier = Modifier, label: String? = null, colours: SourceColours? = null) {
|
||||
val c = colours ?: sourceColours(source)
|
||||
Box(modifier.fillMaxWidth().heightIn(min = 20.dp).background(c.fill).padding(horizontal = 8.dp, vertical = 3.dp), contentAlignment = Alignment.CenterStart) {
|
||||
Text(
|
||||
label ?: sourceLabel(source), fontSize = 10.sp, fontWeight = FontWeight.Bold, letterSpacing = 0.5.sp, lineHeight = 12.sp,
|
||||
color = c.ink, maxLines = 1, overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun StateChip(text: String, tone: ChipTone, small: Boolean = false, fraction: Float? = null, key: Any? = null) {
|
||||
val pal = LocalPalette.current
|
||||
|
||||
@@ -1190,7 +1190,6 @@ private fun GameCard(
|
||||
Column(
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
.onGloballyPositioned { c ->
|
||||
placed[0] = c
|
||||
if (item.accessible && item.sizeBytes <= 0) {
|
||||
val b = c.boundsInWindow()
|
||||
if (b.bottom > -ahead && b.top < screen + ahead && b.width > 0f) com.droiddeck.launcher.stores.StoreSizes.request(ctx, item)
|
||||
@@ -1209,10 +1208,10 @@ private fun GameCard(
|
||||
val priced = installed || item.isFree || item.isDiscounted || item.hasPrice
|
||||
val pill: (@Composable BoxScope.() -> Unit)? = if (priced && !LibraryDisplay.size && !hot) ({
|
||||
Box(Modifier.align(Alignment.TopStart).padding(6.dp).clip(RoundedCornerShape(6.dp)).background(Color.Black.copy(alpha = 0.82f)).padding(horizontal = 6.dp, vertical = 2.dp)) {
|
||||
CardMarker(item, installed, download, compact = true, status = false)
|
||||
CompositionLocalProvider(androidx.compose.material3.LocalContentColor provides Color.White) { CardMarker(item, installed, download, compact = true, status = false) }
|
||||
}
|
||||
}) else null
|
||||
ArtCard(item.title, item.imageUrl, item.tallImageUrl, download, hot, capsule = false, chip = chip, badge = pill) { CardMarker(item, installed, download, status = false) }
|
||||
ArtCard(item.title, item.imageUrl, item.tallImageUrl, download, hot, capsule = false, chip = chip, badge = pill, onArtPlaced = { placed[0] = it }) { CardMarker(item, installed, download, status = false) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1256,19 +1255,19 @@ private fun CardMarker(item: CatalogItem, installed: Boolean, download: com.droi
|
||||
val ctx = LocalContext.current
|
||||
val game = StoresState.installedGame(item.store, item.id)
|
||||
if (game != null && !compact) androidx.compose.runtime.LaunchedEffect(item.key) { com.droiddeck.launcher.stores.StoreSizes.requestDisk(ctx, item.key, game) }
|
||||
if (!compact) com.droiddeck.launcher.stores.StoreSizes.onDisk[item.key]?.let { Text(formatBytes(it), fontSize = 11.sp, fontWeight = FontWeight.Bold, color = Color.White, maxLines = 1) }
|
||||
if (!compact) com.droiddeck.launcher.stores.StoreSizes.onDisk[item.key]?.let { Text(formatBytes(it), fontSize = 11.sp, fontWeight = FontWeight.Bold, color = androidx.compose.material3.LocalContentColor.current, maxLines = 1) }
|
||||
Icon(Icons.Filled.Check, stringResource(R.string.stores_installed_chip), tint = pal.good, modifier = Modifier.size(11.dp))
|
||||
}
|
||||
status && download != null -> Text("${download.percent}%", fontSize = small, fontWeight = FontWeight.Bold, color = pal.signal, maxLines = 1)
|
||||
status && item.accessible && StoresState.isUnfinished(item) -> Text(stringResource(R.string.stores_resume), fontSize = small, fontWeight = FontWeight.Bold, color = pal.signal, maxLines = 1)
|
||||
item.accessible && compact -> Unit
|
||||
item.accessible -> com.droiddeck.launcher.stores.StoreSizes.size(item).takeIf { it > 0 }?.let { Text(formatBytes(it), fontSize = 11.sp, fontWeight = FontWeight.Bold, color = Color.White, maxLines = 1) }
|
||||
item.accessible -> com.droiddeck.launcher.stores.StoreSizes.size(item).takeIf { it > 0 }?.let { Text(formatBytes(it), fontSize = 11.sp, fontWeight = FontWeight.Bold, color = androidx.compose.material3.LocalContentColor.current, maxLines = 1) }
|
||||
item.isFree -> Text(stringResource(R.string.stores_free), fontSize = small, fontWeight = FontWeight.Bold, color = pal.good, maxLines = 1)
|
||||
item.isDiscounted -> Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(4.dp)) {
|
||||
StateChip("-${item.discountPercent}%", ChipTone.DEAL, small = true)
|
||||
Text(item.finalPrice, fontSize = small, fontWeight = FontWeight.Bold, color = Color.White, maxLines = 1)
|
||||
Text(item.finalPrice, fontSize = small, fontWeight = FontWeight.Bold, color = androidx.compose.material3.LocalContentColor.current, maxLines = 1)
|
||||
}
|
||||
item.hasPrice -> Text(item.finalPrice, fontSize = small, fontWeight = FontWeight.Bold, color = Color.White, maxLines = 1)
|
||||
item.hasPrice -> Text(item.finalPrice, fontSize = small, fontWeight = FontWeight.Bold, color = androidx.compose.material3.LocalContentColor.current, maxLines = 1)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
||||
import androidx.compose.foundation.layout.FlowRow
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
@@ -114,36 +115,49 @@ internal fun UpdatesPage(s: FrontEndState, a: FrontEndActions, modifier: Modifie
|
||||
Column(modifier = modifier) {
|
||||
BoxWithConstraints(Modifier.weight(1f).fillMaxWidth()) {
|
||||
val stacked = LocalNarrowPane.current || maxWidth < 600.dp
|
||||
Column(modifier = Modifier.fillMaxSize().verticalScroll(rememberScrollState()).padding(bottom = 16.dp)) {
|
||||
val context = LocalContext.current
|
||||
val agentReady = com.droiddeck.launcher.agent.AgentHost.installed &&
|
||||
(com.droiddeck.launcher.agent.AgentSetup.ready || com.droiddeck.launcher.agent.AgentSetup.completed(context))
|
||||
val installed: @Composable () -> Unit = {
|
||||
SectionLabel(stringResource(R.string.upd_installed_label))
|
||||
InstalledCard(s, u, me)
|
||||
CheckRow(u, ua)
|
||||
SectionLabel(stringResource(R.string.upd_channel))
|
||||
if (stacked) {
|
||||
ChannelPicker(u, ua)
|
||||
Box(Modifier.height(14.dp))
|
||||
StatusPanel(s, u, ua, me)
|
||||
} else {
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(18.dp)) {
|
||||
Box(Modifier.weight(1f)) { ChannelPicker(u, ua) }
|
||||
Box(Modifier.weight(1.15f)) { StatusPanel(s, u, ua, me) }
|
||||
}
|
||||
}
|
||||
SectionLabel(stringResource(R.string.upd_testers), top = 22.dp)
|
||||
ToggleRow(
|
||||
host, "build-watermark", stringResource(R.string.setup_build_watermark),
|
||||
stringResource(R.string.setup_build_watermark_hint), s.buildWatermark,
|
||||
) { a.onBuildWatermark() }
|
||||
val context = LocalContext.current
|
||||
val agentReady = com.droiddeck.launcher.agent.AgentHost.installed &&
|
||||
(com.droiddeck.launcher.agent.AgentSetup.ready || com.droiddeck.launcher.agent.AgentSetup.completed(context))
|
||||
LabBuilds(s.sessionRunning, onRebuild = if (agentReady) { info ->
|
||||
LabBuilds(s.sessionRunning, header = { SectionLabel(stringResource(R.string.lab_builds)) }, onRebuild = if (agentReady) { info ->
|
||||
com.droiddeck.launcher.agent.AgentHost.send(context, context.getString(R.string.agent_rebuild_lab, info.label))
|
||||
context.startActivity(android.content.Intent(context, com.droiddeck.launcher.FrontEndActivity::class.java)
|
||||
.putExtra(com.droiddeck.launcher.stores.download.StoreDownloadService.EXTRA_NAV, "agent")
|
||||
.addFlags(android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP or android.content.Intent.FLAG_ACTIVITY_REORDER_TO_FRONT))
|
||||
} else null)
|
||||
}
|
||||
val channel: @Composable () -> Unit = {
|
||||
SectionLabel(stringResource(R.string.upd_channel))
|
||||
ChannelPicker(u, ua) { StatusPanel(s, u, ua, me, embedded = it) }
|
||||
}
|
||||
val testers: @Composable () -> Unit = {
|
||||
SectionLabel(stringResource(R.string.upd_testers), top = 22.dp)
|
||||
ToggleRow(
|
||||
host, "build-watermark", stringResource(R.string.setup_build_watermark),
|
||||
stringResource(R.string.setup_build_watermark_hint), s.buildWatermark,
|
||||
) { a.onBuildWatermark() }
|
||||
}
|
||||
if (stacked) {
|
||||
Column(modifier = Modifier.fillMaxSize().verticalScroll(rememberScrollState()).padding(bottom = 16.dp)) {
|
||||
installed()
|
||||
Box(Modifier.height(18.dp))
|
||||
channel()
|
||||
testers()
|
||||
}
|
||||
} else {
|
||||
Row(Modifier.fillMaxSize(), horizontalArrangement = Arrangement.spacedBy(24.dp)) {
|
||||
Column(Modifier.weight(1f).fillMaxHeight().verticalScroll(rememberScrollState()).padding(bottom = 16.dp)) {
|
||||
installed()
|
||||
testers()
|
||||
}
|
||||
Column(Modifier.weight(1.15f).fillMaxHeight().verticalScroll(rememberScrollState()).padding(bottom = 16.dp)) {
|
||||
channel()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (u.askPermission) AlertDialog(
|
||||
@@ -266,7 +280,7 @@ private fun CheckRow(u: UpdatesState, ua: UpdatesActions) {
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun StatusPanel(s: FrontEndState, u: UpdatesState, ua: UpdatesActions, me: AppUpdates.Installed) {
|
||||
private fun StatusPanel(s: FrontEndState, u: UpdatesState, ua: UpdatesActions, me: AppUpdates.Installed, embedded: Boolean = false) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
val catalog = u.catalog
|
||||
@@ -292,13 +306,14 @@ private fun StatusPanel(s: FrontEndState, u: UpdatesState, ua: UpdatesActions, m
|
||||
else -> Look(pal.good, stringResource(R.string.upd_current_status), stringResource(R.string.upd_current_headline, name), null)
|
||||
}
|
||||
Column(
|
||||
modifier = Modifier.fillMaxWidth().clip(Shape16).background(colors.surface).border(1.dp, pal.line, Shape16).padding(18.dp),
|
||||
modifier = if (embedded) Modifier.fillMaxWidth().padding(start = 12.dp, end = 12.dp, bottom = 14.dp)
|
||||
else Modifier.fillMaxWidth().clip(Shape16).background(colors.surface).border(1.dp, pal.line, Shape16).padding(18.dp),
|
||||
) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(7.dp)) {
|
||||
Box(Modifier.size(7.dp).clip(CircleShape).background(look.tint))
|
||||
Text(look.status, fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = look.tint)
|
||||
}
|
||||
Text(look.headline, fontSize = 22.sp, fontWeight = FontWeight.Bold, color = colors.onBackground, modifier = Modifier.padding(top = 4.dp))
|
||||
if (!embedded) Text(look.headline, fontSize = 22.sp, fontWeight = FontWeight.Bold, color = colors.onBackground, modifier = Modifier.padding(top = 4.dp))
|
||||
if (offered) {
|
||||
val size = release!!.apk?.size?.takeIf { it > 0 }?.let { megabytes(it) }
|
||||
Text(
|
||||
@@ -419,7 +434,7 @@ private fun changeTitle(t: String): String =
|
||||
private fun megabytes(bytes: Long) = stringResource(R.string.upd_mb, ((bytes + 524_288) / 1_048_576).toInt())
|
||||
|
||||
@Composable
|
||||
private fun ChannelPicker(u: UpdatesState, ua: UpdatesActions) {
|
||||
private fun ChannelPicker(u: UpdatesState, ua: UpdatesActions, status: @Composable (embedded: Boolean) -> Unit) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
val catalog = u.catalog
|
||||
@@ -455,8 +470,9 @@ private fun ChannelPicker(u: UpdatesState, ua: UpdatesActions) {
|
||||
}
|
||||
Text(hint, fontSize = 12.5.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(horizontal = 4.dp))
|
||||
if (tests.isEmpty() && catalog != null && showTests) Text(stringResource(R.string.upd_tests_none), fontSize = 12.5.sp, color = colors.onSurfaceVariant)
|
||||
if (!listing) status(false)
|
||||
AnimatedVisibility(listing, enter = expandVertically(Motion.sp(1f)) + fadeIn(Motion.sp(1f)), exit = shrinkVertically(Motion.sp(1f)) + fadeOut(Motion.sp(1f))) {
|
||||
TestList(tests, me, u, ua)
|
||||
TestList(tests, me, u, ua, status)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -675,7 +691,7 @@ private fun LinkPill(label: String, url: String) {
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun TestList(tests: List<Release>, me: AppUpdates.Installed, u: UpdatesState, ua: UpdatesActions) {
|
||||
private fun TestList(tests: List<Release>, me: AppUpdates.Installed, u: UpdatesState, ua: UpdatesActions, status: @Composable (embedded: Boolean) -> Unit) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
var query by rememberSaveable { mutableStateOf("") }
|
||||
val needle = query.trim().removePrefix("#").removePrefix("@")
|
||||
@@ -686,18 +702,24 @@ private fun TestList(tests: List<Release>, me: AppUpdates.Installed, u: UpdatesS
|
||||
val (ready, old) = matches.partition { it.versionCode >= me.versionCode }
|
||||
val followedOld = u.follow.channel == Channel.TEST && old.any { it.pr == u.follow.pr }
|
||||
var showOld by rememberSaveable { mutableStateOf(false) }
|
||||
Column(Modifier.padding(start = 18.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
if (tests.size > 5 || query.isNotEmpty()) AdbTextField(
|
||||
value = query, onValueChange = { query = it }, label = stringResource(R.string.upd_tests_find),
|
||||
keyboardType = KeyboardType.Text, imeAction = ImeAction.Search, compact = true, showLabel = false,
|
||||
placeholder = stringResource(R.string.upd_tests_find), modifier = Modifier.fillMaxWidth(),
|
||||
)
|
||||
if (matches.isEmpty()) Text(stringResource(R.string.upd_tests_no_match), fontSize = 12.5.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(4.dp))
|
||||
ready.forEach { t -> TestRow(t, u.follow.pr == t.pr && u.follow.channel == Channel.TEST) { ua.onFollow(Follow(Channel.TEST, t.pr)) } }
|
||||
if (old.isNotEmpty()) {
|
||||
MoreLink(stringResource(R.string.upd_tests_old, old.size, me.versionCode), "tests:old") { showOld = !showOld }
|
||||
if (showOld || followedOld || needle.isNotEmpty()) old.forEach { t ->
|
||||
TestRow(t, u.follow.pr == t.pr && u.follow.channel == Channel.TEST, tooOld = true) { ua.onFollow(Follow(Channel.TEST, t.pr)) }
|
||||
val oldShown = showOld || followedOld || needle.isNotEmpty()
|
||||
val followed = u.follow.pr.takeIf { u.follow.channel == Channel.TEST }
|
||||
val rowShown = followed != null && (ready.any { it.pr == followed } || (oldShown && old.any { it.pr == followed }))
|
||||
Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
|
||||
if (!rowShown) status(false)
|
||||
Column(Modifier.padding(start = 18.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
if (tests.size > 5 || query.isNotEmpty()) AdbTextField(
|
||||
value = query, onValueChange = { query = it }, label = stringResource(R.string.upd_tests_find),
|
||||
keyboardType = KeyboardType.Text, imeAction = ImeAction.Search, compact = true, showLabel = false,
|
||||
placeholder = stringResource(R.string.upd_tests_find), modifier = Modifier.fillMaxWidth(),
|
||||
)
|
||||
if (matches.isEmpty()) Text(stringResource(R.string.upd_tests_no_match), fontSize = 12.5.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(4.dp))
|
||||
ready.forEach { t -> TestRow(t, followed == t.pr, status = status) { ua.onFollow(Follow(Channel.TEST, t.pr)) } }
|
||||
if (old.isNotEmpty()) {
|
||||
MoreLink(stringResource(R.string.upd_tests_old, old.size, me.versionCode), "tests:old") { showOld = !showOld }
|
||||
if (oldShown) old.forEach { t ->
|
||||
TestRow(t, followed == t.pr, tooOld = true, status = status) { ua.onFollow(Follow(Channel.TEST, t.pr)) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -712,40 +734,46 @@ private fun RadioDot(selected: Boolean, size: androidx.compose.ui.unit.Dp = 22.d
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun TestRow(t: Release, selected: Boolean, tooOld: Boolean = false, onClick: () -> Unit) {
|
||||
private fun TestRow(t: Release, selected: Boolean, tooOld: Boolean = false, status: @Composable (embedded: Boolean) -> Unit, onClick: () -> Unit) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
val src = remember { MutableInteractionSource() }
|
||||
val hot = rememberHot(src)
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
modifier = Modifier.fillMaxWidth().paneItem("test:${t.pr}")
|
||||
.heightIn(min = 52.dp)
|
||||
.clip(Shape12)
|
||||
.background(colors.surface).background(if (hot) pal.signal.copy(alpha = 0.14f) else Color.Transparent)
|
||||
.glideBorder(hot, Shape12, pal.signal, pal.line)
|
||||
.alpha(if (tooOld && !selected) 0.6f else 1f)
|
||||
.hoverable(src)
|
||||
.clickable(interactionSource = src, indication = null, role = Role.RadioButton, onClick = onClick)
|
||||
.controllerConfirm(onClick = onClick)
|
||||
.padding(horizontal = 12.dp, vertical = 8.dp),
|
||||
Column(
|
||||
Modifier.fillMaxWidth().clip(Shape12).background(colors.surface)
|
||||
.glideBorder(hot, Shape12, pal.signal, if (selected) pal.signal.copy(alpha = 0.5f) else pal.line),
|
||||
) {
|
||||
Text("#${t.pr}", fontSize = 13.sp, fontWeight = FontWeight.Bold, color = if (selected) pal.signal else colors.onSurfaceVariant)
|
||||
Column(Modifier.weight(1f)) {
|
||||
Text(changeTitle(t.title.ifBlank { stringResource(R.string.upd_pr, t.pr) }), fontSize = 13.5.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
val detail = when {
|
||||
t.apk == null -> stringResource(R.string.upd_not_built)
|
||||
tooOld -> stringResource(R.string.upd_tests_old_row, t.versionCode)
|
||||
else -> stringResource(R.string.upd_updated, ago(t.builtAt.takeIf { it > 0 } ?: t.publishedAt))
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
modifier = Modifier.fillMaxWidth().paneItem("test:${t.pr}")
|
||||
.heightIn(min = 52.dp)
|
||||
.background(if (hot) pal.signal.copy(alpha = 0.14f) else Color.Transparent)
|
||||
.alpha(if (tooOld && !selected) 0.6f else 1f)
|
||||
.hoverable(src)
|
||||
.clickable(interactionSource = src, indication = null, role = Role.RadioButton, onClick = onClick)
|
||||
.controllerConfirm(onClick = onClick)
|
||||
.padding(horizontal = 12.dp, vertical = 8.dp),
|
||||
) {
|
||||
Text("#${t.pr}", fontSize = 13.sp, fontWeight = FontWeight.Bold, color = if (selected) pal.signal else colors.onSurfaceVariant)
|
||||
Column(Modifier.weight(1f)) {
|
||||
Text(changeTitle(t.title.ifBlank { stringResource(R.string.upd_pr, t.pr) }), fontSize = 13.5.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
val detail = when {
|
||||
t.apk == null -> stringResource(R.string.upd_not_built)
|
||||
tooOld -> stringResource(R.string.upd_tests_old_row, t.versionCode)
|
||||
else -> stringResource(R.string.upd_updated, ago(t.builtAt.takeIf { it > 0 } ?: t.publishedAt))
|
||||
}
|
||||
Text(
|
||||
listOfNotNull(detail, t.author.takeIf { it.isNotEmpty() }?.let { "@$it" }, t.shortCommit).joinToString(" · "),
|
||||
fontSize = 12.sp, color = colors.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
if (t.newerCommitPushed) Text(stringResource(R.string.upd_newer_commit_short), fontSize = 12.sp, color = AttentionAmber, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
}
|
||||
Text(
|
||||
listOfNotNull(detail, t.author.takeIf { it.isNotEmpty() }?.let { "@$it" }, t.shortCommit).joinToString(" · "),
|
||||
fontSize = 12.sp, color = colors.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
if (t.newerCommitPushed) Text(stringResource(R.string.upd_newer_commit_short), fontSize = 12.sp, color = AttentionAmber, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
RadioDot(selected, 20.dp)
|
||||
}
|
||||
AnimatedVisibility(selected, enter = expandVertically(Motion.sp(1f)) + fadeIn(Motion.sp(1f)), exit = shrinkVertically(Motion.sp(1f)) + fadeOut(Motion.sp(1f))) {
|
||||
status(true)
|
||||
}
|
||||
RadioDot(selected, 20.dp)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2732,6 +2732,7 @@
|
||||
<string name="library_display_smaller">بطاقات أصغر</string>
|
||||
<string name="library_display_title">إظهار العنوان</string>
|
||||
<string name="library_display_size">إظهار الحجم</string>
|
||||
<string name="library_display_store">إظهار المتجر</string>
|
||||
<string name="stores_sort_last_played">لُعب مؤخرًا</string>
|
||||
<string name="stores_sort_recently_installed">ثُبت مؤخرًا</string>
|
||||
<string name="stores_sort_title_asc">العنوان أ–ي</string>
|
||||
|
||||
@@ -2690,6 +2690,7 @@
|
||||
<string name="library_display_smaller">Tarjetas más pequeñas</string>
|
||||
<string name="library_display_title">Mostrar título</string>
|
||||
<string name="library_display_size">Mostrar tamaño</string>
|
||||
<string name="library_display_store">Mostrar tienda</string>
|
||||
<string name="stores_sort_last_played">Jugados recientemente</string>
|
||||
<string name="stores_sort_recently_installed">Instalados recientemente</string>
|
||||
<string name="stores_sort_title_asc">Título A–Z</string>
|
||||
|
||||
@@ -2628,6 +2628,7 @@
|
||||
<string name="library_display_smaller">По-малки карти</string>
|
||||
<string name="library_display_title">Показване на заглавието</string>
|
||||
<string name="library_display_size">Показване на размера</string>
|
||||
<string name="library_display_store">Показване на магазина</string>
|
||||
<string name="stores_sort_last_played">Играни наскоро</string>
|
||||
<string name="stores_sort_recently_installed">Инсталирани наскоро</string>
|
||||
<string name="stores_sort_title_asc">Заглавие А–Я</string>
|
||||
|
||||
@@ -2680,6 +2680,7 @@
|
||||
<string name="library_display_smaller">Menší karty</string>
|
||||
<string name="library_display_title">Zobrazit název</string>
|
||||
<string name="library_display_size">Zobrazit velikost</string>
|
||||
<string name="library_display_store">Zobrazit obchod</string>
|
||||
<string name="stores_sort_last_played">Nedávno hrané</string>
|
||||
<string name="stores_sort_recently_installed">Nedávno nainstalované</string>
|
||||
<string name="stores_sort_title_asc">Název A–Z</string>
|
||||
|
||||
@@ -2628,6 +2628,7 @@
|
||||
<string name="library_display_smaller">Mindre kort</string>
|
||||
<string name="library_display_title">Vis titel</string>
|
||||
<string name="library_display_size">Vis størrelse</string>
|
||||
<string name="library_display_store">Vis butik</string>
|
||||
<string name="stores_sort_last_played">Senest spillet</string>
|
||||
<string name="stores_sort_recently_installed">Senest installeret</string>
|
||||
<string name="stores_sort_title_asc">Titel A–Å</string>
|
||||
|
||||
@@ -2620,6 +2620,7 @@
|
||||
<string name="library_display_smaller">Kleinere Karten</string>
|
||||
<string name="library_display_title">Titel anzeigen</string>
|
||||
<string name="library_display_size">Größe anzeigen</string>
|
||||
<string name="library_display_store">Store anzeigen</string>
|
||||
<string name="stores_sort_last_played">Zuletzt gespielt</string>
|
||||
<string name="stores_sort_recently_installed">Zuletzt installiert</string>
|
||||
<string name="stores_sort_title_asc">Titel A–Z</string>
|
||||
|
||||
@@ -2628,6 +2628,7 @@
|
||||
<string name="library_display_smaller">Μικρότερες κάρτες</string>
|
||||
<string name="library_display_title">Εμφάνιση τίτλου</string>
|
||||
<string name="library_display_size">Εμφάνιση μεγέθους</string>
|
||||
<string name="library_display_store">Εμφάνιση καταστήματος</string>
|
||||
<string name="stores_sort_last_played">Παίχτηκαν πρόσφατα</string>
|
||||
<string name="stores_sort_recently_installed">Εγκαταστήθηκαν πρόσφατα</string>
|
||||
<string name="stores_sort_title_asc">Τίτλος Α–Ω</string>
|
||||
|
||||
@@ -2654,6 +2654,7 @@
|
||||
<string name="library_display_smaller">Tarjetas más pequeñas</string>
|
||||
<string name="library_display_title">Mostrar título</string>
|
||||
<string name="library_display_size">Mostrar tamaño</string>
|
||||
<string name="library_display_store">Mostrar tienda</string>
|
||||
<string name="stores_sort_last_played">Jugados recientemente</string>
|
||||
<string name="stores_sort_recently_installed">Instalados recientemente</string>
|
||||
<string name="stores_sort_title_asc">Título A–Z</string>
|
||||
|
||||
@@ -2628,6 +2628,7 @@
|
||||
<string name="library_display_smaller">Pienemmät kortit</string>
|
||||
<string name="library_display_title">Näytä nimi</string>
|
||||
<string name="library_display_size">Näytä koko</string>
|
||||
<string name="library_display_store">Näytä kauppa</string>
|
||||
<string name="stores_sort_last_played">Viimeksi pelatut</string>
|
||||
<string name="stores_sort_recently_installed">Viimeksi asennetut</string>
|
||||
<string name="stores_sort_title_asc">Nimi A–Ö</string>
|
||||
|
||||
@@ -2653,6 +2653,7 @@
|
||||
<string name="library_display_smaller">Cartes plus petites</string>
|
||||
<string name="library_display_title">Afficher le titre</string>
|
||||
<string name="library_display_size">Afficher la taille</string>
|
||||
<string name="library_display_store">Afficher la boutique</string>
|
||||
<string name="stores_sort_last_played">Joués récemment</string>
|
||||
<string name="stores_sort_recently_installed">Installés récemment</string>
|
||||
<string name="stores_sort_title_asc">Titre A–Z</string>
|
||||
|
||||
@@ -2628,6 +2628,7 @@
|
||||
<string name="library_display_smaller">छोटे कार्ड</string>
|
||||
<string name="library_display_title">टाइटल दिखाएं</string>
|
||||
<string name="library_display_size">साइज़ दिखाएं</string>
|
||||
<string name="library_display_store">स्टोर दिखाएं</string>
|
||||
<string name="stores_sort_last_played">हाल में खेले गए</string>
|
||||
<string name="stores_sort_recently_installed">हाल में इंस्टॉल किए गए</string>
|
||||
<string name="stores_sort_title_asc">शीर्षक A–Z</string>
|
||||
|
||||
@@ -2628,6 +2628,7 @@
|
||||
<string name="library_display_smaller">Kisebb kártyák</string>
|
||||
<string name="library_display_title">Cím megjelenítése</string>
|
||||
<string name="library_display_size">Méret megjelenítése</string>
|
||||
<string name="library_display_store">Áruház megjelenítése</string>
|
||||
<string name="stores_sort_last_played">Nemrég játszott</string>
|
||||
<string name="stores_sort_recently_installed">Nemrég telepített</string>
|
||||
<string name="stores_sort_title_asc">Cím A–Z</string>
|
||||
|
||||
@@ -2603,6 +2603,7 @@
|
||||
<string name="library_display_smaller">Kartu lebih kecil</string>
|
||||
<string name="library_display_title">Tampilkan judul</string>
|
||||
<string name="library_display_size">Tampilkan ukuran</string>
|
||||
<string name="library_display_store">Tampilkan toko</string>
|
||||
<string name="stores_sort_last_played">Baru dimainkan</string>
|
||||
<string name="stores_sort_recently_installed">Baru dipasang</string>
|
||||
<string name="stores_sort_title_asc">Judul A–Z</string>
|
||||
|
||||
@@ -2645,6 +2645,7 @@
|
||||
<string name="library_display_smaller">Schede più piccole</string>
|
||||
<string name="library_display_title">Mostra titolo</string>
|
||||
<string name="library_display_size">Mostra dimensione</string>
|
||||
<string name="library_display_store">Mostra negozio</string>
|
||||
<string name="stores_sort_last_played">Giocate di recente</string>
|
||||
<string name="stores_sort_recently_installed">Installate di recente</string>
|
||||
<string name="stores_sort_title_asc">Titolo A–Z</string>
|
||||
|
||||
@@ -2603,6 +2603,7 @@
|
||||
<string name="library_display_smaller">小さいカード</string>
|
||||
<string name="library_display_title">タイトルを表示</string>
|
||||
<string name="library_display_size">サイズを表示</string>
|
||||
<string name="library_display_store">ストアを表示</string>
|
||||
<string name="stores_sort_last_played">最近プレイ</string>
|
||||
<string name="stores_sort_recently_installed">最近インストール</string>
|
||||
<string name="stores_sort_title_asc">タイトル A–Z</string>
|
||||
|
||||
@@ -2603,6 +2603,7 @@
|
||||
<string name="library_display_smaller">카드 작게</string>
|
||||
<string name="library_display_title">제목 표시</string>
|
||||
<string name="library_display_size">크기 표시</string>
|
||||
<string name="library_display_store">스토어 표시</string>
|
||||
<string name="stores_sort_last_played">최근 플레이</string>
|
||||
<string name="stores_sort_recently_installed">최근 설치</string>
|
||||
<string name="stores_sort_title_asc">제목 A–Z</string>
|
||||
|
||||
@@ -2603,6 +2603,7 @@
|
||||
<string name="library_display_smaller">Kad lebih kecil</string>
|
||||
<string name="library_display_title">Paparkan tajuk</string>
|
||||
<string name="library_display_size">Paparkan saiz</string>
|
||||
<string name="library_display_store">Paparkan kedai</string>
|
||||
<string name="stores_sort_last_played">Baru dimainkan</string>
|
||||
<string name="stores_sort_recently_installed">Baru dipasang</string>
|
||||
<string name="stores_sort_title_asc">Tajuk A–Z</string>
|
||||
|
||||
@@ -2628,6 +2628,7 @@
|
||||
<string name="library_display_smaller">Mindre kort</string>
|
||||
<string name="library_display_title">Vis tittel</string>
|
||||
<string name="library_display_size">Vis størrelse</string>
|
||||
<string name="library_display_store">Vis butikk</string>
|
||||
<string name="stores_sort_last_played">Nylig spilt</string>
|
||||
<string name="stores_sort_recently_installed">Nylig installert</string>
|
||||
<string name="stores_sort_title_asc">Tittel A–Å</string>
|
||||
|
||||
@@ -2628,6 +2628,7 @@
|
||||
<string name="library_display_smaller">Kleinere kaarten</string>
|
||||
<string name="library_display_title">Titel tonen</string>
|
||||
<string name="library_display_size">Grootte tonen</string>
|
||||
<string name="library_display_store">Winkel tonen</string>
|
||||
<string name="stores_sort_last_played">Onlangs gespeeld</string>
|
||||
<string name="stores_sort_recently_installed">Onlangs geïnstalleerd</string>
|
||||
<string name="stores_sort_title_asc">Titel A–Z</string>
|
||||
|
||||
@@ -2680,6 +2680,7 @@
|
||||
<string name="library_display_smaller">Mniejsze karty</string>
|
||||
<string name="library_display_title">Pokazuj tytuł</string>
|
||||
<string name="library_display_size">Pokazuj rozmiar</string>
|
||||
<string name="library_display_store">Pokazuj sklep</string>
|
||||
<string name="stores_sort_last_played">Ostatnio grane</string>
|
||||
<string name="stores_sort_recently_installed">Ostatnio zainstalowane</string>
|
||||
<string name="stores_sort_title_asc">Tytuł A–Z</string>
|
||||
|
||||
@@ -2660,6 +2660,7 @@
|
||||
<string name="library_display_smaller">Cartões mais pequenos</string>
|
||||
<string name="library_display_title">Mostrar título</string>
|
||||
<string name="library_display_size">Mostrar tamanho</string>
|
||||
<string name="library_display_store">Mostrar loja</string>
|
||||
<string name="stores_sort_last_played">Jogados recentemente</string>
|
||||
<string name="stores_sort_recently_installed">Instalados recentemente</string>
|
||||
<string name="stores_sort_title_asc">Título A–Z</string>
|
||||
|
||||
@@ -2670,6 +2670,7 @@
|
||||
<string name="library_display_smaller">Cards menores</string>
|
||||
<string name="library_display_title">Mostrar título</string>
|
||||
<string name="library_display_size">Mostrar tamanho</string>
|
||||
<string name="library_display_store">Mostrar loja</string>
|
||||
<string name="stores_sort_last_played">Jogados recentemente</string>
|
||||
<string name="stores_sort_recently_installed">Instalados recentemente</string>
|
||||
<string name="stores_sort_title_asc">Título A–Z</string>
|
||||
|
||||
@@ -2654,6 +2654,7 @@
|
||||
<string name="library_display_smaller">Carduri mai mici</string>
|
||||
<string name="library_display_title">Afișează titlul</string>
|
||||
<string name="library_display_size">Afișează dimensiunea</string>
|
||||
<string name="library_display_store">Afișează magazinul</string>
|
||||
<string name="stores_sort_last_played">Jucate recent</string>
|
||||
<string name="stores_sort_recently_installed">Instalate recent</string>
|
||||
<string name="stores_sort_title_asc">Titlu A–Z</string>
|
||||
|
||||
@@ -2681,6 +2681,7 @@
|
||||
<string name="library_display_smaller">Мелкие карточки</string>
|
||||
<string name="library_display_title">Показывать название</string>
|
||||
<string name="library_display_size">Показывать размер</string>
|
||||
<string name="library_display_store">Показывать магазин</string>
|
||||
<string name="stores_sort_last_played">Недавно запущенные</string>
|
||||
<string name="stores_sort_recently_installed">Недавно установленные</string>
|
||||
<string name="stores_sort_title_asc">Название А–Я</string>
|
||||
|
||||
@@ -2628,6 +2628,7 @@
|
||||
<string name="library_display_smaller">Mindre kort</string>
|
||||
<string name="library_display_title">Visa titel</string>
|
||||
<string name="library_display_size">Visa storlek</string>
|
||||
<string name="library_display_store">Visa butik</string>
|
||||
<string name="stores_sort_last_played">Senast spelade</string>
|
||||
<string name="stores_sort_recently_installed">Senast installerade</string>
|
||||
<string name="stores_sort_title_asc">Titel A–Ö</string>
|
||||
|
||||
@@ -2603,6 +2603,7 @@
|
||||
<string name="library_display_smaller">การ์ดเล็กลง</string>
|
||||
<string name="library_display_title">แสดงชื่อ</string>
|
||||
<string name="library_display_size">แสดงขนาด</string>
|
||||
<string name="library_display_store">แสดงร้านค้า</string>
|
||||
<string name="stores_sort_last_played">เล่นล่าสุด</string>
|
||||
<string name="stores_sort_recently_installed">เพิ่งติดตั้ง</string>
|
||||
<string name="stores_sort_title_asc">ชื่อ A–Z</string>
|
||||
|
||||
@@ -2620,6 +2620,7 @@
|
||||
<string name="library_display_smaller">Daha küçük kartlar</string>
|
||||
<string name="library_display_title">Başlığı göster</string>
|
||||
<string name="library_display_size">Boyutu göster</string>
|
||||
<string name="library_display_store">Mağazayı göster</string>
|
||||
<string name="stores_sort_last_played">Son oynanan</string>
|
||||
<string name="stores_sort_recently_installed">Son yüklenen</string>
|
||||
<string name="stores_sort_title_asc">Başlık A–Z</string>
|
||||
|
||||
@@ -2680,6 +2680,7 @@
|
||||
<string name="library_display_smaller">Малі картки</string>
|
||||
<string name="library_display_title">Показувати назву</string>
|
||||
<string name="library_display_size">Показувати розмір</string>
|
||||
<string name="library_display_store">Показувати магазин</string>
|
||||
<string name="stores_sort_last_played">Нещодавно запущені</string>
|
||||
<string name="stores_sort_recently_installed">Нещодавно встановлені</string>
|
||||
<string name="stores_sort_title_asc">Назва А–Я</string>
|
||||
|
||||
@@ -2603,6 +2603,7 @@
|
||||
<string name="library_display_smaller">Thẻ nhỏ hơn</string>
|
||||
<string name="library_display_title">Hiện tiêu đề</string>
|
||||
<string name="library_display_size">Hiện kích thước</string>
|
||||
<string name="library_display_store">Hiện cửa hàng</string>
|
||||
<string name="stores_sort_last_played">Chơi gần đây</string>
|
||||
<string name="stores_sort_recently_installed">Cài gần đây</string>
|
||||
<string name="stores_sort_title_asc">Tên A–Z</string>
|
||||
|
||||
@@ -2680,6 +2680,7 @@
|
||||
<string name="library_display_smaller">较小卡片</string>
|
||||
<string name="library_display_title">显示标题</string>
|
||||
<string name="library_display_size">显示大小</string>
|
||||
<string name="library_display_store">显示商店</string>
|
||||
<string name="stores_sort_last_played">最近游玩</string>
|
||||
<string name="stores_sort_recently_installed">最近安装</string>
|
||||
<string name="stores_sort_title_asc">标题 A–Z</string>
|
||||
|
||||
@@ -2600,6 +2600,7 @@
|
||||
<string name="library_display_smaller">較小卡片</string>
|
||||
<string name="library_display_title">顯示標題</string>
|
||||
<string name="library_display_size">顯示大小</string>
|
||||
<string name="library_display_store">顯示商店</string>
|
||||
<string name="stores_sort_last_played">最近遊玩</string>
|
||||
<string name="stores_sort_recently_installed">最近安裝</string>
|
||||
<string name="stores_sort_title_asc">標題 A–Z</string>
|
||||
|
||||
@@ -2600,6 +2600,7 @@
|
||||
<string name="library_display_smaller">較小的卡片</string>
|
||||
<string name="library_display_title">顯示標題</string>
|
||||
<string name="library_display_size">顯示大小</string>
|
||||
<string name="library_display_store">顯示商店</string>
|
||||
<string name="stores_sort_last_played">最近遊玩</string>
|
||||
<string name="stores_sort_recently_installed">最近安裝</string>
|
||||
<string name="stores_sort_title_asc">標題 A–Z</string>
|
||||
|
||||
@@ -1224,6 +1224,10 @@
|
||||
<string name="lab_not_loaded">Not loaded: %1$s</string>
|
||||
<string name="lab_waiting">Waiting for a restart</string>
|
||||
<string name="lab_kept">Kept</string>
|
||||
<plurals name="lab_kept_count">
|
||||
<item quantity="one">%d kept build</item>
|
||||
<item quantity="other">%d kept builds</item>
|
||||
</plurals>
|
||||
<string name="lab_other_install">For another version</string>
|
||||
<string name="lab_rebuild">Rebuild</string>
|
||||
<string name="lab_delete_warning">Deletes this build from the device</string>
|
||||
@@ -2981,6 +2985,7 @@
|
||||
<string name="library_display_smaller">Smaller cards</string>
|
||||
<string name="library_display_title">Show title</string>
|
||||
<string name="library_display_size">Show size</string>
|
||||
<string name="library_display_store">Show store</string>
|
||||
<string name="stores_sort_last_played">Recently played</string>
|
||||
<string name="stores_sort_recently_installed">Recently installed</string>
|
||||
<string name="stores_sort_title_asc">Title A–Z</string>
|
||||
|
||||
@@ -41,7 +41,18 @@ class DesktopLanguageIndexSourceTest {
|
||||
context = ApplicationProvider.getApplicationContext()
|
||||
DownloadSource.init(context)
|
||||
DownloadSource.setMode(context, DownloadSource.MODE_MIRROR)
|
||||
}
|
||||
|
||||
// Downloads other tests leave running also go through this proxy while it is set, so it is set only around [block].
|
||||
private fun tunnelsDuring(block: () -> Unit): List<String> {
|
||||
DownloadSource.setProxy(context, "127.0.0.1:${proxy.localPort}")
|
||||
tunnels.clear()
|
||||
try {
|
||||
block()
|
||||
} finally {
|
||||
DownloadSource.setProxy(context, "")
|
||||
}
|
||||
return tunnels.toList()
|
||||
}
|
||||
|
||||
@After fun tearDown() {
|
||||
@@ -51,12 +62,12 @@ class DesktopLanguageIndexSourceTest {
|
||||
}
|
||||
|
||||
@Test fun mirrorModeWouldOtherwiseSendTheIndexThroughAMirror() {
|
||||
Downloader.downloadString(base + "desktop-kde.i18n.txt")
|
||||
assertTrue(tunnels.toString(), tunnels.any { host -> DownloadSource.MIRRORS.any { it.host == host } })
|
||||
val seen = tunnelsDuring { Downloader.downloadString(base + "desktop-kde.i18n.txt") }
|
||||
assertTrue(seen.toString(), seen.any { host -> DownloadSource.MIRRORS.any { it.host == host } })
|
||||
}
|
||||
|
||||
@Test fun indexIsFetchedOnlyFromGithubInMirrorMode() {
|
||||
assertNull(DesktopLanguage.fetchIndex(base))
|
||||
assertEquals(listOf("github.com"), tunnels.toList())
|
||||
val seen = tunnelsDuring { assertNull(DesktopLanguage.fetchIndex(base)) }
|
||||
assertEquals(listOf("github.com"), seen)
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,21 @@ import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class SessionVisibilityPolicyTest {
|
||||
@Test fun attachmentPickerKeepsTheDockedDrawerAliveDuringActivityStop() {
|
||||
assertFalse(SessionVisibilityPolicy.shouldCloseSecondScreenOnStop(
|
||||
screenOff = false, dockedDrawerOpen = true, attachmentPickerOpen = true,
|
||||
))
|
||||
assertTrue(SessionVisibilityPolicy.shouldCloseSecondScreenOnStop(
|
||||
screenOff = false, dockedDrawerOpen = true, attachmentPickerOpen = false,
|
||||
))
|
||||
assertTrue(SessionVisibilityPolicy.shouldCloseSecondScreenOnStop(
|
||||
screenOff = false, dockedDrawerOpen = false, attachmentPickerOpen = true,
|
||||
))
|
||||
assertFalse(SessionVisibilityPolicy.shouldCloseSecondScreenOnStop(
|
||||
screenOff = true, dockedDrawerOpen = false, attachmentPickerOpen = false,
|
||||
))
|
||||
}
|
||||
|
||||
@Test fun handsetScreenStateControlsActivityOnDefaultDisplay() {
|
||||
assertFalse(SessionVisibilityPolicy.isHidden(true, true, true, false))
|
||||
assertTrue(SessionVisibilityPolicy.isHidden(true, false, true, true))
|
||||
|
||||
@@ -25,11 +25,17 @@ class LibraryDisplayTest {
|
||||
assertFalse(LibraryDisplay.size)
|
||||
}
|
||||
|
||||
@Test fun storeBannerDefaultsOn() {
|
||||
assertTrue(LibraryDisplay.store)
|
||||
}
|
||||
|
||||
@Test fun savedChoicesStillLoad() {
|
||||
LibraryDisplay.toggleTitle(context)
|
||||
LibraryDisplay.toggleSize(context)
|
||||
LibraryDisplay.toggleStore(context)
|
||||
LibraryDisplay.load(context)
|
||||
assertTrue(LibraryDisplay.title)
|
||||
assertTrue(LibraryDisplay.size)
|
||||
assertFalse(LibraryDisplay.store)
|
||||
}
|
||||
}
|
||||
@@ -9,15 +9,7 @@ publishes it on the Steam Deck client channels. `droiddeck-steam-install` instal
|
||||
- The default is `steamdeck_publicbeta` (manifest `steam_client_steamdeck_publicbeta_linuxarm64`).
|
||||
Valve also publishes `steam_client_steamdeck_stable_linuxarm64`.
|
||||
- `droiddeck-steam-install --channel` prints the channel in use. The session passes that value as
|
||||
`-clientbeta` and writes it to `package/beta` before every start, also when the file is missing.
|
||||
The two must match, or the client loops on rc 42.
|
||||
- Valve's client keeps a `steamdeck_*` beta only when it runs as a Steam Deck. Without `-steamdeck` it
|
||||
clears the beta a few seconds after sign-in ("Client beta changed from 'steamdeck_publicbeta' to ''"),
|
||||
deletes `package/beta`, downloads the desktop `steam_client_linuxarm64` client and exits with rc 42.
|
||||
In the stored session logs this happened in 722 desktop UI starts and in none of 27,429 Deck mode
|
||||
starts. The desktop UI therefore starts the arm64 client with `-steamdeck` too, without `-steamos3`
|
||||
or `-gamepadui`. Bazzite's Desktop Mode launcher does the same to keep the update branch between
|
||||
Desktop and Game Mode.
|
||||
`-clientbeta` and writes it to `package/beta`. The two must match, or the client loops on rc 42.
|
||||
- Setting: `DD_STEAM_CHANNEL`, otherwise `~/.config/droiddeck/steam-channel`, set to `beta` or
|
||||
`stable`. A set channel never changes on its own.
|
||||
- With no setting, the client falls back to `steamdeck_stable` automatically. It stays on stable
|
||||
|
||||
@@ -1641,9 +1641,6 @@ case $mode in
|
||||
export STEAM_GAMESCOPE_FANCY_SCALING_SUPPORT=1
|
||||
echo "== steam: Deck mode on (-steamdeck -steamos3)"
|
||||
fi
|
||||
elif [ "$steam_x64" = 0 ]; then
|
||||
_dd_ui+=(-steamdeck)
|
||||
echo "== steam: desktop UI on the Steam Deck client channel (-steamdeck)"
|
||||
fi
|
||||
export STEAMOS_STEAM_SHUTDOWN_SENTINEL="$HOME/.dd-steam-shutdown"
|
||||
export STEAMOS_STEAM_REBOOT_SENTINEL="$HOME/.dd-steam-reboot"
|
||||
@@ -2036,12 +2033,10 @@ case $mode in
|
||||
fi
|
||||
while :; do
|
||||
rm -f "$HOME/.dd-restart-once" "$HOME/.dd-restart-lost"
|
||||
_dd_beta=$(cat "$steam_beta" 2>/dev/null || true)
|
||||
if [ "$_dd_beta" != "$steam_channel" ] && [ -d "${steam_beta%/*}" ]; then
|
||||
echo "== steam: client branch on disk was '${_dd_beta:-missing}', set to '$steam_channel' to match -clientbeta"
|
||||
if [ -f "$steam_beta" ] && [ "$(cat "$steam_beta" 2>/dev/null)" != "$steam_channel" ]; then
|
||||
echo "== steam: client branch on disk was '$(cat "$steam_beta" 2>/dev/null)', set to '$steam_channel' to match -clientbeta"
|
||||
echo "$steam_channel" > "$steam_beta"
|
||||
fi
|
||||
unset _dd_beta
|
||||
if [ -z "${_dd_counted:-}" ] && [ -z "${DD_DESKTOP:-}" ]; then
|
||||
echo start >> "$steam_root/package/droiddeck-unconfirmed"
|
||||
_dd_counted=1
|
||||
|
||||
@@ -33,6 +33,13 @@ class CiChecksTest(unittest.TestCase):
|
||||
robolectric = [cache['path'] for cache in caches if cache['key'].startswith('robolectric-')]
|
||||
self.assertEqual(robolectric, ['${{ steps.robolectric-jars.outputs.path }}'] * 2)
|
||||
|
||||
def test_only_main_saves_the_robolectric_cache(self):
|
||||
steps = yaml.safe_load((ROOT / '.github/workflows/unit-tests.yml').read_text())['jobs']['unit-tests']['steps']
|
||||
saves = [step for step in steps if step.get('uses', '').startswith('actions/cache/save')
|
||||
and step['with']['key'].startswith('robolectric-')]
|
||||
self.assertEqual(len(saves), 1)
|
||||
self.assertIn("github.event_name != 'pull_request'", saves[0]['if'])
|
||||
|
||||
def test_unit_test_retry_requires_maven_exception(self):
|
||||
steps = yaml.safe_load((ROOT / '.github/workflows/unit-tests.yml').read_text())['jobs']['unit-tests']['steps']
|
||||
run = next(step['run'] for step in steps if step.get('id') == 'unit-tests')
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
from tools.tests.test_vk_pending_completion import function
|
||||
|
||||
|
||||
class FramegenHangBreakerTest(unittest.TestCase):
|
||||
def run_c(self, body):
|
||||
compiler = shutil.which(os.environ.get('CC', 'cc'))
|
||||
if not compiler:
|
||||
self.skipTest('A host C compiler is required')
|
||||
root = Path(__file__).resolve().parents[2]
|
||||
source = (root / 'app/src/main/cpp/waylandcomp/src/framegen_bridge.c').read_text()
|
||||
code = '#include <assert.h>\n#include <stdatomic.h>\n#include <stdint.h>\n'
|
||||
code += '#define FG_PROVEN_FRAMES 120\n#define FG_HANG_STRIKES 2\n'
|
||||
code += 'static _Atomic int g_hang_strikes, g_dev_lost;\n'
|
||||
code += 'static int g_submitted_since_ready;\nstatic uint64_t g_total_generated, g_generated_at_ready;\n'
|
||||
code += function(source, 'framegen_loss_strike')
|
||||
code += function(source, 'framegen_count_loss')
|
||||
code += 'int main(void) {\n' + body + '\n}\n'
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
folder = Path(tmp)
|
||||
probe = folder / 'breaker.c'
|
||||
binary = folder / 'breaker'
|
||||
probe.write_text(code)
|
||||
subprocess.run([compiler, '-std=c11', str(probe), '-o', str(binary)], check=True,
|
||||
capture_output=True, text=True)
|
||||
subprocess.run([str(binary)], check=True, capture_output=True, timeout=10)
|
||||
|
||||
def test_losses_before_any_generated_frame_completes_switch_generation_off(self):
|
||||
self.run_c('''
|
||||
assert(framegen_loss_strike(1, 0) == 0);
|
||||
assert(framegen_loss_strike(1, 0) == 1);
|
||||
assert(framegen_loss_strike(1, 0) == 0);
|
||||
''')
|
||||
|
||||
def test_a_loss_after_generation_worked_keeps_it_armed(self):
|
||||
self.run_c('''
|
||||
assert(framegen_loss_strike(1, 0) == 0);
|
||||
assert(framegen_loss_strike(1, 500) == 0);
|
||||
assert(framegen_loss_strike(1, 0) == 0);
|
||||
''')
|
||||
|
||||
def test_a_loss_without_generation_work_is_not_a_strike(self):
|
||||
self.run_c('''
|
||||
assert(framegen_loss_strike(1, 0) == 0);
|
||||
assert(framegen_loss_strike(0, 0) == 0);
|
||||
assert(framegen_loss_strike(1, 0) == 0);
|
||||
''')
|
||||
|
||||
def test_a_loss_reported_twice_counts_once(self):
|
||||
self.run_c('''
|
||||
for (int loss = 0; loss < 2; loss++) {
|
||||
g_dev_lost = 0;
|
||||
g_submitted_since_ready = 1;
|
||||
int first = framegen_count_loss();
|
||||
int again = framegen_count_loss();
|
||||
assert(again == 0);
|
||||
assert(first == (loss == 1));
|
||||
}
|
||||
''')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -184,20 +184,3 @@ class DesktopSteamLaunchTest(unittest.TestCase):
|
||||
env=env, text=True)
|
||||
self.assertEqual('-cef-disable-gpu' in result, software)
|
||||
self.assertEqual('-cef-use-angle=vulkan' in result, not software)
|
||||
|
||||
def test_the_arm64_desktop_client_runs_as_a_steam_deck_so_it_keeps_the_deck_channel(self):
|
||||
source = (BIN / 'droiddeck-session').read_text()
|
||||
setup = source[source.index(' _dd_ui=(-gamepadui)'):source.index(' export STEAMOS_STEAM_SHUTDOWN_SENTINEL=')]
|
||||
cases = [
|
||||
('0', '1', 'desktop', ['-nobigpicture', '-steamdeck']),
|
||||
('0', '', 'desktop', ['-steamdeck']),
|
||||
('0', '1', 'bigpicture', ['-gamepadui', '-steamdeck', '-steamos3']),
|
||||
('1', '1', 'desktop', ['-nobigpicture']),
|
||||
('1', '1', 'bigpicture', ['-gamepadui', '-steamdeck', '-steamos3']),
|
||||
]
|
||||
for x64, desktop, ui, flags in cases:
|
||||
with self.subTest(x64=x64, desktop=desktop, ui=ui):
|
||||
env = dict(self.env, steam_x64=x64, DD_DESKTOP=desktop, DD_STEAM_UI=ui, DD_VKBRIDGE='0')
|
||||
result = subprocess.check_output(['bash', '-c', setup + '\nprintf "%s\\n" "${_dd_ui[@]}"'],
|
||||
env=env, text=True)
|
||||
self.assertEqual(flags, [line for line in result.splitlines() if line.startswith('-')])
|
||||
@@ -119,45 +119,5 @@ class SessionChannelTest(unittest.TestCase):
|
||||
self.assertIn('echo "$steam_channel" > "$steam_beta"', SESSION)
|
||||
|
||||
|
||||
class SessionBetaFileTest(unittest.TestCase):
|
||||
BLOCK = re.search(r'\n( +_dd_beta=\$\(cat "\$steam_beta".*?\n +unset _dd_beta\n)', SESSION, re.S).group(1)
|
||||
|
||||
def run_block(self, package, existing=None):
|
||||
beta = package / 'beta'
|
||||
if existing is not None:
|
||||
package.mkdir(parents=True)
|
||||
beta.write_text(existing)
|
||||
env = dict(os.environ, steam_beta=str(beta), steam_channel='steamdeck_publicbeta')
|
||||
result = subprocess.run(['bash', '-uc', self.BLOCK], env=env, capture_output=True, text=True, timeout=30)
|
||||
self.assertEqual(0, result.returncode, result.stderr)
|
||||
return beta, result.stdout
|
||||
|
||||
def test_a_branch_file_the_client_deleted_is_written_again(self):
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
package = Path(temp) / 'package'
|
||||
package.mkdir()
|
||||
beta, out = self.run_block(package)
|
||||
self.assertEqual('steamdeck_publicbeta\n', beta.read_text())
|
||||
self.assertIn("was 'missing', set to 'steamdeck_publicbeta'", out)
|
||||
|
||||
def test_another_branch_is_replaced(self):
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
beta, out = self.run_block(Path(temp) / 'package', 'steamdeck_stable\n')
|
||||
self.assertEqual('steamdeck_publicbeta\n', beta.read_text())
|
||||
self.assertIn("was 'steamdeck_stable'", out)
|
||||
|
||||
def test_the_selected_branch_is_left_alone(self):
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
beta, out = self.run_block(Path(temp) / 'package', 'steamdeck_publicbeta\n')
|
||||
self.assertEqual('steamdeck_publicbeta\n', beta.read_text())
|
||||
self.assertEqual('', out)
|
||||
|
||||
def test_nothing_is_created_without_a_client(self):
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
beta, out = self.run_block(Path(temp) / 'package')
|
||||
self.assertFalse(beta.parent.exists())
|
||||
self.assertEqual('', out)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user