diff --git a/app/build.gradle b/app/build.gradle index f3534243..4df52f8a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -24,8 +24,8 @@ android { vectorDrawables.useSupportLibrary = true applicationId "code.name.monkey.retromusic" - versionCode 423 - versionName '3.5.120' + versionCode 424 + versionName '3.5.200' multiDexEnabled true diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/AlbumDetailsActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/AlbumDetailsActivity.kt index 7ea2f661..fbb0fe18 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/AlbumDetailsActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/AlbumDetailsActivity.kt @@ -88,7 +88,6 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C slide.excludeTarget(R.id.status_bar, true) slide.excludeTarget(android.R.id.statusBarBackground, true) slide.excludeTarget(android.R.id.navigationBarBackground, true) - window.enterTransition = slide } @@ -348,7 +347,8 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C R.id.action_sort_order_title -> sortOrder = AlbumSongSortOrder.SONG_A_Z R.id.action_sort_order_title_desc -> sortOrder = AlbumSongSortOrder.SONG_Z_A R.id.action_sort_order_track_list -> sortOrder = AlbumSongSortOrder.SONG_TRACK_LIST - R.id.action_sort_order_artist_song_duration -> sortOrder = AlbumSongSortOrder.SONG_DURATION + R.id.action_sort_order_artist_song_duration -> + sortOrder = AlbumSongSortOrder.SONG_DURATION } if (sortOrder != null) { item.isChecked = true @@ -364,8 +364,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C AlbumSongSortOrder.SONG_Z_A -> sortOrder.findItem(R.id.action_sort_order_title_desc) .isChecked = true AlbumSongSortOrder.SONG_TRACK_LIST -> sortOrder.findItem(R.id.action_sort_order_track_list) - .isChecked = - true + .isChecked = true AlbumSongSortOrder.SONG_DURATION -> sortOrder.findItem(R.id.action_sort_order_artist_song_duration) .isChecked = true } @@ -373,7 +372,29 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C private fun setSaveSortOrder(sortOrder: String?) { PreferenceUtil.getInstance(this).albumDetailSongSortOrder = sortOrder - reload() + when (sortOrder) { + AlbumSongSortOrder.SONG_TRACK_LIST -> album.songs?.sortWith(Comparator { o1, o2 -> + o1.trackNumber.compareTo( + o2.trackNumber + ) + }) + AlbumSongSortOrder.SONG_A_Z -> album.songs?.sortWith(Comparator { o1, o2 -> + o1.title.compareTo( + o2.title + ) + }) + AlbumSongSortOrder.SONG_Z_A -> album.songs?.sortWith(Comparator { o1, o2 -> + o2.title.compareTo( + o1.title + ) + }) + AlbumSongSortOrder.SONG_DURATION -> album.songs?.sortWith(Comparator { o1, o2 -> + o1.duration.compareTo( + o2.duration + ) + }) + } + album.songs?.let { simpleSongAdapter.swapDataSet(it) } } override fun onMediaStoreChanged() { diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/PlaylistDetailActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/PlaylistDetailActivity.kt index 4541ecb5..2026237a 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/PlaylistDetailActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/PlaylistDetailActivity.kt @@ -185,7 +185,7 @@ class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, Playli } private fun setToolbarTitle(title: String) { - supportActionBar!!.title = title + supportActionBar?.title = title } private fun checkForPadding() { diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/HomeAdapter.kt b/app/src/main/java/code/name/monkey/retromusic/adapter/HomeAdapter.kt index c186a14b..bd7a6a56 100644 --- a/app/src/main/java/code/name/monkey/retromusic/adapter/HomeAdapter.kt +++ b/app/src/main/java/code/name/monkey/retromusic/adapter/HomeAdapter.kt @@ -113,16 +113,16 @@ class HomeAdapter( inner class ArtistViewHolder(view: View) : AbsHomeViewItem(view) { fun bindView(list: ArrayList, titleRes: Int) { if (list.isNotEmpty()) { + val manager = LinearLayoutManager(activity, LinearLayoutManager.HORIZONTAL, false) + val artistAdapter = ArtistAdapter( + activity, + list, + PreferenceUtil.getInstance(activity).getHomeGridStyle(activity), + null + ) recyclerView.apply { show() - layoutManager = - LinearLayoutManager(activity, LinearLayoutManager.HORIZONTAL, false) - val artistAdapter = ArtistAdapter( - activity, - list, - PreferenceUtil.getInstance(activity).getHomeGridStyle(activity), - null - ) + layoutManager = manager adapter = artistAdapter } title.text = activity.getString(titleRes) diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/album/AlbumFullWidthAdapter.kt b/app/src/main/java/code/name/monkey/retromusic/adapter/album/AlbumFullWidthAdapter.kt index 0bea5f5b..9986fe28 100644 --- a/app/src/main/java/code/name/monkey/retromusic/adapter/album/AlbumFullWidthAdapter.kt +++ b/app/src/main/java/code/name/monkey/retromusic/adapter/album/AlbumFullWidthAdapter.kt @@ -77,6 +77,7 @@ class AlbumFullWidthAdapter( if (holder.image == null) { return } + AlbumGlideRequest.Builder.from(Glide.with(activity), album.safeGetFirstSong()) .checkIgnoreMediaStore(activity) .generatePalette(activity) diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/base/MediaEntryViewHolder.java b/app/src/main/java/code/name/monkey/retromusic/adapter/base/MediaEntryViewHolder.java index 42a76d01..ddf99c21 100644 --- a/app/src/main/java/code/name/monkey/retromusic/adapter/base/MediaEntryViewHolder.java +++ b/app/src/main/java/code/name/monkey/retromusic/adapter/base/MediaEntryViewHolder.java @@ -41,6 +41,8 @@ public class MediaEntryViewHolder extends AbstractDraggableSwipeableItemViewHold @Nullable public ImageView image; + @Nullable + public ImageView artistImage; @Nullable public ImageView playerImage; @@ -87,6 +89,7 @@ public class MediaEntryViewHolder extends AbstractDraggableSwipeableItemViewHold text = itemView.findViewById(R.id.text); image = itemView.findViewById(R.id.image); + artistImage = itemView.findViewById(R.id.artistImage); playerImage = itemView.findViewById(R.id.player_image); time = itemView.findViewById(R.id.time); diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/adaptive/AdaptiveFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/adaptive/AdaptiveFragment.kt index 8a0d96d7..4453d728 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/adaptive/AdaptiveFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/adaptive/AdaptiveFragment.kt @@ -196,8 +196,8 @@ class AdaptiveFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Call } override fun onColorChanged(color: MediaNotificationProcessor) { - playbackControlsFragment.setDark(color.backgroundColor) - lastColor = color.backgroundColor + playbackControlsFragment.setDark(color.primaryTextColor) + lastColor = color.primaryTextColor callbacks?.onPaletteColorChanged() ToolbarContentTintHelper.colorizeToolbar( playerToolbar, diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/card/CardFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/card/CardFragment.kt index f44721b3..011bc12b 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/card/CardFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/card/CardFragment.kt @@ -45,10 +45,9 @@ class CardFragment : AbsPlayerFragment() { } override fun onColorChanged(color: MediaNotificationProcessor) { - playbackControlsFragment.setDark(color.backgroundColor) - lastColor = color.backgroundColor - callbacks!!.onPaletteColorChanged() - + playbackControlsFragment.setDark(color.primaryTextColor) + lastColor = color.primaryTextColor + callbacks?.onPaletteColorChanged() ToolbarContentTintHelper.colorizeToolbar(playerToolbar, Color.WHITE, activity) } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/circle/CirclePlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/circle/CirclePlayerFragment.kt index f433c7d2..e6e2d7d8 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/circle/CirclePlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/circle/CirclePlayerFragment.kt @@ -129,7 +129,7 @@ class CirclePlayerFragment : AbsPlayerFragment(), Callback, OnAudioVolumeChanged if (audioVolumeObserver == null) { audioVolumeObserver = AudioVolumeObserver(requireActivity()) } - audioVolumeObserver!!.register(AudioManager.STREAM_MUSIC, this) + audioVolumeObserver?.register(AudioManager.STREAM_MUSIC, this) val audioManager = audioManager if (audioManager != null) { @@ -163,6 +163,7 @@ class CirclePlayerFragment : AbsPlayerFragment(), Callback, OnAudioVolumeChanged get() = Color.BLACK override fun onColorChanged(color: MediaNotificationProcessor) { + } override fun onFavoriteToggled() { diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/classic/ClassicPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/classic/ClassicPlayerFragment.kt index 30e0c8cb..9a2b1751 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/classic/ClassicPlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/classic/ClassicPlayerFragment.kt @@ -7,7 +7,6 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import android.widget.LinearLayout import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.Toolbar import androidx.core.view.ViewCompat @@ -66,7 +65,6 @@ class ClassicPlayerFragment : AbsPlayerFragment(), View.OnLayoutChangeListener, playerQueueSheet.contentPaddingRight, playerQueueSheet.contentPaddingBottom ) - val corner = (1 - slideOffset) * DensityUtil.dip2px(requireContext(), 16f) shapeDrawable.interpolation = 1 - slideOffset } @@ -120,6 +118,11 @@ class ClassicPlayerFragment : AbsPlayerFragment(), View.OnLayoutChangeListener, 0 ).build() ) + ToolbarContentTintHelper.colorizeToolbar( + playerToolbar, + Color.WHITE, + requireActivity() + ) } private fun hideVolumeIfAvailable() { @@ -270,6 +273,12 @@ class ClassicPlayerFragment : AbsPlayerFragment(), View.OnLayoutChangeListener, updateRepeatState() updateShuffleState() updatePrevNextColor() + + ToolbarContentTintHelper.colorizeToolbar( + playerToolbar, + Color.WHITE, + requireActivity() + ) } override fun toggleFavorite(song: Song) { diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/fit/FitFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/fit/FitFragment.kt index 97b367aa..dbacacbf 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/fit/FitFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/fit/FitFragment.kt @@ -44,8 +44,8 @@ class FitFragment : AbsPlayerFragment() { } override fun onColorChanged(color: MediaNotificationProcessor) { - playbackControlsFragment.setDark(color.backgroundColor) - lastColor = color.backgroundColor + playbackControlsFragment.setDark(color.primaryTextColor) + lastColor = color.primaryTextColor callbacks?.onPaletteColorChanged() ToolbarContentTintHelper.colorizeToolbar( playerToolbar, diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/flat/FlatPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/flat/FlatPlayerFragment.kt index ae838c8e..763b4b76 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/flat/FlatPlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/flat/FlatPlayerFragment.kt @@ -29,13 +29,13 @@ class FlatPlayerFragment : AbsPlayerFragment() { } private var valueAnimator: ValueAnimator? = null - private lateinit var flatPlaybackControlsFragment: FlatPlaybackControlsFragment + private lateinit var controlsFragment: FlatPlaybackControlsFragment private var lastColor: Int = 0 override val paletteColor: Int get() = lastColor private fun setUpSubFragments() { - flatPlaybackControlsFragment = + controlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as FlatPlaybackControlsFragment val playerAlbumCoverFragment = childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment @@ -55,11 +55,11 @@ class FlatPlayerFragment : AbsPlayerFragment() { private fun colorize(i: Int) { if (valueAnimator != null) { - valueAnimator!!.cancel() + valueAnimator?.cancel() } valueAnimator = ValueAnimator.ofObject(ArgbEvaluator(), android.R.color.transparent, i) - valueAnimator!!.addUpdateListener { animation -> + valueAnimator?.addUpdateListener { animation -> val drawable = DrawableGradient( GradientDrawable.Orientation.TOP_BOTTOM, intArrayOf(animation.animatedValue as Int, android.R.color.transparent), 0 @@ -67,7 +67,7 @@ class FlatPlayerFragment : AbsPlayerFragment() { colorGradientBackground?.background = drawable } - valueAnimator!!.setDuration(ViewUtil.RETRO_MUSIC_ANIM_TIME.toLong()).start() + valueAnimator?.setDuration(ViewUtil.RETRO_MUSIC_ANIM_TIME.toLong())?.start() } override fun onCreateView( @@ -84,11 +84,11 @@ class FlatPlayerFragment : AbsPlayerFragment() { } override fun onShow() { - flatPlaybackControlsFragment.show() + controlsFragment.show() } override fun onHide() { - flatPlaybackControlsFragment.hide() + controlsFragment.hide() onBackPressed() } @@ -106,7 +106,7 @@ class FlatPlayerFragment : AbsPlayerFragment() { override fun onColorChanged(color: MediaNotificationProcessor) { lastColor = color.backgroundColor - flatPlaybackControlsFragment.setDark(color.backgroundColor) + controlsFragment.setDark(color.primaryTextColor) callbacks?.onPaletteColorChanged() val isLight = ColorUtil.isColorLight(color.backgroundColor) val iconColor = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/full/FullPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/full/FullPlayerFragment.kt index 50ddade6..8fc7bda2 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/full/FullPlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/full/FullPlayerFragment.kt @@ -125,7 +125,7 @@ class FullPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca private var lastColor: Int = 0 override val paletteColor: Int get() = lastColor - private lateinit var fullPlaybackControlsFragment: FullPlaybackControlsFragment + private lateinit var controlsFragment: FullPlaybackControlsFragment private fun setUpPlayerToolbar() { playerToolbar.apply { @@ -174,7 +174,7 @@ class FullPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca } private fun setUpSubFragments() { - fullPlaybackControlsFragment = + controlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as FullPlaybackControlsFragment val playerAlbumCoverFragment = @@ -199,14 +199,14 @@ class FullPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca override fun onColorChanged(color: MediaNotificationProcessor) { lastColor = color.backgroundColor - fullPlaybackControlsFragment.setDark(color.backgroundColor) + controlsFragment.setDark(color.primaryTextColor) callbacks?.onPaletteColorChanged() ToolbarContentTintHelper.colorizeToolbar(playerToolbar, Color.WHITE, activity) } override fun onFavoriteToggled() { toggleFavorite(MusicPlayerRemote.currentSong) - fullPlaybackControlsFragment.onFavoriteToggled() + controlsFragment.onFavoriteToggled() } override fun toggleFavorite(song: Song) { diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/normal/PlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/normal/PlayerFragment.kt index 7c618122..1e5f8210 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/normal/PlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/normal/PlayerFragment.kt @@ -28,7 +28,7 @@ class PlayerFragment : AbsPlayerFragment() { override val paletteColor: Int get() = lastColor - private lateinit var playbackControlsFragment: PlayerPlaybackControlsFragment + private lateinit var controlsFragment: PlayerPlaybackControlsFragment private var valueAnimator: ValueAnimator? = null @@ -58,11 +58,11 @@ class PlayerFragment : AbsPlayerFragment() { } override fun onShow() { - playbackControlsFragment.show() + controlsFragment.show() } override fun onHide() { - playbackControlsFragment.hide() + controlsFragment.hide() onBackPressed() } @@ -75,7 +75,7 @@ class PlayerFragment : AbsPlayerFragment() { } override fun onColorChanged(color: MediaNotificationProcessor) { - playbackControlsFragment.setDark(color.backgroundColor) + controlsFragment.setDark(color.primaryTextColor) lastColor = color.backgroundColor callbacks?.onPaletteColorChanged() @@ -118,7 +118,7 @@ class PlayerFragment : AbsPlayerFragment() { private fun setUpSubFragments() { - playbackControlsFragment = + controlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as PlayerPlaybackControlsFragment val playerAlbumCoverFragment = childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/peak/PeakPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/peak/PeakPlayerFragment.kt index 696c552b..ea5748e4 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/peak/PeakPlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/peak/PeakPlayerFragment.kt @@ -40,7 +40,7 @@ import kotlinx.android.synthetic.main.fragment_peak_player.* class PeakPlayerFragment : AbsPlayerFragment() { - private lateinit var playbackControlsFragment: PeakPlayerControlFragment + private lateinit var controlsFragment: PeakPlayerControlFragment private var lastColor: Int = 0 override fun onCreateView( @@ -62,7 +62,7 @@ class PeakPlayerFragment : AbsPlayerFragment() { } private fun setUpSubFragments() { - playbackControlsFragment = + controlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as PeakPlayerControlFragment } @@ -101,8 +101,8 @@ class PeakPlayerFragment : AbsPlayerFragment() { get() = lastColor override fun onColorChanged(color: MediaNotificationProcessor) { - playbackControlsFragment.setDark(color.backgroundColor) - lastColor = color.backgroundColor + controlsFragment.setDark(color.primaryTextColor) + lastColor = color.primaryTextColor callbacks?.onPaletteColorChanged() } @@ -127,7 +127,7 @@ class PeakPlayerFragment : AbsPlayerFragment() { .build() .into(object : RetroMusicColoredTarget(playerImage) { override fun onColorReady(colors: MediaNotificationProcessor) { - playbackControlsFragment.setDark(colors.backgroundColor) + controlsFragment.setDark(colors.primaryTextColor) } }) } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/plain/PlainPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/plain/PlainPlayerFragment.kt index c268d95c..87527eaf 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/plain/PlainPlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/plain/PlainPlayerFragment.kt @@ -95,8 +95,8 @@ class PlainPlayerFragment : AbsPlayerFragment() { } override fun onColorChanged(color: MediaNotificationProcessor) { - plainPlaybackControlsFragment.setDark(color.backgroundColor) - lastColor = color.backgroundColor + plainPlaybackControlsFragment.setDark(color.primaryTextColor) + lastColor = color.primaryTextColor callbacks!!.onPaletteColorChanged() ToolbarContentTintHelper.colorizeToolbar( playerToolbar, diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/simple/SimplePlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/simple/SimplePlayerFragment.kt index 3bb0a55f..d2e31026 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/simple/SimplePlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/simple/SimplePlayerFragment.kt @@ -29,7 +29,7 @@ class SimplePlayerFragment : AbsPlayerFragment() { override val paletteColor: Int get() = lastColor - private lateinit var simplePlaybackControlsFragment: SimplePlaybackControlsFragment + private lateinit var controlsFragment: SimplePlaybackControlsFragment override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, @@ -49,16 +49,16 @@ class SimplePlayerFragment : AbsPlayerFragment() { val playerAlbumCoverFragment = childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment playerAlbumCoverFragment.setCallbacks(this) - simplePlaybackControlsFragment = + controlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as SimplePlaybackControlsFragment } override fun onShow() { - simplePlaybackControlsFragment.show() + controlsFragment.show() } override fun onHide() { - simplePlaybackControlsFragment.hide() + controlsFragment.hide() } override fun onBackPressed(): Boolean { @@ -72,7 +72,7 @@ class SimplePlayerFragment : AbsPlayerFragment() { override fun onColorChanged(color: MediaNotificationProcessor) { lastColor = color.backgroundColor callbacks?.onPaletteColorChanged() - simplePlaybackControlsFragment.setDark(color.backgroundColor) + controlsFragment.setDark(color.primaryTextColor) ToolbarContentTintHelper.colorizeToolbar( playerToolbar, ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal), diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/tiny/TinyPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/tiny/TinyPlayerFragment.kt index 1f25883d..ee96810f 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/tiny/TinyPlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/tiny/TinyPlayerFragment.kt @@ -75,7 +75,7 @@ class TinyPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca override fun onColorChanged(color: MediaNotificationProcessor) { val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) { - color.backgroundColor + color.primaryTextColor } else { ThemeStore.accentColor(requireContext()) } diff --git a/app/src/main/java/code/name/monkey/retromusic/loaders/AlbumLoader.kt b/app/src/main/java/code/name/monkey/retromusic/loaders/AlbumLoader.kt index 49342d0d..7971994d 100644 --- a/app/src/main/java/code/name/monkey/retromusic/loaders/AlbumLoader.kt +++ b/app/src/main/java/code/name/monkey/retromusic/loaders/AlbumLoader.kt @@ -16,13 +16,13 @@ package code.name.monkey.retromusic.loaders import android.content.Context import android.provider.MediaStore.Audio.AudioColumns +import code.name.monkey.retromusic.App +import code.name.monkey.retromusic.helper.SortOrder import code.name.monkey.retromusic.model.Album import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.util.PreferenceUtil import java.util.* import kotlin.collections.ArrayList -import kotlin.collections.isNotEmpty -import kotlin.collections.sortWith /** @@ -108,12 +108,32 @@ object AlbumLoader { } private fun sortSongsByTrackNumber(album: Album) { - album.songs?.sortWith(Comparator { o1, o2 -> o1.trackNumber.compareTo(o2.trackNumber) }) + when (PreferenceUtil.getInstance(App.getContext()).albumDetailSongSortOrder) { + SortOrder.AlbumSongSortOrder.SONG_TRACK_LIST -> album.songs?.sortWith(Comparator { o1, o2 -> + o1.trackNumber.compareTo( + o2.trackNumber + ) + }) + SortOrder.AlbumSongSortOrder.SONG_A_Z -> album.songs?.sortWith(Comparator { o1, o2 -> + o1.title.compareTo( + o2.title + ) + }) + SortOrder.AlbumSongSortOrder.SONG_Z_A -> album.songs?.sortWith(Comparator { o1, o2 -> + o2.title.compareTo( + o1.title + ) + }) + SortOrder.AlbumSongSortOrder.SONG_DURATION -> album.songs?.sortWith(Comparator { o1, o2 -> + o1.duration.compareTo( + o2.duration + ) + }) + } } private fun getSongLoaderSortOrder(context: Context): String { - return PreferenceUtil.getInstance(context).albumSortOrder + ", " + PreferenceUtil.getInstance( - context - ).albumSongSortOrder + return PreferenceUtil.getInstance(context).albumSortOrder + ", " + + PreferenceUtil.getInstance(context).albumSongSortOrder } } diff --git a/app/src/main/java/code/name/monkey/retromusic/loaders/SongLoader.kt b/app/src/main/java/code/name/monkey/retromusic/loaders/SongLoader.kt index aa9fc369..f95df2cf 100644 --- a/app/src/main/java/code/name/monkey/retromusic/loaders/SongLoader.kt +++ b/app/src/main/java/code/name/monkey/retromusic/loaders/SongLoader.kt @@ -31,7 +31,6 @@ import java.util.* object SongLoader { - fun getAllSongs( context: Context ): ArrayList { @@ -128,9 +127,8 @@ object SongLoader { return context.contentResolver.query( MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, baseProjection, - selectionFinal + " AND " + MediaStore.Audio.Media.DURATION + ">= " + (PreferenceUtil.getInstance( - context - ).filterLength * 1000), + selectionFinal + " AND " + MediaStore.Audio.Media.DURATION + ">= " + + (PreferenceUtil.getInstance(context).filterLength * 1000), selectionValuesFinal, sortOrder ) diff --git a/app/src/main/java/code/name/monkey/retromusic/util/PlaylistsUtil.java b/app/src/main/java/code/name/monkey/retromusic/util/PlaylistsUtil.java index b6df807e..12b6a9d7 100644 --- a/app/src/main/java/code/name/monkey/retromusic/util/PlaylistsUtil.java +++ b/app/src/main/java/code/name/monkey/retromusic/util/PlaylistsUtil.java @@ -42,7 +42,241 @@ import static android.provider.MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI; public class PlaylistsUtil { - public static void addToPlaylist(@NonNull Context context, + public static int createPlaylist(@NonNull final Context context, @Nullable final String name) { + int id = -1; + if (name != null && name.length() > 0) { + try { + Cursor cursor = context.getContentResolver().query(EXTERNAL_CONTENT_URI, + new String[]{MediaStore.Audio.Playlists._ID}, + MediaStore.Audio.PlaylistsColumns.NAME + "=?", new String[]{name}, + null); + if (cursor == null || cursor.getCount() < 1) { + final ContentValues values = new ContentValues(1); + values.put(MediaStore.Audio.PlaylistsColumns.NAME, name); + final Uri uri = context.getContentResolver().insert( + EXTERNAL_CONTENT_URI, + values); + if (uri != null) { + // Necessary because somehow the MediaStoreObserver is not notified when adding a playlist + context.getContentResolver().notifyChange(Uri.parse("content://media"), null); + Toast.makeText(context, context.getResources().getString( + R.string.created_playlist_x, name), Toast.LENGTH_SHORT).show(); + id = Integer.parseInt(uri.getLastPathSegment()); + } + } else { + // Playlist exists + if (cursor.moveToFirst()) { + id = cursor.getInt(cursor.getColumnIndex(MediaStore.Audio.Playlists._ID)); + } + } + if (cursor != null) { + cursor.close(); + } + } catch (SecurityException e) { + e.printStackTrace(); + Toast.makeText(context, "Don't have permission for adding to playlist", Toast.LENGTH_SHORT).show(); + } + } + if (id == -1) { + Toast.makeText(context, context.getResources().getString( + R.string.could_not_create_playlist), Toast.LENGTH_SHORT).show(); + } + return id; + } + + public static void deletePlaylists(@NonNull final Context context, @NonNull final ArrayList playlists) { + final StringBuilder selection = new StringBuilder(); + selection.append(MediaStore.Audio.Playlists._ID + " IN ("); + for (int i = 0; i < playlists.size(); i++) { + selection.append(playlists.get(i).id); + if (i < playlists.size() - 1) { + selection.append(","); + } + } + selection.append(")"); + try { + context.getContentResolver().delete(EXTERNAL_CONTENT_URI, selection.toString(), null); + context.getContentResolver().notifyChange(Uri.parse("content://media"), null); + } catch (SecurityException ignored) { + } + } + + public static void addToPlaylist(@NonNull final Context context, final Song song, final int playlistId, final boolean showToastOnFinish) { + List helperList = new ArrayList<>(); + helperList.add(song); + addToPlaylist(context, helperList, playlistId, showToastOnFinish); + } + + public static void addToPlaylist(@NonNull final Context context, @NonNull final List songs, final int playlistId, final boolean showToastOnFinish) { + final int size = songs.size(); + final ContentResolver resolver = context.getContentResolver(); + final String[] projection = new String[]{ + "max(" + MediaStore.Audio.Playlists.Members.PLAY_ORDER + ")", + }; + final Uri uri = MediaStore.Audio.Playlists.Members.getContentUri("external", playlistId); + Cursor cursor = null; + int base = 0; + + try { + try { + cursor = resolver.query(uri, projection, null, null, null); + + if (cursor != null && cursor.moveToFirst()) { + base = cursor.getInt(0) + 1; + } + } finally { + if (cursor != null) { + cursor.close(); + } + } + + int numInserted = 0; + for (int offSet = 0; offSet < size; offSet += 1000) + numInserted += resolver.bulkInsert(uri, makeInsertItems(songs, offSet, 1000, base)); + + if (showToastOnFinish) { + Toast.makeText(context, context.getResources().getString( + R.string.inserted_x_songs_into_playlist_x, numInserted, getNameForPlaylist(context, playlistId)), Toast.LENGTH_SHORT).show(); + } + } catch (SecurityException ignored) { + ignored.printStackTrace(); + Toast.makeText(context, "Don't have permission for adding to playlist", Toast.LENGTH_SHORT).show(); + } + } + + @NonNull + public static ContentValues[] makeInsertItems(@NonNull final List songs, final int offset, int len, final int base) { + if (offset + len > songs.size()) { + len = songs.size() - offset; + } + + ContentValues[] contentValues = new ContentValues[len]; + + for (int i = 0; i < len; i++) { + contentValues[i] = new ContentValues(); + contentValues[i].put(MediaStore.Audio.Playlists.Members.PLAY_ORDER, base + offset + i); + contentValues[i].put(MediaStore.Audio.Playlists.Members.AUDIO_ID, songs.get(offset + i).getId()); + } + return contentValues; + } + + public static String getNameForPlaylist(@NonNull final Context context, final long id) { + try { + Cursor cursor = context.getContentResolver().query(EXTERNAL_CONTENT_URI, + new String[]{MediaStore.Audio.PlaylistsColumns.NAME}, + BaseColumns._ID + "=?", + new String[]{String.valueOf(id)}, + null); + if (cursor != null) { + try { + if (cursor.moveToFirst()) { + return cursor.getString(0); + } + } finally { + cursor.close(); + } + } + } catch (SecurityException ignored) { + } + return ""; + } + + public static void removeFromPlaylist(@NonNull final Context context, @NonNull final Song song, int playlistId) { + Uri uri = MediaStore.Audio.Playlists.Members.getContentUri( + "external", playlistId); + String selection = MediaStore.Audio.Playlists.Members.AUDIO_ID + " =?"; + String[] selectionArgs = new String[]{String.valueOf(song.getId())}; + + try { + context.getContentResolver().delete(uri, selection, selectionArgs); + } catch (SecurityException ignored) { + } + } + + public static void removeFromPlaylist(@NonNull final Context context, @NonNull final List songs) { + final int playlistId = songs.get(0).getPlaylistId(); + Uri uri = MediaStore.Audio.Playlists.Members.getContentUri( + "external", playlistId); + String selectionArgs[] = new String[songs.size()]; + for (int i = 0; i < selectionArgs.length; i++) { + selectionArgs[i] = String.valueOf(songs.get(i).getIdInPlayList()); + } + String selection = MediaStore.Audio.Playlists.Members._ID + " in ("; + //noinspection unused + for (String selectionArg : selectionArgs) selection += "?, "; + selection = selection.substring(0, selection.length() - 2) + ")"; + + try { + context.getContentResolver().delete(uri, selection, selectionArgs); + } catch (SecurityException ignored) { + } + } + + public static boolean doPlaylistContains(@NonNull final Context context, final long playlistId, final int songId) { + if (playlistId != -1) { + try { + Cursor c = context.getContentResolver().query( + MediaStore.Audio.Playlists.Members.getContentUri("external", playlistId), + new String[]{MediaStore.Audio.Playlists.Members.AUDIO_ID}, MediaStore.Audio.Playlists.Members.AUDIO_ID + "=?", new String[]{String.valueOf(songId)}, null); + int count = 0; + if (c != null) { + count = c.getCount(); + c.close(); + } + return count > 0; + } catch (SecurityException ignored) { + } + } + return false; + } + + public static boolean moveItem(@NonNull final Context context, int playlistId, int from, int to) { + return MediaStore.Audio.Playlists.Members.moveItem(context.getContentResolver(), + playlistId, from, to); + } + + public static void renamePlaylist(@NonNull final Context context, final long id, final String newName) { + ContentValues contentValues = new ContentValues(); + contentValues.put(MediaStore.Audio.PlaylistsColumns.NAME, newName); + try { + context.getContentResolver().update(EXTERNAL_CONTENT_URI, + contentValues, + MediaStore.Audio.Playlists._ID + "=?", + new String[]{String.valueOf(id)}); + context.getContentResolver().notifyChange(Uri.parse("content://media"), null); + } catch (SecurityException ignored) { + } + } + + public static File savePlaylist(Context context, Playlist playlist) throws IOException { + return M3UWriter.write(context, new File(Environment.getExternalStorageDirectory(), "Playlists"), playlist); + } + + public static boolean doesPlaylistExist(@NonNull final Context context, final int playlistId) { + return playlistId != -1 && doesPlaylistExist(context, + MediaStore.Audio.Playlists._ID + "=?", + new String[]{String.valueOf(playlistId)}); + } + + public static boolean doesPlaylistExist(@NonNull final Context context, final String name) { + return doesPlaylistExist(context, + MediaStore.Audio.PlaylistsColumns.NAME + "=?", + new String[]{name}); + } + + private static boolean doesPlaylistExist(@NonNull Context context, @NonNull final String selection, @NonNull final String[] values) { + Cursor cursor = context.getContentResolver().query(EXTERNAL_CONTENT_URI, + new String[]{}, selection, values, null); + + boolean exists = false; + if (cursor != null) { + exists = cursor.getCount() != 0; + cursor.close(); + } + return exists; + } + + /*public static void addToPlaylist(@NonNull Context context, @NonNull List songs, int playlistId, boolean showToastOnFinish) { @@ -273,5 +507,5 @@ public class PlaylistsUtil { cursor.close(); } return exists; - } + }*/ } \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/views/RetroShapeableImageView.kt b/app/src/main/java/code/name/monkey/retromusic/views/RetroShapeableImageView.kt index 5e305122..df479136 100644 --- a/app/src/main/java/code/name/monkey/retromusic/views/RetroShapeableImageView.kt +++ b/app/src/main/java/code/name/monkey/retromusic/views/RetroShapeableImageView.kt @@ -37,7 +37,7 @@ class RetroShapeableImageView @JvmOverloads constructor( typedArray.recycle() } - fun updateCornerSize(cornerSize: Float) { + private fun updateCornerSize(cornerSize: Float) { shapeAppearanceModel = ShapeAppearanceModel.Builder() .setAllCorners(CornerFamily.ROUNDED, cornerSize) .build() diff --git a/app/src/main/res/drawable-xxxhdpi/np_adaptive.webp b/app/src/main/res/drawable-xxxhdpi/np_adaptive.webp index c60809ec..b4c80dc7 100644 Binary files a/app/src/main/res/drawable-xxxhdpi/np_adaptive.webp and b/app/src/main/res/drawable-xxxhdpi/np_adaptive.webp differ diff --git a/app/src/main/res/drawable-xxxhdpi/np_blur.webp b/app/src/main/res/drawable-xxxhdpi/np_blur.webp index 5a164d1c..3fe7e201 100644 Binary files a/app/src/main/res/drawable-xxxhdpi/np_blur.webp and b/app/src/main/res/drawable-xxxhdpi/np_blur.webp differ diff --git a/app/src/main/res/drawable-xxxhdpi/np_blur_card.webp b/app/src/main/res/drawable-xxxhdpi/np_blur_card.webp index cc42ebff..67d26de4 100644 Binary files a/app/src/main/res/drawable-xxxhdpi/np_blur_card.webp and b/app/src/main/res/drawable-xxxhdpi/np_blur_card.webp differ diff --git a/app/src/main/res/drawable-xxxhdpi/np_card.webp b/app/src/main/res/drawable-xxxhdpi/np_card.webp index cd3279e9..5a8f0a17 100644 Binary files a/app/src/main/res/drawable-xxxhdpi/np_card.webp and b/app/src/main/res/drawable-xxxhdpi/np_card.webp differ diff --git a/app/src/main/res/drawable-xxxhdpi/np_circle.webp b/app/src/main/res/drawable-xxxhdpi/np_circle.webp index 7a812475..5028d1b4 100644 Binary files a/app/src/main/res/drawable-xxxhdpi/np_circle.webp and b/app/src/main/res/drawable-xxxhdpi/np_circle.webp differ diff --git a/app/src/main/res/drawable-xxxhdpi/np_classic.webp b/app/src/main/res/drawable-xxxhdpi/np_classic.webp index d086fafe..dc9f9323 100644 Binary files a/app/src/main/res/drawable-xxxhdpi/np_classic.webp and b/app/src/main/res/drawable-xxxhdpi/np_classic.webp differ diff --git a/app/src/main/res/drawable-xxxhdpi/np_color.webp b/app/src/main/res/drawable-xxxhdpi/np_color.webp index 2e007e36..ec34d1fa 100644 Binary files a/app/src/main/res/drawable-xxxhdpi/np_color.webp and b/app/src/main/res/drawable-xxxhdpi/np_color.webp differ diff --git a/app/src/main/res/drawable-xxxhdpi/np_fit.webp b/app/src/main/res/drawable-xxxhdpi/np_fit.webp index b93dca49..b5ed505d 100644 Binary files a/app/src/main/res/drawable-xxxhdpi/np_fit.webp and b/app/src/main/res/drawable-xxxhdpi/np_fit.webp differ diff --git a/app/src/main/res/drawable-xxxhdpi/np_flat.webp b/app/src/main/res/drawable-xxxhdpi/np_flat.webp index f445b596..e81cbcb3 100644 Binary files a/app/src/main/res/drawable-xxxhdpi/np_flat.webp and b/app/src/main/res/drawable-xxxhdpi/np_flat.webp differ diff --git a/app/src/main/res/drawable-xxxhdpi/np_full.webp b/app/src/main/res/drawable-xxxhdpi/np_full.webp index 6733a782..b9d58a33 100644 Binary files a/app/src/main/res/drawable-xxxhdpi/np_full.webp and b/app/src/main/res/drawable-xxxhdpi/np_full.webp differ diff --git a/app/src/main/res/drawable-xxxhdpi/np_material.webp b/app/src/main/res/drawable-xxxhdpi/np_material.webp index 692893dd..e6ae21f2 100644 Binary files a/app/src/main/res/drawable-xxxhdpi/np_material.webp and b/app/src/main/res/drawable-xxxhdpi/np_material.webp differ diff --git a/app/src/main/res/drawable-xxxhdpi/np_normal.webp b/app/src/main/res/drawable-xxxhdpi/np_normal.webp index 06965c7a..f54fadc7 100644 Binary files a/app/src/main/res/drawable-xxxhdpi/np_normal.webp and b/app/src/main/res/drawable-xxxhdpi/np_normal.webp differ diff --git a/app/src/main/res/drawable-xxxhdpi/np_peak.webp b/app/src/main/res/drawable-xxxhdpi/np_peak.webp index 6af06443..80586e83 100644 Binary files a/app/src/main/res/drawable-xxxhdpi/np_peak.webp and b/app/src/main/res/drawable-xxxhdpi/np_peak.webp differ diff --git a/app/src/main/res/drawable-xxxhdpi/np_plain.webp b/app/src/main/res/drawable-xxxhdpi/np_plain.webp index 35c1448e..cbc8de8e 100644 Binary files a/app/src/main/res/drawable-xxxhdpi/np_plain.webp and b/app/src/main/res/drawable-xxxhdpi/np_plain.webp differ diff --git a/app/src/main/res/drawable-xxxhdpi/np_simple.webp b/app/src/main/res/drawable-xxxhdpi/np_simple.webp index a56e9ee9..2bab76da 100644 Binary files a/app/src/main/res/drawable-xxxhdpi/np_simple.webp and b/app/src/main/res/drawable-xxxhdpi/np_simple.webp differ diff --git a/app/src/main/res/drawable-xxxhdpi/np_tiny.webp b/app/src/main/res/drawable-xxxhdpi/np_tiny.webp index 6ae2b804..b2ec68aa 100644 Binary files a/app/src/main/res/drawable-xxxhdpi/np_tiny.webp and b/app/src/main/res/drawable-xxxhdpi/np_tiny.webp differ diff --git a/app/src/main/res/drawable/ic_check_circle_white_24dp.xml b/app/src/main/res/drawable/ic_check_circle_white_24dp.xml new file mode 100644 index 00000000..7cdc15de --- /dev/null +++ b/app/src/main/res/drawable/ic_check_circle_white_24dp.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/layout/activity_pro_version.xml b/app/src/main/res/layout/activity_pro_version.xml index f3ae45b2..212e133f 100644 --- a/app/src/main/res/layout/activity_pro_version.xml +++ b/app/src/main/res/layout/activity_pro_version.xml @@ -3,8 +3,8 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:background="@color/md_black_1000" android:layout_height="match_parent" + android:background="@color/md_black_1000" android:orientation="vertical"> diff --git a/app/src/main/res/layout/fragment_album_full_card_cover.xml b/app/src/main/res/layout/fragment_album_full_card_cover.xml index f3deeb40..0828390d 100644 --- a/app/src/main/res/layout/fragment_album_full_card_cover.xml +++ b/app/src/main/res/layout/fragment_album_full_card_cover.xml @@ -8,10 +8,11 @@ + android:layout_margin="16dp" + app:cardCornerRadius="16dp" + app:cardElevation="8dp"> - - - - - + + tools:text="@tools:sample/first_names" /> + tools:text="@tools:sample/first_names" /> \ No newline at end of file diff --git a/app/src/main/res/layout/item_list_quick_actions.xml b/app/src/main/res/layout/item_list_quick_actions.xml index da3e0fda..70fd399f 100644 --- a/app/src/main/res/layout/item_list_quick_actions.xml +++ b/app/src/main/res/layout/item_list_quick_actions.xml @@ -17,15 +17,14 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" - android:orientation="horizontal" - > + android:orientation="horizontal"> + android:layout_height="wrap_content" + tools:background="@color/md_red_500"> + tools:text="@tools:sample/full_names" /> - + app:cardCornerRadius="16dp" + app:layout_constraintDimensionRatio="16:9" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> + + tools:text="@tools:sample/full_names" /> + tools:text="@tools:sample/full_names" /> - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/section_recycler_view.xml b/app/src/main/res/layout/section_recycler_view.xml index 2477a113..531d3772 100644 --- a/app/src/main/res/layout/section_recycler_view.xml +++ b/app/src/main/res/layout/section_recycler_view.xml @@ -12,7 +12,8 @@ android:id="@+id/title" android:layout_width="0dp" android:layout_height="wrap_content" - android:padding="16dp" + android:paddingHorizontal="16dp" + android:paddingVertical="12dp" android:textAppearance="@style/TextViewHeadline6" android:textStyle="bold" app:layout_constrainedWidth="true" diff --git a/app/src/main/res/menu/menu_player.xml b/app/src/main/res/menu/menu_player.xml index 522fc7c9..d1919c1f 100755 --- a/app/src/main/res/menu/menu_player.xml +++ b/app/src/main/res/menu/menu_player.xml @@ -10,7 +10,7 @@ app:showAsAction="ifRoom" />