Skip to content

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

Merge branch 'pr-40' into minor-fixes

David Nashash9ada9fa267d1
diff --cc app/src/main/java/com/streamvault/app/ui/screens/welcome/WelcomeScreen.kt
index 8e23f755,85658e7d..33b6b4bb
--- a/app/src/main/java/com/streamvault/app/ui/screens/welcome/WelcomeScreen.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/welcome/WelcomeScreen.kt
@@@ -10,9 -8,10 +10,11 @@@ import androidx.compose.foundation.layo
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
+ import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.CircularProgressIndicator
+ import androidx.compose.material3.LinearProgressIndicator
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
@@@ -36,11 -32,10 +38,14 @@@ import com.streamvault.app.BuildConfi
import com.streamvault.app.R
import com.streamvault.app.ui.components.shell.StatusPill
import com.streamvault.app.ui.design.AppColors
+import com.streamvault.app.ui.interaction.TvButton
+ import com.streamvault.data.sync.SyncProgressBus
import com.streamvault.domain.repository.ProviderRepository
+ import com.streamvault.domain.sync.Section
+ import com.streamvault.domain.sync.SyncProgress
+import com.streamvault.domain.usecase.M3uProviderSetupCommand
+import com.streamvault.domain.usecase.ValidateAndAddProvider
+import com.streamvault.domain.usecase.XtreamProviderSetupCommand
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
import kotlinx.coroutines.flow.MutableStateFlow
@@@ -53,64 -52,35 +62,64 @@@ import kotlinx.coroutines.launc
@HiltViewModel
class WelcomeViewModel @Inject constructor(
private val providerRepository: ProviderRepository,
- private val validateAndAddProvider: ValidateAndAddProvider
++ private val validateAndAddProvider: ValidateAndAddProvider,
+ syncProgressBus: SyncProgressBus
) : ViewModel() {
private val _hasProviders = MutableStateFlow<Boolean?>(null)
val hasProviders: StateFlow<Boolean?> = _hasProviders.asStateFlow()
- // D8 — garde anti-rebond : une fois `hasProviders` connu (true ou false),
- // on cesse définitivement de relayer le bus pour ne pas afficher la
- // progression d'un sync ultérieur (settings refresh, retry) sur Welcome.
+ private val acceptingProgress = MutableStateFlow(true)
+
+ val syncProgress: StateFlow<SyncProgress?> =
+ combine(syncProgressBus.flow, acceptingProgress) { progress, accept ->
+ if (accept) progress else null
+ }.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5_000), null)
+
init {
viewModelScope.launch {
+ maybeSeedDevProvider()
providerRepository.getProviders()
.map { it.isNotEmpty() }
.collect { _hasProviders.value = it }
}
+ viewModelScope.launch {
+ _hasProviders
+ .filterNotNull()
+ .first()
+ acceptingProgress.value = false
+ }
}
+
- // Optional dev-seed flow driven by `rootProject/local.properties`
- // (gitignored). When populated, the first-boot onboarding is skipped
- // and a provider is auto-created using the same code path as the
- // manual setup form.
- //
- // Priority:
- // 1. Xtream — if all of `xtream.dev.server` / `xtream.dev.username`
- // / `xtream.dev.password` are non-blank.
- // 2. M3U — if `m3u.dev.url` is non-blank.
- // 3. Otherwise no-op (manual onboarding runs normally).
- //
- // Release builds always see empty strings (defaultConfig in
- // `app/build.gradle.kts`), so this is a permanent no-op there.
- // See `local.properties.example` and `docs/DEV_SEEDING.md`.
+ private suspend fun maybeSeedDevProvider() {
+ if (providerRepository.getProviders().first().isNotEmpty()) return
+
+ val xtreamServer = BuildConfig.XTREAM_DEV_SERVER
+ val xtreamUser = BuildConfig.XTREAM_DEV_USERNAME
+ val xtreamPass = BuildConfig.XTREAM_DEV_PASSWORD
+ if (xtreamServer.isNotBlank() && xtreamUser.isNotBlank() && xtreamPass.isNotBlank()) {
+ validateAndAddProvider.loginXtream(
+ XtreamProviderSetupCommand(
+ serverUrl = xtreamServer,
+ username = xtreamUser,
+ password = xtreamPass,
+ name = BuildConfig.XTREAM_DEV_NAME.ifBlank { "Dev (seeded)" },
+ xtreamFastSyncEnabled = true
+ )
+ )
+ return
+ }
+
+ val m3uUrl = BuildConfig.M3U_DEV_URL
+ if (m3uUrl.isNotBlank()) {
+ validateAndAddProvider.addM3u(
+ M3uProviderSetupCommand(
+ url = m3uUrl,
+ name = BuildConfig.M3U_DEV_NAME.ifBlank { "Dev M3U (seeded)" }
+ )
+ )
+ }
+ }
}
@Composable
@@@ -144,114 -115,94 +154,173 @@@ fun WelcomeScreen
)
)
- Surface(
- modifier = Modifier
- .align(Alignment.Center)
- .padding(32.dp),
- shape = RoundedCornerShape(28.dp),
- colors = SurfaceDefaults.colors(containerColor = AppColors.Surface.copy(alpha = 0.9f))
+ when (hasProviders) {
+ false -> WelcomeStartCard(
+ onNavigateToHome = onNavigateToHome,
+ onNavigateToSetup = onNavigateToSetup,
+ modifier = Modifier
+ .align(Alignment.Center)
+ .padding(32.dp)
+ )
+
+ else -> WelcomeLoadingCard(
++ syncProgress = syncProgress,
+ modifier = Modifier
+ .align(Alignment.Center)
+ .padding(32.dp)
+ )
+ }
+ }
+}
+
+@Composable
- private fun WelcomeLoadingCard(modifier: Modifier = Modifier) {
++private fun WelcomeLoadingCard(
++ syncProgress: SyncProgress?,
++ modifier: Modifier = Modifier
++) {
+ Surface(
+ modifier = modifier,
+ shape = RoundedCornerShape(28.dp),
+ colors = SurfaceDefaults.colors(containerColor = AppColors.Surface.copy(alpha = 0.9f))
+ ) {
+ Column(
+ modifier = Modifier.padding(horizontal = 36.dp, vertical = 28.dp),
+ horizontalAlignment = Alignment.CenterHorizontally
) {
- Column(
- modifier = Modifier.padding(horizontal = 36.dp, vertical = 28.dp),
- horizontalAlignment = Alignment.CenterHorizontally
- ) {
- val progress = syncProgress
- val pillLabel = if (progress != null) {
- stringResource(sectionLabelRes(progress.section))
- } else {
- stringResource(R.string.app_name)
- }
- val pillColor = if (progress != null) {
- sectionColor(progress.section)
- } else {
- AppColors.BrandMuted
- }
- StatusPill(
- label = pillLabel,
- containerColor = pillColor
- )
++ val pillLabel = if (syncProgress != null) {
++ stringResource(sectionLabelRes(syncProgress.section))
++ } else {
++ stringResource(R.string.app_name)
++ }
++ val pillColor = if (syncProgress != null) {
++ sectionColor(syncProgress.section)
++ } else {
++ AppColors.BrandMuted
++ }
+ StatusPill(
- label = stringResource(R.string.app_name),
- containerColor = AppColors.BrandMuted
++ label = pillLabel,
++ containerColor = pillColor
+ )
+ Spacer(modifier = Modifier.height(18.dp))
- CircularProgressIndicator(color = AppColors.Brand)
- Spacer(modifier = Modifier.height(18.dp))
++ if (syncProgress == null) {
++ CircularProgressIndicator(color = AppColors.Brand)
+ Spacer(modifier = Modifier.height(18.dp))
- // D13 — spinner masqué dès qu'on a une progression structurée.
- if (progress == null) {
- CircularProgressIndicator(color = AppColors.Brand)
- Spacer(modifier = Modifier.height(18.dp))
- }
- Text(
- text = stringResource(R.string.welcome_loading_title),
- style = MaterialTheme.typography.titleLarge,
- color = AppColors.TextPrimary
- )
- Spacer(modifier = Modifier.height(6.dp))
- val subtitle = if (progress != null && progress.currentLabel.isNotBlank()) {
- progress.currentLabel
++ }
+ Text(
+ text = stringResource(R.string.welcome_loading_title),
+ style = MaterialTheme.typography.titleLarge,
+ color = AppColors.TextPrimary
+ )
+ Spacer(modifier = Modifier.height(6.dp))
++ val subtitle = if (syncProgress != null && syncProgress.currentLabel.isNotBlank()) {
++ syncProgress.currentLabel
++ } else {
++ stringResource(R.string.welcome_loading_subtitle)
++ }
+ Text(
- text = stringResource(R.string.welcome_loading_subtitle),
++ text = subtitle,
+ style = MaterialTheme.typography.bodyLarge,
+ color = AppColors.TextSecondary
+ )
++ if (syncProgress != null) {
++ Spacer(modifier = Modifier.height(14.dp))
++ if (syncProgress.total > 0) {
++ LinearProgressIndicator(
++ progress = { syncProgress.current.toFloat() / syncProgress.total.toFloat() },
++ modifier = Modifier.width(260.dp),
++ color = AppColors.Brand,
++ trackColor = AppColors.BrandMuted
++ )
+ } else {
- stringResource(R.string.welcome_loading_subtitle)
++ LinearProgressIndicator(
++ modifier = Modifier.width(260.dp),
++ color = AppColors.Brand,
++ trackColor = AppColors.BrandMuted
++ )
+ }
++ Spacer(modifier = Modifier.height(10.dp))
+ Text(
- text = subtitle,
- style = MaterialTheme.typography.bodyLarge,
++ text = stringResource(
++ R.string.sync_items_indexed_format,
++ syncProgress.itemsIndexed
++ ),
++ style = MaterialTheme.typography.labelLarge,
+ color = AppColors.TextSecondary
+ )
- if (progress != null) {
- Spacer(modifier = Modifier.height(14.dp))
- if (progress.total > 0) {
- LinearProgressIndicator(
- progress = { progress.current.toFloat() / progress.total.toFloat() },
- modifier = Modifier.width(260.dp),
- color = AppColors.Brand,
- trackColor = AppColors.BrandMuted
- )
- } else {
- LinearProgressIndicator(
- modifier = Modifier.width(260.dp),
- color = AppColors.Brand,
- trackColor = AppColors.BrandMuted
- )
- }
- Spacer(modifier = Modifier.height(10.dp))
- Text(
- text = stringResource(
- R.string.sync_items_indexed_format,
- progress.itemsIndexed
- ),
- style = MaterialTheme.typography.labelLarge,
- color = AppColors.TextSecondary
++ }
+ }
+ }
+}
+
+@Composable
+private fun WelcomeStartCard(
+ onNavigateToHome: () -> Unit,
+ onNavigateToSetup: () -> Unit,
+ modifier: Modifier = Modifier
+) {
+ Surface(
+ modifier = modifier
+ .widthIn(max = 720.dp)
+ .fillMaxWidth(),
+ shape = RoundedCornerShape(28.dp),
+ colors = SurfaceDefaults.colors(containerColor = AppColors.Surface.copy(alpha = 0.9f))
+ ) {
+ Column(
+ modifier = Modifier.padding(horizontal = 40.dp, vertical = 34.dp),
+ horizontalAlignment = Alignment.CenterHorizontally,
+ verticalArrangement = Arrangement.spacedBy(18.dp)
+ ) {
+ StatusPill(
+ label = stringResource(R.string.app_name),
+ containerColor = AppColors.BrandMuted
+ )
+ Text(
+ text = stringResource(R.string.welcome_tagline),
+ style = MaterialTheme.typography.headlineMedium,
+ color = AppColors.TextPrimary,
+ textAlign = TextAlign.Center
+ )
+ Text(
+ text = stringResource(R.string.welcome_subtitle),
+ style = MaterialTheme.typography.bodyLarge,
+ color = AppColors.TextSecondary,
+ textAlign = TextAlign.Center
+ )
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.spacedBy(14.dp),
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ TvButton(
+ onClick = onNavigateToSetup,
+ modifier = Modifier.weight(1f)
+ ) {
+ Text(text = stringResource(R.string.welcome_setup_provider))
+ }
+ TvButton(
+ onClick = onNavigateToHome,
+ modifier = Modifier.weight(1f),
+ colors = ButtonDefaults.colors(
+ containerColor = AppColors.SurfaceElevated,
+ focusedContainerColor = AppColors.BrandMuted,
+ contentColor = AppColors.TextPrimary
)
+ ) {
+ Text(text = stringResource(R.string.welcome_setup_later))
}
}
}
}
}
+
-@Composable
+ private fun sectionColor(section: Section): Color = when (section) {
+ Section.LIVE -> AppColors.Brand
+ Section.VOD -> AppColors.Success
+ Section.SERIES -> AppColors.Warning
+ }
+
+ private fun sectionLabelRes(section: Section): Int = when (section) {
+ Section.LIVE -> R.string.sync_section_live
+ Section.VOD -> R.string.sync_section_vod
+ Section.SERIES -> R.string.sync_section_series
+ }
diff --cc app/src/main/res/values-fr/strings.xml
index b2709007,bc5fbe8f..2eb411a1
--- a/app/src/main/res/values-fr/strings.xml
+++ b/app/src/main/res/values-fr/strings.xml
@@@ -7,12 -7,16 +7,16 @@@
<string name="nav_series">Série</string>
<string name="nav_epg">Guider</string>
<string name="nav_settings">Paramètres</string>
- <string name="welcome_enter_app">Entrez dans l\'application</string>
+ <string name="welcome_enter_app">Entrez dans l’application</string>
<string name="welcome_manage_providers">Gérer les fournisseurs</string>
- <string name="welcome_setup_provider">Fournisseur d\'installation</string>
+ <string name="welcome_setup_provider">Fournisseur d’installation</string>
<string name="welcome_version">v1.0.3</string>
<string name="welcome_loading_title">Préparation de votre bibliothèque</string>
- <string name="welcome_loading_subtitle">Ouverture de l\'écran de droite pour cet appareil.</string>
+ <string name="welcome_loading_subtitle">Ouverture du bon écran pour cet appareil.</string>
+ <string name="sync_section_live">Live</string>
+ <string name="sync_section_vod">VOD</string>
+ <string name="sync_section_series">Séries</string>
+ <string name="sync_items_indexed_format">%1$d éléments indexés</string>
<string name="welcome_tagline">IPTV premium pour le salon</string>
<string name="welcome_subtitle">Profitez des chaînes en direct, du visionnage de rattrapage, des films et des séries avec une expérience Android TV propriétaire.</string>
<string name="welcome_feature_live">Navigation en direct rapide avec mise au point à distance</string>