diff --git a/app/src/main/assets/contributors.json b/app/src/main/assets/contributors.json index aecc3a7e..b7620161 100644 --- a/app/src/main/assets/contributors.json +++ b/app/src/main/assets/contributors.json @@ -13,13 +13,13 @@ }, { "name": "Daksh P. Jain", - "summary": "Telegram group maintainer", + "summary": "Support Representative & Moderator", "link": "https://daksh.eu.org", "profile_image": "https://i.imgur.com/fnYpg65.jpg" }, { "name": "Milind Goel", - "summary": "Github & Telegram maintainer", + "summary": "Support Representative & Moderator", "link": "https://t.me/MilindGoel15", "profile_image": "https://i.imgur.com/Bz4De21_d.jpg" } diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/album/AlbumCoverPagerAdapter.kt b/app/src/main/java/code/name/monkey/retromusic/adapter/album/AlbumCoverPagerAdapter.kt index 1a82f465..2ee9ddb2 100644 --- a/app/src/main/java/code/name/monkey/retromusic/adapter/album/AlbumCoverPagerAdapter.kt +++ b/app/src/main/java/code/name/monkey/retromusic/adapter/album/AlbumCoverPagerAdapter.kt @@ -9,7 +9,6 @@ import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager import androidx.lifecycle.lifecycleScope import code.name.monkey.retromusic.R -import code.name.monkey.retromusic.dialogs.LyricsDialog import code.name.monkey.retromusic.fragments.AlbumCoverStyle import code.name.monkey.retromusic.fragments.NowPlayingScreen.* import code.name.monkey.retromusic.glide.RetroMusicColoredTarget @@ -91,7 +90,7 @@ class AlbumCoverPagerAdapter( val view = inflater.inflate(getLayoutWithPlayerTheme(), container, false) albumCover = view.findViewById(R.id.player_image) albumCover.setOnClickListener { - LyricsDialog().show(childFragmentManager, "LyricsDialog") + //LyricsDialog().show(childFragmentManager, "LyricsDialog") showLyricsDialog() } return view diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/DetailListFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/DetailListFragment.kt index fc9ee92c..7824826b 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/DetailListFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/DetailListFragment.kt @@ -3,8 +3,11 @@ package code.name.monkey.retromusic.fragments import android.os.Bundle import android.view.View import android.widget.ImageView +import androidx.core.os.bundleOf import androidx.lifecycle.Observer import androidx.lifecycle.lifecycleScope +import androidx.navigation.fragment.FragmentNavigatorExtras +import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.navArgs import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.LinearLayoutManager @@ -179,10 +182,20 @@ class DetailListFragment : AbsMainActivityFragment(R.layout.fragment_playlist_de override fun onArtist(artistId: Long, imageView: ImageView) { - + findNavController().navigate( + R.id.artistDetailsFragment, + bundleOf(EXTRA_ARTIST_ID to artistId), + null, + FragmentNavigatorExtras(imageView to getString(R.string.transition_artist_image)) + ) } override fun onAlbumClick(albumId: Long, view: View) { - + findNavController().navigate( + R.id.albumDetailsFragment, + bundleOf(EXTRA_ALBUM_ID to albumId), + null, + FragmentNavigatorExtras(view to getString(R.string.transition_album_art)) + ) } } \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/LibraryViewModel.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/LibraryViewModel.kt index 94de6a91..a44cd7bb 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/LibraryViewModel.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/LibraryViewModel.kt @@ -75,7 +75,6 @@ class LibraryViewModel( } fun getHome(): LiveData> { - fetchHomeSections() return home } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumDetailsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumDetailsFragment.kt index e3a3733b..3ae09641 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumDetailsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumDetailsFragment.kt @@ -10,6 +10,7 @@ import androidx.core.text.HtmlCompat import androidx.lifecycle.Observer import androidx.lifecycle.lifecycleScope import androidx.navigation.findNavController +import androidx.navigation.fragment.FragmentNavigatorExtras import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.navArgs import androidx.recyclerview.widget.DefaultItemAnimator @@ -267,7 +268,9 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det override fun onAlbumClick(albumId: Long, view: View) { findNavController().navigate( R.id.albumDetailsFragment, - bundleOf(EXTRA_ALBUM_ID to albumId) + bundleOf(EXTRA_ALBUM_ID to albumId), + null, + FragmentNavigatorExtras(view to getString(R.string.transition_album_art)) ) } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/artists/ArtistDetailsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/artists/ArtistDetailsFragment.kt index 018520e2..42b3a11d 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/artists/ArtistDetailsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/artists/ArtistDetailsFragment.kt @@ -17,7 +17,6 @@ import androidx.navigation.fragment.navArgs import androidx.recyclerview.widget.DefaultItemAnimator import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.LinearLayoutManager -import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.retromusic.EXTRA_ALBUM_ID import code.name.monkey.retromusic.R import code.name.monkey.retromusic.adapter.album.HorizontalAlbumAdapter @@ -38,7 +37,6 @@ import code.name.monkey.retromusic.network.model.LastFmArtist import code.name.monkey.retromusic.repository.RealRepository import code.name.monkey.retromusic.util.CustomArtistImageUtil import code.name.monkey.retromusic.util.MusicUtil -import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.RetroUtil import com.bumptech.glide.Glide import kotlinx.android.synthetic.main.fragment_artist_content.* @@ -199,10 +197,8 @@ class ArtistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_artist_d } private fun setColors(color: Int) { - val finalColor = if (PreferenceUtil.isAdaptiveColor) color - else ThemeStore.accentColor(requireContext()) - shuffleAction.applyColor(finalColor) - playAction.applyOutlineColor(finalColor) + shuffleAction.applyColor(color) + playAction.applyOutlineColor(color) } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/gradient/GradientPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/gradient/GradientPlayerFragment.kt index 6bfd39d2..1800df08 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/gradient/GradientPlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/gradient/GradientPlayerFragment.kt @@ -14,12 +14,16 @@ import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.Toolbar import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.view.ViewCompat +import androidx.lifecycle.lifecycleScope import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import code.name.monkey.appthemehelper.util.ColorUtil import code.name.monkey.retromusic.R import code.name.monkey.retromusic.RetroBottomSheetBehavior import code.name.monkey.retromusic.adapter.song.PlayingQueueAdapter +import code.name.monkey.retromusic.db.PlaylistEntity +import code.name.monkey.retromusic.db.SongEntity +import code.name.monkey.retromusic.db.toSongEntity import code.name.monkey.retromusic.extensions.hide import code.name.monkey.retromusic.extensions.ripAlpha import code.name.monkey.retromusic.extensions.show @@ -45,6 +49,9 @@ import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils import kotlinx.android.synthetic.main.fragment_gradient_controls.* import kotlinx.android.synthetic.main.fragment_gradient_player.* import kotlinx.android.synthetic.main.status_bar.* +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext class GradientPlayerFragment : AbsPlayerFragment(R.layout.fragment_gradient_player), MusicProgressViewUpdateHelper.Callback, @@ -216,7 +223,7 @@ class GradientPlayerFragment : AbsPlayerFragment(R.layout.fragment_gradient_play override fun toggleFavorite(song: Song) { super.toggleFavorite(song) if (song.id == MusicPlayerRemote.currentSong.id) { - updateIsFavorite() + updateIsFavoriteIcon() } } @@ -224,6 +231,23 @@ class GradientPlayerFragment : AbsPlayerFragment(R.layout.fragment_gradient_play toggleFavorite(MusicPlayerRemote.currentSong) } + private fun updateIsFavoriteIcon() { + lifecycleScope.launch(Dispatchers.IO) { + val playlist: PlaylistEntity? = libraryViewModel.favoritePlaylist() + if (playlist != null) { + val song: SongEntity = + MusicPlayerRemote.currentSong.toSongEntity(playlist.playListId) + val isFavorite: Boolean = libraryViewModel.isFavoriteSong(song).isNotEmpty() + withContext(Dispatchers.Main) { + val icon = + if (isFavorite) R.drawable.ic_favorite + else R.drawable.ic_favorite_border + songFavourite.setImageResource(icon) + } + } + } + } + private fun hideVolumeIfAvailable() { if (PreferenceUtil.isVolumeVisibilityMode) { childFragmentManager.beginTransaction() @@ -241,6 +265,7 @@ class GradientPlayerFragment : AbsPlayerFragment(R.layout.fragment_gradient_play updatePlayPauseDrawableState() updatePlayPauseDrawableState() updateQueue() + updateIsFavoriteIcon() } override fun onPlayStateChanged() { @@ -259,6 +284,7 @@ class GradientPlayerFragment : AbsPlayerFragment(R.layout.fragment_gradient_play super.onPlayingMetaChanged() updateSong() updateQueuePosition() + updateIsFavoriteIcon() } override fun onQueueChanged() { @@ -457,15 +483,11 @@ class GradientPlayerFragment : AbsPlayerFragment(R.layout.fragment_gradient_play override fun onUpdateProgressViews(progress: Int, total: Int) { progressSlider.max = total - val animator = ObjectAnimator.ofInt(progressSlider, "progress", progress) animator.duration = AbsPlayerControlsFragment.SLIDER_ANIMATION_TIME animator.interpolator = LinearInterpolator() animator.start() - songTotalTime.text = MusicUtil.getReadableDurationString(total.toLong()) songCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong()) } - - } \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/repository/ArtistRepository.kt b/app/src/main/java/code/name/monkey/retromusic/repository/ArtistRepository.kt index 9c14becf..6ecf6509 100644 --- a/app/src/main/java/code/name/monkey/retromusic/repository/ArtistRepository.kt +++ b/app/src/main/java/code/name/monkey/retromusic/repository/ArtistRepository.kt @@ -39,7 +39,16 @@ class RealArtistRepository( PreferenceUtil.artistAlbumSortOrder + ", " + PreferenceUtil.artistSongSortOrder } - + override fun artist(artistId: Long): Artist { + val songs = songRepository.songs( + songRepository.makeSongCursor( + AudioColumns.ARTIST_ID + "=?", + arrayOf(artistId.toString()), + getSongLoaderSortOrder() + ) + ) + return Artist(artistId, albumRepository.splitIntoAlbums(songs)) + } override fun artists(): List { val songs = songRepository.songs( songRepository.makeSongCursor( @@ -50,17 +59,6 @@ class RealArtistRepository( return splitIntoArtists(albumRepository.splitIntoAlbums(songs)) } - override fun artists(query: String): List { - val songs = songRepository.songs( - songRepository.makeSongCursor( - AudioColumns.ARTIST + " LIKE ?", - arrayOf("%$query%"), - getSongLoaderSortOrder() - ) - ) - return splitIntoArtists(albumRepository.splitIntoAlbums(songs)) - } - override fun albumArtists(): List { val songs = songRepository.songs( songRepository.makeSongCursor( @@ -72,6 +70,18 @@ class RealArtistRepository( return splitIntoAlbumArtists(albumRepository.splitIntoAlbums(songs)) } + override fun artists(query: String): List { + val songs = songRepository.songs( + songRepository.makeSongCursor( + AudioColumns.ARTIST + " LIKE ?", + arrayOf("%$query%"), + getSongLoaderSortOrder() + ) + ) + return splitIntoArtists(albumRepository.splitIntoAlbums(songs)) + } + + private fun splitIntoAlbumArtists(albums: List): List { return albums.groupBy { it.albumArtist } .map { @@ -84,20 +94,10 @@ class RealArtistRepository( } } - override fun artist(artistId: Long): Artist { - val songs = songRepository.songs( - songRepository.makeSongCursor( - AudioColumns.ARTIST_ID + "=?", - arrayOf(artistId.toString()), - getSongLoaderSortOrder() - ) - ) - return Artist(artistId, albumRepository.splitIntoAlbums(songs)) - } + fun splitIntoArtists(albums: List): List { return albums.groupBy { it.artistId } .map { Artist(it.key, it.value) } } - } diff --git a/app/src/main/java/code/name/monkey/retromusic/repository/PlaylistRepository.kt b/app/src/main/java/code/name/monkey/retromusic/repository/PlaylistRepository.kt index 79ad8ca7..5f215670 100644 --- a/app/src/main/java/code/name/monkey/retromusic/repository/PlaylistRepository.kt +++ b/app/src/main/java/code/name/monkey/retromusic/repository/PlaylistRepository.kt @@ -18,8 +18,9 @@ import android.content.ContentResolver import android.database.Cursor import android.provider.BaseColumns import android.provider.MediaStore -import android.provider.MediaStore.Audio.* +import android.provider.MediaStore.Audio.AudioColumns import android.provider.MediaStore.Audio.Playlists.* +import android.provider.MediaStore.Audio.PlaylistsColumns import code.name.monkey.retromusic.Constants import code.name.monkey.retromusic.extensions.getInt import code.name.monkey.retromusic.extensions.getLong @@ -150,7 +151,7 @@ class RealPlaylistRepository( val artistId = cursor.getLong(AudioColumns.ARTIST_ID) val artistName = cursor.getString(AudioColumns.ARTIST) val idInPlaylist = cursor.getLong(Members._ID) - val composer = cursor.getString(AudioColumns.COMPOSER) + val composer = cursor.getStringOrNull(AudioColumns.COMPOSER) val albumArtist = cursor.getStringOrNull("album_artist") return PlaylistSong( id, @@ -166,7 +167,7 @@ class RealPlaylistRepository( artistName, playlistId, idInPlaylist, - composer, + composer ?: "", albumArtist ) } diff --git a/app/src/main/java/code/name/monkey/retromusic/repository/SongRepository.kt b/app/src/main/java/code/name/monkey/retromusic/repository/SongRepository.kt index a8a5f83b..3155c84b 100644 --- a/app/src/main/java/code/name/monkey/retromusic/repository/SongRepository.kt +++ b/app/src/main/java/code/name/monkey/retromusic/repository/SongRepository.kt @@ -17,8 +17,8 @@ package code.name.monkey.retromusic.repository import android.content.Context import android.database.Cursor import android.provider.MediaStore -import android.provider.MediaStore.Audio -import android.provider.MediaStore.Audio.* +import android.provider.MediaStore.Audio.AudioColumns +import android.provider.MediaStore.Audio.Media import code.name.monkey.retromusic.Constants.IS_MUSIC import code.name.monkey.retromusic.Constants.baseProjection import code.name.monkey.retromusic.extensions.getInt @@ -148,17 +148,14 @@ class RealSongRepository(private val context: Context) : SongRepository { } selectionFinal = selectionFinal + " AND " + Media.DURATION + ">= " + (PreferenceUtil.filterLength * 1000) - try { - return context.contentResolver.query( - Media.EXTERNAL_CONTENT_URI, - baseProjection, - selectionFinal, - selectionValuesFinal, - sortOrder - ) - } catch (e: SecurityException) { - return null - } + + return context.contentResolver.query( + Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY), + baseProjection, + selectionFinal, + selectionValuesFinal, + sortOrder + ) } private fun generateBlacklistSelection(