Add shuffle buttons to Detail Fragments

Add shuffle buttons to AlbumDetailFragment & ArtistDetailFragment.
This commit is contained in:
OxygenCobalt 2020-10-15 15:31:06 -06:00
parent c422071e93
commit 00667151dc
4 changed files with 54 additions and 6 deletions

View file

@ -79,7 +79,7 @@ class PlaybackViewModel : ViewModel() {
PlaybackMode.IN_ALBUM -> song.album PlaybackMode.IN_ALBUM -> song.album
} }
if (isShuffling.value!!) { if (mIsShuffling.value!!) {
genShuffle(true) genShuffle(true)
} else { } else {
resetShuffle() resetShuffle()
@ -100,6 +100,12 @@ class PlaybackViewModel : ViewModel() {
mCurrentParent.value = album mCurrentParent.value = album
mIsShuffling.value = isShuffled mIsShuffling.value = isShuffled
mCurrentMode.value = PlaybackMode.IN_ALBUM mCurrentMode.value = PlaybackMode.IN_ALBUM
if (mIsShuffling.value!!) {
genShuffle(false)
} else {
resetShuffle()
}
} }
fun play(artist: Artist, isShuffled: Boolean) { fun play(artist: Artist, isShuffled: Boolean) {
@ -114,6 +120,12 @@ class PlaybackViewModel : ViewModel() {
mCurrentParent.value = artist mCurrentParent.value = artist
mIsShuffling.value = isShuffled mIsShuffling.value = isShuffled
mCurrentMode.value = PlaybackMode.IN_ARTIST mCurrentMode.value = PlaybackMode.IN_ARTIST
if (mIsShuffling.value!!) {
genShuffle(false)
} else {
resetShuffle()
}
} }
// Update the current duration using a SeekBar progress // Update the current duration using a SeekBar progress

View file

@ -6,4 +6,4 @@
<solid android:color="@android:color/white" /> <solid android:color="@android:color/white" />
</shape> </shape>
</item> </item>
</ripple> </ripple>

View file

@ -65,6 +65,7 @@
android:layout_marginEnd="@dimen/margin_medium" android:layout_marginEnd="@dimen/margin_medium"
android:maxLines="1" android:maxLines="1"
android:text="@{album.name}" android:text="@{album.name}"
android:ellipsize="end"
app:autoSizeMaxTextSize="@dimen/text_size_header_max" app:autoSizeMaxTextSize="@dimen/text_size_header_max"
app:autoSizeMinTextSize="@dimen/text_size_min" app:autoSizeMinTextSize="@dimen/text_size_min"
app:autoSizeStepGranularity="@dimen/text_size_increment" app:autoSizeStepGranularity="@dimen/text_size_increment"
@ -108,12 +109,30 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_marginTop="@dimen/margin_tiny" android:layout_marginTop="@dimen/margin_tiny"
android:layout_marginEnd="@dimen/margin_medium" android:layout_marginEnd="@dimen/margin_tiny"
android:background="@drawable/ui_circular_button" android:background="@drawable/ui_circular_button"
android:backgroundTint="?android:attr/colorPrimary" android:backgroundTint="?android:attr/colorPrimary"
android:contentDescription="@string/description_play" android:contentDescription="@string/description_play"
android:src="@drawable/ic_play"
android:onClick="@{() -> playbackModel.play(album, false)}" android:onClick="@{() -> playbackModel.play(album, false)}"
android:src="@drawable/ic_play"
app:layout_constraintBottom_toBottomOf="@+id/album_details"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintEnd_toStartOf="@+id/album_shuffle"
app:layout_constraintTop_toTopOf="@+id/album_artist" />
<ImageButton
android:id="@+id/album_shuffle"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginEnd="@dimen/margin_medium"
android:layout_marginTop="@dimen/margin_tiny"
android:background="@drawable/ui_circular_button"
android:backgroundTint="?android:attr/colorPrimary"
android:contentDescription="@string/description_play"
android:onClick="@{() -> playbackModel.play(album, true)}"
android:src="@drawable/ic_shuffle_small"
android:tint="@color/background"
app:layout_constraintBottom_toBottomOf="@+id/album_details" app:layout_constraintBottom_toBottomOf="@+id/album_details"
app:layout_constraintDimensionRatio="1:1" app:layout_constraintDimensionRatio="1:1"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"

View file

@ -104,7 +104,7 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_marginTop="@dimen/margin_tiny" android:layout_marginTop="@dimen/margin_tiny"
android:layout_marginEnd="@dimen/margin_medium" android:layout_marginEnd="@dimen/margin_tiny"
android:background="@drawable/ui_circular_button" android:background="@drawable/ui_circular_button"
android:backgroundTint="?android:attr/colorPrimary" android:backgroundTint="?android:attr/colorPrimary"
android:contentDescription="@string/description_play" android:contentDescription="@string/description_play"
@ -112,6 +112,24 @@
android:onClick="@{() -> playbackModel.play(artist, false)}" android:onClick="@{() -> playbackModel.play(artist, false)}"
app:layout_constraintBottom_toBottomOf="@+id/artist_counts" app:layout_constraintBottom_toBottomOf="@+id/artist_counts"
app:layout_constraintDimensionRatio="1:1" app:layout_constraintDimensionRatio="1:1"
app:layout_constraintEnd_toStartOf="@+id/album_shuffle"
app:layout_constraintTop_toTopOf="@+id/artist_genre" />
<ImageButton
android:id="@+id/album_shuffle"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginEnd="@dimen/margin_medium"
android:layout_marginTop="@dimen/margin_tiny"
android:background="@drawable/ui_circular_button"
android:backgroundTint="?android:attr/colorPrimary"
android:contentDescription="@string/description_play"
android:onClick="@{() -> playbackModel.play(artist, true)}"
android:src="@drawable/ic_shuffle_small"
android:tint="@color/background"
app:layout_constraintBottom_toBottomOf="@+id/artist_counts"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/artist_genre" /> app:layout_constraintTop_toTopOf="@+id/artist_genre" />
@ -166,5 +184,4 @@
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView> </androidx.core.widget.NestedScrollView>
</LinearLayout> </LinearLayout>
</layout> </layout>