diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/VideoView.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/VideoView.kt index 7fb068148..1cb447507 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/VideoView.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/VideoView.kt @@ -101,9 +101,9 @@ fun LoadThumbAndThenVideoView( if (loadingFinished.first) { if (loadingFinished.second != null) { - VideoView(videoUri, description, VideoThumb(loadingFinished.second), accountViewModel, onDialog) + VideoView(videoUri, description, VideoThumb(loadingFinished.second), accountViewModel, onDialog = onDialog) } else { - VideoView(videoUri, description, null, accountViewModel, onDialog) + VideoView(videoUri, description, null, accountViewModel, onDialog = onDialog) } } } @@ -115,10 +115,11 @@ fun VideoView( description: String? = null, thumb: VideoThumb? = null, accountViewModel: AccountViewModel, + alwaysShowVideo: Boolean = false, onDialog: ((Boolean) -> Unit)? = null ) { val (value, elapsed) = measureTimedValue { - VideoView1(videoUri, description, thumb, onDialog, accountViewModel) + VideoView1(videoUri, description, thumb, onDialog, accountViewModel, alwaysShowVideo) } Log.d("Rendering Metrics", "VideoView $elapsed $videoUri") } @@ -129,7 +130,8 @@ fun VideoView1( description: String? = null, thumb: VideoThumb? = null, onDialog: ((Boolean) -> Unit)? = null, - accountViewModel: AccountViewModel + accountViewModel: AccountViewModel, + alwaysShowVideo: Boolean = false ) { var exoPlayerData by remember { mutableStateOf(null) } val defaultToStart by remember { mutableStateOf(DefaultMutedSetting.value) } @@ -144,7 +146,7 @@ fun VideoView1( } exoPlayerData?.let { - VideoView(videoUri, description, it, defaultToStart, thumb, onDialog, accountViewModel) + VideoView(videoUri, description, it, defaultToStart, thumb, onDialog, accountViewModel, alwaysShowVideo) } DisposableEffect(Unit) { @@ -163,10 +165,11 @@ fun VideoView( defaultToStart: Boolean = false, thumb: VideoThumb? = null, onDialog: ((Boolean) -> Unit)? = null, - accountViewModel: AccountViewModel + accountViewModel: AccountViewModel, + alwaysShowVideo: Boolean = false ) { val (_, elapsed) = measureTimedValue { - VideoView1(videoUri, description, exoPlayerData, defaultToStart, thumb, onDialog, accountViewModel) + VideoView1(videoUri, description, exoPlayerData, defaultToStart, thumb, onDialog, accountViewModel, alwaysShowVideo) } Log.d("Rendering Metrics", "VideoView $elapsed $videoUri") } @@ -179,7 +182,8 @@ fun VideoView1( defaultToStart: Boolean = false, thumb: VideoThumb? = null, onDialog: ((Boolean) -> Unit)? = null, - accountViewModel: AccountViewModel + accountViewModel: AccountViewModel, + alwaysShowVideo: Boolean = false ) { val lifecycleOwner = rememberUpdatedState(LocalLifecycleOwner.current) @@ -190,10 +194,12 @@ fun VideoView1( val automaticallyStartPlayback = remember { mutableStateOf( - when (settings.automaticallyStartPlayback) { - true -> !isMobile - false -> false - else -> true + if (alwaysShowVideo) { true } else { + when (settings.automaticallyStartPlayback) { + true -> !isMobile + false -> false + else -> true + } } ) } @@ -222,7 +228,11 @@ fun VideoView1( prepare() } - RenderVideoPlayer(exoPlayerData, thumb, automaticallyStartPlayback, onDialog) + if (!automaticallyStartPlayback.value) { + ImageUrlWithDownloadButton(url = videoUri, showImage = automaticallyStartPlayback) + } else { + RenderVideoPlayer(exoPlayerData, thumb, automaticallyStartPlayback, onDialog) + } DisposableEffect(Unit) { val observer = LifecycleEventObserver { _, event -> diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentView.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentView.kt index 21affa985..61a612608 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentView.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentView.kt @@ -201,11 +201,20 @@ fun ZoomableContentView( when (content) { is ZoomableUrlImage -> UrlImageView(content, mainImageModifier, accountViewModel) - is ZoomableUrlVideo -> VideoView(content.url, content.description, accountViewModel = accountViewModel) { dialogOpen = true } + is ZoomableUrlVideo -> VideoView( + content.url, + content.description, + accountViewModel = accountViewModel + ) { dialogOpen = true } + is ZoomableLocalImage -> LocalImageView(content, mainImageModifier, accountViewModel) is ZoomableLocalVideo -> content.localFile?.let { - VideoView(it.toUri().toString(), content.description, accountViewModel = accountViewModel) { dialogOpen = true } + VideoView( + it.toUri().toString(), + content.description, + accountViewModel = accountViewModel + ) { dialogOpen = true } } } @@ -218,7 +227,8 @@ fun ZoomableContentView( private fun LocalImageView( content: ZoomableLocalImage, mainImageModifier: Modifier, - accountViewModel: AccountViewModel? + accountViewModel: AccountViewModel?, + alwayShowImage: Boolean = false ) { if (content.localFile != null && content.localFile.exists()) { BoxWithConstraints(contentAlignment = Alignment.Center) { @@ -227,10 +237,12 @@ private fun LocalImageView( val showImage = remember { mutableStateOf( - when (settings?.automaticallyShowImages) { - true -> !isMobile - false -> false - else -> true + if (alwayShowImage) { true } else { + when (settings?.automaticallyShowImages) { + true -> !isMobile + false -> false + else -> true + } } ) } @@ -268,7 +280,14 @@ private fun LocalImageView( ) } - AddedImageFeatures(painterState, content, contentScale, myModifier, verifierModifier, showImage) + AddedImageFeatures( + painterState, + content, + contentScale, + myModifier, + verifierModifier, + showImage + ) } } else { BlankNote() @@ -279,7 +298,8 @@ private fun LocalImageView( private fun UrlImageView( content: ZoomableUrlImage, mainImageModifier: Modifier, - accountViewModel: AccountViewModel? + accountViewModel: AccountViewModel?, + alwayShowImage: Boolean = false ) { BoxWithConstraints(contentAlignment = Alignment.Center) { val settings = accountViewModel?.account?.settings @@ -287,10 +307,12 @@ private fun UrlImageView( val showImage = remember { mutableStateOf( - when (settings?.automaticallyShowImages) { - true -> !isMobile - false -> false - else -> true + if (alwayShowImage) { true } else { + when (settings?.automaticallyShowImages) { + true -> !isMobile + false -> false + else -> true + } } ) } @@ -328,7 +350,14 @@ private fun UrlImageView( ) } - AddedImageFeatures(painterState, content, contentScale, myModifier, verifierModifier, showImage) + AddedImageFeatures( + painterState, + content, + contentScale, + myModifier, + verifierModifier, + showImage + ) } } @@ -540,7 +569,12 @@ private fun DisplayBlurHash( @OptIn(ExperimentalFoundationApi::class) @Composable -fun ZoomableImageDialog(imageUrl: ZoomableContent, allImages: ImmutableList = listOf(imageUrl).toImmutableList(), onDismiss: () -> Unit, accountViewModel: AccountViewModel) { +fun ZoomableImageDialog( + imageUrl: ZoomableContent, + allImages: ImmutableList = listOf(imageUrl).toImmutableList(), + onDismiss: () -> Unit, + accountViewModel: AccountViewModel +) { val view = LocalView.current DisposableEffect(key1 = Unit) { @@ -602,7 +636,10 @@ fun ZoomableImageDialog(imageUrl: ZoomableContent, allImages: ImmutableList