diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/LyricsActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/LyricsActivity.kt index 76bc7665..2c64c8a3 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/LyricsActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/LyricsActivity.kt @@ -20,7 +20,6 @@ import kotlinx.android.synthetic.main.activity_lyrics.* class LyricsActivity : AbsMusicServiceActivity(), MusicProgressViewUpdateHelper.Callback { private lateinit var updateHelper: MusicProgressViewUpdateHelper - private lateinit var song: Song private val googleSearchLrcUrl: String diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/SupportDevelopmentActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/SupportDevelopmentActivity.kt index 56cbe177..66bd0aa8 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/SupportDevelopmentActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/SupportDevelopmentActivity.kt @@ -28,7 +28,6 @@ import code.name.monkey.retromusic.extensions.textColorSecondary import com.anjlab.android.iab.v3.BillingProcessor import com.anjlab.android.iab.v3.SkuDetails import com.anjlab.android.iab.v3.TransactionDetails -import kotlinx.android.synthetic.main.activity_about.toolbar import kotlinx.android.synthetic.main.activity_donation.* import java.lang.ref.WeakReference import java.util.* diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsSlidingMusicPanelActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsSlidingMusicPanelActivity.kt index 3a7ff7e2..b14b44bd 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsSlidingMusicPanelActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsSlidingMusicPanelActivity.kt @@ -120,6 +120,7 @@ abstract class AbsSlidingMusicPanelActivity() : AbsMusicServiceActivity() { fun collapsePanel() { behavior.state = BottomSheetBehavior.STATE_COLLAPSED + setMiniPlayerAlphaProgress(0f) } fun expandPanel() { diff --git a/app/src/main/java/code/name/monkey/retromusic/extensions/FragmentExt.kt b/app/src/main/java/code/name/monkey/retromusic/extensions/FragmentExt.kt index 7a6086cc..8f53f469 100644 --- a/app/src/main/java/code/name/monkey/retromusic/extensions/FragmentExt.kt +++ b/app/src/main/java/code/name/monkey/retromusic/extensions/FragmentExt.kt @@ -51,10 +51,9 @@ val FragmentManager.currentNavigationFragment: Fragment? get() = primaryNavigationFragment?.childFragmentManager?.fragments?.first() fun AppCompatActivity.currentFragment(navHostId: Int): Fragment? { - val navHostFragment: NavHostFragment = - supportFragmentManager.findFragmentById(navHostId) as NavHostFragment + val navHostFragment: NavHostFragment = supportFragmentManager.findFragmentById(navHostId) as NavHostFragment navHostFragment.targetFragment - return navHostFragment?.childFragmentManager?.fragments?.first() + return navHostFragment.childFragmentManager.fragments.first() } @Suppress("UNCHECKED_CAST") 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 66f5a231..c8398f63 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 @@ -1,8 +1,9 @@ package code.name.monkey.retromusic.fragments.albums +import android.app.ActivityOptions +import android.content.Intent import android.os.Bundle -import android.view.MenuItem -import android.view.View +import android.view.* import androidx.appcompat.app.AppCompatActivity import androidx.core.os.bundleOf import androidx.lifecycle.Observer @@ -12,10 +13,16 @@ 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.common.ATHToolbarActivity.getToolbarBackgroundColor +import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper import code.name.monkey.retromusic.EXTRA_ARTIST_ID import code.name.monkey.retromusic.R +import code.name.monkey.retromusic.activities.tageditor.AbsTagEditorActivity +import code.name.monkey.retromusic.activities.tageditor.AlbumTagEditorActivity import code.name.monkey.retromusic.adapter.album.HorizontalAlbumAdapter import code.name.monkey.retromusic.adapter.song.SimpleSongAdapter +import code.name.monkey.retromusic.dialogs.AddToPlaylistDialog +import code.name.monkey.retromusic.dialogs.DeleteSongsDialog import code.name.monkey.retromusic.extensions.applyColor import code.name.monkey.retromusic.extensions.show import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment @@ -23,6 +30,7 @@ import code.name.monkey.retromusic.glide.AlbumGlideRequest import code.name.monkey.retromusic.glide.ArtistGlideRequest import code.name.monkey.retromusic.glide.RetroMusicColoredTarget import code.name.monkey.retromusic.helper.MusicPlayerRemote +import code.name.monkey.retromusic.helper.SortOrder import code.name.monkey.retromusic.model.Album import code.name.monkey.retromusic.model.Artist import code.name.monkey.retromusic.network.model.LastFmAlbum @@ -31,27 +39,29 @@ import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.RetroUtil import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import com.bumptech.glide.Glide -import kotlinx.android.synthetic.main.activity_album_content.* -import kotlinx.android.synthetic.main.activity_album_details.* +import kotlinx.android.synthetic.main.fragment_album_content.* +import kotlinx.android.synthetic.main.fragment_album_details.* import org.koin.androidx.viewmodel.ext.android.viewModel import org.koin.core.parameter.parametersOf import java.util.* class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_details), AlbumClickListener { + + private val arguments by navArgs() + private val detailsViewModel by viewModel { + parametersOf(arguments.extraAlbumId) + } + private lateinit var simpleSongAdapter: SimpleSongAdapter private lateinit var album: Album - private val args: AlbumDetailsFragmentArgs by navArgs() private val savedSortOrder: String get() = PreferenceUtil.albumDetailSongSortOrder - private val detailsViewModel by viewModel { - parametersOf(args.extraAlbumId) - } - override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) + setHasOptionsMenu(true) mainActivity.setSupportActionBar(toolbar) mainActivity.setBottomBarVisibility(View.GONE) toolbar.title = null @@ -107,12 +117,6 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det playerActivity?.removeMusicServiceEventListener(detailsViewModel) } - override fun onOptionsItemSelected(item: MenuItem): Boolean { - when (item.itemId) { - android.R.id.home -> findNavController().navigateUp() - } - return super.onOptionsItemSelected(item) - } private fun setupRecyclerView() { simpleSongAdapter = SimpleSongAdapter( @@ -239,4 +243,114 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det bundleOf("extra_album_id" to albumId) ) } + + override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { + super.onCreateOptionsMenu(menu, inflater) + inflater.inflate(R.menu.menu_album_detail, menu) + val sortOrder = menu.findItem(R.id.action_sort_order) + setUpSortOrderMenu(sortOrder.subMenu) + ToolbarContentTintHelper.handleOnCreateOptionsMenu( + requireContext(), + toolbar, + menu, + getToolbarBackgroundColor(toolbar) + ) + } + + override fun onOptionsItemSelected(item: MenuItem): Boolean { + return handleSortOrderMenuItem(item) + } + + private fun handleSortOrderMenuItem(item: MenuItem): Boolean { + var sortOrder: String? = null + val songs = simpleSongAdapter.dataSet + when (item.itemId) { + R.id.action_play_next -> { + MusicPlayerRemote.playNext(songs) + return true + } + R.id.action_add_to_current_playing -> { + MusicPlayerRemote.enqueue(songs) + return true + } + R.id.action_add_to_playlist -> { + AddToPlaylistDialog.create(songs).show(childFragmentManager, "ADD_PLAYLIST") + return true + } + R.id.action_delete_from_device -> { + DeleteSongsDialog.create(songs).show(childFragmentManager, "DELETE_SONGS") + return true + } + R.id.action_tag_editor -> { + val intent = Intent(requireContext(), AlbumTagEditorActivity::class.java) + intent.putExtra(AbsTagEditorActivity.EXTRA_ID, album.id) + val options = ActivityOptions.makeSceneTransitionAnimation( + requireActivity(), + albumCoverContainer, + "${getString(R.string.transition_album_art)}_${album.id}" + ) + startActivityForResult( + intent, + TAG_EDITOR_REQUEST, options.toBundle() + ) + return true + } + /*Sort*/ + R.id.action_sort_order_title -> sortOrder = SortOrder.AlbumSongSortOrder.SONG_A_Z + R.id.action_sort_order_title_desc -> sortOrder = SortOrder.AlbumSongSortOrder.SONG_Z_A + R.id.action_sort_order_track_list -> sortOrder = + SortOrder.AlbumSongSortOrder.SONG_TRACK_LIST + R.id.action_sort_order_artist_song_duration -> + sortOrder = SortOrder.AlbumSongSortOrder.SONG_DURATION + } + if (sortOrder != null) { + item.isChecked = true + setSaveSortOrder(sortOrder) + } + return true + } + + private fun setUpSortOrderMenu(sortOrder: SubMenu) { + when (savedSortOrder) { + SortOrder.AlbumSongSortOrder.SONG_A_Z -> sortOrder.findItem(R.id.action_sort_order_title) + .isChecked = true + SortOrder.AlbumSongSortOrder.SONG_Z_A -> sortOrder.findItem(R.id.action_sort_order_title_desc) + .isChecked = true + SortOrder.AlbumSongSortOrder.SONG_TRACK_LIST -> sortOrder.findItem(R.id.action_sort_order_track_list) + .isChecked = true + SortOrder.AlbumSongSortOrder.SONG_DURATION -> sortOrder.findItem(R.id.action_sort_order_artist_song_duration) + .isChecked = true + } + } + + private fun setSaveSortOrder(sortOrder: String) { + PreferenceUtil.albumDetailSongSortOrder = sortOrder + when (sortOrder) { + 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 + ) + }) + } + album.songs?.let { simpleSongAdapter.swapDataSet(it) } + } + + companion object { + const val TAG_EDITOR_REQUEST = 9002 + } } \ No newline at end of file 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 d834ae31..38dec7c6 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 @@ -1,23 +1,28 @@ package code.name.monkey.retromusic.fragments.artists +import android.content.Intent import android.os.Bundle import android.text.Spanned +import android.view.Menu +import android.view.MenuInflater +import android.view.MenuItem import android.view.View import androidx.core.os.bundleOf import androidx.core.text.HtmlCompat import androidx.lifecycle.Observer import androidx.navigation.fragment.FragmentNavigatorExtras import androidx.navigation.fragment.findNavController +import androidx.navigation.fragment.navArgs import androidx.recyclerview.widget.DefaultItemAnimator import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.LinearLayoutManager -import code.name.monkey.retromusic.EXTRA_ARTIST_ID import code.name.monkey.retromusic.R import code.name.monkey.retromusic.adapter.album.HorizontalAlbumAdapter import code.name.monkey.retromusic.adapter.song.SimpleSongAdapter +import code.name.monkey.retromusic.dialogs.AddToPlaylistDialog import code.name.monkey.retromusic.extensions.applyColor -import code.name.monkey.retromusic.extensions.extraNotNull import code.name.monkey.retromusic.extensions.show +import code.name.monkey.retromusic.extensions.showToast import code.name.monkey.retromusic.fragments.albums.AlbumClickListener import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment import code.name.monkey.retromusic.glide.ArtistGlideRequest @@ -25,12 +30,13 @@ import code.name.monkey.retromusic.glide.RetroMusicColoredTarget import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.model.Artist import code.name.monkey.retromusic.network.model.LastFmArtist +import code.name.monkey.retromusic.util.CustomArtistImageUtil import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.RetroUtil import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import com.bumptech.glide.Glide -import kotlinx.android.synthetic.main.activity_artist_content.* -import kotlinx.android.synthetic.main.activity_artist_details.* +import kotlinx.android.synthetic.main.fragment_artist_content.* +import kotlinx.android.synthetic.main.fragment_artist_details.* import org.koin.androidx.viewmodel.ext.android.viewModel import org.koin.core.parameter.parametersOf import java.util.* @@ -38,20 +44,21 @@ import kotlin.collections.ArrayList class ArtistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_artist_details), AlbumClickListener { + private val arguments by navArgs() + private val detailsViewModel: ArtistDetailsViewModel by viewModel { + parametersOf(arguments.extraArtistId) + } - private var biography: Spanned? = null private lateinit var artist: Artist private lateinit var songAdapter: SimpleSongAdapter private lateinit var albumAdapter: HorizontalAlbumAdapter private var forceDownload: Boolean = false private var lang: String? = null - - private val detailsViewModel: ArtistDetailsViewModel by viewModel { - parametersOf(extraNotNull(EXTRA_ARTIST_ID).value) - } + private var biography: Spanned? = null override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) + setHasOptionsMenu(true) mainActivity.setSupportActionBar(toolbar) mainActivity.setBottomBarVisibility(View.GONE) toolbar.title = null @@ -188,4 +195,52 @@ class ArtistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_artist_d ) ) } + + override fun onOptionsItemSelected(item: MenuItem): Boolean { + return handleSortOrderMenuItem(item) + } + + private fun handleSortOrderMenuItem(item: MenuItem): Boolean { + val songs = artist.songs + when (item.itemId) { + android.R.id.home -> findNavController().navigateUp() + R.id.action_play_next -> { + MusicPlayerRemote.playNext(songs) + return true + } + R.id.action_add_to_current_playing -> { + MusicPlayerRemote.enqueue(songs) + return true + } + R.id.action_add_to_playlist -> { + AddToPlaylistDialog.create(songs).show(childFragmentManager, "ADD_PLAYLIST") + return true + } + R.id.action_set_artist_image -> { + val intent = Intent(Intent.ACTION_GET_CONTENT) + intent.type = "image/*" + startActivityForResult( + Intent.createChooser(intent, getString(R.string.pick_from_local_storage)), + REQUEST_CODE_SELECT_IMAGE + ) + return true + } + R.id.action_reset_artist_image -> { + showToast(resources.getString(R.string.updating)) + CustomArtistImageUtil.getInstance(requireContext()).resetCustomArtistImage(artist) + forceDownload = true + return true + } + } + return true + } + + override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { + super.onCreateOptionsMenu(menu, inflater) + inflater.inflate(R.menu.menu_artist_detail, menu) + } + + companion object { + const val REQUEST_CODE_SELECT_IMAGE = 9002 + } } \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsPlayerFragment.kt index 62089b49..f37423fe 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsPlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsPlayerFragment.kt @@ -87,6 +87,7 @@ abstract class AbsPlayerFragment(@LayoutRes layout: Int) : AbsMainActivityFragme return true } R.id.action_go_to_album -> { + mainActivity.collapsePanel() requireActivity().findNavController(R.id.fragment_container).navigate( R.id.albumDetailsFragment, bundleOf(EXTRA_ALBUM_ID to song.albumId) @@ -94,6 +95,7 @@ abstract class AbsPlayerFragment(@LayoutRes layout: Int) : AbsMainActivityFragme return true } R.id.action_go_to_artist -> { + mainActivity.collapsePanel() requireActivity().findNavController(R.id.fragment_container).navigate( R.id.artistDetailsFragment, bundleOf(EXTRA_ARTIST_ID to song.artistId) diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/genres/GenreDetailsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/genres/GenreDetailsFragment.kt index bb9fa8fb..0cbeed7b 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/genres/GenreDetailsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/genres/GenreDetailsFragment.kt @@ -1,16 +1,19 @@ package code.name.monkey.retromusic.fragments.genres import android.os.Bundle +import android.view.Menu +import android.view.MenuInflater +import android.view.MenuItem import android.view.View +import androidx.navigation.fragment.navArgs import androidx.recyclerview.widget.DefaultItemAnimator import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView -import code.name.monkey.retromusic.EXTRA_GENRE import code.name.monkey.retromusic.R import code.name.monkey.retromusic.adapter.song.SongAdapter import code.name.monkey.retromusic.extensions.dipToPix -import code.name.monkey.retromusic.extensions.extraNotNull import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment +import code.name.monkey.retromusic.helper.menu.GenreMenuHelper import code.name.monkey.retromusic.model.Genre import code.name.monkey.retromusic.model.Song import kotlinx.android.synthetic.main.fragment_playlist_detail.* @@ -19,16 +22,20 @@ import org.koin.core.parameter.parametersOf import java.util.* class GenreDetailsFragment : AbsMainActivityFragment(R.layout.fragment_playlist_detail) { + private val arguments by navArgs() private val detailsViewModel: GenreDetailsViewModel by viewModel { - parametersOf(extraNotNull(EXTRA_GENRE).value) + parametersOf(arguments.extraGenre) } private lateinit var genre: Genre private lateinit var songAdapter: SongAdapter - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) + + override fun onActivityCreated(savedInstanceState: Bundle?) { + super.onActivityCreated(savedInstanceState) + setHasOptionsMenu(true) mainActivity.addMusicServiceEventListener(detailsViewModel) mainActivity.setSupportActionBar(toolbar) + mainActivity.setBottomBarVisibility(View.GONE) setupRecyclerView() detailsViewModel.getSongs().observe(viewLifecycleOwner, androidx.lifecycle.Observer { @@ -73,4 +80,13 @@ class GenreDetailsFragment : AbsMainActivityFragment(R.layout.fragment_playlist_ val height = dipToPix(52f).toInt() recyclerView.setPadding(0, 0, 0, height) } + + override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { + super.onCreateOptionsMenu(menu, inflater) + inflater.inflate(R.menu.menu_genre_detail, menu) + } + + override fun onOptionsItemSelected(item: MenuItem): Boolean { + return GenreMenuHelper.handleMenuClick(requireActivity(), genre, item) + } } \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/playlists/PlaylistDetailsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/playlists/PlaylistDetailsFragment.kt index 872128e6..474df7dd 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/playlists/PlaylistDetailsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/playlists/PlaylistDetailsFragment.kt @@ -3,17 +3,18 @@ package code.name.monkey.retromusic.fragments.playlists import android.os.Bundle import android.view.Menu import android.view.MenuInflater +import android.view.MenuItem import android.view.View import androidx.lifecycle.Observer +import androidx.navigation.fragment.navArgs import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView -import code.name.monkey.retromusic.EXTRA_PLAYLIST import code.name.monkey.retromusic.R import code.name.monkey.retromusic.adapter.song.OrderablePlaylistSongAdapter import code.name.monkey.retromusic.adapter.song.SongAdapter import code.name.monkey.retromusic.extensions.dipToPix -import code.name.monkey.retromusic.extensions.extraNotNull import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment +import code.name.monkey.retromusic.helper.menu.PlaylistMenuHelper import code.name.monkey.retromusic.model.AbsCustomPlaylist import code.name.monkey.retromusic.model.Playlist import code.name.monkey.retromusic.model.Song @@ -26,21 +27,25 @@ import org.koin.androidx.viewmodel.ext.android.viewModel import org.koin.core.parameter.parametersOf class PlaylistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_playlist_detail) { + private val arguments by navArgs() private val viewModel: PlaylistDetailsViewModel by viewModel { - parametersOf(extraNotNull(EXTRA_PLAYLIST).value) + parametersOf(arguments.extraPlaylist) } + private lateinit var playlist: Playlist private lateinit var adapter: SongAdapter private var wrappedAdapter: RecyclerView.Adapter<*>? = null private var recyclerViewDragDropManager: RecyclerViewDragDropManager? = null - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) + override fun onActivityCreated(savedInstanceState: Bundle?) { + super.onActivityCreated(savedInstanceState) + setHasOptionsMenu(true) mainActivity.addMusicServiceEventListener(viewModel) mainActivity.setSupportActionBar(toolbar) + mainActivity.setBottomBarVisibility(View.GONE) - playlist = extraNotNull(EXTRA_PLAYLIST).value + playlist = arguments.extraPlaylist setUpRecyclerView() @@ -52,7 +57,6 @@ class PlaylistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_playli playlist = it toolbar.title = it.name }) - } private fun setUpRecyclerView() { @@ -99,12 +103,15 @@ class PlaylistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_playli override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { super.onCreateOptionsMenu(menu, inflater) - inflater.inflate( - if (playlist is AbsCustomPlaylist) R.menu.menu_smart_playlist_detail - else R.menu.menu_playlist_detail, menu - ) + val menuRes = if (playlist is AbsCustomPlaylist) + R.menu.menu_smart_playlist_detail + else R.menu.menu_playlist_detail + inflater.inflate(menuRes, menu) } + override fun onOptionsItemSelected(item: MenuItem): Boolean { + return PlaylistMenuHelper.handleMenuClick(requireActivity(), playlist, item) + } private fun checkForPadding() { val height = dipToPix(52f) @@ -147,7 +154,7 @@ class PlaylistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_playli super.onDestroy() } - fun showEmptyView() { + private fun showEmptyView() { empty.visibility = View.VISIBLE emptyText.visibility = View.VISIBLE } @@ -159,4 +166,5 @@ class PlaylistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_playli showEmptyView() } } + } \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/helper/menu/GenreMenuHelper.kt b/app/src/main/java/code/name/monkey/retromusic/helper/menu/GenreMenuHelper.kt index af790d95..b6238a85 100644 --- a/app/src/main/java/code/name/monkey/retromusic/helper/menu/GenreMenuHelper.kt +++ b/app/src/main/java/code/name/monkey/retromusic/helper/menu/GenreMenuHelper.kt @@ -16,8 +16,7 @@ package code.name.monkey.retromusic.helper.menu import android.app.Activity import android.view.MenuItem -import androidx.appcompat.app.AppCompatActivity - +import androidx.fragment.app.FragmentActivity import code.name.monkey.retromusic.R import code.name.monkey.retromusic.dialogs.AddToPlaylistDialog import code.name.monkey.retromusic.helper.MusicPlayerRemote @@ -27,7 +26,7 @@ import code.name.monkey.retromusic.model.Song import java.util.* object GenreMenuHelper { - fun handleMenuClick(activity: AppCompatActivity, genre: Genre, item: MenuItem): Boolean { + fun handleMenuClick(activity: FragmentActivity, genre: Genre, item: MenuItem): Boolean { when (item.itemId) { R.id.action_play -> { MusicPlayerRemote.openQueue(getGenreSongs(activity, genre), 0, true) diff --git a/app/src/main/java/code/name/monkey/retromusic/lyrics/LrcView.java b/app/src/main/java/code/name/monkey/retromusic/lyrics/LrcView.java index 707ad20a..abd4d750 100644 --- a/app/src/main/java/code/name/monkey/retromusic/lyrics/LrcView.java +++ b/app/src/main/java/code/name/monkey/retromusic/lyrics/LrcView.java @@ -89,11 +89,6 @@ public class LrcView extends View { } } }; - - public LrcView(Context context) { - this(context, null); - } - /** * 手势监听器 */ @@ -151,6 +146,10 @@ public class LrcView extends View { } }; + public LrcView(Context context) { + this(context, null); + } + public LrcView(Context context, AttributeSet attrs) { this(context, attrs, 0); } diff --git a/app/src/main/java/code/name/monkey/retromusic/model/CategoryInfo.java b/app/src/main/java/code/name/monkey/retromusic/model/CategoryInfo.java index ce703790..f8689439 100644 --- a/app/src/main/java/code/name/monkey/retromusic/model/CategoryInfo.java +++ b/app/src/main/java/code/name/monkey/retromusic/model/CategoryInfo.java @@ -59,7 +59,7 @@ public class CategoryInfo implements Parcelable { } public enum Category { - Home(R.id.action_home, R.string.for_you, R.drawable.ic_baseline), + Home(R.id.action_home, R.string.for_you, R.drawable.ic_face), Songs(R.id.action_song, R.string.songs, R.drawable.ic_audiotrack), Albums(R.id.action_album, R.string.albums, R.drawable.ic_album), Artists(R.id.action_artist, R.string.artists, R.drawable.ic_artist), diff --git a/app/src/main/res/drawable/ic_baseline.xml b/app/src/main/res/drawable/ic_baseline.xml deleted file mode 100644 index ef34eabe..00000000 --- a/app/src/main/res/drawable/ic_baseline.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_car.xml b/app/src/main/res/drawable/ic_car.xml new file mode 100644 index 00000000..e3839d9b --- /dev/null +++ b/app/src/main/res/drawable/ic_car.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_face.xml b/app/src/main/res/drawable/ic_face.xml new file mode 100644 index 00000000..602d3dc1 --- /dev/null +++ b/app/src/main/res/drawable/ic_face.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout-land/activity_album_details.xml b/app/src/main/res/layout-land/activity_album_details.xml deleted file mode 100644 index 3376fb29..00000000 --- a/app/src/main/res/layout-land/activity_album_details.xml +++ /dev/null @@ -1,141 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout-land/activity_artist_details.xml b/app/src/main/res/layout-land/activity_artist_details.xml deleted file mode 100644 index c697c814..00000000 --- a/app/src/main/res/layout-land/activity_artist_details.xml +++ /dev/null @@ -1,119 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout-land/fragment_album_details.xml b/app/src/main/res/layout-land/fragment_album_details.xml index 32d4c7f6..4b4d503e 100644 --- a/app/src/main/res/layout-land/fragment_album_details.xml +++ b/app/src/main/res/layout-land/fragment_album_details.xml @@ -133,7 +133,7 @@ - + diff --git a/app/src/main/res/layout-land/fragment_artist_details.xml b/app/src/main/res/layout-land/fragment_artist_details.xml index c697c814..2a0cae06 100644 --- a/app/src/main/res/layout-land/fragment_artist_details.xml +++ b/app/src/main/res/layout-land/fragment_artist_details.xml @@ -112,7 +112,7 @@ - + diff --git a/app/src/main/res/layout-xlarge/activity_about_content.xml b/app/src/main/res/layout-xlarge/fragment_about_content.xml similarity index 100% rename from app/src/main/res/layout-xlarge/activity_about_content.xml rename to app/src/main/res/layout-xlarge/fragment_about_content.xml diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml deleted file mode 100644 index 6fb10ecd..00000000 --- a/app/src/main/res/layout/activity_about.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_album_details.xml b/app/src/main/res/layout/activity_album_details.xml deleted file mode 100755 index 473a20ee..00000000 --- a/app/src/main/res/layout/activity_album_details.xml +++ /dev/null @@ -1,141 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_artist_details.xml b/app/src/main/res/layout/activity_artist_details.xml deleted file mode 100755 index a222a336..00000000 --- a/app/src/main/res/layout/activity_artist_details.xml +++ /dev/null @@ -1,126 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_drive_mode.xml b/app/src/main/res/layout/activity_drive_mode.xml index e7eb13d8..5e2c17a2 100644 --- a/app/src/main/res/layout/activity_drive_mode.xml +++ b/app/src/main/res/layout/activity_drive_mode.xml @@ -50,7 +50,6 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> - + + @@ -161,10 +173,10 @@ android:id="@+id/songText" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="4dp" + android:layout_marginTop="8dp" android:gravity="center" android:maxLines="3" - android:textAppearance="@style/TextViewHeadline6" + android:textAppearance="@style/TextViewHeadline5" android:textColor="@color/md_grey_200" tools:text="@tools:sample/lorem/random" /> diff --git a/app/src/main/res/layout/activity_lyrics.xml b/app/src/main/res/layout/activity_lyrics.xml index d95ba442..ee6c0382 100644 --- a/app/src/main/res/layout/activity_lyrics.xml +++ b/app/src/main/res/layout/activity_lyrics.xml @@ -6,10 +6,30 @@ android:layout_height="match_parent" android:transitionName="@string/transition_lyrics"> - + + + android:layout_gravity="bottom" + android:padding="0dp" + app:contentInsetLeft="0dp" + app:contentInsetStart="0dp" + app:contentInsetStartWithNavigation="0dp" + app:hideOnScroll="true" + app:titleMargin="0dp" + app:titleMarginStart="0dp" + tools:backgroundTint="@color/md_red_400"> - - - - + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_playlist_detail.xml b/app/src/main/res/layout/activity_playlist_detail.xml deleted file mode 100644 index af405033..00000000 --- a/app/src/main/res/layout/activity_playlist_detail.xml +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_search.xml b/app/src/main/res/layout/activity_search.xml deleted file mode 100755 index 6d0b4087..00000000 --- a/app/src/main/res/layout/activity_search.xml +++ /dev/null @@ -1,128 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml deleted file mode 100755 index 4e115feb..00000000 --- a/app/src/main/res/layout/activity_settings.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/fragment_about.xml b/app/src/main/res/layout/fragment_about.xml index 33efb3af..d64fb15a 100644 --- a/app/src/main/res/layout/fragment_about.xml +++ b/app/src/main/res/layout/fragment_about.xml @@ -7,5 +7,5 @@ android:overScrollMode="never" app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"> - + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_about_content.xml b/app/src/main/res/layout/fragment_about_content.xml similarity index 100% rename from app/src/main/res/layout/activity_about_content.xml rename to app/src/main/res/layout/fragment_about_content.xml diff --git a/app/src/main/res/layout/activity_album_content.xml b/app/src/main/res/layout/fragment_album_content.xml similarity index 100% rename from app/src/main/res/layout/activity_album_content.xml rename to app/src/main/res/layout/fragment_album_content.xml diff --git a/app/src/main/res/layout/fragment_album_details.xml b/app/src/main/res/layout/fragment_album_details.xml index 8a24f5e1..f84cb563 100644 --- a/app/src/main/res/layout/fragment_album_details.xml +++ b/app/src/main/res/layout/fragment_album_details.xml @@ -97,7 +97,7 @@ android:layout_marginStart="16dp" android:layout_marginEnd="16dp" android:maxLines="3" - android:textAppearance="@style/TextViewHeadline4" + android:textAppearance="@style/TextViewHeadline5" android:textColor="?android:attr/textColorPrimary" android:textStyle="bold" app:layout_constrainedWidth="true" @@ -126,7 +126,7 @@ tools:text="@tools:sample/lorem/random" /> + tools:layout="@layout/fragment_album_details"> diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 6f0c9387..8d29c063 100755 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -125,9 +125,7 @@ this_year - - @layout/activity_album_details - + System default Afrikaans