Fix list colors

This commit is contained in:
h4h13 2019-10-09 23:08:13 +05:30
parent 12c87eb74b
commit b41288f7b8
16 changed files with 37 additions and 1083 deletions

View file

@ -13,8 +13,8 @@ android {
vectorDrawables.useSupportLibrary = true
applicationId "code.name.monkey.retromusic"
versionCode 378
versionName '3.4.200-beta04'
versionCode 379
versionName '3.4.400-beta05'
multiDexEnabled true
@ -118,7 +118,7 @@ dependencies {
implementation 'androidx.palette:palette-ktx:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.1.0-alpha10'
implementation 'com.google.android.material:material:1.1.0-beta01'
implementation 'com.google.android.play:core:1.6.3'
implementation 'com.squareup.retrofit2:retrofit:2.6.1'
@ -151,7 +151,6 @@ dependencies {
implementation 'com.github.ksoichiro:android-observablescrollview:1.6.0'
implementation 'com.github.kabouzeid:recyclerview-fastscroll:1.9-kmod'
implementation 'com.github.kabouzeid:AndroidSlidingUpPanel:3.3.3-kmod'
implementation 'com.github.AdrienPoupa:jaudiotagger:2.2.3'

File diff suppressed because one or more lines are too long

View file

@ -88,8 +88,6 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), AbsPlay
updateTabs()
bottomSheetBehavior = BottomSheetBehavior.from(slidingPanel)
bottomSheetBehavior.bottomSheetCallback = bottomSheetCallbackList
}
override fun onResume() {
@ -97,6 +95,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), AbsPlay
if (currentNowPlayingScreen != PreferenceUtil.getInstance(this).nowPlayingScreen) {
postRecreate()
}
bottomSheetBehavior.addBottomSheetCallback(bottomSheetCallbackList)
if (bottomSheetBehavior.state == BottomSheetBehavior.STATE_EXPANDED) {
setMiniPlayerAlphaProgress(1f)
@ -105,6 +104,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), AbsPlay
override fun onDestroy() {
super.onDestroy()
bottomSheetBehavior.removeBottomSheetCallback(bottomSheetCallbackList)
if (navigationBarColorAnimator != null) navigationBarColorAnimator!!.cancel() // just in case
}

View file

@ -99,7 +99,8 @@ class HomeAdapter(
fun bindView(home: Home) {
recyclerView.apply {
layoutManager = GridLayoutManager(activity, 1, GridLayoutManager.HORIZONTAL, false)
val artistAdapter = ArtistAdapter(activity, home.arrayList as ArrayList<Artist>, PreferenceUtil.getInstance(activity).getHomeGridStyle(context!!), false, null)
val artistAdapter = ArtistAdapter(activity, home.arrayList as ArrayList<Artist>,
PreferenceUtil.getInstance(activity).getHomeGridStyle(activity), false, null)
adapter = artistAdapter
}

View file

@ -97,12 +97,13 @@ open class AlbumAdapter(protected val activity: AppCompatActivity,
}
protected open fun setColors(color: Int, holder: ViewHolder) {
holder.paletteColorContainer?.let {
it.setBackgroundColor(color)
if (holder.paletteColorContainer != null) {
holder.title?.setTextColor(
MaterialValueHelper.getPrimaryTextColor(activity, ColorUtil.isColorLight(color)))
holder.text?.setTextColor(MaterialValueHelper.getSecondaryTextColor(activity, ColorUtil.isColorLight(color)))
holder.paletteColorContainer?.setBackgroundColor(color)
}
holder.mask?.backgroundTintList = ColorStateList.valueOf(color)
}
@ -121,10 +122,7 @@ open class AlbumAdapter(protected val activity: AppCompatActivity,
}
override fun onColorReady(color: Int) {
if (usePalette)
setColors(color, holder)
else
setColors(defaultFooterColor, holder)
}
})
}

View file

@ -32,7 +32,7 @@ class ArtistAdapter(val activity: AppCompatActivity,
@LayoutRes var itemLayoutRes: Int,
var usePalette: Boolean,
cabHolder: CabHolder?
) : AbsMultiSelectAdapter<ArtistAdapter.ViewHolder, Artist>(activity, cabHolder, code.name.monkey.retromusic.R.menu.menu_media_selection), FastScrollRecyclerView.SectionedAdapter {
) : AbsMultiSelectAdapter<ArtistAdapter.ViewHolder, Artist>(activity, cabHolder, R.menu.menu_media_selection), FastScrollRecyclerView.SectionedAdapter {
fun swapDataSet(dataSet: ArrayList<Artist>) {
this.dataSet = dataSet
@ -67,10 +67,11 @@ class ArtistAdapter(val activity: AppCompatActivity,
}
fun setColors(color: Int, holder: ViewHolder) {
holder.paletteColorContainer?.let {
it.setBackgroundColor(color)
if (holder.paletteColorContainer != null) {
holder.paletteColorContainer?.setBackgroundColor(color)
holder.title?.setTextColor(MaterialValueHelper.getPrimaryTextColor(activity, ColorUtil.isColorLight(color)))
}
holder.mask?.backgroundTintList = ColorStateList.valueOf(color)
}
@ -87,10 +88,7 @@ class ArtistAdapter(val activity: AppCompatActivity,
}
override fun onColorReady(color: Int) {
if (usePalette)
setColors(color, holder)
else
setColors(defaultFooterColor, holder)
}
})
}

View file

@ -1,413 +0,0 @@
package code.name.monkey.retromusic.fragments.player.classic
import android.animation.Animator
import android.animation.AnimatorSet
import android.graphics.Color
import android.graphics.PorterDuff
import android.os.Build
import android.os.Bundle
import android.view.*
import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity
import code.name.monkey.retromusic.adapter.base.MediaEntryViewHolder
import code.name.monkey.retromusic.adapter.song.PlayingQueueAdapter
import code.name.monkey.retromusic.dialogs.SongShareDialog
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.helper.menu.SongMenuHelper
import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.RetroUtil
import code.name.monkey.retromusic.util.ViewUtil
import code.name.monkey.retromusic.views.WidthFitSquareLayout
import com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator
import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils
import com.sothree.slidinguppanel.SlidingUpPanelLayout
import com.sothree.slidinguppanel.SlidingUpPanelLayout.PanelState.ANCHORED
import com.sothree.slidinguppanel.SlidingUpPanelLayout.PanelState.COLLAPSED
import kotlinx.android.synthetic.main.fragment_classic_player.*
import kotlinx.android.synthetic.main.fragment_classic_player_playback_controls.*
import kotlin.math.max
class ClassicPlayerFragment : AbsPlayerFragment(), SlidingUpPanelLayout.PanelSlideListener {
override fun onPanelSlide(p0: View?, p1: Float) {
}
override fun onPanelStateChanged(p0: View?, p1: SlidingUpPanelLayout.PanelState?, p2: SlidingUpPanelLayout.PanelState?) {
when (p2) {
COLLAPSED -> onPanelCollapsed(p0!!)
ANCHORED -> playerSlidingLayout.panelState = COLLAPSED // this fixes a bug where the panel would get stuck for some reason
else -> {
}
}
}
override fun playerToolbar(): Toolbar {
return playerToolbar
}
override fun onShow() {
controlsFragment.show()
}
override fun onHide() {
controlsFragment.hide()
onBackPressed()
}
override fun onBackPressed(): Boolean {
var wasExpanded = false
if (playerSlidingLayout != null) {
wasExpanded = playerSlidingLayout.panelState === SlidingUpPanelLayout.PanelState.EXPANDED
playerSlidingLayout.panelState = COLLAPSED
}
return wasExpanded
}
override fun toolbarIconColor(): Int {
return Color.WHITE
}
override val paletteColor: Int
get() = lastColor
override fun onColorChanged(color: Int) {
animateColorChange(color)
controlsFragment.setDark(ColorUtil.isColorLight(color))
callbacks?.onPaletteColorChanged()
}
override fun toggleFavorite(song: Song) {
super.toggleFavorite(song)
if (song.id == MusicPlayerRemote.currentSong.id) {
updateIsFavorite()
}
}
override fun onFavoriteToggled() {
toggleFavorite(MusicPlayerRemote.currentSong)
}
var lastColor: Int = 0
lateinit var controlsFragment: ClassicPlayerPlaybackControlsFragment
private var playerAlbumCoverFragment: PlayerAlbumCoverFragment? = null
private lateinit var layoutManager: LinearLayoutManager
private lateinit var playingQueueAdapter: PlayingQueueAdapter
private lateinit var wrappedAdapter: RecyclerView.Adapter<*>
private lateinit var recyclerViewDragDropManager: RecyclerViewDragDropManager
private lateinit var impl: Impl
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
if (RetroUtil.isLandscape()) {
impl = LandscapeImpl(this)
} else {
impl = PortraitImpl(this)
}
return inflater.inflate(R.layout.fragment_classic_player, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
impl.init()
setUpPlayerToolbar()
setUpSubFragments()
setUpRecyclerView()
playerSlidingLayout.addPanelSlideListener(this)
playerSlidingLayout.setAntiDragView(view.findViewById<View>(R.id.draggableArea))
view.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
override fun onGlobalLayout() {
view.viewTreeObserver.removeOnGlobalLayoutListener(this)
impl.setUpPanelAndAlbumCoverHeight()
}
})
// for some reason the xml attribute doesn't get applied here.
playingQueueCard.setCardBackgroundColor(ATHUtil.resolveColor(requireContext(), R.attr.colorPrimary))
}
private fun setUpPlayerToolbar() {
playerToolbar.apply {
inflateMenu(R.menu.menu_player)
setNavigationOnClickListener { activity!!.onBackPressed() }
setOnMenuItemClickListener(this@ClassicPlayerFragment)
}
}
private fun setUpSubFragments() {
controlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as ClassicPlayerPlaybackControlsFragment
playerAlbumCoverFragment = childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
playerAlbumCoverFragment?.setCallbacks(this)
}
private fun setUpRecyclerView() {
recyclerViewDragDropManager = RecyclerViewDragDropManager()
val animator = RefactoredDefaultItemAnimator()
playingQueueAdapter = PlayingQueueAdapter(
activity as AppCompatActivity,
MusicPlayerRemote.playingQueue,
MusicPlayerRemote.position,
R.layout.item_queue)
wrappedAdapter = recyclerViewDragDropManager.createWrappedAdapter(playingQueueAdapter)
layoutManager = LinearLayoutManager(activity)
playerRecyclerView.layoutManager = layoutManager
playerRecyclerView.adapter = wrappedAdapter
playerRecyclerView.itemAnimator = animator
recyclerViewDragDropManager.attachRecyclerView(playerRecyclerView)
layoutManager.scrollToPositionWithOffset(MusicPlayerRemote.position + 1, 0)
}
override fun onDestroyView() {
if (playerSlidingLayout != null) {
playerSlidingLayout.removePanelSlideListener(this)
}
recyclerViewDragDropManager.release()
if (playerRecyclerView != null) {
playerRecyclerView.itemAnimator = null
playerRecyclerView.adapter = null
}
WrapperAdapterUtils.releaseAll(wrappedAdapter)
super.onDestroyView()
}
override fun onPause() {
recyclerViewDragDropManager.cancelDrag()
super.onPause()
}
override fun onServiceConnected() {
updateQueue()
updateCurrentSong()
updateIsFavorite()
//updateLyrics()
}
override fun onPlayingMetaChanged() {
updateCurrentSong()
updateIsFavorite()
updateQueuePosition()
//updateLyrics()
}
override fun onQueueChanged() {
updateQueue()
}
override fun onMediaStoreChanged() {
updateQueue()
}
private fun updateQueue() {
playingQueueAdapter.swapDataSet(MusicPlayerRemote.playingQueue, MusicPlayerRemote.position)
playerQueueSubHeader.text = getUpNextAndQueueTime()
if (playerSlidingLayout.panelState === COLLAPSED) {
resetToCurrentPosition()
}
}
private fun updateQueuePosition() {
playingQueueAdapter.setCurrent(MusicPlayerRemote.position)
playerQueueSubHeader.text = getUpNextAndQueueTime()
if (playerSlidingLayout.panelState === COLLAPSED) {
resetToCurrentPosition()
}
}
private fun updateCurrentSong() {
impl.updateCurrentSong(MusicPlayerRemote.currentSong)
}
private fun animateColorChange(newColor: Int) {
impl.animateColorChange(newColor)
lastColor = newColor
}
private fun onPanelCollapsed(panel: View) {
resetToCurrentPosition()
}
private fun resetToCurrentPosition() {
playerRecyclerView.stopScroll()
layoutManager.scrollToPositionWithOffset(MusicPlayerRemote.position + 1, 0)
}
}
abstract class BaseImpl(private val fragment: ClassicPlayerFragment) : Impl {
fun createDefaultColorChangeAnimatorSet(color: Int): AnimatorSet {
val backgroundAnimator: Animator
backgroundAnimator = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
val x = (fragment.controlsFragment.playerPlayPauseFab.x + (fragment.controlsFragment.playerPlayPauseFab.width / 2).toFloat() + fragment.controlsFragment.view!!.x).toInt()
val y = (fragment.controlsFragment.playerPlayPauseFab.y + (fragment.controlsFragment.playerPlayPauseFab.height / 2).toFloat() + fragment.controlsFragment.view!!.y + fragment.controlsFragment.playerProgressSlider.height.toFloat()).toInt()
val startRadius = max(fragment.controlsFragment.playerPlayPauseFab.width / 2, fragment.controlsFragment.playerPlayPauseFab.height / 2).toFloat()
val endRadius = max(fragment.colorBackground.width, fragment.colorBackground.height).toFloat()
fragment.colorBackground.setBackgroundColor(color)
ViewAnimationUtils.createCircularReveal(fragment.colorBackground, x, y, startRadius, endRadius)
} else {
ViewUtil.createBackgroundColorTransition(fragment.colorBackground, fragment.lastColor, color)
}
val animatorSet = AnimatorSet()
animatorSet.play(backgroundAnimator)
if (!ATHUtil.isWindowBackgroundDark(fragment.activity!!)) {
val adjustedLastColor = if (ColorUtil.isColorLight(fragment.lastColor)) ColorUtil.darkenColor(fragment.lastColor) else fragment.lastColor
val adjustedNewColor = if (ColorUtil.isColorLight(color)) ColorUtil.darkenColor(color) else color
val subHeaderAnimator = ViewUtil.createTextColorTransition(fragment.playerQueueSubHeader, adjustedLastColor, adjustedNewColor)
animatorSet.play(subHeaderAnimator)
}
animatorSet.duration = ViewUtil.RETRO_MUSIC_ANIM_TIME.toLong()
return animatorSet
}
override fun animateColorChange(newColor: Int) {
if (ATHUtil.isWindowBackgroundDark(fragment.activity!!)) {
fragment.playerQueueSubHeader.setTextColor(ThemeStore.textColorSecondary(fragment.activity!!))
}
}
}
class PortraitImpl(private val fragment: ClassicPlayerFragment) : BaseImpl(fragment) {
override fun init() {
currentSongViewHolder = MediaEntryViewHolder(fragment.view?.findViewById(R.id.currentSong)!!)
currentSongViewHolder?.apply {
image?.apply {
scaleType = ImageView.ScaleType.CENTER
setColorFilter(ATHUtil.resolveColor(fragment.activity!!, R.attr.iconColor, ThemeStore.textColorSecondary(fragment.activity!!)), PorterDuff.Mode.SRC_IN)
setImageResource(R.drawable.ic_equalizer_white_24dp)
}
imageTextContainer?.let {
it.cardElevation = 0f
it.setCardBackgroundColor(ATHUtil.resolveColor(fragment.requireContext(), R.attr.colorPrimary))
}
itemView.setOnClickListener {
// toggle the panel
if (fragment.playerSlidingLayout.panelState == COLLAPSED) {
fragment.playerSlidingLayout.panelState = SlidingUpPanelLayout.PanelState.EXPANDED
} else if (fragment.playerSlidingLayout.panelState == SlidingUpPanelLayout.PanelState.EXPANDED) {
fragment.playerSlidingLayout.panelState = COLLAPSED
}
}
menu?.setOnClickListener(object : SongMenuHelper.OnClickSongMenu((fragment.activity as AppCompatActivity?)!!) {
override val song: Song
get() = currentSong
override val menuRes: Int
get() = R.menu.menu_item_playing_queue_song
override fun onMenuItemClick(item: MenuItem): Boolean {
when (item.itemId) {
R.id.action_remove_from_playing_queue -> {
MusicPlayerRemote.removeFromQueue(MusicPlayerRemote.position)
return true
}
R.id.action_share -> {
SongShareDialog.create(song).show(fragment.fragmentManager!!, "SONG_SHARE_DIALOG")
return true
}
}
return super.onMenuItemClick(item)
}
})
}
}
override fun updateCurrentSong(song: Song) {
currentSong = song
currentSongViewHolder?.apply {
title?.text = song.title
text?.text = MusicUtil.getSongInfoString(song)
}
}
override fun animateColorChange(newColor: Int) {
fragment.playerSlidingLayout.setBackgroundColor(fragment.lastColor)
createDefaultColorChangeAnimatorSet(newColor).start()
}
override fun setUpPanelAndAlbumCoverHeight() {
val albumCoverContainer = fragment.view!!.findViewById<WidthFitSquareLayout>(R.id.albumCoverContainer)
val availablePanelHeight = fragment.playerSlidingLayout.height - fragment.view!!.findViewById<View>(R.id.playerContent).height + ViewUtil.convertDpToPixel(8f, fragment.resources).toInt()
val minPanelHeight = ViewUtil.convertDpToPixel(72f + 24f, fragment.resources).toInt()
if (availablePanelHeight < minPanelHeight) {
albumCoverContainer.layoutParams.height = albumCoverContainer.height - (minPanelHeight - availablePanelHeight)
albumCoverContainer.forceSquare(false)
}
fragment.playerSlidingLayout.panelHeight = Math.max(minPanelHeight, availablePanelHeight)
(fragment.activity as AbsSlidingMusicPanelActivity).setAntiDragView(fragment.playerSlidingLayout.findViewById<View>(R.id.playerPanel))
}
private var currentSongViewHolder: MediaEntryViewHolder? = null
var currentSong = Song.emptySong
}
class LandscapeImpl(private val fragment: ClassicPlayerFragment) : BaseImpl(fragment) {
override fun init() {
}
override fun updateCurrentSong(song: Song) {
fragment.playerToolbar.title = song.title
fragment.playerToolbar.subtitle = MusicUtil.getSongInfoString(song)
}
override fun animateColorChange(newColor: Int) {
fragment.playerSlidingLayout.setBackgroundColor(fragment.lastColor)
val animatorSet = createDefaultColorChangeAnimatorSet(newColor)
animatorSet.play(ViewUtil.createBackgroundColorTransition(fragment.playerToolbar, fragment.lastColor, newColor)).with(ViewUtil.createBackgroundColorTransition(fragment.view?.findViewById(R.id.status_bar)!!, ColorUtil.darkenColor(fragment.lastColor), ColorUtil.darkenColor(newColor)))
animatorSet.start()
}
override fun setUpPanelAndAlbumCoverHeight() {
val panelHeight = fragment.playerSlidingLayout.height - fragment.controlsFragment.view?.height!!
fragment.playerSlidingLayout.panelHeight = panelHeight
(fragment.activity as AbsSlidingMusicPanelActivity).setAntiDragView(fragment.playerSlidingLayout.findViewById(R.id.playerPanel))
}
}
internal interface Impl {
fun init()
fun updateCurrentSong(song: Song)
fun animateColorChange(newColor: Int)
fun setUpPanelAndAlbumCoverHeight()
}

