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 structure #398

Merged
merged 1 commit into from
Jan 19, 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
2 changes: 1 addition & 1 deletion pillarbox-demo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
android:launchMode="singleTask"
android:supportsPictureInPicture="true" />
<activity
android:name=".ui.player.mediacontroller.MediaControllerActivity"
android:name=".ui.showcases.integrations.MediaControllerActivity"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden|smallestScreenSize"
android:exported="true"
android:launchMode="singleTask"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.ui.Modifier
import ch.srgssr.pillarbox.demo.ui.MainNavigation
import ch.srgssr.pillarbox.demo.ui.theme.PillarboxTheme

/**
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.ui
package ch.srgssr.pillarbox.demo

import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
Expand Down Expand Up @@ -53,20 +53,17 @@ import ch.srg.dataProvider.integrationlayer.request.image.ImageWidth
import ch.srg.dataProvider.integrationlayer.request.image.decorated
import ch.srgssr.pillarbox.analytics.SRGAnalytics
import ch.srgssr.pillarbox.core.business.integrationlayer.service.IlHost
import ch.srgssr.pillarbox.demo.DemoPageView
import ch.srgssr.pillarbox.demo.R
import ch.srgssr.pillarbox.demo.shared.data.DemoItem
import ch.srgssr.pillarbox.demo.shared.di.PlayerModule
import ch.srgssr.pillarbox.demo.shared.ui.HomeDestination
import ch.srgssr.pillarbox.demo.shared.ui.NavigationRoutes
import ch.srgssr.pillarbox.demo.shared.ui.integrationLayer.SearchViewModel
import ch.srgssr.pillarbox.demo.shared.ui.navigate
import ch.srgssr.pillarbox.demo.trackPagView
import ch.srgssr.pillarbox.demo.ui.examples.ExamplesHome
import ch.srgssr.pillarbox.demo.ui.integrationLayer.SearchView
import ch.srgssr.pillarbox.demo.ui.integrationLayer.listNavGraph
import ch.srgssr.pillarbox.demo.ui.lists.listsNavGraph
import ch.srgssr.pillarbox.demo.ui.player.SimplePlayerActivity
import ch.srgssr.pillarbox.demo.ui.showcases.showCasesNavGraph
import ch.srgssr.pillarbox.demo.ui.search.SearchHome
import ch.srgssr.pillarbox.demo.ui.showcases.showcasesNavGraph
import ch.srgssr.pillarbox.demo.ui.theme.PillarboxTheme
import ch.srgssr.pillarbox.demo.ui.theme.paddings
import java.net.URL
Expand Down Expand Up @@ -129,19 +126,19 @@ fun MainNavigation() {
}

navigation(startDestination = NavigationRoutes.showcaseList, route = HomeDestination.ShowCases.route) {
showCasesNavGraph(navController)
showcasesNavGraph(navController)
}

navigation(startDestination = NavigationRoutes.contentLists, route = HomeDestination.Lists.route) {
val ilRepository = PlayerModule.createIlRepository(context, ilHost)

listNavGraph(navController, ilRepository, ilHost)
listsNavGraph(navController, ilRepository, ilHost)
}

composable(route = NavigationRoutes.searchHome, DemoPageView("home", listOf("app", "pillarbox", "search"))) {
val ilRepository = PlayerModule.createIlRepository(context)
val viewModel: SearchViewModel = viewModel(factory = SearchViewModel.Factory(ilRepository))
SearchView(searchViewModel = viewModel) {
SearchHome(searchViewModel = viewModel) {
val item = DemoItem(
title = it.title,
uri = it.urn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import androidx.media3.session.LibraryResult
import androidx.media3.session.MediaSession
import ch.srgssr.pillarbox.demo.shared.data.DemoBrowser
import ch.srgssr.pillarbox.demo.shared.di.PlayerModule
import ch.srgssr.pillarbox.demo.ui.player.mediacontroller.MediaControllerActivity
import ch.srgssr.pillarbox.demo.ui.showcases.integrations.MediaControllerActivity
import ch.srgssr.pillarbox.player.service.PillarboxMediaLibraryService
import ch.srgssr.pillarbox.player.utils.PendingIntentUtils
import com.google.common.collect.ImmutableList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import androidx.media3.common.C
import androidx.media3.common.MediaItem
import ch.srgssr.pillarbox.demo.shared.data.DemoItem
import ch.srgssr.pillarbox.demo.shared.di.PlayerModule
import ch.srgssr.pillarbox.demo.ui.player.mediacontroller.MediaControllerActivity
import ch.srgssr.pillarbox.demo.ui.showcases.integrations.MediaControllerActivity
import ch.srgssr.pillarbox.player.service.PillarboxMediaSessionService
import ch.srgssr.pillarbox.player.utils.PendingIntentUtils

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
* Copyright (c) SRG SSR. All rights reserved.
* License information is available from the LICENSE file.
*/
package ch.srgssr.pillarbox.demo.ui.integrationLayer
package ch.srgssr.pillarbox.demo.ui.components

