increase bottom bar margin upon landscape

This commit is contained in:
Bnyro 2022-10-05 22:15:45 +02:00
parent 4f7d28ee0e
commit 404ea99c8e
3 changed files with 25 additions and 11 deletions

View File

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

View File

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

View File

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