From fd46ee168c8e84cae8f245680ba05157d8618469 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Muller?= Date: Wed, 11 Sep 2024 10:11:37 +0200 Subject: [PATCH] Update AndroidX Compose (#698) --- gradle/libs.versions.toml | 6 +- gradle/wrapper/gradle-wrapper.properties | 2 +- .../source/BlockedTimeRangeAssetLoader.kt | 2 +- .../demo/shared/source/CustomAssetLoader.kt | 2 +- .../demo/shared/ui/HomeDestination.kt | 6 +- .../shared/ui/components/PillarboxSlider.kt | 37 ++-- .../ui/integrationLayer/data/Content.kt | 8 +- .../ui/integrationLayer/data/ILRepository.kt | 16 +- .../settings/PlayerSettingsViewModel.kt | 4 +- .../demo/tv/ui/components/TVDemoTopBar.kt | 2 +- .../pillarbox/demo/tv/ui/search/SearchHome.kt | 18 +- pillarbox-demo/build.gradle.kts | 2 +- .../demo/service/DemoMediaLibraryService.kt | 2 +- .../demo/service/DemoMediaSessionService.kt | 2 +- .../demo/service/DemoPlaybackService.kt | 2 +- .../demo/ui/player/DemoPlayerView.kt | 16 +- .../pillarbox/demo/ui/player/LiveIndicator.kt | 5 +- .../demo/ui/player/SimplePlayerActivity.kt | 2 +- .../demo/ui/player/SimplePlayerViewModel.kt | 2 +- .../demo/ui/player/controls/PlayerControls.kt | 2 +- .../ui/player/controls/PlayerTimeSlider.kt | 6 +- .../ui/player/playlist/MediaItemLibrary.kt | 4 +- .../player/settings/PlaybackSpeedSettings.kt | 2 +- .../player/settings/TrackSelectionSettings.kt | 4 +- .../pillarbox/demo/ui/search/SearchHome.kt | 165 +++++++++--------- .../ui/showcases/layouts/ChapterShowcase.kt | 6 +- .../ui/showcases/layouts/OptimizedStory.kt | 6 +- .../demo/ui/showcases/layouts/SimpleStory.kt | 8 +- .../showcases/layouts/StoryLayoutShowcase.kt | 6 +- .../ui/showcases/misc/MultiPlayerShowcase.kt | 3 +- .../showcases/misc/ResizablePlayerShowcase.kt | 2 - .../showcases/misc/SmoothSeekingShowcase.kt | 2 +- .../misc/UpdatableMediaItemViewModel.kt | 2 +- .../pillarbox/player/PlayerCallbackFlow.kt | 2 +- .../player/TestPlayerCallbackFlow.kt | 2 +- .../ui/exoplayer/ExoplayerSubtitleView.kt | 8 +- .../ui/widget/DelayedVisibilityState.kt | 12 +- .../ui/widget/player/PlayerSurface.kt | 6 +- .../ui/widget/player/SphericalSurface.kt | 2 +- 39 files changed, 200 insertions(+), 186 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 348b4c265..b22e2d350 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,9 +1,9 @@ [versions] -accompanist = "0.34.0" android-gradle-plugin = "8.6.0" androidx-activity = "1.9.2" androidx-annotation = "1.8.2" -androidx-compose = "2024.08.00" +androidx-compose = "2024.09.01" +androidx-compose-material-navigation = "1.7.0-beta01" # TODO Remove this once https://issuetracker.google.com/issues/347719428 is resolved androidx-core = "1.13.1" androidx-fragment = "1.8.3" androidx-lifecycle = "2.8.5" @@ -37,7 +37,6 @@ tag-commander-server-side = "5.5.2" turbine = "1.1.0" [libraries] -accompanist-navigation-material = { module = "com.google.accompanist:accompanist-navigation-material", version.ref = "accompanist" } android-gradle-api = { module = "com.android.tools.build:gradle-api", version.ref = "android-gradle-plugin" } androidx-activity = { module = "androidx.activity:activity", version.ref = "androidx-activity" } androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity" } @@ -123,6 +122,7 @@ androidx-compose-ui-util = { module = "androidx.compose.ui:ui-util" } androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3" } androidx-compose-material-icons-core = { module = "androidx.compose.material:material-icons-core" } androidx-compose-material-icons-extended = { module = "androidx.compose.material:material-icons-extended" } +androidx-compose-material-navigation = { module = "androidx.compose.material:material-navigation", version.ref = "androidx-compose-material-navigation" } androidx-compose-runtime = { module = "androidx.compose.runtime:runtime" } androidx-compose-runtime-saveable = { module = "androidx.compose.runtime:runtime-saveable" } androidx-test-ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidx-test-ext-junit" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 66cd5a0e4..1ed247ec1 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-all.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/source/BlockedTimeRangeAssetLoader.kt b/pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/source/BlockedTimeRangeAssetLoader.kt index 0f8e1fa7f..9e86731a6 100644 --- a/pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/source/BlockedTimeRangeAssetLoader.kt +++ b/pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/source/BlockedTimeRangeAssetLoader.kt @@ -20,7 +20,7 @@ import kotlin.time.Duration.Companion.seconds class BlockedTimeRangeAssetLoader(context: Context) : AssetLoader(DefaultMediaSourceFactory(context)) { override fun canLoadAsset(mediaItem: MediaItem): Boolean { - return mediaItem.localConfiguration?.uri?.toString()?.startsWith("blocked:") ?: false + return mediaItem.localConfiguration?.uri?.toString()?.startsWith("blocked:") == true } override suspend fun loadAsset(mediaItem: MediaItem): Asset { diff --git a/pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/source/CustomAssetLoader.kt b/pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/source/CustomAssetLoader.kt index 714be0f4d..132475a52 100644 --- a/pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/source/CustomAssetLoader.kt +++ b/pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/source/CustomAssetLoader.kt @@ -18,7 +18,7 @@ import ch.srgssr.pillarbox.player.asset.Asset import ch.srgssr.pillarbox.player.asset.AssetLoader /** - * Custom asset loader that always load the same url and the content is not seekable. + * Custom asset loader that always loads the same url and the content is not seekable. * * @param context The context. */ diff --git a/pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/ui/HomeDestination.kt b/pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/ui/HomeDestination.kt index d3f1db2e0..92fd9e3f7 100644 --- a/pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/ui/HomeDestination.kt +++ b/pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/ui/HomeDestination.kt @@ -28,7 +28,7 @@ sealed class HomeDestination( val imageVector: ImageVector ) { /** - * Examples home page containing all kind of streams + * Examples home page containing all kinds of streams */ data object Examples : HomeDestination(NavigationRoutes.homeSamples, R.string.examples, Icons.Default.Home) @@ -62,9 +62,9 @@ fun NavController.navigate(destination: HomeDestination) { saveState = true } // Avoid multiple copies of the same destination when - // reselecting the same item + // re-selecting the same item launchSingleTop = true - // Restore state when reselecting a previously selected item + // Restore state when re-selecting a previously selected item restoreState = true } } diff --git a/pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/ui/components/PillarboxSlider.kt b/pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/ui/components/PillarboxSlider.kt index 801de533a..6bda61b55 100644 --- a/pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/ui/components/PillarboxSlider.kt +++ b/pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/ui/components/PillarboxSlider.kt @@ -87,7 +87,7 @@ fun PillarboxSlider( inactiveTrackColorDisabled: Color, secondaryTrackColorEnabled: Color = Color.Unspecified, secondaryTrackColorDisabled: Color = Color.Unspecified, - interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, + interactionSource: MutableInteractionSource? = null, onValueChange: (value: Long) -> Unit = {}, onValueChangeFinished: () -> Unit = {}, onSeekBack: () -> Unit = {}, @@ -109,7 +109,7 @@ fun PillarboxSlider( secondaryTrackColorDisabled = secondaryTrackColorDisabled, interactionSource = interactionSource, onSliderValueChange = { ratio -> - onValueChange((ratio * (range.last - range.start)).toLong()) + onValueChange((ratio * (range.last - range.first)).toLong()) }, onSliderValueChangeFinished = onValueChangeFinished, onSeekBack = onSeekBack, @@ -157,7 +157,7 @@ fun PillarboxSlider( inactiveTrackColorDisabled: Color, secondaryTrackColorEnabled: Color = Color.Unspecified, secondaryTrackColorDisabled: Color = Color.Unspecified, - interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, + interactionSource: MutableInteractionSource? = null, onValueChange: (value: Float) -> Unit = {}, onValueChangeFinished: () -> Unit = {}, onSeekBack: () -> Unit = {}, @@ -202,7 +202,7 @@ private fun PillarboxSliderInternal( inactiveTrackColorDisabled: Color, secondaryTrackColorEnabled: Color, secondaryTrackColorDisabled: Color, - interactionSource: MutableInteractionSource, + interactionSource: MutableInteractionSource?, onSliderValueChange: (ratio: Float) -> Unit, onSliderValueChangeFinished: () -> Unit, onSeekBack: () -> Unit, @@ -231,15 +231,22 @@ private fun PillarboxSliderInternal( Row( modifier = modifier .height(seekBarHeight) - .clickToSlide( - interactionSource = interactionSource, - onSliderValueChange = onSliderValueChange, - onSliderValueChangeFinished = onSliderValueChangeFinished, - ) - .dragThumb( - interactionSource = interactionSource, - onSliderValueChange = onSliderValueChange, - onSliderValueChangeFinished = onSliderValueChangeFinished, + .then( + if (interactionSource != null) { + Modifier + .clickToSlide( + interactionSource = interactionSource, + onSliderValueChange = onSliderValueChange, + onSliderValueChangeFinished = onSliderValueChangeFinished, + ) + .dragThumb( + interactionSource = interactionSource, + onSliderValueChange = onSliderValueChange, + onSliderValueChangeFinished = onSliderValueChangeFinished, + ) + } else { + Modifier + } ), horizontalArrangement = Arrangement.spacedBy(6.dp), ) { @@ -291,12 +298,12 @@ private fun Modifier.clickToSlide( } } - return this then pointerInput(Unit) { + return this then Modifier.pointerInput(Unit) { detectTapGestures( onPress = { offset -> initPressInteraction(offset) - val nextInteraction = if (tryAwaitRelease()) { + val nextInteraction: (PressInteraction.Press) -> PressInteraction = if (tryAwaitRelease()) { PressInteraction::Release } else { PressInteraction::Cancel diff --git a/pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/ui/integrationLayer/data/Content.kt b/pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/ui/integrationLayer/data/Content.kt index cbf16f8a3..cb9c93e84 100644 --- a/pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/ui/integrationLayer/data/Content.kt +++ b/pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/ui/integrationLayer/data/Content.kt @@ -34,7 +34,7 @@ sealed interface Content { val duration = media.duration.toDuration(DurationUnit.MILLISECONDS).inWholeMinutes.coerceAtLeast(1) /** - * @property imageTitle The image image of the media. + * @property imageTitle The image title of the media. */ val imageTitle = media.imageTitle @@ -71,7 +71,7 @@ sealed interface Content { */ data class Show(private val show: ch.srg.dataProvider.integrationlayer.data.remote.Show) : Content { /** - * @property imageTitle The image image of the show. + * @property imageTitle The image title of the show. */ val imageTitle = show.imageTitle @@ -98,7 +98,7 @@ sealed interface Content { */ data class Topic(private val topic: ch.srg.dataProvider.integrationlayer.data.remote.Topic) : Content { /** - * @property imageTitle The image image of the topic. + * @property imageTitle The image title of the topic. */ val imageTitle = topic.imageTitle @@ -135,7 +135,7 @@ sealed interface Content { val id = channel.id /** - * @property imageTitle The image image of the channel. + * @property imageTitle The image title of the channel. */ val imageTitle = channel.imageTitle diff --git a/pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/ui/integrationLayer/data/ILRepository.kt b/pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/ui/integrationLayer/data/ILRepository.kt index 22e9d8afe..8b8a1ea28 100644 --- a/pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/ui/integrationLayer/data/ILRepository.kt +++ b/pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/ui/integrationLayer/data/ILRepository.kt @@ -80,7 +80,7 @@ class ILRepository( } /** - * Get tv topics + * Get TV topics * * @param bu */ @@ -94,7 +94,7 @@ class ILRepository( } /** - * Get latest media by show urn + * Get the latest media by show urn * * @param urn */ @@ -103,7 +103,7 @@ class ILRepository( } /** - * Get latest media by show urn + * Get the latest media by show urn * * @param urn * @param pageSize @@ -114,7 +114,7 @@ class ILRepository( } /** - * Get latest media by topic urn + * Get the latest media by topic urn * * @param urn */ @@ -123,7 +123,7 @@ class ILRepository( } /** - * Get tv live stream + * Get TV live stream * * @param bu */ @@ -151,7 +151,7 @@ class ILRepository( } /** - * Get tv live web + * Get TV live web * * @param bu */ @@ -160,7 +160,7 @@ class ILRepository( } /** - * Get tv live center + * Get TV live center * * @param bu */ @@ -169,7 +169,7 @@ class ILRepository( } /** - * Get tv live center + * Get TV live center * * @param bu * @param pageSize diff --git a/pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/ui/player/settings/PlayerSettingsViewModel.kt b/pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/ui/player/settings/PlayerSettingsViewModel.kt index b4ac8681f..3bb51d443 100644 --- a/pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/ui/player/settings/PlayerSettingsViewModel.kt +++ b/pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/ui/player/settings/PlayerSettingsViewModel.kt @@ -45,7 +45,7 @@ import kotlinx.coroutines.flow.stateIn /** * Player settings view model * - * @constructor Create empty Player settings view model + * @constructor Create an empty Player settings view model */ class PlayerSettingsViewModel( private val player: Player, @@ -274,7 +274,7 @@ class PlayerSettingsViewModel( * * @param player * @param application - * @constructor Create empty Factory + * @constructor Create an empty Factory */ @Suppress("UndocumentedPublicClass") class Factory( diff --git a/pillarbox-demo-tv/src/main/java/ch/srgssr/pillarbox/demo/tv/ui/components/TVDemoTopBar.kt b/pillarbox-demo-tv/src/main/java/ch/srgssr/pillarbox/demo/tv/ui/components/TVDemoTopBar.kt index e664b1e13..b38dd5f7f 100644 --- a/pillarbox-demo-tv/src/main/java/ch/srgssr/pillarbox/demo/tv/ui/components/TVDemoTopBar.kt +++ b/pillarbox-demo-tv/src/main/java/ch/srgssr/pillarbox/demo/tv/ui/components/TVDemoTopBar.kt @@ -36,7 +36,7 @@ import ch.srgssr.pillarbox.demo.tv.ui.theme.paddings * Top bar displayed in the demo app on TV. * * @param destinations The list of destinations to display. - * @param currentNavDestination The currently destination selected. + * @param currentNavDestination The currently selected destination. * @param modifier The [Modifier] to apply to the top bar. * @param onDestinationClick The action to perform the selected a destination. */ diff --git a/pillarbox-demo-tv/src/main/java/ch/srgssr/pillarbox/demo/tv/ui/search/SearchHome.kt b/pillarbox-demo-tv/src/main/java/ch/srgssr/pillarbox/demo/tv/ui/search/SearchHome.kt index be939d0fd..1337ec5fc 100644 --- a/pillarbox-demo-tv/src/main/java/ch/srgssr/pillarbox/demo/tv/ui/search/SearchHome.kt +++ b/pillarbox-demo-tv/src/main/java/ch/srgssr/pillarbox/demo/tv/ui/search/SearchHome.kt @@ -15,10 +15,13 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.text.BasicTextField import androidx.compose.foundation.text.KeyboardOptions +import androidx.compose.foundation.text.input.TextFieldLineLimits +import androidx.compose.foundation.text.input.rememberTextFieldState import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Block import androidx.compose.material.icons.filled.Search import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment @@ -158,9 +161,14 @@ private fun SearchInput( modifier: Modifier = Modifier, onQueryChange: (query: String) -> Unit ) { + val textFieldState = rememberTextFieldState(query) + + LaunchedEffect(textFieldState.text) { + onQueryChange(textFieldState.text.toString()) + } + BasicTextField( - value = query, - onValueChange = onQueryChange, + state = textFieldState, modifier = modifier.background( color = MaterialTheme.colorScheme.surfaceVariant, shape = MaterialTheme.shapes.small @@ -168,14 +176,14 @@ private fun SearchInput( textStyle = MaterialTheme.typography.titleSmall .copy(color = MaterialTheme.colorScheme.onSurface), keyboardOptions = KeyboardOptions( - autoCorrect = false, + autoCorrectEnabled = false, imeAction = ImeAction.Search ), - singleLine = true, + lineLimits = TextFieldLineLimits.SingleLine, cursorBrush = Brush.verticalGradient( colors = listOf(LocalContentColor.current, LocalContentColor.current) ), - decorationBox = { innerTextField -> + decorator = { innerTextField -> Box(modifier = Modifier.padding(MaterialTheme.paddings.baseline)) { innerTextField() diff --git a/pillarbox-demo/build.gradle.kts b/pillarbox-demo/build.gradle.kts index 81c20798e..ef5c49dfb 100644 --- a/pillarbox-demo/build.gradle.kts +++ b/pillarbox-demo/build.gradle.kts @@ -48,7 +48,6 @@ dependencies { implementation(project(":pillarbox-player")) implementation(project(":pillarbox-ui")) - implementation(libs.accompanist.navigation.material) implementation(libs.androidx.activity) implementation(libs.androidx.activity.compose) implementation(libs.androidx.annotation) @@ -59,6 +58,7 @@ dependencies { implementation(libs.androidx.compose.foundation.layout) implementation(libs.androidx.compose.material.icons.core) implementation(libs.androidx.compose.material.icons.extended) + implementation(libs.androidx.compose.material.navigation) implementation(libs.androidx.compose.material3) implementation(libs.androidx.compose.runtime) implementation(libs.androidx.compose.ui) diff --git a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/service/DemoMediaLibraryService.kt b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/service/DemoMediaLibraryService.kt index 54936f256..90ed39875 100644 --- a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/service/DemoMediaLibraryService.kt +++ b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/service/DemoMediaLibraryService.kt @@ -26,7 +26,7 @@ import okhttp3.internal.toImmutableList /** * The only way to handle an Android Auto application. * - * Hints for testing : https://developer.android.com/training/cars/testing + * Hints for testing: https://developer.android.com/training/cars/testing */ class DemoMediaLibraryService : PillarboxMediaLibraryService() { diff --git a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/service/DemoMediaSessionService.kt b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/service/DemoMediaSessionService.kt index 853025b71..efeff0d0d 100644 --- a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/service/DemoMediaSessionService.kt +++ b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/service/DemoMediaSessionService.kt @@ -18,7 +18,7 @@ import ch.srgssr.pillarbox.player.utils.PendingIntentUtils * Demo media session service to handle background playback has Media3 would us to use. * Can be still useful when using with MediaLibrary for android auto. * - * Limitations : + * Limitations: * - No custom data access from MediaController so no MediaComposition or other custom attributes integrator wants. * * @constructor Create empty Demo media session service diff --git a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/service/DemoPlaybackService.kt b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/service/DemoPlaybackService.kt index fcbc360b9..6e492d537 100644 --- a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/service/DemoPlaybackService.kt +++ b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/service/DemoPlaybackService.kt @@ -13,7 +13,7 @@ import ch.srgssr.pillarbox.player.utils.PendingIntentUtils /** * Demo playback service * - * It doesn't stop playback after 1min while in background and maintain a MediaNotification. + * It doesn't stop playback after 1min while in the background and maintains a MediaNotification. * * @constructor Create empty Demo playback service */ diff --git a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/DemoPlayerView.kt b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/DemoPlayerView.kt index aadbdcbee..b97f3fdfe 100644 --- a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/DemoPlayerView.kt +++ b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/DemoPlayerView.kt @@ -2,6 +2,8 @@ * Copyright (c) SRG SSR. All rights reserved. * License information is available from the LICENSE file. */ +@file:Suppress("UsingMaterialAndMaterial3Libraries") // Using the Material Navigation + package ch.srgssr.pillarbox.demo.ui.player import androidx.compose.foundation.gestures.detectTransformGestures @@ -9,6 +11,9 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding +import androidx.compose.material.navigation.ModalBottomSheetLayout +import androidx.compose.material.navigation.bottomSheet +import androidx.compose.material.navigation.rememberBottomSheetNavigator import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect @@ -28,21 +33,16 @@ import ch.srgssr.pillarbox.demo.ui.player.playlist.PlaylistView import ch.srgssr.pillarbox.demo.ui.player.settings.PlaybackSettingsContent import ch.srgssr.pillarbox.demo.ui.theme.paddings import ch.srgssr.pillarbox.ui.ScaleMode -import com.google.accompanist.navigation.material.ExperimentalMaterialNavigationApi -import com.google.accompanist.navigation.material.ModalBottomSheetLayout -import com.google.accompanist.navigation.material.bottomSheet -import com.google.accompanist.navigation.material.rememberBottomSheetNavigator /** * Demo player * * @param player The [Player] to observe. - * @param modifier The modifier to be applied to the layout. + * @param modifier The [Modifier] to be applied to the layout. * @param pictureInPicture The picture in picture state. - * @param pictureInPictureClick he picture in picture button action. If null no button. - * @param displayPlaylist If it displays playlist ui or not. + * @param pictureInPictureClick The picture in picture button action. If `null` no button. + * @param displayPlaylist If it displays the playlist UI or not. */ -@OptIn(ExperimentalMaterialNavigationApi::class) @Composable fun DemoPlayerView( player: Player, diff --git a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/LiveIndicator.kt b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/LiveIndicator.kt index 0ca94fb67..dbaeb05b6 100644 --- a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/LiveIndicator.kt +++ b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/LiveIndicator.kt @@ -36,7 +36,10 @@ fun LiveIndicator( modifier: Modifier = Modifier, onClick: () -> Unit = {}, ) { - val backgroundColor by animateColorAsState(targetValue = if (isAtLive) Color.Red else Color.Gray) + val backgroundColor by animateColorAsState( + targetValue = if (isAtLive) Color.Red else Color.Gray, + label = "live_background_color", + ) Box( modifier = modifier diff --git a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/SimplePlayerActivity.kt b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/SimplePlayerActivity.kt index b70d4619a..72e378a3a 100644 --- a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/SimplePlayerActivity.kt +++ b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/SimplePlayerActivity.kt @@ -200,7 +200,7 @@ class SimplePlayerActivity : ComponentActivity(), ServiceConnection { private fun bindPlaybackService() { val intent = Intent(this, DemoPlaybackService::class.java) - bindService(intent, this, Context.BIND_AUTO_CREATE) + bindService(intent, this, BIND_AUTO_CREATE) } companion object { diff --git a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/SimplePlayerViewModel.kt b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/SimplePlayerViewModel.kt index 7733be243..bd88b1ee0 100644 --- a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/SimplePlayerViewModel.kt +++ b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/SimplePlayerViewModel.kt @@ -64,7 +64,7 @@ class SimplePlayerViewModel( /* * When handleAudioFocus = true, will pause media when interrupted. - * Playback will resume depending of the "importance" of the interruption (call, playback) + * Playback will resume depending on the "importance" of the interruption (call, playback) */ player.setHandleAudioFocus(true) } diff --git a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/controls/PlayerControls.kt b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/controls/PlayerControls.kt index 3ea6eb0b3..38e5b82f7 100644 --- a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/controls/PlayerControls.kt +++ b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/controls/PlayerControls.kt @@ -53,7 +53,7 @@ fun PlayerControls( player: Player, modifier: Modifier = Modifier, backgroundColor: Color = Color.Black.copy(0.5f), - interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, + interactionSource: MutableInteractionSource? = null, progressTracker: ProgressTrackerState = rememberProgressTrackerState(player = player, smoothTracker = true), credit: Credit? = null, content: @Composable ColumnScope.() -> Unit, diff --git a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/controls/PlayerTimeSlider.kt b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/controls/PlayerTimeSlider.kt index f95feb518..fe7cc946e 100644 --- a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/controls/PlayerTimeSlider.kt +++ b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/controls/PlayerTimeSlider.kt @@ -74,7 +74,7 @@ fun PlayerTimeSlider( player: Player, modifier: Modifier = Modifier, progressTracker: ProgressTrackerState = rememberProgressTrackerState(player = player, smoothTracker = true), - interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, + interactionSource: MutableInteractionSource? = null, ) { val rememberedProgressTracker by rememberUpdatedState(progressTracker) val durationMs by player.durationAsState() @@ -87,8 +87,8 @@ fun PlayerTimeSlider( val bufferPercentage by player.currentBufferedPercentageAsState() val availableCommands by player.availableCommandsAsState() val formatter = duration.getFormatter() - val isDragged by interactionSource.collectIsDraggedAsState() - val isPressed by interactionSource.collectIsPressedAsState() + val isDragged = interactionSource != null && interactionSource.collectIsDraggedAsState().value + val isPressed = interactionSource != null && interactionSource.collectIsPressedAsState().value val compactSlider = !isDragged && !isPressed Row( diff --git a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/playlist/MediaItemLibrary.kt b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/playlist/MediaItemLibrary.kt index 731b73a2d..9c762f70f 100644 --- a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/playlist/MediaItemLibrary.kt +++ b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/playlist/MediaItemLibrary.kt @@ -41,7 +41,7 @@ import ch.srgssr.pillarbox.demo.ui.theme.paddings * @param items The items to display. * @param modifier The [Modifier] to apply to the root of the layout. * @param onAddClick The action to perform when the "Add" button is clicked. - * @param onDismissRequest The action to perform when the dialog is dimissed/"Cancel" is clicked. + * @param onDismissRequest The action to perform when the dialog is dismissed/"Cancel" is clicked. */ @Composable @OptIn(ExperimentalMaterial3Api::class) @@ -193,7 +193,7 @@ private fun ItemListPreview() { @Preview @Composable -private fun ButtonsRowPrewiew() { +private fun ButtonsRowPreview() { PillarboxTheme { ButtonsRow( modifier = Modifier.fillMaxWidth(), diff --git a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/settings/PlaybackSpeedSettings.kt b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/settings/PlaybackSpeedSettings.kt index 7da112aac..f0729792f 100644 --- a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/settings/PlaybackSpeedSettings.kt +++ b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/settings/PlaybackSpeedSettings.kt @@ -23,7 +23,7 @@ import ch.srgssr.pillarbox.demo.ui.theme.PillarboxTheme * Playback speed settings * * @param playbackSpeeds The list of possible speeds. - * @param modifier The [Modifier] to layout the view. + * @param modifier The [Modifier] to lay out the view. * @param onSpeedSelected Called when a speed is clicked. * @receiver */ diff --git a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/settings/TrackSelectionSettings.kt b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/settings/TrackSelectionSettings.kt index c6521be8d..a98f857d6 100644 --- a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/settings/TrackSelectionSettings.kt +++ b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/settings/TrackSelectionSettings.kt @@ -44,7 +44,7 @@ import ch.srgssr.pillarbox.player.tracks.VideoTrack * @param tracksSetting List of tracks. * @param modifier The [Modifier] to apply to this screen. * @param onResetClick The action to perform when clicking on the reset button. - * @param onDisabledClick The action to perform when clicking on the disable button. + * @param onDisabledClick The action to perform when clicking on the "Disabled" button. * @param onTrackClick The action to perform when clicking on a track. */ @Composable @@ -154,7 +154,7 @@ fun TrackSelectionSettings( @Preview @Composable private fun TextTrackSelectionPreview() { - // Track are group by language. + // Tracks are group by language. val textTrackFr1 = Format.Builder() .setLabel("FR1") .setId("subtitle:0") diff --git a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/search/SearchHome.kt b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/search/SearchHome.kt index fedc9d6a2..793f468f4 100644 --- a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/search/SearchHome.kt +++ b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/search/SearchHome.kt @@ -12,13 +12,11 @@ import androidx.compose.animation.scaleIn import androidx.compose.animation.scaleOut import androidx.compose.foundation.background import androidx.compose.foundation.clickable -import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.WindowInsets -import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding @@ -40,6 +38,7 @@ import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme import androidx.compose.material3.SearchBar +import androidx.compose.material3.SearchBarDefaults import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect @@ -205,89 +204,95 @@ private fun SearchInput( val focusRequester = remember { FocusRequester() } SearchBar( - query = query, - onQueryChange = onQueryChange, - onSearch = {}, - active = false, - onActiveChange = {}, - modifier = modifier.focusRequester(focusRequester), - placeholder = { Text(text = stringResource(sharedR.string.search_placeholder)) }, - leadingIcon = { - var showBuSelector by remember { mutableStateOf(false) } - - Row( - modifier = Modifier - .padding(end = MaterialTheme.paddings.small) - .clickable( - interactionSource = remember { MutableInteractionSource() }, - indication = null + inputField = { + SearchBarDefaults.InputField( + query = query, + onQueryChange = onQueryChange, + onSearch = {}, + expanded = false, + onExpandedChange = {}, + modifier = Modifier.fillMaxWidth(), + placeholder = { Text(text = stringResource(sharedR.string.search_placeholder)) }, + leadingIcon = { + var showBuSelector by remember { mutableStateOf(false) } + + Row( + modifier = Modifier + .padding(end = MaterialTheme.paddings.small) + .clickable( + interactionSource = null, + indication = null, + ) { + showBuSelector = true + } + .padding( + start = MaterialTheme.paddings.baseline, + end = MaterialTheme.paddings.small + ), + verticalAlignment = Alignment.CenterVertically ) { - showBuSelector = true + val iconRotation by animateFloatAsState( + targetValue = if (showBuSelector) -180f else 0f, + label = "icon_rotation_animation" + ) + + Text(text = selectedBu.name.uppercase()) + + Icon( + imageVector = Icons.Default.ExpandMore, + contentDescription = null, + modifier = Modifier.rotate(iconRotation) + ) } - .fillMaxHeight() - .padding( - start = MaterialTheme.paddings.baseline, - end = MaterialTheme.paddings.small - ), - verticalAlignment = Alignment.CenterVertically - ) { - val iconRotation by animateFloatAsState( - targetValue = if (showBuSelector) -180f else 0f, - label = "icon_rotation_animation" - ) - - Text(text = selectedBu.name.uppercase()) - - Icon( - imageVector = Icons.Default.ExpandMore, - contentDescription = null, - modifier = Modifier.rotate(iconRotation) - ) - } - DropdownMenu( - expanded = showBuSelector, - onDismissRequest = { showBuSelector = false }, - offset = DpOffset( - x = 0.dp, - y = MaterialTheme.paddings.small - ) - ) { - bus.forEach { bu -> - DropdownMenuItem( - text = { Text(text = bu.name.uppercase()) }, - onClick = { - onBuChange(bu) - showBuSelector = false - }, - trailingIcon = if (selectedBu == bu) { - { - Icon( - imageVector = Icons.Default.Check, - contentDescription = null - ) - } - } else { - null + DropdownMenu( + expanded = showBuSelector, + onDismissRequest = { showBuSelector = false }, + offset = DpOffset( + x = 0.dp, + y = MaterialTheme.paddings.small + ) + ) { + bus.forEach { bu -> + DropdownMenuItem( + text = { Text(text = bu.name.uppercase()) }, + onClick = { + onBuChange(bu) + showBuSelector = false + }, + trailingIcon = if (selectedBu == bu) { + { + Icon( + imageVector = Icons.Default.Check, + contentDescription = null + ) + } + } else { + null + } + ) } - ) - } - } - }, - trailingIcon = { - AnimatedVisibility( - visible = query.isNotBlank(), - enter = fadeIn() + scaleIn(), - exit = fadeOut() + scaleOut() - ) { - IconButton(onClick = onClearClick) { - Icon( - imageVector = Icons.Default.Close, - contentDescription = stringResource(R.string.clear) - ) - } - } + } + }, + trailingIcon = { + AnimatedVisibility( + visible = query.isNotBlank(), + enter = fadeIn() + scaleIn(), + exit = fadeOut() + scaleOut() + ) { + IconButton(onClick = onClearClick) { + Icon( + imageVector = Icons.Default.Close, + contentDescription = stringResource(R.string.clear) + ) + } + } + }, + ) }, + expanded = false, + onExpandedChange = {}, + modifier = modifier.focusRequester(focusRequester), shape = MaterialTheme.shapes.large, windowInsets = WindowInsets(0.dp), ) {} diff --git a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/layouts/ChapterShowcase.kt b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/layouts/ChapterShowcase.kt index c81dd1714..5d0e9b69a 100644 --- a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/layouts/ChapterShowcase.kt +++ b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/layouts/ChapterShowcase.kt @@ -129,9 +129,9 @@ private fun ChapterItem( onClick: () -> Unit, modifier: Modifier = Modifier, ) { - val zIndex by animateFloatAsState(targetValue = if (active) 1f else 0f) - val scale by animateFloatAsState(targetValue = if (active) 1.05f else 0.95f) - val imageAlpha by animateFloatAsState(targetValue = if (active) 0.2f else 0.5f) + val zIndex by animateFloatAsState(targetValue = if (active) 1f else 0f, label = "zIndex") + val scale by animateFloatAsState(targetValue = if (active) 1.05f else 0.95f, label = "scale") + val imageAlpha by animateFloatAsState(targetValue = if (active) 0.2f else 0.5f, label = "image_alpha") Box( modifier = modifier .zIndex(zIndex) diff --git a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/layouts/OptimizedStory.kt b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/layouts/OptimizedStory.kt index bf14534a6..c8fbecbfb 100644 --- a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/layouts/OptimizedStory.kt +++ b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/layouts/OptimizedStory.kt @@ -6,7 +6,6 @@ package ch.srgssr.pillarbox.demo.ui.showcases.layouts import androidx.compose.animation.core.Spring import androidx.compose.animation.core.spring -import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Row @@ -34,11 +33,10 @@ import ch.srgssr.pillarbox.ui.ScaleMode import ch.srgssr.pillarbox.ui.widget.player.PlayerSurface /** - * Optimized story trying to reproduce story like TikTok or Instagram. + * Optimized story trying to reproduce story-like TikTok or Instagram. * * Surface view may sometimes keep on screen. Maybe if we use TextView with PlayerView this strange behavior will disappear. */ -@OptIn(ExperimentalFoundationApi::class) @Composable fun OptimizedStory(storyViewModel: StoryViewModel = viewModel()) { val pagerState = rememberPagerState { @@ -55,7 +53,7 @@ fun OptimizedStory(storyViewModel: StoryViewModel = viewModel()) { val playlist = storyViewModel.playlist.items Box(modifier = Modifier.fillMaxSize()) { HorizontalPager( - beyondBoundsPageCount = 0, + beyondViewportPageCount = 0, key = { page -> playlist[page].uri }, flingBehavior = PagerDefaults.flingBehavior( state = pagerState, diff --git a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/layouts/SimpleStory.kt b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/layouts/SimpleStory.kt index 29b65cb21..c67e7c370 100644 --- a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/layouts/SimpleStory.kt +++ b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/layouts/SimpleStory.kt @@ -6,7 +6,6 @@ package ch.srgssr.pillarbox.demo.ui.showcases.layouts import androidx.compose.animation.core.Spring import androidx.compose.animation.core.spring -import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.pager.HorizontalPager @@ -29,10 +28,9 @@ import ch.srgssr.pillarbox.ui.ScaleMode import ch.srgssr.pillarbox.ui.widget.player.PlayerSurface /** - * A sample trying to reproduce story like TikTok. - * Each page own its PillarboxPlayer and release it when no more needed. + * A sample trying to reproduce story-like TikTok. + * Each page owns its PillarboxPlayer and releases it when no more needed. */ -@OptIn(ExperimentalFoundationApi::class) @Composable fun SimpleStory() { val playlist = remember { @@ -43,7 +41,7 @@ fun SimpleStory() { HorizontalPager( modifier = Modifier.fillMaxHeight(), key = { page -> playlist.items[page].uri }, - beyondBoundsPageCount = 1, + beyondViewportPageCount = 1, flingBehavior = PagerDefaults.flingBehavior( state = pagerState, pagerSnapDistance = PagerSnapDistance.atMost(0), diff --git a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/layouts/StoryLayoutShowcase.kt b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/layouts/StoryLayoutShowcase.kt index 226875d22..27052072b 100644 --- a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/layouts/StoryLayoutShowcase.kt +++ b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/layouts/StoryLayoutShowcase.kt @@ -9,9 +9,9 @@ import androidx.compose.runtime.Composable /** * Story home * - * Two version available - * - Simple which create and release for each pages. - * - Optimized with 3 players, 1 for the 3 visible pages. + * Two versions are available: + * - "Simple" which creates and releases for each page. + * - "Optimized" with 3 players, 1 for each visible page. * * @param optimizedStory `true` to use an optimized implementation, `false` otherwise. */ diff --git a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/misc/MultiPlayerShowcase.kt b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/misc/MultiPlayerShowcase.kt index e2bc1e405..f4d9d4116 100644 --- a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/misc/MultiPlayerShowcase.kt +++ b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/misc/MultiPlayerShowcase.kt @@ -6,7 +6,6 @@ package ch.srgssr.pillarbox.demo.ui.showcases.misc import android.content.res.Configuration import androidx.compose.foundation.clickable -import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxSize @@ -88,7 +87,7 @@ private fun ActivablePlayer( modifier = modifier .padding(MaterialTheme.paddings.mini) .clickable( - interactionSource = remember { MutableInteractionSource() }, + interactionSource = null, indication = null, enabled = !isActive, onClick = onClick, diff --git a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/misc/ResizablePlayerShowcase.kt b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/misc/ResizablePlayerShowcase.kt index 06ebcf3eb..05a2d87c6 100644 --- a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/misc/ResizablePlayerShowcase.kt +++ b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/misc/ResizablePlayerShowcase.kt @@ -16,7 +16,6 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.systemGestureExclusion -import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.MaterialTheme import androidx.compose.material3.SegmentedButton import androidx.compose.material3.SegmentedButtonDefaults @@ -73,7 +72,6 @@ fun ResizablePlayerShowcase() { } @Composable -@OptIn(ExperimentalMaterial3Api::class) private fun AdaptivePlayer(player: Player, modifier: Modifier = Modifier) { var resizeMode by remember { mutableStateOf(ScaleMode.Fit) } val (widthPercent, setWidthPercent) = remember { mutableFloatStateOf(1f) } diff --git a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/misc/SmoothSeekingShowcase.kt b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/misc/SmoothSeekingShowcase.kt index 3be736b47..40fc56f68 100644 --- a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/misc/SmoothSeekingShowcase.kt +++ b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/misc/SmoothSeekingShowcase.kt @@ -40,7 +40,7 @@ import ch.srgssr.pillarbox.ui.extension.playbackStateAsState import ch.srgssr.pillarbox.ui.widget.player.PlayerSurface /** - * Smooth seeking show case + * Smooth seeking showcase */ @Composable fun SmoothSeekingShowcase() { diff --git a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/misc/UpdatableMediaItemViewModel.kt b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/misc/UpdatableMediaItemViewModel.kt index 1ed9f1a23..88dcbc72f 100644 --- a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/misc/UpdatableMediaItemViewModel.kt +++ b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/misc/UpdatableMediaItemViewModel.kt @@ -24,7 +24,7 @@ import kotlin.time.Duration.Companion.seconds /** * Updatable media item view model * - * This demo demonstrate how to update an existing [MediaItem.mediaMetadata]. + * This demo demonstrates how to update an existing [MediaItem.mediaMetadata]. * * @constructor * diff --git a/pillarbox-player/src/main/java/ch/srgssr/pillarbox/player/PlayerCallbackFlow.kt b/pillarbox-player/src/main/java/ch/srgssr/pillarbox/player/PlayerCallbackFlow.kt index bf46d3085..c6edc61ad 100644 --- a/pillarbox-player/src/main/java/ch/srgssr/pillarbox/player/PlayerCallbackFlow.kt +++ b/pillarbox-player/src/main/java/ch/srgssr/pillarbox/player/PlayerCallbackFlow.kt @@ -171,7 +171,7 @@ fun Player.tickerWhilePlayingAsFlow( } /** - * Current position of the player update every [updateInterval] when it is playing. + * Current position of the player updates every [updateInterval] when it is playing. * Send current position once if not playing. */ fun Player.currentPositionAsFlow(updateInterval: Duration = DefaultUpdateInterval): Flow = diff --git a/pillarbox-player/src/test/java/ch/srgssr/pillarbox/player/TestPlayerCallbackFlow.kt b/pillarbox-player/src/test/java/ch/srgssr/pillarbox/player/TestPlayerCallbackFlow.kt index 4a8fbe3b2..63f5bdb74 100644 --- a/pillarbox-player/src/test/java/ch/srgssr/pillarbox/player/TestPlayerCallbackFlow.kt +++ b/pillarbox-player/src/test/java/ch/srgssr/pillarbox/player/TestPlayerCallbackFlow.kt @@ -67,7 +67,7 @@ class TestPlayerCallbackFlow { } /** - * Test current position while not playing + * Test current position while not playing. * We expected a Timeout as the flow doesn't start */ @Test diff --git a/pillarbox-ui/src/main/java/ch/srgssr/pillarbox/ui/exoplayer/ExoplayerSubtitleView.kt b/pillarbox-ui/src/main/java/ch/srgssr/pillarbox/ui/exoplayer/ExoplayerSubtitleView.kt index 41ccb9a67..734c35199 100644 --- a/pillarbox-ui/src/main/java/ch/srgssr/pillarbox/ui/exoplayer/ExoplayerSubtitleView.kt +++ b/pillarbox-ui/src/main/java/ch/srgssr/pillarbox/ui/exoplayer/ExoplayerSubtitleView.kt @@ -29,8 +29,8 @@ import com.google.common.collect.ImmutableList * * @param player The Player to get Cues * @param modifier The modifier to be applied to the layout. - * @param captionStyle Caption style of the subtitle texts. It will override any user preferred style. - * @param subtitleTextSize Text size of the subtitle texts. It will override any user preferred size. + * @param captionStyle Caption style of the subtitle texts. It will override any user-preferred style. + * @param subtitleTextSize Text size of the subtitle texts. It will override any user-preferred size. */ @Composable fun ExoPlayerSubtitleView( @@ -47,8 +47,8 @@ fun ExoPlayerSubtitleView( * Composable basic version of [ExoPlayerSubtitleView] from Media3 (Exoplayer) * @param modifier The modifier to be applied to the layout. * @param cues The cues to displays [Player.getCurrentCues] - * @param captionStyle Caption style of the subtitle texts. It will override any user preferred style. - * @param subtitleTextSize Text size of the subtitle texts. It will override any user preferred size. + * @param captionStyle Caption style of the subtitle texts. It will override any user-preferred style. + * @param subtitleTextSize Text size of the subtitle texts. It will override any user-preferred size. */ @Composable fun ExoPlayerSubtitleView( diff --git a/pillarbox-ui/src/main/java/ch/srgssr/pillarbox/ui/widget/DelayedVisibilityState.kt b/pillarbox-ui/src/main/java/ch/srgssr/pillarbox/ui/widget/DelayedVisibilityState.kt index 29b4f7c36..e1c7bd937 100644 --- a/pillarbox-ui/src/main/java/ch/srgssr/pillarbox/ui/widget/DelayedVisibilityState.kt +++ b/pillarbox-ui/src/main/java/ch/srgssr/pillarbox/ui/widget/DelayedVisibilityState.kt @@ -121,7 +121,7 @@ class DelayedVisibilityState internal constructor( /** * Toggleable * - * @param enabled whether or not this toggleable will handle input events and appear enabled for semantics purposes + * @param enabled whether this toggleable will handle input events and appear enabled for semantics purposes * @param role the type of user interface element. Accessibility services might use this to describe the element or do customizations * @param delayedVisibilityState the delayed visibility state to link */ @@ -133,9 +133,7 @@ fun Modifier.toggleable( toggleable( enabled = enabled, role = role, - interactionSource = remember { - MutableInteractionSource() - }, + interactionSource = null, delayedVisibilityState = delayedVisibilityState ) } @@ -143,9 +141,9 @@ fun Modifier.toggleable( /** * Toggleable * - * @param enabled whether or not this toggleable will handle input events and appear enabled for semantics purposes + * @param enabled whether this toggleable will handle input events and appear enabled for semantics purposes * @param role the type of user interface element. Accessibility services might use this to describe the element or do customizations - * @param indication indication to be shown when modified element is pressed. Be default, indication from LocalIndication will be used. + * @param indication indication to be shown when the modified element is pressed. By default, indication from LocalIndication will be used. * Pass null to show no indication, or current value from LocalIndication to show theme default * @param interactionSource MutableInteractionSource that will be used to emit PressInteraction.Press when this toggleable is being pressed. * @param delayedVisibilityState the delayed visibility state to link @@ -154,7 +152,7 @@ fun Modifier.toggleable( enabled: Boolean = true, role: Role? = Role.Switch, indication: Indication? = null, - interactionSource: MutableInteractionSource, + interactionSource: MutableInteractionSource?, delayedVisibilityState: DelayedVisibilityState ): Modifier = this.then( Modifier diff --git a/pillarbox-ui/src/main/java/ch/srgssr/pillarbox/ui/widget/player/PlayerSurface.kt b/pillarbox-ui/src/main/java/ch/srgssr/pillarbox/ui/widget/player/PlayerSurface.kt index a9426f3e1..3c2b73222 100644 --- a/pillarbox-ui/src/main/java/ch/srgssr/pillarbox/ui/widget/player/PlayerSurface.kt +++ b/pillarbox-ui/src/main/java/ch/srgssr/pillarbox/ui/widget/player/PlayerSurface.kt @@ -48,7 +48,7 @@ import ch.srgssr.pillarbox.ui.extension.getAspectRatioAsState * @param contentAlignment The "letterboxing" content alignment inside the parent. Only used when the aspect ratio is strictly positive. * @param defaultAspectRatio The aspect ratio to use while video is loading or for audio content. * @param displayDebugView When `true`, displays debug information on top of the surface. Only used when the aspect ratio is strictly positive. - * @param surfaceContent The Composable content to display on top of the [SurfaceView]. By default render the subtitles. Only used when the aspect + * @param surfaceContent The Composable content to display on top of the [SurfaceView]. By default, render the subtitles. Only used when the aspect * ratio is strictly positive. */ @Composable @@ -165,7 +165,7 @@ private fun DebugPlayerView(modifier: Modifier) { private fun AndroidPlayerSurfaceView(player: Player, modifier: Modifier = Modifier) { AndroidView( /* - * On some devices (Pixel 2 XL Android 11) + * On some devices (Pixel 2 XL Android 11), * the "black" background of the SurfaceView shows outside its bound. */ modifier = modifier.clipToBounds(), @@ -176,7 +176,7 @@ private fun AndroidPlayerSurfaceView(player: Player, modifier: Modifier = Modifi }, onRelease = { view -> view.player = null }, onReset = { view -> - // onReset is called before `update`, when the composable is reused with a different context. + // onReset is called before `update` when the composable is reused with a different context. view.player = null } ) diff --git a/pillarbox-ui/src/main/java/ch/srgssr/pillarbox/ui/widget/player/SphericalSurface.kt b/pillarbox-ui/src/main/java/ch/srgssr/pillarbox/ui/widget/player/SphericalSurface.kt index 583c5fc80..90d72e1e7 100644 --- a/pillarbox-ui/src/main/java/ch/srgssr/pillarbox/ui/widget/player/SphericalSurface.kt +++ b/pillarbox-ui/src/main/java/ch/srgssr/pillarbox/ui/widget/player/SphericalSurface.kt @@ -29,7 +29,7 @@ fun SphericalSurface(player: Player, modifier: Modifier = Modifier) { player.setVideoSurfaceView(null) view.onPause() }, onReset = { - // onReset is called before `update`, when the composable is reused with a different context. + // onReset is called before `update` when the composable is reused with a different context. player.setVideoSurface(null) } )