Add play/pause controls

Add play/pause controls to the playback fragments.
This commit is contained in:
OxygenCobalt
2020-10-11 11:03:06 -06:00
parent 0c069dfbac
commit eb6839b10c
33 changed files with 207 additions and 60 deletions
+11
View File
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="30dp"
android:height="30dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="@color/control_color">
<path
android:fillColor="@android:color/white"
android:pathData="M6,19h4L10,5L6,5v14zM14,5v14h4L18,5h-4z" />
</vector>
+12
View File
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="30dp"
android:height="30dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="@color/control_color">
<path
android:name="play"
android:fillColor="@android:color/white"
android:pathData="M8,5v14l11,-7z" />
</vector>
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/selection_color">
<item>
<shape android:shape="oval">
<solid android:color="@android:color/white" />
</shape>
</item>
</ripple>
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?><!--
Custom cursor shape that reflects the current accent color.
Custom ui_cursor shape that reflects the current accent color.
https://stackoverflow.com/a/28311351/14143986
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="oval">
<solid android:color="?android:attr/colorPrimary" />
</shape>
</item>
</selector>
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/selection_color"
android:radius="24dp" />
@@ -103,7 +103,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/padding_medium"
android:background="@drawable/header_dividers"
android:background="@drawable/ui_header_dividers"
android:fontFamily="@font/inter_bold"
android:paddingStart="@dimen/padding_medium"
android:paddingTop="@dimen/padding_small"
@@ -119,7 +119,7 @@
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="@dimen/margin_medium"
android:background="@drawable/header_dividers"
android:background="@drawable/ui_header_dividers"
android:contentDescription="@string/description_sort_button"
android:paddingStart="@dimen/padding_medium"
android:paddingTop="@dimen/padding_small"
@@ -100,7 +100,7 @@
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="@dimen/margin_medium"
android:background="@drawable/header_dividers"
android:background="@drawable/ui_header_dividers"
android:fontFamily="@font/inter_bold"
android:paddingStart="@dimen/padding_medium"
android:paddingTop="@dimen/padding_small"
@@ -117,7 +117,7 @@
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="@dimen/margin_medium"
android:background="@drawable/header_dividers"
android:background="@drawable/ui_header_dividers"
android:contentDescription="@string/description_sort_button"
android:paddingStart="@dimen/padding_medium"
android:paddingTop="@dimen/padding_small"
@@ -9,18 +9,22 @@
<variable
name="song"
type="org.oxycblt.auxio.music.Song" />
<variable
name="playbackModel"
type="org.oxycblt.auxio.playback.PlaybackViewModel" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:animateLayoutChanges="true"
android:background="@drawable/ripple"
android:background="@drawable/ui_ripple"
android:clickable="true"
android:focusable="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ProgressBar
android:id="@+id/song_progress"
android:id="@+id/playback_progress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="@dimen/playback_progress_size"
@@ -32,7 +36,7 @@
tools:progress="70" />
<ImageView
android:id="@+id/album_cover"
android:id="@+id/playback_cover"
android:layout_width="@dimen/cover_size_compact"
android:layout_height="@dimen/cover_size_compact"
android:contentDescription="@{@string/description_album_cover(song.name)}"
@@ -40,42 +44,58 @@
app:coverArt="@{song}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/song_progress"
app:layout_constraintTop_toBottomOf="@+id/playback_progress"
tools:src="@drawable/ic_song" />
<TextView
android:id="@+id/song_name"
android:id="@+id/playback_song"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:fontFamily="@font/inter_semibold"
android:text="@{song.name}"
android:layout_marginStart="@dimen/margin_smallish"
android:textAppearance="@style/TextAppearance.SmallHeader"
android:singleLine="true"
android:layout_marginEnd="@dimen/margin_smallish"
android:ellipsize="marquee"
android:fontFamily="@font/inter_semibold"
android:marqueeRepeatLimit="marquee_forever"
app:layout_constraintBottom_toTopOf="@+id/song_info"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/album_cover"
android:singleLine="true"
android:text="@{song.name}"
android:textAppearance="@style/TextAppearance.SmallHeader"
app:layout_constraintBottom_toTopOf="@+id/playback_info"
app:layout_constraintEnd_toStartOf="@+id/playback_controls"
app:layout_constraintStart_toEndOf="@+id/playback_cover"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed"
tools:text="Song Name" />
<TextView
android:id="@+id/song_info"
android:id="@+id/playback_info"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_smallish"
android:layout_marginEnd="@dimen/margin_smallish"
android:ellipsize="marquee"
android:singleLine="true"
android:marqueeRepeatLimit="marquee_forever"
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption"
android:singleLine="true"
android:text="@{@string/format_info(song.album.artist.name, song.album.name)}"
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/playback_controls"
app:layout_constraintStart_toEndOf="@+id/playback_cover"
app:layout_constraintTop_toBottomOf="@+id/playback_song"
tools:text="Artist Name / Album Name" />
<ImageButton
android:id="@+id/playback_controls"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_marginEnd="@dimen/margin_smallish"
android:contentDescription="@{playbackModel.isPlaying ? @string/description_pause : @string/description_play}"
android:layout_width="@dimen/controls_size_compact"
android:layout_height="@dimen/controls_size_compact"
android:background="@drawable/ui_unbounded_ripple"
android:onClick="@{() -> playbackModel.invertPlayingStatus()}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/album_cover"
app:layout_constraintTop_toBottomOf="@+id/song_name"
tools:text="Artist Name / Album Name" />
app:layout_constraintTop_toTopOf="parent"
tools:src="@drawable/ic_play" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
@@ -100,7 +100,7 @@
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="@dimen/margin_medium"
android:background="@drawable/header_dividers"
android:background="@drawable/ui_header_dividers"
android:fontFamily="@font/inter_bold"
android:paddingStart="@dimen/padding_medium"
android:paddingTop="@dimen/padding_small"
@@ -117,7 +117,7 @@
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="@dimen/margin_medium"
android:background="@drawable/header_dividers"
android:background="@drawable/ui_header_dividers"
android:contentDescription="@string/description_sort_button"
android:paddingStart="@dimen/padding_medium"
android:paddingTop="@dimen/padding_small"
+1 -1
View File
@@ -34,7 +34,7 @@
app:tabGravity="fill"
app:tabIconTint="?android:attr/colorPrimary"
app:tabIconTintMode="src_in"
app:tabIndicator="@drawable/indicator"
app:tabIndicator="@drawable/ui_indicator"
app:tabIndicatorColor="?android:attr/colorPrimary"
app:tabMode="fixed"
app:tabRippleColor="@color/selection_color"
+45 -18
View File
@@ -8,17 +8,22 @@
<variable
name="song"
type="org.oxycblt.auxio.music.Song" />
<variable
name="playbackModel"
type="org.oxycblt.auxio.playback.PlaybackViewModel" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/playback_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/background"
android:padding="@dimen/padding_medium"
android:theme="@style/ThemeOverlay.AppCompat.DayNight">
android:theme="@style/ThemeOverlay.AppCompat.DayNight"
android:padding="@dimen/padding_medium">
<ImageView
android:id="@+id/album_cover"
android:id="@+id/playback_cover"
android:layout_width="@dimen/cover_size_playback"
android:layout_height="@dimen/cover_size_playback"
android:contentDescription="@{@string/description_album_cover(song.name)}"
@@ -29,7 +34,7 @@
tools:src="@drawable/ic_song" />
<TextView
android:id="@+id/song_name"
android:id="@+id/playback_song"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_medium"
@@ -40,32 +45,33 @@
android:focusable="true"
android:text="@{song.name}"
android:textAppearance="@style/TextAppearance.MaterialComponents.Headline6"
app:layout_constraintBottom_toTopOf="@+id/song_artist"
app:layout_constraintBottom_toTopOf="@+id/playback_artist"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/album_cover"
app:layout_constraintStart_toEndOf="@+id/playback_cover"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed"
tools:text="Song Name" />
<TextView
android:id="@+id/song_artist"
android:id="@+id/playback_artist"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_medium"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true"
android:text="@{song.album.artist.name}"
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1"
android:textColor="?android:attr/textColorSecondary"
app:layout_constraintBottom_toTopOf="@+id/song_album"
app:layout_constraintBottom_toTopOf="@+id/playback_album"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/album_cover"
app:layout_constraintTop_toBottomOf="@+id/song_name"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="@+id/playback_cover"
app:layout_constraintTop_toBottomOf="@+id/playback_song"
tools:text="Artist Name" />
<TextView
android:id="@+id/song_album"
android:id="@+id/playback_album"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_medium"
@@ -75,24 +81,45 @@
android:text="@{song.album.name}"
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1"
android:textColor="?android:attr/textColorSecondary"
app:layout_constraintBottom_toBottomOf="@+id/album_cover"
app:layout_constraintBottom_toBottomOf="@+id/playback_cover"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/album_cover"
app:layout_constraintTop_toBottomOf="@+id/song_artist"
app:layout_constraintStart_toEndOf="@+id/playback_cover"
app:layout_constraintTop_toBottomOf="@+id/playback_artist"
tools:text="Album Name" />
<SeekBar
android:id="@+id/song_seek_bar"
android:id="@+id/playback_seek_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_medium"
android:paddingStart="6dp"
android:paddingEnd="6dp"
android:thumbTint="?android:attr/colorPrimary"
android:splitTrack="false"
android:progressBackgroundTint="?android:attr/colorControlNormal"
android:progressTint="?android:attr/colorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/playback_cover"
tools:progress="70" />
<ImageButton
android:id="@+id/playback_play_pause"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_marginTop="@dimen/margin_medium"
android:layout_marginBottom="160dp"
android:layout_marginBottom="@dimen/margin_medium"
android:background="@drawable/ui_circular_button"
android:contentDescription="@{playbackModel.isPlaying ? @string/description_pause : @string/description_play}"
android:foregroundTint="@color/background"
android:onClick="@{() -> playbackModel.invertPlayingStatus()}"
android:tint="@color/background"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/album_cover" />
app:layout_constraintTop_toBottomOf="@+id/playback_seek_bar"
android:backgroundTint="?android:attr/colorPrimary"
tools:src="@drawable/ic_play" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
+1 -1
View File
@@ -14,7 +14,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple"
android:background="@drawable/ui_ripple"
android:clickable="true"
android:focusable="true"
android:padding="@dimen/padding_medium">
+1 -1
View File
@@ -14,7 +14,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple"
android:background="@drawable/ui_ripple"
android:clickable="true"
android:focusable="true"
android:padding="@dimen/padding_medium">
+1 -1
View File
@@ -14,7 +14,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple"
android:background="@drawable/ui_ripple"
android:clickable="true"
android:focusable="true"
android:padding="@dimen/padding_medium">
@@ -14,7 +14,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple"
android:background="@drawable/ui_ripple"
android:clickable="true"
android:focusable="true"
android:padding="@dimen/padding_medium">
+1 -1
View File
@@ -14,7 +14,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple"
android:background="@drawable/ui_ripple"
android:clickable="true"
android:focusable="true"
android:padding="@dimen/padding_medium">
@@ -14,7 +14,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple"
android:background="@drawable/ui_ripple"
android:clickable="true"
android:focusable="true"
android:padding="@dimen/padding_medium">
+1 -1
View File
@@ -19,7 +19,7 @@
android:id="@+id/header_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/header_dividers"
android:background="@drawable/ui_header_dividers"
android:fontFamily="@font/inter_bold"
android:paddingStart="@dimen/padding_medium"
android:paddingTop="@dimen/padding_small"
+1 -1
View File
@@ -14,7 +14,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple"
android:background="@drawable/ui_ripple"
android:clickable="true"
android:focusable="true"
android:padding="@dimen/padding_medium">
+4
View File
@@ -7,6 +7,7 @@
<dimen name="margin_small">8dp</dimen>
<dimen name="margin_smallish">10dp</dimen>
<dimen name="margin_medium">16dp</dimen>
<dimen name="margin_large">24dp</dimen>
<dimen name="status_icon_size">48dp</dimen>
@@ -31,5 +32,8 @@
<dimen name="playback_progress_size">2dp</dimen>
<dimen name="controls_size">70dp</dimen>
<dimen name="controls_size_compact">36dp</dimen>
<dimen name="elevation_normal">4dp</dimen>
</resources>
+2
View File
@@ -36,6 +36,8 @@
<string name="description_sort_none">Default Sort Order</string>
<string name="description_sort_alpha_down">Sort from A to Z</string>
<string name="description_sort_alpha_up">Sort from Z to A</string>
<string name="description_play">Play</string>
<string name="description_pause">Pause</string>
<!-- Placeholder Namespace | Placeholder values -->
<string name="placeholder_genre">Unknown Genre</string>
+3 -1
View File
@@ -5,7 +5,7 @@
<item name="android:windowBackground">@color/background</item>
<item name="android:statusBarColor">@android:color/black</item>
<item name="android:fontFamily">@font/inter</item>
<item name="android:textCursorDrawable">@drawable/cursor</item>
<item name="android:textCursorDrawable">@drawable/ui_cursor</item>
<item name="actionBarPopupTheme">@style/AppThemeOverlay.Popup</item>
</style>
@@ -35,4 +35,6 @@
<item name="android:colorBackground">@color/background</item>
<item name="colorControlHighlight">@color/selection_color</item>
</style>
<style name="Theme.BottomSheet" parent="Theme.Design.BottomSheetDialog" />
</resources>