Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ dependencies {

implementation(libs.bundles.compose)
implementation(libs.activity.compose)
implementation(libs.tv.material)
implementation(libs.kotlinx.io.core) // Logcat parser

implementation(project(":library"))
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,18 @@
android:foregroundServiceType="dataSync"
tools:node="merge" />


<!-- Phase 2 Compose for TV shell: not a launcher; start via adb on debug builds.
adb shell am start -n com.lagradost.cloudstream3.debug/com.lagradost.cloudstream3.tv.TvComposeProbeActivity
(stableRelease / no debug suffix: com.lagradost.cloudstream3/.tv.TvComposeProbeActivity) -->
<activity
android:name=".tv.TvComposeProbeActivity"
android:exported="false"
android:label="TV Compose"
android:resizeableActivity="true"
android:theme="@style/AppTheme"
android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|keyboard|keyboardHidden|navigation|uiMode" />

<activity
android:name=".ui.ControllerActivity"
android:exported="false" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package com.lagradost.cloudstream3.tv

import android.os.Bundle
import android.view.KeyEvent
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.ui.platform.ComposeView
import androidx.lifecycle.lifecycleScope
import com.lagradost.cloudstream3.CommonActivity
import com.lagradost.cloudstream3.CommonActivity.loadThemes
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.tv.model.TvPlaybackRequest
import com.lagradost.cloudstream3.tv.navigation.TvNavigationShell
import com.lagradost.cloudstream3.tv.playback.TvPlaybackBridge
import kotlinx.coroutines.launch

/**
* Compose-for-TV host activity (Phase 10: CW polish / Hero Watch Now → existing GeneratorPlayer).
*
* Layout: [R.layout.activity_tv_compose_probe] —
* Compose shell + [R.id.tv_player_container] Fragment boundary for GeneratorPlayer.
*
* Not registered as MAIN / LEANBACK_LAUNCHER — default phone + legacy TV startup unchanged.
*
* Launch (debug / stableDebug package id suffix `.debug`):
* ```
* adb shell am start -n com.lagradost.cloudstream3.debug/com.lagradost.cloudstream3.tv.TvComposeProbeActivity
* ```
*
* Also available from Settings → Updates → Actions → "Compose TV (debug)" when BuildConfig.DEBUG.
*/
class TvComposeProbeActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
loadThemes(this)
enableEdgeToEdge()
super.onCreate(savedInstanceState)
CommonActivity.init(this)
setContentView(R.layout.activity_tv_compose_probe)
findViewById<ComposeView>(R.id.tv_compose_host).setContent {
TvTheme {
TvNavigationShell(
onPlaybackRequest = ::onPlaybackRequest,
)
}
}
}

override fun onResume() {
super.onResume()
CommonActivity.setActivityInstance(this)
}

override fun dispatchKeyEvent(event: KeyEvent): Boolean =
CommonActivity.dispatchKeyEvent(this, event) ?: super.dispatchKeyEvent(event)

override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean =
CommonActivity.onKeyDown(this, keyCode, event) ?: super.onKeyDown(keyCode, event)

/**
* Activity-level callback from Home CW Resume / Details Watch Now / Play Episode.
* Request stays immutable; mock rejected by bridge. No Compose seek / PosDur writes here.
* After GeneratorPlayer pops, Home re-reads CW (read-only) and restores focus.
*/
private fun onPlaybackRequest(request: TvPlaybackRequest) {
lifecycleScope.launch {
val result = TvPlaybackBridge.launch(this@TvComposeProbeActivity, request)
TvPlaybackBridge.report(this@TvComposeProbeActivity, result)
}
}
}
154 changes: 154 additions & 0 deletions app/src/main/java/com/lagradost/cloudstream3/tv/TvProbeScreen.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
package com.lagradost.cloudstream3.tv

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import androidx.tv.material3.Button
import androidx.tv.material3.ButtonDefaults
import androidx.tv.material3.CardDefaults
import androidx.tv.material3.ClassicCard
import androidx.tv.material3.MaterialTheme
import androidx.tv.material3.Surface
import androidx.tv.material3.SurfaceDefaults
import androidx.tv.material3.Text
import androidx.tv.material3.WideButton
import androidx.tv.material3.WideButtonDefaults

/**
* Minimal Compose-for-TV focus probe: title + small row of focusable cards/buttons.
* Obvious focus scale, D-pad friendly, wide spacing. No carousel / lazy rails / catalog.
*/
@Composable
fun TvProbeScreen() {
Surface(
modifier = Modifier.fillMaxSize(),
colors = SurfaceDefaults.colors(
containerColor = MaterialTheme.colorScheme.background,
contentColor = MaterialTheme.colorScheme.onBackground,
),
) {
Column(
modifier = Modifier
.fillMaxSize()
.padding(horizontal = 48.dp, vertical = 36.dp),
verticalArrangement = Arrangement.spacedBy(28.dp),
) {
Text(
text = "CloudStream TV Compose Probe",
style = MaterialTheme.typography.headlineLarge,
color = MaterialTheme.colorScheme.onBackground,
)
Text(
text = "Phase 1 — D-pad focus / scale smoke test (no catalog, no player)",
style = MaterialTheme.typography.bodyLarge,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)

Spacer(modifier = Modifier.height(8.dp))

Text(
text = "Focusable cards",
style = MaterialTheme.typography.titleMedium,
color = MaterialTheme.colorScheme.onBackground,
)

Row(
horizontalArrangement = Arrangement.spacedBy(32.dp),
verticalAlignment = Alignment.Top,
) {
ProbeClassicCard(title = "Card A", accent = MaterialTheme.colorScheme.primary)
ProbeClassicCard(title = "Card B", accent = MaterialTheme.colorScheme.secondary)
ProbeClassicCard(title = "Card C", accent = MaterialTheme.colorScheme.tertiary)
}

Spacer(modifier = Modifier.height(8.dp))

Text(
text = "Focusable buttons",
style = MaterialTheme.typography.titleMedium,
color = MaterialTheme.colorScheme.onBackground,
)

Row(
horizontalArrangement = Arrangement.spacedBy(24.dp),
verticalAlignment = Alignment.CenterVertically,
) {
Button(
onClick = {},
scale = ButtonDefaults.scale(focusedScale = 1.12f),
) {
Text("Continue")
}
Button(
onClick = {},
scale = ButtonDefaults.scale(focusedScale = 1.12f),
) {
Text("Details")
}
}

WideButton(
onClick = {},
modifier = Modifier.fillMaxWidth(0.55f),
scale = WideButtonDefaults.scale(focusedScale = 1.05f),
) {
Text("Wide action (focus me with D-pad)")
}
}
}
}

