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"
)
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
)

View File

@ -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,

View File

@ -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)) {

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

View File

@ -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(