Skip to content

Commit

Permalink
prevent hiding ui through hide ui delay timer when dialog is visible
Browse files Browse the repository at this point in the history
  • Loading branch information
theScrabi committed Nov 1, 2024
1 parent 9efa1dd commit 9d68cad
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,15 @@ internal fun PlaySurface(
ActualView(modifier.fillMaxSize(), player)
else {
val modifier = modifier.aspectRatio(contentRatio)
if (uiRatio <= contentRatio) {
ActualView(modifier.fillMaxWidth(), player)
} else {
ActualView(modifier.fillMaxHeight(), player)
if (fitMode == ContentScale.FIT_INSIDE) {
ActualView(modifier.fillMaxSize(), player)
} else { /* if(fitMode == ContentScale.CROP) */
if (uiRatio <= contentRatio) {
ActualView(modifier.fillMaxHeight(), player)
} else {
ActualView(modifier.fillMaxWidth(), player)
}
}


}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ class NewPlayerViewModelImpl @Inject constructor(

private var playbackPositionWhenFastSeekStarted = 0L

private var dialogIsVisible = false

private val audioManager =
getSystemService(application.applicationContext, AudioManager::class.java)!!

Expand Down Expand Up @@ -398,9 +400,12 @@ class NewPlayerViewModelImpl @Inject constructor(

override fun resetHideDelayTimer() {
hideUiDelayedJob?.cancel()
hideUiDelayedJob = viewModelScope.launch {
delay(2000)
changeUiMode(uiState.value.uiMode.getUiHiddenState(), null)
if(!dialogIsVisible) {
hideUiDelayedJob = viewModelScope.launch {
delay(2000)
if(!dialogIsVisible)
changeUiMode(uiState.value.uiMode.getUiHiddenState(), null)
}
}
}

Expand Down Expand Up @@ -673,6 +678,7 @@ class NewPlayerViewModelImpl @Inject constructor(
}

override fun dialogVisible(visible: Boolean) {
dialogIsVisible = visible
if (visible) {
hideUiDelayedJob?.cancel()
if (!uiState.value.uiMode.videoControllerUiVisible) {
Expand Down

0 comments on commit 9d68cad

Please sign in to comment.