mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-27 08:35:42 +00:00
Compare commits
6
Commits
fix/sd-gap-fill
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f0a4b084d9 | ||
|
|
ae66be5521 | ||
|
|
aef4a11595 | ||
|
|
cc04546373 | ||
|
|
bdd3d247c3 | ||
|
|
e71c37b34f |
No files matched your search
@@ -1769,6 +1769,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
wowChat = wowChat.remembered,
|
||||
onWowChat = wowChat::choose,
|
||||
controller = controllerSettings,
|
||||
onControllerSize = { percent -> updateControllerPrefs { ControllerPrefs.setSize(this@SessionActivity, percent) } },
|
||||
onRumble = { on -> updateControllerPrefs { ControllerPrefs.setRumble(this@SessionActivity, on) } },
|
||||
onSteamMenu = if (SessionState.mode == SessionService.MODE_STEAM) ({ sendSteamGuide() }) else null,
|
||||
onQam = if (SessionState.mode == SessionService.MODE_STEAM) ({ triggerSteamQam() }) else null,
|
||||
@@ -2110,6 +2111,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
change()
|
||||
controllerSettings = ControllerPrefs.read(this)
|
||||
onScreenControls?.reload()
|
||||
bottomInputControls?.reload()
|
||||
unfoldedPanel?.reload()
|
||||
}
|
||||
|
||||
private fun routeBackAction() {
|
||||
@@ -2846,7 +2849,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
|
||||
private fun installProton(): String? {
|
||||
uiHandler.post { loading.percent = -1; loading.say(getString(PROTON_LINES.downloading), PROTON_LINES.topic, readable = true) }
|
||||
if (com.droiddeck.launcher.session.SessionPrefs.ownProtonFirst(this)) return installOwnProton()
|
||||
val catalog = com.droiddeck.launcher.runtime.DesktopCatalog
|
||||
val cancellation = com.droiddeck.launcher.core.Downloader.Cancellation { SessionState.stopRequested }
|
||||
SessionState.installCancellation = cancellation
|
||||
@@ -2859,24 +2861,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}
|
||||
}
|
||||
|
||||
private fun installOwnProton(): String? {
|
||||
val extras = com.droiddeck.launcher.session.ProtonExtras
|
||||
while ((extras.prefetching || extras.installInProgress) && !SessionState.stopRequested) {
|
||||
try { Thread.sleep(250) } catch (_: InterruptedException) { Thread.currentThread().interrupt(); return "interrupted" }
|
||||
}
|
||||
if (SessionState.stopRequested) return "cancelled"
|
||||
if (!com.droiddeck.launcher.runtime.DesktopCatalog.ownProtonMissing(this)) return null
|
||||
val cancellation = com.droiddeck.launcher.core.Downloader.Cancellation { SessionState.stopRequested }
|
||||
SessionState.installCancellation = cancellation
|
||||
return try {
|
||||
extras.install(this, extras.tools.first { it.id == extras.OWN }, cancellation) { label, percent ->
|
||||
uiHandler.post { loading.percent = percent; loading.say(label, PROTON_LINES.topic, readable = true) }
|
||||
}.also { if (it == null) com.droiddeck.launcher.session.Onboarding.recheck(this) }
|
||||
} finally {
|
||||
if (SessionState.installCancellation === cancellation) SessionState.installCancellation = null
|
||||
}
|
||||
}
|
||||
|
||||
override fun surfaceCreated(holder: SurfaceHolder) {
|
||||
if (holder !== outputHolder()) return
|
||||
if (installingRuntime || SessionState.stopRequested || ended) return
|
||||
|
||||
@@ -126,6 +126,16 @@ object AgentSetup {
|
||||
Thread({ for ((step, command) in probes) probe(app, harness, step, command) }, "agent-checks").start()
|
||||
}
|
||||
|
||||
/** The last failed refresh ends the script: the installs after it would run from stale indexes and could report success. */
|
||||
internal fun installScript(harnessInstall: String) = "set -e; export DEBIAN_FRONTEND=noninteractive; " +
|
||||
"apt() { apt-get -o Acquire::Retries=5 -o Acquire::http::Timeout=30 \"\$@\"; }; " +
|
||||
"dpkg --configure -a || echo 'Some packages are not configured yet; repairing dependencies'; " +
|
||||
"for i in 1 2 3; do apt -o APT::Update::Error-Mode=any update -q && break; " +
|
||||
"[ \$i = 3 ] && { echo 'Some package sources could not be refreshed'; exit 1; }; " +
|
||||
"echo 'Some package sources could not be refreshed; retrying'; sleep 3; done; " +
|
||||
"apt -f install -y --fix-missing; " +
|
||||
"apt install -y --no-install-recommends git gh adb curl ca-certificates python3; $harnessInstall"
|
||||
|
||||
fun runsAsRoot(step: Step) = step == Step.INSTALL
|
||||
|
||||
/** Runs [step]'s action. [CONNECTION] is the app's own pairing flow, so the caller opens it. */
|
||||
@@ -140,12 +150,7 @@ object AgentSetup {
|
||||
val command = override ?: when (step) {
|
||||
Step.CONNECTION -> return
|
||||
Step.INSTALL -> {
|
||||
listOf("sh", "-c", "set -e; export DEBIAN_FRONTEND=noninteractive; " +
|
||||
"apt() { apt-get -o Acquire::Retries=5 -o Acquire::http::Timeout=30 \"\$@\"; }; " +
|
||||
"dpkg --configure -a || echo 'Some packages are not configured yet; repairing dependencies'; " +
|
||||
"for i in 1 2 3; do apt -o APT::Update::Error-Mode=any update -q && break; echo 'Some package sources could not be refreshed; retrying'; sleep 3; done; " +
|
||||
"apt -f install -y --fix-missing; " +
|
||||
"apt install -y --no-install-recommends git gh adb curl ca-certificates python3; ${harness.install}")
|
||||
listOf("sh", "-c", installScript(harness.install))
|
||||
}
|
||||
Step.SIGN_IN -> harness.signIn
|
||||
Step.GITHUB -> listOf("dd-gh-login")
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.droiddeck.launcher.session.SessionPrefs
|
||||
|
||||
internal object DroidDeckHudConfig {
|
||||
val DEFAULTS: Map<String, String> = linkedMapOf(
|
||||
"hudSize" to "minimal", "hudLocked" to "1", "hudHold" to "collapse", "hudSnap" to "1", "hudScale" to "100", "hudDock" to "none", "hudOpacity" to "80", "hudColor" to "mid",
|
||||
"hudSize" to "minimal", "hudLocked" to "0", "hudHold" to "collapse", "hudSnap" to "1", "hudScale" to "100", "hudDock" to "none", "hudOpacity" to "80", "hudColor" to "mid",
|
||||
"hudOutline" to "40", "hudOutlineAccent" to "1",
|
||||
"showGpuModel" to "1", "showGPULoad" to "1", "showCPUUsage" to "1", "showCPULoad" to "1",
|
||||
"showPerCore" to "1", "showTemp" to "1", "showBatteryTemp" to "1", "showGpuTemp" to "0",
|
||||
|
||||
@@ -349,7 +349,7 @@ class DroidDeckHudView(context: Context) : View(context) {
|
||||
showProton = switchOn("showProton")
|
||||
showSession = switchOn("showSession")
|
||||
tempDisplay = HudMetrics.TempDisplay.from(cfg)
|
||||
lockController.setLocked(cfg.get("hudLocked", "1") == "1")
|
||||
lockController.setLocked(cfg.get("hudLocked", "0") == "1")
|
||||
lockController.setHoldLocks(cfg.get("hudHold", "collapse") == DroidDeckHudConfig.HOLD_LOCKS)
|
||||
dock = DroidDeckHudDock.from(cfg.get("hudDock", "none"))
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ object ControllerPrefs {
|
||||
|
||||
val opacities = listOf(40, 60, 80, 100)
|
||||
|
||||
val sizes = listOf(80, 90, 100, 110, 125)
|
||||
val sizes = listOf(80, 85, 90, 95, 100, 105, 110, 115, 120, 125)
|
||||
|
||||
val deadZones = listOf(0, 5, 8, 12, 15, 20, 25)
|
||||
const val DEFAULT_DEAD_ZONE_PERCENT = 12
|
||||
|
||||
@@ -5,7 +5,7 @@ import android.graphics.Rect
|
||||
import kotlin.math.*
|
||||
|
||||
internal class LegacyGamepadLayout(private val context: Context, private val width: Int, private val height: Int, private val safe: Rect = Rect(),
|
||||
private val scale: Float = 1f) {
|
||||
private val scale: Float = 1f, private val sizeOverride: Int? = null) {
|
||||
private val resources get() = context.resources
|
||||
private val settings = ControllerPrefs.read(context)
|
||||
private var fit = 1f
|
||||
@@ -41,7 +41,7 @@ internal class LegacyGamepadLayout(private val context: Context, private val wid
|
||||
|
||||
private fun dp(value: Float) = value * resources.displayMetrics.density
|
||||
|
||||
private fun scaled(value: Float) = dp(value) * settings.size / 100f * scale * fit
|
||||
private fun scaled(value: Float) = dp(value) * (sizeOverride ?: settings.size) / 100f * scale * fit
|
||||
|
||||
private fun fitScale(): Float {
|
||||
val metrics = resources.displayMetrics
|
||||
|
||||
@@ -44,9 +44,10 @@ object OnScreenLayout {
|
||||
val (reference, matched) = reference(context, layout, width, height)
|
||||
if (buttonsOnly && dock == null) return generator.buttonsOnly(stored) + fit(stored.filter { it.alwaysShown }, reference.first, reference.second, width, height, safe)
|
||||
if (dock?.portrait == true && !dock.grips && !matched && layout.aspect > 0f && layout.aspect < 1f && stored.any(::isGamepad))
|
||||
return cluster(stored.filterNot { it.alwaysShown || isGamepad(it) && (it.id == KEYBOARD_ID || it.control in BAR) }, layout.aspect, width, height, safe)
|
||||
val generated = matched || PadKit.forOverlay(context, layout) != null && stored.any(::isGamepad) &&
|
||||
(dock != null || height > width && layout.aspect >= 1f || height <= width && layout.aspect > 0f && layout.aspect < 1f)
|
||||
return scaleDocked(context, cluster(stored.filterNot { it.alwaysShown || isGamepad(it) && (it.id == KEYBOARD_ID || it.control in BAR) }, layout.aspect, width, height, safe), ControllerPrefs.read(context).size / 100f, width, height, safe)
|
||||
val oppositeOrientation = layout.aspect > 0f && ((layout.aspect < 1f) != (height > width))
|
||||
val generated = matched ||
|
||||
dock == null && oppositeOrientation && stored.any(::isGamepad)
|
||||
val gamepad = if (generated) stored.filter(::isGamepad) else emptyList()
|
||||
val others = fit(stored.filterNot { generated && isGamepad(it) || dock != null && it.alwaysShown }, reference.first, reference.second, width, height, safe)
|
||||
val regenerated = when {
|
||||
@@ -57,22 +58,144 @@ object OnScreenLayout {
|
||||
val placed = regenerated + gamepad.filter { g -> dock == null && optional(g) && regenerated.none { it.id == g.id } }
|
||||
val byId = (placed + others).associateBy { it.id }
|
||||
val ordered = stored.mapNotNull { byId[it.id] } + placed.filter { p -> stored.none { it.id == p.id } }
|
||||
val kit = PadKit.forOverlay(context, layout) ?: return ordered
|
||||
val kit = PadKit.forOverlay(context, layout) ?: return if (dock == null) ordered else scaleDocked(context, ordered, ControllerPrefs.read(context).size / 100f, width, height, safe)
|
||||
val controllerScale = layout.scale * ControllerPrefs.read(context).size / 100f
|
||||
if (generated &&
|
||||
ControllerPrefs.layout(context, reference.first.toInt(), reference.second.toInt()).isEmpty() &&
|
||||
ControllerPrefs.layout(context, width, height).isEmpty()) {
|
||||
if (dock != null || height > width) {
|
||||
return ControllerPortraitGeometry(width.toFloat(), height.toFloat(), safe, context.resources.displayMetrics.density)
|
||||
.place(ordered, kit, dock != null, layout.scale, rearButtons == true, trackpads == true)
|
||||
val placed = ControllerPortraitGeometry(width.toFloat(), height.toFloat(), safe, context.resources.displayMetrics.density)
|
||||
.place(ordered, kit, dock != null, controllerScale, rearButtons == true, trackpads == true)
|
||||
return if (dock != null) {
|
||||
scaleDocked(context, placed, ControllerPrefs.read(context).size / 100f, width, height, safe)
|
||||
} else placed
|
||||
}
|
||||
return ControllerOverlayGeometry(width, height, safe, context.resources.displayMetrics, layout.scale)
|
||||
return ControllerOverlayGeometry(width, height, safe, context.resources.displayMetrics, controllerScale)
|
||||
.place(ordered, kit, rearButtons == true, trackpads == true)
|
||||
}
|
||||
if (dock != null || !kit.steam) return ordered
|
||||
if (dock != null || !kit.steam) {
|
||||
if (dock == null) return ordered
|
||||
return scaleDocked(context, ordered, ControllerPrefs.read(context).size / 100f, width, height, safe)
|
||||
}
|
||||
return FloatingSteamOverlay(width, height, safe, context.resources.displayMetrics.density)
|
||||
.place(ordered, lowerShortcuts = generated, rearButtons = rearButtons, trackpads = trackpads)
|
||||
}
|
||||
|
||||
private fun scaleDocked(context: Context, elements: List<InputSurfaceElement>, scale: Float, width: Int, height: Int, safe: Rect): List<InputSurfaceElement> {
|
||||
val usableWidth = (width - safe.left - safe.right).coerceAtLeast(1).toFloat() / width
|
||||
val usableHeight = (height - safe.top - safe.bottom).coerceAtLeast(1).toFloat() / height
|
||||
val leftBound = safe.left.toFloat() / width
|
||||
val rightBound = (width - safe.right).toFloat() / width
|
||||
val topBound = safe.top.toFloat() / height
|
||||
val bottomBound = (height - safe.bottom).toFloat() / height
|
||||
val scaled = elements.map { element ->
|
||||
if (!isGamepad(element)) return@map element
|
||||
val w = (element.width * scale).coerceIn(min(.001f, usableWidth), usableWidth)
|
||||
val h = (element.height * scale).coerceIn(min(.001f, usableHeight), usableHeight)
|
||||
val x = (element.x + element.width / 2f - w / 2f)
|
||||
.coerceIn(leftBound, (rightBound - w).coerceAtLeast(leftBound))
|
||||
val y = (element.y + element.height / 2f - h / 2f)
|
||||
.coerceIn(topBound, (bottomBound - h).coerceAtLeast(topBound))
|
||||
element.copy(x = x, y = y, width = w, height = h).bounded()
|
||||
}.toMutableList()
|
||||
if (scale > 1f) {
|
||||
val gap = 4f / width
|
||||
fun spacePair(leftControl: InputControl, rightControl: InputControl) {
|
||||
val li = scaled.indexOfFirst { isGamepad(it) && it.control == leftControl }
|
||||
val ri = scaled.indexOfFirst { isGamepad(it) && it.control == rightControl }
|
||||
if (li < 0 || ri < 0) return
|
||||
var left = scaled[li]
|
||||
var right = scaled[ri]
|
||||
val available = (rightBound - leftBound).coerceAtLeast(.001f)
|
||||
var gapSize = gap.coerceAtMost(available / 4f)
|
||||
if (left.width + right.width + gapSize > available) {
|
||||
val factor = ((available - gapSize).coerceAtLeast(0f) / (left.width + right.width)).coerceAtMost(1f)
|
||||
left = left.copy(width = left.width * factor)
|
||||
right = right.copy(width = right.width * factor)
|
||||
}
|
||||
val total = left.width + gapSize + right.width
|
||||
val center = ((left.x + left.width / 2f) + (right.x + right.width / 2f)) / 2f
|
||||
val start = (center - total / 2f).coerceIn(leftBound, (rightBound - total).coerceAtLeast(leftBound))
|
||||
scaled[li] = left.copy(x = start)
|
||||
scaled[ri] = right.copy(x = start + left.width + gapSize)
|
||||
}
|
||||
spacePair(InputControl.LT, InputControl.LB)
|
||||
spacePair(InputControl.RB, InputControl.RT)
|
||||
}
|
||||
if (scale > 1f && ControllerPrefs.layout(context, width, height).isEmpty()) {
|
||||
repeat(scaled.size) {
|
||||
for (i in scaled.indices) {
|
||||
if (!isGamepad(scaled[i])) continue
|
||||
for (j in i + 1 until scaled.size) {
|
||||
if (!isGamepad(scaled[j])) continue
|
||||
val a = scaled[i]
|
||||
val b = scaled[j]
|
||||
val overlapX = min(a.x + a.width, b.x + b.width) - max(a.x, b.x)
|
||||
val overlapY = min(a.y + a.height, b.y + b.height) - max(a.y, b.y)
|
||||
if (overlapX <= 0f || overlapY <= 0f) continue
|
||||
|
||||
val centerAX = a.x + a.width / 2f
|
||||
val centerBX = b.x + b.width / 2f
|
||||
val centerAY = a.y + a.height / 2f
|
||||
val centerBY = b.y + b.height / 2f
|
||||
if (overlapX / min(a.width, b.width) <= overlapY / min(a.height, b.height)) {
|
||||
val gapX = 2f / width
|
||||
val available = (rightBound - leftBound).coerceAtLeast(.001f)
|
||||
val leftFirst = centerAX <= centerBX
|
||||
val factor = ((available - gapX).coerceAtLeast(0f) / (a.width + b.width)).coerceIn(0f, 1f)
|
||||
val aw = a.width * factor
|
||||
val ah = a.height * factor
|
||||
val bw = b.width * factor
|
||||
val bh = b.height * factor
|
||||
val total = aw + gapX + bw
|
||||
val center = ((centerAX + centerBX) / 2f).coerceIn(
|
||||
leftBound + total / 2f,
|
||||
(rightBound - total / 2f).coerceAtLeast(leftBound + total / 2f))
|
||||
val firstX = center - total / 2f
|
||||
val secondX = firstX + (if (leftFirst) aw else bw) + gapX
|
||||
scaled[i] = if (leftFirst) {
|
||||
a.copy(x = firstX, y = centerAY - ah / 2f, width = aw, height = ah)
|
||||
} else {
|
||||
a.copy(x = secondX, y = centerAY - ah / 2f, width = aw, height = ah)
|
||||
}
|
||||
scaled[j] = if (leftFirst) {
|
||||
b.copy(x = secondX, y = centerBY - bh / 2f, width = bw, height = bh)
|
||||
} else {
|
||||
b.copy(x = firstX, y = centerBY - bh / 2f, width = bw, height = bh)
|
||||
}
|
||||
} else {
|
||||
val gapY = 2f / height
|
||||
val available = (bottomBound - topBound).coerceAtLeast(.001f)
|
||||
val topFirst = centerAY <= centerBY
|
||||
val factor = ((available - gapY).coerceAtLeast(0f) / (a.height + b.height)).coerceIn(0f, 1f)
|
||||
val aw = a.width * factor
|
||||
val ah = a.height * factor
|
||||
val bw = b.width * factor
|
||||
val bh = b.height * factor
|
||||
val total = ah + gapY + bh
|
||||
val center = ((centerAY + centerBY) / 2f).coerceIn(
|
||||
topBound + total / 2f,
|
||||
(bottomBound - total / 2f).coerceAtLeast(topBound + total / 2f))
|
||||
val firstY = center - total / 2f
|
||||
val secondY = firstY + (if (topFirst) ah else bh) + gapY
|
||||
scaled[i] = if (topFirst) {
|
||||
a.copy(x = centerAX - aw / 2f, y = firstY, width = aw, height = ah)
|
||||
} else {
|
||||
a.copy(x = centerAX - aw / 2f, y = secondY, width = aw, height = ah)
|
||||
}
|
||||
scaled[j] = if (topFirst) {
|
||||
b.copy(x = centerBX - bw / 2f, y = secondY, width = bw, height = bh)
|
||||
} else {
|
||||
b.copy(x = centerBX - bw / 2f, y = firstY, width = bw, height = bh)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return scaled
|
||||
}
|
||||
|
||||
fun oriented(layout: SavedInputLayout, width: Int, height: Int): SavedInputLayout = oriented(layout, height > width)
|
||||
|
||||
private fun oriented(layout: SavedInputLayout, portrait: Boolean): SavedInputLayout {
|
||||
@@ -181,7 +304,14 @@ object OnScreenLayout {
|
||||
?.let { (it * height).roundToInt().coerceAtLeast(1) to height }
|
||||
for ((w, h) in listOfNotNull(named, width to height, aspectSize, long to short, short to long).distinct()) {
|
||||
val generator = LegacyGamepadLayout(display, w, h, scale = layout.scale)
|
||||
if (matches(gamepad, generator.elements()) || matches(gamepad, generator.elements(previousStickGeometry = true))) return (w.toFloat() to h.toFloat()) to true
|
||||
val sizedGenerator = LegacyGamepadLayout(
|
||||
display, w, h, scale = layout.scale,
|
||||
sizeOverride = ControllerPrefs.read(context).size
|
||||
)
|
||||
if (matches(gamepad, generator.elements()) || matches(gamepad, generator.elements(previousStickGeometry = true)) ||
|
||||
matches(gamepad, sizedGenerator.elements()) || matches(gamepad, sizedGenerator.elements(previousStickGeometry = true))) {
|
||||
return (w.toFloat() to h.toFloat()) to true
|
||||
}
|
||||
}
|
||||
}
|
||||
val aspect = layout.aspect.takeIf { it > 0f } ?: (long.toFloat() / short)
|
||||
|
||||
@@ -39,6 +39,10 @@ internal object BuildWatermarkSetting {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
notifyChanged(context)
|
||||
}
|
||||
|
||||
fun notifyChanged(context: Context) {
|
||||
context.sendBroadcast(Intent(CHANGED).setPackage(context.packageName))
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,9 @@ object SessionPaths {
|
||||
@Volatile
|
||||
private var startedAt = 0L
|
||||
|
||||
@Volatile
|
||||
private var debugLogsContext: Context? = null
|
||||
|
||||
@Synchronized
|
||||
fun beginOrCurrent(context: Context, label: String? = null): File {
|
||||
dir?.let { if (it.isDirectory) return it }
|
||||
@@ -44,6 +47,7 @@ object SessionPaths {
|
||||
startedAt = System.currentTimeMillis()
|
||||
if (!made.isDirectory && !made.mkdirs()) Log.e(TAG, "could not create $made")
|
||||
dir = made
|
||||
debugLogsContext = if (SessionPrefs.gameDebugLogsEnabled(context)) context.applicationContext else null
|
||||
if (enhanced && !EnhancedDiagnostics.consumeInto(context, made)) {
|
||||
Log.e(TAG, "could not activate enhanced diagnostics for $made")
|
||||
}
|
||||
@@ -65,6 +69,9 @@ object SessionPaths {
|
||||
val taken = dir
|
||||
dir = null
|
||||
if (taken != null) ended = taken
|
||||
val expiring = debugLogsContext
|
||||
debugLogsContext = null
|
||||
if (taken != null && expiring != null) SessionPrefs.expireGameDebugLogs(expiring)
|
||||
return taken
|
||||
}
|
||||
|
||||
|
||||
@@ -1228,7 +1228,7 @@ object SessionPrefs {
|
||||
oldValue = logsEnabled(context),
|
||||
newValue = on,
|
||||
newEffective = gameDebugLogsEffective(context, on, gameDebugLogsEnabled(context)),
|
||||
)
|
||||
).also { if (it) BuildWatermarkSetting.notifyChanged(context) }
|
||||
}
|
||||
|
||||
fun gameDebugLogsEnabled(context: Context): Boolean =
|
||||
@@ -1241,7 +1241,13 @@ object SessionPrefs {
|
||||
oldValue = gameDebugLogsEnabled(context),
|
||||
newValue = on,
|
||||
newEffective = gameDebugLogsEffective(context, logsEnabled(context), on),
|
||||
)
|
||||
).also { if (it) BuildWatermarkSetting.notifyChanged(context) }
|
||||
}
|
||||
|
||||
/** The setting lasts for the session that started with it on; the next session's start republishes the environment. */
|
||||
internal fun expireGameDebugLogs(context: Context) {
|
||||
prefs(context).edit().putBoolean("gameDebugLogsEnabled", false).apply()
|
||||
runCatching { BuildWatermarkSetting.notifyChanged(context) }
|
||||
}
|
||||
|
||||
private fun setLogPreference(
|
||||
|
||||
@@ -81,10 +81,13 @@ object BuildWatermark {
|
||||
if (activity is QuestXrActivity) return
|
||||
val decor = activity.window.decorView as? ViewGroup ?: return
|
||||
decor.findViewWithTag<View>(TAG)?.let(decor::removeView)
|
||||
if (!com.droiddeck.launcher.session.SessionPrefs.buildWatermarkEnabled(activity)) return
|
||||
val lab = com.droiddeck.launcher.lab.LabOverlay.active?.let { "LAB | ${truncate(it.label)}" }
|
||||
val build = lineProvider().orEmpty()
|
||||
val content = (listOfNotNull(lab) + build).ifEmpty { return }
|
||||
val prefs = com.droiddeck.launcher.session.SessionPrefs
|
||||
val debugLogs = if (prefs.logsEnabled(activity) && prefs.gameDebugLogsEnabled(activity)) DEBUG_LOGS_LINE else null
|
||||
val build = if (prefs.buildWatermarkEnabled(activity)) {
|
||||
listOfNotNull(com.droiddeck.launcher.lab.LabOverlay.active?.let { "LAB | ${truncate(it.label)}" }) +
|
||||
lineProvider().orEmpty()
|
||||
} else emptyList()
|
||||
val content = (build + listOfNotNull(debugLogs)).ifEmpty { return }
|
||||
val margin = (8 * activity.resources.displayMetrics.density).toInt()
|
||||
decor.addView(
|
||||
MarkView(activity, content).apply { tag = TAG },
|
||||
@@ -96,6 +99,8 @@ object BuildWatermark {
|
||||
)
|
||||
}
|
||||
|
||||
internal const val DEBUG_LOGS_LINE = "GAME DEBUG LOGS ON | slows games"
|
||||
|
||||
private const val TAG = "build-watermark"
|
||||
|
||||
private class MarkView(context: Context, private val lines: List<String>) : View(context) {
|
||||
|
||||
@@ -226,10 +226,22 @@ internal fun GameDetail(
|
||||
val t = tab ?: return@LaunchedEffect
|
||||
if (!inPage) focusWithinFrames({ onStrip }) { tabFocus.getValue(t) }
|
||||
}
|
||||
var steppedTo by remember(key) { mutableStateOf<GameTab?>(null) }
|
||||
LaunchedEffect(steppedTo, tab) {
|
||||
val t = steppedTo ?: return@LaunchedEffect
|
||||
if (t != tab) {
|
||||
steppedTo = null
|
||||
return@LaunchedEffect
|
||||
}
|
||||
focusSoon { tabFocus.getValue(t) }
|
||||
steppedTo = null
|
||||
}
|
||||
fun cycle(step: Int) {
|
||||
if (tabs.size < 2) return
|
||||
val at = tabs.indexOf(tab).coerceAtLeast(0)
|
||||
picked = tabs[(at + step + tabs.size) % tabs.size]
|
||||
val next = tabs[(at + step + tabs.size) % tabs.size]
|
||||
picked = next
|
||||
if (inPage) steppedTo = next
|
||||
}
|
||||
val art: Any? = game?.hero ?: item?.imageUrl ?: installed?.sidecar?.hero ?: installed?.sidecar?.cover
|
||||
val artModel: Any? = if (art is String) cardArtRequest(art, item?.tallImageUrl) else art
|
||||
|
||||
@@ -374,7 +374,7 @@ internal fun LibraryPage(s: FrontEndState, a: FrontEndActions, selected: String,
|
||||
.map { it.store.id }.toSet()
|
||||
val sources = librarySources(
|
||||
all, storeTabs.map { it.store.id },
|
||||
listOfNotNull(Store.ITCH.id.takeIf { itchSignedIn && !soundMode }, Store.GAMEJOLT.id.takeIf { gameJoltSignedIn && !soundMode }, Library.ADDED.takeIf { stores }).toSet() + signInChips,
|
||||
listOfNotNull(Store.ITCH.id.takeIf { itchSignedIn && !soundMode }, Store.GAMEJOLT.id.takeIf { gameJoltSignedIn && !soundMode }, Library.ADDED.takeIf { stores }, Store.BATTLENET.id.takeIf { stores }).toSet() + signInChips,
|
||||
favorites, concealed,
|
||||
offStores = if (soundMode) emptySet() else storeTabs.filterNot { it.shown }.map { it.store.id }.toSet(),
|
||||
places = if (soundMode) DEFAULT_LIBRARY_PLACES else StoreTabsState.libraryPlaces,
|
||||
@@ -632,7 +632,8 @@ private fun LibraryGrid(
|
||||
// A search that matches nothing keeps the toolbar, so the search can still be cleared.
|
||||
val customEmpty = !soundMode && source == Library.ADDED && visible.isEmpty() && hiddenUninstalled == 0 && LibraryView.query.isBlank()
|
||||
val splash = !soundMode && (signInStore != null || customEmpty)
|
||||
val headerItems = (if (splash) 1 else 2) + (if (sizesPending) 1 else 0) + syncing.size
|
||||
val showHeader = !splash || source == Store.BATTLENET.id
|
||||
val headerItems = (if (showHeader) 2 else 1) + (if (sizesPending) 1 else 0) + syncing.size
|
||||
val expanded = showUninstalled == true
|
||||
val notInstalled = if (expanded) visible.count { !it.installed } else hiddenUninstalled
|
||||
val toggleAt = when {
|
||||
@@ -766,7 +767,7 @@ private fun LibraryGrid(
|
||||
Box(Modifier.onSizeChanged { chipsH = it.height }) { Rise(0) { if (soundMode) header() else filters() } }
|
||||
}
|
||||
val splashHeight = with(density) { (gridH - chipsH).toDp() - 28.dp }.coerceAtLeast(300.dp)
|
||||
if (!splash) item(key = if (soundMode) "filters" else "header", span = { GridItemSpan(maxLineSpan) }) { Rise(1) { if (soundMode) filters() else header() } }
|
||||
if (showHeader) item(key = if (soundMode) "filters" else "header", span = { GridItemSpan(maxLineSpan) }) { Rise(1) { if (soundMode) filters() else header() } }
|
||||
for ((store, line) in syncing) item(key = "sync-${store.id}", span = { GridItemSpan(maxLineSpan) }) {
|
||||
Column(verticalArrangement = Arrangement.spacedBy(4.dp), modifier = Modifier.fillMaxWidth()) {
|
||||
Text(store.shortLabel + " · " + line, fontSize = 12.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
@@ -882,6 +883,12 @@ private fun LibraryHeader(
|
||||
clearSearchFocus = searchCleared, inlineWhenStacked = true,
|
||||
lead = soundLead,
|
||||
) {
|
||||
if (!soundMode && !s.shortcutPicker && source == Store.BATTLENET.id) {
|
||||
SecondaryButton(
|
||||
stringResource(R.string.bnet_open), enabled = !s.busy && DevPreview.library == LibraryPreview.OFF,
|
||||
compact = true, modifier = Modifier.testTag("library-battlenet-open"), onClick = a.onBattleNet,
|
||||
)
|
||||
}
|
||||
if (soundMode) HeaderIconButton(stringResource(R.string.soundtracks_saved), Icons.Filled.BookmarkBorder, "collections", onClick = onCollections)
|
||||
if (!soundMode && DeveloperTools.on && DevPreview.shortcuts) LibraryPreviewButton()
|
||||
DisplayButton()
|
||||
|
||||
@@ -27,7 +27,7 @@ internal object DeveloperTools {
|
||||
internal object NavTabs {
|
||||
const val MORE = "more"
|
||||
val ALL = listOf("steam", "desktop", "games", "downloads", "setup", "updates", "stores", "soundtracks", "components", "storage", "sync", "decky", "boot-movies", "android-apps", "agent")
|
||||
val DEFAULT_SHELVED = setOf("soundtracks", "components", "storage", "sync", "decky", "boot-movies", "agent")
|
||||
val DEFAULT_SHELVED = setOf("stores", "soundtracks", "components", "storage", "sync", "decky", "boot-movies", "agent")
|
||||
val DEFAULT_HIDDEN = setOf("android-apps", "agent")
|
||||
private val SHELVED_WHEN_NEW = setOf("storage", "sync", "decky", "boot-movies", "agent")
|
||||
private val OLD_ORDER = listOf("steam", "games", "soundtracks", "stores", "downloads", "desktop", "agent", "components", "android-apps", "storage", "sync", "setup", "updates")
|
||||
|
||||
@@ -315,6 +315,7 @@ class DrawerActions(
|
||||
val onOsc: (String) -> Unit,
|
||||
val onEditSteamTouch: (() -> Unit)? = null,
|
||||
val controller: com.droiddeck.launcher.input.ControllerPrefs.Settings? = null,
|
||||
val onControllerSize: (Int) -> Unit = {},
|
||||
val onRumble: (Boolean) -> Unit = {},
|
||||
val onSuspendPolicy: (String) -> Unit,
|
||||
val onSteamDownloadsInBackground: (Boolean) -> Unit = {},
|
||||
@@ -749,9 +750,11 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
|
||||
type, chipModifier = focus.track(page, "pad-type"), onPick = a.onPadType)
|
||||
}
|
||||
a.controller?.let { c ->
|
||||
SliderRow(stringResource(R.string.ctrl_size), null, c.size, 80..125, step = 5,
|
||||
format = { "$it%" }, modifier = focus.track(page, "controller-size"),
|
||||
onChange = a.onControllerSize)
|
||||
ToggleRow(host, "rumble", stringResource(R.string.ctrl_rumble), null, c.rumble,
|
||||
chipModifier = focus.track(page, "rumble"), onChange = a.onRumble)
|
||||
|
||||
}
|
||||
}
|
||||
SettingsGroup(stringResource(R.string.input_touchscreen)) {
|
||||
|
||||
@@ -966,7 +966,7 @@
|
||||
<string name="diagnostics_share_games">Games and compatibility</string>
|
||||
<string name="diagnostics_share_all">All bundles</string>
|
||||
<string name="setup_game_debug_logs">Game debug logs</string>
|
||||
<string name="setup_game_debug_logs_hint">Include Proton, Wine and graphics diagnostics on the next game launch. Can reduce performance and use more storage.</string>
|
||||
<string name="setup_game_debug_logs_hint">Include Proton, Wine and graphics diagnostics on the next game launch. Turns itself off when that session ends. Can reduce performance and use more storage.</string>
|
||||
<string name="setup_game_debug_logs_restart">Restart this session to save game debug logs</string>
|
||||
<string name="setup_logging_update_failed">Couldn\'t update logging. Check the switch and try again.</string>
|
||||
<string name="setup_agent_commands">Debugging tools</string>
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.droiddeck.launcher.agent
|
||||
|
||||
import java.io.File
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Assume.assumeTrue
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TemporaryFolder
|
||||
|
||||
class AgentSetupInstallScriptTest {
|
||||
@get:Rule val tmp = TemporaryFolder()
|
||||
|
||||
private fun run(updateSucceedsOnCall: Int): Pair<Int, List<String>> {
|
||||
val sh = listOf("/bin/sh", "/usr/bin/sh").firstOrNull { File(it).canExecute() }
|
||||
assumeTrue(sh != null)
|
||||
val bin = tmp.newFolder("bin")
|
||||
val calls = File(tmp.root, "calls")
|
||||
fun tool(name: String, body: String) = File(bin, name).apply { writeText("#!/bin/sh\n$body\n"); setExecutable(true) }
|
||||
tool("dpkg", "exit 0")
|
||||
tool("sleep", "exit 0")
|
||||
tool("apt-get", """
|
||||
echo "${'$'}*" >> '${calls.path}'
|
||||
case "${'$'}*" in
|
||||
*" update "*) n=${'$'}(grep -c ' update ' '${calls.path}'); [ "${'$'}n" -ge $updateSucceedsOnCall ] ;;
|
||||
*) exit 0 ;;
|
||||
esac
|
||||
""".trimIndent())
|
||||
val child = ProcessBuilder(sh, "-c", AgentSetup.installScript("echo harness-installed >> '${calls.path}'"))
|
||||
.apply { environment()["PATH"] = bin.path + File.pathSeparator + System.getenv("PATH") }
|
||||
.redirectErrorStream(true).start()
|
||||
child.inputStream.readBytes()
|
||||
val exit = child.waitFor()
|
||||
return exit to (if (calls.exists()) calls.readLines() else emptyList())
|
||||
}
|
||||
|
||||
@Test fun theInstallStopsWhenEveryUpdateAttemptFails() {
|
||||
val (exit, calls) = run(updateSucceedsOnCall = 99)
|
||||
assertTrue(exit != 0)
|
||||
assertEquals(3, calls.count { " update " in "$it " })
|
||||
assertTrue(calls.none { "install" in it })
|
||||
}
|
||||
|
||||
@Test fun theInstallContinuesWhenALaterUpdateAttemptSucceeds() {
|
||||
val (exit, calls) = run(updateSucceedsOnCall = 3)
|
||||
assertEquals(0, exit)
|
||||
assertTrue(calls.any { "install -y --no-install-recommends" in it })
|
||||
assertTrue("harness-installed" in calls.last())
|
||||
}
|
||||
}
|
||||
@@ -34,8 +34,8 @@ class DroidDeckHudPanelTest {
|
||||
assertEquals(DroidDeckHudSize.MINIMAL, DroidDeckHudSize.from(DroidDeckHudConfig.DEFAULTS["hudSize"]))
|
||||
}
|
||||
|
||||
@Test fun theHudStartsLocked() {
|
||||
assertEquals("1", DroidDeckHudConfig.DEFAULTS["hudLocked"])
|
||||
@Test fun theHudStartsUnlocked() {
|
||||
assertEquals("0", DroidDeckHudConfig.DEFAULTS["hudLocked"])
|
||||
}
|
||||
|
||||
@Test fun aLongPressCollapsesTheHudUnlessTheUserChoseToLockWithIt() {
|
||||
|
||||
@@ -96,6 +96,115 @@ class OnScreenLayoutTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun changingControllerSizeRegeneratesAnUneditedBuiltInLandscapeOverlay() {
|
||||
SessionPrefs.setSteamController(context, SessionPrefs.CONTROLLER_DECK)
|
||||
val layout = gamepad()
|
||||
val w = 1200
|
||||
val h = 540
|
||||
ControllerPrefs.setSize(context, 100)
|
||||
val original = OnScreenLayout.elements(context, layout, w, h, Rect())
|
||||
ControllerPrefs.setSize(context, 115)
|
||||
val resized = OnScreenLayout.elements(context, layout, w, h, Rect())
|
||||
assertNotEquals(original.single { it.id == "legacy:a" }.width, resized.single { it.id == "legacy:a" }.width, .0001f)
|
||||
assertNotEquals(original.single { it.id == "legacy:ls" }.height, resized.single { it.id == "legacy:ls" }.height, .0001f)
|
||||
}
|
||||
|
||||
@Test fun unchangedSizeDoesNotCollapseCoincidentEditedPortraitControls() {
|
||||
SessionPrefs.setSteamController(context, SessionPrefs.CONTROLLER_DECK)
|
||||
val stock = gamepad()
|
||||
val coincident = stock.elements.map { element ->
|
||||
if (element.id == "legacy:a" || element.id == "legacy:b") {
|
||||
element.copy(x = .2f, y = .2f, width = .1f, height = .1f)
|
||||
} else element
|
||||
}
|
||||
val edited = stock.copy(elements = coincident, aspect = .5f)
|
||||
ControllerPrefs.setSize(context, 100)
|
||||
val placed = OnScreenLayout.elements(
|
||||
context, edited, 540, 1080, Rect(),
|
||||
dock = OnScreenLayout.Dock(true, false),
|
||||
)
|
||||
assertTrue(placed.at(InputControl.A).width > 0f)
|
||||
assertTrue(placed.at(InputControl.B).width > 0f)
|
||||
}
|
||||
|
||||
@Test fun changingControllerSizeResizesDefaultDockedControlsWithoutASavedLayout() {
|
||||
SessionPrefs.setSteamController(context, SessionPrefs.CONTROLLER_DECK)
|
||||
val layout = gamepad()
|
||||
val w = 1200
|
||||
val h = 540
|
||||
val dock = OnScreenLayout.Dock(false, false)
|
||||
ControllerPrefs.setSize(context, 100)
|
||||
val original = OnScreenLayout.elements(context, layout, w, h, Rect(), dock = dock)
|
||||
ControllerPrefs.setSize(context, 125)
|
||||
val resized = OnScreenLayout.elements(context, layout, w, h, Rect(), dock = dock)
|
||||
assertNotEquals(original.at(InputControl.LS).width, resized.at(InputControl.LS).width, .0001f)
|
||||
assertNotEquals(original.at(InputControl.A).height, resized.at(InputControl.A).height, .0001f)
|
||||
assertInside(resized, w, h)
|
||||
}
|
||||
|
||||
@Test fun changingControllerSizeRegeneratesSavedLandscapeBuiltInOverlay() {
|
||||
SessionPrefs.setSteamController(context, SessionPrefs.CONTROLLER_DECK)
|
||||
val layout = gamepad().copy(aspect = 2f)
|
||||
val w = 1200
|
||||
val h = 540
|
||||
ControllerPrefs.setSize(context, 100)
|
||||
val original = OnScreenLayout.elements(context, layout, w, h, Rect())
|
||||
ControllerPrefs.setSize(context, 125)
|
||||
val resized = OnScreenLayout.elements(context, layout, w, h, Rect())
|
||||
assertNotEquals(original.at(InputControl.A).width, resized.at(InputControl.A).width, .0001f)
|
||||
}
|
||||
|
||||
@Test fun enlargedDefaultDockedControlsDoNotOverlapTheActionButtonAndRightStick() {
|
||||
SessionPrefs.setSteamController(context, SessionPrefs.CONTROLLER_DECK)
|
||||
ControllerPrefs.setSize(context, 125)
|
||||
val placed = OnScreenLayout.elements(
|
||||
context, gamepad(), 1200, 540, Rect(),
|
||||
dock = OnScreenLayout.Dock(false, false),
|
||||
)
|
||||
val stick = placed.at(InputControl.RS)
|
||||
val button = placed.at(InputControl.A)
|
||||
val overlapX = minOf(stick.x + stick.width, button.x + button.width) - maxOf(stick.x, button.x)
|
||||
val overlapY = minOf(stick.y + stick.height, button.y + button.height) - maxOf(stick.y, button.y)
|
||||
assertFalse("RS and A hit rectangles must not overlap", overlapX > 0f && overlapY > 0f)
|
||||
}
|
||||
|
||||
@Test fun changingControllerSizeResizesDockedControlsWithASavedLayout() {
|
||||
SessionPrefs.setSteamController(context, SessionPrefs.CONTROLLER_DECK)
|
||||
val layout = gamepad()
|
||||
val w = 1200
|
||||
val h = 540
|
||||
ControllerPrefs.setLayout(context, w, h, mapOf("ls" to (.12f to .7f)))
|
||||
val dock = OnScreenLayout.Dock(false, false)
|
||||
ControllerPrefs.setSize(context, 100)
|
||||
val original = OnScreenLayout.elements(context, layout, w, h, Rect(), dock = dock)
|
||||
ControllerPrefs.setSize(context, 120)
|
||||
val resized = OnScreenLayout.elements(context, layout, w, h, Rect(), dock = dock)
|
||||
val before = original.single { it.id == "legacy:a" }
|
||||
val after = resized.single { it.id == "legacy:a" }
|
||||
assertTrue(after.width > before.width)
|
||||
assertTrue(after.height > before.height)
|
||||
assertEquals(before.x + before.width / 2f, after.x + after.width / 2f, .001f)
|
||||
assertEquals(before.y + before.height / 2f, after.y + after.height / 2f, .001f)
|
||||
assertEquals(mapOf("ls" to (.12f to .7f)), ControllerPrefs.layout(context, w, h))
|
||||
}
|
||||
|
||||
@Test fun enlargedDockedControlsStayInsideSafeAreaAndKeepShoulderGaps() {
|
||||
SessionPrefs.setSteamController(context, SessionPrefs.CONTROLLER_DECK)
|
||||
val w = 1080
|
||||
val h = 200
|
||||
val safe = Rect(20, 0, 20, 24)
|
||||
ControllerPrefs.setLayout(context, w, h, mapOf("ls" to (.12f to .7f)))
|
||||
ControllerPrefs.setSize(context, 125)
|
||||
val placed = OnScreenLayout.elements(context, gamepad(), w, h, safe, dock = OnScreenLayout.Dock(false, false))
|
||||
assertInside(placed, w, h, safe)
|
||||
for ((left, right) in listOf(InputControl.LT to InputControl.LB, InputControl.RB to InputControl.RT)) {
|
||||
val a = placed.single { it.control == left }
|
||||
val b = placed.single { it.control == right }
|
||||
assertTrue("$left should remain left of $right", a.x + a.width <= b.x)
|
||||
assertTrue("$left and $right should retain a gap", (b.x - a.x - a.width) * w >= 3.5f)
|
||||
}
|
||||
}
|
||||
|
||||
@Test @Config(qualifiers = "w745dp-h343dp-land-420dpi")
|
||||
fun aBuiltInGamepadSavedAtTheDisplaySizeRegeneratesForTheMeasuredSurface() {
|
||||
SessionPrefs.setSteamController(context, SessionPrefs.CONTROLLER_NONE)
|
||||
@@ -574,6 +683,12 @@ class OnScreenLayoutTest {
|
||||
val normal = at(1f)
|
||||
for (scale in listOf(.8f, 1.25f)) {
|
||||
val placed = at(scale)
|
||||
for (control in listOf(InputControl.A, InputControl.B, InputControl.X, InputControl.Y, InputControl.LS, InputControl.RS)) {
|
||||
val before = normal.at(control)
|
||||
val after = placed.at(control)
|
||||
assertEquals("$kit $scale ${control.id} aspect ratio", before.width / before.height,
|
||||
after.width / after.height, .02f)
|
||||
}
|
||||
assertEquals("$kit $scale", normal.at(InputControl.A).width * scale, placed.at(InputControl.A).width, .002f)
|
||||
assertEquals("$kit $scale", normal.at(InputControl.LS).height * scale, placed.at(InputControl.LS).height, .002f)
|
||||
if (scale > 1f) for (cluster in listOf(face, dpad)) {
|
||||
@@ -699,4 +814,34 @@ class OnScreenLayoutTest {
|
||||
assertFalse(kit.artwork(layout.elements.first { it.control == InputControl.A }.copy(image = "picture")))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun dockedSizeAppliesWithoutAKitAndToThePortraitCluster() {
|
||||
SessionPrefs.setSteamController(context, SessionPrefs.CONTROLLER_NONE)
|
||||
val stock = gamepad()
|
||||
val dock = OnScreenLayout.Dock(false, false)
|
||||
|
||||
ControllerPrefs.setSize(context, 100)
|
||||
val defaultNormal = OnScreenLayout.elements(context, stock, 1200, 540, Rect(), dock = dock)
|
||||
ControllerPrefs.setSize(context, 125)
|
||||
val defaultLarge = OnScreenLayout.elements(context, stock, 1200, 540, Rect(), dock = dock)
|
||||
assertTrue(defaultLarge.at(InputControl.A).width > defaultNormal.at(InputControl.A).width)
|
||||
|
||||
val portraitEdited = stock.copy(
|
||||
elements = stock.elements.map {
|
||||
if (it.control == InputControl.A) it.copy(x = it.x + .07f) else it
|
||||
},
|
||||
aspect = .5f,
|
||||
)
|
||||
val portraitDock = OnScreenLayout.Dock(true, false)
|
||||
ControllerPrefs.setSize(context, 100)
|
||||
val clusterNormal = OnScreenLayout.elements(
|
||||
context, portraitEdited, 540, 1200, Rect(), dock = portraitDock,
|
||||
)
|
||||
ControllerPrefs.setSize(context, 125)
|
||||
val clusterLarge = OnScreenLayout.elements(
|
||||
context, portraitEdited, 540, 1200, Rect(), dock = portraitDock,
|
||||
)
|
||||
assertTrue(clusterLarge.at(InputControl.A).width > clusterNormal.at(InputControl.A).width)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.os.Looper
|
||||
import android.view.View
|
||||
import com.droiddeck.launcher.ui.BuildWatermark
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.Robolectric
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.Shadows.shadowOf
|
||||
import org.robolectric.annotation.Config
|
||||
import org.robolectric.annotation.ConscryptMode
|
||||
import org.robolectric.annotation.GraphicsMode
|
||||
import java.io.File
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@ConscryptMode(ConscryptMode.Mode.OFF)
|
||||
@GraphicsMode(GraphicsMode.Mode.LEGACY)
|
||||
@Config(sdk = [34], manifest = Config.NONE, application = Application::class)
|
||||
class GameDebugLogsExpiryTest {
|
||||
private val context get() = RuntimeEnvironment.getApplication()
|
||||
private val prefs get() = context.getSharedPreferences("session", Context.MODE_PRIVATE)
|
||||
|
||||
@Before fun reset() {
|
||||
SessionPaths.take()
|
||||
prefs.edit().clear().commit()
|
||||
listOf("build-watermark", "build-watermark.lock").forEach { File(context.filesDir, it).delete() }
|
||||
}
|
||||
|
||||
@After fun end() {
|
||||
SessionPaths.take()
|
||||
}
|
||||
|
||||
private fun setDebugLogs(on: Boolean) = prefs.edit().putBoolean("gameDebugLogsEnabled", on).commit()
|
||||
|
||||
@Test fun settingTurnsOffWhenTheSessionItStartedWithEnds() {
|
||||
setDebugLogs(true)
|
||||
SessionPaths.beginOrCurrent(context, "steam")
|
||||
assertTrue(SessionPrefs.gameDebugLogsEnabled(context))
|
||||
SessionPaths.take()
|
||||
assertFalse(SessionPrefs.gameDebugLogsEnabled(context))
|
||||
}
|
||||
|
||||
@Test fun settingStaysOnForTheSessionRunningWhenItWasEnabled() {
|
||||
SessionPaths.beginOrCurrent(context, "steam")
|
||||
setDebugLogs(true)
|
||||
SessionPaths.take()
|
||||
assertTrue(SessionPrefs.gameDebugLogsEnabled(context))
|
||||
SessionPaths.beginOrCurrent(context, "steam")
|
||||
SessionPaths.take()
|
||||
assertFalse(SessionPrefs.gameDebugLogsEnabled(context))
|
||||
}
|
||||
|
||||
@Test fun settingThatWasOffStaysOff() {
|
||||
SessionPaths.beginOrCurrent(context, "steam")
|
||||
SessionPaths.take()
|
||||
assertFalse(SessionPrefs.gameDebugLogsEnabled(context))
|
||||
}
|
||||
|
||||
@Test fun badgeShowsWhileOnEvenWithTheBuildWatermarkOff() {
|
||||
BuildWatermark.install(context)
|
||||
SessionPrefs.setBuildWatermarkEnabled(context, false)
|
||||
val activity = Robolectric.buildActivity(Activity::class.java).setup()
|
||||
try {
|
||||
assertNull(activity.get().window.decorView.findViewWithTag<View>("build-watermark"))
|
||||
setDebugLogs(true)
|
||||
BuildWatermarkSetting.notifyChanged(context)
|
||||
shadowOf(Looper.getMainLooper()).idle()
|
||||
assertNotNull(activity.get().window.decorView.findViewWithTag<View>("build-watermark"))
|
||||
SessionPaths.beginOrCurrent(context, "steam")
|
||||
SessionPaths.take()
|
||||
shadowOf(Looper.getMainLooper()).idle()
|
||||
assertNull(activity.get().window.decorView.findViewWithTag<View>("build-watermark"))
|
||||
} finally {
|
||||
activity.pause().stop().destroy()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import androidx.compose.runtime.snapshots.Snapshot
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.test.assertIsDisplayed
|
||||
import androidx.compose.ui.test.assertIsNotEnabled
|
||||
import androidx.compose.ui.test.assertCountEquals
|
||||
import androidx.compose.ui.test.onAllNodesWithText
|
||||
import androidx.compose.ui.test.onNodeWithContentDescription
|
||||
@@ -195,13 +196,32 @@ class LibraryVisibilityTest {
|
||||
compose.onNodeWithText("Uninstalled GOG").assertExists()
|
||||
}
|
||||
|
||||
private fun show() {
|
||||
@Test fun battleNetHasAnOpenClientActionEvenWithoutInstalledGames() {
|
||||
var opened = 0
|
||||
show(actions(onBattleNet = { opened++ }))
|
||||
compose.onNodeWithTag("library-battlenet-open").assertDoesNotExist()
|
||||
compose.onNodeWithTag("library-source-battlenet").performClick()
|
||||
compose.mainClock.advanceTimeBy(1_000)
|
||||
compose.onNodeWithTag("library-battlenet-open").assertIsDisplayed().performClick()
|
||||
assertEquals(1, opened)
|
||||
compose.onNodeWithTag("library-source-steam").performClick()
|
||||
compose.mainClock.advanceTimeBy(1_000)
|
||||
compose.onNodeWithTag("library-battlenet-open").assertDoesNotExist()
|
||||
}
|
||||
|
||||
@Test fun battleNetOpenIsDisabledWhileBusy() {
|
||||
LibraryView.source = Store.BATTLENET.id
|
||||
show(frontState = state(busy = true))
|
||||
compose.onNodeWithTag("library-battlenet-open").assertIsNotEnabled()
|
||||
}
|
||||
|
||||
private fun show(frontActions: FrontEndActions = actions(), frontState: FrontEndState = state()) {
|
||||
compose.mainClock.autoAdvance = false
|
||||
compose.setContent { key(generation) {
|
||||
DroidDeckTheme {
|
||||
CompositionLocalProvider(LocalFrontFocus provides FrontFocus()) {
|
||||
FocusGlideHost { Box(Modifier.fillMaxSize()) {
|
||||
LibraryPage(state(), actions(), "games", {}, Modifier.fillMaxSize())
|
||||
LibraryPage(frontState, frontActions, "games", {}, Modifier.fillMaxSize())
|
||||
StepsLayer(Offset.Zero)
|
||||
} }
|
||||
}
|
||||
@@ -216,15 +236,16 @@ class LibraryVisibilityTest {
|
||||
assertEquals(show, SessionPrefs.libraryShowUninstalled(ctx))
|
||||
}
|
||||
|
||||
private fun state(games: List<Library.SteamGame> = listOf(Library.SteamGame(440, "Installed Steam game", null, "internal"))) = FrontEndState(
|
||||
installed = "r9", ready = true, available = null, busy = false, stage = "", percent = -1,
|
||||
private fun state(games: List<Library.SteamGame> = listOf(Library.SteamGame(440, "Installed Steam game", null, "internal")), busy: Boolean = false) = FrontEndState(
|
||||
installed = "r9", ready = true, available = null, busy = busy, stage = "", percent = -1,
|
||||
desktopInstalled = true, offlineAccount = null, offline = false, frameGenLabel = "",
|
||||
romsDir = null, logsEnabled = false,
|
||||
steamGames = games,
|
||||
emulators = emptyList(), running = null,
|
||||
)
|
||||
|
||||
private fun actions() = FrontEndActions(
|
||||
private fun actions(onBattleNet: () -> Unit = {}) = FrontEndActions(
|
||||
onBattleNet = onBattleNet,
|
||||
onPlay = {}, onPlayDesktopUi = {}, onSteamGame = {}, onDesktop = {}, onEmulator = {},
|
||||
onRom = {}, onResume = {}, onSteamSettings = {}, onDesktopSettings = {},
|
||||
onInstallPackage = {}, onRemovePackage = {}, onRuntime = {}, onFrameGenPick = {},
|
||||
|
||||
@@ -40,8 +40,8 @@ class NavTabsTest {
|
||||
}
|
||||
|
||||
@Test fun aFreshInstallShowsTheDefaultBarMoreAndHiddenTabs() {
|
||||
assertEquals(listOf("steam", "desktop", "games", "downloads", "setup", "updates", "stores", NavTabs.MORE), navigationKeys(state()))
|
||||
assertEquals(listOf("soundtracks", "components", "storage", "sync", "decky", "boot-movies"), NavTabs.more(state()))
|
||||
assertEquals(listOf("steam", "desktop", "games", "downloads", "setup", "updates", NavTabs.MORE), navigationKeys(state()))
|
||||
assertEquals(listOf("stores", "soundtracks", "components", "storage", "sync", "decky", "boot-movies"), NavTabs.more(state()))
|
||||
assertEquals(TabPlace.HIDDEN, NavTabs.place(state(), "android-apps"))
|
||||
assertEquals(TabPlace.HIDDEN, NavTabs.place(state(), "agent"))
|
||||
assertFalse(com.droiddeck.launcher.agent.AgentTab.shown)
|
||||
@@ -66,13 +66,13 @@ class NavTabsTest {
|
||||
@Test fun showingMusicOnceKeepsItShownAfterReload() {
|
||||
place("soundtracks", TabPlace.BAR)
|
||||
NavTabs.load(ctx)
|
||||
assertEquals(listOf("steam", "desktop", "games", "downloads", "setup", "updates", "stores", "soundtracks", NavTabs.MORE), navigationKeys(state()))
|
||||
assertEquals(listOf("steam", "desktop", "games", "downloads", "setup", "updates", "soundtracks", NavTabs.MORE), navigationKeys(state()))
|
||||
}
|
||||
|
||||
@Test fun shelvedTabsLeaveTheBarAndAddMoreAtTheEnd() {
|
||||
place("desktop", TabPlace.MORE)
|
||||
val s = state()
|
||||
assertEquals(listOf("desktop", "soundtracks", "components", "storage", "sync", "decky", "boot-movies"), NavTabs.more(s))
|
||||
assertEquals(listOf("desktop", "stores", "soundtracks", "components", "storage", "sync", "decky", "boot-movies"), NavTabs.more(s))
|
||||
assertEquals(NavTabs.MORE, navigationKeys(s).last())
|
||||
assertFalse("desktop" in navigationKeys(s))
|
||||
}
|
||||
@@ -85,14 +85,14 @@ class NavTabsTest {
|
||||
}
|
||||
|
||||
@Test fun resettingPutsBackTheDefaultLayout() {
|
||||
place("stores", TabPlace.MORE)
|
||||
place("stores", TabPlace.BAR)
|
||||
place("updates", TabPlace.HIDDEN)
|
||||
moveTab("downloads", -1)
|
||||
assertFalse(NavTabs.isDefault())
|
||||
NavTabs.reset(ctx)
|
||||
NavTabs.load(ctx)
|
||||
assertTrue(NavTabs.isDefault())
|
||||
assertEquals(listOf("steam", "desktop", "games", "downloads", "setup", "updates", "stores", NavTabs.MORE), navigationKeys(state()))
|
||||
assertEquals(listOf("steam", "desktop", "games", "downloads", "setup", "updates", NavTabs.MORE), navigationKeys(state()))
|
||||
}
|
||||
|
||||
@Test fun anOldLayoutKeepsWhatItsSwitchesShowed() {
|
||||
|
||||
Reference in new issue
Block a user