import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import ch.srg.dataProvider.integrationlayer.data.ImageUrl
import ch.srg.dataProvider.integrationlayer.data.remote.Channel
import ch.srg.dataProvider.integrationlayer.data.remote.Media
import ch.srg.dataProvider.integrationlayer.data.remote.MediaType
import ch.srg.dataProvider.integrationlayer.data.remote.Show
Expand All @@ -19,7 +20,6 @@ import ch.srg.dataProvider.integrationlayer.data.remote.Type
import ch.srg.dataProvider.integrationlayer.data.remote.Vendor
import ch.srgssr.pillarbox.demo.shared.R
import ch.srgssr.pillarbox.demo.shared.ui.integrationLayer.data.Content
import ch.srgssr.pillarbox.demo.ui.DemoListItemView
import ch.srgssr.pillarbox.demo.ui.theme.PillarboxTheme
import java.util.Date
import kotlin.time.Duration.Companion.seconds
Expand Down Expand Up @@ -100,7 +100,7 @@ private fun ShowPreview() {
title = "Show Title",
description = "Show description",
transmission = Transmission.TV,
imageUrl = ImageUrl("https://image1.png")
imageUrl = ImageUrl("https://show.image.png")
)

PillarboxTheme {
Expand All @@ -120,7 +120,7 @@ private fun TopicPreview() {
urn = "urn:show:id",
title = "Topic title",
transmission = Transmission.TV,
imageUrl = ImageUrl("https://image2.png")
imageUrl = ImageUrl("https://topic.image.png")
)

PillarboxTheme {
Expand All @@ -145,7 +145,7 @@ private fun MediaPreview() {
mediaType = MediaType.VIDEO,
playableAbroad = true,
type = Type.CLIP,
imageUrl = ImageUrl("https://image2.png")
imageUrl = ImageUrl("https://media.image.png")
)

PillarboxTheme {
Expand All @@ -155,3 +155,24 @@ private fun MediaPreview() {
)
}
}

@Composable
@Preview(showBackground = true)
private fun ChannelPreview() {
val channel = Channel(
id = "id",
vendor = Vendor.RTR,
urn = "urn:media:id",
title = "Channel title",
description = "Channel description",
imageUrl = ImageUrl("https://channel.image.png"),
transmission = Transmission.RADIO
)

PillarboxTheme {
ContentView(
content = Content.Channel(channel),
onClick = {}
)
}
}
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
package ch.srgssr.pillarbox.demo.ui.components

import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
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.ui
package ch.srgssr.pillarbox.demo.ui.components

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
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.ui
package ch.srgssr.pillarbox.demo.ui.components

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
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.ui
package ch.srgssr.pillarbox.demo.ui.components

import android.app.Activity
import android.content.Context
Expand All @@ -13,32 +13,9 @@ import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.remember
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.window.DialogWindowProvider
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat

/**
* Hide system ui
*/
fun Activity.hideSystemUi() {
WindowCompat.setDecorFitsSystemWindows(window, false)
WindowInsetsControllerCompat(window, window.decorView).let { controller ->
controller.hide(WindowInsetsCompat.Type.systemBars())
controller.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
}
}

/**
* Show system ui
*/
fun Activity.showSystemUi() {
WindowCompat.setDecorFitsSystemWindows(window, true)
WindowInsetsControllerCompat(
window,
window.decorView
).show(WindowInsetsCompat.Type.systemBars())
}

/**
* Show system ui
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ 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.ui.DemoListHeaderView
import ch.srgssr.pillarbox.demo.ui.DemoListItemView
import ch.srgssr.pillarbox.demo.ui.DemoListSectionView
import ch.srgssr.pillarbox.demo.ui.components.DemoListHeaderView
import ch.srgssr.pillarbox.demo.ui.components.DemoListItemView
import ch.srgssr.pillarbox.demo.ui.components.DemoListSectionView
import ch.srgssr.pillarbox.demo.ui.player.SimplePlayerActivity
import ch.srgssr.pillarbox.demo.ui.theme.PillarboxTheme
import ch.srgssr.pillarbox.demo.ui.theme.paddings
Expand All @@ -39,9 +39,9 @@ import ch.srgssr.pillarbox.demo.ui.theme.paddings
*/
@Composable
fun ExamplesHome() {
val exampleViewModel: ExampleViewModel = viewModel()
val examplesViewModel: ExamplesViewModel = viewModel()
val context = LocalContext.current
val playlists by exampleViewModel.contents.collectAsState()
val playlists by examplesViewModel.contents.collectAsState()

ListStreamView(playlists = playlists) {
SimplePlayerActivity.startActivity(context, it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.stateIn

/**
* Example view model
* Examples view model
*
* @param application Android Application to create [ILRepository]
*/
class ExampleViewModel(application: Application) : AndroidViewModel(application) {
class ExamplesViewModel(application: Application) : AndroidViewModel(application) {
private val repository: ILRepository = PlayerModule.createIlRepository(application)

/**
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.ui.integrationLayer
package ch.srgssr.pillarbox.demo.ui.lists

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.PaddingValues
Expand All @@ -21,6 +21,7 @@ import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.paging.compose.collectAsLazyPagingItems
import ch.srgssr.pillarbox.demo.DemoPageView
import ch.srgssr.pillarbox.demo.composable
import ch.srgssr.pillarbox.demo.shared.data.DemoItem
import ch.srgssr.pillarbox.demo.shared.ui.NavigationRoutes
import ch.srgssr.pillarbox.demo.shared.ui.integrationLayer.ContentList
Expand All @@ -29,10 +30,9 @@ import ch.srgssr.pillarbox.demo.shared.ui.integrationLayer.data.Content
import ch.srgssr.pillarbox.demo.shared.ui.integrationLayer.data.ILRepository
import ch.srgssr.pillarbox.demo.shared.ui.integrationLayer.data.contentListFactories
import ch.srgssr.pillarbox.demo.shared.ui.integrationLayer.data.contentListSections
import ch.srgssr.pillarbox.demo.ui.DemoListHeaderView
import ch.srgssr.pillarbox.demo.ui.DemoListItemView
import ch.srgssr.pillarbox.demo.ui.DemoListSectionView
import ch.srgssr.pillarbox.demo.ui.composable
import ch.srgssr.pillarbox.demo.ui.components.DemoListHeaderView
import ch.srgssr.pillarbox.demo.ui.components.DemoListItemView
import ch.srgssr.pillarbox.demo.ui.components.DemoListSectionView
import ch.srgssr.pillarbox.demo.ui.player.SimplePlayerActivity
import ch.srgssr.pillarbox.demo.ui.theme.PillarboxTheme
import ch.srgssr.pillarbox.demo.ui.theme.paddings
Expand All @@ -43,7 +43,7 @@ private val defaultListsLevels = listOf("app", "pillarbox", "lists")
/**
* Build Navigation for integration layer list view
*/
fun NavGraphBuilder.listNavGraph(navController: NavController, ilRepository: ILRepository, ilHost: URL) {
fun NavGraphBuilder.listsNavGraph(navController: NavController, ilRepository: ILRepository, ilHost: URL) {
val contentClick = { contentList: ContentList, content: Content ->
when (content) {
is Content.Show -> {
Expand Down Expand Up @@ -92,7 +92,7 @@ fun NavGraphBuilder.listNavGraph(navController: NavController, ilRepository: ILR
}

composable(route = NavigationRoutes.contentLists, DemoPageView("home", defaultListsLevels)) {
ContentListsView { contentList ->
ListsHome { contentList ->
navController.navigate(route = contentList.destinationRoute)
}
}
Expand All @@ -110,7 +110,7 @@ fun NavGraphBuilder.listNavGraph(navController: NavController, ilRepository: ILR
)
)

ContentListView(
ListsSubSection(
title = contentList.destinationTitle,
items = viewModel.data.collectAsLazyPagingItems(),
modifier = Modifier.fillMaxWidth(),
Expand All @@ -125,7 +125,7 @@ fun NavGraphBuilder.listNavGraph(navController: NavController, ilRepository: ILR
}

@Composable
private fun ContentListsView(onContentSelected: (ContentList) -> Unit) {
private fun ListsHome(onContentSelected: (ContentList) -> Unit) {
LazyColumn(
contentPadding = PaddingValues(
start = MaterialTheme.paddings.baseline,
Expand Down Expand Up @@ -161,7 +161,7 @@ private fun ContentListsView(onContentSelected: (ContentList) -> Unit) {
@Preview(showBackground = true)
private fun ContentListPreview() {
PillarboxTheme {
ContentListsView {
ListsHome {
}
}
}
Loading