Twelve: AlbumFragment/ArtistFragment: More UI/UX improvements

Change-Id: Ib8fe8f97c05b55f6792c653f7e2e68573a8984cd
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 0d75337..4be5391 100644
--- a/app/src/main/java/org/lineageos/twelve/fragments/AlbumFragment.kt
+++ b/app/src/main/java/org/lineageos/twelve/fragments/AlbumFragment.kt
@@ -11,6 +11,7 @@
 import android.view.View
 import android.widget.ImageView
 import android.widget.LinearLayout
+import android.widget.TextView
 import androidx.core.os.bundleOf
 import androidx.core.view.isVisible
 import androidx.fragment.app.Fragment
@@ -49,11 +50,14 @@
 
     // Views
     private val appBarLayout by getViewProperty<AppBarLayout>(R.id.appBarLayout)
+    private val artistNameTextView by getViewProperty<TextView>(R.id.artistNameTextView)
     private val linearProgressIndicator by getViewProperty<LinearProgressIndicator>(R.id.linearProgressIndicator)
     private val noElementsLinearLayout by getViewProperty<LinearLayout>(R.id.noElementsLinearLayout)
     private val recyclerView by getViewProperty<RecyclerView>(R.id.recyclerView)
     private val thumbnailImageView by getViewProperty<ImageView>(R.id.thumbnailImageView)
     private val toolbar by getViewProperty<MaterialToolbar>(R.id.toolbar)
+    private val tracksInfoTextView by getViewProperty<TextView>(R.id.tracksInfoTextView)
+    private val yearTextView by getViewProperty<TextView>(R.id.yearTextView)
 
     // Recyclerview
     private val adapter by lazy {
@@ -140,6 +144,31 @@
                                 thumbnailImageView.setImageBitmap(album.thumbnail)
                             }
 
+                            artistNameTextView.text = album.artistName
+                            artistNameTextView.setOnClickListener {
+                                findNavController().navigate(
+                                    R.id.action_albumFragment_to_fragment_artist,
+                                    ArtistFragment.createBundle(album.artistUri)
+                                )
+                            }
+
+                            album.year?.also { year ->
+                                yearTextView.isVisible = true
+                                yearTextView.text = year.toString()
+                            } ?: run {
+                                yearTextView.isVisible = false
+                            }
+
+                            val totalDurationMs = audios.sumOf { audio ->
+                                audio.durationMs
+                            }
+                            val totalDurationMinutes = totalDurationMs / 1000 / 60
+
+                            tracksInfoTextView.text = getString(
+                                R.string.album_tracks_info,
+                                audios.size, totalDurationMinutes
+                            )
+
                             adapter.submitList(audios)
 
                             val isEmpty = audios.isEmpty()
diff --git a/app/src/main/res/color/textview_pressed.xml b/app/src/main/res/color/textview_pressed.xml
new file mode 100644
index 0000000..1f5b0f2
--- /dev/null
+++ b/app/src/main/res/color/textview_pressed.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+     SPDX-FileCopyrightText: 2024 The LineageOS Project
+     SPDX-License-Identifier: Apache-2.0
+-->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:color="?attr/colorControlHighlight" android:state_pressed="true" />
+    <item android:color="?attr/colorOnSurfaceVariant" />
+</selector>
diff --git a/app/src/main/res/layout/fragment_album.xml b/app/src/main/res/layout/fragment_album.xml
index ae7d523..e01cf1a 100644
--- a/app/src/main/res/layout/fragment_album.xml
+++ b/app/src/main/res/layout/fragment_album.xml
@@ -5,6 +5,7 @@
 -->
 <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">
@@ -20,7 +21,6 @@
             style="?attr/collapsingToolbarLayoutLargeStyle"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            app:expandedTitleMarginBottom="28dp"
             app:expandedTitleTextAppearance="?attr/textAppearanceHeadlineMedium"
             app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
             app:maxLines="3">
@@ -50,6 +50,17 @@
                     app:layout_constraintStart_toStartOf="parent"
                     app:layout_constraintTop_toTopOf="parent" />
 
+                <View
+                    android:layout_width="0dp"
+                    android:layout_height="0dp"
+                    android:alpha="0.4"
+                    android:background="?attr/colorSurface"
+                    android:fitsSystemWindows="true"
+                    app:layout_constraintBottom_toBottomOf="parent"
+                    app:layout_constraintEnd_toEndOf="parent"
+                    app:layout_constraintStart_toStartOf="parent"
+                    app:layout_constraintTop_toTopOf="parent" />
+
             </androidx.constraintlayout.widget.ConstraintLayout>
 
             <com.google.android.material.appbar.MaterialToolbar