@Composable
private fun ProbeClassicCard(
title: String,
accent: Color,
) {
ClassicCard(
onClick = {},
modifier = Modifier.width(180.dp),
image = {
Box(
modifier = Modifier
.fillMaxWidth()
.height(100.dp)
.background(accent),
contentAlignment = Alignment.Center,
) {
Text(
text = title.takeLast(1),
style = MaterialTheme.typography.headlineMedium,
color = MaterialTheme.colorScheme.onPrimary,
)
}
},
title = {
Text(
text = title,
style = MaterialTheme.typography.titleMedium,
modifier = Modifier.padding(top = 8.dp),
)
},
subtitle = {
Text(
text = "Focus scales up",
style = MaterialTheme.typography.bodySmall,
)
},
scale = CardDefaults.scale(focusedScale = 1.12f),
contentPadding = PaddingValues(12.dp),
)
}
42 changes: 42 additions & 0 deletions app/src/main/java/com/lagradost/cloudstream3/tv/TvTheme.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.lagradost.cloudstream3.tv

import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.tv.material3.MaterialTheme
import androidx.tv.material3.darkColorScheme

/**
* Cinematic dark high-contrast theme for Compose TV.
* Uses only [androidx.tv.material3] — never phone Material3.
*/
private val TvCinematicDarkColorScheme = darkColorScheme(
primary = Color(0xFFFFB74D),
onPrimary = Color(0xFF1A1200),
primaryContainer = Color(0xFF5C3B00),
onPrimaryContainer = Color(0xFFFFE0B2),
secondary = Color(0xFF80CBC4),
onSecondary = Color(0xFF00201D),
secondaryContainer = Color(0xFF004D47),
onSecondaryContainer = Color(0xFFB2DFDB),
tertiary = Color(0xFFCE93D8),
onTertiary = Color(0xFF2A0030),
background = Color(0xFF07070A),
onBackground = Color(0xFFF5F5F7),
surface = Color(0xFF121218),
onSurface = Color(0xFFF5F5F7),
surfaceVariant = Color(0xFF24242E),
onSurfaceVariant = Color(0xFFC8C8D2),
border = Color(0xFF5A5A68),
borderVariant = Color(0xFF3A3A44),
error = Color(0xFFFF8A80),
onError = Color(0xFF3B0000),
scrim = Color(0xCC000000),
)

@Composable
fun TvTheme(content: @Composable () -> Unit) {
MaterialTheme(
colorScheme = TvCinematicDarkColorScheme,
content = content,
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package com.lagradost.cloudstream3.tv.components

import androidx.activity.compose.BackHandler
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import androidx.tv.material3.Button
import androidx.tv.material3.ButtonDefaults
import androidx.tv.material3.MaterialTheme
import androidx.tv.material3.Surface
import androidx.tv.material3.SurfaceDefaults
import androidx.tv.material3.Text

/**
* Minimal TV confirm dialog — not a dialog framework.
* Back cancels; initial focus on Cancel (never silent destructive).
*/
@Composable
fun TvConfirmDialog(
title: String,
message: String,
confirmLabel: String,
onConfirm: () -> Unit,
onDismiss: () -> Unit,
modifier: Modifier = Modifier,
) {
val cancelFocus = remember { FocusRequester() }
LaunchedEffect(Unit) {
runCatching { cancelFocus.requestFocus() }
}
BackHandler(onBack = onDismiss)

Box(
modifier = modifier
.fillMaxSize()
.background(Color.Black.copy(alpha = 0.72f)),
contentAlignment = Alignment.Center,
) {
Surface(
modifier = Modifier
.widthIn(min = 360.dp, max = 560.dp)
.padding(24.dp),
shape = RoundedCornerShape(16.dp),
colors = SurfaceDefaults.colors(
containerColor = MaterialTheme.colorScheme.surface,
),
) {
Column(
modifier = Modifier.padding(28.dp),
verticalArrangement = Arrangement.spacedBy(16.dp),
) {
Text(
text = title,
style = MaterialTheme.typography.headlineSmall,
color = MaterialTheme.colorScheme.onSurface,
)
Text(
text = message,
style = MaterialTheme.typography.bodyLarge,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
Row(horizontalArrangement = Arrangement.spacedBy(16.dp)) {
Button(
onClick = onDismiss,
modifier = Modifier.focusRequester(cancelFocus),
scale = ButtonDefaults.scale(focusedScale = TvFocusScale.ButtonFocused),
) {
Text("Cancel")
}
Button(
onClick = onConfirm,
scale = ButtonDefaults.scale(focusedScale = TvFocusScale.ButtonFocused),
) {
Text(confirmLabel)
}
}
}
}
}
}
Loading