diff --git a/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt b/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt index 24092e33b..28adf2550 100644 --- a/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt +++ b/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt @@ -1,5 +1,6 @@ package com.github.libretube.ui.activities +import android.annotation.SuppressLint import android.content.Intent import android.content.pm.ActivityInfo import android.content.res.Configuration @@ -387,15 +388,13 @@ class MainActivity : BaseActivity() { } } + @SuppressLint("SwitchIntDef") override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) - val orientation = newConfig.orientation - if (orientation == Configuration.ORIENTATION_PORTRAIT) { - println("Portrait") - unsetFullscreen() - } else if (orientation == Configuration.ORIENTATION_LANDSCAPE) { - println("Landscape") - setFullscreen() + + when (newConfig.orientation) { + Configuration.ORIENTATION_PORTRAIT -> unsetFullscreen() + Configuration.ORIENTATION_LANDSCAPE -> setFullscreen() } } diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index 9cdef7810..4ddb1e203 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -1558,12 +1558,11 @@ class PlayerFragment : BaseFragment() { if (autoRotationEnabled) { val orientation = newConfig.orientation - if (orientation == Configuration.ORIENTATION_LANDSCAPE) { + when (orientation) { // go to fullscreen mode - setFullscreen() - } else { + Configuration.ORIENTATION_LANDSCAPE -> setFullscreen() // exit fullscreen if not landscape - unsetFullscreen() + else -> unsetFullscreen() } } } diff --git a/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt b/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt index 5c3b26935..0c11f9a44 100644 --- a/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt +++ b/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt @@ -2,6 +2,7 @@ package com.github.libretube.ui.views import android.annotation.SuppressLint import android.content.Context +import android.content.res.Configuration import android.os.Handler import android.os.Looper import android.util.AttributeSet @@ -384,4 +385,19 @@ internal class CustomExoPlayerView( } .show(childFragmentManager) } + + override fun onConfigurationChanged(newConfig: Configuration?) { + super.onConfigurationChanged(newConfig) + + val offsetFactor: Float = when (newConfig?.orientation) { + Configuration.ORIENTATION_LANDSCAPE -> 2F + else -> 1F / 2F + } + + binding.progressBar.let { + val params = it.layoutParams as MarginLayoutParams + params.bottomMargin = (params.bottomMargin * offsetFactor).toInt() + it.layoutParams = params + } + } }