diff --git a/app/src/main/java/com/battlelancer/seriesguide/shows/ShowsDistillationFragment.kt b/app/src/main/java/com/battlelancer/seriesguide/shows/ShowsDistillationFragment.kt index 4e98c86fc7..79a66afb4c 100644 --- a/app/src/main/java/com/battlelancer/seriesguide/shows/ShowsDistillationFragment.kt +++ b/app/src/main/java/com/battlelancer/seriesguide/shows/ShowsDistillationFragment.kt @@ -87,7 +87,6 @@ class ShowsDistillationFragment : AppCompatDialogFragment() { setContent { WatchProviderFilter( watchProvidersFlow = model.watchProvidersFlow, - watchProvidersRegionFlow = model.watchProviderRegionFlow, onProviderFilterChange = { provider: SgWatchProvider, checked: Boolean -> model.changeWatchProviderFilter( provider, diff --git a/app/src/main/java/com/battlelancer/seriesguide/shows/ShowsDistillationViewModel.kt b/app/src/main/java/com/battlelancer/seriesguide/shows/ShowsDistillationViewModel.kt index a5dee0156f..2fe4ff06e9 100644 --- a/app/src/main/java/com/battlelancer/seriesguide/shows/ShowsDistillationViewModel.kt +++ b/app/src/main/java/com/battlelancer/seriesguide/shows/ShowsDistillationViewModel.kt @@ -5,15 +5,12 @@ package com.battlelancer.seriesguide.shows import android.app.Application import androidx.lifecycle.AndroidViewModel -import androidx.lifecycle.asFlow import androidx.lifecycle.viewModelScope import com.battlelancer.seriesguide.provider.SgRoomDatabase import com.battlelancer.seriesguide.streaming.SgWatchProvider -import com.battlelancer.seriesguide.streaming.StreamingSearch import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow -import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.launch @@ -28,17 +25,6 @@ class ShowsDistillationViewModel(application: Application) : AndroidViewModel(ap initialValue = listOf() ) - val watchProviderRegionFlow: StateFlow = StreamingSearch.regionLiveData.asFlow() - .map { - // Simpler to just use the existing API that reads from SharedPreferences - StreamingSearch.getCurrentRegionOrSelectString(application) - } - .stateIn( - scope = viewModelScope, - started = SharingStarted.WhileSubscribed(), - initialValue = StreamingSearch.getCurrentRegionOrSelectString(application) - ) - fun changeWatchProviderFilter(watchProvider: SgWatchProvider, filter: Boolean) { viewModelScope.launch(Dispatchers.IO) { SgRoomDatabase.getInstance(getApplication()).sgWatchProviderHelper() diff --git a/app/src/main/java/com/battlelancer/seriesguide/shows/WatchProviderFilterView.kt b/app/src/main/java/com/battlelancer/seriesguide/shows/WatchProviderFilterView.kt index 05540618cc..348955188d 100644 --- a/app/src/main/java/com/battlelancer/seriesguide/shows/WatchProviderFilterView.kt +++ b/app/src/main/java/com/battlelancer/seriesguide/shows/WatchProviderFilterView.kt @@ -14,9 +14,12 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.selection.toggleable -import androidx.compose.material3.AssistChip +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.outlined.Settings import androidx.compose.material3.Checkbox import androidx.compose.material3.Divider +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable @@ -36,17 +39,14 @@ import kotlinx.coroutines.flow.StateFlow @Composable fun WatchProviderFilter( watchProvidersFlow: StateFlow>, - watchProvidersRegionFlow: StateFlow, onProviderFilterChange: (SgWatchProvider, Boolean) -> Unit, onProviderIncludeAny: () -> Unit, onSelectRegion: () -> Unit ) { val watchProviders by watchProvidersFlow.collectAsState() - val watchProvidersRegion by watchProvidersRegionFlow.collectAsState() SeriesGuideTheme { WatchProviderList( watchProviders, - watchProvidersRegion, onProviderFilterChange, onProviderIncludeAny, onSelectRegion @@ -57,7 +57,6 @@ fun WatchProviderFilter( @Composable fun WatchProviderList( watchProviders: List, - watchProvidersRegion: String, onProviderFilterChange: (SgWatchProvider, Boolean) -> Unit, onProviderIncludeAny: () -> Unit, onSelectRegion: () -> Unit @@ -88,11 +87,15 @@ fun WatchProviderList( ) { Text(stringResource(id = R.string.action_include_any_watch_provider)) } - AssistChip( - modifier = Modifier.padding(start = 8.dp, top = 2.dp, end = 16.dp), - onClick = onSelectRegion, - label = { Text(watchProvidersRegion) } - ) + IconButton( + modifier = Modifier.padding(top = 2.dp, start = 4.dp, end = 4.dp), + onClick = onSelectRegion + ) { + Icon( + imageVector = Icons.Outlined.Settings, + contentDescription = stringResource(id = R.string.action_stream_info) + ) + } } } } @@ -145,7 +148,6 @@ fun WatchProviderFilterPreview() { type = SgWatchProvider.Type.SHOWS.id ) }, - watchProvidersRegion = "United States", onProviderFilterChange = { _: SgWatchProvider, _: Boolean -> }, onProviderIncludeAny = {}, onSelectRegion = {}