From de2293376603ce139f650693851f7cb1cfe37179 Mon Sep 17 00:00:00 2001 From: Damontecres Date: Wed, 22 Oct 2025 12:43:14 -0400 Subject: [PATCH] Only show record program button if it hasn't ended --- .../wholphin/ui/detail/livetv/DvrSchedule.kt | 1 + .../ui/detail/livetv/ProgramDialog.kt | 100 ++++++++++-------- .../wholphin/ui/detail/livetv/TvGuideGrid.kt | 1 + 3 files changed, 55 insertions(+), 47 deletions(-) diff --git a/app/src/main/java/com/github/damontecres/wholphin/ui/detail/livetv/DvrSchedule.kt b/app/src/main/java/com/github/damontecres/wholphin/ui/detail/livetv/DvrSchedule.kt index 433d2c82..ad43c16f 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/ui/detail/livetv/DvrSchedule.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/ui/detail/livetv/DvrSchedule.kt @@ -147,6 +147,7 @@ fun DvrSchedule( showDialog?.let { item -> ProgramDialog( item = item, + canRecord = true, loading = LoadingState.Success, onDismissRequest = { showDialog = null diff --git a/app/src/main/java/com/github/damontecres/wholphin/ui/detail/livetv/ProgramDialog.kt b/app/src/main/java/com/github/damontecres/wholphin/ui/detail/livetv/ProgramDialog.kt index d1349c8c..a5f6db0b 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/ui/detail/livetv/ProgramDialog.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/ui/detail/livetv/ProgramDialog.kt @@ -43,6 +43,7 @@ import java.time.ZoneId @Composable fun ProgramDialog( item: BaseItem?, + canRecord: Boolean, loading: LoadingState, onDismissRequest: () -> Unit, onWatch: () -> Unit, @@ -138,59 +139,64 @@ fun ProgramDialog( .padding(top = 8.dp) .fillMaxWidth(), ) { - Row( - horizontalArrangement = Arrangement.spacedBy(16.dp), - ) { - if (dto.isSeries ?: false) { - Button( - onClick = { - if (isSeriesRecording) { - onCancelRecord.invoke(true) - } else { - onRecord.invoke(true) - } - }, - ) { - Row( - horizontalArrangement = Arrangement.spacedBy(4.dp), - verticalAlignment = Alignment.CenterVertically, + if (canRecord) { + Row( + horizontalArrangement = Arrangement.spacedBy(16.dp), + ) { + if (dto.isSeries ?: false) { + Button( + onClick = { + if (isSeriesRecording) { + onCancelRecord.invoke(true) + } else { + onRecord.invoke(true) + } + }, ) { - if (isSeriesRecording) { - Icon( - imageVector = Icons.Default.Close, - contentDescription = null, - tint = Color.Red, + Row( + horizontalArrangement = Arrangement.spacedBy(4.dp), + verticalAlignment = Alignment.CenterVertically, + ) { + if (isSeriesRecording) { + Icon( + imageVector = Icons.Default.Close, + contentDescription = null, + tint = Color.Red, + ) + } + Text( + text = if (isSeriesRecording) "Cancel Series Recording" else "Record Series", ) } - Text( - text = if (isSeriesRecording) "Cancel Series Recording" else "Record Series", - ) } } - } - Button( - onClick = { - if (isRecording) { - onCancelRecord.invoke(false) - } else { - onRecord.invoke(false) + if (dto.endDate?.isAfter(LocalDateTime.now()) ?: true) { + // Only show program specific recording button if it hasn't finished yet + Button( + onClick = { + if (isRecording) { + onCancelRecord.invoke(false) + } else { + onRecord.invoke(false) + } + }, + ) { + Row( + horizontalArrangement = Arrangement.spacedBy(4.dp), + verticalAlignment = Alignment.CenterVertically, + ) { + if (isRecording) { + Icon( + imageVector = Icons.Default.Close, + contentDescription = null, + tint = Color.Red, + ) + } + Text( + text = if (isRecording) "Cancel Recording" else "Record Program", + ) + } } - }, - ) { - Row( - horizontalArrangement = Arrangement.spacedBy(4.dp), - verticalAlignment = Alignment.CenterVertically, - ) { - if (isRecording) { - Icon( - imageVector = Icons.Default.Close, - contentDescription = null, - tint = Color.Red, - ) - } - Text( - text = if (isRecording) "Cancel Recording" else "Record Program", - ) } } } diff --git a/app/src/main/java/com/github/damontecres/wholphin/ui/detail/livetv/TvGuideGrid.kt b/app/src/main/java/com/github/damontecres/wholphin/ui/detail/livetv/TvGuideGrid.kt index b0503e1d..ec625df3 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/ui/detail/livetv/TvGuideGrid.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/ui/detail/livetv/TvGuideGrid.kt @@ -143,6 +143,7 @@ fun TvGuideGrid( val onDismissRequest = { showItemDialog = null } ProgramDialog( item = fetchedItem, + canRecord = true, loading = loadingItem, onDismissRequest = onDismissRequest, onWatch = {