Skip to content

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

improved default landing screen and provider deletion

David Nashash97d2080feae7
diff --git a/app/src/main/java/com/streamvault/app/MainActivity.kt b/app/src/main/java/com/streamvault/app/MainActivity.kt
index 75c09815..9a8ea2e0 100644
--- a/app/src/main/java/com/streamvault/app/MainActivity.kt
+++ b/app/src/main/java/com/streamvault/app/MainActivity.kt
@@ -28,6 +28,7 @@ import com.streamvault.domain.repository.ChannelRepository
import com.streamvault.domain.repository.CombinedM3uRepository
import com.streamvault.domain.repository.FavoriteRepository
import com.streamvault.domain.repository.PlaybackHistoryRepository
+import com.streamvault.domain.repository.ProviderRepository
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject
@@ -89,6 +90,9 @@ class MainActivity : ComponentActivity() {
@Inject
lateinit var channelRepository: ChannelRepository
+ @Inject
+ lateinit var providerRepository: ProviderRepository
+
@Inject
lateinit var watchNextManager: WatchNextManager
diff --git a/app/src/main/java/com/streamvault/app/navigation/AppNavigation.kt b/app/src/main/java/com/streamvault/app/navigation/AppNavigation.kt
index c19ddd22..4fb61f3d 100644
--- a/app/src/main/java/com/streamvault/app/navigation/AppNavigation.kt
+++ b/app/src/main/java/com/streamvault/app/navigation/AppNavigation.kt
@@ -5,7 +5,10 @@ import android.util.Log
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.produceState
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleEventObserver
import androidx.lifecycle.compose.collectAsStateWithLifecycle
@@ -54,10 +57,9 @@ internal const val MOVIE_DETAIL_PRESENTATION_HINT_KEY = "movie_detail_presentati
internal const val SERIES_DETAIL_PRESENTATION_HINT_KEY = "series_detail_presentation_hint"
private const val TAG = "AppNavigation"
-private sealed interface StartupNavigationTarget {
- data class Route(val route: String) : StartupNavigationTarget
- data class Player(val request: PlayerNavigationRequest) : StartupNavigationTarget
-}
+private fun requiresResolvedStartupTarget(landingDestination: AppLandingDestination): Boolean =
+ landingDestination == AppLandingDestination.FIRST_FAVORITE_LIVE ||
+ landingDestination == AppLandingDestination.LAST_WATCHED_LIVE
data class PlayerNavigationRequest(
val streamUrl: String,
@@ -345,35 +347,56 @@ fun AppNavigation(mainActivity: MainActivity) {
.collectAsStateWithLifecycle(initialValue = AppTopLevelDestination.defaultOrder)
.value
val appLandingDestination = mainActivity.preferencesRepository.appLandingDestination
- .collectAsStateWithLifecycle(initialValue = AppLandingDestination.HOME)
+ .collectAsStateWithLifecycle(initialValue = null)
.value
- val resolvedLandingDestination = AppTopLevelDestination.resolveLandingDestination(
- preferred = appLandingDestination,
- destinations = topLevelDestinations
- )
- val startupTarget by produceState<StartupNavigationTarget>(
- initialValue = StartupNavigationTarget.Route(resolvedLandingDestination.toAppRoute()),
- resolvedLandingDestination,
- topLevelDestinations
- ) {
- value = resolveStartupNavigationTarget(
- mainActivity = mainActivity,
- landingDestination = resolvedLandingDestination,
+ val resolvedLandingDestination = appLandingDestination?.let { landingDestination ->
+ AppTopLevelDestination.resolveLandingDestination(
+ preferred = landingDestination,
destinations = topLevelDestinations
)
}
+ // Route to land on when leaving the Welcome screen. For the "first favorite" / "last watched"
+ // landings this resolves to the Live TV tab (via toAppRoute); the channel itself is opened on top
+ // afterwards (see startupPlayerRequest below). This is computed immediately with no channel
+ // lookup, so Welcome is never held open long enough for a quick Back press to fall through the
+ // start destination and exit the app.
+ val startupRoute: String? = resolvedLandingDestination?.toAppRoute()
- fun navigateToStartupTarget(popUpRoute: String): Boolean = when (val target = startupTarget) {
- is StartupNavigationTarget.Route -> navController.navigateIfResumed(target.route) {
+ // Deferred auto-play request for the live landings. Resolved off the Welcome screen so the app
+ // stays interactive on Live TV while the channel is looked up.
+ val startupPlayerRequest by produceState<PlayerNavigationRequest?>(
+ initialValue = null,
+ resolvedLandingDestination
+ ) {
+ val landing = resolvedLandingDestination
+ value = if (landing != null && requiresResolvedStartupTarget(landing)) {
+ resolveStartupPlayerRequest(mainActivity, landing)
+ } else {
+ null
+ }
+ }
+ var startupPlayerHandled by remember { mutableStateOf(false) }
+
+ fun navigateToStartupTarget(popUpRoute: String): Boolean {
+ val route = startupRoute ?: return false
+ return navController.navigateIfResumed(route) {
popUpTo(popUpRoute) { inclusive = true }
}
- is StartupNavigationTarget.Player -> {
- if (navController.navigateToPlayer(target.request)) {
- navController.popBackStack(popUpRoute, inclusive = true)
- true
- } else {
- false
- }
+ }
+
+ // Once the live landing has placed us on the Live TV tab, open the resolved channel on top of it.
+ // Opening on top of Live TV (instead of replacing it) means Back from the player returns into the
+ // app rather than exiting. Guarded so it fires once, and only while still on the freshly-landed
+ // Live TV tab, to avoid hijacking navigation after the user has started interacting.
+ LaunchedEffect(startupPlayerRequest, currentBackStackEntry) {
+ if (startupPlayerHandled) return@LaunchedEffect
+ val request = startupPlayerRequest ?: return@LaunchedEffect
+ val entry = currentBackStackEntry ?: return@LaunchedEffect
+ val route = entry.destination?.route
+ if (route != Routes.LIVE_TV_DESTINATION && route != Routes.LIVE_TV) return@LaunchedEffect
+ entry.lifecycle.awaitResumed()
+ if (navController.navigateToPlayer(request)) {
+ startupPlayerHandled = true
}
}
@@ -441,6 +464,7 @@ fun AppNavigation(mainActivity: MainActivity) {
onNavigateToHome = dropUnlessResumed {
navigateToStartupTarget(Routes.WELCOME)
},
+ startupReady = startupRoute != null,
onNavigateToSetup = dropUnlessResumed {
navController.navigate(Routes.providerSetup()) {
popUpTo(Routes.WELCOME) { inclusive = true }
@@ -903,31 +927,18 @@ fun AppNavigation(mainActivity: MainActivity) {
}
}
-private suspend fun resolveStartupNavigationTarget(
+private suspend fun resolveStartupPlayerRequest(
mainActivity: MainActivity,
- landingDestination: AppLandingDestination,
- destinations: List<AppTopLevelDestination>
-): StartupNavigationTarget {
- val fallback = fallbackStartupNavigationTarget(destinations)
- return when (landingDestination) {
- AppLandingDestination.FIRST_FAVORITE_LIVE -> resolveFirstFavoriteStartupTarget(mainActivity) ?: fallback
- AppLandingDestination.LAST_WATCHED_LIVE -> resolveLastWatchedStartupTarget(mainActivity) ?: fallback
- else -> StartupNavigationTarget.Route(landingDestination.toAppRoute())
- }
+ landingDestination: AppLandingDestination
+): PlayerNavigationRequest? = when (landingDestination) {
+ AppLandingDestination.FIRST_FAVORITE_LIVE -> resolveFirstFavoriteStartupTarget(mainActivity)
+ AppLandingDestination.LAST_WATCHED_LIVE -> resolveLastWatchedStartupTarget(mainActivity)
+ else -> null
}
-private fun fallbackStartupNavigationTarget(
- destinations: List<AppTopLevelDestination>
-): StartupNavigationTarget = StartupNavigationTarget.Route(
- AppTopLevelDestination.resolveLandingDestination(
- preferred = AppLandingDestination.LIVE_TV,
- destinations = destinations
- ).toAppRoute()
-)
-
private suspend fun resolveFirstFavoriteStartupTarget(
mainActivity: MainActivity
-): StartupNavigationTarget.Player? {
+): PlayerNavigationRequest? {
if (!mainActivity.preferencesRepository.showFavoritesCategory.first()) return null
val context = resolveLiveStartupContext(mainActivity) ?: return null
val favorites = when (context) {
@@ -944,7 +955,7 @@ private suspend fun resolveFirstFavoriteStartupTarget(
private suspend fun resolveLastWatchedStartupTarget(
mainActivity: MainActivity
-): StartupNavigationTarget.Player? {
+): PlayerNavigationRequest? {
val context = resolveLiveStartupContext(mainActivity) ?: return null
val recentHistory = when (context) {
is LiveStartupContext.Provider -> mainActivity.playbackHistoryRepository.getRecentlyWatchedByProvider(context.providerId, limit = 24).first()
@@ -966,7 +977,7 @@ private suspend fun resolveStartupChannelTarget(
channelIds: List<Long>,
sourceContext: LiveStartupContext,
virtualCategoryId: Long
-): StartupNavigationTarget.Player? {
+): PlayerNavigationRequest? {
if (channelIds.isEmpty()) return null
val hiddenChannelIdsByProvider = sourceContext.providerIds.associateWith { providerId ->
mainActivity.preferencesRepository.getHiddenChannelIds(providerId).first()
@@ -975,15 +986,13 @@ private suspend fun resolveStartupChannelTarget(
val channel = mainActivity.channelRepository.getChannel(channelId) ?: continue
if (channel.providerId !in sourceContext.providerIds) continue
if (channel.id in hiddenChannelIdsByProvider[channel.providerId].orEmpty()) continue
- return StartupNavigationTarget.Player(
- Routes.livePlayer(
- channel = channel,
- categoryId = virtualCategoryId,
- providerId = channel.providerId,
- isVirtual = true,
- combinedProfileId = (sourceContext as? LiveStartupContext.Combined)?.profileId,
- returnRoute = Routes.LIVE_TV
- )
+ return Routes.livePlayer(
+ channel = channel,
+ categoryId = virtualCategoryId,
+ providerId = channel.providerId,
+ isVirtual = true,
+ combinedProfileId = (sourceContext as? LiveStartupContext.Combined)?.profileId,
+ returnRoute = Routes.LIVE_TV
)
}
return null
@@ -1003,7 +1012,11 @@ private suspend fun resolveLiveStartupContext(
.distinct()
if (providerIds.isEmpty()) null else LiveStartupContext.Combined(activeSource.profileId, providerIds)
}
- null -> null
+ null -> {
+ mainActivity.providerRepository.getActiveProvider().first()?.id?.let { providerId ->
+ LiveStartupContext.Provider(providerId)
+ }
+ }
}
}
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderActions.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderActions.kt
index 15fe5118..b6b2be4d 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderActions.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderActions.kt
@@ -481,16 +481,43 @@ internal class SettingsProviderActions(
fun deleteProvider(scope: CoroutineScope, providerId: Long, onSuccess: () -> Unit = {}) {
scope.launch {
- uiState.update { it.copy(isDeletingProvider = true) }
- when (val result = providerRepository.deleteProvider(providerId)) {
+ uiState.update {
+ it.copy(
+ isDeletingProvider = true,
+ deleteProviderProgressMessage = "Preparing provider deletion...",
+ deleteProviderProgressFraction = 0f
+ )
+ }
+ when (val result = providerRepository.deleteProvider(providerId) { progress ->
+ uiState.update {
+ it.copy(
+ deleteProviderProgressMessage = progress.message,
+ deleteProviderProgressFraction = progress.fraction
+ )
+ }
+ }) {
is Result.Success -> {
- uiState.update { it.copy(isDeletingProvider = false, userMessage = "Provider deleted") }
+ uiState.update {
+ it.copy(
+ isDeletingProvider = false,
+ deleteProviderProgressMessage = null,
+ deleteProviderProgressFraction = null,
+ userMessage = "Provider deleted"
+ )
+ }
onSuccess()
runCatching { watchNextManager.refreshWatchNext() }
runCatching { launcherRecommendationsManager.refreshRecommendations(force = true) }
runCatching { tvInputChannelSyncManager.refreshTvInputCatalog() }
}
- is Result.Error -> uiState.update { it.copy(isDeletingProvider = false, userMessage = "Could not delete provider: ${result.message}") }
+ is Result.Error -> uiState.update {
+ it.copy(
+ isDeletingProvider = false,
+ deleteProviderProgressMessage = null,
+ deleteProviderProgressFraction = null,
+ userMessage = "Could not delete provider: ${result.message}"
+ )
+ }
Result.Loading -> Unit
}
}
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
index accb4043..568ff130 100644
--- 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
@@ -1,15 +1,23 @@
package com.streamvault.app.ui.screens.settings
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.material3.LinearProgressIndicator
import androidx.compose.runtime.LaunchedEffect
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 com.streamvault.app.ui.components.dialogs.PremiumDialog
import com.streamvault.app.ui.components.dialogs.PremiumDialogFooterButton
import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.unit.dp
+import androidx.tv.material3.Text
import com.streamvault.app.R
+import com.streamvault.app.ui.theme.OnSurfaceDim
+import com.streamvault.app.ui.theme.Primary
@Composable
internal fun SettingsProviderManagementDialogs(
@@ -134,7 +142,31 @@ internal fun SettingsProviderManagementDialogs(
onDismissRequest = { if (!uiState.isDeletingProvider) providerState.pendingDeleteProviderId = null },
widthFraction = 0.48f,
heightFraction = null,
- content = {},
+ content = {
+ if (uiState.isDeletingProvider) {
+ val fraction = uiState.deleteProviderProgressFraction
+ if (fraction != null) {
+ LinearProgressIndicator(
+ progress = { fraction.coerceIn(0f, 1f) },
+ color = Primary,
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(bottom = 12.dp)
+ )
+ } else {
+ LinearProgressIndicator(
+ color = Primary,
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(bottom = 12.dp)
+ )
+ }
+ Text(
+ text = uiState.deleteProviderProgressMessage ?: "Deleting provider...",
+ color = OnSurfaceDim
+ )
+ }
+ },
footer = {
PremiumDialogFooterButton(
label = stringResource(R.string.settings_cancel),
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
index 82b0e866..bd0834c6 100644
--- 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
@@ -108,6 +108,8 @@ data class SettingsUiState(
val lastSpeedTest: InternetSpeedTestUiModel? = null,
val isRunningInternetSpeedTest: Boolean = false,
val isDeletingProvider: Boolean = false,
+ val deleteProviderProgressMessage: String? = null,
+ val deleteProviderProgressFraction: Float? = null,
val isImportingBackup: Boolean = false,
val backupPreview: BackupPreview? = null,
val pendingBackupUri: String? = null,
diff --git 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
index 8536fb5a..3ebed40a 100644
--- 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
@@ -125,15 +125,16 @@ class WelcomeViewModel @Inject constructor(
@Composable
fun WelcomeScreen(
onNavigateToHome: () -> Unit,
+ startupReady: Boolean = true,
onNavigateToSetup: () -> Unit,
viewModel: WelcomeViewModel = hiltViewModel()
) {
val hasProviders by viewModel.hasProviders.collectAsStateWithLifecycle()
val syncProgress by viewModel.syncProgress.collectAsStateWithLifecycle()
- LaunchedEffect(hasProviders) {
+ LaunchedEffect(hasProviders, startupReady) {
when (hasProviders) {
- true -> onNavigateToHome()
+ true -> if (startupReady) onNavigateToHome()
false -> Unit
null -> Unit
}
diff --git a/data/src/main/java/com/streamvault/data/local/dao/Daos.kt b/data/src/main/java/com/streamvault/data/local/dao/Daos.kt
index fdf96d7b..92ca6c90 100644
--- a/data/src/main/java/com/streamvault/data/local/dao/Daos.kt
+++ b/data/src/main/java/com/streamvault/data/local/dao/Daos.kt
@@ -437,6 +437,9 @@ abstract class ChannelDao {
@Query("SELECT id, stream_id AS remote_id FROM channels WHERE provider_id = :providerId")
abstract suspend fun getIdMappings(providerId: Long): List<RemoteIdMapping>
+ @Query("SELECT COUNT(*) FROM channels WHERE provider_id = :providerId")
+ abstract suspend fun countByProvider(providerId: Long): Int
+
@Query("DELETE FROM channels WHERE provider_id = :providerId")
abstract suspend fun deleteByProvider(providerId: Long)
@@ -1679,6 +1682,9 @@ interface MovieDao {
@Query("UPDATE movies SET watch_progress = 0, watch_count = 0, last_watched_at = 0")
suspend fun resetAllWatchProgress()
+ @Query("SELECT COUNT(*) FROM movies WHERE provider_id = :providerId")
+ suspend fun countByProvider(providerId: Long): Int
+
@Query("DELETE FROM movies WHERE provider_id = :providerId")
suspend fun deleteByProvider(providerId: Long)
@@ -2612,6 +2618,9 @@ interface SeriesDao {
)
suspend fun getIdMappingsByCategory(providerId: Long, categoryId: Long): List<SeriesRemoteIdMapping>
+ @Query("SELECT COUNT(*) FROM series WHERE provider_id = :providerId")
+ suspend fun countByProvider(providerId: Long): Int
+
@Query("DELETE FROM series WHERE provider_id = :providerId")
suspend fun deleteByProvider(providerId: Long)
diff --git a/data/src/main/java/com/streamvault/data/repository/ProviderRepositoryImpl.kt b/data/src/main/java/com/streamvault/data/repository/ProviderRepositoryImpl.kt
index bc86b11e..b434d173 100644
--- a/data/src/main/java/com/streamvault/data/repository/ProviderRepositoryImpl.kt
+++ b/data/src/main/java/com/streamvault/data/repository/ProviderRepositoryImpl.kt
@@ -24,6 +24,7 @@ import com.streamvault.domain.manager.ProviderCredentials
import com.streamvault.domain.model.*
import com.streamvault.domain.provider.IptvProvider
import com.streamvault.domain.repository.LiveStreamProgramRequest
+import com.streamvault.domain.repository.ProviderDeleteProgress
import com.streamvault.domain.repository.ProviderRepository
import com.streamvault.domain.repository.SyncMetadataRepository
import kotlinx.coroutines.async
@@ -46,6 +47,8 @@ class ProviderRepositoryImpl @Inject constructor(
private val providerDao: ProviderDao,
private val categoryDao: CategoryDao,
private val channelDao: ChannelDao,
+ private val movieDao: MovieDao,
+ private val seriesDao: SeriesDao,
private val programDao: ProgramDao,
private val recordingRunDao: RecordingRunDao,
private val programReminderDao: ProgramReminderDao,
@@ -63,6 +66,11 @@ class ProviderRepositoryImpl @Inject constructor(
private companion object {
const val XTREAM_GUIDE_BATCH_CONCURRENCY = 4
const val BACKGROUND_EPG_START_DELAY_MS = 15_000L
+ // Row-equivalent weights for non-row delete steps so the progress bar still moves
+ // meaningfully on providers with tiny (or empty) catalogs.
+ const val ALARM_STEP_WEIGHT = 5
+ const val PROVIDER_ROW_STEP_WEIGHT = 200
+ const val FINALIZE_STEP_WEIGHT = 200
val logger: Logger = Logger.getLogger(ProviderRepositoryImpl::class.java.name)
}
@@ -120,27 +128,80 @@ class ProviderRepositoryImpl @Inject constructor(
return true
}
- override suspend fun deleteProvider(id: Long): Result<Unit> = try {
+ override suspend fun deleteProvider(
+ id: Long,
+ onProgress: ((ProviderDeleteProgress) -> Unit)?
+ ): Result<Unit> = try {
val recordingRunIds = recordingRunDao.getIdsByProvider(id)
val reminderIds = programReminderDao.getIdsByProvider(id)
+
+ // Weight progress by the real row counts of the large child tables so the bar
+ // advances proportionally to the work being done instead of in two big jumps.
+ val programCount = programDao.countByProvider(id)
+ val channelCount = channelDao.countByProvider(id)
+ val movieCount = movieDao.countByProvider(id)
+ val seriesCount = seriesDao.countByProvider(id)
+
+ val totalWeight = (
+ programCount + channelCount + movieCount + seriesCount +
+ (recordingRunIds.size + reminderIds.size) * ALARM_STEP_WEIGHT +
+ PROVIDER_ROW_STEP_WEIGHT + FINALIZE_STEP_WEIGHT
+ ).coerceAtLeast(1)
+ var completedWeight = 0
+
+ fun reportProgress(message: String) {
+ onProgress?.invoke(
+ ProviderDeleteProgress(
+ message = message,
+ fraction = (completedWeight.toFloat() / totalWeight.toFloat()).coerceIn(0f, 1f)
+ )
+ )
+ }
+
+ reportProgress("Preparing to remove provider...")
transactionRunner.inTransaction {
// ProgramEntity still has no provider FK, so it requires explicit cleanup.
+ if (programCount > 0) reportProgress("Removing $programCount guide entries...")
programDao.deleteByProvider(id)
+ completedWeight += programCount
+
+ if (channelCount > 0) reportProgress("Removing $channelCount channels...")
+ channelDao.deleteByProvider(id)
+ completedWeight += channelCount
+
+ if (movieCount > 0) reportProgress("Removing $movieCount movies...")
+ movieDao.deleteByProvider(id)
+ completedWeight += movieCount
+
+ if (seriesCount > 0) reportProgress("Removing $seriesCount series...")
+ seriesDao.deleteByProvider(id)
+ completedWeight += seriesCount
+
+ reportProgress("Removing provider record...")
providerDao.delete(id)
+ completedWeight += PROVIDER_ROW_STEP_WEIGHT
}
+ reportProgress("Provider library removed.")
recordingRunIds.forEach { runId ->
+ reportProgress("Cleaning recording alarms...")
runPostDeleteCleanup("recording alarm $runId") {
recordingAlarmScheduler.cancel(runId)
}
+ completedWeight += ALARM_STEP_WEIGHT
}
reminderIds.forEach { reminderId ->
+ reportProgress("Cleaning reminders...")
runPostDeleteCleanup("reminder alarm $reminderId") {
programReminderAlarmScheduler.cancel(reminderId)
}
+ completedWeight += ALARM_STEP_WEIGHT
}
+ reportProgress("Finalizing provider cleanup...")
runPostDeleteCleanup("provider sync cleanup $id") {
syncManager.onProviderDeleted(id)
}
+ completedWeight += FINALIZE_STEP_WEIGHT
+ reportProgress("Provider deleted.")
Result.success(Unit)
} catch (e: Exception) {
Result.error("Failed to delete provider: ${e.message}", e)
diff --git a/data/src/test/java/com/streamvault/data/repository/ProviderRepositoryImplTest.kt b/data/src/test/java/com/streamvault/data/repository/ProviderRepositoryImplTest.kt
index fd5388aa..2657bd9d 100644
--- a/data/src/test/java/com/streamvault/data/repository/ProviderRepositoryImplTest.kt
+++ b/data/src/test/java/com/streamvault/data/repository/ProviderRepositoryImplTest.kt
@@ -4,10 +4,12 @@ import com.google.common.truth.Truth.assertThat
import com.streamvault.data.local.DatabaseTransactionRunner
import com.streamvault.data.local.dao.CategoryDao
import com.streamvault.data.local.dao.ChannelDao
+import com.streamvault.data.local.dao.MovieDao
import com.streamvault.data.local.dao.ProgramDao
import com.streamvault.data.local.dao.ProgramReminderDao
import com.streamvault.data.local.dao.ProviderDao
import com.streamvault.data.local.dao.RecordingRunDao
+import com.streamvault.data.local.dao.SeriesDao
import com.streamvault.data.local.entity.ProviderEntity
import com.streamvault.data.local.entity.CategoryEntity
import com.streamvault.data.manager.recording.RecordingAlarmScheduler
@@ -50,6 +52,8 @@ class ProviderRepositoryImplTest {
private val providerDao: ProviderDao = mock()
private val categoryDao: CategoryDao = mock()
private val channelDao: ChannelDao = mock()
+ private val movieDao: MovieDao = mock()
+ private val seriesDao: SeriesDao = mock()
private val programDao: ProgramDao = mock()
private val recordingRunDao: RecordingRunDao = mock()
private val programReminderDao: ProgramReminderDao = mock()
@@ -72,6 +76,8 @@ class ProviderRepositoryImplTest {
providerDao = providerDao,
categoryDao = categoryDao,
channelDao = channelDao,
+ movieDao = movieDao,
+ seriesDao = seriesDao,
programDao = programDao,
recordingRunDao = recordingRunDao,
programReminderDao = programReminderDao,
@@ -93,6 +99,10 @@ class ProviderRepositoryImplTest {
whenever(preferencesRepository.xtreamBase64TextCompatibility).thenReturn(flowOf(false))
runBlocking {
whenever(categoryDao.getByProviderAndTypeSync(any(), any())).thenReturn(emptyList())
+ whenever(programDao.countByProvider(any())).thenReturn(0)
+ whenever(channelDao.countByProvider(any())).thenReturn(0)
+ whenever(movieDao.countByProvider(any())).thenReturn(0)
+ whenever(seriesDao.countByProvider(any())).thenReturn(0)
}
}
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 866a2fd3..20d8a0c1 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -14,6 +14,7 @@ All notable product changes are recorded in this document.
- Added capability-aware catch-up playback handling for Xtream and Stalker providers, including archive mechanism detection, replay-window diagnostics, and provider-specific troubleshooting messages.
- Added Google Cast entry points to movie details and series details, including casting the current movie, the resume episode, or an explicitly selected episode with title, artwork, and saved watch progress metadata.
- Added a richer manual provider-sync overlay in Settings with current-section labeling, elapsed-time tracking, and a cancel action for cancelable sync operations.
+- Added provider deletion progress bar.
### Fixed
diff --git a/domain/src/main/java/com/streamvault/domain/repository/ProviderRepository.kt b/domain/src/main/java/com/streamvault/domain/repository/ProviderRepository.kt
index 3ddfbd0f..546b0967 100644
--- a/domain/src/main/java/com/streamvault/domain/repository/ProviderRepository.kt
+++ b/domain/src/main/java/com/streamvault/domain/repository/ProviderRepository.kt
@@ -16,13 +16,18 @@ data class LiveStreamProgramRequest(
val epgChannelId: String? = null
)
+data class ProviderDeleteProgress(
+ val message: String,
+ val fraction: Float? = null
+)
+
interface ProviderRepository {
fun getProviders(): Flow<List<Provider>>
fun getActiveProvider(): Flow<Provider?>
suspend fun getProvider(id: Long): Provider?
suspend fun addProvider(provider: Provider): Result<Long>
suspend fun updateProvider(provider: Provider): Result<Unit>
- suspend fun deleteProvider(id: Long): Result<Unit>
+ suspend fun deleteProvider(id: Long, onProgress: ((ProviderDeleteProgress) -> Unit)? = null): Result<Unit>
/**
* Returns cleartext credentials for all providers that have both a