Merge pull request #2570 from Bnyro/master

Add a horizontal margin to the player controls at landscape
This commit is contained in:
Bnyro 2023-01-03 18:44:22 +01:00 committed by GitHub
commit 8fba32adde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 5 deletions

View File

@ -488,6 +488,7 @@ internal class CustomExoPlayerView(
override fun onConfigurationChanged(newConfig: Configuration?) {
super.onConfigurationChanged(newConfig)
// add a larger bottom margin to the time bar in landscape mode
val offset = when (newConfig?.orientation) {
Configuration.ORIENTATION_LANDSCAPE -> 20.toPixel()
else -> 10.toPixel()
@ -498,6 +499,22 @@ internal class CustomExoPlayerView(
params.bottomMargin = offset.toInt()
it.layoutParams = params
}
// add a margin to the top and the bottom bar in landscape mode for notches
val newMargin = if (
newConfig?.orientation == Configuration.ORIENTATION_LANDSCAPE
) {
LANDSCAPE_MARGIN_HORIZONTAL
} else {
0
}
listOf(binding.exoTopBar, binding.exoBottomBar).forEach {
val params = it.layoutParams as MarginLayoutParams
params.marginStart = newMargin
params.marginEnd = newMargin
it.layoutParams = params
}
}
override fun onSingleTap() {
@ -576,5 +593,6 @@ internal class CustomExoPlayerView(
companion object {
private const val SUBTITLE_BOTTOM_PADDING_FRACTION = 0.158f
private val LANDSCAPE_MARGIN_HORIZONTAL = (30).toPixel().toInt()
}
}

View File

@ -16,9 +16,8 @@
android:layout_gravity="top"
android:animateLayoutChanges="true"
android:orientation="vertical"
android:paddingStart="5dp"
android:paddingTop="5dp"
android:paddingEnd="10dp">
android:paddingHorizontal="5dp"
android:paddingTop="5dp" >
<LinearLayout
android:layout_width="match_parent"
@ -41,8 +40,8 @@
<ImageView
android:id="@+id/lock_player"
style="@style/PlayerControlTop"
android:scaleX=".8"
android:scaleY=".8"
android:scaleX="0.8"
android:scaleY="0.8"
android:src="@drawable/ic_unlocked" />
</LinearLayout>