Improved home page support for Live TV & Recordings (#890)
## Description Improves home page customization for Live TV & Recordings - Add row for live tv channels - Add row for "on now" programs - Clicking on a TV channel or TV program starts playback - Better name for "Recently recorded" instead of "Recently added in Recordings" Also fixes a back stack issue after adding rows ### Related issues Follow up from #803 ### Testing Emulator ## Screenshots <img width="663" height="190" alt="image" src="https://github.com/user-attachments/assets/49d41953-42ab-4621-92f1-b7936aab7e97" /> ## AI or LLM usage None
This commit is contained in:
parent
7fcd66f407
commit
91900af7a9
13 changed files with 229 additions and 64 deletions
|
|
@ -84,7 +84,7 @@ val PhotoItemFields =
|
|||
object Cards {
|
||||
const val HEIGHT_2X3_DP = 172
|
||||
val height2x3 = HEIGHT_2X3_DP.dp
|
||||
val HEIGHT_EPISODE = (HEIGHT_2X3_DP * .75f).toInt().let { it - it % 4 }
|
||||
const val HEIGHT_EPISODE = 128
|
||||
val heightEpisode = HEIGHT_EPISODE.dp
|
||||
val playedPercentHeight = 6.dp
|
||||
val serverUserCircle = height2x3 * .75f
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import com.github.damontecres.wholphin.services.MediaReportService
|
|||
import com.github.damontecres.wholphin.services.NavDrawerService
|
||||
import com.github.damontecres.wholphin.services.NavigationManager
|
||||
import com.github.damontecres.wholphin.services.UserPreferencesService
|
||||
import com.github.damontecres.wholphin.services.tvAccess
|
||||
import com.github.damontecres.wholphin.ui.launchIO
|
||||
import com.github.damontecres.wholphin.ui.showToast
|
||||
import com.github.damontecres.wholphin.util.ExceptionHandler
|
||||
|
|
@ -68,7 +69,8 @@ class HomeViewModel
|
|||
val prefs = preferences.appPreferences.homePagePreferences
|
||||
|
||||
serverRepository.currentUserDto.value?.let { userDto ->
|
||||
val libraries = navDrawerService.getAllUserLibraries(userDto.id)
|
||||
val libraries =
|
||||
navDrawerService.getAllUserLibraries(userDto.id, userDto.tvAccess)
|
||||
val settings =
|
||||
homeSettingsService.currentSettings.first { it != HomePageResolvedSettings.EMPTY }
|
||||
val state = state.value
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import com.github.damontecres.wholphin.R
|
|||
import com.github.damontecres.wholphin.services.SuggestionsWorker
|
||||
import com.github.damontecres.wholphin.ui.ifElse
|
||||
import com.github.damontecres.wholphin.ui.tryRequestFocus
|
||||
import org.jellyfin.sdk.model.api.CollectionType
|
||||
|
||||
@Composable
|
||||
fun HomeLibraryRowTypeList(
|
||||
|
|
@ -63,11 +64,38 @@ fun HomeLibraryRowTypeList(
|
|||
}
|
||||
|
||||
fun getSupportedRowTypes(library: Library): List<LibraryRowType> {
|
||||
val itemKind = SuggestionsWorker.getTypeForCollection(library.collectionType)
|
||||
return if (itemKind != null) {
|
||||
LibraryRowType.entries
|
||||
} else {
|
||||
LibraryRowType.entries.toMutableList().apply { remove(LibraryRowType.SUGGESTIONS) }
|
||||
val supportsSuggestions = SuggestionsWorker.getTypeForCollection(library.collectionType) != null
|
||||
return when {
|
||||
library.isRecordingFolder -> {
|
||||
listOf(
|
||||
LibraryRowType.RECENTLY_RECORDED,
|
||||
LibraryRowType.GENRES,
|
||||
)
|
||||
}
|
||||
|
||||
library.collectionType == CollectionType.LIVETV -> {
|
||||
listOf(
|
||||
LibraryRowType.TV_CHANNELS,
|
||||
LibraryRowType.TV_PROGRAMS,
|
||||
)
|
||||
}
|
||||
|
||||
supportsSuggestions -> {
|
||||
listOf(
|
||||
LibraryRowType.RECENTLY_ADDED,
|
||||
LibraryRowType.RECENTLY_RELEASED,
|
||||
LibraryRowType.SUGGESTIONS,
|
||||
LibraryRowType.GENRES,
|
||||
)
|
||||
}
|
||||
|
||||
else -> {
|
||||
listOf(
|
||||
LibraryRowType.RECENTLY_ADDED,
|
||||
LibraryRowType.RECENTLY_RELEASED,
|
||||
LibraryRowType.GENRES,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -78,4 +106,7 @@ enum class LibraryRowType(
|
|||
RECENTLY_RELEASED(R.string.recently_released),
|
||||
SUGGESTIONS(R.string.suggestions),
|
||||
GENRES(R.string.genres),
|
||||
TV_CHANNELS(R.string.channels),
|
||||
TV_PROGRAMS(R.string.live_tv),
|
||||
RECENTLY_RECORDED(R.string.recently_recorded),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,9 @@ fun HomeSettingsPage(
|
|||
// Adds a row, waits until its done loading, then scrolls to the new row
|
||||
fun addRow(func: () -> Job) {
|
||||
scope.launch(ExceptionHandler(autoToast = true)) {
|
||||
backStack.add(HomeSettingsDestination.RowList)
|
||||
while (backStack.size > 1) {
|
||||
backStack.removeAt(backStack.lastIndex)
|
||||
}
|
||||
func.invoke().join()
|
||||
listState.animateScrollToItem(state.rows.lastIndex)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import com.github.damontecres.wholphin.services.SeerrServerRepository
|
|||
import com.github.damontecres.wholphin.services.UnsupportedHomeSettingsVersionException
|
||||
import com.github.damontecres.wholphin.services.UserPreferencesService
|
||||
import com.github.damontecres.wholphin.services.hilt.IoCoroutineScope
|
||||
import com.github.damontecres.wholphin.services.tvAccess
|
||||
import com.github.damontecres.wholphin.ui.launchIO
|
||||
import com.github.damontecres.wholphin.ui.showToast
|
||||
import com.github.damontecres.wholphin.util.HomeRowLoadingState
|
||||
|
|
@ -83,8 +84,8 @@ class HomeSettingsViewModel
|
|||
init {
|
||||
addCloseable { saveToLocal() }
|
||||
viewModelScope.launchIO {
|
||||
val userId = serverRepository.currentUser.value?.id ?: return@launchIO
|
||||
val libraries = navDrawerService.getAllUserLibraries(userId)
|
||||
val userDto = serverRepository.currentUserDto.value ?: return@launchIO
|
||||
val libraries = navDrawerService.getAllUserLibraries(userDto.id, userDto.tvAccess)
|
||||
val currentSettings =
|
||||
homeSettingsService.currentSettings.first { it != HomePageResolvedSettings.EMPTY }
|
||||
Timber.v("currentSettings=%s", currentSettings)
|
||||
|
|
@ -292,6 +293,36 @@ class HomeSettingsViewModel
|
|||
config = Suggestions(library.itemId),
|
||||
)
|
||||
}
|
||||
|
||||
LibraryRowType.TV_CHANNELS -> {
|
||||
val title = context.getString(R.string.channels)
|
||||
HomeRowConfigDisplay(
|
||||
id = id,
|
||||
title = title,
|
||||
config =
|
||||
HomeRowConfig.TvChannels(
|
||||
viewOptions = HomeRowViewOptions.channelsDefault,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
LibraryRowType.TV_PROGRAMS -> {
|
||||
val title = context.getString(R.string.watch_live)
|
||||
HomeRowConfigDisplay(
|
||||
id = id,
|
||||
title = title,
|
||||
config = HomeRowConfig.TvPrograms(),
|
||||
)
|
||||
}
|
||||
|
||||
LibraryRowType.RECENTLY_RECORDED -> {
|
||||
val title = context.getString(R.string.recently_recorded)
|
||||
HomeRowConfigDisplay(
|
||||
id = id,
|
||||
title = title,
|
||||
config = RecentlyAdded(library.itemId),
|
||||
)
|
||||
}
|
||||
}
|
||||
updateState {
|
||||
it.copy(
|
||||
|
|
@ -614,6 +645,10 @@ class HomeSettingsViewModel
|
|||
is HomeRowConfig.TvPrograms -> {
|
||||
it.config.updateViewOptions(preset.tvLibrary)
|
||||
}
|
||||
|
||||
is HomeRowConfig.TvChannels -> {
|
||||
it.config
|
||||
}
|
||||
}
|
||||
it.copy(config = newConfig)
|
||||
}
|
||||
|
|
@ -658,5 +693,7 @@ data class HomePageSettingsState(
|
|||
data class Library(
|
||||
@Serializable(UUIDSerializer::class) val itemId: UUID,
|
||||
val name: String,
|
||||
val type: BaseItemKind,
|
||||
val collectionType: CollectionType,
|
||||
val isRecordingFolder: Boolean,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ fun DestinationContent(
|
|||
|
||||
else -> {
|
||||
Timber.w("Unsupported item type: ${destination.type}")
|
||||
Text("Unsupported item type: ${destination.type}")
|
||||
Text("Unsupported item type: ${destination.type}", modifier)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue