bring back embeded config
This commit is contained in:
parent
3dc5ca3e10
commit
33b0360507
|
@ -42,7 +42,7 @@ interface VideoPlayerViewModel {
|
||||||
fun pause()
|
fun pause()
|
||||||
fun prevStream()
|
fun prevStream()
|
||||||
fun nextStream()
|
fun nextStream()
|
||||||
fun switchToFullscreen()
|
fun switchToFullscreen(embeddedUiConfig: EmbeddedUiConfig)
|
||||||
fun switchToEmbeddedView()
|
fun switchToEmbeddedView()
|
||||||
fun onBackPressed()
|
fun onBackPressed()
|
||||||
fun showUi()
|
fun showUi()
|
||||||
|
@ -54,7 +54,7 @@ interface VideoPlayerViewModel {
|
||||||
fun finishFastSeek()
|
fun finishFastSeek()
|
||||||
fun brightnessChange(changeRate: Float, systemBrightness: Float)
|
fun brightnessChange(changeRate: Float, systemBrightness: Float)
|
||||||
fun volumeChange(changeRate: Float)
|
fun volumeChange(changeRate: Float)
|
||||||
fun openStreamSelection(selectChapter: Boolean)
|
fun openStreamSelection(selectChapter: Boolean, embeddedUiConfig: EmbeddedUiConfig)
|
||||||
fun closeStreamSelection()
|
fun closeStreamSelection()
|
||||||
fun chapterSelected(chapterId: Int)
|
fun chapterSelected(chapterId: Int)
|
||||||
fun streamSelected(streamId: Int)
|
fun streamSelected(streamId: Int)
|
||||||
|
|
|
@ -438,8 +438,11 @@ class VideoPlayerViewModelImpl @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openStreamSelection(selectChapter: Boolean) {
|
override fun openStreamSelection(selectChapter: Boolean, embeddedUiConfig: EmbeddedUiConfig) {
|
||||||
uiVisibilityJob?.cancel()
|
uiVisibilityJob?.cancel()
|
||||||
|
if (!uiState.value.uiMode.fullscreen) {
|
||||||
|
this.embeddedUiConfig = embeddedUiConfig
|
||||||
|
}
|
||||||
updateUiMode(
|
updateUiMode(
|
||||||
if (selectChapter) uiState.value.uiMode.getChapterSelectUiState()
|
if (selectChapter) uiState.value.uiMode.getChapterSelectUiState()
|
||||||
else uiState.value.uiMode.getStreamSelectUiState()
|
else uiState.value.uiMode.getStreamSelectUiState()
|
||||||
|
@ -472,10 +475,11 @@ class VideoPlayerViewModelImpl @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun switchToFullscreen() {
|
override fun switchToFullscreen(embeddedUiConfig: EmbeddedUiConfig) {
|
||||||
uiVisibilityJob?.cancel()
|
uiVisibilityJob?.cancel()
|
||||||
finishFastSeek()
|
finishFastSeek()
|
||||||
|
|
||||||
|
this.embeddedUiConfig = embeddedUiConfig
|
||||||
updateUiMode(UIModeState.FULLSCREEN_VIDEO)
|
updateUiMode(UIModeState.FULLSCREEN_VIDEO)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ open class VideoPlayerViewModelDummy : VideoPlayerViewModel {
|
||||||
println("dummy impl")
|
println("dummy impl")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun switchToFullscreen() {
|
override fun switchToFullscreen(embeddedUiConfig: EmbeddedUiConfig) {
|
||||||
println("dummy impl")
|
println("dummy impl")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ open class VideoPlayerViewModelDummy : VideoPlayerViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun fastSeek(steps: Int) {
|
override fun fastSeek(steps: Int) {
|
||||||
println("dummy impl, steps: $steps")
|
println("dummy impl: steps: $steps")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun finishFastSeek() {
|
override fun finishFastSeek() {
|
||||||
|
@ -76,7 +76,7 @@ open class VideoPlayerViewModelDummy : VideoPlayerViewModel {
|
||||||
println("dummy impl")
|
println("dummy impl")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openStreamSelection(selectChapter: Boolean) {
|
override fun openStreamSelection(selectChapter: Boolean, embeddedUiConfig: EmbeddedUiConfig) {
|
||||||
println("dummy impl")
|
println("dummy impl")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,6 +95,7 @@ fun VideoPlayerUI(
|
||||||
|
|
||||||
// Setup fullscreen
|
// Setup fullscreen
|
||||||
|
|
||||||
|
|
||||||
LaunchedEffect(uiState.uiMode.fullscreen) {
|
LaunchedEffect(uiState.uiMode.fullscreen) {
|
||||||
if (uiState.uiMode.fullscreen) {
|
if (uiState.uiMode.fullscreen) {
|
||||||
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars =
|
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars =
|
||||||
|
|
|
@ -57,6 +57,7 @@ import net.newpipe.newplayer.ui.seeker.Seeker
|
||||||
import net.newpipe.newplayer.ui.seeker.SeekerColors
|
import net.newpipe.newplayer.ui.seeker.SeekerColors
|
||||||
import net.newpipe.newplayer.ui.seeker.Segment
|
import net.newpipe.newplayer.ui.seeker.Segment
|
||||||
import net.newpipe.newplayer.ui.theme.VideoPlayerTheme
|
import net.newpipe.newplayer.ui.theme.VideoPlayerTheme
|
||||||
|
import net.newpipe.newplayer.utils.getEmbeddedUiConfig
|
||||||
import net.newpipe.newplayer.utils.getLocale
|
import net.newpipe.newplayer.utils.getLocale
|
||||||
import net.newpipe.newplayer.utils.getTimeStringFromMs
|
import net.newpipe.newplayer.utils.getTimeStringFromMs
|
||||||
|
|
||||||
|
@ -86,11 +87,12 @@ fun BottomUI(
|
||||||
|
|
||||||
Text(getTimeStringFromMs(uiState.durationInMs, getLocale() ?: locale))
|
Text(getTimeStringFromMs(uiState.durationInMs, getLocale() ?: locale))
|
||||||
|
|
||||||
|
val embeddedUiConfig = getEmbeddedUiConfig(LocalContext.current as Activity)
|
||||||
IconButton(
|
IconButton(
|
||||||
onClick = if (uiState.uiMode.fullscreen) viewModel::switchToEmbeddedView
|
onClick = if (uiState.uiMode.fullscreen) viewModel::switchToEmbeddedView
|
||||||
else {
|
else {
|
||||||
{ // <- head of lambda ... yea kotlin is weird
|
{ // <- head of lambda ... yea kotlin is weird
|
||||||
viewModel.switchToFullscreen()
|
viewModel.switchToFullscreen(embeddedUiConfig)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -53,12 +53,13 @@ import net.newpipe.newplayer.model.VideoPlayerViewModel
|
||||||
import net.newpipe.newplayer.model.VideoPlayerViewModelDummy
|
import net.newpipe.newplayer.model.VideoPlayerViewModelDummy
|
||||||
import net.newpipe.newplayer.ui.theme.VideoPlayerTheme
|
import net.newpipe.newplayer.ui.theme.VideoPlayerTheme
|
||||||
import net.newpipe.newplayer.ui.theme.video_player_onSurface
|
import net.newpipe.newplayer.ui.theme.video_player_onSurface
|
||||||
|
import net.newpipe.newplayer.utils.getEmbeddedUiConfig
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun TopUI(
|
fun TopUI(
|
||||||
modifier: Modifier, viewModel: VideoPlayerViewModel, uiState: VideoPlayerUIState
|
modifier: Modifier, viewModel: VideoPlayerViewModel, uiState: VideoPlayerUIState
|
||||||
) {
|
) {
|
||||||
|
val embeddedUiConfig = getEmbeddedUiConfig(activity = LocalContext.current as Activity)
|
||||||
Row(
|
Row(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
@ -99,7 +100,7 @@ fun TopUI(
|
||||||
}
|
}
|
||||||
AnimatedVisibility(visible = uiState.chapters.isNotEmpty()) {
|
AnimatedVisibility(visible = uiState.chapters.isNotEmpty()) {
|
||||||
IconButton(
|
IconButton(
|
||||||
onClick = { viewModel.openStreamSelection(selectChapter = true) },
|
onClick = { viewModel.openStreamSelection(selectChapter = true, embeddedUiConfig) },
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.AutoMirrored.Filled.MenuBook,
|
imageVector = Icons.AutoMirrored.Filled.MenuBook,
|
||||||
|
@ -111,7 +112,8 @@ fun TopUI(
|
||||||
IconButton(
|
IconButton(
|
||||||
onClick = {
|
onClick = {
|
||||||
viewModel.openStreamSelection(
|
viewModel.openStreamSelection(
|
||||||
selectChapter = false
|
selectChapter = false,
|
||||||
|
embeddedUiConfig
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
package net.newpipe.newplayer.ui.videoplayer.gesture_ui
|
package net.newpipe.newplayer.ui.videoplayer.gesture_ui
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
|
@ -35,11 +36,13 @@ import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import net.newpipe.newplayer.model.VideoPlayerUIState
|
import net.newpipe.newplayer.model.VideoPlayerUIState
|
||||||
import net.newpipe.newplayer.model.VideoPlayerViewModel
|
import net.newpipe.newplayer.model.VideoPlayerViewModel
|
||||||
import net.newpipe.newplayer.model.VideoPlayerViewModelDummy
|
import net.newpipe.newplayer.model.VideoPlayerViewModelDummy
|
||||||
import net.newpipe.newplayer.ui.theme.VideoPlayerTheme
|
import net.newpipe.newplayer.ui.theme.VideoPlayerTheme
|
||||||
|
import net.newpipe.newplayer.utils.getEmbeddedUiConfig
|
||||||
|
|
||||||
private const val TAG = "EmbeddedGestureUI"
|
private const val TAG = "EmbeddedGestureUI"
|
||||||
|
|
||||||
|
@ -52,6 +55,8 @@ fun EmbeddedGestureUI(
|
||||||
mutableStateOf(false)
|
mutableStateOf(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val embeddedUiConfig = getEmbeddedUiConfig(LocalContext.current as Activity)
|
||||||
|
|
||||||
val handleMovement = { movement: TouchedPosition ->
|
val handleMovement = { movement: TouchedPosition ->
|
||||||
Log.d(TAG, "${movement.x}:${movement.y}")
|
Log.d(TAG, "${movement.x}:${movement.y}")
|
||||||
if (0 < movement.y) {
|
if (0 < movement.y) {
|
||||||
|
@ -61,7 +66,7 @@ fun EmbeddedGestureUI(
|
||||||
|
|
||||||
// this check is there to allow a temporary move up in the downward gesture
|
// this check is there to allow a temporary move up in the downward gesture
|
||||||
if (downwardMovementMode == false) {
|
if (downwardMovementMode == false) {
|
||||||
viewModel.switchToFullscreen()
|
viewModel.switchToFullscreen(embeddedUiConfig)
|
||||||
} else {
|
} else {
|
||||||
viewModel.embeddedDraggedDown(movement.y)
|
viewModel.embeddedDraggedDown(movement.y)
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,6 +89,25 @@ fun getLocale(): Locale? {
|
||||||
return ConfigurationCompat.getLocales(configuration).get(0)
|
return ConfigurationCompat.getLocales(configuration).get(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
@ReadOnlyComposable
|
||||||
|
fun getEmbeddedUiConfig(activity: Activity): EmbeddedUiConfig {
|
||||||
|
val window = activity.window
|
||||||
|
val view = LocalView.current
|
||||||
|
|
||||||
|
val isLightStatusBar = WindowCompat.getInsetsController(
|
||||||
|
window,
|
||||||
|
view
|
||||||
|
).isAppearanceLightStatusBars
|
||||||
|
val screenOrientation = activity.requestedOrientation
|
||||||
|
val defaultBrightness = getDefaultBrightness(activity)
|
||||||
|
return EmbeddedUiConfig(
|
||||||
|
systemBarInLightMode = isLightStatusBar,
|
||||||
|
brightness = defaultBrightness,
|
||||||
|
screenOrientation = screenOrientation
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun getInsets() =
|
fun getInsets() =
|
||||||
WindowInsets.systemBars.union(WindowInsets.displayCutout).union(WindowInsets.waterfall)
|
WindowInsets.systemBars.union(WindowInsets.displayCutout).union(WindowInsets.waterfall)
|
||||||
|
|
Loading…
Reference in New Issue