From aa017fc8eba483f70ba8f6f31fdad09c6e615c90 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Fri, 9 Aug 2024 13:04:43 +0200 Subject: [PATCH] increese size of volume indicator --- .../newplayer/model/VideoPlayerViewModelImpl.kt | 4 ++-- .../newpipe/newplayer/ui/videoplayer/GestureUI.kt | 5 +++++ .../gesture_ui/FastSeekVisualFeedback.kt | 3 ++- .../videoplayer/gesture_ui/FullscreenGestureUI.kt | 2 +- .../ui/videoplayer/gesture_ui/VolumeCircle.kt | 13 +++++++------ 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/new-player/src/main/java/net/newpipe/newplayer/model/VideoPlayerViewModelImpl.kt b/new-player/src/main/java/net/newpipe/newplayer/model/VideoPlayerViewModelImpl.kt index 2e943f0..53c3904 100644 --- a/new-player/src/main/java/net/newpipe/newplayer/model/VideoPlayerViewModelImpl.kt +++ b/new-player/src/main/java/net/newpipe/newplayer/model/VideoPlayerViewModelImpl.kt @@ -309,7 +309,7 @@ class VideoPlayerViewModelImpl @Inject constructor( "currentBrightnes: $currentBrightness, sytemBrightness: $systemBrightness, changeRate: $changeRate" ) - val newBrightness = (currentBrightness + changeRate).coerceIn(0f, 1f) + val newBrightness = (currentBrightness + changeRate * 1.3f).coerceIn(0f, 1f) mutableUiState.update { it.copy(brightness = newBrightness) } @@ -321,7 +321,7 @@ class VideoPlayerViewModelImpl @Inject constructor( val maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC).toFloat() // we multiply changeRate by 1.5 so your finger only has to swipe a portion of the whole // screen in order to fully enable or disable the volume - val newVolume = (currentVolume + changeRate * 1.5f).coerceIn(0f, 1f) + val newVolume = (currentVolume + changeRate * 1.3f).coerceIn(0f, 1f) audioManager.setStreamVolume( AudioManager.STREAM_MUSIC, (newVolume * maxVolume).toInt(), 0 ) diff --git a/new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer/GestureUI.kt b/new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer/GestureUI.kt index a619db4..eab7cac 100644 --- a/new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer/GestureUI.kt +++ b/new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer/GestureUI.kt @@ -22,6 +22,7 @@ package net.newpipe.newplayer.ui.videoplayer import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color import net.newpipe.newplayer.ui.videoplayer.gesture_ui.EmbeddedGestureUI import net.newpipe.newplayer.ui.videoplayer.gesture_ui.FullscreenGestureUI @@ -34,6 +35,8 @@ const val FAST_SEEK_MODE_DURATION = 500L const val SEEK_ANIMATION_FADE_IN = 200 const val SEEK_ANIMATION_FADE_OUT = 500 +val INDICATOR_BACKGROUND_COLOR = Color.Black.copy(alpha = 0.3f) + @Composable fun GestureUI( modifier: Modifier, @@ -62,6 +65,7 @@ fun GestureUI( if (fullscreen) { FullscreenGestureUI( + modifier = modifier, uiVissible = uiVissible, fastSeekSeconds = fastSeekSeconds, hideUi = hideUi, @@ -75,6 +79,7 @@ fun GestureUI( brightnesChange = brightnessChange) } else { EmbeddedGestureUI( + modifier = modifier, fastSeekSeconds = fastSeekSeconds, uiVissible = uiVissible, switchToFullscreen = switchToFullscreen, diff --git a/new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer/gesture_ui/FastSeekVisualFeedback.kt b/new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer/gesture_ui/FastSeekVisualFeedback.kt index a97630d..2968937 100644 --- a/new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer/gesture_ui/FastSeekVisualFeedback.kt +++ b/new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer/gesture_ui/FastSeekVisualFeedback.kt @@ -56,6 +56,7 @@ import androidx.compose.ui.unit.dp import com.google.android.material.color.MaterialColors import net.newpipe.newplayer.R import net.newpipe.newplayer.ui.theme.VideoPlayerTheme +import net.newpipe.newplayer.ui.videoplayer.INDICATOR_BACKGROUND_COLOR import net.newpipe.newplayer.ui.videoplayer.SEEK_ANIMATION_DURATION_IN_MS import net.newpipe.newplayer.ui.videoplayer.SEEK_ANIMATION_FADE_IN import net.newpipe.newplayer.ui.videoplayer.SEEK_ANIMATION_FADE_OUT @@ -123,7 +124,7 @@ fun FastSeekVisualFeedback(modifier: Modifier = Modifier, seconds: Int, backward val secondsString = "Seconds" Surface( - color = Color.Black.copy(alpha = 0.5f), + color = INDICATOR_BACKGROUND_COLOR, modifier = modifier.clip(RoundedCornerShape(50.dp)) ) { Box(modifier = Modifier.padding(10.dp, 5.dp)) { diff --git a/new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer/gesture_ui/FullscreenGestureUI.kt b/new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer/gesture_ui/FullscreenGestureUI.kt index b8e00c4..820a294 100644 --- a/new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer/gesture_ui/FullscreenGestureUI.kt +++ b/new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer/gesture_ui/FullscreenGestureUI.kt @@ -214,7 +214,7 @@ fun FullscreenGestureUIPreview() { } } -@Preview(device = "spec:width=1080px,height=600px,dpi=440,orientation=landscape") +@Preview(device = "spec:parent=pixel_8,orientation=landscape") @Composable fun FullscreenGestureUIPreviewInteractive() { diff --git a/new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer/gesture_ui/VolumeCircle.kt b/new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer/gesture_ui/VolumeCircle.kt index 7ef46c9..1075df3 100644 --- a/new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer/gesture_ui/VolumeCircle.kt +++ b/new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer/gesture_ui/VolumeCircle.kt @@ -47,11 +47,12 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import net.newpipe.newplayer.R import net.newpipe.newplayer.ui.theme.VideoPlayerTheme +import net.newpipe.newplayer.ui.videoplayer.INDICATOR_BACKGROUND_COLOR private const val TAG = "VolumeCircle" -private const val LINE_STROKE_WIDTH = 4 -private const val CIRCLE_SIZE = 100 +private const val LINE_STROKE_WIDTH = 8 +private const val CIRCLE_SIZE = 150 @Composable fun VolumeCircle( @@ -59,14 +60,14 @@ fun VolumeCircle( volumeFraction: Float, isBrightness: Boolean = false ) { - assert(0f <= volumeFraction && volumeFraction <= 1f) { + assert(volumeFraction in 0f..1f) { Log.e(TAG, "Volume fraction must be in ragne [0;1]. It was $volumeFraction") } Box(modifier) { Canvas(Modifier.size(CIRCLE_SIZE.dp)) { val arcSize = (CIRCLE_SIZE - LINE_STROKE_WIDTH).dp.toPx(); - drawCircle(color = Color.Black.copy(alpha = 0.3f), radius = (CIRCLE_SIZE / 2).dp.toPx()) + drawCircle(color = INDICATOR_BACKGROUND_COLOR, radius = (CIRCLE_SIZE / 2).dp.toPx()) drawArc( topLeft = Offset( (LINE_STROKE_WIDTH / 2).dp.toPx(), (LINE_STROKE_WIDTH / 2).dp.toPx() @@ -76,14 +77,14 @@ fun VolumeCircle( sweepAngle = 360f * volumeFraction, useCenter = false, color = Color.White, - style = Stroke(width = 4.dp.toPx(), cap = StrokeCap.Round) + style = Stroke(width = LINE_STROKE_WIDTH.dp.toPx(), cap = StrokeCap.Round) ) } Icon( modifier = Modifier .align(Alignment.Center) - .size(60.dp), + .size(80.dp), imageVector = (if (isBrightness) getBrightnesIcon(volumeFraction = volumeFraction) else getVolumeIcon(volumeFraction = volumeFraction)), contentDescription = stringResource(