Fix OrbitHive blue screen on the box, darken the Horror ident sky
pauljd/davidson-ci: Davidson CI / quality (push) Failing after 1m41s
pauljd/davidson-ci: Davidson CI / ai-review (push) Failing after 1m32s

The game's canvas had no height in the app's WebView because 100vh read as 0.
Screenshots stay allowed while the game is open. Horror ident logo no longer
sits on a flat red sky; compose script gains an optional logo shadow.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-11-02 19:18:20 +00:00
co-authored by Claude Opus 5.5
parent 022d27c0d8
commit 1ed2b6ade4
10 changed files with 50 additions and 12 deletions
@@ -66,7 +66,7 @@ internal class HttpsEmbyTransport(internal val deviceId: String = UUID.randomUUI
connection.connectTimeout = 10_000
connection.readTimeout = request.readTimeoutMs ?: if (request.path == "/Sessions/Logout") 5_000 else 15_000
connection.setRequestProperty("Accept", "application/json")
connection.setRequestProperty("X-Emby-Authorization", "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.79.0\"")
connection.setRequestProperty("X-Emby-Authorization", "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.79.3\"")
request.token?.let { connection.setRequestProperty("X-Emby-Token", it) }
if (request.method == "POST") {
val bytes = request.body.orEmpty().toByteArray(Charsets.UTF_8)
@@ -42,7 +42,10 @@ import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.viewinterop.AndroidView
import android.webkit.ConsoleMessage
import android.webkit.JavascriptInterface
import android.webkit.WebChromeClient
import android.webkit.WebViewClient
import android.webkit.WebView
import androidx.tv.material3.Text
import kotlinx.coroutines.delay
@@ -260,14 +263,33 @@ private fun SnakeScreen(best: Int, onBest: (Int) -> Unit, onLeave: () -> Unit) {
@Composable
private fun OrbitHiveScreen(onLeave: () -> Unit) {
var web by remember { mutableStateOf<WebView?>(null) }
// No protected picture here, and leaving the window open to screenshots lets the game be checked on the box.
val activity = androidx.activity.compose.LocalActivity.current
androidx.compose.runtime.DisposableEffect(Unit) {
activity?.window?.clearFlags(android.view.WindowManager.LayoutParams.FLAG_SECURE)
onDispose { activity?.window?.addFlags(android.view.WindowManager.LayoutParams.FLAG_SECURE) }
}
BackHandler { web?.evaluateJavascript("window.orbitBack()", null) }
AndroidView(modifier = Modifier.fillMaxSize(), factory = { context ->
WebView(context).apply {
setBackgroundColor(android.graphics.Color.rgb(7, 22, 50))
settings.javaScriptEnabled = true
settings.domStorageEnabled = true
settings.blockNetworkLoads = true
settings.allowFileAccess = true
settings.mediaPlaybackRequiresUserGesture = false
// The page is the app's own and asks for nothing outside it. Its problems go to the log.
webChromeClient = object : WebChromeClient() {
override fun onConsoleMessage(message: ConsoleMessage): Boolean {
android.util.Log.i("OrbitHive", "${message.messageLevel()} ${message.message()} line ${message.lineNumber()}")
return true
}
}
webViewClient = object : WebViewClient() {
override fun onPageFinished(view: WebView, url: String) { android.util.Log.i("OrbitHive", "loaded size=${view.width}x${view.height}") }
override fun onReceivedError(view: WebView, request: android.webkit.WebResourceRequest, error: android.webkit.WebResourceError) {
android.util.Log.w("OrbitHive", "failed ${request.url.lastPathSegment}: ${error.description}")
}
}
isFocusable = true; isFocusableInTouchMode = true
addJavascriptInterface(object {
@JavascriptInterface fun leave() { post { onLeave() } }
@@ -33,7 +33,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.79.0")
next.setRequestProperty("User-Agent", "OrbitTV/0.79.3")
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()) {