View file

@ -1,218 +0,0 @@
package code.name.monkey.retromusic.fragments.player.classic
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.LinearInterpolator
import android.widget.SeekBar
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.extensions.ripAlpha
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
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.util.MusicUtil
import kotlinx.android.synthetic.main.fragment_classic_player_playback_controls.*
class ClassicPlayerPlaybackControlsFragment : AbsPlayerControlsFragment() {
public override fun show() {
}
public override fun hide() {
}
override fun setDark(color: Int) {
}
fun setDark(dark: Boolean) {
if (dark) {
lastPlaybackControlsColor = MaterialValueHelper.getSecondaryTextColor(activity, true)
lastDisabledPlaybackControlsColor = MaterialValueHelper.getSecondaryDisabledTextColor(activity, true)
} else {
lastPlaybackControlsColor = MaterialValueHelper.getPrimaryTextColor(activity, false)
lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(activity, false)
}
volumeFragment?.setTintableColor(lastPlaybackControlsColor.ripAlpha())
updateRepeatState()
updateShuffleState()
updatePrevNextColor()
updateProgressTextColor()
val fabColor = Color.WHITE
TintHelper.setTintAuto(playerPlayPauseFab, fabColor, true)
TintHelper.setTintAuto(playerPlayPauseFab, MaterialValueHelper.getPrimaryTextColor(requireContext(), ColorUtil.isColorLight(fabColor)), false)
}
private var lastPlaybackControlsColor = 0
private var lastDisabledPlaybackControlsColor = 0
private lateinit var progressViewUpdateHelper: MusicProgressViewUpdateHelper
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_classic_player_playback_controls, container, false)
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setUpMusicControllers()
updateProgressTextColor()
//volumeFragment = childFragmentManager.findFragmentById(R.id.volumeFragment) as VolumeFragment
}
private fun setUpMusicControllers() {
setUpPlayPauseFab()
setUpPrevNext()
setUpRepeatButton()
setUpShuffleButton()
setUpProgressSlider()
}
private fun updateProgressTextColor() {
val color = MaterialValueHelper.getPrimaryTextColor(context, false)
playerSongTotalTime.setTextColor(color)
playerSongCurrentProgress.setTextColor(color)
}
private fun updatePlayPauseDrawableState() {
if (MusicPlayerRemote.isPlaying) {
playerPlayPauseFab.setImageResource(R.drawable.ic_pause_white_24dp)
} else {
playerPlayPauseFab.setImageResource(R.drawable.ic_play_arrow_white_32dp)
}
}
private fun setUpPlayPauseFab() {
playerPlayPauseFab.setOnClickListener(PlayPauseButtonOnClickHandler())
playerPlayPauseFab.post {
if (playerPlayPauseFab != null) {
playerPlayPauseFab.pivotX = (playerPlayPauseFab.width / 2).toFloat()
playerPlayPauseFab.pivotY = (playerPlayPauseFab.height / 2).toFloat()
}
}
}
private fun setUpPrevNext() {
updatePrevNextColor()
playerNextButton.setOnClickListener { _ -> MusicPlayerRemote.playNextSong() }
playerPrevButton.setOnClickListener { _ -> MusicPlayerRemote.back() }
}
private fun updatePrevNextColor() {
playerNextButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
playerPrevButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
}
private fun setUpShuffleButton() {
playerShuffleButton.setOnClickListener { MusicPlayerRemote.toggleShuffleMode() }
}
override fun updateShuffleState() {
when (MusicPlayerRemote.shuffleMode) {
MusicService.SHUFFLE_MODE_SHUFFLE -> playerShuffleButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
else -> playerShuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
}
}
private fun setUpRepeatButton() {
playerRepeatButton.setOnClickListener { MusicPlayerRemote.cycleRepeatMode() }
}
override fun updateRepeatState() {
when (MusicPlayerRemote.repeatMode) {
MusicService.REPEAT_MODE_NONE -> {
playerRepeatButton.setImageResource(code.name.monkey.retromusic.R.drawable.ic_repeat_white_24dp)
playerRepeatButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
}
MusicService.REPEAT_MODE_ALL -> {
playerRepeatButton.setImageResource(code.name.monkey.retromusic.R.drawable.ic_repeat_white_24dp)
playerRepeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
}
MusicService.REPEAT_MODE_THIS -> {
playerRepeatButton.setImageResource(code.name.monkey.retromusic.R.drawable.ic_repeat_one_white_24dp)
playerRepeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
}
}
}
override fun setUpProgressSlider() {
val color = MaterialValueHelper.getPrimaryTextColor(context, false)
playerProgressSlider.thumb.mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN)
playerProgressSlider.progressDrawable.mutate().setColorFilter(Color.TRANSPARENT, PorterDuff.Mode.SRC_IN)
playerProgressSlider.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) {
playerProgressSlider.max = total
val animator = ObjectAnimator.ofInt(playerProgressSlider, "progress", progress)
animator.duration = SLIDER_ANIMATION_TIME
animator.interpolator = LinearInterpolator()
animator.start()
playerSongTotalTime.text = MusicUtil.getReadableDurationString(total.toLong())
playerSongCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong())
}
override fun onResume() {
super.onResume()
progressViewUpdateHelper.start()
}
override fun onPause() {
super.onPause()
progressViewUpdateHelper.stop()
}
override fun onServiceConnected() {
updatePlayPauseDrawableState()
updateRepeatState()
updateShuffleState()
}
override fun onPlayStateChanged() {
updatePlayPauseDrawableState()
}
override fun onRepeatModeChanged() {
updateRepeatState()
}
override fun onShuffleModeChanged() {
updateShuffleState()
}
}

