StreamVault is a TV-first free IPTV player for Android TV built with Kotlin, Jetpack Compose, Room, Hilt, and Media3.
Kotlin iptv-player
Implement Parental Lock System
Davidona04147d865390
diff --git a/app/src/main/java/com/streamvault/app/ui/components/Cards.kt b/app/src/main/java/com/streamvault/app/ui/components/Cards.ktindex 62d7e249..b0c54d38 100644--- a/app/src/main/java/com/streamvault/app/ui/components/Cards.kt+++ b/app/src/main/java/com/streamvault/app/ui/components/Cards.kt@@ -86,7 +86,8 @@ fun ChannelCard(channel: Channel,onClick: () -> Unit,modifier: Modifier = Modifier,- onLongClick: (() -> Unit)? = null+ onLongClick: (() -> Unit)? = null,+ isLocked: Boolean = false) {FocusableCard(onClick = onClick,@@ -105,7 +106,7 @@ fun ChannelCard(verticalAlignment = Alignment.CenterVertically,modifier = Modifier.weight(1f)) {- if (!channel.logoUrl.isNullOrBlank()) {+ if (!channel.logoUrl.isNullOrBlank() && !isLocked) {AsyncImage(model = channel.logoUrl,contentDescription = channel.name,@@ -117,7 +118,7 @@ fun ChannelCard(}Text(- text = channel.name,+ text = if (isLocked) "Locked Channel" else channel.name,style = MaterialTheme.typography.bodySmall,color = if (isFocused) OnBackground else OnSurface,maxLines = 2,@@ -125,41 +126,57 @@ fun ChannelCard()}- // Bottom section: Current Program- channel.currentProgram?.let { program ->- Spacer(modifier = Modifier.height(4.dp))-+ // Bottom section: Current Program (Hide if locked)+ if (!isLocked) {+ channel.currentProgram?.let { program ->+ Spacer(modifier = Modifier.height(4.dp))++ Text(+ text = program.title,+ style = MaterialTheme.typography.labelSmall,+ color = if (isFocused) OnBackground.copy(alpha = 0.8f) else OnSurfaceDim,+ maxLines = 1,+ overflow = TextOverflow.Ellipsis+ )++ // Progress Bar+ val now = System.currentTimeMillis()+ val totalDuration = program.endTime - program.startTime+ val elapsed = now - program.startTime+ val progress = if (totalDuration > 0) elapsed.toFloat() / totalDuration else 0f++ Spacer(modifier = Modifier.height(4.dp))+ LinearProgressIndicator(+ progress = { progress.coerceIn(0f, 1f) },+ modifier = Modifier+ .fillMaxWidth()+ .height(2.dp),+ color = if (isFocused) Primary else OnSurfaceDim,+ trackColor = SurfaceHighlight+ )+ }+ }+ }++ // Lock Overlay+ if (isLocked) {+ Box(+ modifier = Modifier.fillMaxSize(),+ contentAlignment = Alignment.Center+ ) {Text(- text = program.title,- style = MaterialTheme.typography.labelSmall,- color = if (isFocused) OnBackground.copy(alpha = 0.8f) else OnSurfaceDim,- maxLines = 1,- overflow = TextOverflow.Ellipsis- )-- // Progress Bar- val now = System.currentTimeMillis()- val totalDuration = program.endTime - program.startTime- val elapsed = now - program.startTime- val progress = if (totalDuration > 0) elapsed.toFloat() / totalDuration else 0f-- Spacer(modifier = Modifier.height(4.dp))- LinearProgressIndicator(- progress = { progress.coerceIn(0f, 1f) },- modifier = Modifier- .fillMaxWidth()- .height(2.dp),- color = if (isFocused) Primary else OnSurfaceDim,- trackColor = SurfaceHighlight+ text = "π",+ style = MaterialTheme.typography.displayMedium)}}-- // Live indicator- Box(- modifier = Modifier- .align(Alignment.TopEnd)- .padding(4.dp)++ // Live indicator (Hide if locked)+ if (!isLocked) {+ Box(+ modifier = Modifier+ .align(Alignment.TopEnd)+ .padding(4.dp)) {Row(verticalAlignment = Alignment.CenterVertically) {if (channel.isFavorite) {@@ -191,10 +208,12 @@ fun ChannelCard(color = Color.White)}+ }}+ }}}-}+// ββ Movie Card βββββββββββββββββββββββββββββββββββββββββββββββββββββdiff --git a/app/src/main/java/com/streamvault/app/ui/components/dialogs/PinDialog.kt b/app/src/main/java/com/streamvault/app/ui/components/dialogs/PinDialog.ktnew file mode 100644index 00000000..9a21ffe3--- /dev/null+++ b/app/src/main/java/com/streamvault/app/ui/components/dialogs/PinDialog.kt@@ -0,0 +1,127 @@+package com.streamvault.app.ui.components.dialogs++import androidx.compose.foundation.background+import androidx.compose.foundation.border+import androidx.compose.foundation.layout.*+import androidx.compose.foundation.shape.CircleShape+import androidx.compose.foundation.shape.RoundedCornerShape+import androidx.compose.foundation.text.BasicTextField+import androidx.compose.foundation.text.KeyboardOptions+import androidx.compose.material3.*+import androidx.compose.runtime.*+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.draw.clip+import androidx.compose.ui.focus.FocusRequester+import androidx.compose.ui.focus.focusRequester+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.text.input.KeyboardType+import androidx.compose.ui.text.input.PasswordVisualTransformation+import androidx.compose.ui.unit.dp+import androidx.compose.ui.window.Dialog+import androidx.compose.ui.window.DialogProperties+import com.streamvault.app.ui.theme.ErrorColor+import com.streamvault.app.ui.theme.Primary+import com.streamvault.app.ui.theme.SurfaceElevated+import kotlinx.coroutines.delay++@Composable+fun PinDialog(+ onDismissRequest: () -> Unit,+ onPinEntered: (String) -> Unit,+ title: String = "Enter PIN",+ error: String? = null+) {+ var pin by remember { mutableStateOf("") }+ val focusRequester = remember { FocusRequester() }++ LaunchedEffect(Unit) {+ focusRequester.requestFocus()+ }++ // Auto-submit when length reaches 4+ LaunchedEffect(pin) {+ if (pin.length == 4) {+ delay(300) // Small delay for visual feedback+ onPinEntered(pin)+ pin = "" // Reset logic usually handled by parent state (error or dismiss)+ }+ }++ Dialog(+ onDismissRequest = onDismissRequest,+ properties = DialogProperties(usePlatformDefaultWidth = false)+ ) {+ Box(+ modifier = Modifier+ .width(320.dp)+ .background(SurfaceElevated, RoundedCornerShape(16.dp))+ .border(1.dp, Color.White.copy(alpha = 0.1f), RoundedCornerShape(16.dp))+ .padding(24.dp),+ contentAlignment = Alignment.Center+ ) {+ Column(+ horizontalAlignment = Alignment.CenterHorizontally,+ verticalArrangement = Arrangement.spacedBy(24.dp)+ ) {+ Text(+ text = title,+ style = MaterialTheme.typography.titleLarge,+ color = Color.White+ )++ // PIN Dots+ Row(+ horizontalArrangement = Arrangement.spacedBy(16.dp),+ verticalAlignment = Alignment.CenterVertically+ ) {+ repeat(4) { index ->+ val isFilled = index < pin.length+ Box(+ modifier = Modifier+ .size(20.dp)+ .clip(CircleShape)+ .background(+ if (isFilled) Primary else Color.White.copy(alpha = 0.1f)+ )+ .border(+ 1.dp,+ if (isFilled) Primary else Color.White.copy(alpha = 0.3f),+ CircleShape+ )+ )+ }+ }++ if (error != null) {+ Text(+ text = error,+ style = MaterialTheme.typography.bodyMedium,+ color = ErrorColor+ )+ }++ // Hidden text field to capture input overlays everything but is invisible+ // We use a small size to ensure it doesn't displace layout but is focusable+ BasicTextField(+ value = pin,+ onValueChange = {+ if (it.length <= 4 && it.all { char -> char.isDigit() }) {+ pin = it+ }+ },+ modifier = Modifier+ .size(1.dp)+ .focusRequester(focusRequester),+ keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.NumberPassword),+ visualTransformation = PasswordVisualTransformation()+ )++ // Cancel Button+ TextButton(onClick = onDismissRequest) {+ Text("Cancel", color = Color.White.copy(alpha = 0.7f))+ }+ }+ }+ }+}diff --git a/app/src/main/java/com/streamvault/app/ui/screens/home/HomeScreen.kt b/app/src/main/java/com/streamvault/app/ui/screens/home/HomeScreen.ktindex 8474bcd2..082f3c07 100644--- a/app/src/main/java/com/streamvault/app/ui/screens/home/HomeScreen.kt+++ b/app/src/main/java/com/streamvault/app/ui/screens/home/HomeScreen.kt@@ -31,12 +31,16 @@ import androidx.compose.material3.SnackbarHostStateimport androidx.compose.material3.TextButtonimport com.streamvault.app.ui.components.CategoryRowimport com.streamvault.app.ui.components.ChannelCard+import com.streamvault.app.ui.components.dialogs.PinDialogimport com.streamvault.app.ui.components.TopNavBarimport com.streamvault.app.ui.theme.*import com.streamvault.domain.model.Categoryimport com.streamvault.domain.model.Channelimport com.streamvault.domain.model.Providerimport com.streamvault.domain.repository.ChannelRepository+import com.streamvault.data.preferences.PreferencesRepository+import kotlinx.coroutines.flow.combine+import kotlinx.coroutines.flow.firstOrNullimport com.streamvault.domain.repository.EpgRepositoryimport com.streamvault.domain.repository.ProviderRepositoryimport kotlinx.coroutines.Job@@ -53,7 +57,7 @@ class HomeViewModel @Inject constructor(private val providerRepository: ProviderRepository,private val channelRepository: ChannelRepository,private val favoriteRepository: com.streamvault.domain.repository.FavoriteRepository,- private val preferencesRepository: com.streamvault.data.preferences.PreferencesRepository,+ private val preferencesRepository: PreferencesRepository,private val epgRepository: EpgRepository,private val getCustomCategories: com.streamvault.domain.usecase.GetCustomCategories) : ViewModel() {@@ -107,10 +111,17 @@ class HomeViewModel @Inject constructor(_uiState.update { it.copy(filteredChannels = markedChannels, isLoading = false) }- // 3. Fetch EPG for visible channels+ // 3. Fetch EPG for visible channelsfetchEpgForChannels(markedChannels)}}++ // Observe Parental Control Level+ viewModelScope.launch {+ preferencesRepository.parentalControlLevel.collectLatest { level ->+ _uiState.update { it.copy(parentalControlLevel = level) }+ }+ }}private fun loadAllProviders() {@@ -418,6 +429,11 @@ class HomeViewModel @Inject constructor(fun onDismissDialog() {_uiState.update { it.copy(showDialog = false, selectedChannelForDialog = null) }}++ suspend fun verifyPin(pin: String): Boolean {+ val storedPin = preferencesRepository.parentalPin.firstOrNull() ?: "0000"+ return pin == storedPin+ }}data class HomeUiState(@@ -435,7 +451,8 @@ data class HomeUiState(val dialogGroupMemberships: List<Long> = emptyList(),val userMessage: String? = null,val showDeleteGroupDialog: Boolean = false,- val groupToDelete: Category? = null+ val groupToDelete: Category? = null,+ val parentalControlLevel: Int = 0)// ββ Screen βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ@@ -449,6 +466,13 @@ fun HomeScreen() {val uiState by viewModel.uiState.collectAsState()val snackbarHostState = remember { SnackbarHostState() }++ // Parental Control State+ var showPinDialog by remember { mutableStateOf(false) }+ var pinError by remember { mutableStateOf<String?>(null) }+ var pendingUnlockCategory by remember { mutableStateOf<Category?>(null) }+ var pendingUnlockChannel by remember { mutableStateOf<Channel?>(null) }+ val scope = rememberCoroutineScope()LaunchedEffect(uiState.userMessage) {uiState.userMessage?.let { message ->@@ -456,6 +480,38 @@ fun HomeScreen(viewModel.userMessageShown()}}++ if (showPinDialog) {+ PinDialog(+ onDismissRequest = {+ showPinDialog = false+ pinError = null+ pendingUnlockCategory = null+ pendingUnlockChannel = null+ },+ onPinEntered = { pin ->+ scope.launch {+ if (viewModel.verifyPin(pin)) {+ showPinDialog = false+ pinError = null++ pendingUnlockCategory?.let { category ->+ viewModel.selectCategory(category)+ pendingUnlockCategory = null+ }++ pendingUnlockChannel?.let { channel ->+ onChannelClick(channel, uiState.selectedCategory, uiState.provider)+ pendingUnlockChannel = null+ }+ } else {+ pinError = "Incorrect PIN"+ }+ }+ },+ error = pinError+ )+ }Box(modifier = Modifier.fillMaxSize()) {Column(modifier = Modifier.fillMaxSize()) {@@ -521,10 +577,20 @@ fun HomeScreen(},key = { it.id }) { category ->+ val isLocked = category.isAdult && uiState.parentalControlLevel == 1+CategoryItem(category = category,isSelected = category.id == uiState.selectedCategory?.id,- onClick = { viewModel.selectCategory(category) },+ isLocked = isLocked,+ onClick = {+ if (isLocked) {+ pendingUnlockCategory = category+ showPinDialog = true+ } else {+ viewModel.selectCategory(category)+ }+ },onLongClick = { viewModel.requestDeleteGroup(category) })}@@ -619,16 +685,26 @@ fun HomeScreen(items = uiState.filteredChannels,key = { it.id }) { channel ->+ val isLocked = channel.isAdult && uiState.parentalControlLevel == 1+ChannelCard(channel = channel,+ isLocked = isLocked,onClick = {if (ignoreNextClick) {ignoreNextClick = false} else if (!uiState.showDialog) {- onChannelClick(channel, uiState.selectedCategory, uiState.provider)+ if (isLocked) {+ pendingUnlockChannel = channel+ showPinDialog = true+ } else {+ onChannelClick(channel, uiState.selectedCategory, uiState.provider)+ }}},onLongClick = {+ // Allow long click even if locked? Maybe restricts context menu?+ // For now, allow it (e.g. to delete from favorites/groups)ignoreNextClick = trueviewModel.onShowDialog(channel)},@@ -712,6 +788,7 @@ fun HomeScreen(private fun CategoryItem(category: Category,isSelected: Boolean,+ isLocked: Boolean = false,onClick: () -> Unit,onLongClick: (() -> Unit)? = null) {@@ -737,13 +814,27 @@ private fun CategoryItem())) {- Text(- text = "${category.name} (${category.count})",- style = if (isSelected) MaterialTheme.typography.titleSmall else MaterialTheme.typography.bodyMedium,+ Row(modifier = Modifier.padding(horizontal = 16.dp, vertical = 12.dp),- maxLines = 1,- color = if (isFocused) OnBackground else if (isSelected) Primary else OnSurface- )+ verticalAlignment = Alignment.CenterVertically,+ horizontalArrangement = Arrangement.SpaceBetween+ ) {+ Text(+ text = "${category.name} (${category.count})",+ style = if (isSelected) MaterialTheme.typography.titleSmall else MaterialTheme.typography.bodyMedium,+ maxLines = 1,+ color = if (isFocused) OnBackground else if (isSelected) Primary else OnSurface,+ modifier = Modifier.weight(1f)+ )++ if (isLocked) {+ Text(+ text = "π",+ style = MaterialTheme.typography.bodySmall,+ modifier = Modifier.padding(start = 8.dp)+ )+ }+ }}}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.ktindex 44f9e271..7889ac4f 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@@ -19,6 +19,15 @@ import androidx.compose.material3.SnackbarHostStateimport androidx.compose.material3.CircularProgressIndicatorimport androidx.compose.ui.graphics.Colorimport androidx.compose.foundation.clickable+import androidx.compose.material3.Switch+import androidx.compose.material3.RadioButton+import androidx.compose.material3.AlertDialog+import androidx.compose.material3.TextButton+import androidx.compose.material3.Button+import androidx.compose.material3.OutlinedButton+import androidx.compose.material3.HorizontalDivider++import com.streamvault.app.ui.components.dialogs.PinDialogimport com.streamvault.app.ui.components.TopNavBarimport com.streamvault.app.ui.theme.*import com.streamvault.domain.model.Provider@@ -42,14 +51,16 @@ class SettingsViewModel @Inject constructor(viewModelScope.launch {combine(providerRepository.getProviders(),- preferencesRepository.lastActiveProviderId- ) { providers, activeId ->- Pair(providers, activeId)- }.collect { (providers, activeId) ->+ preferencesRepository.lastActiveProviderId,+ preferencesRepository.parentalControlLevel+ ) { providers, activeId, level ->+ Triple(providers, activeId, level)+ }.collect { (providers, activeId, level) ->_uiState.update {it.copy(providers = providers,- activeProviderId = activeId+ activeProviderId = activeId,+ parentalControlLevel = level)}}@@ -65,6 +76,29 @@ class SettingsViewModel @Inject constructor(}}+ fun setParentalControlLevel(level: Int) {+ viewModelScope.launch {+ preferencesRepository.setParentalControlLevel(level)+ }+ }++ suspend fun verifyPin(pin: String): Boolean {+ // Simple verification for now. In a real app we might hash this.+ val currentPin = preferencesRepository.parentalPin.firstOrNull() ?: "0000"+ return pin == currentPin+ }++ fun changePin(newPin: String) {+ viewModelScope.launch {+ preferencesRepository.setParentalPin(newPin)+ _uiState.update { it.copy(userMessage = "PIN changed successfully") }+ }+ }++ fun clearUserMessage() {+ _uiState.update { it.copy(userMessage = null) }+ }+fun refreshProvider(providerId: Long) {viewModelScope.launch {_uiState.update { it.copy(isSyncing = true) }@@ -95,7 +129,8 @@ data class SettingsUiState(val providers: List<Provider> = emptyList(),val activeProviderId: Long? = null,val isSyncing: Boolean = false,- val userMessage: String? = null+ val userMessage: String? = null,+ val parentalControlLevel: Int = 0)@Composable@@ -107,7 +142,17 @@ fun SettingsScreen(viewModel: SettingsViewModel = hiltViewModel()) {val uiState by viewModel.uiState.collectAsState()+val snackbarHostState = remember { SnackbarHostState() }+ val scope = rememberCoroutineScope()++ // Parental Control State+ var showPinDialog by remember { mutableStateOf(false) }+ var showLevelDialog by remember { mutableStateOf(false) }+ var pinError by remember { mutableStateOf<String?>(null) }+ var pendingAction by remember { mutableStateOf<ParentalAction?>(null) }++LaunchedEffect(uiState.userMessage) {uiState.userMessage?.let { message ->@@ -171,6 +216,10 @@ fun SettingsScreen(onEdit = { onEditProvider(provider) })}++++}// Add Provider button@@ -226,8 +275,9 @@ fun SettingsScreen(SettingsRow(label = "App Version", value = "1.0.0")SettingsRow(label = "Build", value = "StreamVault for Android TV")}+ }}- }+SnackbarHost(hostState = snackbarHostState,@@ -265,6 +315,143 @@ fun SettingsScreen(}}}+++ if (showPinDialog) {+ PinDialog(+ onDismissRequest = {+ showPinDialog = false+ pinError = null+ },+ onPinEntered = { pin ->+ scope.launch {+ if (pendingAction == ParentalAction.SetNewPin) {+ viewModel.changePin(pin)+ showPinDialog = false+ pendingAction = null+ } else {+ if (viewModel.verifyPin(pin)) {+ showPinDialog = false+ pinError = null+ when (pendingAction) {+ ParentalAction.ChangeLevel -> showLevelDialog = true+ ParentalAction.ChangePin -> {+ pendingAction = ParentalAction.SetNewPin+ showPinDialog = true+ }+ else -> pendingAction = null+ }+ } else {+ pinError = "Incorrect PIN"+ }+ }+ }+ },+ title = if (pendingAction == ParentalAction.SetNewPin) "Enter New PIN" else "Enter PIN",+ error = pinError+ )+ }++ if (showLevelDialog) {+ AlertDialog(+ onDismissRequest = { showLevelDialog = false },+ title = { Text("Select Protection Level") },+ text = {+ Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {+ LevelOption(0, "OFF - No restrictions", uiState.parentalControlLevel) {+ viewModel.setParentalControlLevel(0)+ showLevelDialog = false+ }+ LevelOption(1, "LOCKED - Content visible, PIN required", uiState.parentalControlLevel) {+ viewModel.setParentalControlLevel(1)+ showLevelDialog = false+ }+ LevelOption(2, "HIDDEN - Content hidden from all lists", uiState.parentalControlLevel) {+ viewModel.setParentalControlLevel(2)+ showLevelDialog = false+ }+ }+ },+ confirmButton = {+ TextButton(onClick = { showLevelDialog = false }) {+ Text("Cancel")+ }+ }+ )+ }+ }+}++private enum class ParentalAction {+ ChangeLevel, ChangePin, SetNewPin+}++@Composable+private fun LevelOption(level: Int, text: String, currentLevel: Int, 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))+ Text(text, style = MaterialTheme.typography.bodyMedium, color = OnBackground)+ }+}++@Composable+private fun ParentalControlCard(+ level: Int,+ 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("Protection Level", style = MaterialTheme.typography.bodyLarge, color = OnBackground)+ Text(+ text = when(level) {+ 0 -> "OFF"+ 1 -> "LOCKED"+ 2 -> "HIDDEN"+ else -> "UNKNOWN"+ },+ style = MaterialTheme.typography.bodyMedium,+ color = if (level == 0) ErrorColor else Primary+ )+ }+ Button(onClick = onChangeLevel) {+ Text("Change")+ }+ }++ HorizontalDivider(color = Color.White.copy(alpha = 0.1f))++ Row(+ modifier = Modifier.fillMaxWidth(),+ horizontalArrangement = Arrangement.SpaceBetween,+ verticalAlignment = Alignment.CenterVertically+ ) {+ Text("Parental PIN", style = MaterialTheme.typography.bodyLarge, color = OnBackground)+ OutlinedButton(onClick = onChangePin) {+ Text("Change PIN")+ }+ }}}diff --git a/build_log.txt b/build_log.txtindex 4e128723..d14790b3 100644Binary files a/build_log.txt and b/build_log.txt differdiff --git a/build_log_utf8.txt b/build_log_utf8.txtindex f16da897..da8d9b46 100644--- a/build_log_utf8.txt+++ b/build_log_utf8.txt@@ -44,7 +44,13 @@> Task :player:generateDebugRFile UP-TO-DATE> Task :app:processDebugResources UP-TO-DATE> Task :data:checkKotlinGradlePluginConfigurationErrors SKIPPED+> Task :data:kspDebugKotlin UP-TO-DATE+> Task :data:compileDebugKotlin UP-TO-DATE> Task :data:javaPreCompileDebug UP-TO-DATE+> Task :data:compileDebugJavaWithJavac UP-TO-DATE+> Task :data:copyRoomSchemas NO-SOURCE+> Task :data:transformDebugClassesWithAsm UP-TO-DATE+> Task :data:bundleLibCompileToJarDebug UP-TO-DATE> Task :player:checkKotlinGradlePluginConfigurationErrors SKIPPED> Task :player:kspDebugKotlin UP-TO-DATE> Task :player:compileDebugKotlin UP-TO-DATE@@ -66,14 +72,18 @@> Task :player:packageDebugAssets UP-TO-DATE> Task :app:mergeDebugAssets UP-TO-DATE> Task :app:compressDebugAssets UP-TO-DATE+> Task :data:bundleLibRuntimeToJarDebug UP-TO-DATE> Task :player:bundleLibRuntimeToJarDebug UP-TO-DATE> Task :app:desugarDebugFileDependencies UP-TO-DATE+> Task :data:processDebugJavaRes UP-TO-DATE> Task :player:processDebugJavaRes UP-TO-DATE> Task :app:checkDebugDuplicateClasses UP-TO-DATE> Task :app:mergeExtDexDebug UP-TO-DATE+> Task :data:bundleLibRuntimeToDirDebug UP-TO-DATE> Task :player:bundleLibRuntimeToDirDebug UP-TO-DATE> Task :app:mergeDebugJniLibFolders UP-TO-DATE> Task :data:mergeDebugJniLibFolders UP-TO-DATE+> Task :app:mergeLibDexDebug UP-TO-DATE> Task :data:mergeDebugNativeLibs NO-SOURCE> Task :data:copyDebugJniLibsProjectOnly UP-TO-DATE> Task :player:mergeDebugJniLibFolders UP-TO-DATE@@ -86,9 +96,16 @@> Task :app:writeDebugSigningConfigVersions UP-TO-DATE> Task :data:stripDebugDebugSymbols NO-SOURCE> Task :data:copyDebugJniLibsProjectAndLocalJars UP-TO-DATE+> Task :data:extractDebugAnnotations UP-TO-DATE> Task :data:extractDeepLinksForAarDebug UP-TO-DATE+> Task :data:mergeDebugGeneratedProguardFiles UP-TO-DATE+> Task :data:mergeDebugConsumerProguardFiles UP-TO-DATE> Task :data:prepareDebugArtProfile UP-TO-DATE> Task :data:prepareLintJarForPublish UP-TO-DATE+> Task :data:mergeDebugJavaResource UP-TO-DATE+> Task :data:syncDebugLibJars UP-TO-DATE+> Task :data:bundleDebugAar UP-TO-DATE+> Task :data:assembleDebug UP-TO-DATE> Task :player:stripDebugDebugSymbols NO-SOURCE> Task :player:copyDebugJniLibsProjectAndLocalJars UP-TO-DATE> Task :player:extractDebugAnnotations UP-TO-DATE@@ -101,28 +118,38 @@> Task :player:syncDebugLibJars UP-TO-DATE> Task :player:bundleDebugAar UP-TO-DATE> Task :player:assembleDebug UP-TO-DATE+> Task :app:kspDebugKotlin-> Task :data:kspDebugKotlin FAILED-e: [ksp] [MissingType]: Element 'com.streamvault.data.local.StreamVaultDatabase' references a type that is not present-e: Error occurred in KSP, check log for detail-e: file:///C:/Users/david/.gemini/antigravity/scratch/iptv-player/data/src/main/java/com/streamvault/data/repository/ChannelRepositoryImpl.kt:39:13 Expecting ')'-e: file:///C:/Users/david/.gemini/antigravity/scratch/iptv-player/data/src/main/java/com/streamvault/data/repository/ChannelRepositoryImpl.kt:39:26 Expecting an element-e: file:///C:/Users/david/.gemini/antigravity/scratch/iptv-player/data/src/main/java/com/streamvault/data/repository/ChannelRepositoryImpl.kt:39:34 Expecting an element-e: file:///C:/Users/david/.gemini/antigravity/scratch/iptv-player/data/src/main/java/com/streamvault/data/repository/ChannelRepositoryImpl.kt:52:13 Expecting member declaration-e: file:///C:/Users/david/.gemini/antigravity/scratch/iptv-player/data/src/main/java/com/streamvault/data/repository/ChannelRepositoryImpl.kt:52:19 Expecting member declaration-e: file:///C:/Users/david/.gemini/antigravity/scratch/iptv-player/data/src/main/java/com/streamvault/data/repository/ChannelRepositoryImpl.kt:52:20 Expecting member declaration-e: file:///C:/Users/david/.gemini/antigravity/scratch/iptv-player/data/src/main/java/com/streamvault/data/repository/ChannelRepositoryImpl.kt:52:39 Expecting member declaration-e: file:///C:/Users/david/.gemini/antigravity/scratch/iptv-player/data/src/main/java/com/streamvault/data/repository/ChannelRepositoryImpl.kt:52:41 Expecting member declaration-e: file:///C:/Users/david/.gemini/antigravity/scratch/iptv-player/data/src/main/java/com/streamvault/data/repository/ChannelRepositoryImpl.kt:52:43 Expecting member declaration-e: file:///C:/Users/david/.gemini/antigravity/scratch/iptv-player/data/src/main/java/com/streamvault/data/repository/ChannelRepositoryImpl.kt:75:1 Expecting a top level declaration--> Task :data:copyRoomSchemas NO-SOURCE+> Task :app:compileDebugKotlin FAILED+cmd : e: file:///C:/Users/david/.gemini/antigravity/scratch/iptv-player/app/+src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreen.kt:63:2+5 No parameter with name 'parentalControlLevel' found.+At line:1 char:1++ cmd /c gradlew assembleDebug > build_log.txt 2>&1++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ + CategoryInfo : NotSpecified: (e: file:///C:/U...olLevel' fou+ nd.:String) [], RemoteException+ + FullyQualifiedErrorId : NativeCommandError++e: file:///C:/Users/david/.gemini/antigravity/scratch/iptv-player/app/src/ma+in/java/com/streamvault/app/ui/screens/settings/SettingsScreen.kt:324:21+Unresolved reference 'scope'.+e: file:///C:/Users/david/.gemini/antigravity/scratch/iptv-player/app/src/ma+in/java/com/streamvault/app/ui/screens/settings/SettingsScreen.kt:358:73+Unresolved reference 'parentalControlLevel'.+e: file:///C:/Users/david/.gemini/antigravity/scratch/iptv-player/app/src/ma+in/java/com/streamvault/app/ui/screens/settings/SettingsScreen.kt:362:90+Unresolved reference 'parentalControlLevel'.+e: file:///C:/Users/david/.gemini/antigravity/scratch/iptv-player/app/src/ma+in/java/com/streamvault/app/ui/screens/settings/SettingsScreen.kt:366:90+Unresolved reference 'parentalControlLevel'.FAILURE: Build failed with an exception.* What went wrong:-Execution failed for task ':data:kspDebugKotlin'.-> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction+Execution failed for task ':app:compileDebugKotlin'.+> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.Gra+dleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction> Compilation error. See log for more details* Try:@@ -131,5 +158,5 @@ Execution failed for task ':data:kspDebugKotlin'.> Run with --scan to get full insights.> Get more help at https://help.gradle.org.-BUILD FAILED in 3s-79 actionable tasks: 1 executed, 78 up-to-date+BUILD FAILED in 9s+95 actionable tasks: 2 executed, 93 up-to-datediff --git a/data/src/main/java/com/streamvault/data/local/StreamVaultDatabase.kt b/data/src/main/java/com/streamvault/data/local/StreamVaultDatabase.ktindex 9c990ae2..b3736b94 100644--- a/data/src/main/java/com/streamvault/data/local/StreamVaultDatabase.kt+++ b/data/src/main/java/com/streamvault/data/local/StreamVaultDatabase.kt@@ -17,8 +17,8 @@ import com.streamvault.data.local.entity.*FavoriteEntity::class,VirtualGroupEntity::class],- version = 1,- exportSchema = true+ version = 2,+ exportSchema = false)abstract class StreamVaultDatabase : RoomDatabase() {abstract fun providerDao(): ProviderDaodiff --git a/data/src/main/java/com/streamvault/data/local/entity/Entities.kt b/data/src/main/java/com/streamvault/data/local/entity/Entities.ktindex e7f82445..8f1f4289 100644--- a/data/src/main/java/com/streamvault/data/local/entity/Entities.kt+++ b/data/src/main/java/com/streamvault/data/local/entity/Entities.kt@@ -49,7 +49,8 @@ data class ChannelEntity(val number: Int = 0,@ColumnInfo(name = "catch_up_supported") val catchUpSupported: Boolean = false,@ColumnInfo(name = "catch_up_days") val catchUpDays: Int = 0,- @ColumnInfo(name = "provider_id") val providerId: Long = 0+ @ColumnInfo(name = "provider_id") val providerId: Long = 0,+ @ColumnInfo(name = "is_adult") val isAdult: Boolean = false)@Entity(@@ -160,7 +161,8 @@ data class CategoryEntity(val name: String,@ColumnInfo(name = "parent_id") val parentId: Long? = null,val type: String = "LIVE", // LIVE, MOVIE, SERIES- @ColumnInfo(name = "provider_id") val providerId: Long = 0+ @ColumnInfo(name = "provider_id") val providerId: Long = 0,+ @ColumnInfo(name = "is_adult") val isAdult: Boolean = false)@Entity(diff --git a/data/src/main/java/com/streamvault/data/preferences/PreferencesRepository.kt b/data/src/main/java/com/streamvault/data/preferences/PreferencesRepository.ktindex 9c8db070..63a20be1 100644--- a/data/src/main/java/com/streamvault/data/preferences/PreferencesRepository.kt+++ b/data/src/main/java/com/streamvault/data/preferences/PreferencesRepository.kt@@ -4,6 +4,7 @@ import android.content.Contextimport androidx.datastore.core.DataStoreimport androidx.datastore.preferences.core.Preferencesimport androidx.datastore.preferences.core.edit+import androidx.datastore.preferences.core.intPreferencesKeyimport androidx.datastore.preferences.core.longPreferencesKeyimport androidx.datastore.preferences.core.stringPreferencesKeyimport androidx.datastore.preferences.preferencesDataStore@@ -23,6 +24,8 @@ class PreferencesRepository @Inject constructor(private object PreferencesKeys {val LAST_ACTIVE_PROVIDER_ID = longPreferencesKey("last_active_provider_id")val DEFAULT_VIEW_MODE = stringPreferencesKey("default_view_mode")+ val PARENTAL_CONTROL_LEVEL = intPreferencesKey("parental_control_level")+ val PARENTAL_PIN = stringPreferencesKey("parental_pin")}val lastActiveProviderId: Flow<Long?> = context.dataStore.data.map { preferences ->@@ -33,9 +36,19 @@ class PreferencesRepository @Inject constructor(preferences[PreferencesKeys.DEFAULT_VIEW_MODE]}- suspend fun setLastActiveProviderId(providerId: Long) {+ val parentalControlLevel: Flow<Int> = context.dataStore.data+ .map { preferences ->+ preferences[PreferencesKeys.PARENTAL_CONTROL_LEVEL] ?: 0 // 0 = OFF, 1 = LOCKED, 2 = HIDDEN+ }++ val parentalPin: Flow<String> = context.dataStore.data+ .map { preferences ->+ preferences[PreferencesKeys.PARENTAL_PIN] ?: "0000"+ }++ suspend fun setLastActiveProviderId(id: Long) {context.dataStore.edit { preferences ->- preferences[PreferencesKeys.LAST_ACTIVE_PROVIDER_ID] = providerId+ preferences[PreferencesKeys.LAST_ACTIVE_PROVIDER_ID] = id}}@@ -45,9 +58,20 @@ class PreferencesRepository @Inject constructor(}}+ suspend fun setParentalControlLevel(level: Int) {+ context.dataStore.edit { preferences ->+ preferences[PreferencesKeys.PARENTAL_CONTROL_LEVEL] = level+ }+ }++ suspend fun setParentalPin(pin: String) {+ context.dataStore.edit { preferences ->+ preferences[PreferencesKeys.PARENTAL_PIN] = pin+ }+ }+suspend fun clearDefaultViewMode() {context.dataStore.edit { preferences ->- preferences.remove(PreferencesKeys.DEFAULT_VIEW_MODE)}}}diff --git a/data/src/main/java/com/streamvault/data/remote/xtream/XtreamProvider.kt b/data/src/main/java/com/streamvault/data/remote/xtream/XtreamProvider.ktindex a48a0ec8..549497a4 100644--- a/data/src/main/java/com/streamvault/data/remote/xtream/XtreamProvider.kt+++ b/data/src/main/java/com/streamvault/data/remote/xtream/XtreamProvider.kt@@ -266,27 +266,41 @@ class XtreamProvider(}// ββ Mappers ββββββββββββββββββββββββββββββββββββββββββββββββββββ++ private fun isAdultContent(name: String?): Boolean {+ if (name == null) return false+ val keywords = listOf("XXX", "Adult", "Porn", "Erotic", "18+")+ return keywords.any { name.contains(it, ignoreCase = true) }+ }private fun XtreamCategory.toDomain(type: ContentType) = Category(id = categoryId.toLongOrNull() ?: 0,name = categoryName,parentId = if (parentId > 0) parentId.toLong() else null,- type = type+ type = type,+ isAdult = isAdultContent(categoryName))- private fun XtreamStream.toChannel() = Channel(- id = streamId,- name = name,- logoUrl = streamIcon,- categoryId = categoryId?.toLongOrNull(),- categoryName = categoryName,- epgChannelId = epgChannelId,- number = num,- catchUpSupported = tvArchive == 1,- catchUpDays = tvArchiveDuration ?: 0,- providerId = providerId,- streamUrl = "$serverUrl/live/$username/$password/$streamId.ts"- )+ private fun XtreamStream.toChannel(): Channel {+ val isCatAdult = isAdultContent(categoryName)+ // Check group title as fallback if available, though usually categoryName is the group+ val isGroupAdult = false++ return Channel(+ id = streamId,+ name = name,+ logoUrl = streamIcon,+ categoryId = categoryId?.toLongOrNull(),+ categoryName = categoryName,+ epgChannelId = epgChannelId,+ number = num,+ catchUpSupported = tvArchive == 1,+ catchUpDays = tvArchiveDuration ?: 0,+ providerId = providerId,+ streamUrl = "$serverUrl/live/$username/$password/$streamId.ts",+ isAdult = isCatAdult+ )+ }private fun XtreamStream.toMovie() = Movie(id = streamId,diff --git a/data/src/main/java/com/streamvault/data/repository/ChannelRepositoryImpl.kt b/data/src/main/java/com/streamvault/data/repository/ChannelRepositoryImpl.ktindex 681e00f3..47b523d9 100644--- a/data/src/main/java/com/streamvault/data/repository/ChannelRepositoryImpl.kt+++ b/data/src/main/java/com/streamvault/data/repository/ChannelRepositoryImpl.kt@@ -13,22 +13,48 @@ import kotlinx.coroutines.flow.Flowimport kotlinx.coroutines.flow.mapimport kotlinx.coroutines.flow.combineimport javax.inject.Inject+import com.streamvault.data.preferences.PreferencesRepositoryimport javax.inject.Singleton@Singletonclass ChannelRepositoryImpl @Inject constructor(private val channelDao: ChannelDao,- private val categoryDao: CategoryDao+ private val categoryDao: CategoryDao,+ private val preferencesRepository: PreferencesRepository) : ChannelRepository {override fun getChannels(providerId: Long): Flow<List<Channel>> =- channelDao.getByProvider(providerId).map { entities -> entities.map { it.toDomain() } }+ combine(+ channelDao.getByProvider(providerId),+ preferencesRepository.parentalControlLevel+ ) { entities, level ->+ // Level 2 = HIDDEN. If hidden, filter out adult channels.+ if (level == 2) {+ entities.filter { !it.isAdult }+ } else {+ entities+ }+ }.map { entities ->+ entities.map { it.toDomain() }+ }override fun getChannelsByCategory(providerId: Long, categoryId: Long): Flow<List<Channel>> =- if (categoryId == ChannelRepository.ALL_CHANNELS_ID) {- channelDao.getByProvider(providerId).map { entities -> entities.map { it.toDomain() } }- } else {- channelDao.getByCategory(providerId, categoryId).map { entities -> entities.map { it.toDomain() } }+ combine(+ if (categoryId == ChannelRepository.ALL_CHANNELS_ID) {+ channelDao.getByProvider(providerId)+ } else {+ channelDao.getByCategory(providerId, categoryId)+ },+ preferencesRepository.parentalControlLevel+ ) { entities, level ->+ // Level 2 = HIDDEN. If hidden, filter out adult channels.+ if (level == 2) {+ entities.filter { !it.isAdult }+ } else {+ entities+ }+ }.map { entities ->+ entities.map { it.toDomain() }}override fun getCategories(providerId: Long): Flow<List<Category>> =diff --git a/domain/bin/main/com/streamvault/domain/model/Category.kt b/domain/bin/main/com/streamvault/domain/model/Category.ktindex 46462db7..16f7ecf0 100644--- a/domain/bin/main/com/streamvault/domain/model/Category.kt+++ b/domain/bin/main/com/streamvault/domain/model/Category.kt@@ -6,5 +6,6 @@ data class Category(val parentId: Long? = null,val type: ContentType = ContentType.LIVE,val isVirtual: Boolean = false,- val count: Int = 0+ val count: Int = 0,+ val isAdult: Boolean = false)diff --git a/domain/bin/main/com/streamvault/domain/model/Channel.kt b/domain/bin/main/com/streamvault/domain/model/Channel.ktindex e97b2dca..8d7f0130 100644--- a/domain/bin/main/com/streamvault/domain/model/Channel.kt+++ b/domain/bin/main/com/streamvault/domain/model/Channel.kt@@ -15,5 +15,6 @@ data class Channel(val catchUpDays: Int = 0,val providerId: Long = 0,val currentProgram: Program? = null,- val nextProgram: Program? = null+ val nextProgram: Program? = null,+ val isAdult: Boolean = false)diff --git a/domain/src/main/java/com/streamvault/domain/model/Category.kt b/domain/src/main/java/com/streamvault/domain/model/Category.ktindex 46462db7..16f7ecf0 100644--- a/domain/src/main/java/com/streamvault/domain/model/Category.kt+++ b/domain/src/main/java/com/streamvault/domain/model/Category.kt@@ -6,5 +6,6 @@ data class Category(val parentId: Long? = null,val type: ContentType = ContentType.LIVE,val isVirtual: Boolean = false,- val count: Int = 0+ val count: Int = 0,+ val isAdult: Boolean = false)diff --git a/domain/src/main/java/com/streamvault/domain/model/Channel.kt b/domain/src/main/java/com/streamvault/domain/model/Channel.ktindex e97b2dca..8d7f0130 100644--- a/domain/src/main/java/com/streamvault/domain/model/Channel.kt+++ b/domain/src/main/java/com/streamvault/domain/model/Channel.kt@@ -15,5 +15,6 @@ data class Channel(val catchUpDays: Int = 0,val providerId: Long = 0,val currentProgram: Program? = null,- val nextProgram: Program? = null+ val nextProgram: Program? = null,+ val isAdult: Boolean = false)