diff --git a/app/src/main/java/code/name/monkey/retromusic/extensions/ColorExt.kt b/app/src/main/java/code/name/monkey/retromusic/extensions/ColorExt.kt index c15a821a..b00bb940 100644 --- a/app/src/main/java/code/name/monkey/retromusic/extensions/ColorExt.kt +++ b/app/src/main/java/code/name/monkey/retromusic/extensions/ColorExt.kt @@ -128,10 +128,8 @@ fun ExtendedFloatingActionButton.accentColor() { fun FloatingActionButton.accentColor() { val color = ThemeStore.accentColor(context) val textColor = MaterialValueHelper.getPrimaryTextColor(context, ColorUtil.isColorLight(color)) - val colorStateList = ColorStateList.valueOf(color) - val textColorStateList = ColorStateList.valueOf(textColor) - backgroundTintList = colorStateList - imageTintList = textColorStateList + backgroundTintList = ColorStateList.valueOf(color) + imageTintList = ColorStateList.valueOf(textColor) } fun MaterialButton.applyColor(color: Int) { diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumsFragment.kt index 11f77971..907ce38b 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumsFragment.kt @@ -27,10 +27,12 @@ import code.name.monkey.retromusic.adapter.album.AlbumAdapter import code.name.monkey.retromusic.extensions.surfaceColor import code.name.monkey.retromusic.fragments.ReloadType import code.name.monkey.retromusic.fragments.base.AbsRecyclerViewCustomGridSizeFragment +import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.SortOrder.AlbumSortOrder import code.name.monkey.retromusic.interfaces.IAlbumClickListener import code.name.monkey.retromusic.interfaces.ICabCallback import code.name.monkey.retromusic.interfaces.ICabHolder +import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.RetroColorUtil import code.name.monkey.retromusic.util.RetroUtil @@ -65,6 +67,20 @@ class AlbumsFragment : AbsRecyclerViewCustomGridSizeFragment album.songs }, + startPosition = 0, + startPlaying = true + ) + } + } + override fun createLayoutManager(): GridLayoutManager { return GridLayoutManager(requireActivity(), getGridSize()) } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/artists/ArtistsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/artists/ArtistsFragment.kt index c96d9c2f..60e7d85e 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/artists/ArtistsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/artists/ArtistsFragment.kt @@ -28,11 +28,13 @@ import code.name.monkey.retromusic.adapter.artist.ArtistAdapter import code.name.monkey.retromusic.extensions.surfaceColor import code.name.monkey.retromusic.fragments.ReloadType import code.name.monkey.retromusic.fragments.base.AbsRecyclerViewCustomGridSizeFragment +import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.SortOrder.ArtistSortOrder import code.name.monkey.retromusic.interfaces.IAlbumArtistClickListener import code.name.monkey.retromusic.interfaces.IArtistClickListener import code.name.monkey.retromusic.interfaces.ICabCallback import code.name.monkey.retromusic.interfaces.ICabHolder +import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.RetroColorUtil import code.name.monkey.retromusic.util.RetroUtil @@ -62,9 +64,24 @@ class ArtistsFragment : AbsRecyclerViewCustomGridSizeFragment artist.songs }, + startPosition = 0, + startPlaying = true + ) + } + } + override fun setSortOrder(sortOrder: String) { libraryViewModel.forceReload(ReloadType.Artists) } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsRecyclerViewFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsRecyclerViewFragment.kt index 066dad98..a9fa457c 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsRecyclerViewFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsRecyclerViewFragment.kt @@ -21,6 +21,7 @@ import androidx.annotation.StringRes import androidx.appcompat.widget.Toolbar import androidx.coordinatorlayout.widget.CoordinatorLayout import androidx.core.view.doOnPreDraw +import androidx.core.view.isVisible import androidx.core.view.updatePadding import androidx.navigation.fragment.findNavController import androidx.recyclerview.widget.RecyclerView @@ -30,6 +31,7 @@ import code.name.monkey.retromusic.R import code.name.monkey.retromusic.databinding.FragmentMainRecyclerBinding import code.name.monkey.retromusic.dialogs.CreatePlaylistDialog import code.name.monkey.retromusic.dialogs.ImportPlaylistDialog +import code.name.monkey.retromusic.extensions.accentColor import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.util.DensityUtil import code.name.monkey.retromusic.util.ThemedFastScroller.create @@ -45,6 +47,8 @@ abstract class AbsRecyclerViewFragment, LM : Recycle private val binding get() = _binding!! protected var adapter: A? = null protected var layoutManager: LM? = null + val shuffleButton get() = binding.shuffleButton + abstract val isShuffleVisible: Boolean override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) @@ -60,6 +64,30 @@ abstract class AbsRecyclerViewFragment, LM : Recycle setupToolbar() binding.appBarLayout.statusBarForeground = MaterialShapeDrawable.createWithElevationOverlay(requireContext()) + + // Add listeners when shuffle is visible + if (isShuffleVisible) { + binding.recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() { + override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { + super.onScrolled(recyclerView, dx, dy) + if (dy > 0) { + binding.shuffleButton.hide() + } else if (dy < 0) { + binding.shuffleButton.show() + } + + } + }) + binding.shuffleButton.setOnClickListener { + onShuffleClicked() + } + binding.shuffleButton.accentColor() + } else { + binding.shuffleButton.isVisible = false + } + } + + open fun onShuffleClicked() { } fun toolbar(): Toolbar { diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/genres/GenresFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/genres/GenresFragment.kt index de1cb4d6..b588553b 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/genres/GenresFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/genres/GenresFragment.kt @@ -82,6 +82,9 @@ GenresFragment : AbsRecyclerViewFragment(), override val emptyMessage: Int get() = R.string.no_genres + override val isShuffleVisible: Boolean + get() = false + companion object { @JvmField val TAG: String = GenresFragment::class.java.simpleName diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/playlists/PlaylistsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/playlists/PlaylistsFragment.kt index 9a4880fe..500d8f7f 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/playlists/PlaylistsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/playlists/PlaylistsFragment.kt @@ -48,9 +48,13 @@ class PlaylistsFragment : override val titleRes: Int get() = R.string.playlists + override val emptyMessage: Int get() = R.string.no_playlists + override val isShuffleVisible: Boolean + get() = false + override fun createLayoutManager(): GridLayoutManager { return GridLayoutManager(requireContext(), getGridSize()) } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/queue/PlayingQueueFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/queue/PlayingQueueFragment.kt index c8a218c7..01098567 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/queue/PlayingQueueFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/queue/PlayingQueueFragment.kt @@ -40,6 +40,8 @@ class PlayingQueueFragment : AbsRecyclerViewFragment + + \ No newline at end of file