feat(hud): long press collapses or expands the HUD, locking becomes an option (#2723)

* feat(hud): long press collapses or expands the HUD, locking becomes an option

* fix(hud): keep the collapsing tab at the press point while layout runs

The layout listener could run keepOnScreen during the dock animation and replace the press-centered target with the anchored edge position, which was then saved as the tab position. The dock animation now holds the same guard the other HUD animations use until the dock is committed.
This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-11-16 15:29:17 -05:00
1 parent 8e514ada62
commit fde3089900
41 files changed
+369 -51

No files matched your search

@@ -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", "hudSnap" to "1", "hudScale" to "100", "hudDock" to "none", "hudOpacity" to "80", "hudColor" to "mid",
"hudSize" to "minimal", "hudLocked" to "1", "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",
@@ -18,6 +18,8 @@ internal object DroidDeckHudConfig {
"tempUnit" to "c", "tempBands" to "1", "tempAuto" to "1", "tempRedCpu" to "90", "tempRedGpu" to "90", "tempRedBat" to "48",
)
const val HOLD_LOCKS = "lock"
private val NOT_READINGS = setOf("showCPULoad", "showRenderer", "fpsDecimal")
/** Orders saved before the GPU switch was named after the alias the HUD actually reads. */
@@ -119,6 +119,7 @@ class DroidDeckHudHost(context: Context) {
}
hud.setOnSizeCycledListener { size -> DroidDeckHudConfig.set(context, "hudSize", size); onConfigChanged?.invoke() }
hud.setOnDockChangedListener { token -> setDock(hud, DroidDeckHudDock.from(token)) }
hud.setOnHoldListener { rawX, rawY -> collapseAt(hud, rawX, rawY) }
hud.setOnScaledListener { percent ->
DroidDeckHudConfig.set(context, "hudScale", percent.toString())
onConfigChanged?.invoke()
@@ -291,7 +292,7 @@ class DroidDeckHudHost(context: Context) {
DroidDeckHudDock.RIGHT -> (maxX - hud.x) / hud.width
DroidDeckHudDock.TOP -> hud.y / hud.height
DroidDeckHudDock.BOTTOM -> (maxY - hud.y) / hud.height
DroidDeckHudDock.NONE -> 0f
DroidDeckHudDock.NONE, DroidDeckHudDock.FLOAT -> 0f
}
if (pulled >= 1f) { setDock(hud, DroidDeckHudDock.NONE); return }
wantX = hud.x; wantY = hud.y
@@ -375,12 +376,30 @@ class DroidDeckHudHost(context: Context) {
hud.scaleX = s; hud.scaleY = s
}
private fun setDock(hud: DroidDeckHudView, edge: DroidDeckHudDock) {
private fun setDock(hud: DroidDeckHudView, edge: DroidDeckHudDock, center: Pair<Float, Float>? = null) {
if (edge == hud.dock) return
animateDock(hud, edge) { commitDock(hud, edge) }
animateDock(hud, edge, center) { commitDock(hud, edge) }
}
private fun collapseAt(hud: DroidDeckHudView, rawX: Float, rawY: Float) {
if (hud.dock != DroidDeckHudDock.NONE) return
val p = hud.parent as? View ?: return
val at = IntArray(2).also { p.getLocationOnScreen(it) }
val x = rawX - at[0]
val y = rawY - at[1]
val edge = if (snaps) nearestEdge(x, y, p.width.toFloat(), p.height.toFloat()) else DroidDeckHudDock.FLOAT
setDock(hud, edge, Pair(x, y))
}
private fun nearestEdge(x: Float, y: Float, width: Float, height: Float): DroidDeckHudDock = mapOf(
DroidDeckHudDock.LEFT to x,
DroidDeckHudDock.RIGHT to width - x,
DroidDeckHudDock.TOP to y,
DroidDeckHudDock.BOTTOM to height - y,
).minByOrNull { it.value }!!.key
private fun commitDock(hud: DroidDeckHudView, edge: DroidDeckHudDock) {
snapping = false
val tabX = hud.x; val tabY = hud.y
if (edge != DroidDeckHudDock.NONE) {
val p = hud.parent as? View
@@ -407,12 +426,17 @@ class DroidDeckHudHost(context: Context) {
SessionPrefs.setDroidDeckHudPosition(context, wantX, wantY)
}
private fun animateDock(hud: DroidDeckHudView, edge: DroidDeckHudDock, commit: () -> Unit) {
private fun animateDock(hud: DroidDeckHudView, edge: DroidDeckHudDock, center: Pair<Float, Float>?, commit: () -> Unit) {
stopMotion(hud)
previewFade?.cancel(); previewFade = null
snapping = false
hud.alpha = 1f
val p = hud.parent as? View
if (edge != DroidDeckHudDock.NONE && center != null) {
val (tabW, tabH) = hud.dockTabSize()
wantX = center.first - tabW / 2f
wantY = center.second - tabH / 2f
}
if (Motion.scale == 0f || p == null || !hud.isLaidOut || hud.width <= 0) {
hud.scaleX = 1f; hud.scaleY = 1f
hud.setDockPreview(DroidDeckHudDock.NONE, 0f)
@@ -424,11 +448,14 @@ class DroidDeckHudHost(context: Context) {
hud.pivotX = 0f; hud.pivotY = 0f
hud.x = left; hud.y = top
val (tabW, tabH) = hud.dockTabSize()
wantX = left + (shownW - tabW) / 2f
wantY = top + (shownH - tabH) / 2f
if (center == null) {
wantX = left + (shownW - tabW) / 2f
wantY = top + (shownH - tabH) / 2f
}
val (tabX, tabY) = settled(p, edge, tabW, tabH)
val sx = tabW / hud.width; val sy = tabH / hud.height
val from = hud.dockPreviewBlend
snapping = true
hud.animate().x(tabX).y(tabY).scaleX(sx).scaleY(sy).setDuration(Motion.ms(220).toLong()).setInterpolator(EASE)
.setUpdateListener { hud.setDockPreview(edge, from + (1f - from) * it.animatedFraction) }
.withEndAction {
@@ -473,7 +500,7 @@ class DroidDeckHudHost(context: Context) {
DroidDeckHudDock.RIGHT -> x = maxX
DroidDeckHudDock.TOP -> y = 0f
DroidDeckHudDock.BOTTOM -> y = maxY
DroidDeckHudDock.NONE -> {}
DroidDeckHudDock.NONE, DroidDeckHudDock.FLOAT -> {}
}
return Pair(x, y)
}
@@ -118,7 +118,7 @@ enum class DroidDeckHudSize(val token: String, val label: String) {
}
enum class DroidDeckHudDock(val token: String) {
NONE("none"), LEFT("left"), RIGHT("right"), TOP("top"), BOTTOM("bottom");
NONE("none"), LEFT("left"), RIGHT("right"), TOP("top"), BOTTOM("bottom"), FLOAT("float");
companion object {
fun from(token: String?): DroidDeckHudDock = values().firstOrNull { it.token == token } ?: NONE
@@ -191,6 +191,8 @@ class DroidDeckHudView(context: Context) : View(context) {
private var onMovedListener: BiConsumer<Float, Float>? = null
private var onSizeCycledListener: Consumer<String>? = null
private var onLockChangedListener: Consumer<Boolean>? = null
private var onHoldListener: BiConsumer<Float, Float>? = null
fun setOnHoldListener(l: BiConsumer<Float, Float>?) { onHoldListener = l }
fun setOnMovedListener(l: BiConsumer<Float, Float>?) { onMovedListener = l }
fun setOnSizeCycledListener(l: Consumer<String>?) { onSizeCycledListener = l }
fun setOnLockChangedListener(l: Consumer<Boolean>?) { onLockChangedListener = l }
@@ -209,6 +211,7 @@ class DroidDeckHudView(context: Context) : View(context) {
override fun onDragged(rawX: Float, rawY: Float) { onDraggedListener?.accept(rawX, rawY) }
override fun onFlung(velocityX: Float, velocityY: Float) { onFlungListener?.accept(velocityX, velocityY) }
override fun onLockChanged(locked: Boolean) { onLockChangedListener?.accept(locked) }
override fun onHold(rawX: Float, rawY: Float) { onHoldListener?.accept(rawX, rawY) }
override fun onPinch(factor: Float) {
val next = (scale * factor).coerceIn(MIN_SCALE, MAX_SCALE)
if (next == scale) return
@@ -224,6 +227,7 @@ class DroidDeckHudView(context: Context) : View(context) {
private var tabStartX = 0f
private var tabStartY = 0f
private var tabDragging = false
private var tabPressed = false
private var onTabDraggedListener: BiConsumer<Float, Float>? = null
private var onTabDroppedListener: Runnable? = null
private var onTabDragCancelledListener: Runnable? = null
@@ -237,19 +241,24 @@ class DroidDeckHudView(context: Context) : View(context) {
tabDownRawX = event.rawX; tabDownRawY = event.rawY
tabStartX = x; tabStartY = y
tabDragging = false
tabPressed = true
}
MotionEvent.ACTION_MOVE -> {
MotionEvent.ACTION_MOVE -> if (tabPressed) {
val dx = event.rawX - tabDownRawX; val dy = event.rawY - tabDownRawY
if (!tabDragging && dx * dx + dy * dy > touchSlop * touchSlop) tabDragging = true
if (tabDragging) onTabDraggedListener?.accept(tabStartX + dx, tabStartY + dy)
}
MotionEvent.ACTION_UP -> {
MotionEvent.ACTION_UP -> if (tabPressed) {
tabPressed = false
if (tabDragging) { tabDragging = false; onTabDroppedListener?.run() }
else onDockChangedListener?.accept(DroidDeckHudDock.NONE.token)
}
MotionEvent.ACTION_CANCEL -> if (tabDragging) {
tabDragging = false
onTabDragCancelledListener?.run()
MotionEvent.ACTION_CANCEL -> {
tabPressed = false
if (tabDragging) {
tabDragging = false
onTabDragCancelledListener?.run()
}
}
}
return true
@@ -341,6 +350,7 @@ class DroidDeckHudView(context: Context) : View(context) {
showSession = switchOn("showSession")
tempDisplay = HudMetrics.TempDisplay.from(cfg)
lockController.setLocked(cfg.get("hudLocked", "1") == "1")
lockController.setHoldLocks(cfg.get("hudHold", "collapse") == DroidDeckHudConfig.HOLD_LOCKS)
dock = DroidDeckHudDock.from(cfg.get("hudDock", "none"))
colorIntensity = when (cfg.get("hudColor", "vivid")) {
@@ -591,7 +601,7 @@ class DroidDeckHudView(context: Context) : View(context) {
DroidDeckHudDock.RIGHT -> intArrayOf(1, 2)
DroidDeckHudDock.TOP -> intArrayOf(0, 1)
DroidDeckHudDock.BOTTOM -> intArrayOf(2, 3)
DroidDeckHudDock.NONE -> intArrayOf()
DroidDeckHudDock.NONE, DroidDeckHudDock.FLOAT -> intArrayOf()
}
for (corner in edge) { round[corner * 2] = 0f; round[corner * 2 + 1] = 0f }
tabPath.rewind()
@@ -36,6 +36,7 @@ public class HudLockController {
default void onDragged(float rawX, float rawY) {}
default void onFlung(float velocityX, float velocityY) {}
void onLockChanged(boolean locked);
default void onHold(float rawX, float rawY) {}
default void onPinch(float factor) {}
default void onPinchEnd() {}
}
@@ -53,6 +54,7 @@ public class HudLockController {
private final android.view.VelocityTracker velocity = android.view.VelocityTracker.obtain();
private boolean locked = false;
private boolean holdLocks = false;
private float downRawX, downRawY, startX, startY;
private boolean dragging = false;
@@ -80,6 +82,8 @@ public class HudLockController {
public void setLocked(boolean locked) { this.locked = locked; }
public void setHoldLocks(boolean holdLocks) { this.holdLocks = holdLocks; }
public boolean isLocked() { return locked; }
public boolean isDragging() { return dragging; }
@@ -119,6 +123,10 @@ public class HudLockController {
@Override
public void onLongPress(MotionEvent e) {
if (!holdLocks) {
cb.onHold(e.getRawX(), e.getRawY());
return;
}
locked = !locked;
cb.onLockChanged(locked);
flash(locked, HOLD_TOGGLE_MS);
@@ -37,6 +37,11 @@ internal fun DroidDeckHudSettings(host: MenuHost, a: DrawerActions, track: (Stri
DroidDeckHudSize.STRIP to stringResource(R.string.hud_size_strip),
),
size, chipModifier = track("hud-size")) { a.onHudSetting("hudSize", it.token) }
ChoiceRow(host, "hud-hold", stringResource(R.string.hud_hold), null,
listOf("collapse" to stringResource(R.string.hud_hold_collapse),
DroidDeckHudConfig.HOLD_LOCKS to stringResource(R.string.hud_hold_lock)),
if (cfg["hudHold"] == DroidDeckHudConfig.HOLD_LOCKS) DroidDeckHudConfig.HOLD_LOCKS else "collapse",
chipModifier = track("hud-hold")) { a.onHudSetting("hudHold", it) }
ToggleRow(host, "hud-locked", stringResource(R.string.hud_locked), stringResource(R.string.hud_locked_hint), on("hudLocked"),
chipModifier = track("hud-locked")) { a.onHudSetting("hudLocked", flag(it)) }
ToggleRow(host, "hud-snap", stringResource(R.string.hud_snap), stringResource(R.string.hud_snap_hint), on("hudSnap"),
+4 -1
View File
@@ -718,7 +718,10 @@
<string name="hud_size_mega">ضخم</string>
<string name="hud_size_strip">شريط</string>
<string name="hud_locked">تثبيت في مكانه</string>
<string name="hud_locked_hint">اسحب HUD لتحريكه؛ والضغط مطولًا يثبّته أو يلغي تثبيته. أثناء تثبيته، تظل عناصر التحكم على الشاشة الموجودة تحته تعمل.</string>
<string name="hud_locked_hint">اسحب HUD لتحريكه. أثناء تثبيته، تظل عناصر التحكم على الشاشة الموجودة تحته تعمل.</string>
<string name="hud_hold">ضغط مطوّل</string>
<string name="hud_hold_collapse">طيّ أو توسيع</string>
<string name="hud_hold_lock">تثبيت أو إلغاء التثبيت</string>
<string name="hud_snap">الالتصاق بالجانبين</string>
<string name="hud_snap_hint">اترك الواجهة لتنتقل إلى أقرب جانب من الشاشة. اسحبها بسرعة لترميها في ذلك الاتجاه.</string>
<string name="hud_group_look">المظهر</string>
+4 -1
View File
@@ -712,7 +712,10 @@
<string name="hud_size_mega">Mega</string>
<string name="hud_size_strip">Barra</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. Mientras está bloqueado, los controles en pantalla que tiene debajo siguen funcionando.</string>
<string name="hud_locked_hint">Arrastra el HUD para moverlo. Mientras está bloqueado, los controles en pantalla que tiene debajo siguen funcionando.</string>
<string name="hud_hold">Pulsación larga</string>
<string name="hud_hold_collapse">Contraer o expandir</string>
<string name="hud_hold_lock">Bloquear o desbloquear</string>
<string name="hud_snap">Ajustar a los lados</string>
<string name="hud_snap_hint">Al soltar el HUD, se mueve al lado más cercano de la pantalla. Un gesto rápido lo lanza en esa dirección.</string>
<string name="hud_group_look">Aspecto</string>
+4 -1
View File
@@ -710,7 +710,10 @@
<string name="hud_size_mega">Мега</string>
<string name="hud_size_strip">Лента</string>
<string name="hud_locked">Заключване на място</string>
<string name="hud_locked_hint">Плъзнете HUD, за да го преместите; продължително натискане го заключва или отключва. Докато е заключен, екранните контроли под него продължават да работят.</string>
<string name="hud_locked_hint">Плъзнете HUD, за да го преместите. Докато е заключен, екранните контроли под него продължават да работят.</string>
<string name="hud_hold">Продължително натискане</string>
<string name="hud_hold_collapse">Свиване или разгъване</string>
<string name="hud_hold_lock">Заключване или отключване</string>
<string name="hud_snap">Залепване отстрани</string>
<string name="hud_snap_hint">Пуснете HUD и той отива към по-близката страна на екрана. Бързо плъзване го хвърля в тази посока.</string>
<string name="hud_group_look">Визия</string>
+4 -1
View File
@@ -714,7 +714,10 @@
<string name="hud_size_mega">Mega</string>
<string name="hud_size_strip">Lišta</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. Když je zamknutý, ovládací prvky na obrazovce pod ním dál fungují.</string>
<string name="hud_locked_hint">Přetažením HUD přesunete. Když je zamknutý, ovládací prvky na obrazovce pod ním dál fungují.</string>
<string name="hud_hold">Dlouhý stisk</string>
<string name="hud_hold_collapse">Sbalit nebo rozbalit</string>
<string name="hud_hold_lock">Zamknout nebo odemknout</string>
<string name="hud_snap">Přichytit ke stranám</string>
<string name="hud_snap_hint">Pusťte HUD a přesune se k bližší straně obrazovky. Rychlým švihnutím ho hodíte tím směrem.</string>
<string name="hud_group_look">Vzhled</string>
+4 -1
View File
@@ -710,7 +710,10 @@
<string name="hud_size_mega">Mega</string>
<string name="hud_size_strip">Bjælke</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. Mens det er låst, virker skærmknapperne under det stadig.</string>
<string name="hud_locked_hint">Træk i HUD for at flytte det. Mens det er låst, virker skærmknapperne under det stadig.</string>
<string name="hud_hold">Langt tryk</string>
<string name="hud_hold_collapse">Skjul eller udvid</string>
<string name="hud_hold_lock">Lås eller frigør</string>
<string name="hud_snap">Fastgør til siderne</string>
<string name="hud_snap_hint">Slip HUD\'en, så flytter den sig til skærmens nærmeste side. Et hurtigt stryg kaster den i den retning.</string>
<string name="hud_group_look">Udseende</string>
+4 -1
View File
@@ -710,7 +710,10 @@
<string name="hud_size_mega">Mega</string>
<string name="hud_size_strip">Leiste</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. Solange es gesperrt ist, funktionieren die Bildschirmsteuerungen darunter weiter.</string>
<string name="hud_locked_hint">Ziehe das HUD, um es zu verschieben. Solange es gesperrt ist, funktionieren die Bildschirmsteuerungen darunter weiter.</string>
<string name="hud_hold">Langes Drücken</string>
<string name="hud_hold_collapse">Ein- oder ausklappen</string>
<string name="hud_hold_lock">Sperren oder entsperren</string>
<string name="hud_snap">An Seiten einrasten</string>
<string name="hud_snap_hint">Lass das HUD los, und es springt an die nähere Bildschirmseite. Ein Wischen wirft es in diese Richtung.</string>
<string name="hud_group_look">Aussehen</string>
+4 -1
View File
@@ -710,7 +710,10 @@
<string name="hud_size_mega">Μέγα</string>
<string name="hud_size_strip">Λωρίδα</string>
<string name="hud_locked">Κλείδωμα θέσης</string>
<string name="hud_locked_hint">Σύρετε το HUD για να το μετακινήσετε· ένα παρατεταμένο πάτημα το κλειδώνει ή το ξεκλειδώνει. Όσο είναι κλειδωμένο, τα χειριστήρια οθόνης από κάτω του εξακολουθούν να λειτουργούν.</string>
<string name="hud_locked_hint">Σύρετε το HUD για να το μετακινήσετε. Όσο είναι κλειδωμένο, τα χειριστήρια οθόνης από κάτω του εξακολουθούν να λειτουργούν.</string>
<string name="hud_hold">Παρατεταμένο πάτημα</string>
<string name="hud_hold_collapse">Σύμπτυξη ή ανάπτυξη</string>
<string name="hud_hold_lock">Κλείδωμα ή ξεκλείδωμα</string>
<string name="hud_snap">Προσκόλληση στα πλάγια</string>
<string name="hud_snap_hint">Αφήστε το HUD και μετακινείται στην πιο κοντινή πλευρά της οθόνης. Μια γρήγορη κίνηση το πετάει προς εκείνη την κατεύθυνση.</string>
<string name="hud_group_look">Εμφάνιση</string>
+4 -1
View File
@@ -712,7 +712,10 @@
<string name="hud_size_mega">Mega</string>
<string name="hud_size_strip">Barra</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. Mientras está bloqueado, los controles en pantalla que tiene debajo siguen funcionando.</string>
<string name="hud_locked_hint">Arrastra el HUD para moverlo. Mientras está bloqueado, los controles en pantalla que tiene debajo siguen funcionando.</string>
<string name="hud_hold">Pulsación larga</string>
<string name="hud_hold_collapse">Contraer o expandir</string>
<string name="hud_hold_lock">Bloquear o desbloquear</string>
<string name="hud_snap">Ajustar a los lados</string>
<string name="hud_snap_hint">Al soltar el HUD, se mueve al lado más cercano de la pantalla. Un gesto rápido lo lanza en esa dirección.</string>
<string name="hud_group_look">Aspecto</string>
+4 -1
View File
@@ -710,7 +710,10 @@
<string name="hud_size_mega">Mega</string>
<string name="hud_size_strip">Palkki</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. Lukittuna sen alla olevat näytön ohjaimet toimivat edelleen.</string>
<string name="hud_locked_hint">Siirrä HUD:ia vetämällä. Lukittuna sen alla olevat näytön ohjaimet toimivat edelleen.</string>
<string name="hud_hold">Pitkä painallus</string>
<string name="hud_hold_collapse">Tiivistä tai laajenna</string>
<string name="hud_hold_lock">Lukitse tai vapauta</string>
<string name="hud_snap">Kiinnitä sivuille</string>
<string name="hud_snap_hint">Kun päästät HUDista irti, se siirtyy näytön lähempään reunaan. Nopea pyyhkäisy heittää sen siihen suuntaan.</string>
<string name="hud_group_look">Ulkoasu</string>
+4 -1
View File
@@ -712,7 +712,10 @@
<string name="hud_size_mega">Méga</string>
<string name="hud_size_strip">Bandeau</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. Tant qu\'il est verrouillé, les commandes à l\'écran situées dessous restent utilisables.</string>
<string name="hud_locked_hint">Faites glisser le HUD pour le déplacer. Tant qu\'il est verrouillé, les commandes à l\'écran situées dessous restent utilisables.</string>
<string name="hud_hold">Appui long</string>
<string name="hud_hold_collapse">Réduire ou développer</string>
<string name="hud_hold_lock">Verrouiller ou déverrouiller</string>
<string name="hud_snap">Aimanter sur les côtés</string>
<string name="hud_snap_hint">Relâchez le HUD et il rejoint le côté de l’écran le plus proche. Un geste rapide le lance dans cette direction.</string>
<string name="hud_group_look">Apparence</string>
+4 -1
View File
@@ -710,7 +710,10 @@
<string name="hud_size_mega">मेगा</string>
<string name="hud_size_strip">पट्टी</string>
<string name="hud_locked">जगह पर लॉक करें</string>
<string name="hud_locked_hint">HUD को खिसकाने के लिए उसे ड्रैग करें; देर तक दबाने से वह लॉक या अनलॉक होता है। लॉक रहने पर भी उसके नीचे के ऑन-स्क्रीन कंट्रोल काम करते रहते हैं।</string>
<string name="hud_locked_hint">HUD को खिसकाने के लिए उसे ड्रैग करें। लॉक रहने पर भी उसके नीचे के ऑन-स्क्रीन कंट्रोल काम करते रहते हैं।</string>
<string name="hud_hold">देर तक दबाना</string>
<string name="hud_hold_collapse">सिकोड़ें या फैलाएँ</string>
<string name="hud_hold_lock">लॉक या अनलॉक करें</string>
<string name="hud_snap">किनारों पर चिपकाएँ</string>
<string name="hud_snap_hint">HUD छोड़ने पर यह स्क्रीन की पास वाली ओर चला जाता है। तेज़ी से झटकने पर यह उसी दिशा में जाता है।</string>
<string name="hud_group_look">लुक</string>
+4 -1
View File
@@ -710,7 +710,10 @@
<string name="hud_size_mega">Mega</string>
<string name="hud_size_strip">Sáv</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. Rögzítve is működnek az alatta lévő képernyős vezérlők.</string>
<string name="hud_locked_hint">Húzd a HUD-ot az áthelyezéshez. Rögzítve is működnek az alatta lévő képernyős vezérlők.</string>
<string name="hud_hold">Hosszú nyomás</string>
<string name="hud_hold_collapse">Összecsukás vagy kinyitás</string>
<string name="hud_hold_lock">Rögzítés vagy feloldás</string>
<string name="hud_snap">Igazítás az oldalakhoz</string>
<string name="hud_snap_hint">Engedd el a HUD-ot, és a képernyő közelebbi oldalára ugrik. Egy gyors pöccintés abba az irányba dobja.</string>
<string name="hud_group_look">Megjelenés</string>
+4 -1
View File
@@ -708,7 +708,10 @@
<string name="hud_size_mega">Mega</string>
<string name="hud_size_strip">Bilah</string>
<string name="hud_locked">Kunci posisi</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_locked_hint">Seret HUD untuk memindahkannya. Saat terkunci, kontrol layar di bawahnya tetap berfungsi.</string>
<string name="hud_hold">Tekan lama</string>
<string name="hud_hold_collapse">Ciutkan atau perluas</string>
<string name="hud_hold_lock">Kunci atau buka kunci</string>
<string name="hud_snap">Tempel ke sisi</string>
<string name="hud_snap_hint">Lepaskan HUD dan HUD akan pindah ke sisi layar yang lebih dekat. Jentikan cepat melemparnya ke arah itu.</string>
<string name="hud_group_look">Tampilan</string>
+4 -1
View File
@@ -712,7 +712,10 @@
<string name="hud_size_mega">Mega</string>
<string name="hud_size_strip">Barra</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. Mentre è bloccato, i controlli su schermo sotto di esso continuano a funzionare.</string>
<string name="hud_locked_hint">Trascina l\'HUD per spostarlo. Mentre è bloccato, i controlli su schermo sotto di esso continuano a funzionare.</string>
<string name="hud_hold">Pressione prolungata</string>
<string name="hud_hold_collapse">Comprimi o espandi</string>
<string name="hud_hold_lock">Blocca o sblocca</string>
<string name="hud_snap">Aggancia ai lati</string>
<string name="hud_snap_hint">Rilascia l\'HUD e si sposta sul lato più vicino dello schermo. Un gesto rapido lo lancia in quella direzione.</string>
<string name="hud_group_look">Aspetto</string>
+4 -1
View File
@@ -708,7 +708,10 @@
<string name="hud_size_mega">メガ</string>
<string name="hud_size_strip">バー</string>
<string name="hud_locked">位置を固定</string>
<string name="hud_locked_hint">HUDはドラッグで移動できます。長押しで固定または解除します。固定中も、下にある画面上のコントロールは使えます。</string>
<string name="hud_locked_hint">HUDはドラッグで移動できます。固定中も、下にある画面上のコントロールは使えます。</string>
<string name="hud_hold">長押し</string>
<string name="hud_hold_collapse">折りたたみ/展開</string>
<string name="hud_hold_lock">固定/解除</string>
<string name="hud_snap">左右に吸着</string>
<string name="hud_snap_hint">HUD を離すと、画面の近い方の端に移動します。はじくとその方向へ飛びます。</string>
<string name="hud_group_look">外観</string>
+4 -1
View File
@@ -708,7 +708,10 @@
<string name="hud_size_mega">메가</string>
<string name="hud_size_strip">바</string>
<string name="hud_locked">위치 고정</string>
<string name="hud_locked_hint">HUD를 드래그하여 이동하고, 길게 눌러 고정하거나 해제합니다. 고정된 동안에도 아래에 있는 화면 컨트롤은 계속 작동합니다.</string>
<string name="hud_locked_hint">HUD를 드래그하여 이동합니다. 고정된 동안에도 아래에 있는 화면 컨트롤은 계속 작동합니다.</string>
<string name="hud_hold">길게 누르기</string>
<string name="hud_hold_collapse">접기 또는 펼치기</string>
<string name="hud_hold_lock">고정 또는 해제</string>
<string name="hud_snap">양옆에 맞추기</string>
<string name="hud_snap_hint">HUD를 놓으면 화면에서 더 가까운 쪽으로 이동합니다. 튕기면 그 방향으로 이동합니다.</string>
<string name="hud_group_look">외관</string>
+4 -1
View File
@@ -708,7 +708,10 @@
<string name="hud_size_mega">Mega</string>
<string name="hud_size_strip">Jalur</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. Semasa dikunci, kawalan skrin di bawahnya masih berfungsi.</string>
<string name="hud_locked_hint">Seret HUD untuk mengalihkannya. Semasa dikunci, kawalan skrin di bawahnya masih berfungsi.</string>
<string name="hud_hold">Tekan lama</string>
<string name="hud_hold_collapse">Kuncupkan atau kembangkan</string>
<string name="hud_hold_lock">Kunci atau buka kunci</string>
<string name="hud_snap">Lekap ke sisi</string>
<string name="hud_snap_hint">Lepaskan HUD dan ia akan beralih ke sisi skrin yang lebih dekat. Kuis pantas melemparkannya ke arah itu.</string>
<string name="hud_group_look">Rupa</string>
+4 -1
View File
@@ -710,7 +710,10 @@
<string name="hud_size_mega">Mega</string>
<string name="hud_size_strip">Linje</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. Mens den er låst, fungerer skjermkontrollene under den fortsatt.</string>
<string name="hud_locked_hint">Dra HUD-en for å flytte den. Mens den er låst, fungerer skjermkontrollene under den fortsatt.</string>
<string name="hud_hold">Langt trykk</string>
<string name="hud_hold_collapse">Skjul eller utvid</string>
<string name="hud_hold_lock">Lås eller lås opp</string>
<string name="hud_snap">Fest til sidene</string>
<string name="hud_snap_hint">Slipp HUD-en, så flytter den seg til nærmeste side av skjermen. Et raskt sveip kaster den den veien.</string>
<string name="hud_group_look">Utseende</string>
+4 -1
View File
@@ -710,7 +710,10 @@
<string name="hud_size_mega">Mega</string>
<string name="hud_size_strip">Balk</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. Zolang hij vastzit, blijven de schermknoppen eronder werken.</string>
<string name="hud_locked_hint">Sleep de HUD om hem te verplaatsen. Zolang hij vastzit, blijven de schermknoppen eronder werken.</string>
<string name="hud_hold">Lang drukken</string>
<string name="hud_hold_collapse">Samenvouwen of uitklappen</string>
<string name="hud_hold_lock">Vastzetten of losmaken</string>
<string name="hud_snap">Vastklikken aan zijkanten</string>
<string name="hud_snap_hint">Laat de HUD los en hij gaat naar de dichtstbijzijnde kant van het scherm. Met een snelle veeg gooi je hem die kant op.</string>
<string name="hud_group_look">Weergave</string>
+4 -1
View File
@@ -714,7 +714,10 @@
<string name="hud_size_mega">Mega</string>
<string name="hud_size_strip">Pasek</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. Gdy jest zablokowany, sterowanie ekranowe pod nim nadal działa.</string>
<string name="hud_locked_hint">Przeciągnij HUD, aby go przesunąć. Gdy jest zablokowany, sterowanie ekranowe pod nim nadal działa.</string>
<string name="hud_hold">Długie naciśnięcie</string>
<string name="hud_hold_collapse">Zwiń lub rozwiń</string>
<string name="hud_hold_lock">Zablokuj lub odblokuj</string>
<string name="hud_snap">Przyciągaj do boków</string>
<string name="hud_snap_hint">Puść HUD, a przesunie się do bliższego boku ekranu. Szybki ruch rzuca go w tę stronę.</string>
<string name="hud_group_look">Wygląd</string>
+4 -1
View File
@@ -712,7 +712,10 @@
<string name="hud_size_mega">Mega</string>
<string name="hud_size_strip">Barra</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. Enquanto estiver bloqueado, os controlos no ecrã por baixo dele continuam a funcionar.</string>
<string name="hud_locked_hint">Arraste o HUD para o mover. Enquanto estiver bloqueado, os controlos no ecrã por baixo dele continuam a funcionar.</string>
<string name="hud_hold">Toque longo</string>
<string name="hud_hold_collapse">Recolher ou expandir</string>
<string name="hud_hold_lock">Bloquear ou desbloquear</string>
<string name="hud_snap">Encaixar nas laterais</string>
<string name="hud_snap_hint">Solte o HUD e ele vai para a lateral mais próxima do ecrã. Um gesto rápido lança-o nessa direção.</string>
<string name="hud_group_look">Aspeto</string>
+4 -1
View File
@@ -712,7 +712,10 @@
<string name="hud_size_mega">Mega</string>
<string name="hud_size_strip">Barra</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. Enquanto estiver travado, os controles na tela embaixo dele continuam funcionando.</string>
<string name="hud_locked_hint">Arraste o HUD para movê-lo. Enquanto estiver travado, os controles na tela embaixo dele continuam funcionando.</string>
<string name="hud_hold">Toque longo</string>
<string name="hud_hold_collapse">Recolher ou expandir</string>
<string name="hud_hold_lock">Travar ou destravar</string>
<string name="hud_snap">Encaixar nas laterais</string>
<string name="hud_snap_hint">Solte o HUD e ele vai para a lateral mais próxima da tela. Um gesto rápido o lança nessa direção.</string>
<string name="hud_group_look">Aparência</string>
+4 -1
View File
@@ -712,7 +712,10 @@
<string name="hud_size_mega">Mega</string>
<string name="hud_size_strip">Bară</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ă. Cât timp e blocat, comenzile de pe ecran de sub el funcționează în continuare.</string>
<string name="hud_locked_hint">Trage HUD-ul pentru a-l muta. Cât timp e blocat, comenzile de pe ecran de sub el funcționează în continuare.</string>
<string name="hud_hold">Apăsare lungă</string>
<string name="hud_hold_collapse">Restrânge sau extinde</string>
<string name="hud_hold_lock">Blochează sau deblochează</string>
<string name="hud_snap">Fixare în lateral</string>
<string name="hud_snap_hint">Eliberează HUD-ul și se mută în partea mai apropiată a ecranului. Un gest rapid îl aruncă în acea direcție.</string>
<string name="hud_group_look">Aspect</string>
+4 -1
View File
@@ -714,7 +714,10 @@
<string name="hud_size_mega">Мега</string>
<string name="hud_size_strip">Полоса</string>
<string name="hud_locked">Закрепить на месте</string>
<string name="hud_locked_hint">Перетащите HUD, чтобы переместить его; долгое нажатие закрепляет или открепляет его. Пока он закреплён, экранные элементы управления под ним продолжают работать.</string>
<string name="hud_locked_hint">Перетащите HUD, чтобы переместить его. Пока он закреплён, экранные элементы управления под ним продолжают работать.</string>
<string name="hud_hold">Долгое нажатие</string>
<string name="hud_hold_collapse">Свернуть или развернуть</string>
<string name="hud_hold_lock">Закрепить или открепить</string>
<string name="hud_snap">Прилипание к бокам</string>
<string name="hud_snap_hint">Отпустите HUD, и он переместится к ближайшей стороне экрана. Резкий жест отбросит его в ту сторону.</string>
<string name="hud_group_look">Внешний вид</string>
+4 -1
View File
@@ -710,7 +710,10 @@
<string name="hud_size_mega">Mega</string>
<string name="hud_size_strip">List</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. När den är låst fungerar skärmkontrollerna under den fortfarande.</string>
<string name="hud_locked_hint">Dra HUD:en för att flytta den. När den är låst fungerar skärmkontrollerna under den fortfarande.</string>
<string name="hud_hold">Långt tryck</string>
<string name="hud_hold_collapse">Fäll ihop eller fäll ut</string>
<string name="hud_hold_lock">Lås eller lås upp</string>
<string name="hud_snap">Fäst mot sidorna</string>
<string name="hud_snap_hint">Släpp HUD:en så flyttas den till skärmens närmaste sida. En snabb svepning kastar den åt det hållet.</string>
<string name="hud_group_look">Utseende</string>
+4 -1
View File
@@ -708,7 +708,10 @@
<string name="hud_size_mega">เมกะ</string>
<string name="hud_size_strip">แถบ</string>
<string name="hud_locked">ล็อกตำแหน่ง</string>
<string name="hud_locked_hint">ลาก HUD เพื่อย้าย กดค้างเพื่อล็อกหรือปลดล็อก ขณะล็อก ปุ่มควบคุมบนหน้าจอที่อยู่ด้านล่างยังใช้งานได้</string>
<string name="hud_locked_hint">ลาก HUD เพื่อย้าย ขณะล็อก ปุ่มควบคุมบนหน้าจอที่อยู่ด้านล่างยังใช้งานได้</string>
<string name="hud_hold">กดค้าง</string>
<string name="hud_hold_collapse">ย่อหรือขยาย</string>
<string name="hud_hold_lock">ล็อกหรือปลดล็อก</string>
<string name="hud_snap">ยึดติดด้านข้าง</string>
<string name="hud_snap_hint">ปล่อย HUD แล้วจะย้ายไปด้านที่ใกล้กว่าของหน้าจอ ปัดเร็วๆ เพื่อเหวี่ยงไปทางนั้น</string>
<string name="hud_group_look">รูปลักษณ์</string>
+4 -1
View File
@@ -710,7 +710,10 @@
<string name="hud_size_mega">Mega</string>
<string name="hud_size_strip">Şerit</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. Kilitliyken altındaki ekran kontrolleri çalışmaya devam eder.</string>
<string name="hud_locked_hint">Taşımak için HUD\'u sürükleyin. Kilitliyken altındaki ekran kontrolleri çalışmaya devam eder.</string>
<string name="hud_hold">Uzun basma</string>
<string name="hud_hold_collapse">Daralt veya genişlet</string>
<string name="hud_hold_lock">Kilitle veya kilidini aç</string>
<string name="hud_snap">Yanlara yapıştır</string>
<string name="hud_snap_hint">HUD\'u bıraktığınızda ekranın daha yakın tarafına gider. Hızlı bir kaydırma onu o yöne fırlatır.</string>
<string name="hud_group_look">Görünüm</string>
+4 -1
View File
@@ -714,7 +714,10 @@
<string name="hud_size_mega">Мега</string>
<string name="hud_size_strip">Смуга</string>
<string name="hud_locked">Закріпити на місці</string>
<string name="hud_locked_hint">Перетягніть HUD, щоб перемістити його; довге натискання закріплює або відкріплює його. Поки його закріплено, екранні елементи керування під ним працюють і далі.</string>
<string name="hud_locked_hint">Перетягніть HUD, щоб перемістити його. Поки його закріплено, екранні елементи керування під ним працюють і далі.</string>
<string name="hud_hold">Довге натискання</string>
<string name="hud_hold_collapse">Згорнути або розгорнути</string>
<string name="hud_hold_lock">Закріпити або відкріпити</string>
<string name="hud_snap">Прилипання до боків</string>
<string name="hud_snap_hint">Відпустіть HUD, і він переміститься до ближчого боку екрана. Різкий жест відкине його в той бік.</string>
<string name="hud_group_look">Вигляд</string>
+4 -1
View File
@@ -708,7 +708,10 @@
<string name="hud_size_mega">Mega</string>
<string name="hud_size_strip">Thanh</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. 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_locked_hint">Kéo HUD để di chuyển. 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_hold">Nhấn giữ</string>
<string name="hud_hold_collapse">Thu gọn hoặc mở rộng</string>
<string name="hud_hold_lock">Khóa hoặc mở khóa</string>
<string name="hud_snap">Bám vào cạnh trái/phải</string>
<string name="hud_snap_hint">Thả HUD ra và nó sẽ di chuyển sang cạnh màn hình gần hơn. Vuốt nhanh để ném nó theo hướng đó.</string>
<string name="hud_group_look">Giao diện</string>
+4 -1
View File
@@ -708,7 +708,10 @@
<string name="hud_size_mega">超大</string>
<string name="hud_size_strip">横条</string>
<string name="hud_locked">锁定位置</string>
<string name="hud_locked_hint">拖动 HUD 可移动位置;长按可锁定或解锁。锁定时,下方的屏幕控件仍可使用。</string>
<string name="hud_locked_hint">拖动 HUD 可移动位置。锁定时,下方的屏幕控件仍可使用。</string>
<string name="hud_hold">长按</string>
<string name="hud_hold_collapse">折叠或展开</string>
<string name="hud_hold_lock">锁定或解锁</string>
<string name="hud_snap">吸附到两侧</string>
<string name="hud_snap_hint">松开 HUD 后,它会移到屏幕较近的一侧。轻甩可将它甩向该方向。</string>
<string name="hud_group_look">外观</string>
+4 -1
View File
@@ -708,7 +708,10 @@
<string name="hud_size_mega">超大</string>
<string name="hud_size_strip">橫條</string>
<string name="hud_locked">鎖定位置</string>
<string name="hud_locked_hint">拖曳 HUD 可移動位置;長按可鎖定或解鎖。鎖定時,下方的螢幕控制項仍可使用。</string>
<string name="hud_locked_hint">拖曳 HUD 可移動位置。鎖定時,下方的螢幕控制項仍可使用。</string>
<string name="hud_hold">長按</string>
<string name="hud_hold_collapse">摺疊或展開</string>
<string name="hud_hold_lock">鎖定或解鎖</string>
<string name="hud_snap">貼齊兩側</string>
<string name="hud_snap_hint">放開 HUD 後,它會移到螢幕較近的一側。輕甩可將它甩向該方向。</string>
<string name="hud_group_look">外觀</string>
+4 -1
View File
@@ -708,7 +708,10 @@
<string name="hud_size_mega">超大</string>
<string name="hud_size_strip">橫條</string>
<string name="hud_locked">鎖定位置</string>
<string name="hud_locked_hint">拖曳 HUD 可移動位置;長按可鎖定或解鎖。鎖定時,下方的螢幕控制項仍可使用。</string>
<string name="hud_locked_hint">拖曳 HUD 可移動位置。鎖定時,下方的螢幕控制項仍可使用。</string>
<string name="hud_hold">長按</string>
<string name="hud_hold_collapse">收合或展開</string>
<string name="hud_hold_lock">鎖定或解鎖</string>
<string name="hud_snap">貼齊兩側</string>
<string name="hud_snap_hint">放開 HUD 後,它會移到螢幕較近的一側。輕甩可將它甩向該方向。</string>
<string name="hud_group_look">外觀</string>
+4 -1
View File
@@ -738,7 +738,10 @@
<string name="hud_size_mega">Mega</string>
<string name="hud_size_strip">Strip</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. While it is locked, on-screen controls under it still work.</string>
<string name="hud_locked_hint">Drag the HUD to move it. While it is locked, on-screen controls under it still work.</string>
<string name="hud_hold">Long press</string>
<string name="hud_hold_collapse">Collapse or expand</string>
<string name="hud_hold_lock">Lock or unlock</string>
<string name="hud_snap">Snap to sides</string>
<string name="hud_snap_hint">Let go of the HUD and it moves to the nearer side of the screen. A flick throws it that way.</string>
<string name="hud_group_look">Look</string>
@@ -0,0 +1,99 @@
package com.droiddeck.launcher.hud
import android.os.Looper
import android.os.SystemClock
import android.provider.Settings
import android.view.MotionEvent
import android.view.View
import android.view.ViewConfiguration
import android.widget.FrameLayout
import com.droiddeck.launcher.session.SessionPrefs
import com.droiddeck.launcher.ui.Motion
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Before
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.time.Duration
import java.util.function.BiConsumer
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [33], qualifiers = "xhdpi")
@GraphicsMode(GraphicsMode.Mode.NATIVE)
class DroidDeckHudHostCollapseTest {
private fun animate(scale: Float) {
val app = RuntimeEnvironment.getApplication()
Settings.Global.putFloat(app.contentResolver, Settings.Global.ANIMATOR_DURATION_SCALE, scale)
Motion.refresh(app)
}
@Before fun noAnimation() = animate(0f)
@After fun restoreAnimation() = animate(1f)
private fun collapse(snap: String, hudX: Float, hudY: Float, pressX: Float, pressY: Float, layoutDuringCollapse: Boolean = false): Triple<DroidDeckHudView, String, Pair<Float, Float>> {
val app = RuntimeEnvironment.getApplication()
SessionPrefs.setDroidDeckHudConfig(app, DroidDeckHudConfig.encode(DroidDeckHudConfig.DEFAULTS + ("hudSnap" to snap) + ("hudSize" to "full")))
SessionPrefs.setDroidDeckHudPosition(app, hudX, hudY)
val root = FrameLayout(app)
val host = DroidDeckHudHost(app)
host.attach(root, 0)
val hud = root.getChildAt(0) as DroidDeckHudView
hud.visibility = View.VISIBLE
hud.showForTest(DroidDeckHudPanelTest.SNAPSHOT, "DXVK", 0L)
val exactly = { size: Int -> View.MeasureSpec.makeMeasureSpec(size, View.MeasureSpec.EXACTLY) }
root.measure(exactly(2000), exactly(1000))
root.layout(0, 0, 2000, 1000)
hud.x = hudX; hud.y = hudY
if (layoutDuringCollapse) {
@Suppress("UNCHECKED_CAST")
val collapse = DroidDeckHudView::class.java.getDeclaredField("onHoldListener").also { it.isAccessible = true }.get(hud) as BiConsumer<Float, Float>
hud.setOnHoldListener { x, y ->
collapse.accept(x, y)
hud.requestLayout()
root.measure(exactly(2000), exactly(1000))
root.layout(0, 0, 2000, 1000)
}
}
val down = SystemClock.uptimeMillis()
MotionEvent.obtain(down, down, MotionEvent.ACTION_DOWN, pressX, pressY, 0).also { root.dispatchTouchEvent(it); it.recycle() }
shadowOf(Looper.getMainLooper()).idleFor(Duration.ofMillis(ViewConfiguration.getLongPressTimeout() + 300L))
MotionEvent.obtain(down, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, pressX, pressY, 0).also { root.dispatchTouchEvent(it); it.recycle() }
shadowOf(Looper.getMainLooper()).idleFor(Duration.ofMillis(1000))
root.measure(exactly(2000), exactly(1000))
root.layout(0, 0, 2000, 1000)
shadowOf(Looper.getMainLooper()).idle()
val stored = DroidDeckHudConfig.load(app)["hudDock"].orEmpty()
return Triple(hud, stored, hud.x to hud.y)
}
@Test fun withSnappingTheHudCollapsesIntoTheEdgeNearestWhereThePressBegan() {
assertEquals("top", collapse("1", 400f, 40f, 500f, 60f).second)
assertEquals("left", collapse("1", 20f, 300f, 40f, 500f).second)
assertEquals("right", collapse("1", 1500f, 300f, 1900f, 500f).second)
assertEquals("bottom", collapse("1", 400f, 700f, 500f, 980f).second)
}
@Test fun withoutSnappingTheHudCollapsesWhereItWasTouched() {
val (hud, stored, at) = collapse("0", 600f, 300f, 700f, 350f)
assertEquals("float", stored)
assertEquals(DroidDeckHudDock.FLOAT, hud.dock)
val (tabW, tabH) = hud.dockTabSize()
assertEquals(700f - tabW / 2f, at.first, 2f)
assertEquals(350f - tabH / 2f, at.second, 2f)
}
@Test fun aLayoutPassDuringTheCollapseKeepsTheTabWhereThePressPutIt() {
animate(1f)
val (hud, stored, at) = collapse("1", 600f, 300f, 700f, 350f, layoutDuringCollapse = true)
val (tabW, tabH) = hud.dockTabSize()
assertEquals("top", stored)
assertEquals(700f - tabW / 2f, SessionPrefs.droidDeckHudPosition(RuntimeEnvironment.getApplication())!!.first, 2f)
assertEquals(700f - tabW / 2f, at.first, 2f)
}
}
@@ -38,6 +38,74 @@ class DroidDeckHudPanelTest {
assertEquals("1", DroidDeckHudConfig.DEFAULTS["hudLocked"])
}
@Test fun aLongPressCollapsesTheHudUnlessTheUserChoseToLockWithIt() {
assertEquals("collapse", DroidDeckHudConfig.DEFAULTS["hudHold"])
for ((hold, locked) in listOf("collapse" to "1", "collapse" to "0", "lock" to "1", "lock" to "0")) {
val app = RuntimeEnvironment.getApplication()
val hud = DroidDeckHudView(app)
val parent = FrameLayout(app)
parent.addView(hud, FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT))
hud.applyConfig(DroidDeckHudConfig.encode(DroidDeckHudConfig.DEFAULTS + ("hudHold" to hold) + ("hudLocked" to locked)))
hud.showForTest(SNAPSHOT, "DXVK", 0L)
val exactly = View.MeasureSpec.makeMeasureSpec(2000, View.MeasureSpec.EXACTLY)
parent.measure(exactly, exactly)
parent.layout(0, 0, 2000, 2000)
val holds = ArrayList<Pair<Float, Float>>()
val locks = ArrayList<Boolean>()
hud.setOnHoldListener { x, y -> holds += x to y }
hud.setOnLockChangedListener { locks += it }
val down = SystemClock.uptimeMillis()
MotionEvent.obtain(down, down, MotionEvent.ACTION_DOWN, 30f, 20f, 0).also { hud.dispatchTouchEvent(it); it.recycle() }
shadowOf(Looper.getMainLooper()).idleFor(Duration.ofMillis(ViewConfiguration.getLongPressTimeout() + 300L))
MotionEvent.obtain(down, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, 30f, 20f, 0).also { hud.dispatchTouchEvent(it); it.recycle() }
shadowOf(Looper.getMainLooper()).idle()
if (hold == "collapse") {
assertEquals("$hold/$locked collapses from where the press began", listOf(30f to 20f), holds)
assertTrue("$hold/$locked leaves the lock alone", locks.isEmpty())
} else {
assertTrue("$hold/$locked does not collapse", holds.isEmpty())
assertEquals("$hold/$locked toggles the lock", listOf(locked != "1"), locks)
}
}
}
@Test fun releasingTheFingerThatCollapsedTheHudDoesNotExpandItAgain() {
val app = RuntimeEnvironment.getApplication()
val hud = DroidDeckHudView(app)
val parent = FrameLayout(app)
parent.addView(hud, FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT))
val config = DroidDeckHudConfig.DEFAULTS + ("hudSize" to "full")
hud.applyConfig(DroidDeckHudConfig.encode(config))
hud.showForTest(SNAPSHOT, "DXVK", 0L)
val exactly = View.MeasureSpec.makeMeasureSpec(2000, View.MeasureSpec.EXACTLY)
parent.measure(exactly, exactly)
parent.layout(0, 0, 2000, 2000)
val docks = ArrayList<String>()
hud.setOnDockChangedListener { docks += it }
hud.setOnHoldListener { _, _ -> hud.applyConfig(DroidDeckHudConfig.encode(config + ("hudDock" to "float"))) }
val down = SystemClock.uptimeMillis()
MotionEvent.obtain(down, down, MotionEvent.ACTION_DOWN, 30f, 20f, 0).also { hud.dispatchTouchEvent(it); it.recycle() }
shadowOf(Looper.getMainLooper()).idleFor(Duration.ofMillis(ViewConfiguration.getLongPressTimeout() + 300L))
assertEquals(DroidDeckHudDock.FLOAT, hud.dock)
MotionEvent.obtain(down, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, 30f, 20f, 0).also { hud.dispatchTouchEvent(it); it.recycle() }
shadowOf(Looper.getMainLooper()).idle()
assertTrue("the release of the collapsing press is not a tap on the tab: $docks", docks.isEmpty())
val next = SystemClock.uptimeMillis()
MotionEvent.obtain(next, next, MotionEvent.ACTION_DOWN, 5f, 5f, 0).also { hud.dispatchTouchEvent(it); it.recycle() }
MotionEvent.obtain(next, next + 40, MotionEvent.ACTION_UP, 5f, 5f, 0).also { hud.dispatchTouchEvent(it); it.recycle() }
assertEquals("a later tap on the tab expands it", listOf("none"), docks)
}
@Test fun aFloatingTabIsATabWithoutAnEdge() {
assertEquals(DroidDeckHudDock.FLOAT, DroidDeckHudDock.from("float"))
val hud = DroidDeckHudView(RuntimeEnvironment.getApplication())
hud.applyConfig(DroidDeckHudConfig.encode(DroidDeckHudConfig.DEFAULTS + ("hudSize" to "full") + ("hudDock" to "float")))
hud.showForTest(SNAPSHOT, "DXVK", 0L)
val unspecified = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)
hud.measure(unspecified, unspecified)
assertTrue("a tab, not the panel: ${hud.measuredWidth}x${hud.measuredHeight}", hud.measuredWidth < 400 && hud.measuredHeight < 200)
}
@Test fun lowMetricsCanBeHiddenIndependentlyInEveryLayoutThatShowsThem() {
val metrics = listOf("showLow1" to "1%", "showLow01" to "0.1%", "showLow001" to "0.01%")
for (size in DroidDeckHudSize.values().filter { it != DroidDeckHudSize.PILL }) {
@@ -331,7 +399,7 @@ class DroidDeckHudPanelTest {
hud.passesTouchAt = { _, _ -> control }
val locks = ArrayList<Boolean>()
hud.setOnLockChangedListener { locks += it }
hud.applyConfig(DroidDeckHudConfig.encode(DroidDeckHudConfig.DEFAULTS + ("hudLocked" to "0")))
hud.applyConfig(DroidDeckHudConfig.encode(DroidDeckHudConfig.DEFAULTS + ("hudLocked" to "0") + ("hudHold" to "lock")))
hud.showForTest(SNAPSHOT, "DXVK", 0L)
val exactly = View.MeasureSpec.makeMeasureSpec(2000, View.MeasureSpec.EXACTLY)
parent.measure(exactly, exactly)
@@ -348,7 +416,7 @@ class DroidDeckHudPanelTest {
control = true
touch()
assertEquals("an unlocked HUD keeps the touch (tap, drag, long press)", 0, reached)
hud.applyConfig(DroidDeckHudConfig.encode(DroidDeckHudConfig.DEFAULTS + ("hudLocked" to "1")))
hud.applyConfig(DroidDeckHudConfig.encode(DroidDeckHudConfig.DEFAULTS + ("hudLocked" to "1") + ("hudHold" to "lock")))
touch()
assertEquals("a locked HUD passes it to the control under it", 1, reached)
control = false
@@ -377,7 +445,7 @@ class DroidDeckHudPanelTest {
assertEquals("a locked, docked HUD still answers a tap", listOf("none"), docks)
}
private companion object {
internal 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),