mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-24 23:36:04 +00:00
feat(hud): every reading gets its own switch and a row order (#2454)
* feat: every HUD reading has its own switch and a row order * feat: readings get a reorder dialog of their own * refactor: drag alone moves a reading * fix: the readings list is one column with a switch per row * fix: one scrolling readings list, titled HUD info * refactor: derive the readings order from the defaults instead of a second list * fix: the readings dialog loses its doubled title and follows the saved order * refactor: no title in the readings dialog, its actions sit beside the list * refactor: readings dialog actions take the free side on landscape, the foot on portrait * fix: the readings list follows the size it draws and drags with a live gap * fix: the readings dialog fills the window and keeps scrolling under a held drag * fix: reset restores every size's order, and the new HUD strings are translated * refactor: one table for each size's rows and one for its text sizes * refactor: the readings list swaps rows as the drag passes them, and the list animates the rest * refactor: give the readings rows test tags for the local UI test * refactor: HUD readings follow one configurable row table * refactor: the Strip HUD draws its rows from the same table * refactor: each size orders its rows by its own table, and the frame graph is a row * fix: the readings dialog keeps the row order a drag leaves * fix: each size keeps its own row order, and reset clears only the order * refactor: the graph's size lives in one place, and the section markers are gone * fix: a size change and the first save of a legacy config both keep the order * chore: retrigger the build * feat: a reading can be grabbed with Y and shuffled with the d-pad * feat: controller hints float beside the dialog, and a moved row stays in view * feat: Y grabs on a hold and drops on release, and a touch no longer flips the dialog * fix: keep the key hints off the rows on narrow windows, and let Enter toggle a row
This commit is contained in:
1 parent
d8b3c66b95
commit
269d462825
42 files changed
+1322
-625
No files matched your search
@@ -51,11 +51,12 @@ class DroidDeckHudPanelTest {
|
||||
key to if (mask and (1 shl index) != 0) "1" else "0"
|
||||
}.toMap()
|
||||
view.applyConfig(DroidDeckHudConfig.encode(DroidDeckHudConfig.DEFAULTS +
|
||||
("hudSize" to size.token) + settings))
|
||||
DroidDeckHudConfig.ORDER.associateWith { "0" } + settings + mapOf(
|
||||
"hudSize" to size.token, "showFPSGraph" to "0", "showClock" to "0")))
|
||||
view.showForTest(SNAPSHOT, "DXVK", 0L)
|
||||
val lines = view.linesForTest().joinToString(" ")
|
||||
for ((index, metric) in metrics.withIndex()) {
|
||||
val supported = size != DroidDeckHudSize.TILES || index == 0
|
||||
val supported = metrics[index].first in size.rows
|
||||
val expected = supported && mask and (1 shl index) != 0
|
||||
val label = Regex("(?<![0-9.])${Regex.escape(metric.second)}")
|
||||
assertEquals("$size, mask=$mask, ${metric.second}: $lines", expected, label.containsMatchIn(lines))
|
||||
@@ -100,6 +101,70 @@ class DroidDeckHudPanelTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun aSwitchTurnsItsRowOff() {
|
||||
fun full(vararg settings: Pair<String, String>): List<String> {
|
||||
val values = LinkedHashMap(DroidDeckHudConfig.DEFAULTS)
|
||||
values["hudSize"] = DroidDeckHudSize.FULL.token
|
||||
for ((key, value) in settings) values[key] = value
|
||||
val view = DroidDeckHudView(RuntimeEnvironment.getApplication())
|
||||
view.applyConfig(DroidDeckHudConfig.encode(values))
|
||||
view.showForTest(SNAPSHOT, "DXVK", 0L)
|
||||
return view.linesForTest()
|
||||
}
|
||||
assertTrue(full().toString(), full().any { "RAM67%" in it })
|
||||
val noRam = full("showRAM" to "0")
|
||||
assertFalse(noRam.toString(), noRam.any { "RAM67%" in it })
|
||||
assertTrue(noRam.toString(), noRam.any { "FPS0.0" in it })
|
||||
}
|
||||
|
||||
@Test fun theSavedOrderDecidesTheRowOrder() {
|
||||
fun only(order: String): List<String> {
|
||||
val off = DroidDeckHudConfig.ORDER.associateWith { "0" }
|
||||
val view = DroidDeckHudView(RuntimeEnvironment.getApplication())
|
||||
view.applyConfig(DroidDeckHudConfig.encode(
|
||||
DroidDeckHudConfig.DEFAULTS + off + mapOf(
|
||||
"hudSize" to DroidDeckHudSize.FULL.token,
|
||||
"showPower" to "1", "showFPS" to "1", "showRAM" to "1",
|
||||
"showFPSGraph" to "0", "showClock" to "0", "hudOrder" to order,
|
||||
)))
|
||||
view.showForTest(SNAPSHOT, "DXVK", 0L)
|
||||
return view.linesForTest().filter { !it.startsWith("DroidDeck") }
|
||||
}
|
||||
val powerFirst = only("full:showPower|showFPS|showRAM")
|
||||
assertEquals(powerFirst.toString(), listOf("PWR", "FPS", "RAM"), powerFirst.map { it.take(3) })
|
||||
val ramFirst = only("full:showRAM|showFPS|showPower")
|
||||
assertEquals(ramFirst.toString(), listOf("RAM", "FPS", "PWR"), ramFirst.map { it.take(3) })
|
||||
}
|
||||
|
||||
@Test fun aSaveKeepsTheLegacyOrderForTheOtherSizes() {
|
||||
val app = RuntimeEnvironment.getApplication()
|
||||
SessionPrefs.setDroidDeckHudConfig(app, "hudSize=strip,hudOrder=showRAM|showFPS")
|
||||
val saved = DroidDeckHudConfig.choose(app, emptyMap(), listOf("showFPS", "showRAM"))
|
||||
assertEquals(listOf("showRAM", "showFPS"), DroidDeckHudConfig.storedOrder(saved, DroidDeckHudSize.FULL))
|
||||
assertEquals(listOf("showFPS", "showRAM"), DroidDeckHudConfig.storedOrder(saved, DroidDeckHudSize.STRIP))
|
||||
}
|
||||
|
||||
@Test fun thePillHeroIsWhicheverRowTheUserPutsFirst() {
|
||||
fun pill(order: String): List<String> {
|
||||
val off = DroidDeckHudConfig.ORDER.associateWith { "0" }
|
||||
val view = DroidDeckHudView(RuntimeEnvironment.getApplication())
|
||||
view.applyConfig(DroidDeckHudConfig.encode(
|
||||
DroidDeckHudConfig.DEFAULTS + off + mapOf(
|
||||
"hudSize" to DroidDeckHudSize.PILL.token,
|
||||
"showFPS" to "1", "showRAM" to "1", "showPower" to "1",
|
||||
"showFPSGraph" to "0", "showClock" to "0",
|
||||
"hudOrder" to order,
|
||||
)))
|
||||
view.showForTest(SNAPSHOT, "DXVK", 0L)
|
||||
return view.linesForTest()
|
||||
}
|
||||
val fpsFirst = pill("pill:showFPS|showRAM|showPower")
|
||||
assertTrue(fpsFirst.toString(), fpsFirst.any { it.trim() == "0.0fps" })
|
||||
val fpsLast = pill("pill:showRAM|showPower|showFPS")
|
||||
assertTrue(fpsLast.toString(), fpsLast.any { it.trim().startsWith("FPS") })
|
||||
assertFalse(fpsLast.toString(), fpsLast.any { it.trim() == "0.0fps" })
|
||||
}
|
||||
|
||||
@Test fun stripIsOneLineAcrossTheParentWithTheClockOnTheRight() {
|
||||
val app = RuntimeEnvironment.getApplication()
|
||||
val parent = FrameLayout(app)
|
||||
@@ -232,27 +297,24 @@ class DroidDeckHudPanelTest {
|
||||
}
|
||||
|
||||
@Test fun pillShowsEachBatteryPartOnItsOwnSwitch() {
|
||||
fun pill(vararg settings: Pair<String, String>): List<String> {
|
||||
fun pill(vararg settings: Pair<String, String>): String {
|
||||
val view = DroidDeckHudView(RuntimeEnvironment.getApplication())
|
||||
view.applyConfig(DroidDeckHudConfig.encode(DroidDeckHudConfig.DEFAULTS + ("hudSize" to DroidDeckHudSize.PILL.token) + settings))
|
||||
view.showForTest(SNAPSHOT, "DXVK", 0L)
|
||||
return view.linesForTest()
|
||||
return view.linesForTest().toString()
|
||||
}
|
||||
val all = pill("showBattery" to "1")
|
||||
assertTrue(all.toString(), all.any { "BAT 79% · 34°C · 16.0W" in it })
|
||||
assertEquals(all.toString(), 1, all.count { "BAT" in it })
|
||||
assertFalse(all.toString(), all.single { "RAM" in it }.contains("BAT"))
|
||||
|
||||
val noMemory = pill("showBattery" to "1", "showRAM" to "0")
|
||||
assertTrue(noMemory.toString(), noMemory.none { "RAM" in it })
|
||||
assertTrue(noMemory.toString(), noMemory.any { "BAT 79% · 34°C · 16.0W" in it })
|
||||
|
||||
val defaults = pill()
|
||||
assertTrue(defaults.toString(), defaults.any { "BAT 34°C · 16.0W" in it })
|
||||
val wattsOnly = pill("showBatteryTemp" to "0")
|
||||
assertTrue(wattsOnly.toString(), wattsOnly.any { "BAT 16.0W" in it })
|
||||
val nothing = pill("showBatteryTemp" to "0", "showPower" to "0")
|
||||
assertTrue(nothing.toString(), nothing.none { "BAT" in it })
|
||||
assertTrue(defaults, defaults.contains("BAT.T"))
|
||||
assertTrue(defaults, defaults.contains("PWR"))
|
||||
assertFalse(defaults, defaults.contains("BAT79%"))
|
||||
val levelOn = pill("showBattery" to "1")
|
||||
assertTrue(levelOn, levelOn.contains("BAT79%"))
|
||||
val tempOff = pill("showBatteryTemp" to "0")
|
||||
assertFalse(tempOff, tempOff.contains("BAT.T"))
|
||||
assertTrue(tempOff, tempOff.contains("PWR"))
|
||||
val powerOff = pill("showPower" to "0")
|
||||
assertFalse(powerOff, powerOff.contains("PWR"))
|
||||
assertTrue(powerOff, powerOff.contains("BAT.T"))
|
||||
}
|
||||
|
||||
@Test fun aLockedHudLetsTouchesThroughOnlyWhereAControlTakesThem() {
|
||||
|
||||
Reference in new issue
Block a user