Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganize pillarbox-demo-tv structure and add missing examples #405

Merged
merged 3 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) SRG SSR. All rights reserved.
* License information is available from the LICENSE file.
*/
package ch.srgssr.pillarbox.demo.ui.examples
package ch.srgssr.pillarbox.demo.shared.ui.examples

import android.app.Application
import androidx.lifecycle.AndroidViewModel
Expand Down Expand Up @@ -40,6 +40,7 @@ class ExamplesViewModel(application: Application) : AndroidViewModel(application
item.title
},
description = "DRM-protected video",
imageUrl = item.imageUrl.rawUrl,
uri = item.urn
)
}
Expand All @@ -48,6 +49,7 @@ class ExamplesViewModel(application: Application) : AndroidViewModel(application
DemoItem(
title = item.title,
description = "Token-protected video",
imageUrl = item.imageUrl.rawUrl,
uri = item.urn
)
}
Expand Down
2 changes: 1 addition & 1 deletion pillarbox-demo-tv/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</intent-filter>
</activity>
<activity
android:name=".player.PlayerActivity"
android:name=".ui.player.PlayerActivity"
android:theme="@style/Theme.Leanback" />
</application>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ import androidx.tv.material3.LocalContentColor
import androidx.tv.material3.MaterialTheme
import ch.srgssr.pillarbox.demo.shared.ui.HomeDestination
import ch.srgssr.pillarbox.demo.shared.ui.navigate
import ch.srgssr.pillarbox.demo.tv.ui.TVDemoNavigation
import ch.srgssr.pillarbox.demo.tv.ui.TVDemoTopBar
import ch.srgssr.pillarbox.demo.tv.ui.components.TVDemoTopBar
import ch.srgssr.pillarbox.demo.tv.ui.theme.PillarboxTheme
import ch.srgssr.pillarbox.demo.tv.ui.theme.paddings

Expand Down Expand Up @@ -74,7 +73,7 @@ class MainActivity : ComponentActivity() {
}
)

