[Android] Show video player huds background under cutouts
Nicolas Pomepuy
git at videolan.org
Tue Jun 30 14:06:25 CEST 2020
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Jun 30 10:23:39 2020 +0200| [9d73947496a76c40d8f85aa4dcd42eed9603171a] | committer: Nicolas Pomepuy
Show video player huds background under cutouts
Fixes #1387
> https://code.videolan.org/videolan/vlc-android/commit/9d73947496a76c40d8f85aa4dcd42eed9603171a
---
application/vlc-android/res/layout/player.xml | 16 +++++++
application/vlc-android/res/layout/player_hud.xml | 1 -
.../vlc-android/res/layout/player_hud_right.xml | 8 ----
application/vlc-android/res/values-v21/styles.xml | 4 +-
.../videolan/vlc/gui/video/VideoPlayerActivity.kt | 51 +++++++++++-----------
5 files changed, 43 insertions(+), 37 deletions(-)
diff --git a/application/vlc-android/res/layout/player.xml b/application/vlc-android/res/layout/player.xml
index 4e548b817..87536cf52 100644
--- a/application/vlc-android/res/layout/player.xml
+++ b/application/vlc-android/res/layout/player.xml
@@ -46,6 +46,22 @@
android:layout_marginBottom="@dimen/default_margin"
android:layout="@layout/player_overlay_volume" />
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="130dp"
+ android:layout_alignParentBottom="true"
+ android:id="@+id/hud_background"
+ android:background="@drawable/gradient_hud_player"
+ android:visibility="gone"/>
+
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="150dp"
+ android:layout_alignParentTop="true"
+ android:id="@+id/hud_right_background"
+ android:background="@drawable/gradient_title_player"
+ android:visibility="gone"/>
+
<RelativeLayout
android:id="@+id/player_ui_container"
android:layout_width="match_parent"
diff --git a/application/vlc-android/res/layout/player_hud.xml b/application/vlc-android/res/layout/player_hud.xml
index b946baddd..7b05604ab 100644
--- a/application/vlc-android/res/layout/player_hud.xml
+++ b/application/vlc-android/res/layout/player_hud.xml
@@ -176,7 +176,6 @@
android:id="@+id/constraintLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:background="@drawable/gradient_hud_player"
android:paddingTop="@dimen/overlay_padding_top"
android:paddingBottom="@dimen/overlay_padding_bottom"
tools:theme="@style/Theme.VLC.Player"
diff --git a/application/vlc-android/res/layout/player_hud_right.xml b/application/vlc-android/res/layout/player_hud_right.xml
index 6a27c7d50..df00d7d55 100644
--- a/application/vlc-android/res/layout/player_hud_right.xml
+++ b/application/vlc-android/res/layout/player_hud_right.xml
@@ -16,14 +16,6 @@
android:visibility="invisible"
tools:visibility="visible">
- <View
- android:id="@+id/top_gradient"
- android:layout_width="0dp"
- android:layout_height="150dp"
- android:background="@drawable/gradient_title_player"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/player_overlay_navmenu"
diff --git a/application/vlc-android/res/values-v21/styles.xml b/application/vlc-android/res/values-v21/styles.xml
index 643db1aa4..bd849955f 100644
--- a/application/vlc-android/res/values-v21/styles.xml
+++ b/application/vlc-android/res/values-v21/styles.xml
@@ -8,8 +8,8 @@
<style name="Theme.VLC.Player" parent="Theme.VLC.Player.7">
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
- <item name="android:statusBarColor">@color/status_bar_transparency</item>
- <item name="android:navigationBarColor">@color/status_bar_transparency</item>
+ <item name="android:statusBarColor">@color/transparent</item>
+ <item name="android:navigationBarColor">@color/transparent</item>
</style>
<style name="Theme.VLC" parent="Theme.VLC.19">
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
index b4d1fb123..b458b8757 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
@@ -1954,15 +1954,10 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
showControls(true)
}
dimStatusBar(false)
- hudBinding.progressOverlay.setVisible()
- hudBinding.progressOverlay.alpha = 0f
- hudBinding.progressOverlay.translationY = 100.dp.toFloat()
- hudBinding.progressOverlay.animate().alpha(1F).translationY(0F).setDuration(150L).setListener(null)
-
- hudRightBinding.hudRightOverlay.setVisible()
- hudRightBinding.hudRightOverlay.alpha = 0f
- hudRightBinding.hudRightOverlay.translationY = -100.dp.toFloat()
- hudRightBinding.hudRightOverlay.animate().alpha(1F).translationY(0F).setDuration(150L).setListener(null)
+
+ enterAnimate(arrayOf(hudBinding.progressOverlay, hud_background), 100.dp.toFloat())
+ enterAnimate(arrayOf(hudRightBinding.hudRightOverlay, hud_right_background), -100.dp.toFloat())
+
if (!displayManager.isPrimary)
overlayBackground.setVisible()
updateOverlayPausePlay(true)
@@ -2161,23 +2156,9 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
overlayBackground.setInvisible()
}
- hudBinding.progressOverlay.animate().alpha(0F).translationY(100.dp.toFloat()).setDuration(150L).setListener(object : Animator.AnimatorListener {
- override fun onAnimationEnd(animation: Animator?) {
- hudBinding.progressOverlay.setInvisible()
- }
- override fun onAnimationCancel(animation: Animator?) {}
- override fun onAnimationRepeat(animation: Animator?) {}
- override fun onAnimationStart(animation: Animator?) {}
- })
-
- hudRightBinding.hudRightOverlay.animate().alpha(0F).translationY(-100.dp.toFloat()).setDuration(150L).setListener(object : Animator.AnimatorListener {
- override fun onAnimationEnd(animation: Animator?) {
- hudRightBinding.hudRightOverlay.setInvisible()
- }
- override fun onAnimationCancel(animation: Animator?) {}
- override fun onAnimationRepeat(animation: Animator?) {}
- override fun onAnimationStart(animation: Animator?) {}
- })
+ exitAnimate(arrayOf(hudBinding.progressOverlay, hud_background),100.dp.toFloat())
+ exitAnimate(arrayOf(hudRightBinding.hudRightOverlay, hud_right_background),-100.dp.toFloat())
+
showControls(false)
isShowing = false
dimStatusBar(true)
@@ -2192,6 +2173,24 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
}
}
+ private fun enterAnimate(views: Array<View?>, translationStart: Float) = views.forEach { view ->
+ view.setVisible()
+ view?.alpha = 0f
+ view?.translationY = translationStart
+ view?.animate()?.alpha(1F)?.translationY(0F)?.setDuration(150L)?.setListener(null)
+ }
+
+ private fun exitAnimate(views: Array<View?>, translationEnd: Float) = views.forEach { view ->
+ view?.animate()?.alpha(0F)?.translationY(translationEnd)?.setDuration(150L)?.setListener(object : Animator.AnimatorListener {
+ override fun onAnimationEnd(animation: Animator?) {
+ view.setInvisible()
+ }
+ override fun onAnimationCancel(animation: Animator?) {}
+ override fun onAnimationRepeat(animation: Animator?) {}
+ override fun onAnimationStart(animation: Animator?) {}
+ })
+ }
+
/**
* Dim the status bar and/or navigation icons when needed on Android 3.x.
* Hide it on Android 4.0 and later
More information about the Android
mailing list