[Android] Change audio player landscape layout for large screens
Nicolas Pomepuy
git at videolan.org
Thu Dec 23 09:45:07 UTC 2021
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Wed Dec 22 10:28:53 2021 +0100| [cc6194ea38afa595828ddc8e4db43d319f7155e6] | committer: Nicolas Pomepuy
Change audio player landscape layout for large screens
> https://code.videolan.org/videolan/vlc-android/commit/cc6194ea38afa595828ddc8e4db43d319f7155e6
---
.../vlc-android/res/layout-land/audio_player.xml | 4 +-
.../cover_media_switcher_item.xml | 100 +++++++++++++++++++++
.../videolan/vlc/gui/audio/AudioPlayerAnimator.kt | 9 ++
.../videolan/vlc/gui/view/CoverMediaSwitcher.kt | 6 +-
4 files changed, 114 insertions(+), 5 deletions(-)
diff --git a/application/vlc-android/res/layout-land/audio_player.xml b/application/vlc-android/res/layout-land/audio_player.xml
index 0392c721f..2b020590c 100644
--- a/application/vlc-android/res/layout-land/audio_player.xml
+++ b/application/vlc-android/res/layout-land/audio_player.xml
@@ -613,7 +613,6 @@
android:id="@+id/cover_media_switcher"
android:layout_width="0dp"
android:layout_height="0dp"
- android:visibility="visible"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="@+id/time"
@@ -621,7 +620,8 @@
app:layout_constraintEnd_toStartOf="@+id/guideline14"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/header"
- tools:layout_constraintLeft_creator="1" />
+ tools:layout_constraintLeft_creator="1"
+ tools:visibility="visible" />
<TextView
diff --git a/application/vlc-android/res/layout-large-land/cover_media_switcher_item.xml b/application/vlc-android/res/layout-large-land/cover_media_switcher_item.xml
new file mode 100644
index 000000000..31da254cb
--- /dev/null
+++ b/application/vlc-android/res/layout-large-land/cover_media_switcher_item.xml
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ *************************************************************************
+ ~ cover_media_switcher_item.xml
+ ~ **************************************************************************
+ ~ Copyright © 2021 VLC authors and VideoLAN
+ ~ Author: Nicolas POMEPUY
+ ~ This program is free software; you can redistribute it and/or modify
+ ~ it under the terms of the GNU General Public License as published by
+ ~ the Free Software Foundation; either version 2 of the License, or
+ ~ (at your option) any later version.
+ ~
+ ~ This program is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ ~ GNU General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU General Public License
+ ~ along with this program; if not, write to the Free Software
+ ~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ ~ ***************************************************************************
+ ~
+ ~
+ -->
+
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="#00000000"
+ android:orientation="horizontal">
+
+ <androidx.cardview.widget.CardView
+ android:id="@+id/cover_card"
+ android:layout_width="0dp"
+ android:layout_height="0dp"
+ android:layout_marginTop="16dp"
+ app:cardBackgroundColor="@android:color/transparent"
+ app:cardCornerRadius="0dp"
+ app:cardElevation="16dp"
+ app:layout_constrainedHeight="true"
+ app:layout_constrainedWidth="true"
+ app:layout_constraintBottom_toTopOf="@+id/song_title"
+ app:layout_constraintDimensionRatio="1"
+ app:layout_constraintLeft_toLeftOf="parent"
+ app:layout_constraintRight_toRightOf="parent"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintVertical_chainStyle="packed">
+
+ <androidx.appcompat.widget.AppCompatImageView
+ android:id="@+id/cover"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="#00000000"
+ android:scaleType="centerCrop"
+ app:elevation="8dp"
+ tools:srcCompat="@tools:sample/avatars" />
+ </androidx.cardview.widget.CardView>
+
+
+ <TextView
+ android:id="@+id/song_title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="24dp"
+ android:layout_marginTop="24dp"
+ android:layout_marginEnd="24dp"
+ android:fontFamily="sans-serif-light"
+ android:maxLines="1"
+ android:textColor="?attr/font_default"
+ android:textSize="24sp"
+ android:visibility="gone"
+ app:layout_constrainedWidth="true"
+ app:layout_constraintBottom_toTopOf="@+id/song_subtitle"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/cover_card"
+ tools:text="5th Symphony" />
+
+ <TextView
+ android:id="@+id/song_subtitle"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="24dp"
+ android:layout_marginTop="8dp"
+ android:layout_marginEnd="24dp"
+ android:maxLines="1"
+ android:textColor="?attr/font_audio_light"
+ android:textSize="14sp"
+ android:visibility="gone"
+ app:layout_constrainedWidth="true"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/song_title"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_goneMarginBottom="32dp"
+ tools:text="Beethoven" />
+
+</androidx.constraintlayout.widget.ConstraintLayout>
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 48c7582ed..f79dea1e7 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
@@ -143,6 +143,15 @@ internal class AudioPlayerAnimator : IAudioPlayerAnimator, LifecycleObserver {
hidePlaylistLandscapeConstraint.setVisibility(R.id.songs_list, View.GONE)
hidePlaylistLandscapeConstraint.setVisibility(R.id.cover_media_switcher, View.VISIBLE)
hidePlaylistLandscapeConstraint.setVisibility(R.id.track_info_container, View.VISIBLE)
+ if (audioPlayer.isTablet()) {
+ hidePlaylistLandscapeConstraint.constrainHeight(R.id.track_info_container, ConstraintSet.WRAP_CONTENT)
+ hidePlaylistLandscapeConstraint.setDimensionRatio(R.id.cover_media_switcher, null)
+ hidePlaylistLandscapeConstraint.connect(R.id.cover_media_switcher, ConstraintSet.TOP, R.id.header, ConstraintSet.BOTTOM)
+ hidePlaylistLandscapeConstraint.connect(R.id.cover_media_switcher, ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END)
+ hidePlaylistLandscapeConstraint.connect(R.id.track_info_container, ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START)
+ hidePlaylistLandscapeConstraint.connect(R.id.audio_play_progress, ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END)
+ hidePlaylistLandscapeConstraint.createVerticalChain(R.id.header, ConstraintSet.BOTTOM, R.id.time, ConstraintSet.TOP, arrayOf(R.id.cover_media_switcher, R.id.track_info_container, R.id.audio_play_progress).toIntArray(), null, ConstraintSet.CHAIN_PACKED)
+ }
}
/**
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/view/CoverMediaSwitcher.kt b/application/vlc-android/src/org/videolan/vlc/gui/view/CoverMediaSwitcher.kt
index c0c7c5a44..0ec6530b0 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/view/CoverMediaSwitcher.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/view/CoverMediaSwitcher.kt
@@ -43,7 +43,7 @@ class CoverMediaSwitcher(context: Context, attrs: AttributeSet) : AudioMediaSwit
val coverView = v.findViewById<ImageView>(R.id.cover)
val titleView = v.findViewById<TextView>(R.id.song_title)
val artistView = v.findViewById<TextView>(R.id.song_subtitle)
- val trackInfoView = v.findViewById<TextView>(R.id.song_track_info)
+ val trackInfoView = v.findViewById<TextView?>(R.id.song_track_info)
if (cover != null) {
coverView.setImageBitmap(cover)
@@ -51,14 +51,14 @@ class CoverMediaSwitcher(context: Context, attrs: AttributeSet) : AudioMediaSwit
coverView.setImageDrawable(ContextCompat.getDrawable(v.context, R.drawable.ic_player_cover_audiotrack))
}
- trackInfoView.visibility = if (Settings.showAudioTrackInfo) View.VISIBLE else View.GONE
+ trackInfoView?.visibility = if (Settings.showAudioTrackInfo) View.VISIBLE else View.GONE
titleView.setOnClickListener { onTextClicked() }
artistView.setOnClickListener { onTextClicked() }
titleView.text = title
artistView.text = artist
- trackInfoView.text = trackInfo
+ trackInfoView?.text = trackInfo
addView(v)
More information about the Android
mailing list