TVDemoNavigation(
MainNavigation(
navController = navController,
startDestination = startDestination,
modifier = Modifier.fillMaxSize()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) SRG SSR. All rights reserved.
* License information is available from the LICENSE file.
*/
package ch.srgssr.pillarbox.demo.tv.ui
package ch.srgssr.pillarbox.demo.tv

import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
Expand All @@ -21,10 +21,10 @@ import ch.srgssr.pillarbox.demo.shared.di.PlayerModule
import ch.srgssr.pillarbox.demo.shared.ui.HomeDestination
import ch.srgssr.pillarbox.demo.shared.ui.integrationLayer.SearchViewModel
import ch.srgssr.pillarbox.demo.shared.ui.integrationLayer.data.contentListSections
import ch.srgssr.pillarbox.demo.tv.examples.ExamplesHome
import ch.srgssr.pillarbox.demo.tv.player.PlayerActivity
import ch.srgssr.pillarbox.demo.tv.ui.integrationLayer.ListsHome
import ch.srgssr.pillarbox.demo.tv.ui.integrationLayer.SearchView
import ch.srgssr.pillarbox.demo.tv.ui.examples.ExamplesHome
import ch.srgssr.pillarbox.demo.tv.ui.lists.ListsHome
import ch.srgssr.pillarbox.demo.tv.ui.player.PlayerActivity
import ch.srgssr.pillarbox.demo.tv.ui.search.SearchHome
import ch.srgssr.pillarbox.demo.tv.ui.theme.PillarboxTheme
import ch.srgssr.pillarbox.demo.tv.ui.theme.paddings

Expand All @@ -37,7 +37,7 @@ import ch.srgssr.pillarbox.demo.tv.ui.theme.paddings
*/
@Composable
@OptIn(ExperimentalTvMaterial3Api::class)
fun TVDemoNavigation(
fun MainNavigation(
navController: NavHostController,
startDestination: HomeDestination,
modifier: Modifier = Modifier,
Expand Down Expand Up @@ -71,7 +71,7 @@ fun TVDemoNavigation(
factory = SearchViewModel.Factory(ilRepository)
)

SearchView(
SearchHome(
searchViewModel = searchViewModel,
modifier = Modifier.padding(top = MaterialTheme.paddings.baseline)
)
Expand All @@ -81,9 +81,9 @@ fun TVDemoNavigation(

@Preview
@Composable
private fun TVDemoNavigationPreview() {
private fun MainNavigationPreview() {
PillarboxTheme {
TVDemoNavigation(
MainNavigation(
navController = rememberNavController(),
startDestination = HomeDestination.Examples
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) SRG SSR. All rights reserved.
* License information is available from the LICENSE file.
*/
package ch.srgssr.pillarbox.demo.tv.ui
package ch.srgssr.pillarbox.demo.tv.ui.components

import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) SRG SSR. All rights reserved.
* License information is available from the LICENSE file.
*/
package ch.srgssr.pillarbox.demo.tv.examples
package ch.srgssr.pillarbox.demo.tv.ui.examples

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
Expand All @@ -13,6 +13,7 @@ import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
Expand All @@ -37,6 +38,7 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.NavHostController
import androidx.navigation.NavType
import androidx.navigation.compose.NavHost
Expand All @@ -52,8 +54,8 @@ import androidx.tv.material3.ExperimentalTvMaterial3Api
import androidx.tv.material3.MaterialTheme
import androidx.tv.material3.Text
import ch.srgssr.pillarbox.demo.shared.data.DemoItem
import ch.srgssr.pillarbox.demo.shared.data.Playlist
import ch.srgssr.pillarbox.demo.shared.ui.NavigationRoutes
import ch.srgssr.pillarbox.demo.shared.ui.examples.ExamplesViewModel
import ch.srgssr.pillarbox.demo.tv.extension.onDpadEvent
import ch.srgssr.pillarbox.demo.tv.ui.theme.PillarboxTheme
import ch.srgssr.pillarbox.demo.tv.ui.theme.paddings
Expand All @@ -73,8 +75,9 @@ fun ExamplesHome(
modifier: Modifier = Modifier,
onItemSelected: (DemoItem) -> Unit = {},
) {
val examplesViewModel: ExamplesViewModel = viewModel()
val navController = rememberNavController()
val playlists = Playlist.examplesPlaylists
val playlists by examplesViewModel.contents.collectAsState()

NavHost(
navController = navController,
Expand Down Expand Up @@ -268,7 +271,7 @@ private fun <T> ExamplesSection(

@Preview
@Composable
private fun ExamplesPreview() {
private fun ExamplesHomePreview() {
PillarboxTheme {
ExamplesHome()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) SRG SSR. All rights reserved.
* License information is available from the LICENSE file.
*/
package ch.srgssr.pillarbox.demo.tv.ui.integrationLayer
package ch.srgssr.pillarbox.demo.tv.ui.lists

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
Expand Down Expand Up @@ -89,7 +89,7 @@ import ch.srgssr.pillarbox.demo.shared.ui.integrationLayer.data.contentListFacto
import ch.srgssr.pillarbox.demo.shared.ui.integrationLayer.data.contentListSections
import ch.srgssr.pillarbox.demo.tv.R
import ch.srgssr.pillarbox.demo.tv.extension.onDpadEvent
import ch.srgssr.pillarbox.demo.tv.player.PlayerActivity
import ch.srgssr.pillarbox.demo.tv.ui.player.PlayerActivity
import ch.srgssr.pillarbox.demo.tv.ui.theme.PillarboxTheme
import ch.srgssr.pillarbox.demo.tv.ui.theme.paddings
import coil.compose.AsyncImage
Expand Down Expand Up @@ -701,7 +701,7 @@ private fun ListsSectionError(

@Preview
@Composable
private fun ContentListsViewPreview() {
private fun ListsHomePreview() {
PillarboxTheme {
ListsHome(sections = contentListSections)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) SRG SSR. All rights reserved.
* License information is available from the LICENSE file.
*/
package ch.srgssr.pillarbox.demo.tv.player
package ch.srgssr.pillarbox.demo.tv.ui.player

import android.content.Context
import android.content.Intent
Expand All @@ -15,7 +15,7 @@ import androidx.compose.ui.Modifier
import androidx.media3.session.MediaSession
import ch.srgssr.pillarbox.demo.shared.data.DemoItem
import ch.srgssr.pillarbox.demo.shared.di.PlayerModule
import ch.srgssr.pillarbox.demo.tv.player.compose.TvPlayerView
import ch.srgssr.pillarbox.demo.tv.ui.player.compose.PlayerView
import ch.srgssr.pillarbox.demo.tv.ui.theme.PillarboxTheme
import ch.srgssr.pillarbox.player.PillarboxPlayer

Expand Down Expand Up @@ -49,7 +49,7 @@ class PlayerActivity : ComponentActivity() {

setContent {
PillarboxTheme {
TvPlayerView(
PlayerView(
player = player,
modifier = Modifier.fillMaxSize()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) SRG SSR. All rights reserved.
* License information is available from the LICENSE file.
*/
package ch.srgssr.pillarbox.demo.tv.player.compose
package ch.srgssr.pillarbox.demo.tv.ui.player.compose

import androidx.activity.compose.BackHandler
import androidx.compose.animation.AnimatedVisibility
Expand All @@ -29,6 +29,9 @@ import androidx.tv.material3.MaterialTheme
import androidx.tv.material3.rememberDrawerState
import ch.srgssr.pillarbox.demo.shared.R
import ch.srgssr.pillarbox.demo.tv.extension.onDpadEvent
import ch.srgssr.pillarbox.demo.tv.ui.player.compose.controls.PlayerError
import ch.srgssr.pillarbox.demo.tv.ui.player.compose.controls.PlayerPlaybackRow
import ch.srgssr.pillarbox.demo.tv.ui.player.compose.settings.PlaybackSettingsDrawer
import ch.srgssr.pillarbox.demo.tv.ui.theme.paddings
import ch.srgssr.pillarbox.ui.extension.playerErrorAsState
import ch.srgssr.pillarbox.ui.widget.maintainVisibleOnFocus
Expand All @@ -43,7 +46,7 @@ import ch.srgssr.pillarbox.ui.widget.rememberDelayedVisibilityState
*/
@Composable
@OptIn(ExperimentalTvMaterial3Api::class)
fun TvPlayerView(
fun PlayerView(
player: Player,
modifier: Modifier = Modifier
) {
Expand All @@ -57,7 +60,7 @@ fun TvPlayerView(
}
}

PlayerSettingDrawer(
PlaybackSettingsDrawer(
player = player,
drawerState = drawerState,
modifier = modifier
Expand Down Expand Up @@ -89,7 +92,7 @@ fun TvPlayerView(
.maintainVisibleOnFocus(delayedVisibilityState = visibilityState),
contentAlignment = Alignment.Center
) {
TvPlaybackRow(
PlayerPlaybackRow(
player = player,
state = visibilityState
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) SRG SSR. All rights reserved.
* License information is available from the LICENSE file.
*/
package ch.srgssr.pillarbox.demo.tv.player.compose
package ch.srgssr.pillarbox.demo.tv.ui.player.compose.controls

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) SRG SSR. All rights reserved.
* License information is available from the LICENSE file.
*/
package ch.srgssr.pillarbox.demo.tv.player.compose
package ch.srgssr.pillarbox.demo.tv.ui.player.compose.controls

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
Expand Down Expand Up @@ -43,7 +43,7 @@ import ch.srgssr.pillarbox.ui.widget.DelayedVisibilityState
*/
@OptIn(ExperimentalTvMaterial3Api::class)
@Composable
fun TvPlaybackRow(
fun PlayerPlaybackRow(
player: Player,
state: DelayedVisibilityState,
modifier: Modifier = Modifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) SRG SSR. All rights reserved.
* License information is available from the LICENSE file.
*/
package ch.srgssr.pillarbox.demo.tv.player.compose
package ch.srgssr.pillarbox.demo.tv.ui.player.compose.settings

import android.app.Application
import androidx.activity.compose.BackHandler
Expand Down Expand Up @@ -69,7 +69,7 @@ import ch.srgssr.pillarbox.player.extension.hasAccessibilityRoles
*/
@Composable
@OptIn(ExperimentalTvMaterial3Api::class)
fun PlayerSettingDrawer(
fun PlaybackSettingsDrawer(
player: Player,
drawerState: DrawerState,
modifier: Modifier = Modifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) SRG SSR. All rights reserved.
* License information is available from the LICENSE file.
*/
package ch.srgssr.pillarbox.demo.tv.player.leanback
package ch.srgssr.pillarbox.demo.tv.ui.player.leanback

import android.app.Activity
import android.content.Intent
Expand All @@ -24,7 +24,7 @@ class LeanbackPlayerActivity : FragmentActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_player)
setContentView(R.layout.activity_leanback_player)
leanbackPlayerFragment = supportFragmentManager.findFragmentById(R.id.fragment_container) as LeanbackPlayerFragment
val demoItem = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
intent.getSerializableExtra(ARG_ITEM, DemoItem::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) SRG SSR. All rights reserved.
* License information is available from the LICENSE file.
*/
package ch.srgssr.pillarbox.demo.tv.player.leanback
package ch.srgssr.pillarbox.demo.tv.ui.player.leanback

import android.os.Bundle
import androidx.leanback.app.VideoSupportFragment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) SRG SSR. All rights reserved.
* License information is available from the LICENSE file.
*/
package ch.srgssr.pillarbox.demo.tv.ui.integrationLayer
package ch.srgssr.pillarbox.demo.tv.ui.search

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
Expand Down Expand Up @@ -48,7 +48,8 @@ import ch.srgssr.pillarbox.demo.shared.data.DemoItem
import ch.srgssr.pillarbox.demo.shared.ui.integrationLayer.SearchViewModel
import ch.srgssr.pillarbox.demo.shared.ui.integrationLayer.data.bus
import ch.srgssr.pillarbox.demo.tv.extension.onDpadEvent
import ch.srgssr.pillarbox.demo.tv.player.PlayerActivity
import ch.srgssr.pillarbox.demo.tv.ui.lists.ListsSection
import ch.srgssr.pillarbox.demo.tv.ui.player.PlayerActivity
import ch.srgssr.pillarbox.demo.tv.ui.theme.PillarboxTheme
import ch.srgssr.pillarbox.demo.tv.ui.theme.paddings

Expand All @@ -60,7 +61,7 @@ import ch.srgssr.pillarbox.demo.tv.ui.theme.paddings
*/
@Composable
@OptIn(ExperimentalTvMaterial3Api::class)
fun SearchView(
fun SearchHome(
searchViewModel: SearchViewModel,
modifier: Modifier = Modifier
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
-->
<androidx.fragment.app.FragmentContainerView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment_container"
android:name="ch.srgssr.pillarbox.demo.tv.player.leanback.LeanbackPlayerFragment"
android:name="ch.srgssr.pillarbox.demo.tv.ui.player.leanback.LeanbackPlayerFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
~ Copyright (c) SRG SSR. All rights reserved.
~ License information is available from the LICENSE file.
-->
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_pillarbox_background"/>
<foreground android:drawable="@mipmap/ic_launcher_pillarbox_foreground"/>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="MonochromeLauncherIcon">
<background android:drawable="@color/ic_launcher_pillarbox_background" />
<foreground android:drawable="@mipmap/ic_launcher_pillarbox_foreground" />
</adaptive-icon>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import androidx.lifecycle.viewmodel.compose.viewModel
import ch.srgssr.pillarbox.demo.BuildConfig
import ch.srgssr.pillarbox.demo.shared.data.DemoItem
import ch.srgssr.pillarbox.demo.shared.data.Playlist
import ch.srgssr.pillarbox.demo.shared.ui.examples.ExamplesViewModel
import ch.srgssr.pillarbox.demo.ui.components.DemoListHeaderView
import ch.srgssr.pillarbox.demo.ui.components.DemoListItemView
import ch.srgssr.pillarbox.demo.ui.components.DemoListSectionView
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.