Smoother motion: screens and guide rows change at once, top bar gold lands in place (0.108.59)

Paul, 6 November 2026, on the box: switching between the guide, the channels
and the Arcade stuttered, the guide seemed to jump back and forth, and the top
bar's gold glided then jumped elsewhere. Screens and guide rows now change at
once, and the gold lands where focus comes back instead of sliding from its
last spot.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-11-06 15:49:18 +00:00
co-authored by Claude Opus 5.5
parent 1d2965ea83
commit 44ec691bad
7 changed files with 25 additions and 80 deletions
+2 -2
View File
@@ -9,8 +9,8 @@ android {
applicationId = "tv.orbit.classic"
minSdk = 26
targetSdk = 36
versionCode = 218
versionName = "0.108.58-motion"
versionCode = 219
versionName = "0.108.59-smoother"
}
buildFeatures { compose = true }
// Android logging and the like do nothing in unit tests, so whole flows (a channel read from a fake server) can run.
@@ -62,9 +62,9 @@ internal class HttpsEmbyTransport(internal val deviceId: String = UUID.randomUUI
}
/** The sign-in headers for this kind of server. */
internal fun authHeaders(token: String?): Map<String, String> = when (kind) {
ServerKind.Emby -> mapOf("X-Emby-Authorization" to "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.58\"") +
ServerKind.Emby -> mapOf("X-Emby-Authorization" to "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.59\"") +
(token?.let { mapOf("X-Emby-Token" to it) } ?: emptyMap())
ServerKind.Jellyfin -> mapOf("Authorization" to "MediaBrowser Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.58\"" +
ServerKind.Jellyfin -> mapOf("Authorization" to "MediaBrowser Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.59\"" +
(token?.let { ", Token=\"$it\"" } ?: ""))
}
/** One picture from the provider, or nothing. Same fixed origin and no redirects, and failures are never shown or logged. */
@@ -11,7 +11,6 @@ import androidx.compose.foundation.layout.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clipToBounds
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusProperties
import androidx.compose.ui.focus.focusRequester
@@ -189,14 +188,12 @@ internal fun GuideGrid(channels: List<SampleChannel>, selectedNumber: Int, modif
if (nowFraction != null) Box(Modifier.align(Alignment.BottomStart).offset(x = maxWidth * nowFraction - 3.dp).size(6.dp, 6.dp).background(Yellow))
}
}
BoxWithConstraints(Modifier.fillMaxWidth().weight(1f).clipToBounds()) {
BoxWithConstraints(Modifier.fillMaxWidth().weight(1f)) {
val visibleRows = ((maxHeight + 3.dp) / 41.dp).toInt().coerceAtLeast(1)
firstRow = guideFirstRow(row, firstRow, visibleRows, channels.size)
rowsShown = minOf(visibleRows, channels.size)
// The channels ease under the focus a row at a time (design/motion); a held button doesn't wait.
// One row is drawn beyond each edge, out of sight, so a row easing in arrives already drawn.
val lead = if (firstRow > 0) 1 else 0
Column(Modifier.fillMaxWidth().wrapContentHeight(Alignment.Top, unbounded = true).easeRows(firstRow, 41.dp, lead).focusRequester(gridFocus).onFocusChanged { gridFocused = it.isFocused }.focusable().onPreviewKeyEvent { event ->
// The rows step at once (Paul, 6 November 2026: easing them stuttered and seemed to jump back and forth).
Column(Modifier.fillMaxWidth().focusRequester(gridFocus).onFocusChanged { gridFocused = it.isFocused }.focusable().onPreviewKeyEvent { event ->
val native = event.nativeKeyEvent
if (native.action != KeyEvent.ACTION_DOWN) return@onPreviewKeyEvent false
when (native.keyCode) {
@@ -222,8 +219,8 @@ internal fun GuideGrid(channels: List<SampleChannel>, selectedNumber: Int, modif
else -> false
}
}, verticalArrangement = Arrangement.spacedBy(3.dp)) {
channels.subList(firstRow - lead, minOf(firstRow + visibleRows + 1, channels.size)).forEachIndexed { offset, line ->
val index = firstRow - lead + offset
channels.subList(firstRow, minOf(firstRow + visibleRows, channels.size)).forEachIndexed { offset, line ->
val index = firstRow + offset
Row(Modifier.fillMaxWidth().height(38.dp), horizontalArrangement = Arrangement.spacedBy(6.dp)) {
val mark = ChannelBrands.forNumber(line.number)
// A takeover on at the guide's time wears its own mark (Paul, 6 November 2026).
@@ -175,12 +175,9 @@ private fun OrbitApp() {
CompositionLocalProvider(LocalNavFocus provides navFocus, LocalDriveInFocus provides driveInFocus) {
// The Drive-In and a game in play take the whole screen; the bar sits over the Drive-In's sky.
val fullBleed = section == "Drive-In" || playingGame
// A new section slides on from the side it lies on along the top bar (design/motion); the Drive-In and a
// game have their own openings, and full-screen viewing never moves.
val cameFrom = remember { arrayOf(section) }
val direction = remember(section) { sectionDirection(cameFrom[0], section).also { cameFrom[0] = section } }
val slides = !fullBleed && !FullScreen.active
Column((if (fullBleed) Modifier.fillMaxSize() else Modifier.fillMaxSize().padding(start = 36.dp, end = 36.dp, top = 56.dp, bottom = 16.dp)).arrive(section, direction, slides)) {
// Sections change at once (Paul, 6 November 2026: the slide stuttered on the box while the new screen was
// being built, between the guide, the channels and the Arcade).
Column(if (fullBleed) Modifier.fillMaxSize() else Modifier.fillMaxSize().padding(start = 36.dp, end = 36.dp, top = 56.dp, bottom = 16.dp)) {
if (section == "Arcade" && realChannelAvailable && chosen) OrbitArcade(Modifier.weight(1f), onPlaying = { playingGame = it })
EmbyConnectionScreen(if (section == "Arcade") Modifier else Modifier.weight(1f), visible = section == "Connect Emby",
onboarding = onboarding, onSignedIn = { if (Onboarding.step == OnboardStep.SignIn) Onboarding.go(OnboardStep.Channels) },
@@ -32,22 +32,18 @@ import kotlinx.coroutines.launch
/**
* Orbit motion (Paul, 6 November 2026, from the approved design/motion sheet): one set of timings for moving around the
* app. Only position and fade move, a press always acts at once, and Reduce motion turns everything into a short fade.
* Screens and the guide's rows change at once: sliding them stuttered on the box while the new screen was built.
*/
internal object Motion {
/** Quick out, gentle landing: the one curve used everywhere. */
val Ease = CubicBezierEasing(.2f, 0f, 0f, 1f)
const val FOCUS = 140
const val SCREEN = 240
const val BACK = 200
const val CARD = 180
const val STAGGER = 40
const val STAGGERED = 6
const val DIM = 160
const val RISE = 200
const val GUIDE = 220
const val CALM = 120
/** A guide press sooner than this after the last is a held button: no easing, full speed. */
const val HELD_MS = 250L
/** Settings › On screen › Reduce motion, kept here so every screen follows it as it changes. */
var reduce by mutableStateOf(false)
@@ -55,36 +51,11 @@ internal object Motion {
fun load(settings: OrbitSettings) { reduce = settings.reduceMotion }
}
/** The order of the top bar, so a move to the right slides on from the right and Back slides the other way. */
internal fun sectionDirection(from: String, to: String): Int {
val order = listOf("Home", "What's On", "TV Guide", "Catch Up", "Drive-In", "Arcade", "Connect Emby")
return if (order.indexOf(to) >= order.indexOf(from)) 1 else -1
}
/** A focus fill that eases in [Motion.FOCUS] instead of snapping. */
@Composable
internal fun focusColor(target: Color) =
animateColorAsState(target, if (Motion.reduce) tween(0) else tween(Motion.FOCUS, easing = Motion.Ease), label = "focus").value
/**
* A new screen slides on 24 dp from the side it came from and fades up; nothing waits for it, and the first screen
* Orbit opens on just appears.
*/
internal fun Modifier.arrive(key: Any, direction: Int, enabled: Boolean = true): Modifier = composed {
val shift = remember { Animatable(0f) }
var first by remember { mutableStateOf(true) }
var calm by remember { mutableStateOf(false) }
LaunchedEffect(key) {
if (first || !enabled) { first = false; shift.snapTo(0f); return@LaunchedEffect }
// Reduce motion: the same arrival as a short fade, with no slide.
calm = Motion.reduce
shift.snapTo(direction.toFloat())
shift.animateTo(0f, if (calm) tween(Motion.CALM) else tween(if (direction > 0) Motion.SCREEN else Motion.BACK, easing = Motion.Ease))
}
val distance = with(LocalDensity.current) { 24.dp.toPx() }
graphicsLayer { translationX = if (calm) 0f else shift.value * distance; alpha = 1f - kotlin.math.abs(shift.value) }
}
/** Cards rise into place in turn, 40 ms apart, for the first six only; later ones are simply there. */
internal fun Modifier.riseIn(index: Int): Modifier = composed {
val calm = remember { Motion.reduce }
@@ -113,26 +84,6 @@ internal fun OverlayCard(scrim: Color, content: @Composable BoxScope.() -> Unit)
Box(Modifier.fillMaxSize().graphicsLayer { translationY = if (calm) 0f else (1f - rise.value) * lift; alpha = rise.value }, contentAlignment = Alignment.Center, content = content)
}
/**
* The guide's channels ease under the focus by one row in [Motion.GUIDE]. A held button scrolls at full speed: a move
* sooner than [Motion.HELD_MS] after the last one snaps.
*/
internal fun Modifier.easeRows(firstRow: Int, rowHeight: Dp, lead: Int = 0): Modifier = composed {
val shift = remember { Animatable(0f) }
var last by remember { mutableIntStateOf(firstRow) }
var lastAt by remember { mutableLongStateOf(0L) }
LaunchedEffect(firstRow) {
val moved = firstRow - last
last = firstRow
val at = System.currentTimeMillis(); val held = at - lastAt < Motion.HELD_MS; lastAt = at
if (moved == 0 || Motion.reduce || held || kotlin.math.abs(moved) > 3) { shift.snapTo(0f); return@LaunchedEffect }
shift.snapTo(moved.toFloat())
shift.animateTo(0f, tween(Motion.GUIDE, easing = Motion.Ease))
}
val height = with(LocalDensity.current) { rowHeight.toPx() }
graphicsLayer { translationY = (shift.value - lead) * height }
}
/**
* The gold that glides from one item to the next (Home's list, the top bar). The area draws one gold box behind its
* items and moves it to whichever item has focus; the items leave their own focused fill clear.
@@ -142,6 +93,13 @@ internal class Glide(private val scope: CoroutineScope) {
private val w = Animatable(0f); private val h = Animatable(0f)
internal var area: LayoutCoordinates? = null
internal var shown by mutableStateOf(false)
private set
/**
* Focus coming back into the area lands the gold where it is, never sliding over from where it was last (Paul,
* 6 November 2026: on the top bar it glided and then seemed to jump somewhere else entirely).
*/
fun focusInside(inside: Boolean) { if (!inside) { placed = false; shown = false } }
private var placed = false
private var target = Offset.Zero
private var targetSize = androidx.compose.ui.unit.IntSize.Zero
@@ -156,7 +114,7 @@ internal class Glide(private val scope: CoroutineScope) {
val jump = !placed || Motion.reduce
placed = true
scope.launch {
if (jump) { x.snapTo(at.x); y.snapTo(at.y); w.snapTo(size.width.toFloat()); h.snapTo(size.height.toFloat()); return@launch }
if (jump) { x.snapTo(at.x); y.snapTo(at.y); w.snapTo(size.width.toFloat()); h.snapTo(size.height.toFloat()); shown = true; return@launch }
val spec = tween<Float>(Motion.FOCUS, easing = Motion.Ease)
launch { x.animateTo(at.x, spec) }; launch { y.animateTo(at.y, spec) }
launch { w.animateTo(size.width.toFloat(), spec) }; h.animateTo(size.height.toFloat(), spec)
@@ -177,7 +135,7 @@ internal val LocalGlide = staticCompositionLocalOf<Glide?> { null }
/** The area the gold glides within: it draws the box behind its items, and only while one of them has focus. */
internal fun Modifier.glideArea(glide: Glide, color: Color, corner: Dp): Modifier = composed {
val radius = with(LocalDensity.current) { corner.toPx() }
onPlaced { glide.area = it }.onFocusChanged { glide.shown = it.hasFocus }.drawBehind { glide.draw(this, color, radius) }
onPlaced { glide.area = it }.onFocusChanged { glide.focusInside(it.hasFocus) }.drawBehind { glide.draw(this, color, radius) }
}
/** An item the gold glides to when it takes focus. */
@@ -39,7 +39,7 @@ internal class SecureMediaDataSource(private val session: EmbySampleSession) : B
next.instanceFollowRedirects = false
next.connectTimeout = 10_000
next.readTimeout = 20_000
next.setRequestProperty("User-Agent", "OrbitTV/0.108.58")
next.setRequestProperty("User-Agent", "OrbitTV/0.108.59")
next.setRequestProperty("Accept-Encoding", "identity")
session.mediaHeaders(address).forEach { (key, value) -> next.setRequestProperty(key, value) }
if (dataSpec.position != 0L || dataSpec.length != C.LENGTH_UNSET.toLong()) {
@@ -5,20 +5,13 @@ import org.junit.Test
/** Orbit motion (Paul, 6 November 2026, design/motion): one set of timings, and a moment for every Arcade game. */
class MotionTest {
@Test fun screensSlideFromTheSideTheyLieOnAlongTheBar() {
assertEquals(1, sectionDirection("Home", "TV Guide"))
assertEquals(-1, sectionDirection("Arcade", "Home"))
assertEquals(1, sectionDirection("Home", "Connect Emby"))
}
@Test fun everyArcadeGameHasItsOpening() {
for (game in listOf("OrbMan", "Blast", "Sky", "Hive", "Snake", "Blocks", "Bricks", "Pairs", "Patience")) assertNotNull(game, Moment.forGame(game))
assertNull(Moment.forGame("Welcome".lowercase()))
}
@Test fun theTimingsMatchTheSheet() {
assertEquals(140, Motion.FOCUS); assertEquals(240, Motion.SCREEN); assertEquals(200, Motion.BACK)
assertEquals(180, Motion.CARD); assertEquals(40, Motion.STAGGER); assertEquals(220, Motion.GUIDE); assertEquals(120, Motion.CALM)
assertTrue(Motion.BACK < Motion.SCREEN)
assertEquals(140, Motion.FOCUS)
assertEquals(180, Motion.CARD); assertEquals(40, Motion.STAGGER); assertEquals(120, Motion.CALM)
}
}