mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 05:46:03 +00:00
fix: FusionHUD Pill battery row, and a locked HUD lets on-screen controls work (#1763)
Pill: battery level, temperature and watts share one "BAT" row, as on the other sizes, and each part follows its own switch. Turning Memory off no longer hides the battery temperature (reported by Keegan), and watts show without the battery level. Touch (part of #1752, reported by ZZCSK): a locked HUD lets a touch through where an on-screen control under it takes it: controller buttons and sticks, Steam touch controls, screen keys and the controls panel below the game. Each layer answers takesTouchAt with its own touch checks. Everywhere else the HUD keeps the touch, so a long press still locks or unlocks it. A new HUD starts locked. The "Lock in place" hint says so in every language. Tests: Pill battery row per switch combination; takesTouchAt agrees with a real touch over a grid for the controller buttons, screen keys and both controls panel layouts (Deck and gamepad, landscape and portrait); a locked HUD passes touches to a control under it, keeps the rest, and unlocks on a long press.
This commit is contained in:
1 parent
283e3b4549
commit
5de690ef39
46 files changed
+279
-61
No files matched your search
@@ -655,6 +655,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
}
|
||||
hud = FusionHudHost(this)
|
||||
hud.onConfigChanged = { hudConfig = FusionHudConfig.load(this) }
|
||||
hud.passesTouchAt = ::controlTakesTouchAt
|
||||
hud.attach(root, root.childCount)
|
||||
memoryHud = com.droiddeck.launcher.session.MemoryHud(this)
|
||||
hud.onPresentingWindowChanged = {
|
||||
@@ -2439,6 +2440,22 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
override fun dispatchTrackballEvent(event: MotionEvent): Boolean =
|
||||
onCapturedPointer(event) || super.dispatchTrackballEvent(event)
|
||||
|
||||
/** Whether one of the on-screen control layers takes a finger going down at this screen point. */
|
||||
private fun controlTakesTouchAt(rawX: Float, rawY: Float): Boolean {
|
||||
val at = IntArray(2)
|
||||
fun takes(view: View, hit: (Float, Float) -> Boolean): Boolean {
|
||||
if (!view.isShown) return false
|
||||
view.getLocationOnScreen(at)
|
||||
val x = rawX - at[0]
|
||||
val y = rawY - at[1]
|
||||
return x >= 0f && y >= 0f && x < view.width && y < view.height && hit(x, y)
|
||||
}
|
||||
return onScreenControls?.let { takes(it, it::takesTouchAt) } == true ||
|
||||
steamTouchControls?.let { takes(it, it::takesTouchAt) } == true ||
|
||||
screenKeys?.let { takes(it, it::takesTouchAt) } == true ||
|
||||
unfoldedPanel?.let { takes(it, it::takesTouchAt) } == true
|
||||
}
|
||||
|
||||
override fun dispatchTouchEvent(event: MotionEvent): Boolean {
|
||||
if (pipUi) return true
|
||||
if (event.actionMasked == MotionEvent.ACTION_DOWN && event.isFromSource(InputDevice.SOURCE_TOUCHSCREEN)) {
|
||||
|
||||
@@ -5,9 +5,12 @@ import com.droiddeck.launcher.session.SessionPrefs
|
||||
|
||||
/** FusionHUD's settings as one "key=value,…" string (FusionHudView.applyConfig), stored in SessionPrefs. */
|
||||
internal object FusionHudConfig {
|
||||
/** Bannerlator's Fusion defaults (DeckOverlaySettings), with the FPS graph from the old DroidDeck HUD. */
|
||||
/**
|
||||
* Bannerlator's Fusion defaults (DeckOverlaySettings), with the FPS graph from the old DroidDeck HUD. The HUD starts
|
||||
* locked, so like the old HUD it lets touches through until it is unlocked to move it.
|
||||
*/
|
||||
val DEFAULTS: Map<String, String> = linkedMapOf(
|
||||
"hudSize" to "minimal", "hudLocked" to "0", "hudScale" to "100", "hudOpacity" to "80", "hudColor" to "mid",
|
||||
"hudSize" to "minimal", "hudLocked" to "1", "hudScale" to "100", "hudOpacity" to "80", "hudColor" to "mid",
|
||||
"hudOutline" to "40", "hudOutlineAccent" to "1",
|
||||
"showFPS" to "1", "showFPSGraph" to "1", "showCPUUsage" to "1", "showCPULoad" to "1", "showGPULoad" to "1",
|
||||
"showVram" to "1", "showRAM" to "1", "showPower" to "1", "showTemp" to "1", "showBatteryTemp" to "1",
|
||||
|
||||
@@ -44,6 +44,9 @@ class FusionHudHost(context: Context) {
|
||||
/** The HUD itself changed a setting: a tap cycles the size, a long press locks it. */
|
||||
var onConfigChanged: (() -> Unit)? = null
|
||||
|
||||
/** Screen point → whether an on-screen control takes a touch there; a locked HUD lets those through. */
|
||||
var passesTouchAt: ((rawX: Float, rawY: Float) -> Boolean)? = null
|
||||
|
||||
private val listener = object : WaylandCompositor.GameListener {
|
||||
override fun onGameSurface(window: String?, gpuName: String?) {
|
||||
if (!gpuName.isNullOrBlank()) handler.post { this@FusionHudHost.gpuName = cleanGpuName(gpuName) }
|
||||
@@ -90,6 +93,7 @@ class FusionHudHost(context: Context) {
|
||||
onConfigChanged?.invoke()
|
||||
}
|
||||
hud.addOnLayoutChangeListener { _, _, _, _, _, _, _, _, _ -> if (!hud.isDragging) keepOnScreen(hud) }
|
||||
hud.passesTouchAt = { x, y -> passesTouchAt?.invoke(x, y) == true }
|
||||
hud.visibility = View.GONE
|
||||
val margin = (16 * root.resources.displayMetrics.density).roundToInt()
|
||||
root.addView(hud, index, FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT).apply {
|
||||
|
||||
@@ -57,7 +57,8 @@ import kotlinx.coroutines.withTimeoutOrNull
|
||||
*
|
||||
* Gestures go through [HudLockController]: long-press toggles the position lock (with a lock/unlock
|
||||
* badge fade), a tap cycles the size (Full→Tiles→Pill→Minimal→Full), and a drag repositions — tap +
|
||||
* drag are frozen while locked.
|
||||
* drag are frozen while locked. A locked HUD lets a touch through where an on-screen control under it
|
||||
* takes it ([passesTouchAt]); everywhere else it keeps the touch, so a long press there unlocks it.
|
||||
*/
|
||||
class FusionHudView(context: Context) : View(context) {
|
||||
|
||||
@@ -294,7 +295,7 @@ class FusionHudView(context: Context) : View(context) {
|
||||
showDxVer = cfg.get("showDxVer", "1") == "1"
|
||||
showSession = cfg.get("showSession", "1") == "1"
|
||||
tempDisplay = HudMetrics.TempDisplay.from(cfg)
|
||||
lockController.setLocked(cfg.get("hudLocked", "0") == "1")
|
||||
lockController.setLocked(cfg.get("hudLocked", "1") == "1")
|
||||
|
||||
colorIntensity = when (cfg.get("hudColor", "vivid")) {
|
||||
"soft" -> 0.72f; "mid" -> 0.88f; else -> 1.0f
|
||||
@@ -865,25 +866,20 @@ class FusionHudView(context: Context) : View(context) {
|
||||
}
|
||||
// RAM % (system-wide) takes the slot the latency row used to occupy, matching the GPU/CPU idiom
|
||||
// on the row above it. colRam keeps RAM's identity colour consistent with the Full/Tiles sizes.
|
||||
if (showRAM) {
|
||||
if (showRAM) stack.add(listOf(Span("RAM ${s.ramPercent.roundToInt()}%", colRam, stkPx)))
|
||||
// One battery row, as on the other sizes: each part shows on its own switch, so the battery
|
||||
// temperature no longer goes with the RAM switch and watts show without the battery level.
|
||||
if (showBattery || showPower || showBatteryTemp) {
|
||||
val l = ArrayList<Span>()
|
||||
l += Span("RAM ${s.ramPercent.roundToInt()}%", colRam, stkPx)
|
||||
// Battery temperature as a "BAT" chip right after RAM (pill-only placement, per user
|
||||
// request). Colour-banded warm→red via tempSpans/TempSensor.BATTERY — the exact same
|
||||
// danger bands the GPU/CPU temps use. Only shown when the battery-temp toggle is on
|
||||
// and a reading is available; the other sizes keep battery temp in the battery row.
|
||||
if (showBatteryTemp && s.battery.tempC != null) {
|
||||
l += Span(" · ", colDim, stkPx)
|
||||
l += Span("BAT ", colBat, stkPx)
|
||||
l += tempSpans(s.battery.tempC, HudMetrics.TempSensor.BATTERY, stkPx, stkPx * 0.62f)
|
||||
fun part(spans: List<Span>) {
|
||||
l += if (l.isEmpty()) Span("BAT ", colBat, stkPx) else Span(" · ", colDim, stkPx)
|
||||
l += spans
|
||||
}
|
||||
stack.add(l)
|
||||
}
|
||||
if (showBattery || showPower) {
|
||||
val l = ArrayList<Span>(); var any = false
|
||||
if (showBattery && s.battery.percent != null) { l += Span("BAT ${s.battery.percent}%", colBat, stkPx); any = true }
|
||||
if (showPower && s.battery.watts > 0f) { if (any) l += Span(" · ", colDim, stkPx); l += Span("${fmt1(s.battery.watts)}W", colDim, stkPx) }
|
||||
if (any) stack.add(l)
|
||||
if (showBattery && s.battery.percent != null) part(listOf(Span("${s.battery.percent}%", colBat, stkPx)))
|
||||
if (showBatteryTemp && s.battery.tempC != null)
|
||||
part(tempSpans(s.battery.tempC, HudMetrics.TempSensor.BATTERY, stkPx, stkPx * 0.62f))
|
||||
if (showPower && s.battery.watts > 0f) part(listOf(Span("${fmt1(s.battery.watts)}W", colDim, stkPx)))
|
||||
if (l.isNotEmpty()) stack.add(l)
|
||||
}
|
||||
// Latency (+ the display server, + optional VRAM) drops to the bottom of the stack, under the
|
||||
// battery row. The display server sits here, not on the GPU-model line: that line is the
|
||||
@@ -1340,6 +1336,8 @@ class FusionHudView(context: Context) : View(context) {
|
||||
@VisibleForTesting internal fun panelForTest(): RectF? = dPanel
|
||||
@VisibleForTesting internal fun panelRadiusForTest(): Float = dRadius
|
||||
@VisibleForTesting internal fun graphForTest(): RectF? = graphRect
|
||||
@VisibleForTesting internal fun linesForTest(): List<String> =
|
||||
glyphs.groupBy { it.baseline.roundToInt() }.toSortedMap().values.map { line -> line.sortedBy { it.x }.joinToString("") { it.text } }
|
||||
|
||||
private fun drawChip(canvas: Canvas, rect: RectF) {
|
||||
val r = sp(6f)
|
||||
@@ -1355,7 +1353,15 @@ class FusionHudView(context: Context) : View(context) {
|
||||
DroidDeckMark.draw(canvas, rect.centerX() - markW / 2f, rect.centerY() - markH / 2f, markH, blend(colValue), accent)
|
||||
}
|
||||
|
||||
override fun onTouchEvent(event: MotionEvent): Boolean = lockController.onTouchEvent(event)
|
||||
/** Screen point → whether an on-screen control under the HUD takes a touch there. */
|
||||
internal var passesTouchAt: ((rawX: Float, rawY: Float) -> Boolean)? = null
|
||||
|
||||
// Declining the down event hands the whole gesture to the views under the HUD.
|
||||
override fun onTouchEvent(event: MotionEvent): Boolean {
|
||||
if (event.actionMasked == MotionEvent.ACTION_DOWN && lockController.isLocked() &&
|
||||
passesTouchAt?.invoke(event.rawX, event.rawY) == true) return false
|
||||
return lockController.onTouchEvent(event)
|
||||
}
|
||||
|
||||
internal val isDragging: Boolean get() = lockController.isDragging()
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ import java.util.function.Consumer;
|
||||
* position — disabled (frozen) while locked.</li>
|
||||
* <li><b>long-press</b> → toggles {@code hudLocked}, persisted via {@link Callbacks#onLockChanged}
|
||||
* and kept in sync with the "Lock in place" menu chip. Works locked or unlocked (so a long-press
|
||||
* always unlocks).</li>
|
||||
* always unlocks); a locked {@code FusionHudView} passes touches on only over on-screen controls.</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>On every lock/unlock (and on a blocked gesture while locked) a small padlock badge fades in →
|
||||
|
||||
@@ -672,6 +672,11 @@ class OnScreenControls(
|
||||
private fun closestSnap(position: Float, targets: List<Float>): Float? =
|
||||
targets.minByOrNull { abs(position - it) }?.takeIf { abs(position - it) <= dp(SNAP_DP) }
|
||||
|
||||
/** Whether a finger going down at ([x], [y]) lands on something here, as [onTouchEvent] decides it. */
|
||||
fun takesTouchAt(x: Float, y: Float): Boolean =
|
||||
editing || keyboardContains(x, y) || (!buttonsOnly && quickContains(x, y)) ||
|
||||
(!quickHidden && (controlAt(x, y) ?: adaptiveStickAt(x, y)) != null)
|
||||
|
||||
private fun controlAt(x: Float, y: Float): Control? =
|
||||
controls.firstOrNull {
|
||||
!quickHidden && isVisible(it) && (editing || !settings.adaptiveSticks || it.stick < 0) && it.contains(x, y, it.radius)
|
||||
|
||||
@@ -609,6 +609,9 @@ class ScreenKeys(context: Context, private val sendKey: (Int, Boolean) -> Unit)
|
||||
else -> entry.halfH
|
||||
}
|
||||
|
||||
/** Whether a finger going down at ([x], [y]) lands on something here, as [onTouchEvent] decides it. */
|
||||
fun takesTouchAt(x: Float, y: Float): Boolean = editing || entryAt(x, y) != null
|
||||
|
||||
private fun entryAt(x: Float, y: Float): Entry? = entries.lastOrNull { entry ->
|
||||
x >= entry.cx - entry.halfW && x <= entry.cx + entry.halfW && y >= entry.cy - entry.halfH && y <= entry.cy + entry.halfH
|
||||
}
|
||||
|
||||
@@ -244,6 +244,9 @@ class SteamTouchControls(
|
||||
private fun hit(list: List<Element>, x: Float, y: Float): Element? =
|
||||
list.filter { reach(it, x, y) <= 1.15f }.minByOrNull { reach(it, x, y) }
|
||||
|
||||
/** Whether a finger going down at ([x], [y]) lands on something here, as [onTouchEvent] decides it. */
|
||||
fun takesTouchAt(x: Float, y: Float): Boolean = editing || menuOpen || hit(live(), x, y) != null
|
||||
|
||||
private fun live(): List<Element> =
|
||||
if (shakenAway) emptyList() else if (options.inputMode == SteamTouchConfig.INPUT_MOUSE) elements.filter { it.type == SteamTouchConfig.THUMB } else elements
|
||||
|
||||
|
||||
@@ -254,6 +254,21 @@ class DeckControlsPanel(
|
||||
show()
|
||||
}
|
||||
|
||||
/** Whether a finger going down at ([x], [y]) lands on one of the panel's controls. */
|
||||
fun takesTouchAt(x: Float, y: Float): Boolean = controlUnder(this, x, y)
|
||||
|
||||
// Every control here takes the touches it gets: buttons and tabs (clickable), the scrolling tab strip,
|
||||
// and the drawn surfaces, pads and face buttons. The layouts around them do not.
|
||||
private fun controlUnder(view: View, x: Float, y: Float): Boolean {
|
||||
if (view.visibility != VISIBLE || x < 0f || y < 0f || x >= view.width || y >= view.height) return false
|
||||
if (view.isClickable || view is HorizontalScrollView || view is Surface || view is DirectionPad || view is FaceButtons) return true
|
||||
val group = view as? ViewGroup ?: return false
|
||||
return (group.childCount - 1 downTo 0).any { i ->
|
||||
val child = group.getChildAt(i)
|
||||
controlUnder(child, x + group.scrollX - child.x, y + group.scrollY - child.y)
|
||||
}
|
||||
}
|
||||
|
||||
private fun roundButton(label: String, description: String, onClick: () -> Unit, wide: Boolean = false) =
|
||||
roundButton(context, label, description, onClick, wide)
|
||||
|
||||
|
||||
@@ -624,7 +624,7 @@
|
||||
<string name="hud_size_minimal">مصغّر</string>
|
||||
<string name="hud_size_mega">ضخم</string>
|
||||
<string name="hud_locked">تثبيت في مكانه</string>
|
||||
<string name="hud_locked_hint">اسحب HUD لتحريكه؛ والضغط مطولًا يثبّته أو يلغي تثبيته.</string>
|
||||
<string name="hud_locked_hint">اسحب HUD لتحريكه؛ والضغط مطولًا يثبّته أو يلغي تثبيته. أثناء تثبيته، تظل عناصر التحكم على الشاشة الموجودة تحته تعمل.</string>
|
||||
<string name="hud_group_look">المظهر</string>
|
||||
<string name="hud_scale">الحجم على الشاشة</string>
|
||||
<string name="hud_color_soft">هادئ</string>
|
||||
|
||||
@@ -611,7 +611,7 @@
|
||||
<string name="hud_size_minimal">Mínimo</string>
|
||||
<string name="hud_size_mega">Mega</string>
|
||||
<string name="hud_locked">Fijar posición</string>
|
||||
<string name="hud_locked_hint">Arrastra el HUD para moverlo; una pulsación larga lo bloquea o lo desbloquea.</string>
|
||||
<string name="hud_locked_hint">Arrastra el HUD para moverlo; una pulsación larga lo bloquea o lo desbloquea. Mientras está bloqueado, los controles en pantalla que tiene debajo siguen funcionando.</string>
|
||||
<string name="hud_group_look">Aspecto</string>
|
||||
<string name="hud_scale">Tamaño en pantalla</string>
|
||||
<string name="hud_color_soft">Suave</string>
|
||||
|
||||
@@ -616,7 +616,7 @@
|
||||
<string name="hud_size_minimal">Минимален</string>
|
||||
<string name="hud_size_mega">Мега</string>
|
||||
<string name="hud_locked">Заключване на място</string>
|
||||
<string name="hud_locked_hint">Плъзнете HUD, за да го преместите; продължително натискане го заключва или отключва.</string>
|
||||
<string name="hud_locked_hint">Плъзнете HUD, за да го преместите; продължително натискане го заключва или отключва. Докато е заключен, екранните контроли под него продължават да работят.</string>
|
||||
<string name="hud_group_look">Визия</string>
|
||||
<string name="hud_scale">Размер на екрана</string>
|
||||
<string name="hud_color_soft">Мек</string>
|
||||
|
||||
@@ -620,7 +620,7 @@
|
||||
<string name="hud_size_minimal">Minimální</string>
|
||||
<string name="hud_size_mega">Mega</string>
|
||||
<string name="hud_locked">Zamknout na místě</string>
|
||||
<string name="hud_locked_hint">Přetažením HUD přesunete; dlouhým stiskem ho zamknete nebo odemknete.</string>
|
||||
<string name="hud_locked_hint">Přetažením HUD přesunete; dlouhým stiskem ho zamknete nebo odemknete. Když je zamknutý, ovládací prvky na obrazovce pod ním dál fungují.</string>
|
||||
<string name="hud_group_look">Vzhled</string>
|
||||
<string name="hud_scale">Velikost na obrazovce</string>
|
||||
<string name="hud_color_soft">Jemná</string>
|
||||
|
||||
@@ -616,7 +616,7 @@
|
||||
<string name="hud_size_minimal">Minimal</string>
|
||||
<string name="hud_size_mega">Mega</string>
|
||||
<string name="hud_locked">Lås fast</string>
|
||||
<string name="hud_locked_hint">Træk i HUD for at flytte det; et langt tryk låser eller frigør det.</string>
|
||||
<string name="hud_locked_hint">Træk i HUD for at flytte det; et langt tryk låser eller frigør det. Mens det er låst, virker skærmknapperne under det stadig.</string>
|
||||
<string name="hud_group_look">Udseende</string>
|
||||
<string name="hud_scale">Størrelse på skærmen</string>
|
||||
<string name="hud_color_soft">Blød</string>
|
||||
|
||||
@@ -616,7 +616,7 @@
|
||||
<string name="hud_size_minimal">Minimal</string>
|
||||
<string name="hud_size_mega">Mega</string>
|
||||
<string name="hud_locked">Position sperren</string>
|
||||
<string name="hud_locked_hint">Ziehe das HUD, um es zu verschieben; langes Drücken sperrt oder entsperrt es.</string>
|
||||
<string name="hud_locked_hint">Ziehe das HUD, um es zu verschieben; langes Drücken sperrt oder entsperrt es. Solange es gesperrt ist, funktionieren die Bildschirmsteuerungen darunter weiter.</string>
|
||||
<string name="hud_group_look">Aussehen</string>
|
||||
<string name="hud_scale">Größe auf dem Bildschirm</string>
|
||||
<string name="hud_color_soft">Dezent</string>
|
||||
|
||||
@@ -616,7 +616,7 @@
|
||||
<string name="hud_size_minimal">Ελάχιστο</string>
|
||||
<string name="hud_size_mega">Μέγα</string>
|
||||
<string name="hud_locked">Κλείδωμα θέσης</string>
|
||||
<string name="hud_locked_hint">Σύρετε το HUD για να το μετακινήσετε· ένα παρατεταμένο πάτημα το κλειδώνει ή το ξεκλειδώνει.</string>
|
||||
<string name="hud_locked_hint">Σύρετε το HUD για να το μετακινήσετε· ένα παρατεταμένο πάτημα το κλειδώνει ή το ξεκλειδώνει. Όσο είναι κλειδωμένο, τα χειριστήρια οθόνης από κάτω του εξακολουθούν να λειτουργούν.</string>
|
||||
<string name="hud_group_look">Εμφάνιση</string>
|
||||
<string name="hud_scale">Μέγεθος στην οθόνη</string>
|
||||
<string name="hud_color_soft">Απαλό</string>
|
||||
|
||||
@@ -620,7 +620,7 @@
|
||||
<string name="hud_size_minimal">Mínimo</string>
|
||||
<string name="hud_size_mega">Mega</string>
|
||||
<string name="hud_locked">Fijar posición</string>
|
||||
<string name="hud_locked_hint">Arrastra el HUD para moverlo; una pulsación larga lo bloquea o lo desbloquea.</string>
|
||||
<string name="hud_locked_hint">Arrastra el HUD para moverlo; una pulsación larga lo bloquea o lo desbloquea. Mientras está bloqueado, los controles en pantalla que tiene debajo siguen funcionando.</string>
|
||||
<string name="hud_group_look">Aspecto</string>
|
||||
<string name="hud_scale">Tamaño en pantalla</string>
|
||||
<string name="hud_color_soft">Suave</string>
|
||||
|
||||
@@ -616,7 +616,7 @@
|
||||
<string name="hud_size_minimal">Minimaalinen</string>
|
||||
<string name="hud_size_mega">Mega</string>
|
||||
<string name="hud_locked">Lukitse paikalleen</string>
|
||||
<string name="hud_locked_hint">Siirrä HUD:ia vetämällä; pitkä painallus lukitsee tai vapauttaa sen.</string>
|
||||
<string name="hud_locked_hint">Siirrä HUD:ia vetämällä; pitkä painallus lukitsee tai vapauttaa sen. Lukittuna sen alla olevat näytön ohjaimet toimivat edelleen.</string>
|
||||
<string name="hud_group_look">Ulkoasu</string>
|
||||
<string name="hud_scale">Koko näytöllä</string>
|
||||
<string name="hud_color_soft">Pehmeä</string>
|
||||
|
||||
@@ -620,7 +620,7 @@
|
||||
<string name="hud_size_minimal">Minimal</string>
|
||||
<string name="hud_size_mega">Méga</string>
|
||||
<string name="hud_locked">Verrouiller la position</string>
|
||||
<string name="hud_locked_hint">Faites glisser le HUD pour le déplacer ; un appui long le verrouille ou le déverrouille.</string>
|
||||
<string name="hud_locked_hint">Faites glisser le HUD pour le déplacer ; un appui long le verrouille ou le déverrouille. Tant qu\'il est verrouillé, les commandes à l\'écran situées dessous restent utilisables.</string>
|
||||
<string name="hud_group_look">Apparence</string>
|
||||
<string name="hud_scale">Taille à l\'écran</string>
|
||||
<string name="hud_color_soft">Douce</string>
|
||||
|
||||
@@ -616,7 +616,7 @@
|
||||
<string name="hud_size_minimal">मिनिमल</string>
|
||||
<string name="hud_size_mega">मेगा</string>
|
||||
<string name="hud_locked">जगह पर लॉक करें</string>
|
||||
<string name="hud_locked_hint">HUD को खिसकाने के लिए उसे ड्रैग करें; देर तक दबाने से वह लॉक या अनलॉक होता है।</string>
|
||||
<string name="hud_locked_hint">HUD को खिसकाने के लिए उसे ड्रैग करें; देर तक दबाने से वह लॉक या अनलॉक होता है। लॉक रहने पर भी उसके नीचे के ऑन-स्क्रीन कंट्रोल काम करते रहते हैं।</string>
|
||||
<string name="hud_group_look">लुक</string>
|
||||
<string name="hud_scale">स्क्रीन पर आकार</string>
|
||||
<string name="hud_color_soft">हल्का</string>
|
||||
|
||||
@@ -616,7 +616,7 @@
|
||||
<string name="hud_size_minimal">Minimális</string>
|
||||
<string name="hud_size_mega">Mega</string>
|
||||
<string name="hud_locked">Rögzítés a helyén</string>
|
||||
<string name="hud_locked_hint">Húzd a HUD-ot az áthelyezéshez; hosszú nyomással rögzítheted vagy feloldhatod.</string>
|
||||
<string name="hud_locked_hint">Húzd a HUD-ot az áthelyezéshez; hosszú nyomással rögzítheted vagy feloldhatod. Rögzítve is működnek az alatta lévő képernyős vezérlők.</string>
|
||||
<string name="hud_group_look">Megjelenés</string>
|
||||
<string name="hud_scale">Méret a képernyőn</string>
|
||||
<string name="hud_color_soft">Lágy</string>
|
||||
|
||||
@@ -614,7 +614,7 @@
|
||||
<string name="hud_size_minimal">Minimal</string>
|
||||
<string name="hud_size_mega">Mega</string>
|
||||
<string name="hud_locked">Kunci posisi</string>
|
||||
<string name="hud_locked_hint">Seret HUD untuk memindahkannya; tekan lama untuk mengunci atau membuka kuncinya.</string>
|
||||
<string name="hud_locked_hint">Seret HUD untuk memindahkannya; tekan lama untuk mengunci atau membuka kuncinya. Saat terkunci, kontrol layar di bawahnya tetap berfungsi.</string>
|
||||
<string name="hud_group_look">Tampilan</string>
|
||||
<string name="hud_scale">Ukuran di layar</string>
|
||||
<string name="hud_color_soft">Lembut</string>
|
||||
|
||||
@@ -618,7 +618,7 @@
|
||||
<string name="hud_size_minimal">Minimo</string>
|
||||
<string name="hud_size_mega">Mega</string>
|
||||
<string name="hud_locked">Blocca in posizione</string>
|
||||
<string name="hud_locked_hint">Trascina l\'HUD per spostarlo; una pressione prolungata lo blocca o lo sblocca.</string>
|
||||
<string name="hud_locked_hint">Trascina l\'HUD per spostarlo; una pressione prolungata lo blocca o lo sblocca. Mentre è bloccato, i controlli su schermo sotto di esso continuano a funzionare.</string>
|
||||
<string name="hud_group_look">Aspetto</string>
|
||||
<string name="hud_scale">Dimensione sullo schermo</string>
|
||||
<string name="hud_color_soft">Tenue</string>
|
||||
|
||||
@@ -616,7 +616,7 @@
|
||||
<string name="hud_size_minimal">ミニマル</string>
|
||||
<string name="hud_size_mega">メガ</string>
|
||||
<string name="hud_locked">位置を固定</string>
|
||||
<string name="hud_locked_hint">HUDはドラッグで移動できます。長押しで固定または解除します。</string>
|
||||
<string name="hud_locked_hint">HUDはドラッグで移動できます。長押しで固定または解除します。固定中も、下にある画面上のコントロールは使えます。</string>
|
||||
<string name="hud_group_look">外観</string>
|
||||
<string name="hud_scale">画面上のサイズ</string>
|
||||
<string name="hud_color_soft">ソフト</string>
|
||||
|
||||
@@ -616,7 +616,7 @@
|
||||
<string name="hud_size_minimal">미니멀</string>
|
||||
<string name="hud_size_mega">메가</string>
|
||||
<string name="hud_locked">위치 고정</string>
|
||||
<string name="hud_locked_hint">HUD를 드래그하여 이동하고, 길게 눌러 고정하거나 해제합니다.</string>
|
||||
<string name="hud_locked_hint">HUD를 드래그하여 이동하고, 길게 눌러 고정하거나 해제합니다. 고정된 동안에도 아래에 있는 화면 컨트롤은 계속 작동합니다.</string>
|
||||
<string name="hud_group_look">외관</string>
|
||||
<string name="hud_scale">화면상 크기</string>
|
||||
<string name="hud_color_soft">은은함</string>
|
||||
|
||||
@@ -614,7 +614,7 @@
|
||||
<string name="hud_size_minimal">Minimal</string>
|
||||
<string name="hud_size_mega">Mega</string>
|
||||
<string name="hud_locked">Kunci di tempat</string>
|
||||
<string name="hud_locked_hint">Seret HUD untuk mengalihkannya; tekan lama untuk mengunci atau membuka kuncinya.</string>
|
||||
<string name="hud_locked_hint">Seret HUD untuk mengalihkannya; tekan lama untuk mengunci atau membuka kuncinya. Semasa dikunci, kawalan skrin di bawahnya masih berfungsi.</string>
|
||||
<string name="hud_group_look">Rupa</string>
|
||||
<string name="hud_scale">Saiz pada skrin</string>
|
||||
<string name="hud_color_soft">Lembut</string>
|
||||
|
||||
@@ -616,7 +616,7 @@
|
||||
<string name="hud_size_minimal">Minimal</string>
|
||||
<string name="hud_size_mega">Mega</string>
|
||||
<string name="hud_locked">Lås på plass</string>
|
||||
<string name="hud_locked_hint">Dra HUD-en for å flytte den; et langt trykk låser eller låser den opp.</string>
|
||||
<string name="hud_locked_hint">Dra HUD-en for å flytte den; et langt trykk låser eller låser den opp. Mens den er låst, fungerer skjermkontrollene under den fortsatt.</string>
|
||||
<string name="hud_group_look">Utseende</string>
|
||||
<string name="hud_scale">Størrelse på skjermen</string>
|
||||
<string name="hud_color_soft">Myk</string>
|
||||
|
||||
@@ -616,7 +616,7 @@
|
||||
<string name="hud_size_minimal">Minimaal</string>
|
||||
<string name="hud_size_mega">Mega</string>
|
||||
<string name="hud_locked">Vastzetten</string>
|
||||
<string name="hud_locked_hint">Sleep de HUD om hem te verplaatsen; lang drukken zet hem vast of los.</string>
|
||||
<string name="hud_locked_hint">Sleep de HUD om hem te verplaatsen; lang drukken zet hem vast of los. Zolang hij vastzit, blijven de schermknoppen eronder werken.</string>
|
||||
<string name="hud_group_look">Weergave</string>
|
||||
<string name="hud_scale">Grootte op scherm</string>
|
||||
<string name="hud_color_soft">Zacht</string>
|
||||
|
||||
@@ -620,7 +620,7 @@
|
||||
<string name="hud_size_minimal">Minimalny</string>
|
||||
<string name="hud_size_mega">Mega</string>
|
||||
<string name="hud_locked">Zablokuj w miejscu</string>
|
||||
<string name="hud_locked_hint">Przeciągnij HUD, aby go przesunąć; długie naciśnięcie blokuje go lub odblokowuje.</string>
|
||||
<string name="hud_locked_hint">Przeciągnij HUD, aby go przesunąć; długie naciśnięcie blokuje go lub odblokowuje. Gdy jest zablokowany, sterowanie ekranowe pod nim nadal działa.</string>
|
||||
<string name="hud_group_look">Wygląd</string>
|
||||
<string name="hud_scale">Rozmiar na ekranie</string>
|
||||
<string name="hud_color_soft">Stonowany</string>
|
||||
|
||||
@@ -618,7 +618,7 @@
|
||||
<string name="hud_size_minimal">Mínimo</string>
|
||||
<string name="hud_size_mega">Mega</string>
|
||||
<string name="hud_locked">Bloquear posição</string>
|
||||
<string name="hud_locked_hint">Arraste o HUD para o mover; um toque longo bloqueia-o ou desbloqueia-o.</string>
|
||||
<string name="hud_locked_hint">Arraste o HUD para o mover; um toque longo bloqueia-o ou desbloqueia-o. Enquanto estiver bloqueado, os controlos no ecrã por baixo dele continuam a funcionar.</string>
|
||||
<string name="hud_group_look">Aspeto</string>
|
||||
<string name="hud_scale">Tamanho no ecrã</string>
|
||||
<string name="hud_color_soft">Suave</string>
|
||||
|
||||
@@ -618,7 +618,7 @@
|
||||
<string name="hud_size_minimal">Mínimo</string>
|
||||
<string name="hud_size_mega">Mega</string>
|
||||
<string name="hud_locked">Travar posição</string>
|
||||
<string name="hud_locked_hint">Arraste o HUD para movê-lo; um toque longo o trava ou destrava.</string>
|
||||
<string name="hud_locked_hint">Arraste o HUD para movê-lo; um toque longo o trava ou destrava. Enquanto estiver travado, os controles na tela embaixo dele continuam funcionando.</string>
|
||||
<string name="hud_group_look">Aparência</string>
|
||||
<string name="hud_scale">Tamanho na tela</string>
|
||||
<string name="hud_color_soft">Suave</string>
|
||||
|
||||
@@ -618,7 +618,7 @@
|
||||
<string name="hud_size_minimal">Minimal</string>
|
||||
<string name="hud_size_mega">Mega</string>
|
||||
<string name="hud_locked">Blochează pe loc</string>
|
||||
<string name="hud_locked_hint">Trage HUD-ul pentru a-l muta; o apăsare lungă îl blochează sau îl deblochează.</string>
|
||||
<string name="hud_locked_hint">Trage HUD-ul pentru a-l muta; o apăsare lungă îl blochează sau îl deblochează. Cât timp e blocat, comenzile de pe ecran de sub el funcționează în continuare.</string>
|
||||
<string name="hud_group_look">Aspect</string>
|
||||
<string name="hud_scale">Dimensiune pe ecran</string>
|
||||
<string name="hud_color_soft">Discretă</string>
|
||||
|
||||
@@ -622,7 +622,7 @@
|
||||
<string name="hud_size_minimal">Минимальный</string>
|
||||
<string name="hud_size_mega">Мега</string>
|
||||
<string name="hud_locked">Закрепить на месте</string>
|
||||
<string name="hud_locked_hint">Перетащите HUD, чтобы переместить его; долгое нажатие закрепляет или открепляет его.</string>
|
||||
<string name="hud_locked_hint">Перетащите HUD, чтобы переместить его; долгое нажатие закрепляет или открепляет его. Пока он закреплён, экранные элементы управления под ним продолжают работать.</string>
|
||||
<string name="hud_group_look">Внешний вид</string>
|
||||
<string name="hud_scale">Размер на экране</string>
|
||||
<string name="hud_color_soft">Мягкий</string>
|
||||
|
||||
@@ -616,7 +616,7 @@
|
||||
<string name="hud_size_minimal">Minimal</string>
|
||||
<string name="hud_size_mega">Mega</string>
|
||||
<string name="hud_locked">Lås på plats</string>
|
||||
<string name="hud_locked_hint">Dra HUD:en för att flytta den; ett långt tryck låser eller låser upp den.</string>
|
||||
<string name="hud_locked_hint">Dra HUD:en för att flytta den; ett långt tryck låser eller låser upp den. När den är låst fungerar skärmkontrollerna under den fortfarande.</string>
|
||||
<string name="hud_group_look">Utseende</string>
|
||||
<string name="hud_scale">Storlek på skärmen</string>
|
||||
<string name="hud_color_soft">Mjuk</string>
|
||||
|
||||
@@ -614,7 +614,7 @@
|
||||
<string name="hud_size_minimal">มินิมอล</string>
|
||||
<string name="hud_size_mega">เมกะ</string>
|
||||
<string name="hud_locked">ล็อกตำแหน่ง</string>
|
||||
<string name="hud_locked_hint">ลาก HUD เพื่อย้าย กดค้างเพื่อล็อกหรือปลดล็อก</string>
|
||||
<string name="hud_locked_hint">ลาก HUD เพื่อย้าย กดค้างเพื่อล็อกหรือปลดล็อก ขณะล็อก ปุ่มควบคุมบนหน้าจอที่อยู่ด้านล่างยังใช้งานได้</string>
|
||||
<string name="hud_group_look">รูปลักษณ์</string>
|
||||
<string name="hud_scale">ขนาดบนหน้าจอ</string>
|
||||
<string name="hud_color_soft">อ่อน</string>
|
||||
|
||||
@@ -616,7 +616,7 @@
|
||||
<string name="hud_size_minimal">Minimal</string>
|
||||
<string name="hud_size_mega">Mega</string>
|
||||
<string name="hud_locked">Yerinde kilitle</string>
|
||||
<string name="hud_locked_hint">Taşımak için HUD\'u sürükleyin; uzun basmak onu kilitler veya kilidini açar.</string>
|
||||
<string name="hud_locked_hint">Taşımak için HUD\'u sürükleyin; uzun basmak onu kilitler veya kilidini açar. Kilitliyken altındaki ekran kontrolleri çalışmaya devam eder.</string>
|
||||
<string name="hud_group_look">Görünüm</string>
|
||||
<string name="hud_scale">Ekrandaki boyut</string>
|
||||
<string name="hud_color_soft">Yumuşak</string>
|
||||
|
||||
@@ -620,7 +620,7 @@
|
||||
<string name="hud_size_minimal">Мінімальний</string>
|
||||
<string name="hud_size_mega">Мега</string>
|
||||
<string name="hud_locked">Закріпити на місці</string>
|
||||
<string name="hud_locked_hint">Перетягніть HUD, щоб перемістити його; довге натискання закріплює або відкріплює його.</string>
|
||||
<string name="hud_locked_hint">Перетягніть HUD, щоб перемістити його; довге натискання закріплює або відкріплює його. Поки його закріплено, екранні елементи керування під ним працюють і далі.</string>
|
||||
<string name="hud_group_look">Вигляд</string>
|
||||
<string name="hud_scale">Розмір на екрані</string>
|
||||
<string name="hud_color_soft">М\'який</string>
|
||||
|
||||
@@ -614,7 +614,7 @@
|
||||
<string name="hud_size_minimal">Tối giản</string>
|
||||
<string name="hud_size_mega">Mega</string>
|
||||
<string name="hud_locked">Khóa vị trí</string>
|
||||
<string name="hud_locked_hint">Kéo HUD để di chuyển; nhấn giữ để khóa hoặc mở khóa.</string>
|
||||
<string name="hud_locked_hint">Kéo HUD để di chuyển; nhấn giữ để khóa hoặc mở khóa. Khi đã khóa, các nút điều khiển trên màn hình bên dưới vẫn hoạt động.</string>
|
||||
<string name="hud_group_look">Giao diện</string>
|
||||
<string name="hud_scale">Kích thước trên màn hình</string>
|
||||
<string name="hud_color_soft">Dịu</string>
|
||||
|
||||
@@ -616,7 +616,7 @@
|
||||
<string name="hud_size_minimal">极简</string>
|
||||
<string name="hud_size_mega">超大</string>
|
||||
<string name="hud_locked">锁定位置</string>
|
||||
<string name="hud_locked_hint">拖动 HUD 可移动位置;长按可锁定或解锁。</string>
|
||||
<string name="hud_locked_hint">拖动 HUD 可移动位置;长按可锁定或解锁。锁定时,下方的屏幕控件仍可使用。</string>
|
||||
<string name="hud_group_look">外观</string>
|
||||
<string name="hud_scale">屏幕显示大小</string>
|
||||
<string name="hud_color_soft">柔和</string>
|
||||
|
||||
@@ -616,7 +616,7 @@
|
||||
<string name="hud_size_minimal">極簡</string>
|
||||
<string name="hud_size_mega">超大</string>
|
||||
<string name="hud_locked">鎖定位置</string>
|
||||
<string name="hud_locked_hint">拖曳 HUD 可移動位置;長按可鎖定或解鎖。</string>
|
||||
<string name="hud_locked_hint">拖曳 HUD 可移動位置;長按可鎖定或解鎖。鎖定時,下方的螢幕控制項仍可使用。</string>
|
||||
<string name="hud_group_look">外觀</string>
|
||||
<string name="hud_scale">螢幕顯示大小</string>
|
||||
<string name="hud_color_soft">柔和</string>
|
||||
|
||||
@@ -616,7 +616,7 @@
|
||||
<string name="hud_size_minimal">極簡</string>
|
||||
<string name="hud_size_mega">超大</string>
|
||||
<string name="hud_locked">鎖定位置</string>
|
||||
<string name="hud_locked_hint">拖曳 HUD 可移動位置;長按可鎖定或解鎖。</string>
|
||||
<string name="hud_locked_hint">拖曳 HUD 可移動位置;長按可鎖定或解鎖。鎖定時,下方的螢幕控制項仍可使用。</string>
|
||||
<string name="hud_group_look">外觀</string>
|
||||
<string name="hud_scale">螢幕顯示大小</string>
|
||||
<string name="hud_color_soft">柔和</string>
|
||||
|
||||
@@ -675,7 +675,7 @@
|
||||
<string name="hud_size_minimal">Minimal</string>
|
||||
<string name="hud_size_mega">Mega</string>
|
||||
<string name="hud_locked">Lock in place</string>
|
||||
<string name="hud_locked_hint">Drag the HUD to move it; a long press locks or unlocks it.</string>
|
||||
<string name="hud_locked_hint">Drag the HUD to move it; a long press locks or unlocks it. While it is locked, on-screen controls under it still work.</string>
|
||||
<string name="hud_group_look">Look</string>
|
||||
<string name="hud_scale">Size on screen</string>
|
||||
<string name="hud_color_soft">Soft</string>
|
||||
|
||||
@@ -3,16 +3,24 @@ package com.droiddeck.launcher.hud
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Color
|
||||
import android.os.Looper
|
||||
import android.os.SystemClock
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.ViewConfiguration
|
||||
import android.widget.FrameLayout
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.Shadows.shadowOf
|
||||
import org.robolectric.annotation.Config
|
||||
import org.robolectric.annotation.GraphicsMode
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.time.Duration
|
||||
import java.util.Base64
|
||||
import kotlin.math.roundToInt
|
||||
import kotlin.math.sqrt
|
||||
@@ -25,6 +33,10 @@ class FusionHudPanelTest {
|
||||
assertEquals(FusionSize.MINIMAL, FusionSize.from(FusionHudConfig.DEFAULTS["hudSize"]))
|
||||
}
|
||||
|
||||
@Test fun theHudStartsLocked() {
|
||||
assertEquals("1", FusionHudConfig.DEFAULTS["hudLocked"])
|
||||
}
|
||||
|
||||
@Test fun everySizeDrawsTheDPanelWithEverythingInsideIt() {
|
||||
val stats = FrameStats()
|
||||
var now = 1_000_000_000L
|
||||
@@ -33,11 +45,7 @@ class FusionHudPanelTest {
|
||||
now += frametime
|
||||
stats.add(frametime, now)
|
||||
}
|
||||
val snapshot = HudMetrics.Snapshot(64, 52, 3302, 1050, 89, 79, 10_800_000_000L, 16_000_000_000L, 67f,
|
||||
1_800_000_000L, HudMetrics.Battery(16f, false, 79, 34, null),
|
||||
intArrayOf(91, 91, 48, 50, 48, 19, 17, 73), intArrayOf(2265, 2265, 3148, 3148, 3148, 2956, 2956, 3302),
|
||||
2_700_000_000L, 6_400_000_000L, 31_000L, 9_000L)
|
||||
|
||||
val snapshot = SNAPSHOT
|
||||
for (size in FusionSize.values()) {
|
||||
val view = FusionHudView(RuntimeEnvironment.getApplication())
|
||||
view.applyConfig(FusionHudConfig.encode(FusionHudConfig.DEFAULTS + ("hudSize" to size.token)))
|
||||
@@ -65,4 +73,76 @@ class FusionHudPanelTest {
|
||||
assertTrue("$size orb on the left side", Color.blue(orb) > 200 && Color.alpha(orb) > 200)
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun pillShowsEachBatteryPartOnItsOwnSwitch() {
|
||||
fun pill(vararg settings: Pair<String, String>): List<String> {
|
||||
val view = FusionHudView(RuntimeEnvironment.getApplication())
|
||||
view.applyConfig(FusionHudConfig.encode(FusionHudConfig.DEFAULTS + ("hudSize" to FusionSize.PILL.token) + settings))
|
||||
view.showForTest(SNAPSHOT, "DXVK", 0L)
|
||||
return view.linesForTest()
|
||||
}
|
||||
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 })
|
||||
}
|
||||
|
||||
@Test fun aLockedHudLetsTouchesThroughOnlyWhereAControlTakesThem() {
|
||||
val app = RuntimeEnvironment.getApplication()
|
||||
var reached = 0
|
||||
val under = View(app).apply {
|
||||
setOnTouchListener { _, e -> if (e.actionMasked == MotionEvent.ACTION_DOWN) reached++; true }
|
||||
}
|
||||
val hud = FusionHudView(app)
|
||||
val parent = FrameLayout(app)
|
||||
parent.addView(under, FrameLayout.LayoutParams(2000, 2000))
|
||||
parent.addView(hud, FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT))
|
||||
var control = false
|
||||
hud.passesTouchAt = { _, _ -> control }
|
||||
val locks = ArrayList<Boolean>()
|
||||
hud.setOnLockChangedListener { locks += it }
|
||||
hud.applyConfig(FusionHudConfig.encode(FusionHudConfig.DEFAULTS + ("hudLocked" to "0")))
|
||||
hud.showForTest(SNAPSHOT, "DXVK", 0L)
|
||||
val exactly = View.MeasureSpec.makeMeasureSpec(2000, View.MeasureSpec.EXACTLY)
|
||||
parent.measure(exactly, exactly)
|
||||
parent.layout(0, 0, 2000, 2000)
|
||||
assertTrue(hud.width > 0 && hud.height > 0)
|
||||
fun touch(holdMs: Long = 50L) {
|
||||
val x = hud.width / 2f; val y = hud.height / 2f
|
||||
val down = SystemClock.uptimeMillis()
|
||||
MotionEvent.obtain(down, down, MotionEvent.ACTION_DOWN, x, y, 0).also { parent.dispatchTouchEvent(it); it.recycle() }
|
||||
shadowOf(Looper.getMainLooper()).idleFor(Duration.ofMillis(holdMs))
|
||||
MotionEvent.obtain(down, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, x, y, 0).also { parent.dispatchTouchEvent(it); it.recycle() }
|
||||
shadowOf(Looper.getMainLooper()).idle()
|
||||
}
|
||||
control = true
|
||||
touch()
|
||||
assertEquals("an unlocked HUD keeps the touch (tap, drag, long press)", 0, reached)
|
||||
hud.applyConfig(FusionHudConfig.encode(FusionHudConfig.DEFAULTS + ("hudLocked" to "1")))
|
||||
touch()
|
||||
assertEquals("a locked HUD passes it to the control under it", 1, reached)
|
||||
control = false
|
||||
touch()
|
||||
assertEquals("a locked HUD keeps a touch no control takes", 1, reached)
|
||||
touch(holdMs = ViewConfiguration.getLongPressTimeout() + 300L)
|
||||
assertEquals("a long press there unlocks it", listOf(false), locks)
|
||||
}
|
||||
|
||||
private companion object {
|
||||
val SNAPSHOT = HudMetrics.Snapshot(64, 52, 3302, 1050, 89, 79, 10_800_000_000L, 16_000_000_000L, 67f,
|
||||
1_800_000_000L, HudMetrics.Battery(16f, false, 79, 34, null),
|
||||
intArrayOf(91, 91, 48, 50, 48, 19, 17, 73), intArrayOf(2265, 2265, 3148, 3148, 3148, 2956, 2956, 3302),
|
||||
2_700_000_000L, 6_400_000_000L, 31_000L, 9_000L)
|
||||
}
|
||||
}
|
||||
@@ -173,6 +173,17 @@ class OnScreenControlsTest {
|
||||
assertEquals(-1, field(control("rs"), "pressedBy"))
|
||||
}
|
||||
|
||||
@Test fun takesTouchAtMatchesWhatATouchDoes() {
|
||||
var checked = 0
|
||||
for (x in 0 until 1200 step 40) for (y in 0 until 800 step 40) {
|
||||
val expected = view.takesTouchAt(x.toFloat(), y.toFloat())
|
||||
assertEquals("($x, $y)", expected, touch(MotionEvent.ACTION_DOWN, 0 to (x.toFloat() to y.toFloat())))
|
||||
touch(MotionEvent.ACTION_UP, 0 to (x.toFloat() to y.toFloat()))
|
||||
if (expected) checked++
|
||||
}
|
||||
assertTrue("some points land on controls", checked > 0)
|
||||
}
|
||||
|
||||
@Test fun fixedSticksAndEditorRemainVisibleAtSavedPositions() {
|
||||
ControllerPrefs.setAdaptiveSticks(context, false)
|
||||
view.reload()
|
||||
|
||||
@@ -68,6 +68,22 @@ class ScreenKeysTest {
|
||||
assertTrue(accepts(GestureTouchStreamGate.Source.SURFACE, MotionEvent.ACTION_DOWN))
|
||||
}
|
||||
|
||||
@Test fun takesTouchAtMatchesWhatATouchDoes() {
|
||||
val keys = ScreenKeys(context) { _, _ -> }
|
||||
keys.layout(0, 0, 1000, 600)
|
||||
keys.add(listOf(KeyEvent.KEYCODE_W))
|
||||
var checked = 0
|
||||
for (x in 0 until 1000 step 25) for (y in 0 until 600 step 25) {
|
||||
val expected = keys.takesTouchAt(x.toFloat(), y.toFloat())
|
||||
val down = MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, x.toFloat(), y.toFloat(), 0)
|
||||
assertEquals("($x, $y)", expected, keys.onTouchEvent(down))
|
||||
down.recycle()
|
||||
MotionEvent.obtain(0L, 1L, MotionEvent.ACTION_UP, x.toFloat(), y.toFloat(), 0).also { keys.onTouchEvent(it); it.recycle() }
|
||||
if (expected) checked++
|
||||
}
|
||||
assertTrue("some points land on the key", checked > 0)
|
||||
}
|
||||
|
||||
@Test fun loadingLayoutReleasesLatchedKeysBeforeReplacingEntries() {
|
||||
val sent = mutableListOf<Pair<Int, Boolean>>()
|
||||
val keys = ScreenKeys(context) { code, down -> sent += code to down }
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import com.droiddeck.launcher.input.JoyConPadTest
|
||||
import com.droiddeck.launcher.input.PadBridge
|
||||
import com.droiddeck.launcher.session.SessionState
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.annotation.Config
|
||||
import java.nio.file.Files
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [34], manifest = Config.NONE, instrumentedPackages = ["com.droiddeck.launcher.input.FakeInputWriter"],
|
||||
shadows = [JoyConPadTest.RecordingWriter::class])
|
||||
class DeckControlsPanelTest {
|
||||
@Test fun takesTouchAtMatchesWhatATouchDoes() {
|
||||
val directory = Files.createTempDirectory("deck-panel").toFile()
|
||||
try {
|
||||
SessionState.deckPad = false
|
||||
// No pad: the Deck layouts (trackpads, grips). A pad without Deck controls: the gamepad layout
|
||||
// (sticks, d-pad, face buttons).
|
||||
for (pad in listOf(null, PadBridge(directory))) for (portraitDock in listOf(false, true)) {
|
||||
val name = "pad=${pad != null} portraitDock=$portraitDock"
|
||||
val panel = DeckControlsPanel(RuntimeEnvironment.getApplication(), onClose = {}, onSteamMenu = {}, onQam = {},
|
||||
pad = pad, portraitDock = portraitDock)
|
||||
assertEquals(name, pad == null, panel.deckControls)
|
||||
// The portrait dock sits under a portrait game; its gamepad layout needs a tall panel.
|
||||
val (w, h) = if (portraitDock) 720 to 1000 else 1200 to 480
|
||||
panel.measure(View.MeasureSpec.makeMeasureSpec(w, View.MeasureSpec.EXACTLY),
|
||||
View.MeasureSpec.makeMeasureSpec(h, View.MeasureSpec.EXACTLY))
|
||||
panel.layout(0, 0, w, h)
|
||||
var taken = 0
|
||||
var missed = 0
|
||||
for (x in 0 until w step w / 40) for (y in 0 until h step h / 24) {
|
||||
val expected = panel.takesTouchAt(x.toFloat(), y.toFloat())
|
||||
val down = MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, x.toFloat(), y.toFloat(), 0)
|
||||
assertEquals("$name ($x, $y)", expected, panel.dispatchTouchEvent(down))
|
||||
down.recycle()
|
||||
// Cancel rather than lift, so no button fires its action.
|
||||
MotionEvent.obtain(0L, 1L, MotionEvent.ACTION_CANCEL, x.toFloat(), y.toFloat(), 0).also { panel.dispatchTouchEvent(it); it.recycle() }
|
||||
if (expected) taken++ else missed++
|
||||
}
|
||||
assertTrue("$name: some points land on controls", taken > 0)
|
||||
assertTrue("$name: some points land between them", missed > 0)
|
||||
}
|
||||
} finally {
|
||||
directory.deleteRecursively()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user