increese size of volume indicator

This commit is contained in:
Christian Schabesberger 2024-08-09 13:04:43 +02:00
parent 601dbf2e7f
commit aa017fc8eb
5 changed files with 17 additions and 10 deletions

View File

@ -309,7 +309,7 @@ class VideoPlayerViewModelImpl @Inject constructor(
"currentBrightnes: $currentBrightness, sytemBrightness: $systemBrightness, changeRate: $changeRate" "currentBrightnes: $currentBrightness, sytemBrightness: $systemBrightness, changeRate: $changeRate"
) )
val newBrightness = (currentBrightness + changeRate).coerceIn(0f, 1f) val newBrightness = (currentBrightness + changeRate * 1.3f).coerceIn(0f, 1f)
mutableUiState.update { mutableUiState.update {
it.copy(brightness = newBrightness) it.copy(brightness = newBrightness)
} }
@ -321,7 +321,7 @@ class VideoPlayerViewModelImpl @Inject constructor(
val maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC).toFloat() 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 // 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 // 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.setStreamVolume(
AudioManager.STREAM_MUSIC, (newVolume * maxVolume).toInt(), 0 AudioManager.STREAM_MUSIC, (newVolume * maxVolume).toInt(), 0
) )

View File

@ -22,6 +22,7 @@ package net.newpipe.newplayer.ui.videoplayer
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier 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.EmbeddedGestureUI
import net.newpipe.newplayer.ui.videoplayer.gesture_ui.FullscreenGestureUI 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_IN = 200
const val SEEK_ANIMATION_FADE_OUT = 500 const val SEEK_ANIMATION_FADE_OUT = 500
val INDICATOR_BACKGROUND_COLOR = Color.Black.copy(alpha = 0.3f)
@Composable @Composable
fun GestureUI( fun GestureUI(
modifier: Modifier, modifier: Modifier,
@ -62,6 +65,7 @@ fun GestureUI(
if (fullscreen) { if (fullscreen) {
FullscreenGestureUI( FullscreenGestureUI(
modifier = modifier,
uiVissible = uiVissible, uiVissible = uiVissible,
fastSeekSeconds = fastSeekSeconds, fastSeekSeconds = fastSeekSeconds,
hideUi = hideUi, hideUi = hideUi,
@ -75,6 +79,7 @@ fun GestureUI(
brightnesChange = brightnessChange) brightnesChange = brightnessChange)
} else { } else {
EmbeddedGestureUI( EmbeddedGestureUI(
modifier = modifier,
fastSeekSeconds = fastSeekSeconds, fastSeekSeconds = fastSeekSeconds,
uiVissible = uiVissible, uiVissible = uiVissible,
switchToFullscreen = switchToFullscreen, switchToFullscreen = switchToFullscreen,

View File

@ -56,6 +56,7 @@ import androidx.compose.ui.unit.dp
import com.google.android.material.color.MaterialColors import com.google.android.material.color.MaterialColors
import net.newpipe.newplayer.R import net.newpipe.newplayer.R
import net.newpipe.newplayer.ui.theme.VideoPlayerTheme 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_DURATION_IN_MS
import net.newpipe.newplayer.ui.videoplayer.SEEK_ANIMATION_FADE_IN import net.newpipe.newplayer.ui.videoplayer.SEEK_ANIMATION_FADE_IN
import net.newpipe.newplayer.ui.videoplayer.SEEK_ANIMATION_FADE_OUT 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" val secondsString = "Seconds"
Surface( Surface(
color = Color.Black.copy(alpha = 0.5f), color = INDICATOR_BACKGROUND_COLOR,
modifier = modifier.clip(RoundedCornerShape(50.dp)) modifier = modifier.clip(RoundedCornerShape(50.dp))
) { ) {
Box(modifier = Modifier.padding(10.dp, 5.dp)) { Box(modifier = Modifier.padding(10.dp, 5.dp)) {

View File

@ -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 @Composable
fun FullscreenGestureUIPreviewInteractive() { fun FullscreenGestureUIPreviewInteractive() {

View File

@ -47,11 +47,12 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import net.newpipe.newplayer.R import net.newpipe.newplayer.R
import net.newpipe.newplayer.ui.theme.VideoPlayerTheme import net.newpipe.newplayer.ui.theme.VideoPlayerTheme
import net.newpipe.newplayer.ui.videoplayer.INDICATOR_BACKGROUND_COLOR
private const val TAG = "VolumeCircle" private const val TAG = "VolumeCircle"
private const val LINE_STROKE_WIDTH = 4 private const val LINE_STROKE_WIDTH = 8
private const val CIRCLE_SIZE = 100 private const val CIRCLE_SIZE = 150
@Composable @Composable
fun VolumeCircle( fun VolumeCircle(
@ -59,14 +60,14 @@ fun VolumeCircle(
volumeFraction: Float, volumeFraction: Float,
isBrightness: Boolean = false 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") Log.e(TAG, "Volume fraction must be in ragne [0;1]. It was $volumeFraction")
} }
Box(modifier) { Box(modifier) {
Canvas(Modifier.size(CIRCLE_SIZE.dp)) { Canvas(Modifier.size(CIRCLE_SIZE.dp)) {
val arcSize = (CIRCLE_SIZE - LINE_STROKE_WIDTH).dp.toPx(); 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( drawArc(
topLeft = Offset( topLeft = Offset(
(LINE_STROKE_WIDTH / 2).dp.toPx(), (LINE_STROKE_WIDTH / 2).dp.toPx() (LINE_STROKE_WIDTH / 2).dp.toPx(), (LINE_STROKE_WIDTH / 2).dp.toPx()
@ -76,14 +77,14 @@ fun VolumeCircle(
sweepAngle = 360f * volumeFraction, sweepAngle = 360f * volumeFraction,
useCenter = false, useCenter = false,
color = Color.White, color = Color.White,
style = Stroke(width = 4.dp.toPx(), cap = StrokeCap.Round) style = Stroke(width = LINE_STROKE_WIDTH.dp.toPx(), cap = StrokeCap.Round)
) )
} }
Icon( Icon(
modifier = Modifier modifier = Modifier
.align(Alignment.Center) .align(Alignment.Center)
.size(60.dp), .size(80.dp),
imageVector = (if (isBrightness) getBrightnesIcon(volumeFraction = volumeFraction) imageVector = (if (isBrightness) getBrightnesIcon(volumeFraction = volumeFraction)
else getVolumeIcon(volumeFraction = volumeFraction)), else getVolumeIcon(volumeFraction = volumeFraction)),
contentDescription = stringResource( contentDescription = stringResource(