From 7471f7cac2a869f86474fdea6836dcb81e834243 Mon Sep 17 00:00:00 2001 From: Elijah Date: Wed, 28 Oct 2026 16:23:28 -0700 Subject: [PATCH] Redesign browse previews after Silo, with an optional artwork colour wash Home's hero now compacts into a preview of the focused card instead of scrolling away, and Movies and TV share the same preview: large title art, facts, a three-line synopsis, cast and format badges, with the card's own image scaled whole into the top-right. Artwork crossfades and copy fades and lifts between titles, driven from graphics layers so no composition or layout runs per frame. An Interface setting tints the page with the artwork's colour, baked into the cached backdrop frame. Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 4 +- .../java/tv/kaleido/app/BrowseBackdrop.kt | 106 +++++- .../main/java/tv/kaleido/app/FocusedBrowse.kt | 306 +++++++++++++----- .../java/tv/kaleido/app/KaleidoViewModel.kt | 11 +- .../java/tv/kaleido/app/SettingsScreen.kt | 11 +- docs/design-system.md | 4 +- 6 files changed, 342 insertions(+), 100 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index e0e974d..d863e75 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -10,8 +10,8 @@ ## UI and architecture -- **Home:** large cinematic hero with playback/information actions and integrated landscape Continue Watching. Do not replace it with the compact section preview. -- **Movies:** compact preview/backdrop follows focused posters; recent releases and movie recommendations lead. **TV:** episode-first layout with wider next-episode thumbnails, new seasons and new episodes. Keep these destinations visibly distinct. +- **Home:** large cinematic hero with playback/information actions and integrated landscape Continue Watching. Entering the rows compacts it into a Silo-style preview of the focused card (its own image, top-right); Up/Back restores the hero. +- **Movies:** the same Silo-style preview follows focused posters; recent releases and movie recommendations lead. **TV:** episode-first layout with wider next-episode thumbnails, new seasons and new episodes. Keep these destinations' rows visibly distinct. The optional artwork colour wash is baked into the preview backdrop bitmap. - Both sections retain a dedicated, filtered/sorted **A–Z poster grid**. Primary tabs activate on focus. Use neutral near-black chrome, artwork-led color, restrained controls and stable card bounds. Inspect actual TV screenshots and D-pad behavior after UI changes. - `KaleidoViewModel.kt`: navigation, async loading and section caches. `PlexApi.kt` / `Models.kt`: Plex transport and parsing. `FocusedBrowse.kt`, `BrowseBackdrop.kt`, `BrowseScreens.kt`, `Theme.kt`: browsing/focus/design. `Playback.kt`: controller, negotiation and progress. `PlayerControls.kt` / `PlaybackExtras.kt`: controls, options and post-play. `SecureSession.kt`: Android Keystore persistence. `AppUpdater.kt`: repository updates. diff --git a/app/src/main/java/tv/kaleido/app/BrowseBackdrop.kt b/app/src/main/java/tv/kaleido/app/BrowseBackdrop.kt index 7e8e8bc..7de92bb 100644 --- a/app/src/main/java/tv/kaleido/app/BrowseBackdrop.kt +++ b/app/src/main/java/tv/kaleido/app/BrowseBackdrop.kt @@ -4,10 +4,18 @@ import android.graphics.Bitmap import android.graphics.Canvas import android.graphics.LinearGradient import android.graphics.Paint +import android.graphics.PorterDuff +import android.graphics.PorterDuffXfermode +import android.graphics.Rect +import android.graphics.RectF import android.graphics.Shader import android.graphics.drawable.BitmapDrawable import android.content.Context -import androidx.compose.animation.Crossfade +import androidx.compose.animation.core.Animatable +import androidx.compose.animation.core.FastOutSlowInEasing +import androidx.compose.foundation.layout.Box +import androidx.compose.ui.graphics.CompositingStrategy +import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.animation.core.tween import androidx.compose.foundation.Image import androidx.compose.foundation.layout.fillMaxSize @@ -25,10 +33,16 @@ import coil.request.ImageRequest import coil.size.Size import coil.transform.Transformation -/** Bake contrast into the cached bitmap on Coil's worker thread, not two screen-sized GPU passes per frame. */ -private class BrowseContrast(val cinematic:Boolean):Transformation { - override val cacheKey="kaleido-browse-contrast-v2-$cinematic" +/** + * Bake contrast into the cached bitmap on Coil's worker thread, not two screen-sized GPU passes per frame. + * [header] artwork is scaled whole into the top-right of a screen-sized frame and fades into the page + * toward its left and bottom edges, so the frame still crossfades like any other backdrop. With [wash], + * the page beneath carries the artwork's own colour, as Silo does, at no per-frame cost. + */ +private class BrowseContrast(val cinematic:Boolean,val header:Boolean,val wash:Boolean):Transformation { + override val cacheKey="kaleido-browse-contrast-v2-$cinematic"+if(header)"-header-corner4-$wash"else "" override suspend fun transform(input:Bitmap,size:Size):Bitmap { + if(header)return headerFrame(input) val output=input.copy(Bitmap.Config.ARGB_8888,true) val canvas=Canvas(output) val paint=Paint(Paint.ANTI_ALIAS_FLAG) @@ -38,26 +52,96 @@ private class BrowseContrast(val cinematic:Boolean):Transformation { canvas.drawRect(0f,0f,output.width.toFloat(),output.height.toFloat(),paint) return output } + private fun headerFrame(input:Bitmap):Bitmap { + val output=Bitmap.createBitmap(960,540,Bitmap.Config.ARGB_8888) + val canvas=Canvas(output) + val width=output.width.toFloat();val height=output.height.toFloat() + canvas.drawColor(0xFF090909.toInt()) + if(wash) { + // Richest behind the art (top-right), carried dimmer toward the rows (bottom-left). + val tint=ambientTint(input) and 0xFFFFFF + val paint=Paint() + paint.shader=LinearGradient(width,0f,0f,height,intArrayOf(0xFF shl 24 or tint,0x80 shl 24 or tint,0x2E shl 24 or tint),floatArrayOf(0f,.45f,1f),Shader.TileMode.CLAMP) + canvas.drawRect(0f,0f,width,height,paint) + } + // Whole pixels: a fractional edge left a faint seam beside the fade. + val art=RectF((width*(1f-HeaderArtWidth)).toInt().toFloat(),0f,width,(height*HeaderArtHeight).toInt().toFloat()) + // The art gets its own layer, so its fading edges reveal the page (or wash) beneath. + val layer=canvas.saveLayer(art,null) + // Centre-crop only the small difference between the image's and the box's proportions. + val scale=maxOf(art.width()/input.width,art.height()/input.height) + val cropWidth=art.width()/scale;val cropHeight=art.height()/scale + val left=((input.width-cropWidth)/2f).toInt();val top=((input.height-cropHeight)/2f).toInt() + canvas.drawBitmap(input,Rect(left,top,left+cropWidth.toInt(),top+cropHeight.toInt()),art,Paint(Paint.FILTER_BITMAP_FLAG)) + val mask=Paint().apply{xfermode=PorterDuffXfermode(PorterDuff.Mode.DST_IN)} + mask.shader=LinearGradient(art.left,0f,art.right,0f,intArrayOf(0,0x4D000000,0xFF000000.toInt()),floatArrayOf(0f,.2f,.5f),Shader.TileMode.CLAMP) + canvas.drawRect(art,mask) + mask.shader=LinearGradient(0f,art.top,0f,art.bottom,intArrayOf(0xFF000000.toInt(),0xFF000000.toInt(),0x4D000000,0),floatArrayOf(0f,.45f,.8f,1f),Shader.TileMode.CLAMP) + canvas.drawRect(art,mask) + canvas.restoreToCount(layer) + return output + } } -internal fun browseBackdropRequest(context:Context,api:PlexApi,path:String,cinematic:Boolean):ImageRequest? = +/** + * The artwork's average colour at a fixed, low luminance (as Silo and tvOS do): bright art is dimmed + * and dark art lifted, giving a subtle, consistent tint over the near-black page. + */ +private fun ambientTint(input:Bitmap):Int { + val sample=Bitmap.createScaledBitmap(input,32,18,true) + val pixels=IntArray(sample.width*sample.height).also{sample.getPixels(it,0,sample.width,0,0,sample.width,sample.height)} + if(sample!==input)sample.recycle() + var r=0.0;var g=0.0;var b=0.0 + for(pixel in pixels){r+=(pixel shr 16 and 0xFF);g+=(pixel shr 8 and 0xFF);b+=(pixel and 0xFF)} + r/=pixels.size*255.0;g/=pixels.size*255.0;b/=pixels.size*255.0 + val luminance=.2126*r+.7152*g+.0722*b + val scale=when{luminance<=.001->0.0;luminance>.22->.22/luminance;else->maxOf(1.0,.22/maxOf(luminance,.05))} + fun channel(value:Double)=(value*scale*255).toInt().coerceIn(0,255) + return android.graphics.Color.rgb(channel(r),channel(g),channel(b)) +} + +/** The preview artwork box (Home, Movies, TV), as fractions of the screen; close to 16:9, so stills and art show whole. */ +private const val HeaderArtWidth=.72f +private const val HeaderArtHeight=.78f + +/** Old and new artwork overlap briefly instead of the new one popping in. */ +internal const val ArtworkFadeMillis=320 + +internal fun browseBackdropRequest(context:Context,api:PlexApi,path:String,cinematic:Boolean,header:Boolean=false,wash:Boolean=false):ImageRequest? = api.image(path,if(cinematic)1280 else 960,if(cinematic)720 else 540)?.let{url-> ImageRequest.Builder(context).data(url).apply{api.headers().forEach{(k,v)->addHeader(k,v)}} .size(if(cinematic)1280 else 960,if(cinematic)720 else 540).allowHardware(false) - .transformations(BrowseContrast(cinematic)).crossfade(false).build() + .transformations(BrowseContrast(cinematic,header&&!cinematic,wash)).crossfade(false).build() } -@Composable internal fun BrowseBackdrop(api:PlexApi,path:String,modifier:Modifier,cinematic:Boolean=false,animate:Boolean=false,alignment:Alignment=Alignment.Center,contentScale:ContentScale=ContentScale.Crop) { +/** The new artwork fades in over the old one; only its layer alpha changes per frame. */ +@Composable private fun FadingArtwork(bitmap:Bitmap?,modifier:Modifier,contentScale:ContentScale,alignment:Alignment) { + val progress=remember{Animatable(1f)} + var shown by remember{mutableStateOf(null)} + var under by remember{mutableStateOf(null)} + LaunchedEffect(bitmap) { + if(bitmap==null||bitmap===shown)return@LaunchedEffect + under=shown;shown=bitmap + progress.snapTo(0f);progress.animateTo(1f,tween(ArtworkFadeMillis,easing=FastOutSlowInEasing)) + under=null + } + Box(modifier) { + under?.let{Image(remember(it){it.asImageBitmap()},null,contentScale=contentScale,alignment=alignment,modifier=Modifier.fillMaxSize())} + shown?.let{Image(remember(it){it.asImageBitmap()},null,contentScale=contentScale,alignment=alignment,modifier=Modifier.fillMaxSize().graphicsLayer{ + compositingStrategy=CompositingStrategy.ModulateAlpha;alpha=progress.value + })} + } +} + +@Composable internal fun BrowseBackdrop(api:PlexApi,path:String,modifier:Modifier,cinematic:Boolean=false,header:Boolean=false,wash:Boolean=false,animate:Boolean=false,alignment:Alignment=Alignment.Center,contentScale:ContentScale=ContentScale.Crop) { val context=LocalContext.current var previous by remember{mutableStateOf(null)} - val request=remember(path,api.session?.server,cinematic,animate){browseBackdropRequest(context,api,path,cinematic)?.newBuilder()?.placeholderMemoryCacheKey(previous)?.build()} + val request=remember(path,api.session?.server,cinematic,header,wash,animate){browseBackdropRequest(context,api,path,cinematic,header,wash)?.newBuilder()?.placeholderMemoryCacheKey(previous)?.build()} if(animate) { // Animate cache hits too; Coil intentionally skips its own crossfade for memory-cache results. val bitmap by produceState(null,request){ if(request!=null){val result=context.imageLoader.execute(request);if(result is SuccessResult){previous=result.memoryCacheKey;value=(result.drawable as? BitmapDrawable)?.bitmap}} } - Crossfade(bitmap,modifier=modifier,animationSpec=tween(220),label="heroArtwork"){loaded-> - loaded?.let{Image(it.asImageBitmap(),null,contentScale=contentScale,alignment=alignment,modifier=Modifier.fillMaxSize())} - } + FadingArtwork(bitmap,modifier,contentScale,alignment) }else AsyncImage(request,contentDescription=null,modifier=modifier,contentScale=contentScale,alignment=alignment,onSuccess={previous=it.result.memoryCacheKey}) } diff --git a/app/src/main/java/tv/kaleido/app/FocusedBrowse.kt b/app/src/main/java/tv/kaleido/app/FocusedBrowse.kt index 4466745..b86effa 100644 --- a/app/src/main/java/tv/kaleido/app/FocusedBrowse.kt +++ b/app/src/main/java/tv/kaleido/app/FocusedBrowse.kt @@ -10,9 +10,16 @@ import androidx.compose.foundation.gestures.BringIntoViewSpec import androidx.compose.foundation.gestures.LocalBringIntoViewSpec import androidx.compose.foundation.gestures.animateScrollBy import androidx.compose.foundation.gestures.scrollBy -import androidx.compose.animation.core.tween import androidx.compose.animation.core.Animatable +import androidx.compose.animation.core.FastOutSlowInEasing +import androidx.compose.animation.core.tween import androidx.compose.ui.graphics.graphicsLayer +import androidx.compose.ui.graphics.CompositingStrategy +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.unit.DpSize +import coil.imageLoader +import kotlinx.coroutines.flow.collectLatest +import kotlinx.coroutines.withTimeoutOrNull import androidx.compose.material3.* import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.PlayArrow @@ -72,7 +79,7 @@ private suspend fun LazyListState.animateBrowseTo(index:Int) { val focused=Snapshot.withoutReadObservation{vm.focusId} hubs.withIndex().firstNotNullOfOrNull{(row,h)->val column=if(focused=="${h.id}:$VIEW_ALL")h.items.size else h.items.indexOfFirst{"${h.id}:${it.id}"==focused};if(column>=0)Triple(h.id,row,column)else null} } - val initialRow=restore?.let{it.second+if(home)1 else 0} ?: 0 + val initialRow=restore?.second ?: 0 // Keep the hero/preview and adjacent rows prepared across vertical moves. // Without a behind window, every return discards and recomposes those cards. val list=rememberLazyListState(initialFirstVisibleItemIndex=initialRow, @@ -107,24 +114,34 @@ private suspend fun LazyListState.animateBrowseTo(index:Int) { var featureIndex by rememberSaveable{mutableIntStateOf(0)} val nextFeature=features.getOrNull(featureIndex % features.size.coerceAtLeast(1)) var selectedFeature by remember{mutableStateOf(nextFeature)} - val heroFade=remember{Animatable(1f)} + val context=LocalContext.current LaunchedEffect(nextFeature){ - if(home)nextFeature?.item?.let{vm.anticipate(it,cinematic=true)} - if(home&&selectedFeature!=null&&nextFeature!=null&&selectedFeature?.item?.id!=nextFeature.item.id)heroFade.animateTo(0f,tween(100)) + val next=nextFeature?.item + if(home&&next!=null)vm.anticipate(next,cinematic=true) + // Hold the copy briefly until the new artwork is decoded, so both fade together. + if(home&&next!=null&&selectedFeature!=null&&selectedFeature?.item?.id!=next.id) + browseBackdropRequest(context,vm.api,next.art.ifBlank{next.thumb},true)?.let{withTimeoutOrNull(700){context.imageLoader.execute(it)}} selectedFeature=nextFeature - heroFade.animateTo(1f,tween(180)) } val feature=selectedFeature?.item val activeFeature=rememberUpdatedState(feature) - var heroActive by remember{mutableStateOf(restore==null)} + // Home only: the large hero while it holds focus; a compact preview of the focused card otherwise. + // Read only inside effects, callbacks and layers: switching modes must not recompose the catalog. + val heroMode=remember{mutableStateOf(restore==null)} + var heroActive by heroMode + val compact=remember{Animatable(if(home&&restore==null)0f else 1f)} + LaunchedEffect(compact,home){snapshotFlow{home&&heroMode.value}.collectLatest{compact.animateTo(if(it)0f else 1f,tween(HeaderMillis,easing=FastOutSlowInEasing))}} + val firstCard=rememberUpdatedState(hubs.firstOrNull()?.items?.firstOrNull()) + val preview=restingPreview(hovered,{firstCard.value}){!home||!heroMode.value} + fun anticipateCard(item:Title)=vm.anticipate(item,path=previewArt(item),header=true) var rotating by remember{mutableStateOf(true)} - LaunchedEffect(home,features,heroActive,rotating,featureIndex){ - if(home&&heroActive&&rotating&&features.size>1){delay(12000);featureIndex=(featureIndex+1)%features.size} + LaunchedEffect(home,features,rotating,featureIndex){ + snapshotFlow{heroMode.value}.collectLatest{if(home&&it&&rotating&&features.size>1){delay(12000);featureIndex=(featureIndex+1)%features.size}} } val heroFocus=remember{FocusRequester()} val staging=remember{CardStaging()} LaunchedEffect(staging){delay(1000);staging.entering=false} - val rowOffset=if(home)1 else 0 + suspend fun focusHero(){repeat(4){withFrameNanos{};if(runCatching{heroFocus.requestFocus()}.getOrDefault(false))return}} suspend fun moveToRow(hubId:String,titleId:String)=coroutineScope { val row=hubs.indexOfFirst{it.id==hubId} val hub=hubs.getOrNull(row) ?: return@coroutineScope @@ -132,21 +149,21 @@ private suspend fun LazyListState.animateBrowseTo(index:Int) { if(column<0)return@coroutineScope val state=rowStates[hub.id] ?: return@coroutineScope val focusKey="$hubId:$titleId" - val visible=list.layoutInfo.visibleItemsInfo.any{it.index==row+rowOffset}&&state.layoutInfo.visibleItemsInfo.any{it.index==column} + val visible=list.layoutInfo.visibleItemsInfo.any{it.index==row}&&state.layoutInfo.visibleItemsInfo.any{it.index==column} val focused=visible&&runCatching{requesters[focusKey]?.requestFocus()==true}.getOrDefault(false) - val scrolling=launch{list.animateBrowseTo(row+rowOffset)} + val scrolling=launch{list.animateBrowseTo(row)} if(!state.layoutInfo.visibleItemsInfo.any{it.index==column})state.requestScrollToItem(column) if(!focused) { - snapshotFlow{list.layoutInfo.visibleItemsInfo.any{it.index==row+rowOffset}&&state.layoutInfo.visibleItemsInfo.any{it.index==column}}.first{it} + snapshotFlow{list.layoutInfo.visibleItemsInfo.any{it.index==row}&&state.layoutInfo.visibleItemsInfo.any{it.index==column}}.first{it} withFrameNanos{} runCatching{requesters.getOrPut(focusKey){FocusRequester()}.requestFocus()} } scrolling.join() } suspend fun moveToHero()=coroutineScope { + heroActive=true val scrolling=launch{list.animateBrowseTo(0)} - snapshotFlow{list.layoutInfo.visibleItemsInfo.any{it.index==0}}.first{it} - withFrameNanos{};runCatching{heroFocus.requestFocus()};scrolling.join() + focusHero();scrolling.join() } LaunchedEffect(hubs) { val old=previousHubs @@ -189,7 +206,7 @@ private suspend fun LazyListState.animateBrowseTo(index:Int) { hovered.value=null if(home&&feature!=null) { vm.focusId="home-feature";heroActive=true - navigationJob[0]=scope.launch{list.scrollToItem(0);withFrameNanos{};runCatching{heroFocus.requestFocus()}} + navigationJob[0]=scope.launch{list.scrollToItem(0);focusHero()} }else if(!home) { vm.focusId="discovery-entry" navigationJob[0]=scope.launch{withFrameNanos{};runCatching{navigation.section.requestFocus()}} @@ -200,7 +217,7 @@ private suspend fun LazyListState.animateBrowseTo(index:Int) { } } } - LaunchedEffect(home,features.isNotEmpty()){if(home&&vm.focusId=="home-feature"){list.scrollToItem(0);withFrameNanos{};runCatching{heroFocus.requestFocus()}}} + LaunchedEffect(home,features.isNotEmpty()){if(home&&vm.focusId=="home-feature"){heroActive=true;list.scrollToItem(0);focusHero()}} DisposableEffect(navigation,list,hubs){ navigation.scrolled=false navigation.enter={ @@ -209,9 +226,8 @@ private suspend fun LazyListState.animateBrowseTo(index:Int) { // or waiting for two lazy lists to lay out. The next Down explicitly enters row 0. if(!home)runCatching{navigation.section.requestFocus()} else { - val visible=list.layoutInfo.visibleItemsInfo.any{it.index==0} - if(visible)runCatching{heroFocus.requestFocus()} - navigationJob[0]=scope.launch{if(visible)list.animateBrowseTo(0)else moveToHero()} + if(heroActive)runCatching{heroFocus.requestFocus()} + navigationJob[0]=scope.launch{moveToHero()} activeFeature.value?.let{vm.anticipate(it,cinematic=true)} } } @@ -244,8 +260,32 @@ private suspend fun LazyListState.animateBrowseTo(index:Int) { val title=when(destination){"movies"->"Movies";"tv"->"TV Shows";else->"Home"} BoxWithConstraints(Modifier.fillMaxSize()) { val heroHeight=maxHeight*.80f-62.dp - if(home)HomeBackdrop(vm.api,hovered,feature,heroActive) - else FocusedPreviewCanvas(vm,hovered,hubs.firstOrNull()?.items?.firstOrNull(),destination) + if(home)HomeBackdrop(vm.api,preview,feature,heroMode,vm.colourWash) + else FocusedPreviewCanvas(vm,preview,hubs.firstOrNull()?.items?.firstOrNull(),vm.colourWash) + if(home) { + val lift=with(density){HeaderLift.toPx()} + // Leaving for the rows, the hero lifts away as the preview rises in; the reverse settles it back. + HeaderLayer({compact.value},{heroMode.value},true,lift,Modifier.padding(top=62.dp).fillMaxWidth().height(heroHeight)) { + feature?.let{item->Box(Modifier.fillMaxSize()) { + Column(Modifier.align(Alignment.BottomStart).padding(start=Cinema.gutter,bottom=35.dp).width(350.dp)) { + FadingCopy(selectedFeature,{it.item.id},lift,contentAlignment=Alignment.BottomStart){HeroCopy(vm,it)} + Row(Modifier.padding(top=16.dp).onPreviewKeyEvent{event-> + if(event.type==KeyEventType.KeyDown&&event.key==Key.DirectionDown){hubs.firstOrNull()?.items?.firstOrNull()?.let{anticipateCard(it)};navigationJob[0]?.cancel();navigationJob[0]=scope.launch{hubs.firstOrNull()?.let{hub->hub.items.firstOrNull()?.let{moveToRow(hub.id,it.id)}}};true}else false + }.onFocusChanged{if(it.hasFocus){heroActive=true;hovered.value=null}},horizontalArrangement=Arrangement.spacedBy(9.dp),verticalAlignment=Alignment.CenterVertically) { + ActionButton(if(item.offset>0)"Resume"else "Play",Icons.Filled.PlayArrow,primary=true,modifier=Modifier.focusRequester(heroFocus).focusProperties{up=navigation.top}.onFocusChanged{if(it.isFocused){vm.focusId="home-feature";rotating=true}}){vm.play(item)} + IconControl(Icons.Outlined.Info,"More info",modifier=Modifier.focusProperties{up=navigation.top},onFocused={rotating=false}){vm.open(item)} + if(features.size>1)IconControl(Icons.Outlined.ChevronRight,"Next featured title",modifier=Modifier.focusProperties{up=navigation.top},onFocused={rotating=false}){featureIndex=(featureIndex+1)%features.size} + } + } + Row(Modifier.align(Alignment.BottomCenter).padding(bottom=8.dp),horizontalArrangement=Arrangement.spacedBy(5.dp)) { + features.forEachIndexed{i,_->Box(Modifier.size(if(i==featureIndex)12.dp else 3.dp,3.dp).background(Accent.copy(alpha=if(i==featureIndex).9f else .35f),RoundedCornerShape(2.dp)))} + } + }} + } + HeaderLayer({compact.value},{heroMode.value},false,lift,Modifier.padding(start=Cinema.gutter,top=78.dp).height(200.dp)) { + HomePreview(vm,preview) + } + } Column(Modifier.fillMaxSize().padding(top=62.dp)) { if(!home) { Row(Modifier.fillMaxWidth().height(39.dp).padding(horizontal=Cinema.gutter),verticalAlignment=Alignment.CenterVertically) { @@ -253,7 +293,7 @@ private suspend fun LazyListState.animateBrowseTo(index:Int) { if(!home) { NavigationLabel("Discover",true,modifier=Modifier.focusRequester(navigation.section).focusProperties{up=navigation.top;down=navigation.entry}.onPreviewKeyEvent { if(it.type==KeyEventType.KeyDown&&it.key==Key.DirectionDown){ - hubs.firstOrNull()?.items?.firstOrNull()?.let{item->vm.anticipate(item)} + hubs.firstOrNull()?.items?.firstOrNull()?.let{item->anticipateCard(item)} navigationJob[0]?.cancel();navigationJob[0]=scope.launch{hubs.firstOrNull()?.let{hub->hub.items.firstOrNull()?.let{moveToRow(hub.id,it.id)}}};true }else false },initialFocus=sectionEntry){} @@ -272,39 +312,14 @@ private suspend fun LazyListState.animateBrowseTo(index:Int) { }){sectionMenu=true} } } - Spacer(Modifier.fillMaxWidth().height(if(destination=="movies")137.dp else 119.dp)) + Spacer(Modifier.fillMaxWidth().height(SectionPreviewSpace)) } + else Spacer(Modifier.fillMaxWidth().height(HomePreviewHeight)) + // The rows sit below the hero, then slide up beneath the compact preview. A layer + // offset rather than a resized list: the catalog never re-measures during the move. + val heroDrop=with(density){(heroHeight+15.dp-HomePreviewHeight).toPx()} CompositionLocalProvider(LocalBringIntoViewSpec provides BrowseScroll) { - LazyColumn(state=list,modifier=Modifier.fillMaxWidth().weight(1f).onFocusChanged{catalogFocus=it.hasFocus},verticalArrangement=Arrangement.spacedBy(15.dp),contentPadding=PaddingValues(bottom=22.dp)) { - if(home)item(key="home-feature") { - Box(Modifier.fillMaxWidth().height(heroHeight)) { - feature?.let{item-> - val metadata by produceState(item,item.id){value=item;value=vm.previewDetails(item)} - Column(Modifier.align(Alignment.BottomStart).padding(start=Cinema.gutter,bottom=35.dp).width(350.dp)) { - Column(Modifier.graphicsLayer{alpha=heroFade.value}) { - Eyebrow(selectedFeature?.reason.orEmpty()) - Spacer(Modifier.height(9.dp)) - TitleIdentity(vm.api,item,Modifier.width(264.dp).height(80.dp)) - Row(Modifier.fillMaxWidth().padding(top=8.dp,bottom=8.dp),verticalAlignment=Alignment.CenterVertically) { - Text(listOf(item.year,item.genres.firstOrNull().orEmpty(),item.contentRating).filter{it.isNotBlank()}.joinToString(" · "),color=Cinema.secondary,fontSize=10.sp,maxLines=1,overflow=TextOverflow.Ellipsis,modifier=Modifier.weight(1f,fill=false)) - AudienceRatings(metadata,Modifier.padding(start=10.dp)) - } - Text(item.summary,color=Cinema.secondary,fontSize=12.sp,lineHeight=18.sp,maxLines=3,overflow=TextOverflow.Ellipsis) - } - Row(Modifier.padding(top=16.dp).onPreviewKeyEvent{event-> - if(event.type==KeyEventType.KeyDown&&event.key==Key.DirectionDown){hubs.firstOrNull()?.items?.firstOrNull()?.let{vm.anticipate(it,cinematic=true)};navigationJob[0]?.cancel();navigationJob[0]=scope.launch{hubs.firstOrNull()?.let{hub->hub.items.firstOrNull()?.let{moveToRow(hub.id,it.id)}}};true}else false - }.onFocusChanged{if(it.hasFocus){heroActive=true;hovered.value=null}},horizontalArrangement=Arrangement.spacedBy(9.dp),verticalAlignment=Alignment.CenterVertically) { - ActionButton(if(item.offset>0)"Resume"else "Play",Icons.Filled.PlayArrow,primary=true,modifier=Modifier.focusRequester(heroFocus).focusProperties{up=navigation.top}.onFocusChanged{if(it.isFocused){vm.focusId="home-feature";rotating=true}}){vm.play(item)} - IconControl(Icons.Outlined.Info,"More info",modifier=Modifier.focusProperties{up=navigation.top},onFocused={rotating=false}){vm.open(item)} - if(features.size>1)IconControl(Icons.Outlined.ChevronRight,"Next featured title",modifier=Modifier.focusProperties{up=navigation.top},onFocused={rotating=false}){featureIndex=(featureIndex+1)%features.size} - } - } - Row(Modifier.align(Alignment.BottomCenter).padding(bottom=8.dp),horizontalArrangement=Arrangement.spacedBy(5.dp)) { - features.forEachIndexed{i,_->Box(Modifier.size(if(i==featureIndex)12.dp else 3.dp,3.dp).background(Accent.copy(alpha=if(i==featureIndex).9f else .35f),RoundedCornerShape(2.dp)))} - } - } - } - } + LazyColumn(state=list,modifier=Modifier.fillMaxWidth().weight(1f).then(if(home)Modifier.graphicsLayer{translationY=heroDrop*(1f-compact.value)}else Modifier).onFocusChanged{catalogFocus=it.hasFocus},verticalArrangement=Arrangement.spacedBy(15.dp),contentPadding=PaddingValues(bottom=22.dp)) { itemsIndexed(hubs,key={_,h->h.id},contentType={_,h->if(h.items.firstOrNull()?.type=="episode")"episodes"else "titles"}) {row,hub-> val poster=hub.items.firstOrNull()?.type in listOf("movie","show","season")&&!hub.title.contains("Continue",true)&&(destination=="movies"||destination=="tv"||row==1) val wideEpisode=destination=="tv"&&!poster @@ -331,7 +346,7 @@ private suspend fun LazyListState.animateBrowseTo(index:Int) { // catalog layout between those events. Bursts keep the latest // logical column instead of dropping a move while awaiting layout. withFrameNanos{} - if(!rapid)hub.items.getOrNull(target)?.let{vm.anticipate(it,cinematic=home)} + if(!rapid)hub.items.getOrNull(target)?.let{anticipateCard(it)} val visible=state.layoutInfo.visibleItemsInfo.any{it.index==target} val anchor=(target-1).coerceAtLeast(0) if(visible&&!rapid) { @@ -349,7 +364,7 @@ private suspend fun LazyListState.animateBrowseTo(index:Int) { // A held direction snaps to the latest anchor. Repeatedly // cancelling pixel animations and decoding transient backdrops // costs more than the focus move; predict only after it settles. - if(rapid){delay(70);hub.items.getOrNull(target)?.let{vm.anticipate(it,cinematic=home)}} + if(rapid){delay(70);hub.items.getOrNull(target)?.let{anticipateCard(it)}} } } true @@ -357,7 +372,7 @@ private suspend fun LazyListState.animateBrowseTo(index:Int) { if(event.key==Key.DirectionUp&&row==0) { if(home)feature?.let{vm.anticipate(it,cinematic=true)} navigationJob[0]?.cancel() - navigationJob[0]=scope.launch{if(home)moveToHero()else{withFrameNanos{};runCatching{navigation.section.requestFocus()}}} + navigationJob[0]=scope.launch{if(home&&feature!=null)moveToHero()else{withFrameNanos{};runCatching{(if(home)navigation.top else navigation.section).requestFocus()}}} } else { navigationJob[0]?.cancel() @@ -366,7 +381,7 @@ private suspend fun LazyListState.animateBrowseTo(index:Int) { val targetHub=hubs[target] val selectedId=columns[targetHub.id] val col=targetHub.items.indexOfFirst{it.id==selectedId}.takeIf{it>=0} ?: 0 - vm.anticipate(hubs[target].items[col],cinematic=home) + anticipateCard(hubs[target].items[col]) navigationJob[0]=scope.launch{moveToRow(targetHub.id,targetHub.items[col].id)} } } @@ -401,35 +416,166 @@ private suspend fun LazyListState.animateBrowseTo(index:Int) { if(sectionMenu)ChoiceDialog("Libraries",sectionChoices.map{it.title},sectionChoices.indexOf(vm.section),{sectionMenu=false}){vm.chooseSection(sectionChoices[it]);sectionMenu=false} } -/** Focus changes invalidate this small preview scope, never the catalog hierarchy. */ -@Composable private fun HomeBackdrop(api:PlexApi,hovered:State,feature:Title?,heroActive:Boolean) { - var displayed by remember{mutableStateOf(null)} - val current=if(heroActive)feature else hovered.value ?: feature - LaunchedEffect(current){if(!heroActive)delay(90);displayed=current} - (displayed ?: feature)?.let{BrowseBackdrop(api,it.art.ifBlank{it.thumb},Modifier.fillMaxSize(),cinematic=true,animate=heroActive)} +/** Home's compact header: the preview block Movies and TV show above their rows. */ +/** Home's compact header (after Silo's): its height below the top bar, and its title art. */ +private val HomePreviewHeight=228.dp +private val HomeLogo=DpSize(300.dp,64.dp) +/** Movies and TV use the same preview below their Discover/Library/Categories line, slightly smaller. */ +private val SectionPreviewSpace=199.dp +private val SectionPreviewHeight=190.dp +private val SectionLogo=DpSize(280.dp,56.dp) +private const val HeaderMillis=380 +private const val CopyMillis=380 +private val HeaderLift=12.dp +/** Focus must rest this long before the preview follows it, so a held direction doesn't replay fades. */ +private const val PreviewRestMillis=110L + +/** Previews show a card's own image: an episode's still, not its show's artwork. */ +internal fun previewArt(item:Title)=if(item.type=="episode")item.still.ifBlank{item.thumb}.ifBlank{item.art}else item.art.ifBlank{item.thumb} + +/** + * The card the preview shows: [hovered] once focus rests on it. The first card after the + * preview reappears shows at once. Inactive, it holds [idle] (the card Down enters), already + * composed under the hero, so entering the rows is only a fade. + */ +@Composable private fun restingPreview(hovered:State,idle:()->Title?,active:()->Boolean):State { + val rested=remember{mutableStateOf(null)} + LaunchedEffect(hovered) { + snapshotFlow{if(active())hovered.value else idle()}.collectLatest{ + if(it!=null&&rested.value!=null)delay(PreviewRestMillis) + rested.value=it + } + } + return rested } -@Composable private fun FocusedPreviewCanvas(vm:KaleidoViewModel,hovered:State,fallback:Title?,destination:String) { - var displayed by remember{mutableStateOf(null)} - val current=hovered.value - LaunchedEffect(current){delay(120);displayed=current} - val feature=displayed ?: fallback - val metadata by produceState(feature,feature){value=feature;feature?.let{value=vm.previewDetails(it)}} - Box(Modifier.fillMaxSize()) { - feature?.let{item-> - BrowseBackdrop(vm.api,item.art,Modifier.fillMaxSize()) - Column(Modifier.padding(start=Cinema.gutter,top=106.dp).width(350.dp).clearAndSetSemantics{contentDescription=listOf(item.displayTitle,metadata?.rating.orEmpty(),item.summary).filter{it.isNotBlank()}.joinToString(". ")}) { - TitleIdentity(vm.api,item,Modifier.width(if(destination=="tv")230.dp else 260.dp).height(if(destination=="tv")43.dp else 53.dp)) - Row(Modifier.fillMaxWidth().padding(top=7.dp,bottom=5.dp),verticalAlignment=Alignment.CenterVertically) { - Text(listOf(if(item.type=="episode")"S${item.parentIndex} · E${item.index} ${item.title}"else item.year,item.genres.firstOrNull().orEmpty(),item.contentRating).filter{it.isNotBlank()}.joinToString(" · "),fontSize=10.sp,lineHeight=14.sp,color=Cinema.secondary,maxLines=1,overflow=TextOverflow.Ellipsis,modifier=Modifier.weight(1f,fill=false)) - AudienceRatings(metadata ?: item,Modifier.padding(start=10.dp)) - } - Text(item.summary,color=Cinema.secondary,fontSize=11.5.sp,lineHeight=16.sp,maxLines=2,overflow=TextOverflow.Ellipsis) +/** + * The hero ([hero]) or the compact preview, faded and lifted by [progress] in its own layer: one + * animation, no per-frame composition or layout. The hero is composed only while shown or leaving; + * the preview stays composed, invisible under the hero. + */ +@Composable private fun HeaderLayer(progress:()->Float,heroShown:()->Boolean,hero:Boolean,lift:Float,modifier:Modifier,content:@Composable ()->Unit) { + val composed by remember{derivedStateOf{!hero||heroShown()||progress()<1f}} + if(composed)Box(modifier.graphicsLayer{ + val c=progress() + compositingStrategy=CompositingStrategy.ModulateAlpha + if(hero){alpha=(1f-c*1.6f).coerceIn(0f,1f);translationY=-lift*c} + else{alpha=((c-.3f)/.7f).coerceIn(0f,1f);translationY=lift*(1f-c)} + }){content()} +} + +/** + * Swaps [item] Silo-style: the outgoing copy lifts slightly as it fades; the next rises into + * place as it fades in. Two keyed layers driven by one animation, read only while drawing. + */ +@Composable private fun FadingCopy(item:T?,id:(T)->String,lift:Float,modifier:Modifier=Modifier,contentAlignment:Alignment=Alignment.TopStart,content:@Composable (T)->Unit) { + val progress=remember{Animatable(1f)} + var shown by remember{mutableStateOf(item)} + var leaving by remember{mutableStateOf(null)} + LaunchedEffect(item?.let(id)) { + val previous=shown + shown=item + if(previous==null||item==null){leaving=null;progress.snapTo(1f);return@LaunchedEffect} + if(id(previous)==id(item))return@LaunchedEffect + leaving=previous + progress.snapTo(0f) + progress.animateTo(1f,tween(CopyMillis,easing=FastOutSlowInEasing)) + leaving=null + } + // The same title with fresher details updates in place. + val current=if(item!=null&&shown?.let(id)==id(item))item else shown + Box(modifier,contentAlignment=contentAlignment) { + listOfNotNull(leaving,current).forEach{entry-> + val outgoing=entry===leaving + key(id(entry)) { + Box(Modifier.graphicsLayer{ + val t=progress.value + compositingStrategy=CompositingStrategy.ModulateAlpha + if(outgoing){alpha=(1f-t*2.5f).coerceAtLeast(0f);translationY=-lift*.66f*t} + else{alpha=((t-.2f)/.8f).coerceIn(0f,1f);translationY=lift*(1f-t)} + }){content(entry)} } } } } +/** Focus changes invalidate this small preview scope, never the catalog hierarchy. */ +@Composable private fun HomeBackdrop(api:PlexApi,preview:State,feature:Title?,heroMode:State,wash:Boolean) { + val target=if(heroMode.value)feature?.let{it.art.ifBlank{it.thumb} to true}else preview.value?.let{previewArt(it) to false} + // Keep the last artwork while the preview waits for its first resting card. + val last=remember{arrayOfNulls>(1)} + val shown=target ?: last[0] ?: feature?.let{it.art.ifBlank{it.thumb} to true} + last[0]=shown + shown?.let{(path,cinematic)->BrowseBackdrop(api,path,Modifier.fillMaxSize(),cinematic=cinematic,header=true,wash=wash,animate=true)} +} + +@Composable private fun FocusedPreviewCanvas(vm:KaleidoViewModel,preview:State,fallback:Title?,wash:Boolean) { + val feature=preview.value ?: fallback + Box(Modifier.fillMaxSize()) { + feature?.let{BrowseBackdrop(vm.api,previewArt(it),Modifier.fillMaxSize(),header=true,wash=wash,animate=true)} + Box(Modifier.padding(start=Cinema.gutter,top=104.dp).height(SectionPreviewHeight)) { + PreviewBlock(vm,feature,SectionLogo) + } + } +} + +@Composable private fun HomePreview(vm:KaleidoViewModel,preview:State)=PreviewBlock(vm,preview.value,HomeLogo) + +/** Bottom-anchored like Silo's: a shorter synopsis leaves room above the title, not a gap above the rows. */ +@Composable private fun PreviewBlock(vm:KaleidoViewModel,item:Title?,logo:DpSize) { + FadingCopy(item,{it.id},with(LocalDensity.current){HeaderLift.toPx()},Modifier.fillMaxHeight(),Alignment.BottomStart){PreviewText(vm,it,logo)} +} + +/** The focused card: large title art, the facts, three lines of synopsis, then cast and format. */ +@Composable private fun PreviewText(vm:KaleidoViewModel,item:Title,logo:DpSize) { + var loaded by remember{mutableStateOf(false)} + val metadata by produceState(item,item){value=vm.previewDetails(item);loaded=true} + // Cast and formats need the full details. Their rows are reserved, and fade in when they arrive. + val details=remember{Animatable(0f)} + LaunchedEffect(loaded){if(loaded)details.animateTo(1f,tween(220))} + val media=metadata.media.firstOrNull() + val formats=listOfNotNull(media?.resolutionLabel?.ifBlank{null},media?.dynamicRange?.ifBlank{null},media?.let{if(it.atmos)"Atmos"else it.channelLabel.ifBlank{null}}) + val runtime=when{item.duration<=0->"";item.offset>0->runtimeLabel(item.duration-item.offset)+" left";else->runtimeLabel(item.duration)} + Column(Modifier.width(420.dp).clearAndSetSemantics{contentDescription=listOf(item.displayTitle,metadata.rating,item.summary).filter{it.isNotBlank()}.joinToString(". ")}) { + TitleIdentity(vm.api,item,Modifier.size(logo)) + Row(Modifier.fillMaxWidth().padding(top=10.dp,bottom=7.dp).height(17.dp),verticalAlignment=Alignment.CenterVertically) { + if(item.contentRating.isNotBlank())FormatBadge(item.contentRating,Modifier.padding(end=8.dp)) + Text(listOf(if(item.type=="episode")"S${item.parentIndex} · E${item.index} ${item.title}"else item.year,item.genres.firstOrNull().orEmpty(),runtime).filter{it.isNotBlank()}.joinToString(" · "),fontSize=11.sp,lineHeight=15.sp,color=Cinema.secondary,maxLines=1,overflow=TextOverflow.Ellipsis,modifier=Modifier.weight(1f,fill=false)) + AudienceRatings(metadata,Modifier.padding(start=10.dp)) + } + Text(item.summary,color=Cinema.secondary,fontSize=12.sp,lineHeight=17.5.sp,maxLines=3,overflow=TextOverflow.Ellipsis) + Column(Modifier.graphicsLayer{alpha=details.value}) { + Text(metadata.cast.take(3).joinToString(", "),color=Muted,fontSize=10.5.sp,lineHeight=14.sp,maxLines=1,overflow=TextOverflow.Ellipsis,modifier=Modifier.padding(top=6.dp).height(14.dp)) + Row(Modifier.padding(top=8.dp).height(16.dp),horizontalArrangement=Arrangement.spacedBy(6.dp),verticalAlignment=Alignment.CenterVertically) { + formats.forEach{FormatBadge(it)} + } + } + } +} + +/** A small outlined label: a content rating or a video/audio format. */ +@Composable private fun FormatBadge(label:String,modifier:Modifier=Modifier) { + Text(label.uppercase(),color=Color.White.copy(alpha=.9f),fontSize=8.5.sp,lineHeight=11.sp,fontWeight=FontWeight.SemiBold,letterSpacing=.5.sp,maxLines=1, + modifier=modifier.border(.5.dp,Color.White.copy(alpha=.3f),RoundedCornerShape(3.dp)).background(Color.White.copy(alpha=.06f),RoundedCornerShape(3.dp)).padding(horizontal=5.dp,vertical=1.5.dp)) +} + +private fun runtimeLabel(ms:Long):String {val minutes=(ms/60000).coerceAtLeast(1);return if(minutes>=60)"${minutes/60}h ${minutes%60}m"else "${minutes}m"} + +@Composable private fun HeroCopy(vm:KaleidoViewModel,feature:HomeFeature) { + val item=feature.item + val metadata by produceState(item,item.id){value=item;value=vm.previewDetails(item)} + Column { + Eyebrow(feature.reason) + Spacer(Modifier.height(9.dp)) + TitleIdentity(vm.api,item,Modifier.width(264.dp).height(80.dp)) + Row(Modifier.fillMaxWidth().padding(top=8.dp,bottom=8.dp),verticalAlignment=Alignment.CenterVertically) { + Text(listOf(item.year,item.genres.firstOrNull().orEmpty(),item.contentRating).filter{it.isNotBlank()}.joinToString(" · "),color=Cinema.secondary,fontSize=10.sp,maxLines=1,overflow=TextOverflow.Ellipsis,modifier=Modifier.weight(1f,fill=false)) + AudienceRatings(metadata,Modifier.padding(start=10.dp)) + } + Text(item.summary,color=Cinema.secondary,fontSize=12.sp,lineHeight=18.sp,maxLines=3,overflow=TextOverflow.Ellipsis) + } +} + /** * A newly shown section composed every visible card in one 100–200 ms frame. While it is * entering, each card first lays out at its fixed size and fills in its artwork and titles a diff --git a/app/src/main/java/tv/kaleido/app/KaleidoViewModel.kt b/app/src/main/java/tv/kaleido/app/KaleidoViewModel.kt index 966ffde..be30b33 100644 --- a/app/src/main/java/tv/kaleido/app/KaleidoViewModel.kt +++ b/app/src/main/java/tv/kaleido/app/KaleidoViewModel.kt @@ -109,6 +109,8 @@ class KaleidoViewModel(app: Application): AndroidViewModel(app) { var debugValidationFile:File?=null; private set var watchedPercent by mutableStateOf(preferences.getInt("watchedPercent",80).coerceIn(50,100)); private set var navigationSounds by mutableStateOf(preferences.getBoolean("navigationSounds",true)); private set + /** Tint the page behind browse previews with the focused artwork's colour. */ + var colourWash by mutableStateOf(preferences.getBoolean("colourWash",true)); private set var themeMusic by mutableStateOf(preferences.getBoolean("themeMusic",false)); private set var themeVolume by mutableIntStateOf(preferences.getInt("themeVolume",30).coerceIn(10,100)); private set var volumeBoostDb by mutableIntStateOf(preferences.getInt("volumeBoostDb",0).coerceIn(0,12)); private set @@ -262,13 +264,13 @@ class KaleidoViewModel(app: Application): AndroidViewModel(app) { suspend fun previewDetails(item:Title):Title { return try{previews.details(item)}catch(e:CancellationException){throw e}catch(_:Exception){item} } - fun anticipate(item:Title,cinematic:Boolean=false,backdrop:Boolean=true) { + fun anticipate(item:Title,cinematic:Boolean=false,backdrop:Boolean=true,path:String=item.art.ifBlank{item.thumb},header:Boolean=false) { previews.anticipate(item) - val path=item.art.ifBlank{item.thumb} - val key=if(backdrop)"$cinematic:$path"else "" + val wash=header&&colourWash + val key=if(backdrop)"$cinematic:$header:$wash:$path"else "" if(key!=predictedArtworkKey){ predictedArtwork?.dispose();predictedArtwork=null;predictedArtworkKey=key - if(backdrop)browseBackdropRequest(application,api,path,cinematic)?.let{predictedArtwork=application.imageLoader.enqueue(it.newBuilder().dispatcher(artworkPrefetchDispatcher).build())} + if(backdrop)browseBackdropRequest(application,api,path,cinematic,header,wash)?.let{predictedArtwork=application.imageLoader.enqueue(it.newBuilder().dispatcher(artworkPrefetchDispatcher).build())} } } private fun cancelAnticipation(){previews.cancelPrediction();predictedArtwork?.dispose();predictedArtwork=null;predictedArtworkKey=""} @@ -678,6 +680,7 @@ class KaleidoViewModel(app: Application): AndroidViewModel(app) { fun chooseSubtitleStyle(value:SubtitleStyle){subtitleStyle=value;preferences.edit().putString("subtitleStyle",value.name).apply()} fun chooseWatchedPercent(value:Int){watchedPercent=value.coerceIn(50,100);preferences.edit().putInt("watchedPercent",watchedPercent).apply()} fun chooseNavigationSounds(value:Boolean){navigationSounds=value;preferences.edit().putBoolean("navigationSounds",value).apply()} + fun chooseColourWash(value:Boolean){colourWash=value;preferences.edit().putBoolean("colourWash",value).apply()} fun chooseThemeMusic(value:Boolean){themeMusic=value;preferences.edit().putBoolean("themeMusic",value).apply()} fun chooseThemeVolume(value:Int){themeVolume=value.coerceIn(10,100);preferences.edit().putInt("themeVolume",themeVolume).apply()} fun chooseVolumeBoostDb(value:Int){volumeBoostDb=value.coerceIn(0,12);preferences.edit().putInt("volumeBoostDb",volumeBoostDb).apply()} diff --git a/app/src/main/java/tv/kaleido/app/SettingsScreen.kt b/app/src/main/java/tv/kaleido/app/SettingsScreen.kt index 187e4fd..a01a911 100644 --- a/app/src/main/java/tv/kaleido/app/SettingsScreen.kt +++ b/app/src/main/java/tv/kaleido/app/SettingsScreen.kt @@ -54,6 +54,7 @@ fun CohesiveSettingsScreen(vm: KaleidoViewModel, install: (File) -> Unit) { val creditsFocus = remember { FocusRequester() } val subtitleStyleFocus = remember { FocusRequester() } val themeMusicFocus = remember { FocusRequester() } + val colourWashFocus = remember { FocusRequester() } val themeVolumeFocus = remember { FocusRequester() } val volumeBoostFocus = remember { FocusRequester() } @@ -296,7 +297,7 @@ fun CohesiveSettingsScreen(vm: KaleidoViewModel, install: (File) -> Unit) { } 3 -> { - SettingsSectionDescription("Choose the sounds Kaleido plays while you browse.") + SettingsSectionDescription("Choose how Kaleido looks and sounds while you browse.") SettingsValueRow( title = "Navigation sounds", description = "Play the TV's system tap when focus moves. Follows the TV sound-effects setting.", @@ -321,6 +322,14 @@ fun CohesiveSettingsScreen(vm: KaleidoViewModel, install: (File) -> Unit) { leftTarget = categoryFocus[3], onClick = { dialogRestoreFocus = themeVolumeFocus; themeVolumeDialog = true } ) + SettingsValueRow( + title = "Artwork colour wash", + description = "Tint the page behind Home, Movies and TV previews with the focused artwork's colour.", + value = if (vm.colourWash) "On" else "Off", + requester = colourWashFocus, + leftTarget = categoryFocus[3], + onClick = { vm.chooseColourWash(!vm.colourWash) } + ) } else -> { diff --git a/docs/design-system.md b/docs/design-system.md index 8d17e61..411f0f8 100644 --- a/docs/design-system.md +++ b/docs/design-system.md @@ -5,7 +5,7 @@ The interface gives artwork priority. App chrome uses neutral near-black, charco ## Layout and typography - Horizontal safe gutter: 44 dp. Navigation: 62 dp, with centered text destinations and independent search/settings icons. -- Home retains a large cinematic feature: an 80 percent stage with original title artwork, synopsis, playback and information actions. The scene continues beneath Continue Watching; entering the rail scrolls the feature away and the backdrop follows focused titles. Features interleave recently released, highly rated unwatched, and Plex-suggested movies/shows, excluding Continue Watching. They shuffle per refresh and rotate every 12 seconds while the hero is active, pausing during row browsing. +- Home retains a large cinematic feature: an 80 percent stage with original title artwork, synopsis, playback and information actions, with Continue Watching peeking below. Entering the rows compacts it into a Silo-style preview of the focused card instead of scrolling it away: the hero lifts and fades as the rows slide up beneath a bottom-anchored block (64 dp title art, content-rating badge, year/episode, genre, runtime or time left, ratings, three synopsis lines, three cast names and 4K/HDR/Atmos format badges). The card's own image (an episode's still, not its show's art) is scaled whole into a top-right box of 72 × 78 percent of the screen, baked off-thread to fade into the page toward its left and bottom edges. Movies and TV use the same preview (56 dp title art) beneath their Discover/Library/Categories line, with rows starting 300 dp down; their row content stays distinct. With Settings › Interface › Artwork colour wash (default On), the page beneath carries the artwork's average colour normalized to 0.22 luminance, diagonally from the top-right (full) to the bottom-left (18 percent), as Silo does. It is baked into the same cached 960 × 540 frame, so it costs nothing per frame and changes through the artwork crossfade. A 1280 × 720 frame was tried for sharper art and raised Movies' horizontal p95 from about 31 to 36 ms through larger texture uploads, so it was not kept. The preview stays composed, invisible, under the hero with the first row's first card, so entering the rows is only a fade. Up from the first row or Back restores the hero. Features interleave recently released, highly rated unwatched, and Plex-suggested movies/shows, excluding Continue Watching. They shuffle per refresh and rotate every 12 seconds while the hero is active, pausing during row browsing. - Movies uses a compact fixed preview above poster rows, with the backdrop and synopsis following focused titles. Recently released films and movie recommendations lead. TV uses a shorter preview, larger episode thumbnails, next episodes, newly added seasons, and then new episodes and show recommendations. Redundant TV hubs are omitted when their episode lists match exactly. These are deliberately different compositions. - Library: title and discovery/full-library navigation share a 64 dp header. A 43 dp filter row sits immediately above the six-column poster grid. - Browsing card widths: landscape 214 dp, TV episodes 264 dp, posters 120 dp. Landscape artwork uses 16:9; posters use 2:3. The full grid scales six columns to available width. Captions reserve a fixed height. @@ -27,7 +27,7 @@ The interface gives artwork priority. App chrome uses neutral near-black, charco - Navigation contrast comes from a gradient extending past the controls and fading to transparent. Home/Movies/TV activate on focus. Explicit row and column links prevent beyond-bounds focus searches when holding a remote direction. - A spaced D-pad move predicts the actual row/column destination before starting its scroll or focus change. The target backdrop is fetched and contrast-processed through the same Coil request/cache as the visible scene. Speculative artwork uses one low-priority worker so it cannot flood normal decode workers during a burst of input. Metadata starts in parallel; the visible preview and details page share that in-flight request. Rapid horizontal input settles to the latest target before starting speculative work. Full metadata uses a 64-item LRU with a 30-second lifetime, cleared on account/server changes and refreshed after watched updates. Neutral library/search grids prefetch metadata without fetching an unused full-screen backdrop. - Home's vertical list prepares content within one viewport ahead and retains one viewport behind, using Compose's bounded lazy-layout cache window. This keeps the hero and nearby rows ready when moving between them, rather than repeatedly composing and measuring the exposed image cards during the animation. Movies/TV use the same window. The window only fills ahead after the list has scrolled, so once a section settles it is nudged 1 px and back, letting the next rows compose in idle frames instead of during the first move down. Card sizes, row targets and the large cinematic Home layout are unchanged. -- Section previews settle for 120 ms (Home artwork for 90 ms), overlapping the navigation animation, and retain previous artwork until replacement data is ready. Contrast gradients are baked into a cached bitmap on a worker thread, reducing GPU overdraw. Hero recommendation changes crossfade the artwork over 220 ms, including cache hits, and fade the title/summary out for 100 ms and back in over 180 ms. Rotation pauses on the information/next controls and preserves their focus. Vertical row changes animate to explicit row/column targets; page entrances fade and slide 28 dp over 280 ms, using per-draw alpha rather than an offscreen layer, and start once the new section's composition frames have passed (at most 300 ms). While a section enters, its cards lay out at their fixed size first and fill in artwork and titles three per frame under the fade, so the section's first frame stays short. Focusing a top tab lets its highlight draw before the section switches. The cold-start sequence lasts 2.9 seconds. The six exact facets begin as a closed, overlapping iris lit from behind; it holds there (at most 700 ms) until startup data has arrived and frames are steady, so cold-start hitches never interrupt the motion. The iris then twists 44° open and locks with a slight overshoot while light leaks through the six gaps, a single sheen crosses the settled mark, and the mark shrinks into a lockup scaled from the header brand as KALEIDO slides out from behind it. Once loading finishes (up to 600 ms extra) the camera flies through the aperture's dark center over 640 ms, revealing the app beneath as it settles from 114 percent scale. The completed mark itself is never redesigned. Android animation duration scale is honored, including animations off. It does not replay when returning from background. +- Home, Movies and TV previews follow focus once it rests for 110 ms and retain previous artwork until replacement data is ready. New artwork fades in over the old for 320 ms, including cache hits; the outgoing title and synopsis lift slightly as they fade while the new ones rise 12 dp into place (380 ms). Hero recommendation changes use the same artwork and copy transitions, holding the copy up to 700 ms for the new artwork to decode. These fades, and the hero/preview exchange, are single animations read only in graphics layers, so they add no per-frame composition or layout. Contrast gradients are baked into a cached bitmap on a worker thread, reducing GPU overdraw. Rotation pauses on the information/next controls and preserves their focus. Vertical row changes animate to explicit row/column targets; page entrances fade and slide 28 dp over 280 ms, using per-draw alpha rather than an offscreen layer, and start once the new section's composition frames have passed (at most 300 ms). While a section enters, its cards lay out at their fixed size first and fill in artwork and titles three per frame under the fade, so the section's first frame stays short. Focusing a top tab lets its highlight draw before the section switches. The cold-start sequence lasts 2.9 seconds. The six exact facets begin as a closed, overlapping iris lit from behind; it holds there (at most 700 ms) until startup data has arrived and frames are steady, so cold-start hitches never interrupt the motion. The iris then twists 44° open and locks with a slight overshoot while light leaks through the six gaps, a single sheen crosses the settled mark, and the mark shrinks into a lockup scaled from the header brand as KALEIDO slides out from behind it. Once loading finishes (up to 600 ms extra) the camera flies through the aperture's dark center over 640 ms, revealing the app beneath as it settles from 114 percent scale. The completed mark itself is never redesigned. Android animation duration scale is honored, including animations off. It does not replay when returning from background. - Returning from details restores the library's mode, scroll position, and previously focused title. - Entering Movies/TV from the top bar focuses the fixed Discover control immediately. Down from Discover explicitly reveals the first catalog card; focus on already-visible targets changes before scrolling. A quick tab/Down sequence queues entry for the new destination, and focused tabs never repeat their delayed initial-focus request. - Offscreen card navigation requests the next lazy layout instead of forcing synchronous composition between key events. Up at the top bar is consumed because there is no destination above it; it must not start a lazy-list focus search.