@@ -58,7 +69,7 @@
                 android:layout_height="?attr/actionBarSize"
                 android:elevation="0dp"
                 app:layout_collapseMode="pin"
-                app:layout_scrollFlags="scroll|enterAlways|snap" />
+                tools:title="Sweet Revenge" />
 
         </com.google.android.material.appbar.CollapsingToolbarLayout>
 
@@ -74,29 +85,87 @@
             android:layout_width="match_parent"
             android:layout_height="match_parent">
 
-            <androidx.recyclerview.widget.RecyclerView
-                android:id="@+id/recyclerView"
+            <LinearLayout
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
-                android:visibility="gone"
-                app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
-                app:spanCount="1" />
+                android:orientation="vertical">
 
-            <LinearLayout
-                android:id="@+id/noElementsLinearLayout"
-                style="@style/Theme.Twelve.NoElements.LinearLayout"
-                android:layout_gravity="center">
+                <LinearLayout
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_marginHorizontal="16dp"
+                    android:orientation="vertical"
+                    android:paddingVertical="8dp">
 
-                <ImageView
-                    style="@style/Theme.Twelve.NoElements.ImageView"
-                    android:contentDescription="@string/no_audios"
-                    android:src="@drawable/ic_music_note" />
+                    <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" />
 
-                <Space style="@style/Theme.Twelve.NoElements.Space" />
+                    <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
-                    style="@style/Theme.Twelve.NoElements.TextView"
-                    android:text="@string/no_audios" />
+                    <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>
+
+                <FrameLayout
+                    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:visibility="gone"
+                        app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
+                        app:spanCount="1"
+                        tools:itemCount="7"
+                        tools:visibility="visible" />
+
+                    <LinearLayout
+                        android:id="@+id/noElementsLinearLayout"
+                        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>
+
+                </FrameLayout>
 
             </LinearLayout>
 
diff --git a/app/src/main/res/layout/fragment_artist.xml b/app/src/main/res/layout/fragment_artist.xml
index ebb6e1f..3e4a9e5 100644
--- a/app/src/main/res/layout/fragment_artist.xml
+++ b/app/src/main/res/layout/fragment_artist.xml
@@ -51,6 +51,17 @@
                     app:layout_constraintStart_toStartOf="parent"
                     app:layout_constraintTop_toTopOf="parent" />
 
+                <View
+                    android:layout_width="0dp"
+                    android:layout_height="0dp"
+                    android:alpha="0.4"
+                    android:background="?attr/colorSurface"
+                    android:fitsSystemWindows="true"
+                    app:layout_constraintBottom_toBottomOf="parent"
+                    app:layout_constraintEnd_toEndOf="parent"
+                    app:layout_constraintStart_toStartOf="parent"
+                    app:layout_constraintTop_toTopOf="parent" />
+
             </androidx.constraintlayout.widget.ConstraintLayout>
 
             <com.google.android.material.appbar.MaterialToolbar
@@ -59,7 +70,8 @@
                 android:layout_height="?attr/actionBarSize"
                 android:elevation="0dp"
                 app:layout_collapseMode="pin"
-                app:layout_scrollFlags="scroll|enterAlways|snap" />
+                app:layout_scrollFlags="scroll|enterAlways|snap"
+                tools:title="Ryuichi Sakamoto" />
 
         </com.google.android.material.appbar.CollapsingToolbarLayout>
 
diff --git a/app/src/main/res/navigation/fragment_album.xml b/app/src/main/res/navigation/fragment_album.xml
index 5d1cc9f..c3df8c7 100644
--- a/app/src/main/res/navigation/fragment_album.xml
+++ b/app/src/main/res/navigation/fragment_album.xml
@@ -15,6 +15,14 @@
         tools:layout="@layout/fragment_album">
 
         <action
+            android:id="@+id/action_albumFragment_to_fragment_artist"
+            app:destination="@+id/fragment_artist"
+            app:enterAnim="@anim/nav_default_enter_anim"
+            app:exitAnim="@anim/nav_default_exit_anim"
+            app:popEnterAnim="@anim/nav_default_pop_enter_anim"
+            app:popExitAnim="@anim/nav_default_pop_exit_anim" />
+
+        <action
             android:id="@+id/action_albumFragment_to_fragment_now_playing"
             app:destination="@+id/fragment_now_playing"
             app:enterAnim="@anim/nav_default_enter_anim"
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 44b19b2..b334dce 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -38,6 +38,9 @@
     <!-- Genres -->
     <string name="genre_unknown">Unknown</string>
 
+    <!-- Album fragment -->
+    <string name="album_tracks_info">%1$d tracks, %2$d minutes</string>
+
     <!-- Artist fragment -->
     <string name="artist_albums_header">Albums</string>
     <string name="artist_appears_in_album_header">Appears in album</string>