Move home page specific settings

This commit is contained in:
Damontecres 2026-02-05 14:33:54 -05:00
parent 682b81d936
commit c844395acd
No known key found for this signature in database
7 changed files with 70 additions and 19 deletions

View file

@ -85,11 +85,7 @@ sealed interface HomeRowConfig {
@SerialName("Genres") @SerialName("Genres")
data class Genres( data class Genres(
val parentId: UUID, val parentId: UUID,
override val viewOptions: HomeRowViewOptions = override val viewOptions: HomeRowViewOptions = HomeRowViewOptions.genreDefault,
HomeRowViewOptions(
heightDp = Cards.HEIGHT_EPISODE,
aspectRatio = AspectRatio.WIDE,
),
) : HomeRowConfig { ) : HomeRowConfig {
override fun updateViewOptions(viewOptions: HomeRowViewOptions): Genres = this.copy(viewOptions = viewOptions) override fun updateViewOptions(viewOptions: HomeRowViewOptions): Genres = this.copy(viewOptions = viewOptions)
} }
@ -214,4 +210,12 @@ data class HomeRowViewOptions(
val episodeContentScale: PrefContentScale = PrefContentScale.FIT, val episodeContentScale: PrefContentScale = PrefContentScale.FIT,
val episodeAspectRatio: AspectRatio = AspectRatio.TALL, val episodeAspectRatio: AspectRatio = AspectRatio.TALL,
val episodeImageType: ViewOptionImageType = ViewOptionImageType.PRIMARY, val episodeImageType: ViewOptionImageType = ViewOptionImageType.PRIMARY,
) {
companion object {
val genreDefault =
HomeRowViewOptions(
heightDp = Cards.HEIGHT_EPISODE,
aspectRatio = AspectRatio.WIDE,
) )
}
}

View file

