diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 337646bf..948e0761 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -9,8 +9,8 @@ android { applicationId = "tv.orbit.classic" minSdk = 26 targetSdk = 36 - versionCode = 269 - versionName = "0.108.109-restore" + versionCode = 275 + versionName = "0.108.114-pick-card" } buildFeatures { compose = true } // The finished build for the TVs (Paul, 6 November 2026: the test build stuttered on the box). Not debuggable, so diff --git a/android/app/src/main/java/tv/orbit/classic/EmbyClient.kt b/android/app/src/main/java/tv/orbit/classic/EmbyClient.kt index 6ee09a89..a1a95811 100644 --- a/android/app/src/main/java/tv/orbit/classic/EmbyClient.kt +++ b/android/app/src/main/java/tv/orbit/classic/EmbyClient.kt @@ -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 = when (kind) { - ServerKind.Emby -> mapOf("X-Emby-Authorization" to "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.109\"") + + ServerKind.Emby -> mapOf("X-Emby-Authorization" to "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.114\"") + (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.109\"" + + ServerKind.Jellyfin -> mapOf("Authorization" to "MediaBrowser Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.114\"" + (token?.let { ", Token=\"$it\"" } ?: "")) } /** One picture from the provider, or nothing. Same fixed origin and no redirects, and failures are never shown or logged. */ diff --git a/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt b/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt index 46098f1b..88142cb7 100644 --- a/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt +++ b/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt @@ -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.109") + next.setRequestProperty("User-Agent", "OrbitTV/0.108.114") 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()) { diff --git a/android/app/src/main/java/tv/orbit/classic/WhatsOn.kt b/android/app/src/main/java/tv/orbit/classic/WhatsOn.kt index 9a770d11..2efd6bd2 100644 --- a/android/app/src/main/java/tv/orbit/classic/WhatsOn.kt +++ b/android/app/src/main/java/tv/orbit/classic/WhatsOn.kt @@ -19,6 +19,8 @@ import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.asImageBitmap import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.layout.onSizeChanged +import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.text.font.Font import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontWeight @@ -100,9 +102,20 @@ internal fun WhatsOnScreen(session: EmbySampleSession, plans: Map(null, picture, size) { + value = if (picture == null || size.width <= 0 || size.height <= 0) null + else kotlinx.coroutines.withContext(kotlinx.coroutines.Dispatchers.Default) { runCatching { pickCard(picture, size.width, size.height) }.getOrNull() } + } + Box(Modifier.fillMaxSize().onSizeChanged { size = it }.background(Panel)) { + val baked = card + if (baked != null) Image(baked.asImageBitmap(), null, Modifier.fillMaxSize(), contentScale = ContentScale.FillBounds) + else { + if (picture != null) Image(picture.asImageBitmap(), null, Modifier.fillMaxSize(), contentScale = ContentScale.Crop) + Box(Modifier.fillMaxSize().background(Brush.horizontalGradient(0f to Navy.copy(alpha = .97f), .45f to Navy.copy(alpha = .88f), .75f to Navy.copy(alpha = .35f), 1f to Navy.copy(alpha = .15f)))) + } Column(Modifier.fillMaxSize().padding(16.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) { Tag("TONIGHT'S PICK", Yellow, 11) Logo(pick.channel, 96, 30) @@ -222,3 +235,25 @@ internal fun ProgrammeReminderCard(reminder: ProgrammeReminder, nowMs: Long, onW } } + + +/** + * Tonight's Pick's card, painted once (profiling fix C): the panel colour, the picture cropped to fill the card as + * ContentScale.Crop does, and the same left-to-right navy fade, all in one bitmap of the card's size. + */ +internal fun pickCard(picture: android.graphics.Bitmap, width: Int, height: Int): android.graphics.Bitmap { + val out = android.graphics.Bitmap.createBitmap(width, height, android.graphics.Bitmap.Config.ARGB_8888) + val canvas = android.graphics.Canvas(out) + canvas.drawColor(Panel.toArgb()) + val scale = maxOf(width.toFloat() / picture.width, height.toFloat() / picture.height) + val w = picture.width * scale; val h = picture.height * scale + val dst = android.graphics.RectF((width - w) / 2f, (height - h) / 2f, (width + w) / 2f, (height + h) / 2f) + canvas.drawBitmap(picture, null, dst, android.graphics.Paint(android.graphics.Paint.FILTER_BITMAP_FLAG)) + val fade = android.graphics.Paint().apply { + shader = android.graphics.LinearGradient(0f, 0f, width.toFloat(), 0f, + intArrayOf(Navy.copy(alpha = .97f).toArgb(), Navy.copy(alpha = .88f).toArgb(), Navy.copy(alpha = .35f).toArgb(), Navy.copy(alpha = .15f).toArgb()), + floatArrayOf(0f, .45f, .75f, 1f), android.graphics.Shader.TileMode.CLAMP) + } + canvas.drawRect(0f, 0f, width.toFloat(), height.toFloat(), fade) + return out +}