Twelve: Album fragment tablet UI
Change-Id: I84f5f0ce68654146fd2d33248875b7c714e9e58d
diff --git a/app/src/main/java/org/lineageos/twelve/fragments/AlbumFragment.kt b/app/src/main/java/org/lineageos/twelve/fragments/AlbumFragment.kt
index 0193b0f..a946bad 100644
--- a/app/src/main/java/org/lineageos/twelve/fragments/AlbumFragment.kt
+++ b/app/src/main/java/org/lineageos/twelve/fragments/AlbumFragment.kt
@@ -15,7 +15,6 @@
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.isVisible
-import androidx.core.view.updatePadding
import androidx.core.widget.NestedScrollView
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
@@ -34,6 +33,7 @@
import org.lineageos.twelve.ext.getParcelable
import org.lineageos.twelve.ext.getViewProperty
import org.lineageos.twelve.ext.setProgressCompat
+import org.lineageos.twelve.ext.updatePadding
import org.lineageos.twelve.models.Audio
import org.lineageos.twelve.models.RequestStatus
import org.lineageos.twelve.ui.recyclerview.SimpleListAdapter
@@ -54,6 +54,7 @@
// Views
private val albumTitleTextView by getViewProperty<TextView>(R.id.albumTitleTextView)
private val artistNameTextView by getViewProperty<TextView>(R.id.artistNameTextView)
+ private val infoNestedScrollView by getViewProperty<NestedScrollView?>(R.id.infoNestedScrollView)
private val linearProgressIndicator by getViewProperty<LinearProgressIndicator>(R.id.linearProgressIndicator)
private val noElementsNestedScrollView by getViewProperty<NestedScrollView>(R.id.noElementsNestedScrollView)
private val recyclerView by getViewProperty<RecyclerView>(R.id.recyclerView)
@@ -117,13 +118,37 @@
super.onViewCreated(view, savedInstanceState)
// Insets
+ ViewCompat.setOnApplyWindowInsetsListener(toolbar) { v, windowInsets ->
+ val insets = windowInsets.getInsets(WindowInsetsCompat.Type.displayCutout())
+
+ v.updatePadding(
+ insets,
+ start = true,
+ end = true,
+ )
+
+ windowInsets
+ }
+
+ infoNestedScrollView?.let {
+ ViewCompat.setOnApplyWindowInsetsListener(it) { v, windowInsets ->
+ val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())
+
+ v.updatePadding(
+ insets,
+ bottom = true,
+ )
+
+ windowInsets
+ }
+ }
+
ViewCompat.setOnApplyWindowInsetsListener(recyclerView) { v, windowInsets ->
val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())
v.updatePadding(
- left = insets.left,
- right = insets.right,
- bottom = insets.bottom,
+ insets,
+ bottom = true,
)
windowInsets
@@ -133,9 +158,8 @@
val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())
v.updatePadding(
- left = insets.left,
- right = insets.right,
- bottom = insets.bottom,
+ insets,
+ bottom = true,
)
windowInsets
diff --git a/app/src/main/res/layout-land/fragment_album.xml b/app/src/main/res/layout-land/fragment_album.xml
new file mode 100644
index 0000000..ce15464
--- /dev/null
+++ b/app/src/main/res/layout-land/fragment_album.xml
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ SPDX-FileCopyrightText: 2024 The LineageOS Project
+ SPDX-License-Identifier: Apache-2.0
+-->
+<androidx.coordinatorlayout.widget.CoordinatorLayout 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:fitsSystemWindows="true">
+
+ <com.google.android.material.appbar.AppBarLayout
+ android:id="@+id/appBarLayout"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:fitsSystemWindows="true"
+ app:liftOnScrollTargetViewId="@+id/recyclerView">
+
+ <com.google.android.material.appbar.MaterialToolbar
+ android:id="@+id/toolbar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ tools:title="Sweet Revenge" />
+
+ </com.google.android.material.appbar.AppBarLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:baselineAligned="false"
+ android:orientation="horizontal"
+ app:layout_behavior="@string/appbar_scrolling_view_behavior">
+
+ <androidx.core.widget.NestedScrollView
+ android:id="@+id/infoNestedScrollView"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:clipToPadding="false"
+ android:fillViewport="true">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:paddingHorizontal="32dp"
+ android:paddingVertical="8dp">
+
+ <com.google.android.material.card.MaterialCardView
+ style="@style/Widget.Material3.CardView.Elevated"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginVertical="16dp"
+ app:cardCornerRadius="16dp">
+
+ <androidx.constraintlayout.widget.ConstraintLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <ImageView
+ android:id="@+id/thumbnailImageView"
+ android:layout_width="0dp"
+ android:layout_height="0dp"
+ app:layout_constraintDimensionRatio="H,1:1"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent" />
+
+ </androidx.constraintlayout.widget.ConstraintLayout>
+
+ </com.google.android.material.card.MaterialCardView>
+
+ <include
+ layout="@layout/album_labels"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ </LinearLayout>
+
+ </androidx.core.widget.NestedScrollView>
+
+ <include
+ layout="@layout/album_content"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="2" />
+
+ </LinearLayout>
+
+ <com.google.android.material.progressindicator.LinearProgressIndicator
+ android:id="@+id/linearProgressIndicator"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:indeterminate="true"
+ app:layout_behavior="@string/appbar_scrolling_view_behavior" />
+
+</androidx.coordinatorlayout.widget.CoordinatorLayout>
diff --git a/app/src/main/res/layout/album_content.xml b/app/src/main/res/layout/album_content.xml
new file mode 100644
index 0000000..549b42c
--- /dev/null
+++ b/app/src/main/res/layout/album_content.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ SPDX-FileCopyrightText: 2024 The LineageOS Project
+ SPDX-License-Identifier: Apache-2.0
+-->
+<FrameLayout 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">
+
+ <androidx.recyclerview.widget.RecyclerView
+ android:id="@+id/recyclerView"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:clipToPadding="false"
+ android:visibility="gone"
+ app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
+ app:spanCount="1"
+ tools:itemCount="7"
+ tools:visibility="visible" />
+
+ <androidx.core.widget.NestedScrollView
+ android:id="@+id/noElementsNestedScrollView"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:clipToPadding="false"
+ android:visibility="gone">
+
+ <LinearLayout
+ style="@style/Theme.Twelve.NoElements.LinearLayout"
+ android:layout_gravity="center">
+
+ <ImageView
+ style="@style/Theme.Twelve.NoElements.ImageView"
+ android:contentDescription="@string/no_audios"
+ android:src="@drawable/ic_music_note" />
+
+ <Space style="@style/Theme.Twelve.NoElements.Space" />
+
+ <TextView
+ style="@style/Theme.Twelve.NoElements.TextView"
+ android:text="@string/no_audios" />
+
+ </LinearLayout>
+
+ </androidx.core.widget.NestedScrollView>
+
+</FrameLayout>
diff --git a/app/src/main/res/layout/album_labels.xml b/app/src/main/res/layout/album_labels.xml
new file mode 100644
index 0000000..18aa3de
--- /dev/null
+++ b/app/src/main/res/layout/album_labels.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ SPDX-FileCopyrightText: 2024 The LineageOS Project
+ SPDX-License-Identifier: Apache-2.0
+-->
+<LinearLayout 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:orientation="vertical">
+
+ <TextView
+ android:id="@+id/albumTitleTextView"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="8dp"
+ android:textAppearance="?attr/textAppearanceHeadlineMedium"
+ tools:text="Sweet Revenge" />
+
+ <TextView
+ android:id="@+id/artistNameTextView"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:drawablePadding="8dp"
+ android:gravity="center_vertical"
+ android:paddingVertical="4dp"
+ android:paddingStart="0dp"
+ android:paddingEnd="4dp"
+ android:textAppearance="?attr/textAppearanceLabelLarge"
+ android:textColor="@color/textview_pressed"
+ app:backgroundTint="@android:color/transparent"
+ app:drawableStartCompat="@drawable/ic_person"
+ app:drawableTint="@color/textview_pressed"
+ tools:text="Ryuichi Sakamoto" />
+
+ <TextView
+ android:id="@+id/yearTextView"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:textAppearance="?attr/textAppearanceLabelLarge"
+ android:textColor="?attr/colorOnSurfaceVariant"
+ android:visibility="gone"
+ tools:text="1994"
+ tools:visibility="visible" />
+
+ <TextView
+ android:id="@+id/tracksInfoTextView"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:textAppearance="?attr/textAppearanceLabelLarge"
+ android:textColor="?attr/colorOnSurfaceVariant"
+ tools:text="7 tracks, 51 minutes" />
+
+</LinearLayout>
diff --git a/app/src/main/res/layout/fragment_album.xml b/app/src/main/res/layout/fragment_album.xml
index b4f0ff9..fa0ff2b 100644
--- a/app/src/main/res/layout/fragment_album.xml
+++ b/app/src/main/res/layout/fragment_album.xml
@@ -63,57 +63,13 @@
</androidx.constraintlayout.widget.ConstraintLayout>
- <LinearLayout
+ <include
+ layout="@layout/album_labels"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
- android:layout_marginHorizontal="16dp"
- android:layout_marginVertical="8dp"
- android:orientation="vertical">
-
- <TextView
- android:id="@+id/albumTitleTextView"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginBottom="8dp"
- android:textAppearance="?attr/textAppearanceHeadlineMedium"
- tools:text="Sweet Revenge" />
-
- <TextView
- android:id="@+id/artistNameTextView"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:drawablePadding="8dp"
- android:gravity="center_vertical"
- android:paddingVertical="4dp"
- android:paddingStart="0dp"
- android:paddingEnd="4dp"
- android:textAppearance="?attr/textAppearanceLabelLarge"
- android:textColor="@color/textview_pressed"
- app:backgroundTint="@android:color/transparent"
- app:drawableStartCompat="@drawable/ic_person"
- app:drawableTint="@color/textview_pressed"
- tools:text="Ryuichi Sakamoto" />
-
- <TextView
- android:id="@+id/yearTextView"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="?attr/textAppearanceLabelLarge"
- android:textColor="?attr/colorOnSurfaceVariant"
- android:visibility="gone"
- tools:text="1994"
- tools:visibility="visible" />
-
- <TextView
- android:id="@+id/tracksInfoTextView"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="?attr/textAppearanceLabelLarge"
- android:textColor="?attr/colorOnSurfaceVariant"
- tools:text="7 tracks, 51 minutes" />
-
- </LinearLayout>
+ android:layout_marginBottom="8dp"
+ android:layout_marginHorizontal="16dp" />
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
@@ -127,44 +83,11 @@
</com.google.android.material.appbar.AppBarLayout>
- <androidx.recyclerview.widget.RecyclerView
- android:id="@+id/recyclerView"
+ <include
+ layout="@layout/album_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:clipToPadding="false"
- android:visibility="gone"
- app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
- app:layout_behavior="@string/appbar_scrolling_view_behavior"
- app:spanCount="1"
- tools:itemCount="7"
- tools:visibility="visible" />
-
- <androidx.core.widget.NestedScrollView
- android:id="@+id/noElementsNestedScrollView"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:clipToPadding="false"
- android:visibility="gone"
- app:layout_behavior="@string/appbar_scrolling_view_behavior">
-
- <LinearLayout
- style="@style/Theme.Twelve.NoElements.LinearLayout"
- android:layout_gravity="center">
-
- <ImageView
- style="@style/Theme.Twelve.NoElements.ImageView"
- android:contentDescription="@string/no_audios"
- android:src="@drawable/ic_music_note" />
-
- <Space style="@style/Theme.Twelve.NoElements.Space" />
-
- <TextView
- style="@style/Theme.Twelve.NoElements.TextView"
- android:text="@string/no_audios" />
-
- </LinearLayout>
-
- </androidx.core.widget.NestedScrollView>
+ app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/linearProgressIndicator"