View file

@ -1,7 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:left="4dp"
android:right="4dp">
<shape android:shape="rectangle">
<solid android:color="@android:color/white" />
<corners
android:topLeftRadius="8dp"
android:topRightRadius="8dp" />
<solid android:color="@color/md_red_500" />
android:bottomLeftRadius="0dp"
android:bottomRightRadius="0dp"
android:topLeftRadius="3dp"
android:topRightRadius="3dp" />
<size android:height="3dp" />
</shape>
</item>
</layer-list>

View file

@ -1,134 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--The unused FrameLayout layout is necessary to prevent a crash on rotate-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:ignore="UselessParent">
<include layout="@layout/status_bar" />
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/playerToolbar"
style="@style/Toolbar"
android:background="@android:color/transparent"
android:navigationIcon="@drawable/ic_keyboard_arrow_down_black_24dp"
app:navigationIcon="@drawable/ic_keyboard_arrow_down_black_24dp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<code.name.monkey.retromusic.views.HeightFitSquareLayout
android:id="@+id/coverContainer"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/playerAlbumCoverFragment"
class="code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout="@layout/fragment_album_full_cover" />
</code.name.monkey.retromusic.views.HeightFitSquareLayout>
<com.sothree.slidinguppanel.SlidingUpPanelLayout xmlns:sothree="http://schemas.android.com/apk/res-auto"
android:id="@+id/playerSlidingLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toEndOf="@+id/coverContainer"
android:layout_toRightOf="@+id/coverContainer"
android:clickable="false"
android:focusable="true"
android:gravity="bottom"
sothree:umanoFadeColor="#00000000"
sothree:umanoOverlay="true"
sothree:umanoPanelHeight="0dp"
sothree:umanoScrollableView="@+id/playerRecyclerView"
sothree:umanoShadowHeight="0dp">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="@+id/colorBackground"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<fragment
android:id="@+id/playbackControlsFragment"
class="code.name.monkey.retromusic.fragments.player.classic.ClassicPlayerPlaybackControlsFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</FrameLayout>
<FrameLayout
android:id="@+id/playerPanel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp">
<com.google.android.material.card.MaterialCardView
android:id="@+id/playingQueueCard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="-8dp"
app:cardBackgroundColor="?colorSurface"
app:cardElevation="@dimen/card_elevation"
app:cardUseCompatPadding="false"
sothree:cardCornerRadius="12dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!--This is necessary for the drag sorting to work at the top-->
<View
android:id="@+id/draggableArea"
android:layout_width="72dp"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/cardContent"
android:layout_alignBottom="@+id/cardContent"
android:layout_marginTop="48dp" />
<LinearLayout
android:id="@+id/cardContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/playerQueueSubHeader"
android:layout_width="match_parent"
android:layout_height="48dp"
android:gravity="center_vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:text="@string/up_next"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
android:textColor="?android:textColorSecondary" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/playerRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="8dp"
android:requiresFadingEdge="vertical" />
</LinearLayout>
</RelativeLayout>
</com.google.android.material.card.MaterialCardView>
</FrameLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
</RelativeLayout>
</LinearLayout>
</FrameLayout>

