@@ -7,13 +7,21 @@ package org.lineageos.tv.launcher.view
77
88import android.animation.AnimatorInflater
99import android.content.Context
10+ import android.graphics.PorterDuff
11+ import android.graphics.PorterDuffColorFilter
12+ import android.graphics.RenderEffect
13+ import android.graphics.Shader
1014import android.util.AttributeSet
1115import android.widget.ImageView
1216import android.widget.TextView
17+ import androidx.core.content.ContextCompat
1318import androidx.core.view.isInvisible
1419import androidx.core.view.isVisible
1520import androidx.tvprovider.media.tv.BasePreviewProgram
21+ import androidx.tvprovider.media.tv.TvContractCompat
1622import coil.load
23+ import coil.size.Scale
24+ import coil.transform.RoundedCornersTransformation
1725import com.google.android.material.progressindicator.LinearProgressIndicator
1826import org.lineageos.tv.launcher.R
1927import org.lineageos.tv.launcher.ext.getAttributeResourceId
@@ -22,7 +30,9 @@ class WatchNextCard @JvmOverloads constructor(
2230 context : Context , attrs : AttributeSet ? = null , defStyleAttr : Int = 0
2331) : Card(context, attrs, defStyleAttr) {
2432 // Views
33+ private val bannerBackgroundView: ImageView by lazy { findViewById(R .id.app_banner_background)!! }
2534 private val bannerView: ImageView by lazy { findViewById(R .id.app_banner)!! }
35+ private val smallBannerView: ImageView by lazy { findViewById(R .id.app_banner_small)!! }
2636 private val title: TextView by lazy { findViewById(R .id.title)!! }
2737 private val progressView: LinearProgressIndicator by lazy { findViewById(R .id.watch_progress)!! }
2838
@@ -48,9 +58,12 @@ class WatchNextCard @JvmOverloads constructor(
4858
4959 @Suppress(" RestrictedApi" )
5060 fun setInfo (info : BasePreviewProgram ) {
61+ bannerView.isVisible = false
62+ smallBannerView.isVisible = false
63+ progressView.isVisible = false
64+
5165 title.isInvisible = true
5266 label = info.title
53- bannerView.isVisible = true
5467 launchIntent = info.intent
5568 title.text = info.title
5669
@@ -63,6 +76,43 @@ class WatchNextCard @JvmOverloads constructor(
6376 }
6477 }
6578
79+ // Other than 16:9, use blurred background and smaller art
80+ if (info.posterArtAspectRatio != TvContractCompat .PreviewPrograms .ASPECT_RATIO_16_9 ) {
81+ bannerView.isVisible = false
82+ smallBannerView.isVisible = true
83+ bannerBackgroundView.load(info.posterArtUri) {
84+ placeholder(
85+ context.getAttributeResourceId(
86+ com.google.android.material.R .attr.colorSecondaryContainer
87+ )
88+ )
89+ crossfade(500 )
90+ scale(Scale .FILL )
91+ listener(onSuccess = { _, _ ->
92+ bannerBackgroundView.setRenderEffect(
93+ RenderEffect .createBlurEffect(
94+ 25f , 25f , Shader .TileMode .CLAMP
95+ )
96+ )
97+
98+ bannerBackgroundView.colorFilter = PorterDuffColorFilter (
99+ ContextCompat .getColor(context, R .color.watchNextCardFilter),
100+ PorterDuff .Mode .SRC_ATOP
101+ )
102+ }
103+ )
104+ }
105+
106+ smallBannerView.load(info.posterArtUri) {
107+ crossfade(500 )
108+ transformations(RoundedCornersTransformation (5F ))
109+ }
110+
111+ return
112+ }
113+
114+ bannerView.isVisible = true
115+ smallBannerView.isVisible = false
66116 bannerView.load(info.posterArtUri) {
67117 placeholder(
68118 context.getAttributeResourceId(
0 commit comments