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 2cc09e95..761a56e1 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 @@ -1,6 +1,6 @@ package code.name.monkey.retromusic.adapter.album -import android.content.Intent +import android.app.ActivityOptions import android.os.Bundle import android.view.LayoutInflater import android.view.View @@ -8,12 +8,13 @@ import android.view.ViewGroup import android.widget.ImageView import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager -import code.name.monkey.retromusic.activities.LyricsActivity +import code.name.monkey.retromusic.R import code.name.monkey.retromusic.fragments.AlbumCoverStyle import code.name.monkey.retromusic.glide.RetroMusicColoredTarget import code.name.monkey.retromusic.glide.SongGlideRequest import code.name.monkey.retromusic.misc.CustomFragmentStatePagerAdapter import code.name.monkey.retromusic.model.Song +import code.name.monkey.retromusic.util.NavigationUtil import code.name.monkey.retromusic.util.PreferenceUtil import com.bumptech.glide.Glide import java.util.* @@ -69,14 +70,14 @@ class AlbumCoverPagerAdapter(fm: FragmentManager, private val dataSet: ArrayList private val layout: Int get() { return when (PreferenceUtil.getInstance(activity).albumCoverStyle) { - AlbumCoverStyle.NORMAL -> code.name.monkey.retromusic.R.layout.fragment_album_cover - AlbumCoverStyle.FLAT -> code.name.monkey.retromusic.R.layout.fragment_album_flat_cover - AlbumCoverStyle.CIRCLE -> code.name.monkey.retromusic.R.layout.fragment_album_circle_cover - AlbumCoverStyle.CARD -> code.name.monkey.retromusic.R.layout.fragment_album_card_cover - AlbumCoverStyle.MATERIAL -> code.name.monkey.retromusic.R.layout.fragment_album_material_cover - AlbumCoverStyle.FULL -> code.name.monkey.retromusic.R.layout.fragment_album_full_cover - AlbumCoverStyle.FULL_CARD -> code.name.monkey.retromusic.R.layout.fragment_album_full_card_cover - else -> code.name.monkey.retromusic.R.layout.fragment_album_cover + AlbumCoverStyle.NORMAL -> R.layout.fragment_album_cover + AlbumCoverStyle.FLAT -> R.layout.fragment_album_flat_cover + AlbumCoverStyle.CIRCLE -> R.layout.fragment_album_circle_cover + AlbumCoverStyle.CARD -> R.layout.fragment_album_card_cover + AlbumCoverStyle.MATERIAL -> R.layout.fragment_album_material_cover + AlbumCoverStyle.FULL -> R.layout.fragment_album_full_cover + AlbumCoverStyle.FULL_CARD -> R.layout.fragment_album_full_card_cover + else -> R.layout.fragment_album_cover } } @@ -89,12 +90,15 @@ class AlbumCoverPagerAdapter(fm: FragmentManager, private val dataSet: ArrayList override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { val finalLayout = when { - PreferenceUtil.getInstance(activity).carouselEffect() -> code.name.monkey.retromusic.R.layout.fragment_album_carousel_cover + PreferenceUtil.getInstance(activity).carouselEffect() -> R.layout.fragment_album_carousel_cover else -> layout } val view = inflater.inflate(finalLayout, container, false) - albumCover = view.findViewById(code.name.monkey.retromusic.R.id.player_image) - albumCover.setOnClickListener { startActivity(Intent(context, LyricsActivity::class.java)) } + albumCover = view.findViewById(R.id.player_image) + albumCover.setOnClickListener { + val options = ActivityOptions.makeSceneTransitionAnimation(requireActivity(), it, getString(R.string.transition_lyrics)) + NavigationUtil.goToLyrics(requireActivity(), options) + } return view } 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 1189df52..74352780 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 @@ -109,7 +109,7 @@ abstract class AbsPlayerFragment : AbsMusicServiceFragment(), return true } R.id.action_show_lyrics -> { - NavigationUtil.goToLyrics(requireActivity()) + NavigationUtil.goToLyrics(requireActivity(), null) return true } R.id.action_equalizer -> { 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 7dd92924..5fdd933d 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 @@ -14,6 +14,7 @@ package code.name.monkey.retromusic.fragments.player.peak +import android.app.ActivityOptions import android.os.Bundle import android.view.LayoutInflater import android.view.View @@ -26,6 +27,7 @@ import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment import code.name.monkey.retromusic.glide.RetroMusicColoredTarget import code.name.monkey.retromusic.glide.SongGlideRequest import code.name.monkey.retromusic.helper.MusicPlayerRemote +import code.name.monkey.retromusic.util.NavigationUtil import com.bumptech.glide.Glide import kotlinx.android.synthetic.main.fragment_peak_player.* @@ -46,6 +48,11 @@ class PeakPlayerFragment : AbsPlayerFragment() { super.onViewCreated(view, savedInstanceState) setUpPlayerToolbar() setUpSubFragments() + + playerImage.setOnClickListener { + val options = ActivityOptions.makeSceneTransitionAnimation(requireActivity(), it, getString(R.string.transition_lyrics)) + NavigationUtil.goToLyrics(requireActivity(), options) + } } private fun setUpSubFragments() { @@ -111,10 +118,6 @@ class PeakPlayerFragment : AbsPlayerFragment() { } - override fun onPlayStateChanged() { - super.onPlayStateChanged() - } - override fun onServiceConnected() { super.onServiceConnected() updateSong() @@ -124,7 +127,4 @@ class PeakPlayerFragment : AbsPlayerFragment() { super.onPlayingMetaChanged() updateSong() } - - - } \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/util/NavigationUtil.java b/app/src/main/java/code/name/monkey/retromusic/util/NavigationUtil.java index 3de177e5..1c16240d 100755 --- a/app/src/main/java/code/name/monkey/retromusic/util/NavigationUtil.java +++ b/app/src/main/java/code/name/monkey/retromusic/util/NavigationUtil.java @@ -23,6 +23,7 @@ import android.media.audiofx.AudioEffect; import android.widget.Toast; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.ActivityCompat; @@ -116,9 +117,10 @@ public class NavigationUtil { ActivityCompat.startActivity(activity, intent, null); } - public static void goToLyrics(@NonNull Activity activity) { + public static void goToLyrics(@NonNull Activity activity, + @Nullable ActivityOptions activityOptions) { Intent intent = new Intent(activity, LyricsActivity.class); - ActivityCompat.startActivity(activity, intent, null); + ActivityCompat.startActivity(activity, intent, activityOptions != null ? activityOptions.toBundle() : null); } public static void goToGenre(@NonNull Activity activity, @NonNull Genre genre) { diff --git a/app/src/main/res/layout/activity_lyrics.xml b/app/src/main/res/layout/activity_lyrics.xml index 3062eafe..5ab20e30 100644 --- a/app/src/main/res/layout/activity_lyrics.xml +++ b/app/src/main/res/layout/activity_lyrics.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:layout_height="match_parent"> - + android:layout_height="match_parent" + android:transitionName="@string/transition_lyrics"> artist_image_transition mini_player_transition toolbar_transition + toolbar_transition \ No newline at end of file