View file

@ -1,153 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--The unused FrameLayout layout is necessary to prevent a crash on rotate-->
<com.sothree.slidinguppanel.SlidingUpPanelLayout xmlns:sothree="http://schemas.android.com/apk/res-auto"
android:id="@+id/playerSlidingLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="false"
android:focusable="true"
android:gravity="bottom"
sothree:umanoDragView="@id/playerPanel"
sothree:umanoFadeColor="#00000000"
sothree:umanoOverlay="true"
sothree:umanoPanelHeight="0dp"
sothree:umanoScrollableView="@+id/playerRecyclerView"
sothree:umanoShadowHeight="0dp">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="@+id/colorBackground"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<RelativeLayout
android:id="@+id/playerContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<code.name.monkey.retromusic.views.WidthFitSquareLayout
android:id="@+id/albumCoverContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true">
<fragment
android:id="@+id/playerAlbumCoverFragment"
class="code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout="@layout/fragment_album_full_cover" />
</code.name.monkey.retromusic.views.WidthFitSquareLayout>
<fragment
android:id="@+id/playbackControlsFragment"
class="code.name.monkey.retromusic.fragments.player.classic.ClassicPlayerPlaybackControlsFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/albumCoverContainer" />
</RelativeLayout>
<FrameLayout
android:id="@+id/toolbarContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<include layout="@layout/shadow_statusbar_toolbar" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<code.name.monkey.retromusic.views.StatusBarView
android:layout_width="match_parent"
android:layout_height="@dimen/status_bar_padding" />
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/playerToolbar"
style="@style/Toolbar"
android:background="@android:color/transparent"
android:navigationIcon="@drawable/ic_keyboard_arrow_down_black_24dp"
app:navigationIcon="@drawable/ic_keyboard_arrow_down_black_24dp" />
</LinearLayout>
</FrameLayout>
</FrameLayout>
<code.name.monkey.retromusic.views.StatusBarMarginFrameLayout
android:id="@+id/playerPanel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.google.android.material.card.MaterialCardView
android:id="@+id/playingQueueCard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="-8dp"
app:cardBackgroundColor="?colorPrimary"
app:cardElevation="@dimen/card_elevation"
app:cardUseCompatPadding="false"
sothree:cardCornerRadius="12dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!--This is necessary for the drag sorting to work at the top-->
<View
android:id="@+id/draggableArea"
android:layout_width="72dp"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/cardContent"
android:layout_alignBottom="@+id/cardContent"
android:layout_marginTop="120dp" />
<LinearLayout
android:id="@+id/cardContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
android:id="@+id/currentSong"
layout="@layout/item_list" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/playerQueueSubHeader"
android:layout_width="match_parent"
android:layout_height="48dp"
android:gravity="center_vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:text="@string/up_next"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
android:textColor="?android:textColorSecondary" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/playerRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="8dp"
android:requiresFadingEdge="vertical" />
</LinearLayout>
</RelativeLayout>
</com.google.android.material.card.MaterialCardView>
</code.name.monkey.retromusic.views.StatusBarMarginFrameLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
</FrameLayout>

