[Android] Fix tablet controls appearing on mobile

Nicolas Pomepuy git at videolan.org
Mon Jan 10 06:57:59 UTC 2022


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Fri Jan  7 14:42:04 2022 +0100| [07ff55f75ce80c9fbd1d17d0948f2f4d4d30a326] | committer: Nicolas Pomepuy

Fix tablet controls appearing on mobile

Fixes #2304

> https://code.videolan.org/videolan/vlc-android/commit/07ff55f75ce80c9fbd1d17d0948f2f4d4d30a326
---

 application/vlc-android/res/layout-land/audio_player.xml      | 11 +++++------
 application/vlc-android/res/layout/audio_player.xml           | 11 +++++------
 .../src/org/videolan/vlc/gui/audio/AudioPlayerAnimator.kt     |  8 ++++++++
 3 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/application/vlc-android/res/layout-land/audio_player.xml b/application/vlc-android/res/layout-land/audio_player.xml
index d80d5669b..620cc0f94 100644
--- a/application/vlc-android/res/layout-land/audio_player.xml
+++ b/application/vlc-android/res/layout-land/audio_player.xml
@@ -120,7 +120,7 @@
                     android:focusable="true"
                     android:onClick="@{fragment::onShuffleClick}"
                     android:padding="8dp"
-                    android:visibility="@{fragment.isTablet() ? View.VISIBLE : View.GONE}"
+                    android:visibility="gone"
                     app:layout_constraintBottom_toBottomOf="@id/header_large_play_pause"
                     app:layout_constraintEnd_toStartOf="@+id/header_previous"
                     app:layout_constraintHorizontal_bias="0.5"
@@ -141,7 +141,7 @@
                     android:focusable="true"
                     android:onClick="@{fragment::onPreviousClick}"
                     android:padding="8dp"
-                    android:visibility="@{fragment.isTablet() ? View.VISIBLE : View.GONE}"
+                    android:visibility="gone"
                     app:layout_constraintBottom_toBottomOf="@id/header_large_play_pause"
                     app:layout_constraintEnd_toStartOf="@+id/header_large_play_pause"
                     app:layout_constraintHorizontal_bias="0.5"
@@ -160,7 +160,7 @@
                     android:onClick="@{fragment::onPlayPauseClick}"
                     android:onLongClick="@{fragment::onStopClick}"
                     android:padding="4dp"
-                    android:visibility="@{fragment.isTablet() ? View.VISIBLE : View.GONE}"
+                    android:visibility="gone"
                     app:layout_constraintBottom_toBottomOf="parent"
                     app:layout_constraintEnd_toStartOf="@+id/header_next"
                     app:layout_constraintHorizontal_bias="0.5"
@@ -180,7 +180,7 @@
                     android:onClick="@{fragment::onNextClick}"
                     android:padding="8dp"
                     android:scaleType="fitXY"
-                    android:visibility="@{fragment.isTablet() ? View.VISIBLE : View.GONE}"
+                    android:visibility="gone"
                     app:layout_constraintBottom_toBottomOf="@id/header_large_play_pause"
                     app:layout_constraintEnd_toStartOf="@+id/header_repeat"
                     app:layout_constraintHorizontal_bias="0.5"
@@ -201,7 +201,7 @@
                     android:onClick="@{fragment::onRepeatClick}"
                     android:padding="8dp"
                     android:scaleType="fitXY"
-                    android:visibility="@{fragment.isTablet() ? View.VISIBLE : View.GONE}"
+                    android:visibility="gone"
                     app:layout_constraintBottom_toBottomOf="@id/header_large_play_pause"
                     app:layout_constraintEnd_toEndOf="parent"
                     app:layout_constraintHorizontal_bias="0.5"
@@ -410,7 +410,6 @@
                     android:layout_height="38dp"
                     android:layout_marginEnd="@dimen/default_margin"
                     android:contentDescription="@string/play"
-                    android:visibility="@{fragment.isTablet() ? View.GONE : View.VISIBLE}"
                     android:focusable="true"
                     android:onClick="@{fragment::onPlayPauseClick}"
                     android:onLongClick="@{fragment::onStopClick}"
diff --git a/application/vlc-android/res/layout/audio_player.xml b/application/vlc-android/res/layout/audio_player.xml
index fc9b94fe9..193a1bbe4 100644
--- a/application/vlc-android/res/layout/audio_player.xml
+++ b/application/vlc-android/res/layout/audio_player.xml
@@ -108,7 +108,7 @@
                     android:focusable="true"
                     android:onClick="@{fragment::onShuffleClick}"
                     android:padding="8dp"
