Channel rows with real logos (Entwurf A), no focus scale clipping
- Rows carry the Dispatcharr channel logo in a small tile (initials as fallback), sit on a surface instead of transparent black, and get the accent focus border; the group subline is gone — the logo carries channel identity. - Focus scale disabled on settings rows, picker options, rail items and channel rows: the grown surface got clipped by its parent. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -12,8 +12,8 @@ android {
|
|||||||
applicationId = "dev.castarr.tv"
|
applicationId = "dev.castarr.tv"
|
||||||
minSdk = 26
|
minSdk = 26
|
||||||
targetSdk = 35
|
targetSdk = 35
|
||||||
versionCode = 17
|
versionCode = 18
|
||||||
versionName = "0.8.1"
|
versionName = "0.8.2"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release signing from environment (see ~/.keys/castarr-release.env on the
|
// Release signing from environment (see ~/.keys/castarr-release.env on the
|
||||||
@@ -81,6 +81,7 @@ dependencies {
|
|||||||
implementation("org.nanohttpd:nanohttpd:2.3.1")
|
implementation("org.nanohttpd:nanohttpd:2.3.1")
|
||||||
implementation("org.nanohttpd:nanohttpd-websocket:2.3.1")
|
implementation("org.nanohttpd:nanohttpd-websocket:2.3.1")
|
||||||
implementation("com.google.zxing:core:3.5.3")
|
implementation("com.google.zxing:core:3.5.3")
|
||||||
|
implementation("io.coil-kt:coil-compose:2.7.0")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Full JDK for javac via toolchain (host may only have a JRE); resolved by
|
// Full JDK for javac via toolchain (host may only have a JRE); resolved by
|
||||||
|
|||||||
@@ -126,7 +126,14 @@ class DispatcharrRepository(context: Context, private val auth: DeviceAuth) {
|
|||||||
name = obj.optString("effective_name").ifEmpty { obj.optString("name") },
|
name = obj.optString("effective_name").ifEmpty { obj.optString("name") },
|
||||||
url = streamUrl(uuid),
|
url = streamUrl(uuid),
|
||||||
group = groups[obj.optInt("channel_group_id")].orEmpty(),
|
group = groups[obj.optInt("channel_group_id")].orEmpty(),
|
||||||
logo = "",
|
// logo-cache endpoint is AllowAny — loads without auth.
|
||||||
|
logo = obj.optJSONObject("logo")?.optString("cache_url").orEmpty().let {
|
||||||
|
when {
|
||||||
|
it.isEmpty() || it == "null" -> ""
|
||||||
|
it.startsWith("http") -> it
|
||||||
|
else -> auth.serverUrl.trimEnd('/') + it
|
||||||
|
}
|
||||||
|
},
|
||||||
tvgId = obj.optString("effective_tvg_id").ifEmpty { obj.optString("tvg_id") },
|
tvgId = obj.optString("effective_tvg_id").ifEmpty { obj.optString("tvg_id") },
|
||||||
backendId = id,
|
backendId = id,
|
||||||
streamKey = uuid,
|
streamKey = uuid,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package dev.castarr.tv.ui
|
package dev.castarr.tv.ui
|
||||||
|
|
||||||
|
import androidx.compose.foundation.BorderStroke
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
@@ -36,6 +37,9 @@ import androidx.compose.ui.text.style.TextOverflow
|
|||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
|
import coil.compose.SubcomposeAsyncImage
|
||||||
|
import androidx.compose.ui.layout.ContentScale
|
||||||
|
import androidx.tv.material3.Border
|
||||||
import androidx.tv.material3.ClickableSurfaceDefaults
|
import androidx.tv.material3.ClickableSurfaceDefaults
|
||||||
import androidx.tv.material3.Surface
|
import androidx.tv.material3.Surface
|
||||||
import androidx.tv.material3.Text
|
import androidx.tv.material3.Text
|
||||||
@@ -166,7 +170,7 @@ fun LiveScreen(state: AppState) {
|
|||||||
contentPadding = androidx.compose.foundation.layout.PaddingValues(
|
contentPadding = androidx.compose.foundation.layout.PaddingValues(
|
||||||
start = 8.dp, end = 40.dp, top = 4.dp, bottom = 32.dp
|
start = 8.dp, end = 40.dp, top = 4.dp, bottom = 32.dp
|
||||||
),
|
),
|
||||||
verticalArrangement = Arrangement.spacedBy(4.dp),
|
verticalArrangement = Arrangement.spacedBy(6.dp),
|
||||||
) {
|
) {
|
||||||
if (channels.isEmpty()) {
|
if (channels.isEmpty()) {
|
||||||
item {
|
item {
|
||||||
@@ -190,7 +194,6 @@ fun LiveScreen(state: AppState) {
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.focusProperties { left = railFocus }
|
.focusProperties { left = railFocus }
|
||||||
.then(if (listIndex == 0) Modifier.focusRequester(listFocus) else Modifier),
|
.then(if (listIndex == 0) Modifier.focusRequester(listFocus) else Modifier),
|
||||||
showGroup = state.groupFilter == null,
|
|
||||||
nowNext = state.nowNext(channel),
|
nowNext = state.nowNext(channel),
|
||||||
playing = state.currentChannel?.url == channel.url,
|
playing = state.currentChannel?.url == channel.url,
|
||||||
// All rows are favorites in the favorites view — the
|
// All rows are favorites in the favorites view — the
|
||||||
@@ -223,6 +226,7 @@ private fun GroupItem(
|
|||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.onFocusChanged { if (it.isFocused) onSelect() },
|
.onFocusChanged { if (it.isFocused) onSelect() },
|
||||||
shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(10.dp)),
|
shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(10.dp)),
|
||||||
|
scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
|
||||||
colors = ClickableSurfaceDefaults.colors(
|
colors = ClickableSurfaceDefaults.colors(
|
||||||
containerColor = if (selected) CastarrColors.accentDim else Color.Transparent,
|
containerColor = if (selected) CastarrColors.accentDim else Color.Transparent,
|
||||||
contentColor = if (selected) CastarrColors.accent else CastarrColors.muted,
|
contentColor = if (selected) CastarrColors.accent else CastarrColors.muted,
|
||||||
@@ -258,7 +262,6 @@ private fun ChannelRow(
|
|||||||
channel: Channel,
|
channel: Channel,
|
||||||
number: Int,
|
number: Int,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
showGroup: Boolean,
|
|
||||||
nowNext: NowNext,
|
nowNext: NowNext,
|
||||||
playing: Boolean,
|
playing: Boolean,
|
||||||
favorite: Boolean,
|
favorite: Boolean,
|
||||||
@@ -271,12 +274,20 @@ private fun ChannelRow(
|
|||||||
onLongClick = onLongClick,
|
onLongClick = onLongClick,
|
||||||
modifier = modifier.fillMaxWidth(),
|
modifier = modifier.fillMaxWidth(),
|
||||||
shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(12.dp)),
|
shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(12.dp)),
|
||||||
|
// No focus scale — grown rows get clipped at the pane edges.
|
||||||
|
scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
|
||||||
colors = ClickableSurfaceDefaults.colors(
|
colors = ClickableSurfaceDefaults.colors(
|
||||||
containerColor = if (playing) CastarrColors.accentDim else Color.Transparent,
|
containerColor = if (playing) CastarrColors.accentDim else CastarrColors.surface,
|
||||||
contentColor = CastarrColors.fg,
|
contentColor = CastarrColors.fg,
|
||||||
focusedContainerColor = CastarrColors.surfaceFocused,
|
focusedContainerColor = CastarrColors.surfaceFocused,
|
||||||
focusedContentColor = CastarrColors.fg,
|
focusedContentColor = CastarrColors.fg,
|
||||||
),
|
),
|
||||||
|
border = ClickableSurfaceDefaults.border(
|
||||||
|
focusedBorder = Border(
|
||||||
|
border = BorderStroke(2.dp, CastarrColors.accent),
|
||||||
|
shape = RoundedCornerShape(12.dp),
|
||||||
|
),
|
||||||
|
),
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.padding(horizontal = 16.dp, vertical = 10.dp),
|
modifier = Modifier.padding(horizontal = 16.dp, vertical = 10.dp),
|
||||||
@@ -288,34 +299,27 @@ private fun ChannelRow(
|
|||||||
fontFamily = AppFont,
|
fontFamily = AppFont,
|
||||||
fontSize = 14.sp,
|
fontSize = 14.sp,
|
||||||
fontWeight = FontWeight.Medium,
|
fontWeight = FontWeight.Medium,
|
||||||
modifier = Modifier.width(44.dp),
|
modifier = Modifier.width(40.dp),
|
||||||
)
|
)
|
||||||
Column(Modifier.width(250.dp)) {
|
LogoTile(channel)
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
Spacer(Modifier.width(14.dp))
|
||||||
Text(
|
Row(
|
||||||
channel.name,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
color = if (playing) CastarrColors.accent else CastarrColors.fg,
|
modifier = Modifier.width(230.dp),
|
||||||
fontFamily = AppFont,
|
) {
|
||||||
fontSize = 16.sp,
|
Text(
|
||||||
fontWeight = if (playing) FontWeight.Medium else FontWeight.Normal,
|
channel.name,
|
||||||
maxLines = 1,
|
color = if (playing) CastarrColors.accent else CastarrColors.fg,
|
||||||
overflow = TextOverflow.Ellipsis,
|
fontFamily = AppFont,
|
||||||
modifier = Modifier.weight(1f, fill = false),
|
fontSize = 16.sp,
|
||||||
)
|
fontWeight = if (playing) FontWeight.Medium else FontWeight.Normal,
|
||||||
if (favorite) {
|
maxLines = 1,
|
||||||
Spacer(Modifier.width(8.dp))
|
overflow = TextOverflow.Ellipsis,
|
||||||
Text("★", color = CastarrColors.accent, fontSize = 13.sp)
|
modifier = Modifier.weight(1f, fill = false),
|
||||||
}
|
)
|
||||||
}
|
if (favorite) {
|
||||||
if (showGroup && channel.group.isNotEmpty()) {
|
Spacer(Modifier.width(8.dp))
|
||||||
Text(
|
Text("★", color = CastarrColors.accent, fontSize = 13.sp)
|
||||||
channel.group,
|
|
||||||
color = CastarrColors.faint,
|
|
||||||
fontFamily = AppFont,
|
|
||||||
fontSize = 12.sp,
|
|
||||||
maxLines = 1,
|
|
||||||
overflow = TextOverflow.Ellipsis,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Spacer(Modifier.width(24.dp))
|
Spacer(Modifier.width(24.dp))
|
||||||
@@ -333,6 +337,46 @@ private fun ChannelRow(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Channel logo in a small tile; initials while loading or without a logo. */
|
||||||
|
@Composable
|
||||||
|
private fun LogoTile(channel: Channel) {
|
||||||
|
val initials = channel.name.split(" ").filter { it.isNotBlank() }
|
||||||
|
.take(2).map { it.first() }.joinToString("").uppercase()
|
||||||
|
Box(
|
||||||
|
Modifier
|
||||||
|
.size(38.dp)
|
||||||
|
.clip(RoundedCornerShape(8.dp))
|
||||||
|
.background(CastarrColors.surfaceFocused),
|
||||||
|
contentAlignment = Alignment.Center,
|
||||||
|
) {
|
||||||
|
if (channel.logo.isNotEmpty()) {
|
||||||
|
SubcomposeAsyncImage(
|
||||||
|
model = channel.logo,
|
||||||
|
contentDescription = null,
|
||||||
|
contentScale = ContentScale.Fit,
|
||||||
|
modifier = Modifier.fillMaxSize().padding(5.dp),
|
||||||
|
loading = { LogoInitials(initials) },
|
||||||
|
error = { LogoInitials(initials) },
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
LogoInitials(initials)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun LogoInitials(initials: String) {
|
||||||
|
Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
|
||||||
|
Text(
|
||||||
|
initials,
|
||||||
|
color = CastarrColors.faint,
|
||||||
|
fontFamily = AppFont,
|
||||||
|
fontSize = 12.sp,
|
||||||
|
fontWeight = FontWeight.SemiBold,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun formatClock(millis: Long): String =
|
private fun formatClock(millis: Long): String =
|
||||||
SimpleDateFormat("HH:mm", Locale.GERMANY).format(Date(millis))
|
SimpleDateFormat("HH:mm", Locale.GERMANY).format(Date(millis))
|
||||||
|
|
||||||
|
|||||||
@@ -297,6 +297,7 @@ private fun PickerDialog(picker: Picker, onClose: () -> Unit) {
|
|||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.then(if (selected) Modifier.focusRequester(selectedFocus) else Modifier),
|
.then(if (selected) Modifier.focusRequester(selectedFocus) else Modifier),
|
||||||
shape = ClickableSurfaceDefaults.shape(rowShape),
|
shape = ClickableSurfaceDefaults.shape(rowShape),
|
||||||
|
scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
|
||||||
colors = ClickableSurfaceDefaults.colors(
|
colors = ClickableSurfaceDefaults.colors(
|
||||||
containerColor = androidx.compose.ui.graphics.Color.Transparent,
|
containerColor = androidx.compose.ui.graphics.Color.Transparent,
|
||||||
contentColor = CastarrColors.fg,
|
contentColor = CastarrColors.fg,
|
||||||
@@ -405,6 +406,7 @@ private fun SettingRow(
|
|||||||
onClick = onClick,
|
onClick = onClick,
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
shape = ClickableSurfaceDefaults.shape(rowShape),
|
shape = ClickableSurfaceDefaults.shape(rowShape),
|
||||||
|
scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
|
||||||
colors = ClickableSurfaceDefaults.colors(
|
colors = ClickableSurfaceDefaults.colors(
|
||||||
containerColor = androidx.compose.ui.graphics.Color.Transparent,
|
containerColor = androidx.compose.ui.graphics.Color.Transparent,
|
||||||
contentColor = CastarrColors.fg,
|
contentColor = CastarrColors.fg,
|
||||||
|
|||||||
Reference in New Issue
Block a user