View file

@ -1,135 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<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"
android:id="@+id/playerFooterFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="@dimen/progress_container_height"
android:background="@color/twenty_percent_black_overlay">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/playerSongCurrentProgress"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:fontFamily="sans-serif-medium"
android:gravity="center_vertical|left|end"
android:paddingLeft="8dp"
android:singleLine="true"
android:textColor="?colorOnSecondary"
android:textSize="12sp"
tools:ignore="RtlHardcoded,RtlSymmetry"
tools:text="00:22" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/playerSongTotalTime"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:fontFamily="sans-serif-medium"
android:gravity="center_vertical|right|end"
android:paddingRight="8dp"
android:singleLine="true"
android:textColor="?colorOnSecondary"
android:textSize="12sp"
tools:ignore="RtlHardcoded,RtlSymmetry"
tools:text="00:22" />
<androidx.appcompat.widget.AppCompatSeekBar
android:id="@+id/playerProgressSlider"
style="@style/MusicProgressSlider"
android:layout_height="match_parent"
android:layout_toLeftOf="@id/playerSongTotalTime"
android:layout_toRightOf="@id/playerSongCurrentProgress"
tools:ignore="RtlHardcoded,UnusedAttribute" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/playerMediaControllerContainer"
android:layout_width="match_parent"
android:layout_height="112dp"
android:layoutDirection="ltr"
tools:ignore="ContentDescription,UnusedAttribute">
<ImageButton
android:id="@+id/playerPrevButton"
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_centerVertical="true"
android:layout_marginEnd="-8dp"
android:layout_marginRight="-8dp"
android:layout_toStartOf="@+id/dummyFab"
android:layout_toLeftOf="@+id/dummyFab"
android:background="?attr/roundSelector"
android:padding="22dp"
android:scaleType="fitCenter"
app:srcCompat="@drawable/ic_skip_previous_white_24dp"
tools:ignore="MissingPrefix" />
<ImageButton
android:id="@+id/playerNextButton"
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_centerVertical="true"
android:layout_marginStart="-8dp"
android:layout_marginLeft="-8dp"
android:layout_toEndOf="@+id/dummyFab"
android:layout_toRightOf="@+id/dummyFab"
android:background="?attr/roundSelector"
android:padding="22dp"
android:scaleType="fitCenter"
app:srcCompat="@drawable/ic_skip_next_white_24dp"
tools:ignore="MissingPrefix" />
<ImageButton
android:id="@+id/playerRepeatButton"
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:background="?attr/roundSelector"
android:padding="22dp"
android:scaleType="fitCenter"
app:srcCompat="@drawable/ic_repeat_white_24dp"
tools:ignore="MissingPrefix" />
<ImageButton
android:id="@+id/playerShuffleButton"
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:background="?attr/roundSelector"
android:padding="22dp"
android:scaleType="fitCenter"
app:srcCompat="@drawable/ic_shuffle_white_24dp"
tools:ignore="MissingPrefix" />
<Space
android:id="@+id/dummyFab"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_centerInParent="true" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/playerPlayPauseFab"
style="@style/Fab"
android:layout_centerInParent="true"
app:elevation="4dp" />
</RelativeLayout>
<include layout="@layout/volume_controls" />
</LinearLayout>

View file

@ -27,7 +27,7 @@
android:layout_height="match_parent"
android:ellipsize="end"
android:maxLines="1"
android:paddingStart="8dp"
android:paddingStart="12dp"
android:paddingTop="6dp"
android:paddingEnd="8dp"
android:paddingBottom="4dp"

View file

@ -15,8 +15,8 @@
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/image"
android:layout_width="104dp"
android:layout_height="128dp"
android:layout_width="112dp"
android:layout_height="156dp"
android:scaleType="centerCrop" />
<FrameLayout

View file

@ -5,6 +5,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="8dp"
app:cardElevation="4dp"
app:cardUseCompatPadding="true"
tools:ignore="MissingPrefix">

View file

@ -6,6 +6,7 @@
android:layout_height="wrap_content"
android:orientation="vertical"
app:cardCornerRadius="8dp"
app:cardElevation="4dp"
app:cardUseCompatPadding="true"
tools:backgroundTint="@color/md_red_400">