@ -959,9 +959,6 @@ val basicPreferences =
preferences = preferences =
listOf( listOf(
AppPreference.SignInAuto, AppPreference.SignInAuto,
AppPreference.HomePageItems,
AppPreference.CombineContinueNext,
AppPreference.RewatchNextUp,
AppPreference.PlayThemeMusic, AppPreference.PlayThemeMusic,
AppPreference.RememberSelectedTab, AppPreference.RememberSelectedTab,
AppPreference.SubtitleStyle, AppPreference.SubtitleStyle,
@ -1058,6 +1055,7 @@ val advancedPreferences =
preferences = preferences =
listOf( listOf(
AppPreference.ShowClock, AppPreference.ShowClock,
AppPreference.CombineContinueNext,
// Temporarily disabled, see https://github.com/damontecres/Wholphin/pull/127#issuecomment-3478058418 // Temporarily disabled, see https://github.com/damontecres/Wholphin/pull/127#issuecomment-3478058418
// AppPreference.NavDrawerSwitchOnFocus, // AppPreference.NavDrawerSwitchOnFocus,
AppPreference.ControllerTimeout, AppPreference.ControllerTimeout,

View file

@ -80,7 +80,6 @@ class TvProviderWorker
getPotentialItems( getPotentialItems(
userId, userId,
prefs.homePagePreferences.enableRewatchingNextUp, prefs.homePagePreferences.enableRewatchingNextUp,
prefs.homePagePreferences.combineContinueNext,
) )
val potentialItemsToAddIds = potentialItemsToAdd.map { it.id.toString() } val potentialItemsToAddIds = potentialItemsToAdd.map { it.id.toString() }
@ -144,7 +143,6 @@ class TvProviderWorker
private suspend fun getPotentialItems( private suspend fun getPotentialItems(
userId: UUID, userId: UUID,
enableRewatching: Boolean, enableRewatching: Boolean,
combineContinueNext: Boolean,
): List<BaseItem> { ): List<BaseItem> {
val resumeItems = latestNextUpService.getResume(userId, 10, true) val resumeItems = latestNextUpService.getResume(userId, 10, true)
val seriesIds = resumeItems.mapNotNull { it.data.seriesId } val seriesIds = resumeItems.mapNotNull { it.data.seriesId }
@ -152,11 +150,7 @@ class TvProviderWorker
latestNextUpService latestNextUpService
.getNextUp(userId, 10, enableRewatching, false) .getNextUp(userId, 10, enableRewatching, false)
.filter { it.data.seriesId != null && it.data.seriesId !in seriesIds } .filter { it.data.seriesId != null && it.data.seriesId !in seriesIds }
return if (combineContinueNext) { return latestNextUpService.buildCombined(resumeItems, nextUpItems)
latestNextUpService.buildCombined(resumeItems, nextUpItems)
} else {
resumeItems + nextUpItems
}
} }
private suspend fun getCurrentTvChannelNextUp(): List<WatchNextProgram> = private suspend fun getCurrentTvChannelNextUp(): List<WatchNextProgram> =

View file

@ -23,11 +23,16 @@ import androidx.tv.material3.Icon
import androidx.tv.material3.MaterialTheme import androidx.tv.material3.MaterialTheme
import androidx.tv.material3.Text import androidx.tv.material3.Text
import com.github.damontecres.wholphin.R import com.github.damontecres.wholphin.R
import com.github.damontecres.wholphin.preferences.AppPreference
import com.github.damontecres.wholphin.preferences.AppPreferences
import com.github.damontecres.wholphin.ui.FontAwesome import com.github.damontecres.wholphin.ui.FontAwesome
import com.github.damontecres.wholphin.ui.preferences.ComposablePreference
import com.github.damontecres.wholphin.ui.tryRequestFocus import com.github.damontecres.wholphin.ui.tryRequestFocus
@Composable @Composable
fun HomeSettingsGlobal( fun HomeSettingsGlobal(
preferences: AppPreferences,
onPreferenceChange: (AppPreferences) -> Unit,
onClickResize: (Int) -> Unit, onClickResize: (Int) -> Unit,
onClickSave: () -> Unit, onClickSave: () -> Unit,
onClickLoad: () -> Unit, onClickLoad: () -> Unit,
@ -52,6 +57,31 @@ fun HomeSettingsGlobal(
.fillMaxHeight() .fillMaxHeight()
.focusRestorer(firstFocus), .focusRestorer(firstFocus),
) { ) {
item {
ComposablePreference(
preference = AppPreference.HomePageItems,
value = AppPreference.HomePageItems.getter.invoke(preferences),
onValueChange = {
val newPrefs = AppPreference.HomePageItems.setter.invoke(preferences, it)
onPreferenceChange.invoke(newPrefs)
},
onNavigate = {},
modifier = Modifier.focusRequester(firstFocus),
)
}
item {
ComposablePreference(
preference = AppPreference.RewatchNextUp,
value = AppPreference.RewatchNextUp.getter.invoke(preferences),
onValueChange = {
val newPrefs = AppPreference.RewatchNextUp.setter.invoke(preferences, it)
onPreferenceChange.invoke(newPrefs)
},
onNavigate = {},
modifier = Modifier,
)
}
item { HorizontalDivider() }
item { item {
HomeSettingsListItem( HomeSettingsListItem(
selected = false, selected = false,
@ -63,7 +93,7 @@ fun HomeSettingsGlobal(
) )
}, },
onClick = { onClickResize.invoke(1) }, onClick = { onClickResize.invoke(1) },
modifier = Modifier.focusRequester(firstFocus), modifier = Modifier,
) )
} }
item { item {

View file

@ -30,7 +30,10 @@ import androidx.tv.material3.MaterialTheme
import androidx.tv.material3.surfaceColorAtElevation import androidx.tv.material3.surfaceColorAtElevation
import com.github.damontecres.wholphin.R import com.github.damontecres.wholphin.R
import com.github.damontecres.wholphin.data.model.HomeRowConfig import com.github.damontecres.wholphin.data.model.HomeRowConfig
import com.github.damontecres.wholphin.data.model.HomeRowViewOptions
import com.github.damontecres.wholphin.preferences.AppPreferences
import com.github.damontecres.wholphin.ui.components.ConfirmDialog import com.github.damontecres.wholphin.ui.components.ConfirmDialog
import com.github.damontecres.wholphin.ui.launchIO
import com.github.damontecres.wholphin.ui.main.HomePageContent import com.github.damontecres.wholphin.ui.main.HomePageContent
import com.github.damontecres.wholphin.ui.main.settings.HomeSettingsDestination.ChooseRowType import com.github.damontecres.wholphin.ui.main.settings.HomeSettingsDestination.ChooseRowType
import com.github.damontecres.wholphin.ui.main.settings.HomeSettingsDestination.RowSettings import com.github.damontecres.wholphin.ui.main.settings.HomeSettingsDestination.RowSettings
@ -163,10 +166,18 @@ fun HomeSettingsPage(
else -> Options.OPTIONS else -> Options.OPTIONS
} }
} }
val defaultViewOptions =
remember(row.config) {
when (row.config) {
is HomeRowConfig.Genres -> HomeRowViewOptions.genreDefault
else -> HomeRowViewOptions()
}
}
HomeRowSettings( HomeRowSettings(
title = row.title, title = row.title,
preferenceOptions = preferenceOptions, preferenceOptions = preferenceOptions,
viewOptions = row.config.viewOptions, viewOptions = row.config.viewOptions,
defaultViewOptions = defaultViewOptions,
onViewOptionsChange = { onViewOptionsChange = {
viewModel.updateViewOptions(dest.rowId, it) viewModel.updateViewOptions(dest.rowId, it)
}, },
@ -190,7 +201,18 @@ fun HomeSettingsPage(
} }
HomeSettingsDestination.GlobalSettings -> { HomeSettingsDestination.GlobalSettings -> {
val preferences by
viewModel.preferencesDataStore.data.collectAsState(
AppPreferences.getDefaultInstance(),
)
HomeSettingsGlobal( HomeSettingsGlobal(
preferences = preferences,
onPreferenceChange = { newPrefs ->
scope.launchIO {
viewModel.preferencesDataStore.updateData { newPrefs }
}
},
onClickResize = { viewModel.resizeCards(it) }, onClickResize = { viewModel.resizeCards(it) },
onClickSave = { onClickSave = {
showConfirmDialog = showConfirmDialog =

View file

@ -3,6 +3,7 @@ package com.github.damontecres.wholphin.ui.main.settings
import android.content.Context import android.content.Context
import android.widget.Toast import android.widget.Toast
import androidx.compose.runtime.Immutable import androidx.compose.runtime.Immutable
import androidx.datastore.core.DataStore
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import com.github.damontecres.wholphin.R import com.github.damontecres.wholphin.R
@ -19,6 +20,7 @@ import com.github.damontecres.wholphin.data.model.HomeRowConfig.RecentlyAdded
import com.github.damontecres.wholphin.data.model.HomeRowConfig.RecentlyReleased import com.github.damontecres.wholphin.data.model.HomeRowConfig.RecentlyReleased
import com.github.damontecres.wholphin.data.model.HomeRowConfig.Suggestions import com.github.damontecres.wholphin.data.model.HomeRowConfig.Suggestions
import com.github.damontecres.wholphin.data.model.HomeRowViewOptions import com.github.damontecres.wholphin.data.model.HomeRowViewOptions
import com.github.damontecres.wholphin.preferences.AppPreferences
import com.github.damontecres.wholphin.services.BackdropService import com.github.damontecres.wholphin.services.BackdropService
import com.github.damontecres.wholphin.services.HomePageResolvedSettings import com.github.damontecres.wholphin.services.HomePageResolvedSettings
import com.github.damontecres.wholphin.services.HomeRowConfigDisplay import com.github.damontecres.wholphin.services.HomeRowConfigDisplay
@ -64,6 +66,7 @@ class HomeSettingsViewModel
private val navDrawerItemRepository: NavDrawerItemRepository, private val navDrawerItemRepository: NavDrawerItemRepository,
private val backdropService: BackdropService, private val backdropService: BackdropService,
private val seerrServerRepository: SeerrServerRepository, private val seerrServerRepository: SeerrServerRepository,
val preferencesDataStore: DataStore<AppPreferences>,
@param:IoCoroutineScope private val ioScope: CoroutineScope, @param:IoCoroutineScope private val ioScope: CoroutineScope,
) : ViewModel() { ) : ViewModel() {
private val _state = MutableStateFlow(HomePageSettingsState.EMPTY) private val _state = MutableStateFlow(HomePageSettingsState.EMPTY)

View file

@ -501,8 +501,8 @@
<string name="overwrite_local_settings">Overwrite local settings?</string> <string name="overwrite_local_settings">Overwrite local settings?</string>
<string name="for_episodes">For episodes</string> <string name="for_episodes">For episodes</string>
<string name="suggestions_for">Suggestions for %1$s</string> <string name="suggestions_for">Suggestions for %1$s</string>
<string name="increase_all_cards_size">Increase all cards size</string> <string name="increase_all_cards_size">Increase size for all cards</string>
<string name="decrease_all_cards_size">Decrease all cards size</string> <string name="decrease_all_cards_size">Decrease size for all cards</string>
<string name="use_thumb_images">Use thumb images</string> <string name="use_thumb_images">Use thumb images</string>
<string-array name="theme_song_volume"> <string-array name="theme_song_volume">