-                    android:visibility="@{fragment.isTablet() && can_shuffle ? View.VISIBLE : View.GONE}"
+                    android:visibility="gone"
                     app:layout_constraintBottom_toBottomOf="@id/header_large_play_pause"
                     app:layout_constraintEnd_toStartOf="@+id/header_previous"
                     app:layout_constraintHorizontal_bias="0.5"
@@ -129,7 +129,7 @@
                     android:focusable="true"
                     android:onClick="@{fragment::onPreviousClick}"
                     android:padding="8dp"
-                    android:visibility="@{fragment.isTablet() ? View.VISIBLE : View.GONE}"
+                    android:visibility="gone"
                     app:layout_constraintBottom_toBottomOf="@id/header_large_play_pause"
                     app:layout_constraintEnd_toStartOf="@+id/header_large_play_pause"
                     app:layout_constraintHorizontal_bias="0.5"
@@ -148,7 +148,7 @@
                     android:onClick="@{fragment::onPlayPauseClick}"
                     android:onLongClick="@{fragment::onStopClick}"
                     android:padding="4dp"
-                    android:visibility="@{fragment.isTablet() ? View.VISIBLE : View.GONE}"
+                    android:visibility="gone"
                     app:layout_constraintBottom_toBottomOf="parent"
                     app:layout_constraintEnd_toStartOf="@+id/header_next"
                     app:layout_constraintHorizontal_bias="0.5"
@@ -168,7 +168,7 @@
                     android:onClick="@{fragment::onNextClick}"
                     android:padding="8dp"
                     android:scaleType="fitXY"
-                    android:visibility="@{fragment.isTablet() ? View.VISIBLE : View.GONE}"
+                    android:visibility="gone"
                     app:layout_constraintBottom_toBottomOf="@id/header_large_play_pause"
                     app:layout_constraintEnd_toStartOf="@+id/header_repeat"
                     app:layout_constraintHorizontal_bias="0.5"
@@ -189,7 +189,7 @@
                     android:onClick="@{fragment::onRepeatClick}"
                     android:padding="8dp"
                     android:scaleType="fitXY"
-                    android:visibility="@{fragment.isTablet() ? View.VISIBLE : View.GONE}"
+                    android:visibility="gone"
                     app:layout_constraintBottom_toBottomOf="@id/header_large_play_pause"
                     app:layout_constraintEnd_toEndOf="parent"
                     app:layout_constraintHorizontal_bias="0.5"
@@ -370,7 +370,6 @@
                     android:layout_marginEnd="@dimen/default_margin"
                     android:contentDescription="@string/play"
                     android:focusable="true"
-                    android:visibility="@{fragment.isTablet() ? View.GONE : View.VISIBLE}"
                     android:onClick="@{fragment::onPlayPauseClick}"
                     android:onLongClick="@{fragment::onStopClick}"
                     android:scaleType="fitXY"
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayerAnimator.kt b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayerAnimator.kt
index cc15fe139..2aaf4b4e0 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayerAnimator.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayerAnimator.kt
@@ -128,6 +128,14 @@ internal class AudioPlayerAnimator : IAudioPlayerAnimator, LifecycleObserver {
         headerShowPlaylistConstraint.clone(binding.header)
         headerHidePlaylistConstraint.clone(binding.header)
         headerHidePlaylistLandscapeConstraint.clone(binding.header)
+        arrayOf(headerShowPlaylistConstraint, headerHidePlaylistConstraint, headerHidePlaylistLandscapeConstraint).forEach {constraintSet ->
+            constraintSet.setVisibility(R.id.header_shuffle, if (audioPlayer.isTablet() && audioPlayer.playlistModel.canShuffle) View.VISIBLE else View.GONE)
+            arrayOf(R.id.header_previous, R.id.header_large_play_pause, R.id.header_next, R.id.header_repeat).forEach {
+                constraintSet.setVisibility(it, if (audioPlayer.isTablet()) View.VISIBLE else View.GONE)
+            }
+            constraintSet.setVisibility(R.id.header_play_pause, if (audioPlayer.isTablet()) View.GONE else View.VISIBLE)
+        }
+        headerShowPlaylistConstraint.applyTo(binding.header)
 
         hidePlaylistConstraint.setVisibility(R.id.songs_list, View.GONE)
         hidePlaylistConstraint.setVisibility(R.id.cover_media_switcher, View.VISIBLE)



More information about the Android mailing list