Added more themes
This commit is contained in:
parent
dbb9c9828b
commit
567cf0781f
18 changed files with 1565 additions and 156 deletions
|
@ -23,9 +23,11 @@ import code.name.monkey.retromusic.ui.fragments.player.adaptive.AdaptiveFragment
|
||||||
import code.name.monkey.retromusic.ui.fragments.player.blur.BlurPlayerFragment
|
import code.name.monkey.retromusic.ui.fragments.player.blur.BlurPlayerFragment
|
||||||
import code.name.monkey.retromusic.ui.fragments.player.card.CardFragment
|
import code.name.monkey.retromusic.ui.fragments.player.card.CardFragment
|
||||||
import code.name.monkey.retromusic.ui.fragments.player.cardblur.CardBlurFragment
|
import code.name.monkey.retromusic.ui.fragments.player.cardblur.CardBlurFragment
|
||||||
|
import code.name.monkey.retromusic.ui.fragments.player.color.ColorFragment
|
||||||
import code.name.monkey.retromusic.ui.fragments.player.fit.FitFragment
|
import code.name.monkey.retromusic.ui.fragments.player.fit.FitFragment
|
||||||
import code.name.monkey.retromusic.ui.fragments.player.flat.FlatPlayerFragment
|
import code.name.monkey.retromusic.ui.fragments.player.flat.FlatPlayerFragment
|
||||||
import code.name.monkey.retromusic.ui.fragments.player.full.FullPlayerFragment
|
import code.name.monkey.retromusic.ui.fragments.player.full.FullPlayerFragment
|
||||||
|
import code.name.monkey.retromusic.ui.fragments.player.material.MaterialFragment
|
||||||
import code.name.monkey.retromusic.ui.fragments.player.normal.PlayerFragment
|
import code.name.monkey.retromusic.ui.fragments.player.normal.PlayerFragment
|
||||||
import code.name.monkey.retromusic.ui.fragments.player.plain.PlainPlayerFragment
|
import code.name.monkey.retromusic.ui.fragments.player.plain.PlainPlayerFragment
|
||||||
import code.name.monkey.retromusic.ui.fragments.player.simple.SimplePlayerFragment
|
import code.name.monkey.retromusic.ui.fragments.player.simple.SimplePlayerFragment
|
||||||
|
@ -229,6 +231,8 @@ abstract class AbsSlidingMusicPanelActivity protected constructor() : AbsMusicSe
|
||||||
NowPlayingScreen.FULL -> FullPlayerFragment()
|
NowPlayingScreen.FULL -> FullPlayerFragment()
|
||||||
NowPlayingScreen.PLAIN -> PlainPlayerFragment()
|
NowPlayingScreen.PLAIN -> PlainPlayerFragment()
|
||||||
NowPlayingScreen.SIMPLE -> SimplePlayerFragment()
|
NowPlayingScreen.SIMPLE -> SimplePlayerFragment()
|
||||||
|
NowPlayingScreen.MATERIAL -> MaterialFragment()
|
||||||
|
NowPlayingScreen.COLOR->ColorFragment()
|
||||||
else -> PlayerFragment()
|
else -> PlayerFragment()
|
||||||
} // must implement AbsPlayerFragment
|
} // must implement AbsPlayerFragment
|
||||||
supportFragmentManager.beginTransaction().replace(R.id.player_fragment_container, fragment).commit()
|
supportFragmentManager.beginTransaction().replace(R.id.player_fragment_container, fragment).commit()
|
||||||
|
|
|
@ -11,13 +11,13 @@ public enum NowPlayingScreen {
|
||||||
FULL(R.string.full, R.drawable.np_full, 2),
|
FULL(R.string.full, R.drawable.np_full, 2),
|
||||||
PLAIN(R.string.plain, R.drawable.np_plain, 3),
|
PLAIN(R.string.plain, R.drawable.np_plain, 3),
|
||||||
BLUR(R.string.blur, R.drawable.np_blur, 4),
|
BLUR(R.string.blur, R.drawable.np_blur, 4),
|
||||||
//COLOR(R.string.color, R.drawable.np_color, 5),
|
COLOR(R.string.color, R.drawable.np_color, 5),
|
||||||
CARD(R.string.card, R.drawable.np_card, 6),
|
CARD(R.string.card, R.drawable.np_card, 6),
|
||||||
//TINY(R.string.tiny, R.drawable.np_tiny, 7),
|
//TINY(R.string.tiny, R.drawable.np_tiny, 7),
|
||||||
SIMPLE(R.string.simple, R.drawable.np_simple, 8),
|
SIMPLE(R.string.simple, R.drawable.np_simple, 8),
|
||||||
BLUR_CARD(R.string.blur_card, R.drawable.np_blur_card, 9),
|
BLUR_CARD(R.string.blur_card, R.drawable.np_blur_card, 9),
|
||||||
ADAPTIVE(R.string.adaptive, R.drawable.np_adaptive, 10),
|
ADAPTIVE(R.string.adaptive, R.drawable.np_adaptive, 10),
|
||||||
//MATERIAL(R.string.material, R.drawable.np_material, 11),
|
MATERIAL(R.string.material, R.drawable.np_material, 11),
|
||||||
FIT(R.string.fit, R.drawable.np_adaptive, 12);
|
FIT(R.string.fit, R.drawable.np_adaptive, 12);
|
||||||
|
|
||||||
@StringRes
|
@StringRes
|
||||||
|
|
|
@ -103,7 +103,7 @@ class VolumeFragment : Fragment(), SeekBar.OnSeekBarChangeListener, OnAudioVolum
|
||||||
volumeUp.setColorFilter(newColor, PorterDuff.Mode.SRC_IN)
|
volumeUp.setColorFilter(newColor, PorterDuff.Mode.SRC_IN)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setTintable(color: Int) {
|
fun setTintable(color: Int) {
|
||||||
setProgressBarColor(color)
|
setProgressBarColor(color)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,7 @@ class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setUpShuffleButton() {
|
private fun setUpShuffleButton() {
|
||||||
shuffleButton.setOnClickListener { v -> MusicPlayerRemote.toggleShuffleMode() }
|
shuffleButton.setOnClickListener { MusicPlayerRemote.toggleShuffleMode() }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateShuffleState() {
|
override fun updateShuffleState() {
|
||||||
|
|
|
@ -0,0 +1,112 @@
|
||||||
|
package code.name.monkey.retromusic.ui.fragments.player.card
|
||||||
|
|
||||||
|
import android.graphics.Color
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.appcompat.widget.Toolbar
|
||||||
|
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||||
|
import code.name.monkey.retromusic.R
|
||||||
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
|
import code.name.monkey.retromusic.model.Song
|
||||||
|
import code.name.monkey.retromusic.ui.fragments.base.AbsPlayerFragment
|
||||||
|
import code.name.monkey.retromusic.ui.fragments.player.PlayerAlbumCoverFragment
|
||||||
|
import code.name.monkey.retromusic.ui.fragments.player.normal.PlayerFragment
|
||||||
|
import kotlinx.android.synthetic.main.fragment_card_player.*
|
||||||
|
|
||||||
|
class CardFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Callbacks {
|
||||||
|
override fun toolbarGet(): Toolbar {
|
||||||
|
return playerToolbar
|
||||||
|
}
|
||||||
|
|
||||||
|
private var lastColor: Int = 0
|
||||||
|
override val paletteColor: Int
|
||||||
|
get() = lastColor
|
||||||
|
|
||||||
|
private lateinit var playbackControlsFragment: CardPlaybackControlsFragment
|
||||||
|
|
||||||
|
override fun onShow() {
|
||||||
|
playbackControlsFragment.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onHide() {
|
||||||
|
playbackControlsFragment.hide()
|
||||||
|
onBackPressed()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBackPressed(): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun toolbarIconColor(): Int {
|
||||||
|
return Color.WHITE
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onColorChanged(color: Int) {
|
||||||
|
playbackControlsFragment.setDark(color)
|
||||||
|
lastColor = color
|
||||||
|
callbacks!!.onPaletteColorChanged()
|
||||||
|
|
||||||
|
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, Color.WHITE, activity)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun toggleFavorite(song: Song) {
|
||||||
|
super.toggleFavorite(song)
|
||||||
|
if (song.id == MusicPlayerRemote.currentSong.id) {
|
||||||
|
updateIsFavorite()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onFavoriteToggled() {
|
||||||
|
toggleFavorite(MusicPlayerRemote.currentSong)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?): View? {
|
||||||
|
|
||||||
|
return inflater.inflate(R.layout.fragment_card_player, container, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
setUpSubFragments()
|
||||||
|
setUpPlayerToolbar()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpSubFragments() {
|
||||||
|
playbackControlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as CardPlaybackControlsFragment
|
||||||
|
val playerAlbumCoverFragment = childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
||||||
|
playerAlbumCoverFragment.setCallbacks(this)
|
||||||
|
playerAlbumCoverFragment.removeSlideEffect()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpPlayerToolbar() {
|
||||||
|
playerToolbar.inflateMenu(R.menu.menu_player)
|
||||||
|
playerToolbar.setNavigationOnClickListener { activity!!.onBackPressed() }
|
||||||
|
playerToolbar.setOnMenuItemClickListener(this)
|
||||||
|
|
||||||
|
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, Color.WHITE, activity)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onServiceConnected() {
|
||||||
|
updateIsFavorite()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPlayingMetaChanged() {
|
||||||
|
updateIsFavorite()
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
fun newInstance(): PlayerFragment {
|
||||||
|
val args = Bundle()
|
||||||
|
val fragment = PlayerFragment()
|
||||||
|
fragment.arguments = args
|
||||||
|
return fragment
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,230 @@
|
||||||
|
package code.name.monkey.retromusic.ui.fragments.player.card
|
||||||
|
|
||||||
|
import android.animation.ObjectAnimator
|
||||||
|
import android.graphics.PorterDuff
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.view.animation.LinearInterpolator
|
||||||
|
import android.widget.SeekBar
|
||||||
|
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||||
|
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||||
|
import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||||
|
import code.name.monkey.appthemehelper.util.TintHelper
|
||||||
|
import code.name.monkey.retromusic.R
|
||||||
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
|
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
|
||||||
|
import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
|
||||||
|
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
||||||
|
import code.name.monkey.retromusic.service.MusicService
|
||||||
|
import code.name.monkey.retromusic.ui.fragments.base.AbsPlayerControlsFragment
|
||||||
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
|
import kotlinx.android.synthetic.main.fragment_card_player_playback_controls.*
|
||||||
|
import kotlinx.android.synthetic.main.media_button.*
|
||||||
|
|
||||||
|
class CardPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
||||||
|
|
||||||
|
private var lastPlaybackControlsColor: Int = 0
|
||||||
|
private var lastDisabledPlaybackControlsColor: Int = 0
|
||||||
|
private var progressViewUpdateHelper: MusicProgressViewUpdateHelper? = null
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?): View? {
|
||||||
|
return inflater.inflate(R.layout.fragment_card_player_playback_controls, container, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
setUpMusicControllers()
|
||||||
|
|
||||||
|
setupControls()
|
||||||
|
|
||||||
|
playPauseButton.setOnClickListener {
|
||||||
|
if (MusicPlayerRemote.isPlaying) {
|
||||||
|
MusicPlayerRemote.pauseSong()
|
||||||
|
} else {
|
||||||
|
MusicPlayerRemote.resumePlaying()
|
||||||
|
}
|
||||||
|
showBonceAnimation(playPauseButton)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupControls() {
|
||||||
|
image.apply {
|
||||||
|
setImageResource(R.drawable.ic_play_circle_filled_white_24dp)
|
||||||
|
val iconPadding = activity!!.resources.getDimensionPixelSize(R.dimen.list_item_image_icon_padding)
|
||||||
|
setPadding(iconPadding, iconPadding, iconPadding, iconPadding)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateSong() {
|
||||||
|
val song = MusicPlayerRemote.currentSong
|
||||||
|
songTitle.text = song.title
|
||||||
|
songText.text = song.artistName
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
progressViewUpdateHelper!!.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPause() {
|
||||||
|
super.onPause()
|
||||||
|
progressViewUpdateHelper!!.stop()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onServiceConnected() {
|
||||||
|
updatePlayPauseDrawableState()
|
||||||
|
updateRepeatState()
|
||||||
|
updateShuffleState()
|
||||||
|
updateSong()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPlayingMetaChanged() {
|
||||||
|
super.onPlayingMetaChanged()
|
||||||
|
updateSong()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPlayStateChanged() {
|
||||||
|
updatePlayPauseDrawableState()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onRepeatModeChanged() {
|
||||||
|
updateRepeatState()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onShuffleModeChanged() {
|
||||||
|
updateShuffleState()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setDark(color: Int) {
|
||||||
|
image!!.setColorFilter(color, PorterDuff.Mode.SRC_IN)
|
||||||
|
if (ColorUtil.isColorLight(ATHUtil.resolveColor(context, android.R.attr.windowBackground))) {
|
||||||
|
lastPlaybackControlsColor = MaterialValueHelper.getSecondaryTextColor(activity, true)
|
||||||
|
lastDisabledPlaybackControlsColor = MaterialValueHelper.getSecondaryDisabledTextColor(activity, true)
|
||||||
|
} else {
|
||||||
|
lastPlaybackControlsColor = MaterialValueHelper.getPrimaryTextColor(activity, false)
|
||||||
|
lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(activity, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
updateRepeatState()
|
||||||
|
updateShuffleState()
|
||||||
|
updatePrevNextColor()
|
||||||
|
updatePlayPauseColor()
|
||||||
|
updateProgressTextColor()
|
||||||
|
|
||||||
|
TintHelper.setTintAuto(playPauseButton!!, MaterialValueHelper.getPrimaryTextColor(context, ColorUtil.isColorLight(color)), false)
|
||||||
|
TintHelper.setTintAuto(playPauseButton!!, color, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updatePlayPauseColor() {
|
||||||
|
//playPauseButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN);
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpPlayPauseFab() {
|
||||||
|
playPauseButton.setOnClickListener(PlayPauseButtonOnClickHandler())
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updatePlayPauseDrawableState() {
|
||||||
|
if (MusicPlayerRemote.isPlaying) {
|
||||||
|
playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp)
|
||||||
|
} else {
|
||||||
|
playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_24dp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpMusicControllers() {
|
||||||
|
setUpPlayPauseFab()
|
||||||
|
setUpPrevNext()
|
||||||
|
setUpRepeatButton()
|
||||||
|
setUpShuffleButton()
|
||||||
|
setUpProgressSlider()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpPrevNext() {
|
||||||
|
updatePrevNextColor()
|
||||||
|
nextButton.setOnClickListener { MusicPlayerRemote.playNextSong() }
|
||||||
|
previousButton.setOnClickListener { MusicPlayerRemote.back() }
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updatePrevNextColor() {
|
||||||
|
nextButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
previousButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpShuffleButton() {
|
||||||
|
shuffleButton.setOnClickListener { MusicPlayerRemote.toggleShuffleMode() }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun updateShuffleState() {
|
||||||
|
when (MusicPlayerRemote.shuffleMode) {
|
||||||
|
MusicService.SHUFFLE_MODE_SHUFFLE -> shuffleButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
else -> shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpRepeatButton() {
|
||||||
|
repeatButton.setOnClickListener { MusicPlayerRemote.cycleRepeatMode() }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun updateRepeatState() {
|
||||||
|
when (MusicPlayerRemote.repeatMode) {
|
||||||
|
MusicService.REPEAT_MODE_NONE -> {
|
||||||
|
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||||
|
repeatButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
}
|
||||||
|
MusicService.REPEAT_MODE_ALL -> {
|
||||||
|
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||||
|
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
}
|
||||||
|
MusicService.REPEAT_MODE_THIS -> {
|
||||||
|
repeatButton.setImageResource(R.drawable.ic_repeat_one_white_24dp)
|
||||||
|
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onUpdateProgressViews(progress: Int, total: Int) {
|
||||||
|
progressSlider.max = total
|
||||||
|
|
||||||
|
val animator = ObjectAnimator.ofInt(progressSlider, "progress", progress)
|
||||||
|
animator.duration = 1500
|
||||||
|
animator.interpolator = LinearInterpolator()
|
||||||
|
animator.start()
|
||||||
|
|
||||||
|
songTotalTime.text = MusicUtil.getReadableDurationString(total.toLong())
|
||||||
|
songCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong())
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateProgressTextColor() {
|
||||||
|
val color = MaterialValueHelper.getPrimaryTextColor(context, false)
|
||||||
|
songTotalTime!!.setTextColor(color)
|
||||||
|
songCurrentProgress!!.setTextColor(color)
|
||||||
|
}
|
||||||
|
|
||||||
|
public override fun show() {
|
||||||
|
//Ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
public override fun hide() {
|
||||||
|
//Ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setUpProgressSlider() {
|
||||||
|
progressSlider.setOnSeekBarChangeListener(object : SimpleOnSeekbarChangeListener() {
|
||||||
|
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
|
||||||
|
if (fromUser) {
|
||||||
|
MusicPlayerRemote.seekTo(progress)
|
||||||
|
onUpdateProgressViews(MusicPlayerRemote.songProgressMillis, MusicPlayerRemote.songDurationMillis)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,269 @@
|
||||||
|
package code.name.monkey.retromusic.ui.fragments.player.color
|
||||||
|
|
||||||
|
import android.animation.ArgbEvaluator
|
||||||
|
import android.animation.ValueAnimator
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.content.Intent
|
||||||
|
import android.graphics.drawable.Drawable
|
||||||
|
import android.os.AsyncTask
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.text.TextUtils
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.appcompat.widget.Toolbar
|
||||||
|
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||||
|
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||||
|
import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||||
|
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||||
|
import code.name.monkey.retromusic.R
|
||||||
|
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
|
||||||
|
import code.name.monkey.retromusic.glide.SongGlideRequest
|
||||||
|
import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper
|
||||||
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
|
import code.name.monkey.retromusic.model.Song
|
||||||
|
import code.name.monkey.retromusic.model.lyrics.Lyrics
|
||||||
|
import code.name.monkey.retromusic.ui.activities.LyricsActivity
|
||||||
|
import code.name.monkey.retromusic.ui.fragments.base.AbsPlayerFragment
|
||||||
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
|
import code.name.monkey.retromusic.util.RetroColorUtil
|
||||||
|
import code.name.monkey.retromusic.util.ViewUtil
|
||||||
|
import com.bumptech.glide.Glide
|
||||||
|
import com.bumptech.glide.request.animation.GlideAnimation
|
||||||
|
import kotlinx.android.synthetic.main.fragment_color_player.*
|
||||||
|
|
||||||
|
class ColorFragment : AbsPlayerFragment() {
|
||||||
|
override fun toolbarGet(): Toolbar {
|
||||||
|
return playerToolbar
|
||||||
|
}
|
||||||
|
|
||||||
|
override val paletteColor: Int
|
||||||
|
get() = backgroundColor
|
||||||
|
|
||||||
|
override fun onColorChanged(color: Int) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onFavoriteToggled() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private var lastColor: Int = 0
|
||||||
|
private var backgroundColor: Int = 0
|
||||||
|
|
||||||
|
private var playbackControlsFragment: ColorPlaybackControlsFragment? = null
|
||||||
|
|
||||||
|
private var valueAnimator: ValueAnimator? = null
|
||||||
|
private var updateLyricsAsyncTask: AsyncTask<*, *, *>? = null
|
||||||
|
private var lyrics: Lyrics? = null
|
||||||
|
|
||||||
|
override fun onShow() {
|
||||||
|
playbackControlsFragment!!.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onHide() {
|
||||||
|
playbackControlsFragment!!.hide()
|
||||||
|
onBackPressed()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBackPressed(): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun toolbarIconColor(): Int {
|
||||||
|
return lastColor
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun toggleFavorite(song: Song) {
|
||||||
|
super.toggleFavorite(song)
|
||||||
|
if (song.id == MusicPlayerRemote.currentSong.id) {
|
||||||
|
updateIsFavorite()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroyView() {
|
||||||
|
super.onDestroyView()
|
||||||
|
if (valueAnimator != null) {
|
||||||
|
valueAnimator!!.cancel()
|
||||||
|
valueAnimator = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?): View? {
|
||||||
|
|
||||||
|
return inflater.inflate(R.layout.fragment_color_player, container, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
setUpSubFragments()
|
||||||
|
setUpPlayerToolbar()
|
||||||
|
setupViews()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpSubFragments() {
|
||||||
|
playbackControlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as ColorPlaybackControlsFragment?
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpPlayerToolbar() {
|
||||||
|
playerToolbar.apply {
|
||||||
|
inflateMenu(R.menu.menu_player)
|
||||||
|
setNavigationOnClickListener { activity!!.onBackPressed() }
|
||||||
|
setOnMenuItemClickListener(this@ColorFragment)
|
||||||
|
ToolbarContentTintHelper.colorizeToolbar(this, ATHUtil.resolveColor(context, R.attr.iconColor), activity)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPlayingMetaChanged() {
|
||||||
|
super.onPlayingMetaChanged()
|
||||||
|
updateSong()
|
||||||
|
updateLyricsLocal()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onServiceConnected() {
|
||||||
|
super.onServiceConnected()
|
||||||
|
updateSong()
|
||||||
|
updateLyricsLocal()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateSong() {
|
||||||
|
val activity = activity
|
||||||
|
|
||||||
|
SongGlideRequest.Builder.from(Glide.with(activity), MusicPlayerRemote.currentSong)
|
||||||
|
.checkIgnoreMediaStore(activity)
|
||||||
|
.generatePalette(activity).build().dontAnimate()
|
||||||
|
.into(object : RetroMusicColoredTarget(playerImage) {
|
||||||
|
override fun onColorReady(color: Int) {
|
||||||
|
//setColors(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onLoadFailed(e: Exception?, errorDrawable: Drawable?) {
|
||||||
|
super.onLoadFailed(e, errorDrawable)
|
||||||
|
|
||||||
|
val backgroundColor = defaultFooterColor
|
||||||
|
val textColor = if (ColorUtil.isColorLight(defaultFooterColor))
|
||||||
|
MaterialValueHelper.getPrimaryTextColor(context, true)
|
||||||
|
else
|
||||||
|
MaterialValueHelper.getPrimaryTextColor(context, false)
|
||||||
|
|
||||||
|
setColors(backgroundColor, textColor)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResourceReady(resource: BitmapPaletteWrapper,
|
||||||
|
glideAnimation: GlideAnimation<in BitmapPaletteWrapper>?) {
|
||||||
|
super.onResourceReady(resource, glideAnimation)
|
||||||
|
/* MediaNotificationProcessor processor = new MediaNotificationProcessor(getContext(),
|
||||||
|
getContext());
|
||||||
|
Palette.Builder builder = MediaNotificationProcessor
|
||||||
|
.generatePalette(resource.getBitmap());
|
||||||
|
|
||||||
|
int backgroundColor = processor.getBackgroundColor(builder);
|
||||||
|
int textColor = processor.getTextColor(builder);*/
|
||||||
|
|
||||||
|
val palette = resource.palette
|
||||||
|
val swatch = RetroColorUtil.getSwatch(palette)
|
||||||
|
|
||||||
|
val textColor = RetroColorUtil.getTextColor(palette)
|
||||||
|
val backgroundColor = swatch.rgb
|
||||||
|
|
||||||
|
setColors(backgroundColor, textColor)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setColors(backgroundColor: Int, textColor: Int) {
|
||||||
|
playbackControlsFragment!!.setDark(textColor, backgroundColor)
|
||||||
|
|
||||||
|
colorGradientBackground.setBackgroundColor(backgroundColor)
|
||||||
|
|
||||||
|
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, textColor, activity)
|
||||||
|
|
||||||
|
lastColor = textColor
|
||||||
|
|
||||||
|
this.backgroundColor = backgroundColor
|
||||||
|
|
||||||
|
if (playerActivity != null) {
|
||||||
|
playerActivity!!.setLightNavigationBar(ColorUtil.isColorLight(backgroundColor))
|
||||||
|
}
|
||||||
|
callbacks!!.onPaletteColorChanged()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun colorize(i: Int) {
|
||||||
|
if (valueAnimator != null) {
|
||||||
|
valueAnimator!!.cancel()
|
||||||
|
}
|
||||||
|
|
||||||
|
valueAnimator = ValueAnimator.ofObject(ArgbEvaluator(), paletteColor, i)
|
||||||
|
valueAnimator!!.addUpdateListener { animation ->
|
||||||
|
colorGradientBackground.setBackgroundColor(animation.animatedValue as Int)
|
||||||
|
}
|
||||||
|
valueAnimator!!.setDuration(ViewUtil.RETRO_MUSIC_ANIM_TIME.toLong()).start()
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("StaticFieldLeak")
|
||||||
|
private fun updateLyricsLocal() {
|
||||||
|
if (updateLyricsAsyncTask != null) {
|
||||||
|
updateLyricsAsyncTask!!.cancel(false)
|
||||||
|
}
|
||||||
|
val song = MusicPlayerRemote.currentSong
|
||||||
|
updateLyricsAsyncTask = object : AsyncTask<Void, Void, Lyrics>() {
|
||||||
|
override fun onPreExecute() {
|
||||||
|
super.onPreExecute()
|
||||||
|
lyrics = null
|
||||||
|
playerToolbar.menu.removeItem(R.id.action_show_lyrics)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun doInBackground(vararg params: Void): Lyrics? {
|
||||||
|
val data = MusicUtil.getLyrics(song)
|
||||||
|
return if (TextUtils.isEmpty(data)) {
|
||||||
|
null
|
||||||
|
} else Lyrics.parse(song, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPostExecute(l: Lyrics?) {
|
||||||
|
lyrics = l
|
||||||
|
if (lyrics == null) {
|
||||||
|
lyricsView.setText(R.string.no_lyrics_found)
|
||||||
|
} else {
|
||||||
|
lyricsView.text = lyrics!!.text
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCancelled(s: Lyrics) {
|
||||||
|
onPostExecute(null)
|
||||||
|
}
|
||||||
|
}.execute()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupViews() {
|
||||||
|
lyricsView.setOnClickListener {
|
||||||
|
if (lyricsContainer!!.visibility == View.GONE) {
|
||||||
|
lyricsContainer!!.visibility = View.VISIBLE
|
||||||
|
} else {
|
||||||
|
lyricsContainer!!.visibility = View.GONE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
playerImage.setOnClickListener {
|
||||||
|
if (lyricsContainer!!.visibility == View.GONE) {
|
||||||
|
lyricsContainer!!.visibility = View.VISIBLE
|
||||||
|
} else {
|
||||||
|
lyricsContainer!!.visibility = View.GONE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expand.setOnClickListener { startActivity(Intent(context, LyricsActivity::class.java)) }
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
fun newInstance(): ColorFragment {
|
||||||
|
val args = Bundle()
|
||||||
|
val fragment = ColorFragment()
|
||||||
|
fragment.arguments = args
|
||||||
|
return fragment
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,225 @@
|
||||||
|
package code.name.monkey.retromusic.ui.fragments.player.color
|
||||||
|
|
||||||
|
import android.animation.ObjectAnimator
|
||||||
|
import android.graphics.Color
|
||||||
|
import android.graphics.PorterDuff
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.view.animation.DecelerateInterpolator
|
||||||
|
import android.view.animation.LinearInterpolator
|
||||||
|
import android.widget.SeekBar
|
||||||
|
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||||
|
import code.name.monkey.appthemehelper.util.TintHelper
|
||||||
|
import code.name.monkey.retromusic.R
|
||||||
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
|
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
|
||||||
|
import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
|
||||||
|
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
||||||
|
import code.name.monkey.retromusic.service.MusicService
|
||||||
|
import code.name.monkey.retromusic.ui.fragments.VolumeFragment
|
||||||
|
import code.name.monkey.retromusic.ui.fragments.base.AbsPlayerControlsFragment
|
||||||
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
|
import kotlinx.android.synthetic.main.fragment_color_player_playback_controls.*
|
||||||
|
import kotlinx.android.synthetic.main.media_button.*
|
||||||
|
import kotlinx.android.synthetic.main.player_time.*
|
||||||
|
|
||||||
|
class ColorPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
||||||
|
|
||||||
|
private var lastPlaybackControlsColor: Int = 0
|
||||||
|
private var lastDisabledPlaybackControlsColor: Int = 0
|
||||||
|
private lateinit var progressViewUpdateHelper: MusicProgressViewUpdateHelper
|
||||||
|
private lateinit var volumeFragment: VolumeFragment
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
|
|
||||||
|
return inflater.inflate(R.layout.fragment_color_player_playback_controls, container, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
progressViewUpdateHelper.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPause() {
|
||||||
|
super.onPause()
|
||||||
|
progressViewUpdateHelper.stop()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
setUpMusicControllers()
|
||||||
|
|
||||||
|
volumeFragment = childFragmentManager.findFragmentById(R.id.volumeFragment) as VolumeFragment
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateSong() {
|
||||||
|
val song = MusicPlayerRemote.currentSong
|
||||||
|
title.text = song.title
|
||||||
|
text.text = song.artistName
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onServiceConnected() {
|
||||||
|
updatePlayPauseDrawableState()
|
||||||
|
updateRepeatState()
|
||||||
|
updateShuffleState()
|
||||||
|
updateSong()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPlayingMetaChanged() {
|
||||||
|
super.onPlayingMetaChanged()
|
||||||
|
updateSong()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPlayStateChanged() {
|
||||||
|
updatePlayPauseDrawableState()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onRepeatModeChanged() {
|
||||||
|
updateRepeatState()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onShuffleModeChanged() {
|
||||||
|
updateShuffleState()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun setDark(textColor: Int, background: Int) {
|
||||||
|
setDark(textColor)
|
||||||
|
TintHelper.setTintAuto(playPauseButton, background, false)
|
||||||
|
TintHelper.setTintAuto(playPauseButton, textColor, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setDark(color: Int) {
|
||||||
|
lastPlaybackControlsColor = color
|
||||||
|
lastDisabledPlaybackControlsColor = ColorUtil.withAlpha(color, 0.5f)
|
||||||
|
|
||||||
|
title!!.setTextColor(lastPlaybackControlsColor)
|
||||||
|
text!!.setTextColor(lastDisabledPlaybackControlsColor)
|
||||||
|
|
||||||
|
TintHelper.setTintAuto(progressSlider!!, lastPlaybackControlsColor, false)
|
||||||
|
|
||||||
|
volumeFragment.setTintable(lastPlaybackControlsColor)
|
||||||
|
|
||||||
|
songCurrentProgress.setTextColor(lastDisabledPlaybackControlsColor)
|
||||||
|
songTotalTime.setTextColor(lastDisabledPlaybackControlsColor)
|
||||||
|
|
||||||
|
updateRepeatState()
|
||||||
|
updateShuffleState()
|
||||||
|
updatePrevNextColor()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun setUpPlayPauseFab() {
|
||||||
|
TintHelper.setTintAuto(playPauseButton, Color.WHITE, true)
|
||||||
|
TintHelper.setTintAuto(playPauseButton, Color.BLACK, false)
|
||||||
|
playPauseButton.setOnClickListener(PlayPauseButtonOnClickHandler())
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun updatePlayPauseDrawableState() {
|
||||||
|
when {
|
||||||
|
MusicPlayerRemote.isPlaying -> playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp)
|
||||||
|
else -> playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_24dp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun setUpMusicControllers() {
|
||||||
|
setUpPlayPauseFab()
|
||||||
|
setUpPrevNext()
|
||||||
|
setUpRepeatButton()
|
||||||
|
setUpShuffleButton()
|
||||||
|
setUpProgressSlider()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpPrevNext() {
|
||||||
|
updatePrevNextColor()
|
||||||
|
nextButton.setOnClickListener { MusicPlayerRemote.playNextSong() }
|
||||||
|
previousButton.setOnClickListener { MusicPlayerRemote.back() }
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updatePrevNextColor() {
|
||||||
|
nextButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
previousButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpShuffleButton() {
|
||||||
|
shuffleButton.setOnClickListener { MusicPlayerRemote.toggleShuffleMode() }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun updateShuffleState() {
|
||||||
|
when (MusicPlayerRemote.shuffleMode) {
|
||||||
|
MusicService.SHUFFLE_MODE_SHUFFLE -> shuffleButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
else -> shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpRepeatButton() {
|
||||||
|
repeatButton.setOnClickListener { MusicPlayerRemote.cycleRepeatMode() }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun updateRepeatState() {
|
||||||
|
when (MusicPlayerRemote.repeatMode) {
|
||||||
|
MusicService.REPEAT_MODE_NONE -> {
|
||||||
|
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||||
|
repeatButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
}
|
||||||
|
MusicService.REPEAT_MODE_ALL -> {
|
||||||
|
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||||
|
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
}
|
||||||
|
MusicService.REPEAT_MODE_THIS -> {
|
||||||
|
repeatButton.setImageResource(R.drawable.ic_repeat_one_white_24dp)
|
||||||
|
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override fun show() {
|
||||||
|
playPauseButton!!.animate()
|
||||||
|
.scaleX(1f)
|
||||||
|
.scaleY(1f)
|
||||||
|
.rotation(360f)
|
||||||
|
.setInterpolator(DecelerateInterpolator())
|
||||||
|
.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
public override fun hide() {
|
||||||
|
playPauseButton.apply {
|
||||||
|
scaleX = 0f
|
||||||
|
scaleY = 0f
|
||||||
|
rotation = 0f
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setUpProgressSlider() {
|
||||||
|
progressSlider.setOnSeekBarChangeListener(object : SimpleOnSeekbarChangeListener() {
|
||||||
|
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
|
||||||
|
if (fromUser) {
|
||||||
|
MusicPlayerRemote.seekTo(progress)
|
||||||
|
onUpdateProgressViews(MusicPlayerRemote.songProgressMillis, MusicPlayerRemote.songDurationMillis)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onUpdateProgressViews(progress: Int, total: Int) {
|
||||||
|
progressSlider!!.max = total
|
||||||
|
|
||||||
|
val animator = ObjectAnimator.ofInt(progressSlider, "progress", progress)
|
||||||
|
animator.duration = 1500
|
||||||
|
animator.interpolator = LinearInterpolator()
|
||||||
|
animator.start()
|
||||||
|
|
||||||
|
songTotalTime.text = MusicUtil.getReadableDurationString(total.toLong())
|
||||||
|
songCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong())
|
||||||
|
}
|
||||||
|
}
|
|
@ -161,7 +161,7 @@ class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setUpShuffleButton() {
|
private fun setUpShuffleButton() {
|
||||||
shuffleButton.setOnClickListener { v -> MusicPlayerRemote.toggleShuffleMode() }
|
shuffleButton.setOnClickListener { MusicPlayerRemote.toggleShuffleMode() }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateShuffleState() {
|
override fun updateShuffleState() {
|
||||||
|
|
|
@ -196,7 +196,7 @@ class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setUpRepeatButton() {
|
private fun setUpRepeatButton() {
|
||||||
repeatButton.setOnClickListener { v -> MusicPlayerRemote.cycleRepeatMode() }
|
repeatButton.setOnClickListener { MusicPlayerRemote.cycleRepeatMode() }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateRepeatState() {
|
override fun updateRepeatState() {
|
||||||
|
|
|
@ -201,7 +201,7 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setUpShuffleButton() {
|
private fun setUpShuffleButton() {
|
||||||
shuffleButton.setOnClickListener { v -> MusicPlayerRemote.toggleShuffleMode() }
|
shuffleButton.setOnClickListener { MusicPlayerRemote.toggleShuffleMode() }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateShuffleState() {
|
override fun updateShuffleState() {
|
||||||
|
|
|
@ -0,0 +1,212 @@
|
||||||
|
package code.name.monkey.retromusic.ui.fragments.player.material
|
||||||
|
|
||||||
|
import android.animation.ObjectAnimator
|
||||||
|
import android.graphics.PorterDuff
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.view.animation.LinearInterpolator
|
||||||
|
import android.widget.SeekBar
|
||||||
|
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||||
|
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||||
|
import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||||
|
import code.name.monkey.retromusic.R
|
||||||
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
|
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
|
||||||
|
import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
|
||||||
|
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
||||||
|
import code.name.monkey.retromusic.service.MusicService
|
||||||
|
import code.name.monkey.retromusic.ui.fragments.base.AbsPlayerControlsFragment
|
||||||
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
|
import kotlinx.android.synthetic.main.fragment_material_playback_controls.*
|
||||||
|
import kotlinx.android.synthetic.main.player_time.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Hemanth S (h4h13).
|
||||||
|
*/
|
||||||
|
class MaterialControlsFragment : AbsPlayerControlsFragment() {
|
||||||
|
|
||||||
|
private var lastPlaybackControlsColor: Int = 0
|
||||||
|
private var lastDisabledPlaybackControlsColor: Int = 0
|
||||||
|
private var progressViewUpdateHelper: MusicProgressViewUpdateHelper? = null
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?): View? {
|
||||||
|
val view = inflater.inflate(R.layout.fragment_material_playback_controls, container, false)
|
||||||
|
|
||||||
|
return view
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
setUpMusicControllers()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateSong() {
|
||||||
|
val song = MusicPlayerRemote.currentSong
|
||||||
|
title.text = song.title
|
||||||
|
text.text = song.artistName
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
progressViewUpdateHelper!!.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPause() {
|
||||||
|
super.onPause()
|
||||||
|
progressViewUpdateHelper!!.stop()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onServiceConnected() {
|
||||||
|
updatePlayPauseDrawableState()
|
||||||
|
updateRepeatState()
|
||||||
|
updateShuffleState()
|
||||||
|
updateSong()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPlayingMetaChanged() {
|
||||||
|
super.onPlayingMetaChanged()
|
||||||
|
updateSong()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPlayStateChanged() {
|
||||||
|
updatePlayPauseDrawableState()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onRepeatModeChanged() {
|
||||||
|
updateRepeatState()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onShuffleModeChanged() {
|
||||||
|
updateShuffleState()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setDark(color: Int) {
|
||||||
|
val colorBg = ATHUtil.resolveColor(activity, android.R.attr.colorBackground)
|
||||||
|
if (ColorUtil.isColorLight(colorBg)) {
|
||||||
|
lastPlaybackControlsColor = MaterialValueHelper.getSecondaryTextColor(activity, true)
|
||||||
|
lastDisabledPlaybackControlsColor = MaterialValueHelper.getSecondaryDisabledTextColor(activity, true)
|
||||||
|
} else {
|
||||||
|
lastPlaybackControlsColor = MaterialValueHelper.getPrimaryTextColor(activity, false)
|
||||||
|
lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(activity, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
updateRepeatState()
|
||||||
|
updateShuffleState()
|
||||||
|
|
||||||
|
if (PreferenceUtil.getInstance().adaptiveColor) {
|
||||||
|
lastPlaybackControlsColor = color
|
||||||
|
text.setTextColor(color)
|
||||||
|
}
|
||||||
|
|
||||||
|
updatePlayPauseColor()
|
||||||
|
updatePrevNextColor()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updatePlayPauseColor() {
|
||||||
|
playPauseButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpPlayPauseFab() {
|
||||||
|
playPauseButton.setOnClickListener(PlayPauseButtonOnClickHandler())
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updatePlayPauseDrawableState() {
|
||||||
|
if (MusicPlayerRemote.isPlaying) {
|
||||||
|
playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp)
|
||||||
|
} else {
|
||||||
|
playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_24dp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpMusicControllers() {
|
||||||
|
setUpPlayPauseFab()
|
||||||
|
setUpPrevNext()
|
||||||
|
setUpRepeatButton()
|
||||||
|
setUpShuffleButton()
|
||||||
|
setUpProgressSlider()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpPrevNext() {
|
||||||
|
updatePrevNextColor()
|
||||||
|
nextButton.setOnClickListener { MusicPlayerRemote.playNextSong() }
|
||||||
|
previousButton.setOnClickListener { MusicPlayerRemote.back() }
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updatePrevNextColor() {
|
||||||
|
nextButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
previousButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpShuffleButton() {
|
||||||
|
shuffleButton.setOnClickListener { MusicPlayerRemote.toggleShuffleMode() }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun updateShuffleState() {
|
||||||
|
when (MusicPlayerRemote.shuffleMode) {
|
||||||
|
MusicService.SHUFFLE_MODE_SHUFFLE -> shuffleButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
else -> shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpRepeatButton() {
|
||||||
|
repeatButton.setOnClickListener { MusicPlayerRemote.cycleRepeatMode() }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun updateRepeatState() {
|
||||||
|
when (MusicPlayerRemote.repeatMode) {
|
||||||
|
MusicService.REPEAT_MODE_NONE -> {
|
||||||
|
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||||
|
repeatButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
}
|
||||||
|
MusicService.REPEAT_MODE_ALL -> {
|
||||||
|
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||||
|
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
}
|
||||||
|
MusicService.REPEAT_MODE_THIS -> {
|
||||||
|
repeatButton.setImageResource(R.drawable.ic_repeat_one_white_24dp)
|
||||||
|
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override fun show() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override fun hide() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setUpProgressSlider() {
|
||||||
|
progressSlider.setOnSeekBarChangeListener(object : SimpleOnSeekbarChangeListener() {
|
||||||
|
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
|
||||||
|
if (fromUser) {
|
||||||
|
MusicPlayerRemote.seekTo(progress)
|
||||||
|
onUpdateProgressViews(MusicPlayerRemote.songProgressMillis,
|
||||||
|
MusicPlayerRemote.songDurationMillis)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onUpdateProgressViews(progress: Int, total: Int) {
|
||||||
|
progressSlider!!.max = total
|
||||||
|
|
||||||
|
val animator = ObjectAnimator.ofInt(progressSlider, "progress", progress)
|
||||||
|
animator.duration = 1500
|
||||||
|
animator.interpolator = LinearInterpolator()
|
||||||
|
animator.start()
|
||||||
|
|
||||||
|
songTotalTime.text = MusicUtil.getReadableDurationString(total.toLong())
|
||||||
|
songCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong())
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,108 @@
|
||||||
|
package code.name.monkey.retromusic.ui.fragments.player.material
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.appcompat.widget.Toolbar
|
||||||
|
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||||
|
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||||
|
import code.name.monkey.retromusic.R
|
||||||
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
|
import code.name.monkey.retromusic.model.Song
|
||||||
|
import code.name.monkey.retromusic.ui.fragments.base.AbsPlayerFragment
|
||||||
|
import code.name.monkey.retromusic.ui.fragments.player.PlayerAlbumCoverFragment
|
||||||
|
import code.name.monkey.retromusic.ui.fragments.player.normal.PlayerFragment
|
||||||
|
import kotlinx.android.synthetic.main.fragment_material.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Hemanth S (h4h13).
|
||||||
|
*/
|
||||||
|
class MaterialFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Callbacks {
|
||||||
|
override fun toolbarGet(): Toolbar {
|
||||||
|
return playerToolbar
|
||||||
|
}
|
||||||
|
|
||||||
|
private var lastColor: Int = 0
|
||||||
|
override val paletteColor: Int
|
||||||
|
get() = lastColor
|
||||||
|
|
||||||
|
private lateinit var playbackControlsFragment: MaterialControlsFragment
|
||||||
|
|
||||||
|
override fun onShow() {
|
||||||
|
playbackControlsFragment.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onHide() {
|
||||||
|
playbackControlsFragment.hide()
|
||||||
|
onBackPressed()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBackPressed(): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun toolbarIconColor(): Int {
|
||||||
|
return ATHUtil.resolveColor(context, R.attr.iconColor)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onColorChanged(color: Int) {
|
||||||
|
playbackControlsFragment.setDark(color)
|
||||||
|
lastColor = color
|
||||||
|
callbacks!!.onPaletteColorChanged()
|
||||||
|
|
||||||
|
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, ATHUtil.resolveColor(context, R.attr.iconColor), activity)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun toggleFavorite(song: Song) {
|
||||||
|
super.toggleFavorite(song)
|
||||||
|
if (song.id == MusicPlayerRemote.currentSong.id) {
|
||||||
|
updateIsFavorite()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onFavoriteToggled() {
|
||||||
|
toggleFavorite(MusicPlayerRemote.currentSong)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?): View? {
|
||||||
|
return inflater.inflate(R.layout.fragment_material, container, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
setUpSubFragments()
|
||||||
|
setUpPlayerToolbar()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpSubFragments() {
|
||||||
|
playbackControlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as MaterialControlsFragment
|
||||||
|
val playerAlbumCoverFragment = childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
||||||
|
playerAlbumCoverFragment.setCallbacks(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpPlayerToolbar() {
|
||||||
|
playerToolbar.apply {
|
||||||
|
inflateMenu(R.menu.menu_player)
|
||||||
|
setNavigationOnClickListener { activity!!.onBackPressed() }
|
||||||
|
setOnMenuItemClickListener(this@MaterialFragment)
|
||||||
|
ToolbarContentTintHelper.colorizeToolbar(this, ATHUtil.resolveColor(context, R.attr.iconColor), activity)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onServiceConnected() {
|
||||||
|
updateIsFavorite()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPlayingMetaChanged() {
|
||||||
|
updateIsFavorite()
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
fun newInstance(): PlayerFragment {
|
||||||
|
return PlayerFragment()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,134 @@
|
||||||
|
package code.name.monkey.retromusic.ui.fragments.player.normal
|
||||||
|
|
||||||
|
import android.animation.ArgbEvaluator
|
||||||
|
import android.animation.ValueAnimator
|
||||||
|
import android.graphics.drawable.GradientDrawable
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.appcompat.widget.Toolbar
|
||||||
|
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||||
|
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||||
|
import code.name.monkey.retromusic.R
|
||||||
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
|
import code.name.monkey.retromusic.model.Song
|
||||||
|
import code.name.monkey.retromusic.ui.fragments.base.AbsPlayerFragment
|
||||||
|
import code.name.monkey.retromusic.ui.fragments.player.PlayerAlbumCoverFragment
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
|
import code.name.monkey.retromusic.util.ViewUtil
|
||||||
|
import code.name.monkey.retromusic.views.DrawableGradient
|
||||||
|
import kotlinx.android.synthetic.main.fragment_player.*
|
||||||
|
|
||||||
|
|
||||||
|
class PlayerFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Callbacks {
|
||||||
|
|
||||||
|
private var lastColor: Int = 0
|
||||||
|
override val paletteColor: Int
|
||||||
|
get() = lastColor
|
||||||
|
|
||||||
|
private lateinit var playbackControlsFragment: PlayerPlaybackControlsFragment
|
||||||
|
private var valueAnimator: ValueAnimator? = null
|
||||||
|
|
||||||
|
|
||||||
|
private fun colorize(i: Int) {
|
||||||
|
if (valueAnimator != null) {
|
||||||
|
valueAnimator!!.cancel()
|
||||||
|
}
|
||||||
|
|
||||||
|
valueAnimator = ValueAnimator.ofObject(ArgbEvaluator(), android.R.color.transparent, i)
|
||||||
|
valueAnimator!!.addUpdateListener { animation ->
|
||||||
|
val drawable = DrawableGradient(GradientDrawable.Orientation.TOP_BOTTOM,
|
||||||
|
intArrayOf(animation.animatedValue as Int, android.R.color.transparent), 0)
|
||||||
|
colorGradientBackground.background = drawable
|
||||||
|
}
|
||||||
|
valueAnimator!!.setDuration(ViewUtil.RETRO_MUSIC_ANIM_TIME.toLong()).start()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onShow() {
|
||||||
|
playbackControlsFragment.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onHide() {
|
||||||
|
playbackControlsFragment.hide()
|
||||||
|
onBackPressed()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBackPressed(): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun toolbarIconColor(): Int {
|
||||||
|
return ATHUtil.resolveColor(context, R.attr.iconColor)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onColorChanged(color: Int) {
|
||||||
|
playbackControlsFragment.setDark(color)
|
||||||
|
lastColor = color
|
||||||
|
callbacks!!.onPaletteColorChanged()
|
||||||
|
|
||||||
|
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, ATHUtil.resolveColor(context, R.attr.iconColor), activity)
|
||||||
|
|
||||||
|
if (PreferenceUtil.getInstance().adaptiveColor) {
|
||||||
|
colorize(color)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun toggleFavorite(song: Song) {
|
||||||
|
super.toggleFavorite(song)
|
||||||
|
if (song.id == MusicPlayerRemote.currentSong.id) {
|
||||||
|
updateIsFavorite()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onFavoriteToggled() {
|
||||||
|
toggleFavorite(MusicPlayerRemote.currentSong)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?): View? {
|
||||||
|
|
||||||
|
return inflater.inflate(R.layout.fragment_player, container, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
setUpSubFragments()
|
||||||
|
setUpPlayerToolbar()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpSubFragments() {
|
||||||
|
playbackControlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as PlayerPlaybackControlsFragment
|
||||||
|
val playerAlbumCoverFragment = childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
||||||
|
playerAlbumCoverFragment.setCallbacks(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpPlayerToolbar() {
|
||||||
|
playerToolbar.inflateMenu(R.menu.menu_player)
|
||||||
|
playerToolbar.setNavigationOnClickListener { activity!!.onBackPressed() }
|
||||||
|
playerToolbar.setOnMenuItemClickListener(this)
|
||||||
|
|
||||||
|
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, ATHUtil.resolveColor(context, R.attr.iconColor), activity)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onServiceConnected() {
|
||||||
|
updateIsFavorite()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPlayingMetaChanged() {
|
||||||
|
updateIsFavorite()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun toolbarGet(): Toolbar {
|
||||||
|
return playerToolbar
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
fun newInstance(): PlayerFragment {
|
||||||
|
return PlayerFragment()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,243 @@
|
||||||
|
package code.name.monkey.retromusic.ui.fragments.player.normal
|
||||||
|
|
||||||
|
import android.animation.ObjectAnimator
|
||||||
|
import android.graphics.PorterDuff
|
||||||
|
import android.graphics.drawable.ClipDrawable
|
||||||
|
import android.graphics.drawable.LayerDrawable
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.view.animation.DecelerateInterpolator
|
||||||
|
import android.view.animation.LinearInterpolator
|
||||||
|
import android.widget.SeekBar
|
||||||
|
import code.name.monkey.appthemehelper.ThemeStore
|
||||||
|
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||||
|
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||||
|
import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||||
|
import code.name.monkey.appthemehelper.util.TintHelper
|
||||||
|
import code.name.monkey.retromusic.R
|
||||||
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
|
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
|
||||||
|
import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
|
||||||
|
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
||||||
|
import code.name.monkey.retromusic.service.MusicService
|
||||||
|
import code.name.monkey.retromusic.ui.fragments.base.AbsPlayerControlsFragment
|
||||||
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
|
import kotlinx.android.synthetic.main.fragment_player_playback_controls.*
|
||||||
|
import kotlinx.android.synthetic.main.media_button.*
|
||||||
|
import kotlinx.android.synthetic.main.player_time.*
|
||||||
|
import kotlinx.android.synthetic.main.volume_controls.*
|
||||||
|
|
||||||
|
class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
||||||
|
|
||||||
|
private var lastPlaybackControlsColor: Int = 0
|
||||||
|
private var lastDisabledPlaybackControlsColor: Int = 0
|
||||||
|
private var progressViewUpdateHelper: MusicProgressViewUpdateHelper? = null
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?): View? {
|
||||||
|
|
||||||
|
return inflater.inflate(R.layout.fragment_player_playback_controls, container, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
setUpMusicControllers()
|
||||||
|
playPauseButton.setOnClickListener {
|
||||||
|
if (MusicPlayerRemote.isPlaying) {
|
||||||
|
MusicPlayerRemote.pauseSong()
|
||||||
|
} else {
|
||||||
|
MusicPlayerRemote.resumePlaying()
|
||||||
|
}
|
||||||
|
showBonceAnimation(playPauseButton)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setDark(color: Int) {
|
||||||
|
val colorBg = ATHUtil.resolveColor(activity, android.R.attr.colorBackground)
|
||||||
|
if (ColorUtil.isColorLight(colorBg)) {
|
||||||
|
lastPlaybackControlsColor = MaterialValueHelper.getSecondaryTextColor(activity, true)
|
||||||
|
lastDisabledPlaybackControlsColor = MaterialValueHelper.getSecondaryDisabledTextColor(activity, true)
|
||||||
|
} else {
|
||||||
|
lastPlaybackControlsColor = MaterialValueHelper.getPrimaryTextColor(activity, false)
|
||||||
|
lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(activity, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PreferenceUtil.getInstance().adaptiveColor) {
|
||||||
|
setFabColor(color)
|
||||||
|
} else {
|
||||||
|
setFabColor(ThemeStore.accentColor(context!!))
|
||||||
|
}
|
||||||
|
|
||||||
|
updateRepeatState()
|
||||||
|
updateShuffleState()
|
||||||
|
updatePrevNextColor()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setFabColor(i: Int) {
|
||||||
|
TintHelper.setTintAuto(playPauseButton, MaterialValueHelper.getPrimaryTextColor(context, ColorUtil.isColorLight(i)), false)
|
||||||
|
TintHelper.setTintAuto(playPauseButton, i, true)
|
||||||
|
setProgressBarColor(i)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateSong() {
|
||||||
|
val song = MusicPlayerRemote.currentSong
|
||||||
|
title.text = song.title
|
||||||
|
text.text = song.artistName
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
progressViewUpdateHelper!!.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPause() {
|
||||||
|
super.onPause()
|
||||||
|
progressViewUpdateHelper!!.stop()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onServiceConnected() {
|
||||||
|
updatePlayPauseDrawableState()
|
||||||
|
updateRepeatState()
|
||||||
|
updateShuffleState()
|
||||||
|
updateSong()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPlayingMetaChanged() {
|
||||||
|
super.onPlayingMetaChanged()
|
||||||
|
updateSong()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPlayStateChanged() {
|
||||||
|
updatePlayPauseDrawableState()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onRepeatModeChanged() {
|
||||||
|
updateRepeatState()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onShuffleModeChanged() {
|
||||||
|
updateShuffleState()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun setProgressBarColor(newColor: Int) {
|
||||||
|
val ld = progressSlider.progressDrawable as LayerDrawable
|
||||||
|
val clipDrawable = ld.findDrawableByLayerId(android.R.id.progress) as ClipDrawable
|
||||||
|
clipDrawable.setColorFilter(newColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpPlayPauseFab() {
|
||||||
|
playPauseButton.setOnClickListener(PlayPauseButtonOnClickHandler())
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updatePlayPauseDrawableState() {
|
||||||
|
if (MusicPlayerRemote.isPlaying) {
|
||||||
|
playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp)
|
||||||
|
} else {
|
||||||
|
playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_24dp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpMusicControllers() {
|
||||||
|
setUpPlayPauseFab()
|
||||||
|
setUpPrevNext()
|
||||||
|
setUpRepeatButton()
|
||||||
|
setUpShuffleButton()
|
||||||
|
setUpProgressSlider()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpPrevNext() {
|
||||||
|
updatePrevNextColor()
|
||||||
|
nextButton.setOnClickListener { MusicPlayerRemote.playNextSong() }
|
||||||
|
previousButton.setOnClickListener { MusicPlayerRemote.back() }
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updatePrevNextColor() {
|
||||||
|
nextButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
previousButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpShuffleButton() {
|
||||||
|
shuffleButton.setOnClickListener { MusicPlayerRemote.toggleShuffleMode() }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun updateShuffleState() {
|
||||||
|
when (MusicPlayerRemote.shuffleMode) {
|
||||||
|
MusicService.SHUFFLE_MODE_SHUFFLE -> shuffleButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
else -> shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpRepeatButton() {
|
||||||
|
repeatButton.setOnClickListener { MusicPlayerRemote.cycleRepeatMode() }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun updateRepeatState() {
|
||||||
|
when (MusicPlayerRemote.repeatMode) {
|
||||||
|
MusicService.REPEAT_MODE_NONE -> {
|
||||||
|
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||||
|
repeatButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
}
|
||||||
|
MusicService.REPEAT_MODE_ALL -> {
|
||||||
|
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||||
|
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
}
|
||||||
|
MusicService.REPEAT_MODE_THIS -> {
|
||||||
|
repeatButton.setImageResource(R.drawable.ic_repeat_one_white_24dp)
|
||||||
|
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override fun show() {
|
||||||
|
playPauseButton!!.animate()
|
||||||
|
.scaleX(1f)
|
||||||
|
.scaleY(1f)
|
||||||
|
.rotation(360f)
|
||||||
|
.setInterpolator(DecelerateInterpolator())
|
||||||
|
.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
public override fun hide() {
|
||||||
|
if (playPauseButton != null) {
|
||||||
|
playPauseButton!!.apply {
|
||||||
|
scaleX = 0f
|
||||||
|
scaleY = 0f
|
||||||
|
rotation = 0f
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setUpProgressSlider() {
|
||||||
|
progressSlider.setOnSeekBarChangeListener(object : SimpleOnSeekbarChangeListener() {
|
||||||
|
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
|
||||||
|
if (fromUser) {
|
||||||
|
MusicPlayerRemote.seekTo(progress)
|
||||||
|
onUpdateProgressViews(MusicPlayerRemote.songProgressMillis,
|
||||||
|
MusicPlayerRemote.songDurationMillis)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onUpdateProgressViews(progress: Int, total: Int) {
|
||||||
|
progressSlider.max = total
|
||||||
|
|
||||||
|
val animator = ObjectAnimator.ofInt(progressSlider, "progress", progress)
|
||||||
|
animator.duration = 1500
|
||||||
|
animator.interpolator = LinearInterpolator()
|
||||||
|
animator.start()
|
||||||
|
|
||||||
|
songTotalTime.text = MusicUtil.getReadableDurationString(total.toLong())
|
||||||
|
songCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong())
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -8,7 +8,7 @@
|
||||||
android:background="?android:attr/windowBackground">
|
android:background="?android:attr/windowBackground">
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/gradient_background"
|
android:id="@+id/colorGradientBackground"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
@ -37,7 +37,6 @@
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<code.name.monkey.retromusic.views.HeightFitSquareLayout
|
<code.name.monkey.retromusic.views.HeightFitSquareLayout
|
||||||
android:id="@+id/album_cover_container"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
@ -49,14 +48,14 @@
|
||||||
app:cardPreventCornerOverlap="false"
|
app:cardPreventCornerOverlap="false"
|
||||||
app:cardUseCompatPadding="true">
|
app:cardUseCompatPadding="true">
|
||||||
|
|
||||||
<ImageView
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
android:id="@+id/image"
|
android:id="@+id/playerImage"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:scaleType="centerCrop" />
|
android:scaleType="centerCrop" />
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:id="@+id/lyrics_container"
|
android:id="@+id/lyricsContainer"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@color/twenty_percent_black_overlay"
|
android:background="@color/twenty_percent_black_overlay"
|
||||||
|
@ -69,7 +68,7 @@
|
||||||
android:padding="16dp">
|
android:padding="16dp">
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
android:id="@+id/lyrics"
|
android:id="@+id/lyricsView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
|
@ -104,7 +103,7 @@
|
||||||
android:layout_weight="1">
|
android:layout_weight="1">
|
||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/playback_controls_fragment"
|
android:id="@+id/playbackControlsFragment"
|
||||||
android:name="code.name.monkey.retromusic.ui.fragments.player.color.ColorPlaybackControlsFragment"
|
android:name="code.name.monkey.retromusic.ui.fragments.player.color.ColorPlaybackControlsFragment"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
@ -112,13 +111,12 @@
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/toolbar_container"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="0">
|
android:layout_weight="0">
|
||||||
|
|
||||||
<androidx.appcompat.widget.Toolbar
|
<androidx.appcompat.widget.Toolbar
|
||||||
android:id="@+id/player_toolbar"
|
android:id="@+id/playerToolbar"
|
||||||
style="@style/Toolbar"
|
style="@style/Toolbar"
|
||||||
android:navigationIcon="@drawable/ic_close_white_24dp"
|
android:navigationIcon="@drawable/ic_close_white_24dp"
|
||||||
app:navigationIcon="@drawable/ic_close_white_24dp" />
|
app:navigationIcon="@drawable/ic_close_white_24dp" />
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
android:focusable="true">
|
android:focusable="true">
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/gradient_background"
|
android:id="@+id/colorGradientBackground"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
@ -43,21 +43,20 @@
|
||||||
app:cardUseCompatPadding="true">
|
app:cardUseCompatPadding="true">
|
||||||
|
|
||||||
<code.name.monkey.retromusic.views.WidthFitSquareLayout
|
<code.name.monkey.retromusic.views.WidthFitSquareLayout
|
||||||
android:id="@+id/album_cover_container"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal">
|
android:layout_gravity="center_horizontal">
|
||||||
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatImageView
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
android:id="@+id/image"
|
android:id="@+id/playerImage"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:scaleType="centerCrop"
|
android:scaleType="centerCrop"
|
||||||
tools:ignore="ContentDescription,UnusedAttribute" />
|
tools:ignore="ContentDescription,UnusedAttribute" />
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:id="@+id/lyrics_container"
|
android:id="@+id/lyricsContainer"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@color/twenty_percent_black_overlay"
|
android:background="@color/twenty_percent_black_overlay"
|
||||||
|
@ -70,7 +69,7 @@
|
||||||
android:padding="16dp">
|
android:padding="16dp">
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
android:id="@+id/lyrics"
|
android:id="@+id/lyricsView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
|
@ -100,7 +99,7 @@
|
||||||
android:layout_weight="1">
|
android:layout_weight="1">
|
||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/playback_controls_fragment"
|
android:id="@+id/playbackControlsFragment"
|
||||||
android:name="code.name.monkey.retromusic.ui.fragments.player.color.ColorPlaybackControlsFragment"
|
android:name="code.name.monkey.retromusic.ui.fragments.player.color.ColorPlaybackControlsFragment"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
@ -108,14 +107,13 @@
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/toolbar_container"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="0">
|
android:layout_weight="0">
|
||||||
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.Toolbar
|
<androidx.appcompat.widget.Toolbar
|
||||||
android:id="@+id/player_toolbar"
|
android:id="@+id/playerToolbar"
|
||||||
style="@style/Toolbar"
|
style="@style/Toolbar"
|
||||||
android:navigationIcon="@drawable/ic_close_white_24dp"
|
android:navigationIcon="@drawable/ic_close_white_24dp"
|
||||||
app:navigationIcon="@drawable/ic_close_white_24dp" />
|
app:navigationIcon="@drawable/ic_close_white_24dp" />
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/playback_controls"
|
android:id="@+id/playback_controls"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -9,49 +8,17 @@
|
||||||
tools:ignore="MissingPrefix">
|
tools:ignore="MissingPrefix">
|
||||||
|
|
||||||
<SeekBar
|
<SeekBar
|
||||||
android:id="@+id/player_progress_slider"
|
android:id="@+id/progressSlider"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:maxHeight="3dp"
|
android:maxHeight="3dp"
|
||||||
android:paddingEnd="24dp"
|
|
||||||
android:paddingStart="24dp"
|
android:paddingStart="24dp"
|
||||||
android:splitTrack="false"
|
android:paddingEnd="24dp"
|
||||||
android:progressDrawable="@drawable/color_progress_seek"
|
android:progressDrawable="@drawable/color_progress_seek"
|
||||||
|
android:splitTrack="false"
|
||||||
tools:progress="20" />
|
tools:progress="20" />
|
||||||
|
|
||||||
<LinearLayout
|
<include layout="@layout/player_time" />
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:paddingEnd="16dp"
|
|
||||||
android:paddingStart="16dp">
|
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/player_song_current_progress"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:paddingEnd="8dp"
|
|
||||||
android:paddingStart="8dp"
|
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
|
||||||
android:textSize="12sp"
|
|
||||||
android:textStyle="bold"
|
|
||||||
tools:text="22.00" />
|
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/player_song_total_time"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="0"
|
|
||||||
android:paddingEnd="8dp"
|
|
||||||
android:paddingStart="8dp"
|
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
|
||||||
android:textSize="12sp"
|
|
||||||
android:textStyle="bold"
|
|
||||||
tools:text="22.00" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -71,8 +38,8 @@
|
||||||
android:freezesText="true"
|
android:freezesText="true"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:marqueeRepeatLimit="marquee_forever"
|
android:marqueeRepeatLimit="marquee_forever"
|
||||||
android:paddingEnd="16dp"
|
|
||||||
android:paddingStart="16dp"
|
android:paddingStart="16dp"
|
||||||
|
android:paddingEnd="16dp"
|
||||||
android:scrollHorizontally="true"
|
android:scrollHorizontally="true"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||||
|
@ -88,103 +55,12 @@
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:paddingEnd="24dp"
|
|
||||||
android:paddingStart="24dp"
|
android:paddingStart="24dp"
|
||||||
|
android:paddingEnd="24dp"
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Small" />
|
android:textAppearance="@style/TextAppearance.AppCompat.Small" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
<include layout="@layout/media_button" />
|
||||||
android:id="@+id/player_media_controller_container"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
tools:ignore="ContentDescription,UnusedAttribute">
|
|
||||||
|
|
||||||
<ImageButton
|
<include layout="@layout/volume_controls" />
|
||||||
android:id="@+id/player_prev_button"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:layout_marginEnd="8dp"
|
|
||||||
android:layout_toStartOf="@+id/dummy_fab"
|
|
||||||
android:background="?attr/roundSelector"
|
|
||||||
android:padding="16dp"
|
|
||||||
android:scaleType="fitCenter"
|
|
||||||
app:srcCompat="@drawable/ic_skip_previous_white_24dp"
|
|
||||||
tools:ignore="MissingPrefix"
|
|
||||||
tools:tint="@color/md_black_1000" />
|
|
||||||
|
|
||||||
<ImageButton
|
|
||||||
android:id="@+id/player_next_button"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:layout_marginStart="8dp"
|
|
||||||
android:layout_toEndOf="@+id/dummy_fab"
|
|
||||||
android:background="?attr/roundSelector"
|
|
||||||
android:padding="16dp"
|
|
||||||
android:scaleType="fitCenter"
|
|
||||||
app:srcCompat="@drawable/ic_skip_next_white_24dp"
|
|
||||||
tools:ignore="MissingPrefix"
|
|
||||||
tools:tint="@color/md_black_1000" />
|
|
||||||
|
|
||||||
<ImageButton
|
|
||||||
android:id="@+id/player_repeat_button"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentStart="true"
|
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:background="?attr/roundSelector"
|
|
||||||
android:padding="16dp"
|
|
||||||
android:scaleType="fitCenter"
|
|
||||||
app:srcCompat="@drawable/ic_repeat_white_24dp"
|
|
||||||
tools:ignore="MissingPrefix"
|
|
||||||
tools:tint="@color/md_black_1000" />
|
|
||||||
|
|
||||||
<ImageButton
|
|
||||||
android:id="@+id/player_shuffle_button"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentEnd="true"
|
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:background="?attr/roundSelector"
|
|
||||||
android:padding="16dp"
|
|
||||||
android:scaleType="fitCenter"
|
|
||||||
app:srcCompat="@drawable/ic_shuffle_white_24dp"
|
|
||||||
tools:ignore="MissingPrefix"
|
|
||||||
tools:tint="@color/md_black_1000" />
|
|
||||||
|
|
||||||
<Space
|
|
||||||
android:id="@+id/dummy_fab"
|
|
||||||
android:layout_width="56dp"
|
|
||||||
android:layout_height="56dp"
|
|
||||||
android:layout_centerInParent="true" />
|
|
||||||
|
|
||||||
<ImageButton
|
|
||||||
android:id="@+id/player_play_pause_button"
|
|
||||||
android:layout_width="52dp"
|
|
||||||
android:layout_height="52dp"
|
|
||||||
android:layout_above="@id/title_container"
|
|
||||||
android:layout_centerInParent="true"
|
|
||||||
android:background="@drawable/color_circle_gradient"
|
|
||||||
android:elevation="4dp"
|
|
||||||
android:padding="16dp"
|
|
||||||
app:srcCompat="@drawable/ic_play_arrow_white_24dp" />
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/volume_fragment_container"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1">
|
|
||||||
|
|
||||||
<fragment
|
|
||||||
android:id="@+id/volume_fragment"
|
|
||||||
android:name="code.name.monkey.retromusic.ui.fragments.VolumeFragment"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
tools:layout="@layout/fragment_volume" />
|
|
||||||
</FrameLayout>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
Loading…
Reference in a new issue