Added link to lyrics page from peak theme

main
h4h13 2019-10-13 00:43:48 +05:30
parent cf402a27c2
commit 27190d5b74
6 changed files with 32 additions and 25 deletions

View File

@ -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
}

View File

@ -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 -> {

View File

@ -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()
}
}

View File

@ -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) {

View File

@ -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">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBarLayout"

View File

@ -9,4 +9,5 @@
<string name="transition_artist_text" translatable="false">artist_image_transition</string>
<string name="transition_mini_player" translatable="false">mini_player_transition</string>
<string name="transition_toolbar" translatable="false">toolbar_transition</string>
<string name="transition_lyrics" translatable="false">toolbar_transition</string>
</resources>