Skip to content

StreamVault is a TV-first free IPTV player for Android TV built with Kotlin, Jetpack Compose, Room, Hilt, and Media3.

Refactor settings screen into modular slices

David Nashash6c07a51603d9
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerSleepTimerSupport.kt b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerSleepTimerSupport.kt
new file mode 100644
index 00000000..67f84c94
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerSleepTimerSupport.kt
@@ -0,0 +1,31 @@
+package com.streamvault.app.ui.screens.player
+
+internal fun computeSleepTimerUiState(
+ current: SleepTimerUiState,
+ nowElapsedMs: Long,
+ stopPlaybackTimerEndsAtMs: Long,
+ idleStandbyTimerEndsAtMs: Long,
+ stopMinutes: Int = current.stopTimerMinutes,
+ idleMinutes: Int = current.idleTimerMinutes
+): SleepTimerUiState {
+ return current.copy(
+ stopTimerMinutes = stopMinutes,
+ stopRemainingMs = if (stopPlaybackTimerEndsAtMs > 0L) {
+ (stopPlaybackTimerEndsAtMs - nowElapsedMs).coerceAtLeast(0L)
+ } else {
+ 0L
+ },
+ idleTimerMinutes = idleMinutes,
+ idleRemainingMs = if (idleStandbyTimerEndsAtMs > 0L) {
+ (idleStandbyTimerEndsAtMs - nowElapsedMs).coerceAtLeast(0L)
+ } else {
+ 0L
+ }
+ )
+}
+
+internal fun sanitizePlaybackTimerMinutes(minutes: Int, allowedPresets: Set<Int>): Int =
+ minutes.takeIf { it in allowedPresets } ?: 0
+
+internal fun formatTimerMinutesNotice(minutes: Int): String =
+ if (minutes == 1) "1 minute" else "$minutes minutes"
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerViewModel.kt b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerViewModel.kt
index 6cfc65f1..008818c9 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerViewModel.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerViewModel.kt
@@ -523,12 +523,12 @@ class PlayerViewModel @Inject constructor(
}
viewModelScope.launch {
preferencesRepository.defaultStopPlaybackTimerMinutes.collect {
- defaultStopPlaybackTimerMinutes = sanitizePlaybackTimerMinutes(it)
+ defaultStopPlaybackTimerMinutes = sanitizePlaybackTimerMinutes(it, PLAYBACK_TIMER_PRESETS_MINUTES)
}
}
viewModelScope.launch {
preferencesRepository.defaultIdleStandbyTimerMinutes.collect {
- defaultIdleStandbyTimerMinutes = sanitizePlaybackTimerMinutes(it)
+ defaultIdleStandbyTimerMinutes = sanitizePlaybackTimerMinutes(it, PLAYBACK_TIMER_PRESETS_MINUTES)
}
}
viewModelScope.launch {
@@ -2743,7 +2743,7 @@ class PlayerViewModel @Inject constructor(
}
fun setStopPlaybackTimer(minutes: Int) {
- val normalized = sanitizePlaybackTimerMinutes(minutes)
+ val normalized = sanitizePlaybackTimerMinutes(minutes, PLAYBACK_TIMER_PRESETS_MINUTES)
if (normalized == 0) {
disableStopPlaybackTimer()
return
@@ -2756,7 +2756,7 @@ class PlayerViewModel @Inject constructor(
}
fun setIdleStandbyTimer(minutes: Int) {
- val normalized = sanitizePlaybackTimerMinutes(minutes)
+ val normalized = sanitizePlaybackTimerMinutes(minutes, PLAYBACK_TIMER_PRESETS_MINUTES)
if (normalized == 0) {
disableIdleStandbyTimer()
return
@@ -2814,8 +2814,14 @@ class PlayerViewModel @Inject constructor(
playbackTimerDefaultsApplied = true
sleepTimerExitEmitted = false
viewModelScope.launch {
- val stopMinutes = sanitizePlaybackTimerMinutes(preferencesRepository.defaultStopPlaybackTimerMinutes.first())
- val idleMinutes = sanitizePlaybackTimerMinutes(preferencesRepository.defaultIdleStandbyTimerMinutes.first())
+ val stopMinutes = sanitizePlaybackTimerMinutes(
+ preferencesRepository.defaultStopPlaybackTimerMinutes.first(),
+ PLAYBACK_TIMER_PRESETS_MINUTES
+ )
+ val idleMinutes = sanitizePlaybackTimerMinutes(
+ preferencesRepository.defaultIdleStandbyTimerMinutes.first(),
+ PLAYBACK_TIMER_PRESETS_MINUTES
+ )
if (!playbackTimerDefaultsApplied || _sleepTimerUiState.value.stopTimerActive || _sleepTimerUiState.value.idleTimerActive) {
return@launch
}
@@ -2860,12 +2866,13 @@ class PlayerViewModel @Inject constructor(
stopMinutes: Int = _sleepTimerUiState.value.stopTimerMinutes,
idleMinutes: Int = _sleepTimerUiState.value.idleTimerMinutes
): SleepTimerUiState {
- val now = SystemClock.elapsedRealtime()
- val next = _sleepTimerUiState.value.copy(
- stopTimerMinutes = stopMinutes,
- stopRemainingMs = if (stopPlaybackTimerEndsAtMs > 0L) (stopPlaybackTimerEndsAtMs - now).coerceAtLeast(0L) else 0L,
- idleTimerMinutes = idleMinutes,
- idleRemainingMs = if (idleStandbyTimerEndsAtMs > 0L) (idleStandbyTimerEndsAtMs - now).coerceAtLeast(0L) else 0L
+ val next = computeSleepTimerUiState(
+ current = _sleepTimerUiState.value,
+ nowElapsedMs = SystemClock.elapsedRealtime(),
+ stopPlaybackTimerEndsAtMs = stopPlaybackTimerEndsAtMs,
+ idleStandbyTimerEndsAtMs = idleStandbyTimerEndsAtMs,
+ stopMinutes = stopMinutes,
+ idleMinutes = idleMinutes
)
_sleepTimerUiState.value = next
return next
@@ -2896,12 +2903,6 @@ class PlayerViewModel @Inject constructor(
_sleepTimerUiState.value = SleepTimerUiState()
}
- private fun sanitizePlaybackTimerMinutes(minutes: Int): Int =
- minutes.takeIf { it in PLAYBACK_TIMER_PRESETS_MINUTES } ?: 0
-
- private fun formatTimerMinutesNotice(minutes: Int): String =
- if (minutes == 1) "1 minute" else "$minutes minutes"
-
fun seekForward() {
notifyUserActivity()
playerEngine.seekForward()
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsAppUpdateFormatting.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsAppUpdateFormatting.kt
new file mode 100644
index 00000000..7ab66078
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsAppUpdateFormatting.kt
@@ -0,0 +1,57 @@
+package com.streamvault.app.ui.screens.settings
+
+import com.streamvault.app.R
+import com.streamvault.app.update.AppUpdateDownloadStatus
+import java.text.DateFormat
+
+internal fun formatLatestReleaseLabel(update: AppUpdateUiModel, context: android.content.Context): String {
+ val versionName = update.latestVersionName ?: return context.getString(R.string.settings_update_not_checked)
+ val versionCodeSuffix = update.latestVersionCode?.let { " ($it)" }.orEmpty()
+ return "$versionName$versionCodeSuffix"
+}
+
+internal fun formatUpdateStatusLabel(update: AppUpdateUiModel, context: android.content.Context): String {
+ val downloadedReleaseMatchesLatest = update.downloadedVersionName != null &&
+ (update.latestVersionName == null || update.downloadedVersionName == update.latestVersionName)
+ return when {
+ update.errorMessage != null -> context.getString(R.string.settings_update_status_check_failed)
+ update.downloadStatus == AppUpdateDownloadStatus.Downloading -> context.getString(R.string.settings_update_status_downloading)
+ update.downloadStatus == AppUpdateDownloadStatus.Downloaded && downloadedReleaseMatchesLatest -> context.getString(R.string.settings_update_status_ready_to_install)
+ update.latestVersionName == null -> context.getString(R.string.settings_update_not_checked)
+ update.isUpdateAvailable -> context.getString(R.string.settings_update_status_available)
+ else -> context.getString(R.string.settings_update_status_current)
+ }
+}
+
+internal fun formatUpdateCheckTimeLabel(timestamp: Long?, context: android.content.Context): String {
+ if (timestamp == null || timestamp <= 0L) {
+ return context.getString(R.string.settings_update_not_checked)
+ }
+ return DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT).format(java.util.Date(timestamp))
+}
+
+internal fun shouldShowUpdateDownloadAction(update: AppUpdateUiModel): Boolean {
+ val downloadedReleaseMatchesLatest = update.downloadedVersionName != null &&
+ (update.latestVersionName == null || update.downloadedVersionName == update.latestVersionName)
+ return when (update.downloadStatus) {
+ AppUpdateDownloadStatus.Downloading,
+ AppUpdateDownloadStatus.Downloaded -> downloadedReleaseMatchesLatest || (update.isUpdateAvailable && !update.downloadUrl.isNullOrBlank())
+ else -> update.isUpdateAvailable && !update.downloadUrl.isNullOrBlank()
+ }
+}
+
+internal fun formatUpdateDownloadLabel(update: AppUpdateUiModel, context: android.content.Context): String {
+ val downloadedReleaseMatchesLatest = update.downloadedVersionName != null &&
+ (update.latestVersionName == null || update.downloadedVersionName == update.latestVersionName)
+ return when (update.downloadStatus) {
+ AppUpdateDownloadStatus.Downloading -> context.getString(R.string.settings_update_download_in_progress)
+ AppUpdateDownloadStatus.Downloaded -> {
+ if (downloadedReleaseMatchesLatest) {
+ context.getString(R.string.settings_update_install_action)
+ } else {
+ context.getString(R.string.settings_update_download_action)
+ }
+ }
+ else -> context.getString(R.string.settings_update_download_action)
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsAppUpdateModels.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsAppUpdateModels.kt
new file mode 100644
index 00000000..2160f67c
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsAppUpdateModels.kt
@@ -0,0 +1,85 @@
+package com.streamvault.app.ui.screens.settings
+
+import com.streamvault.app.BuildConfig
+import com.streamvault.app.update.AppUpdateDownloadState
+import com.streamvault.app.update.AppUpdateDownloadStatus
+import com.streamvault.app.update.GitHubReleaseInfo
+import kotlin.math.max
+
+data class AppUpdateUiModel(
+ val latestVersionName: String? = null,
+ val latestVersionCode: Int? = null,
+ val releaseUrl: String? = null,
+ val downloadUrl: String? = null,
+ val releaseNotes: String = "",
+ val publishedAt: String? = null,
+ val isUpdateAvailable: Boolean = false,
+ val lastCheckedAt: Long? = null,
+ val errorMessage: String? = null,
+ val downloadStatus: AppUpdateDownloadStatus = AppUpdateDownloadStatus.Idle,
+ val downloadedVersionName: String? = null
+)
+
+internal fun AppUpdateUiModel.toReleaseInfoOrNull(): GitHubReleaseInfo? {
+ val versionName = latestVersionName ?: return null
+ val releaseUrl = releaseUrl ?: return null
+ return GitHubReleaseInfo(
+ versionName = versionName,
+ versionCode = latestVersionCode,
+ releaseUrl = releaseUrl,
+ downloadUrl = downloadUrl,
+ releaseNotes = releaseNotes,
+ publishedAt = publishedAt
+ )
+}
+
+internal fun AppUpdateUiModel.withDownloadState(downloadState: AppUpdateDownloadState): AppUpdateUiModel {
+ return copy(
+ downloadStatus = downloadState.status,
+ downloadedVersionName = downloadState.versionName
+ )
+}
+
+internal fun AppUpdateUiModel.toDownloadState(): AppUpdateDownloadState {
+ return AppUpdateDownloadState(
+ status = downloadStatus,
+ versionName = downloadedVersionName
+ )
+}
+
+internal fun SettingsPreferenceSnapshot.toCachedAppUpdateUiModel(): AppUpdateUiModel {
+ val versionName = cachedAppUpdateVersionName
+ return AppUpdateUiModel(
+ latestVersionName = versionName,
+ latestVersionCode = cachedAppUpdateVersionCode,
+ releaseUrl = cachedAppUpdateReleaseUrl,
+ downloadUrl = cachedAppUpdateDownloadUrl,
+ releaseNotes = cachedAppUpdateReleaseNotes,
+ publishedAt = cachedAppUpdatePublishedAt,
+ isUpdateAvailable = versionName?.let {
+ isRemoteVersionNewer(cachedAppUpdateVersionCode, it)
+ } ?: false,
+ lastCheckedAt = lastAppUpdateCheckAt
+ )
+}
+
+internal fun isRemoteVersionNewer(remoteVersionCode: Int?, remoteVersionName: String): Boolean {
+ if (remoteVersionCode != null && remoteVersionCode > BuildConfig.VERSION_CODE) {
+ return true
+ }
+ return compareVersionNamesStatic(remoteVersionName, BuildConfig.VERSION_NAME) > 0
+}
+
+internal fun compareVersionNamesStatic(left: String, right: String): Int {
+ val leftParts = left.removePrefix("v").split('.')
+ val rightParts = right.removePrefix("v").split('.')
+ val length = max(leftParts.size, rightParts.size)
+ for (index in 0 until length) {
+ val leftValue = leftParts.getOrNull(index)?.toIntOrNull() ?: 0
+ val rightValue = rightParts.getOrNull(index)?.toIntOrNull() ?: 0
+ if (leftValue != rightValue) {
+ return leftValue.compareTo(rightValue)
+ }
+ }
+ return 0
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsBackupAboutSections.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsBackupAboutSections.kt
new file mode 100644
index 00000000..10ce7d87
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsBackupAboutSections.kt
@@ -0,0 +1,193 @@
+package com.streamvault.app.ui.screens.settings
+
+import android.content.Context
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.lazy.LazyListScope
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.text.style.TextAlign
+import androidx.compose.ui.unit.dp
+import androidx.tv.material3.ClickableSurfaceDefaults
+import androidx.tv.material3.MaterialTheme
+import androidx.tv.material3.Text
+import com.streamvault.app.BuildConfig
+import com.streamvault.app.R
+import com.streamvault.app.ui.interaction.TvClickableSurface
+import com.streamvault.app.ui.theme.OnSurfaceDim
+import com.streamvault.app.ui.theme.Primary
+import com.streamvault.app.ui.theme.Secondary
+
+internal fun LazyListScope.settingsBackupSection(
+ onCreateBackup: () -> Unit,
+ onRestoreBackup: () -> Unit
+) {
+ item {
+ Row(
+ horizontalArrangement = Arrangement.spacedBy(16.dp),
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ TvClickableSurface(
+ onClick = onCreateBackup,
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(12.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Primary.copy(alpha = 0.12f),
+ focusedContainerColor = Primary.copy(alpha = 0.28f)
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
+ modifier = Modifier.weight(1f)
+ ) {
+ Column(
+ modifier = Modifier.padding(24.dp),
+ verticalArrangement = Arrangement.spacedBy(8.dp),
+ horizontalAlignment = Alignment.CenterHorizontally
+ ) {
+ Text(text = "\u2191", style = MaterialTheme.typography.titleLarge, color = Primary, fontWeight = FontWeight.Bold)
+ Text(text = stringResource(R.string.settings_backup_data), style = MaterialTheme.typography.titleSmall, color = Primary, textAlign = TextAlign.Center)
+ Text(text = stringResource(R.string.settings_backup_subtitle), style = MaterialTheme.typography.bodySmall, color = OnSurfaceDim, textAlign = TextAlign.Center)
+ }
+ }
+ TvClickableSurface(
+ onClick = onRestoreBackup,
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(12.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Secondary.copy(alpha = 0.12f),
+ focusedContainerColor = Secondary.copy(alpha = 0.28f)
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
+ modifier = Modifier.weight(1f)
+ ) {
+ Column(
+ modifier = Modifier.padding(24.dp),
+ verticalArrangement = Arrangement.spacedBy(8.dp),
+ horizontalAlignment = Alignment.CenterHorizontally
+ ) {
+ Text(text = "\u2193", style = MaterialTheme.typography.titleLarge, color = Secondary, fontWeight = FontWeight.Bold)
+ Text(text = stringResource(R.string.settings_restore_data), style = MaterialTheme.typography.titleSmall, color = Secondary, textAlign = TextAlign.Center)
+ Text(text = stringResource(R.string.settings_backup_subtitle), style = MaterialTheme.typography.bodySmall, color = OnSurfaceDim, textAlign = TextAlign.Center)
+ }
+ }
+ }
+ }
+}
+
+internal fun LazyListScope.settingsAboutSection(
+ uiState: SettingsUiState,
+ context: Context,
+ buildVerificationLabel: String,
+ onOpenUri: (String) -> Unit,
+ onCheckForUpdates: () -> Unit,
+ onInstallDownloadedUpdate: () -> Unit,
+ onDownloadLatestUpdate: () -> Unit,
+ onSetAutoCheckAppUpdates: (Boolean) -> Unit,
+ onSetAutoDownloadAppUpdates: (Boolean) -> Unit,
+ onRefreshDownloadState: () -> Unit
+) {
+ item {
+ val downloadStatus = uiState.appUpdate.downloadStatus
+ LaunchedEffect(downloadStatus) {
+ if (downloadStatus == com.streamvault.app.update.AppUpdateDownloadStatus.Downloading) {
+ while (true) {
+ kotlinx.coroutines.delay(2000L)
+ onRefreshDownloadState()
+ }
+ }
+ }
+ SettingsSectionHeader(
+ title = stringResource(R.string.settings_updates_title),
+ subtitle = stringResource(R.string.settings_updates_subtitle)
+ )
+ SettingsRow(label = stringResource(R.string.settings_app_version), value = "${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})")
+ SwitchSettingsRow(
+ label = stringResource(R.string.settings_update_auto_check),
+ value = stringResource(
+ if (uiState.autoCheckAppUpdates) R.string.settings_enabled else R.string.settings_disabled
+ ),
+ checked = uiState.autoCheckAppUpdates,
+ onCheckedChange = onSetAutoCheckAppUpdates
+ )
+ if (uiState.autoCheckAppUpdates) {
+ SwitchSettingsRow(
+ label = stringResource(R.string.settings_update_auto_download),
+ value = stringResource(
+ if (uiState.autoDownloadAppUpdates) R.string.settings_enabled else R.string.settings_disabled
+ ),
+ checked = uiState.autoDownloadAppUpdates,
+ onCheckedChange = onSetAutoDownloadAppUpdates
+ )
+ }
+ SettingsRow(
+ label = stringResource(R.string.settings_update_latest_release),
+ value = formatLatestReleaseLabel(uiState.appUpdate, context)
+ )
+ SettingsRow(
+ label = stringResource(R.string.settings_update_status),
+ value = formatUpdateStatusLabel(uiState.appUpdate, context)
+ )
+ SettingsRow(
+ label = stringResource(R.string.settings_update_last_checked),
+ value = formatUpdateCheckTimeLabel(uiState.appUpdate.lastCheckedAt, context)
+ )
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_update_check_now),
+ value = stringResource(
+ if (uiState.isCheckingForUpdates) R.string.settings_update_checking else R.string.settings_update_check_action
+ ),
+ onClick = {
+ if (!uiState.isCheckingForUpdates) {
+ onCheckForUpdates()
+ }
+ }
+ )
+ if (shouldShowUpdateDownloadAction(uiState.appUpdate)) {
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_update_download),
+ value = formatUpdateDownloadLabel(uiState.appUpdate, context),
+ onClick = {
+ if (uiState.appUpdate.downloadStatus == com.streamvault.app.update.AppUpdateDownloadStatus.Downloaded) {
+ onInstallDownloadedUpdate()
+ } else if (uiState.appUpdate.downloadStatus != com.streamvault.app.update.AppUpdateDownloadStatus.Downloading) {
+ onDownloadLatestUpdate()
+ }
+ }
+ )
+ }
+ if (!uiState.appUpdate.releaseUrl.isNullOrBlank()) {
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_update_view_release),
+ value = uiState.appUpdate.latestVersionName ?: stringResource(R.string.settings_update_release_notes),
+ onClick = { onOpenUri(uiState.appUpdate.releaseUrl.orEmpty()) }
+ )
+ }
+ if (!uiState.appUpdate.errorMessage.isNullOrBlank()) {
+ SettingsRow(
+ label = stringResource(R.string.settings_update_error),
+ value = uiState.appUpdate.errorMessage.orEmpty()
+ )
+ }
+ }
+
+ item {
+ SettingsRow(label = stringResource(R.string.settings_build), value = stringResource(R.string.settings_build_desc))
+ SettingsRow(label = stringResource(R.string.settings_build_verification), value = buildVerificationLabel)
+ SettingsRow(label = stringResource(R.string.settings_developed_by), value = stringResource(R.string.settings_developer_name))
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_github),
+ value = stringResource(R.string.settings_github_url),
+ onClick = { onOpenUri(context.getString(R.string.settings_github_url)) }
+ )
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_donate),
+ value = stringResource(R.string.settings_donate_url),
+ onClick = { onOpenUri(context.getString(R.string.settings_donate_url)) }
+ )
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsBackupImportPreviewDialog.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsBackupImportPreviewDialog.kt
new file mode 100644
index 00000000..d77d7baf
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsBackupImportPreviewDialog.kt
@@ -0,0 +1,168 @@
+package com.streamvault.app.ui.screens.settings
+
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material3.Switch
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.unit.dp
+import androidx.tv.material3.ClickableSurfaceDefaults
+import androidx.tv.material3.MaterialTheme
+import androidx.tv.material3.Text
+import com.streamvault.app.R
+import com.streamvault.app.ui.components.dialogs.PremiumDialog
+import com.streamvault.app.ui.components.dialogs.PremiumDialogFooterButton
+import com.streamvault.app.ui.interaction.TvClickableSurface
+import com.streamvault.app.ui.theme.OnBackground
+import com.streamvault.app.ui.theme.OnSurfaceDim
+import com.streamvault.app.ui.theme.Primary
+import com.streamvault.app.ui.theme.Secondary
+import com.streamvault.app.ui.theme.SurfaceElevated
+import com.streamvault.domain.manager.BackupConflictStrategy
+import com.streamvault.domain.manager.BackupImportPlan
+import com.streamvault.domain.manager.BackupPreview
+
+@Composable
+internal fun BackupImportPreviewDialog(
+ preview: BackupPreview,
+ plan: BackupImportPlan,
+ onDismiss: () -> Unit,
+ onStrategySelected: (BackupConflictStrategy) -> Unit,
+ onImportPreferencesChanged: (Boolean) -> Unit,
+ onImportProvidersChanged: (Boolean) -> Unit,
+ onImportSavedLibraryChanged: (Boolean) -> Unit,
+ onImportPlaybackHistoryChanged: (Boolean) -> Unit,
+ onImportMultiViewChanged: (Boolean) -> Unit,
+ onImportRecordingSchedulesChanged: (Boolean) -> Unit,
+ onConfirm: () -> Unit
+) {
+ PremiumDialog(
+ title = stringResource(R.string.settings_backup_preview_title),
+ subtitle = stringResource(R.string.settings_backup_preview_subtitle, preview.version),
+ onDismissRequest = onDismiss,
+ widthFraction = 0.58f,
+ content = {
+ BackupPreviewRow(stringResource(R.string.settings_backup_section_preferences), preview.preferenceCount, 0)
+ BackupPreviewRow(stringResource(R.string.settings_backup_section_providers), preview.providerCount, preview.providerConflicts)
+ BackupPreviewRow(stringResource(R.string.settings_backup_section_saved), preview.favoriteCount + preview.groupCount + preview.protectedCategoryCount, preview.favoriteConflicts + preview.groupConflicts + preview.protectedCategoryConflicts)
+ BackupPreviewRow(stringResource(R.string.settings_backup_section_history), preview.playbackHistoryCount, preview.historyConflicts)
+ BackupPreviewRow(stringResource(R.string.settings_backup_section_multiview), preview.multiViewPresetCount, 0)
+ BackupPreviewRow(stringResource(R.string.settings_backup_section_recordings), preview.scheduledRecordingCount, preview.recordingConflicts)
+ Text(
+ text = stringResource(R.string.settings_backup_conflict_strategy),
+ style = MaterialTheme.typography.titleSmall,
+ color = Primary
+ )
+ Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) {
+ BackupStrategyChip(
+ title = stringResource(R.string.settings_backup_keep_existing),
+ selected = plan.conflictStrategy == BackupConflictStrategy.KEEP_EXISTING,
+ onClick = { onStrategySelected(BackupConflictStrategy.KEEP_EXISTING) }
+ )
+ BackupStrategyChip(
+ title = stringResource(R.string.settings_backup_replace_existing),
+ selected = plan.conflictStrategy == BackupConflictStrategy.REPLACE_EXISTING,
+ onClick = { onStrategySelected(BackupConflictStrategy.REPLACE_EXISTING) }
+ )
+ }
+ Text(
+ text = stringResource(R.string.settings_backup_import_sections),
+ style = MaterialTheme.typography.titleSmall,
+ color = Primary
+ )
+ BackupToggleRow(stringResource(R.string.settings_backup_section_preferences), plan.importPreferences, onImportPreferencesChanged)
+ BackupToggleRow(stringResource(R.string.settings_backup_section_providers), plan.importProviders, onImportProvidersChanged)
+ BackupToggleRow(stringResource(R.string.settings_backup_section_saved), plan.importSavedLibrary, onImportSavedLibraryChanged)
+ BackupToggleRow(stringResource(R.string.settings_backup_section_history), plan.importPlaybackHistory, onImportPlaybackHistoryChanged)
+ BackupToggleRow(stringResource(R.string.settings_backup_section_multiview), plan.importMultiViewPresets, onImportMultiViewChanged)
+ BackupToggleRow(stringResource(R.string.settings_backup_section_recordings), plan.importRecordingSchedules, onImportRecordingSchedulesChanged)
+ },
+ footer = {
+ PremiumDialogFooterButton(
+ label = stringResource(R.string.settings_cancel),
+ onClick = onDismiss
+ )
+ PremiumDialogFooterButton(
+ label = stringResource(R.string.settings_backup_import_confirm),
+ onClick = onConfirm,
+ emphasized = true
+ )
+ }
+ )
+}
+
+@Composable
+private fun BackupPreviewRow(
+ title: String,
+ itemCount: Int,
+ conflictCount: Int
+) {
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Column {
+ Text(title, style = MaterialTheme.typography.bodyLarge, color = OnBackground)
+ Text(
+ text = if (conflictCount > 0) {
+ stringResource(R.string.settings_backup_conflict_count, conflictCount)
+ } else {
+ stringResource(R.string.settings_backup_no_conflicts)
+ },
+ style = MaterialTheme.typography.bodySmall,
+ color = if (conflictCount > 0) Secondary else OnSurfaceDim
+ )
+ }
+ Text(
+ text = stringResource(R.string.settings_backup_item_count, itemCount),
+ style = MaterialTheme.typography.labelLarge,
+ color = OnBackground
+ )
+ }
+}
+
+@Composable
+private fun BackupStrategyChip(
+ title: String,
+ selected: Boolean,
+ onClick: () -> Unit
+) {
+ TvClickableSurface(
+ onClick = onClick,
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(24.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = if (selected) Primary.copy(alpha = 0.2f) else SurfaceElevated,
+ focusedContainerColor = Primary.copy(alpha = 0.35f)
+ )
+ ) {
+ Text(
+ text = title,
+ style = MaterialTheme.typography.labelLarge,
+ color = if (selected) Primary else OnBackground,
+ modifier = Modifier.padding(horizontal = 16.dp, vertical = 10.dp)
+ )
+ }
+}
+
+@Composable
+private fun BackupToggleRow(
+ label: String,
+ checked: Boolean,
+ onCheckedChange: (Boolean) -> Unit
+) {
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Text(label, style = MaterialTheme.typography.bodyLarge, color = OnBackground)
+ Switch(checked = checked, onCheckedChange = onCheckedChange)
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsBrowsingSection.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsBrowsingSection.kt
new file mode 100644
index 00000000..85f4c985
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsBrowsingSection.kt
@@ -0,0 +1,219 @@
+package com.streamvault.app.ui.screens.settings
+
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.lazy.LazyListScope
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material3.HorizontalDivider
+import androidx.compose.material3.Switch
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.unit.dp
+import androidx.tv.material3.ClickableSurfaceDefaults
+import androidx.tv.material3.MaterialTheme
+import androidx.tv.material3.Text
+import com.streamvault.app.R
+import com.streamvault.app.ui.interaction.TvClickableSurface
+import com.streamvault.app.ui.model.VodViewMode
+import com.streamvault.app.ui.theme.OnBackground
+import com.streamvault.app.ui.theme.OnSurface
+import com.streamvault.app.ui.theme.Primary
+import com.streamvault.domain.model.CategorySortMode
+import com.streamvault.domain.model.ContentType
+import com.streamvault.domain.model.LiveChannelGroupingMode
+
+internal fun LazyListScope.settingsBrowsingSection(
+ uiState: SettingsUiState,
+ viewModel: SettingsViewModel,
+ context: android.content.Context,
+ guideDefaultCategoryLabel: String,
+ timeFormatLabel: String,
+ appLanguageLabel: String,
+ onShowLiveTvModeDialogChange: (Boolean) -> Unit,
+ onShowLiveTvFiltersDialogChange: (Boolean) -> Unit,
+ onShowLiveTvQuickFilterVisibilityDialogChange: (Boolean) -> Unit,
+ onShowLiveChannelNumberingDialogChange: (Boolean) -> Unit,
+ onShowLiveChannelGroupingDialogChange: (Boolean) -> Unit,
+ onShowGroupedChannelLabelDialogChange: (Boolean) -> Unit,
+ onShowLiveVariantPreferenceDialogChange: (Boolean) -> Unit,
+ onShowGuideDefaultCategoryDialogChange: (Boolean) -> Unit,
+ onShowTimeFormatDialogChange: (Boolean) -> Unit,
+ onShowVodViewModeDialogChange: (Boolean) -> Unit,
+ onCategorySortDialogTypeChange: (String?) -> Unit,
+ onShowLanguageDialogChange: (Boolean) -> Unit
+) {
+ item {
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_live_tv_channel_mode),
+ value = stringResource(uiState.liveTvChannelMode.labelResId()),
+ onClick = { onShowLiveTvModeDialogChange(true) }
+ )
+ TvClickableSurface(
+ onClick = { viewModel.setShowLiveSourceSwitcher(!uiState.showLiveSourceSwitcher) },
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Color.Transparent,
+ focusedContainerColor = Primary.copy(alpha = 0.15f)
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ Row(
+ modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 12.dp),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Column(modifier = Modifier.weight(1f)) {
+ Text(text = stringResource(R.string.settings_show_live_source_switcher), style = MaterialTheme.typography.bodyMedium, color = OnSurface)
+ Text(text = stringResource(R.string.settings_show_live_source_switcher_subtitle), style = MaterialTheme.typography.bodySmall, color = OnBackground.copy(alpha = 0.6f))
+ }
+ Switch(checked = uiState.showLiveSourceSwitcher, onCheckedChange = { viewModel.setShowLiveSourceSwitcher(it) })
+ }
+ }
+ TvClickableSurface(
+ onClick = { viewModel.setShowAllChannelsCategory(!uiState.showAllChannelsCategory) },
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Color.Transparent,
+ focusedContainerColor = Primary.copy(alpha = 0.15f)
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ Row(
+ modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 12.dp),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Column(modifier = Modifier.weight(1f)) {
+ Text(text = stringResource(R.string.settings_show_all_channels_category), style = MaterialTheme.typography.bodyMedium, color = OnSurface)
+ Text(text = stringResource(R.string.settings_show_all_channels_category_subtitle), style = MaterialTheme.typography.bodySmall, color = OnBackground.copy(alpha = 0.6f))
+ }
+ Switch(checked = uiState.showAllChannelsCategory, onCheckedChange = { viewModel.setShowAllChannelsCategory(it) })
+ }
+ }
+ TvClickableSurface(
+ onClick = { viewModel.setShowRecentChannelsCategory(!uiState.showRecentChannelsCategory) },
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Color.Transparent,
+ focusedContainerColor = Primary.copy(alpha = 0.15f)
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ Row(
+ modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 12.dp),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Column(modifier = Modifier.weight(1f)) {
+ Text(text = stringResource(R.string.settings_show_recent_channels_category), style = MaterialTheme.typography.bodyMedium, color = OnSurface)
+ Text(text = stringResource(R.string.settings_show_recent_channels_category_subtitle), style = MaterialTheme.typography.bodySmall, color = OnBackground.copy(alpha = 0.6f))
+ }
+ Switch(checked = uiState.showRecentChannelsCategory, onCheckedChange = { viewModel.setShowRecentChannelsCategory(it) })
+ }
+ }
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_live_tv_quick_filters),
+ value = formatLiveTvQuickFiltersValue(uiState.liveTvCategoryFilters, context),
+ onClick = { onShowLiveTvFiltersDialogChange(true) }
+ )
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_live_tv_quick_filter_visibility),
+ value = stringResource(uiState.liveTvQuickFilterVisibilityMode.labelResId()),
+ onClick = { onShowLiveTvQuickFilterVisibilityDialogChange(true) }
+ )
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_live_channel_numbering_mode),
+ value = stringResource(uiState.liveChannelNumberingMode.labelResId()),
+ onClick = { onShowLiveChannelNumberingDialogChange(true) }
+ )
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_live_channel_grouping_mode),
+ value = stringResource(uiState.liveChannelGroupingMode.labelResId()),
+ onClick = { onShowLiveChannelGroupingDialogChange(true) }
+ )
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_grouped_channel_label_mode),
+ value = stringResource(uiState.groupedChannelLabelMode.labelResId()),
+ onClick = { onShowGroupedChannelLabelDialogChange(true) },
+ enabled = uiState.liveChannelGroupingMode == LiveChannelGroupingMode.GROUPED,
+ indent = 24.dp
+ )
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_live_variant_preference_mode),
+ value = stringResource(uiState.liveVariantPreferenceMode.labelResId()),
+ onClick = { onShowLiveVariantPreferenceDialogChange(true) },
+ enabled = uiState.liveChannelGroupingMode == LiveChannelGroupingMode.GROUPED,
+ indent = 24.dp
+ )
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_guide_default_category),
+ value = guideDefaultCategoryLabel,
+ onClick = { onShowGuideDefaultCategoryDialogChange(true) }
+ )
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_time_format),
+ value = timeFormatLabel,
+ onClick = { onShowTimeFormatDialogChange(true) }
+ )
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_vod_view_mode),
+ value = stringResource(uiState.vodViewMode.labelResId()),
+ onClick = { onShowVodViewModeDialogChange(true) }
+ )
+ SwitchSettingsRow(
+ label = stringResource(R.string.settings_vod_infinite_scroll),
+ value = stringResource(
+ if (uiState.vodInfiniteScroll) R.string.settings_vod_infinite_scroll_on
+ else R.string.settings_vod_infinite_scroll_off
+ ),
+ checked = uiState.vodInfiniteScroll,
+ onCheckedChange = { viewModel.setVodInfiniteScroll(it) },
+ enabled = uiState.vodViewMode == VodViewMode.MODERN,
+ indent = 24.dp
+ )
+ HorizontalDivider(color = Color.White.copy(alpha = 0.07f), modifier = Modifier.padding(vertical = 4.dp))
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_category_sort_live),
+ value = formatCategorySortModeLabel(uiState.categorySortModes[ContentType.LIVE] ?: CategorySortMode.DEFAULT, context),
+ onClick = { onCategorySortDialogTypeChange(ContentType.LIVE.name) }
+ )
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_category_sort_movies),
+ value = formatCategorySortModeLabel(uiState.categorySortModes[ContentType.MOVIE] ?: CategorySortMode.DEFAULT, context),
+ onClick = { onCategorySortDialogTypeChange(ContentType.MOVIE.name) }
+ )
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_category_sort_series),
+ value = formatCategorySortModeLabel(uiState.categorySortModes[ContentType.SERIES] ?: CategorySortMode.DEFAULT, context),
+ onClick = { onCategorySortDialogTypeChange(ContentType.SERIES.name) }
+ )
+ HorizontalDivider(color = Color.White.copy(alpha = 0.07f), modifier = Modifier.padding(vertical = 4.dp))
+ TvClickableSurface(
+ onClick = { onShowLanguageDialogChange(true) },
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Color.Transparent,
+ focusedContainerColor = Primary.copy(alpha = 0.15f)
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ Row(
+ modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 12.dp),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Text(text = stringResource(R.string.settings_app_language), style = MaterialTheme.typography.bodyMedium, color = OnSurface)
+ Text(text = appLanguageLabel, style = MaterialTheme.typography.bodyMedium, color = Primary)
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsCombinedM3uComponents.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsCombinedM3uComponents.kt
new file mode 100644
index 00000000..1c53df8d
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsCombinedM3uComponents.kt
@@ -0,0 +1,487 @@
+package com.streamvault.app.ui.screens.settings
+
+import androidx.compose.foundation.BorderStroke
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.FlowRow
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.heightIn
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.widthIn
+import androidx.compose.foundation.lazy.LazyRow
+import androidx.compose.foundation.lazy.items
+import androidx.compose.foundation.rememberScrollState
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.foundation.verticalScroll
+import androidx.compose.material3.Checkbox
+import androidx.compose.material3.RadioButton
+import androidx.compose.material3.Switch
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.saveable.rememberSaveable
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.unit.dp
+import androidx.tv.material3.Border
+import androidx.tv.material3.ClickableSurfaceDefaults
+import androidx.tv.material3.MaterialTheme
+import androidx.tv.material3.Surface
+import androidx.tv.material3.SurfaceDefaults
+import androidx.tv.material3.Text
+import com.streamvault.app.R
+import com.streamvault.app.ui.components.dialogs.PremiumDialog
+import com.streamvault.app.ui.components.dialogs.PremiumDialogFooterButton
+import com.streamvault.app.ui.design.FocusSpec
+import com.streamvault.app.ui.interaction.TvClickableSurface
+import com.streamvault.app.ui.theme.ErrorColor
+import com.streamvault.app.ui.theme.OnBackground
+import com.streamvault.app.ui.theme.OnSurface
+import com.streamvault.app.ui.theme.OnSurfaceDim
+import com.streamvault.app.ui.theme.Primary
+import com.streamvault.app.ui.theme.SurfaceElevated
+import com.streamvault.domain.model.ActiveLiveSource
+import com.streamvault.domain.model.CombinedM3uProfile
+import com.streamvault.domain.model.Provider
+import com.streamvault.domain.model.ProviderType
+
+@Composable
+internal fun CombinedM3uProfilesCard(
+ profiles: List<CombinedM3uProfile>,
+ availableProviders: List<Provider>,
+ selectedProfileId: Long?,
+ activeLiveSource: ActiveLiveSource?,
+ onSelectProfile: (Long) -> Unit,
+ onCreateProfile: () -> Unit,
+ onActivateProfile: (Long) -> Unit,
+ onDeleteProfile: (Long) -> Unit,
+ onRenameProfile: (Long) -> Unit,
+ onAddProvider: (Long) -> Unit,
+ onRemoveProvider: (Long, Long) -> Unit,
+ onToggleProviderEnabled: (Long, Long, Boolean) -> Unit,
+ onMoveProvider: (Long, Long, Boolean) -> Unit
+) {
+ Surface(
+ shape = RoundedCornerShape(12.dp),
+ colors = SurfaceDefaults.colors(containerColor = SurfaceElevated),
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ Column(
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(16.dp),
+ verticalArrangement = Arrangement.spacedBy(12.dp)
+ ) {
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Column(verticalArrangement = Arrangement.spacedBy(4.dp)) {
+ Text("Combined M3U", style = MaterialTheme.typography.titleMedium, color = OnSurface)
+ Text(
+ "Merge selected M3U playlists into one Live TV and EPG source.",
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim
+ )
+ }
+ CompactSettingsActionChip(
+ label = "Create Combined",
+ accent = Primary,
+ onClick = onCreateProfile
+ )
+ }
+
+ if (profiles.isEmpty()) {
+ Text("No combined M3U sources yet.", style = MaterialTheme.typography.bodySmall, color = OnSurfaceDim)
+ } else {
+ LazyRow(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
+ items(profiles, key = { it.id }) { profile ->
+ val isActive = (activeLiveSource as? ActiveLiveSource.CombinedM3uSource)?.profileId == profile.id
+ ProviderChip(
+ title = profile.name,
+ subtitle = buildString {
+ append("${profile.members.count { it.enabled }}/${profile.members.size} playlist(s)")
+ if (isActive) append(" • Active")
+ if (profile.members.none { it.enabled }) append(" • Empty")
+ },
+ isSelected = selectedProfileId == profile.id,
+ isActive = isActive,
+ onClick = { onSelectProfile(profile.id) }
+ )
+ }
+ }
+
+ val selectedProfile = profiles.firstOrNull { it.id == selectedProfileId } ?: profiles.first()
+ Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
+ FlowRow(
+ horizontalArrangement = Arrangement.spacedBy(10.dp),
+ verticalArrangement = Arrangement.spacedBy(10.dp)
+ ) {
+ CompactSettingsActionChip(
+ label = "Use For Live TV",
+ accent = Primary,
+ onClick = { onActivateProfile(selectedProfile.id) }
+ )
+ CompactSettingsActionChip(
+ label = "Rename",
+ accent = OnBackground,
+ onClick = { onRenameProfile(selectedProfile.id) }
+ )
+ CompactSettingsActionChip(
+ label = "Add Playlist",
+ accent = OnBackground,
+ onClick = { onAddProvider(selectedProfile.id) }
+ )
+ CompactSettingsActionChip(
+ label = "Delete",
+ accent = ErrorColor,
+ onClick = { onDeleteProfile(selectedProfile.id) }
+ )
+ }
+
+ Text(
+ text = "${selectedProfile.members.count { it.enabled }} of ${selectedProfile.members.size} playlists enabled",
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim
+ )
+
+ if (selectedProfile.members.isEmpty()) {
+ Text(
+ text = "This combined source has no playlists yet. Add at least one M3U playlist before using it.",
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim
+ )
+ } else if (selectedProfile.members.none { it.enabled }) {
+ Text(
+ text = "All playlists in this combined source are disabled. Enable at least one to use it in Live TV.",
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim
+ )
+ }
+
+ selectedProfile.members
+ .sortedBy { it.priority }
+ .forEachIndexed { index, member ->
+ val providerName = member.providerName.ifBlank {
+ availableProviders.firstOrNull { it.id == member.providerId }?.name ?: "Playlist ${member.providerId}"
+ }
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Column(modifier = Modifier.weight(1f)) {
+ Text(providerName, style = MaterialTheme.typography.bodyMedium, color = OnSurface)
+ Text(
+ if (member.enabled) "Enabled in merged source" else "Disabled in merged source",
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim
+ )
+ }
+ Row(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalAlignment = Alignment.CenterVertically) {
+ CompactSettingsActionChip(
+ label = "Up",
+ accent = OnBackground,
+ enabled = index > 0,
+ onClick = { onMoveProvider(selectedProfile.id, member.providerId, true) }
+ )
+ CompactSettingsActionChip(
+ label = "Down",
+ accent = OnBackground,
+ enabled = index < selectedProfile.members.lastIndex,
+ onClick = { onMoveProvider(selectedProfile.id, member.providerId, false) }
+ )
+ Switch(
+ checked = member.enabled,
+ onCheckedChange = { onToggleProviderEnabled(selectedProfile.id, member.providerId, it) }
+ )
+ CompactSettingsActionChip(
+ label = "Remove",
+ accent = ErrorColor,
+ onClick = { onRemoveProvider(selectedProfile.id, member.providerId) }
+ )
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+@Composable
+internal fun RenameCombinedM3uDialog(
+ profile: CombinedM3uProfile,
+ onDismiss: () -> Unit,
+ onRename: (String) -> Unit
+) {
+ var name by rememberSaveable(profile.id) { mutableStateOf(profile.name) }
+
+ PremiumDialog(
+ title = "Rename Combined M3U",
+ subtitle = "Update the name shown in Live TV and provider settings.",
+ onDismissRequest = onDismiss,
+ widthFraction = 0.48f,
+ content = {
+ EpgSourceTextField(
+ value = name,
+ onValueChange = { updated -> name = updated },
+ placeholder = "Combined source name"
+ )
+ },
+ footer = {
+ PremiumDialogFooterButton(
+ label = stringResource(R.string.settings_cancel),
+ onClick = onDismiss
+ )
+ PremiumDialogFooterButton(
+ label = "Save",
+ onClick = { onRename(name.trim()) },
+ enabled = name.isNotBlank(),
+ emphasized = true
+ )
+ }
+ )
+}
+
+@Composable
+internal fun CreateCombinedM3uDialog(
+ providers: List<Provider>,
+ onDismiss: () -> Unit,
+ onCreate: (String, List<Long>) -> Unit
+) {
+ var name by rememberSaveable { mutableStateOf("") }
+ var selectedProviderIds by rememberSaveable { mutableStateOf(setOf<Long>()) }
+ val m3uProviders = remember(providers) { providers.filter { it.type == ProviderType.M3U } }
+ val effectiveName = remember(name, selectedProviderIds, m3uProviders) {
+ val manualName = name.trim()
+ if (manualName.isNotBlank()) {
+ manualName
+ } else {
+ val selectedProviders = m3uProviders.filter { it.id in selectedProviderIds }
+ when {
+ selectedProviders.isEmpty() -> ""
+ selectedProviders.size == 1 -> "${selectedProviders.first().name} Mix"
+ selectedProviders.size == 2 -> "${selectedProviders[0].name} + ${selectedProviders[1].name}"
+ else -> "${selectedProviders.first().name} + ${selectedProviders.size - 1} More"
+ }
+ }
+ }
+
+ PremiumDialog(
+ title = "Create Combined M3U",
+ subtitle = "Pick the M3U playlists you want to browse together in Live TV and guide.",
+ onDismissRequest = onDismiss,
+ widthFraction = 0.52f,
+ content = {
+ EpgSourceTextField(
+ value = name,
+ onValueChange = { updated -> name = updated },
+ placeholder = effectiveName.ifBlank { "Combined source name" }
+ )
+
+ if (m3uProviders.isEmpty()) {
+ Text(
+ text = "No M3U playlists are available yet. Add at least one playlist first.",
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim
+ )
+ } else {
+ Column(
+ modifier = Modifier
+ .fillMaxWidth()
+ .heightIn(max = 360.dp)
+ .verticalScroll(rememberScrollState()),
+ verticalArrangement = Arrangement.spacedBy(8.dp)
+ ) {
+ m3uProviders.forEach { provider ->
+ val isSelected = provider.id in selectedProviderIds
+ TvClickableSurface(
+ onClick = {
+ selectedProviderIds = if (isSelected) {
+ selectedProviderIds - provider.id
+ } else {
+ selectedProviderIds + provider.id
+ }
+ },
+ modifier = Modifier.fillMaxWidth(),
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(12.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = if (isSelected) Primary.copy(alpha = 0.16f) else Color.White.copy(alpha = 0.04f),
+ focusedContainerColor = Primary.copy(alpha = 0.24f)
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
+ ) {
+ Row(
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(horizontal = 14.dp, vertical = 12.dp),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Column(
+ modifier = Modifier.weight(1f),
+ verticalArrangement = Arrangement.spacedBy(2.dp)
+ ) {
+ Text(
+ text = provider.name,
+ style = MaterialTheme.typography.bodyMedium,
+ color = OnSurface
+ )
+ Text(
+ text = if (isSelected) "Included in this combined source" else "Press to include this playlist",
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim
+ )
+ }
+ Checkbox(
+ checked = isSelected,
+ onCheckedChange = null
+ )
+ }
+ }
+ }
+ }
+ }
+ },
+ footer = {
+ PremiumDialogFooterButton(
+ label = stringResource(R.string.settings_cancel),
+ onClick = onDismiss
+ )
+ PremiumDialogFooterButton(
+ label = "Create",
+ onClick = { onCreate(effectiveName, selectedProviderIds.toList()) },
+ enabled = selectedProviderIds.isNotEmpty() && effectiveName.isNotBlank(),
+ emphasized = true
+ )
+ }
+ )
+}
+
+@Composable
+internal fun AddCombinedProviderDialog(
+ profile: CombinedM3uProfile,
+ availableProviders: List<Provider>,
+ onDismiss: () -> Unit,
+ onAddProvider: (Long) -> Unit
+) {
+ val candidateProviders = remember(profile, availableProviders) {
+ availableProviders.filter { provider -> profile.members.none { it.providerId == provider.id } }
+ }
+ var selectedProviderId by rememberSaveable(profile.id) { mutableStateOf(candidateProviders.firstOrNull()?.id) }
+ PremiumDialog(
+ title = "Add Playlist To ${profile.name}",
+ subtitle = "Select another M3U playlist to include in this combined source.",
+ onDismissRequest = onDismiss,
+ widthFraction = 0.52f,
+ content = {
+ if (candidateProviders.isEmpty()) {
+ Text(
+ text = "All M3U playlists are already in this combined source.",
+ style = MaterialTheme.typography.bodyMedium,
+ color = OnSurfaceDim
+ )
+ } else {
+ Column(
+ modifier = Modifier
+ .fillMaxWidth()
+ .heightIn(max = 320.dp)
+ .verticalScroll(rememberScrollState()),
+ verticalArrangement = Arrangement.spacedBy(8.dp)
+ ) {
+ candidateProviders.forEach { provider ->
+ val isSelected = selectedProviderId == provider.id
+ TvClickableSurface(
+ onClick = { selectedProviderId = provider.id },
+ modifier = Modifier.fillMaxWidth(),
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(12.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = if (isSelected) Primary.copy(alpha = 0.16f) else Color.White.copy(alpha = 0.04f),
+ focusedContainerColor = Primary.copy(alpha = 0.22f)
+ ),
+ border = ClickableSurfaceDefaults.border(
+ border = Border(
+ border = BorderStroke(
+ 1.dp,
+ if (isSelected) Primary.copy(alpha = 0.4f) else Color.White.copy(alpha = 0.08f)
+ ),
+ shape = RoundedCornerShape(12.dp)
+ ),
+ focusedBorder = Border(
+ border = BorderStroke(FocusSpec.BorderWidth, Color.White),
+ shape = RoundedCornerShape(12.dp)
+ )
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
+ ) {
+ Row(
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(horizontal = 14.dp, vertical = 12.dp),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Text(
+ text = provider.name,
+ style = MaterialTheme.typography.bodyMedium,
+ color = OnSurface,
+ modifier = Modifier.weight(1f)
+ )
+ RadioButton(
+ selected = isSelected,
+ onClick = { selectedProviderId = provider.id }
+ )
+ }
+ }
+ }
+ }
+ }
+ },
+ footer = {
+ PremiumDialogFooterButton(
+ label = stringResource(R.string.settings_cancel),
+ onClick = onDismiss
+ )
+ PremiumDialogFooterButton(
+ label = "Add",
+ onClick = { selectedProviderId?.let(onAddProvider) },
+ enabled = selectedProviderId != null && candidateProviders.isNotEmpty(),
+ emphasized = true
+ )
+ }
+ )
+}
+
+@Composable
+private fun ProviderChip(
+ title: String,
+ subtitle: String,
+ isSelected: Boolean,
+ isActive: Boolean,
+ onClick: () -> Unit
+) {
+ TvClickableSurface(
+ onClick = onClick,
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(10.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = if (isSelected) Primary.copy(alpha = 0.16f) else Color.Transparent,
+ focusedContainerColor = Primary.copy(alpha = 0.24f)
+ )
+ ) {
+ Column(modifier = Modifier.padding(horizontal = 14.dp, vertical = 12.dp)) {
+ Text(title, style = MaterialTheme.typography.bodyMedium, color = OnSurface)
+ Text(
+ if (isActive) "$subtitle • Active" else subtitle,
+ style = MaterialTheme.typography.bodySmall,
+ color = if (isActive) Primary else OnSurfaceDim
+ )
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsContentPane.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsContentPane.kt
new file mode 100644
index 00000000..924aec56
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsContentPane.kt
@@ -0,0 +1,157 @@
+package com.streamvault.app.ui.screens.settings
+
+import android.content.Context
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.PaddingValues
+import androidx.compose.foundation.layout.fillMaxHeight
+import androidx.compose.foundation.layout.imePadding
+import androidx.compose.foundation.lazy.LazyColumn
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.unit.dp
+import com.streamvault.domain.model.Provider
+
+@Composable
+internal fun SettingsContentPane(
+ uiState: SettingsUiState,
+ viewModel: SettingsViewModel,
+ context: Context,
+ screenLabels: SettingsScreenLabels,
+ dialogState: SettingsScreenDialogState,
+ providerState: SettingsProviderSectionState,
+ onAddProvider: () -> Unit,
+ onEditProvider: (Provider) -> Unit,
+ onNavigateToParentalControl: (Long) -> Unit,
+ onChooseRecordingFolder: () -> Unit,
+ onCreateBackup: () -> Unit,
+ onRestoreBackup: () -> Unit,
+ onOpenUri: (String) -> Unit,
+ modifier: Modifier = Modifier
+) {
+ LazyColumn(
+ modifier = modifier
+ .fillMaxHeight()
+ .imePadding(),
+ contentPadding = PaddingValues(start = 20.dp, top = 76.dp, end = 20.dp, bottom = 32.dp),
+ verticalArrangement = Arrangement.spacedBy(10.dp),
+ userScrollEnabled = !uiState.isSyncing
+ ) {
+ if (dialogState.selectedCategory == 0) {
+ providerSection(
+ uiState = uiState,
+ onAddProvider = onAddProvider,
+ onEditProvider = onEditProvider,
+ onNavigateToParentalControl = onNavigateToParentalControl,
+ viewModel = viewModel,
+ providerState = providerState
+ )
+ } else if (dialogState.selectedCategory == 1) {
+ settingsPlaybackSection(
+ uiState = uiState,
+ viewModel = viewModel,
+ timeshiftDepthLabel = screenLabels.timeshiftDepthLabel,
+ decoderModeLabel = screenLabels.decoderModeLabel,
+ surfaceModeLabel = screenLabels.surfaceModeLabel,
+ playbackSpeedLabel = screenLabels.playbackSpeedLabel,
+ defaultStopTimerLabel = screenLabels.defaultStopTimerLabel,
+ defaultIdleTimerLabel = screenLabels.defaultIdleTimerLabel,
+ audioVideoOffsetLabel = screenLabels.audioVideoOffsetLabel,
+ controlsTimeoutLabel = screenLabels.controlsTimeoutLabel,
+ liveOverlayTimeoutLabel = screenLabels.liveOverlayTimeoutLabel,
+ noticeTimeoutLabel = screenLabels.noticeTimeoutLabel,
+ diagnosticsTimeoutLabel = screenLabels.diagnosticsTimeoutLabel,
+ preferredAudioLanguageLabel = screenLabels.preferredAudioLanguageLabel,
+ subtitleSizeLabel = screenLabels.subtitleSizeLabel,
+ subtitleTextColorLabel = screenLabels.subtitleTextColorLabel,
+ subtitleBackgroundLabel = screenLabels.subtitleBackgroundLabel,
+ wifiQualityLabel = screenLabels.wifiQualityLabel,
+ ethernetQualityLabel = screenLabels.ethernetQualityLabel,
+ lastSpeedTestLabel = screenLabels.lastSpeedTestLabel,
+ lastSpeedTestSummary = screenLabels.lastSpeedTestSummary,
+ speedTestRecommendationLabel = screenLabels.speedTestRecommendationLabel,
+ onShowTimeshiftDepthDialogChange = { dialogState.showTimeshiftDepthDialog = it },
+ onShowDecoderModeDialogChange = { dialogState.showDecoderModeDialog = it },
+ onShowSurfaceModeDialogChange = { dialogState.showSurfaceModeDialog = it },
+ onShowPlaybackSpeedDialogChange = { dialogState.showPlaybackSpeedDialog = it },
+ onShowDefaultStopTimerDialogChange = { dialogState.showDefaultStopTimerDialog = it },
+ onShowDefaultIdleTimerDialogChange = { dialogState.showDefaultIdleTimerDialog = it },
+ onShowAudioVideoOffsetDialogChange = { dialogState.showAudioVideoOffsetDialog = it },
+ onShowControlsTimeoutDialogChange = { dialogState.showControlsTimeoutDialog = it },
+ onShowLiveOverlayTimeoutDialogChange = { dialogState.showLiveOverlayTimeoutDialog = it },
+ onShowNoticeTimeoutDialogChange = { dialogState.showNoticeTimeoutDialog = it },
+ onShowDiagnosticsTimeoutDialogChange = { dialogState.showDiagnosticsTimeoutDialog = it },
+ onShowAudioLanguageDialogChange = { dialogState.showAudioLanguageDialog = it },
+ onShowSubtitleSizeDialogChange = { dialogState.showSubtitleSizeDialog = it },
+ onShowSubtitleTextColorDialogChange = { dialogState.showSubtitleTextColorDialog = it },
+ onShowSubtitleBackgroundDialogChange = { dialogState.showSubtitleBackgroundDialog = it },
+ onShowWifiQualityDialogChange = { dialogState.showWifiQualityDialog = it },
+ onShowEthernetQualityDialogChange = { dialogState.showEthernetQualityDialog = it }
+ )
+ } else if (dialogState.selectedCategory == 2) {
+ settingsBrowsingSection(
+ uiState = uiState,
+ viewModel = viewModel,
+ context = context,
+ guideDefaultCategoryLabel = screenLabels.guideDefaultCategoryLabel,
+ timeFormatLabel = screenLabels.timeFormatLabel,
+ appLanguageLabel = screenLabels.appLanguageLabel,
+ onShowLiveTvModeDialogChange = { dialogState.showLiveTvModeDialog = it },
+ onShowLiveTvFiltersDialogChange = { dialogState.showLiveTvFiltersDialog = it },
+ onShowLiveTvQuickFilterVisibilityDialogChange = { dialogState.showLiveTvQuickFilterVisibilityDialog = it },
+ onShowLiveChannelNumberingDialogChange = { dialogState.showLiveChannelNumberingDialog = it },
+ onShowLiveChannelGroupingDialogChange = { dialogState.showLiveChannelGroupingDialog = it },
+ onShowGroupedChannelLabelDialogChange = { dialogState.showGroupedChannelLabelDialog = it },
+ onShowLiveVariantPreferenceDialogChange = { dialogState.showLiveVariantPreferenceDialog = it },
+ onShowGuideDefaultCategoryDialogChange = { dialogState.showGuideDefaultCategoryDialog = it },
+ onShowTimeFormatDialogChange = { dialogState.showTimeFormatDialog = it },
+ onShowVodViewModeDialogChange = { dialogState.showVodViewModeDialog = it },
+ onCategorySortDialogTypeChange = { dialogState.categorySortDialogType = it },
+ onShowLanguageDialogChange = { dialogState.showLanguageDialog = it }
+ )
+ } else if (dialogState.selectedCategory == 3) {
+ settingsPrivacySection(
+ uiState = uiState,
+ viewModel = viewModel,
+ onPendingProtectionLevelChange = { dialogState.pendingProtectionLevel = it },
+ onPendingActionChange = { dialogState.pendingAction = it },
+ onShowPinDialogChange = { dialogState.showPinDialog = it },
+ onShowLevelDialogChange = { dialogState.showLevelDialog = it },
+ onShowClearHistoryDialogChange = { dialogState.showClearHistoryDialog = it }
+ )
+ } else if (dialogState.selectedCategory == 4) {
+ settingsRecordingSection(
+ uiState = uiState,
+ viewModel = viewModel,
+ onChooseFolder = onChooseRecordingFolder,
+ onShowRecordingPatternDialogChange = { dialogState.showRecordingPatternDialog = it },
+ onShowRecordingRetentionDialogChange = { dialogState.showRecordingRetentionDialog = it },
+ onShowRecordingConcurrencyDialogChange = { dialogState.showRecordingConcurrencyDialog = it },
+ onShowRecordingPaddingDialogChange = { dialogState.showRecordingPaddingDialog = it },
+ onShowRecordingBrowserDialogChange = { dialogState.showRecordingBrowserDialog = it }
+ )
+ } else if (dialogState.selectedCategory == 5) {
+ settingsBackupSection(
+ onCreateBackup = onCreateBackup,
+ onRestoreBackup = onRestoreBackup
+ )
+ } else if (dialogState.selectedCategory == 6) {
+ epgSourcesSection(
+ uiState = uiState,
+ viewModel = viewModel
+ )
+ } else if (dialogState.selectedCategory == 7) {
+ settingsAboutSection(
+ uiState = uiState,
+ context = context,
+ buildVerificationLabel = screenLabels.buildVerificationLabel,
+ onOpenUri = onOpenUri,
+ onCheckForUpdates = viewModel::checkForAppUpdates,
+ onInstallDownloadedUpdate = viewModel::installDownloadedUpdate,
+ onDownloadLatestUpdate = viewModel::downloadLatestUpdate,
+ onSetAutoCheckAppUpdates = viewModel::setAutoCheckAppUpdates,
+ onSetAutoDownloadAppUpdates = viewModel::setAutoDownloadAppUpdates,
+ onRefreshDownloadState = viewModel::refreshDownloadState
+ )
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsDerivedStateObservers.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsDerivedStateObservers.kt
new file mode 100644
index 00000000..1aa82276
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsDerivedStateObservers.kt
@@ -0,0 +1,196 @@
+@file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class)
+
+package com.streamvault.app.ui.screens.settings
+
+import android.app.Application
+import com.streamvault.app.R
+import com.streamvault.domain.model.Category
+import com.streamvault.domain.model.CategorySortMode
+import com.streamvault.domain.model.ContentType
+import com.streamvault.domain.model.Provider
+import com.streamvault.domain.model.ProviderType
+import com.streamvault.domain.model.VodSyncMode
+import com.streamvault.domain.repository.CategoryRepository
+import com.streamvault.domain.repository.ProviderRepository
+import com.streamvault.domain.repository.SyncMetadataRepository
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.combine
+import kotlinx.coroutines.flow.flatMapLatest
+import kotlinx.coroutines.flow.flowOf
+import kotlinx.coroutines.flow.map
+import java.text.SimpleDateFormat
+import java.util.Date
+import java.util.Locale
+
+internal fun observeProviderDiagnostics(
+ providerRepository: ProviderRepository,
+ syncMetadataRepository: SyncMetadataRepository,
+ application: Application
+): Flow<Map<Long, ProviderDiagnosticsUiModel>> {
+ return providerRepository.getProviders()
+ .flatMapLatest { providers ->
+ if (providers.isEmpty()) {
+ flowOf(emptyMap())
+ } else {
+ combine(
+ providers.map { provider ->
+ syncMetadataRepository.observeMetadata(provider.id).map { metadata ->
+ provider.id to ProviderDiagnosticsUiModel(
+ lastSyncStatus = metadata?.lastSyncStatus ?: "NONE",
+ lastLiveSync = metadata?.lastLiveSync ?: 0L,
+ lastMovieSync = metadata?.lastMovieSync ?: 0L,
+ lastMovieAttempt = metadata?.lastMovieAttempt ?: 0L,
+ lastMovieSuccess = metadata?.lastMovieSuccess ?: 0L,
+ lastMoviePartial = metadata?.lastMoviePartial ?: 0L,
+ lastSeriesSync = metadata?.lastSeriesSync ?: 0L,
+ lastEpgSync = metadata?.lastEpgSync ?: 0L,
+ liveCount = metadata?.liveCount ?: 0,
+ movieCount = metadata?.movieCount ?: 0,
+ seriesCount = metadata?.seriesCount ?: 0,
+ epgCount = metadata?.epgCount ?: 0,
+ movieSyncMode = metadata?.movieSyncMode ?: VodSyncMode.UNKNOWN,
+ movieWarningsCount = metadata?.movieWarningsCount ?: 0,
+ movieCatalogStale = metadata?.movieCatalogStale ?: false,
+ liveSequentialFailuresRemembered = metadata?.liveSequentialFailuresRemembered ?: false,
+ liveHealthySyncStreak = metadata?.liveHealthySyncStreak ?: 0,
+ movieParallelFailuresRemembered = metadata?.movieParallelFailuresRemembered ?: false,
+ movieHealthySyncStreak = metadata?.movieHealthySyncStreak ?: 0,
+ seriesSequentialFailuresRemembered = metadata?.seriesSequentialFailuresRemembered ?: false,
+ seriesHealthySyncStreak = metadata?.seriesHealthySyncStreak ?: 0,
+ capabilitySummary = buildCapabilitySummary(application, provider),
+ sourceLabel = provider.sourceLabel(),
+ expirySummary = provider.expirySummary(),
+ connectionSummary = "${provider.maxConnections} connection(s)",
+ archiveSummary = provider.archiveSummary()
+ )
+ }
+ }
+ ) { pairs ->
+ pairs.toMap()
+ }
+ }
+ }
+}
+
+internal fun observeCategoryManagement(
+ activeProviderIdFlow: Flow<Long?>,
+ preferencesRepository: com.streamvault.data.preferences.PreferencesRepository,
+ categoryRepository: CategoryRepository
+): Flow<CategoryManagementSnapshot> {
+ return activeProviderIdFlow.flatMapLatest { providerId ->
+ if (providerId == null) {
+ flowOf(CategoryManagementSnapshot())
+ } else {
+ combine(
+ observeCategorySortModes(providerId, preferencesRepository),
+ categoryRepository.getCategories(providerId),
+ observeHiddenCategoryIdsByType(providerId, preferencesRepository)
+ ) { sortModes, categories, hiddenByType ->
+ CategoryManagementSnapshot(
+ categorySortModes = sortModes,
+ hiddenCategories = categories
+ .filter { category -> category.id in hiddenByType[category.type].orEmpty() }
+ .sortedWith(compareBy<Category>({ it.type.ordinal }, { it.name.lowercase() }))
+ )
+ }
+ }
+ }
+}
+
+private fun observeCategorySortModes(
+ providerId: Long,
+ preferencesRepository: com.streamvault.data.preferences.PreferencesRepository
+): Flow<Map<ContentType, CategorySortMode>> {
+ return combine(
+ preferencesRepository.getCategorySortMode(providerId, ContentType.LIVE),
+ preferencesRepository.getCategorySortMode(providerId, ContentType.MOVIE),
+ preferencesRepository.getCategorySortMode(providerId, ContentType.SERIES)
+ ) { liveSort, movieSort, seriesSort ->
+ mapOf(
+ ContentType.LIVE to liveSort,
+ ContentType.MOVIE to movieSort,
+ ContentType.SERIES to seriesSort
+ )
+ }
+}
+
+private fun observeHiddenCategoryIdsByType(
+ providerId: Long,
+ preferencesRepository: com.streamvault.data.preferences.PreferencesRepository
+): Flow<Map<ContentType, Set<Long>>> {
+ return combine(
+ preferencesRepository.getHiddenCategoryIds(providerId, ContentType.LIVE),
+ preferencesRepository.getHiddenCategoryIds(providerId, ContentType.MOVIE),
+ preferencesRepository.getHiddenCategoryIds(providerId, ContentType.SERIES)
+ ) { hiddenLive, hiddenMovies, hiddenSeries ->
+ mapOf(
+ ContentType.LIVE to hiddenLive,
+ ContentType.MOVIE to hiddenMovies,
+ ContentType.SERIES to hiddenSeries
+ )
+ }
+}
+
+private fun buildCapabilitySummary(application: Application, provider: Provider): String {
+ return when (provider.type) {
+ ProviderType.XTREAM_CODES -> {
+ if (provider.epgUrl.isNotBlank()) {
+ application.getString(R.string.settings_capability_xtream_with_epg)
+ } else {
+ application.getString(R.string.settings_capability_xtream_without_epg)
+ }
+ }
+ ProviderType.M3U -> {
+ if (provider.epgUrl.isNotBlank()) {
+ application.getString(R.string.settings_capability_m3u_with_epg)
+ } else {
+ application.getString(R.string.settings_capability_m3u_without_epg)
+ }
+ }
+ ProviderType.STALKER_PORTAL -> {
+ if (provider.epgUrl.isNotBlank()) {
+ "Portal catalog with MAC auth, XMLTV import, and on-demand playback link resolution."
+ } else {
+ "Portal catalog with MAC auth and on-demand guide/playback resolution."
+ }
+ }
+ }
+}
+
+private fun Provider.sourceLabel(): String = when (type) {
+ ProviderType.XTREAM_CODES -> "Xtream Codes"
+ ProviderType.M3U -> "M3U Playlist"
+ ProviderType.STALKER_PORTAL -> "Stalker/MAG Portal"
+}
+
+private fun Provider.expirySummary(): String {
+ val expirationDate = expirationDate
+ return when {
+ expirationDate == null -> "Expiry unknown"
+ expirationDate == Long.MAX_VALUE -> "No expiry reported"
+ expirationDate < System.currentTimeMillis() -> "Expired"
+ else -> {
+ val formatter = SimpleDateFormat("d MMM yyyy", Locale.getDefault())
+ "Active until ${formatter.format(Date(expirationDate))}"
+ }
+ }
+}
+
+private fun Provider.archiveSummary(): String = when (type) {
+ ProviderType.XTREAM_CODES -> "Catch-up depends on provider archive flags and replay stream ids."
+ ProviderType.M3U -> {
+ if (epgUrl.isBlank()) {
+ "M3U replay is limited without guide coverage."
+ } else {
+ "M3U replay depends on channel templates and guide alignment."
+ }
+ }
+ ProviderType.STALKER_PORTAL -> {
+ if (epgUrl.isBlank()) {
+ "Stalker replay depends on portal support; guide falls back to portal data."
+ } else {
+ "Stalker replay depends on portal support with optional XMLTV coverage."
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsDialogComponents.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsDialogComponents.kt
deleted file mode 100644
index 883944f9..00000000
--- a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsDialogComponents.kt
+++ /dev/null
@@ -1,1730 +0,0 @@
-package com.streamvault.app.ui.screens.settings
-
-import androidx.compose.foundation.BorderStroke
-import androidx.compose.foundation.background
-import androidx.compose.foundation.border
-import androidx.compose.foundation.clickable
-import androidx.compose.foundation.layout.*
-import androidx.compose.foundation.lazy.LazyColumn
-import androidx.compose.foundation.lazy.items
-import androidx.compose.foundation.rememberScrollState
-import androidx.compose.foundation.shape.RoundedCornerShape
-import androidx.compose.foundation.verticalScroll
-import androidx.compose.foundation.text.BasicTextField
-import androidx.compose.foundation.text.KeyboardActions
-import androidx.compose.foundation.text.KeyboardOptions
-import androidx.compose.material3.HorizontalDivider
-import androidx.compose.material3.RadioButton
-import androidx.compose.material3.Switch
-import androidx.compose.runtime.*
-import androidx.compose.runtime.saveable.rememberSaveable
-import androidx.compose.ui.Alignment
-import androidx.compose.ui.Modifier
-import androidx.compose.ui.focus.FocusRequester
-import androidx.compose.ui.focus.focusProperties
-import androidx.compose.ui.focus.focusRequester
-import androidx.compose.ui.focus.onFocusChanged
-import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.graphics.SolidColor
-import androidx.compose.ui.input.key.onPreviewKeyEvent
-import androidx.compose.ui.platform.LocalSoftwareKeyboardController
-import androidx.compose.ui.res.stringResource
-import androidx.compose.ui.text.TextRange
-import androidx.compose.ui.text.font.FontWeight
-import androidx.compose.ui.text.input.ImeAction
-import androidx.compose.ui.text.input.KeyboardType
-import androidx.compose.ui.text.input.TextFieldValue
-import androidx.compose.ui.text.style.TextOverflow
-import androidx.compose.ui.unit.dp
-import androidx.compose.ui.window.Dialog
-import androidx.tv.material3.*
-import com.streamvault.app.R
-import com.streamvault.app.localization.localeForLanguageTag
-import com.streamvault.app.localization.supportedAppLanguageTags
-import com.streamvault.app.ui.components.dialogs.PremiumDialog
-import com.streamvault.app.ui.components.dialogs.PremiumDialogActionButton
-import com.streamvault.app.ui.components.dialogs.PremiumDialogFooterButton
-import com.streamvault.app.ui.components.dialogs.rememberDialogOpenGestureBlocker
-import com.streamvault.app.ui.design.FocusSpec
-import com.streamvault.app.ui.interaction.TvButton
-import com.streamvault.app.ui.interaction.TvClickableSurface
-import com.streamvault.app.ui.interaction.mouseClickable
-import com.streamvault.app.ui.model.LiveTvChannelMode
-import com.streamvault.app.ui.model.LiveTvQuickFilterVisibilityMode
-import com.streamvault.app.ui.model.VodViewMode
-import com.streamvault.app.ui.theme.*
-import com.streamvault.domain.model.CategorySortMode
-import com.streamvault.domain.model.ChannelNumberingMode
-import com.streamvault.domain.model.ContentType
-import com.streamvault.domain.model.DecoderMode
-import com.streamvault.domain.model.GroupedChannelLabelMode
-import com.streamvault.domain.model.LiveChannelGroupingMode
-import com.streamvault.domain.model.LiveVariantPreferenceMode
-import com.streamvault.domain.model.RecordingFailureCategory
-import com.streamvault.domain.model.RecordingItem
-import com.streamvault.domain.model.RecordingSourceType
-import kotlinx.coroutines.launch
-import java.text.DateFormat
-import java.util.Locale
-
-internal enum class ParentalAction {
- ChangeLevel, ChangePin, SetNewPin
-}
-
-@Composable
-internal fun PremiumSelectionDialog(
- title: String,
- onDismiss: () -> Unit,
- content: @Composable ColumnScope.() -> Unit
-) {
- val isTelevisionDevice = com.streamvault.app.device.rememberIsTelevisionDevice()
- var canInteract by remember { mutableStateOf(false) }
- val blockOpenGesture = rememberDialogOpenGestureBlocker(canInteract)
- LaunchedEffect(Unit) {
- kotlinx.coroutines.delay(500)
- canInteract = true
- }
- Dialog(onDismissRequest = { if (canInteract) onDismiss() }) {
- val dialogContent: @Composable (Modifier) -> Unit = { resolvedModifier ->
- androidx.compose.material3.Surface(
- shape = RoundedCornerShape(14.dp),
- color = SurfaceElevated,
- modifier = resolvedModifier
- .border(1.dp, Primary.copy(alpha = 0.4f), RoundedCornerShape(14.dp))
- .onPreviewKeyEvent(blockOpenGesture)
- ) {
- Column(
- modifier = Modifier.padding(18.dp),
- verticalArrangement = Arrangement.spacedBy(8.dp)
- ) {
- Text(
- text = title,
- style = MaterialTheme.typography.titleMedium,
- color = Primary
- )
- HorizontalDivider(color = Color.White.copy(alpha = 0.1f))
- Column(
- verticalArrangement = Arrangement.spacedBy(6.dp),
- modifier = Modifier
- .padding(top = 6.dp)
- .weight(1f, fill = false)
- .verticalScroll(rememberScrollState())
- ) {
- content()
- }
- Row(
- modifier = Modifier.fillMaxWidth().padding(top = 8.dp),
- horizontalArrangement = Arrangement.End
- ) {
- TvClickableSurface(
- onClick = { if (canInteract) onDismiss() },
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(6.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Primary.copy(alpha = 0.2f),
- focusedContainerColor = Primary.copy(alpha = 0.4f)
- )
- ) {
- Text(
- text = stringResource(R.string.settings_cancel),
- style = MaterialTheme.typography.labelMedium,
- color = Primary,
- modifier = Modifier.padding(horizontal = 14.dp, vertical = 9.dp)
- )
- }
- }
- }
- }
- }
-
- if (isTelevisionDevice) {
- dialogContent(Modifier.fillMaxWidth(0.62f))
- } else {
- BoxWithConstraints(
- modifier = Modifier.fillMaxWidth(),
- contentAlignment = Alignment.Center
- ) {
- val dialogWidthFraction = when {
- maxWidth < 700.dp -> 0.92f
- maxWidth < 1000.dp -> 0.78f
- else -> 0.62f
- }
- dialogContent(Modifier.fillMaxWidth(dialogWidthFraction))
- }
- }
- }
-}
-
-@Composable
-internal fun TimeoutValueDialog(
- title: String,
- subtitle: String,
- initialValue: Int,
- onDismiss: () -> Unit,
- onConfirm: (Int) -> Unit
-) {
- var value by rememberSaveable(initialValue) { mutableStateOf(initialValue.toString()) }
- val parsedValue = value.toIntOrNull()
- val isValid = parsedValue != null && parsedValue in 2..60
-
- PremiumDialog(
- title = title,
- subtitle = subtitle,
- onDismissRequest = onDismiss,
- widthFraction = 0.42f,
- content = {
- Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {
- Text(
- text = stringResource(R.string.settings_timeout_seconds_label),
- style = MaterialTheme.typography.bodyMedium,
- color = OnSurface
- )
- NumericSettingsTextField(
- value = value,
- onValueChange = { updated -> value = updated.filter(Char::isDigit).take(2) },
- placeholder = stringResource(R.string.settings_timeout_seconds_placeholder)
- )
- Text(
- text = if (isValid) {
- formatTimeoutSecondsLabel(parsedValue ?: initialValue, androidx.compose.ui.platform.LocalContext.current)
- } else {
- stringResource(R.string.settings_timeout_validation)
- },
- style = MaterialTheme.typography.bodySmall,
- color = if (isValid) OnSurfaceDim else Color(0xFFFF8A80)
- )
- }
- },
- footer = {
- Row(
- modifier = Modifier.fillMaxWidth(),
- horizontalArrangement = Arrangement.spacedBy(12.dp, Alignment.End)
- ) {
- PremiumDialogFooterButton(
- label = stringResource(R.string.settings_cancel),
- onClick = onDismiss
- )
- PremiumDialogFooterButton(
- label = stringResource(R.string.settings_timeout_apply),
- onClick = { parsedValue?.let(onConfirm) },
- enabled = isValid
- )
- }
- }
- )
-}
-
-@Composable
-internal fun LevelOption(
- level: Int,
- text: String,
- currentLevel: Int,
- subtitle: String? = null,
- onSelect: () -> Unit
-) {
- Row(
- modifier = Modifier
- .fillMaxWidth()
- .clickable(onClick = onSelect)
- .padding(vertical = 12.dp),
- verticalAlignment = Alignment.CenterVertically
- ) {
- RadioButton(
- selected = level == currentLevel,
- onClick = onSelect
- )
- Spacer(modifier = Modifier.width(8.dp))
- if (subtitle != null) {
- Column(verticalArrangement = Arrangement.spacedBy(2.dp)) {
- Text(text, style = MaterialTheme.typography.titleSmall, color = OnBackground)
- Text(subtitle, style = MaterialTheme.typography.bodySmall, color = OnSurfaceDim)
- }
- } else {
- Text(text, style = MaterialTheme.typography.bodyMedium, color = OnBackground)
- }
- }
-}
-
-@Composable
-private fun NumericSettingsTextField(
- value: String,
- onValueChange: (String) -> Unit,
- placeholder: String
-) {
- val isTelevisionDevice = com.streamvault.app.device.rememberIsTelevisionDevice()
- val focusRequester = remember { FocusRequester() }
- val keyboardController = LocalSoftwareKeyboardController.current
- var hasContainerFocus by remember { mutableStateOf(false) }
- var hasInputFocus by remember { mutableStateOf(false) }
- var acceptsInput by remember(isTelevisionDevice) { mutableStateOf(!isTelevisionDevice) }
- var pendingInputActivation by remember { mutableStateOf(false) }
- var fieldValue by remember {
- mutableStateOf(TextFieldValue(text = value, selection = TextRange(value.length)))
- }
- val isFocused = hasContainerFocus || hasInputFocus
-
- LaunchedEffect(value) {
- if (value != fieldValue.text) {
- fieldValue = TextFieldValue(text = value, selection = TextRange(value.length))
- }
- }
-
- LaunchedEffect(acceptsInput, pendingInputActivation) {
- if (!isTelevisionDevice || !acceptsInput || !pendingInputActivation) return@LaunchedEffect
- focusRequester.requestFocus()
- keyboardController?.show()
- pendingInputActivation = false
- }
-
- TvClickableSurface(
- onClick = {
- if (!isTelevisionDevice) {
- focusRequester.requestFocus()
- keyboardController?.show()
- return@TvClickableSurface
- }
- acceptsInput = true
- pendingInputActivation = true
- },
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Color.White.copy(alpha = 0.08f),
- focusedContainerColor = Color.White.copy(alpha = 0.12f)
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
- modifier = Modifier
- .fillMaxWidth()
- .onFocusChanged { hasContainerFocus = it.isFocused }
- ) {
- Box(modifier = Modifier.padding(horizontal = 12.dp, vertical = 10.dp)) {
- if (value.isEmpty() && !isFocused) {
- Text(placeholder, style = MaterialTheme.typography.bodyMedium, color = OnSurfaceDim)
- }
- BasicTextField(
- value = fieldValue,
- onValueChange = { updatedValue ->
- val digitsOnly = updatedValue.text.filter(Char::isDigit).take(2)
- fieldValue = updatedValue.copy(
- text = digitsOnly,
- selection = TextRange(digitsOnly.length.coerceAtMost(digitsOnly.length))
- )
- if (digitsOnly != value) {
- onValueChange(digitsOnly)
- }
- },
- textStyle = MaterialTheme.typography.bodyMedium.copy(color = Color.White),
- singleLine = true,
- cursorBrush = SolidColor(Primary),
- keyboardOptions = KeyboardOptions(
- keyboardType = KeyboardType.Number,
- imeAction = ImeAction.Done
- ),
- keyboardActions = KeyboardActions(onDone = { keyboardController?.hide() }),
- modifier = Modifier
- .fillMaxWidth()
- .focusRequester(focusRequester)
- .focusProperties {
- canFocus = !isTelevisionDevice || acceptsInput
- if (isTelevisionDevice && acceptsInput) {
- left = FocusRequester.Cancel
- right = FocusRequester.Cancel
- }
- }
- .onFocusChanged {
- hasInputFocus = it.isFocused
- if (!it.isFocused) {
- if (isTelevisionDevice) {
- acceptsInput = false
- }
- keyboardController?.hide()
- }
- },
- readOnly = isTelevisionDevice && !acceptsInput
- )
- }
- }
-}
-
-@Composable
-internal fun QualityCapSelectionDialog(
- title: String,
- currentValue: Int?,
- onDismiss: () -> Unit,
- onSelect: (Int?) -> Unit
-) {
- val context = androidx.compose.ui.platform.LocalContext.current
- val options = remember(context) {
- listOf<Int?>(null, 2160, 1080, 720, 480)
- }
- PremiumSelectionDialog(
- title = title,
- onDismiss = onDismiss
- ) {
- options.forEachIndexed { index, option ->
- LevelOption(
- level = index,
- text = formatQualityCapLabel(option, context.getString(R.string.settings_quality_cap_auto)),
- currentLevel = if (option == currentValue) index else -1,
- onSelect = { onSelect(option) }
- )
- }
- }
-}
-
-@Composable
-internal fun CategorySortModeDialog(
- type: ContentType,
- currentMode: CategorySortMode,
- onDismiss: () -> Unit,
- onModeSelected: (CategorySortMode) -> Unit
-) {
- val context = androidx.compose.ui.platform.LocalContext.current
- PremiumDialog(
- title = categoryTypeLabel(type, context),
- subtitle = categoryTypeDescription(type, context),
- onDismissRequest = onDismiss,
- widthFraction = 0.52f,
- content = {
- Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
- CategorySortMode.entries.forEach { mode ->
- TvClickableSurface(
- onClick = { onModeSelected(mode) },
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(14.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = if (mode == currentMode) Primary.copy(alpha = 0.18f) else SurfaceElevated,
- focusedContainerColor = Primary.copy(alpha = 0.28f)
- ),
- modifier = Modifier.fillMaxWidth()
- ) {
- Column(
- modifier = Modifier.padding(horizontal = 16.dp, vertical = 14.dp),
- verticalArrangement = Arrangement.spacedBy(4.dp)
- ) {
- Text(
- text = formatCategorySortModeLabel(mode, context),
- style = MaterialTheme.typography.titleSmall,
- color = if (mode == currentMode) Primary else OnBackground
- )
- Text(
- text = sortModeLabel(mode, context),
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim
- )
- }
- }
- }
- }
- },
- footer = {
- PremiumDialogFooterButton(
- label = stringResource(R.string.settings_cancel),
- onClick = onDismiss
- )
- }
- )
-}
-
-@Composable
-internal fun ParentalControlCard(
- level: Int,
- hasParentalPin: Boolean,
- hasActiveProvider: Boolean,
- onChangeLevel: () -> Unit,
- onChangePin: () -> Unit
-) {
- Column(
- modifier = Modifier
- .fillMaxWidth()
- .background(SurfaceElevated, RoundedCornerShape(8.dp))
- .padding(16.dp),
- verticalArrangement = Arrangement.spacedBy(16.dp)
- ) {
- Row(
- modifier = Modifier.fillMaxWidth(),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically
- ) {
- Column {
- Text(stringResource(R.string.settings_protection_level), style = MaterialTheme.typography.bodyLarge, color = OnBackground)
- Text(
- text = when(level) {
- 0 -> stringResource(R.string.settings_level_off)
- 1 -> stringResource(R.string.settings_level_locked)
- 2 -> stringResource(R.string.settings_level_private)
- 3 -> stringResource(R.string.settings_level_hidden)
- else -> stringResource(R.string.settings_level_unknown)
- },
- style = MaterialTheme.typography.bodyMedium,
- color = if (level == 0) ErrorColor else Primary
- )
- }
-
- // Custom Focusable Button for "Change"
- TvClickableSurface(
- onClick = onChangeLevel,
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(6.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Secondary.copy(alpha = 0.2f),
- focusedContainerColor = Secondary.copy(alpha = 0.5f),
- contentColor = Secondary,
- focusedContentColor = Secondary
- )
- ) {
- Text(
- text = stringResource(R.string.settings_change),
- style = MaterialTheme.typography.labelMedium,
- modifier = Modifier.padding(horizontal = 16.dp, vertical = 10.dp)
- )
- }
- }
-
- HorizontalDivider(color = Color.White.copy(alpha = 0.1f))
-
- Row(
- modifier = Modifier.fillMaxWidth(),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically
- ) {
- Text(stringResource(R.string.settings_parental_pin), style = MaterialTheme.typography.bodyLarge, color = OnBackground)
-
- // Custom Focusable Button for "Change PIN"
- TvClickableSurface(
- onClick = onChangePin,
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(6.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Primary.copy(alpha = 0.2f),
- focusedContainerColor = Primary.copy(alpha = 0.5f),
- contentColor = Primary,
- focusedContentColor = Primary
- )
- ) {
- Text(
- text = stringResource(if (hasParentalPin) R.string.settings_change_pin else R.string.settings_set_pin),
- style = MaterialTheme.typography.labelMedium,
- modifier = Modifier.padding(horizontal = 16.dp, vertical = 10.dp)
- )
- }
- }
- }
-}
-
-@Composable
-internal fun LiveTvChannelModeDialog(
- selectedMode: LiveTvChannelMode,
- onDismiss: () -> Unit,
- onModeSelected: (LiveTvChannelMode) -> Unit
-) {
- PremiumDialog(
- title = stringResource(R.string.settings_live_tv_channel_mode),
- subtitle = stringResource(R.string.settings_live_tv_channel_mode_subtitle),
- onDismissRequest = onDismiss,
- widthFraction = 0.52f,
- content = {
- Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
- LiveTvChannelMode.entries.forEach { mode ->
- TvClickableSurface(
- onClick = { onModeSelected(mode) },
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(14.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = if (mode == selectedMode) Primary.copy(alpha = 0.18f) else SurfaceElevated,
- focusedContainerColor = Primary.copy(alpha = 0.28f)
- ),
- modifier = Modifier.fillMaxWidth()
- ) {
- Column(
- modifier = Modifier.padding(horizontal = 16.dp, vertical = 14.dp),
- verticalArrangement = Arrangement.spacedBy(4.dp)
- ) {
- Text(
- text = stringResource(mode.labelResId()),
- style = MaterialTheme.typography.titleSmall,
- color = if (mode == selectedMode) Primary else OnBackground
- )
- Text(
- text = stringResource(mode.descriptionResId()),
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim
- )
- }
- }
- }
- }
- },
- footer = {
- PremiumDialogFooterButton(
- label = stringResource(R.string.settings_cancel),
- onClick = onDismiss
- )
- }
- )
-}
-
-@Composable
-internal fun LiveTvQuickFilterVisibilityDialog(
- selectedMode: LiveTvQuickFilterVisibilityMode,
- onDismiss: () -> Unit,
- onModeSelected: (LiveTvQuickFilterVisibilityMode) -> Unit
-) {
- PremiumDialog(
- title = stringResource(R.string.settings_live_tv_quick_filter_visibility),
- subtitle = stringResource(R.string.settings_live_tv_quick_filter_visibility_subtitle),
- onDismissRequest = onDismiss,
- widthFraction = 0.52f,
- content = {
- Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
- LiveTvQuickFilterVisibilityMode.entries.forEach { mode ->
- TvClickableSurface(
- onClick = { onModeSelected(mode) },
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(14.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = if (mode == selectedMode) Primary.copy(alpha = 0.18f) else SurfaceElevated,
- focusedContainerColor = Primary.copy(alpha = 0.28f)
- ),
- modifier = Modifier.fillMaxWidth()
- ) {
- Column(
- modifier = Modifier.padding(horizontal = 16.dp, vertical = 14.dp),
- verticalArrangement = Arrangement.spacedBy(4.dp)
- ) {
- Text(
- text = stringResource(mode.labelResId()),
- style = MaterialTheme.typography.titleSmall,
- color = if (mode == selectedMode) Primary else OnBackground
- )
- Text(
- text = stringResource(mode.descriptionResId()),
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim
- )
- }
- }
- }
- }
- },
- footer = {
- PremiumDialogFooterButton(
- label = stringResource(R.string.settings_cancel),
- onClick = onDismiss
- )
- }
- )
-}
-
-@Composable
-internal fun SettingsSectionHeader(
- title: String,
- subtitle: String
-) {
- Column(
- modifier = Modifier.fillMaxWidth(),
- verticalArrangement = Arrangement.spacedBy(4.dp)
- ) {
- Text(
- text = title,
- style = MaterialTheme.typography.titleMedium,
- color = Primary
- )
- Text(
- text = subtitle,
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim
- )
- }
-}
-
-@Composable
-internal fun VodViewModeDialog(
- selectedMode: VodViewMode,
- onDismiss: () -> Unit,
- onModeSelected: (VodViewMode) -> Unit
-) {
- PremiumDialog(
- title = stringResource(R.string.settings_vod_view_mode),
- subtitle = stringResource(R.string.settings_vod_view_mode_subtitle),
- onDismissRequest = onDismiss,
- widthFraction = 0.52f,
- content = {
- Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
- VodViewMode.entries.forEach { mode ->
- TvClickableSurface(
- onClick = { onModeSelected(mode) },
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(14.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = if (mode == selectedMode) Primary.copy(alpha = 0.18f) else SurfaceElevated,
- focusedContainerColor = Primary.copy(alpha = 0.28f)
- ),
- modifier = Modifier.fillMaxWidth()
- ) {
- Column(
- modifier = Modifier.padding(horizontal = 16.dp, vertical = 14.dp),
- verticalArrangement = Arrangement.spacedBy(4.dp)
- ) {
- Text(
- text = stringResource(mode.labelResId()),
- style = MaterialTheme.typography.titleSmall,
- color = if (mode == selectedMode) Primary else OnBackground
- )
- Text(
- text = stringResource(mode.descriptionResId()),
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim
- )
- }
- }
- }
- }
- },
- footer = {
- PremiumDialogFooterButton(
- label = stringResource(R.string.settings_cancel),
- onClick = onDismiss
- )
- }
- )
-}
-
-@Composable
-internal fun LiveChannelNumberingModeDialog(
- selectedMode: ChannelNumberingMode,
- onDismiss: () -> Unit,
- onModeSelected: (ChannelNumberingMode) -> Unit
-) {
- PremiumDialog(
- title = stringResource(R.string.settings_live_channel_numbering_mode),
- subtitle = stringResource(R.string.settings_live_channel_numbering_mode_subtitle),
- onDismissRequest = onDismiss,
- widthFraction = 0.52f,
- content = {
- Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
- ChannelNumberingMode.entries.forEach { mode ->
- TvClickableSurface(
- onClick = { onModeSelected(mode) },
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(14.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = if (mode == selectedMode) Primary.copy(alpha = 0.18f) else SurfaceElevated,
- focusedContainerColor = Primary.copy(alpha = 0.28f)
- ),
- modifier = Modifier.fillMaxWidth()
- ) {
- Column(
- modifier = Modifier.padding(horizontal = 16.dp, vertical = 14.dp),
- verticalArrangement = Arrangement.spacedBy(4.dp)
- ) {
- Text(
- text = stringResource(mode.labelResId()),
- style = MaterialTheme.typography.titleSmall,
- color = if (mode == selectedMode) Primary else OnBackground
- )
- Text(
- text = stringResource(mode.descriptionResId()),
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim
- )
- }
- }
- }
- }
- },
- footer = {
- PremiumDialogFooterButton(
- label = stringResource(R.string.settings_cancel),
- onClick = onDismiss
- )
- }
- )
-}
-
-@Composable
-internal fun LiveChannelGroupingModeDialog(
- selectedMode: LiveChannelGroupingMode,
- onDismiss: () -> Unit,
- onModeSelected: (LiveChannelGroupingMode) -> Unit
-) {
- PremiumDialog(
- title = stringResource(R.string.settings_live_channel_grouping_mode),
- subtitle = stringResource(R.string.settings_live_channel_grouping_mode_subtitle),
- onDismissRequest = onDismiss,
- widthFraction = 0.52f,
- content = {
- Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
- LiveChannelGroupingMode.entries.forEach { mode ->
- TvClickableSurface(
- onClick = { onModeSelected(mode) },
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(14.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = if (mode == selectedMode) Primary.copy(alpha = 0.18f) else SurfaceElevated,
- focusedContainerColor = Primary.copy(alpha = 0.28f)
- ),
- modifier = Modifier.fillMaxWidth()
- ) {
- Column(
- modifier = Modifier.padding(horizontal = 16.dp, vertical = 14.dp),
- verticalArrangement = Arrangement.spacedBy(4.dp)
- ) {
- Text(
- text = stringResource(mode.labelResId()),
- style = MaterialTheme.typography.titleSmall,
- color = if (mode == selectedMode) Primary else OnBackground
- )
- Text(
- text = stringResource(mode.descriptionResId()),
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim
- )
- }
- }
- }
- }
- },
- footer = {
- PremiumDialogFooterButton(
- label = stringResource(R.string.settings_cancel),
- onClick = onDismiss
- )
- }
- )
-}
-
-@Composable
-internal fun GroupedChannelLabelModeDialog(
- selectedMode: GroupedChannelLabelMode,
- onDismiss: () -> Unit,
- onModeSelected: (GroupedChannelLabelMode) -> Unit
-) {
- PremiumDialog(
- title = stringResource(R.string.settings_grouped_channel_label_mode),
- subtitle = stringResource(R.string.settings_grouped_channel_label_mode_subtitle),
- onDismissRequest = onDismiss,
- widthFraction = 0.52f,
- content = {
- Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
- GroupedChannelLabelMode.entries.forEach { mode ->
- TvClickableSurface(
- onClick = { onModeSelected(mode) },
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(14.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = if (mode == selectedMode) Primary.copy(alpha = 0.18f) else SurfaceElevated,
- focusedContainerColor = Primary.copy(alpha = 0.28f)
- ),
- modifier = Modifier.fillMaxWidth()
- ) {
- Column(
- modifier = Modifier.padding(horizontal = 16.dp, vertical = 14.dp),
- verticalArrangement = Arrangement.spacedBy(4.dp)
- ) {
- Text(
- text = stringResource(mode.labelResId()),
- style = MaterialTheme.typography.titleSmall,
- color = if (mode == selectedMode) Primary else OnBackground
- )
- Text(
- text = stringResource(mode.descriptionResId()),
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim
- )
- }
- }
- }
- }
- },
- footer = {
- PremiumDialogFooterButton(
- label = stringResource(R.string.settings_cancel),
- onClick = onDismiss
- )
- }
- )
-}
-
-@Composable
-internal fun LiveVariantPreferenceModeDialog(
- selectedMode: LiveVariantPreferenceMode,
- onDismiss: () -> Unit,
- onModeSelected: (LiveVariantPreferenceMode) -> Unit
-) {
- PremiumDialog(
- title = stringResource(R.string.settings_live_variant_preference_mode),
- subtitle = stringResource(R.string.settings_live_variant_preference_mode_subtitle),
- onDismissRequest = onDismiss,
- widthFraction = 0.52f,
- content = {
- Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
- LiveVariantPreferenceMode.entries.forEach { mode ->
- TvClickableSurface(
- onClick = { onModeSelected(mode) },
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(14.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = if (mode == selectedMode) Primary.copy(alpha = 0.18f) else SurfaceElevated,
- focusedContainerColor = Primary.copy(alpha = 0.28f)
- ),
- modifier = Modifier.fillMaxWidth()
- ) {
- Column(
- modifier = Modifier.padding(horizontal = 16.dp, vertical = 14.dp),
- verticalArrangement = Arrangement.spacedBy(4.dp)
- ) {
- Text(
- text = stringResource(mode.labelResId()),
- style = MaterialTheme.typography.titleSmall,
- color = if (mode == selectedMode) Primary else OnBackground
- )
- Text(
- text = stringResource(mode.descriptionResId()),
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim
- )
- }
- }
- }
- }
- },
- footer = {
- PremiumDialogFooterButton(
- label = stringResource(R.string.settings_cancel),
- onClick = onDismiss
- )
- }
- )
-}
-
-@Composable
-internal fun SettingsRow(label: String, value: String) {
- val focusRequester = remember { FocusRequester() }
- TvClickableSurface(
- onClick = {},
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Color.Transparent,
- focusedContainerColor = Primary.copy(alpha = 0.15f)
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
- modifier = Modifier
- .fillMaxWidth()
- .focusRequester(focusRequester)
- .mouseClickable(
- focusRequester = focusRequester,
- onClick = {}
- )
- ) {
- Row(
- modifier = Modifier
- .fillMaxWidth()
- .padding(horizontal = 8.dp, vertical = 8.dp),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically
- ) {
- Text(text = label, style = MaterialTheme.typography.bodyMedium, color = OnSurface)
- Text(text = value, style = MaterialTheme.typography.bodyMedium, color = OnBackground)
- }
- }
-}
-
-@Composable
-internal fun ClickableSettingsRow(
- label: String,
- value: String,
- onClick: () -> Unit,
- enabled: Boolean = true,
- indent: androidx.compose.ui.unit.Dp = 0.dp
-) {
- val focusRequester = remember { FocusRequester() }
- TvClickableSurface(
- onClick = { if (enabled) onClick() },
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Color.Transparent,
- focusedContainerColor = if (enabled) Primary.copy(alpha = 0.15f) else Color.Transparent
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
- modifier = Modifier
- .fillMaxWidth()
- .focusRequester(focusRequester)
- .mouseClickable(
- focusRequester = focusRequester,
- onClick = { if (enabled) onClick() }
- )
- ) {
- Row(
- modifier = Modifier
- .fillMaxWidth()
- .padding(start = 8.dp + indent, end = 8.dp, top = 12.dp, bottom = 12.dp),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically
- ) {
- Text(
- text = label,
- style = MaterialTheme.typography.bodyMedium,
- color = if (enabled) OnSurface else OnSurfaceDim
- )
- Text(
- text = value,
- style = MaterialTheme.typography.bodyMedium,
- color = if (enabled) Primary else OnSurfaceDim
- )
- }
- }
-}
-
-@Composable
-internal fun SwitchSettingsRow(
- label: String,
- value: String,
- checked: Boolean,
- onCheckedChange: (Boolean) -> Unit,
- enabled: Boolean = true,
- indent: androidx.compose.ui.unit.Dp = 0.dp
-) {
- val focusRequester = remember { FocusRequester() }
- TvClickableSurface(
- onClick = { if (enabled) onCheckedChange(!checked) },
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Color.Transparent,
- focusedContainerColor = if (enabled) Primary.copy(alpha = 0.15f) else Color.Transparent
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
- modifier = Modifier
- .fillMaxWidth()
- .focusRequester(focusRequester)
- .mouseClickable(
- focusRequester = focusRequester,
- onClick = { if (enabled) onCheckedChange(!checked) }
- )
- ) {
- Row(
- modifier = Modifier
- .fillMaxWidth()
- .padding(start = 8.dp + indent, end = 8.dp, top = 12.dp, bottom = 12.dp),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically
- ) {
- Column(verticalArrangement = Arrangement.spacedBy(2.dp)) {
- Text(
- text = label,
- style = MaterialTheme.typography.bodyMedium,
- color = if (enabled) OnSurface else OnSurfaceDim
- )
- Text(text = value, style = MaterialTheme.typography.bodySmall, color = OnSurfaceDim)
- }
- Switch(
- checked = checked,
- onCheckedChange = { if (enabled) onCheckedChange(it) },
- enabled = enabled
- )
- }
- }
-}
-
-internal fun formatLatestReleaseLabel(update: AppUpdateUiModel, context: android.content.Context): String {
- val versionName = update.latestVersionName ?: return context.getString(R.string.settings_update_not_checked)
- val versionCodeSuffix = update.latestVersionCode?.let { " ($it)" }.orEmpty()
- return "$versionName$versionCodeSuffix"
-}
-
-internal fun formatUpdateStatusLabel(update: AppUpdateUiModel, context: android.content.Context): String {
- val downloadedReleaseMatchesLatest = update.downloadedVersionName != null &&
- (update.latestVersionName == null || update.downloadedVersionName == update.latestVersionName)
- return when {
- update.errorMessage != null -> context.getString(R.string.settings_update_status_check_failed)
- update.downloadStatus == com.streamvault.app.update.AppUpdateDownloadStatus.Downloading -> context.getString(R.string.settings_update_status_downloading)
- update.downloadStatus == com.streamvault.app.update.AppUpdateDownloadStatus.Downloaded && downloadedReleaseMatchesLatest -> context.getString(R.string.settings_update_status_ready_to_install)
- update.latestVersionName == null -> context.getString(R.string.settings_update_not_checked)
- update.isUpdateAvailable -> context.getString(R.string.settings_update_status_available)
- else -> context.getString(R.string.settings_update_status_current)
- }
-}
-
-internal fun formatUpdateCheckTimeLabel(timestamp: Long?, context: android.content.Context): String {
- if (timestamp == null || timestamp <= 0L) {
- return context.getString(R.string.settings_update_not_checked)
- }
- return DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT).format(java.util.Date(timestamp))
-}
-
-internal fun shouldShowUpdateDownloadAction(update: AppUpdateUiModel): Boolean {
- val downloadedReleaseMatchesLatest = update.downloadedVersionName != null &&
- (update.latestVersionName == null || update.downloadedVersionName == update.latestVersionName)
- return when (update.downloadStatus) {
- com.streamvault.app.update.AppUpdateDownloadStatus.Downloading,
- com.streamvault.app.update.AppUpdateDownloadStatus.Downloaded -> downloadedReleaseMatchesLatest || (update.isUpdateAvailable && !update.downloadUrl.isNullOrBlank())
- else -> update.isUpdateAvailable && !update.downloadUrl.isNullOrBlank()
- }
-}
-
-internal fun formatUpdateDownloadLabel(update: AppUpdateUiModel, context: android.content.Context): String {
- val downloadedReleaseMatchesLatest = update.downloadedVersionName != null &&
- (update.latestVersionName == null || update.downloadedVersionName == update.latestVersionName)
- return when (update.downloadStatus) {
- com.streamvault.app.update.AppUpdateDownloadStatus.Downloading -> context.getString(R.string.settings_update_download_in_progress)
- com.streamvault.app.update.AppUpdateDownloadStatus.Downloaded -> {
- if (downloadedReleaseMatchesLatest) {
- context.getString(R.string.settings_update_install_action)
- } else {
- context.getString(R.string.settings_update_download_action)
- }
- }
- else -> context.getString(R.string.settings_update_download_action)
- }
-}
-@Composable
-internal fun LiveTvQuickFiltersDialog(
- filters: List<String>,
- onDismiss: () -> Unit,
- onAddFilter: (String) -> Unit,
- onRemoveFilter: (String) -> Unit
-) {
- var pendingFilter by rememberSaveable { mutableStateOf("") }
-
- PremiumDialog(
- title = stringResource(R.string.settings_live_tv_quick_filters_dialog_title),
- subtitle = stringResource(R.string.settings_live_tv_quick_filters_dialog_subtitle),
- onDismissRequest = onDismiss,
- widthFraction = 0.5f,
- content = {
- EpgSourceTextField(
- value = pendingFilter,
- onValueChange = { pendingFilter = it },
- placeholder = stringResource(R.string.settings_live_tv_quick_filters_placeholder)
- )
- PremiumDialogActionButton(
- label = stringResource(R.string.settings_live_tv_quick_filters_add),
- enabled = pendingFilter.isNotBlank(),
- onClick = {
- onAddFilter(pendingFilter)
- pendingFilter = ""
- }
- )
- if (filters.isEmpty()) {
- Text(
- text = stringResource(R.string.settings_live_tv_quick_filters_empty),
- style = MaterialTheme.typography.bodyMedium,
- color = OnSurfaceDim
- )
- } else {
- Text(
- text = stringResource(R.string.settings_live_tv_quick_filters_saved),
- style = MaterialTheme.typography.labelMedium,
- color = OnSurfaceDim
- )
- LazyColumn(
- modifier = Modifier.heightIn(max = 260.dp),
- verticalArrangement = Arrangement.spacedBy(8.dp)
- ) {
- items(filters, key = { it }) { filter ->
- Box(
- modifier = Modifier
- .fillMaxWidth()
- .background(Color.White.copy(alpha = 0.06f), RoundedCornerShape(12.dp))
- .padding(horizontal = 14.dp, vertical = 10.dp)
- ) {
- Row(
- modifier = Modifier.fillMaxWidth(),
- horizontalArrangement = Arrangement.spacedBy(12.dp),
- verticalAlignment = Alignment.CenterVertically
- ) {
- Text(
- text = filter,
- style = MaterialTheme.typography.bodyMedium,
- color = OnSurface,
- modifier = Modifier.weight(1f)
- )
- TvButton(onClick = { onRemoveFilter(filter) }) {
- Text(stringResource(R.string.settings_live_tv_quick_filters_remove))
- }
- }
- }
- }
- }
- }
- },
- footer = {
- PremiumDialogFooterButton(
- label = stringResource(R.string.settings_cancel),
- onClick = onDismiss
- )
- }
- )
-}
-
-internal fun formatLiveTvQuickFiltersValue(filters: List<String>, context: android.content.Context): String {
- if (filters.isEmpty()) {
- return context.getString(R.string.settings_live_tv_quick_filters_none)
- }
- return context.resources.getQuantityString(
- R.plurals.settings_live_tv_quick_filters_count,
- filters.size,
- filters.size
- )
-}
-
-@Composable
-internal fun SettingsNavItem(
- label: String,
- badgeChar: String,
- accentColor: Color,
- isSelected: Boolean,
- modifier: Modifier = Modifier,
- onClick: () -> Unit
-) {
- val focusRequester = remember { FocusRequester() }
- TvClickableSurface(
- onClick = onClick,
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(0.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = if (isSelected) Primary.copy(alpha = 0.11f) else Color.Transparent,
- focusedContainerColor = Primary.copy(alpha = 0.22f)
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
- modifier = modifier
- .fillMaxWidth()
- .focusRequester(focusRequester)
- .mouseClickable(focusRequester = focusRequester, onClick = onClick)
- ) {
- Row(
- modifier = Modifier
- .fillMaxWidth()
- .padding(horizontal = 10.dp, vertical = 12.dp),
- verticalAlignment = Alignment.CenterVertically,
- horizontalArrangement = Arrangement.spacedBy(10.dp)
- ) {
- Box(
- Modifier
- .width(3.dp)
- .height(22.dp)
- .background(
- color = if (isSelected) Primary else Color.Transparent,
- shape = RoundedCornerShape(2.dp)
- )
- )
- Box(
- Modifier
- .size(28.dp)
- .background(accentColor.copy(alpha = 0.18f), RoundedCornerShape(7.dp)),
- contentAlignment = Alignment.Center
- ) {
- Text(
- text = badgeChar,
- style = MaterialTheme.typography.labelSmall,
- color = accentColor,
- fontWeight = FontWeight.Bold
- )
- }
- Text(
- text = label,
- style = MaterialTheme.typography.labelLarge,
- color = if (isSelected) Primary else OnBackground,
- fontWeight = if (isSelected) FontWeight.SemiBold else FontWeight.Normal
- )
- }
- }
-}
-
-internal fun formatBytes(bytes: Long): String {
- if (bytes <= 0L) return "0 B"
- val kb = 1024.0
- val mb = kb * 1024.0
- val gb = mb * 1024.0
- return when {
- bytes >= gb -> String.format(Locale.getDefault(), "%.1f GB", bytes / gb)
- bytes >= mb -> String.format(Locale.getDefault(), "%.1f MB", bytes / mb)
- bytes >= kb -> String.format(Locale.getDefault(), "%.1f KB", bytes / kb)
- else -> "$bytes B"
- }
-}
-
-internal fun formatTimestamp(
- timestampMs: Long,
- dateTimeFormat: DateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT)
-): String {
- if (timestampMs <= 0L) return "--:--"
- return dateTimeFormat.format(java.util.Date(timestampMs))
-}
-
-internal data class AppLanguageOption(
- val tag: String,
- val label: String
-)
-
-internal fun supportedAppLanguages(systemDefaultLabel: String): List<AppLanguageOption> {
- val localeTags = listOf("system") + supportedAppLanguageTags()
-
- return localeTags.map { tag ->
- AppLanguageOption(
- tag = tag,
- label = if (tag == "system") {
- systemDefaultLabel
- } else {
- val locale = localeForLanguageTag(tag)
- locale.getDisplayLanguage(locale)
- .replaceFirstChar { character ->
- if (character.isLowerCase()) {
- character.titlecase(locale)
- } else {
- character.toString()
- }
- }
- }
- )
- }
-}
-
-internal fun supportedAudioLanguages(autoLabel: String): List<AppLanguageOption> {
- return buildList {
- add(AppLanguageOption(tag = "auto", label = autoLabel))
- addAll(supportedAppLanguages(autoLabel).filterNot { it.tag == "system" })
- }
-}
-
-internal data class SubtitleScaleOption(
- val scale: Float,
- val label: (android.content.Context) -> String
-)
-
-internal data class SubtitleColorOption(
- val colorArgb: Int,
- val label: String
-)
-
-internal fun subtitleSizeOptions(): List<SubtitleScaleOption> {
- return listOf(
- SubtitleScaleOption(0.85f) { it.getString(R.string.settings_subtitle_size_small) },
- SubtitleScaleOption(1f) { it.getString(R.string.settings_subtitle_size_default) },
- SubtitleScaleOption(1.15f) { it.getString(R.string.settings_subtitle_size_large) },
- SubtitleScaleOption(1.3f) { it.getString(R.string.settings_subtitle_size_extra_large) }
- )
-}
-
-internal fun subtitleTextColorOptions(context: android.content.Context): List<SubtitleColorOption> {
- return listOf(
- SubtitleColorOption(0xFFFFFFFF.toInt(), context.getString(R.string.settings_subtitle_color_white)),
- SubtitleColorOption(0xFFFFEB3B.toInt(), context.getString(R.string.settings_subtitle_color_yellow)),
- SubtitleColorOption(0xFF80DEEA.toInt(), context.getString(R.string.settings_subtitle_color_cyan)),
- SubtitleColorOption(0xFFA5D6A7.toInt(), context.getString(R.string.settings_subtitle_color_green))
- )
-}
-
-internal fun subtitleBackgroundColorOptions(context: android.content.Context): List<SubtitleColorOption> {
- return listOf(
- SubtitleColorOption(0x00000000, context.getString(R.string.settings_subtitle_background_transparent)),
- SubtitleColorOption(0x80000000.toInt(), context.getString(R.string.settings_subtitle_background_dim)),
- SubtitleColorOption(0xCC000000.toInt(), context.getString(R.string.settings_subtitle_background_black)),
- SubtitleColorOption(0xCC102A43.toInt(), context.getString(R.string.settings_subtitle_background_blue))
- )
-}
-
-internal fun displayLanguageLabel(languageTag: String, defaultLabel: String): String {
- if (languageTag.isBlank() || languageTag == "system" || languageTag == "auto") return defaultLabel
- val locale = localeForLanguageTag(languageTag)
- if (locale.language.isBlank()) return defaultLabel
- return locale.getDisplayLanguage(Locale.getDefault())
- .replaceFirstChar { character ->
- if (character.isLowerCase()) {
- character.titlecase(Locale.getDefault())
- } else {
- character.toString()
- }
- }
-}
-
-internal fun formatPlaybackSpeedLabel(speed: Float): String {
- return if (speed % 1f == 0f) {
- "${speed.toInt()}x"
- } else {
- "${("%.2f".format(Locale.US, speed)).trimEnd('0').trimEnd('.')}x"
- }
-}
-
-internal fun formatPlaybackTimerMinutesLabel(minutes: Int, context: android.content.Context): String {
- return if (minutes <= 0) {
- context.getString(R.string.settings_timer_off)
- } else {
- context.resources.getQuantityString(R.plurals.settings_timer_minutes, minutes, minutes)
- }
-}
-
-@Composable
-internal fun PlaybackTimerPresetDialog(
- title: String,
- selectedMinutes: Int,
- onDismiss: () -> Unit,
- onSelect: (Int) -> Unit
-) {
- val context = androidx.compose.ui.platform.LocalContext.current
- val options = remember { listOf(0, 15, 30, 45, 60, 90, 120) }
-
- PremiumSelectionDialog(
- title = title,
- onDismiss = onDismiss
- ) {
- options.forEachIndexed { index, minutes ->
- LevelOption(
- level = index,
- text = formatPlaybackTimerMinutesLabel(minutes, context),
- currentLevel = if (selectedMinutes == minutes) index else -1,
- onSelect = { onSelect(minutes) }
- )
- }
- }
-}
-
-internal fun formatAudioVideoOffsetLabel(offsetMs: Int): String = when {
- offsetMs > 0 -> "+$offsetMs ms"
- offsetMs < 0 -> "$offsetMs ms"
- else -> "0 ms"
-}
-
-@Composable
-internal fun AudioVideoOffsetValueDialog(
- title: String,
- subtitle: String,
- initialValue: Int,
- onDismiss: () -> Unit,
- onConfirm: (Int) -> Unit
-) {
- var value by rememberSaveable(initialValue) { mutableStateOf(initialValue.coerceIn(-2_000, 2_000)) }
-
- PremiumDialog(
- title = title,
- subtitle = subtitle,
- onDismissRequest = onDismiss,
- widthFraction = 0.42f,
- content = {
- Column(verticalArrangement = Arrangement.spacedBy(14.dp)) {
- Text(
- text = formatAudioVideoOffsetLabel(value),
- style = MaterialTheme.typography.headlineSmall,
- color = Primary
- )
- Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
- PremiumDialogFooterButton(
- label = "-50",
- onClick = { value = (value - 50).coerceAtLeast(-2_000) }
- )
- PremiumDialogFooterButton(
- label = "+50",
- onClick = { value = (value + 50).coerceAtMost(2_000) }
- )
- PremiumDialogFooterButton(
- label = stringResource(R.string.settings_reset),
- onClick = { value = 0 }
- )
- }
- }
- },
- footer = {
- Row(
- modifier = Modifier.fillMaxWidth(),
- horizontalArrangement = Arrangement.spacedBy(12.dp, Alignment.End)
- ) {
- PremiumDialogFooterButton(
- label = stringResource(R.string.settings_cancel),
- onClick = onDismiss
- )
- PremiumDialogFooterButton(
- label = stringResource(R.string.settings_save),
- onClick = { onConfirm(value) }
- )
- }
- }
- )
-}
-
-@Composable
-internal fun RecordingMetaPill(label: String, value: String) {
- Column(
- modifier = Modifier
- .widthIn(min = 92.dp, max = 160.dp)
- .background(Color.White.copy(alpha = 0.05f), RoundedCornerShape(10.dp))
- .padding(horizontal = 7.dp, vertical = 5.dp)
- ) {
- Text(text = label, style = MaterialTheme.typography.labelSmall, color = OnSurfaceDim)
- Text(text = value, style = MaterialTheme.typography.labelMedium, color = OnBackground, maxLines = 1, overflow = TextOverflow.Ellipsis)
- }
-}
-
-internal fun summarizeRecordingOutputPath(path: String): String {
- val trimmed = path.trim()
- if (trimmed.isBlank()) return trimmed
- val decoded = runCatching { android.net.Uri.decode(trimmed) }.getOrDefault(trimmed)
- return decoded
- .substringAfterLast('/')
- .substringAfterLast('\\')
- .ifBlank { decoded }
-}
-
-@Composable
-internal fun RecordingActionButton(
- label: String,
- accent: Color,
- modifier: Modifier = Modifier,
- onClick: () -> Unit
-) {
- TvButton(
- onClick = onClick,
- modifier = Modifier
- .widthIn(min = 168.dp, max = 220.dp)
- .heightIn(min = 52.dp)
- .then(modifier),
- shape = ButtonDefaults.shape(RoundedCornerShape(10.dp)),
- colors = ButtonDefaults.colors(
- containerColor = accent.copy(alpha = 0.14f),
- focusedContainerColor = accent.copy(alpha = 0.28f),
- contentColor = accent,
- focusedContentColor = accent
- ),
- border = ButtonDefaults.border(
- border = Border(
- border = BorderStroke(1.dp, Color.White.copy(alpha = 0.08f)),
- shape = RoundedCornerShape(10.dp)
- ),
- focusedBorder = Border(
- border = BorderStroke(FocusSpec.BorderWidth, Color.White),
- shape = RoundedCornerShape(10.dp)
- )
- ),
- scale = ButtonDefaults.scale(focusedScale = 1f)
- ) {
- Text(
- text = label,
- color = accent,
- style = MaterialTheme.typography.labelMedium,
- maxLines = 2,
- modifier = Modifier.padding(horizontal = 6.dp, vertical = 2.dp)
- )
- }
-}
-
-@Composable
-internal fun SimpleTextValueDialog(
- title: String,
- subtitle: String,
- initialValue: String,
- onDismiss: () -> Unit,
- onConfirm: (String) -> Unit
-) {
- var value by remember(initialValue) { mutableStateOf(initialValue) }
- PremiumDialog(
- title = title,
- subtitle = subtitle,
- onDismissRequest = onDismiss,
- widthFraction = 0.58f,
- content = {
- EpgSourceTextField(
- value = value,
- onValueChange = { value = it },
- placeholder = initialValue
- )
- },
- footer = {
- Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) {
- PremiumDialogFooterButton(
- label = stringResource(R.string.settings_cancel),
- onClick = onDismiss
- )
- PremiumDialogActionButton(
- label = stringResource(R.string.settings_save),
- onClick = { onConfirm(value.trim()) }
- )
- }
- }
- )
-}
-
-internal fun formatRecordingSourceType(sourceType: RecordingSourceType): String = when (sourceType) {
- RecordingSourceType.TS -> "TS"
- RecordingSourceType.HLS -> "HLS"
- RecordingSourceType.DASH -> "DASH"
- RecordingSourceType.UNKNOWN -> "Auto"
-}
-
-internal fun formatRecordingFailureCategory(category: RecordingFailureCategory): String = when (category) {
- RecordingFailureCategory.NONE -> "None"
- RecordingFailureCategory.NETWORK -> "Network"
- RecordingFailureCategory.STORAGE -> "Storage"
- RecordingFailureCategory.AUTH -> "Auth"
- RecordingFailureCategory.TOKEN_EXPIRED -> "Token"
- RecordingFailureCategory.DRM_UNSUPPORTED -> "DRM"
- RecordingFailureCategory.FORMAT_UNSUPPORTED -> "Format"
- RecordingFailureCategory.SCHEDULE_CONFLICT -> "Conflict"
- RecordingFailureCategory.PROVIDER_LIMIT -> "Connection limit"
- RecordingFailureCategory.UNKNOWN -> "Unknown"
-}
-
-internal fun playerTimeoutOptions(): List<Int> = listOf(2, 3, 4, 5, 6, 8, 10, 15, 20, 30)
-
-internal fun formatDecoderModeLabel(mode: DecoderMode, context: android.content.Context): String {
- return when (mode) {
- DecoderMode.AUTO -> context.getString(R.string.settings_decoder_auto)
- DecoderMode.HARDWARE -> context.getString(R.string.settings_decoder_hardware)
- DecoderMode.SOFTWARE -> context.getString(R.string.settings_decoder_software)
- DecoderMode.COMPATIBILITY -> context.getString(R.string.settings_decoder_compatibility)
- }
-}
-
-internal fun formatSurfaceModeLabel(
- mode: com.streamvault.domain.model.PlayerSurfaceMode,
- context: android.content.Context
-): String = when (mode) {
- com.streamvault.domain.model.PlayerSurfaceMode.AUTO -> context.getString(R.string.settings_surface_auto)
- com.streamvault.domain.model.PlayerSurfaceMode.SURFACE_VIEW -> context.getString(R.string.settings_surface_surface_view)
- com.streamvault.domain.model.PlayerSurfaceMode.TEXTURE_VIEW -> context.getString(R.string.settings_surface_texture_view)
-}
-
-internal fun formatTimeoutSecondsLabel(seconds: Int, context: android.content.Context): String {
- return context.resources.getQuantityString(
- R.plurals.settings_timeout_seconds,
- seconds,
- seconds
- )
-}
-
-internal fun formatSubtitleSizeLabel(scale: Float, context: android.content.Context): String {
- return subtitleSizeOptions().firstOrNull { it.scale == scale }?.label?.invoke(context)
- ?: context.getString(R.string.settings_subtitle_size_default)
-}
-
-internal fun formatSubtitleColorLabel(colorArgb: Int, options: List<SubtitleColorOption>): String {
- return options.firstOrNull { it.colorArgb == colorArgb }?.label ?: options.first().label
-}
-
-internal fun formatQualityCapLabel(maxHeight: Int?, autoLabel: String): String {
- return maxHeight?.let { "${it}p" } ?: autoLabel
-}
-
-internal fun formatSpeedTestValueLabel(speedTest: InternetSpeedTestUiModel): String {
- return String.format(Locale.getDefault(), "%.1f Mbps", speedTest.megabitsPerSecond)
-}
-
-internal fun formatSpeedTestSummary(
- speedTest: InternetSpeedTestUiModel,
- context: android.content.Context,
- dateTimeFormat: DateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT)
-): String {
- val transportLabel = when (speedTest.transportLabel) {
- InternetSpeedTestTransport.WIFI.name -> context.getString(R.string.settings_speed_test_transport_wifi)
- InternetSpeedTestTransport.ETHERNET.name -> context.getString(R.string.settings_speed_test_transport_ethernet)
- InternetSpeedTestTransport.CELLULAR.name -> context.getString(R.string.settings_speed_test_transport_cellular)
- InternetSpeedTestTransport.OTHER.name -> context.getString(R.string.settings_speed_test_transport_other)
- else -> context.getString(R.string.settings_speed_test_transport_unknown)
- }
- val measuredAtLabel = formatTimestamp(speedTest.measuredAtMs, dateTimeFormat)
- return if (speedTest.isEstimated) {
- context.getString(R.string.settings_speed_test_summary_estimated, transportLabel, measuredAtLabel)
- } else {
- context.getString(R.string.settings_speed_test_summary_measured, transportLabel, measuredAtLabel)
- }
-}
-
-internal fun sortModeLabel(mode: CategorySortMode, context: android.content.Context): String {
- return when (mode) {
- CategorySortMode.DEFAULT -> context.getString(R.string.settings_category_sort_default)
- CategorySortMode.TITLE_ASC -> context.getString(R.string.settings_category_sort_az)
- CategorySortMode.TITLE_DESC -> context.getString(R.string.settings_category_sort_za)
- CategorySortMode.COUNT_DESC -> context.getString(R.string.settings_category_sort_most_items)
- CategorySortMode.COUNT_ASC -> context.getString(R.string.settings_category_sort_least_items)
- }
-}
-
-internal fun formatCategorySortModeLabel(mode: CategorySortMode, context: android.content.Context): String {
- return sortModeLabel(mode, context)
-}
-
-internal fun categoryTypeLabel(type: ContentType, context: android.content.Context): String {
- return when (type) {
- ContentType.LIVE -> context.getString(R.string.settings_category_sort_live)
- ContentType.MOVIE -> context.getString(R.string.settings_category_sort_movies)
- ContentType.SERIES -> context.getString(R.string.settings_category_sort_series)
- ContentType.SERIES_EPISODE -> context.getString(R.string.settings_category_sort_series)
- }
-}
-
-internal fun categoryTypeDescription(type: ContentType, context: android.content.Context): String {
- return when (type) {
- ContentType.LIVE -> context.getString(R.string.settings_category_type_live_description)
- ContentType.MOVIE -> context.getString(R.string.settings_category_type_movies_description)
- ContentType.SERIES -> context.getString(R.string.settings_category_type_series_description)
- ContentType.SERIES_EPISODE -> context.getString(R.string.settings_category_type_series_description)
- }
-}
-
-internal fun LiveTvChannelMode.labelResId(): Int = when (this) {
- LiveTvChannelMode.COMFORTABLE -> R.string.settings_live_tv_mode_comfortable
- LiveTvChannelMode.COMPACT -> R.string.settings_live_tv_mode_compact
- LiveTvChannelMode.PRO -> R.string.settings_live_tv_mode_pro
-}
-
-internal fun LiveTvChannelMode.descriptionResId(): Int = when (this) {
- LiveTvChannelMode.COMFORTABLE -> R.string.settings_live_tv_mode_comfortable_desc
- LiveTvChannelMode.COMPACT -> R.string.settings_live_tv_mode_compact_desc
- LiveTvChannelMode.PRO -> R.string.settings_live_tv_mode_pro_desc
-}
-
-internal fun LiveTvQuickFilterVisibilityMode.labelResId(): Int = when (this) {
- LiveTvQuickFilterVisibilityMode.HIDE -> R.string.settings_live_tv_quick_filter_visibility_hide
- LiveTvQuickFilterVisibilityMode.SHOW_WHEN_FILTERS_AVAILABLE -> R.string.settings_live_tv_quick_filter_visibility_available
- LiveTvQuickFilterVisibilityMode.ALWAYS_VISIBLE -> R.string.settings_live_tv_quick_filter_visibility_always
-}
-
-internal fun LiveTvQuickFilterVisibilityMode.descriptionResId(): Int = when (this) {
- LiveTvQuickFilterVisibilityMode.HIDE -> R.string.settings_live_tv_quick_filter_visibility_hide_desc
- LiveTvQuickFilterVisibilityMode.SHOW_WHEN_FILTERS_AVAILABLE -> R.string.settings_live_tv_quick_filter_visibility_available_desc
- LiveTvQuickFilterVisibilityMode.ALWAYS_VISIBLE -> R.string.settings_live_tv_quick_filter_visibility_always_desc
-}
-
-internal fun VodViewMode.labelResId(): Int = when (this) {
- VodViewMode.MODERN -> R.string.settings_vod_view_mode_modern
- VodViewMode.CLASSIC -> R.string.settings_vod_view_mode_classic
-}
-
-internal fun VodViewMode.descriptionResId(): Int = when (this) {
- VodViewMode.MODERN -> R.string.settings_vod_view_mode_modern_desc
- VodViewMode.CLASSIC -> R.string.settings_vod_view_mode_classic_desc
-}
-
-internal fun ChannelNumberingMode.labelResId(): Int = when (this) {
- ChannelNumberingMode.GROUP -> R.string.settings_live_channel_numbering_group
- ChannelNumberingMode.PROVIDER -> R.string.settings_live_channel_numbering_provider
- ChannelNumberingMode.HIDDEN -> R.string.settings_live_channel_numbering_hidden
-}
-
-internal fun ChannelNumberingMode.descriptionResId(): Int = when (this) {
- ChannelNumberingMode.GROUP -> R.string.settings_live_channel_numbering_group_desc
- ChannelNumberingMode.PROVIDER -> R.string.settings_live_channel_numbering_provider_desc
- ChannelNumberingMode.HIDDEN -> R.string.settings_live_channel_numbering_hidden_desc
-}
-
-internal fun LiveChannelGroupingMode.labelResId(): Int = when (this) {
- LiveChannelGroupingMode.GROUPED -> R.string.settings_live_channel_grouping_grouped
- LiveChannelGroupingMode.RAW_VARIANTS -> R.string.settings_live_channel_grouping_raw_variants
-}
-
-internal fun LiveChannelGroupingMode.descriptionResId(): Int = when (this) {
- LiveChannelGroupingMode.GROUPED -> R.string.settings_live_channel_grouping_grouped_desc
- LiveChannelGroupingMode.RAW_VARIANTS -> R.string.settings_live_channel_grouping_raw_variants_desc
-}
-
-internal fun GroupedChannelLabelMode.labelResId(): Int = when (this) {
- GroupedChannelLabelMode.CANONICAL -> R.string.settings_grouped_channel_label_canonical
- GroupedChannelLabelMode.ORIGINAL_PROVIDER_LABEL -> R.string.settings_grouped_channel_label_original
- GroupedChannelLabelMode.HYBRID -> R.string.settings_grouped_channel_label_hybrid
-}
-
-internal fun GroupedChannelLabelMode.descriptionResId(): Int = when (this) {
- GroupedChannelLabelMode.CANONICAL -> R.string.settings_grouped_channel_label_canonical_desc
- GroupedChannelLabelMode.ORIGINAL_PROVIDER_LABEL -> R.string.settings_grouped_channel_label_original_desc
- GroupedChannelLabelMode.HYBRID -> R.string.settings_grouped_channel_label_hybrid_desc
-}
-
-internal fun LiveVariantPreferenceMode.labelResId(): Int = when (this) {
- LiveVariantPreferenceMode.BEST_QUALITY -> R.string.settings_live_variant_preference_best_quality
- LiveVariantPreferenceMode.OBSERVED_ONLY -> R.string.settings_live_variant_preference_observed_only
- LiveVariantPreferenceMode.BALANCED -> R.string.settings_live_variant_preference_balanced
- LiveVariantPreferenceMode.STABILITY_FIRST -> R.string.settings_live_variant_preference_stability_first
-}
-
-internal fun LiveVariantPreferenceMode.descriptionResId(): Int = when (this) {
- LiveVariantPreferenceMode.BEST_QUALITY -> R.string.settings_live_variant_preference_best_quality_desc
- LiveVariantPreferenceMode.OBSERVED_ONLY -> R.string.settings_live_variant_preference_observed_only_desc
- LiveVariantPreferenceMode.BALANCED -> R.string.settings_live_variant_preference_balanced_desc
- LiveVariantPreferenceMode.STABILITY_FIRST -> R.string.settings_live_variant_preference_stability_first_desc
-}
-
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsEpgAssignmentComponents.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsEpgAssignmentComponents.kt
new file mode 100644
index 00000000..06d83797
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsEpgAssignmentComponents.kt
@@ -0,0 +1,180 @@
+package com.streamvault.app.ui.screens.settings
+
+import androidx.compose.foundation.background
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.ExperimentalLayoutApi
+import androidx.compose.foundation.layout.FlowRow
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.shape.RoundedCornerShape
+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.ClickableSurfaceDefaults
+import androidx.tv.material3.MaterialTheme
+import androidx.tv.material3.Text
+import com.streamvault.app.ui.interaction.TvClickableSurface
+import com.streamvault.app.ui.theme.OnSurfaceDim
+import com.streamvault.domain.model.EpgResolutionSummary
+import com.streamvault.domain.model.EpgSource
+import com.streamvault.domain.model.ProviderEpgSourceAssignment
+
+@OptIn(ExperimentalLayoutApi::class)
+@Composable
+internal fun ProviderEpgAssignmentsCard(
+ providerName: String,
+ assignments: List<ProviderEpgSourceAssignment>,
+ resolutionSummary: EpgResolutionSummary?,
+ unassignedSources: List<EpgSource>,
+ onMoveUp: (Long) -> Unit,
+ onMoveDown: (Long) -> Unit,
+ onRemove: (Long) -> Unit,
+ onAssign: (Long) -> Unit
+) {
+ androidx.compose.foundation.layout.Box(
+ modifier = Modifier
+ .fillMaxWidth()
+ .background(Color.White.copy(alpha = 0.06f), RoundedCornerShape(12.dp))
+ ) {
+ Column(modifier = Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {
+ Text(providerName, style = MaterialTheme.typography.titleSmall, color = Color.White)
+ if (resolutionSummary != null) {
+ val matchedChannels = (resolutionSummary.totalChannels - resolutionSummary.unresolvedChannels).coerceAtLeast(0)
+ val summaryParts = buildList {
+ add("Matched $matchedChannels/${resolutionSummary.totalChannels} channels")
+ if (resolutionSummary.exactIdMatches > 0) add("${resolutionSummary.exactIdMatches} exact")
+ if (resolutionSummary.normalizedNameMatches > 0) add("${resolutionSummary.normalizedNameMatches} name")
+ if (resolutionSummary.providerNativeMatches > 0) add("${resolutionSummary.providerNativeMatches} provider")
+ if (resolutionSummary.manualMatches > 0) add("${resolutionSummary.manualMatches} manual")
+ if (resolutionSummary.unresolvedChannels > 0) add("${resolutionSummary.unresolvedChannels} without EPG")
+ if (resolutionSummary.lowConfidenceChannels > 0) add("${resolutionSummary.lowConfidenceChannels} weak")
+ if (resolutionSummary.rematchCandidateChannels > 0) add("${resolutionSummary.rematchCandidateChannels} need review")
+ }
+ Text(
+ text = summaryParts.joinToString(" • "),
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim
+ )
+ }
+
+ if (assignments.isEmpty()) {
+ Text("No EPG sources assigned", style = MaterialTheme.typography.bodySmall, color = OnSurfaceDim)
+ } else {
+ assignments.sortedBy { it.priority }.forEachIndexed { assignmentIndex, assignment ->
+ ProviderEpgAssignmentRow(
+ assignment = assignment,
+ canMoveUp = assignmentIndex > 0,
+ canMoveDown = assignmentIndex < assignments.lastIndex,
+ onMoveUp = { onMoveUp(assignment.epgSourceId) },
+ onMoveDown = { onMoveDown(assignment.epgSourceId) },
+ onRemove = { onRemove(assignment.epgSourceId) }
+ )
+ }
+ }
+
+ if (unassignedSources.isNotEmpty()) {
+ FlowRow(
+ horizontalArrangement = Arrangement.spacedBy(8.dp),
+ verticalArrangement = Arrangement.spacedBy(6.dp)
+ ) {
+ unassignedSources.forEach { source ->
+ val assignActionShape = RoundedCornerShape(8.dp)
+ TvClickableSurface(
+ onClick = { onAssign(source.id) },
+ shape = ClickableSurfaceDefaults.shape(assignActionShape),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Color(0xFF66BB6A).copy(alpha = 0.12f),
+ focusedContainerColor = Color(0xFF66BB6A).copy(alpha = 0.25f)
+ ),
+ border = epgActionBorder(assignActionShape),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
+ ) {
+ Text(
+ "+ ${source.name}",
+ modifier = Modifier.padding(horizontal = 12.dp, vertical = 6.dp),
+ style = MaterialTheme.typography.labelSmall,
+ color = Color(0xFF66BB6A)
+ )
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+@Composable
+private fun ProviderEpgAssignmentRow(
+ assignment: ProviderEpgSourceAssignment,
+ canMoveUp: Boolean,
+ canMoveDown: Boolean,
+ onMoveUp: () -> Unit,
+ onMoveDown: () -> Unit,
+ onRemove: () -> Unit
+) {
+ Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth()) {
+ Text(
+ "${assignment.epgSourceName} (priority: ${assignment.priority})",
+ style = MaterialTheme.typography.bodySmall,
+ color = Color.White,
+ modifier = Modifier.weight(1f)
+ )
+ val priorityActionShape = RoundedCornerShape(6.dp)
+ Row(horizontalArrangement = Arrangement.spacedBy(6.dp), verticalAlignment = Alignment.CenterVertically) {
+ ProviderEpgAssignmentButton(
+ label = "Up",
+ enabled = canMoveUp,
+ shape = priorityActionShape,
+ onClick = onMoveUp
+ )
+ ProviderEpgAssignmentButton(
+ label = "Down",
+ enabled = canMoveDown,
+ shape = priorityActionShape,
+ onClick = onMoveDown
+ )
+ }
+ Spacer(modifier = Modifier.width(6.dp))
+ TvClickableSurface(
+ onClick = onRemove,
+ shape = ClickableSurfaceDefaults.shape(priorityActionShape),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Color(0xFFEF5350).copy(alpha = 0.12f),
+ focusedContainerColor = Color(0xFFEF5350).copy(alpha = 0.25f)
+ ),
+ border = epgActionBorder(priorityActionShape),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
+ ) {
+ Text("Remove", modifier = Modifier.padding(horizontal = 8.dp, vertical = 4.dp), style = MaterialTheme.typography.labelSmall, color = Color(0xFFEF5350))
+ }
+ }
+}
+
+@Composable
+private fun ProviderEpgAssignmentButton(
+ label: String,
+ enabled: Boolean,
+ shape: RoundedCornerShape,
+ onClick: () -> Unit
+) {
+ TvClickableSurface(
+ onClick = onClick,
+ enabled = enabled,
+ shape = ClickableSurfaceDefaults.shape(shape),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Color.White.copy(alpha = 0.08f),
+ focusedContainerColor = Color.White.copy(alpha = 0.16f),
+ disabledContainerColor = Color.White.copy(alpha = 0.04f)
+ ),
+ border = epgActionBorder(shape, enabled = enabled),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
+ ) {
+ Text(label, modifier = Modifier.padding(horizontal = 8.dp, vertical = 4.dp), style = MaterialTheme.typography.labelSmall, color = Color.White)
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsEpgSection.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsEpgSection.kt
index 90f6b8d3..94a63e65 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsEpgSection.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsEpgSection.kt
@@ -75,105 +75,17 @@ internal fun LazyListScope.epgSourcesSection(
}
} else {
items(epgSources, key = { source -> "epg-source-${source.id}" }) { source ->
- Box(
- modifier = Modifier
- .fillMaxWidth()
- .clip(RoundedCornerShape(12.dp))
- .background(Color.White.copy(alpha = 0.06f))
- ) {
- Column(modifier = Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(4.dp)) {
- Row(verticalAlignment = Alignment.CenterVertically) {
- Column(modifier = Modifier.weight(1f)) {
- Text(source.name, style = MaterialTheme.typography.titleSmall, color = Color.White)
- Text(displayableEpgUrl(source.url), style = MaterialTheme.typography.bodySmall, color = OnSurfaceDim, maxLines = 1)
- if (source.lastError != null) {
- Text("Error: ${source.lastError}", style = MaterialTheme.typography.bodySmall, color = Color(0xFFEF5350))
- }
- if (source.lastSuccessAt > 0L) {
- val ago = (System.currentTimeMillis() - source.lastSuccessAt) / 60000
- Text("Last synced: ${ago}m ago", style = MaterialTheme.typography.bodySmall, color = OnSurfaceDim)
- }
- }
- val sourceActionShape = RoundedCornerShape(8.dp)
- Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
- TvClickableSurface(
- onClick = { viewModel.toggleEpgSourceEnabled(source.id, !source.enabled) },
- shape = ClickableSurfaceDefaults.shape(sourceActionShape),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = if (source.enabled) Color(0xFF66BB6A).copy(alpha = 0.2f) else Color.White.copy(alpha = 0.08f),
- focusedContainerColor = if (source.enabled) Color(0xFF66BB6A).copy(alpha = 0.4f) else Color.White.copy(alpha = 0.15f)
- ),
- border = epgActionBorder(sourceActionShape),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
- ) {
- Text(
- if (source.enabled) "ON" else "OFF",
- modifier = Modifier.padding(horizontal = 12.dp, vertical = 6.dp),
- style = MaterialTheme.typography.labelSmall,
- color = if (source.enabled) Color(0xFF66BB6A) else OnSurfaceDim
- )
- }
- TvClickableSurface(
- onClick = { viewModel.refreshEpgSource(source.id) },
- shape = ClickableSurfaceDefaults.shape(sourceActionShape),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Primary.copy(alpha = 0.15f),
- focusedContainerColor = Primary.copy(alpha = 0.3f)
- ),
- border = epgActionBorder(sourceActionShape, enabled = source.id !in uiState.refreshingEpgSourceIds),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
- enabled = source.id !in uiState.refreshingEpgSourceIds
- ) {
- Text(
- if (source.id in uiState.refreshingEpgSourceIds) "..." else "Refresh",
- modifier = Modifier.padding(horizontal = 12.dp, vertical = 6.dp),
- style = MaterialTheme.typography.labelSmall,
- color = Primary
- )
- }
- if (uiState.epgPendingDeleteSourceId == source.id) {
- TvClickableSurface(
- onClick = { viewModel.setPendingDeleteEpgSource(null) },
- shape = ClickableSurfaceDefaults.shape(sourceActionShape),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Color.White.copy(alpha = 0.08f),
- focusedContainerColor = Color.White.copy(alpha = 0.15f)
- ),
- border = epgActionBorder(sourceActionShape),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
- ) {
- Text("Cancel", modifier = Modifier.padding(horizontal = 12.dp, vertical = 6.dp), style = MaterialTheme.typography.labelSmall, color = OnSurfaceDim)
- }
- TvClickableSurface(
- onClick = { viewModel.deleteEpgSource(source.id) },
- shape = ClickableSurfaceDefaults.shape(sourceActionShape),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Color(0xFFEF5350).copy(alpha = 0.25f),
- focusedContainerColor = Color(0xFFEF5350).copy(alpha = 0.45f)
- ),
- border = epgActionBorder(sourceActionShape),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
- ) {
- Text("Confirm Delete", modifier = Modifier.padding(horizontal = 12.dp, vertical = 6.dp), style = MaterialTheme.typography.labelSmall, color = Color(0xFFEF5350))
- }
- } else {
- TvClickableSurface(
- onClick = { viewModel.setPendingDeleteEpgSource(source.id) },
- shape = ClickableSurfaceDefaults.shape(sourceActionShape),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Color(0xFFEF5350).copy(alpha = 0.12f),
- focusedContainerColor = Color(0xFFEF5350).copy(alpha = 0.25f)
- ),
- border = epgActionBorder(sourceActionShape),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
- ) {
- Text("Delete", modifier = Modifier.padding(horizontal = 12.dp, vertical = 6.dp), style = MaterialTheme.typography.labelSmall, color = Color(0xFFEF5350))
- }
- }
- }
- }
- }
- }
+ EpgSourceCard(
+ source = source,
+ isRefreshing = source.id in uiState.refreshingEpgSourceIds,
+ pendingDelete = uiState.epgPendingDeleteSourceId == source.id,
+ onToggleEnabled = { enabled -> viewModel.toggleEpgSourceEnabled(source.id, enabled) },
+ onRefresh = { viewModel.refreshEpgSource(source.id) },
+ onSetPendingDelete = { pending ->
+ viewModel.setPendingDeleteEpgSource(if (pending) source.id else null)
+ },
+ onDelete = { viewModel.deleteEpgSource(source.id) }
+ )
}
}
@@ -202,212 +114,17 @@ internal fun LazyListScope.epgSourcesSection(
viewModel.loadEpgAssignments(provider.id)
}
- Box(
- modifier = Modifier
- .fillMaxWidth()
- .clip(RoundedCornerShape(12.dp))
- .background(Color.White.copy(alpha = 0.06f))
- ) {
- Column(modifier = Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {
- Text(provider.name, style = MaterialTheme.typography.titleSmall, color = Color.White)
- if (resolutionSummary != null) {
- val matchedChannels = (resolutionSummary.totalChannels - resolutionSummary.unresolvedChannels).coerceAtLeast(0)
- val summaryParts = buildList {
- add("Matched $matchedChannels/${resolutionSummary.totalChannels} channels")
- if (resolutionSummary.exactIdMatches > 0) add("${resolutionSummary.exactIdMatches} exact")
- if (resolutionSummary.normalizedNameMatches > 0) add("${resolutionSummary.normalizedNameMatches} name")
- if (resolutionSummary.providerNativeMatches > 0) add("${resolutionSummary.providerNativeMatches} provider")
- if (resolutionSummary.manualMatches > 0) add("${resolutionSummary.manualMatches} manual")
- if (resolutionSummary.unresolvedChannels > 0) add("${resolutionSummary.unresolvedChannels} without EPG")
- if (resolutionSummary.lowConfidenceChannels > 0) add("${resolutionSummary.lowConfidenceChannels} weak")
- if (resolutionSummary.rematchCandidateChannels > 0) add("${resolutionSummary.rematchCandidateChannels} need review")
- }
- Text(
- text = summaryParts.joinToString(" \u2022 "),
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim
- )
- }
-
- if (assignments.isEmpty()) {
- Text("No EPG sources assigned", style = MaterialTheme.typography.bodySmall, color = OnSurfaceDim)
- } else {
- assignments.sortedBy { it.priority }.forEachIndexed { assignmentIndex, assignment ->
- Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth()) {
- Text(
- "${assignment.epgSourceName} (priority: ${assignment.priority})",
- style = MaterialTheme.typography.bodySmall,
- color = Color.White,
- modifier = Modifier.weight(1f)
- )
- val priorityActionShape = RoundedCornerShape(6.dp)
- Row(horizontalArrangement = Arrangement.spacedBy(6.dp), verticalAlignment = Alignment.CenterVertically) {
- TvClickableSurface(
- onClick = { viewModel.moveEpgSourceAssignmentUp(provider.id, assignment.epgSourceId) },
- enabled = assignmentIndex > 0,
- shape = ClickableSurfaceDefaults.shape(priorityActionShape),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Color.White.copy(alpha = 0.08f),
- focusedContainerColor = Color.White.copy(alpha = 0.16f),
- disabledContainerColor = Color.White.copy(alpha = 0.04f)
- ),
- border = epgActionBorder(priorityActionShape, enabled = assignmentIndex > 0),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
- ) {
- Text("Up", modifier = Modifier.padding(horizontal = 8.dp, vertical = 4.dp), style = MaterialTheme.typography.labelSmall, color = Color.White)
- }
- TvClickableSurface(
- onClick = { viewModel.moveEpgSourceAssignmentDown(provider.id, assignment.epgSourceId) },
- enabled = assignmentIndex < assignments.lastIndex,
- shape = ClickableSurfaceDefaults.shape(priorityActionShape),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Color.White.copy(alpha = 0.08f),
- focusedContainerColor = Color.White.copy(alpha = 0.16f),
- disabledContainerColor = Color.White.copy(alpha = 0.04f)
- ),
- border = epgActionBorder(priorityActionShape, enabled = assignmentIndex < assignments.lastIndex),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
- ) {
- Text("Down", modifier = Modifier.padding(horizontal = 8.dp, vertical = 4.dp), style = MaterialTheme.typography.labelSmall, color = Color.White)
- }
- }
- Spacer(modifier = Modifier.width(6.dp))
- TvClickableSurface(
- onClick = { viewModel.unassignEpgSourceFromProvider(provider.id, assignment.epgSourceId) },
- shape = ClickableSurfaceDefaults.shape(priorityActionShape),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Color(0xFFEF5350).copy(alpha = 0.12f),
- focusedContainerColor = Color(0xFFEF5350).copy(alpha = 0.25f)
- ),
- border = epgActionBorder(priorityActionShape),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
- ) {
- Text("Remove", modifier = Modifier.padding(horizontal = 8.dp, vertical = 4.dp), style = MaterialTheme.typography.labelSmall, color = Color(0xFFEF5350))
- }
- }
- }
- }
-
- if (unassignedSources.isNotEmpty()) {
- FlowRow(
- horizontalArrangement = Arrangement.spacedBy(8.dp),
- verticalArrangement = Arrangement.spacedBy(6.dp)
- ) {
- unassignedSources.forEach { source ->
- val assignActionShape = RoundedCornerShape(8.dp)
- TvClickableSurface(
- onClick = { viewModel.assignEpgSourceToProvider(provider.id, source.id) },
- shape = ClickableSurfaceDefaults.shape(assignActionShape),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Color(0xFF66BB6A).copy(alpha = 0.12f),
- focusedContainerColor = Color(0xFF66BB6A).copy(alpha = 0.25f)
- ),
- border = epgActionBorder(assignActionShape),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
- ) {
- Text("+ ${source.name}", modifier = Modifier.padding(horizontal = 12.dp, vertical = 6.dp), style = MaterialTheme.typography.labelSmall, color = Color(0xFF66BB6A))
- }
- }
- }
- }
- }
- }
- }
- }
-}
-
-@Composable
-private fun AddEpgSourceCard(viewModel: SettingsViewModel) {
- var newName by remember { mutableStateOf("") }
- var newUrl by remember { mutableStateOf("") }
- val context = LocalContext.current
- val filePickerLauncher = rememberLauncherForActivityResult(
- contract = ActivityResultContracts.OpenDocument()
- ) { uri ->
- if (uri != null) {
- try {
- context.contentResolver.takePersistableUriPermission(
- uri,
- android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION
- )
- } catch (_: SecurityException) {
- }
- newUrl = uri.toString()
- }
- }
-
- Box(
- modifier = Modifier
- .fillMaxWidth()
- .clip(RoundedCornerShape(12.dp))
- .background(Color.White.copy(alpha = 0.06f))
- ) {
- Column(modifier = Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {
- Text("Add EPG Source", style = MaterialTheme.typography.titleSmall, color = Color.White)
- EpgSourceTextField(value = newName, onValueChange = { newName = it }, placeholder = "Source name")
- Row(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalAlignment = Alignment.CenterVertically) {
- Box(modifier = Modifier.weight(1f)) {
- EpgSourceTextField(
- value = newUrl,
- onValueChange = { newUrl = it },
- placeholder = "XMLTV URL (HTTP/HTTPS) or browse file"
- )
- }
- val addActionShape = RoundedCornerShape(8.dp)
- TvClickableSurface(
- onClick = { filePickerLauncher.launch(arrayOf("*/*")) },
- shape = ClickableSurfaceDefaults.shape(addActionShape),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Primary.copy(alpha = 0.15f),
- focusedContainerColor = Primary.copy(alpha = 0.3f)
- ),
- border = epgActionBorder(addActionShape),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
- ) {
- Text("Browse", modifier = Modifier.padding(horizontal = 12.dp, vertical = 10.dp), style = MaterialTheme.typography.labelMedium, color = Primary)
- }
- }
- val addSourceShape = RoundedCornerShape(8.dp)
- TvClickableSurface(
- onClick = {
- if (newName.isNotBlank() && newUrl.isNotBlank()) {
- viewModel.addEpgSource(newName.trim(), newUrl.trim())
- newName = ""
- newUrl = ""
- }
- },
- shape = ClickableSurfaceDefaults.shape(addSourceShape),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Color(0xFF66BB6A).copy(alpha = 0.2f),
- focusedContainerColor = Color(0xFF66BB6A).copy(alpha = 0.4f)
- ),
- border = epgActionBorder(addSourceShape),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
- ) {
- Text("Add Source", modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp), color = Color(0xFF66BB6A), fontWeight = FontWeight.Medium)
- }
+ ProviderEpgAssignmentsCard(
+ providerName = provider.name,
+ assignments = assignments,
+ resolutionSummary = resolutionSummary,
+ unassignedSources = unassignedSources,
+ onMoveUp = { epgSourceId -> viewModel.moveEpgSourceAssignmentUp(provider.id, epgSourceId) },
+ onMoveDown = { epgSourceId -> viewModel.moveEpgSourceAssignmentDown(provider.id, epgSourceId) },
+ onRemove = { epgSourceId -> viewModel.unassignEpgSourceFromProvider(provider.id, epgSourceId) },
+ onAssign = { epgSourceId -> viewModel.assignEpgSourceToProvider(provider.id, epgSourceId) }
+ )
}
}
}
-@Composable
-private fun epgActionBorder(shape: RoundedCornerShape, enabled: Boolean = true) =
- ClickableSurfaceDefaults.border(
- border = Border(
- border = BorderStroke(1.dp, Color.White.copy(alpha = if (enabled) 0.08f else 0.04f)),
- shape = shape
- ),
- focusedBorder = Border(
- border = BorderStroke(FocusSpec.BorderWidth, Color.White),
- shape = shape
- )
- )
-
-private fun displayableEpgUrl(url: String): String = when {
- url.startsWith("content://") -> {
- val lastSegment = try { android.net.Uri.parse(url).lastPathSegment } catch (_: Exception) { null }
- val decoded = lastSegment?.let { android.net.Uri.decode(it) }?.substringAfterLast("/")?.substringAfterLast("\\")
- if (!decoded.isNullOrBlank() && decoded.length < 60) "local: $decoded" else "local file"
- }
- else -> url
-}
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsEpgSourceComponents.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsEpgSourceComponents.kt
new file mode 100644
index 00000000..7e97906b
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsEpgSourceComponents.kt
@@ -0,0 +1,241 @@
+package com.streamvault.app.ui.screens.settings
+
+import androidx.activity.compose.rememberLauncherForActivityResult
+import androidx.activity.result.contract.ActivityResultContracts
+import androidx.compose.foundation.BorderStroke
+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.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.clip
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.unit.dp
+import androidx.tv.material3.Border
+import androidx.tv.material3.ClickableSurfaceDefaults
+import androidx.tv.material3.MaterialTheme
+import androidx.tv.material3.Text
+import com.streamvault.app.ui.design.FocusSpec
+import com.streamvault.app.ui.interaction.TvClickableSurface
+import com.streamvault.app.ui.theme.OnSurfaceDim
+import com.streamvault.app.ui.theme.Primary
+import com.streamvault.domain.model.EpgSource
+
+@Composable
+internal fun EpgSourceCard(
+ source: EpgSource,
+ isRefreshing: Boolean,
+ pendingDelete: Boolean,
+ onToggleEnabled: (Boolean) -> Unit,
+ onRefresh: () -> Unit,
+ onSetPendingDelete: (Boolean) -> Unit,
+ onDelete: () -> Unit
+) {
+ Box(
+ modifier = Modifier
+ .fillMaxWidth()
+ .clip(RoundedCornerShape(12.dp))
+ .background(Color.White.copy(alpha = 0.06f))
+ ) {
+ Column(modifier = Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(4.dp)) {
+ Row(verticalAlignment = Alignment.CenterVertically) {
+ Column(modifier = Modifier.weight(1f)) {
+ Text(source.name, style = MaterialTheme.typography.titleSmall, color = Color.White)
+ Text(displayableEpgUrl(source.url), style = MaterialTheme.typography.bodySmall, color = OnSurfaceDim, maxLines = 1)
+ if (source.lastError != null) {
+ Text("Error: ${source.lastError}", style = MaterialTheme.typography.bodySmall, color = Color(0xFFEF5350))
+ }
+ if (source.lastSuccessAt > 0L) {
+ val ago = (System.currentTimeMillis() - source.lastSuccessAt) / 60000
+ Text("Last synced: ${ago}m ago", style = MaterialTheme.typography.bodySmall, color = OnSurfaceDim)
+ }
+ }
+ val sourceActionShape = RoundedCornerShape(8.dp)
+ Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
+ TvClickableSurface(
+ onClick = { onToggleEnabled(!source.enabled) },
+ shape = ClickableSurfaceDefaults.shape(sourceActionShape),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = if (source.enabled) Color(0xFF66BB6A).copy(alpha = 0.2f) else Color.White.copy(alpha = 0.08f),
+ focusedContainerColor = if (source.enabled) Color(0xFF66BB6A).copy(alpha = 0.4f) else Color.White.copy(alpha = 0.15f)
+ ),
+ border = epgActionBorder(sourceActionShape),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
+ ) {
+ Text(
+ if (source.enabled) "ON" else "OFF",
+ modifier = Modifier.padding(horizontal = 12.dp, vertical = 6.dp),
+ style = MaterialTheme.typography.labelSmall,
+ color = if (source.enabled) Color(0xFF66BB6A) else OnSurfaceDim
+ )
+ }
+ TvClickableSurface(
+ onClick = onRefresh,
+ shape = ClickableSurfaceDefaults.shape(sourceActionShape),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Primary.copy(alpha = 0.15f),
+ focusedContainerColor = Primary.copy(alpha = 0.3f)
+ ),
+ border = epgActionBorder(sourceActionShape, enabled = !isRefreshing),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
+ enabled = !isRefreshing
+ ) {
+ Text(
+ if (isRefreshing) "..." else "Refresh",
+ modifier = Modifier.padding(horizontal = 12.dp, vertical = 6.dp),
+ style = MaterialTheme.typography.labelSmall,
+ color = Primary
+ )
+ }
+ if (pendingDelete) {
+ TvClickableSurface(
+ onClick = { onSetPendingDelete(false) },
+ shape = ClickableSurfaceDefaults.shape(sourceActionShape),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Color.White.copy(alpha = 0.08f),
+ focusedContainerColor = Color.White.copy(alpha = 0.15f)
+ ),
+ border = epgActionBorder(sourceActionShape),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
+ ) {
+ Text("Cancel", modifier = Modifier.padding(horizontal = 12.dp, vertical = 6.dp), style = MaterialTheme.typography.labelSmall, color = OnSurfaceDim)
+ }
+ TvClickableSurface(
+ onClick = onDelete,
+ shape = ClickableSurfaceDefaults.shape(sourceActionShape),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Color(0xFFEF5350).copy(alpha = 0.25f),
+ focusedContainerColor = Color(0xFFEF5350).copy(alpha = 0.45f)
+ ),
+ border = epgActionBorder(sourceActionShape),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
+ ) {
+ Text("Confirm Delete", modifier = Modifier.padding(horizontal = 12.dp, vertical = 6.dp), style = MaterialTheme.typography.labelSmall, color = Color(0xFFEF5350))
+ }
+ } else {
+ TvClickableSurface(
+ onClick = { onSetPendingDelete(true) },
+ shape = ClickableSurfaceDefaults.shape(sourceActionShape),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Color(0xFFEF5350).copy(alpha = 0.12f),
+ focusedContainerColor = Color(0xFFEF5350).copy(alpha = 0.25f)
+ ),
+ border = epgActionBorder(sourceActionShape),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
+ ) {
+ Text("Delete", modifier = Modifier.padding(horizontal = 12.dp, vertical = 6.dp), style = MaterialTheme.typography.labelSmall, color = Color(0xFFEF5350))
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+@Composable
+internal fun AddEpgSourceCard(viewModel: SettingsViewModel) {
+ var newName by remember { mutableStateOf("") }
+ var newUrl by remember { mutableStateOf("") }
+ val context = LocalContext.current
+ val filePickerLauncher = rememberLauncherForActivityResult(
+ contract = ActivityResultContracts.OpenDocument()
+ ) { uri ->
+ if (uri != null) {
+ try {
+ context.contentResolver.takePersistableUriPermission(
+ uri,
+ android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION
+ )
+ } catch (_: SecurityException) {
+ }
+ newUrl = uri.toString()
+ }
+ }
+
+ Box(
+ modifier = Modifier
+ .fillMaxWidth()
+ .clip(RoundedCornerShape(12.dp))
+ .background(Color.White.copy(alpha = 0.06f))
+ ) {
+ Column(modifier = Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {
+ Text("Add EPG Source", style = MaterialTheme.typography.titleSmall, color = Color.White)
+ EpgSourceTextField(value = newName, onValueChange = { newName = it }, placeholder = "Source name")
+ Row(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalAlignment = Alignment.CenterVertically) {
+ Box(modifier = Modifier.weight(1f)) {
+ EpgSourceTextField(
+ value = newUrl,
+ onValueChange = { newUrl = it },
+ placeholder = "XMLTV URL (HTTP/HTTPS) or browse file"
+ )
+ }
+ val addActionShape = RoundedCornerShape(8.dp)
+ TvClickableSurface(
+ onClick = { filePickerLauncher.launch(arrayOf("*/*")) },
+ shape = ClickableSurfaceDefaults.shape(addActionShape),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Primary.copy(alpha = 0.15f),
+ focusedContainerColor = Primary.copy(alpha = 0.3f)
+ ),
+ border = epgActionBorder(addActionShape),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
+ ) {
+ Text("Browse", modifier = Modifier.padding(horizontal = 12.dp, vertical = 10.dp), style = MaterialTheme.typography.labelMedium, color = Primary)
+ }
+ }
+ val addSourceShape = RoundedCornerShape(8.dp)
+ TvClickableSurface(
+ onClick = {
+ if (newName.isNotBlank() && newUrl.isNotBlank()) {
+ viewModel.addEpgSource(newName.trim(), newUrl.trim())
+ newName = ""
+ newUrl = ""
+ }
+ },
+ shape = ClickableSurfaceDefaults.shape(addSourceShape),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Color(0xFF66BB6A).copy(alpha = 0.2f),
+ focusedContainerColor = Color(0xFF66BB6A).copy(alpha = 0.4f)
+ ),
+ border = epgActionBorder(addSourceShape),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
+ ) {
+ Text("Add Source", modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp), color = Color(0xFF66BB6A), fontWeight = FontWeight.Medium)
+ }
+ }
+ }
+}
+
+@Composable
+internal fun epgActionBorder(shape: RoundedCornerShape, enabled: Boolean = true) =
+ ClickableSurfaceDefaults.border(
+ border = Border(
+ border = BorderStroke(1.dp, Color.White.copy(alpha = if (enabled) 0.08f else 0.04f)),
+ shape = shape
+ ),
+ focusedBorder = Border(
+ border = BorderStroke(FocusSpec.BorderWidth, Color.White),
+ shape = shape
+ )
+ )
+
+private fun displayableEpgUrl(url: String): String = when {
+ url.startsWith("content://") -> {
+ val lastSegment = try { android.net.Uri.parse(url).lastPathSegment } catch (_: Exception) { null }
+ val decoded = lastSegment?.let { android.net.Uri.decode(it) }?.substringAfterLast("/")?.substringAfterLast("\\")
+ if (!decoded.isNullOrBlank() && decoded.length < 60) "local: $decoded" else "local file"
+ }
+ else -> url
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsFormatting.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsFormatting.kt
new file mode 100644
index 00000000..940e16f1
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsFormatting.kt
@@ -0,0 +1,311 @@
+package com.streamvault.app.ui.screens.settings
+
+import com.streamvault.app.R
+import com.streamvault.app.localization.localeForLanguageTag
+import com.streamvault.app.localization.supportedAppLanguageTags
+import com.streamvault.app.ui.model.LiveTvChannelMode
+import com.streamvault.app.ui.model.LiveTvQuickFilterVisibilityMode
+import com.streamvault.app.ui.model.VodViewMode
+import com.streamvault.domain.model.CategorySortMode
+import com.streamvault.domain.model.ChannelNumberingMode
+import com.streamvault.domain.model.ContentType
+import com.streamvault.domain.model.DecoderMode
+import com.streamvault.domain.model.GroupedChannelLabelMode
+import com.streamvault.domain.model.LiveChannelGroupingMode
+import com.streamvault.domain.model.LiveVariantPreferenceMode
+import com.streamvault.domain.model.PlayerSurfaceMode
+import java.text.DateFormat
+import java.util.Locale
+
+internal fun formatBytes(bytes: Long): String {
+ val kb = 1024.0
+ val mb = kb * 1024.0
+ val gb = mb * 1024.0
+ return when {
+ bytes >= gb -> String.format(Locale.getDefault(), "%.1f GB", bytes / gb)
+ bytes >= mb -> String.format(Locale.getDefault(), "%.1f MB", bytes / mb)
+ bytes >= kb -> String.format(Locale.getDefault(), "%.1f KB", bytes / kb)
+ else -> "$bytes B"
+ }
+}
+
+internal fun formatTimestamp(
+ timestampMs: Long,
+ dateTimeFormat: DateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT)
+): String {
+ if (timestampMs <= 0L) return "--:--"
+ return dateTimeFormat.format(java.util.Date(timestampMs))
+}
+
+internal data class AppLanguageOption(
+ val tag: String,
+ val label: String
+)
+
+internal fun supportedAppLanguages(systemDefaultLabel: String): List<AppLanguageOption> {
+ val localeTags = listOf("system") + supportedAppLanguageTags()
+
+ return localeTags.map { tag ->
+ AppLanguageOption(
+ tag = tag,
+ label = if (tag == "system") {
+ systemDefaultLabel
+ } else {
+ val locale = localeForLanguageTag(tag)
+ locale.getDisplayLanguage(locale)
+ .replaceFirstChar { character ->
+ if (character.isLowerCase()) {
+ character.titlecase(locale)
+ } else {
+ character.toString()
+ }
+ }
+ }
+ )
+ }
+}
+
+internal fun supportedAudioLanguages(autoLabel: String): List<AppLanguageOption> {
+ return buildList {
+ add(AppLanguageOption(tag = "auto", label = autoLabel))
+ addAll(supportedAppLanguages(autoLabel).filterNot { it.tag == "system" })
+ }
+}
+
+internal data class SubtitleScaleOption(
+ val scale: Float,
+ val label: (android.content.Context) -> String
+)
+
+internal data class SubtitleColorOption(
+ val colorArgb: Int,
+ val label: String
+)
+
+internal fun subtitleSizeOptions(): List<SubtitleScaleOption> {
+ return listOf(
+ SubtitleScaleOption(0.85f) { it.getString(R.string.settings_subtitle_size_small) },
+ SubtitleScaleOption(1f) { it.getString(R.string.settings_subtitle_size_default) },
+ SubtitleScaleOption(1.15f) { it.getString(R.string.settings_subtitle_size_large) },
+ SubtitleScaleOption(1.3f) { it.getString(R.string.settings_subtitle_size_extra_large) }
+ )
+}
+
+internal fun subtitleTextColorOptions(context: android.content.Context): List<SubtitleColorOption> {
+ return listOf(
+ SubtitleColorOption(0xFFFFFFFF.toInt(), context.getString(R.string.settings_subtitle_color_white)),
+ SubtitleColorOption(0xFFFFEB3B.toInt(), context.getString(R.string.settings_subtitle_color_yellow)),
+ SubtitleColorOption(0xFF80DEEA.toInt(), context.getString(R.string.settings_subtitle_color_cyan)),
+ SubtitleColorOption(0xFFA5D6A7.toInt(), context.getString(R.string.settings_subtitle_color_green))
+ )
+}
+
+internal fun subtitleBackgroundColorOptions(context: android.content.Context): List<SubtitleColorOption> {
+ return listOf(
+ SubtitleColorOption(0x00000000, context.getString(R.string.settings_subtitle_background_transparent)),
+ SubtitleColorOption(0x80000000.toInt(), context.getString(R.string.settings_subtitle_background_dim)),
+ SubtitleColorOption(0xCC000000.toInt(), context.getString(R.string.settings_subtitle_background_black)),
+ SubtitleColorOption(0xCC102A43.toInt(), context.getString(R.string.settings_subtitle_background_blue))
+ )
+}
+
+internal fun displayLanguageLabel(languageTag: String, defaultLabel: String): String {
+ if (languageTag.isBlank() || languageTag == "system" || languageTag == "auto") return defaultLabel
+ val locale = localeForLanguageTag(languageTag)
+ if (locale.language.isBlank()) return defaultLabel
+ return locale.getDisplayLanguage(Locale.getDefault())
+ .replaceFirstChar { character ->
+ if (character.isLowerCase()) {
+ character.titlecase(Locale.getDefault())
+ } else {
+ character.toString()
+ }
+ }
+}
+
+internal fun formatPlaybackSpeedLabel(speed: Float): String {
+ return if (speed % 1f == 0f) {
+ "${speed.toInt()}x"
+ } else {
+ "${("%.2f".format(Locale.US, speed)).trimEnd('0').trimEnd('.')}x"
+ }
+}
+
+internal fun playerTimeoutOptions(): List<Int> = listOf(2, 3, 4, 5, 6, 8, 10, 15, 20, 30)
+
+internal fun formatDecoderModeLabel(mode: DecoderMode, context: android.content.Context): String {
+ return when (mode) {
+ DecoderMode.AUTO -> context.getString(R.string.settings_decoder_auto)
+ DecoderMode.HARDWARE -> context.getString(R.string.settings_decoder_hardware)
+ DecoderMode.SOFTWARE -> context.getString(R.string.settings_decoder_software)
+ DecoderMode.COMPATIBILITY -> context.getString(R.string.settings_decoder_compatibility)
+ }
+}
+
+internal fun formatSurfaceModeLabel(
+ mode: PlayerSurfaceMode,
+ context: android.content.Context
+): String = when (mode) {
+ PlayerSurfaceMode.AUTO -> context.getString(R.string.settings_surface_auto)
+ PlayerSurfaceMode.SURFACE_VIEW -> context.getString(R.string.settings_surface_surface_view)
+ PlayerSurfaceMode.TEXTURE_VIEW -> context.getString(R.string.settings_surface_texture_view)
+}
+
+internal fun formatTimeoutSecondsLabel(seconds: Int, context: android.content.Context): String {
+ return context.resources.getQuantityString(
+ R.plurals.settings_timeout_seconds,
+ seconds,
+ seconds
+ )
+}
+
+internal fun formatSubtitleSizeLabel(scale: Float, context: android.content.Context): String {
+ return subtitleSizeOptions().firstOrNull { it.scale == scale }?.label?.invoke(context)
+ ?: context.getString(R.string.settings_subtitle_size_default)
+}
+
+internal fun formatSubtitleColorLabel(colorArgb: Int, options: List<SubtitleColorOption>): String {
+ return options.firstOrNull { it.colorArgb == colorArgb }?.label ?: options.first().label
+}
+
+internal fun formatQualityCapLabel(maxHeight: Int?, autoLabel: String): String {
+ return maxHeight?.let { "${it}p" } ?: autoLabel
+}
+
+internal fun formatSpeedTestValueLabel(speedTest: InternetSpeedTestUiModel): String {
+ return String.format(Locale.getDefault(), "%.1f Mbps", speedTest.megabitsPerSecond)
+}
+
+internal fun formatSpeedTestSummary(
+ speedTest: InternetSpeedTestUiModel,
+ context: android.content.Context,
+ dateTimeFormat: DateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT)
+): String {
+ val transportLabel = when (speedTest.transportLabel) {
+ InternetSpeedTestTransport.WIFI.name -> context.getString(R.string.settings_speed_test_transport_wifi)
+ InternetSpeedTestTransport.ETHERNET.name -> context.getString(R.string.settings_speed_test_transport_ethernet)
+ InternetSpeedTestTransport.CELLULAR.name -> context.getString(R.string.settings_speed_test_transport_cellular)
+ InternetSpeedTestTransport.OTHER.name -> context.getString(R.string.settings_speed_test_transport_other)
+ else -> context.getString(R.string.settings_speed_test_transport_unknown)
+ }
+ val measuredAtLabel = formatTimestamp(speedTest.measuredAtMs, dateTimeFormat)
+ return if (speedTest.isEstimated) {
+ context.getString(R.string.settings_speed_test_summary_estimated, transportLabel, measuredAtLabel)
+ } else {
+ context.getString(R.string.settings_speed_test_summary_measured, transportLabel, measuredAtLabel)
+ }
+}
+
+internal fun sortModeLabel(mode: CategorySortMode, context: android.content.Context): String {
+ return when (mode) {
+ CategorySortMode.DEFAULT -> context.getString(R.string.settings_category_sort_default)
+ CategorySortMode.TITLE_ASC -> context.getString(R.string.settings_category_sort_az)
+ CategorySortMode.TITLE_DESC -> context.getString(R.string.settings_category_sort_za)
+ CategorySortMode.COUNT_DESC -> context.getString(R.string.settings_category_sort_most_items)
+ CategorySortMode.COUNT_ASC -> context.getString(R.string.settings_category_sort_least_items)
+ }
+}
+
+internal fun formatCategorySortModeLabel(mode: CategorySortMode, context: android.content.Context): String {
+ return sortModeLabel(mode, context)
+}
+
+internal fun categoryTypeLabel(type: ContentType, context: android.content.Context): String {
+ return when (type) {
+ ContentType.LIVE -> context.getString(R.string.settings_category_sort_live)
+ ContentType.MOVIE -> context.getString(R.string.settings_category_sort_movies)
+ ContentType.SERIES -> context.getString(R.string.settings_category_sort_series)
+ ContentType.SERIES_EPISODE -> context.getString(R.string.settings_category_sort_series)
+ }
+}
+
+internal fun categoryTypeDescription(type: ContentType, context: android.content.Context): String {
+ return when (type) {
+ ContentType.LIVE -> context.getString(R.string.settings_category_type_live_description)
+ ContentType.MOVIE -> context.getString(R.string.settings_category_type_movies_description)
+ ContentType.SERIES -> context.getString(R.string.settings_category_type_series_description)
+ ContentType.SERIES_EPISODE -> context.getString(R.string.settings_category_type_series_description)
+ }
+}
+
+internal fun LiveTvChannelMode.labelResId(): Int = when (this) {
+ LiveTvChannelMode.COMFORTABLE -> R.string.settings_live_tv_mode_comfortable
+ LiveTvChannelMode.COMPACT -> R.string.settings_live_tv_mode_compact
+ LiveTvChannelMode.PRO -> R.string.settings_live_tv_mode_pro
+}
+
+internal fun LiveTvChannelMode.descriptionResId(): Int = when (this) {
+ LiveTvChannelMode.COMFORTABLE -> R.string.settings_live_tv_mode_comfortable_desc
+ LiveTvChannelMode.COMPACT -> R.string.settings_live_tv_mode_compact_desc
+ LiveTvChannelMode.PRO -> R.string.settings_live_tv_mode_pro_desc
+}
+
+internal fun LiveTvQuickFilterVisibilityMode.labelResId(): Int = when (this) {
+ LiveTvQuickFilterVisibilityMode.HIDE -> R.string.settings_live_tv_quick_filter_visibility_hide
+ LiveTvQuickFilterVisibilityMode.SHOW_WHEN_FILTERS_AVAILABLE -> R.string.settings_live_tv_quick_filter_visibility_available
+ LiveTvQuickFilterVisibilityMode.ALWAYS_VISIBLE -> R.string.settings_live_tv_quick_filter_visibility_always
+}
+
+internal fun LiveTvQuickFilterVisibilityMode.descriptionResId(): Int = when (this) {
+ LiveTvQuickFilterVisibilityMode.HIDE -> R.string.settings_live_tv_quick_filter_visibility_hide_desc
+ LiveTvQuickFilterVisibilityMode.SHOW_WHEN_FILTERS_AVAILABLE -> R.string.settings_live_tv_quick_filter_visibility_available_desc
+ LiveTvQuickFilterVisibilityMode.ALWAYS_VISIBLE -> R.string.settings_live_tv_quick_filter_visibility_always_desc
+}
+
+internal fun VodViewMode.labelResId(): Int = when (this) {
+ VodViewMode.MODERN -> R.string.settings_vod_view_mode_modern
+ VodViewMode.CLASSIC -> R.string.settings_vod_view_mode_classic
+}
+
+internal fun VodViewMode.descriptionResId(): Int = when (this) {
+ VodViewMode.MODERN -> R.string.settings_vod_view_mode_modern_desc
+ VodViewMode.CLASSIC -> R.string.settings_vod_view_mode_classic_desc
+}
+
+internal fun ChannelNumberingMode.labelResId(): Int = when (this) {
+ ChannelNumberingMode.GROUP -> R.string.settings_live_channel_numbering_group
+ ChannelNumberingMode.PROVIDER -> R.string.settings_live_channel_numbering_provider
+ ChannelNumberingMode.HIDDEN -> R.string.settings_live_channel_numbering_hidden
+}
+
+internal fun ChannelNumberingMode.descriptionResId(): Int = when (this) {
+ ChannelNumberingMode.GROUP -> R.string.settings_live_channel_numbering_group_desc
+ ChannelNumberingMode.PROVIDER -> R.string.settings_live_channel_numbering_provider_desc
+ ChannelNumberingMode.HIDDEN -> R.string.settings_live_channel_numbering_hidden_desc
+}
+
+internal fun LiveChannelGroupingMode.labelResId(): Int = when (this) {
+ LiveChannelGroupingMode.GROUPED -> R.string.settings_live_channel_grouping_grouped
+ LiveChannelGroupingMode.RAW_VARIANTS -> R.string.settings_live_channel_grouping_raw_variants
+}
+
+internal fun LiveChannelGroupingMode.descriptionResId(): Int = when (this) {
+ LiveChannelGroupingMode.GROUPED -> R.string.settings_live_channel_grouping_grouped_desc
+ LiveChannelGroupingMode.RAW_VARIANTS -> R.string.settings_live_channel_grouping_raw_variants_desc
+}
+
+internal fun GroupedChannelLabelMode.labelResId(): Int = when (this) {
+ GroupedChannelLabelMode.CANONICAL -> R.string.settings_grouped_channel_label_canonical
+ GroupedChannelLabelMode.ORIGINAL_PROVIDER_LABEL -> R.string.settings_grouped_channel_label_original
+ GroupedChannelLabelMode.HYBRID -> R.string.settings_grouped_channel_label_hybrid
+}
+
+internal fun GroupedChannelLabelMode.descriptionResId(): Int = when (this) {
+ GroupedChannelLabelMode.CANONICAL -> R.string.settings_grouped_channel_label_canonical_desc
+ GroupedChannelLabelMode.ORIGINAL_PROVIDER_LABEL -> R.string.settings_grouped_channel_label_original_desc
+ GroupedChannelLabelMode.HYBRID -> R.string.settings_grouped_channel_label_hybrid_desc
+}
+
+internal fun LiveVariantPreferenceMode.labelResId(): Int = when (this) {
+ LiveVariantPreferenceMode.BEST_QUALITY -> R.string.settings_live_variant_preference_best_quality
+ LiveVariantPreferenceMode.OBSERVED_ONLY -> R.string.settings_live_variant_preference_observed_only
+ LiveVariantPreferenceMode.BALANCED -> R.string.settings_live_variant_preference_balanced
+ LiveVariantPreferenceMode.STABILITY_FIRST -> R.string.settings_live_variant_preference_stability_first
+}
+
+internal fun LiveVariantPreferenceMode.descriptionResId(): Int = when (this) {
+ LiveVariantPreferenceMode.BEST_QUALITY -> R.string.settings_live_variant_preference_best_quality_desc
+ LiveVariantPreferenceMode.OBSERVED_ONLY -> R.string.settings_live_variant_preference_observed_only_desc
+ LiveVariantPreferenceMode.BALANCED -> R.string.settings_live_variant_preference_balanced_desc
+ LiveVariantPreferenceMode.STABILITY_FIRST -> R.string.settings_live_variant_preference_stability_first_desc
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsGuideDefaultCategoryBindings.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsGuideDefaultCategoryBindings.kt
new file mode 100644
index 00000000..6dd67000
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsGuideDefaultCategoryBindings.kt
@@ -0,0 +1,105 @@
+package com.streamvault.app.ui.screens.settings
+
+import com.streamvault.app.ui.model.applyProviderCategoryDisplayPreferences
+import com.streamvault.data.preferences.PreferencesRepository
+import com.streamvault.domain.model.ActiveLiveSource
+import com.streamvault.domain.model.Category
+import com.streamvault.domain.model.ContentType
+import com.streamvault.domain.model.VirtualCategoryIds
+import com.streamvault.domain.repository.ChannelRepository
+import com.streamvault.domain.repository.CombinedM3uRepository
+import com.streamvault.domain.usecase.GetCustomCategories
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.combine
+import kotlinx.coroutines.flow.flatMapLatest
+import kotlinx.coroutines.flow.flow
+import kotlinx.coroutines.flow.flowOf
+
+@OptIn(ExperimentalCoroutinesApi::class)
+internal fun observeGuideDefaultCategoryOptions(
+ combinedM3uRepository: CombinedM3uRepository,
+ channelRepository: ChannelRepository,
+ preferencesRepository: PreferencesRepository,
+ getCustomCategories: GetCustomCategories
+): Flow<List<Category>> {
+ return combinedM3uRepository.getActiveLiveSource().flatMapLatest { activeSource ->
+ when (activeSource) {
+ is ActiveLiveSource.CombinedM3uSource -> {
+ combine(
+ combinedM3uRepository.getCombinedCategories(activeSource.profileId),
+ flow {
+ emit(combinedM3uRepository.getProfile(activeSource.profileId)?.members.orEmpty())
+ }.flatMapLatest { members ->
+ getCustomCategories(
+ members.filter { it.enabled }.map { it.providerId },
+ ContentType.LIVE
+ )
+ }
+ ) { combinedCategories, customCategories ->
+ buildGuideDefaultCategoryOptions(
+ physicalCategories = combinedCategories.map { it.category },
+ customCategories = customCategories
+ )
+ }
+ }
+
+ is ActiveLiveSource.ProviderSource -> {
+ combine(
+ channelRepository.getCategories(activeSource.providerId),
+ getCustomCategories(activeSource.providerId, ContentType.LIVE),
+ preferencesRepository.getHiddenCategoryIds(activeSource.providerId, ContentType.LIVE),
+ preferencesRepository.getCategorySortMode(activeSource.providerId, ContentType.LIVE)
+ ) { categories, customCategories, hiddenCategoryIds, sortMode ->
+ val visibleProviderCategories = applyProviderCategoryDisplayPreferences(
+ categories = categories.filter { it.id != ChannelRepository.ALL_CHANNELS_ID },
+ hiddenCategoryIds = hiddenCategoryIds,
+ sortMode = sortMode
+ )
+ buildGuideDefaultCategoryOptions(
+ physicalCategories = visibleProviderCategories,
+ customCategories = customCategories
+ )
+ }
+ }
+
+ null -> flowOf(
+ listOf(
+ Category(
+ id = VirtualCategoryIds.FAVORITES,
+ name = "Favorites",
+ type = ContentType.LIVE,
+ isVirtual = true
+ ),
+ Category(
+ id = ChannelRepository.ALL_CHANNELS_ID,
+ name = "All Channels",
+ type = ContentType.LIVE
+ )
+ )
+ )
+ }
+ }
+}
+
+internal fun buildGuideDefaultCategoryOptions(
+ physicalCategories: List<Category>,
+ customCategories: List<Category>
+): List<Category> {
+ val favorites = customCategories.find { it.id == VirtualCategoryIds.FAVORITES }
+ return buildList {
+ if (favorites != null) {
+ add(favorites)
+ }
+ addAll(customCategories.filter { it.id != VirtualCategoryIds.FAVORITES })
+ add(
+ Category(
+ id = ChannelRepository.ALL_CHANNELS_ID,
+ name = "All Channels",
+ type = ContentType.LIVE,
+ count = physicalCategories.sumOf(Category::count)
+ )
+ )
+ addAll(physicalCategories)
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsInternetSpeedTestCard.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsInternetSpeedTestCard.kt
new file mode 100644
index 00000000..0ebe59c6
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsInternetSpeedTestCard.kt
@@ -0,0 +1,163 @@
+package com.streamvault.app.ui.screens.settings
+
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material3.CircularProgressIndicator
+import androidx.compose.runtime.Composable
+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.res.stringResource
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.unit.dp
+import androidx.tv.material3.ClickableSurfaceDefaults
+import androidx.tv.material3.MaterialTheme
+import androidx.tv.material3.Text
+import com.streamvault.app.R
+import com.streamvault.app.ui.interaction.TvClickableSurface
+import com.streamvault.app.ui.interaction.mouseClickable
+import com.streamvault.app.ui.theme.OnBackground
+import com.streamvault.app.ui.theme.OnSurface
+import com.streamvault.app.ui.theme.OnSurfaceDim
+import com.streamvault.app.ui.theme.Primary
+import com.streamvault.app.ui.theme.Secondary
+import com.streamvault.app.ui.theme.SurfaceElevated
+
+@Composable
+internal fun InternetSpeedTestCard(
+ valueLabel: String,
+ summary: String,
+ recommendationLabel: String,
+ isRunning: Boolean,
+ canApplyRecommendation: Boolean,
+ onRunTest: () -> Unit,
+ onApplyWifi: () -> Unit,
+ onApplyEthernet: () -> Unit
+) {
+ val focusRequester = remember { FocusRequester() }
+ TvClickableSurface(
+ onClick = onRunTest,
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(12.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = SurfaceElevated,
+ focusedContainerColor = Primary.copy(alpha = 0.18f)
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(top = 8.dp)
+ .focusRequester(focusRequester)
+ .mouseClickable(
+ focusRequester = focusRequester,
+ onClick = onRunTest
+ )
+ ) {
+ Column(
+ modifier = Modifier.padding(16.dp),
+ verticalArrangement = Arrangement.spacedBy(12.dp)
+ ) {
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Column(verticalArrangement = Arrangement.spacedBy(4.dp)) {
+ Text(
+ text = stringResource(R.string.settings_speed_test_title),
+ style = MaterialTheme.typography.bodyLarge,
+ color = OnBackground
+ )
+ Text(
+ text = valueLabel,
+ style = MaterialTheme.typography.titleSmall,
+ color = Primary,
+ fontWeight = FontWeight.SemiBold
+ )
+ }
+ if (isRunning) {
+ CircularProgressIndicator(
+ color = Primary,
+ strokeWidth = 2.dp,
+ modifier = Modifier.size(20.dp)
+ )
+ } else {
+ Text(
+ text = stringResource(R.string.settings_speed_test_run_action),
+ style = MaterialTheme.typography.labelLarge,
+ color = Primary
+ )
+ }
+ }
+
+ Text(
+ text = summary,
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim
+ )
+
+ Text(
+ text = stringResource(R.string.settings_speed_test_recommendation, recommendationLabel),
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurface
+ )
+
+ Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
+ TvClickableSurface(
+ onClick = onRunTest,
+ enabled = !isRunning,
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Primary.copy(alpha = 0.18f),
+ focusedContainerColor = Primary.copy(alpha = 0.32f)
+ )
+ ) {
+ Text(
+ text = stringResource(if (isRunning) R.string.settings_speed_test_running_action else R.string.settings_speed_test_run_action),
+ style = MaterialTheme.typography.labelMedium,
+ color = Primary,
+ modifier = Modifier.padding(horizontal = 14.dp, vertical = 10.dp)
+ )
+ }
+ TvClickableSurface(
+ onClick = onApplyWifi,
+ enabled = canApplyRecommendation && !isRunning,
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Secondary.copy(alpha = 0.16f),
+ focusedContainerColor = Secondary.copy(alpha = 0.28f)
+ )
+ ) {
+ Text(
+ text = stringResource(R.string.settings_speed_test_apply_wifi),
+ style = MaterialTheme.typography.labelMedium,
+ color = Secondary,
+ modifier = Modifier.padding(horizontal = 14.dp, vertical = 10.dp)
+ )
+ }
+ TvClickableSurface(
+ onClick = onApplyEthernet,
+ enabled = canApplyRecommendation && !isRunning,
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Secondary.copy(alpha = 0.16f),
+ focusedContainerColor = Secondary.copy(alpha = 0.28f)
+ )
+ ) {
+ Text(
+ text = stringResource(R.string.settings_speed_test_apply_ethernet),
+ style = MaterialTheme.typography.labelMedium,
+ color = Secondary,
+ modifier = Modifier.padding(horizontal = 14.dp, vertical = 10.dp)
+ )
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsLiveTvComponents.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsLiveTvComponents.kt
new file mode 100644
index 00000000..93532daf
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsLiveTvComponents.kt
@@ -0,0 +1,219 @@
+package com.streamvault.app.ui.screens.settings
+
+import androidx.compose.foundation.background
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material3.HorizontalDivider
+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.res.stringResource
+import androidx.compose.ui.unit.dp
+import androidx.tv.material3.ClickableSurfaceDefaults
+import androidx.tv.material3.MaterialTheme
+import androidx.tv.material3.Text
+import com.streamvault.app.R
+import com.streamvault.app.ui.components.dialogs.PremiumDialog
+import com.streamvault.app.ui.components.dialogs.PremiumDialogFooterButton
+import com.streamvault.app.ui.interaction.TvClickableSurface
+import com.streamvault.app.ui.model.LiveTvChannelMode
+import com.streamvault.app.ui.model.LiveTvQuickFilterVisibilityMode
+import com.streamvault.app.ui.theme.ErrorColor
+import com.streamvault.app.ui.theme.OnBackground
+import com.streamvault.app.ui.theme.OnSurfaceDim
+import com.streamvault.app.ui.theme.Primary
+import com.streamvault.app.ui.theme.Secondary
+import com.streamvault.app.ui.theme.SurfaceElevated
+
+internal enum class ParentalAction {
+ ChangeLevel, ChangePin, SetNewPin
+}
+
+@Composable
+internal fun ParentalControlCard(
+ level: Int,
+ hasParentalPin: Boolean,
+ hasActiveProvider: Boolean,
+ onChangeLevel: () -> Unit,
+ onChangePin: () -> Unit
+) {
+ Column(
+ modifier = Modifier
+ .fillMaxWidth()
+ .background(SurfaceElevated, RoundedCornerShape(8.dp))
+ .padding(16.dp),
+ verticalArrangement = Arrangement.spacedBy(16.dp)
+ ) {
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Column {
+ Text(stringResource(R.string.settings_protection_level), style = MaterialTheme.typography.bodyLarge, color = OnBackground)
+ Text(
+ text = when (level) {
+ 0 -> stringResource(R.string.settings_level_off)
+ 1 -> stringResource(R.string.settings_level_locked)
+ 2 -> stringResource(R.string.settings_level_private)
+ 3 -> stringResource(R.string.settings_level_hidden)
+ else -> stringResource(R.string.settings_level_unknown)
+ },
+ style = MaterialTheme.typography.bodyMedium,
+ color = if (level == 0) ErrorColor else Primary
+ )
+ }
+
+ TvClickableSurface(
+ onClick = onChangeLevel,
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(6.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Secondary.copy(alpha = 0.2f),
+ focusedContainerColor = Secondary.copy(alpha = 0.5f),
+ contentColor = Secondary,
+ focusedContentColor = Secondary
+ )
+ ) {
+ Text(
+ text = stringResource(R.string.settings_change),
+ style = MaterialTheme.typography.labelMedium,
+ modifier = Modifier.padding(horizontal = 16.dp, vertical = 10.dp)
+ )
+ }
+ }
+
+ HorizontalDivider(color = Color.White.copy(alpha = 0.1f))
+
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Text(stringResource(R.string.settings_parental_pin), style = MaterialTheme.typography.bodyLarge, color = OnBackground)
+
+ TvClickableSurface(
+ onClick = onChangePin,
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(6.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Primary.copy(alpha = 0.2f),
+ focusedContainerColor = Primary.copy(alpha = 0.5f),
+ contentColor = Primary,
+ focusedContentColor = Primary
+ )
+ ) {
+ Text(
+ text = stringResource(if (hasParentalPin) R.string.settings_change_pin else R.string.settings_set_pin),
+ style = MaterialTheme.typography.labelMedium,
+ modifier = Modifier.padding(horizontal = 16.dp, vertical = 10.dp)
+ )
+ }
+ }
+ }
+}
+
+@Composable
+internal fun LiveTvChannelModeDialog(
+ selectedMode: LiveTvChannelMode,
+ onDismiss: () -> Unit,
+ onModeSelected: (LiveTvChannelMode) -> Unit
+) {
+ PremiumDialog(
+ title = stringResource(R.string.settings_live_tv_channel_mode),
+ subtitle = stringResource(R.string.settings_live_tv_channel_mode_subtitle),
+ onDismissRequest = onDismiss,
+ widthFraction = 0.52f,
+ content = {
+ Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
+ LiveTvChannelMode.entries.forEach { mode ->
+ TvClickableSurface(
+ onClick = { onModeSelected(mode) },
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(14.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = if (mode == selectedMode) Primary.copy(alpha = 0.18f) else SurfaceElevated,
+ focusedContainerColor = Primary.copy(alpha = 0.28f)
+ ),
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ Column(
+ modifier = Modifier.padding(horizontal = 16.dp, vertical = 14.dp),
+ verticalArrangement = Arrangement.spacedBy(4.dp)
+ ) {
+ Text(
+ text = stringResource(mode.labelResId()),
+ style = MaterialTheme.typography.titleSmall,
+ color = if (mode == selectedMode) Primary else OnBackground
+ )
+ Text(
+ text = stringResource(mode.descriptionResId()),
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim
+ )
+ }
+ }
+ }
+ }
+ },
+ footer = {
+ PremiumDialogFooterButton(
+ label = stringResource(R.string.settings_cancel),
+ onClick = onDismiss
+ )
+ }
+ )
+}
+
+@Composable
+internal fun LiveTvQuickFilterVisibilityDialog(
+ selectedMode: LiveTvQuickFilterVisibilityMode,
+ onDismiss: () -> Unit,
+ onModeSelected: (LiveTvQuickFilterVisibilityMode) -> Unit
+) {
+ PremiumDialog(
+ title = stringResource(R.string.settings_live_tv_quick_filter_visibility),
+ subtitle = stringResource(R.string.settings_live_tv_quick_filter_visibility_subtitle),
+ onDismissRequest = onDismiss,
+ widthFraction = 0.52f,
+ content = {
+ Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
+ LiveTvQuickFilterVisibilityMode.entries.forEach { mode ->
+ TvClickableSurface(
+ onClick = { onModeSelected(mode) },
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(14.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = if (mode == selectedMode) Primary.copy(alpha = 0.18f) else SurfaceElevated,
+ focusedContainerColor = Primary.copy(alpha = 0.28f)
+ ),
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ Column(
+ modifier = Modifier.padding(horizontal = 16.dp, vertical = 14.dp),
+ verticalArrangement = Arrangement.spacedBy(4.dp)
+ ) {
+ Text(
+ text = stringResource(mode.labelResId()),
+ style = MaterialTheme.typography.titleSmall,
+ color = if (mode == selectedMode) Primary else OnBackground
+ )
+ Text(
+ text = stringResource(mode.descriptionResId()),
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim
+ )
+ }
+ }
+ }
+ }
+ },
+ footer = {
+ PremiumDialogFooterButton(
+ label = stringResource(R.string.settings_cancel),
+ onClick = onDismiss
+ )
+ }
+ )
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsModeDialogs.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsModeDialogs.kt
new file mode 100644
index 00000000..c37f191d
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsModeDialogs.kt
@@ -0,0 +1,282 @@
+package com.streamvault.app.ui.screens.settings
+
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.unit.dp
+import androidx.tv.material3.ClickableSurfaceDefaults
+import androidx.tv.material3.MaterialTheme
+import androidx.tv.material3.Text
+import com.streamvault.app.R
+import com.streamvault.app.ui.components.dialogs.PremiumDialog
+import com.streamvault.app.ui.components.dialogs.PremiumDialogFooterButton
+import com.streamvault.app.ui.interaction.TvClickableSurface
+import com.streamvault.app.ui.model.VodViewMode
+import com.streamvault.app.ui.theme.OnBackground
+import com.streamvault.app.ui.theme.OnSurfaceDim
+import com.streamvault.app.ui.theme.Primary
+import com.streamvault.app.ui.theme.SurfaceElevated
+import com.streamvault.domain.model.ChannelNumberingMode
+import com.streamvault.domain.model.GroupedChannelLabelMode
+import com.streamvault.domain.model.LiveChannelGroupingMode
+import com.streamvault.domain.model.LiveVariantPreferenceMode
+
+@Composable
+internal fun VodViewModeDialog(
+ selectedMode: VodViewMode,
+ onDismiss: () -> Unit,
+ onModeSelected: (VodViewMode) -> Unit
+) {
+ PremiumDialog(
+ title = stringResource(R.string.settings_vod_view_mode),
+ subtitle = stringResource(R.string.settings_vod_view_mode_subtitle),
+ onDismissRequest = onDismiss,
+ widthFraction = 0.52f,
+ content = {
+ Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
+ VodViewMode.entries.forEach { mode ->
+ TvClickableSurface(
+ onClick = { onModeSelected(mode) },
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(14.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = if (mode == selectedMode) Primary.copy(alpha = 0.18f) else SurfaceElevated,
+ focusedContainerColor = Primary.copy(alpha = 0.28f)
+ ),
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ Column(
+ modifier = Modifier.padding(horizontal = 16.dp, vertical = 14.dp),
+ verticalArrangement = Arrangement.spacedBy(4.dp)
+ ) {
+ Text(
+ text = stringResource(mode.labelResId()),
+ style = MaterialTheme.typography.titleSmall,
+ color = if (mode == selectedMode) Primary else OnBackground
+ )
+ Text(
+ text = stringResource(mode.descriptionResId()),
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim
+ )
+ }
+ }
+ }
+ }
+ },
+ footer = {
+ PremiumDialogFooterButton(
+ label = stringResource(R.string.settings_cancel),
+ onClick = onDismiss
+ )
+ }
+ )
+}
+
+@Composable
+internal fun LiveChannelNumberingModeDialog(
+ selectedMode: ChannelNumberingMode,
+ onDismiss: () -> Unit,
+ onModeSelected: (ChannelNumberingMode) -> Unit
+) {
+ PremiumDialog(
+ title = stringResource(R.string.settings_live_channel_numbering_mode),
+ subtitle = stringResource(R.string.settings_live_channel_numbering_mode_subtitle),
+ onDismissRequest = onDismiss,
+ widthFraction = 0.52f,
+ content = {
+ Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
+ ChannelNumberingMode.entries.forEach { mode ->
+ TvClickableSurface(
+ onClick = { onModeSelected(mode) },
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(14.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = if (mode == selectedMode) Primary.copy(alpha = 0.18f) else SurfaceElevated,
+ focusedContainerColor = Primary.copy(alpha = 0.28f)
+ ),
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ Column(
+ modifier = Modifier.padding(horizontal = 16.dp, vertical = 14.dp),
+ verticalArrangement = Arrangement.spacedBy(4.dp)
+ ) {
+ Text(
+ text = stringResource(mode.labelResId()),
+ style = MaterialTheme.typography.titleSmall,
+ color = if (mode == selectedMode) Primary else OnBackground
+ )
+ Text(
+ text = stringResource(mode.descriptionResId()),
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim
+ )
+ }
+ }
+ }
+ }
+ },
+ footer = {
+ PremiumDialogFooterButton(
+ label = stringResource(R.string.settings_cancel),
+ onClick = onDismiss
+ )
+ }
+ )
+}
+
+@Composable
+internal fun LiveChannelGroupingModeDialog(
+ selectedMode: LiveChannelGroupingMode,
+ onDismiss: () -> Unit,
+ onModeSelected: (LiveChannelGroupingMode) -> Unit
+) {
+ PremiumDialog(
+ title = stringResource(R.string.settings_live_channel_grouping_mode),
+ subtitle = stringResource(R.string.settings_live_channel_grouping_mode_subtitle),
+ onDismissRequest = onDismiss,
+ widthFraction = 0.52f,
+ content = {
+ Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
+ LiveChannelGroupingMode.entries.forEach { mode ->
+ TvClickableSurface(
+ onClick = { onModeSelected(mode) },
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(14.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = if (mode == selectedMode) Primary.copy(alpha = 0.18f) else SurfaceElevated,
+ focusedContainerColor = Primary.copy(alpha = 0.28f)
+ ),
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ Column(
+ modifier = Modifier.padding(horizontal = 16.dp, vertical = 14.dp),
+ verticalArrangement = Arrangement.spacedBy(4.dp)
+ ) {
+ Text(
+ text = stringResource(mode.labelResId()),
+ style = MaterialTheme.typography.titleSmall,
+ color = if (mode == selectedMode) Primary else OnBackground
+ )
+ Text(
+ text = stringResource(mode.descriptionResId()),
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim
+ )
+ }
+ }
+ }
+ }
+ },
+ footer = {
+ PremiumDialogFooterButton(
+ label = stringResource(R.string.settings_cancel),
+ onClick = onDismiss
+ )
+ }
+ )
+}
+
+@Composable
+internal fun GroupedChannelLabelModeDialog(
+ selectedMode: GroupedChannelLabelMode,
+ onDismiss: () -> Unit,
+ onModeSelected: (GroupedChannelLabelMode) -> Unit
+) {
+ PremiumDialog(
+ title = stringResource(R.string.settings_grouped_channel_label_mode),
+ subtitle = stringResource(R.string.settings_grouped_channel_label_mode_subtitle),
+ onDismissRequest = onDismiss,
+ widthFraction = 0.52f,
+ content = {
+ Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
+ GroupedChannelLabelMode.entries.forEach { mode ->
+ TvClickableSurface(
+ onClick = { onModeSelected(mode) },
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(14.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = if (mode == selectedMode) Primary.copy(alpha = 0.18f) else SurfaceElevated,
+ focusedContainerColor = Primary.copy(alpha = 0.28f)
+ ),
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ Column(
+ modifier = Modifier.padding(horizontal = 16.dp, vertical = 14.dp),
+ verticalArrangement = Arrangement.spacedBy(4.dp)
+ ) {
+ Text(
+ text = stringResource(mode.labelResId()),
+ style = MaterialTheme.typography.titleSmall,
+ color = if (mode == selectedMode) Primary else OnBackground
+ )
+ Text(
+ text = stringResource(mode.descriptionResId()),
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim
+ )
+ }
+ }
+ }
+ }
+ },
+ footer = {
+ PremiumDialogFooterButton(
+ label = stringResource(R.string.settings_cancel),
+ onClick = onDismiss
+ )
+ }
+ )
+}
+
+@Composable
+internal fun LiveVariantPreferenceModeDialog(
+ selectedMode: LiveVariantPreferenceMode,
+ onDismiss: () -> Unit,
+ onModeSelected: (LiveVariantPreferenceMode) -> Unit
+) {
+ PremiumDialog(
+ title = stringResource(R.string.settings_live_variant_preference_mode),
+ subtitle = stringResource(R.string.settings_live_variant_preference_mode_subtitle),
+ onDismissRequest = onDismiss,
+ widthFraction = 0.52f,
+ content = {
+ Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
+ LiveVariantPreferenceMode.entries.forEach { mode ->
+ TvClickableSurface(
+ onClick = { onModeSelected(mode) },
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(14.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = if (mode == selectedMode) Primary.copy(alpha = 0.18f) else SurfaceElevated,
+ focusedContainerColor = Primary.copy(alpha = 0.28f)
+ ),
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ Column(
+ modifier = Modifier.padding(horizontal = 16.dp, vertical = 14.dp),
+ verticalArrangement = Arrangement.spacedBy(4.dp)
+ ) {
+ Text(
+ text = stringResource(mode.labelResId()),
+ style = MaterialTheme.typography.titleSmall,
+ color = if (mode == selectedMode) Primary else OnBackground
+ )
+ Text(
+ text = stringResource(mode.descriptionResId()),
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim
+ )
+ }
+ }
+ }
+ }
+ },
+ footer = {
+ PremiumDialogFooterButton(
+ label = stringResource(R.string.settings_cancel),
+ onClick = onDismiss
+ )
+ }
+ )
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsNavigationRail.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsNavigationRail.kt
new file mode 100644
index 00000000..2b294e71
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsNavigationRail.kt
@@ -0,0 +1,94 @@
+package com.streamvault.app.ui.screens.settings
+
+import androidx.compose.foundation.background
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.PaddingValues
+import androidx.compose.foundation.layout.fillMaxHeight
+import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.lazy.LazyColumn
+import androidx.compose.foundation.lazy.itemsIndexed
+import androidx.compose.runtime.Composable
+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.res.stringResource
+import androidx.compose.ui.unit.dp
+import com.streamvault.app.R
+import com.streamvault.app.ui.theme.Primary
+
+private data class SettingsNavEntry(
+ val label: String,
+ val icon: String,
+ val accent: Color
+)
+
+@Composable
+internal fun SettingsNavigationRail(
+ selectedCategory: Int,
+ focusRequester: FocusRequester,
+ onCategorySelected: (Int) -> Unit
+) {
+ val entries = listOf(
+ SettingsNavEntry(
+ label = stringResource(R.string.settings_providers),
+ icon = "P",
+ accent = Primary
+ ),
+ SettingsNavEntry(
+ label = stringResource(R.string.settings_playback),
+ icon = ">",
+ accent = Color(0xFF9E8FFF)
+ ),
+ SettingsNavEntry(
+ label = stringResource(R.string.settings_browsing),
+ icon = "#",
+ accent = Color(0xFF26A69A)
+ ),
+ SettingsNavEntry(
+ label = stringResource(R.string.settings_privacy),
+ icon = "L",
+ accent = Color(0xFFFFB74D)
+ ),
+ SettingsNavEntry(
+ label = stringResource(R.string.settings_recording_title),
+ icon = "R",
+ accent = Color(0xFFEF5350)
+ ),
+ SettingsNavEntry(
+ label = stringResource(R.string.settings_backup_restore),
+ icon = "B",
+ accent = Color(0xFF42A5F5)
+ ),
+ SettingsNavEntry(
+ label = "EPG Sources",
+ icon = "E",
+ accent = Color(0xFF66BB6A)
+ ),
+ SettingsNavEntry(
+ label = stringResource(R.string.settings_about),
+ icon = "i",
+ accent = Color(0xFF78909C)
+ )
+ )
+
+ LazyColumn(
+ modifier = Modifier
+ .width(236.dp)
+ .fillMaxHeight()
+ .background(Color.Black.copy(alpha = 0.25f)),
+ contentPadding = PaddingValues(top = 76.dp, bottom = 16.dp),
+ verticalArrangement = Arrangement.spacedBy(2.dp)
+ ) {
+ itemsIndexed(entries) { index, entry ->
+ SettingsNavItem(
+ label = entry.label,
+ badgeChar = entry.icon,
+ accentColor = entry.accent,
+ isSelected = selectedCategory == index,
+ modifier = if (selectedCategory == index) Modifier.focusRequester(focusRequester) else Modifier,
+ onClick = { onCategorySelected(index) }
+ )
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsObserverRegistrations.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsObserverRegistrations.kt
new file mode 100644
index 00000000..732fd924
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsObserverRegistrations.kt
@@ -0,0 +1,189 @@
+package com.streamvault.app.ui.screens.settings
+
+import android.app.Application
+import com.streamvault.app.update.AppUpdateInstaller
+import com.streamvault.data.preferences.PreferencesRepository
+import com.streamvault.domain.manager.RecordingManager
+import com.streamvault.domain.model.RecordingItem
+import com.streamvault.domain.repository.CategoryRepository
+import com.streamvault.domain.repository.ChannelRepository
+import com.streamvault.domain.repository.CombinedM3uRepository
+import com.streamvault.domain.repository.EpgSourceRepository
+import com.streamvault.domain.repository.SyncMetadataRepository
+import com.streamvault.domain.repository.ProviderRepository
+import com.streamvault.domain.usecase.GetCustomCategories
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.combine
+import kotlinx.coroutines.flow.distinctUntilChanged
+import kotlinx.coroutines.flow.update
+import kotlinx.coroutines.launch
+
+internal fun registerSettingsAppUpdateObservers(
+ scope: CoroutineScope,
+ preferencesRepository: PreferencesRepository,
+ appUpdateActions: SettingsAppUpdateActions,
+ appUpdateInstaller: AppUpdateInstaller,
+ uiState: MutableStateFlow<SettingsUiState>
+) {
+ scope.launch {
+ combine(
+ preferencesRepository.autoCheckAppUpdates,
+ preferencesRepository.lastAppUpdateCheckTimestamp,
+ preferencesRepository.autoDownloadAppUpdates
+ ) { autoCheckEnabled, lastCheckedAt, autoDownload ->
+ Triple(autoCheckEnabled, lastCheckedAt, autoDownload)
+ }.distinctUntilChanged().collect { (autoCheckEnabled, lastCheckedAt, autoDownload) ->
+ if (autoCheckEnabled && appUpdateActions.shouldAutoCheckForUpdates(lastCheckedAt)) {
+ appUpdateActions.checkForAppUpdates(
+ scope = scope,
+ manual = false,
+ isRemoteVersionNewer = ::isRemoteVersionNewer,
+ autoDownload = autoDownload
+ )
+ }
+ }
+ }
+
+ scope.launch {
+ appUpdateInstaller.downloadState.collect { downloadState ->
+ uiState.update {
+ it.copy(appUpdate = it.appUpdate.withDownloadState(downloadState))
+ }
+ }
+ }
+
+ scope.launch {
+ appUpdateInstaller.refreshState()
+ }
+}
+
+internal fun registerCombinedProfileObservers(
+ scope: CoroutineScope,
+ combinedM3uRepository: CombinedM3uRepository,
+ uiState: MutableStateFlow<SettingsUiState>
+) {
+ scope.launch {
+ combinedM3uRepository.getProfiles().collect { profiles ->
+ uiState.update { it.copy(combinedProfiles = profiles) }
+ }
+ }
+
+ scope.launch {
+ combinedM3uRepository.getAvailableM3uProviders().collect { providers ->
+ uiState.update { it.copy(availableM3uProviders = providers) }
+ }
+ }
+
+ scope.launch {
+ combinedM3uRepository.getActiveLiveSource().collect { activeSource ->
+ uiState.update { it.copy(activeLiveSource = activeSource) }
+ }
+ }
+}
+
+internal fun registerRecordingObservers(
+ scope: CoroutineScope,
+ recordingManager: RecordingManager,
+ preferencesRepository: PreferencesRepository,
+ uiState: MutableStateFlow<SettingsUiState>
+) {
+ scope.launch {
+ recordingManager.observeRecordingItems().collect { items ->
+ uiState.update { it.copy(recordingItems = items.sortedByDescending(RecordingItem::scheduledStartMs)) }
+ }
+ }
+
+ scope.launch {
+ recordingManager.observeStorageState().collect { storage ->
+ uiState.update { it.copy(recordingStorageState = storage) }
+ }
+ }
+
+ scope.launch {
+ preferencesRepository.recordingWifiOnly.collect { wifiOnly ->
+ uiState.update { it.copy(wifiOnlyRecording = wifiOnly) }
+ }
+ }
+
+ scope.launch {
+ preferencesRepository.recordingPaddingBeforeMinutes.collect { minutes ->
+ uiState.update { it.copy(recordingPaddingBeforeMinutes = minutes) }
+ }
+ }
+
+ scope.launch {
+ preferencesRepository.recordingPaddingAfterMinutes.collect { minutes ->
+ uiState.update { it.copy(recordingPaddingAfterMinutes = minutes) }
+ }
+ }
+}
+
+internal fun registerEpgObservers(
+ scope: CoroutineScope,
+ epgSourceRepository: EpgSourceRepository,
+ uiState: MutableStateFlow<SettingsUiState>
+) {
+ scope.launch {
+ epgSourceRepository.getAllSources().collect { sources ->
+ uiState.update { it.copy(epgSources = sources) }
+ }
+ }
+}
+
+internal fun registerDerivedStateObservers(
+ scope: CoroutineScope,
+ providerRepository: ProviderRepository,
+ syncMetadataRepository: SyncMetadataRepository,
+ application: Application,
+ preferencesRepository: PreferencesRepository,
+ activeProviderIdFlow: Flow<Long?>,
+ categoryRepository: CategoryRepository,
+ combinedM3uRepository: CombinedM3uRepository,
+ channelRepository: ChannelRepository,
+ getCustomCategories: GetCustomCategories,
+ uiState: MutableStateFlow<SettingsUiState>
+) {
+ scope.launch {
+ observeProviderDiagnostics(
+ providerRepository = providerRepository,
+ syncMetadataRepository = syncMetadataRepository,
+ application = application
+ ).collect { diagnosticsByProvider ->
+ uiState.update { it.copy(diagnosticsByProvider = diagnosticsByProvider) }
+ }
+ }
+
+ scope.launch {
+ preferencesRepository.lastMaintenanceSnapshot.collect { snapshot ->
+ uiState.update { it.copy(databaseMaintenance = snapshot?.toUiModel()) }
+ }
+ }
+
+ scope.launch {
+ observeCategoryManagement(
+ activeProviderIdFlow = activeProviderIdFlow,
+ preferencesRepository = preferencesRepository,
+ categoryRepository = categoryRepository
+ ).collect { snapshot ->
+ uiState.update {
+ it.copy(
+ categorySortModes = snapshot.categorySortModes,
+ hiddenCategories = snapshot.hiddenCategories
+ )
+ }
+ }
+ }
+
+ scope.launch {
+ observeGuideDefaultCategoryOptions(
+ combinedM3uRepository = combinedM3uRepository,
+ channelRepository = channelRepository,
+ preferencesRepository = preferencesRepository,
+ getCustomCategories = getCustomCategories
+ ).collect { categories ->
+ uiState.update { it.copy(guideDefaultCategoryOptions = categories) }
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsOperationalModels.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsOperationalModels.kt
new file mode 100644
index 00000000..737d6cec
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsOperationalModels.kt
@@ -0,0 +1,97 @@
+package com.streamvault.app.ui.screens.settings
+
+import com.streamvault.data.preferences.DatabaseMaintenanceSnapshot
+import com.streamvault.domain.model.Category
+import com.streamvault.domain.model.CategorySortMode
+import com.streamvault.domain.model.ContentType
+import com.streamvault.domain.model.VodSyncMode
+
+data class ProviderDiagnosticsUiModel(
+ val lastSyncStatus: String = "NONE",
+ val lastLiveSync: Long = 0L,
+ val lastMovieSync: Long = 0L,
+ val lastMovieAttempt: Long = 0L,
+ val lastMovieSuccess: Long = 0L,
+ val lastMoviePartial: Long = 0L,
+ val lastSeriesSync: Long = 0L,
+ val lastEpgSync: Long = 0L,
+ val liveCount: Int = 0,
+ val movieCount: Int = 0,
+ val seriesCount: Int = 0,
+ val epgCount: Int = 0,
+ val movieSyncMode: VodSyncMode = VodSyncMode.UNKNOWN,
+ val movieWarningsCount: Int = 0,
+ val movieCatalogStale: Boolean = false,
+ val liveSequentialFailuresRemembered: Boolean = false,
+ val liveHealthySyncStreak: Int = 0,
+ val movieParallelFailuresRemembered: Boolean = false,
+ val movieHealthySyncStreak: Int = 0,
+ val seriesSequentialFailuresRemembered: Boolean = false,
+ val seriesHealthySyncStreak: Int = 0,
+ val capabilitySummary: String = "",
+ val sourceLabel: String = "",
+ val expirySummary: String = "",
+ val connectionSummary: String = "",
+ val archiveSummary: String = ""
+) {
+ val hasHealthWarning: Boolean
+ get() = liveSequentialFailuresRemembered ||
+ movieParallelFailuresRemembered ||
+ seriesSequentialFailuresRemembered ||
+ movieCatalogStale ||
+ movieWarningsCount > 0
+}
+
+data class DatabaseMaintenanceUiModel(
+ val ranAt: Long,
+ val deletedPrograms: Int,
+ val deletedExternalProgrammes: Int,
+ val deletedOrphanEpisodes: Int,
+ val deletedStaleFavorites: Int,
+ val vacuumRan: Boolean,
+ val mainDbBytes: Long,
+ val walBytes: Long,
+ val reclaimableBytes: Long,
+ val channelRows: Long,
+ val movieRows: Long,
+ val seriesRows: Long,
+ val episodeRows: Long,
+ val programRows: Long,
+ val epgProgrammeRows: Long,
+ val playbackHistoryRows: Long,
+ val favoriteRows: Long
+)
+
+internal fun DatabaseMaintenanceSnapshot.toUiModel(): DatabaseMaintenanceUiModel =
+ DatabaseMaintenanceUiModel(
+ ranAt = ranAt,
+ deletedPrograms = deletedPrograms,
+ deletedExternalProgrammes = deletedExternalProgrammes,
+ deletedOrphanEpisodes = deletedOrphanEpisodes,
+ deletedStaleFavorites = deletedStaleFavorites,
+ vacuumRan = vacuumRan,
+ mainDbBytes = mainDbBytes,
+ walBytes = walBytes,
+ reclaimableBytes = reclaimableBytes,
+ channelRows = channelRows,
+ movieRows = movieRows,
+ seriesRows = seriesRows,
+ episodeRows = episodeRows,
+ programRows = programRows,
+ epgProgrammeRows = epgProgrammeRows,
+ playbackHistoryRows = playbackHistoryRows,
+ favoriteRows = favoriteRows
+ )
+
+data class InternetSpeedTestUiModel(
+ val megabitsPerSecond: Double,
+ val measuredAtMs: Long,
+ val transportLabel: String,
+ val recommendedMaxVideoHeight: Int?,
+ val isEstimated: Boolean
+)
+
+internal data class CategoryManagementSnapshot(
+ val categorySortModes: Map<ContentType, CategorySortMode> = emptyMap(),
+ val hiddenCategories: List<Category> = emptyList()
+)
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsPlaybackSection.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsPlaybackSection.kt
new file mode 100644
index 00000000..da5caeb2
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsPlaybackSection.kt
@@ -0,0 +1,295 @@
+package com.streamvault.app.ui.screens.settings
+
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.lazy.LazyListScope
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material3.HorizontalDivider
+import androidx.compose.material3.Switch
+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.res.stringResource
+import androidx.compose.ui.unit.dp
+import androidx.tv.material3.ClickableSurfaceDefaults
+import androidx.tv.material3.MaterialTheme
+import androidx.tv.material3.Text
+import com.streamvault.app.R
+import com.streamvault.app.ui.interaction.TvClickableSurface
+import com.streamvault.app.ui.theme.OnBackground
+import com.streamvault.app.ui.theme.OnSurface
+import com.streamvault.app.ui.theme.Primary
+
+internal fun LazyListScope.settingsPlaybackSection(
+ uiState: SettingsUiState,
+ viewModel: SettingsViewModel,
+ timeshiftDepthLabel: String,
+ decoderModeLabel: String,
+ surfaceModeLabel: String,
+ playbackSpeedLabel: String,
+ defaultStopTimerLabel: String,
+ defaultIdleTimerLabel: String,
+ audioVideoOffsetLabel: String,
+ controlsTimeoutLabel: String,
+ liveOverlayTimeoutLabel: String,
+ noticeTimeoutLabel: String,
+ diagnosticsTimeoutLabel: String,
+ preferredAudioLanguageLabel: String,
+ subtitleSizeLabel: String,
+ subtitleTextColorLabel: String,
+ subtitleBackgroundLabel: String,
+ wifiQualityLabel: String,
+ ethernetQualityLabel: String,
+ lastSpeedTestLabel: String,
+ lastSpeedTestSummary: String,
+ speedTestRecommendationLabel: String,
+ onShowTimeshiftDepthDialogChange: (Boolean) -> Unit,
+ onShowDecoderModeDialogChange: (Boolean) -> Unit,
+ onShowSurfaceModeDialogChange: (Boolean) -> Unit,
+ onShowPlaybackSpeedDialogChange: (Boolean) -> Unit,
+ onShowDefaultStopTimerDialogChange: (Boolean) -> Unit,
+ onShowDefaultIdleTimerDialogChange: (Boolean) -> Unit,
+ onShowAudioVideoOffsetDialogChange: (Boolean) -> Unit,
+ onShowControlsTimeoutDialogChange: (Boolean) -> Unit,
+ onShowLiveOverlayTimeoutDialogChange: (Boolean) -> Unit,
+ onShowNoticeTimeoutDialogChange: (Boolean) -> Unit,
+ onShowDiagnosticsTimeoutDialogChange: (Boolean) -> Unit,
+ onShowAudioLanguageDialogChange: (Boolean) -> Unit,
+ onShowSubtitleSizeDialogChange: (Boolean) -> Unit,
+ onShowSubtitleTextColorDialogChange: (Boolean) -> Unit,
+ onShowSubtitleBackgroundDialogChange: (Boolean) -> Unit,
+ onShowWifiQualityDialogChange: (Boolean) -> Unit,
+ onShowEthernetQualityDialogChange: (Boolean) -> Unit
+) {
+ item {
+ TvClickableSurface(
+ onClick = { viewModel.setPreventStandbyDuringPlayback(!uiState.preventStandbyDuringPlayback) },
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Color.Transparent,
+ focusedContainerColor = Primary.copy(alpha = 0.15f)
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ Row(
+ modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 12.dp),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Column(modifier = Modifier.weight(1f)) {
+ Text(text = stringResource(R.string.settings_prevent_standby), style = MaterialTheme.typography.bodyMedium, color = OnSurface)
+ Text(text = stringResource(R.string.settings_prevent_standby_subtitle), style = MaterialTheme.typography.bodySmall, color = OnBackground.copy(alpha = 0.6f))
+ }
+ Switch(checked = uiState.preventStandbyDuringPlayback, onCheckedChange = { viewModel.setPreventStandbyDuringPlayback(it) })
+ }
+ }
+ HorizontalDivider(color = Color.White.copy(alpha = 0.07f), modifier = Modifier.padding(vertical = 4.dp))
+ TvClickableSurface(
+ onClick = { viewModel.setAutoPlayNextEpisode(!uiState.autoPlayNextEpisode) },
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Color.Transparent,
+ focusedContainerColor = Primary.copy(alpha = 0.15f)
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ Row(
+ modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 12.dp),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Column(modifier = Modifier.weight(1f)) {
+ Text(text = stringResource(R.string.settings_auto_play_next_episode), style = MaterialTheme.typography.bodyMedium, color = OnSurface)
+ Text(text = stringResource(R.string.settings_auto_play_next_episode_subtitle), style = MaterialTheme.typography.bodySmall, color = OnBackground.copy(alpha = 0.6f))
+ }
+ Switch(checked = uiState.autoPlayNextEpisode, onCheckedChange = { viewModel.setAutoPlayNextEpisode(it) })
+ }
+ }
+ HorizontalDivider(color = Color.White.copy(alpha = 0.07f), modifier = Modifier.padding(vertical = 4.dp))
+ TvClickableSurface(
+ onClick = { viewModel.setPlayerMediaSessionEnabled(!uiState.playerMediaSessionEnabled) },
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Color.Transparent,
+ focusedContainerColor = Primary.copy(alpha = 0.15f)
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ Row(
+ modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 12.dp),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Column(modifier = Modifier.weight(1f)) {
+ Text(text = stringResource(R.string.settings_media_session), style = MaterialTheme.typography.bodyMedium, color = OnSurface)
+ Text(text = stringResource(R.string.settings_media_session_subtitle), style = MaterialTheme.typography.bodySmall, color = OnBackground.copy(alpha = 0.6f))
+ }
+ Switch(checked = uiState.playerMediaSessionEnabled, onCheckedChange = { viewModel.setPlayerMediaSessionEnabled(it) })
+ }
+ }
+ HorizontalDivider(color = Color.White.copy(alpha = 0.07f), modifier = Modifier.padding(vertical = 4.dp))
+ TvClickableSurface(
+ onClick = { viewModel.setPlayerTimeshiftEnabled(!uiState.playerTimeshiftEnabled) },
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Color.Transparent,
+ focusedContainerColor = Primary.copy(alpha = 0.15f)
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ Row(
+ modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 12.dp),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Column(modifier = Modifier.weight(1f)) {
+ Text(text = stringResource(R.string.settings_live_timeshift), style = MaterialTheme.typography.bodyMedium, color = OnSurface)
+ Text(text = stringResource(R.string.settings_live_timeshift_subtitle), style = MaterialTheme.typography.bodySmall, color = OnBackground.copy(alpha = 0.6f))
+ }
+ Switch(checked = uiState.playerTimeshiftEnabled, onCheckedChange = { viewModel.setPlayerTimeshiftEnabled(it) })
+ }
+ }
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_live_timeshift_depth),
+ value = timeshiftDepthLabel,
+ onClick = { onShowTimeshiftDepthDialogChange(true) }
+ )
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_live_timeshift_backend),
+ value = stringResource(R.string.settings_live_timeshift_backend_value),
+ onClick = {}
+ )
+ Text(
+ text = stringResource(R.string.settings_live_timeshift_backend_subtitle),
+ style = MaterialTheme.typography.bodySmall,
+ color = OnBackground.copy(alpha = 0.6f),
+ modifier = Modifier.padding(horizontal = 8.dp, vertical = 4.dp)
+ )
+ HorizontalDivider(color = Color.White.copy(alpha = 0.07f), modifier = Modifier.padding(vertical = 4.dp))
+ TvClickableSurface(
+ onClick = { viewModel.setZapAutoRevert(!uiState.zapAutoRevert) },
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Color.Transparent,
+ focusedContainerColor = Primary.copy(alpha = 0.15f)
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ Row(
+ modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 12.dp),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Column(modifier = Modifier.weight(1f)) {
+ Text(text = stringResource(R.string.settings_zap_auto_revert), style = MaterialTheme.typography.bodyMedium, color = OnSurface)
+ Text(text = stringResource(R.string.settings_zap_auto_revert_subtitle), style = MaterialTheme.typography.bodySmall, color = OnBackground.copy(alpha = 0.6f))
+ }
+ Switch(checked = uiState.zapAutoRevert, onCheckedChange = { viewModel.setZapAutoRevert(it) })
+ }
+ }
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_decoder_mode),
+ value = decoderModeLabel,
+ onClick = { onShowDecoderModeDialogChange(true) }
+ )
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_surface_mode),
+ value = surfaceModeLabel,
+ onClick = { onShowSurfaceModeDialogChange(true) }
+ )
+ HorizontalDivider(color = Color.White.copy(alpha = 0.07f), modifier = Modifier.padding(vertical = 4.dp))
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_default_playback_speed),
+ value = playbackSpeedLabel,
+ onClick = { onShowPlaybackSpeedDialogChange(true) }
+ )
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_default_stop_timer),
+ value = defaultStopTimerLabel,
+ onClick = { onShowDefaultStopTimerDialogChange(true) }
+ )
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_default_idle_standby_timer),
+ value = defaultIdleTimerLabel,
+ onClick = { onShowDefaultIdleTimerDialogChange(true) }
+ )
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_audio_video_sync_default),
+ value = audioVideoOffsetLabel,
+ onClick = { onShowAudioVideoOffsetDialogChange(true) }
+ )
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_player_controls_timeout),
+ value = controlsTimeoutLabel,
+ onClick = { onShowControlsTimeoutDialogChange(true) }
+ )
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_live_overlay_timeout),
+ value = liveOverlayTimeoutLabel,
+ onClick = { onShowLiveOverlayTimeoutDialogChange(true) }
+ )
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_player_notice_timeout),
+ value = noticeTimeoutLabel,
+ onClick = { onShowNoticeTimeoutDialogChange(true) }
+ )
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_player_diagnostics_timeout),
+ value = diagnosticsTimeoutLabel,
+ onClick = { onShowDiagnosticsTimeoutDialogChange(true) }
+ )
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_preferred_audio_language),
+ value = preferredAudioLanguageLabel,
+ onClick = { onShowAudioLanguageDialogChange(true) }
+ )
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_subtitle_size),
+ value = subtitleSizeLabel,
+ onClick = { onShowSubtitleSizeDialogChange(true) }
+ )
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_subtitle_text_color),
+ value = subtitleTextColorLabel,
+ onClick = { onShowSubtitleTextColorDialogChange(true) }
+ )
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_subtitle_background),
+ value = subtitleBackgroundLabel,
+ onClick = { onShowSubtitleBackgroundDialogChange(true) }
+ )
+ HorizontalDivider(color = Color.White.copy(alpha = 0.07f), modifier = Modifier.padding(vertical = 4.dp))
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_wifi_quality_cap),
+ value = wifiQualityLabel,
+ onClick = { onShowWifiQualityDialogChange(true) }
+ )
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_ethernet_quality_cap),
+ value = ethernetQualityLabel,
+ onClick = { onShowEthernetQualityDialogChange(true) }
+ )
+ }
+
+ item {
+ InternetSpeedTestCard(
+ valueLabel = lastSpeedTestLabel,
+ summary = lastSpeedTestSummary,
+ recommendationLabel = speedTestRecommendationLabel,
+ isRunning = uiState.isRunningInternetSpeedTest,
+ canApplyRecommendation = uiState.lastSpeedTest != null,
+ onRunTest = viewModel::runInternetSpeedTest,
+ onApplyWifi = viewModel::applySpeedTestRecommendationToWifi,
+ onApplyEthernet = viewModel::applySpeedTestRecommendationToEthernet
+ )
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsPlayerPreferenceDialogs.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsPlayerPreferenceDialogs.kt
new file mode 100644
index 00000000..31a39ff3
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsPlayerPreferenceDialogs.kt
@@ -0,0 +1,250 @@
+package com.streamvault.app.ui.screens.settings
+
+import android.content.Context
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.remember
+import androidx.compose.ui.res.stringResource
+import com.streamvault.app.R
+import com.streamvault.domain.model.AppTimeFormat
+import com.streamvault.domain.model.DecoderMode
+import com.streamvault.domain.model.PlayerSurfaceMode
+
+@Composable
+internal fun SettingsPlayerPreferenceDialogs(
+ uiState: SettingsUiState,
+ viewModel: SettingsViewModel,
+ context: Context,
+ showPlaybackSpeedDialog: Boolean,
+ onShowPlaybackSpeedDialogChange: (Boolean) -> Unit,
+ showTimeFormatDialog: Boolean,
+ onShowTimeFormatDialogChange: (Boolean) -> Unit,
+ showAudioVideoOffsetDialog: Boolean,
+ onShowAudioVideoOffsetDialogChange: (Boolean) -> Unit,
+ showDecoderModeDialog: Boolean,
+ onShowDecoderModeDialogChange: (Boolean) -> Unit,
+ showSurfaceModeDialog: Boolean,
+ onShowSurfaceModeDialogChange: (Boolean) -> Unit,
+ showTimeshiftDepthDialog: Boolean,
+ onShowTimeshiftDepthDialogChange: (Boolean) -> Unit,
+ showDefaultStopTimerDialog: Boolean,
+ onShowDefaultStopTimerDialogChange: (Boolean) -> Unit,
+ showDefaultIdleTimerDialog: Boolean,
+ onShowDefaultIdleTimerDialogChange: (Boolean) -> Unit,
+ showControlsTimeoutDialog: Boolean,
+ onShowControlsTimeoutDialogChange: (Boolean) -> Unit,
+ showLiveOverlayTimeoutDialog: Boolean,
+ onShowLiveOverlayTimeoutDialogChange: (Boolean) -> Unit,
+ showNoticeTimeoutDialog: Boolean,
+ onShowNoticeTimeoutDialogChange: (Boolean) -> Unit,
+ showDiagnosticsTimeoutDialog: Boolean,
+ onShowDiagnosticsTimeoutDialogChange: (Boolean) -> Unit
+) {
+ if (showPlaybackSpeedDialog) {
+ val speedOptions = remember { listOf(0.5f, 0.75f, 1f, 1.25f, 1.5f, 2f) }
+ PremiumSelectionDialog(
+ title = stringResource(R.string.settings_select_playback_speed),
+ onDismiss = { onShowPlaybackSpeedDialogChange(false) }
+ ) {
+ speedOptions.forEachIndexed { index, speed ->
+ LevelOption(
+ level = index,
+ text = formatPlaybackSpeedLabel(speed),
+ currentLevel = if (speed == uiState.playerPlaybackSpeed) index else -1,
+ onSelect = {
+ viewModel.setDefaultPlaybackSpeed(speed)
+ onShowPlaybackSpeedDialogChange(false)
+ }
+ )
+ }
+ }
+ }
+
+ if (showTimeFormatDialog) {
+ PremiumSelectionDialog(
+ title = stringResource(R.string.settings_select_time_format),
+ onDismiss = { onShowTimeFormatDialogChange(false) }
+ ) {
+ AppTimeFormat.entries.forEachIndexed { index, format ->
+ LevelOption(
+ level = index,
+ text = context.getString(format.labelResId()),
+ currentLevel = if (uiState.appTimeFormat == format) index else -1,
+ onSelect = {
+ viewModel.setAppTimeFormat(format)
+ onShowTimeFormatDialogChange(false)
+ }
+ )
+ }
+ }
+ }
+
+ if (showAudioVideoOffsetDialog) {
+ AudioVideoOffsetValueDialog(
+ title = stringResource(R.string.settings_audio_video_sync_default),
+ subtitle = stringResource(R.string.settings_audio_video_sync_default_subtitle),
+ initialValue = uiState.playerAudioVideoOffsetMs,
+ onDismiss = { onShowAudioVideoOffsetDialogChange(false) },
+ onConfirm = { offsetMs ->
+ viewModel.setPlayerAudioVideoOffsetMs(offsetMs)
+ onShowAudioVideoOffsetDialogChange(false)
+ }
+ )
+ }
+
+ if (showDecoderModeDialog) {
+ val decoderOptions = remember(context) {
+ listOf(
+ DecoderMode.AUTO to context.getString(R.string.settings_decoder_auto),
+ DecoderMode.HARDWARE to context.getString(R.string.settings_decoder_hardware),
+ DecoderMode.SOFTWARE to context.getString(R.string.settings_decoder_software),
+ DecoderMode.COMPATIBILITY to context.getString(R.string.settings_decoder_compatibility)
+ )
+ }
+ PremiumSelectionDialog(
+ title = stringResource(R.string.settings_select_decoder_mode),
+ onDismiss = { onShowDecoderModeDialogChange(false) }
+ ) {
+ decoderOptions.forEachIndexed { index, option ->
+ LevelOption(
+ level = index,
+ text = option.second,
+ currentLevel = if (uiState.playerDecoderMode == option.first) index else -1,
+ onSelect = {
+ viewModel.setPlayerDecoderMode(option.first)
+ onShowDecoderModeDialogChange(false)
+ }
+ )
+ }
+ }
+ }
+
+ if (showSurfaceModeDialog) {
+ val surfaceOptions = remember(context) {
+ listOf(
+ PlayerSurfaceMode.AUTO to context.getString(R.string.settings_surface_auto),
+ PlayerSurfaceMode.SURFACE_VIEW to context.getString(R.string.settings_surface_surface_view),
+ PlayerSurfaceMode.TEXTURE_VIEW to context.getString(R.string.settings_surface_texture_view)
+ )
+ }
+ PremiumSelectionDialog(
+ title = stringResource(R.string.settings_surface_mode),
+ onDismiss = { onShowSurfaceModeDialogChange(false) }
+ ) {
+ surfaceOptions.forEachIndexed { index, option ->
+ LevelOption(
+ level = index,
+ text = option.second,
+ currentLevel = if (uiState.playerSurfaceMode == option.first) index else -1,
+ onSelect = {
+ viewModel.setPlayerSurfaceMode(option.first)
+ onShowSurfaceModeDialogChange(false)
+ }
+ )
+ }
+ }
+ }
+
+ if (showControlsTimeoutDialog) {
+ TimeoutValueDialog(
+ title = stringResource(R.string.settings_player_controls_timeout),
+ subtitle = stringResource(R.string.settings_timeout_vod_controls_subtitle),
+ initialValue = uiState.playerControlsTimeoutSeconds,
+ onDismiss = { onShowControlsTimeoutDialogChange(false) }
+ ) { seconds ->
+ viewModel.setPlayerControlsTimeoutSeconds(seconds)
+ onShowControlsTimeoutDialogChange(false)
+ }
+ }
+
+ if (showLiveOverlayTimeoutDialog) {
+ TimeoutValueDialog(
+ title = stringResource(R.string.settings_live_overlay_timeout),
+ subtitle = stringResource(R.string.settings_timeout_live_overlays_subtitle),
+ initialValue = uiState.playerLiveOverlayTimeoutSeconds,
+ onDismiss = { onShowLiveOverlayTimeoutDialogChange(false) }
+ ) { seconds ->
+ viewModel.setPlayerLiveOverlayTimeoutSeconds(seconds)
+ onShowLiveOverlayTimeoutDialogChange(false)
+ }
+ }
+
+ if (showNoticeTimeoutDialog) {
+ TimeoutValueDialog(
+ title = stringResource(R.string.settings_player_notice_timeout),
+ subtitle = stringResource(R.string.settings_timeout_notices_subtitle),
+ initialValue = uiState.playerNoticeTimeoutSeconds,
+ onDismiss = { onShowNoticeTimeoutDialogChange(false) }
+ ) { seconds ->
+ viewModel.setPlayerNoticeTimeoutSeconds(seconds)
+ onShowNoticeTimeoutDialogChange(false)
+ }
+ }
+
+ if (showDiagnosticsTimeoutDialog) {
+ TimeoutValueDialog(
+ title = stringResource(R.string.settings_player_diagnostics_timeout),
+ subtitle = stringResource(R.string.settings_timeout_diagnostics_subtitle),
+ initialValue = uiState.playerDiagnosticsTimeoutSeconds,
+ onDismiss = { onShowDiagnosticsTimeoutDialogChange(false) }
+ ) { seconds ->
+ viewModel.setPlayerDiagnosticsTimeoutSeconds(seconds)
+ onShowDiagnosticsTimeoutDialogChange(false)
+ }
+ }
+
+ if (showTimeshiftDepthDialog) {
+ val depthOptions = remember(context) {
+ listOf(
+ 15 to context.getString(R.string.settings_live_timeshift_depth_15),
+ 30 to context.getString(R.string.settings_live_timeshift_depth_30),
+ 60 to context.getString(R.string.settings_live_timeshift_depth_60)
+ )
+ }
+ PremiumSelectionDialog(
+ title = stringResource(R.string.settings_select_live_timeshift_depth),
+ onDismiss = { onShowTimeshiftDepthDialogChange(false) }
+ ) {
+ depthOptions.forEachIndexed { index, option ->
+ LevelOption(
+ level = index,
+ text = option.second,
+ currentLevel = if (uiState.playerTimeshiftDepthMinutes == option.first) index else -1,
+ onSelect = {
+ viewModel.setPlayerTimeshiftDepthMinutes(option.first)
+ onShowTimeshiftDepthDialogChange(false)
+ }
+ )
+ }
+ }
+ }
+
+ if (showDefaultStopTimerDialog) {
+ PlaybackTimerPresetDialog(
+ title = stringResource(R.string.settings_default_stop_timer),
+ selectedMinutes = uiState.defaultStopPlaybackTimerMinutes,
+ onDismiss = { onShowDefaultStopTimerDialogChange(false) },
+ onSelect = { minutes ->
+ viewModel.setDefaultStopPlaybackTimerMinutes(minutes)
+ onShowDefaultStopTimerDialogChange(false)
+ }
+ )
+ }
+
+ if (showDefaultIdleTimerDialog) {
+ PlaybackTimerPresetDialog(
+ title = stringResource(R.string.settings_default_idle_standby_timer),
+ selectedMinutes = uiState.defaultIdleStandbyTimerMinutes,
+ onDismiss = { onShowDefaultIdleTimerDialogChange(false) },
+ onSelect = { minutes ->
+ viewModel.setDefaultIdleStandbyTimerMinutes(minutes)
+ onShowDefaultIdleTimerDialogChange(false)
+ }
+ )
+ }
+}
+
+private fun AppTimeFormat.labelResId(): Int = when (this) {
+ AppTimeFormat.SYSTEM -> R.string.settings_time_format_system
+ AppTimeFormat.TWELVE_HOUR -> R.string.settings_time_format_12h
+ AppTimeFormat.TWENTY_FOUR_HOUR -> R.string.settings_time_format_24h
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsPreferenceDialogs.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsPreferenceDialogs.kt
new file mode 100644
index 00000000..274e7dcc
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsPreferenceDialogs.kt
@@ -0,0 +1,262 @@
+package com.streamvault.app.ui.screens.settings
+
+import android.content.Context
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.remember
+import androidx.compose.ui.res.stringResource
+import com.streamvault.app.R
+import com.streamvault.domain.model.AppTimeFormat
+import com.streamvault.domain.model.CategorySortMode
+import com.streamvault.domain.model.ContentType
+import com.streamvault.domain.model.DecoderMode
+import com.streamvault.domain.model.PlayerSurfaceMode
+
+@Composable
+internal fun SettingsPreferenceDialogs(
+ uiState: SettingsUiState,
+ viewModel: SettingsViewModel,
+ context: Context,
+ showGuideDefaultCategoryDialog: Boolean,
+ onShowGuideDefaultCategoryDialogChange: (Boolean) -> Unit,
+ showPlaybackSpeedDialog: Boolean,
+ onShowPlaybackSpeedDialogChange: (Boolean) -> Unit,
+ showTimeFormatDialog: Boolean,
+ onShowTimeFormatDialogChange: (Boolean) -> Unit,
+ showAudioVideoOffsetDialog: Boolean,
+ onShowAudioVideoOffsetDialogChange: (Boolean) -> Unit,
+ showDecoderModeDialog: Boolean,
+ onShowDecoderModeDialogChange: (Boolean) -> Unit,
+ showSurfaceModeDialog: Boolean,
+ onShowSurfaceModeDialogChange: (Boolean) -> Unit,
+ showTimeshiftDepthDialog: Boolean,
+ onShowTimeshiftDepthDialogChange: (Boolean) -> Unit,
+ showDefaultStopTimerDialog: Boolean,
+ onShowDefaultStopTimerDialogChange: (Boolean) -> Unit,
+ showDefaultIdleTimerDialog: Boolean,
+ onShowDefaultIdleTimerDialogChange: (Boolean) -> Unit,
+ showControlsTimeoutDialog: Boolean,
+ onShowControlsTimeoutDialogChange: (Boolean) -> Unit,
+ showLiveOverlayTimeoutDialog: Boolean,
+ onShowLiveOverlayTimeoutDialogChange: (Boolean) -> Unit,
+ showNoticeTimeoutDialog: Boolean,
+ onShowNoticeTimeoutDialogChange: (Boolean) -> Unit,
+ showDiagnosticsTimeoutDialog: Boolean,
+ onShowDiagnosticsTimeoutDialogChange: (Boolean) -> Unit,
+ showLiveTvFiltersDialog: Boolean,
+ onShowLiveTvFiltersDialogChange: (Boolean) -> Unit,
+ showAudioLanguageDialog: Boolean,
+ onShowAudioLanguageDialogChange: (Boolean) -> Unit,
+ showSubtitleSizeDialog: Boolean,
+ onShowSubtitleSizeDialogChange: (Boolean) -> Unit,
+ showSubtitleTextColorDialog: Boolean,
+ onShowSubtitleTextColorDialogChange: (Boolean) -> Unit,
+ showSubtitleBackgroundDialog: Boolean,
+ onShowSubtitleBackgroundDialogChange: (Boolean) -> Unit,
+ showWifiQualityDialog: Boolean,
+ onShowWifiQualityDialogChange: (Boolean) -> Unit,
+ showEthernetQualityDialog: Boolean,
+ onShowEthernetQualityDialogChange: (Boolean) -> Unit,
+ showLanguageDialog: Boolean,
+ onShowLanguageDialogChange: (Boolean) -> Unit,
+ categorySortDialogType: String?,
+ onCategorySortDialogTypeChange: (String?) -> Unit
+) {
+ SettingsPlayerPreferenceDialogs(
+ uiState = uiState,
+ viewModel = viewModel,
+ context = context,
+ showPlaybackSpeedDialog = showPlaybackSpeedDialog,
+ onShowPlaybackSpeedDialogChange = onShowPlaybackSpeedDialogChange,
+ showTimeFormatDialog = showTimeFormatDialog,
+ onShowTimeFormatDialogChange = onShowTimeFormatDialogChange,
+ showAudioVideoOffsetDialog = showAudioVideoOffsetDialog,
+ onShowAudioVideoOffsetDialogChange = onShowAudioVideoOffsetDialogChange,
+ showDecoderModeDialog = showDecoderModeDialog,
+ onShowDecoderModeDialogChange = onShowDecoderModeDialogChange,
+ showSurfaceModeDialog = showSurfaceModeDialog,
+ onShowSurfaceModeDialogChange = onShowSurfaceModeDialogChange,
+ showTimeshiftDepthDialog = showTimeshiftDepthDialog,
+ onShowTimeshiftDepthDialogChange = onShowTimeshiftDepthDialogChange,
+ showDefaultStopTimerDialog = showDefaultStopTimerDialog,
+ onShowDefaultStopTimerDialogChange = onShowDefaultStopTimerDialogChange,
+ showDefaultIdleTimerDialog = showDefaultIdleTimerDialog,
+ onShowDefaultIdleTimerDialogChange = onShowDefaultIdleTimerDialogChange,
+ showControlsTimeoutDialog = showControlsTimeoutDialog,
+ onShowControlsTimeoutDialogChange = onShowControlsTimeoutDialogChange,
+ showLiveOverlayTimeoutDialog = showLiveOverlayTimeoutDialog,
+ onShowLiveOverlayTimeoutDialogChange = onShowLiveOverlayTimeoutDialogChange,
+ showNoticeTimeoutDialog = showNoticeTimeoutDialog,
+ onShowNoticeTimeoutDialogChange = onShowNoticeTimeoutDialogChange,
+ showDiagnosticsTimeoutDialog = showDiagnosticsTimeoutDialog,
+ onShowDiagnosticsTimeoutDialogChange = onShowDiagnosticsTimeoutDialogChange
+ )
+
+ if (showGuideDefaultCategoryDialog) {
+ PremiumSelectionDialog(
+ title = stringResource(R.string.settings_select_guide_default_category),
+ onDismiss = { onShowGuideDefaultCategoryDialogChange(false) }
+ ) {
+ uiState.guideDefaultCategoryOptions.forEachIndexed { index, category ->
+ LevelOption(
+ level = index,
+ text = category.name,
+ currentLevel = if (uiState.guideDefaultCategoryId == category.id) index else -1,
+ onSelect = {
+ viewModel.setGuideDefaultCategory(category.id)
+ onShowGuideDefaultCategoryDialogChange(false)
+ }
+ )
+ }
+ }
+ }
+
+ if (showLiveTvFiltersDialog) {
+ LiveTvQuickFiltersDialog(
+ filters = uiState.liveTvCategoryFilters,
+ onDismiss = { onShowLiveTvFiltersDialogChange(false) },
+ onAddFilter = viewModel::addLiveTvCategoryFilter,
+ onRemoveFilter = viewModel::removeLiveTvCategoryFilter
+ )
+ }
+
+ if (showAudioLanguageDialog) {
+ val autoLabel = stringResource(R.string.settings_audio_language_auto)
+ val audioLanguageOptions = remember(autoLabel) { supportedAudioLanguages(autoLabel) }
+ PremiumSelectionDialog(
+ title = stringResource(R.string.settings_select_audio_language),
+ onDismiss = { onShowAudioLanguageDialogChange(false) }
+ ) {
+ audioLanguageOptions.forEachIndexed { index, option ->
+ LevelOption(
+ level = index,
+ text = option.label,
+ currentLevel = if (uiState.preferredAudioLanguage == option.tag) index else -1,
+ onSelect = {
+ viewModel.setPreferredAudioLanguage(option.tag)
+ onShowAudioLanguageDialogChange(false)
+ }
+ )
+ }
+ }
+ }
+
+ if (showSubtitleSizeDialog) {
+ val subtitleSizeOptions = remember { subtitleSizeOptions() }
+ PremiumSelectionDialog(
+ title = stringResource(R.string.settings_select_subtitle_size),
+ onDismiss = { onShowSubtitleSizeDialogChange(false) }
+ ) {
+ subtitleSizeOptions.forEachIndexed { index, option ->
+ LevelOption(
+ level = index,
+ text = option.label(context),
+ currentLevel = if (uiState.subtitleTextScale == option.scale) index else -1,
+ onSelect = {
+ viewModel.setSubtitleTextScale(option.scale)
+ onShowSubtitleSizeDialogChange(false)
+ }
+ )
+ }
+ }
+ }
+
+ if (showSubtitleTextColorDialog) {
+ val options = remember(context) { subtitleTextColorOptions(context) }
+ PremiumSelectionDialog(
+ title = stringResource(R.string.settings_select_subtitle_text_color),
+ onDismiss = { onShowSubtitleTextColorDialogChange(false) }
+ ) {
+ options.forEachIndexed { index, option ->
+ LevelOption(
+ level = index,
+ text = option.label,
+ currentLevel = if (uiState.subtitleTextColor == option.colorArgb) index else -1,
+ onSelect = {
+ viewModel.setSubtitleTextColor(option.colorArgb)
+ onShowSubtitleTextColorDialogChange(false)
+ }
+ )
+ }
+ }
+ }
+
+ if (showSubtitleBackgroundDialog) {
+ val options = remember(context) { subtitleBackgroundColorOptions(context) }
+ PremiumSelectionDialog(
+ title = stringResource(R.string.settings_select_subtitle_background),
+ onDismiss = { onShowSubtitleBackgroundDialogChange(false) }
+ ) {
+ options.forEachIndexed { index, option ->
+ LevelOption(
+ level = index,
+ text = option.label,
+ currentLevel = if (uiState.subtitleBackgroundColor == option.colorArgb) index else -1,
+ onSelect = {
+ viewModel.setSubtitleBackgroundColor(option.colorArgb)
+ onShowSubtitleBackgroundDialogChange(false)
+ }
+ )
+ }
+ }
+ }
+
+ if (showWifiQualityDialog) {
+ QualityCapSelectionDialog(
+ title = stringResource(R.string.settings_select_wifi_quality_cap),
+ currentValue = uiState.wifiMaxVideoHeight,
+ onDismiss = { onShowWifiQualityDialogChange(false) },
+ onSelect = {
+ viewModel.setWifiQualityCap(it)
+ onShowWifiQualityDialogChange(false)
+ }
+ )
+ }
+
+ if (showEthernetQualityDialog) {
+ QualityCapSelectionDialog(
+ title = stringResource(R.string.settings_select_ethernet_quality_cap),
+ currentValue = uiState.ethernetMaxVideoHeight,
+ onDismiss = { onShowEthernetQualityDialogChange(false) },
+ onSelect = {
+ viewModel.setEthernetQualityCap(it)
+ onShowEthernetQualityDialogChange(false)
+ }
+ )
+ }
+
+ if (showLanguageDialog) {
+ val systemDefaultLabel = stringResource(R.string.settings_system_default)
+ val languageOptions = remember(systemDefaultLabel) { supportedAppLanguages(systemDefaultLabel) }
+ PremiumSelectionDialog(
+ title = stringResource(R.string.settings_select_language),
+ onDismiss = { onShowLanguageDialogChange(false) }
+ ) {
+ languageOptions.forEachIndexed { index, option ->
+ LevelOption(
+ level = index,
+ text = option.label,
+ currentLevel = if (uiState.appLanguage == option.tag) index else -1,
+ onSelect = {
+ viewModel.setAppLanguage(option.tag)
+ onShowLanguageDialogChange(false)
+ }
+ )
+ }
+ }
+ }
+
+ categorySortDialogType?.let { typeName ->
+ val type = ContentType.entries.firstOrNull { it.name == typeName }
+ if (type != null) {
+ CategorySortModeDialog(
+ type = type,
+ currentMode = uiState.categorySortModes[type] ?: CategorySortMode.DEFAULT,
+ onDismiss = { onCategorySortDialogTypeChange(null) },
+ onModeSelected = { mode ->
+ viewModel.setCategorySortMode(type, mode)
+ onCategorySortDialogTypeChange(null)
+ }
+ )
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsPreferenceModels.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsPreferenceModels.kt
new file mode 100644
index 00000000..b916f3b3
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsPreferenceModels.kt
@@ -0,0 +1,102 @@
+package com.streamvault.app.ui.screens.settings
+
+import android.app.Application
+import com.streamvault.app.R
+import com.streamvault.app.ui.model.LiveTvChannelMode
+import com.streamvault.app.ui.model.LiveTvQuickFilterVisibilityMode
+import com.streamvault.app.ui.model.VodViewMode
+import com.streamvault.domain.model.AppTimeFormat
+import com.streamvault.domain.model.Category
+import com.streamvault.domain.model.ChannelNumberingMode
+import com.streamvault.domain.model.DecoderMode
+import com.streamvault.domain.model.GroupedChannelLabelMode
+import com.streamvault.domain.model.LiveChannelGroupingMode
+import com.streamvault.domain.model.LiveVariantPreferenceMode
+import com.streamvault.domain.model.PlayerSurfaceMode
+import com.streamvault.domain.model.Provider
+
+enum class ProviderWarningAction {
+ EPG,
+ MOVIES,
+ SERIES
+}
+
+enum class ProviderSyncSelection {
+ ALL,
+ FAST,
+ TV,
+ MOVIES,
+ SERIES,
+ EPG
+}
+
+internal data class SettingsPreferenceSnapshot(
+ val providers: List<Provider>,
+ val activeProviderId: Long?,
+ val parentalControlLevel: Int,
+ val hasParentalPin: Boolean,
+ val appLanguage: String,
+ val appTimeFormat: AppTimeFormat,
+ val preferredAudioLanguage: String,
+ val playerMediaSessionEnabled: Boolean,
+ val playerDecoderMode: DecoderMode,
+ val playerSurfaceMode: PlayerSurfaceMode,
+ val playerPlaybackSpeed: Float,
+ val playerAudioVideoOffsetMs: Int,
+ val playerControlsTimeoutSeconds: Int,
+ val playerLiveOverlayTimeoutSeconds: Int,
+ val playerNoticeTimeoutSeconds: Int,
+ val playerDiagnosticsTimeoutSeconds: Int,
+ val subtitleTextScale: Float,
+ val subtitleTextColor: Int,
+ val subtitleBackgroundColor: Int,
+ val wifiMaxVideoHeight: Int?,
+ val ethernetMaxVideoHeight: Int?,
+ val playerTimeshiftEnabled: Boolean,
+ val playerTimeshiftDepthMinutes: Int,
+ val defaultStopPlaybackTimerMinutes: Int,
+ val defaultIdleStandbyTimerMinutes: Int,
+ val lastSpeedTestMegabits: Double?,
+ val lastSpeedTestTimestamp: Long?,
+ val lastSpeedTestTransport: String?,
+ val lastSpeedTestRecommendedHeight: Int?,
+ val lastSpeedTestEstimated: Boolean,
+ val isIncognitoMode: Boolean,
+ val useXtreamTextClassification: Boolean,
+ val xtreamBase64TextCompatibility: Boolean,
+ val liveTvChannelMode: LiveTvChannelMode,
+ val showLiveSourceSwitcher: Boolean,
+ val showAllChannelsCategory: Boolean,
+ val showRecentChannelsCategory: Boolean,
+ val liveTvCategoryFilters: List<String>,
+ val liveTvQuickFilterVisibilityMode: LiveTvQuickFilterVisibilityMode,
+ val liveChannelNumberingMode: ChannelNumberingMode,
+ val liveChannelGroupingMode: LiveChannelGroupingMode,
+ val groupedChannelLabelMode: GroupedChannelLabelMode,
+ val liveVariantPreferenceMode: LiveVariantPreferenceMode,
+ val vodViewMode: VodViewMode,
+ val vodInfiniteScroll: Boolean,
+ val guideDefaultCategoryId: Long,
+ val guideDefaultCategoryOptions: List<Category>,
+ val preventStandbyDuringPlayback: Boolean,
+ val zapAutoRevert: Boolean,
+ val autoPlayNextEpisode: Boolean,
+ val autoCheckAppUpdates: Boolean,
+ val autoDownloadAppUpdates: Boolean,
+ val lastAppUpdateCheckAt: Long?,
+ val cachedAppUpdateVersionName: String?,
+ val cachedAppUpdateVersionCode: Int?,
+ val cachedAppUpdateReleaseUrl: String?,
+ val cachedAppUpdateDownloadUrl: String?,
+ val cachedAppUpdateReleaseNotes: String,
+ val cachedAppUpdatePublishedAt: String?
+)
+
+internal fun ProviderSyncSelection.label(application: Application): String = when (this) {
+ ProviderSyncSelection.ALL -> application.getString(R.string.settings_sync_option_all)
+ ProviderSyncSelection.FAST -> application.getString(R.string.settings_sync_option_fast)
+ ProviderSyncSelection.TV -> application.getString(R.string.settings_sync_option_tv)
+ ProviderSyncSelection.MOVIES -> application.getString(R.string.settings_sync_option_movies)
+ ProviderSyncSelection.SERIES -> application.getString(R.string.settings_sync_option_series)
+ ProviderSyncSelection.EPG -> application.getString(R.string.settings_sync_option_epg)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsPreferenceSnapshotMapper.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsPreferenceSnapshotMapper.kt
new file mode 100644
index 00000000..3da833cb
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsPreferenceSnapshotMapper.kt
@@ -0,0 +1,68 @@
+package com.streamvault.app.ui.screens.settings
+
+internal fun SettingsUiState.applyPreferenceSnapshot(snapshot: SettingsPreferenceSnapshot): SettingsUiState {
+ val cachedAppUpdate = snapshot.toCachedAppUpdateUiModel()
+ return copy(
+ providers = snapshot.providers,
+ activeProviderId = snapshot.activeProviderId,
+ parentalControlLevel = snapshot.parentalControlLevel,
+ hasParentalPin = snapshot.hasParentalPin,
+ appLanguage = snapshot.appLanguage,
+ appTimeFormat = snapshot.appTimeFormat,
+ preferredAudioLanguage = snapshot.preferredAudioLanguage,
+ playerMediaSessionEnabled = snapshot.playerMediaSessionEnabled,
+ playerDecoderMode = snapshot.playerDecoderMode,
+ playerSurfaceMode = snapshot.playerSurfaceMode,
+ playerPlaybackSpeed = snapshot.playerPlaybackSpeed,
+ playerAudioVideoOffsetMs = snapshot.playerAudioVideoOffsetMs,
+ playerControlsTimeoutSeconds = snapshot.playerControlsTimeoutSeconds,
+ playerLiveOverlayTimeoutSeconds = snapshot.playerLiveOverlayTimeoutSeconds,
+ playerNoticeTimeoutSeconds = snapshot.playerNoticeTimeoutSeconds,
+ playerDiagnosticsTimeoutSeconds = snapshot.playerDiagnosticsTimeoutSeconds,
+ subtitleTextScale = snapshot.subtitleTextScale,
+ subtitleTextColor = snapshot.subtitleTextColor,
+ subtitleBackgroundColor = snapshot.subtitleBackgroundColor,
+ wifiMaxVideoHeight = snapshot.wifiMaxVideoHeight,
+ ethernetMaxVideoHeight = snapshot.ethernetMaxVideoHeight,
+ playerTimeshiftEnabled = snapshot.playerTimeshiftEnabled,
+ playerTimeshiftDepthMinutes = snapshot.playerTimeshiftDepthMinutes,
+ defaultStopPlaybackTimerMinutes = snapshot.defaultStopPlaybackTimerMinutes,
+ defaultIdleStandbyTimerMinutes = snapshot.defaultIdleStandbyTimerMinutes,
+ lastSpeedTest = snapshot.lastSpeedTestMegabits?.let {
+ InternetSpeedTestUiModel(
+ megabitsPerSecond = it,
+ measuredAtMs = snapshot.lastSpeedTestTimestamp ?: 0L,
+ transportLabel = snapshot.lastSpeedTestTransport ?: InternetSpeedTestTransport.UNKNOWN.name,
+ recommendedMaxVideoHeight = snapshot.lastSpeedTestRecommendedHeight,
+ isEstimated = snapshot.lastSpeedTestEstimated
+ )
+ },
+ isIncognitoMode = snapshot.isIncognitoMode,
+ useXtreamTextClassification = snapshot.useXtreamTextClassification,
+ xtreamBase64TextCompatibility = snapshot.xtreamBase64TextCompatibility,
+ liveTvChannelMode = snapshot.liveTvChannelMode,
+ showLiveSourceSwitcher = snapshot.showLiveSourceSwitcher,
+ showAllChannelsCategory = snapshot.showAllChannelsCategory,
+ showRecentChannelsCategory = snapshot.showRecentChannelsCategory,
+ liveTvCategoryFilters = snapshot.liveTvCategoryFilters,
+ liveTvQuickFilterVisibilityMode = snapshot.liveTvQuickFilterVisibilityMode,
+ liveChannelNumberingMode = snapshot.liveChannelNumberingMode,
+ liveChannelGroupingMode = snapshot.liveChannelGroupingMode,
+ groupedChannelLabelMode = snapshot.groupedChannelLabelMode,
+ liveVariantPreferenceMode = snapshot.liveVariantPreferenceMode,
+ vodViewMode = snapshot.vodViewMode,
+ vodInfiniteScroll = snapshot.vodInfiniteScroll,
+ guideDefaultCategoryId = snapshot.guideDefaultCategoryId,
+ guideDefaultCategoryOptions = guideDefaultCategoryOptions,
+ preventStandbyDuringPlayback = snapshot.preventStandbyDuringPlayback,
+ zapAutoRevert = snapshot.zapAutoRevert,
+ autoPlayNextEpisode = snapshot.autoPlayNextEpisode,
+ autoCheckAppUpdates = snapshot.autoCheckAppUpdates,
+ autoDownloadAppUpdates = snapshot.autoDownloadAppUpdates,
+ appUpdate = cachedAppUpdate.copy(
+ downloadStatus = appUpdate.downloadStatus,
+ downloadedVersionName = appUpdate.downloadedVersionName,
+ errorMessage = appUpdate.errorMessage
+ )
+ )
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsPrivacySection.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsPrivacySection.kt
new file mode 100644
index 00000000..a5b5ef93
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsPrivacySection.kt
@@ -0,0 +1,158 @@
+package com.streamvault.app.ui.screens.settings
+
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.lazy.LazyListScope
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material3.HorizontalDivider
+import androidx.compose.material3.Switch
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.unit.dp
+import androidx.tv.material3.ClickableSurfaceDefaults
+import androidx.tv.material3.MaterialTheme
+import androidx.tv.material3.Text
+import com.streamvault.app.R
+import com.streamvault.app.ui.interaction.TvClickableSurface
+import com.streamvault.app.ui.theme.OnBackground
+import com.streamvault.app.ui.theme.OnSurface
+import com.streamvault.app.ui.theme.Primary
+
+internal fun LazyListScope.settingsPrivacySection(
+ uiState: SettingsUiState,
+ viewModel: SettingsViewModel,
+ onPendingProtectionLevelChange: (Int?) -> Unit,
+ onPendingActionChange: (ParentalAction?) -> Unit,
+ onShowPinDialogChange: (Boolean) -> Unit,
+ onShowLevelDialogChange: (Boolean) -> Unit,
+ onShowClearHistoryDialogChange: (Boolean) -> Unit
+) {
+ item {
+ ParentalControlCard(
+ level = uiState.parentalControlLevel,
+ hasParentalPin = uiState.hasParentalPin,
+ hasActiveProvider = uiState.activeProviderId != null,
+ onChangeLevel = {
+ onPendingProtectionLevelChange(null)
+ if (uiState.hasParentalPin) {
+ onPendingActionChange(ParentalAction.ChangeLevel)
+ onShowPinDialogChange(true)
+ } else {
+ onShowLevelDialogChange(true)
+ }
+ },
+ onChangePin = {
+ onPendingProtectionLevelChange(null)
+ onPendingActionChange(
+ if (uiState.hasParentalPin) {
+ ParentalAction.ChangePin
+ } else {
+ ParentalAction.SetNewPin
+ }
+ )
+ onShowPinDialogChange(true)
+ }
+ )
+ }
+ item {
+ HorizontalDivider(color = Color.White.copy(alpha = 0.07f), modifier = Modifier.padding(vertical = 4.dp))
+ TvClickableSurface(
+ onClick = { viewModel.toggleIncognitoMode() },
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Color.Transparent,
+ focusedContainerColor = Primary.copy(alpha = 0.15f)
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ Row(
+ modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 12.dp),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Column(modifier = Modifier.weight(1f)) {
+ Text(text = stringResource(R.string.settings_incognito_mode), style = MaterialTheme.typography.bodyMedium, color = OnSurface)
+ Text(text = stringResource(R.string.settings_incognito_mode_subtitle), style = MaterialTheme.typography.bodySmall, color = OnBackground.copy(alpha = 0.6f))
+ }
+ Switch(checked = uiState.isIncognitoMode, onCheckedChange = { viewModel.toggleIncognitoMode() })
+ }
+ }
+ Spacer(Modifier.height(2.dp))
+ TvClickableSurface(
+ onClick = { viewModel.toggleXtreamTextClassification() },
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Color.Transparent,
+ focusedContainerColor = Primary.copy(alpha = 0.15f)
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ Row(
+ modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 12.dp),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Column(modifier = Modifier.weight(1f)) {
+ Text(text = stringResource(R.string.settings_xtream_text_classification), style = MaterialTheme.typography.bodyMedium, color = OnSurface)
+ Text(text = stringResource(R.string.settings_xtream_text_classification_subtitle), style = MaterialTheme.typography.bodySmall, color = OnBackground.copy(alpha = 0.6f))
+ }
+ Switch(checked = uiState.useXtreamTextClassification, onCheckedChange = { viewModel.toggleXtreamTextClassification() })
+ }
+ }
+ Spacer(Modifier.height(2.dp))
+ TvClickableSurface(
+ onClick = { viewModel.toggleXtreamBase64TextCompatibility() },
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Color.Transparent,
+ focusedContainerColor = Primary.copy(alpha = 0.15f)
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ Row(
+ modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 12.dp),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Column(modifier = Modifier.weight(1f)) {
+ Text(text = stringResource(R.string.settings_xtream_base64_compatibility), style = MaterialTheme.typography.bodyMedium, color = OnSurface)
+ Text(text = stringResource(R.string.settings_xtream_base64_compatibility_subtitle), style = MaterialTheme.typography.bodySmall, color = OnBackground.copy(alpha = 0.6f))
+ }
+ Switch(checked = uiState.xtreamBase64TextCompatibility, onCheckedChange = { viewModel.toggleXtreamBase64TextCompatibility() })
+ }
+ }
+ Spacer(Modifier.height(2.dp))
+ TvClickableSurface(
+ onClick = { onShowClearHistoryDialogChange(true) },
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Color.Transparent,
+ focusedContainerColor = Primary.copy(alpha = 0.15f)
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ Row(
+ modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 12.dp),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Column(modifier = Modifier.weight(1f)) {
+ Text(text = stringResource(R.string.settings_clear_history), style = MaterialTheme.typography.bodyMedium, color = OnSurface)
+ Text(text = stringResource(R.string.settings_clear_history_subtitle), style = MaterialTheme.typography.bodySmall, color = OnBackground.copy(alpha = 0.6f))
+ }
+ Text(text = stringResource(R.string.settings_clear_history_confirm), style = MaterialTheme.typography.labelLarge, color = Primary)
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProtectionDialogs.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProtectionDialogs.kt
new file mode 100644
index 00000000..8dcdd94e
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProtectionDialogs.kt
@@ -0,0 +1,134 @@
+package com.streamvault.app.ui.screens.settings
+
+import android.content.Context
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.res.stringResource
+import com.streamvault.app.R
+import com.streamvault.app.ui.components.dialogs.PinDialog
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.launch
+
+@Composable
+internal fun SettingsProtectionDialogs(
+ uiState: SettingsUiState,
+ viewModel: SettingsViewModel,
+ context: Context,
+ scope: CoroutineScope,
+ showPinDialog: Boolean,
+ onShowPinDialogChange: (Boolean) -> Unit,
+ showLevelDialog: Boolean,
+ onShowLevelDialogChange: (Boolean) -> Unit,
+ pinError: String?,
+ onPinErrorChange: (String?) -> Unit,
+ pendingAction: ParentalAction?,
+ onPendingActionChange: (ParentalAction?) -> Unit,
+ pendingProtectionLevel: Int?,
+ onPendingProtectionLevelChange: (Int?) -> Unit
+) {
+ if (showPinDialog) {
+ PinDialog(
+ onDismissRequest = {
+ onShowPinDialogChange(false)
+ onPinErrorChange(null)
+ if (pendingAction == ParentalAction.SetNewPin) {
+ onPendingActionChange(null)
+ onPendingProtectionLevelChange(null)
+ }
+ },
+ onPinEntered = { pin ->
+ scope.launch {
+ if (pendingAction == ParentalAction.SetNewPin) {
+ viewModel.changePin(pin)
+ pendingProtectionLevel?.let(viewModel::setParentalControlLevel)
+ onPendingProtectionLevelChange(null)
+ onShowPinDialogChange(false)
+ onPendingActionChange(null)
+ } else {
+ if (viewModel.verifyPin(pin)) {
+ onShowPinDialogChange(false)
+ onPinErrorChange(null)
+ when (pendingAction) {
+ ParentalAction.ChangeLevel -> onShowLevelDialogChange(true)
+ ParentalAction.ChangePin -> {
+ onPendingActionChange(ParentalAction.SetNewPin)
+ onShowPinDialogChange(true)
+ }
+ else -> onPendingActionChange(null)
+ }
+ } else {
+ onPinErrorChange(context.getString(R.string.home_incorrect_pin))
+ }
+ }
+ }
+ },
+ title = if (pendingAction == ParentalAction.SetNewPin) {
+ stringResource(R.string.settings_enter_new_pin)
+ } else {
+ stringResource(R.string.settings_enter_pin)
+ },
+ error = pinError
+ )
+ }
+
+ if (showLevelDialog) {
+ PremiumSelectionDialog(
+ title = stringResource(R.string.settings_select_level),
+ onDismiss = { onShowLevelDialogChange(false) }
+ ) {
+ LevelOption(
+ level = 0,
+ text = stringResource(R.string.settings_level_off_desc),
+ subtitle = stringResource(R.string.settings_level_off_subtitle),
+ currentLevel = uiState.parentalControlLevel
+ ) {
+ viewModel.setParentalControlLevel(0)
+ onShowLevelDialogChange(false)
+ }
+ LevelOption(
+ level = 1,
+ text = stringResource(R.string.settings_level_locked_desc),
+ subtitle = stringResource(R.string.settings_level_locked_subtitle),
+ currentLevel = uiState.parentalControlLevel
+ ) {
+ if (uiState.hasParentalPin) {
+ viewModel.setParentalControlLevel(1)
+ } else {
+ onPendingProtectionLevelChange(1)
+ onPendingActionChange(ParentalAction.SetNewPin)
+ onShowPinDialogChange(true)
+ }
+ onShowLevelDialogChange(false)
+ }
+ LevelOption(
+ level = 2,
+ text = stringResource(R.string.settings_level_private_desc),
+ subtitle = stringResource(R.string.settings_level_private_subtitle),
+ currentLevel = uiState.parentalControlLevel
+ ) {
+ if (uiState.hasParentalPin) {
+ viewModel.setParentalControlLevel(2)
+ } else {
+ onPendingProtectionLevelChange(2)
+ onPendingActionChange(ParentalAction.SetNewPin)
+ onShowPinDialogChange(true)
+ }
+ onShowLevelDialogChange(false)
+ }
+ LevelOption(
+ level = 3,
+ text = stringResource(R.string.settings_level_hidden_desc),
+ subtitle = stringResource(R.string.settings_level_hidden_subtitle),
+ currentLevel = uiState.parentalControlLevel
+ ) {
+ if (uiState.hasParentalPin) {
+ viewModel.setParentalControlLevel(3)
+ } else {
+ onPendingProtectionLevelChange(3)
+ onPendingActionChange(ParentalAction.SetNewPin)
+ onShowPinDialogChange(true)
+ }
+ onShowLevelDialogChange(false)
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderCardSections.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderCardSections.kt
new file mode 100644
index 00000000..c7b7da56
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderCardSections.kt
@@ -0,0 +1,247 @@
+package com.streamvault.app.ui.screens.settings
+
+import androidx.compose.foundation.BorderStroke
+import androidx.compose.foundation.background
+import androidx.compose.foundation.border
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.widthIn
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material3.Switch
+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.res.stringResource
+import androidx.compose.ui.unit.dp
+import androidx.tv.material3.Border
+import androidx.tv.material3.ClickableSurfaceDefaults
+import androidx.tv.material3.MaterialTheme
+import androidx.tv.material3.Text
+import com.streamvault.app.R
+import com.streamvault.app.ui.design.FocusSpec
+import com.streamvault.app.ui.interaction.TvClickableSurface
+import com.streamvault.app.ui.theme.ErrorColor
+import com.streamvault.app.ui.theme.OnBackground
+import com.streamvault.app.ui.theme.OnSurfaceDim
+import com.streamvault.app.ui.theme.Primary
+import com.streamvault.app.ui.theme.Secondary
+import com.streamvault.app.ui.theme.Surface
+import com.streamvault.app.ui.theme.SurfaceHighlight
+import com.streamvault.domain.model.ProviderType
+
+@Composable
+internal fun ProviderM3uOptionsPanel(
+ m3uVodClassificationEnabled: Boolean,
+ isSyncing: Boolean,
+ onToggleM3uVodClassification: (Boolean) -> Unit,
+ onRefreshM3uClassification: () -> Unit
+) {
+ Column(
+ modifier = Modifier
+ .fillMaxWidth()
+ .background(Surface, RoundedCornerShape(10.dp))
+ .border(1.dp, SurfaceHighlight, RoundedCornerShape(10.dp))
+ .padding(12.dp),
+ verticalArrangement = Arrangement.spacedBy(10.dp)
+ ) {
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Column(
+ modifier = Modifier.weight(1f),
+ verticalArrangement = Arrangement.spacedBy(4.dp)
+ ) {
+ Text(
+ text = stringResource(R.string.settings_m3u_vod_classification_title),
+ style = MaterialTheme.typography.titleSmall,
+ color = OnBackground
+ )
+ Text(
+ text = stringResource(R.string.settings_m3u_vod_classification_summary),
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim
+ )
+ }
+ Switch(
+ checked = m3uVodClassificationEnabled,
+ onCheckedChange = onToggleM3uVodClassification
+ )
+ }
+ Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
+ TvClickableSurface(
+ onClick = onRefreshM3uClassification,
+ enabled = !isSyncing,
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(6.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Primary.copy(alpha = 0.15f),
+ focusedContainerColor = Primary.copy(alpha = 0.3f)
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
+ ) {
+ Text(
+ text = stringResource(R.string.settings_m3u_vod_classification_refresh),
+ style = MaterialTheme.typography.labelMedium,
+ color = Primary,
+ modifier = Modifier.padding(horizontal = 16.dp, vertical = 10.dp)
+ )
+ }
+ }
+ }
+}
+
+@Composable
+internal fun ProviderSyncWarningsPanel(
+ providerType: ProviderType,
+ syncWarnings: List<String>,
+ isSyncing: Boolean,
+ onRetryWarningAction: (ProviderWarningAction) -> Unit
+) {
+ val hasEpgWarning = syncWarnings.any { it.contains("EPG", ignoreCase = true) }
+ val hasMoviesWarning = syncWarnings.any { it.contains("Movies", ignoreCase = true) }
+ val hasSeriesWarning = syncWarnings.any { it.contains("Series", ignoreCase = true) }
+
+ Text(
+ text = stringResource(R.string.settings_provider_warnings, syncWarnings.take(3).joinToString(", ")),
+ style = MaterialTheme.typography.bodySmall,
+ color = Secondary
+ )
+
+ Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
+ if (hasEpgWarning) {
+ ProviderWarningRetryButton(
+ label = stringResource(R.string.settings_retry_epg),
+ isSyncing = isSyncing,
+ onClick = { onRetryWarningAction(ProviderWarningAction.EPG) }
+ )
+ }
+ if (hasMoviesWarning) {
+ ProviderWarningRetryButton(
+ label = stringResource(R.string.settings_retry_movies),
+ isSyncing = isSyncing,
+ onClick = { onRetryWarningAction(ProviderWarningAction.MOVIES) }
+ )
+ }
+ if (hasSeriesWarning && providerType == ProviderType.XTREAM_CODES) {
+ ProviderWarningRetryButton(
+ label = stringResource(R.string.settings_retry_series),
+ isSyncing = isSyncing,
+ onClick = { onRetryWarningAction(ProviderWarningAction.SERIES) }
+ )
+ }
+ }
+}
+
+@Composable
+private fun ProviderWarningRetryButton(
+ label: String,
+ isSyncing: Boolean,
+ onClick: () -> Unit
+) {
+ TvClickableSurface(
+ onClick = onClick,
+ enabled = !isSyncing,
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(6.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Secondary.copy(alpha = 0.16f),
+ focusedContainerColor = Secondary.copy(alpha = 0.35f)
+ )
+ ) {
+ Text(
+ text = label,
+ style = MaterialTheme.typography.labelSmall,
+ color = Secondary,
+ modifier = Modifier.padding(horizontal = 10.dp, vertical = 8.dp)
+ )
+ }
+}
+
+@Composable
+internal fun ProviderActionButtons(
+ isActive: Boolean,
+ isSyncing: Boolean,
+ onConnect: () -> Unit,
+ onRefresh: () -> Unit,
+ onEdit: () -> Unit,
+ onDelete: () -> Unit,
+ onParentalControl: () -> Unit
+) {
+ Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
+ if (!isActive) {
+ ProviderActionButton(
+ label = stringResource(R.string.settings_connect),
+ accent = Primary,
+ filled = true,
+ contentColor = Color.White,
+ onClick = onConnect
+ )
+ } else {
+ ProviderActionButton(
+ label = if (isSyncing) stringResource(R.string.settings_syncing_btn) else stringResource(R.string.settings_sync_btn),
+ accent = Primary,
+ onClick = onRefresh
+ )
+ }
+
+ ProviderActionButton(
+ label = stringResource(R.string.settings_edit),
+ accent = Secondary,
+ onClick = onEdit
+ )
+
+ ProviderActionButton(
+ label = stringResource(R.string.settings_delete),
+ accent = ErrorColor,
+ onClick = onDelete
+ )
+
+ if (isActive) {
+ ProviderActionButton(
+ label = stringResource(R.string.settings_provider_category_controls_action),
+ accent = Primary,
+ onClick = onParentalControl
+ )
+ }
+ }
+}
+
+@Composable
+private fun ProviderActionButton(
+ label: String,
+ accent: Color,
+ onClick: () -> Unit,
+ filled: Boolean = false,
+ contentColor: Color = accent
+) {
+ TvClickableSurface(
+ onClick = onClick,
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(6.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = if (filled) accent else accent.copy(alpha = 0.2f),
+ focusedContainerColor = if (filled) accent.copy(alpha = 0.8f) else accent.copy(alpha = 0.5f),
+ contentColor = contentColor,
+ focusedContentColor = contentColor
+ ),
+ border = ClickableSurfaceDefaults.border(
+ focusedBorder = Border(
+ border = BorderStroke(FocusSpec.BorderWidth, Color.White),
+ shape = RoundedCornerShape(6.dp)
+ )
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
+ ) {
+ Text(
+ text = label,
+ style = MaterialTheme.typography.labelMedium,
+ color = contentColor,
+ modifier = Modifier
+ .widthIn(min = 0.dp)
+ .padding(horizontal = 16.dp, vertical = 10.dp)
+ )
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderComponents.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderComponents.kt
index dc493082..4011ef30 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderComponents.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderComponents.kt
@@ -55,568 +55,6 @@ import kotlinx.coroutines.launch
import java.text.DateFormat
import java.util.Locale
-@Composable
-internal fun CombinedM3uProfilesCard(
- profiles: List<CombinedM3uProfile>,
- availableProviders: List<Provider>,
- selectedProfileId: Long?,
- activeLiveSource: ActiveLiveSource?,
- onSelectProfile: (Long) -> Unit,
- onCreateProfile: () -> Unit,
- onActivateProfile: (Long) -> Unit,
- onDeleteProfile: (Long) -> Unit,
- onRenameProfile: (Long) -> Unit,
- onAddProvider: (Long) -> Unit,
- onRemoveProvider: (Long, Long) -> Unit,
- onToggleProviderEnabled: (Long, Long, Boolean) -> Unit,
- onMoveProvider: (Long, Long, Boolean) -> Unit
-) {
- Surface(
- shape = RoundedCornerShape(12.dp),
- colors = SurfaceDefaults.colors(containerColor = SurfaceElevated),
- modifier = Modifier.fillMaxWidth()
- ) {
- Column(
- modifier = Modifier
- .fillMaxWidth()
- .padding(16.dp),
- verticalArrangement = Arrangement.spacedBy(12.dp)
- ) {
- Row(
- modifier = Modifier.fillMaxWidth(),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically
- ) {
- Column(verticalArrangement = Arrangement.spacedBy(4.dp)) {
- Text("Combined M3U", style = MaterialTheme.typography.titleMedium, color = OnSurface)
- Text(
- "Merge selected M3U playlists into one Live TV and EPG source.",
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim
- )
- }
- CompactSettingsActionChip(
- label = "Create Combined",
- accent = Primary,
- onClick = onCreateProfile
- )
- }
-
- if (profiles.isEmpty()) {
- Text("No combined M3U sources yet.", style = MaterialTheme.typography.bodySmall, color = OnSurfaceDim)
- } else {
- LazyRow(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
- items(profiles, key = { it.id }) { profile ->
- val isActive = (activeLiveSource as? ActiveLiveSource.CombinedM3uSource)?.profileId == profile.id
- ProviderChip(
- title = profile.name,
- subtitle = buildString {
- append("${profile.members.count { it.enabled }}/${profile.members.size} playlist(s)")
- if (isActive) append(" • Active")
- if (profile.members.none { it.enabled }) append(" • Empty")
- },
- isSelected = selectedProfileId == profile.id,
- isActive = isActive,
- onClick = { onSelectProfile(profile.id) }
- )
- }
- }
-
- val selectedProfile = profiles.firstOrNull { it.id == selectedProfileId } ?: profiles.first()
- Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
- FlowRow(
- horizontalArrangement = Arrangement.spacedBy(10.dp),
- verticalArrangement = Arrangement.spacedBy(10.dp)
- ) {
- CompactSettingsActionChip(
- label = "Use For Live TV",
- accent = Primary,
- onClick = { onActivateProfile(selectedProfile.id) }
- )
- CompactSettingsActionChip(
- label = "Rename",
- accent = OnBackground,
- onClick = { onRenameProfile(selectedProfile.id) }
- )
- CompactSettingsActionChip(
- label = "Add Playlist",
- accent = OnBackground,
- onClick = { onAddProvider(selectedProfile.id) }
- )
- CompactSettingsActionChip(
- label = "Delete",
- accent = ErrorColor,
- onClick = { onDeleteProfile(selectedProfile.id) }
- )
- }
-
- Text(
- text = "${selectedProfile.members.count { it.enabled }} of ${selectedProfile.members.size} playlists enabled",
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim
- )
-
- if (selectedProfile.members.isEmpty()) {
- Text(
- text = "This combined source has no playlists yet. Add at least one M3U playlist before using it.",
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim
- )
- } else if (selectedProfile.members.none { it.enabled }) {
- Text(
- text = "All playlists in this combined source are disabled. Enable at least one to use it in Live TV.",
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim
- )
- }
-
- selectedProfile.members
- .sortedBy { it.priority }
- .forEachIndexed { index, member ->
- val providerName = member.providerName.ifBlank {
- availableProviders.firstOrNull { it.id == member.providerId }?.name ?: "Playlist ${member.providerId}"
- }
- Row(
- modifier = Modifier.fillMaxWidth(),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically
- ) {
- Column(modifier = Modifier.weight(1f)) {
- Text(providerName, style = MaterialTheme.typography.bodyMedium, color = OnSurface)
- Text(
- if (member.enabled) "Enabled in merged source" else "Disabled in merged source",
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim
- )
- }
- Row(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalAlignment = Alignment.CenterVertically) {
- CompactSettingsActionChip(
- label = "Up",
- accent = OnBackground,
- enabled = index > 0,
- onClick = { onMoveProvider(selectedProfile.id, member.providerId, true) }
- )
- CompactSettingsActionChip(
- label = "Down",
- accent = OnBackground,
- enabled = index < selectedProfile.members.lastIndex,
- onClick = { onMoveProvider(selectedProfile.id, member.providerId, false) }
- )
- Switch(
- checked = member.enabled,
- onCheckedChange = { onToggleProviderEnabled(selectedProfile.id, member.providerId, it) }
- )
- CompactSettingsActionChip(
- label = "Remove",
- accent = ErrorColor,
- onClick = { onRemoveProvider(selectedProfile.id, member.providerId) }
- )
- }
- }
- }
- }
- }
- }
- }
-}
-
-@Composable
-internal fun RenameCombinedM3uDialog(
- profile: CombinedM3uProfile,
- onDismiss: () -> Unit,
- onRename: (String) -> Unit
-) {
- var name by rememberSaveable(profile.id) { mutableStateOf(profile.name) }
-
- PremiumDialog(
- title = "Rename Combined M3U",
- subtitle = "Update the name shown in Live TV and provider settings.",
- onDismissRequest = onDismiss,
- widthFraction = 0.48f,
- content = {
- EpgSourceTextField(
- value = name,
- onValueChange = { updated -> name = updated },
- placeholder = "Combined source name"
- )
- },
- footer = {
- PremiumDialogFooterButton(
- label = stringResource(R.string.settings_cancel),
- onClick = onDismiss
- )
- PremiumDialogFooterButton(
- label = "Save",
- onClick = { onRename(name.trim()) },
- enabled = name.isNotBlank(),
- emphasized = true
- )
- }
- )
-}
-
-@Composable
-internal fun CreateCombinedM3uDialog(
- providers: List<Provider>,
- onDismiss: () -> Unit,
- onCreate: (String, List<Long>) -> Unit
-) {
- var name by rememberSaveable { mutableStateOf("") }
- var selectedProviderIds by rememberSaveable { mutableStateOf(setOf<Long>()) }
- val m3uProviders = remember(providers) { providers.filter { it.type == ProviderType.M3U } }
- val effectiveName = remember(name, selectedProviderIds, m3uProviders) {
- val manualName = name.trim()
- if (manualName.isNotBlank()) {
- manualName
- } else {
- val selectedProviders = m3uProviders.filter { it.id in selectedProviderIds }
- when {
- selectedProviders.isEmpty() -> ""
- selectedProviders.size == 1 -> "${selectedProviders.first().name} Mix"
- selectedProviders.size == 2 -> "${selectedProviders[0].name} + ${selectedProviders[1].name}"
- else -> "${selectedProviders.first().name} + ${selectedProviders.size - 1} More"
- }
- }
- }
-
- PremiumDialog(
- title = "Create Combined M3U",
- subtitle = "Pick the M3U playlists you want to browse together in Live TV and guide.",
- onDismissRequest = onDismiss,
- widthFraction = 0.52f,
- content = {
- EpgSourceTextField(
- value = name,
- onValueChange = { updated -> name = updated },
- placeholder = effectiveName.ifBlank { "Combined source name" }
- )
-
- if (m3uProviders.isEmpty()) {
- Text(
- text = "No M3U playlists are available yet. Add at least one playlist first.",
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim
- )
- } else {
- Column(
- modifier = Modifier
- .fillMaxWidth()
- .heightIn(max = 360.dp)
- .verticalScroll(rememberScrollState()),
- verticalArrangement = Arrangement.spacedBy(8.dp)
- ) {
- m3uProviders.forEach { provider ->
- val isSelected = provider.id in selectedProviderIds
- TvClickableSurface(
- onClick = {
- selectedProviderIds = if (isSelected) {
- selectedProviderIds - provider.id
- } else {
- selectedProviderIds + provider.id
- }
- },
- modifier = Modifier.fillMaxWidth(),
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(12.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = if (isSelected) Primary.copy(alpha = 0.16f) else Color.White.copy(alpha = 0.04f),
- focusedContainerColor = Primary.copy(alpha = 0.24f)
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
- ) {
- Row(
- modifier = Modifier
- .fillMaxWidth()
- .padding(horizontal = 14.dp, vertical = 12.dp),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically
- ) {
- Column(
- modifier = Modifier.weight(1f),
- verticalArrangement = Arrangement.spacedBy(2.dp)
- ) {
- Text(
- text = provider.name,
- style = MaterialTheme.typography.bodyMedium,
- color = OnSurface
- )
- Text(
- text = if (isSelected) "Included in this combined source" else "Press to include this playlist",
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim
- )
- }
- Checkbox(
- checked = isSelected,
- onCheckedChange = null
- )
- }
- }
- }
- }
- }
- },
- footer = {
- PremiumDialogFooterButton(
- label = stringResource(R.string.settings_cancel),
- onClick = onDismiss
- )
- PremiumDialogFooterButton(
- label = "Create",
- onClick = { onCreate(effectiveName, selectedProviderIds.toList()) },
- enabled = selectedProviderIds.isNotEmpty() && effectiveName.isNotBlank(),
- emphasized = true
- )
- }
- )
-}
-
-@Composable
-internal fun AddCombinedProviderDialog(
- profile: CombinedM3uProfile,
- availableProviders: List<Provider>,
- onDismiss: () -> Unit,
- onAddProvider: (Long) -> Unit
-) {
- val candidateProviders = remember(profile, availableProviders) {
- availableProviders.filter { provider -> profile.members.none { it.providerId == provider.id } }
- }
- var selectedProviderId by rememberSaveable(profile.id) { mutableStateOf(candidateProviders.firstOrNull()?.id) }
- PremiumDialog(
- title = "Add Playlist To ${profile.name}",
- subtitle = "Select another M3U playlist to include in this combined source.",
- onDismissRequest = onDismiss,
- widthFraction = 0.52f,
- content = {
- if (candidateProviders.isEmpty()) {
- Text(
- text = "All M3U playlists are already in this combined source.",
- style = MaterialTheme.typography.bodyMedium,
- color = OnSurfaceDim
- )
- } else {
- Column(
- modifier = Modifier
- .fillMaxWidth()
- .heightIn(max = 320.dp)
- .verticalScroll(rememberScrollState()),
- verticalArrangement = Arrangement.spacedBy(8.dp)
- ) {
- candidateProviders.forEach { provider ->
- val isSelected = selectedProviderId == provider.id
- TvClickableSurface(
- onClick = { selectedProviderId = provider.id },
- modifier = Modifier.fillMaxWidth(),
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(12.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = if (isSelected) Primary.copy(alpha = 0.16f) else Color.White.copy(alpha = 0.04f),
- focusedContainerColor = Primary.copy(alpha = 0.22f)
- ),
- border = ClickableSurfaceDefaults.border(
- border = Border(
- border = BorderStroke(
- 1.dp,
- if (isSelected) Primary.copy(alpha = 0.4f) else Color.White.copy(alpha = 0.08f)
- ),
- shape = RoundedCornerShape(12.dp)
- ),
- focusedBorder = Border(
- border = BorderStroke(FocusSpec.BorderWidth, Color.White),
- shape = RoundedCornerShape(12.dp)
- )
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
- ) {
- Row(
- modifier = Modifier
- .fillMaxWidth()
- .padding(horizontal = 14.dp, vertical = 12.dp),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically
- ) {
- Text(
- text = provider.name,
- style = MaterialTheme.typography.bodyMedium,
- color = OnSurface,
- modifier = Modifier.weight(1f)
- )
- RadioButton(
- selected = isSelected,
- onClick = { selectedProviderId = provider.id }
- )
- }
- }
- }
- }
- }
- },
- footer = {
- PremiumDialogFooterButton(
- label = stringResource(R.string.settings_cancel),
- onClick = onDismiss
- )
- PremiumDialogFooterButton(
- label = "Add",
- onClick = { selectedProviderId?.let(onAddProvider) },
- enabled = selectedProviderId != null && candidateProviders.isNotEmpty(),
- emphasized = true
- )
- }
- )
-}
-
-@Composable
-private fun ProviderChip(
- title: String,
- subtitle: String,
- isSelected: Boolean,
- isActive: Boolean,
- onClick: () -> Unit
-) {
- TvClickableSurface(
- onClick = onClick,
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(10.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = if (isSelected) Primary.copy(alpha = 0.16f) else Color.Transparent,
- focusedContainerColor = Primary.copy(alpha = 0.24f)
- )
- ) {
- Column(modifier = Modifier.padding(horizontal = 14.dp, vertical = 12.dp)) {
- Text(title, style = MaterialTheme.typography.bodyMedium, color = OnSurface)
- Text(
- if (isActive) "$subtitle • Active" else subtitle,
- style = MaterialTheme.typography.bodySmall,
- color = if (isActive) Primary else OnSurfaceDim
- )
- }
- }
-}
-
-private fun availableSyncSelections(provider: Provider): List<ProviderSyncSelection> = buildList {
- add(ProviderSyncSelection.TV)
- add(ProviderSyncSelection.MOVIES)
- if (provider.type == ProviderType.XTREAM_CODES) {
- add(ProviderSyncSelection.SERIES)
- }
- add(ProviderSyncSelection.EPG)
-}
-
-@Composable
-internal fun ProviderSyncOptionsDialog(
- provider: Provider,
- onDismiss: () -> Unit,
- onSelect: (ProviderSyncSelection?) -> Unit
-) {
- PremiumDialog(
- onDismissRequest = onDismiss,
- title = stringResource(R.string.settings_sync_dialog_title, provider.name),
- content = {
- Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
- Text(
- text = stringResource(R.string.settings_sync_dialog_subtitle),
- style = MaterialTheme.typography.bodyMedium,
- color = OnSurface
- )
- SyncOptionButton(stringResource(R.string.settings_sync_option_fast)) {
- onSelect(ProviderSyncSelection.FAST)
- }
- availableSyncSelections(provider).forEach { option ->
- SyncOptionButton(text = syncSelectionLabel(option)) {
- onSelect(option)
- }
- }
- OutlinedButton(
- onClick = { onSelect(null) },
- modifier = Modifier.fillMaxWidth()
- ) {
- Text(stringResource(R.string.settings_sync_option_custom))
- }
- }
- }
- )
-}
-
-@Composable
-internal fun ProviderCustomSyncDialog(
- provider: Provider,
- selected: Set<ProviderSyncSelection>,
- onToggle: (ProviderSyncSelection) -> Unit,
- onDismiss: () -> Unit,
- onConfirm: () -> Unit
-) {
- PremiumDialog(
- onDismissRequest = onDismiss,
- title = stringResource(R.string.settings_sync_custom_title, provider.name),
- content = {
- Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
- Text(
- text = stringResource(R.string.settings_sync_custom_subtitle),
- style = MaterialTheme.typography.bodyMedium,
- color = OnSurface
- )
- availableSyncSelections(provider).forEach { option ->
- Row(
- modifier = Modifier
- .fillMaxWidth()
- .clickable { onToggle(option) }
- .padding(vertical = 8.dp),
- verticalAlignment = Alignment.CenterVertically,
- horizontalArrangement = Arrangement.spacedBy(12.dp)
- ) {
- Checkbox(
- checked = option in selected,
- onCheckedChange = { onToggle(option) }
- )
- Text(
- text = syncSelectionLabel(option),
- style = MaterialTheme.typography.bodyLarge,
- color = OnBackground
- )
- }
- }
- }
- },
- footer = {
- Row(
- modifier = Modifier.fillMaxWidth(),
- horizontalArrangement = Arrangement.spacedBy(12.dp, Alignment.End)
- ) {
- PremiumDialogFooterButton(
- label = stringResource(R.string.settings_cancel),
- onClick = onDismiss
- )
- PremiumDialogFooterButton(
- label = stringResource(R.string.settings_sync_btn),
- onClick = onConfirm,
- enabled = selected.isNotEmpty()
- )
- }
- }
- )
-}
-
-@Composable
-private fun SyncOptionButton(
- text: String,
- onClick: () -> Unit
-) {
- TvButton(
- onClick = onClick,
- modifier = Modifier.fillMaxWidth()
- ) {
- Text(text)
- }
-}
-
-@Composable
-private fun syncSelectionLabel(selection: ProviderSyncSelection): String = when (selection) {
- ProviderSyncSelection.ALL -> stringResource(R.string.settings_sync_option_all)
- ProviderSyncSelection.FAST -> stringResource(R.string.settings_sync_option_fast)
- ProviderSyncSelection.TV -> stringResource(R.string.settings_sync_option_tv)
- ProviderSyncSelection.MOVIES -> stringResource(R.string.settings_sync_option_movies)
- ProviderSyncSelection.SERIES -> stringResource(R.string.settings_sync_option_series)
- ProviderSyncSelection.EPG -> stringResource(R.string.settings_sync_option_epg)
-}
-
@Composable
internal fun ProviderSettingsCard(
provider: Provider,
@@ -723,908 +161,35 @@ internal fun ProviderSettingsCard(
}
if (provider.type == ProviderType.M3U) {
- Column(
- modifier = Modifier
- .fillMaxWidth()
- .background(Surface, RoundedCornerShape(10.dp))
- .border(1.dp, SurfaceHighlight, RoundedCornerShape(10.dp))
- .padding(12.dp),
- verticalArrangement = Arrangement.spacedBy(10.dp)
- ) {
- Row(
- modifier = Modifier.fillMaxWidth(),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically
- ) {
- Column(
- modifier = Modifier.weight(1f),
- verticalArrangement = Arrangement.spacedBy(4.dp)
- ) {
- Text(
- text = stringResource(R.string.settings_m3u_vod_classification_title),
- style = MaterialTheme.typography.titleSmall,
- color = OnBackground
- )
- Text(
- text = stringResource(R.string.settings_m3u_vod_classification_summary),
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim
- )
- }
- Switch(
- checked = provider.m3uVodClassificationEnabled,
- onCheckedChange = onToggleM3uVodClassification
- )
- }
- Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
- TvClickableSurface(
- onClick = onRefreshM3uClassification,
- enabled = !isSyncing,
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(6.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Primary.copy(alpha = 0.15f),
- focusedContainerColor = Primary.copy(alpha = 0.3f)
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
- ) {
- Text(
- text = stringResource(R.string.settings_m3u_vod_classification_refresh),
- style = MaterialTheme.typography.labelMedium,
- color = Primary,
- modifier = Modifier.padding(horizontal = 16.dp, vertical = 10.dp)
- )
- }
- }
- }
- }
-
- if (syncWarnings.isNotEmpty()) {
- val hasEpgWarning = syncWarnings.any { it.contains("EPG", ignoreCase = true) }
- val hasMoviesWarning = syncWarnings.any { it.contains("Movies", ignoreCase = true) }
- val hasSeriesWarning = syncWarnings.any { it.contains("Series", ignoreCase = true) }
-
- Text(
- text = stringResource(R.string.settings_provider_warnings, syncWarnings.take(3).joinToString(", ")),
- style = MaterialTheme.typography.bodySmall,
- color = Secondary
- )
-
- Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
- if (hasEpgWarning) {
- TvClickableSurface(
- onClick = { onRetryWarningAction(ProviderWarningAction.EPG) },
- enabled = !isSyncing,
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(6.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Secondary.copy(alpha = 0.16f),
- focusedContainerColor = Secondary.copy(alpha = 0.35f)
- )
- ) {
- Text(
- text = stringResource(R.string.settings_retry_epg),
- style = MaterialTheme.typography.labelSmall,
- color = Secondary,
- modifier = Modifier.padding(horizontal = 10.dp, vertical = 8.dp)
- )
- }
- }
- if (hasMoviesWarning) {
- TvClickableSurface(
- onClick = { onRetryWarningAction(ProviderWarningAction.MOVIES) },
- enabled = !isSyncing,
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(6.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Secondary.copy(alpha = 0.16f),
- focusedContainerColor = Secondary.copy(alpha = 0.35f)
- )
- ) {
- Text(
- text = stringResource(R.string.settings_retry_movies),
- style = MaterialTheme.typography.labelSmall,
- color = Secondary,
- modifier = Modifier.padding(horizontal = 10.dp, vertical = 8.dp)
- )
- }
- }
- if (hasSeriesWarning && provider.type == ProviderType.XTREAM_CODES) {
- TvClickableSurface(
- onClick = { onRetryWarningAction(ProviderWarningAction.SERIES) },
- enabled = !isSyncing,
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(6.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Secondary.copy(alpha = 0.16f),
- focusedContainerColor = Secondary.copy(alpha = 0.35f)
- )
- ) {
- Text(
- text = stringResource(R.string.settings_retry_series),
- style = MaterialTheme.typography.labelSmall,
- color = Secondary,
- modifier = Modifier.padding(horizontal = 10.dp, vertical = 8.dp)
- )
- }
- }
- }
- }
-
- // Action buttons - each independently focusable for d-pad
- Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
- if (!isActive) {
- TvClickableSurface(
- onClick = onConnect,
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(6.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Primary,
- focusedContainerColor = Primary.copy(alpha = 0.8f),
- contentColor = Color.White
- ),
- border = ClickableSurfaceDefaults.border(
- focusedBorder = Border(
- border = BorderStroke(FocusSpec.BorderWidth, Color.White),
- shape = RoundedCornerShape(6.dp)
- )
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
- ) {
- Text(
- text = stringResource(R.string.settings_connect),
- style = MaterialTheme.typography.labelMedium,
- color = Color.White,
- modifier = Modifier.padding(horizontal = 16.dp, vertical = 10.dp)
- )
- }
- } else {
- TvClickableSurface(
- onClick = onRefresh,
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(6.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Primary.copy(alpha = 0.2f),
- focusedContainerColor = Primary.copy(alpha = 0.5f)
- ),
- border = ClickableSurfaceDefaults.border(
- focusedBorder = Border(
- border = BorderStroke(FocusSpec.BorderWidth, Color.White),
- shape = RoundedCornerShape(6.dp)
- )
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
- ) {
- Text(
- text = if (isSyncing) stringResource(R.string.settings_syncing_btn) else stringResource(R.string.settings_sync_btn),
- style = MaterialTheme.typography.labelMedium,
- color = Primary,
- modifier = Modifier.padding(horizontal = 16.dp, vertical = 10.dp)
- )
- }
- }
-
- TvClickableSurface(
- onClick = onEdit,
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(6.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Secondary.copy(alpha = 0.2f),
- focusedContainerColor = Secondary.copy(alpha = 0.5f)
- ),
- border = ClickableSurfaceDefaults.border(
- focusedBorder = Border(
- border = BorderStroke(FocusSpec.BorderWidth, Color.White),
- shape = RoundedCornerShape(6.dp)
- )
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
- ) {
- Text(
- text = stringResource(R.string.settings_edit),
- style = MaterialTheme.typography.labelMedium,
- color = Secondary,
- modifier = Modifier.padding(horizontal = 16.dp, vertical = 10.dp)
- )
- }
-
- TvClickableSurface(
- onClick = onDelete,
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(6.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = ErrorColor.copy(alpha = 0.2f),
- focusedContainerColor = ErrorColor.copy(alpha = 0.5f)
- ),
- border = ClickableSurfaceDefaults.border(
- focusedBorder = Border(
- border = BorderStroke(FocusSpec.BorderWidth, Color.White),
- shape = RoundedCornerShape(6.dp)
- )
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
- ) {
- Text(
- text = stringResource(R.string.settings_delete),
- style = MaterialTheme.typography.labelMedium,
- color = ErrorColor,
- modifier = Modifier.padding(horizontal = 16.dp, vertical = 10.dp)
- )
- }
-
- if (isActive) {
- TvClickableSurface(
- onClick = onParentalControl,
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(6.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Primary.copy(alpha = 0.15f),
- focusedContainerColor = Primary.copy(alpha = 0.3f)
- ),
- border = ClickableSurfaceDefaults.border(
- focusedBorder = Border(
- border = BorderStroke(FocusSpec.BorderWidth, Color.White),
- shape = RoundedCornerShape(6.dp)
- )
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
- ) {
- Text(
- text = stringResource(R.string.settings_provider_category_controls_action),
- style = MaterialTheme.typography.labelMedium,
- color = Primary,
- modifier = Modifier.padding(horizontal = 16.dp, vertical = 10.dp)
- )
- }
- }
- }
-
- }
-}
-
-@Composable
-internal fun ProviderSelectorTab(
- provider: Provider,
- isSelected: Boolean,
- isActive: Boolean,
- onClick: () -> Unit
-) {
- val focusRequester = remember { FocusRequester() }
- TvClickableSurface(
- onClick = onClick,
- modifier = Modifier
- .focusRequester(focusRequester)
- .mouseClickable(
- focusRequester = focusRequester,
- onClick = onClick
- ),
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(999.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = if (isSelected) Primary.copy(alpha = 0.18f) else SurfaceElevated,
- focusedContainerColor = Primary.copy(alpha = 0.34f)
- ),
- border = ClickableSurfaceDefaults.border(
- border = Border(
- border = androidx.compose.foundation.BorderStroke(
- width = 1.dp,
- color = if (isSelected) Primary.copy(alpha = 0.45f) else Color.White.copy(alpha = 0.08f)
- )
- ),
- focusedBorder = Border(
- border = androidx.compose.foundation.BorderStroke(
- width = 2.dp,
- color = Primary
- )
- )
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
- ) {
- Row(
- modifier = Modifier.padding(horizontal = 16.dp, vertical = 10.dp),
- horizontalArrangement = Arrangement.spacedBy(10.dp),
- verticalAlignment = Alignment.CenterVertically
- ) {
- Column(
- verticalArrangement = Arrangement.spacedBy(2.dp)
- ) {
- Text(
- text = provider.name,
- style = MaterialTheme.typography.labelLarge,
- color = OnBackground,
- fontWeight = FontWeight.Bold,
- maxLines = 1
- )
- Text(
- text = provider.type.name,
- style = MaterialTheme.typography.labelSmall,
- color = OnSurfaceDim
- )
- }
- if (isActive) {
- Text(
- text = stringResource(R.string.settings_active),
- style = MaterialTheme.typography.labelSmall,
- color = Primary,
- fontWeight = FontWeight.Bold
- )
- }
- }
- }
-}
-
-@Composable
-private fun ProviderCompactStat(
- title: String,
- count: Int
-) {
- Surface(
- shape = RoundedCornerShape(10.dp),
- colors = SurfaceDefaults.colors(containerColor = Color.White.copy(alpha = 0.06f))
- ) {
- Column(
- modifier = Modifier.padding(horizontal = 10.dp, vertical = 8.dp),
- verticalArrangement = Arrangement.spacedBy(2.dp)
- ) {
- Text(
- text = title,
- style = MaterialTheme.typography.labelSmall,
- color = OnSurfaceDim
- )
- Text(
- text = count.toString(),
- style = MaterialTheme.typography.labelMedium,
- color = OnBackground
- )
- }
- }
-}
-
-@Composable
-private fun ProviderStatusBadge(status: ProviderStatus) {
- val (label, color) = when (status) {
- ProviderStatus.ACTIVE -> stringResource(R.string.settings_status_active) to Primary
- ProviderStatus.PARTIAL -> stringResource(R.string.settings_status_partial) to Secondary
- ProviderStatus.ERROR -> stringResource(R.string.settings_status_error) to ErrorColor
- ProviderStatus.EXPIRED -> stringResource(R.string.settings_status_expired) to ErrorColor
- ProviderStatus.DISABLED -> stringResource(R.string.settings_status_disabled) to OnSurfaceDim
- ProviderStatus.UNKNOWN -> stringResource(R.string.settings_status_unknown) to OnSurfaceDim
- }
-
- Text(
- text = label,
- style = MaterialTheme.typography.labelSmall,
- color = color,
- fontWeight = androidx.compose.ui.text.font.FontWeight.Bold,
- modifier = Modifier
- .background(color.copy(alpha = 0.16f), RoundedCornerShape(4.dp))
- .padding(horizontal = 8.dp, vertical = 4.dp)
- )
-}
-
-@Composable
-internal fun SettingsOverviewCard(
- activeProviderName: String,
- providerCount: Int,
- protectionSummary: String,
- languageLabel: String
-) {
- Surface(
- modifier = Modifier.fillMaxWidth(),
- colors = SurfaceDefaults.colors(containerColor = SurfaceElevated),
- shape = RoundedCornerShape(16.dp)
- ) {
- Column(
- modifier = Modifier.padding(20.dp),
- verticalArrangement = Arrangement.spacedBy(14.dp)
- ) {
- Text(
- text = stringResource(R.string.settings_overview_title),
- style = MaterialTheme.typography.titleLarge,
- color = OnBackground
- )
- Text(
- text = stringResource(R.string.settings_overview_subtitle),
- style = MaterialTheme.typography.bodyMedium,
- color = OnSurfaceDim
- )
- Row(
- modifier = Modifier.fillMaxWidth(),
- horizontalArrangement = Arrangement.spacedBy(12.dp)
- ) {
- SettingsOverviewStat(
- modifier = Modifier.weight(1f),
- label = stringResource(R.string.settings_overview_provider_label),
- value = activeProviderName
- )
- SettingsOverviewStat(
- modifier = Modifier.weight(1f),
- label = stringResource(R.string.settings_overview_count_label),
- value = providerCount.toString()
- )
- SettingsOverviewStat(
- modifier = Modifier.weight(1f),
- label = stringResource(R.string.settings_overview_protection_label),
- value = protectionSummary
- )
- SettingsOverviewStat(
- modifier = Modifier.weight(1f),
- label = stringResource(R.string.settings_overview_language_label),
- value = languageLabel
- )
- }
- }
-
- }
-}
-
-@Composable
-private fun ProviderDiagnosticsPanel(
- provider: Provider,
- diagnostics: ProviderDiagnosticsUiModel,
- databaseMaintenance: DatabaseMaintenanceUiModel?
-) {
- Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
- Text(
- text = stringResource(R.string.settings_provider_diagnostics_title),
- style = MaterialTheme.typography.titleSmall,
- color = Primary
- )
- Text(
- text = diagnostics.capabilitySummary,
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim
- )
- Text(
- text = stringResource(R.string.diagnostics_summary_format, diagnostics.sourceLabel, diagnostics.connectionSummary),
- style = MaterialTheme.typography.bodySmall,
- color = OnSurface
- )
- Text(
- text = diagnostics.expirySummary,
- style = MaterialTheme.typography.bodySmall,
- color = OnSurface
- )
- Text(
- text = diagnostics.archiveSummary,
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim
- )
- Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
- ProviderDiagnosticPill(
- title = stringResource(R.string.settings_diagnostic_live),
- count = diagnostics.liveCount,
- timestamp = diagnostics.lastLiveSync
- )
- ProviderDiagnosticPill(
- title = stringResource(R.string.settings_diagnostic_movies),
- count = diagnostics.movieCount,
- timestamp = diagnostics.lastMovieSync
- )
- if (provider.type == ProviderType.XTREAM_CODES) {
- ProviderDiagnosticPill(
- title = stringResource(R.string.settings_diagnostic_series),
- count = diagnostics.seriesCount,
- timestamp = diagnostics.lastSeriesSync
- )
- }
- ProviderDiagnosticPill(
- title = stringResource(R.string.settings_diagnostic_epg),
- count = diagnostics.epgCount,
- timestamp = diagnostics.lastEpgSync
- )
- }
- Text(
- text = stringResource(R.string.settings_diagnostic_status, diagnostics.lastSyncStatus),
- style = MaterialTheme.typography.labelSmall,
- color = OnSurface
- )
- diagnostics.healthSummary(provider.type)?.let { summary ->
- Text(
- text = summary,
- style = MaterialTheme.typography.bodySmall,
- color = ErrorColor,
- fontWeight = FontWeight.Medium
- )
- }
- databaseMaintenance?.let { report ->
- DatabaseMaintenancePanel(report = report)
- }
- }
-}
-
-@Composable
-private fun DatabaseMaintenancePanel(report: DatabaseMaintenanceUiModel) {
- val appTimeFormat = LocalAppTimeFormat.current
- val dateTimeFormat = remember(appTimeFormat) { appTimeFormat.createDateTimeFormat() }
- Column(
- modifier = Modifier
- .fillMaxWidth()
- .background(Color.White.copy(alpha = 0.04f), RoundedCornerShape(10.dp))
- .padding(12.dp),
- verticalArrangement = Arrangement.spacedBy(6.dp)
- ) {
- Text(
- text = "Database Health",
- style = MaterialTheme.typography.titleSmall,
- color = Primary
- )
- Text(
- text = "Last maintenance ${formatDiagnosticTimestamp(report.ranAt, dateTimeFormat)}",
- style = MaterialTheme.typography.bodySmall,
- color = OnSurface
- )
- Text(
- text = buildString {
- append("Pruned ")
- append(report.deletedPrograms)
- append(" internal programs, ")
- append(report.deletedExternalProgrammes)
- append(" external programs, ")
- append(report.deletedOrphanEpisodes)
- append(" orphan episodes, and ")
- append(report.deletedStaleFavorites)
- append(" stale favorites.")
- },
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim
- )
- Text(
- text = buildString {
- append("Main DB ")
- append(formatMaintenanceBytes(report.mainDbBytes))
- append(" • WAL ")
- append(formatMaintenanceBytes(report.walBytes))
- append(" • Reclaimable ")
- append(formatMaintenanceBytes(report.reclaimableBytes))
- append(" • VACUUM ")
- append(if (report.vacuumRan) "ran" else "not needed or skipped")
- },
- style = MaterialTheme.typography.bodySmall,
- color = OnSurface
- )
- Text(
- text = buildString {
- append("Rows: channels ")
- append(formatMaintenanceCount(report.channelRows))
- append(", movies ")
- append(formatMaintenanceCount(report.movieRows))
- append(", series ")
- append(formatMaintenanceCount(report.seriesRows))
- append(", episodes ")
- append(formatMaintenanceCount(report.episodeRows))
- },
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim
- )
- Text(
- text = buildString {
- append("Programs ")
- append(formatMaintenanceCount(report.programRows))
- append(", external EPG ")
- append(formatMaintenanceCount(report.epgProgrammeRows))
- append(", history ")
- append(formatMaintenanceCount(report.playbackHistoryRows))
- append(", favorites ")
- append(formatMaintenanceCount(report.favoriteRows))
- },
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim
- )
- }
-}
-
-@Composable
-private fun ProviderDiagnosticPill(
- title: String,
- count: Int,
- timestamp: Long
-) {
- val appTimeFormat = LocalAppTimeFormat.current
- val dateTimeFormat = remember(appTimeFormat) { appTimeFormat.createDateTimeFormat() }
- val syncLabel = remember(timestamp, dateTimeFormat) { formatDiagnosticTimestamp(timestamp, dateTimeFormat) }
- Surface(
- shape = RoundedCornerShape(10.dp),
- colors = SurfaceDefaults.colors(
- containerColor = Color.White.copy(alpha = 0.06f)
- )
- ) {
- Column(
- modifier = Modifier.padding(horizontal = 12.dp, vertical = 10.dp),
- verticalArrangement = Arrangement.spacedBy(4.dp)
- ) {
- Text(
- text = title,
- style = MaterialTheme.typography.labelSmall,
- color = OnSurfaceDim
- )
- Text(
- text = stringResource(R.string.settings_diagnostic_items, count),
- style = MaterialTheme.typography.labelLarge,
- color = OnBackground
- )
- Text(
- text = syncLabel ?: stringResource(R.string.settings_diagnostic_never),
- style = MaterialTheme.typography.labelSmall,
- color = OnSurface
+ ProviderM3uOptionsPanel(
+ m3uVodClassificationEnabled = provider.m3uVodClassificationEnabled,
+ isSyncing = isSyncing,
+ onToggleM3uVodClassification = onToggleM3uVodClassification,
+ onRefreshM3uClassification = onRefreshM3uClassification
)
}
- }
-}
-private fun ProviderDiagnosticsUiModel.healthSummary(providerType: ProviderType): String? {
- val warnings = buildList {
- if (liveSequentialFailuresRemembered) {
- add("Live sync needs attention")
- }
- if (movieParallelFailuresRemembered) {
- add(
- if (movieWarningsCount > 0) {
- "Movies have $movieWarningsCount remembered warning(s)"
- } else {
- "Movie sync still has remembered warnings"
- }
+ if (syncWarnings.isNotEmpty()) {
+ ProviderSyncWarningsPanel(
+ providerType = provider.type,
+ syncWarnings = syncWarnings,
+ isSyncing = isSyncing,
+ onRetryWarningAction = onRetryWarningAction
)
}
- if (movieCatalogStale) {
- add("Movie catalog is running stale")
- }
- if (providerType == ProviderType.XTREAM_CODES && seriesSequentialFailuresRemembered) {
- add("Series sync needs attention")
- }
- }
- if (warnings.isEmpty()) {
- val streakParts = buildList {
- if (liveHealthySyncStreak > 0) add("Live streak $liveHealthySyncStreak")
- if (movieHealthySyncStreak > 0) add("Movies streak $movieHealthySyncStreak")
- if (providerType == ProviderType.XTREAM_CODES && seriesHealthySyncStreak > 0) {
- add("Series streak $seriesHealthySyncStreak")
- }
- }
- return streakParts.takeIf { it.isNotEmpty() }?.joinToString(" • ")
- }
- return warnings.joinToString(" • ")
-}
-
-private fun formatDiagnosticTimestamp(timestamp: Long, dateTimeFormat: DateFormat): String? =
- if (timestamp <= 0L) {
- null
- } else {
- dateTimeFormat.format(java.util.Date(timestamp))
- }
-private fun formatMaintenanceBytes(bytes: Long): String {
- if (bytes <= 0L) return "0 B"
- val units = arrayOf("B", "KB", "MB", "GB", "TB")
- var value = bytes.toDouble()
- var unitIndex = 0
- while (value >= 1024.0 && unitIndex < units.lastIndex) {
- value /= 1024.0
- unitIndex++
- }
- val formatted = if (value >= 10 || unitIndex == 0) {
- value.toInt().toString()
- } else {
- String.format(Locale.US, "%.1f", value)
- }
- return "$formatted ${units[unitIndex]}"
-}
-
-private fun formatMaintenanceCount(value: Long): String = when {
- value >= 1_000_000L -> String.format(Locale.US, "%.1fM", value / 1_000_000.0)
- value >= 1_000L -> String.format(Locale.US, "%.1fk", value / 1_000.0)
- else -> value.toString()
-}
-
-@Composable
-internal fun SettingsOverviewStat(
- label: String,
- value: String,
- modifier: Modifier = Modifier
-) {
- Column(
- modifier = modifier
- .background(SurfaceHighlight.copy(alpha = 0.28f), RoundedCornerShape(12.dp))
- .padding(horizontal = 14.dp, vertical = 12.dp),
- verticalArrangement = Arrangement.spacedBy(4.dp)
- ) {
- Text(
- text = label.uppercase(Locale.getDefault()),
- style = MaterialTheme.typography.labelSmall,
- color = OnSurfaceDim
+ ProviderActionButtons(
+ isActive = isActive,
+ isSyncing = isSyncing,
+ onConnect = onConnect,
+ onRefresh = onRefresh,
+ onEdit = onEdit,
+ onDelete = onDelete,
+ onParentalControl = onParentalControl
)
- Text(
- text = value,
- style = MaterialTheme.typography.titleSmall,
- color = OnBackground,
- fontWeight = FontWeight.SemiBold
- )
- }
-}
-@Composable
-private fun CompactSettingsActionChip(
- label: String,
- accent: Color,
- enabled: Boolean = true,
- onClick: () -> Unit
-) {
- TvClickableSurface(
- onClick = onClick,
- enabled = enabled,
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = accent.copy(alpha = if (enabled) 0.14f else 0.08f),
- contentColor = accent.copy(alpha = if (enabled) 1f else 0.42f),
- focusedContainerColor = accent.copy(alpha = if (enabled) 0.28f else 0.08f),
- focusedContentColor = accent.copy(alpha = if (enabled) 1f else 0.42f),
- disabledContainerColor = accent.copy(alpha = 0.08f),
- disabledContentColor = accent.copy(alpha = 0.42f)
- ),
- border = ClickableSurfaceDefaults.border(
- border = Border(
- border = BorderStroke(1.dp, Color.White.copy(alpha = if (enabled) 0.08f else 0.04f)),
- shape = RoundedCornerShape(8.dp)
- ),
- focusedBorder = Border(
- border = BorderStroke(FocusSpec.BorderWidth, Color.White),
- shape = RoundedCornerShape(8.dp)
- )
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
- ) {
- Text(
- text = label,
- color = accent.copy(alpha = if (enabled) 1f else 0.42f),
- style = MaterialTheme.typography.labelSmall,
- modifier = Modifier.padding(horizontal = 12.dp, vertical = 8.dp)
- )
}
}
-@Composable
-internal fun EpgSourceTextField(
- value: String,
- onValueChange: (String) -> Unit,
- placeholder: String
-) {
- val isTelevisionDevice = com.streamvault.app.device.rememberIsTelevisionDevice()
- val focusRequester = remember { FocusRequester() }
- val keyboardController = LocalSoftwareKeyboardController.current
- val bringIntoViewRequester = remember { BringIntoViewRequester() }
- val coroutineScope = rememberCoroutineScope()
- var hasContainerFocus by remember { mutableStateOf(false) }
- var hasInputFocus by remember { mutableStateOf(false) }
- var acceptsInput by remember(isTelevisionDevice) { mutableStateOf(!isTelevisionDevice) }
- var pendingInputActivation by remember { mutableStateOf(false) }
- var fieldValue by remember {
- mutableStateOf(TextFieldValue(text = value, selection = TextRange(value.length)))
- }
- val isFocused = hasContainerFocus || hasInputFocus
-
- // Re-call bringIntoView on every frame of the keyboard animation so the
- // LazyColumn keeps scrolling the focused field into view as imePadding shrinks.
- val density = LocalDensity.current
- val imeBottom = WindowInsets.ime.getBottom(density)
- LaunchedEffect(imeBottom) {
- if ((hasInputFocus || hasContainerFocus) && imeBottom > 0) {
- runCatching { bringIntoViewRequester.bringIntoView() }
- }
- }
-
- fun requestBringIntoView(delayMillis: Long = 0L) {
- coroutineScope.launch {
- if (delayMillis > 0) {
- kotlinx.coroutines.delay(delayMillis)
- }
- runCatching { bringIntoViewRequester.bringIntoView() }
- }
- }
-
- LaunchedEffect(value) {
- if (value != fieldValue.text) {
- val coercedSelectionStart = fieldValue.selection.start.coerceIn(0, value.length)
- val coercedSelectionEnd = fieldValue.selection.end.coerceIn(0, value.length)
- val coercedComposition = fieldValue.composition?.let { composition ->
- val compositionStart = composition.start.coerceIn(0, value.length)
- val compositionEnd = composition.end.coerceIn(0, value.length)
- if (compositionStart <= compositionEnd) {
- TextRange(compositionStart, compositionEnd)
- } else {
- null
- }
- }
- fieldValue = fieldValue.copy(
- text = value,
- selection = TextRange(coercedSelectionStart, coercedSelectionEnd),
- composition = coercedComposition
- )
- }
- }
-
- LaunchedEffect(acceptsInput, pendingInputActivation) {
- if (!isTelevisionDevice || !acceptsInput || !pendingInputActivation) {
- return@LaunchedEffect
- }
- focusRequester.requestFocus()
- keyboardController?.show()
- requestBringIntoView(120)
- pendingInputActivation = false
- }
-
- TvClickableSurface(
- onClick = {
- if (!isTelevisionDevice) {
- focusRequester.requestFocus()
- keyboardController?.show()
- requestBringIntoView()
- requestBringIntoView(180)
- return@TvClickableSurface
- }
- acceptsInput = true
- pendingInputActivation = true
- requestBringIntoView()
- },
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Color.White.copy(alpha = 0.08f),
- focusedContainerColor = Color.White.copy(alpha = 0.12f)
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
- modifier = Modifier
- .fillMaxWidth()
- .bringIntoViewRequester(bringIntoViewRequester)
- .onFocusChanged { hasContainerFocus = it.isFocused }
- ) {
- Box(modifier = Modifier.padding(horizontal = 12.dp, vertical = 10.dp)) {
- if (value.isEmpty() && !isFocused) {
- Text(placeholder, style = MaterialTheme.typography.bodyMedium, color = OnSurfaceDim)
- }
- BasicTextField(
- value = fieldValue,
- onValueChange = { updatedValue ->
- fieldValue = updatedValue
- if (updatedValue.text != value) {
- onValueChange(updatedValue.text)
- }
- },
- textStyle = MaterialTheme.typography.bodyMedium.copy(color = Color.White),
- singleLine = true,
- cursorBrush = SolidColor(Primary),
- modifier = Modifier
- .fillMaxWidth()
- .focusRequester(focusRequester)
- .focusProperties {
- canFocus = !isTelevisionDevice || acceptsInput
- if (isTelevisionDevice && acceptsInput) {
- left = FocusRequester.Cancel
- right = FocusRequester.Cancel
- }
- }
- .onPreviewKeyEvent { event ->
- if (!isTelevisionDevice || !acceptsInput || event.nativeKeyEvent.action != android.view.KeyEvent.ACTION_DOWN) {
- return@onPreviewKeyEvent false
- }
- val cursor = fieldValue.selection.end
- when (event.nativeKeyEvent.keyCode) {
- android.view.KeyEvent.KEYCODE_DPAD_LEFT -> {
- val nextCursor = (cursor - 1).coerceAtLeast(0)
- fieldValue = fieldValue.copy(selection = TextRange(nextCursor))
- true
- }
- android.view.KeyEvent.KEYCODE_DPAD_RIGHT -> {
- val nextCursor = (cursor + 1).coerceAtMost(fieldValue.text.length)
- fieldValue = fieldValue.copy(selection = TextRange(nextCursor))
- true
- }
- else -> false
- }
- }
- .onFocusChanged {
- hasInputFocus = it.isFocused
- if (it.isFocused) {
- requestBringIntoView(120)
- } else {
- if (isTelevisionDevice) {
- acceptsInput = false
- }
- keyboardController?.hide()
- }
- },
- readOnly = isTelevisionDevice && !acceptsInput
- )
- }
- }
-}
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderDiagnosticsPanel.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderDiagnosticsPanel.kt
new file mode 100644
index 00000000..c08e2454
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderDiagnosticsPanel.kt
@@ -0,0 +1,290 @@
+package com.streamvault.app.ui.screens.settings
+
+import androidx.compose.foundation.background
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.remember
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.unit.dp
+import androidx.tv.material3.MaterialTheme
+import androidx.tv.material3.Surface
+import androidx.tv.material3.SurfaceDefaults
+import androidx.tv.material3.Text
+import com.streamvault.app.R
+import com.streamvault.app.ui.theme.ErrorColor
+import com.streamvault.app.ui.theme.OnBackground
+import com.streamvault.app.ui.theme.OnSurface
+import com.streamvault.app.ui.theme.OnSurfaceDim
+import com.streamvault.app.ui.theme.Primary
+import com.streamvault.app.ui.time.LocalAppTimeFormat
+import com.streamvault.app.ui.time.createDateTimeFormat
+import com.streamvault.domain.model.Provider
+import com.streamvault.domain.model.ProviderType
+import java.text.DateFormat
+import java.util.Locale
+
+@Composable
+internal fun ProviderDiagnosticsPanel(
+ provider: Provider,
+ diagnostics: ProviderDiagnosticsUiModel,
+ databaseMaintenance: DatabaseMaintenanceUiModel?
+) {
+ Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
+ Text(
+ text = stringResource(R.string.settings_provider_diagnostics_title),
+ style = MaterialTheme.typography.titleSmall,
+ color = Primary
+ )
+ Text(
+ text = diagnostics.capabilitySummary,
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim
+ )
+ Text(
+ text = stringResource(R.string.diagnostics_summary_format, diagnostics.sourceLabel, diagnostics.connectionSummary),
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurface
+ )
+ Text(
+ text = diagnostics.expirySummary,
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurface
+ )
+ Text(
+ text = diagnostics.archiveSummary,
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim
+ )
+ Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
+ ProviderDiagnosticPill(
+ title = stringResource(R.string.settings_diagnostic_live),
+ count = diagnostics.liveCount,
+ timestamp = diagnostics.lastLiveSync
+ )
+ ProviderDiagnosticPill(
+ title = stringResource(R.string.settings_diagnostic_movies),
+ count = diagnostics.movieCount,
+ timestamp = diagnostics.lastMovieSync
+ )
+ if (provider.type == ProviderType.XTREAM_CODES) {
+ ProviderDiagnosticPill(
+ title = stringResource(R.string.settings_diagnostic_series),
+ count = diagnostics.seriesCount,
+ timestamp = diagnostics.lastSeriesSync
+ )
+ }
+ ProviderDiagnosticPill(
+ title = stringResource(R.string.settings_diagnostic_epg),
+ count = diagnostics.epgCount,
+ timestamp = diagnostics.lastEpgSync
+ )
+ }
+ Text(
+ text = stringResource(R.string.settings_diagnostic_status, diagnostics.lastSyncStatus),
+ style = MaterialTheme.typography.labelSmall,
+ color = OnSurface
+ )
+ diagnostics.healthSummary(provider.type)?.let { summary ->
+ Text(
+ text = summary,
+ style = MaterialTheme.typography.bodySmall,
+ color = ErrorColor,
+ fontWeight = FontWeight.Medium
+ )
+ }
+ databaseMaintenance?.let { report ->
+ DatabaseMaintenancePanel(report = report)
+ }
+ }
+}
+
+@Composable
+private fun DatabaseMaintenancePanel(report: DatabaseMaintenanceUiModel) {
+ val appTimeFormat = LocalAppTimeFormat.current
+ val dateTimeFormat = remember(appTimeFormat) { appTimeFormat.createDateTimeFormat() }
+ Column(
+ modifier = Modifier
+ .fillMaxWidth()
+ .background(Color.White.copy(alpha = 0.04f), RoundedCornerShape(10.dp))
+ .padding(12.dp),
+ verticalArrangement = Arrangement.spacedBy(6.dp)
+ ) {
+ Text(
+ text = "Database Health",
+ style = MaterialTheme.typography.titleSmall,
+ color = Primary
+ )
+ Text(
+ text = "Last maintenance ${formatDiagnosticTimestamp(report.ranAt, dateTimeFormat)}",
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurface
+ )
+ Text(
+ text = buildString {
+ append("Pruned ")
+ append(report.deletedPrograms)
+ append(" internal programs, ")
+ append(report.deletedExternalProgrammes)
+ append(" external programs, ")
+ append(report.deletedOrphanEpisodes)
+ append(" orphan episodes, and ")
+ append(report.deletedStaleFavorites)
+ append(" stale favorites.")
+ },
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim
+ )
+ Text(
+ text = buildString {
+ append("Main DB ")
+ append(formatMaintenanceBytes(report.mainDbBytes))
+ append(" • WAL ")
+ append(formatMaintenanceBytes(report.walBytes))
+ append(" • Reclaimable ")
+ append(formatMaintenanceBytes(report.reclaimableBytes))
+ append(" • VACUUM ")
+ append(if (report.vacuumRan) "ran" else "not needed or skipped")
+ },
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurface
+ )
+ Text(
+ text = buildString {
+ append("Rows: channels ")
+ append(formatMaintenanceCount(report.channelRows))
+ append(", movies ")
+ append(formatMaintenanceCount(report.movieRows))
+ append(", series ")
+ append(formatMaintenanceCount(report.seriesRows))
+ append(", episodes ")
+ append(formatMaintenanceCount(report.episodeRows))
+ },
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim
+ )
+ Text(
+ text = buildString {
+ append("Programs ")
+ append(formatMaintenanceCount(report.programRows))
+ append(", external EPG ")
+ append(formatMaintenanceCount(report.epgProgrammeRows))
+ append(", history ")
+ append(formatMaintenanceCount(report.playbackHistoryRows))
+ append(", favorites ")
+ append(formatMaintenanceCount(report.favoriteRows))
+ },
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim
+ )
+ }
+}
+
+@Composable
+private fun ProviderDiagnosticPill(
+ title: String,
+ count: Int,
+ timestamp: Long
+) {
+ val appTimeFormat = LocalAppTimeFormat.current
+ val dateTimeFormat = remember(appTimeFormat) { appTimeFormat.createDateTimeFormat() }
+ val syncLabel = remember(timestamp, dateTimeFormat) { formatDiagnosticTimestamp(timestamp, dateTimeFormat) }
+ Surface(
+ shape = RoundedCornerShape(10.dp),
+ colors = SurfaceDefaults.colors(
+ containerColor = Color.White.copy(alpha = 0.06f)
+ )
+ ) {
+ Column(
+ modifier = Modifier.padding(horizontal = 12.dp, vertical = 10.dp),
+ verticalArrangement = Arrangement.spacedBy(4.dp)
+ ) {
+ Text(
+ text = title,
+ style = MaterialTheme.typography.labelSmall,
+ color = OnSurfaceDim
+ )
+ Text(
+ text = stringResource(R.string.settings_diagnostic_items, count),
+ style = MaterialTheme.typography.labelLarge,
+ color = OnBackground
+ )
+ Text(
+ text = syncLabel ?: stringResource(R.string.settings_diagnostic_never),
+ style = MaterialTheme.typography.labelSmall,
+ color = OnSurface
+ )
+ }
+ }
+}
+
+private fun ProviderDiagnosticsUiModel.healthSummary(providerType: ProviderType): String? {
+ val warnings = buildList {
+ if (liveSequentialFailuresRemembered) {
+ add("Live sync needs attention")
+ }
+ if (movieParallelFailuresRemembered) {
+ add(
+ if (movieWarningsCount > 0) {
+ "Movies have $movieWarningsCount remembered warning(s)"
+ } else {
+ "Movie sync still has remembered warnings"
+ }
+ )
+ }
+ if (movieCatalogStale) {
+ add("Movie catalog is running stale")
+ }
+ if (providerType == ProviderType.XTREAM_CODES && seriesSequentialFailuresRemembered) {
+ add("Series sync needs attention")
+ }
+ }
+ if (warnings.isEmpty()) {
+ val streakParts = buildList {
+ if (liveHealthySyncStreak > 0) add("Live streak $liveHealthySyncStreak")
+ if (movieHealthySyncStreak > 0) add("Movies streak $movieHealthySyncStreak")
+ if (providerType == ProviderType.XTREAM_CODES && seriesHealthySyncStreak > 0) {
+ add("Series streak $seriesHealthySyncStreak")
+ }
+ }
+ return streakParts.takeIf { it.isNotEmpty() }?.joinToString(" • ")
+ }
+ return warnings.joinToString(" • ")
+}
+
+private fun formatDiagnosticTimestamp(timestamp: Long, dateTimeFormat: DateFormat): String? =
+ if (timestamp <= 0L) {
+ null
+ } else {
+ dateTimeFormat.format(java.util.Date(timestamp))
+ }
+
+private fun formatMaintenanceBytes(bytes: Long): String {
+ if (bytes <= 0L) return "0 B"
+ val units = arrayOf("B", "KB", "MB", "GB", "TB")
+ var value = bytes.toDouble()
+ var unitIndex = 0
+ while (value >= 1024.0 && unitIndex < units.lastIndex) {
+ value /= 1024.0
+ unitIndex++
+ }
+ val formatted = if (value >= 10 || unitIndex == 0) {
+ value.toInt().toString()
+ } else {
+ String.format(Locale.US, "%.1f", value)
+ }
+ return "$formatted ${units[unitIndex]}"
+}
+
+private fun formatMaintenanceCount(value: Long): String = when {
+ value >= 1_000_000L -> String.format(Locale.US, "%.1fM", value / 1_000_000.0)
+ value >= 1_000L -> String.format(Locale.US, "%.1fk", value / 1_000.0)
+ else -> value.toString()
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderManagementDialogs.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderManagementDialogs.kt
new file mode 100644
index 00000000..9ca92d1e
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderManagementDialogs.kt
@@ -0,0 +1,97 @@
+package com.streamvault.app.ui.screens.settings
+
+import androidx.compose.runtime.Composable
+
+@Composable
+internal fun SettingsProviderManagementDialogs(
+ uiState: SettingsUiState,
+ viewModel: SettingsViewModel,
+ providerState: SettingsProviderSectionState
+) {
+ val pendingSyncProvider = providerState.pendingSyncProviderId?.let { providerId ->
+ uiState.providers.firstOrNull { it.id == providerId }
+ }
+
+ if (providerState.showCreateCombinedDialog) {
+ CreateCombinedM3uDialog(
+ providers = uiState.availableM3uProviders,
+ onDismiss = { providerState.showCreateCombinedDialog = false },
+ onCreate = { name, providerIds ->
+ providerState.showCreateCombinedDialog = false
+ viewModel.createCombinedProfile(name, providerIds)
+ }
+ )
+ }
+
+ if (providerState.showRenameCombinedDialog) {
+ val selectedProfile = uiState.combinedProfiles.firstOrNull { it.id == providerState.selectedCombinedProfileId }
+ if (selectedProfile != null) {
+ RenameCombinedM3uDialog(
+ profile = selectedProfile,
+ onDismiss = { providerState.showRenameCombinedDialog = false },
+ onRename = { name ->
+ providerState.showRenameCombinedDialog = false
+ viewModel.renameCombinedProfile(selectedProfile.id, name)
+ }
+ )
+ }
+ }
+
+ if (providerState.showAddCombinedMemberDialog) {
+ val selectedProfile = uiState.combinedProfiles.firstOrNull { it.id == providerState.selectedCombinedProfileId }
+ if (selectedProfile != null) {
+ AddCombinedProviderDialog(
+ profile = selectedProfile,
+ availableProviders = uiState.availableM3uProviders,
+ onDismiss = { providerState.showAddCombinedMemberDialog = false },
+ onAddProvider = { providerId ->
+ providerState.showAddCombinedMemberDialog = false
+ viewModel.addProviderToCombinedProfile(selectedProfile.id, providerId)
+ }
+ )
+ }
+ }
+
+ if (providerState.showProviderSyncDialog && pendingSyncProvider != null) {
+ ProviderSyncOptionsDialog(
+ provider = pendingSyncProvider,
+ onDismiss = {
+ providerState.showProviderSyncDialog = false
+ providerState.pendingSyncProviderId = null
+ },
+ onSelect = { selection ->
+ providerState.showProviderSyncDialog = false
+ if (selection == null) {
+ providerState.showCustomProviderSyncDialog = true
+ } else {
+ viewModel.syncProviderSection(pendingSyncProvider.id, selection)
+ providerState.pendingSyncProviderId = null
+ }
+ }
+ )
+ }
+
+ if (providerState.showCustomProviderSyncDialog && pendingSyncProvider != null) {
+ ProviderCustomSyncDialog(
+ provider = pendingSyncProvider,
+ selected = providerState.customSyncSelections,
+ onToggle = { option ->
+ providerState.customSyncSelections =
+ if (option in providerState.customSyncSelections) {
+ providerState.customSyncSelections - option
+ } else {
+ providerState.customSyncSelections + option
+ }
+ },
+ onDismiss = {
+ providerState.showCustomProviderSyncDialog = false
+ providerState.pendingSyncProviderId = null
+ },
+ onConfirm = {
+ providerState.showCustomProviderSyncDialog = false
+ viewModel.syncProviderCustom(pendingSyncProvider.id, providerState.customSyncSelections)
+ providerState.pendingSyncProviderId = null
+ }
+ )
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderSection.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderSection.kt
index b1f39dc2..f636406e 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderSection.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderSection.kt
@@ -38,14 +38,7 @@ internal fun LazyListScope.providerSection(
onEditProvider: (Provider) -> Unit,
onNavigateToParentalControl: (Long) -> Unit,
viewModel: SettingsViewModel,
- selectedCombinedProfileId: Long?,
- onSelectedCombinedProfileIdChange: (Long?) -> Unit,
- onPendingSyncProviderIdChange: (Long?) -> Unit,
- onCustomSyncSelectionsChange: (Set<ProviderSyncSelection>) -> Unit,
- onShowProviderSyncDialogChange: (Boolean) -> Unit,
- onShowCreateCombinedDialogChange: (Boolean) -> Unit,
- onShowRenameCombinedDialogChange: (Boolean) -> Unit,
- onShowAddCombinedMemberDialogChange: (Boolean) -> Unit
+ providerState: SettingsProviderSectionState
) {
if (uiState.providers.isEmpty()) {
item {
@@ -100,18 +93,16 @@ internal fun LazyListScope.providerSection(
onRetryWarningAction = { action -> viewModel.retryWarningAction(selectedProvider.id, action) },
onConnect = { viewModel.setActiveProvider(selectedProvider.id) },
onRefresh = {
- onPendingSyncProviderIdChange(selectedProvider.id)
- onCustomSyncSelectionsChange(
- buildSet {
- add(ProviderSyncSelection.TV)
- add(ProviderSyncSelection.MOVIES)
- add(ProviderSyncSelection.EPG)
- if (selectedProvider.type == ProviderType.XTREAM_CODES) {
- add(ProviderSyncSelection.SERIES)
- }
+ providerState.pendingSyncProviderId = selectedProvider.id
+ providerState.customSyncSelections = buildSet {
+ add(ProviderSyncSelection.TV)
+ add(ProviderSyncSelection.MOVIES)
+ add(ProviderSyncSelection.EPG)
+ if (selectedProvider.type == ProviderType.XTREAM_CODES) {
+ add(ProviderSyncSelection.SERIES)
}
- )
- onShowProviderSyncDialogChange(true)
+ }
+ providerState.showProviderSyncDialog = true
},
onDelete = { viewModel.deleteProvider(selectedProvider.id) },
onEdit = { onEditProvider(selectedProvider) },
@@ -128,24 +119,24 @@ internal fun LazyListScope.providerSection(
CombinedM3uProfilesCard(
profiles = uiState.combinedProfiles,
availableProviders = uiState.availableM3uProviders,
- selectedProfileId = selectedCombinedProfileId,
+ selectedProfileId = providerState.selectedCombinedProfileId,
activeLiveSource = uiState.activeLiveSource,
- onSelectProfile = onSelectedCombinedProfileIdChange,
- onCreateProfile = { onShowCreateCombinedDialogChange(true) },
+ onSelectProfile = { providerState.selectedCombinedProfileId = it },
+ onCreateProfile = { providerState.showCreateCombinedDialog = true },
onActivateProfile = { profileId -> viewModel.setActiveCombinedProfile(profileId) },
onDeleteProfile = { profileId ->
- if (selectedCombinedProfileId == profileId) {
- onSelectedCombinedProfileIdChange(null)
+ if (providerState.selectedCombinedProfileId == profileId) {
+ providerState.selectedCombinedProfileId = null
}
viewModel.deleteCombinedProfile(profileId)
},
onRenameProfile = { profileId ->
- onSelectedCombinedProfileIdChange(profileId)
- onShowRenameCombinedDialogChange(true)
+ providerState.selectedCombinedProfileId = profileId
+ providerState.showRenameCombinedDialog = true
},
onAddProvider = { profileId ->
- onSelectedCombinedProfileIdChange(profileId)
- onShowAddCombinedMemberDialogChange(true)
+ providerState.selectedCombinedProfileId = profileId
+ providerState.showAddCombinedMemberDialog = true
},
onRemoveProvider = { profileId, providerId ->
viewModel.removeProviderFromCombinedProfile(profileId, providerId)
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderSyncDialogs.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderSyncDialogs.kt
new file mode 100644
index 00000000..433a63aa
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderSyncDialogs.kt
@@ -0,0 +1,151 @@
+package com.streamvault.app.ui.screens.settings
+
+import androidx.compose.foundation.clickable
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.material3.Checkbox
+import androidx.compose.material3.OutlinedButton
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.unit.dp
+import androidx.tv.material3.MaterialTheme
+import androidx.tv.material3.Text
+import com.streamvault.app.R
+import com.streamvault.app.ui.components.dialogs.PremiumDialog
+import com.streamvault.app.ui.components.dialogs.PremiumDialogFooterButton
+import com.streamvault.app.ui.interaction.TvButton
+import com.streamvault.app.ui.theme.OnBackground
+import com.streamvault.app.ui.theme.OnSurface
+import com.streamvault.domain.model.Provider
+import com.streamvault.domain.model.ProviderType
+
+private fun availableSyncSelections(provider: Provider): List<ProviderSyncSelection> = buildList {
+ add(ProviderSyncSelection.TV)
+ add(ProviderSyncSelection.MOVIES)
+ if (provider.type == ProviderType.XTREAM_CODES) {
+ add(ProviderSyncSelection.SERIES)
+ }
+ add(ProviderSyncSelection.EPG)
+}
+
+@Composable
+internal fun ProviderSyncOptionsDialog(
+ provider: Provider,
+ onDismiss: () -> Unit,
+ onSelect: (ProviderSyncSelection?) -> Unit
+) {
+ PremiumDialog(
+ onDismissRequest = onDismiss,
+ title = stringResource(R.string.settings_sync_dialog_title, provider.name),
+ content = {
+ Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
+ Text(
+ text = stringResource(R.string.settings_sync_dialog_subtitle),
+ style = MaterialTheme.typography.bodyMedium,
+ color = OnSurface
+ )
+ SyncOptionButton(stringResource(R.string.settings_sync_option_fast)) {
+ onSelect(ProviderSyncSelection.FAST)
+ }
+ availableSyncSelections(provider).forEach { option ->
+ SyncOptionButton(text = syncSelectionLabel(option)) {
+ onSelect(option)
+ }
+ }
+ OutlinedButton(
+ onClick = { onSelect(null) },
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ Text(stringResource(R.string.settings_sync_option_custom))
+ }
+ }
+ }
+ )
+}
+
+@Composable
+internal fun ProviderCustomSyncDialog(
+ provider: Provider,
+ selected: Set<ProviderSyncSelection>,
+ onToggle: (ProviderSyncSelection) -> Unit,
+ onDismiss: () -> Unit,
+ onConfirm: () -> Unit
+) {
+ PremiumDialog(
+ onDismissRequest = onDismiss,
+ title = stringResource(R.string.settings_sync_custom_title, provider.name),
+ content = {
+ Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
+ Text(
+ text = stringResource(R.string.settings_sync_custom_subtitle),
+ style = MaterialTheme.typography.bodyMedium,
+ color = OnSurface
+ )
+ availableSyncSelections(provider).forEach { option ->
+ Row(
+ modifier = Modifier
+ .fillMaxWidth()
+ .clickable { onToggle(option) }
+ .padding(vertical = 8.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ horizontalArrangement = Arrangement.spacedBy(12.dp)
+ ) {
+ Checkbox(
+ checked = option in selected,
+ onCheckedChange = { onToggle(option) }
+ )
+ Text(
+ text = syncSelectionLabel(option),
+ style = MaterialTheme.typography.bodyLarge,
+ color = OnBackground
+ )
+ }
+ }
+ }
+ },
+ footer = {
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.spacedBy(12.dp, Alignment.End)
+ ) {
+ PremiumDialogFooterButton(
+ label = stringResource(R.string.settings_cancel),
+ onClick = onDismiss
+ )
+ PremiumDialogFooterButton(
+ label = stringResource(R.string.settings_sync_btn),
+ onClick = onConfirm,
+ enabled = selected.isNotEmpty()
+ )
+ }
+ }
+ )
+}
+
+@Composable
+private fun SyncOptionButton(
+ text: String,
+ onClick: () -> Unit
+) {
+ TvButton(
+ onClick = onClick,
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ Text(text)
+ }
+}
+
+@Composable
+private fun syncSelectionLabel(selection: ProviderSyncSelection): String = when (selection) {
+ ProviderSyncSelection.ALL -> stringResource(R.string.settings_sync_option_all)
+ ProviderSyncSelection.FAST -> stringResource(R.string.settings_sync_option_fast)
+ ProviderSyncSelection.TV -> stringResource(R.string.settings_sync_option_tv)
+ ProviderSyncSelection.MOVIES -> stringResource(R.string.settings_sync_option_movies)
+ ProviderSyncSelection.SERIES -> stringResource(R.string.settings_sync_option_series)
+ ProviderSyncSelection.EPG -> stringResource(R.string.settings_sync_option_epg)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderUiComponents.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderUiComponents.kt
new file mode 100644
index 00000000..78ab71a9
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderUiComponents.kt
@@ -0,0 +1,155 @@
+package com.streamvault.app.ui.screens.settings
+
+import androidx.compose.foundation.background
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.remember
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.unit.dp
+import androidx.tv.material3.Border
+import androidx.tv.material3.ClickableSurfaceDefaults
+import androidx.tv.material3.MaterialTheme
+import androidx.tv.material3.Surface
+import androidx.tv.material3.SurfaceDefaults
+import androidx.tv.material3.Text
+import com.streamvault.app.R
+import com.streamvault.app.ui.interaction.TvClickableSurface
+import com.streamvault.app.ui.interaction.mouseClickable
+import com.streamvault.app.ui.theme.ErrorColor
+import com.streamvault.app.ui.theme.OnBackground
+import com.streamvault.app.ui.theme.OnSurfaceDim
+import com.streamvault.app.ui.theme.Primary
+import com.streamvault.app.ui.theme.Secondary
+import com.streamvault.app.ui.theme.SurfaceElevated
+import com.streamvault.domain.model.Provider
+import com.streamvault.domain.model.ProviderStatus
+import androidx.compose.foundation.BorderStroke
+import androidx.compose.ui.focus.FocusRequester
+import androidx.compose.ui.focus.focusRequester
+
+@Composable
+internal fun ProviderSelectorTab(
+ provider: Provider,
+ isSelected: Boolean,
+ isActive: Boolean,
+ onClick: () -> Unit
+) {
+ val focusRequester = remember { FocusRequester() }
+ TvClickableSurface(
+ onClick = onClick,
+ modifier = Modifier
+ .focusRequester(focusRequester)
+ .mouseClickable(
+ focusRequester = focusRequester,
+ onClick = onClick
+ ),
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(999.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = if (isSelected) Primary.copy(alpha = 0.18f) else SurfaceElevated,
+ focusedContainerColor = Primary.copy(alpha = 0.34f)
+ ),
+ border = ClickableSurfaceDefaults.border(
+ border = Border(
+ border = BorderStroke(
+ width = 1.dp,
+ color = if (isSelected) Primary.copy(alpha = 0.45f) else Color.White.copy(alpha = 0.08f)
+ )
+ ),
+ focusedBorder = Border(
+ border = BorderStroke(
+ width = 2.dp,
+ color = Primary
+ )
+ )
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
+ ) {
+ Row(
+ modifier = Modifier.padding(horizontal = 16.dp, vertical = 10.dp),
+ horizontalArrangement = Arrangement.spacedBy(10.dp),
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Column(
+ verticalArrangement = Arrangement.spacedBy(2.dp)
+ ) {
+ Text(
+ text = provider.name,
+ style = MaterialTheme.typography.labelLarge,
+ color = OnBackground,
+ fontWeight = FontWeight.Bold,
+ maxLines = 1
+ )
+ Text(
+ text = provider.type.name,
+ style = MaterialTheme.typography.labelSmall,
+ color = OnSurfaceDim
+ )
+ }
+ if (isActive) {
+ Text(
+ text = stringResource(R.string.settings_active),
+ style = MaterialTheme.typography.labelSmall,
+ color = Primary,
+ fontWeight = FontWeight.Bold
+ )
+ }
+ }
+ }
+}
+
+@Composable
+internal fun ProviderCompactStat(
+ title: String,
+ count: Int
+) {
+ Surface(
+ shape = RoundedCornerShape(10.dp),
+ colors = SurfaceDefaults.colors(containerColor = Color.White.copy(alpha = 0.06f))
+ ) {
+ Column(
+ modifier = Modifier.padding(horizontal = 10.dp, vertical = 8.dp),
+ verticalArrangement = Arrangement.spacedBy(2.dp)
+ ) {
+ Text(
+ text = title,
+ style = MaterialTheme.typography.labelSmall,
+ color = OnSurfaceDim
+ )
+ Text(
+ text = count.toString(),
+ style = MaterialTheme.typography.labelMedium,
+ color = OnBackground
+ )
+ }
+ }
+}
+
+@Composable
+internal fun ProviderStatusBadge(status: ProviderStatus) {
+ val (label, color) = when (status) {
+ ProviderStatus.ACTIVE -> stringResource(R.string.settings_status_active) to Primary
+ ProviderStatus.PARTIAL -> stringResource(R.string.settings_status_partial) to Secondary
+ ProviderStatus.ERROR -> stringResource(R.string.settings_status_error) to ErrorColor
+ ProviderStatus.EXPIRED -> stringResource(R.string.settings_status_expired) to ErrorColor
+ ProviderStatus.DISABLED -> stringResource(R.string.settings_status_disabled) to OnSurfaceDim
+ ProviderStatus.UNKNOWN -> stringResource(R.string.settings_status_unknown) to OnSurfaceDim
+ }
+
+ Text(
+ text = label,
+ style = MaterialTheme.typography.labelSmall,
+ color = color,
+ fontWeight = FontWeight.Bold,
+ modifier = Modifier
+ .background(color.copy(alpha = 0.16f), RoundedCornerShape(4.dp))
+ .padding(horizontal = 8.dp, vertical = 4.dp)
+ )
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingBrowserDetailSections.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingBrowserDetailSections.kt
new file mode 100644
index 00000000..cbc264c0
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingBrowserDetailSections.kt
@@ -0,0 +1,121 @@
+package com.streamvault.app.ui.screens.settings
+
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.ExperimentalLayoutApi
+import androidx.compose.foundation.layout.FlowRow
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.unit.dp
+import com.streamvault.app.R
+import com.streamvault.app.ui.theme.ErrorColor
+import com.streamvault.app.ui.theme.OnBackground
+import com.streamvault.app.ui.theme.Primary
+import com.streamvault.app.ui.theme.Secondary
+import com.streamvault.domain.model.RecordingItem
+import com.streamvault.domain.model.RecordingStatus
+
+@Composable
+internal fun RecordingDetailMetricsRow(
+ item: RecordingItem,
+ modifier: Modifier = Modifier
+) {
+ Row(
+ modifier = modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.spacedBy(10.dp)
+ ) {
+ RecordingMetricCard(
+ modifier = Modifier.weight(1f),
+ label = stringResource(R.string.settings_recording_source_label),
+ value = formatRecordingSourceType(item.sourceType)
+ )
+ RecordingMetricCard(
+ modifier = Modifier.weight(1f),
+ label = stringResource(R.string.settings_recording_bytes_label),
+ value = formatBytes(item.bytesWritten)
+ )
+ RecordingMetricCard(
+ modifier = Modifier.weight(1f),
+ label = stringResource(R.string.settings_recording_speed_label),
+ value = if (item.averageThroughputBytesPerSecond > 0L) {
+ "${formatBytes(item.averageThroughputBytesPerSecond)}/s"
+ } else {
+ "N/A"
+ }
+ )
+ }
+}
+
+@OptIn(ExperimentalLayoutApi::class)
+@Composable
+internal fun RecordingDetailActions(
+ item: RecordingItem,
+ modifier: Modifier = Modifier,
+ onPlay: () -> Unit,
+ onStop: () -> Unit,
+ onCancel: () -> Unit,
+ onSkipOccurrence: () -> Unit,
+ onDelete: () -> Unit,
+ onRetry: () -> Unit,
+ onToggleSchedule: (Boolean) -> Unit
+) {
+ FlowRow(
+ horizontalArrangement = Arrangement.spacedBy(8.dp),
+ verticalArrangement = Arrangement.spacedBy(8.dp),
+ modifier = modifier.fillMaxWidth(),
+ maxItemsInEachRow = 4
+ ) {
+ if (item.status == RecordingStatus.COMPLETED && (!item.outputUri.isNullOrBlank() || !item.outputPath.isNullOrBlank())) {
+ CompactRecordingActionChip(
+ label = "Play",
+ accent = Primary,
+ onClick = onPlay
+ )
+ }
+ if (item.status == RecordingStatus.RECORDING) {
+ CompactRecordingActionChip(
+ label = stringResource(R.string.settings_recording_stop),
+ accent = ErrorColor,
+ onClick = onStop
+ )
+ }
+ if (item.status == RecordingStatus.SCHEDULED) {
+ CompactRecordingActionChip(
+ label = stringResource(
+ if (item.scheduleEnabled) R.string.settings_recording_disable
+ else R.string.settings_recording_enable
+ ),
+ accent = Secondary,
+ onClick = { onToggleSchedule(!item.scheduleEnabled) }
+ )
+ if (item.recurringRuleId != null) {
+ CompactRecordingActionChip(
+ label = stringResource(R.string.settings_recording_skip),
+ accent = OnBackground,
+ onClick = onSkipOccurrence
+ )
+ }
+ CompactRecordingActionChip(
+ label = stringResource(R.string.settings_recording_cancel),
+ accent = OnBackground,
+ onClick = onCancel
+ )
+ }
+ if (item.status == RecordingStatus.COMPLETED || item.status == RecordingStatus.FAILED || item.status == RecordingStatus.CANCELLED) {
+ if (item.status == RecordingStatus.FAILED) {
+ CompactRecordingActionChip(
+ label = stringResource(R.string.settings_recording_retry),
+ accent = Primary,
+ onClick = onRetry
+ )
+ }
+ CompactRecordingActionChip(
+ label = stringResource(R.string.settings_recording_delete),
+ accent = OnBackground,
+ onClick = onDelete
+ )
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingBrowserDialog.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingBrowserDialog.kt
new file mode 100644
index 00000000..a97a7672
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingBrowserDialog.kt
@@ -0,0 +1,442 @@
+package com.streamvault.app.ui.screens.settings
+
+import androidx.compose.foundation.background
+import androidx.compose.foundation.BorderStroke
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.PaddingValues
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxHeight
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.lazy.LazyColumn
+import androidx.compose.foundation.lazy.items
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.focus.onFocusChanged
+import androidx.compose.ui.text.style.TextOverflow
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.window.Dialog
+import androidx.compose.ui.window.DialogProperties
+import androidx.tv.material3.MaterialTheme
+import androidx.tv.material3.Surface
+import androidx.tv.material3.Border
+import androidx.tv.material3.ClickableSurfaceDefaults
+import androidx.tv.material3.SurfaceDefaults
+import androidx.tv.material3.Text
+import com.streamvault.app.R
+import com.streamvault.app.ui.components.TvEmptyState
+import com.streamvault.app.ui.theme.ErrorColor
+import com.streamvault.app.ui.theme.OnBackground
+import com.streamvault.app.ui.design.FocusSpec
+import com.streamvault.app.ui.interaction.TvClickableSurface
+import com.streamvault.app.ui.theme.OnSurface
+import com.streamvault.app.ui.theme.OnSurfaceDim
+import com.streamvault.app.ui.theme.Primary
+import com.streamvault.app.ui.theme.Secondary
+import com.streamvault.app.ui.theme.SurfaceElevated
+import com.streamvault.app.ui.time.LocalAppTimeFormat
+import com.streamvault.app.ui.time.createDateTimeFormat
+import com.streamvault.app.ui.theme.SurfaceHighlight
+import com.streamvault.domain.model.RecordingFailureCategory
+import com.streamvault.domain.model.RecordingItem
+import com.streamvault.domain.model.RecordingRecurrence
+import com.streamvault.domain.model.RecordingStatus
+import androidx.compose.foundation.border
+@Composable
+internal fun RecordingBrowserDialog(
+ recordingItems: List<RecordingItem>,
+ selectedRecordingId: String?,
+ onSelectedRecordingChange: (String) -> Unit,
+ onDismiss: () -> Unit,
+ onPlay: (RecordingItem) -> Unit,
+ onStop: (RecordingItem) -> Unit,
+ onCancel: (RecordingItem) -> Unit,
+ onSkipOccurrence: (RecordingItem) -> Unit,
+ onDelete: (RecordingItem) -> Unit,
+ onRetry: (RecordingItem) -> Unit,
+ onToggleSchedule: (RecordingItem, Boolean) -> Unit
+) {
+ Dialog(
+ onDismissRequest = onDismiss,
+ properties = DialogProperties(
+ dismissOnBackPress = true,
+ dismissOnClickOutside = false,
+ usePlatformDefaultWidth = false
+ )
+ ) {
+ Box(
+ modifier = Modifier
+ .fillMaxSize()
+ .background(Color.Black.copy(alpha = 0.68f)),
+ contentAlignment = Alignment.Center
+ ) {
+ Surface(
+ modifier = Modifier
+ .fillMaxWidth(0.93f)
+ .fillMaxHeight(0.9f),
+ colors = SurfaceDefaults.colors(containerColor = SurfaceElevated),
+ shape = RoundedCornerShape(22.dp)
+ ) {
+ Column(
+ modifier = Modifier
+ .fillMaxSize()
+ .padding(20.dp),
+ verticalArrangement = Arrangement.spacedBy(16.dp)
+ ) {
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Column(verticalArrangement = Arrangement.spacedBy(4.dp)) {
+ Text(
+ text = stringResource(R.string.settings_recording_title),
+ style = MaterialTheme.typography.headlineSmall,
+ color = OnBackground
+ )
+ Text(
+ text = if (recordingItems.isNotEmpty()) {
+ stringResource(R.string.settings_recording_item_count, recordingItems.size)
+ } else {
+ stringResource(R.string.settings_recording_empty_title)
+ },
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim
+ )
+ }
+ CompactRecordingActionChip(
+ label = stringResource(R.string.settings_cancel),
+ accent = OnBackground,
+ onClick = onDismiss
+ )
+ }
+
+ if (recordingItems.isEmpty()) {
+ Box(
+ modifier = Modifier.fillMaxSize(),
+ contentAlignment = Alignment.Center
+ ) {
+ TvEmptyState(
+ title = stringResource(R.string.settings_recording_empty_title),
+ subtitle = stringResource(R.string.settings_recording_empty_subtitle)
+ )
+ }
+ } else {
+ RecordingBrowserPanel(
+ recordingItems = recordingItems,
+ selectedRecordingId = selectedRecordingId,
+ onSelectedRecordingChange = onSelectedRecordingChange,
+ onPlay = onPlay,
+ onStop = onStop,
+ onCancel = onCancel,
+ onSkipOccurrence = onSkipOccurrence,
+ onDelete = onDelete,
+ onRetry = onRetry,
+ onToggleSchedule = onToggleSchedule
+ )
+ }
+ }
+ }
+ }
+ }
+}
+
+@Composable
+private fun RecordingBrowserPanel(
+ recordingItems: List<RecordingItem>,
+ selectedRecordingId: String?,
+ onSelectedRecordingChange: (String) -> Unit,
+ onPlay: (RecordingItem) -> Unit,
+ onStop: (RecordingItem) -> Unit,
+ onCancel: (RecordingItem) -> Unit,
+ onSkipOccurrence: (RecordingItem) -> Unit,
+ onDelete: (RecordingItem) -> Unit,
+ onRetry: (RecordingItem) -> Unit,
+ onToggleSchedule: (RecordingItem, Boolean) -> Unit
+) {
+ val selectedItem = recordingItems.firstOrNull { it.id == selectedRecordingId } ?: recordingItems.first()
+ var searchQuery by remember { mutableStateOf("") }
+ var statusFilter by remember { mutableStateOf<RecordingStatus?>(null) }
+ val filteredItems = remember(recordingItems, searchQuery, statusFilter) {
+ recordingItems.filter { item ->
+ val matchesSearch = searchQuery.isBlank() ||
+ item.channelName.contains(searchQuery, ignoreCase = true) ||
+ item.programTitle?.contains(searchQuery, ignoreCase = true) == true
+ val matchesStatus = statusFilter == null || item.status == statusFilter
+ matchesSearch && matchesStatus
+ }
+ }
+
+ Row(
+ modifier = Modifier.fillMaxSize(),
+ horizontalArrangement = Arrangement.spacedBy(16.dp),
+ verticalAlignment = Alignment.Top
+ ) {
+ Surface(
+ modifier = Modifier
+ .width(380.dp)
+ .fillMaxHeight(),
+ colors = SurfaceDefaults.colors(containerColor = SurfaceElevated),
+ shape = RoundedCornerShape(16.dp)
+ ) {
+ Column(
+ modifier = Modifier
+ .fillMaxSize()
+ .padding(14.dp),
+ verticalArrangement = Arrangement.spacedBy(8.dp)
+ ) {
+ RecordingBrowserSidebarControls(
+ filteredCount = filteredItems.size,
+ totalCount = recordingItems.size,
+ searchQuery = searchQuery,
+ onSearchQueryChange = { searchQuery = it },
+ statusFilter = statusFilter,
+ onStatusFilterChange = { statusFilter = it }
+ )
+ LazyColumn(
+ modifier = Modifier.fillMaxSize(),
+ verticalArrangement = Arrangement.spacedBy(8.dp),
+ contentPadding = PaddingValues(bottom = 4.dp)
+ ) {
+ items(filteredItems, key = { item -> item.id }) { item ->
+ RecordingPickerRow(
+ item = item,
+ selected = item.id == selectedItem.id,
+ onSelected = { onSelectedRecordingChange(item.id) }
+ )
+ }
+ }
+ }
+ }
+
+ RecordingDetailPanel(
+ item = selectedItem,
+ modifier = Modifier
+ .weight(1f)
+ .fillMaxHeight(),
+ onPlay = { onPlay(selectedItem) },
+ onStop = { onStop(selectedItem) },
+ onCancel = { onCancel(selectedItem) },
+ onSkipOccurrence = { onSkipOccurrence(selectedItem) },
+ onDelete = { onDelete(selectedItem) },
+ onRetry = { onRetry(selectedItem) },
+ onToggleSchedule = { enabled -> onToggleSchedule(selectedItem, enabled) }
+ )
+ }
+}
+
+@Composable
+private fun RecordingPickerRow(
+ item: RecordingItem,
+ selected: Boolean,
+ onSelected: () -> Unit
+) {
+ val accent = recordingStatusAccent(item.status)
+ TvClickableSurface(
+ onClick = onSelected,
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(12.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = if (selected) accent.copy(alpha = 0.14f) else Color.Transparent,
+ contentColor = OnBackground,
+ focusedContainerColor = SurfaceHighlight.copy(alpha = 0.48f),
+ focusedContentColor = OnBackground
+ ),
+ border = ClickableSurfaceDefaults.border(
+ border = Border(
+ border = BorderStroke(
+ 1.dp,
+ if (selected) accent.copy(alpha = 0.55f) else Color.White.copy(alpha = 0.08f)
+ ),
+ shape = RoundedCornerShape(12.dp)
+ ),
+ focusedBorder = Border(
+ border = BorderStroke(FocusSpec.BorderWidth, Color.White),
+ shape = RoundedCornerShape(12.dp)
+ )
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
+ modifier = Modifier
+ .fillMaxWidth()
+ .onFocusChanged { focusState ->
+ if (focusState.isFocused) onSelected()
+ }
+ ) {
+ Row(
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(horizontal = 12.dp, vertical = 10.dp),
+ horizontalArrangement = Arrangement.spacedBy(10.dp),
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Box(
+ modifier = Modifier
+ .size(width = 5.dp, height = 36.dp)
+ .background(accent.copy(alpha = 0.92f), RoundedCornerShape(999.dp))
+ )
+ Column(
+ modifier = Modifier.weight(1f),
+ verticalArrangement = Arrangement.spacedBy(3.dp)
+ ) {
+ Text(
+ text = recordingDisplayTitle(item),
+ style = MaterialTheme.typography.bodyMedium,
+ color = OnBackground,
+ maxLines = 1,
+ overflow = TextOverflow.Ellipsis
+ )
+ Text(
+ text = recordingListSecondaryLine(item),
+ style = MaterialTheme.typography.labelSmall,
+ color = OnSurfaceDim,
+ maxLines = 1,
+ overflow = TextOverflow.Ellipsis
+ )
+ }
+ Text(
+ text = recordingStatusLabel(item.status),
+ style = MaterialTheme.typography.labelSmall,
+ color = accent,
+ maxLines = 1
+ )
+ }
+ }
+}
+
+@Composable
+private fun RecordingDetailPanel(
+ item: RecordingItem,
+ modifier: Modifier = Modifier,
+ onPlay: () -> Unit,
+ onStop: () -> Unit,
+ onCancel: () -> Unit,
+ onSkipOccurrence: () -> Unit,
+ onDelete: () -> Unit,
+ onRetry: () -> Unit,
+ onToggleSchedule: (Boolean) -> Unit
+) {
+ val accent = recordingStatusAccent(item.status)
+ val appTimeFormat = LocalAppTimeFormat.current
+ val dateTimeFormat = remember(appTimeFormat) { appTimeFormat.createDateTimeFormat() }
+ Surface(
+ modifier = modifier,
+ colors = SurfaceDefaults.colors(containerColor = SurfaceElevated),
+ shape = RoundedCornerShape(16.dp)
+ ) {
+ Column(
+ modifier = Modifier
+ .fillMaxSize()
+ .padding(20.dp),
+ verticalArrangement = Arrangement.spacedBy(16.dp)
+ ) {
+ Column(
+ modifier = Modifier.fillMaxWidth(),
+ verticalArrangement = Arrangement.spacedBy(10.dp)
+ ) {
+ Text(
+ text = recordingDisplayTitle(item),
+ style = MaterialTheme.typography.titleLarge,
+ color = OnBackground,
+ maxLines = 2,
+ overflow = TextOverflow.Ellipsis
+ )
+ recordingDisplaySubtitle(item)?.let { subtitle ->
+ Text(
+ text = subtitle,
+ style = MaterialTheme.typography.bodyMedium,
+ color = OnSurfaceDim,
+ maxLines = 1,
+ overflow = TextOverflow.Ellipsis
+ )
+ }
+ Row(
+ horizontalArrangement = Arrangement.spacedBy(8.dp),
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ StatusTonePill(
+ label = recordingStatusLabel(item.status),
+ accent = accent
+ )
+ if (item.recurrence != RecordingRecurrence.NONE) {
+ StatusTonePill(
+ label = when (item.recurrence) {
+ RecordingRecurrence.DAILY -> stringResource(R.string.settings_recording_recurrence_daily)
+ RecordingRecurrence.WEEKLY -> stringResource(R.string.settings_recording_recurrence_weekly)
+ RecordingRecurrence.NONE -> stringResource(R.string.settings_recording_recurrence_none)
+ },
+ accent = Secondary
+ )
+ }
+ }
+ Text(
+ text = stringResource(
+ R.string.settings_recording_time_window,
+ formatTimestamp(item.scheduledStartMs, dateTimeFormat),
+ formatTimestamp(item.scheduledEndMs, dateTimeFormat)
+ ),
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurface
+ )
+ }
+
+ RecordingDetailMetricsRow(item = item)
+
+ if (item.retryCount > 0) {
+ RecordingMetaPill(
+ label = stringResource(R.string.settings_recording_retry_count_label),
+ value = item.retryCount.toString()
+ )
+ }
+
+ item.outputDisplayPath?.takeIf { output -> output.isNotBlank() }?.let { output ->
+ Text(
+ text = "${stringResource(R.string.settings_recording_output_label)}: ${summarizeRecordingOutputPath(output)}",
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim,
+ maxLines = 1,
+ overflow = TextOverflow.Ellipsis
+ )
+ }
+
+ item.failureReason?.takeIf { reason -> reason.isNotBlank() }?.let { reason ->
+ Text(
+ text = reason,
+ style = MaterialTheme.typography.bodySmall,
+ color = ErrorColor
+ )
+ }
+
+ if (item.failureCategory != RecordingFailureCategory.NONE) {
+ Text(
+ text = "${stringResource(R.string.settings_recording_failure_label)}: ${formatRecordingFailureCategory(item.failureCategory)}",
+ style = MaterialTheme.typography.bodySmall,
+ color = ErrorColor
+ )
+ }
+
+ RecordingDetailActions(
+ item = item,
+ onPlay = onPlay,
+ onStop = onStop,
+ onCancel = onCancel,
+ onSkipOccurrence = onSkipOccurrence,
+ onDelete = onDelete,
+ onRetry = onRetry,
+ onToggleSchedule = onToggleSchedule
+ )
+ }
+ }
+}
+
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingBrowserDisplay.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingBrowserDisplay.kt
new file mode 100644
index 00000000..25bc88c9
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingBrowserDisplay.kt
@@ -0,0 +1,111 @@
+package com.streamvault.app.ui.screens.settings
+
+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.padding
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.remember
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.text.style.TextOverflow
+import androidx.compose.ui.unit.dp
+import androidx.tv.material3.MaterialTheme
+import androidx.tv.material3.Text
+import com.streamvault.app.R
+import com.streamvault.app.ui.theme.ErrorColor
+import com.streamvault.app.ui.theme.OnBackground
+import com.streamvault.app.ui.theme.OnSurfaceDim
+import com.streamvault.app.ui.theme.Primary
+import com.streamvault.app.ui.theme.Secondary
+import com.streamvault.app.ui.time.LocalAppTimeFormat
+import com.streamvault.app.ui.time.createDateTimeFormat
+import com.streamvault.domain.model.RecordingItem
+import com.streamvault.domain.model.RecordingStatus
+
+@Composable
+internal fun RecordingMetricCard(
+ label: String,
+ value: String,
+ modifier: Modifier = Modifier
+) {
+ Column(
+ modifier = modifier
+ .background(Color.White.copy(alpha = 0.05f), RoundedCornerShape(12.dp))
+ .padding(horizontal = 12.dp, vertical = 10.dp),
+ verticalArrangement = Arrangement.spacedBy(4.dp)
+ ) {
+ Text(
+ text = label,
+ style = MaterialTheme.typography.labelSmall,
+ color = OnSurfaceDim
+ )
+ Text(
+ text = value,
+ style = MaterialTheme.typography.titleSmall,
+ color = OnBackground,
+ maxLines = 1,
+ overflow = TextOverflow.Ellipsis
+ )
+ }
+}
+
+@Composable
+internal fun StatusTonePill(
+ label: String,
+ accent: Color
+) {
+ Box(
+ modifier = Modifier
+ .background(accent.copy(alpha = 0.14f), RoundedCornerShape(999.dp))
+ .padding(horizontal = 10.dp, vertical = 6.dp)
+ ) {
+ Text(
+ text = label,
+ style = MaterialTheme.typography.labelSmall,
+ color = accent
+ )
+ }
+}
+
+internal fun recordingDisplayTitle(item: RecordingItem): String {
+ val title = item.programTitle?.trim().orEmpty()
+ return if (title.isNotBlank()) title else item.channelName
+}
+
+internal fun recordingDisplaySubtitle(item: RecordingItem): String? {
+ val title = item.programTitle?.trim().orEmpty()
+ return if (title.isNotBlank() && title != item.channelName) item.channelName else null
+}
+
+@Composable
+internal fun recordingListSecondaryLine(item: RecordingItem): String {
+ val subtitle = recordingDisplaySubtitle(item)
+ val appTimeFormat = LocalAppTimeFormat.current
+ val dateTimeFormat = remember(appTimeFormat) { appTimeFormat.createDateTimeFormat() }
+ return subtitle ?: stringResource(
+ R.string.settings_recording_time_window,
+ formatTimestamp(item.scheduledStartMs, dateTimeFormat),
+ formatTimestamp(item.scheduledEndMs, dateTimeFormat)
+ )
+}
+
+@Composable
+internal fun recordingStatusLabel(status: RecordingStatus): String = when (status) {
+ RecordingStatus.SCHEDULED -> stringResource(R.string.settings_recording_status_scheduled)
+ RecordingStatus.RECORDING -> stringResource(R.string.settings_recording_status_recording)
+ RecordingStatus.COMPLETED -> stringResource(R.string.settings_recording_status_completed)
+ RecordingStatus.FAILED -> stringResource(R.string.settings_recording_status_failed)
+ RecordingStatus.CANCELLED -> stringResource(R.string.settings_recording_status_cancelled)
+}
+
+internal fun recordingStatusAccent(status: RecordingStatus): Color = when (status) {
+ RecordingStatus.RECORDING -> Primary
+ RecordingStatus.SCHEDULED -> Secondary
+ RecordingStatus.COMPLETED -> Color(0xFF7BA7FF)
+ RecordingStatus.FAILED -> ErrorColor
+ RecordingStatus.CANCELLED -> OnSurfaceDim
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingBrowserSidebarControls.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingBrowserSidebarControls.kt
new file mode 100644
index 00000000..1e6eee25
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingBrowserSidebarControls.kt
@@ -0,0 +1,167 @@
+package com.streamvault.app.ui.screens.settings
+
+import androidx.compose.foundation.BorderStroke
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.ExperimentalLayoutApi
+import androidx.compose.foundation.layout.FlowRow
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.foundation.text.BasicTextField
+import androidx.compose.foundation.text.KeyboardActions
+import androidx.compose.foundation.text.KeyboardOptions
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.focus.FocusRequester
+import androidx.compose.ui.focus.focusRequester
+import androidx.compose.ui.focus.onFocusChanged
+import androidx.compose.ui.graphics.SolidColor
+import androidx.compose.ui.platform.LocalSoftwareKeyboardController
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.text.input.ImeAction
+import androidx.compose.ui.unit.dp
+import androidx.tv.material3.Border
+import androidx.tv.material3.ClickableSurfaceDefaults
+import androidx.tv.material3.MaterialTheme
+import androidx.tv.material3.Text
+import com.streamvault.app.R
+import com.streamvault.app.ui.interaction.TvClickableSurface
+import com.streamvault.app.ui.theme.FocusBorder
+import com.streamvault.app.ui.theme.OnBackground
+import com.streamvault.app.ui.theme.OnSurfaceDim
+import com.streamvault.app.ui.theme.Primary
+import com.streamvault.app.ui.theme.SurfaceElevated
+import com.streamvault.app.ui.theme.SurfaceHighlight
+import com.streamvault.domain.model.RecordingStatus
+
+@OptIn(ExperimentalLayoutApi::class)
+@Composable
+internal fun RecordingBrowserSidebarControls(
+ filteredCount: Int,
+ totalCount: Int,
+ searchQuery: String,
+ onSearchQueryChange: (String) -> Unit,
+ statusFilter: RecordingStatus?,
+ onStatusFilterChange: (RecordingStatus?) -> Unit
+) {
+ Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
+ Column(verticalArrangement = Arrangement.spacedBy(2.dp)) {
+ Text(
+ text = stringResource(R.string.settings_recording_title),
+ style = MaterialTheme.typography.titleSmall,
+ color = Primary
+ )
+ Text(
+ text = "$filteredCount of $totalCount items",
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim
+ )
+ }
+ FlowRow(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.spacedBy(6.dp),
+ verticalArrangement = Arrangement.spacedBy(6.dp)
+ ) {
+ CompactRecordingActionChip(
+ label = "All",
+ accent = if (statusFilter == null) Primary else OnSurfaceDim,
+ onClick = { onStatusFilterChange(null) }
+ )
+ RecordingStatus.entries.forEach { status ->
+ CompactRecordingActionChip(
+ label = recordingStatusLabel(status),
+ accent = if (statusFilter == status) recordingStatusAccent(status) else OnSurfaceDim,
+ onClick = {
+ onStatusFilterChange(if (statusFilter == status) null else status)
+ }
+ )
+ }
+ }
+ RecordingBrowserSearchField(
+ searchQuery = searchQuery,
+ onSearchQueryChange = onSearchQueryChange
+ )
+ }
+}
+
+@Composable
+private fun RecordingBrowserSearchField(
+ searchQuery: String,
+ onSearchQueryChange: (String) -> Unit
+) {
+ val isTelevisionDevice = com.streamvault.app.device.rememberIsTelevisionDevice()
+ val searchFocusRequester = remember { FocusRequester() }
+ val inputFocusRequester = remember { FocusRequester() }
+ val keyboardController = LocalSoftwareKeyboardController.current
+ var acceptsInput by remember(isTelevisionDevice) { mutableStateOf(!isTelevisionDevice) }
+
+ TvClickableSurface(
+ onClick = {
+ acceptsInput = true
+ inputFocusRequester.requestFocus()
+ keyboardController?.show()
+ },
+ modifier = Modifier
+ .fillMaxWidth()
+ .focusRequester(searchFocusRequester),
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = SurfaceElevated,
+ focusedContainerColor = SurfaceHighlight
+ ),
+ border = ClickableSurfaceDefaults.border(
+ border = Border(
+ border = BorderStroke(1.dp, OnSurfaceDim.copy(alpha = 0.3f)),
+ shape = RoundedCornerShape(8.dp)
+ ),
+ focusedBorder = Border(
+ border = BorderStroke(2.dp, FocusBorder),
+ shape = RoundedCornerShape(8.dp)
+ )
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
+ ) {
+ Box(
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(horizontal = 10.dp, vertical = 6.dp)
+ ) {
+ if (searchQuery.isEmpty()) {
+ Text(
+ text = "Search recordings...",
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim
+ )
+ }
+ BasicTextField(
+ value = searchQuery,
+ onValueChange = onSearchQueryChange,
+ textStyle = MaterialTheme.typography.bodySmall.copy(color = OnBackground),
+ singleLine = true,
+ cursorBrush = SolidColor(Primary),
+ readOnly = isTelevisionDevice && !acceptsInput,
+ keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search),
+ keyboardActions = KeyboardActions(onSearch = {
+ acceptsInput = false
+ keyboardController?.hide()
+ searchFocusRequester.requestFocus()
+ }),
+ modifier = Modifier
+ .fillMaxWidth()
+ .focusRequester(inputFocusRequester)
+ .onFocusChanged {
+ if (!it.isFocused && isTelevisionDevice) {
+ acceptsInput = false
+ keyboardController?.hide()
+ }
+ }
+ )
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingComponents.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingComponents.kt
index 9e66b94f..2a56e1a5 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingComponents.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingComponents.kt
@@ -41,6 +41,7 @@ import com.streamvault.app.ui.components.dialogs.PremiumDialog
import com.streamvault.app.ui.components.dialogs.PremiumDialogActionButton
import com.streamvault.app.ui.components.dialogs.PremiumDialogFooterButton
import com.streamvault.app.ui.design.FocusSpec
+import com.streamvault.app.ui.interaction.TvButton
import com.streamvault.app.ui.interaction.TvClickableSurface
import com.streamvault.app.ui.interaction.mouseClickable
import com.streamvault.app.ui.theme.*
@@ -57,1400 +58,87 @@ import com.streamvault.domain.model.RecordingStatus
import androidx.compose.foundation.layout.ExperimentalLayoutApi
@Composable
-internal fun InternetSpeedTestCard(
- valueLabel: String,
- summary: String,
- recommendationLabel: String,
- isRunning: Boolean,
- canApplyRecommendation: Boolean,
- onRunTest: () -> Unit,
- onApplyWifi: () -> Unit,
- onApplyEthernet: () -> Unit
-) {
- val focusRequester = remember { FocusRequester() }
- TvClickableSurface(
- onClick = onRunTest,
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(12.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = SurfaceElevated,
- focusedContainerColor = Primary.copy(alpha = 0.18f)
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
+internal fun RecordingMetaPill(label: String, value: String) {
+ Column(
modifier = Modifier
- .fillMaxWidth()
- .padding(top = 8.dp)
- .focusRequester(focusRequester)
- .mouseClickable(
- focusRequester = focusRequester,
- onClick = onRunTest
- )
+ .widthIn(min = 92.dp, max = 160.dp)
+ .background(Color.White.copy(alpha = 0.05f), RoundedCornerShape(10.dp))
+ .padding(horizontal = 7.dp, vertical = 5.dp)
) {
- Column(
- modifier = Modifier.padding(16.dp),
- verticalArrangement = Arrangement.spacedBy(12.dp)
- ) {
- Row(
- modifier = Modifier.fillMaxWidth(),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically
- ) {
- Column(verticalArrangement = Arrangement.spacedBy(4.dp)) {
- Text(
- text = stringResource(R.string.settings_speed_test_title),
- style = MaterialTheme.typography.bodyLarge,
- color = OnBackground
- )
- Text(
- text = valueLabel,
- style = MaterialTheme.typography.titleSmall,
- color = Primary,
- fontWeight = FontWeight.SemiBold
- )
- }
- if (isRunning) {
- CircularProgressIndicator(
- color = Primary,
- strokeWidth = 2.dp,
- modifier = Modifier.size(20.dp)
- )
- } else {
- Text(
- text = stringResource(R.string.settings_speed_test_run_action),
- style = MaterialTheme.typography.labelLarge,
- color = Primary
- )
- }
- }
-
- Text(
- text = summary,
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim
- )
-
- Text(
- text = stringResource(R.string.settings_speed_test_recommendation, recommendationLabel),
- style = MaterialTheme.typography.bodySmall,
- color = OnSurface
- )
-
- Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
- TvClickableSurface(
- onClick = onRunTest,
- enabled = !isRunning,
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Primary.copy(alpha = 0.18f),
- focusedContainerColor = Primary.copy(alpha = 0.32f)
- )
- ) {
- Text(
- text = stringResource(if (isRunning) R.string.settings_speed_test_running_action else R.string.settings_speed_test_run_action),
- style = MaterialTheme.typography.labelMedium,
- color = Primary,
- modifier = Modifier.padding(horizontal = 14.dp, vertical = 10.dp)
- )
- }
- TvClickableSurface(
- onClick = onApplyWifi,
- enabled = canApplyRecommendation && !isRunning,
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Secondary.copy(alpha = 0.16f),
- focusedContainerColor = Secondary.copy(alpha = 0.28f)
- )
- ) {
- Text(
- text = stringResource(R.string.settings_speed_test_apply_wifi),
- style = MaterialTheme.typography.labelMedium,
- color = Secondary,
- modifier = Modifier.padding(horizontal = 14.dp, vertical = 10.dp)
- )
- }
- TvClickableSurface(
- onClick = onApplyEthernet,
- enabled = canApplyRecommendation && !isRunning,
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Secondary.copy(alpha = 0.16f),
- focusedContainerColor = Secondary.copy(alpha = 0.28f)
- )
- ) {
- Text(
- text = stringResource(R.string.settings_speed_test_apply_ethernet),
- style = MaterialTheme.typography.labelMedium,
- color = Secondary,
- modifier = Modifier.padding(horizontal = 14.dp, vertical = 10.dp)
- )
- }
- }
- }
+ Text(text = label, style = MaterialTheme.typography.labelSmall, color = OnSurfaceDim)
+ Text(text = value, style = MaterialTheme.typography.labelMedium, color = OnBackground, maxLines = 1, overflow = TextOverflow.Ellipsis)
}
}
-@Composable
-internal fun BackupImportPreviewDialog(
- preview: com.streamvault.domain.manager.BackupPreview,
- plan: com.streamvault.domain.manager.BackupImportPlan,
- onDismiss: () -> Unit,
- onStrategySelected: (BackupConflictStrategy) -> Unit,
- onImportPreferencesChanged: (Boolean) -> Unit,
- onImportProvidersChanged: (Boolean) -> Unit,
- onImportSavedLibraryChanged: (Boolean) -> Unit,
- onImportPlaybackHistoryChanged: (Boolean) -> Unit,
- onImportMultiViewChanged: (Boolean) -> Unit,
- onImportRecordingSchedulesChanged: (Boolean) -> Unit,
- onConfirm: () -> Unit
-) {
- PremiumDialog(
- title = stringResource(R.string.settings_backup_preview_title),
- subtitle = stringResource(R.string.settings_backup_preview_subtitle, preview.version),
- onDismissRequest = onDismiss,
- widthFraction = 0.58f,
- content = {
- BackupPreviewRow(stringResource(R.string.settings_backup_section_preferences), preview.preferenceCount, 0)
- BackupPreviewRow(stringResource(R.string.settings_backup_section_providers), preview.providerCount, preview.providerConflicts)
- BackupPreviewRow(stringResource(R.string.settings_backup_section_saved), preview.favoriteCount + preview.groupCount + preview.protectedCategoryCount, preview.favoriteConflicts + preview.groupConflicts + preview.protectedCategoryConflicts)
- BackupPreviewRow(stringResource(R.string.settings_backup_section_history), preview.playbackHistoryCount, preview.historyConflicts)
- BackupPreviewRow(stringResource(R.string.settings_backup_section_multiview), preview.multiViewPresetCount, 0)
- BackupPreviewRow(stringResource(R.string.settings_backup_section_recordings), preview.scheduledRecordingCount, preview.recordingConflicts)
- Text(
- text = stringResource(R.string.settings_backup_conflict_strategy),
- style = MaterialTheme.typography.titleSmall,
- color = Primary
- )
- Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) {
- BackupStrategyChip(
- title = stringResource(R.string.settings_backup_keep_existing),
- selected = plan.conflictStrategy == BackupConflictStrategy.KEEP_EXISTING,
- onClick = { onStrategySelected(BackupConflictStrategy.KEEP_EXISTING) }
- )
- BackupStrategyChip(
- title = stringResource(R.string.settings_backup_replace_existing),
- selected = plan.conflictStrategy == BackupConflictStrategy.REPLACE_EXISTING,
- onClick = { onStrategySelected(BackupConflictStrategy.REPLACE_EXISTING) }
- )
- }
- Text(
- text = stringResource(R.string.settings_backup_import_sections),
- style = MaterialTheme.typography.titleSmall,
- color = Primary
- )
- BackupToggleRow(stringResource(R.string.settings_backup_section_preferences), plan.importPreferences, onImportPreferencesChanged)
- BackupToggleRow(stringResource(R.string.settings_backup_section_providers), plan.importProviders, onImportProvidersChanged)
- BackupToggleRow(stringResource(R.string.settings_backup_section_saved), plan.importSavedLibrary, onImportSavedLibraryChanged)
- BackupToggleRow(stringResource(R.string.settings_backup_section_history), plan.importPlaybackHistory, onImportPlaybackHistoryChanged)
- BackupToggleRow(stringResource(R.string.settings_backup_section_multiview), plan.importMultiViewPresets, onImportMultiViewChanged)
- BackupToggleRow(stringResource(R.string.settings_backup_section_recordings), plan.importRecordingSchedules, onImportRecordingSchedulesChanged)
- },
- footer = {
- PremiumDialogFooterButton(
- label = stringResource(R.string.settings_cancel),
- onClick = onDismiss
- )
- PremiumDialogFooterButton(
- label = stringResource(R.string.settings_backup_import_confirm),
- onClick = onConfirm,
- emphasized = true
- )
- }
- )
-}
-
-@Composable
-private fun BackupPreviewRow(
- title: String,
- itemCount: Int,
- conflictCount: Int
-) {
- Row(
- modifier = Modifier.fillMaxWidth(),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically
- ) {
- Column {
- Text(title, style = MaterialTheme.typography.bodyLarge, color = OnBackground)
- Text(
- text = if (conflictCount > 0) {
- stringResource(R.string.settings_backup_conflict_count, conflictCount)
- } else {
- stringResource(R.string.settings_backup_no_conflicts)
- },
- style = MaterialTheme.typography.bodySmall,
- color = if (conflictCount > 0) Secondary else OnSurfaceDim
- )
- }
- Text(
- text = stringResource(R.string.settings_backup_item_count, itemCount),
- style = MaterialTheme.typography.labelLarge,
- color = OnBackground
- )
- }
+internal fun summarizeRecordingOutputPath(path: String): String {
+ val trimmed = path.trim()
+ if (trimmed.isBlank()) return trimmed
+ val decoded = runCatching { android.net.Uri.decode(trimmed) }.getOrDefault(trimmed)
+ return decoded
+ .substringAfterLast('/')
+ .substringAfterLast('\\')
+ .ifBlank { decoded }
}
@Composable
-private fun BackupStrategyChip(
- title: String,
- selected: Boolean,
+internal fun RecordingActionButton(
+ label: String,
+ accent: Color,
+ modifier: Modifier = Modifier,
onClick: () -> Unit
) {
- TvClickableSurface(
+ TvButton(
onClick = onClick,
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(24.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = if (selected) Primary.copy(alpha = 0.2f) else SurfaceElevated,
- focusedContainerColor = Primary.copy(alpha = 0.35f)
- )
- ) {
- Text(
- text = title,
- style = MaterialTheme.typography.labelLarge,
- color = if (selected) Primary else OnBackground,
- modifier = Modifier.padding(horizontal = 16.dp, vertical = 10.dp)
- )
- }
-}
-
-@Composable
-private fun BackupToggleRow(
- label: String,
- checked: Boolean,
- onCheckedChange: (Boolean) -> Unit
-) {
- Row(
- modifier = Modifier.fillMaxWidth(),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically
- ) {
- Text(label, style = MaterialTheme.typography.bodyLarge, color = OnBackground)
- Switch(checked = checked, onCheckedChange = onCheckedChange)
- }
-}
-
-@OptIn(ExperimentalLayoutApi::class)
-@Composable
-internal fun RecordingInfoCard(
- treeLabel: String?,
- outputDirectory: String?,
- availableBytes: Long?,
- isWritable: Boolean,
- activeCount: Int,
- scheduledCount: Int,
- fileNamePattern: String,
- retentionDays: Int?,
- maxSimultaneousRecordings: Int,
- paddingBeforeMinutes: Int,
- paddingAfterMinutes: Int
-) {
- TvClickableSurface(
- onClick = { },
- modifier = Modifier.fillMaxWidth(),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = SurfaceElevated,
- focusedContainerColor = SurfaceElevated
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(16.dp)),
- border = ClickableSurfaceDefaults.border(
- focusedBorder = Border(
- border = BorderStroke(2.dp, FocusBorder),
- shape = RoundedCornerShape(16.dp)
- )
- )
- ) {
- Column(
- modifier = Modifier.padding(20.dp),
- verticalArrangement = Arrangement.spacedBy(16.dp)
- ) {
- Row(
- modifier = Modifier.fillMaxWidth(),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.Top
- ) {
- Column(
- modifier = Modifier.weight(1f),
- verticalArrangement = Arrangement.spacedBy(6.dp)
- ) {
- Text(
- text = stringResource(R.string.settings_recording_storage_title),
- style = MaterialTheme.typography.titleMedium,
- color = Primary
- )
- treeLabel?.takeIf { it.isNotBlank() }?.let {
- Text(
- text = it,
- style = MaterialTheme.typography.bodySmall,
- color = Secondary,
- maxLines = 1,
- overflow = TextOverflow.Ellipsis
- )
- }
- Text(
- text = outputDirectory ?: stringResource(R.string.settings_recording_storage_unknown),
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim,
- maxLines = 2,
- overflow = TextOverflow.Ellipsis
- )
- }
- StatusTonePill(
- label = if (isWritable) {
- stringResource(R.string.settings_recording_storage_ready)
- } else {
- stringResource(R.string.settings_recording_storage_unavailable)
- },
- accent = if (isWritable) OnSurface else ErrorColor
- )
- }
- Row(
- modifier = Modifier.fillMaxWidth(),
- horizontalArrangement = Arrangement.spacedBy(12.dp)
- ) {
- SettingsOverviewStat(
- label = stringResource(R.string.settings_recording_active_label),
- value = activeCount.toString(),
- modifier = Modifier.weight(1f)
- )
- SettingsOverviewStat(
- label = stringResource(R.string.settings_recording_scheduled_label),
- value = scheduledCount.toString(),
- modifier = Modifier.weight(1f)
- )
- SettingsOverviewStat(
- label = stringResource(R.string.settings_recording_space_label),
- value = availableBytes?.let(::formatBytes) ?: stringResource(R.string.settings_recording_storage_unknown),
- modifier = Modifier.weight(1f)
- )
- }
- FlowRow(
- horizontalArrangement = Arrangement.spacedBy(10.dp),
- verticalArrangement = Arrangement.spacedBy(10.dp)
- ) {
- RecordingMetaPill(
- label = stringResource(R.string.settings_recording_pattern_title),
- value = fileNamePattern
- )
- RecordingMetaPill(
- label = stringResource(R.string.settings_recording_retention_title),
- value = retentionDays?.let {
- stringResource(R.string.settings_recording_retention_days, it)
- } ?: stringResource(R.string.settings_recording_retention_keep_all)
- )
- RecordingMetaPill(
- label = stringResource(R.string.settings_recording_concurrency_title),
- value = maxSimultaneousRecordings.toString()
- )
- RecordingMetaPill(
- label = stringResource(R.string.settings_recording_padding_before),
- value = if (paddingBeforeMinutes > 0) {
- stringResource(R.string.settings_recording_padding_minutes, paddingBeforeMinutes)
- } else {
- stringResource(R.string.settings_recording_padding_none)
- }
- )
- RecordingMetaPill(
- label = stringResource(R.string.settings_recording_padding_after),
- value = if (paddingAfterMinutes > 0) {
- stringResource(R.string.settings_recording_padding_minutes, paddingAfterMinutes)
- } else {
- stringResource(R.string.settings_recording_padding_none)
- }
- )
- }
- }
- }
-}
-
-@Composable
-internal fun RecordingActionsCard(
- wifiOnlyRecording: Boolean,
- onWifiOnlyRecordingChange: (Boolean) -> Unit,
- onChooseFolder: () -> Unit,
- onUseAppStorage: () -> Unit,
- onChangePattern: () -> Unit,
- onChangeRetention: () -> Unit,
- onChangeConcurrency: () -> Unit,
- onChangePadding: () -> Unit,
- onOpenBrowser: () -> Unit,
- onRepairSchedule: () -> Unit
-) {
- Surface(
- modifier = Modifier.fillMaxWidth(),
- colors = SurfaceDefaults.colors(containerColor = SurfaceElevated),
- shape = RoundedCornerShape(16.dp)
- ) {
- Column(
- modifier = Modifier.padding(20.dp),
- verticalArrangement = Arrangement.spacedBy(10.dp)
- ) {
- Row(
- modifier = Modifier.fillMaxWidth(),
- horizontalArrangement = Arrangement.spacedBy(10.dp)
- ) {
- RecordingActionButton(
- label = stringResource(R.string.settings_recording_choose_folder),
- accent = OnBackground,
- modifier = Modifier.weight(1f),
- onClick = onChooseFolder
- )
- RecordingActionButton(
- label = stringResource(R.string.settings_recording_use_app_storage),
- accent = OnBackground,
- modifier = Modifier.weight(1f),
- onClick = onUseAppStorage
- )
- }
- Row(
- modifier = Modifier.fillMaxWidth(),
- horizontalArrangement = Arrangement.spacedBy(10.dp)
- ) {
- RecordingActionButton(
- label = stringResource(R.string.settings_recording_pattern_title),
- accent = OnBackground,
- modifier = Modifier.weight(1f),
- onClick = onChangePattern
- )
- RecordingActionButton(
- label = stringResource(R.string.settings_recording_retention_title),
- accent = OnBackground,
- modifier = Modifier.weight(1f),
- onClick = onChangeRetention
- )
- RecordingActionButton(
- label = stringResource(R.string.settings_recording_concurrency_title),
- accent = OnBackground,
- modifier = Modifier.weight(1f),
- onClick = onChangeConcurrency
- )
- }
- Row(
- modifier = Modifier.fillMaxWidth(),
- horizontalArrangement = Arrangement.spacedBy(10.dp)
- ) {
- RecordingActionButton(
- label = stringResource(R.string.settings_recording_open_browser),
- accent = OnBackground,
- modifier = Modifier.weight(1f),
- onClick = onOpenBrowser
- )
- RecordingActionButton(
- label = stringResource(R.string.settings_recording_reconcile),
- accent = OnBackground,
- modifier = Modifier.weight(1f),
- onClick = onRepairSchedule
- )
- RecordingActionButton(
- label = stringResource(R.string.settings_recording_padding_title),
- accent = OnBackground,
- modifier = Modifier.weight(1f),
- onClick = onChangePadding
- )
- }
- TvClickableSurface(
- onClick = { onWifiOnlyRecordingChange(!wifiOnlyRecording) },
- modifier = Modifier.fillMaxWidth(),
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(10.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Color.Transparent,
- focusedContainerColor = Primary.copy(alpha = 0.12f)
- ),
- border = ClickableSurfaceDefaults.border(
- focusedBorder = Border(
- border = BorderStroke(2.dp, Color.White),
- shape = RoundedCornerShape(10.dp)
- )
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
- ) {
- Row(
- modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 8.dp),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically
- ) {
- Text(
- text = stringResource(R.string.settings_recording_wifi_only),
- style = MaterialTheme.typography.bodyMedium,
- color = OnSurface
- )
- Switch(
- checked = wifiOnlyRecording,
- onCheckedChange = null,
- colors = SwitchDefaults.colors(
- checkedThumbColor = Primary,
- checkedTrackColor = Primary.copy(alpha = 0.3f),
- uncheckedThumbColor = OnSurfaceDim,
- uncheckedTrackColor = OnSurfaceDim.copy(alpha = 0.2f)
- )
- )
- }
- }
- }
- }
-}
-
-@OptIn(ExperimentalLayoutApi::class)
-@Composable
-internal fun RecordingBrowserDialog(
- recordingItems: List<RecordingItem>,
- selectedRecordingId: String?,
- onSelectedRecordingChange: (String) -> Unit,
- onDismiss: () -> Unit,
- onPlay: (RecordingItem) -> Unit,
- onStop: (RecordingItem) -> Unit,
- onCancel: (RecordingItem) -> Unit,
- onSkipOccurrence: (RecordingItem) -> Unit,
- onDelete: (RecordingItem) -> Unit,
- onRetry: (RecordingItem) -> Unit,
- onToggleSchedule: (RecordingItem, Boolean) -> Unit
-) {
- Dialog(
- onDismissRequest = onDismiss,
- properties = DialogProperties(
- dismissOnBackPress = true,
- dismissOnClickOutside = false,
- usePlatformDefaultWidth = false
- )
- ) {
- Box(
- modifier = Modifier
- .fillMaxSize()
- .background(Color.Black.copy(alpha = 0.68f)),
- contentAlignment = Alignment.Center
- ) {
- Surface(
- modifier = Modifier
- .fillMaxWidth(0.93f)
- .fillMaxHeight(0.9f),
- colors = SurfaceDefaults.colors(containerColor = SurfaceElevated),
- shape = RoundedCornerShape(22.dp)
- ) {
- Column(
- modifier = Modifier.fillMaxSize().padding(20.dp),
- verticalArrangement = Arrangement.spacedBy(16.dp)
- ) {
- Row(
- modifier = Modifier.fillMaxWidth(),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically
- ) {
- Column(verticalArrangement = Arrangement.spacedBy(4.dp)) {
- Text(
- text = stringResource(R.string.settings_recording_title),
- style = MaterialTheme.typography.headlineSmall,
- color = OnBackground
- )
- Text(
- text = if (recordingItems.isNotEmpty()) {
- stringResource(R.string.settings_recording_item_count, recordingItems.size)
- } else {
- stringResource(R.string.settings_recording_empty_title)
- },
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim
- )
- }
- CompactRecordingActionChip(
- label = stringResource(R.string.settings_cancel),
- accent = OnBackground,
- onClick = onDismiss
- )
- }
-
- if (recordingItems.isEmpty()) {
- Box(
- modifier = Modifier.fillMaxSize(),
- contentAlignment = Alignment.Center
- ) {
- TvEmptyState(
- title = stringResource(R.string.settings_recording_empty_title),
- subtitle = stringResource(R.string.settings_recording_empty_subtitle)
- )
- }
- } else {
- RecordingBrowserPanel(
- recordingItems = recordingItems,
- selectedRecordingId = selectedRecordingId,
- onSelectedRecordingChange = onSelectedRecordingChange,
- onPlay = onPlay,
- onStop = onStop,
- onCancel = onCancel,
- onSkipOccurrence = onSkipOccurrence,
- onDelete = onDelete,
- onRetry = onRetry,
- onToggleSchedule = onToggleSchedule
- )
- }
- }
- }
- }
- }
-}
-
-@OptIn(ExperimentalLayoutApi::class)
-@Composable
-private fun RecordingBrowserPanel(
- recordingItems: List<RecordingItem>,
- selectedRecordingId: String?,
- onSelectedRecordingChange: (String) -> Unit,
- onPlay: (RecordingItem) -> Unit,
- onStop: (RecordingItem) -> Unit,
- onCancel: (RecordingItem) -> Unit,
- onSkipOccurrence: (RecordingItem) -> Unit,
- onDelete: (RecordingItem) -> Unit,
- onRetry: (RecordingItem) -> Unit,
- onToggleSchedule: (RecordingItem, Boolean) -> Unit
-) {
- val selectedItem = recordingItems.firstOrNull { it.id == selectedRecordingId } ?: recordingItems.first()
- var searchQuery by remember { mutableStateOf("") }
- var statusFilter by remember { mutableStateOf<RecordingStatus?>(null) }
- val filteredItems = remember(recordingItems, searchQuery, statusFilter) {
- recordingItems.filter { item ->
- val matchesSearch = searchQuery.isBlank() ||
- item.channelName.contains(searchQuery, ignoreCase = true) ||
- item.programTitle?.contains(searchQuery, ignoreCase = true) == true
- val matchesStatus = statusFilter == null || item.status == statusFilter
- matchesSearch && matchesStatus
- }
- }
-
- Row(
- modifier = Modifier.fillMaxSize(),
- horizontalArrangement = Arrangement.spacedBy(16.dp),
- verticalAlignment = Alignment.Top
- ) {
- Surface(
- modifier = Modifier
- .width(380.dp)
- .fillMaxHeight(),
- colors = SurfaceDefaults.colors(containerColor = SurfaceElevated),
- shape = RoundedCornerShape(16.dp)
- ) {
- Column(
- modifier = Modifier.fillMaxSize().padding(14.dp),
- verticalArrangement = Arrangement.spacedBy(8.dp)
- ) {
- Column(verticalArrangement = Arrangement.spacedBy(2.dp)) {
- Text(
- text = stringResource(R.string.settings_recording_title),
- style = MaterialTheme.typography.titleSmall,
- color = Primary
- )
- Text(
- text = "${filteredItems.size} of ${recordingItems.size} items",
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim
- )
- }
- androidx.compose.foundation.layout.FlowRow(
- modifier = Modifier.fillMaxWidth(),
- horizontalArrangement = Arrangement.spacedBy(6.dp),
- verticalArrangement = Arrangement.spacedBy(6.dp)
- ) {
- CompactRecordingActionChip(
- label = "All",
- accent = if (statusFilter == null) Primary else OnSurfaceDim,
- onClick = { statusFilter = null }
- )
- RecordingStatus.entries.forEach { status ->
- CompactRecordingActionChip(
- label = recordingStatusLabel(status),
- accent = if (statusFilter == status) recordingStatusAccent(status) else OnSurfaceDim,
- onClick = { statusFilter = if (statusFilter == status) null else status }
- )
- }
- }
- val isTelevisionDevice = com.streamvault.app.device.rememberIsTelevisionDevice()
- val searchFocusRequester = remember { FocusRequester() }
- val inputFocusRequester = remember { FocusRequester() }
- val keyboardController = LocalSoftwareKeyboardController.current
- var acceptsInput by remember(isTelevisionDevice) { mutableStateOf(!isTelevisionDevice) }
- TvClickableSurface(
- onClick = {
- acceptsInput = true
- inputFocusRequester.requestFocus()
- keyboardController?.show()
- },
- modifier = Modifier
- .fillMaxWidth()
- .focusRequester(searchFocusRequester),
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = SurfaceElevated,
- focusedContainerColor = SurfaceHighlight
- ),
- border = ClickableSurfaceDefaults.border(
- border = Border(
- border = BorderStroke(1.dp, OnSurfaceDim.copy(alpha = 0.3f)),
- shape = RoundedCornerShape(8.dp)
- ),
- focusedBorder = Border(
- border = BorderStroke(2.dp, FocusBorder),
- shape = RoundedCornerShape(8.dp)
- )
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
- ) {
- Box(
- modifier = Modifier
- .fillMaxWidth()
- .padding(horizontal = 10.dp, vertical = 6.dp)
- ) {
- if (searchQuery.isEmpty()) {
- Text(
- text = "Search recordings…",
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim
- )
- }
- BasicTextField(
- value = searchQuery,
- onValueChange = { searchQuery = it },
- textStyle = MaterialTheme.typography.bodySmall.copy(color = OnBackground),
- singleLine = true,
- cursorBrush = SolidColor(Primary),
- readOnly = isTelevisionDevice && !acceptsInput,
- keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search),
- keyboardActions = KeyboardActions(onSearch = {
- acceptsInput = false
- keyboardController?.hide()
- searchFocusRequester.requestFocus()
- }),
- modifier = Modifier
- .fillMaxWidth()
- .focusRequester(inputFocusRequester)
- .onFocusChanged {
- if (!it.isFocused && isTelevisionDevice) {
- acceptsInput = false
- keyboardController?.hide()
- }
- }
- )
- }
- }
- LazyColumn(
- modifier = Modifier.fillMaxSize(),
- verticalArrangement = Arrangement.spacedBy(8.dp),
- contentPadding = PaddingValues(bottom = 4.dp)
- ) {
- items(filteredItems, key = { item -> item.id }) { item ->
- RecordingPickerRow(
- item = item,
- selected = item.id == selectedItem.id,
- onSelected = { onSelectedRecordingChange(item.id) }
- )
- }
- }
- }
- }
-
- RecordingDetailPanel(
- item = selectedItem,
- modifier = Modifier
- .weight(1f)
- .fillMaxHeight(),
- onPlay = { onPlay(selectedItem) },
- onStop = { onStop(selectedItem) },
- onCancel = { onCancel(selectedItem) },
- onSkipOccurrence = { onSkipOccurrence(selectedItem) },
- onDelete = { onDelete(selectedItem) },
- onRetry = { onRetry(selectedItem) },
- onToggleSchedule = { enabled -> onToggleSchedule(selectedItem, enabled) }
- )
- }
-}
-
-@Composable
-private fun RecordingPickerRow(
- item: RecordingItem,
- selected: Boolean,
- onSelected: () -> Unit
-) {
- val accent = recordingStatusAccent(item.status)
- TvClickableSurface(
- onClick = onSelected,
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(12.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = if (selected) accent.copy(alpha = 0.14f) else Color.Transparent,
- contentColor = OnBackground,
- focusedContainerColor = SurfaceHighlight.copy(alpha = 0.48f),
- focusedContentColor = OnBackground
+ modifier = Modifier
+ .widthIn(min = 168.dp, max = 220.dp)
+ .heightIn(min = 52.dp)
+ .then(modifier),
+ shape = ButtonDefaults.shape(RoundedCornerShape(10.dp)),
+ colors = ButtonDefaults.colors(
+ containerColor = accent.copy(alpha = 0.14f),
+ focusedContainerColor = accent.copy(alpha = 0.28f),
+ contentColor = accent,
+ focusedContentColor = accent
),
- border = ClickableSurfaceDefaults.border(
+ border = ButtonDefaults.border(
border = Border(
- border = BorderStroke(
- 1.dp,
- if (selected) accent.copy(alpha = 0.55f) else Color.White.copy(alpha = 0.08f)
- ),
- shape = RoundedCornerShape(12.dp)
+ border = BorderStroke(1.dp, Color.White.copy(alpha = 0.08f)),
+ shape = RoundedCornerShape(10.dp)
),
focusedBorder = Border(
border = BorderStroke(FocusSpec.BorderWidth, Color.White),
- shape = RoundedCornerShape(12.dp)
+ shape = RoundedCornerShape(10.dp)
)
),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
- modifier = Modifier
- .fillMaxWidth()
- .onFocusChanged { focusState ->
- if (focusState.isFocused) onSelected()
- }
- ) {
- Row(
- modifier = Modifier.fillMaxWidth().padding(horizontal = 12.dp, vertical = 10.dp),
- horizontalArrangement = Arrangement.spacedBy(10.dp),
- verticalAlignment = Alignment.CenterVertically
- ) {
- Box(
- modifier = Modifier
- .size(width = 5.dp, height = 36.dp)
- .background(accent.copy(alpha = 0.92f), RoundedCornerShape(999.dp))
- )
- Column(
- modifier = Modifier.weight(1f),
- verticalArrangement = Arrangement.spacedBy(3.dp)
- ) {
- Text(
- text = recordingDisplayTitle(item),
- style = MaterialTheme.typography.bodyMedium,
- color = OnBackground,
- maxLines = 1,
- overflow = TextOverflow.Ellipsis
- )
- Text(
- text = recordingListSecondaryLine(item),
- style = MaterialTheme.typography.labelSmall,
- color = OnSurfaceDim,
- maxLines = 1,
- overflow = TextOverflow.Ellipsis
- )
- }
- Text(
- text = recordingStatusLabel(item.status),
- style = MaterialTheme.typography.labelSmall,
- color = accent,
- maxLines = 1
- )
- }
- }
-}
-
-@OptIn(ExperimentalLayoutApi::class)
-@Composable
-private fun RecordingDetailPanel(
- item: RecordingItem,
- modifier: Modifier = Modifier,
- onPlay: () -> Unit,
- onStop: () -> Unit,
- onCancel: () -> Unit,
- onSkipOccurrence: () -> Unit,
- onDelete: () -> Unit,
- onRetry: () -> Unit,
- onToggleSchedule: (Boolean) -> Unit
-) {
- val accent = recordingStatusAccent(item.status)
- val appTimeFormat = LocalAppTimeFormat.current
- val dateTimeFormat = remember(appTimeFormat) { appTimeFormat.createDateTimeFormat() }
- Surface(
- modifier = modifier,
- colors = SurfaceDefaults.colors(containerColor = SurfaceElevated),
- shape = RoundedCornerShape(16.dp)
- ) {
- Column(
- modifier = Modifier.fillMaxSize().padding(20.dp),
- verticalArrangement = Arrangement.spacedBy(16.dp)
- ) {
- Column(
- modifier = Modifier.fillMaxWidth(),
- verticalArrangement = Arrangement.spacedBy(10.dp)
- ) {
- Text(
- text = recordingDisplayTitle(item),
- style = MaterialTheme.typography.titleLarge,
- color = OnBackground,
- maxLines = 2,
- overflow = TextOverflow.Ellipsis
- )
- recordingDisplaySubtitle(item)?.let { subtitle ->
- Text(
- text = subtitle,
- style = MaterialTheme.typography.bodyMedium,
- color = OnSurfaceDim,
- maxLines = 1,
- overflow = TextOverflow.Ellipsis
- )
- }
- Row(
- horizontalArrangement = Arrangement.spacedBy(8.dp),
- verticalAlignment = Alignment.CenterVertically
- ) {
- StatusTonePill(
- label = recordingStatusLabel(item.status),
- accent = accent
- )
- if (item.recurrence != RecordingRecurrence.NONE) {
- StatusTonePill(
- label = when (item.recurrence) {
- RecordingRecurrence.DAILY -> stringResource(R.string.settings_recording_recurrence_daily)
- RecordingRecurrence.WEEKLY -> stringResource(R.string.settings_recording_recurrence_weekly)
- RecordingRecurrence.NONE -> stringResource(R.string.settings_recording_recurrence_none)
- },
- accent = Secondary
- )
- }
- }
- Text(
- text = stringResource(
- R.string.settings_recording_time_window,
- formatTimestamp(item.scheduledStartMs, dateTimeFormat),
- formatTimestamp(item.scheduledEndMs, dateTimeFormat)
- ),
- style = MaterialTheme.typography.bodySmall,
- color = OnSurface
- )
- }
-
- Row(
- modifier = Modifier.fillMaxWidth(),
- horizontalArrangement = Arrangement.spacedBy(10.dp)
- ) {
- RecordingMetricCard(
- modifier = Modifier.weight(1f),
- label = stringResource(R.string.settings_recording_source_label),
- value = formatRecordingSourceType(item.sourceType)
- )
- RecordingMetricCard(
- modifier = Modifier.weight(1f),
- label = stringResource(R.string.settings_recording_bytes_label),
- value = formatBytes(item.bytesWritten)
- )
- RecordingMetricCard(
- modifier = Modifier.weight(1f),
- label = stringResource(R.string.settings_recording_speed_label),
- value = if (item.averageThroughputBytesPerSecond > 0L) {
- "${formatBytes(item.averageThroughputBytesPerSecond)}/s"
- } else {
- "N/A"
- }
- )
- }
-
- if (item.retryCount > 0) {
- RecordingMetaPill(
- label = stringResource(R.string.settings_recording_retry_count_label),
- value = item.retryCount.toString()
- )
- }
-
- item.outputDisplayPath?.takeIf { output -> output.isNotBlank() }?.let { output ->
- Text(
- text = "${stringResource(R.string.settings_recording_output_label)}: ${summarizeRecordingOutputPath(output)}",
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim,
- maxLines = 1,
- overflow = TextOverflow.Ellipsis
- )
- }
-
- item.failureReason?.takeIf { reason -> reason.isNotBlank() }?.let { reason ->
- Text(
- text = reason,
- style = MaterialTheme.typography.bodySmall,
- color = ErrorColor
- )
- }
-
- if (item.failureCategory != RecordingFailureCategory.NONE) {
- Text(
- text = "${stringResource(R.string.settings_recording_failure_label)}: ${formatRecordingFailureCategory(item.failureCategory)}",
- style = MaterialTheme.typography.bodySmall,
- color = ErrorColor
- )
- }
-
- FlowRow(
- horizontalArrangement = Arrangement.spacedBy(8.dp),
- verticalArrangement = Arrangement.spacedBy(8.dp),
- modifier = Modifier.fillMaxWidth(),
- maxItemsInEachRow = 4
- ) {
- if (item.status == RecordingStatus.COMPLETED && (!item.outputUri.isNullOrBlank() || !item.outputPath.isNullOrBlank())) {
- CompactRecordingActionChip(
- label = "Play",
- accent = Primary,
- onClick = onPlay
- )
- }
- if (item.status == RecordingStatus.RECORDING) {
- CompactRecordingActionChip(
- label = stringResource(R.string.settings_recording_stop),
- accent = ErrorColor,
- onClick = onStop
- )
- }
- if (item.status == RecordingStatus.SCHEDULED) {
- CompactRecordingActionChip(
- label = stringResource(
- if (item.scheduleEnabled) R.string.settings_recording_disable
- else R.string.settings_recording_enable
- ),
- accent = Secondary,
- onClick = { onToggleSchedule(!item.scheduleEnabled) }
- )
- if (item.recurringRuleId != null) {
- CompactRecordingActionChip(
- label = stringResource(R.string.settings_recording_skip),
- accent = OnBackground,
- onClick = onSkipOccurrence
- )
- }
- CompactRecordingActionChip(
- label = stringResource(R.string.settings_recording_cancel),
- accent = OnBackground,
- onClick = onCancel
- )
- }
- if (item.status == RecordingStatus.COMPLETED || item.status == RecordingStatus.FAILED || item.status == RecordingStatus.CANCELLED) {
- if (item.status == RecordingStatus.FAILED) {
- CompactRecordingActionChip(
- label = stringResource(R.string.settings_recording_retry),
- accent = Primary,
- onClick = onRetry
- )
- }
- CompactRecordingActionChip(
- label = stringResource(R.string.settings_recording_delete),
- accent = OnBackground,
- onClick = onDelete
- )
- }
- }
- }
- }
-}
-
-@Composable
-private fun RecordingMetricCard(
- label: String,
- value: String,
- modifier: Modifier = Modifier
-) {
- Column(
- modifier = modifier
- .background(Color.White.copy(alpha = 0.05f), RoundedCornerShape(12.dp))
- .padding(horizontal = 12.dp, vertical = 10.dp),
- verticalArrangement = Arrangement.spacedBy(4.dp)
- ) {
- Text(
- text = label,
- style = MaterialTheme.typography.labelSmall,
- color = OnSurfaceDim
- )
- Text(
- text = value,
- style = MaterialTheme.typography.titleSmall,
- color = OnBackground,
- maxLines = 1,
- overflow = TextOverflow.Ellipsis
- )
- }
-}
-
-@Composable
-private fun StatusTonePill(
- label: String,
- accent: Color
-) {
- Box(
- modifier = Modifier
- .background(accent.copy(alpha = 0.14f), RoundedCornerShape(999.dp))
- .padding(horizontal = 10.dp, vertical = 6.dp)
+ scale = ButtonDefaults.scale(focusedScale = 1f)
) {
Text(
text = label,
- style = MaterialTheme.typography.labelSmall,
- color = accent
+ color = accent,
+ style = MaterialTheme.typography.labelMedium,
+ maxLines = 2,
+ modifier = Modifier.padding(horizontal = 6.dp, vertical = 2.dp)
)
}
}
-private fun recordingDisplayTitle(item: RecordingItem): String {
- val title = item.programTitle?.trim().orEmpty()
- return if (title.isNotBlank()) title else item.channelName
-}
-
-private fun recordingDisplaySubtitle(item: RecordingItem): String? {
- val title = item.programTitle?.trim().orEmpty()
- return if (title.isNotBlank() && title != item.channelName) item.channelName else null
+internal fun formatRecordingSourceType(sourceType: RecordingSourceType): String = when (sourceType) {
+ RecordingSourceType.TS -> "TS"
+ RecordingSourceType.HLS -> "HLS"
+ RecordingSourceType.DASH -> "DASH"
+ RecordingSourceType.UNKNOWN -> "Auto"
}
-@Composable
-private fun recordingListSecondaryLine(item: RecordingItem): String {
- val subtitle = recordingDisplaySubtitle(item)
- val appTimeFormat = LocalAppTimeFormat.current
- val dateTimeFormat = remember(appTimeFormat) { appTimeFormat.createDateTimeFormat() }
- return subtitle ?: stringResource(
- R.string.settings_recording_time_window,
- formatTimestamp(item.scheduledStartMs, dateTimeFormat),
- formatTimestamp(item.scheduledEndMs, dateTimeFormat)
- )
-}
-
-@Composable
-private fun recordingStatusLabel(status: RecordingStatus): String = when (status) {
- RecordingStatus.SCHEDULED -> stringResource(R.string.settings_recording_status_scheduled)
- RecordingStatus.RECORDING -> stringResource(R.string.settings_recording_status_recording)
- RecordingStatus.COMPLETED -> stringResource(R.string.settings_recording_status_completed)
- RecordingStatus.FAILED -> stringResource(R.string.settings_recording_status_failed)
- RecordingStatus.CANCELLED -> stringResource(R.string.settings_recording_status_cancelled)
+internal fun formatRecordingFailureCategory(category: RecordingFailureCategory): String = when (category) {
+ RecordingFailureCategory.NONE -> "None"
+ RecordingFailureCategory.NETWORK -> "Network"
+ RecordingFailureCategory.STORAGE -> "Storage"
+ RecordingFailureCategory.AUTH -> "Auth"
+ RecordingFailureCategory.TOKEN_EXPIRED -> "Token"
+ RecordingFailureCategory.DRM_UNSUPPORTED -> "DRM"
+ RecordingFailureCategory.FORMAT_UNSUPPORTED -> "Format"
+ RecordingFailureCategory.SCHEDULE_CONFLICT -> "Conflict"
+ RecordingFailureCategory.PROVIDER_LIMIT -> "Connection limit"
+ RecordingFailureCategory.UNKNOWN -> "Unknown"
}
-private fun recordingStatusAccent(status: RecordingStatus): Color = when (status) {
- RecordingStatus.RECORDING -> Primary
- RecordingStatus.SCHEDULED -> Secondary
- RecordingStatus.COMPLETED -> Color(0xFF7BA7FF)
- RecordingStatus.FAILED -> ErrorColor
- RecordingStatus.CANCELLED -> OnSurfaceDim
-}
-
-@Composable
-internal fun RecordingItemCard(
- item: RecordingItem,
- onPlay: () -> Unit,
- onStop: () -> Unit,
- onCancel: () -> Unit,
- onSkipOccurrence: () -> Unit,
- onDelete: () -> Unit,
- onRetry: () -> Unit,
- onToggleSchedule: (Boolean) -> Unit
-) {
- Surface(
- modifier = Modifier.fillMaxWidth(),
- colors = SurfaceDefaults.colors(containerColor = SurfaceElevated),
- shape = RoundedCornerShape(12.dp)
- ) {
- Column(
- modifier = Modifier.padding(horizontal = 10.dp, vertical = 8.dp),
- verticalArrangement = Arrangement.spacedBy(4.dp)
- ) {
- Row(
- modifier = Modifier.fillMaxWidth(),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically
- ) {
- Column(modifier = Modifier.weight(1f)) {
- Text(
- item.programTitle ?: item.channelName,
- style = MaterialTheme.typography.bodyMedium,
- color = OnBackground,
- maxLines = 1,
- overflow = TextOverflow.Ellipsis
- )
- if (item.programTitle != null && item.programTitle != item.channelName) {
- Text(
- item.channelName,
- style = MaterialTheme.typography.labelSmall,
- color = OnSurfaceDim,
- maxLines = 1,
- overflow = TextOverflow.Ellipsis
- )
- }
- }
- Text(
- text = when (item.status) {
- RecordingStatus.SCHEDULED -> stringResource(R.string.settings_recording_status_scheduled)
- RecordingStatus.RECORDING -> stringResource(R.string.settings_recording_status_recording)
- RecordingStatus.COMPLETED -> stringResource(R.string.settings_recording_status_completed)
- RecordingStatus.FAILED -> stringResource(R.string.settings_recording_status_failed)
- RecordingStatus.CANCELLED -> stringResource(R.string.settings_recording_status_cancelled)
- },
- style = MaterialTheme.typography.labelMedium,
- color = when (item.status) {
- RecordingStatus.RECORDING -> Primary
- RecordingStatus.COMPLETED -> OnBackground
- RecordingStatus.FAILED -> ErrorColor
- RecordingStatus.CANCELLED -> OnSurfaceDim
- RecordingStatus.SCHEDULED -> Secondary
- }
- )
- }
- Row(
- modifier = Modifier.fillMaxWidth(),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically
- ) {
- val appTimeFormat = LocalAppTimeFormat.current
- val dateTimeFormat = remember(appTimeFormat) { appTimeFormat.createDateTimeFormat() }
- Text(
- text = stringResource(
- R.string.settings_recording_time_window,
- formatTimestamp(item.scheduledStartMs, dateTimeFormat),
- formatTimestamp(item.scheduledEndMs, dateTimeFormat)
- ),
- style = MaterialTheme.typography.labelSmall,
- color = OnSurface,
- maxLines = 1,
- overflow = TextOverflow.Ellipsis,
- modifier = Modifier.weight(1f)
- )
- if (item.recurrence != RecordingRecurrence.NONE) {
- Spacer(modifier = Modifier.width(8.dp))
- Text(
- text = when (item.recurrence) {
- RecordingRecurrence.DAILY -> stringResource(R.string.settings_recording_recurrence_daily)
- RecordingRecurrence.WEEKLY -> stringResource(R.string.settings_recording_recurrence_weekly)
- RecordingRecurrence.NONE -> stringResource(R.string.settings_recording_recurrence_none)
- },
- style = MaterialTheme.typography.labelSmall,
- color = Secondary,
- maxLines = 1
- )
- }
- }
- item.failureReason?.takeIf { it.isNotBlank() }?.let { reason ->
- Text(reason, style = MaterialTheme.typography.bodySmall, color = ErrorColor)
- }
- FlowRow(
- horizontalArrangement = Arrangement.spacedBy(6.dp),
- verticalArrangement = Arrangement.spacedBy(6.dp),
- modifier = Modifier.fillMaxWidth(),
- maxItemsInEachRow = 4
- ) {
- RecordingMetaPill(
- label = stringResource(R.string.settings_recording_source_label),
- value = formatRecordingSourceType(item.sourceType)
- )
- RecordingMetaPill(
- label = stringResource(R.string.settings_recording_bytes_label),
- value = formatBytes(item.bytesWritten)
- )
- RecordingMetaPill(
- label = stringResource(R.string.settings_recording_speed_label),
- value = if (item.averageThroughputBytesPerSecond > 0L) {
- "${formatBytes(item.averageThroughputBytesPerSecond)}/s"
- } else {
- "N/A"
- }
- )
- if (item.retryCount > 0) {
- RecordingMetaPill(
- label = stringResource(R.string.settings_recording_retry_count_label),
- value = item.retryCount.toString()
- )
- }
- }
- item.outputDisplayPath?.takeIf { it.isNotBlank() }?.let { output ->
- Text(
- text = "${stringResource(R.string.settings_recording_output_label)}: ${summarizeRecordingOutputPath(output)}",
- style = MaterialTheme.typography.labelSmall,
- color = OnSurfaceDim,
- maxLines = 1,
- overflow = TextOverflow.Ellipsis
- )
- }
- if (item.failureCategory != RecordingFailureCategory.NONE) {
- Text(
- text = "${stringResource(R.string.settings_recording_failure_label)}: ${formatRecordingFailureCategory(item.failureCategory)}",
- style = MaterialTheme.typography.labelSmall,
- color = ErrorColor
- )
- }
- FlowRow(
- horizontalArrangement = Arrangement.spacedBy(6.dp),
- verticalArrangement = Arrangement.spacedBy(6.dp),
- modifier = Modifier.fillMaxWidth(),
- maxItemsInEachRow = 4
- ) {
- if (item.status == RecordingStatus.COMPLETED && (!item.outputUri.isNullOrBlank() || !item.outputPath.isNullOrBlank())) {
- CompactRecordingActionChip(
- label = "Play",
- accent = Primary,
- onClick = onPlay
- )
- }
- if (item.status == RecordingStatus.RECORDING) {
- CompactRecordingActionChip(
- label = stringResource(R.string.settings_recording_stop),
- accent = ErrorColor,
- onClick = onStop
- )
- }
- if (item.status == RecordingStatus.SCHEDULED) {
- CompactRecordingActionChip(
- label = stringResource(
- if (item.scheduleEnabled) R.string.settings_recording_disable
- else R.string.settings_recording_enable
- ),
- accent = Secondary,
- onClick = { onToggleSchedule(!item.scheduleEnabled) }
- )
- if (item.recurringRuleId != null) {
- CompactRecordingActionChip(
- label = stringResource(R.string.settings_recording_skip),
- accent = OnBackground,
- onClick = onSkipOccurrence
- )
- }
- CompactRecordingActionChip(
- label = stringResource(R.string.settings_recording_cancel),
- accent = OnBackground,
- onClick = onCancel
- )
- }
- if (item.status == RecordingStatus.COMPLETED || item.status == RecordingStatus.FAILED || item.status == RecordingStatus.CANCELLED) {
- if (item.status == RecordingStatus.FAILED) {
- CompactRecordingActionChip(
- label = stringResource(R.string.settings_recording_retry),
- accent = Primary,
- onClick = onRetry
- )
- }
- CompactRecordingActionChip(
- label = stringResource(R.string.settings_recording_delete),
- accent = OnBackground,
- onClick = onDelete
- )
- }
- }
- }
- }
-}
-
-@Composable
-internal fun CompactRecordingActionChip(label: String, accent: Color, onClick: () -> Unit) {
- TvClickableSurface(
- onClick = onClick,
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = accent.copy(alpha = 0.14f),
- focusedContainerColor = accent.copy(alpha = 0.3f)
- ),
- border = ClickableSurfaceDefaults.border(
- focusedBorder = Border(
- border = BorderStroke(FocusSpec.BorderWidth, Color.White),
- shape = RoundedCornerShape(8.dp)
- )
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
- ) {
- Text(
- text = label,
- color = accent,
- style = MaterialTheme.typography.labelSmall,
- modifier = Modifier.padding(horizontal = 9.dp, vertical = 5.dp)
- )
- }
-}
-
-internal fun RecordingItem.playbackUrl(): String? {
- val persistedUri = outputUri?.trim()?.takeIf { it.isNotBlank() }
- if (persistedUri != null) {
- return persistedUri
- }
- val localPath = outputPath?.trim()?.takeIf { it.isNotBlank() } ?: return null
- val parsed = runCatching { android.net.Uri.parse(localPath) }.getOrNull()
- return if (parsed?.scheme.isNullOrBlank()) {
- android.net.Uri.fromFile(java.io.File(localPath)).toString()
- } else {
- localPath
- }
-}
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingDashboardCards.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingDashboardCards.kt
new file mode 100644
index 00000000..9b8a7638
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingDashboardCards.kt
@@ -0,0 +1,299 @@
+package com.streamvault.app.ui.screens.settings
+
+import androidx.compose.foundation.BorderStroke
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.ExperimentalLayoutApi
+import androidx.compose.foundation.layout.FlowRow
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material3.Switch
+import androidx.compose.material3.SwitchDefaults
+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.res.stringResource
+import androidx.compose.ui.text.style.TextOverflow
+import androidx.compose.ui.unit.dp
+import androidx.tv.material3.Border
+import androidx.tv.material3.ClickableSurfaceDefaults
+import androidx.tv.material3.MaterialTheme
+import androidx.tv.material3.Surface
+import androidx.tv.material3.SurfaceDefaults
+import androidx.tv.material3.Text
+import com.streamvault.app.R
+import com.streamvault.app.ui.interaction.TvClickableSurface
+import com.streamvault.app.ui.theme.ErrorColor
+import com.streamvault.app.ui.theme.FocusBorder
+import com.streamvault.app.ui.theme.OnBackground
+import com.streamvault.app.ui.theme.OnSurface
+import com.streamvault.app.ui.theme.OnSurfaceDim
+import com.streamvault.app.ui.theme.Primary
+import com.streamvault.app.ui.theme.Secondary
+import com.streamvault.app.ui.theme.SurfaceElevated
+
+@OptIn(ExperimentalLayoutApi::class)
+@Composable
+internal fun RecordingInfoCard(
+ treeLabel: String?,
+ outputDirectory: String?,
+ availableBytes: Long?,
+ isWritable: Boolean,
+ activeCount: Int,
+ scheduledCount: Int,
+ fileNamePattern: String,
+ retentionDays: Int?,
+ maxSimultaneousRecordings: Int,
+ paddingBeforeMinutes: Int,
+ paddingAfterMinutes: Int
+) {
+ TvClickableSurface(
+ onClick = { },
+ modifier = Modifier.fillMaxWidth(),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = SurfaceElevated,
+ focusedContainerColor = SurfaceElevated
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(16.dp)),
+ border = ClickableSurfaceDefaults.border(
+ focusedBorder = Border(
+ border = BorderStroke(2.dp, FocusBorder),
+ shape = RoundedCornerShape(16.dp)
+ )
+ )
+ ) {
+ Column(
+ modifier = Modifier.padding(20.dp),
+ verticalArrangement = Arrangement.spacedBy(16.dp)
+ ) {
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.Top
+ ) {
+ Column(
+ modifier = Modifier.weight(1f),
+ verticalArrangement = Arrangement.spacedBy(6.dp)
+ ) {
+ Text(
+ text = stringResource(R.string.settings_recording_storage_title),
+ style = MaterialTheme.typography.titleMedium,
+ color = Primary
+ )
+ treeLabel?.takeIf { it.isNotBlank() }?.let {
+ Text(
+ text = it,
+ style = MaterialTheme.typography.bodySmall,
+ color = Secondary,
+ maxLines = 1,
+ overflow = TextOverflow.Ellipsis
+ )
+ }
+ Text(
+ text = outputDirectory ?: stringResource(R.string.settings_recording_storage_unknown),
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim,
+ maxLines = 2,
+ overflow = TextOverflow.Ellipsis
+ )
+ }
+ StatusTonePill(
+ label = if (isWritable) {
+ stringResource(R.string.settings_recording_storage_ready)
+ } else {
+ stringResource(R.string.settings_recording_storage_unavailable)
+ },
+ accent = if (isWritable) OnSurface else ErrorColor
+ )
+ }
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.spacedBy(12.dp)
+ ) {
+ SettingsOverviewStat(
+ label = stringResource(R.string.settings_recording_active_label),
+ value = activeCount.toString(),
+ modifier = Modifier.weight(1f)
+ )
+ SettingsOverviewStat(
+ label = stringResource(R.string.settings_recording_scheduled_label),
+ value = scheduledCount.toString(),
+ modifier = Modifier.weight(1f)
+ )
+ SettingsOverviewStat(
+ label = stringResource(R.string.settings_recording_space_label),
+ value = availableBytes?.let(::formatBytes) ?: stringResource(R.string.settings_recording_storage_unknown),
+ modifier = Modifier.weight(1f)
+ )
+ }
+ FlowRow(
+ horizontalArrangement = Arrangement.spacedBy(10.dp),
+ verticalArrangement = Arrangement.spacedBy(10.dp)
+ ) {
+ RecordingMetaPill(
+ label = stringResource(R.string.settings_recording_pattern_title),
+ value = fileNamePattern
+ )
+ RecordingMetaPill(
+ label = stringResource(R.string.settings_recording_retention_title),
+ value = retentionDays?.let {
+ stringResource(R.string.settings_recording_retention_days, it)
+ } ?: stringResource(R.string.settings_recording_retention_keep_all)
+ )
+ RecordingMetaPill(
+ label = stringResource(R.string.settings_recording_concurrency_title),
+ value = maxSimultaneousRecordings.toString()
+ )
+ RecordingMetaPill(
+ label = stringResource(R.string.settings_recording_padding_before),
+ value = if (paddingBeforeMinutes > 0) {
+ stringResource(R.string.settings_recording_padding_minutes, paddingBeforeMinutes)
+ } else {
+ stringResource(R.string.settings_recording_padding_none)
+ }
+ )
+ RecordingMetaPill(
+ label = stringResource(R.string.settings_recording_padding_after),
+ value = if (paddingAfterMinutes > 0) {
+ stringResource(R.string.settings_recording_padding_minutes, paddingAfterMinutes)
+ } else {
+ stringResource(R.string.settings_recording_padding_none)
+ }
+ )
+ }
+ }
+ }
+}
+
+@Composable
+internal fun RecordingActionsCard(
+ wifiOnlyRecording: Boolean,
+ onWifiOnlyRecordingChange: (Boolean) -> Unit,
+ onChooseFolder: () -> Unit,
+ onUseAppStorage: () -> Unit,
+ onChangePattern: () -> Unit,
+ onChangeRetention: () -> Unit,
+ onChangeConcurrency: () -> Unit,
+ onChangePadding: () -> Unit,
+ onOpenBrowser: () -> Unit,
+ onRepairSchedule: () -> Unit
+) {
+ Surface(
+ modifier = Modifier.fillMaxWidth(),
+ colors = SurfaceDefaults.colors(containerColor = SurfaceElevated),
+ shape = RoundedCornerShape(16.dp)
+ ) {
+ Column(
+ modifier = Modifier.padding(20.dp),
+ verticalArrangement = Arrangement.spacedBy(10.dp)
+ ) {
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.spacedBy(10.dp)
+ ) {
+ RecordingActionButton(
+ label = stringResource(R.string.settings_recording_choose_folder),
+ accent = OnBackground,
+ modifier = Modifier.weight(1f),
+ onClick = onChooseFolder
+ )
+ RecordingActionButton(
+ label = stringResource(R.string.settings_recording_use_app_storage),
+ accent = OnBackground,
+ modifier = Modifier.weight(1f),
+ onClick = onUseAppStorage
+ )
+ }
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.spacedBy(10.dp)
+ ) {
+ RecordingActionButton(
+ label = stringResource(R.string.settings_recording_pattern_title),
+ accent = OnBackground,
+ modifier = Modifier.weight(1f),
+ onClick = onChangePattern
+ )
+ RecordingActionButton(
+ label = stringResource(R.string.settings_recording_retention_title),
+ accent = OnBackground,
+ modifier = Modifier.weight(1f),
+ onClick = onChangeRetention
+ )
+ RecordingActionButton(
+ label = stringResource(R.string.settings_recording_concurrency_title),
+ accent = OnBackground,
+ modifier = Modifier.weight(1f),
+ onClick = onChangeConcurrency
+ )
+ }
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.spacedBy(10.dp)
+ ) {
+ RecordingActionButton(
+ label = stringResource(R.string.settings_recording_open_browser),
+ accent = OnBackground,
+ modifier = Modifier.weight(1f),
+ onClick = onOpenBrowser
+ )
+ RecordingActionButton(
+ label = stringResource(R.string.settings_recording_reconcile),
+ accent = OnBackground,
+ modifier = Modifier.weight(1f),
+ onClick = onRepairSchedule
+ )
+ RecordingActionButton(
+ label = stringResource(R.string.settings_recording_padding_title),
+ accent = OnBackground,
+ modifier = Modifier.weight(1f),
+ onClick = onChangePadding
+ )
+ }
+ TvClickableSurface(
+ onClick = { onWifiOnlyRecordingChange(!wifiOnlyRecording) },
+ modifier = Modifier.fillMaxWidth(),
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(10.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Color.Transparent,
+ focusedContainerColor = Primary.copy(alpha = 0.12f)
+ ),
+ border = ClickableSurfaceDefaults.border(
+ focusedBorder = Border(
+ border = BorderStroke(2.dp, Color.White),
+ shape = RoundedCornerShape(10.dp)
+ )
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
+ ) {
+ Row(
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(horizontal = 8.dp, vertical = 8.dp),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Text(
+ text = stringResource(R.string.settings_recording_wifi_only),
+ style = MaterialTheme.typography.bodyMedium,
+ color = OnSurface
+ )
+ Switch(
+ checked = wifiOnlyRecording,
+ onCheckedChange = null,
+ colors = SwitchDefaults.colors(
+ checkedThumbColor = Primary,
+ checkedTrackColor = Primary.copy(alpha = 0.3f),
+ uncheckedThumbColor = OnSurfaceDim,
+ uncheckedTrackColor = OnSurfaceDim.copy(alpha = 0.2f)
+ )
+ )
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingDialogs.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingDialogs.kt
new file mode 100644
index 00000000..6e2c6046
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingDialogs.kt
@@ -0,0 +1,133 @@
+package com.streamvault.app.ui.screens.settings
+
+import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.padding
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.unit.dp
+import androidx.tv.material3.MaterialTheme
+import androidx.tv.material3.Text
+import com.streamvault.app.R
+import com.streamvault.app.ui.theme.OnSurfaceDim
+
+@Composable
+internal fun SettingsRecordingDialogs(
+ uiState: SettingsUiState,
+ viewModel: SettingsViewModel,
+ showRecordingPatternDialog: Boolean,
+ onShowRecordingPatternDialogChange: (Boolean) -> Unit,
+ showRecordingRetentionDialog: Boolean,
+ onShowRecordingRetentionDialogChange: (Boolean) -> Unit,
+ showRecordingConcurrencyDialog: Boolean,
+ onShowRecordingConcurrencyDialogChange: (Boolean) -> Unit,
+ showRecordingPaddingDialog: Boolean,
+ onShowRecordingPaddingDialogChange: (Boolean) -> Unit
+) {
+ if (showRecordingPatternDialog) {
+ SimpleTextValueDialog(
+ title = stringResource(R.string.settings_recording_pattern_title),
+ subtitle = stringResource(R.string.settings_recording_pattern_hint),
+ initialValue = uiState.recordingStorageState.fileNamePattern,
+ onDismiss = { onShowRecordingPatternDialogChange(false) },
+ onConfirm = { pattern ->
+ viewModel.updateRecordingFileNamePattern(pattern)
+ onShowRecordingPatternDialogChange(false)
+ }
+ )
+ }
+
+ if (showRecordingRetentionDialog) {
+ val retentionOptions = listOf<Int?>(null, 7, 14, 30, 60, 90)
+ PremiumSelectionDialog(
+ title = stringResource(R.string.settings_recording_retention_title),
+ onDismiss = { onShowRecordingRetentionDialogChange(false) }
+ ) {
+ retentionOptions.forEachIndexed { index, days ->
+ LevelOption(
+ level = index,
+ text = if (days == null) {
+ stringResource(R.string.settings_recording_retention_keep_all)
+ } else {
+ stringResource(R.string.settings_recording_retention_days, days)
+ },
+ currentLevel = if (days == uiState.recordingStorageState.retentionDays) index else -1,
+ onSelect = {
+ viewModel.updateRecordingRetentionDays(days)
+ onShowRecordingRetentionDialogChange(false)
+ }
+ )
+ }
+ }
+ }
+
+ if (showRecordingConcurrencyDialog) {
+ PremiumSelectionDialog(
+ title = stringResource(R.string.settings_recording_concurrency_title),
+ onDismiss = { onShowRecordingConcurrencyDialogChange(false) }
+ ) {
+ (1..4).forEach { value ->
+ LevelOption(
+ level = value,
+ text = value.toString(),
+ currentLevel = if (value == uiState.recordingStorageState.maxSimultaneousRecordings) value else -1,
+ onSelect = {
+ viewModel.updateRecordingMaxSimultaneous(value)
+ onShowRecordingConcurrencyDialogChange(false)
+ }
+ )
+ }
+ }
+ }
+
+ if (showRecordingPaddingDialog) {
+ val paddingOptions = listOf(0, 1, 2, 3, 5, 10, 15, 30)
+ PremiumSelectionDialog(
+ title = stringResource(R.string.settings_recording_padding_title),
+ onDismiss = { onShowRecordingPaddingDialogChange(false) }
+ ) {
+ Text(
+ text = stringResource(R.string.settings_recording_padding_before),
+ style = MaterialTheme.typography.labelMedium,
+ color = OnSurfaceDim,
+ modifier = Modifier.padding(bottom = 4.dp)
+ )
+ paddingOptions.forEach { minutes ->
+ LevelOption(
+ level = minutes,
+ text = if (minutes == 0) {
+ stringResource(R.string.settings_recording_padding_none)
+ } else {
+ stringResource(R.string.settings_recording_padding_minutes, minutes)
+ },
+ currentLevel = uiState.recordingPaddingBeforeMinutes,
+ onSelect = {
+ viewModel.setRecordingPaddingBeforeMinutes(minutes)
+ }
+ )
+ }
+ Spacer(modifier = Modifier.height(12.dp))
+ Text(
+ text = stringResource(R.string.settings_recording_padding_after),
+ style = MaterialTheme.typography.labelMedium,
+ color = OnSurfaceDim,
+ modifier = Modifier.padding(bottom = 4.dp)
+ )
+ paddingOptions.forEach { minutes ->
+ LevelOption(
+ level = minutes,
+ text = if (minutes == 0) {
+ stringResource(R.string.settings_recording_padding_none)
+ } else {
+ stringResource(R.string.settings_recording_padding_minutes, minutes)
+ },
+ currentLevel = uiState.recordingPaddingAfterMinutes,
+ onSelect = {
+ viewModel.setRecordingPaddingAfterMinutes(minutes)
+ }
+ )
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingItemComponents.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingItemComponents.kt
new file mode 100644
index 00000000..02b668fd
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingItemComponents.kt
@@ -0,0 +1,284 @@
+package com.streamvault.app.ui.screens.settings
+
+import androidx.compose.foundation.BorderStroke
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.ExperimentalLayoutApi
+import androidx.compose.foundation.layout.FlowRow
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.remember
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.text.style.TextOverflow
+import androidx.compose.ui.unit.dp
+import androidx.tv.material3.Border
+import androidx.tv.material3.ClickableSurfaceDefaults
+import androidx.tv.material3.MaterialTheme
+import androidx.tv.material3.Surface
+import androidx.tv.material3.SurfaceDefaults
+import androidx.tv.material3.Text
+import com.streamvault.app.R
+import com.streamvault.app.ui.design.FocusSpec
+import com.streamvault.app.ui.interaction.TvClickableSurface
+import com.streamvault.app.ui.theme.ErrorColor
+import com.streamvault.app.ui.theme.OnBackground
+import com.streamvault.app.ui.theme.OnSurfaceDim
+import com.streamvault.app.ui.theme.Primary
+import com.streamvault.app.ui.theme.Secondary
+import com.streamvault.app.ui.theme.SurfaceElevated
+import com.streamvault.app.ui.time.LocalAppTimeFormat
+import com.streamvault.app.ui.time.createDateTimeFormat
+import com.streamvault.domain.model.RecordingFailureCategory
+import com.streamvault.domain.model.RecordingItem
+import com.streamvault.domain.model.RecordingRecurrence
+import com.streamvault.domain.model.RecordingStatus
+
+@OptIn(ExperimentalLayoutApi::class)
+@Composable
+internal fun RecordingItemCard(
+ item: RecordingItem,
+ onPlay: () -> Unit,
+ onStop: () -> Unit,
+ onCancel: () -> Unit,
+ onSkipOccurrence: () -> Unit,
+ onDelete: () -> Unit,
+ onRetry: () -> Unit,
+ onToggleSchedule: (Boolean) -> Unit
+) {
+ Surface(
+ modifier = Modifier.fillMaxWidth(),
+ colors = SurfaceDefaults.colors(containerColor = SurfaceElevated),
+ shape = RoundedCornerShape(12.dp)
+ ) {
+ Column(
+ modifier = Modifier.padding(horizontal = 10.dp, vertical = 8.dp),
+ verticalArrangement = Arrangement.spacedBy(4.dp)
+ ) {
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Column(modifier = Modifier.weight(1f)) {
+ Text(
+ item.programTitle ?: item.channelName,
+ style = MaterialTheme.typography.bodyMedium,
+ color = OnBackground,
+ maxLines = 1,
+ overflow = TextOverflow.Ellipsis
+ )
+ if (item.programTitle != null && item.programTitle != item.channelName) {
+ Text(
+ item.channelName,
+ style = MaterialTheme.typography.labelSmall,
+ color = OnSurfaceDim,
+ maxLines = 1,
+ overflow = TextOverflow.Ellipsis
+ )
+ }
+ }
+ Text(
+ text = when (item.status) {
+ RecordingStatus.SCHEDULED -> stringResource(R.string.settings_recording_status_scheduled)
+ RecordingStatus.RECORDING -> stringResource(R.string.settings_recording_status_recording)
+ RecordingStatus.COMPLETED -> stringResource(R.string.settings_recording_status_completed)
+ RecordingStatus.FAILED -> stringResource(R.string.settings_recording_status_failed)
+ RecordingStatus.CANCELLED -> stringResource(R.string.settings_recording_status_cancelled)
+ },
+ style = MaterialTheme.typography.labelMedium,
+ color = when (item.status) {
+ RecordingStatus.RECORDING -> Primary
+ RecordingStatus.COMPLETED -> OnBackground
+ RecordingStatus.FAILED -> ErrorColor
+ RecordingStatus.CANCELLED -> OnSurfaceDim
+ RecordingStatus.SCHEDULED -> Secondary
+ }
+ )
+ }
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ val appTimeFormat = LocalAppTimeFormat.current
+ val dateTimeFormat = remember(appTimeFormat) { appTimeFormat.createDateTimeFormat() }
+ Text(
+ text = stringResource(
+ R.string.settings_recording_time_window,
+ formatTimestamp(item.scheduledStartMs, dateTimeFormat),
+ formatTimestamp(item.scheduledEndMs, dateTimeFormat)
+ ),
+ style = MaterialTheme.typography.labelSmall,
+ color = OnSurfaceDim,
+ maxLines = 1,
+ overflow = TextOverflow.Ellipsis,
+ modifier = Modifier.weight(1f)
+ )
+ if (item.recurrence != RecordingRecurrence.NONE) {
+ androidx.compose.foundation.layout.Spacer(modifier = Modifier.padding(start = 8.dp))
+ Text(
+ text = when (item.recurrence) {
+ RecordingRecurrence.DAILY -> stringResource(R.string.settings_recording_recurrence_daily)
+ RecordingRecurrence.WEEKLY -> stringResource(R.string.settings_recording_recurrence_weekly)
+ RecordingRecurrence.NONE -> stringResource(R.string.settings_recording_recurrence_none)
+ },
+ style = MaterialTheme.typography.labelSmall,
+ color = Secondary,
+ maxLines = 1
+ )
+ }
+ }
+ item.failureReason?.takeIf { it.isNotBlank() }?.let { reason ->
+ Text(reason, style = MaterialTheme.typography.bodySmall, color = ErrorColor)
+ }
+ FlowRow(
+ horizontalArrangement = Arrangement.spacedBy(6.dp),
+ verticalArrangement = Arrangement.spacedBy(6.dp),
+ modifier = Modifier.fillMaxWidth(),
+ maxItemsInEachRow = 4
+ ) {
+ RecordingMetaPill(
+ label = stringResource(R.string.settings_recording_source_label),
+ value = formatRecordingSourceType(item.sourceType)
+ )
+ RecordingMetaPill(
+ label = stringResource(R.string.settings_recording_bytes_label),
+ value = formatBytes(item.bytesWritten)
+ )
+ RecordingMetaPill(
+ label = stringResource(R.string.settings_recording_speed_label),
+ value = if (item.averageThroughputBytesPerSecond > 0L) {
+ "${formatBytes(item.averageThroughputBytesPerSecond)}/s"
+ } else {
+ "N/A"
+ }
+ )
+ if (item.retryCount > 0) {
+ RecordingMetaPill(
+ label = stringResource(R.string.settings_recording_retry_count_label),
+ value = item.retryCount.toString()
+ )
+ }
+ }
+ item.outputDisplayPath?.takeIf { it.isNotBlank() }?.let { output ->
+ Text(
+ text = "${stringResource(R.string.settings_recording_output_label)}: ${summarizeRecordingOutputPath(output)}",
+ style = MaterialTheme.typography.labelSmall,
+ color = OnSurfaceDim,
+ maxLines = 1,
+ overflow = TextOverflow.Ellipsis
+ )
+ }
+ if (item.failureCategory != RecordingFailureCategory.NONE) {
+ Text(
+ text = "${stringResource(R.string.settings_recording_failure_label)}: ${formatRecordingFailureCategory(item.failureCategory)}",
+ style = MaterialTheme.typography.labelSmall,
+ color = ErrorColor
+ )
+ }
+ FlowRow(
+ horizontalArrangement = Arrangement.spacedBy(6.dp),
+ verticalArrangement = Arrangement.spacedBy(6.dp),
+ modifier = Modifier.fillMaxWidth(),
+ maxItemsInEachRow = 4
+ ) {
+ if (item.status == RecordingStatus.COMPLETED && (!item.outputUri.isNullOrBlank() || !item.outputPath.isNullOrBlank())) {
+ CompactRecordingActionChip(
+ label = "Play",
+ accent = Primary,
+ onClick = onPlay
+ )
+ }
+ if (item.status == RecordingStatus.RECORDING) {
+ CompactRecordingActionChip(
+ label = stringResource(R.string.settings_recording_stop),
+ accent = ErrorColor,
+ onClick = onStop
+ )
+ }
+ if (item.status == RecordingStatus.SCHEDULED) {
+ CompactRecordingActionChip(
+ label = stringResource(
+ if (item.scheduleEnabled) R.string.settings_recording_disable
+ else R.string.settings_recording_enable
+ ),
+ accent = Secondary,
+ onClick = { onToggleSchedule(!item.scheduleEnabled) }
+ )
+ if (item.recurringRuleId != null) {
+ CompactRecordingActionChip(
+ label = stringResource(R.string.settings_recording_skip),
+ accent = OnBackground,
+ onClick = onSkipOccurrence
+ )
+ }
+ CompactRecordingActionChip(
+ label = stringResource(R.string.settings_recording_cancel),
+ accent = OnBackground,
+ onClick = onCancel
+ )
+ }
+ if (item.status == RecordingStatus.COMPLETED || item.status == RecordingStatus.FAILED || item.status == RecordingStatus.CANCELLED) {
+ if (item.status == RecordingStatus.FAILED) {
+ CompactRecordingActionChip(
+ label = stringResource(R.string.settings_recording_retry),
+ accent = Primary,
+ onClick = onRetry
+ )
+ }
+ CompactRecordingActionChip(
+ label = stringResource(R.string.settings_recording_delete),
+ accent = OnBackground,
+ onClick = onDelete
+ )
+ }
+ }
+ }
+ }
+}
+
+@Composable
+internal fun CompactRecordingActionChip(label: String, accent: Color, onClick: () -> Unit) {
+ TvClickableSurface(
+ onClick = onClick,
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = accent.copy(alpha = 0.14f),
+ focusedContainerColor = accent.copy(alpha = 0.3f)
+ ),
+ border = ClickableSurfaceDefaults.border(
+ focusedBorder = Border(
+ border = BorderStroke(FocusSpec.BorderWidth, Color.White),
+ shape = RoundedCornerShape(8.dp)
+ )
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
+ ) {
+ Text(
+ text = label,
+ color = accent,
+ style = MaterialTheme.typography.labelSmall,
+ modifier = Modifier.padding(horizontal = 9.dp, vertical = 5.dp)
+ )
+ }
+}
+
+internal fun RecordingItem.playbackUrl(): String? {
+ val persistedUri = outputUri?.trim()?.takeIf { it.isNotBlank() }
+ if (persistedUri != null) {
+ return persistedUri
+ }
+ val localPath = outputPath?.trim()?.takeIf { it.isNotBlank() } ?: return null
+ val parsed = runCatching { android.net.Uri.parse(localPath) }.getOrNull()
+ return if (parsed?.scheme.isNullOrBlank()) {
+ android.net.Uri.fromFile(java.io.File(localPath)).toString()
+ } else {
+ localPath
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingSection.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingSection.kt
new file mode 100644
index 00000000..33a79418
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingSection.kt
@@ -0,0 +1,92 @@
+package com.streamvault.app.ui.screens.settings
+
+import androidx.compose.foundation.lazy.LazyListScope
+import androidx.compose.runtime.Composable
+import com.streamvault.app.MainActivity
+import com.streamvault.app.navigation.Routes
+import com.streamvault.domain.model.RecordingStatus
+
+internal fun LazyListScope.settingsRecordingSection(
+ uiState: SettingsUiState,
+ viewModel: SettingsViewModel,
+ onChooseFolder: () -> Unit,
+ onShowRecordingPatternDialogChange: (Boolean) -> Unit,
+ onShowRecordingRetentionDialogChange: (Boolean) -> Unit,
+ onShowRecordingConcurrencyDialogChange: (Boolean) -> Unit,
+ onShowRecordingPaddingDialogChange: (Boolean) -> Unit,
+ onShowRecordingBrowserDialogChange: (Boolean) -> Unit
+) {
+ item {
+ RecordingInfoCard(
+ treeLabel = uiState.recordingStorageState.displayName,
+ outputDirectory = uiState.recordingStorageState.outputDirectory,
+ availableBytes = uiState.recordingStorageState.availableBytes,
+ isWritable = uiState.recordingStorageState.isWritable,
+ activeCount = uiState.recordingItems.count { it.status == RecordingStatus.RECORDING },
+ scheduledCount = uiState.recordingItems.count { it.status == RecordingStatus.SCHEDULED },
+ fileNamePattern = uiState.recordingStorageState.fileNamePattern,
+ retentionDays = uiState.recordingStorageState.retentionDays,
+ maxSimultaneousRecordings = uiState.recordingStorageState.maxSimultaneousRecordings,
+ paddingBeforeMinutes = uiState.recordingPaddingBeforeMinutes,
+ paddingAfterMinutes = uiState.recordingPaddingAfterMinutes
+ )
+ }
+ item {
+ RecordingActionsCard(
+ wifiOnlyRecording = uiState.wifiOnlyRecording,
+ onWifiOnlyRecordingChange = { viewModel.setRecordingWifiOnly(it) },
+ onChooseFolder = onChooseFolder,
+ onUseAppStorage = { viewModel.updateRecordingFolder(null, null) },
+ onChangePattern = { onShowRecordingPatternDialogChange(true) },
+ onChangeRetention = { onShowRecordingRetentionDialogChange(true) },
+ onChangeConcurrency = { onShowRecordingConcurrencyDialogChange(true) },
+ onChangePadding = { onShowRecordingPaddingDialogChange(true) },
+ onRepairSchedule = { viewModel.reconcileRecordings() },
+ onOpenBrowser = { onShowRecordingBrowserDialogChange(true) }
+ )
+ }
+}
+
+@Composable
+internal fun SettingsRecordingBrowserDialog(
+ showRecordingBrowserDialog: Boolean,
+ uiState: SettingsUiState,
+ selectedRecordingId: String?,
+ onSelectedRecordingChange: (String?) -> Unit,
+ onShowRecordingBrowserDialogChange: (Boolean) -> Unit,
+ mainActivity: MainActivity?,
+ currentRoute: String,
+ viewModel: SettingsViewModel
+) {
+ if (!showRecordingBrowserDialog) return
+
+ RecordingBrowserDialog(
+ recordingItems = uiState.recordingItems,
+ selectedRecordingId = selectedRecordingId,
+ onSelectedRecordingChange = onSelectedRecordingChange,
+ onDismiss = { onShowRecordingBrowserDialogChange(false) },
+ onPlay = { item ->
+ val playbackUrl = item.playbackUrl()
+ if (!playbackUrl.isNullOrBlank()) {
+ mainActivity?.openPlayer(
+ Routes.player(
+ streamUrl = playbackUrl,
+ title = item.programTitle ?: item.channelName,
+ internalId = item.id.hashCode().toLong().and(0x7FFFFFFFL),
+ providerId = item.providerId,
+ contentType = "MOVIE",
+ returnRoute = currentRoute
+ )
+ )
+ }
+ },
+ onStop = { item -> viewModel.stopRecording(item.id) },
+ onCancel = { item -> viewModel.cancelRecording(item.id) },
+ onSkipOccurrence = { item -> viewModel.skipOccurrence(item.id) },
+ onDelete = { item -> viewModel.deleteRecording(item.id) },
+ onRetry = { item -> viewModel.retryRecording(item.id) },
+ onToggleSchedule = { item, enabled ->
+ viewModel.setRecordingScheduleEnabled(item.id, enabled)
+ }
+ )
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRowComponents.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRowComponents.kt
new file mode 100644
index 00000000..5d8e782a
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRowComponents.kt
@@ -0,0 +1,349 @@
+package com.streamvault.app.ui.screens.settings
+
+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.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.heightIn
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.lazy.LazyColumn
+import androidx.compose.foundation.lazy.items
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material3.Switch
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.saveable.rememberSaveable
+import androidx.compose.runtime.setValue
+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.res.stringResource
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.unit.Dp
+import androidx.compose.ui.unit.dp
+import androidx.tv.material3.ClickableSurfaceDefaults
+import androidx.tv.material3.MaterialTheme
+import androidx.tv.material3.Text
+import com.streamvault.app.R
+import com.streamvault.app.ui.components.dialogs.PremiumDialog
+import com.streamvault.app.ui.components.dialogs.PremiumDialogActionButton
+import com.streamvault.app.ui.components.dialogs.PremiumDialogFooterButton
+import com.streamvault.app.ui.interaction.TvButton
+import com.streamvault.app.ui.interaction.TvClickableSurface
+import com.streamvault.app.ui.interaction.mouseClickable
+import com.streamvault.app.ui.theme.OnBackground
+import com.streamvault.app.ui.theme.OnSurface
+import com.streamvault.app.ui.theme.OnSurfaceDim
+import com.streamvault.app.ui.theme.Primary
+
+@Composable
+internal fun SettingsSectionHeader(
+ title: String,
+ subtitle: String
+) {
+ Column(
+ modifier = Modifier.fillMaxWidth(),
+ verticalArrangement = Arrangement.spacedBy(4.dp)
+ ) {
+ Text(
+ text = title,
+ style = MaterialTheme.typography.titleMedium,
+ color = Primary
+ )
+ Text(
+ text = subtitle,
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim
+ )
+ }
+}
+
+@Composable
+internal fun SettingsRow(label: String, value: String) {
+ val focusRequester = remember { FocusRequester() }
+ TvClickableSurface(
+ onClick = {},
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Color.Transparent,
+ focusedContainerColor = Primary.copy(alpha = 0.15f)
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
+ modifier = Modifier
+ .fillMaxWidth()
+ .focusRequester(focusRequester)
+ .mouseClickable(
+ focusRequester = focusRequester,
+ onClick = {}
+ )
+ ) {
+ Row(
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(horizontal = 8.dp, vertical = 8.dp),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Text(text = label, style = MaterialTheme.typography.bodyMedium, color = OnSurface)
+ Text(text = value, style = MaterialTheme.typography.bodyMedium, color = OnBackground)
+ }
+ }
+}
+
+@Composable
+internal fun ClickableSettingsRow(
+ label: String,
+ value: String,
+ onClick: () -> Unit,
+ enabled: Boolean = true,
+ indent: Dp = 0.dp
+) {
+ val focusRequester = remember { FocusRequester() }
+ TvClickableSurface(
+ onClick = { if (enabled) onClick() },
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Color.Transparent,
+ focusedContainerColor = if (enabled) Primary.copy(alpha = 0.15f) else Color.Transparent
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
+ modifier = Modifier
+ .fillMaxWidth()
+ .focusRequester(focusRequester)
+ .mouseClickable(
+ focusRequester = focusRequester,
+ onClick = { if (enabled) onClick() }
+ )
+ ) {
+ Row(
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(start = 8.dp + indent, end = 8.dp, top = 12.dp, bottom = 12.dp),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Text(
+ text = label,
+ style = MaterialTheme.typography.bodyMedium,
+ color = if (enabled) OnSurface else OnSurfaceDim
+ )
+ Text(
+ text = value,
+ style = MaterialTheme.typography.bodyMedium,
+ color = if (enabled) Primary else OnSurfaceDim
+ )
+ }
+ }
+}
+
+@Composable
+internal fun SwitchSettingsRow(
+ label: String,
+ value: String,
+ checked: Boolean,
+ onCheckedChange: (Boolean) -> Unit,
+ enabled: Boolean = true,
+ indent: Dp = 0.dp
+) {
+ val focusRequester = remember { FocusRequester() }
+ TvClickableSurface(
+ onClick = { if (enabled) onCheckedChange(!checked) },
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Color.Transparent,
+ focusedContainerColor = if (enabled) Primary.copy(alpha = 0.15f) else Color.Transparent
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
+ modifier = Modifier
+ .fillMaxWidth()
+ .focusRequester(focusRequester)
+ .mouseClickable(
+ focusRequester = focusRequester,
+ onClick = { if (enabled) onCheckedChange(!checked) }
+ )
+ ) {
+ Row(
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(start = 8.dp + indent, end = 8.dp, top = 12.dp, bottom = 12.dp),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Column(verticalArrangement = Arrangement.spacedBy(2.dp)) {
+ Text(
+ text = label,
+ style = MaterialTheme.typography.bodyMedium,
+ color = if (enabled) OnSurface else OnSurfaceDim
+ )
+ Text(text = value, style = MaterialTheme.typography.bodySmall, color = OnSurfaceDim)
+ }
+ Switch(
+ checked = checked,
+ onCheckedChange = { if (enabled) onCheckedChange(it) },
+ enabled = enabled
+ )
+ }
+ }
+}
+
+@Composable
+internal fun LiveTvQuickFiltersDialog(
+ filters: List<String>,
+ onDismiss: () -> Unit,
+ onAddFilter: (String) -> Unit,
+ onRemoveFilter: (String) -> Unit
+) {
+ var pendingFilter by rememberSaveable { mutableStateOf("") }
+
+ PremiumDialog(
+ title = stringResource(R.string.settings_live_tv_quick_filters_dialog_title),
+ subtitle = stringResource(R.string.settings_live_tv_quick_filters_dialog_subtitle),
+ onDismissRequest = onDismiss,
+ widthFraction = 0.5f,
+ content = {
+ EpgSourceTextField(
+ value = pendingFilter,
+ onValueChange = { pendingFilter = it },
+ placeholder = stringResource(R.string.settings_live_tv_quick_filters_placeholder)
+ )
+ PremiumDialogActionButton(
+ label = stringResource(R.string.settings_live_tv_quick_filters_add),
+ enabled = pendingFilter.isNotBlank(),
+ onClick = {
+ onAddFilter(pendingFilter)
+ pendingFilter = ""
+ }
+ )
+ if (filters.isEmpty()) {
+ Text(
+ text = stringResource(R.string.settings_live_tv_quick_filters_empty),
+ style = MaterialTheme.typography.bodyMedium,
+ color = OnSurfaceDim
+ )
+ } else {
+ Text(
+ text = stringResource(R.string.settings_live_tv_quick_filters_saved),
+ style = MaterialTheme.typography.labelMedium,
+ color = OnSurfaceDim
+ )
+ LazyColumn(
+ modifier = Modifier.heightIn(max = 260.dp),
+ verticalArrangement = Arrangement.spacedBy(8.dp)
+ ) {
+ items(filters, key = { it }) { filter ->
+ Box(
+ modifier = Modifier
+ .fillMaxWidth()
+ .background(Color.White.copy(alpha = 0.06f), RoundedCornerShape(12.dp))
+ .padding(horizontal = 14.dp, vertical = 10.dp)
+ ) {
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.spacedBy(12.dp),
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Text(
+ text = filter,
+ style = MaterialTheme.typography.bodyMedium,
+ color = OnSurface,
+ modifier = Modifier.weight(1f)
+ )
+ TvButton(onClick = { onRemoveFilter(filter) }) {
+ Text(stringResource(R.string.settings_live_tv_quick_filters_remove))
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ footer = {
+ PremiumDialogFooterButton(
+ label = stringResource(R.string.settings_cancel),
+ onClick = onDismiss
+ )
+ }
+ )
+}
+
+internal fun formatLiveTvQuickFiltersValue(filters: List<String>, context: android.content.Context): String {
+ if (filters.isEmpty()) {
+ return context.getString(R.string.settings_live_tv_quick_filters_none)
+ }
+ return context.resources.getQuantityString(
+ R.plurals.settings_live_tv_quick_filters_count,
+ filters.size,
+ filters.size
+ )
+}
+
+@Composable
+internal fun SettingsNavItem(
+ label: String,
+ badgeChar: String,
+ accentColor: Color,
+ isSelected: Boolean,
+ modifier: Modifier = Modifier,
+ onClick: () -> Unit
+) {
+ val focusRequester = remember { FocusRequester() }
+ TvClickableSurface(
+ onClick = onClick,
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(0.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = if (isSelected) Primary.copy(alpha = 0.11f) else Color.Transparent,
+ focusedContainerColor = Primary.copy(alpha = 0.22f)
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
+ modifier = modifier
+ .fillMaxWidth()
+ .focusRequester(focusRequester)
+ .mouseClickable(focusRequester = focusRequester, onClick = onClick)
+ ) {
+ Row(
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(horizontal = 10.dp, vertical = 12.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ horizontalArrangement = Arrangement.spacedBy(10.dp)
+ ) {
+ Box(
+ Modifier
+ .width(3.dp)
+ .height(22.dp)
+ .background(
+ color = if (isSelected) Primary else Color.Transparent,
+ shape = RoundedCornerShape(2.dp)
+ )
+ )
+ Box(
+ Modifier
+ .size(28.dp)
+ .background(accentColor.copy(alpha = 0.18f), RoundedCornerShape(7.dp)),
+ contentAlignment = Alignment.Center
+ ) {
+ Text(
+ text = badgeChar,
+ style = MaterialTheme.typography.labelSmall,
+ color = accentColor,
+ fontWeight = FontWeight.Bold
+ )
+ }
+ Text(
+ text = label,
+ style = MaterialTheme.typography.labelLarge,
+ color = if (isSelected) Primary else OnBackground,
+ fontWeight = if (isSelected) FontWeight.SemiBold else FontWeight.Normal
+ )
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreen.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreen.kt
index 4f7f70bb..d47fe741 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreen.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreen.kt
@@ -1,110 +1,32 @@
package com.streamvault.app.ui.screens.settings
import androidx.compose.foundation.background
-import androidx.compose.foundation.border
-import androidx.compose.foundation.BorderStroke
-import androidx.compose.ui.draw.clip
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
-import androidx.compose.foundation.lazy.LazyRow
-import androidx.compose.foundation.lazy.items
-import androidx.compose.foundation.shape.RoundedCornerShape
-import androidx.compose.foundation.text.BasicTextField
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.compose.runtime.*
-import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
-import androidx.compose.foundation.focusable
import androidx.compose.ui.focus.FocusRequester
-import androidx.compose.ui.focus.focusProperties
import androidx.compose.ui.focus.focusRequester
-import androidx.compose.ui.input.key.onKeyEvent
-import androidx.compose.ui.input.key.onPreviewKeyEvent
-import androidx.compose.ui.platform.LocalSoftwareKeyboardController
-import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.platform.LocalUriHandler
-import androidx.compose.ui.text.TextRange
-import androidx.compose.ui.text.input.TextFieldValue
-import androidx.compose.ui.text.input.ImeAction
-import androidx.compose.foundation.text.KeyboardActions
-import androidx.compose.foundation.text.KeyboardOptions
-import androidx.compose.ui.text.input.KeyboardType
-import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
import androidx.tv.material3.*
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
-import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.graphics.SolidColor
-import androidx.compose.foundation.clickable
-import androidx.compose.material3.Switch
-import androidx.compose.material3.RadioButton
-import androidx.compose.material3.Checkbox
-import androidx.compose.material3.TextButton
-import androidx.compose.material3.Button
-import androidx.compose.material3.OutlinedButton
-import androidx.compose.material3.HorizontalDivider
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.documentfile.provider.DocumentFile
-import com.streamvault.app.ui.interaction.TvClickableSurface
-import com.streamvault.app.ui.interaction.TvButton
-import com.streamvault.app.ui.interaction.TvIconButton
-import com.streamvault.app.ui.time.createDateTimeFormat
-import com.streamvault.app.util.OfficialBuildStatus
import com.streamvault.app.util.OfficialBuildVerifier
-
-import com.streamvault.app.ui.components.dialogs.PinDialog
-import com.streamvault.app.ui.components.dialogs.PremiumDialog
-import com.streamvault.app.ui.components.dialogs.PremiumDialogActionButton
-import com.streamvault.app.ui.components.dialogs.PremiumDialogFooterButton
-import com.streamvault.app.ui.components.TvEmptyState
-import com.streamvault.app.localization.localeForLanguageTag
-import com.streamvault.app.localization.supportedAppLanguageTags
import com.streamvault.app.ui.components.shell.AppNavigationChrome
import com.streamvault.app.ui.components.shell.AppScreenScaffold
-import com.streamvault.app.ui.model.LiveTvChannelMode
-import com.streamvault.app.ui.model.LiveTvQuickFilterVisibilityMode
-import com.streamvault.app.ui.model.VodViewMode
import com.streamvault.app.ui.theme.*
-import com.streamvault.domain.manager.BackupConflictStrategy
-import com.streamvault.domain.model.Category
-import com.streamvault.domain.model.CategorySortMode
-import com.streamvault.domain.model.ChannelNumberingMode
-import com.streamvault.domain.model.ContentType
-import com.streamvault.domain.model.DecoderMode
-import com.streamvault.domain.model.ActiveLiveSource
-import com.streamvault.domain.model.AppTimeFormat
-import com.streamvault.domain.model.CombinedM3uProfile
-import com.streamvault.domain.model.GroupedChannelLabelMode
-import com.streamvault.domain.model.LiveChannelGroupingMode
-import com.streamvault.domain.model.LiveVariantPreferenceMode
import com.streamvault.domain.model.Provider
-import com.streamvault.domain.model.ProviderType
-import com.streamvault.domain.model.ProviderStatus
-import com.streamvault.domain.model.RecordingFailureCategory
-import com.streamvault.domain.model.RecordingItem
-import com.streamvault.domain.model.RecordingRecurrence
-import com.streamvault.domain.model.RecordingSourceType
-import com.streamvault.domain.model.RecordingStatus
-import com.streamvault.app.ui.screens.settings.ProviderDiagnosticsUiModel
-import kotlinx.coroutines.launch
import androidx.compose.ui.res.stringResource
-import androidx.compose.ui.window.Dialog
-import androidx.compose.ui.text.style.TextAlign
import com.streamvault.app.R
-import com.streamvault.app.MainActivity
-import com.streamvault.app.navigation.Routes
-import java.util.Locale
-import com.streamvault.app.BuildConfig
-import com.streamvault.app.ui.screens.settings.AppUpdateUiModel
import com.streamvault.app.ui.design.requestFocusSafely
-import com.streamvault.app.ui.interaction.mouseClickable
-import java.text.DateFormat
-import com.streamvault.app.ui.design.FocusSpec
import kotlinx.coroutines.delay
@@ -125,160 +47,13 @@ fun SettingsScreen(
val context = androidx.compose.ui.platform.LocalContext.current
val mainActivity = context.findMainActivity()
val officialBuildVerification = remember(context.packageName) { OfficialBuildVerifier.verify(context) }
- val buildVerificationLabel = remember(officialBuildVerification.status, context) {
- formatOfficialBuildStatusLabel(officialBuildVerification.status, context)
- }
- val appLanguageLabel = remember(uiState.appLanguage, context) {
- displayLanguageLabel(uiState.appLanguage, context.getString(R.string.settings_system_default))
- }
- val timeFormatLabel = remember(uiState.appTimeFormat, context) {
- formatAppTimeFormatLabel(uiState.appTimeFormat, context)
- }
- val dateTimeFormat = remember(uiState.appTimeFormat) { uiState.appTimeFormat.createDateTimeFormat() }
- val preferredAudioLanguageLabel = remember(uiState.preferredAudioLanguage, context) {
- displayLanguageLabel(uiState.preferredAudioLanguage, context.getString(R.string.settings_audio_language_auto))
- }
- val playbackSpeedLabel = remember(uiState.playerPlaybackSpeed) {
- formatPlaybackSpeedLabel(uiState.playerPlaybackSpeed)
- }
- val audioVideoOffsetLabel = remember(uiState.playerAudioVideoOffsetMs) {
- formatAudioVideoOffsetLabel(uiState.playerAudioVideoOffsetMs)
- }
- val decoderModeLabel = remember(uiState.playerDecoderMode, context) {
- formatDecoderModeLabel(uiState.playerDecoderMode, context)
- }
- val surfaceModeLabel = remember(uiState.playerSurfaceMode, context) {
- formatSurfaceModeLabel(uiState.playerSurfaceMode, context)
- }
- val controlsTimeoutLabel = remember(uiState.playerControlsTimeoutSeconds, context) {
- formatTimeoutSecondsLabel(uiState.playerControlsTimeoutSeconds, context)
- }
- val liveOverlayTimeoutLabel = remember(uiState.playerLiveOverlayTimeoutSeconds, context) {
- formatTimeoutSecondsLabel(uiState.playerLiveOverlayTimeoutSeconds, context)
- }
- val noticeTimeoutLabel = remember(uiState.playerNoticeTimeoutSeconds, context) {
- formatTimeoutSecondsLabel(uiState.playerNoticeTimeoutSeconds, context)
- }
- val diagnosticsTimeoutLabel = remember(uiState.playerDiagnosticsTimeoutSeconds, context) {
- formatTimeoutSecondsLabel(uiState.playerDiagnosticsTimeoutSeconds, context)
- }
- val subtitleSizeLabel = remember(uiState.subtitleTextScale, context) {
- formatSubtitleSizeLabel(uiState.subtitleTextScale, context)
- }
- val subtitleTextColorLabel = remember(uiState.subtitleTextColor, context) {
- formatSubtitleColorLabel(uiState.subtitleTextColor, subtitleTextColorOptions(context))
- }
- val subtitleBackgroundLabel = remember(uiState.subtitleBackgroundColor, context) {
- formatSubtitleColorLabel(uiState.subtitleBackgroundColor, subtitleBackgroundColorOptions(context))
- }
- val wifiQualityLabel = remember(uiState.wifiMaxVideoHeight, context) {
- formatQualityCapLabel(uiState.wifiMaxVideoHeight, context.getString(R.string.settings_quality_cap_auto))
- }
- val ethernetQualityLabel = remember(uiState.ethernetMaxVideoHeight, context) {
- formatQualityCapLabel(uiState.ethernetMaxVideoHeight, context.getString(R.string.settings_quality_cap_auto))
- }
- val timeshiftDepthLabel = remember(uiState.playerTimeshiftDepthMinutes, context) {
- formatTimeshiftDepthLabel(uiState.playerTimeshiftDepthMinutes, context)
- }
- val defaultStopTimerLabel = remember(uiState.defaultStopPlaybackTimerMinutes, context) {
- formatPlaybackTimerMinutesLabel(uiState.defaultStopPlaybackTimerMinutes, context)
- }
- val defaultIdleTimerLabel = remember(uiState.defaultIdleStandbyTimerMinutes, context) {
- formatPlaybackTimerMinutesLabel(uiState.defaultIdleStandbyTimerMinutes, context)
- }
- val lastSpeedTestLabel = remember(uiState.lastSpeedTest) {
- uiState.lastSpeedTest?.let(::formatSpeedTestValueLabel)
- ?: context.getString(R.string.settings_speed_test_not_run)
- }
- val lastSpeedTestSummary = remember(uiState.lastSpeedTest, context, dateTimeFormat) {
- uiState.lastSpeedTest?.let { formatSpeedTestSummary(it, context, dateTimeFormat) }
- ?: context.getString(R.string.settings_speed_test_summary_default)
- }
- val speedTestRecommendationLabel = remember(uiState.lastSpeedTest, context) {
- formatQualityCapLabel(
- uiState.lastSpeedTest?.recommendedMaxVideoHeight,
- context.getString(R.string.settings_quality_cap_auto)
- )
- }
- val protectionSummary = remember(uiState.parentalControlLevel, context) {
- when (uiState.parentalControlLevel) {
- 0 -> context.getString(R.string.settings_level_off)
- 1 -> context.getString(R.string.settings_level_locked)
- 2 -> context.getString(R.string.settings_level_private)
- 3 -> context.getString(R.string.settings_level_hidden)
- else -> context.getString(R.string.settings_level_unknown)
- }
- }
- val guideDefaultCategoryLabel = remember(
- uiState.guideDefaultCategoryId,
- uiState.guideDefaultCategoryOptions,
- context
- ) {
- uiState.guideDefaultCategoryOptions
- .firstOrNull { it.id == uiState.guideDefaultCategoryId }
- ?.name
- ?: context.getString(R.string.settings_guide_default_category_fallback)
- }
-
- // Parental Control State
- var showPinDialog by rememberSaveable { mutableStateOf(false) }
- var showLevelDialog by rememberSaveable { mutableStateOf(false) }
- var showLanguageDialog by rememberSaveable { mutableStateOf(false) }
- var showTimeFormatDialog by rememberSaveable { mutableStateOf(false) }
- var showLiveTvModeDialog by rememberSaveable { mutableStateOf(false) }
- var showLiveTvQuickFilterVisibilityDialog by rememberSaveable { mutableStateOf(false) }
- var showLiveChannelNumberingDialog by rememberSaveable { mutableStateOf(false) }
- var showLiveChannelGroupingDialog by rememberSaveable { mutableStateOf(false) }
- var showGroupedChannelLabelDialog by rememberSaveable { mutableStateOf(false) }
- var showLiveVariantPreferenceDialog by rememberSaveable { mutableStateOf(false) }
- var showVodViewModeDialog by rememberSaveable { mutableStateOf(false) }
- var showGuideDefaultCategoryDialog by rememberSaveable { mutableStateOf(false) }
- var showPlaybackSpeedDialog by rememberSaveable { mutableStateOf(false) }
- var showAudioVideoOffsetDialog by rememberSaveable { mutableStateOf(false) }
- var showDecoderModeDialog by rememberSaveable { mutableStateOf(false) }
- var showSurfaceModeDialog by rememberSaveable { mutableStateOf(false) }
- var showTimeshiftDepthDialog by rememberSaveable { mutableStateOf(false) }
- var showDefaultStopTimerDialog by rememberSaveable { mutableStateOf(false) }
- var showDefaultIdleTimerDialog by rememberSaveable { mutableStateOf(false) }
- var showControlsTimeoutDialog by rememberSaveable { mutableStateOf(false) }
- var showLiveOverlayTimeoutDialog by rememberSaveable { mutableStateOf(false) }
- var showNoticeTimeoutDialog by rememberSaveable { mutableStateOf(false) }
- var showDiagnosticsTimeoutDialog by rememberSaveable { mutableStateOf(false) }
- var showLiveTvFiltersDialog by rememberSaveable { mutableStateOf(false) }
- var showAudioLanguageDialog by rememberSaveable { mutableStateOf(false) }
- var showSubtitleSizeDialog by rememberSaveable { mutableStateOf(false) }
- var showSubtitleTextColorDialog by rememberSaveable { mutableStateOf(false) }
- var showSubtitleBackgroundDialog by rememberSaveable { mutableStateOf(false) }
- var showWifiQualityDialog by rememberSaveable { mutableStateOf(false) }
- var showProviderSyncDialog by rememberSaveable { mutableStateOf(false) }
- var showCustomProviderSyncDialog by rememberSaveable { mutableStateOf(false) }
- var showCreateCombinedDialog by rememberSaveable { mutableStateOf(false) }
- var showAddCombinedMemberDialog by rememberSaveable { mutableStateOf(false) }
- var showRenameCombinedDialog by rememberSaveable { mutableStateOf(false) }
- var selectedCombinedProfileId by rememberSaveable { mutableStateOf<Long?>(null) }
- var pendingSyncProviderId by rememberSaveable { mutableStateOf<Long?>(null) }
- var customSyncSelections by rememberSaveable {
- mutableStateOf(
- setOf(
- ProviderSyncSelection.TV,
- ProviderSyncSelection.MOVIES,
- ProviderSyncSelection.EPG
- )
- )
- }
- var showEthernetQualityDialog by rememberSaveable { mutableStateOf(false) }
- var showClearHistoryDialog by rememberSaveable { mutableStateOf(false) }
- var showRecordingPatternDialog by rememberSaveable { mutableStateOf(false) }
- var showRecordingRetentionDialog by rememberSaveable { mutableStateOf(false) }
- var showRecordingConcurrencyDialog by rememberSaveable { mutableStateOf(false) }
- var showRecordingPaddingDialog by rememberSaveable { mutableStateOf(false) }
- var showRecordingBrowserDialog by rememberSaveable { mutableStateOf(false) }
- var selectedRecordingId by rememberSaveable { mutableStateOf<String?>(null) }
- var categorySortDialogType by rememberSaveable { mutableStateOf<String?>(null) }
- var selectedCategory by rememberSaveable { mutableStateOf(0) }
- var pinError by rememberSaveable { mutableStateOf<String?>(null) }
- var pendingAction by remember { mutableStateOf<ParentalAction?>(null) }
- var pendingProtectionLevel by rememberSaveable { mutableStateOf<Int?>(null) }
+ val screenLabels = rememberSettingsScreenLabels(
+ uiState = uiState,
+ context = context,
+ officialBuildStatus = officialBuildVerification.status
+ )
+ val dialogState = rememberSettingsScreenDialogState()
+ val providerState = rememberSettingsProviderSectionState(dialogState)
val createDocumentLauncher = rememberLauncherForActivityResult(
contract = ActivityResultContracts.CreateDocument("application/json")
@@ -318,15 +93,15 @@ fun SettingsScreen(
}
LaunchedEffect(uiState.recordingItems) {
- selectedRecordingId = when {
+ dialogState.selectedRecordingId = when {
uiState.recordingItems.isEmpty() -> null
- selectedRecordingId == null -> uiState.recordingItems.first().id
- uiState.recordingItems.any { item -> item.id == selectedRecordingId } -> selectedRecordingId
+ dialogState.selectedRecordingId == null -> uiState.recordingItems.first().id
+ uiState.recordingItems.any { item -> item.id == dialogState.selectedRecordingId } -> dialogState.selectedRecordingId
else -> uiState.recordingItems.first().id
}
}
- LaunchedEffect(currentRoute, selectedCategory) {
+ LaunchedEffect(currentRoute, dialogState.selectedCategory) {
delay(80)
settingsNavFocusRequester.requestFocusSafely(tag = "SettingsScreen", target = "Selected settings section")
}
@@ -342,88 +117,11 @@ fun SettingsScreen(
showScreenHeader = false
) {
Row(modifier = Modifier.fillMaxSize()) {
- // ג”€ג”€ Left navigation rail ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€
- LazyColumn(
- modifier = Modifier
- .width(236.dp)
- .fillMaxHeight()
- .background(Color.Black.copy(alpha = 0.25f)),
- contentPadding = PaddingValues(top = 76.dp, bottom = 16.dp),
- verticalArrangement = Arrangement.spacedBy(2.dp)
- ) {
- item {
- SettingsNavItem(
- stringResource(R.string.settings_providers),
- "P",
- Primary,
- selectedCategory == 0,
- modifier = if (selectedCategory == 0) Modifier.focusRequester(settingsNavFocusRequester) else Modifier
- ) { selectedCategory = 0 }
- }
- item {
- SettingsNavItem(
- stringResource(R.string.settings_playback),
- ">",
- Color(0xFF9E8FFF),
- selectedCategory == 1,
- modifier = if (selectedCategory == 1) Modifier.focusRequester(settingsNavFocusRequester) else Modifier
- ) { selectedCategory = 1 }
- }
- item {
- SettingsNavItem(
- stringResource(R.string.settings_browsing),
- "#",
- Color(0xFF26A69A),
- selectedCategory == 2,
- modifier = if (selectedCategory == 2) Modifier.focusRequester(settingsNavFocusRequester) else Modifier
- ) { selectedCategory = 2 }
- }
- item {
- SettingsNavItem(
- stringResource(R.string.settings_privacy),
- "L",
- Color(0xFFFFB74D),
- selectedCategory == 3,
- modifier = if (selectedCategory == 3) Modifier.focusRequester(settingsNavFocusRequester) else Modifier
- ) { selectedCategory = 3 }
- }
- item {
- SettingsNavItem(
- stringResource(R.string.settings_recording_title),
- "R",
- Color(0xFFEF5350),
- selectedCategory == 4,
- modifier = if (selectedCategory == 4) Modifier.focusRequester(settingsNavFocusRequester) else Modifier
- ) { selectedCategory = 4 }
- }
- item {
- SettingsNavItem(
- stringResource(R.string.settings_backup_restore),
- "B",
- Color(0xFF42A5F5),
- selectedCategory == 5,
- modifier = if (selectedCategory == 5) Modifier.focusRequester(settingsNavFocusRequester) else Modifier
- ) { selectedCategory = 5 }
- }
- item {
- SettingsNavItem(
- "EPG Sources",
- "E",
- Color(0xFF66BB6A),
- selectedCategory == 6,
- modifier = if (selectedCategory == 6) Modifier.focusRequester(settingsNavFocusRequester) else Modifier
- ) { selectedCategory = 6 }
- }
- item {
- SettingsNavItem(
- stringResource(R.string.settings_about),
- "i",
- Color(0xFF78909C),
- selectedCategory == 7,
- modifier = if (selectedCategory == 7) Modifier.focusRequester(settingsNavFocusRequester) else Modifier
- ) { selectedCategory = 7 }
- }
- }
+ SettingsNavigationRail(
+ selectedCategory = dialogState.selectedCategory,
+ focusRequester = settingsNavFocusRequester,
+ onCategorySelected = { dialogState.selectedCategory = it }
+ )
// Thin vertical separator
Box(
@@ -433,934 +131,36 @@ fun SettingsScreen(
.background(Color.White.copy(alpha = 0.07f))
)
- // ג”€ג”€ Right content pane ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€
- LazyColumn(
- modifier = Modifier
- .weight(1f)
- .fillMaxHeight()
- .imePadding(),
- contentPadding = PaddingValues(start = 20.dp, top = 76.dp, end = 20.dp, bottom = 32.dp),
- verticalArrangement = Arrangement.spacedBy(10.dp),
- userScrollEnabled = !uiState.isSyncing
- ) {
- // ג”€ג”€ 0: Providers ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€
- if (selectedCategory == 0) {
- providerSection(
- uiState = uiState,
- onAddProvider = onAddProvider,
- onEditProvider = onEditProvider,
- onNavigateToParentalControl = onNavigateToParentalControl,
- viewModel = viewModel,
- selectedCombinedProfileId = selectedCombinedProfileId,
- onSelectedCombinedProfileIdChange = { selectedCombinedProfileId = it },
- onPendingSyncProviderIdChange = { pendingSyncProviderId = it },
- onCustomSyncSelectionsChange = { customSyncSelections = it },
- onShowProviderSyncDialogChange = { showProviderSyncDialog = it },
- onShowCreateCombinedDialogChange = { showCreateCombinedDialog = it },
- onShowRenameCombinedDialogChange = { showRenameCombinedDialog = it },
- onShowAddCombinedMemberDialogChange = { showAddCombinedMemberDialog = it }
- )
- }
-
- // ג”€ג”€ 1: Playback ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€
- else if (selectedCategory == 1) {
- item {
- TvClickableSurface(
- onClick = { viewModel.setPreventStandbyDuringPlayback(!uiState.preventStandbyDuringPlayback) },
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Color.Transparent,
- focusedContainerColor = Primary.copy(alpha = 0.15f)
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
- modifier = Modifier.fillMaxWidth()
- ) {
- Row(
- modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 12.dp),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically
- ) {
- Column(modifier = Modifier.weight(1f)) {
- Text(text = stringResource(R.string.settings_prevent_standby), style = MaterialTheme.typography.bodyMedium, color = OnSurface)
- Text(text = stringResource(R.string.settings_prevent_standby_subtitle), style = MaterialTheme.typography.bodySmall, color = OnBackground.copy(alpha = 0.6f))
- }
- Switch(checked = uiState.preventStandbyDuringPlayback, onCheckedChange = { viewModel.setPreventStandbyDuringPlayback(it) })
- }
- }
- HorizontalDivider(color = Color.White.copy(alpha = 0.07f), modifier = Modifier.padding(vertical = 4.dp))
- TvClickableSurface(
- onClick = { viewModel.setAutoPlayNextEpisode(!uiState.autoPlayNextEpisode) },
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Color.Transparent,
- focusedContainerColor = Primary.copy(alpha = 0.15f)
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
- modifier = Modifier.fillMaxWidth()
- ) {
- Row(
- modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 12.dp),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically
- ) {
- Column(modifier = Modifier.weight(1f)) {
- Text(text = stringResource(R.string.settings_auto_play_next_episode), style = MaterialTheme.typography.bodyMedium, color = OnSurface)
- Text(text = stringResource(R.string.settings_auto_play_next_episode_subtitle), style = MaterialTheme.typography.bodySmall, color = OnBackground.copy(alpha = 0.6f))
- }
- Switch(checked = uiState.autoPlayNextEpisode, onCheckedChange = { viewModel.setAutoPlayNextEpisode(it) })
- }
- }
- HorizontalDivider(color = Color.White.copy(alpha = 0.07f), modifier = Modifier.padding(vertical = 4.dp))
- TvClickableSurface(
- onClick = { viewModel.setPlayerMediaSessionEnabled(!uiState.playerMediaSessionEnabled) },
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Color.Transparent,
- focusedContainerColor = Primary.copy(alpha = 0.15f)
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
- modifier = Modifier.fillMaxWidth()
- ) {
- Row(
- modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 12.dp),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically
- ) {
- Column(modifier = Modifier.weight(1f)) {
- Text(text = stringResource(R.string.settings_media_session), style = MaterialTheme.typography.bodyMedium, color = OnSurface)
- Text(text = stringResource(R.string.settings_media_session_subtitle), style = MaterialTheme.typography.bodySmall, color = OnBackground.copy(alpha = 0.6f))
- }
- Switch(checked = uiState.playerMediaSessionEnabled, onCheckedChange = { viewModel.setPlayerMediaSessionEnabled(it) })
- }
- }
- HorizontalDivider(color = Color.White.copy(alpha = 0.07f), modifier = Modifier.padding(vertical = 4.dp))
- TvClickableSurface(
- onClick = { viewModel.setPlayerTimeshiftEnabled(!uiState.playerTimeshiftEnabled) },
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Color.Transparent,
- focusedContainerColor = Primary.copy(alpha = 0.15f)
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
- modifier = Modifier.fillMaxWidth()
- ) {
- Row(
- modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 12.dp),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically
- ) {
- Column(modifier = Modifier.weight(1f)) {
- Text(text = stringResource(R.string.settings_live_timeshift), style = MaterialTheme.typography.bodyMedium, color = OnSurface)
- Text(text = stringResource(R.string.settings_live_timeshift_subtitle), style = MaterialTheme.typography.bodySmall, color = OnBackground.copy(alpha = 0.6f))
- }
- Switch(checked = uiState.playerTimeshiftEnabled, onCheckedChange = { viewModel.setPlayerTimeshiftEnabled(it) })
- }
- }
- ClickableSettingsRow(
- label = stringResource(R.string.settings_live_timeshift_depth),
- value = timeshiftDepthLabel,
- onClick = { showTimeshiftDepthDialog = true }
- )
- ClickableSettingsRow(
- label = stringResource(R.string.settings_live_timeshift_backend),
- value = stringResource(R.string.settings_live_timeshift_backend_value),
- onClick = {}
- )
- Text(
- text = stringResource(R.string.settings_live_timeshift_backend_subtitle),
- style = MaterialTheme.typography.bodySmall,
- color = OnBackground.copy(alpha = 0.6f),
- modifier = Modifier.padding(horizontal = 8.dp, vertical = 4.dp)
- )
- HorizontalDivider(color = Color.White.copy(alpha = 0.07f), modifier = Modifier.padding(vertical = 4.dp))
- TvClickableSurface(
- onClick = { viewModel.setZapAutoRevert(!uiState.zapAutoRevert) },
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Color.Transparent,
- focusedContainerColor = Primary.copy(alpha = 0.15f)
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
- modifier = Modifier.fillMaxWidth()
- ) {
- Row(
- modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 12.dp),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically
- ) {
- Column(modifier = Modifier.weight(1f)) {
- Text(text = stringResource(R.string.settings_zap_auto_revert), style = MaterialTheme.typography.bodyMedium, color = OnSurface)
- Text(text = stringResource(R.string.settings_zap_auto_revert_subtitle), style = MaterialTheme.typography.bodySmall, color = OnBackground.copy(alpha = 0.6f))
- }
- Switch(checked = uiState.zapAutoRevert, onCheckedChange = { viewModel.setZapAutoRevert(it) })
- }
- }
- ClickableSettingsRow(
- label = stringResource(R.string.settings_decoder_mode),
- value = decoderModeLabel,
- onClick = { showDecoderModeDialog = true }
- )
- ClickableSettingsRow(
- label = stringResource(R.string.settings_surface_mode),
- value = surfaceModeLabel,
- onClick = { showSurfaceModeDialog = true }
- )
- HorizontalDivider(color = Color.White.copy(alpha = 0.07f), modifier = Modifier.padding(vertical = 4.dp))
- ClickableSettingsRow(
- label = stringResource(R.string.settings_default_playback_speed),
- value = playbackSpeedLabel,
- onClick = { showPlaybackSpeedDialog = true }
- )
- ClickableSettingsRow(
- label = stringResource(R.string.settings_default_stop_timer),
- value = defaultStopTimerLabel,
- onClick = { showDefaultStopTimerDialog = true }
- )
- ClickableSettingsRow(
- label = stringResource(R.string.settings_default_idle_standby_timer),
- value = defaultIdleTimerLabel,
- onClick = { showDefaultIdleTimerDialog = true }
- )
- ClickableSettingsRow(
- label = stringResource(R.string.settings_audio_video_sync_default),
- value = audioVideoOffsetLabel,
- onClick = { showAudioVideoOffsetDialog = true }
- )
- ClickableSettingsRow(
- label = stringResource(R.string.settings_player_controls_timeout),
- value = controlsTimeoutLabel,
- onClick = { showControlsTimeoutDialog = true }
- )
- ClickableSettingsRow(
- label = stringResource(R.string.settings_live_overlay_timeout),
- value = liveOverlayTimeoutLabel,
- onClick = { showLiveOverlayTimeoutDialog = true }
- )
- ClickableSettingsRow(
- label = stringResource(R.string.settings_player_notice_timeout),
- value = noticeTimeoutLabel,
- onClick = { showNoticeTimeoutDialog = true }
- )
- ClickableSettingsRow(
- label = stringResource(R.string.settings_player_diagnostics_timeout),
- value = diagnosticsTimeoutLabel,
- onClick = { showDiagnosticsTimeoutDialog = true }
- )
- ClickableSettingsRow(
- label = stringResource(R.string.settings_preferred_audio_language),
- value = preferredAudioLanguageLabel,
- onClick = { showAudioLanguageDialog = true }
- )
- ClickableSettingsRow(
- label = stringResource(R.string.settings_subtitle_size),
- value = subtitleSizeLabel,
- onClick = { showSubtitleSizeDialog = true }
- )
- ClickableSettingsRow(
- label = stringResource(R.string.settings_subtitle_text_color),
- value = subtitleTextColorLabel,
- onClick = { showSubtitleTextColorDialog = true }
- )
- ClickableSettingsRow(
- label = stringResource(R.string.settings_subtitle_background),
- value = subtitleBackgroundLabel,
- onClick = { showSubtitleBackgroundDialog = true }
- )
- HorizontalDivider(color = Color.White.copy(alpha = 0.07f), modifier = Modifier.padding(vertical = 4.dp))
- ClickableSettingsRow(
- label = stringResource(R.string.settings_wifi_quality_cap),
- value = wifiQualityLabel,
- onClick = { showWifiQualityDialog = true }
- )
- ClickableSettingsRow(
- label = stringResource(R.string.settings_ethernet_quality_cap),
- value = ethernetQualityLabel,
- onClick = { showEthernetQualityDialog = true }
- )
- }
- item {
- InternetSpeedTestCard(
- valueLabel = lastSpeedTestLabel,
- summary = lastSpeedTestSummary,
- recommendationLabel = speedTestRecommendationLabel,
- isRunning = uiState.isRunningInternetSpeedTest,
- canApplyRecommendation = uiState.lastSpeedTest != null,
- onRunTest = viewModel::runInternetSpeedTest,
- onApplyWifi = viewModel::applySpeedTestRecommendationToWifi,
- onApplyEthernet = viewModel::applySpeedTestRecommendationToEthernet
- )
- }
- }
-
- // ג”€ג”€ 2: Privacy & Parental ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€
- else if (selectedCategory == 2) {
- item {
- ClickableSettingsRow(
- label = stringResource(R.string.settings_live_tv_channel_mode),
- value = stringResource(uiState.liveTvChannelMode.labelResId()),
- onClick = { showLiveTvModeDialog = true }
- )
- TvClickableSurface(
- onClick = { viewModel.setShowLiveSourceSwitcher(!uiState.showLiveSourceSwitcher) },
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Color.Transparent,
- focusedContainerColor = Primary.copy(alpha = 0.15f)
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
- modifier = Modifier.fillMaxWidth()
- ) {
- Row(
- modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 12.dp),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically
- ) {
- Column(modifier = Modifier.weight(1f)) {
- Text(text = stringResource(R.string.settings_show_live_source_switcher), style = MaterialTheme.typography.bodyMedium, color = OnSurface)
- Text(text = stringResource(R.string.settings_show_live_source_switcher_subtitle), style = MaterialTheme.typography.bodySmall, color = OnBackground.copy(alpha = 0.6f))
- }
- Switch(checked = uiState.showLiveSourceSwitcher, onCheckedChange = { viewModel.setShowLiveSourceSwitcher(it) })
- }
- }
- TvClickableSurface(
- onClick = { viewModel.setShowAllChannelsCategory(!uiState.showAllChannelsCategory) },
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Color.Transparent,
- focusedContainerColor = Primary.copy(alpha = 0.15f)
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
- modifier = Modifier.fillMaxWidth()
- ) {
- Row(
- modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 12.dp),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically
- ) {
- Column(modifier = Modifier.weight(1f)) {
- Text(text = stringResource(R.string.settings_show_all_channels_category), style = MaterialTheme.typography.bodyMedium, color = OnSurface)
- Text(text = stringResource(R.string.settings_show_all_channels_category_subtitle), style = MaterialTheme.typography.bodySmall, color = OnBackground.copy(alpha = 0.6f))
- }
- Switch(checked = uiState.showAllChannelsCategory, onCheckedChange = { viewModel.setShowAllChannelsCategory(it) })
- }
- }
- TvClickableSurface(
- onClick = { viewModel.setShowRecentChannelsCategory(!uiState.showRecentChannelsCategory) },
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Color.Transparent,
- focusedContainerColor = Primary.copy(alpha = 0.15f)
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
- modifier = Modifier.fillMaxWidth()
- ) {
- Row(
- modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 12.dp),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically
- ) {
- Column(modifier = Modifier.weight(1f)) {
- Text(text = stringResource(R.string.settings_show_recent_channels_category), style = MaterialTheme.typography.bodyMedium, color = OnSurface)
- Text(text = stringResource(R.string.settings_show_recent_channels_category_subtitle), style = MaterialTheme.typography.bodySmall, color = OnBackground.copy(alpha = 0.6f))
- }
- Switch(checked = uiState.showRecentChannelsCategory, onCheckedChange = { viewModel.setShowRecentChannelsCategory(it) })
- }
- }
- ClickableSettingsRow(
- label = stringResource(R.string.settings_live_tv_quick_filters),
- value = formatLiveTvQuickFiltersValue(uiState.liveTvCategoryFilters, context),
- onClick = { showLiveTvFiltersDialog = true }
- )
- ClickableSettingsRow(
- label = stringResource(R.string.settings_live_tv_quick_filter_visibility),
- value = stringResource(uiState.liveTvQuickFilterVisibilityMode.labelResId()),
- onClick = { showLiveTvQuickFilterVisibilityDialog = true }
- )
- ClickableSettingsRow(
- label = stringResource(R.string.settings_live_channel_numbering_mode),
- value = stringResource(uiState.liveChannelNumberingMode.labelResId()),
- onClick = { showLiveChannelNumberingDialog = true }
- )
- ClickableSettingsRow(
- label = stringResource(R.string.settings_live_channel_grouping_mode),
- value = stringResource(uiState.liveChannelGroupingMode.labelResId()),
- onClick = { showLiveChannelGroupingDialog = true }
- )
- ClickableSettingsRow(
- label = stringResource(R.string.settings_grouped_channel_label_mode),
- value = stringResource(uiState.groupedChannelLabelMode.labelResId()),
- onClick = { showGroupedChannelLabelDialog = true },
- enabled = uiState.liveChannelGroupingMode == LiveChannelGroupingMode.GROUPED,
- indent = 24.dp
- )
- ClickableSettingsRow(
- label = stringResource(R.string.settings_live_variant_preference_mode),
- value = stringResource(uiState.liveVariantPreferenceMode.labelResId()),
- onClick = { showLiveVariantPreferenceDialog = true },
- enabled = uiState.liveChannelGroupingMode == LiveChannelGroupingMode.GROUPED,
- indent = 24.dp
- )
- ClickableSettingsRow(
- label = stringResource(R.string.settings_guide_default_category),
- value = guideDefaultCategoryLabel,
- onClick = { showGuideDefaultCategoryDialog = true }
- )
- ClickableSettingsRow(
- label = stringResource(R.string.settings_time_format),
- value = timeFormatLabel,
- onClick = { showTimeFormatDialog = true }
- )
- ClickableSettingsRow(
- label = stringResource(R.string.settings_vod_view_mode),
- value = stringResource(uiState.vodViewMode.labelResId()),
- onClick = { showVodViewModeDialog = true }
- )
- SwitchSettingsRow(
- label = stringResource(R.string.settings_vod_infinite_scroll),
- value = stringResource(
- if (uiState.vodInfiniteScroll) R.string.settings_vod_infinite_scroll_on
- else R.string.settings_vod_infinite_scroll_off
- ),
- checked = uiState.vodInfiniteScroll,
- onCheckedChange = { viewModel.setVodInfiniteScroll(it) },
- enabled = uiState.vodViewMode == VodViewMode.MODERN,
- indent = 24.dp
- )
- HorizontalDivider(color = Color.White.copy(alpha = 0.07f), modifier = Modifier.padding(vertical = 4.dp))
- ClickableSettingsRow(
- label = stringResource(R.string.settings_category_sort_live),
- value = formatCategorySortModeLabel(uiState.categorySortModes[ContentType.LIVE] ?: CategorySortMode.DEFAULT, context),
- onClick = { categorySortDialogType = ContentType.LIVE.name }
- )
- ClickableSettingsRow(
- label = stringResource(R.string.settings_category_sort_movies),
- value = formatCategorySortModeLabel(uiState.categorySortModes[ContentType.MOVIE] ?: CategorySortMode.DEFAULT, context),
- onClick = { categorySortDialogType = ContentType.MOVIE.name }
- )
- ClickableSettingsRow(
- label = stringResource(R.string.settings_category_sort_series),
- value = formatCategorySortModeLabel(uiState.categorySortModes[ContentType.SERIES] ?: CategorySortMode.DEFAULT, context),
- onClick = { categorySortDialogType = ContentType.SERIES.name }
- )
- HorizontalDivider(color = Color.White.copy(alpha = 0.07f), modifier = Modifier.padding(vertical = 4.dp))
- TvClickableSurface(
- onClick = { showLanguageDialog = true },
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Color.Transparent,
- focusedContainerColor = Primary.copy(alpha = 0.15f)
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
- modifier = Modifier.fillMaxWidth()
- ) {
- Row(
- modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 12.dp),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically
- ) {
- Text(text = stringResource(R.string.settings_app_language), style = MaterialTheme.typography.bodyMedium, color = OnSurface)
- Text(text = appLanguageLabel, style = MaterialTheme.typography.bodyMedium, color = Primary)
- }
- }
- }
- }
-
- else if (selectedCategory == 3) {
- item {
- ParentalControlCard(
- level = uiState.parentalControlLevel,
- hasParentalPin = uiState.hasParentalPin,
- hasActiveProvider = uiState.activeProviderId != null,
- onChangeLevel = {
- pendingProtectionLevel = null
- if (uiState.hasParentalPin) {
- pendingAction = ParentalAction.ChangeLevel
- showPinDialog = true
- } else {
- showLevelDialog = true
- }
- },
- onChangePin = {
- pendingProtectionLevel = null
- pendingAction = if (uiState.hasParentalPin) {
- ParentalAction.ChangePin
- } else {
- ParentalAction.SetNewPin
- }
- showPinDialog = true
- }
- )
- }
- item {
- HorizontalDivider(color = Color.White.copy(alpha = 0.07f), modifier = Modifier.padding(vertical = 4.dp))
- TvClickableSurface(
- onClick = { viewModel.toggleIncognitoMode() },
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Color.Transparent,
- focusedContainerColor = Primary.copy(alpha = 0.15f)
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
- modifier = Modifier.fillMaxWidth()
- ) {
- Row(
- modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 12.dp),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically
- ) {
- Column(modifier = Modifier.weight(1f)) {
- Text(text = stringResource(R.string.settings_incognito_mode), style = MaterialTheme.typography.bodyMedium, color = OnSurface)
- Text(text = stringResource(R.string.settings_incognito_mode_subtitle), style = MaterialTheme.typography.bodySmall, color = OnBackground.copy(alpha = 0.6f))
- }
- Switch(checked = uiState.isIncognitoMode, onCheckedChange = { viewModel.toggleIncognitoMode() })
- }
- }
- Spacer(Modifier.height(2.dp))
- TvClickableSurface(
- onClick = { viewModel.toggleXtreamTextClassification() },
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Color.Transparent,
- focusedContainerColor = Primary.copy(alpha = 0.15f)
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
- modifier = Modifier.fillMaxWidth()
- ) {
- Row(
- modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 12.dp),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically
- ) {
- Column(modifier = Modifier.weight(1f)) {
- Text(text = stringResource(R.string.settings_xtream_text_classification), style = MaterialTheme.typography.bodyMedium, color = OnSurface)
- Text(text = stringResource(R.string.settings_xtream_text_classification_subtitle), style = MaterialTheme.typography.bodySmall, color = OnBackground.copy(alpha = 0.6f))
- }
- Switch(checked = uiState.useXtreamTextClassification, onCheckedChange = { viewModel.toggleXtreamTextClassification() })
- }
- }
- Spacer(Modifier.height(2.dp))
- TvClickableSurface(
- onClick = { viewModel.toggleXtreamBase64TextCompatibility() },
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Color.Transparent,
- focusedContainerColor = Primary.copy(alpha = 0.15f)
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
- modifier = Modifier.fillMaxWidth()
- ) {
- Row(
- modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 12.dp),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically
- ) {
- Column(modifier = Modifier.weight(1f)) {
- Text(text = stringResource(R.string.settings_xtream_base64_compatibility), style = MaterialTheme.typography.bodyMedium, color = OnSurface)
- Text(text = stringResource(R.string.settings_xtream_base64_compatibility_subtitle), style = MaterialTheme.typography.bodySmall, color = OnBackground.copy(alpha = 0.6f))
- }
- Switch(checked = uiState.xtreamBase64TextCompatibility, onCheckedChange = { viewModel.toggleXtreamBase64TextCompatibility() })
- }
- }
- Spacer(Modifier.height(2.dp))
- TvClickableSurface(
- onClick = { showClearHistoryDialog = true },
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Color.Transparent,
- focusedContainerColor = Primary.copy(alpha = 0.15f)
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
- modifier = Modifier.fillMaxWidth()
- ) {
- Row(
- modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 12.dp),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically
- ) {
- Column(modifier = Modifier.weight(1f)) {
- Text(text = stringResource(R.string.settings_clear_history), style = MaterialTheme.typography.bodyMedium, color = OnSurface)
- Text(text = stringResource(R.string.settings_clear_history_subtitle), style = MaterialTheme.typography.bodySmall, color = OnBackground.copy(alpha = 0.6f))
- }
- Text(text = stringResource(R.string.settings_clear_history_confirm), style = MaterialTheme.typography.labelLarge, color = Primary)
- }
- }
- }
- }
-
- // ג”€ג”€ 3: Recordings ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€
- else if (selectedCategory == 4) {
- item {
- RecordingInfoCard(
- treeLabel = uiState.recordingStorageState.displayName,
- outputDirectory = uiState.recordingStorageState.outputDirectory,
- availableBytes = uiState.recordingStorageState.availableBytes,
- isWritable = uiState.recordingStorageState.isWritable,
- activeCount = uiState.recordingItems.count { it.status == RecordingStatus.RECORDING },
- scheduledCount = uiState.recordingItems.count { it.status == RecordingStatus.SCHEDULED },
- fileNamePattern = uiState.recordingStorageState.fileNamePattern,
- retentionDays = uiState.recordingStorageState.retentionDays,
- maxSimultaneousRecordings = uiState.recordingStorageState.maxSimultaneousRecordings,
- paddingBeforeMinutes = uiState.recordingPaddingBeforeMinutes,
- paddingAfterMinutes = uiState.recordingPaddingAfterMinutes
- )
- }
- item {
- RecordingActionsCard(
- wifiOnlyRecording = uiState.wifiOnlyRecording,
- onWifiOnlyRecordingChange = { viewModel.setRecordingWifiOnly(it) },
- onChooseFolder = { recordingFolderLauncher.launch(null) },
- onUseAppStorage = { viewModel.updateRecordingFolder(null, null) },
- onChangePattern = { showRecordingPatternDialog = true },
- onChangeRetention = { showRecordingRetentionDialog = true },
- onChangeConcurrency = { showRecordingConcurrencyDialog = true },
- onChangePadding = { showRecordingPaddingDialog = true },
- onRepairSchedule = { viewModel.reconcileRecordings() },
- onOpenBrowser = { showRecordingBrowserDialog = true }
- )
- }
- }
-
- // ג”€ג”€ 4: Backup ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€
- else if (selectedCategory == 5) {
- item {
- Row(
- horizontalArrangement = Arrangement.spacedBy(16.dp),
- modifier = Modifier.fillMaxWidth()
- ) {
- TvClickableSurface(
- onClick = { createDocumentLauncher.launch("streamvault_backup.json") },
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(12.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Primary.copy(alpha = 0.12f),
- focusedContainerColor = Primary.copy(alpha = 0.28f)
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
- modifier = Modifier.weight(1f)
- ) {
- Column(
- modifier = Modifier.padding(24.dp),
- verticalArrangement = Arrangement.spacedBy(8.dp),
- horizontalAlignment = Alignment.CenterHorizontally
- ) {
- Text(text = "\u2191", style = MaterialTheme.typography.titleLarge, color = Primary, fontWeight = FontWeight.Bold)
- Text(text = stringResource(R.string.settings_backup_data), style = MaterialTheme.typography.titleSmall, color = Primary, textAlign = TextAlign.Center)
- Text(text = stringResource(R.string.settings_backup_subtitle), style = MaterialTheme.typography.bodySmall, color = OnSurfaceDim, textAlign = TextAlign.Center)
- }
- }
- TvClickableSurface(
- onClick = { openDocumentLauncher.launch(arrayOf("application/json")) },
- shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(12.dp)),
- colors = ClickableSurfaceDefaults.colors(
- containerColor = Secondary.copy(alpha = 0.12f),
- focusedContainerColor = Secondary.copy(alpha = 0.28f)
- ),
- scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
- modifier = Modifier.weight(1f)
- ) {
- Column(
- modifier = Modifier.padding(24.dp),
- verticalArrangement = Arrangement.spacedBy(8.dp),
- horizontalAlignment = Alignment.CenterHorizontally
- ) {
- Text(text = "\u2193", style = MaterialTheme.typography.titleLarge, color = Secondary, fontWeight = FontWeight.Bold)
- Text(text = stringResource(R.string.settings_restore_data), style = MaterialTheme.typography.titleSmall, color = Secondary, textAlign = TextAlign.Center)
- Text(text = stringResource(R.string.settings_backup_subtitle), style = MaterialTheme.typography.bodySmall, color = OnSurfaceDim, textAlign = TextAlign.Center)
- }
- }
- }
- }
- }
-
- // ג”€ג”€ 5: EPG Sources ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€
- else if (selectedCategory == 6) {
- epgSourcesSection(
- uiState = uiState,
- viewModel = viewModel
- )
- }
-
- // ג”€ג”€ 6: About ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€ג”€
- else if (selectedCategory == 7) {
- item {
- val downloadStatus = uiState.appUpdate.downloadStatus
- LaunchedEffect(downloadStatus) {
- if (downloadStatus == com.streamvault.app.update.AppUpdateDownloadStatus.Downloading) {
- while (true) {
- delay(2000L)
- viewModel.refreshDownloadState()
- }
- }
- }
- SettingsSectionHeader(
- title = stringResource(R.string.settings_updates_title),
- subtitle = stringResource(R.string.settings_updates_subtitle)
- )
- SettingsRow(label = stringResource(R.string.settings_app_version), value = "${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})")
- SwitchSettingsRow(
- label = stringResource(R.string.settings_update_auto_check),
- value = stringResource(
- if (uiState.autoCheckAppUpdates) R.string.settings_enabled else R.string.settings_disabled
- ),
- checked = uiState.autoCheckAppUpdates,
- onCheckedChange = viewModel::setAutoCheckAppUpdates
- )
- if (uiState.autoCheckAppUpdates) {
- SwitchSettingsRow(
- label = stringResource(R.string.settings_update_auto_download),
- value = stringResource(
- if (uiState.autoDownloadAppUpdates) R.string.settings_enabled else R.string.settings_disabled
- ),
- checked = uiState.autoDownloadAppUpdates,
- onCheckedChange = viewModel::setAutoDownloadAppUpdates
- )
- }
- SettingsRow(
- label = stringResource(R.string.settings_update_latest_release),
- value = formatLatestReleaseLabel(uiState.appUpdate, context)
- )
- SettingsRow(
- label = stringResource(R.string.settings_update_status),
- value = formatUpdateStatusLabel(uiState.appUpdate, context)
- )
- SettingsRow(
- label = stringResource(R.string.settings_update_last_checked),
- value = formatUpdateCheckTimeLabel(uiState.appUpdate.lastCheckedAt, context)
- )
- ClickableSettingsRow(
- label = stringResource(R.string.settings_update_check_now),
- value = stringResource(
- if (uiState.isCheckingForUpdates) R.string.settings_update_checking else R.string.settings_update_check_action
- ),
- onClick = {
- if (!uiState.isCheckingForUpdates) {
- viewModel.checkForAppUpdates()
- }
- }
- )
- if (shouldShowUpdateDownloadAction(uiState.appUpdate)) {
- ClickableSettingsRow(
- label = stringResource(R.string.settings_update_download),
- value = formatUpdateDownloadLabel(uiState.appUpdate, context),
- onClick = {
- if (uiState.appUpdate.downloadStatus == com.streamvault.app.update.AppUpdateDownloadStatus.Downloaded) {
- viewModel.installDownloadedUpdate()
- } else if (uiState.appUpdate.downloadStatus != com.streamvault.app.update.AppUpdateDownloadStatus.Downloading) {
- viewModel.downloadLatestUpdate()
- }
- }
- )
- }
- if (!uiState.appUpdate.releaseUrl.isNullOrBlank()) {
- ClickableSettingsRow(
- label = stringResource(R.string.settings_update_view_release),
- value = uiState.appUpdate.latestVersionName ?: stringResource(R.string.settings_update_release_notes),
- onClick = { uriHandler.openUri(uiState.appUpdate.releaseUrl.orEmpty()) }
- )
- }
- if (!uiState.appUpdate.errorMessage.isNullOrBlank()) {
- SettingsRow(
- label = stringResource(R.string.settings_update_error),
- value = uiState.appUpdate.errorMessage.orEmpty()
- )
- }
- }
-
- item {
- SettingsRow(label = stringResource(R.string.settings_build), value = stringResource(R.string.settings_build_desc))
- SettingsRow(label = stringResource(R.string.settings_build_verification), value = buildVerificationLabel)
- SettingsRow(label = stringResource(R.string.settings_developed_by), value = stringResource(R.string.settings_developer_name))
- ClickableSettingsRow(
- label = stringResource(R.string.settings_github),
- value = stringResource(R.string.settings_github_url),
- onClick = { uriHandler.openUri(context.getString(R.string.settings_github_url)) }
- )
- ClickableSettingsRow(
- label = stringResource(R.string.settings_donate),
- value = stringResource(R.string.settings_donate_url),
- onClick = { uriHandler.openUri(context.getString(R.string.settings_donate_url)) }
- )
- }
- }
- }
+ SettingsContentPane(
+ uiState = uiState,
+ viewModel = viewModel,
+ context = context,
+ screenLabels = screenLabels,
+ dialogState = dialogState,
+ providerState = providerState,
+ onAddProvider = onAddProvider,
+ onEditProvider = onEditProvider,
+ onNavigateToParentalControl = onNavigateToParentalControl,
+ onChooseRecordingFolder = { recordingFolderLauncher.launch(null) },
+ onCreateBackup = { createDocumentLauncher.launch("streamvault_backup.json") },
+ onRestoreBackup = { openDocumentLauncher.launch(arrayOf("application/json")) },
+ onOpenUri = uriHandler::openUri,
+ modifier = Modifier.weight(1f)
+ )
}
}
- SnackbarHost(
- hostState = snackbarHostState,
- modifier = Modifier
- .align(Alignment.BottomCenter)
- .padding(bottom = 16.dp)
- )
-
- if (showRecordingBrowserDialog) {
- RecordingBrowserDialog(
- recordingItems = uiState.recordingItems,
- selectedRecordingId = selectedRecordingId,
- onSelectedRecordingChange = { selectedRecordingId = it },
- onDismiss = { showRecordingBrowserDialog = false },
- onPlay = { item ->
- val playbackUrl = item.playbackUrl()
- if (!playbackUrl.isNullOrBlank()) {
- mainActivity?.openPlayer(
- Routes.player(
- streamUrl = playbackUrl,
- title = item.programTitle ?: item.channelName,
- internalId = item.id.hashCode().toLong().and(0x7FFFFFFFL),
- providerId = item.providerId,
- contentType = "MOVIE",
- returnRoute = currentRoute
- )
- )
- }
- },
- onStop = { item -> viewModel.stopRecording(item.id) },
- onCancel = { item -> viewModel.cancelRecording(item.id) },
- onSkipOccurrence = { item -> viewModel.skipOccurrence(item.id) },
- onDelete = { item -> viewModel.deleteRecording(item.id) },
- onRetry = { item -> viewModel.retryRecording(item.id) },
- onToggleSchedule = { item, enabled ->
- viewModel.setRecordingScheduleEnabled(item.id, enabled)
- }
- )
- }
-
- SettingsScreenDialogs(
+ SettingsScreenOverlays(
+ snackbarHostState = snackbarHostState,
uiState = uiState,
viewModel = viewModel,
context = context,
scope = scope,
- showLiveTvModeDialog = showLiveTvModeDialog,
- onShowLiveTvModeDialogChange = { showLiveTvModeDialog = it },
- showLiveTvQuickFilterVisibilityDialog = showLiveTvQuickFilterVisibilityDialog,
- onShowLiveTvQuickFilterVisibilityDialogChange = { showLiveTvQuickFilterVisibilityDialog = it },
- showLiveChannelNumberingDialog = showLiveChannelNumberingDialog,
- onShowLiveChannelNumberingDialogChange = { showLiveChannelNumberingDialog = it },
- showLiveChannelGroupingDialog = showLiveChannelGroupingDialog,
- onShowLiveChannelGroupingDialogChange = { showLiveChannelGroupingDialog = it },
- showGroupedChannelLabelDialog = showGroupedChannelLabelDialog,
- onShowGroupedChannelLabelDialogChange = { showGroupedChannelLabelDialog = it },
- showLiveVariantPreferenceDialog = showLiveVariantPreferenceDialog,
- onShowLiveVariantPreferenceDialogChange = { showLiveVariantPreferenceDialog = it },
- showVodViewModeDialog = showVodViewModeDialog,
- onShowVodViewModeDialogChange = { showVodViewModeDialog = it },
- showGuideDefaultCategoryDialog = showGuideDefaultCategoryDialog,
- onShowGuideDefaultCategoryDialogChange = { showGuideDefaultCategoryDialog = it },
- showPlaybackSpeedDialog = showPlaybackSpeedDialog,
- onShowPlaybackSpeedDialogChange = { showPlaybackSpeedDialog = it },
- showAudioVideoOffsetDialog = showAudioVideoOffsetDialog,
- onShowAudioVideoOffsetDialogChange = { showAudioVideoOffsetDialog = it },
- showDecoderModeDialog = showDecoderModeDialog,
- onShowDecoderModeDialogChange = { showDecoderModeDialog = it },
- showSurfaceModeDialog = showSurfaceModeDialog,
- onShowSurfaceModeDialogChange = { showSurfaceModeDialog = it },
- showTimeshiftDepthDialog = showTimeshiftDepthDialog,
- onShowTimeshiftDepthDialogChange = { showTimeshiftDepthDialog = it },
- showDefaultStopTimerDialog = showDefaultStopTimerDialog,
- onShowDefaultStopTimerDialogChange = { showDefaultStopTimerDialog = it },
- showDefaultIdleTimerDialog = showDefaultIdleTimerDialog,
- onShowDefaultIdleTimerDialogChange = { showDefaultIdleTimerDialog = it },
- showControlsTimeoutDialog = showControlsTimeoutDialog,
- onShowControlsTimeoutDialogChange = { showControlsTimeoutDialog = it },
- showLiveOverlayTimeoutDialog = showLiveOverlayTimeoutDialog,
- onShowLiveOverlayTimeoutDialogChange = { showLiveOverlayTimeoutDialog = it },
- showNoticeTimeoutDialog = showNoticeTimeoutDialog,
- onShowNoticeTimeoutDialogChange = { showNoticeTimeoutDialog = it },
- showDiagnosticsTimeoutDialog = showDiagnosticsTimeoutDialog,
- onShowDiagnosticsTimeoutDialogChange = { showDiagnosticsTimeoutDialog = it },
- showLiveTvFiltersDialog = showLiveTvFiltersDialog,
- onShowLiveTvFiltersDialogChange = { showLiveTvFiltersDialog = it },
- showAudioLanguageDialog = showAudioLanguageDialog,
- onShowAudioLanguageDialogChange = { showAudioLanguageDialog = it },
- showSubtitleSizeDialog = showSubtitleSizeDialog,
- onShowSubtitleSizeDialogChange = { showSubtitleSizeDialog = it },
- showSubtitleTextColorDialog = showSubtitleTextColorDialog,
- onShowSubtitleTextColorDialogChange = { showSubtitleTextColorDialog = it },
- showSubtitleBackgroundDialog = showSubtitleBackgroundDialog,
- onShowSubtitleBackgroundDialogChange = { showSubtitleBackgroundDialog = it },
- showWifiQualityDialog = showWifiQualityDialog,
- onShowWifiQualityDialogChange = { showWifiQualityDialog = it },
- showEthernetQualityDialog = showEthernetQualityDialog,
- onShowEthernetQualityDialogChange = { showEthernetQualityDialog = it },
- categorySortDialogType = categorySortDialogType,
- onCategorySortDialogTypeChange = { categorySortDialogType = it },
- showPinDialog = showPinDialog,
- onShowPinDialogChange = { showPinDialog = it },
- showLevelDialog = showLevelDialog,
- onShowLevelDialogChange = { showLevelDialog = it },
- pinError = pinError,
- onPinErrorChange = { pinError = it },
- pendingAction = pendingAction,
- onPendingActionChange = { pendingAction = it },
- pendingProtectionLevel = pendingProtectionLevel,
- onPendingProtectionLevelChange = { pendingProtectionLevel = it },
- showLanguageDialog = showLanguageDialog,
- onShowLanguageDialogChange = { showLanguageDialog = it },
- showTimeFormatDialog = showTimeFormatDialog,
- onShowTimeFormatDialogChange = { showTimeFormatDialog = it },
- showRecordingPatternDialog = showRecordingPatternDialog,
- onShowRecordingPatternDialogChange = { showRecordingPatternDialog = it },
- showRecordingRetentionDialog = showRecordingRetentionDialog,
- onShowRecordingRetentionDialogChange = { showRecordingRetentionDialog = it },
- showRecordingConcurrencyDialog = showRecordingConcurrencyDialog,
- onShowRecordingConcurrencyDialogChange = { showRecordingConcurrencyDialog = it },
- showRecordingPaddingDialog = showRecordingPaddingDialog,
- onShowRecordingPaddingDialogChange = { showRecordingPaddingDialog = it },
- showClearHistoryDialog = showClearHistoryDialog,
- onShowClearHistoryDialogChange = { showClearHistoryDialog = it },
- showCreateCombinedDialog = showCreateCombinedDialog,
- onShowCreateCombinedDialogChange = { showCreateCombinedDialog = it },
- showAddCombinedMemberDialog = showAddCombinedMemberDialog,
- onShowAddCombinedMemberDialogChange = { showAddCombinedMemberDialog = it },
- showRenameCombinedDialog = showRenameCombinedDialog,
- onShowRenameCombinedDialogChange = { showRenameCombinedDialog = it },
- selectedCombinedProfileId = selectedCombinedProfileId,
- showProviderSyncDialog = showProviderSyncDialog,
- onShowProviderSyncDialogChange = { showProviderSyncDialog = it },
- showCustomProviderSyncDialog = showCustomProviderSyncDialog,
- onShowCustomProviderSyncDialogChange = { showCustomProviderSyncDialog = it },
- pendingSyncProviderId = pendingSyncProviderId,
- onPendingSyncProviderIdChange = { pendingSyncProviderId = it },
- customSyncSelections = customSyncSelections,
- onCustomSyncSelectionsChange = { customSyncSelections = it }
+ dialogState = dialogState,
+ mainActivity = mainActivity,
+ currentRoute = currentRoute,
+ modifier = Modifier
)
}
}
-private fun formatOfficialBuildStatusLabel(
- status: OfficialBuildStatus,
- context: android.content.Context
-): String = when (status) {
- OfficialBuildStatus.OFFICIAL -> context.getString(R.string.settings_build_verification_official)
- OfficialBuildStatus.UNOFFICIAL -> context.getString(R.string.settings_build_verification_unofficial)
- OfficialBuildStatus.VERIFICATION_UNAVAILABLE -> context.getString(R.string.settings_build_verification_unavailable)
-}
-
-private fun android.content.Context.findMainActivity(): MainActivity? {
- var current: android.content.Context? = this
- while (current is android.content.ContextWrapper) {
- if (current is MainActivity) return current
- current = current.baseContext
- }
- return null
-}
-
-private fun formatAppTimeFormatLabel(
- format: AppTimeFormat,
- context: android.content.Context
-): String = context.getString(
- when (format) {
- AppTimeFormat.SYSTEM -> R.string.settings_time_format_system
- AppTimeFormat.TWELVE_HOUR -> R.string.settings_time_format_12h
- AppTimeFormat.TWENTY_FOUR_HOUR -> R.string.settings_time_format_24h
- }
-)
-
-private fun formatTimeshiftDepthLabel(
- depthMinutes: Int,
- context: android.content.Context
-): String = when (depthMinutes) {
- 15 -> context.getString(R.string.settings_live_timeshift_depth_15)
- 60 -> context.getString(R.string.settings_live_timeshift_depth_60)
- else -> context.getString(R.string.settings_live_timeshift_depth_30)
-}
-
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreenDialogState.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreenDialogState.kt
new file mode 100644
index 00000000..428d0a0c
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreenDialogState.kt
@@ -0,0 +1,287 @@
+package com.streamvault.app.ui.screens.settings
+
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.MutableState
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.saveable.rememberSaveable
+import androidx.compose.runtime.setValue
+
+internal class SettingsScreenDialogState(
+ private val showPinDialogState: MutableState<Boolean>,
+ private val showLevelDialogState: MutableState<Boolean>,
+ private val showLanguageDialogState: MutableState<Boolean>,
+ private val showTimeFormatDialogState: MutableState<Boolean>,
+ private val showLiveTvModeDialogState: MutableState<Boolean>,
+ private val showLiveTvQuickFilterVisibilityDialogState: MutableState<Boolean>,
+ private val showLiveChannelNumberingDialogState: MutableState<Boolean>,
+ private val showLiveChannelGroupingDialogState: MutableState<Boolean>,
+ private val showGroupedChannelLabelDialogState: MutableState<Boolean>,
+ private val showLiveVariantPreferenceDialogState: MutableState<Boolean>,
+ private val showVodViewModeDialogState: MutableState<Boolean>,
+ private val showGuideDefaultCategoryDialogState: MutableState<Boolean>,
+ private val showPlaybackSpeedDialogState: MutableState<Boolean>,
+ private val showAudioVideoOffsetDialogState: MutableState<Boolean>,
+ private val showDecoderModeDialogState: MutableState<Boolean>,
+ private val showSurfaceModeDialogState: MutableState<Boolean>,
+ private val showTimeshiftDepthDialogState: MutableState<Boolean>,
+ private val showDefaultStopTimerDialogState: MutableState<Boolean>,
+ private val showDefaultIdleTimerDialogState: MutableState<Boolean>,
+ private val showControlsTimeoutDialogState: MutableState<Boolean>,
+ private val showLiveOverlayTimeoutDialogState: MutableState<Boolean>,
+ private val showNoticeTimeoutDialogState: MutableState<Boolean>,
+ private val showDiagnosticsTimeoutDialogState: MutableState<Boolean>,
+ private val showLiveTvFiltersDialogState: MutableState<Boolean>,
+ private val showAudioLanguageDialogState: MutableState<Boolean>,
+ private val showSubtitleSizeDialogState: MutableState<Boolean>,
+ private val showSubtitleTextColorDialogState: MutableState<Boolean>,
+ private val showSubtitleBackgroundDialogState: MutableState<Boolean>,
+ private val showWifiQualityDialogState: MutableState<Boolean>,
+ private val showProviderSyncDialogState: MutableState<Boolean>,
+ private val showCustomProviderSyncDialogState: MutableState<Boolean>,
+ private val showCreateCombinedDialogState: MutableState<Boolean>,
+ private val showAddCombinedMemberDialogState: MutableState<Boolean>,
+ private val showRenameCombinedDialogState: MutableState<Boolean>,
+ private val selectedCombinedProfileIdState: MutableState<Long?>,
+ private val pendingSyncProviderIdState: MutableState<Long?>,
+ private val customSyncSelectionsState: MutableState<Set<ProviderSyncSelection>>,
+ private val showEthernetQualityDialogState: MutableState<Boolean>,
+ private val showClearHistoryDialogState: MutableState<Boolean>,
+ private val showRecordingPatternDialogState: MutableState<Boolean>,
+ private val showRecordingRetentionDialogState: MutableState<Boolean>,
+ private val showRecordingConcurrencyDialogState: MutableState<Boolean>,
+ private val showRecordingPaddingDialogState: MutableState<Boolean>,
+ private val showRecordingBrowserDialogState: MutableState<Boolean>,
+ private val selectedRecordingIdState: MutableState<String?>,
+ private val categorySortDialogTypeState: MutableState<String?>,
+ private val selectedCategoryState: MutableState<Int>,
+ private val pinErrorState: MutableState<String?>,
+ private val pendingActionState: MutableState<ParentalAction?>,
+ private val pendingProtectionLevelState: MutableState<Int?>
+) {
+ var showPinDialog by showPinDialogState
+ var showLevelDialog by showLevelDialogState
+ var showLanguageDialog by showLanguageDialogState
+ var showTimeFormatDialog by showTimeFormatDialogState
+ var showLiveTvModeDialog by showLiveTvModeDialogState
+ var showLiveTvQuickFilterVisibilityDialog by showLiveTvQuickFilterVisibilityDialogState
+ var showLiveChannelNumberingDialog by showLiveChannelNumberingDialogState
+ var showLiveChannelGroupingDialog by showLiveChannelGroupingDialogState
+ var showGroupedChannelLabelDialog by showGroupedChannelLabelDialogState
+ var showLiveVariantPreferenceDialog by showLiveVariantPreferenceDialogState
+ var showVodViewModeDialog by showVodViewModeDialogState
+ var showGuideDefaultCategoryDialog by showGuideDefaultCategoryDialogState
+ var showPlaybackSpeedDialog by showPlaybackSpeedDialogState
+ var showAudioVideoOffsetDialog by showAudioVideoOffsetDialogState
+ var showDecoderModeDialog by showDecoderModeDialogState
+ var showSurfaceModeDialog by showSurfaceModeDialogState
+ var showTimeshiftDepthDialog by showTimeshiftDepthDialogState
+ var showDefaultStopTimerDialog by showDefaultStopTimerDialogState
+ var showDefaultIdleTimerDialog by showDefaultIdleTimerDialogState
+ var showControlsTimeoutDialog by showControlsTimeoutDialogState
+ var showLiveOverlayTimeoutDialog by showLiveOverlayTimeoutDialogState
+ var showNoticeTimeoutDialog by showNoticeTimeoutDialogState
+ var showDiagnosticsTimeoutDialog by showDiagnosticsTimeoutDialogState
+ var showLiveTvFiltersDialog by showLiveTvFiltersDialogState
+ var showAudioLanguageDialog by showAudioLanguageDialogState
+ var showSubtitleSizeDialog by showSubtitleSizeDialogState
+ var showSubtitleTextColorDialog by showSubtitleTextColorDialogState
+ var showSubtitleBackgroundDialog by showSubtitleBackgroundDialogState
+ var showWifiQualityDialog by showWifiQualityDialogState
+ var showProviderSyncDialog by showProviderSyncDialogState
+ var showCustomProviderSyncDialog by showCustomProviderSyncDialogState
+ var showCreateCombinedDialog by showCreateCombinedDialogState
+ var showAddCombinedMemberDialog by showAddCombinedMemberDialogState
+ var showRenameCombinedDialog by showRenameCombinedDialogState
+ var selectedCombinedProfileId by selectedCombinedProfileIdState
+ var pendingSyncProviderId by pendingSyncProviderIdState
+ var customSyncSelections by customSyncSelectionsState
+ var showEthernetQualityDialog by showEthernetQualityDialogState
+ var showClearHistoryDialog by showClearHistoryDialogState
+ var showRecordingPatternDialog by showRecordingPatternDialogState
+ var showRecordingRetentionDialog by showRecordingRetentionDialogState
+ var showRecordingConcurrencyDialog by showRecordingConcurrencyDialogState
+ var showRecordingPaddingDialog by showRecordingPaddingDialogState
+ var showRecordingBrowserDialog by showRecordingBrowserDialogState
+ var selectedRecordingId by selectedRecordingIdState
+ var categorySortDialogType by categorySortDialogTypeState
+ var selectedCategory by selectedCategoryState
+ var pinError by pinErrorState
+ var pendingAction by pendingActionState
+ var pendingProtectionLevel by pendingProtectionLevelState
+}
+
+internal class SettingsProviderSectionState(
+ private val dialogState: SettingsScreenDialogState
+) {
+ var showProviderSyncDialog: Boolean
+ get() = dialogState.showProviderSyncDialog
+ set(value) {
+ dialogState.showProviderSyncDialog = value
+ }
+
+ var showCustomProviderSyncDialog: Boolean
+ get() = dialogState.showCustomProviderSyncDialog
+ set(value) {
+ dialogState.showCustomProviderSyncDialog = value
+ }
+
+ var showCreateCombinedDialog: Boolean
+ get() = dialogState.showCreateCombinedDialog
+ set(value) {
+ dialogState.showCreateCombinedDialog = value
+ }
+
+ var showAddCombinedMemberDialog: Boolean
+ get() = dialogState.showAddCombinedMemberDialog
+ set(value) {
+ dialogState.showAddCombinedMemberDialog = value
+ }
+
+ var showRenameCombinedDialog: Boolean
+ get() = dialogState.showRenameCombinedDialog
+ set(value) {
+ dialogState.showRenameCombinedDialog = value
+ }
+
+ var selectedCombinedProfileId: Long?
+ get() = dialogState.selectedCombinedProfileId
+ set(value) {
+ dialogState.selectedCombinedProfileId = value
+ }
+
+ var pendingSyncProviderId: Long?
+ get() = dialogState.pendingSyncProviderId
+ set(value) {
+ dialogState.pendingSyncProviderId = value
+ }
+
+ var customSyncSelections: Set<ProviderSyncSelection>
+ get() = dialogState.customSyncSelections
+ set(value) {
+ dialogState.customSyncSelections = value
+ }
+}
+
+@Composable
+internal fun rememberSettingsProviderSectionState(
+ dialogState: SettingsScreenDialogState
+): SettingsProviderSectionState = remember(dialogState) {
+ SettingsProviderSectionState(dialogState)
+}
+
+@Composable
+internal fun rememberSettingsScreenDialogState(): SettingsScreenDialogState {
+ val showPinDialogState = rememberSaveable { mutableStateOf(false) }
+ val showLevelDialogState = rememberSaveable { mutableStateOf(false) }
+ val showLanguageDialogState = rememberSaveable { mutableStateOf(false) }
+ val showTimeFormatDialogState = rememberSaveable { mutableStateOf(false) }
+ val showLiveTvModeDialogState = rememberSaveable { mutableStateOf(false) }
+ val showLiveTvQuickFilterVisibilityDialogState = rememberSaveable { mutableStateOf(false) }
+ val showLiveChannelNumberingDialogState = rememberSaveable { mutableStateOf(false) }
+ val showLiveChannelGroupingDialogState = rememberSaveable { mutableStateOf(false) }
+ val showGroupedChannelLabelDialogState = rememberSaveable { mutableStateOf(false) }
+ val showLiveVariantPreferenceDialogState = rememberSaveable { mutableStateOf(false) }
+ val showVodViewModeDialogState = rememberSaveable { mutableStateOf(false) }
+ val showGuideDefaultCategoryDialogState = rememberSaveable { mutableStateOf(false) }
+ val showPlaybackSpeedDialogState = rememberSaveable { mutableStateOf(false) }
+ val showAudioVideoOffsetDialogState = rememberSaveable { mutableStateOf(false) }
+ val showDecoderModeDialogState = rememberSaveable { mutableStateOf(false) }
+ val showSurfaceModeDialogState = rememberSaveable { mutableStateOf(false) }
+ val showTimeshiftDepthDialogState = rememberSaveable { mutableStateOf(false) }
+ val showDefaultStopTimerDialogState = rememberSaveable { mutableStateOf(false) }
+ val showDefaultIdleTimerDialogState = rememberSaveable { mutableStateOf(false) }
+ val showControlsTimeoutDialogState = rememberSaveable { mutableStateOf(false) }
+ val showLiveOverlayTimeoutDialogState = rememberSaveable { mutableStateOf(false) }
+ val showNoticeTimeoutDialogState = rememberSaveable { mutableStateOf(false) }
+ val showDiagnosticsTimeoutDialogState = rememberSaveable { mutableStateOf(false) }
+ val showLiveTvFiltersDialogState = rememberSaveable { mutableStateOf(false) }
+ val showAudioLanguageDialogState = rememberSaveable { mutableStateOf(false) }
+ val showSubtitleSizeDialogState = rememberSaveable { mutableStateOf(false) }
+ val showSubtitleTextColorDialogState = rememberSaveable { mutableStateOf(false) }
+ val showSubtitleBackgroundDialogState = rememberSaveable { mutableStateOf(false) }
+ val showWifiQualityDialogState = rememberSaveable { mutableStateOf(false) }
+ val showProviderSyncDialogState = rememberSaveable { mutableStateOf(false) }
+ val showCustomProviderSyncDialogState = rememberSaveable { mutableStateOf(false) }
+ val showCreateCombinedDialogState = rememberSaveable { mutableStateOf(false) }
+ val showAddCombinedMemberDialogState = rememberSaveable { mutableStateOf(false) }
+ val showRenameCombinedDialogState = rememberSaveable { mutableStateOf(false) }
+ val selectedCombinedProfileIdState = rememberSaveable { mutableStateOf<Long?>(null) }
+ val pendingSyncProviderIdState = rememberSaveable { mutableStateOf<Long?>(null) }
+ val customSyncSelectionsState = rememberSaveable {
+ mutableStateOf(
+ setOf(
+ ProviderSyncSelection.TV,
+ ProviderSyncSelection.MOVIES,
+ ProviderSyncSelection.EPG
+ )
+ )
+ }
+ val showEthernetQualityDialogState = rememberSaveable { mutableStateOf(false) }
+ val showClearHistoryDialogState = rememberSaveable { mutableStateOf(false) }
+ val showRecordingPatternDialogState = rememberSaveable { mutableStateOf(false) }
+ val showRecordingRetentionDialogState = rememberSaveable { mutableStateOf(false) }
+ val showRecordingConcurrencyDialogState = rememberSaveable { mutableStateOf(false) }
+ val showRecordingPaddingDialogState = rememberSaveable { mutableStateOf(false) }
+ val showRecordingBrowserDialogState = rememberSaveable { mutableStateOf(false) }
+ val selectedRecordingIdState = rememberSaveable { mutableStateOf<String?>(null) }
+ val categorySortDialogTypeState = rememberSaveable { mutableStateOf<String?>(null) }
+ val selectedCategoryState = rememberSaveable { mutableStateOf(0) }
+ val pinErrorState = rememberSaveable { mutableStateOf<String?>(null) }
+ val pendingActionState = remember { mutableStateOf<ParentalAction?>(null) }
+ val pendingProtectionLevelState = rememberSaveable { mutableStateOf<Int?>(null) }
+
+ return SettingsScreenDialogState(
+ showPinDialogState = showPinDialogState,
+ showLevelDialogState = showLevelDialogState,
+ showLanguageDialogState = showLanguageDialogState,
+ showTimeFormatDialogState = showTimeFormatDialogState,
+ showLiveTvModeDialogState = showLiveTvModeDialogState,
+ showLiveTvQuickFilterVisibilityDialogState = showLiveTvQuickFilterVisibilityDialogState,
+ showLiveChannelNumberingDialogState = showLiveChannelNumberingDialogState,
+ showLiveChannelGroupingDialogState = showLiveChannelGroupingDialogState,
+ showGroupedChannelLabelDialogState = showGroupedChannelLabelDialogState,
+ showLiveVariantPreferenceDialogState = showLiveVariantPreferenceDialogState,
+ showVodViewModeDialogState = showVodViewModeDialogState,
+ showGuideDefaultCategoryDialogState = showGuideDefaultCategoryDialogState,
+ showPlaybackSpeedDialogState = showPlaybackSpeedDialogState,
+ showAudioVideoOffsetDialogState = showAudioVideoOffsetDialogState,
+ showDecoderModeDialogState = showDecoderModeDialogState,
+ showSurfaceModeDialogState = showSurfaceModeDialogState,
+ showTimeshiftDepthDialogState = showTimeshiftDepthDialogState,
+ showDefaultStopTimerDialogState = showDefaultStopTimerDialogState,
+ showDefaultIdleTimerDialogState = showDefaultIdleTimerDialogState,
+ showControlsTimeoutDialogState = showControlsTimeoutDialogState,
+ showLiveOverlayTimeoutDialogState = showLiveOverlayTimeoutDialogState,
+ showNoticeTimeoutDialogState = showNoticeTimeoutDialogState,
+ showDiagnosticsTimeoutDialogState = showDiagnosticsTimeoutDialogState,
+ showLiveTvFiltersDialogState = showLiveTvFiltersDialogState,
+ showAudioLanguageDialogState = showAudioLanguageDialogState,
+ showSubtitleSizeDialogState = showSubtitleSizeDialogState,
+ showSubtitleTextColorDialogState = showSubtitleTextColorDialogState,
+ showSubtitleBackgroundDialogState = showSubtitleBackgroundDialogState,
+ showWifiQualityDialogState = showWifiQualityDialogState,
+ showProviderSyncDialogState = showProviderSyncDialogState,
+ showCustomProviderSyncDialogState = showCustomProviderSyncDialogState,
+ showCreateCombinedDialogState = showCreateCombinedDialogState,
+ showAddCombinedMemberDialogState = showAddCombinedMemberDialogState,
+ showRenameCombinedDialogState = showRenameCombinedDialogState,
+ selectedCombinedProfileIdState = selectedCombinedProfileIdState,
+ pendingSyncProviderIdState = pendingSyncProviderIdState,
+ customSyncSelectionsState = customSyncSelectionsState,
+ showEthernetQualityDialogState = showEthernetQualityDialogState,
+ showClearHistoryDialogState = showClearHistoryDialogState,
+ showRecordingPatternDialogState = showRecordingPatternDialogState,
+ showRecordingRetentionDialogState = showRecordingRetentionDialogState,
+ showRecordingConcurrencyDialogState = showRecordingConcurrencyDialogState,
+ showRecordingPaddingDialogState = showRecordingPaddingDialogState,
+ showRecordingBrowserDialogState = showRecordingBrowserDialogState,
+ selectedRecordingIdState = selectedRecordingIdState,
+ categorySortDialogTypeState = categorySortDialogTypeState,
+ selectedCategoryState = selectedCategoryState,
+ pinErrorState = pinErrorState,
+ pendingActionState = pendingActionState,
+ pendingProtectionLevelState = pendingProtectionLevelState
+ )
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreenDialogs.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreenDialogs.kt
index d7382b72..6a8dfc2f 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreenDialogs.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreenDialogs.kt
@@ -1,46 +1,17 @@
package com.streamvault.app.ui.screens.settings
import android.content.Context
-import androidx.activity.compose.BackHandler
-import androidx.compose.foundation.background
-import androidx.compose.foundation.clickable
-import androidx.compose.foundation.focusable
-import androidx.compose.foundation.layout.Arrangement
-import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.Column
-import androidx.compose.foundation.layout.Spacer
-import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.height
-import androidx.compose.foundation.layout.padding
+import androidx.compose.material3.AlertDialog
+import androidx.compose.material3.TextButton
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.input.key.onKeyEvent
-import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
-import androidx.compose.ui.unit.dp
-import androidx.compose.material3.CircularProgressIndicator
-import androidx.compose.material3.TextButton
-import androidx.compose.material3.AlertDialog
-import androidx.tv.material3.MaterialTheme
import androidx.tv.material3.Text
import com.streamvault.app.R
-import com.streamvault.app.ui.components.dialogs.PinDialog
import com.streamvault.app.ui.theme.OnSurface
-import com.streamvault.app.ui.theme.OnSurfaceDim
import com.streamvault.app.ui.theme.Primary
import com.streamvault.app.ui.theme.SurfaceElevated
import com.streamvault.app.ui.theme.TextSecondary
-import com.streamvault.domain.model.CategorySortMode
-import com.streamvault.domain.model.ContentType
-import com.streamvault.domain.model.DecoderMode
-import com.streamvault.domain.model.AppTimeFormat
import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.launch
@Composable
internal fun SettingsScreenDialogs(
@@ -48,661 +19,172 @@ internal fun SettingsScreenDialogs(
viewModel: SettingsViewModel,
context: Context,
scope: CoroutineScope,
- showLiveTvModeDialog: Boolean,
- onShowLiveTvModeDialogChange: (Boolean) -> Unit,
- showLiveTvQuickFilterVisibilityDialog: Boolean,
- onShowLiveTvQuickFilterVisibilityDialogChange: (Boolean) -> Unit,
- showLiveChannelNumberingDialog: Boolean,
- onShowLiveChannelNumberingDialogChange: (Boolean) -> Unit,
- showLiveChannelGroupingDialog: Boolean,
- onShowLiveChannelGroupingDialogChange: (Boolean) -> Unit,
- showGroupedChannelLabelDialog: Boolean,
- onShowGroupedChannelLabelDialogChange: (Boolean) -> Unit,
- showLiveVariantPreferenceDialog: Boolean,
- onShowLiveVariantPreferenceDialogChange: (Boolean) -> Unit,
- showVodViewModeDialog: Boolean,
- onShowVodViewModeDialogChange: (Boolean) -> Unit,
- showGuideDefaultCategoryDialog: Boolean,
- onShowGuideDefaultCategoryDialogChange: (Boolean) -> Unit,
- showPlaybackSpeedDialog: Boolean,
- onShowPlaybackSpeedDialogChange: (Boolean) -> Unit,
- showAudioVideoOffsetDialog: Boolean,
- onShowAudioVideoOffsetDialogChange: (Boolean) -> Unit,
- showDecoderModeDialog: Boolean,
- onShowDecoderModeDialogChange: (Boolean) -> Unit,
- showSurfaceModeDialog: Boolean,
- onShowSurfaceModeDialogChange: (Boolean) -> Unit,
- showTimeshiftDepthDialog: Boolean,
- onShowTimeshiftDepthDialogChange: (Boolean) -> Unit,
- showDefaultStopTimerDialog: Boolean,
- onShowDefaultStopTimerDialogChange: (Boolean) -> Unit,
- showDefaultIdleTimerDialog: Boolean,
- onShowDefaultIdleTimerDialogChange: (Boolean) -> Unit,
- showControlsTimeoutDialog: Boolean,
- onShowControlsTimeoutDialogChange: (Boolean) -> Unit,
- showLiveOverlayTimeoutDialog: Boolean,
- onShowLiveOverlayTimeoutDialogChange: (Boolean) -> Unit,
- showNoticeTimeoutDialog: Boolean,
- onShowNoticeTimeoutDialogChange: (Boolean) -> Unit,
- showDiagnosticsTimeoutDialog: Boolean,
- onShowDiagnosticsTimeoutDialogChange: (Boolean) -> Unit,
- showLiveTvFiltersDialog: Boolean,
- onShowLiveTvFiltersDialogChange: (Boolean) -> Unit,
- showAudioLanguageDialog: Boolean,
- onShowAudioLanguageDialogChange: (Boolean) -> Unit,
- showSubtitleSizeDialog: Boolean,
- onShowSubtitleSizeDialogChange: (Boolean) -> Unit,
- showSubtitleTextColorDialog: Boolean,
- onShowSubtitleTextColorDialogChange: (Boolean) -> Unit,
- showSubtitleBackgroundDialog: Boolean,
- onShowSubtitleBackgroundDialogChange: (Boolean) -> Unit,
- showWifiQualityDialog: Boolean,
- onShowWifiQualityDialogChange: (Boolean) -> Unit,
- showEthernetQualityDialog: Boolean,
- onShowEthernetQualityDialogChange: (Boolean) -> Unit,
- categorySortDialogType: String?,
- onCategorySortDialogTypeChange: (String?) -> Unit,
- showPinDialog: Boolean,
- onShowPinDialogChange: (Boolean) -> Unit,
- showLevelDialog: Boolean,
- onShowLevelDialogChange: (Boolean) -> Unit,
- pinError: String?,
- onPinErrorChange: (String?) -> Unit,
- pendingAction: ParentalAction?,
- onPendingActionChange: (ParentalAction?) -> Unit,
- pendingProtectionLevel: Int?,
- onPendingProtectionLevelChange: (Int?) -> Unit,
- showLanguageDialog: Boolean,
- onShowLanguageDialogChange: (Boolean) -> Unit,
- showTimeFormatDialog: Boolean,
- onShowTimeFormatDialogChange: (Boolean) -> Unit,
- showRecordingPatternDialog: Boolean,
- onShowRecordingPatternDialogChange: (Boolean) -> Unit,
- showRecordingRetentionDialog: Boolean,
- onShowRecordingRetentionDialogChange: (Boolean) -> Unit,
- showRecordingConcurrencyDialog: Boolean,
- onShowRecordingConcurrencyDialogChange: (Boolean) -> Unit,
- showRecordingPaddingDialog: Boolean,
- onShowRecordingPaddingDialogChange: (Boolean) -> Unit,
- showClearHistoryDialog: Boolean,
- onShowClearHistoryDialogChange: (Boolean) -> Unit,
- showCreateCombinedDialog: Boolean,
- onShowCreateCombinedDialogChange: (Boolean) -> Unit,
- showAddCombinedMemberDialog: Boolean,
- onShowAddCombinedMemberDialogChange: (Boolean) -> Unit,
- showRenameCombinedDialog: Boolean,
- onShowRenameCombinedDialogChange: (Boolean) -> Unit,
- selectedCombinedProfileId: Long?,
- showProviderSyncDialog: Boolean,
- onShowProviderSyncDialogChange: (Boolean) -> Unit,
- showCustomProviderSyncDialog: Boolean,
- onShowCustomProviderSyncDialogChange: (Boolean) -> Unit,
- pendingSyncProviderId: Long?,
- onPendingSyncProviderIdChange: (Long?) -> Unit,
- customSyncSelections: Set<ProviderSyncSelection>,
- onCustomSyncSelectionsChange: (Set<ProviderSyncSelection>) -> Unit
+ dialogState: SettingsScreenDialogState
) {
+ val providerState = rememberSettingsProviderSectionState(dialogState)
+
SyncingOverlay(
isSyncing = uiState.isSyncing,
providerName = uiState.syncingProviderName,
progress = uiState.syncProgress
)
- if (showLiveTvModeDialog) {
+ if (dialogState.showLiveTvModeDialog) {
LiveTvChannelModeDialog(
selectedMode = uiState.liveTvChannelMode,
- onDismiss = { onShowLiveTvModeDialogChange(false) },
+ onDismiss = { dialogState.showLiveTvModeDialog = false },
onModeSelected = { mode ->
viewModel.setLiveTvChannelMode(mode)
- onShowLiveTvModeDialogChange(false)
+ dialogState.showLiveTvModeDialog = false
}
)
}
- if (showLiveTvQuickFilterVisibilityDialog) {
+ if (dialogState.showLiveTvQuickFilterVisibilityDialog) {
LiveTvQuickFilterVisibilityDialog(
selectedMode = uiState.liveTvQuickFilterVisibilityMode,
- onDismiss = { onShowLiveTvQuickFilterVisibilityDialogChange(false) },
+ onDismiss = { dialogState.showLiveTvQuickFilterVisibilityDialog = false },
onModeSelected = { mode ->
viewModel.setLiveTvQuickFilterVisibilityMode(mode)
- onShowLiveTvQuickFilterVisibilityDialogChange(false)
+ dialogState.showLiveTvQuickFilterVisibilityDialog = false
}
)
}
- if (showLiveChannelNumberingDialog) {
+ if (dialogState.showLiveChannelNumberingDialog) {
LiveChannelNumberingModeDialog(
selectedMode = uiState.liveChannelNumberingMode,
- onDismiss = { onShowLiveChannelNumberingDialogChange(false) },
+ onDismiss = { dialogState.showLiveChannelNumberingDialog = false },
onModeSelected = { mode ->
viewModel.setLiveChannelNumberingMode(mode)
- onShowLiveChannelNumberingDialogChange(false)
+ dialogState.showLiveChannelNumberingDialog = false
}
)
}
- if (showLiveChannelGroupingDialog) {
+ if (dialogState.showLiveChannelGroupingDialog) {
LiveChannelGroupingModeDialog(
selectedMode = uiState.liveChannelGroupingMode,
- onDismiss = { onShowLiveChannelGroupingDialogChange(false) },
+ onDismiss = { dialogState.showLiveChannelGroupingDialog = false },
onModeSelected = { mode ->
viewModel.setLiveChannelGroupingMode(mode)
- onShowLiveChannelGroupingDialogChange(false)
+ dialogState.showLiveChannelGroupingDialog = false
}
)
}
- if (showGroupedChannelLabelDialog) {
+ if (dialogState.showGroupedChannelLabelDialog) {
GroupedChannelLabelModeDialog(
selectedMode = uiState.groupedChannelLabelMode,
- onDismiss = { onShowGroupedChannelLabelDialogChange(false) },
+ onDismiss = { dialogState.showGroupedChannelLabelDialog = false },
onModeSelected = { mode ->
viewModel.setGroupedChannelLabelMode(mode)
- onShowGroupedChannelLabelDialogChange(false)
+ dialogState.showGroupedChannelLabelDialog = false
}
)
}
- if (showLiveVariantPreferenceDialog) {
+ if (dialogState.showLiveVariantPreferenceDialog) {
LiveVariantPreferenceModeDialog(
selectedMode = uiState.liveVariantPreferenceMode,
- onDismiss = { onShowLiveVariantPreferenceDialogChange(false) },
+ onDismiss = { dialogState.showLiveVariantPreferenceDialog = false },
onModeSelected = { mode ->
viewModel.setLiveVariantPreferenceMode(mode)
- onShowLiveVariantPreferenceDialogChange(false)
+ dialogState.showLiveVariantPreferenceDialog = false
}
)
}
- if (showVodViewModeDialog) {
+ if (dialogState.showVodViewModeDialog) {
VodViewModeDialog(
selectedMode = uiState.vodViewMode,
- onDismiss = { onShowVodViewModeDialogChange(false) },
+ onDismiss = { dialogState.showVodViewModeDialog = false },
onModeSelected = { mode ->
viewModel.setVodViewMode(mode)
- onShowVodViewModeDialogChange(false)
- }
- )
- }
-
- if (showGuideDefaultCategoryDialog) {
- PremiumSelectionDialog(
- title = stringResource(R.string.settings_select_guide_default_category),
- onDismiss = { onShowGuideDefaultCategoryDialogChange(false) }
- ) {
- uiState.guideDefaultCategoryOptions.forEachIndexed { index, category ->
- LevelOption(
- level = index,
- text = category.name,
- currentLevel = if (uiState.guideDefaultCategoryId == category.id) index else -1,
- onSelect = {
- viewModel.setGuideDefaultCategory(category.id)
- onShowGuideDefaultCategoryDialogChange(false)
- }
- )
- }
- }
- }
-
- if (showPlaybackSpeedDialog) {
- val speedOptions = remember { listOf(0.5f, 0.75f, 1f, 1.25f, 1.5f, 2f) }
- PremiumSelectionDialog(
- title = stringResource(R.string.settings_select_playback_speed),
- onDismiss = { onShowPlaybackSpeedDialogChange(false) }
- ) {
- speedOptions.forEachIndexed { index, speed ->
- LevelOption(
- level = index,
- text = formatPlaybackSpeedLabel(speed),
- currentLevel = if (speed == uiState.playerPlaybackSpeed) index else -1,
- onSelect = {
- viewModel.setDefaultPlaybackSpeed(speed)
- onShowPlaybackSpeedDialogChange(false)
- }
- )
- }
- }
- }
-
- if (showTimeFormatDialog) {
- PremiumSelectionDialog(
- title = stringResource(R.string.settings_select_time_format),
- onDismiss = { onShowTimeFormatDialogChange(false) }
- ) {
- AppTimeFormat.entries.forEachIndexed { index, format ->
- LevelOption(
- level = index,
- text = context.getString(format.labelResId()),
- currentLevel = if (uiState.appTimeFormat == format) index else -1,
- onSelect = {
- viewModel.setAppTimeFormat(format)
- onShowTimeFormatDialogChange(false)
- }
- )
- }
- }
- }
-
- if (showAudioVideoOffsetDialog) {
- AudioVideoOffsetValueDialog(
- title = stringResource(R.string.settings_audio_video_sync_default),
- subtitle = stringResource(R.string.settings_audio_video_sync_default_subtitle),
- initialValue = uiState.playerAudioVideoOffsetMs,
- onDismiss = { onShowAudioVideoOffsetDialogChange(false) },
- onConfirm = { offsetMs ->
- viewModel.setPlayerAudioVideoOffsetMs(offsetMs)
- onShowAudioVideoOffsetDialogChange(false)
- }
- )
- }
-
- if (showDecoderModeDialog) {
- val decoderOptions = remember(context) {
- listOf(
- DecoderMode.AUTO to context.getString(R.string.settings_decoder_auto),
- DecoderMode.HARDWARE to context.getString(R.string.settings_decoder_hardware),
- DecoderMode.SOFTWARE to context.getString(R.string.settings_decoder_software),
- DecoderMode.COMPATIBILITY to context.getString(R.string.settings_decoder_compatibility)
- )
- }
- PremiumSelectionDialog(
- title = stringResource(R.string.settings_select_decoder_mode),
- onDismiss = { onShowDecoderModeDialogChange(false) }
- ) {
- decoderOptions.forEachIndexed { index, option ->
- LevelOption(
- level = index,
- text = option.second,
- currentLevel = if (uiState.playerDecoderMode == option.first) index else -1,
- onSelect = {
- viewModel.setPlayerDecoderMode(option.first)
- onShowDecoderModeDialogChange(false)
- }
- )
- }
- }
- }
-
- if (showSurfaceModeDialog) {
- val surfaceOptions = remember(context) {
- listOf(
- com.streamvault.domain.model.PlayerSurfaceMode.AUTO to context.getString(R.string.settings_surface_auto),
- com.streamvault.domain.model.PlayerSurfaceMode.SURFACE_VIEW to context.getString(R.string.settings_surface_surface_view),
- com.streamvault.domain.model.PlayerSurfaceMode.TEXTURE_VIEW to context.getString(R.string.settings_surface_texture_view)
- )
- }
- PremiumSelectionDialog(
- title = stringResource(R.string.settings_surface_mode),
- onDismiss = { onShowSurfaceModeDialogChange(false) }
- ) {
- surfaceOptions.forEachIndexed { index, option ->
- LevelOption(
- level = index,
- text = option.second,
- currentLevel = if (uiState.playerSurfaceMode == option.first) index else -1,
- onSelect = {
- viewModel.setPlayerSurfaceMode(option.first)
- onShowSurfaceModeDialogChange(false)
- }
- )
- }
- }
- }
-
- if (showControlsTimeoutDialog) {
- TimeoutValueDialog(
- title = stringResource(R.string.settings_player_controls_timeout),
- subtitle = stringResource(R.string.settings_timeout_vod_controls_subtitle),
- initialValue = uiState.playerControlsTimeoutSeconds,
- onDismiss = { onShowControlsTimeoutDialogChange(false) }
- ) { seconds ->
- viewModel.setPlayerControlsTimeoutSeconds(seconds)
- onShowControlsTimeoutDialogChange(false)
- }
- }
-
- if (showLiveOverlayTimeoutDialog) {
- TimeoutValueDialog(
- title = stringResource(R.string.settings_live_overlay_timeout),
- subtitle = stringResource(R.string.settings_timeout_live_overlays_subtitle),
- initialValue = uiState.playerLiveOverlayTimeoutSeconds,
- onDismiss = { onShowLiveOverlayTimeoutDialogChange(false) }
- ) { seconds ->
- viewModel.setPlayerLiveOverlayTimeoutSeconds(seconds)
- onShowLiveOverlayTimeoutDialogChange(false)
- }
- }
-
- if (showNoticeTimeoutDialog) {
- TimeoutValueDialog(
- title = stringResource(R.string.settings_player_notice_timeout),
- subtitle = stringResource(R.string.settings_timeout_notices_subtitle),
- initialValue = uiState.playerNoticeTimeoutSeconds,
- onDismiss = { onShowNoticeTimeoutDialogChange(false) }
- ) { seconds ->
- viewModel.setPlayerNoticeTimeoutSeconds(seconds)
- onShowNoticeTimeoutDialogChange(false)
- }
- }
-
- if (showDiagnosticsTimeoutDialog) {
- TimeoutValueDialog(
- title = stringResource(R.string.settings_player_diagnostics_timeout),
- subtitle = stringResource(R.string.settings_timeout_diagnostics_subtitle),
- initialValue = uiState.playerDiagnosticsTimeoutSeconds,
- onDismiss = { onShowDiagnosticsTimeoutDialogChange(false) }
- ) { seconds ->
- viewModel.setPlayerDiagnosticsTimeoutSeconds(seconds)
- onShowDiagnosticsTimeoutDialogChange(false)
- }
- }
-
- if (showTimeshiftDepthDialog) {
- val depthOptions = remember(context) {
- listOf(
- 15 to context.getString(R.string.settings_live_timeshift_depth_15),
- 30 to context.getString(R.string.settings_live_timeshift_depth_30),
- 60 to context.getString(R.string.settings_live_timeshift_depth_60)
- )
- }
- PremiumSelectionDialog(
- title = stringResource(R.string.settings_select_live_timeshift_depth),
- onDismiss = { onShowTimeshiftDepthDialogChange(false) }
- ) {
- depthOptions.forEachIndexed { index, option ->
- LevelOption(
- level = index,
- text = option.second,
- currentLevel = if (uiState.playerTimeshiftDepthMinutes == option.first) index else -1,
- onSelect = {
- viewModel.setPlayerTimeshiftDepthMinutes(option.first)
- onShowTimeshiftDepthDialogChange(false)
- }
- )
- }
- }
- }
-
- if (showDefaultStopTimerDialog) {
- PlaybackTimerPresetDialog(
- title = stringResource(R.string.settings_default_stop_timer),
- selectedMinutes = uiState.defaultStopPlaybackTimerMinutes,
- onDismiss = { onShowDefaultStopTimerDialogChange(false) },
- onSelect = { minutes ->
- viewModel.setDefaultStopPlaybackTimerMinutes(minutes)
- onShowDefaultStopTimerDialogChange(false)
- }
- )
- }
-
- if (showDefaultIdleTimerDialog) {
- PlaybackTimerPresetDialog(
- title = stringResource(R.string.settings_default_idle_standby_timer),
- selectedMinutes = uiState.defaultIdleStandbyTimerMinutes,
- onDismiss = { onShowDefaultIdleTimerDialogChange(false) },
- onSelect = { minutes ->
- viewModel.setDefaultIdleStandbyTimerMinutes(minutes)
- onShowDefaultIdleTimerDialogChange(false)
- }
- )
- }
-
- if (showLiveTvFiltersDialog) {
- LiveTvQuickFiltersDialog(
- filters = uiState.liveTvCategoryFilters,
- onDismiss = { onShowLiveTvFiltersDialogChange(false) },
- onAddFilter = viewModel::addLiveTvCategoryFilter,
- onRemoveFilter = viewModel::removeLiveTvCategoryFilter
- )
- }
-
- if (showAudioLanguageDialog) {
- val autoLabel = stringResource(R.string.settings_audio_language_auto)
- val audioLanguageOptions = remember(autoLabel) { supportedAudioLanguages(autoLabel) }
- PremiumSelectionDialog(
- title = stringResource(R.string.settings_select_audio_language),
- onDismiss = { onShowAudioLanguageDialogChange(false) }
- ) {
- audioLanguageOptions.forEachIndexed { index, option ->
- LevelOption(
- level = index,
- text = option.label,
- currentLevel = if (uiState.preferredAudioLanguage == option.tag) index else -1,
- onSelect = {
- viewModel.setPreferredAudioLanguage(option.tag)
- onShowAudioLanguageDialogChange(false)
- }
- )
- }
- }
- }
-
- if (showSubtitleSizeDialog) {
- val subtitleSizeOptions = remember { subtitleSizeOptions() }
- PremiumSelectionDialog(
- title = stringResource(R.string.settings_select_subtitle_size),
- onDismiss = { onShowSubtitleSizeDialogChange(false) }
- ) {
- subtitleSizeOptions.forEachIndexed { index, option ->
- LevelOption(
- level = index,
- text = option.label(context),
- currentLevel = if (uiState.subtitleTextScale == option.scale) index else -1,
- onSelect = {
- viewModel.setSubtitleTextScale(option.scale)
- onShowSubtitleSizeDialogChange(false)
- }
- )
- }
- }
- }
-
- if (showSubtitleTextColorDialog) {
- val options = remember(context) { subtitleTextColorOptions(context) }
- PremiumSelectionDialog(
- title = stringResource(R.string.settings_select_subtitle_text_color),
- onDismiss = { onShowSubtitleTextColorDialogChange(false) }
- ) {
- options.forEachIndexed { index, option ->
- LevelOption(
- level = index,
- text = option.label,
- currentLevel = if (uiState.subtitleTextColor == option.colorArgb) index else -1,
- onSelect = {
- viewModel.setSubtitleTextColor(option.colorArgb)
- onShowSubtitleTextColorDialogChange(false)
- }
- )
- }
- }
- }
-
- if (showSubtitleBackgroundDialog) {
- val options = remember(context) { subtitleBackgroundColorOptions(context) }
- PremiumSelectionDialog(
- title = stringResource(R.string.settings_select_subtitle_background),
- onDismiss = { onShowSubtitleBackgroundDialogChange(false) }
- ) {
- options.forEachIndexed { index, option ->
- LevelOption(
- level = index,
- text = option.label,
- currentLevel = if (uiState.subtitleBackgroundColor == option.colorArgb) index else -1,
- onSelect = {
- viewModel.setSubtitleBackgroundColor(option.colorArgb)
- onShowSubtitleBackgroundDialogChange(false)
- }
- )
- }
- }
- }
-
- if (showWifiQualityDialog) {
- QualityCapSelectionDialog(
- title = stringResource(R.string.settings_select_wifi_quality_cap),
- currentValue = uiState.wifiMaxVideoHeight,
- onDismiss = { onShowWifiQualityDialogChange(false) },
- onSelect = {
- viewModel.setWifiQualityCap(it)
- onShowWifiQualityDialogChange(false)
- }
- )
- }
-
- if (showEthernetQualityDialog) {
- QualityCapSelectionDialog(
- title = stringResource(R.string.settings_select_ethernet_quality_cap),
- currentValue = uiState.ethernetMaxVideoHeight,
- onDismiss = { onShowEthernetQualityDialogChange(false) },
- onSelect = {
- viewModel.setEthernetQualityCap(it)
- onShowEthernetQualityDialogChange(false)
- }
- )
- }
-
- categorySortDialogType?.let { typeName ->
- val type = ContentType.entries.firstOrNull { it.name == typeName }
- if (type != null) {
- CategorySortModeDialog(
- type = type,
- currentMode = uiState.categorySortModes[type] ?: CategorySortMode.DEFAULT,
- onDismiss = { onCategorySortDialogTypeChange(null) },
- onModeSelected = { mode ->
- viewModel.setCategorySortMode(type, mode)
- onCategorySortDialogTypeChange(null)
- }
- )
- }
- }
-
- if (showPinDialog) {
- PinDialog(
- onDismissRequest = {
- onShowPinDialogChange(false)
- onPinErrorChange(null)
- if (pendingAction == ParentalAction.SetNewPin) {
- onPendingActionChange(null)
- onPendingProtectionLevelChange(null)
- }
- },
- onPinEntered = { pin ->
- scope.launch {
- if (pendingAction == ParentalAction.SetNewPin) {
- viewModel.changePin(pin)
- pendingProtectionLevel?.let(viewModel::setParentalControlLevel)
- onPendingProtectionLevelChange(null)
- onShowPinDialogChange(false)
- onPendingActionChange(null)
- } else {
- if (viewModel.verifyPin(pin)) {
- onShowPinDialogChange(false)
- onPinErrorChange(null)
- when (pendingAction) {
- ParentalAction.ChangeLevel -> onShowLevelDialogChange(true)
- ParentalAction.ChangePin -> {
- onPendingActionChange(ParentalAction.SetNewPin)
- onShowPinDialogChange(true)
- }
- else -> onPendingActionChange(null)
- }
- } else {
- onPinErrorChange(context.getString(R.string.home_incorrect_pin))
- }
- }
- }
- },
- title = if (pendingAction == ParentalAction.SetNewPin) {
- stringResource(R.string.settings_enter_new_pin)
- } else {
- stringResource(R.string.settings_enter_pin)
- },
- error = pinError
- )
- }
+ dialogState.showVodViewModeDialog = false
+ }
+ )
+ }
+
+ SettingsPreferenceDialogs(
+ uiState = uiState,
+ viewModel = viewModel,
+ context = context,
+ showGuideDefaultCategoryDialog = dialogState.showGuideDefaultCategoryDialog,
+ onShowGuideDefaultCategoryDialogChange = { dialogState.showGuideDefaultCategoryDialog = it },
+ showPlaybackSpeedDialog = dialogState.showPlaybackSpeedDialog,
+ onShowPlaybackSpeedDialogChange = { dialogState.showPlaybackSpeedDialog = it },
+ showTimeFormatDialog = dialogState.showTimeFormatDialog,
+ onShowTimeFormatDialogChange = { dialogState.showTimeFormatDialog = it },
+ showAudioVideoOffsetDialog = dialogState.showAudioVideoOffsetDialog,
+ onShowAudioVideoOffsetDialogChange = { dialogState.showAudioVideoOffsetDialog = it },
+ showDecoderModeDialog = dialogState.showDecoderModeDialog,
+ onShowDecoderModeDialogChange = { dialogState.showDecoderModeDialog = it },
+ showSurfaceModeDialog = dialogState.showSurfaceModeDialog,
+ onShowSurfaceModeDialogChange = { dialogState.showSurfaceModeDialog = it },
+ showTimeshiftDepthDialog = dialogState.showTimeshiftDepthDialog,
+ onShowTimeshiftDepthDialogChange = { dialogState.showTimeshiftDepthDialog = it },
+ showDefaultStopTimerDialog = dialogState.showDefaultStopTimerDialog,
+ onShowDefaultStopTimerDialogChange = { dialogState.showDefaultStopTimerDialog = it },
+ showDefaultIdleTimerDialog = dialogState.showDefaultIdleTimerDialog,
+ onShowDefaultIdleTimerDialogChange = { dialogState.showDefaultIdleTimerDialog = it },
+ showControlsTimeoutDialog = dialogState.showControlsTimeoutDialog,
+ onShowControlsTimeoutDialogChange = { dialogState.showControlsTimeoutDialog = it },
+ showLiveOverlayTimeoutDialog = dialogState.showLiveOverlayTimeoutDialog,
+ onShowLiveOverlayTimeoutDialogChange = { dialogState.showLiveOverlayTimeoutDialog = it },
+ showNoticeTimeoutDialog = dialogState.showNoticeTimeoutDialog,
+ onShowNoticeTimeoutDialogChange = { dialogState.showNoticeTimeoutDialog = it },
+ showDiagnosticsTimeoutDialog = dialogState.showDiagnosticsTimeoutDialog,
+ onShowDiagnosticsTimeoutDialogChange = { dialogState.showDiagnosticsTimeoutDialog = it },
+ showLiveTvFiltersDialog = dialogState.showLiveTvFiltersDialog,
+ onShowLiveTvFiltersDialogChange = { dialogState.showLiveTvFiltersDialog = it },
+ showAudioLanguageDialog = dialogState.showAudioLanguageDialog,
+ onShowAudioLanguageDialogChange = { dialogState.showAudioLanguageDialog = it },
+ showSubtitleSizeDialog = dialogState.showSubtitleSizeDialog,
+ onShowSubtitleSizeDialogChange = { dialogState.showSubtitleSizeDialog = it },
+ showSubtitleTextColorDialog = dialogState.showSubtitleTextColorDialog,
+ onShowSubtitleTextColorDialogChange = { dialogState.showSubtitleTextColorDialog = it },
+ showSubtitleBackgroundDialog = dialogState.showSubtitleBackgroundDialog,
+ onShowSubtitleBackgroundDialogChange = { dialogState.showSubtitleBackgroundDialog = it },
+ showWifiQualityDialog = dialogState.showWifiQualityDialog,
+ onShowWifiQualityDialogChange = { dialogState.showWifiQualityDialog = it },
+ showEthernetQualityDialog = dialogState.showEthernetQualityDialog,
+ onShowEthernetQualityDialogChange = { dialogState.showEthernetQualityDialog = it },
+ showLanguageDialog = dialogState.showLanguageDialog,
+ onShowLanguageDialogChange = { dialogState.showLanguageDialog = it },
+ categorySortDialogType = dialogState.categorySortDialogType,
+ onCategorySortDialogTypeChange = { dialogState.categorySortDialogType = it }
+ )
- if (showLevelDialog) {
- PremiumSelectionDialog(
- title = stringResource(R.string.settings_select_level),
- onDismiss = { onShowLevelDialogChange(false) }
- ) {
- LevelOption(
- level = 0,
- text = stringResource(R.string.settings_level_off_desc),
- subtitle = stringResource(R.string.settings_level_off_subtitle),
- currentLevel = uiState.parentalControlLevel
- ) {
- viewModel.setParentalControlLevel(0)
- onShowLevelDialogChange(false)
- }
- LevelOption(
- level = 1,
- text = stringResource(R.string.settings_level_locked_desc),
- subtitle = stringResource(R.string.settings_level_locked_subtitle),
- currentLevel = uiState.parentalControlLevel
- ) {
- if (uiState.hasParentalPin) {
- viewModel.setParentalControlLevel(1)
- } else {
- onPendingProtectionLevelChange(1)
- onPendingActionChange(ParentalAction.SetNewPin)
- onShowPinDialogChange(true)
- }
- onShowLevelDialogChange(false)
- }
- LevelOption(
- level = 2,
- text = stringResource(R.string.settings_level_private_desc),
- subtitle = stringResource(R.string.settings_level_private_subtitle),
- currentLevel = uiState.parentalControlLevel
- ) {
- if (uiState.hasParentalPin) {
- viewModel.setParentalControlLevel(2)
- } else {
- onPendingProtectionLevelChange(2)
- onPendingActionChange(ParentalAction.SetNewPin)
- onShowPinDialogChange(true)
- }
- onShowLevelDialogChange(false)
- }
- LevelOption(
- level = 3,
- text = stringResource(R.string.settings_level_hidden_desc),
- subtitle = stringResource(R.string.settings_level_hidden_subtitle),
- currentLevel = uiState.parentalControlLevel
- ) {
- if (uiState.hasParentalPin) {
- viewModel.setParentalControlLevel(3)
- } else {
- onPendingProtectionLevelChange(3)
- onPendingActionChange(ParentalAction.SetNewPin)
- onShowPinDialogChange(true)
- }
- onShowLevelDialogChange(false)
- }
- }
- }
+ SettingsProtectionDialogs(
+ uiState = uiState,
+ viewModel = viewModel,
+ context = context,
+ scope = scope,
+ showPinDialog = dialogState.showPinDialog,
+ onShowPinDialogChange = { dialogState.showPinDialog = it },
+ showLevelDialog = dialogState.showLevelDialog,
+ onShowLevelDialogChange = { dialogState.showLevelDialog = it },
+ pinError = dialogState.pinError,
+ onPinErrorChange = { dialogState.pinError = it },
+ pendingAction = dialogState.pendingAction,
+ onPendingActionChange = { dialogState.pendingAction = it },
+ pendingProtectionLevel = dialogState.pendingProtectionLevel,
+ onPendingProtectionLevelChange = { dialogState.pendingProtectionLevel = it }
+ )
- if (showLanguageDialog) {
- val systemDefaultLabel = stringResource(R.string.settings_system_default)
- val languageOptions = remember(systemDefaultLabel) { supportedAppLanguages(systemDefaultLabel) }
- PremiumSelectionDialog(
- title = stringResource(R.string.settings_select_language),
- onDismiss = { onShowLanguageDialogChange(false) }
- ) {
- languageOptions.forEachIndexed { index, option ->
- LevelOption(
- level = index,
- text = option.label,
- currentLevel = if (uiState.appLanguage == option.tag) index else -1,
- onSelect = {
- viewModel.setAppLanguage(option.tag)
- onShowLanguageDialogChange(false)
- }
- )
- }
- }
- }
+ SettingsRecordingDialogs(
+ uiState = uiState,
+ viewModel = viewModel,
+ showRecordingPatternDialog = dialogState.showRecordingPatternDialog,
+ onShowRecordingPatternDialogChange = { dialogState.showRecordingPatternDialog = it },
+ showRecordingRetentionDialog = dialogState.showRecordingRetentionDialog,
+ onShowRecordingRetentionDialogChange = { dialogState.showRecordingRetentionDialog = it },
+ showRecordingConcurrencyDialog = dialogState.showRecordingConcurrencyDialog,
+ onShowRecordingConcurrencyDialogChange = { dialogState.showRecordingConcurrencyDialog = it },
+ showRecordingPaddingDialog = dialogState.showRecordingPaddingDialog,
+ onShowRecordingPaddingDialogChange = { dialogState.showRecordingPaddingDialog = it }
+ )
val backupPreview = uiState.backupPreview
if (backupPreview != null && uiState.pendingBackupUri != null) {
@@ -721,115 +203,9 @@ internal fun SettingsScreenDialogs(
)
}
- if (showRecordingPatternDialog) {
- SimpleTextValueDialog(
- title = stringResource(R.string.settings_recording_pattern_title),
- subtitle = stringResource(R.string.settings_recording_pattern_hint),
- initialValue = uiState.recordingStorageState.fileNamePattern,
- onDismiss = { onShowRecordingPatternDialogChange(false) },
- onConfirm = { pattern ->
- viewModel.updateRecordingFileNamePattern(pattern)
- onShowRecordingPatternDialogChange(false)
- }
- )
- }
-
- if (showRecordingRetentionDialog) {
- val retentionOptions = listOf<Int?>(null, 7, 14, 30, 60, 90)
- PremiumSelectionDialog(
- title = stringResource(R.string.settings_recording_retention_title),
- onDismiss = { onShowRecordingRetentionDialogChange(false) }
- ) {
- retentionOptions.forEachIndexed { index, days ->
- LevelOption(
- level = index,
- text = if (days == null) {
- stringResource(R.string.settings_recording_retention_keep_all)
- } else {
- stringResource(R.string.settings_recording_retention_days, days)
- },
- currentLevel = if (days == uiState.recordingStorageState.retentionDays) index else -1,
- onSelect = {
- viewModel.updateRecordingRetentionDays(days)
- onShowRecordingRetentionDialogChange(false)
- }
- )
- }
- }
- }
-
- if (showRecordingConcurrencyDialog) {
- PremiumSelectionDialog(
- title = stringResource(R.string.settings_recording_concurrency_title),
- onDismiss = { onShowRecordingConcurrencyDialogChange(false) }
- ) {
- (1..4).forEach { value ->
- LevelOption(
- level = value,
- text = value.toString(),
- currentLevel = if (value == uiState.recordingStorageState.maxSimultaneousRecordings) value else -1,
- onSelect = {
- viewModel.updateRecordingMaxSimultaneous(value)
- onShowRecordingConcurrencyDialogChange(false)
- }
- )
- }
- }
- }
-
- if (showRecordingPaddingDialog) {
- val paddingOptions = listOf(0, 1, 2, 3, 5, 10, 15, 30)
- PremiumSelectionDialog(
- title = stringResource(R.string.settings_recording_padding_title),
- onDismiss = { onShowRecordingPaddingDialogChange(false) }
- ) {
- Text(
- text = stringResource(R.string.settings_recording_padding_before),
- style = MaterialTheme.typography.labelMedium,
- color = OnSurfaceDim,
- modifier = Modifier.padding(bottom = 4.dp)
- )
- paddingOptions.forEach { minutes ->
- LevelOption(
- level = minutes,
- text = if (minutes == 0) {
- stringResource(R.string.settings_recording_padding_none)
- } else {
- stringResource(R.string.settings_recording_padding_minutes, minutes)
- },
- currentLevel = uiState.recordingPaddingBeforeMinutes,
- onSelect = {
- viewModel.setRecordingPaddingBeforeMinutes(minutes)
- }
- )
- }
- Spacer(modifier = Modifier.height(12.dp))
- Text(
- text = stringResource(R.string.settings_recording_padding_after),
- style = MaterialTheme.typography.labelMedium,
- color = OnSurfaceDim,
- modifier = Modifier.padding(bottom = 4.dp)
- )
- paddingOptions.forEach { minutes ->
- LevelOption(
- level = minutes,
- text = if (minutes == 0) {
- stringResource(R.string.settings_recording_padding_none)
- } else {
- stringResource(R.string.settings_recording_padding_minutes, minutes)
- },
- currentLevel = uiState.recordingPaddingAfterMinutes,
- onSelect = {
- viewModel.setRecordingPaddingAfterMinutes(minutes)
- }
- )
- }
- }
- }
-
- if (showClearHistoryDialog) {
+ if (dialogState.showClearHistoryDialog) {
AlertDialog(
- onDismissRequest = { onShowClearHistoryDialogChange(false) },
+ onDismissRequest = { dialogState.showClearHistoryDialog = false },
title = { Text(text = stringResource(R.string.settings_clear_history_dialog_title)) },
text = {
Text(
@@ -841,14 +217,14 @@ internal fun SettingsScreenDialogs(
TextButton(
onClick = {
viewModel.clearHistory()
- onShowClearHistoryDialogChange(false)
+ dialogState.showClearHistoryDialog = false
}
) {
Text(text = stringResource(R.string.settings_clear_history_confirm), color = Primary)
}
},
dismissButton = {
- TextButton(onClick = { onShowClearHistoryDialogChange(false) }) {
+ TextButton(onClick = { dialogState.showClearHistoryDialog = false }) {
Text(text = stringResource(R.string.settings_cancel), color = OnSurface)
}
},
@@ -858,141 +234,9 @@ internal fun SettingsScreenDialogs(
)
}
- val pendingSyncProvider = pendingSyncProviderId?.let { providerId ->
- uiState.providers.firstOrNull { it.id == providerId }
- }
- if (showCreateCombinedDialog) {
- CreateCombinedM3uDialog(
- providers = uiState.availableM3uProviders,
- onDismiss = { onShowCreateCombinedDialogChange(false) },
- onCreate = { name, providerIds ->
- onShowCreateCombinedDialogChange(false)
- viewModel.createCombinedProfile(name, providerIds)
- }
- )
- }
- if (showRenameCombinedDialog) {
- val selectedProfile = uiState.combinedProfiles.firstOrNull { it.id == selectedCombinedProfileId }
- if (selectedProfile != null) {
- RenameCombinedM3uDialog(
- profile = selectedProfile,
- onDismiss = { onShowRenameCombinedDialogChange(false) },
- onRename = { name ->
- onShowRenameCombinedDialogChange(false)
- viewModel.renameCombinedProfile(selectedProfile.id, name)
- }
- )
- }
- }
- if (showAddCombinedMemberDialog) {
- val selectedProfile = uiState.combinedProfiles.firstOrNull { it.id == selectedCombinedProfileId }
- if (selectedProfile != null) {
- AddCombinedProviderDialog(
- profile = selectedProfile,
- availableProviders = uiState.availableM3uProviders,
- onDismiss = { onShowAddCombinedMemberDialogChange(false) },
- onAddProvider = { providerId ->
- onShowAddCombinedMemberDialogChange(false)
- viewModel.addProviderToCombinedProfile(selectedProfile.id, providerId)
- }
- )
- }
- }
- if (showProviderSyncDialog && pendingSyncProvider != null) {
- ProviderSyncOptionsDialog(
- provider = pendingSyncProvider,
- onDismiss = {
- onShowProviderSyncDialogChange(false)
- onPendingSyncProviderIdChange(null)
- },
- onSelect = { selection ->
- onShowProviderSyncDialogChange(false)
- if (selection == null) {
- onShowCustomProviderSyncDialogChange(true)
- } else {
- viewModel.syncProviderSection(pendingSyncProvider.id, selection)
- onPendingSyncProviderIdChange(null)
- }
- }
- )
- }
- if (showCustomProviderSyncDialog && pendingSyncProvider != null) {
- ProviderCustomSyncDialog(
- provider = pendingSyncProvider,
- selected = customSyncSelections,
- onToggle = { option ->
- onCustomSyncSelectionsChange(
- if (option in customSyncSelections) {
- customSyncSelections - option
- } else {
- customSyncSelections + option
- }
- )
- },
- onDismiss = {
- onShowCustomProviderSyncDialogChange(false)
- onPendingSyncProviderIdChange(null)
- },
- onConfirm = {
- onShowCustomProviderSyncDialogChange(false)
- viewModel.syncProviderCustom(pendingSyncProvider.id, customSyncSelections)
- onPendingSyncProviderIdChange(null)
- }
- )
- }
-}
-
-private fun AppTimeFormat.labelResId(): Int = when (this) {
- AppTimeFormat.SYSTEM -> R.string.settings_time_format_system
- AppTimeFormat.TWELVE_HOUR -> R.string.settings_time_format_12h
- AppTimeFormat.TWENTY_FOUR_HOUR -> R.string.settings_time_format_24h
-}
-
-@Composable
-private fun SyncingOverlay(
- isSyncing: Boolean,
- providerName: String? = null,
- progress: String? = null
-) {
- if (!isSyncing) return
-
- BackHandler(enabled = true) {}
-
- val overlayFocusRequester = remember { FocusRequester() }
- LaunchedEffect(Unit) { overlayFocusRequester.requestFocus() }
-
- Box(
- modifier = Modifier
- .fillMaxSize()
- .background(Color.Black.copy(alpha = 0.7f))
- .clickable(enabled = true, onClick = {})
- .focusRequester(overlayFocusRequester)
- .focusable()
- .onKeyEvent { true },
- contentAlignment = Alignment.Center
- ) {
- Column(
- horizontalAlignment = Alignment.CenterHorizontally,
- verticalArrangement = Arrangement.spacedBy(16.dp)
- ) {
- CircularProgressIndicator(color = Primary)
- Text(
- text = stringResource(R.string.settings_syncing_title),
- style = MaterialTheme.typography.titleMedium,
- color = OnSurface
- )
- Text(
- text = providerName ?: stringResource(R.string.settings_syncing_subtitle),
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim
- )
- progress?.let { message ->
- Text(
- text = message,
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim
- )
- }
- }
- }
+ SettingsProviderManagementDialogs(
+ uiState = uiState,
+ viewModel = viewModel,
+ providerState = providerState
+ )
}
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreenOverlays.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreenOverlays.kt
new file mode 100644
index 00000000..f40841d3
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreenOverlays.kt
@@ -0,0 +1,51 @@
+package com.streamvault.app.ui.screens.settings
+
+import android.content.Context
+import androidx.compose.foundation.layout.BoxScope
+import androidx.compose.foundation.layout.padding
+import androidx.compose.material3.SnackbarHost
+import androidx.compose.material3.SnackbarHostState
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.unit.dp
+import kotlinx.coroutines.CoroutineScope
+
+@Composable
+internal fun BoxScope.SettingsScreenOverlays(
+ snackbarHostState: SnackbarHostState,
+ uiState: SettingsUiState,
+ viewModel: SettingsViewModel,
+ context: Context,
+ scope: CoroutineScope,
+ dialogState: SettingsScreenDialogState,
+ mainActivity: com.streamvault.app.MainActivity?,
+ currentRoute: String,
+ modifier: Modifier = Modifier
+) {
+ SnackbarHost(
+ hostState = snackbarHostState,
+ modifier = modifier
+ .align(Alignment.BottomCenter)
+ .padding(bottom = 16.dp)
+ )
+
+ SettingsRecordingBrowserDialog(
+ showRecordingBrowserDialog = dialogState.showRecordingBrowserDialog,
+ uiState = uiState,
+ selectedRecordingId = dialogState.selectedRecordingId,
+ onSelectedRecordingChange = { dialogState.selectedRecordingId = it },
+ onShowRecordingBrowserDialogChange = { dialogState.showRecordingBrowserDialog = it },
+ mainActivity = mainActivity,
+ currentRoute = currentRoute,
+ viewModel = viewModel
+ )
+
+ SettingsScreenDialogs(
+ uiState = uiState,
+ viewModel = viewModel,
+ context = context,
+ scope = scope,
+ dialogState = dialogState
+ )
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreenState.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreenState.kt
new file mode 100644
index 00000000..b9b2bcb4
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreenState.kt
@@ -0,0 +1,207 @@
+package com.streamvault.app.ui.screens.settings
+
+import android.content.Context
+import android.content.ContextWrapper
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.remember
+import com.streamvault.app.MainActivity
+import com.streamvault.app.R
+import com.streamvault.app.ui.time.createDateTimeFormat
+import com.streamvault.app.util.OfficialBuildStatus
+import com.streamvault.domain.model.AppTimeFormat
+
+internal data class SettingsScreenLabels(
+ val buildVerificationLabel: String,
+ val appLanguageLabel: String,
+ val timeFormatLabel: String,
+ val preferredAudioLanguageLabel: String,
+ val playbackSpeedLabel: String,
+ val audioVideoOffsetLabel: String,
+ val decoderModeLabel: String,
+ val surfaceModeLabel: String,
+ val controlsTimeoutLabel: String,
+ val liveOverlayTimeoutLabel: String,
+ val noticeTimeoutLabel: String,
+ val diagnosticsTimeoutLabel: String,
+ val subtitleSizeLabel: String,
+ val subtitleTextColorLabel: String,
+ val subtitleBackgroundLabel: String,
+ val wifiQualityLabel: String,
+ val ethernetQualityLabel: String,
+ val timeshiftDepthLabel: String,
+ val defaultStopTimerLabel: String,
+ val defaultIdleTimerLabel: String,
+ val lastSpeedTestLabel: String,
+ val lastSpeedTestSummary: String,
+ val speedTestRecommendationLabel: String,
+ val protectionSummary: String,
+ val guideDefaultCategoryLabel: String
+)
+
+@Composable
+internal fun rememberSettingsScreenLabels(
+ uiState: SettingsUiState,
+ context: Context,
+ officialBuildStatus: OfficialBuildStatus
+): SettingsScreenLabels {
+ val buildVerificationLabel = remember(officialBuildStatus, context) {
+ formatOfficialBuildStatusLabel(officialBuildStatus, context)
+ }
+ val appLanguageLabel = remember(uiState.appLanguage, context) {
+ displayLanguageLabel(uiState.appLanguage, context.getString(R.string.settings_system_default))
+ }
+ val timeFormatLabel = remember(uiState.appTimeFormat, context) {
+ formatAppTimeFormatLabel(uiState.appTimeFormat, context)
+ }
+ val dateTimeFormat = remember(uiState.appTimeFormat) { uiState.appTimeFormat.createDateTimeFormat() }
+ val preferredAudioLanguageLabel = remember(uiState.preferredAudioLanguage, context) {
+ displayLanguageLabel(uiState.preferredAudioLanguage, context.getString(R.string.settings_audio_language_auto))
+ }
+ val playbackSpeedLabel = remember(uiState.playerPlaybackSpeed) {
+ formatPlaybackSpeedLabel(uiState.playerPlaybackSpeed)
+ }
+ val audioVideoOffsetLabel = remember(uiState.playerAudioVideoOffsetMs) {
+ formatAudioVideoOffsetLabel(uiState.playerAudioVideoOffsetMs)
+ }
+ val decoderModeLabel = remember(uiState.playerDecoderMode, context) {
+ formatDecoderModeLabel(uiState.playerDecoderMode, context)
+ }
+ val surfaceModeLabel = remember(uiState.playerSurfaceMode, context) {
+ formatSurfaceModeLabel(uiState.playerSurfaceMode, context)
+ }
+ val controlsTimeoutLabel = remember(uiState.playerControlsTimeoutSeconds, context) {
+ formatTimeoutSecondsLabel(uiState.playerControlsTimeoutSeconds, context)
+ }
+ val liveOverlayTimeoutLabel = remember(uiState.playerLiveOverlayTimeoutSeconds, context) {
+ formatTimeoutSecondsLabel(uiState.playerLiveOverlayTimeoutSeconds, context)
+ }
+ val noticeTimeoutLabel = remember(uiState.playerNoticeTimeoutSeconds, context) {
+ formatTimeoutSecondsLabel(uiState.playerNoticeTimeoutSeconds, context)
+ }
+ val diagnosticsTimeoutLabel = remember(uiState.playerDiagnosticsTimeoutSeconds, context) {
+ formatTimeoutSecondsLabel(uiState.playerDiagnosticsTimeoutSeconds, context)
+ }
+ val subtitleSizeLabel = remember(uiState.subtitleTextScale, context) {
+ formatSubtitleSizeLabel(uiState.subtitleTextScale, context)
+ }
+ val subtitleTextColorLabel = remember(uiState.subtitleTextColor, context) {
+ formatSubtitleColorLabel(uiState.subtitleTextColor, subtitleTextColorOptions(context))
+ }
+ val subtitleBackgroundLabel = remember(uiState.subtitleBackgroundColor, context) {
+ formatSubtitleColorLabel(uiState.subtitleBackgroundColor, subtitleBackgroundColorOptions(context))
+ }
+ val wifiQualityLabel = remember(uiState.wifiMaxVideoHeight, context) {
+ formatQualityCapLabel(uiState.wifiMaxVideoHeight, context.getString(R.string.settings_quality_cap_auto))
+ }
+ val ethernetQualityLabel = remember(uiState.ethernetMaxVideoHeight, context) {
+ formatQualityCapLabel(uiState.ethernetMaxVideoHeight, context.getString(R.string.settings_quality_cap_auto))
+ }
+ val timeshiftDepthLabel = remember(uiState.playerTimeshiftDepthMinutes, context) {
+ formatTimeshiftDepthLabel(uiState.playerTimeshiftDepthMinutes, context)
+ }
+ val defaultStopTimerLabel = remember(uiState.defaultStopPlaybackTimerMinutes, context) {
+ formatPlaybackTimerMinutesLabel(uiState.defaultStopPlaybackTimerMinutes, context)
+ }
+ val defaultIdleTimerLabel = remember(uiState.defaultIdleStandbyTimerMinutes, context) {
+ formatPlaybackTimerMinutesLabel(uiState.defaultIdleStandbyTimerMinutes, context)
+ }
+ val lastSpeedTestLabel = remember(uiState.lastSpeedTest, context) {
+ uiState.lastSpeedTest?.let(::formatSpeedTestValueLabel)
+ ?: context.getString(R.string.settings_speed_test_not_run)
+ }
+ val lastSpeedTestSummary = remember(uiState.lastSpeedTest, context, dateTimeFormat) {
+ uiState.lastSpeedTest?.let { formatSpeedTestSummary(it, context, dateTimeFormat) }
+ ?: context.getString(R.string.settings_speed_test_summary_default)
+ }
+ val speedTestRecommendationLabel = remember(uiState.lastSpeedTest, context) {
+ formatQualityCapLabel(
+ uiState.lastSpeedTest?.recommendedMaxVideoHeight,
+ context.getString(R.string.settings_quality_cap_auto)
+ )
+ }
+ val protectionSummary = remember(uiState.parentalControlLevel, context) {
+ when (uiState.parentalControlLevel) {
+ 0 -> context.getString(R.string.settings_level_off)
+ 1 -> context.getString(R.string.settings_level_locked)
+ 2 -> context.getString(R.string.settings_level_private)
+ 3 -> context.getString(R.string.settings_level_hidden)
+ else -> context.getString(R.string.settings_level_unknown)
+ }
+ }
+ val guideDefaultCategoryLabel = remember(
+ uiState.guideDefaultCategoryId,
+ uiState.guideDefaultCategoryOptions,
+ context
+ ) {
+ uiState.guideDefaultCategoryOptions
+ .firstOrNull { it.id == uiState.guideDefaultCategoryId }
+ ?.name
+ ?: context.getString(R.string.settings_guide_default_category_fallback)
+ }
+
+ return SettingsScreenLabels(
+ buildVerificationLabel = buildVerificationLabel,
+ appLanguageLabel = appLanguageLabel,
+ timeFormatLabel = timeFormatLabel,
+ preferredAudioLanguageLabel = preferredAudioLanguageLabel,
+ playbackSpeedLabel = playbackSpeedLabel,
+ audioVideoOffsetLabel = audioVideoOffsetLabel,
+ decoderModeLabel = decoderModeLabel,
+ surfaceModeLabel = surfaceModeLabel,
+ controlsTimeoutLabel = controlsTimeoutLabel,
+ liveOverlayTimeoutLabel = liveOverlayTimeoutLabel,
+ noticeTimeoutLabel = noticeTimeoutLabel,
+ diagnosticsTimeoutLabel = diagnosticsTimeoutLabel,
+ subtitleSizeLabel = subtitleSizeLabel,
+ subtitleTextColorLabel = subtitleTextColorLabel,
+ subtitleBackgroundLabel = subtitleBackgroundLabel,
+ wifiQualityLabel = wifiQualityLabel,
+ ethernetQualityLabel = ethernetQualityLabel,
+ timeshiftDepthLabel = timeshiftDepthLabel,
+ defaultStopTimerLabel = defaultStopTimerLabel,
+ defaultIdleTimerLabel = defaultIdleTimerLabel,
+ lastSpeedTestLabel = lastSpeedTestLabel,
+ lastSpeedTestSummary = lastSpeedTestSummary,
+ speedTestRecommendationLabel = speedTestRecommendationLabel,
+ protectionSummary = protectionSummary,
+ guideDefaultCategoryLabel = guideDefaultCategoryLabel
+ )
+}
+
+internal fun Context.findMainActivity(): MainActivity? {
+ var current: Context? = this
+ while (current is ContextWrapper) {
+ if (current is MainActivity) return current
+ current = current.baseContext
+ }
+ return null
+}
+
+private fun formatOfficialBuildStatusLabel(
+ status: OfficialBuildStatus,
+ context: Context
+): String = when (status) {
+ OfficialBuildStatus.OFFICIAL -> context.getString(R.string.settings_build_verification_official)
+ OfficialBuildStatus.UNOFFICIAL -> context.getString(R.string.settings_build_verification_unofficial)
+ OfficialBuildStatus.VERIFICATION_UNAVAILABLE -> context.getString(R.string.settings_build_verification_unavailable)
+}
+
+private fun formatAppTimeFormatLabel(
+ format: AppTimeFormat,
+ context: Context
+): String = context.getString(
+ when (format) {
+ AppTimeFormat.SYSTEM -> R.string.settings_time_format_system
+ AppTimeFormat.TWELVE_HOUR -> R.string.settings_time_format_12h
+ AppTimeFormat.TWENTY_FOUR_HOUR -> R.string.settings_time_format_24h
+ }
+)
+
+private fun formatTimeshiftDepthLabel(
+ depthMinutes: Int,
+ context: Context
+): String = when (depthMinutes) {
+ 15 -> context.getString(R.string.settings_live_timeshift_depth_15)
+ 60 -> context.getString(R.string.settings_live_timeshift_depth_60)
+ else -> context.getString(R.string.settings_live_timeshift_depth_30)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsSelectionDialogComponents.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsSelectionDialogComponents.kt
new file mode 100644
index 00000000..d841e93e
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsSelectionDialogComponents.kt
@@ -0,0 +1,159 @@
+package com.streamvault.app.ui.screens.settings
+
+import androidx.compose.foundation.border
+import androidx.compose.foundation.clickable
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.BoxWithConstraints
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.ColumnScope
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.rememberScrollState
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.foundation.verticalScroll
+import androidx.compose.material3.HorizontalDivider
+import androidx.compose.material3.RadioButton
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Alignment.Companion.Center
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.input.key.onPreviewKeyEvent
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.window.Dialog
+import androidx.tv.material3.ClickableSurfaceDefaults
+import androidx.tv.material3.MaterialTheme
+import androidx.tv.material3.Text
+import com.streamvault.app.R
+import com.streamvault.app.ui.components.dialogs.rememberDialogOpenGestureBlocker
+import com.streamvault.app.ui.interaction.TvClickableSurface
+import com.streamvault.app.ui.theme.OnBackground
+import com.streamvault.app.ui.theme.OnSurfaceDim
+import com.streamvault.app.ui.theme.Primary
+import com.streamvault.app.ui.theme.SurfaceElevated
+
+@Composable
+internal fun PremiumSelectionDialog(
+ title: String,
+ onDismiss: () -> Unit,
+ content: @Composable ColumnScope.() -> Unit
+) {
+ val isTelevisionDevice = com.streamvault.app.device.rememberIsTelevisionDevice()
+ var canInteract by remember { mutableStateOf(false) }
+ val blockOpenGesture = rememberDialogOpenGestureBlocker(canInteract)
+ LaunchedEffect(Unit) {
+ kotlinx.coroutines.delay(500)
+ canInteract = true
+ }
+ Dialog(onDismissRequest = { if (canInteract) onDismiss() }) {
+ val dialogContent: @Composable (Modifier) -> Unit = { resolvedModifier ->
+ androidx.compose.material3.Surface(
+ shape = RoundedCornerShape(14.dp),
+ color = SurfaceElevated,
+ modifier = resolvedModifier
+ .border(1.dp, Primary.copy(alpha = 0.4f), RoundedCornerShape(14.dp))
+ .onPreviewKeyEvent(blockOpenGesture)
+ ) {
+ Column(
+ modifier = Modifier.padding(18.dp),
+ verticalArrangement = Arrangement.spacedBy(8.dp)
+ ) {
+ Text(
+ text = title,
+ style = MaterialTheme.typography.titleMedium,
+ color = Primary
+ )
+ HorizontalDivider(color = Color.White.copy(alpha = 0.1f))
+ Column(
+ verticalArrangement = Arrangement.spacedBy(6.dp),
+ modifier = Modifier
+ .padding(top = 6.dp)
+ .weight(1f, fill = false)
+ .verticalScroll(rememberScrollState())
+ ) {
+ content()
+ }
+ Row(
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(top = 8.dp),
+ horizontalArrangement = Arrangement.End
+ ) {
+ TvClickableSurface(
+ onClick = { if (canInteract) onDismiss() },
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(6.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Primary.copy(alpha = 0.2f),
+ focusedContainerColor = Primary.copy(alpha = 0.4f)
+ )
+ ) {
+ Text(
+ text = stringResource(R.string.settings_cancel),
+ style = MaterialTheme.typography.labelMedium,
+ color = Primary,
+ modifier = Modifier.padding(horizontal = 14.dp, vertical = 9.dp)
+ )
+ }
+ }
+ }
+ }
+ }
+
+ if (isTelevisionDevice) {
+ dialogContent(Modifier.fillMaxWidth(0.62f))
+ } else {
+ BoxWithConstraints(
+ modifier = Modifier.fillMaxWidth(),
+ contentAlignment = Center
+ ) {
+ val dialogWidthFraction = when {
+ maxWidth < 700.dp -> 0.92f
+ maxWidth < 1000.dp -> 0.78f
+ else -> 0.62f
+ }
+ dialogContent(Modifier.fillMaxWidth(dialogWidthFraction))
+ }
+ }
+ }
+}
+
+@Composable
+internal fun LevelOption(
+ level: Int,
+ text: String,
+ currentLevel: Int,
+ subtitle: String? = null,
+ onSelect: () -> Unit
+) {
+ Row(
+ modifier = Modifier
+ .fillMaxWidth()
+ .clickable(onClick = onSelect)
+ .padding(vertical = 12.dp),
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ RadioButton(
+ selected = level == currentLevel,
+ onClick = onSelect
+ )
+ Spacer(modifier = Modifier.width(8.dp))
+ if (subtitle != null) {
+ Column(verticalArrangement = Arrangement.spacedBy(2.dp)) {
+ Text(text, style = MaterialTheme.typography.titleSmall, color = OnBackground)
+ Text(subtitle, style = MaterialTheme.typography.bodySmall, color = OnSurfaceDim)
+ }
+ } else {
+ Text(text, style = MaterialTheme.typography.bodyMedium, color = OnBackground)
+ }
+ }
+}
+
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsSelectionDialogs.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsSelectionDialogs.kt
new file mode 100644
index 00000000..2086757f
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsSelectionDialogs.kt
@@ -0,0 +1,106 @@
+package com.streamvault.app.ui.screens.settings
+
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.remember
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.unit.dp
+import androidx.tv.material3.ClickableSurfaceDefaults
+import androidx.tv.material3.MaterialTheme
+import androidx.tv.material3.Text
+import com.streamvault.app.R
+import com.streamvault.app.ui.components.dialogs.PremiumDialog
+import com.streamvault.app.ui.components.dialogs.PremiumDialogFooterButton
+import com.streamvault.app.ui.interaction.TvClickableSurface
+import com.streamvault.app.ui.theme.OnBackground
+import com.streamvault.app.ui.theme.OnSurfaceDim
+import com.streamvault.app.ui.theme.Primary
+import com.streamvault.app.ui.theme.SurfaceElevated
+import com.streamvault.domain.model.CategorySortMode
+import com.streamvault.domain.model.ContentType
+
+@Composable
+internal fun QualityCapSelectionDialog(
+ title: String,
+ currentValue: Int?,
+ onDismiss: () -> Unit,
+ onSelect: (Int?) -> Unit
+) {
+ val context = LocalContext.current
+ val options = remember(context) {
+ listOf<Int?>(null, 2160, 1080, 720, 480)
+ }
+ PremiumSelectionDialog(
+ title = title,
+ onDismiss = onDismiss
+ ) {
+ options.forEachIndexed { index, option ->
+ LevelOption(
+ level = index,
+ text = formatQualityCapLabel(option, context.getString(R.string.settings_quality_cap_auto)),
+ currentLevel = if (option == currentValue) index else -1,
+ onSelect = { onSelect(option) }
+ )
+ }
+ }
+}
+
+@Composable
+internal fun CategorySortModeDialog(
+ type: ContentType,
+ currentMode: CategorySortMode,
+ onDismiss: () -> Unit,
+ onModeSelected: (CategorySortMode) -> Unit
+) {
+ val context = LocalContext.current
+ PremiumDialog(
+ title = categoryTypeLabel(type, context),
+ subtitle = categoryTypeDescription(type, context),
+ onDismissRequest = onDismiss,
+ widthFraction = 0.52f,
+ content = {
+ Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
+ CategorySortMode.entries.forEach { mode ->
+ TvClickableSurface(
+ onClick = { onModeSelected(mode) },
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(14.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = if (mode == currentMode) Primary.copy(alpha = 0.18f) else SurfaceElevated,
+ focusedContainerColor = Primary.copy(alpha = 0.28f)
+ ),
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ Column(
+ modifier = Modifier.padding(horizontal = 16.dp, vertical = 14.dp),
+ verticalArrangement = Arrangement.spacedBy(4.dp)
+ ) {
+ Text(
+ text = formatCategorySortModeLabel(mode, context),
+ style = MaterialTheme.typography.titleSmall,
+ color = if (mode == currentMode) Primary else OnBackground
+ )
+ Text(
+ text = sortModeLabel(mode, context),
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim
+ )
+ }
+ }
+ }
+ }
+ },
+ footer = {
+ PremiumDialogFooterButton(
+ label = stringResource(R.string.settings_cancel),
+ onClick = onDismiss
+ )
+ }
+ )
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsSharedUiComponents.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsSharedUiComponents.kt
new file mode 100644
index 00000000..0ee0bdca
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsSharedUiComponents.kt
@@ -0,0 +1,328 @@
+package com.streamvault.app.ui.screens.settings
+
+import androidx.compose.foundation.BorderStroke
+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.WindowInsets
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.ime
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.relocation.BringIntoViewRequester
+import androidx.compose.foundation.relocation.bringIntoViewRequester
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.foundation.text.BasicTextField
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.rememberCoroutineScope
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.focus.FocusRequester
+import androidx.compose.ui.focus.focusProperties
+import androidx.compose.ui.focus.focusRequester
+import androidx.compose.ui.focus.onFocusChanged
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.SolidColor
+import androidx.compose.ui.input.key.onPreviewKeyEvent
+import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.platform.LocalSoftwareKeyboardController
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.text.TextRange
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.text.input.TextFieldValue
+import androidx.compose.ui.unit.dp
+import androidx.tv.material3.Border
+import androidx.tv.material3.ClickableSurfaceDefaults
+import androidx.tv.material3.MaterialTheme
+import androidx.tv.material3.Surface
+import androidx.tv.material3.SurfaceDefaults
+import androidx.tv.material3.Text
+import com.streamvault.app.R
+import com.streamvault.app.ui.design.FocusSpec
+import com.streamvault.app.ui.interaction.TvClickableSurface
+import com.streamvault.app.ui.theme.OnBackground
+import com.streamvault.app.ui.theme.OnSurfaceDim
+import com.streamvault.app.ui.theme.Primary
+import com.streamvault.app.ui.theme.SurfaceElevated
+import com.streamvault.app.ui.theme.SurfaceHighlight
+import kotlinx.coroutines.launch
+import java.util.Locale
+
+@Composable
+internal fun SettingsOverviewCard(
+ activeProviderName: String,
+ providerCount: Int,
+ protectionSummary: String,
+ languageLabel: String
+) {
+ Surface(
+ modifier = Modifier.fillMaxWidth(),
+ colors = SurfaceDefaults.colors(containerColor = SurfaceElevated),
+ shape = RoundedCornerShape(16.dp)
+ ) {
+ Column(
+ modifier = Modifier.padding(20.dp),
+ verticalArrangement = Arrangement.spacedBy(14.dp)
+ ) {
+ Text(
+ text = stringResource(R.string.settings_overview_title),
+ style = MaterialTheme.typography.titleLarge,
+ color = OnBackground
+ )
+ Text(
+ text = stringResource(R.string.settings_overview_subtitle),
+ style = MaterialTheme.typography.bodyMedium,
+ color = OnSurfaceDim
+ )
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.spacedBy(12.dp)
+ ) {
+ SettingsOverviewStat(
+ modifier = Modifier.weight(1f),
+ label = stringResource(R.string.settings_overview_provider_label),
+ value = activeProviderName
+ )
+ SettingsOverviewStat(
+ modifier = Modifier.weight(1f),
+ label = stringResource(R.string.settings_overview_count_label),
+ value = providerCount.toString()
+ )
+ SettingsOverviewStat(
+ modifier = Modifier.weight(1f),
+ label = stringResource(R.string.settings_overview_protection_label),
+ value = protectionSummary
+ )
+ SettingsOverviewStat(
+ modifier = Modifier.weight(1f),
+ label = stringResource(R.string.settings_overview_language_label),
+ value = languageLabel
+ )
+ }
+ }
+ }
+}
+
+@Composable
+internal fun SettingsOverviewStat(
+ label: String,
+ value: String,
+ modifier: Modifier = Modifier
+) {
+ Column(
+ modifier = modifier
+ .background(SurfaceHighlight.copy(alpha = 0.28f), RoundedCornerShape(12.dp))
+ .padding(horizontal = 14.dp, vertical = 12.dp),
+ verticalArrangement = Arrangement.spacedBy(4.dp)
+ ) {
+ Text(
+ text = label.uppercase(Locale.getDefault()),
+ style = MaterialTheme.typography.labelSmall,
+ color = OnSurfaceDim
+ )
+ Text(
+ text = value,
+ style = MaterialTheme.typography.titleSmall,
+ color = OnBackground,
+ fontWeight = FontWeight.SemiBold
+ )
+ }
+}
+
+@Composable
+internal fun CompactSettingsActionChip(
+ label: String,
+ accent: Color,
+ enabled: Boolean = true,
+ onClick: () -> Unit
+) {
+ TvClickableSurface(
+ onClick = onClick,
+ enabled = enabled,
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = accent.copy(alpha = if (enabled) 0.14f else 0.08f),
+ contentColor = accent.copy(alpha = if (enabled) 1f else 0.42f),
+ focusedContainerColor = accent.copy(alpha = if (enabled) 0.28f else 0.08f),
+ focusedContentColor = accent.copy(alpha = if (enabled) 1f else 0.42f),
+ disabledContainerColor = accent.copy(alpha = 0.08f),
+ disabledContentColor = accent.copy(alpha = 0.42f)
+ ),
+ border = ClickableSurfaceDefaults.border(
+ border = Border(
+ border = BorderStroke(1.dp, Color.White.copy(alpha = if (enabled) 0.08f else 0.04f)),
+ shape = RoundedCornerShape(8.dp)
+ ),
+ focusedBorder = Border(
+ border = BorderStroke(FocusSpec.BorderWidth, Color.White),
+ shape = RoundedCornerShape(8.dp)
+ )
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
+ ) {
+ Text(
+ text = label,
+ color = accent.copy(alpha = if (enabled) 1f else 0.42f),
+ style = MaterialTheme.typography.labelSmall,
+ modifier = Modifier.padding(horizontal = 12.dp, vertical = 8.dp)
+ )
+ }
+}
+
+@Composable
+internal fun EpgSourceTextField(
+ value: String,
+ onValueChange: (String) -> Unit,
+ placeholder: String
+) {
+ val isTelevisionDevice = com.streamvault.app.device.rememberIsTelevisionDevice()
+ val focusRequester = remember { FocusRequester() }
+ val keyboardController = LocalSoftwareKeyboardController.current
+ val bringIntoViewRequester = remember { BringIntoViewRequester() }
+ val coroutineScope = rememberCoroutineScope()
+ var hasContainerFocus by remember { mutableStateOf(false) }
+ var hasInputFocus by remember { mutableStateOf(false) }
+ var acceptsInput by remember(isTelevisionDevice) { mutableStateOf(!isTelevisionDevice) }
+ var pendingInputActivation by remember { mutableStateOf(false) }
+ var fieldValue by remember {
+ mutableStateOf(TextFieldValue(text = value, selection = TextRange(value.length)))
+ }
+ val isFocused = hasContainerFocus || hasInputFocus
+
+ val density = LocalDensity.current
+ val imeBottom = WindowInsets.ime.getBottom(density)
+ LaunchedEffect(imeBottom) {
+ if ((hasInputFocus || hasContainerFocus) && imeBottom > 0) {
+ runCatching { bringIntoViewRequester.bringIntoView() }
+ }
+ }
+
+ fun requestBringIntoView(delayMillis: Long = 0L) {
+ coroutineScope.launch {
+ if (delayMillis > 0) {
+ kotlinx.coroutines.delay(delayMillis)
+ }
+ runCatching { bringIntoViewRequester.bringIntoView() }
+ }
+ }
+
+ LaunchedEffect(value) {
+ if (value != fieldValue.text) {
+ val coercedSelectionStart = fieldValue.selection.start.coerceIn(0, value.length)
+ val coercedSelectionEnd = fieldValue.selection.end.coerceIn(0, value.length)
+ val coercedComposition = fieldValue.composition?.let { composition ->
+ val compositionStart = composition.start.coerceIn(0, value.length)
+ val compositionEnd = composition.end.coerceIn(0, value.length)
+ if (compositionStart <= compositionEnd) {
+ TextRange(compositionStart, compositionEnd)
+ } else {
+ null
+ }
+ }
+ fieldValue = fieldValue.copy(
+ text = value,
+ selection = TextRange(coercedSelectionStart, coercedSelectionEnd),
+ composition = coercedComposition
+ )
+ }
+ }
+
+ LaunchedEffect(acceptsInput, pendingInputActivation) {
+ if (!isTelevisionDevice || !acceptsInput || !pendingInputActivation) {
+ return@LaunchedEffect
+ }
+ focusRequester.requestFocus()
+ keyboardController?.show()
+ requestBringIntoView(120)
+ pendingInputActivation = false
+ }
+
+ TvClickableSurface(
+ onClick = {
+ if (!isTelevisionDevice) {
+ focusRequester.requestFocus()
+ keyboardController?.show()
+ requestBringIntoView()
+ requestBringIntoView(180)
+ return@TvClickableSurface
+ }
+ acceptsInput = true
+ pendingInputActivation = true
+ requestBringIntoView()
+ },
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Color.White.copy(alpha = 0.08f),
+ focusedContainerColor = Color.White.copy(alpha = 0.12f)
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
+ modifier = Modifier
+ .fillMaxWidth()
+ .bringIntoViewRequester(bringIntoViewRequester)
+ .onFocusChanged { hasContainerFocus = it.isFocused }
+ ) {
+ Box(modifier = Modifier.padding(horizontal = 12.dp, vertical = 10.dp)) {
+ if (value.isEmpty() && !isFocused) {
+ Text(placeholder, style = MaterialTheme.typography.bodyMedium, color = OnSurfaceDim)
+ }
+ BasicTextField(
+ value = fieldValue,
+ onValueChange = { updatedValue ->
+ fieldValue = updatedValue
+ if (updatedValue.text != value) {
+ onValueChange(updatedValue.text)
+ }
+ },
+ textStyle = MaterialTheme.typography.bodyMedium.copy(color = Color.White),
+ singleLine = true,
+ cursorBrush = SolidColor(Primary),
+ modifier = Modifier
+ .fillMaxWidth()
+ .focusRequester(focusRequester)
+ .focusProperties {
+ canFocus = !isTelevisionDevice || acceptsInput
+ if (isTelevisionDevice && acceptsInput) {
+ left = FocusRequester.Cancel
+ right = FocusRequester.Cancel
+ }
+ }
+ .onPreviewKeyEvent { event ->
+ if (!isTelevisionDevice || !acceptsInput || event.nativeKeyEvent.action != android.view.KeyEvent.ACTION_DOWN) {
+ return@onPreviewKeyEvent false
+ }
+ val cursor = fieldValue.selection.end
+ when (event.nativeKeyEvent.keyCode) {
+ android.view.KeyEvent.KEYCODE_DPAD_LEFT -> {
+ val nextCursor = (cursor - 1).coerceAtLeast(0)
+ fieldValue = fieldValue.copy(selection = TextRange(nextCursor))
+ true
+ }
+ android.view.KeyEvent.KEYCODE_DPAD_RIGHT -> {
+ val nextCursor = (cursor + 1).coerceAtMost(fieldValue.text.length)
+ fieldValue = fieldValue.copy(selection = TextRange(nextCursor))
+ true
+ }
+ else -> false
+ }
+ }
+ .onFocusChanged {
+ hasInputFocus = it.isFocused
+ if (it.isFocused) {
+ requestBringIntoView(120)
+ } else {
+ if (isTelevisionDevice) {
+ acceptsInput = false
+ }
+ keyboardController?.hide()
+ }
+ },
+ readOnly = isTelevisionDevice && !acceptsInput
+ )
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsStateBindings.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsStateBindings.kt
index 21801841..9eca48df 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsStateBindings.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsStateBindings.kt
@@ -2,37 +2,21 @@
package com.streamvault.app.ui.screens.settings
-import android.app.Application
-import com.streamvault.app.R
import com.streamvault.app.ui.model.LiveTvChannelMode
import com.streamvault.app.ui.model.LiveTvQuickFilterVisibilityMode
import com.streamvault.app.ui.model.VodViewMode
import com.streamvault.data.preferences.PreferencesRepository
import com.streamvault.domain.model.AppTimeFormat
-import com.streamvault.domain.model.Category
-import com.streamvault.domain.model.CategorySortMode
import com.streamvault.domain.model.ChannelNumberingMode
-import com.streamvault.domain.model.ContentType
import com.streamvault.domain.model.DecoderMode
import com.streamvault.domain.model.GroupedChannelLabelMode
import com.streamvault.domain.model.LiveChannelGroupingMode
import com.streamvault.domain.model.LiveVariantPreferenceMode
-import com.streamvault.domain.model.Provider
-import com.streamvault.domain.model.ProviderType
import com.streamvault.domain.model.VirtualCategoryIds
-import com.streamvault.domain.model.VodSyncMode
-import com.streamvault.domain.repository.CategoryRepository
import com.streamvault.domain.repository.ProviderRepository
-import com.streamvault.domain.repository.SyncMetadataRepository
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine
-import kotlinx.coroutines.flow.flatMapLatest
-import kotlinx.coroutines.flow.flowOf
-import kotlinx.coroutines.flow.map
-import java.text.SimpleDateFormat
-import java.util.Date
-import java.util.Locale
internal fun observeSettingsPreferenceSnapshot(
providerRepository: ProviderRepository,
@@ -218,242 +202,3 @@ internal fun observeSettingsPreferenceSnapshot(
snapshot.copy(cachedAppUpdatePublishedAt = publishedAt)
}
}
-
-internal fun SettingsUiState.applyPreferenceSnapshot(snapshot: SettingsPreferenceSnapshot): SettingsUiState {
- val cachedAppUpdate = snapshot.toCachedAppUpdateUiModel()
- return copy(
- providers = snapshot.providers,
- activeProviderId = snapshot.activeProviderId,
- parentalControlLevel = snapshot.parentalControlLevel,
- hasParentalPin = snapshot.hasParentalPin,
- appLanguage = snapshot.appLanguage,
- appTimeFormat = snapshot.appTimeFormat,
- preferredAudioLanguage = snapshot.preferredAudioLanguage,
- playerMediaSessionEnabled = snapshot.playerMediaSessionEnabled,
- playerDecoderMode = snapshot.playerDecoderMode,
- playerSurfaceMode = snapshot.playerSurfaceMode,
- playerPlaybackSpeed = snapshot.playerPlaybackSpeed,
- playerAudioVideoOffsetMs = snapshot.playerAudioVideoOffsetMs,
- playerControlsTimeoutSeconds = snapshot.playerControlsTimeoutSeconds,
- playerLiveOverlayTimeoutSeconds = snapshot.playerLiveOverlayTimeoutSeconds,
- playerNoticeTimeoutSeconds = snapshot.playerNoticeTimeoutSeconds,
- playerDiagnosticsTimeoutSeconds = snapshot.playerDiagnosticsTimeoutSeconds,
- subtitleTextScale = snapshot.subtitleTextScale,
- subtitleTextColor = snapshot.subtitleTextColor,
- subtitleBackgroundColor = snapshot.subtitleBackgroundColor,
- wifiMaxVideoHeight = snapshot.wifiMaxVideoHeight,
- ethernetMaxVideoHeight = snapshot.ethernetMaxVideoHeight,
- playerTimeshiftEnabled = snapshot.playerTimeshiftEnabled,
- playerTimeshiftDepthMinutes = snapshot.playerTimeshiftDepthMinutes,
- defaultStopPlaybackTimerMinutes = snapshot.defaultStopPlaybackTimerMinutes,
- defaultIdleStandbyTimerMinutes = snapshot.defaultIdleStandbyTimerMinutes,
- lastSpeedTest = snapshot.lastSpeedTestMegabits?.let {
- InternetSpeedTestUiModel(
- megabitsPerSecond = it,
- measuredAtMs = snapshot.lastSpeedTestTimestamp ?: 0L,
- transportLabel = snapshot.lastSpeedTestTransport ?: InternetSpeedTestTransport.UNKNOWN.name,
- recommendedMaxVideoHeight = snapshot.lastSpeedTestRecommendedHeight,
- isEstimated = snapshot.lastSpeedTestEstimated
- )
- },
- isIncognitoMode = snapshot.isIncognitoMode,
- useXtreamTextClassification = snapshot.useXtreamTextClassification,
- xtreamBase64TextCompatibility = snapshot.xtreamBase64TextCompatibility,
- liveTvChannelMode = snapshot.liveTvChannelMode,
- showLiveSourceSwitcher = snapshot.showLiveSourceSwitcher,
- showAllChannelsCategory = snapshot.showAllChannelsCategory,
- showRecentChannelsCategory = snapshot.showRecentChannelsCategory,
- liveTvCategoryFilters = snapshot.liveTvCategoryFilters,
- liveTvQuickFilterVisibilityMode = snapshot.liveTvQuickFilterVisibilityMode,
- liveChannelNumberingMode = snapshot.liveChannelNumberingMode,
- liveChannelGroupingMode = snapshot.liveChannelGroupingMode,
- groupedChannelLabelMode = snapshot.groupedChannelLabelMode,
- liveVariantPreferenceMode = snapshot.liveVariantPreferenceMode,
- vodViewMode = snapshot.vodViewMode,
- vodInfiniteScroll = snapshot.vodInfiniteScroll,
- guideDefaultCategoryId = snapshot.guideDefaultCategoryId,
- guideDefaultCategoryOptions = guideDefaultCategoryOptions,
- preventStandbyDuringPlayback = snapshot.preventStandbyDuringPlayback,
- zapAutoRevert = snapshot.zapAutoRevert,
- autoPlayNextEpisode = snapshot.autoPlayNextEpisode,
- autoCheckAppUpdates = snapshot.autoCheckAppUpdates,
- autoDownloadAppUpdates = snapshot.autoDownloadAppUpdates,
- appUpdate = cachedAppUpdate.copy(
- downloadStatus = appUpdate.downloadStatus,
- downloadedVersionName = appUpdate.downloadedVersionName,
- errorMessage = appUpdate.errorMessage
- )
- )
-}
-
-internal fun observeProviderDiagnostics(
- providerRepository: ProviderRepository,
- syncMetadataRepository: SyncMetadataRepository,
- application: Application
-): Flow<Map<Long, ProviderDiagnosticsUiModel>> {
- return providerRepository.getProviders()
- .flatMapLatest { providers ->
- if (providers.isEmpty()) {
- flowOf(emptyMap())
- } else {
- combine(
- providers.map { provider ->
- syncMetadataRepository.observeMetadata(provider.id).map { metadata ->
- provider.id to ProviderDiagnosticsUiModel(
- lastSyncStatus = metadata?.lastSyncStatus ?: "NONE",
- lastLiveSync = metadata?.lastLiveSync ?: 0L,
- lastMovieSync = metadata?.lastMovieSync ?: 0L,
- lastMovieAttempt = metadata?.lastMovieAttempt ?: 0L,
- lastMovieSuccess = metadata?.lastMovieSuccess ?: 0L,
- lastMoviePartial = metadata?.lastMoviePartial ?: 0L,
- lastSeriesSync = metadata?.lastSeriesSync ?: 0L,
- lastEpgSync = metadata?.lastEpgSync ?: 0L,
- liveCount = metadata?.liveCount ?: 0,
- movieCount = metadata?.movieCount ?: 0,
- seriesCount = metadata?.seriesCount ?: 0,
- epgCount = metadata?.epgCount ?: 0,
- movieSyncMode = metadata?.movieSyncMode ?: VodSyncMode.UNKNOWN,
- movieWarningsCount = metadata?.movieWarningsCount ?: 0,
- movieCatalogStale = metadata?.movieCatalogStale ?: false,
- liveSequentialFailuresRemembered = metadata?.liveSequentialFailuresRemembered ?: false,
- liveHealthySyncStreak = metadata?.liveHealthySyncStreak ?: 0,
- movieParallelFailuresRemembered = metadata?.movieParallelFailuresRemembered ?: false,
- movieHealthySyncStreak = metadata?.movieHealthySyncStreak ?: 0,
- seriesSequentialFailuresRemembered = metadata?.seriesSequentialFailuresRemembered ?: false,
- seriesHealthySyncStreak = metadata?.seriesHealthySyncStreak ?: 0,
- capabilitySummary = buildCapabilitySummary(application, provider),
- sourceLabel = provider.sourceLabel(),
- expirySummary = provider.expirySummary(),
- connectionSummary = "${provider.maxConnections} connection(s)",
- archiveSummary = provider.archiveSummary()
- )
- }
- }
- ) { pairs ->
- pairs.toMap()
- }
- }
- }
-}
-
-internal fun observeCategoryManagement(
- activeProviderIdFlow: Flow<Long?>,
- preferencesRepository: PreferencesRepository,
- categoryRepository: CategoryRepository
-): Flow<CategoryManagementSnapshot> {
- return activeProviderIdFlow.flatMapLatest { providerId ->
- if (providerId == null) {
- flowOf(CategoryManagementSnapshot())
- } else {
- combine(
- observeCategorySortModes(providerId, preferencesRepository),
- categoryRepository.getCategories(providerId),
- observeHiddenCategoryIdsByType(providerId, preferencesRepository)
- ) { sortModes, categories, hiddenByType ->
- CategoryManagementSnapshot(
- categorySortModes = sortModes,
- hiddenCategories = categories
- .filter { category -> category.id in hiddenByType[category.type].orEmpty() }
- .sortedWith(compareBy<Category>({ it.type.ordinal }, { it.name.lowercase() }))
- )
- }
- }
- }
-}
-
-private fun observeCategorySortModes(
- providerId: Long,
- preferencesRepository: PreferencesRepository
-): Flow<Map<ContentType, CategorySortMode>> {
- return combine(
- preferencesRepository.getCategorySortMode(providerId, ContentType.LIVE),
- preferencesRepository.getCategorySortMode(providerId, ContentType.MOVIE),
- preferencesRepository.getCategorySortMode(providerId, ContentType.SERIES)
- ) { liveSort, movieSort, seriesSort ->
- mapOf(
- ContentType.LIVE to liveSort,
- ContentType.MOVIE to movieSort,
- ContentType.SERIES to seriesSort
- )
- }
-}
-
-private fun observeHiddenCategoryIdsByType(
- providerId: Long,
- preferencesRepository: PreferencesRepository
-): Flow<Map<ContentType, Set<Long>>> {
- return combine(
- preferencesRepository.getHiddenCategoryIds(providerId, ContentType.LIVE),
- preferencesRepository.getHiddenCategoryIds(providerId, ContentType.MOVIE),
- preferencesRepository.getHiddenCategoryIds(providerId, ContentType.SERIES)
- ) { hiddenLive, hiddenMovies, hiddenSeries ->
- mapOf(
- ContentType.LIVE to hiddenLive,
- ContentType.MOVIE to hiddenMovies,
- ContentType.SERIES to hiddenSeries
- )
- }
-}
-
-private fun buildCapabilitySummary(application: Application, provider: Provider): String {
- return when (provider.type) {
- ProviderType.XTREAM_CODES -> {
- if (provider.epgUrl.isNotBlank()) {
- application.getString(R.string.settings_capability_xtream_with_epg)
- } else {
- application.getString(R.string.settings_capability_xtream_without_epg)
- }
- }
- ProviderType.M3U -> {
- if (provider.epgUrl.isNotBlank()) {
- application.getString(R.string.settings_capability_m3u_with_epg)
- } else {
- application.getString(R.string.settings_capability_m3u_without_epg)
- }
- }
- ProviderType.STALKER_PORTAL -> {
- if (provider.epgUrl.isNotBlank()) {
- "Portal catalog with MAC auth, XMLTV import, and on-demand playback link resolution."
- } else {
- "Portal catalog with MAC auth and on-demand guide/playback resolution."
- }
- }
- }
-}
-
-private fun Provider.sourceLabel(): String = when (type) {
- ProviderType.XTREAM_CODES -> "Xtream Codes"
- ProviderType.M3U -> "M3U Playlist"
- ProviderType.STALKER_PORTAL -> "Stalker/MAG Portal"
-}
-
-private fun Provider.expirySummary(): String {
- val expirationDate = expirationDate
- return when {
- expirationDate == null -> "Expiry unknown"
- expirationDate == Long.MAX_VALUE -> "No expiry reported"
- expirationDate < System.currentTimeMillis() -> "Expired"
- else -> {
- val formatter = SimpleDateFormat("d MMM yyyy", Locale.getDefault())
- "Active until ${formatter.format(Date(expirationDate))}"
- }
- }
-}
-
-private fun Provider.archiveSummary(): String = when (type) {
- ProviderType.XTREAM_CODES -> "Catch-up depends on provider archive flags and replay stream ids."
- ProviderType.M3U -> {
- if (epgUrl.isBlank()) {
- "M3U replay is limited without guide coverage."
- } else {
- "M3U replay depends on channel templates and guide alignment."
- }
- }
- ProviderType.STALKER_PORTAL -> {
- if (epgUrl.isBlank()) {
- "Stalker replay depends on portal support; guide falls back to portal data."
- } else {
- "Stalker replay depends on portal support with optional XMLTV coverage."
- }
- }
-}
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsSyncOverlay.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsSyncOverlay.kt
new file mode 100644
index 00000000..834a1864
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsSyncOverlay.kt
@@ -0,0 +1,77 @@
+package com.streamvault.app.ui.screens.settings
+
+import androidx.activity.compose.BackHandler
+import androidx.compose.foundation.background
+import androidx.compose.foundation.clickable
+import androidx.compose.foundation.focusable
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.fillMaxSize
+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.input.key.onKeyEvent
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.unit.dp
+import androidx.compose.material3.CircularProgressIndicator
+import androidx.tv.material3.MaterialTheme
+import androidx.tv.material3.Text
+import com.streamvault.app.R
+import com.streamvault.app.ui.theme.OnSurface
+import com.streamvault.app.ui.theme.OnSurfaceDim
+import com.streamvault.app.ui.theme.Primary
+
+@Composable
+internal fun SyncingOverlay(
+ isSyncing: Boolean,
+ providerName: String? = null,
+ progress: String? = null
+) {
+ if (!isSyncing) return
+
+ BackHandler(enabled = true) {}
+
+ val overlayFocusRequester = remember { FocusRequester() }
+ LaunchedEffect(Unit) { overlayFocusRequester.requestFocus() }
+
+ Box(
+ modifier = Modifier
+ .fillMaxSize()
+ .background(Color.Black.copy(alpha = 0.7f))
+ .clickable(enabled = true, onClick = {})
+ .focusRequester(overlayFocusRequester)
+ .focusable()
+ .onKeyEvent { true },
+ contentAlignment = Alignment.Center
+ ) {
+ Column(
+ horizontalAlignment = Alignment.CenterHorizontally,
+ verticalArrangement = Arrangement.spacedBy(16.dp)
+ ) {
+ CircularProgressIndicator(color = Primary)
+ Text(
+ text = stringResource(R.string.settings_syncing_title),
+ style = MaterialTheme.typography.titleMedium,
+ color = OnSurface
+ )
+ Text(
+ text = providerName ?: stringResource(R.string.settings_syncing_subtitle),
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim
+ )
+ progress?.let { message ->
+ Text(
+ text = message,
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim
+ )
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsTimeoutValueDialog.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsTimeoutValueDialog.kt
new file mode 100644
index 00000000..83405de2
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsTimeoutValueDialog.kt
@@ -0,0 +1,210 @@
+package com.streamvault.app.ui.screens.settings
+
+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.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.foundation.text.BasicTextField
+import androidx.compose.foundation.text.KeyboardActions
+import androidx.compose.foundation.text.KeyboardOptions
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.saveable.rememberSaveable
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.focus.FocusRequester
+import androidx.compose.ui.focus.focusProperties
+import androidx.compose.ui.focus.focusRequester
+import androidx.compose.ui.focus.onFocusChanged
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.SolidColor
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.platform.LocalSoftwareKeyboardController
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.text.TextRange
+import androidx.compose.ui.text.input.ImeAction
+import androidx.compose.ui.text.input.KeyboardType
+import androidx.compose.ui.text.input.TextFieldValue
+import androidx.compose.ui.unit.dp
+import androidx.tv.material3.ClickableSurfaceDefaults
+import androidx.tv.material3.MaterialTheme
+import androidx.tv.material3.Text
+import com.streamvault.app.R
+import com.streamvault.app.ui.components.dialogs.PremiumDialog
+import com.streamvault.app.ui.components.dialogs.PremiumDialogFooterButton
+import com.streamvault.app.ui.interaction.TvClickableSurface
+import com.streamvault.app.ui.theme.OnSurface
+import com.streamvault.app.ui.theme.OnSurfaceDim
+import com.streamvault.app.ui.theme.Primary
+
+@Composable
+internal fun TimeoutValueDialog(
+ title: String,
+ subtitle: String,
+ initialValue: Int,
+ onDismiss: () -> Unit,
+ onConfirm: (Int) -> Unit
+) {
+ var value by rememberSaveable(initialValue) { mutableStateOf(initialValue.toString()) }
+ val parsedValue = value.toIntOrNull()
+ val isValid = parsedValue != null && parsedValue in 2..60
+
+ PremiumDialog(
+ title = title,
+ subtitle = subtitle,
+ onDismissRequest = onDismiss,
+ widthFraction = 0.42f,
+ content = {
+ Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {
+ Text(
+ text = stringResource(R.string.settings_timeout_seconds_label),
+ style = MaterialTheme.typography.bodyMedium,
+ color = OnSurface
+ )
+ NumericSettingsTextField(
+ value = value,
+ onValueChange = { updated -> value = updated.filter(Char::isDigit).take(2) },
+ placeholder = stringResource(R.string.settings_timeout_seconds_placeholder)
+ )
+ Text(
+ text = if (isValid) {
+ formatTimeoutSecondsLabel(parsedValue ?: initialValue, LocalContext.current)
+ } else {
+ stringResource(R.string.settings_timeout_validation)
+ },
+ style = MaterialTheme.typography.bodySmall,
+ color = if (isValid) OnSurfaceDim else Color(0xFFFF8A80)
+ )
+ }
+ },
+ footer = {
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.spacedBy(12.dp, Alignment.End)
+ ) {
+ PremiumDialogFooterButton(
+ label = stringResource(R.string.settings_cancel),
+ onClick = onDismiss
+ )
+ PremiumDialogFooterButton(
+ label = stringResource(R.string.settings_timeout_apply),
+ onClick = { parsedValue?.let(onConfirm) },
+ enabled = isValid
+ )
+ }
+ }
+ )
+}
+
+@Composable
+private fun NumericSettingsTextField(
+ value: String,
+ onValueChange: (String) -> Unit,
+ placeholder: String
+) {
+ val isTelevisionDevice = com.streamvault.app.device.rememberIsTelevisionDevice()
+ val focusRequester = remember { FocusRequester() }
+ val keyboardController = LocalSoftwareKeyboardController.current
+ var hasContainerFocus by remember { mutableStateOf(false) }
+ var hasInputFocus by remember { mutableStateOf(false) }
+ var acceptsInput by remember(isTelevisionDevice) { mutableStateOf(!isTelevisionDevice) }
+ var pendingInputActivation by remember { mutableStateOf(false) }
+ var fieldValue by remember {
+ mutableStateOf(TextFieldValue(text = value, selection = TextRange(value.length)))
+ }
+ val isFocused = hasContainerFocus || hasInputFocus
+
+ LaunchedEffect(value) {
+ if (value != fieldValue.text) {
+ fieldValue = TextFieldValue(text = value, selection = TextRange(value.length))
+ }
+ }
+
+ LaunchedEffect(acceptsInput, pendingInputActivation) {
+ if (!isTelevisionDevice || !acceptsInput || !pendingInputActivation) return@LaunchedEffect
+ focusRequester.requestFocus()
+ keyboardController?.show()
+ pendingInputActivation = false
+ }
+
+ TvClickableSurface(
+ onClick = {
+ if (!isTelevisionDevice) {
+ focusRequester.requestFocus()
+ keyboardController?.show()
+ return@TvClickableSurface
+ }
+ acceptsInput = true
+ pendingInputActivation = true
+ },
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Color.White.copy(alpha = 0.08f),
+ focusedContainerColor = Color.White.copy(alpha = 0.12f)
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
+ modifier = Modifier
+ .fillMaxWidth()
+ .onFocusChanged { hasContainerFocus = it.isFocused }
+ ) {
+ Box(modifier = Modifier.padding(horizontal = 12.dp, vertical = 10.dp)) {
+ if (value.isEmpty() && !isFocused) {
+ Text(placeholder, style = MaterialTheme.typography.bodyMedium, color = OnSurfaceDim)
+ }
+ BasicTextField(
+ value = fieldValue,
+ onValueChange = { updatedValue ->
+ val digitsOnly = updatedValue.text.filter(Char::isDigit).take(2)
+ fieldValue = updatedValue.copy(
+ text = digitsOnly,
+ selection = TextRange(digitsOnly.length.coerceAtMost(digitsOnly.length))
+ )
+ if (digitsOnly != value) {
+ onValueChange(digitsOnly)
+ }
+ },
+ textStyle = MaterialTheme.typography.bodyMedium.copy(color = Color.White),
+ singleLine = true,
+ cursorBrush = SolidColor(Primary),
+ keyboardOptions = KeyboardOptions(
+ keyboardType = KeyboardType.Number,
+ imeAction = ImeAction.Done
+ ),
+ keyboardActions = KeyboardActions(onDone = { keyboardController?.hide() }),
+ modifier = Modifier
+ .fillMaxWidth()
+ .focusRequester(focusRequester)
+ .focusProperties {
+ canFocus = !isTelevisionDevice || acceptsInput
+ if (isTelevisionDevice && acceptsInput) {
+ left = FocusRequester.Cancel
+ right = FocusRequester.Cancel
+ }
+ }
+ .onFocusChanged { focusState ->
+ hasInputFocus = focusState.isFocused
+ if (!focusState.isFocused && isTelevisionDevice) {
+ acceptsInput = false
+ }
+ },
+ decorationBox = { innerTextField ->
+ if (fieldValue.text.isEmpty() && isFocused) {
+ Text(
+ text = placeholder,
+ style = MaterialTheme.typography.bodyMedium,
+ color = OnSurfaceDim
+ )
+ }
+ innerTextField()
+ }
+ )
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsUiStateModel.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsUiStateModel.kt
new file mode 100644
index 00000000..c6e745b7
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsUiStateModel.kt
@@ -0,0 +1,102 @@
+package com.streamvault.app.ui.screens.settings
+
+import com.streamvault.app.ui.model.LiveTvChannelMode
+import com.streamvault.app.ui.model.LiveTvQuickFilterVisibilityMode
+import com.streamvault.app.ui.model.VodViewMode
+import com.streamvault.domain.manager.BackupImportPlan
+import com.streamvault.domain.manager.BackupPreview
+import com.streamvault.domain.model.ActiveLiveSource
+import com.streamvault.domain.model.AppTimeFormat
+import com.streamvault.domain.model.Category
+import com.streamvault.domain.model.CategorySortMode
+import com.streamvault.domain.model.ChannelNumberingMode
+import com.streamvault.domain.model.CombinedM3uProfile
+import com.streamvault.domain.model.ContentType
+import com.streamvault.domain.model.DecoderMode
+import com.streamvault.domain.model.EpgResolutionSummary
+import com.streamvault.domain.model.GroupedChannelLabelMode
+import com.streamvault.domain.model.LiveChannelGroupingMode
+import com.streamvault.domain.model.LiveVariantPreferenceMode
+import com.streamvault.domain.model.PlayerSurfaceMode
+import com.streamvault.domain.model.Provider
+import com.streamvault.domain.model.RecordingItem
+import com.streamvault.domain.model.RecordingStorageState
+
+data class SettingsUiState(
+ val providers: List<Provider> = emptyList(),
+ val combinedProfiles: List<CombinedM3uProfile> = emptyList(),
+ val availableM3uProviders: List<Provider> = emptyList(),
+ val activeProviderId: Long? = null,
+ val activeLiveSource: ActiveLiveSource? = null,
+ val isSyncing: Boolean = false,
+ val syncProgress: String? = null,
+ val syncingProviderName: String? = null,
+ val userMessage: String? = null,
+ val syncWarningsByProvider: Map<Long, List<String>> = emptyMap(),
+ val diagnosticsByProvider: Map<Long, ProviderDiagnosticsUiModel> = emptyMap(),
+ val databaseMaintenance: DatabaseMaintenanceUiModel? = null,
+ val parentalControlLevel: Int = 0,
+ val hasParentalPin: Boolean = false,
+ val appLanguage: String = "system",
+ val appTimeFormat: AppTimeFormat = AppTimeFormat.SYSTEM,
+ val preferredAudioLanguage: String = "auto",
+ val playerMediaSessionEnabled: Boolean = true,
+ val playerDecoderMode: DecoderMode = DecoderMode.AUTO,
+ val playerSurfaceMode: PlayerSurfaceMode = PlayerSurfaceMode.AUTO,
+ val playerPlaybackSpeed: Float = 1f,
+ val playerAudioVideoOffsetMs: Int = 0,
+ val playerControlsTimeoutSeconds: Int = 5,
+ val playerLiveOverlayTimeoutSeconds: Int = 4,
+ val playerNoticeTimeoutSeconds: Int = 6,
+ val playerDiagnosticsTimeoutSeconds: Int = 15,
+ val subtitleTextScale: Float = 1f,
+ val subtitleTextColor: Int = 0xFFFFFFFF.toInt(),
+ val subtitleBackgroundColor: Int = 0x80000000.toInt(),
+ val wifiMaxVideoHeight: Int? = null,
+ val ethernetMaxVideoHeight: Int? = null,
+ val playerTimeshiftEnabled: Boolean = false,
+ val playerTimeshiftDepthMinutes: Int = 30,
+ val defaultStopPlaybackTimerMinutes: Int = 0,
+ val defaultIdleStandbyTimerMinutes: Int = 0,
+ val lastSpeedTest: InternetSpeedTestUiModel? = null,
+ val isRunningInternetSpeedTest: Boolean = false,
+ val backupPreview: BackupPreview? = null,
+ val pendingBackupUri: String? = null,
+ val backupImportPlan: BackupImportPlan = BackupImportPlan(),
+ val recordingItems: List<RecordingItem> = emptyList(),
+ val recordingStorageState: RecordingStorageState = RecordingStorageState(),
+ val wifiOnlyRecording: Boolean = false,
+ val recordingPaddingBeforeMinutes: Int = 0,
+ val recordingPaddingAfterMinutes: Int = 0,
+ val isIncognitoMode: Boolean = false,
+ val useXtreamTextClassification: Boolean = true,
+ val xtreamBase64TextCompatibility: Boolean = false,
+ val liveTvChannelMode: LiveTvChannelMode = LiveTvChannelMode.PRO,
+ val showLiveSourceSwitcher: Boolean = false,
+ val showAllChannelsCategory: Boolean = true,
+ val showRecentChannelsCategory: Boolean = true,
+ val liveTvCategoryFilters: List<String> = emptyList(),
+ val liveTvQuickFilterVisibilityMode: LiveTvQuickFilterVisibilityMode = LiveTvQuickFilterVisibilityMode.ALWAYS_VISIBLE,
+ val liveChannelNumberingMode: ChannelNumberingMode = ChannelNumberingMode.GROUP,
+ val liveChannelGroupingMode: LiveChannelGroupingMode = LiveChannelGroupingMode.RAW_VARIANTS,
+ val groupedChannelLabelMode: GroupedChannelLabelMode = GroupedChannelLabelMode.HYBRID,
+ val liveVariantPreferenceMode: LiveVariantPreferenceMode = LiveVariantPreferenceMode.BALANCED,
+ val vodViewMode: VodViewMode = VodViewMode.MODERN,
+ val vodInfiniteScroll: Boolean = false,
+ val guideDefaultCategoryId: Long = com.streamvault.domain.model.VirtualCategoryIds.FAVORITES,
+ val guideDefaultCategoryOptions: List<Category> = emptyList(),
+ val preventStandbyDuringPlayback: Boolean = true,
+ val zapAutoRevert: Boolean = true,
+ val autoPlayNextEpisode: Boolean = true,
+ val categorySortModes: Map<ContentType, CategorySortMode> = emptyMap(),
+ val hiddenCategories: List<Category> = emptyList(),
+ val epgSources: List<com.streamvault.domain.model.EpgSource> = emptyList(),
+ val epgSourceAssignments: Map<Long, List<com.streamvault.domain.model.ProviderEpgSourceAssignment>> = emptyMap(),
+ val epgResolutionSummaries: Map<Long, EpgResolutionSummary> = emptyMap(),
+ val refreshingEpgSourceIds: Set<Long> = emptySet(),
+ val epgPendingDeleteSourceId: Long? = null,
+ val autoCheckAppUpdates: Boolean = true,
+ val autoDownloadAppUpdates: Boolean = false,
+ val isCheckingForUpdates: Boolean = false,
+ val appUpdate: AppUpdateUiModel = AppUpdateUiModel()
+)
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsValueDialogs.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsValueDialogs.kt
new file mode 100644
index 00000000..e9be6560
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsValueDialogs.kt
@@ -0,0 +1,156 @@
+package com.streamvault.app.ui.screens.settings
+
+import android.content.Context
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.saveable.rememberSaveable
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.unit.dp
+import androidx.tv.material3.MaterialTheme
+import androidx.tv.material3.Text
+import com.streamvault.app.R
+import com.streamvault.app.ui.components.dialogs.PremiumDialog
+import com.streamvault.app.ui.components.dialogs.PremiumDialogActionButton
+import com.streamvault.app.ui.components.dialogs.PremiumDialogFooterButton
+import com.streamvault.app.ui.theme.Primary
+
+internal fun formatPlaybackTimerMinutesLabel(minutes: Int, context: Context): String {
+ return if (minutes <= 0) {
+ context.getString(R.string.settings_timer_off)
+ } else {
+ context.resources.getQuantityString(R.plurals.settings_timer_minutes, minutes, minutes)
+ }
+}
+
+@Composable
+internal fun PlaybackTimerPresetDialog(
+ title: String,
+ selectedMinutes: Int,
+ onDismiss: () -> Unit,
+ onSelect: (Int) -> Unit
+) {
+ val context = LocalContext.current
+ val options = remember { listOf(0, 15, 30, 45, 60, 90, 120) }
+
+ PremiumSelectionDialog(
+ title = title,
+ onDismiss = onDismiss
+ ) {
+ options.forEachIndexed { index, minutes ->
+ LevelOption(
+ level = index,
+ text = formatPlaybackTimerMinutesLabel(minutes, context),
+ currentLevel = if (selectedMinutes == minutes) index else -1,
+ onSelect = { onSelect(minutes) }
+ )
+ }
+ }
+}
+
+internal fun formatAudioVideoOffsetLabel(offsetMs: Int): String = when {
+ offsetMs > 0 -> "+$offsetMs ms"
+ offsetMs < 0 -> "$offsetMs ms"
+ else -> "0 ms"
+}
+
+@Composable
+internal fun AudioVideoOffsetValueDialog(
+ title: String,
+ subtitle: String,
+ initialValue: Int,
+ onDismiss: () -> Unit,
+ onConfirm: (Int) -> Unit
+) {
+ var value by rememberSaveable(initialValue) { mutableStateOf(initialValue.coerceIn(-2_000, 2_000)) }
+
+ PremiumDialog(
+ title = title,
+ subtitle = subtitle,
+ onDismissRequest = onDismiss,
+ widthFraction = 0.42f,
+ content = {
+ Column(verticalArrangement = Arrangement.spacedBy(14.dp)) {
+ Text(
+ text = formatAudioVideoOffsetLabel(value),
+ style = MaterialTheme.typography.headlineSmall,
+ color = Primary
+ )
+ Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
+ PremiumDialogFooterButton(
+ label = "-50",
+ onClick = { value = (value - 50).coerceAtLeast(-2_000) }
+ )
+ PremiumDialogFooterButton(
+ label = "+50",
+ onClick = { value = (value + 50).coerceAtMost(2_000) }
+ )
+ PremiumDialogFooterButton(
+ label = stringResource(R.string.settings_reset),
+ onClick = { value = 0 }
+ )
+ }
+ }
+ },
+ footer = {
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.spacedBy(12.dp, Alignment.End)
+ ) {
+ PremiumDialogFooterButton(
+ label = stringResource(R.string.settings_cancel),
+ onClick = onDismiss
+ )
+ PremiumDialogFooterButton(
+ label = stringResource(R.string.settings_save),
+ onClick = { onConfirm(value) }
+ )
+ }
+ }
+ )
+}
+
+@Composable
+internal fun SimpleTextValueDialog(
+ title: String,
+ subtitle: String,
+ initialValue: String,
+ onDismiss: () -> Unit,
+ onConfirm: (String) -> Unit
+) {
+ var value by remember(initialValue) { mutableStateOf(initialValue) }
+ PremiumDialog(
+ title = title,
+ subtitle = subtitle,
+ onDismissRequest = onDismiss,
+ widthFraction = 0.58f,
+ content = {
+ EpgSourceTextField(
+ value = value,
+ onValueChange = { value = it },
+ placeholder = initialValue
+ )
+ },
+ footer = {
+ Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) {
+ PremiumDialogFooterButton(
+ label = stringResource(R.string.settings_cancel),
+ onClick = onDismiss
+ )
+ PremiumDialogActionButton(
+ label = stringResource(R.string.settings_save),
+ onClick = { onConfirm(value.trim()) }
+ )
+ }
+ }
+ )
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsViewModel.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsViewModel.kt
index 2d2d80b8..ee212d04 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsViewModel.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsViewModel.kt
@@ -6,7 +6,6 @@ import androidx.lifecycle.viewModelScope
import com.streamvault.app.R
import com.streamvault.app.BuildConfig
import com.streamvault.app.tvinput.TvInputChannelSyncManager
-import com.streamvault.app.ui.model.applyProviderCategoryDisplayPreferences
import com.streamvault.app.ui.model.LiveTvChannelMode
import com.streamvault.app.ui.model.LiveTvQuickFilterVisibilityMode
import com.streamvault.app.ui.model.VodViewMode
@@ -136,6 +135,46 @@ class SettingsViewModel @Inject constructor(
)
init {
+ registerPreferenceObservers()
+ registerSettingsAppUpdateObservers(
+ scope = viewModelScope,
+ preferencesRepository = preferencesRepository,
+ appUpdateActions = appUpdateActions,
+ appUpdateInstaller = appUpdateInstaller,
+ uiState = _uiState
+ )
+ registerCombinedProfileObservers(
+ scope = viewModelScope,
+ combinedM3uRepository = combinedM3uRepository,
+ uiState = _uiState
+ )
+ registerDerivedStateObservers(
+ scope = viewModelScope,
+ providerRepository = providerRepository,
+ syncMetadataRepository = syncMetadataRepository,
+ application = appContext,
+ preferencesRepository = preferencesRepository,
+ activeProviderIdFlow = activeProviderIdFlow,
+ categoryRepository = categoryRepository,
+ combinedM3uRepository = combinedM3uRepository,
+ channelRepository = channelRepository,
+ getCustomCategories = getCustomCategories,
+ uiState = _uiState
+ )
+ registerRecordingObservers(
+ scope = viewModelScope,
+ recordingManager = recordingManager,
+ preferencesRepository = preferencesRepository,
+ uiState = _uiState
+ )
+ registerEpgObservers(
+ scope = viewModelScope,
+ epgSourceRepository = epgSourceRepository,
+ uiState = _uiState
+ )
+ }
+
+ private fun registerPreferenceObservers() {
viewModelScope.launch {
observeSettingsPreferenceSnapshot(
providerRepository = providerRepository,
@@ -145,128 +184,6 @@ class SettingsViewModel @Inject constructor(
_uiState.update { it.applyPreferenceSnapshot(snapshot) }
}
}
-
- viewModelScope.launch {
- combine(
- preferencesRepository.autoCheckAppUpdates,
- preferencesRepository.lastAppUpdateCheckTimestamp,
- preferencesRepository.autoDownloadAppUpdates
- ) { autoCheckEnabled, lastCheckedAt, autoDownload ->
- Triple(autoCheckEnabled, lastCheckedAt, autoDownload)
- }.distinctUntilChanged().collect { (autoCheckEnabled, lastCheckedAt, autoDownload) ->
- if (autoCheckEnabled && appUpdateActions.shouldAutoCheckForUpdates(lastCheckedAt)) {
- appUpdateActions.checkForAppUpdates(
- scope = viewModelScope,
- manual = false,
- isRemoteVersionNewer = ::isRemoteVersionNewer,
- autoDownload = autoDownload
- )
- }
- }
- }
-
- viewModelScope.launch {
- appUpdateInstaller.downloadState.collect { downloadState ->
- _uiState.update {
- it.copy(appUpdate = it.appUpdate.withDownloadState(downloadState))
- }
- }
- }
-
- viewModelScope.launch {
- appUpdateInstaller.refreshState()
- }
-
- viewModelScope.launch {
- combinedM3uRepository.getProfiles().collect { profiles ->
- _uiState.update { it.copy(combinedProfiles = profiles) }
- }
- }
-
- viewModelScope.launch {
- combinedM3uRepository.getAvailableM3uProviders().collect { providers ->
- _uiState.update { it.copy(availableM3uProviders = providers) }
- }
- }
-
- viewModelScope.launch {
- combinedM3uRepository.getActiveLiveSource().collect { activeSource ->
- _uiState.update { it.copy(activeLiveSource = activeSource) }
- }
- }
-
- viewModelScope.launch {
- observeProviderDiagnostics(
- providerRepository = providerRepository,
- syncMetadataRepository = syncMetadataRepository,
- application = appContext
- ).collect { diagnosticsByProvider ->
- _uiState.update { it.copy(diagnosticsByProvider = diagnosticsByProvider) }
- }
- }
-
- viewModelScope.launch {
- preferencesRepository.lastMaintenanceSnapshot.collect { snapshot ->
- _uiState.update { it.copy(databaseMaintenance = snapshot?.toUiModel()) }
- }
- }
-
- viewModelScope.launch {
- observeCategoryManagement(
- activeProviderIdFlow = activeProviderIdFlow,
- preferencesRepository = preferencesRepository,
- categoryRepository = categoryRepository
- ).collect { snapshot ->
- _uiState.update {
- it.copy(
- categorySortModes = snapshot.categorySortModes,
- hiddenCategories = snapshot.hiddenCategories
- )
- }
- }
- }
-
- viewModelScope.launch {
- observeGuideDefaultCategoryOptions().collect { categories ->
- _uiState.update { it.copy(guideDefaultCategoryOptions = categories) }
- }
- }
-
- viewModelScope.launch {
- recordingManager.observeRecordingItems().collect { items ->
- _uiState.update { it.copy(recordingItems = items.sortedByDescending(RecordingItem::scheduledStartMs)) }
- }
- }
-
- viewModelScope.launch {
- recordingManager.observeStorageState().collect { storage ->
- _uiState.update { it.copy(recordingStorageState = storage) }
- }
- }
-
- viewModelScope.launch {
- preferencesRepository.recordingWifiOnly.collect { wifiOnly ->
- _uiState.update { it.copy(wifiOnlyRecording = wifiOnly) }
- }
- }
-
- viewModelScope.launch {
- preferencesRepository.recordingPaddingBeforeMinutes.collect { minutes ->
- _uiState.update { it.copy(recordingPaddingBeforeMinutes = minutes) }
- }
- }
-
- viewModelScope.launch {
- preferencesRepository.recordingPaddingAfterMinutes.collect { minutes ->
- _uiState.update { it.copy(recordingPaddingAfterMinutes = minutes) }
- }
- }
-
- viewModelScope.launch {
- epgSourceRepository.getAllSources().collect { sources ->
- _uiState.update { it.copy(epgSources = sources) }
- }
- }
}
fun setActiveProvider(providerId: Long) {
@@ -778,27 +695,6 @@ class SettingsViewModel @Inject constructor(
_uiState.update { it.copy(userMessage = null) }
}
- private fun isRemoteVersionNewer(remoteVersionCode: Int?, remoteVersionName: String): Boolean {
- if (remoteVersionCode != null && remoteVersionCode > BuildConfig.VERSION_CODE) {
- return true
- }
- return compareVersionNames(remoteVersionName, BuildConfig.VERSION_NAME) > 0
- }
-
- private fun compareVersionNames(left: String, right: String): Int {
- val leftParts = left.removePrefix("v").split('.')
- val rightParts = right.removePrefix("v").split('.')
- val length = max(leftParts.size, rightParts.size)
- for (index in 0 until length) {
- val leftValue = leftParts.getOrNull(index)?.toIntOrNull() ?: 0
- val rightValue = rightParts.getOrNull(index)?.toIntOrNull() ?: 0
- if (leftValue != rightValue) {
- return leftValue.compareTo(rightValue)
- }
- }
- return 0
- }
-
fun exportConfig(uriString: String) {
backupActions.exportConfig(viewModelScope, uriString)
}
@@ -929,83 +825,4 @@ class SettingsViewModel @Inject constructor(
epgActions.moveEpgSourceAssignmentDown(viewModelScope, providerId, epgSourceId)
}
- private fun observeGuideDefaultCategoryOptions(): Flow<List<Category>> {
- return combinedM3uRepository.getActiveLiveSource().flatMapLatest { activeSource ->
- when (activeSource) {
- is ActiveLiveSource.CombinedM3uSource -> {
- combine(
- combinedM3uRepository.getCombinedCategories(activeSource.profileId),
- flow {
- emit(combinedM3uRepository.getProfile(activeSource.profileId)?.members.orEmpty())
- }.flatMapLatest { members ->
- getCustomCategories(
- members.filter { it.enabled }.map { it.providerId },
- ContentType.LIVE
- )
- }
- ) { combinedCategories, customCategories ->
- buildGuideDefaultCategoryOptions(
- physicalCategories = combinedCategories.map { it.category },
- customCategories = customCategories
- )
- }
- }
- is ActiveLiveSource.ProviderSource -> {
- combine(
- channelRepository.getCategories(activeSource.providerId),
- getCustomCategories(activeSource.providerId, ContentType.LIVE),
- preferencesRepository.getHiddenCategoryIds(activeSource.providerId, ContentType.LIVE),
- preferencesRepository.getCategorySortMode(activeSource.providerId, ContentType.LIVE)
- ) { categories, customCategories, hiddenCategoryIds, sortMode ->
- val visibleProviderCategories = applyProviderCategoryDisplayPreferences(
- categories = categories.filter { it.id != ChannelRepository.ALL_CHANNELS_ID },
- hiddenCategoryIds = hiddenCategoryIds,
- sortMode = sortMode
- )
- buildGuideDefaultCategoryOptions(
- physicalCategories = visibleProviderCategories,
- customCategories = customCategories
- )
- }
- }
- null -> flowOf(
- listOf(
- Category(
- id = VirtualCategoryIds.FAVORITES,
- name = "Favorites",
- type = ContentType.LIVE,
- isVirtual = true
- ),
- Category(
- id = ChannelRepository.ALL_CHANNELS_ID,
- name = "All Channels",
- type = ContentType.LIVE
- )
- )
- )
- }
- }
- }
-
- private fun buildGuideDefaultCategoryOptions(
- physicalCategories: List<Category>,
- customCategories: List<Category>
- ): List<Category> {
- val favorites = customCategories.find { it.id == VirtualCategoryIds.FAVORITES }
- return buildList {
- if (favorites != null) {
- add(favorites)
- }
- addAll(customCategories.filter { it.id != VirtualCategoryIds.FAVORITES })
- add(
- Category(
- id = ChannelRepository.ALL_CHANNELS_ID,
- name = "All Channels",
- type = ContentType.LIVE,
- count = physicalCategories.sumOf(Category::count)
- )
- )
- addAll(physicalCategories)
- }
- }
}
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsViewModelModels.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsViewModelModels.kt
deleted file mode 100644
index ee259be4..00000000
--- a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsViewModelModels.kt
+++ /dev/null
@@ -1,362 +0,0 @@
-package com.streamvault.app.ui.screens.settings
-
-import android.app.Application
-import com.streamvault.app.BuildConfig
-import com.streamvault.app.R
-import com.streamvault.app.ui.model.LiveTvChannelMode
-import com.streamvault.app.ui.model.LiveTvQuickFilterVisibilityMode
-import com.streamvault.app.ui.model.VodViewMode
-import com.streamvault.app.update.AppUpdateDownloadState
-import com.streamvault.app.update.AppUpdateDownloadStatus
-import com.streamvault.app.update.GitHubReleaseInfo
-import com.streamvault.data.preferences.DatabaseMaintenanceSnapshot
-import com.streamvault.domain.manager.BackupImportPlan
-import com.streamvault.domain.manager.BackupPreview
-import com.streamvault.domain.model.ActiveLiveSource
-import com.streamvault.domain.model.AppTimeFormat
-import com.streamvault.domain.model.Category
-import com.streamvault.domain.model.CategorySortMode
-import com.streamvault.domain.model.ChannelNumberingMode
-import com.streamvault.domain.model.CombinedM3uProfile
-import com.streamvault.domain.model.ContentType
-import com.streamvault.domain.model.DecoderMode
-import com.streamvault.domain.model.EpgResolutionSummary
-import com.streamvault.domain.model.GroupedChannelLabelMode
-import com.streamvault.domain.model.LiveChannelGroupingMode
-import com.streamvault.domain.model.LiveVariantPreferenceMode
-import com.streamvault.domain.model.PlayerSurfaceMode
-import com.streamvault.domain.model.Provider
-import com.streamvault.domain.model.RecordingItem
-import com.streamvault.domain.model.RecordingStorageState
-import com.streamvault.domain.model.VodSyncMode
-import kotlin.math.max
-
-enum class ProviderWarningAction {
- EPG,
- MOVIES,
- SERIES
-}
-
-enum class ProviderSyncSelection {
- ALL,
- FAST,
- TV,
- MOVIES,
- SERIES,
- EPG
-}
-
-internal data class SettingsPreferenceSnapshot(
- val providers: List<Provider>,
- val activeProviderId: Long?,
- val parentalControlLevel: Int,
- val hasParentalPin: Boolean,
- val appLanguage: String,
- val appTimeFormat: AppTimeFormat,
- val preferredAudioLanguage: String,
- val playerMediaSessionEnabled: Boolean,
- val playerDecoderMode: DecoderMode,
- val playerSurfaceMode: PlayerSurfaceMode,
- val playerPlaybackSpeed: Float,
- val playerAudioVideoOffsetMs: Int,
- val playerControlsTimeoutSeconds: Int,
- val playerLiveOverlayTimeoutSeconds: Int,
- val playerNoticeTimeoutSeconds: Int,
- val playerDiagnosticsTimeoutSeconds: Int,
- val subtitleTextScale: Float,
- val subtitleTextColor: Int,
- val subtitleBackgroundColor: Int,
- val wifiMaxVideoHeight: Int?,
- val ethernetMaxVideoHeight: Int?,
- val playerTimeshiftEnabled: Boolean,
- val playerTimeshiftDepthMinutes: Int,
- val defaultStopPlaybackTimerMinutes: Int,
- val defaultIdleStandbyTimerMinutes: Int,
- val lastSpeedTestMegabits: Double?,
- val lastSpeedTestTimestamp: Long?,
- val lastSpeedTestTransport: String?,
- val lastSpeedTestRecommendedHeight: Int?,
- val lastSpeedTestEstimated: Boolean,
- val isIncognitoMode: Boolean,
- val useXtreamTextClassification: Boolean,
- val xtreamBase64TextCompatibility: Boolean,
- val liveTvChannelMode: LiveTvChannelMode,
- val showLiveSourceSwitcher: Boolean,
- val showAllChannelsCategory: Boolean,
- val showRecentChannelsCategory: Boolean,
- val liveTvCategoryFilters: List<String>,
- val liveTvQuickFilterVisibilityMode: LiveTvQuickFilterVisibilityMode,
- val liveChannelNumberingMode: ChannelNumberingMode,
- val liveChannelGroupingMode: LiveChannelGroupingMode,
- val groupedChannelLabelMode: GroupedChannelLabelMode,
- val liveVariantPreferenceMode: LiveVariantPreferenceMode,
- val vodViewMode: VodViewMode,
- val vodInfiniteScroll: Boolean,
- val guideDefaultCategoryId: Long,
- val guideDefaultCategoryOptions: List<Category>,
- val preventStandbyDuringPlayback: Boolean,
- val zapAutoRevert: Boolean,
- val autoPlayNextEpisode: Boolean,
- val autoCheckAppUpdates: Boolean,
- val autoDownloadAppUpdates: Boolean,
- val lastAppUpdateCheckAt: Long?,
- val cachedAppUpdateVersionName: String?,
- val cachedAppUpdateVersionCode: Int?,
- val cachedAppUpdateReleaseUrl: String?,
- val cachedAppUpdateDownloadUrl: String?,
- val cachedAppUpdateReleaseNotes: String,
- val cachedAppUpdatePublishedAt: String?
-)
-
-data class AppUpdateUiModel(
- val latestVersionName: String? = null,
- val latestVersionCode: Int? = null,
- val releaseUrl: String? = null,
- val downloadUrl: String? = null,
- val releaseNotes: String = "",
- val publishedAt: String? = null,
- val isUpdateAvailable: Boolean = false,
- val lastCheckedAt: Long? = null,
- val errorMessage: String? = null,
- val downloadStatus: AppUpdateDownloadStatus = AppUpdateDownloadStatus.Idle,
- val downloadedVersionName: String? = null
-)
-
-data class ProviderDiagnosticsUiModel(
- val lastSyncStatus: String = "NONE",
- val lastLiveSync: Long = 0L,
- val lastMovieSync: Long = 0L,
- val lastMovieAttempt: Long = 0L,
- val lastMovieSuccess: Long = 0L,
- val lastMoviePartial: Long = 0L,
- val lastSeriesSync: Long = 0L,
- val lastEpgSync: Long = 0L,
- val liveCount: Int = 0,
- val movieCount: Int = 0,
- val seriesCount: Int = 0,
- val epgCount: Int = 0,
- val movieSyncMode: VodSyncMode = VodSyncMode.UNKNOWN,
- val movieWarningsCount: Int = 0,
- val movieCatalogStale: Boolean = false,
- val liveSequentialFailuresRemembered: Boolean = false,
- val liveHealthySyncStreak: Int = 0,
- val movieParallelFailuresRemembered: Boolean = false,
- val movieHealthySyncStreak: Int = 0,
- val seriesSequentialFailuresRemembered: Boolean = false,
- val seriesHealthySyncStreak: Int = 0,
- val capabilitySummary: String = "",
- val sourceLabel: String = "",
- val expirySummary: String = "",
- val connectionSummary: String = "",
- val archiveSummary: String = ""
-) {
- val hasHealthWarning: Boolean
- get() = liveSequentialFailuresRemembered ||
- movieParallelFailuresRemembered ||
- seriesSequentialFailuresRemembered ||
- movieCatalogStale ||
- movieWarningsCount > 0
-}
-
-data class DatabaseMaintenanceUiModel(
- val ranAt: Long,
- val deletedPrograms: Int,
- val deletedExternalProgrammes: Int,
- val deletedOrphanEpisodes: Int,
- val deletedStaleFavorites: Int,
- val vacuumRan: Boolean,
- val mainDbBytes: Long,
- val walBytes: Long,
- val reclaimableBytes: Long,
- val channelRows: Long,
- val movieRows: Long,
- val seriesRows: Long,
- val episodeRows: Long,
- val programRows: Long,
- val epgProgrammeRows: Long,
- val playbackHistoryRows: Long,
- val favoriteRows: Long
-)
-
-internal fun DatabaseMaintenanceSnapshot.toUiModel(): DatabaseMaintenanceUiModel =
- DatabaseMaintenanceUiModel(
- ranAt = ranAt,
- deletedPrograms = deletedPrograms,
- deletedExternalProgrammes = deletedExternalProgrammes,
- deletedOrphanEpisodes = deletedOrphanEpisodes,
- deletedStaleFavorites = deletedStaleFavorites,
- vacuumRan = vacuumRan,
- mainDbBytes = mainDbBytes,
- walBytes = walBytes,
- reclaimableBytes = reclaimableBytes,
- channelRows = channelRows,
- movieRows = movieRows,
- seriesRows = seriesRows,
- episodeRows = episodeRows,
- programRows = programRows,
- epgProgrammeRows = epgProgrammeRows,
- playbackHistoryRows = playbackHistoryRows,
- favoriteRows = favoriteRows
- )
-
-data class SettingsUiState(
- val providers: List<Provider> = emptyList(),
- val combinedProfiles: List<CombinedM3uProfile> = emptyList(),
- val availableM3uProviders: List<Provider> = emptyList(),
- val activeProviderId: Long? = null,
- val activeLiveSource: ActiveLiveSource? = null,
- val isSyncing: Boolean = false,
- val syncProgress: String? = null,
- val syncingProviderName: String? = null,
- val userMessage: String? = null,
- val syncWarningsByProvider: Map<Long, List<String>> = emptyMap(),
- val diagnosticsByProvider: Map<Long, ProviderDiagnosticsUiModel> = emptyMap(),
- val databaseMaintenance: DatabaseMaintenanceUiModel? = null,
- val parentalControlLevel: Int = 0,
- val hasParentalPin: Boolean = false,
- val appLanguage: String = "system",
- val appTimeFormat: AppTimeFormat = AppTimeFormat.SYSTEM,
- val preferredAudioLanguage: String = "auto",
- val playerMediaSessionEnabled: Boolean = true,
- val playerDecoderMode: DecoderMode = DecoderMode.AUTO,
- val playerSurfaceMode: PlayerSurfaceMode = PlayerSurfaceMode.AUTO,
- val playerPlaybackSpeed: Float = 1f,
- val playerAudioVideoOffsetMs: Int = 0,
- val playerControlsTimeoutSeconds: Int = 5,
- val playerLiveOverlayTimeoutSeconds: Int = 4,
- val playerNoticeTimeoutSeconds: Int = 6,
- val playerDiagnosticsTimeoutSeconds: Int = 15,
- val subtitleTextScale: Float = 1f,
- val subtitleTextColor: Int = 0xFFFFFFFF.toInt(),
- val subtitleBackgroundColor: Int = 0x80000000.toInt(),
- val wifiMaxVideoHeight: Int? = null,
- val ethernetMaxVideoHeight: Int? = null,
- val playerTimeshiftEnabled: Boolean = false,
- val playerTimeshiftDepthMinutes: Int = 30,
- val defaultStopPlaybackTimerMinutes: Int = 0,
- val defaultIdleStandbyTimerMinutes: Int = 0,
- val lastSpeedTest: InternetSpeedTestUiModel? = null,
- val isRunningInternetSpeedTest: Boolean = false,
- val backupPreview: BackupPreview? = null,
- val pendingBackupUri: String? = null,
- val backupImportPlan: BackupImportPlan = BackupImportPlan(),
- val recordingItems: List<RecordingItem> = emptyList(),
- val recordingStorageState: RecordingStorageState = RecordingStorageState(),
- val wifiOnlyRecording: Boolean = false,
- val recordingPaddingBeforeMinutes: Int = 0,
- val recordingPaddingAfterMinutes: Int = 0,
- val isIncognitoMode: Boolean = false,
- val useXtreamTextClassification: Boolean = true,
- val xtreamBase64TextCompatibility: Boolean = false,
- val liveTvChannelMode: LiveTvChannelMode = LiveTvChannelMode.PRO,
- val showLiveSourceSwitcher: Boolean = false,
- val showAllChannelsCategory: Boolean = true,
- val showRecentChannelsCategory: Boolean = true,
- val liveTvCategoryFilters: List<String> = emptyList(),
- val liveTvQuickFilterVisibilityMode: LiveTvQuickFilterVisibilityMode = LiveTvQuickFilterVisibilityMode.ALWAYS_VISIBLE,
- val liveChannelNumberingMode: ChannelNumberingMode = ChannelNumberingMode.GROUP,
- val liveChannelGroupingMode: LiveChannelGroupingMode = LiveChannelGroupingMode.RAW_VARIANTS,
- val groupedChannelLabelMode: GroupedChannelLabelMode = GroupedChannelLabelMode.HYBRID,
- val liveVariantPreferenceMode: LiveVariantPreferenceMode = LiveVariantPreferenceMode.BALANCED,
- val vodViewMode: VodViewMode = VodViewMode.MODERN,
- val vodInfiniteScroll: Boolean = false,
- val guideDefaultCategoryId: Long = com.streamvault.domain.model.VirtualCategoryIds.FAVORITES,
- val guideDefaultCategoryOptions: List<Category> = emptyList(),
- val preventStandbyDuringPlayback: Boolean = true,
- val zapAutoRevert: Boolean = true,
- val autoPlayNextEpisode: Boolean = true,
- val categorySortModes: Map<ContentType, CategorySortMode> = emptyMap(),
- val hiddenCategories: List<Category> = emptyList(),
- val epgSources: List<com.streamvault.domain.model.EpgSource> = emptyList(),
- val epgSourceAssignments: Map<Long, List<com.streamvault.domain.model.ProviderEpgSourceAssignment>> = emptyMap(),
- val epgResolutionSummaries: Map<Long, EpgResolutionSummary> = emptyMap(),
- val refreshingEpgSourceIds: Set<Long> = emptySet(),
- val epgPendingDeleteSourceId: Long? = null,
- val autoCheckAppUpdates: Boolean = true,
- val autoDownloadAppUpdates: Boolean = false,
- val isCheckingForUpdates: Boolean = false,
- val appUpdate: AppUpdateUiModel = AppUpdateUiModel()
-)
-
-internal fun AppUpdateUiModel.toReleaseInfoOrNull(): GitHubReleaseInfo? {
- val versionName = latestVersionName ?: return null
- val releaseUrl = releaseUrl ?: return null
- return GitHubReleaseInfo(
- versionName = versionName,
- versionCode = latestVersionCode,
- releaseUrl = releaseUrl,
- downloadUrl = downloadUrl,
- releaseNotes = releaseNotes,
- publishedAt = publishedAt
- )
-}
-
-internal fun AppUpdateUiModel.withDownloadState(downloadState: AppUpdateDownloadState): AppUpdateUiModel {
- return copy(
- downloadStatus = downloadState.status,
- downloadedVersionName = downloadState.versionName
- )
-}
-
-internal fun AppUpdateUiModel.toDownloadState(): AppUpdateDownloadState {
- return AppUpdateDownloadState(
- status = downloadStatus,
- versionName = downloadedVersionName
- )
-}
-
-internal fun SettingsPreferenceSnapshot.toCachedAppUpdateUiModel(): AppUpdateUiModel {
- val versionName = cachedAppUpdateVersionName
- return AppUpdateUiModel(
- latestVersionName = versionName,
- latestVersionCode = cachedAppUpdateVersionCode,
- releaseUrl = cachedAppUpdateReleaseUrl,
- downloadUrl = cachedAppUpdateDownloadUrl,
- releaseNotes = cachedAppUpdateReleaseNotes,
- publishedAt = cachedAppUpdatePublishedAt,
- isUpdateAvailable = versionName?.let {
- if (cachedAppUpdateVersionCode != null && cachedAppUpdateVersionCode > BuildConfig.VERSION_CODE) {
- true
- } else {
- compareVersionNamesStatic(it, BuildConfig.VERSION_NAME) > 0
- }
- } ?: false,
- lastCheckedAt = lastAppUpdateCheckAt
- )
-}
-
-internal fun compareVersionNamesStatic(left: String, right: String): Int {
- val leftParts = left.removePrefix("v").split('.')
- val rightParts = right.removePrefix("v").split('.')
- val length = max(leftParts.size, rightParts.size)
- for (index in 0 until length) {
- val leftValue = leftParts.getOrNull(index)?.toIntOrNull() ?: 0
- val rightValue = rightParts.getOrNull(index)?.toIntOrNull() ?: 0
- if (leftValue != rightValue) {
- return leftValue.compareTo(rightValue)
- }
- }
- return 0
-}
-
-internal fun ProviderSyncSelection.label(application: Application): String = when (this) {
- ProviderSyncSelection.ALL -> application.getString(R.string.settings_sync_option_all)
- ProviderSyncSelection.FAST -> application.getString(R.string.settings_sync_option_fast)
- ProviderSyncSelection.TV -> application.getString(R.string.settings_sync_option_tv)
- ProviderSyncSelection.MOVIES -> application.getString(R.string.settings_sync_option_movies)
- ProviderSyncSelection.SERIES -> application.getString(R.string.settings_sync_option_series)
- ProviderSyncSelection.EPG -> application.getString(R.string.settings_sync_option_epg)
-}
-
-data class InternetSpeedTestUiModel(
- val megabitsPerSecond: Double,
- val measuredAtMs: Long,
- val transportLabel: String,
- val recommendedMaxVideoHeight: Int?,
- val isEstimated: Boolean
-)
-
-internal data class CategoryManagementSnapshot(
- val categorySortModes: Map<ContentType, CategorySortMode> = emptyMap(),
- val hiddenCategories: List<Category> = emptyList()
-)
diff --git a/docs/settings-refactor-review-checklist.md b/docs/settings-refactor-review-checklist.md
new file mode 100644
index 00000000..c608de7f
--- /dev/null
+++ b/docs/settings-refactor-review-checklist.md
@@ -0,0 +1,111 @@
+# Settings Refactor Review Checklist
+
+Generated from the current working tree against `master` on 2026-04-29.
+
+Use this file in phases:
+
+1. Compare each extracted file against the original logic on `master` and tick `Drift` when behavior still matches.
+2. Check the current branch entrypoints and call sites, then tick `Wiring` when the new file is connected in the right place.
+3. Tick `Done` only after both checks are complete for that row.
+
+## Phase 1: Orchestration And State Wiring
+
+Reviewed on 2026-04-29. No drift or wiring findings recorded in this phase.
+
+| Done | Drift | Wiring | Status | File | Focus |
+| --- | --- | --- | --- | --- | --- |
+| [x] | [x] | [x] | modified | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreen.kt | top-level settings screen composition |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsContentPane.kt | category-to-section content routing |
+| [x] | [x] | [x] | modified | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreenDialogs.kt | dialog wiring hub |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreenOverlays.kt | overlay and browser dialog wiring |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreenDialogState.kt | remembered dialog and screen state |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreenState.kt | derived labels and screen helpers |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsNavigationRail.kt | navigation rail extraction |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsUiStateModel.kt | main `SettingsUiState` home |
+| [x] | [x] | [x] | modified | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsViewModel.kt | registration entrypoints and main coordinator |
+| [x] | [x] | [x] | modified | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsStateBindings.kt | preference snapshot observation surface |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsObserverRegistrations.kt | observer registration splits |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsDerivedStateObservers.kt | provider diagnostics and category derived flows |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsGuideDefaultCategoryBindings.kt | guide category options flow |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsPreferenceSnapshotMapper.kt | snapshot-to-ui-state mapping |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsPreferenceModels.kt | preference snapshot and sync enums |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsOperationalModels.kt | diagnostics and maintenance models |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsAppUpdateModels.kt | app update model split |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsAppUpdateFormatting.kt | app update label formatting |
+
+## Phase 2: Shared UI And Dialog Infrastructure
+
+Reviewed on 2026-04-29. No drift or wiring findings recorded in this phase.
+
+| Done | Drift | Wiring | Status | File | Focus |
+| --- | --- | --- | --- | --- | --- |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRowComponents.kt | reusable settings rows and quick-filter dialog |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsSelectionDialogComponents.kt | selection dialog shell and level options |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsSelectionDialogs.kt | quality and sort selection dialogs |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsSharedUiComponents.kt | shared chips, overview cards, text field |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsFormatting.kt | shared formatting helpers |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsTimeoutValueDialog.kt | timeout editing dialog |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsValueDialogs.kt | timer, offset, and text value dialogs |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsModeDialogs.kt | mode picker dialogs |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsPlayerPreferenceDialogs.kt | player preference dialog bundle |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsPreferenceDialogs.kt | preference dialog aggregation |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProtectionDialogs.kt | parental PIN and level dialogs |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsLiveTvComponents.kt | live TV and parental card components |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsBackupAboutSections.kt | backup and about sections |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsBackupImportPreviewDialog.kt | backup import preview dialog |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsSyncOverlay.kt | sync blocking overlay |
+
+## Phase 3: Browsing, Provider, And EPG Slices
+
+Reviewed on 2026-04-29. No drift or wiring findings recorded in this phase.
+
+| Done | Drift | Wiring | Status | File | Focus |
+| --- | --- | --- | --- | --- | --- |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsBrowsingSection.kt | browsing section extraction |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsPlaybackSection.kt | playback section extraction |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsPrivacySection.kt | privacy section extraction |
+| [x] | [x] | [x] | modified | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderSection.kt | provider section orchestration |
+| [x] | [x] | [x] | modified | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderComponents.kt | provider component call sites |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderUiComponents.kt | provider tabs, badges, compact stats |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderCardSections.kt | provider actions and warning panels |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderDiagnosticsPanel.kt | provider diagnostics rendering |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderManagementDialogs.kt | provider management dialog wiring |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderSyncDialogs.kt | provider sync dialog flows |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsCombinedM3uComponents.kt | combined M3U widgets and dialogs |
+| [x] | [x] | [x] | modified | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsEpgSection.kt | EPG section orchestration |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsEpgAssignmentComponents.kt | provider assignment UI |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsEpgSourceComponents.kt | EPG source cards and add flow |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsInternetSpeedTestCard.kt | speed test card extraction |
+
+## Phase 4: Recording Slice
+
+Reviewed on 2026-04-29. Clean after restoring dialog ownership to the top-level settings dialog hub.
+
+| Done | Drift | Wiring | Status | File | Focus |
+| --- | --- | --- | --- | --- | --- |
+| [x] | [x] | [x] | modified | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingComponents.kt | legacy recording component call sites |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingSection.kt | recording section and browser entrypoint |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingDialogs.kt | recording-related dialogs |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingDashboardCards.kt | dashboard cards |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingItemComponents.kt | recording item cards and actions |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingBrowserDialog.kt | recording browser shell |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingBrowserDisplay.kt | browser display helpers |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingBrowserSidebarControls.kt | browser filters and search |
+| [x] | [x] | [x] | new | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingBrowserDetailSections.kt | browser detail metrics and actions |
+
+Phase 4 note: `SettingsRecordingDialogs.kt` now owns only recording-specific dialogs. `BackupImportPreviewDialog` and the clear-history confirmation were returned to `SettingsScreenDialogs.kt`, matching the top-level ownership shape used in `master` without changing visible behavior.
+
+## Removed Source Files To Map During Review
+
+These are not review targets on their own, but they are the original surfaces to compare against when checking extraction drift.
+
+| Done | Drift | Wiring | Status | File | Focus |
+| --- | --- | --- | --- | --- | --- |
+| [x] | [x] | - | deleted | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsDialogComponents.kt | compare old dialog logic against extracted dialog files |
+| [x] | [x] | - | deleted | app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsViewModelModels.kt | compare old models and helpers against extracted model files |
+
+## Notes
+
+- `Drift` means the extracted file still matches the behavior that lived in `master`.
+- `Wiring` means the current branch still calls, observes, or renders that behavior from the correct owner.
+- If a row fails review, leave `Done` unchecked and add a short note in the `Focus` column or below the table before moving on.
\ No newline at end of file