Added proper coloring

This commit is contained in:
h4h13 2020-05-06 01:25:15 +05:30
parent bf9ddfccb7
commit fd22134a23
20 changed files with 90 additions and 160 deletions

View file

@ -63,7 +63,7 @@ class AlbumCoverPagerAdapter(
lateinit var albumCover: ImageView lateinit var albumCover: ImageView
private var isColorReady: Boolean = false private var isColorReady: Boolean = false
private var color: Int = 0 private lateinit var color: MediaNotificationProcessor
private lateinit var song: Song private lateinit var song: Song
private var colorReceiver: ColorReceiver? = null private var colorReceiver: ColorReceiver? = null
private var request: Int = 0 private var request: Int = 0
@ -123,12 +123,12 @@ class AlbumCoverPagerAdapter(
.generatePalette(requireContext()).build() .generatePalette(requireContext()).build()
.into(object : RetroMusicColoredTarget(albumCover) { .into(object : RetroMusicColoredTarget(albumCover) {
override fun onColorReady(colors: MediaNotificationProcessor) { override fun onColorReady(colors: MediaNotificationProcessor) {
setColor(colors.backgroundColor) setColor(colors)
} }
}) })
} }
private fun setColor(color: Int) { private fun setColor(color: MediaNotificationProcessor) {
this.color = color this.color = color
isColorReady = true isColorReady = true
if (colorReceiver != null) { if (colorReceiver != null) {
@ -147,7 +147,7 @@ class AlbumCoverPagerAdapter(
} }
interface ColorReceiver { interface ColorReceiver {
fun onColorReady(color: Int, request: Int) fun onColorReady(color: MediaNotificationProcessor, request: Int)
} }
companion object { companion object {

View file

@ -14,13 +14,14 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.transform.CarousalPagerTransformer import code.name.monkey.retromusic.transform.CarousalPagerTransformer
import code.name.monkey.retromusic.transform.ParallaxPagerTransformer import code.name.monkey.retromusic.transform.ParallaxPagerTransformer
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_player_album_cover.* import kotlinx.android.synthetic.main.fragment_player_album_cover.*
class PlayerAlbumCoverFragment : AbsMusicServiceFragment(), ViewPager.OnPageChangeListener { class PlayerAlbumCoverFragment : AbsMusicServiceFragment(), ViewPager.OnPageChangeListener {
private var callbacks: Callbacks? = null private var callbacks: Callbacks? = null
private var currentPosition: Int = 0 private var currentPosition: Int = 0
private val colorReceiver = object : AlbumCoverFragment.ColorReceiver { private val colorReceiver = object : AlbumCoverFragment.ColorReceiver {
override fun onColorReady(color: Int, request: Int) { override fun onColorReady(color: MediaNotificationProcessor, request: Int) {
if (currentPosition == request) { if (currentPosition == request) {
notifyColorChange(color) notifyColorChange(color)
} }
@ -103,7 +104,7 @@ class PlayerAlbumCoverFragment : AbsMusicServiceFragment(), ViewPager.OnPageChan
override fun onPageScrollStateChanged(state: Int) { override fun onPageScrollStateChanged(state: Int) {
} }
private fun notifyColorChange(color: Int) { private fun notifyColorChange(color: MediaNotificationProcessor) {
callbacks?.onColorChanged(color) callbacks?.onColorChanged(color)
} }
@ -117,7 +118,7 @@ class PlayerAlbumCoverFragment : AbsMusicServiceFragment(), ViewPager.OnPageChan
interface Callbacks { interface Callbacks {
fun onColorChanged(color: Int) fun onColorChanged(color: MediaNotificationProcessor)
fun onFavoriteToggled() fun onFavoriteToggled()
} }

View file

@ -19,6 +19,7 @@ import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.model.lyrics.AbsSynchronizedLyrics import code.name.monkey.retromusic.model.lyrics.AbsSynchronizedLyrics
import code.name.monkey.retromusic.model.lyrics.Lyrics import code.name.monkey.retromusic.model.lyrics.Lyrics
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_adaptive_player.* import kotlinx.android.synthetic.main.fragment_adaptive_player.*
class AdaptiveFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Callback { class AdaptiveFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Callback {
@ -194,9 +195,9 @@ class AdaptiveFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Call
toggleFavorite(MusicPlayerRemote.currentSong) toggleFavorite(MusicPlayerRemote.currentSong)
} }
override fun onColorChanged(color: Int) { override fun onColorChanged(color: MediaNotificationProcessor) {
playbackControlsFragment.setDark(color) playbackControlsFragment.setDark(color.backgroundColor)
lastColor = color lastColor = color.backgroundColor
callbacks?.onPaletteColorChanged() callbacks?.onPaletteColorChanged()
ToolbarContentTintHelper.colorizeToolbar( ToolbarContentTintHelper.colorizeToolbar(
playerToolbar, playerToolbar,

View file

@ -65,9 +65,9 @@ class BlurPlayerFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPrefer
toggleFavorite(MusicPlayerRemote.currentSong) toggleFavorite(MusicPlayerRemote.currentSong)
} }
override fun onColorChanged(color: Int) { override fun onColorChanged(color: MediaNotificationProcessor) {
playbackControlsFragment.setDark(color) playbackControlsFragment.setDark(color.backgroundColor)
lastColor = color lastColor = color.backgroundColor
callbacks?.onPaletteColorChanged() callbacks?.onPaletteColorChanged()
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, Color.WHITE, activity) ToolbarContentTintHelper.colorizeToolbar(playerToolbar, Color.WHITE, activity)
} }

View file

@ -13,6 +13,7 @@ import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
import code.name.monkey.retromusic.fragments.player.normal.PlayerFragment import code.name.monkey.retromusic.fragments.player.normal.PlayerFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_card_player.* import kotlinx.android.synthetic.main.fragment_card_player.*
class CardFragment : AbsPlayerFragment() { class CardFragment : AbsPlayerFragment() {
@ -43,9 +44,9 @@ class CardFragment : AbsPlayerFragment() {
return Color.WHITE return Color.WHITE
} }
override fun onColorChanged(color: Int) { override fun onColorChanged(color: MediaNotificationProcessor) {
playbackControlsFragment.setDark(color) playbackControlsFragment.setDark(color.backgroundColor)
lastColor = color lastColor = color.backgroundColor
callbacks!!.onPaletteColorChanged() callbacks!!.onPaletteColorChanged()
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, Color.WHITE, activity) ToolbarContentTintHelper.colorizeToolbar(playerToolbar, Color.WHITE, activity)

View file

@ -50,9 +50,9 @@ class CardBlurFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPreferen
return Color.WHITE return Color.WHITE
} }
override fun onColorChanged(color: Int) { override fun onColorChanged(color: MediaNotificationProcessor) {
playbackControlsFragment.setDark(color) playbackControlsFragment.setDark(color.backgroundColor)
lastColor = color lastColor = color.backgroundColor
callbacks!!.onPaletteColorChanged() callbacks!!.onPaletteColorChanged()
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, Color.WHITE, activity) ToolbarContentTintHelper.colorizeToolbar(playerToolbar, Color.WHITE, activity)

View file

@ -39,6 +39,7 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.ViewUtil import code.name.monkey.retromusic.util.ViewUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import code.name.monkey.retromusic.views.SeekArc import code.name.monkey.retromusic.views.SeekArc
import code.name.monkey.retromusic.views.SeekArc.OnSeekArcChangeListener import code.name.monkey.retromusic.views.SeekArc.OnSeekArcChangeListener
import code.name.monkey.retromusic.volume.AudioVolumeObserver import code.name.monkey.retromusic.volume.AudioVolumeObserver
@ -161,7 +162,7 @@ class CirclePlayerFragment : AbsPlayerFragment(), Callback, OnAudioVolumeChanged
override val paletteColor: Int override val paletteColor: Int
get() = Color.BLACK get() = Color.BLACK
override fun onColorChanged(color: Int) { override fun onColorChanged(color: MediaNotificationProcessor) {
} }
override fun onFavoriteToggled() { override fun onFavoriteToggled() {

View file

@ -30,6 +30,7 @@ import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.ViewUtil import code.name.monkey.retromusic.util.ViewUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.card.MaterialCardView import com.google.android.material.card.MaterialCardView
import kotlinx.android.synthetic.main.fragment_clasic_player.* import kotlinx.android.synthetic.main.fragment_clasic_player.*
@ -225,8 +226,8 @@ class ClassicPlayerFragment : AbsPlayerFragment(), View.OnLayoutChangeListener,
override val paletteColor: Int override val paletteColor: Int
get() = lastColor get() = lastColor
override fun onColorChanged(color: Int) { override fun onColorChanged(color: MediaNotificationProcessor) {
lastColor = color lastColor = color.backgroundColor
ToolbarContentTintHelper.colorizeToolbar( ToolbarContentTintHelper.colorizeToolbar(
playerToolbar, playerToolbar,
Color.WHITE, Color.WHITE,
@ -246,7 +247,7 @@ class ClassicPlayerFragment : AbsPlayerFragment(), View.OnLayoutChangeListener,
} }
val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) { val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
color color.backgroundColor
} else { } else {
ThemeStore.accentColor(requireContext()) ThemeStore.accentColor(requireContext())
}.ripAlpha() }.ripAlpha()

View file

@ -1,7 +1,6 @@
package code.name.monkey.retromusic.fragments.player.color package code.name.monkey.retromusic.fragments.player.color
import android.animation.ValueAnimator import android.animation.ValueAnimator
import android.graphics.drawable.Drawable
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
@ -9,19 +8,13 @@ import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import code.name.monkey.appthemehelper.util.ATHUtil import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ColorUtil 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.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
import code.name.monkey.retromusic.glide.SongGlideRequest.Builder
import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.NavigationUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import com.bumptech.glide.Glide
import com.bumptech.glide.request.animation.GlideAnimation
import kotlinx.android.synthetic.main.fragment_color_player.* import kotlinx.android.synthetic.main.fragment_color_player.*
class ColorFragment : AbsPlayerFragment() { class ColorFragment : AbsPlayerFragment() {
@ -38,8 +31,16 @@ class ColorFragment : AbsPlayerFragment() {
override val paletteColor: Int override val paletteColor: Int
get() = backgroundColor get() = backgroundColor
override fun onColorChanged(color: Int) { override fun onColorChanged(color: MediaNotificationProcessor) {
playbackControlsFragment.setDark(color)
lastColor = color.backgroundColor
callbacks?.onPaletteColorChanged()
ToolbarContentTintHelper.colorizeToolbar(
playerToolbar,
ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal),
requireActivity()
)
} }
override fun onFavoriteToggled() { override fun onFavoriteToggled() {
@ -90,9 +91,9 @@ class ColorFragment : AbsPlayerFragment() {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
setUpSubFragments() setUpSubFragments()
setUpPlayerToolbar() setUpPlayerToolbar()
playerImage.setOnClickListener { val playerAlbumCoverFragment =
NavigationUtil.goToLyrics(requireActivity()) childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
} playerAlbumCoverFragment.setCallbacks(this)
} }
private fun setUpSubFragments() { private fun setUpSubFragments() {
@ -113,70 +114,6 @@ class ColorFragment : AbsPlayerFragment() {
} }
} }
override fun onPlayingMetaChanged() {
super.onPlayingMetaChanged()
updateSong()
}
override fun onServiceConnected() {
super.onServiceConnected()
updateSong()
}
private fun updateSong() {
Builder.from(Glide.with(requireActivity()), MusicPlayerRemote.currentSong)
.checkIgnoreMediaStore(requireContext())
.generatePalette(requireContext())
.build()
.into(object : RetroMusicColoredTarget(playerImage) {
override fun onColorReady(colors: MediaNotificationProcessor) {
}
override fun onResourceReady(
resource: BitmapPaletteWrapper?,
glideAnimation: GlideAnimation<in BitmapPaletteWrapper>?
) {
super.onResourceReady(resource, glideAnimation)
resource?.let {
val colors =
MediaNotificationProcessor(requireContext(), resource.bitmap)
/* val palette = resource.palette
val swatch = RetroColorUtil.getSwatch(palette)
val textColor = RetroColorUtil.getTextColor(palette)
val backgroundColor = getSuitableColorFor(
palette,
ATHUtil.resolveColor(requireContext(), R.attr.colorSurface),
Color.BLACK
)
if (ATHUtil.isWindowBackgroundDark(requireContext())) {
ColorUtil.desaturateColor(backgroundColor, 0.5f)
}
*/
setColors(colors)
}
}
override fun onLoadFailed(e: Exception?, errorDrawable: Drawable?) {
super.onLoadFailed(e, errorDrawable)
val backgroundColor = defaultFooterColor
val textColor =
if (ColorUtil.isColorLight(defaultFooterColor)) MaterialValueHelper.getPrimaryTextColor(
requireContext(),
true
)
else MaterialValueHelper.getPrimaryTextColor(requireContext(), false)
//setColors(backgroundColor, textColor)
}
})
}
private fun setColors(colors: MediaNotificationProcessor) { private fun setColors(colors: MediaNotificationProcessor) {
this.lastColor = colors.backgroundColor this.lastColor = colors.backgroundColor
this.backgroundColor = colors.backgroundColor this.backgroundColor = colors.backgroundColor

View file

@ -12,6 +12,7 @@ import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_fit.* import kotlinx.android.synthetic.main.fragment_fit.*
class FitFragment : AbsPlayerFragment() { class FitFragment : AbsPlayerFragment() {
@ -42,9 +43,9 @@ class FitFragment : AbsPlayerFragment() {
return ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal) return ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal)
} }
override fun onColorChanged(color: Int) { override fun onColorChanged(color: MediaNotificationProcessor) {
playbackControlsFragment.setDark(color) playbackControlsFragment.setDark(color.backgroundColor)
lastColor = color lastColor = color.backgroundColor
callbacks?.onPaletteColorChanged() callbacks?.onPaletteColorChanged()
ToolbarContentTintHelper.colorizeToolbar( ToolbarContentTintHelper.colorizeToolbar(
playerToolbar, playerToolbar,

View file

@ -19,6 +19,7 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.ViewUtil import code.name.monkey.retromusic.util.ViewUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import code.name.monkey.retromusic.views.DrawableGradient import code.name.monkey.retromusic.views.DrawableGradient
import kotlinx.android.synthetic.main.fragment_flat_player.* import kotlinx.android.synthetic.main.fragment_flat_player.*
@ -103,18 +104,18 @@ class FlatPlayerFragment : AbsPlayerFragment() {
ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal) ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal)
} }
override fun onColorChanged(color: Int) { override fun onColorChanged(color: MediaNotificationProcessor) {
lastColor = color lastColor = color.backgroundColor
flatPlaybackControlsFragment.setDark(color) flatPlaybackControlsFragment.setDark(color.backgroundColor)
callbacks?.onPaletteColorChanged() callbacks?.onPaletteColorChanged()
val isLight = ColorUtil.isColorLight(color) val isLight = ColorUtil.isColorLight(color.backgroundColor)
val iconColor = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) val iconColor = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor)
MaterialValueHelper.getPrimaryTextColor(requireContext(), isLight) MaterialValueHelper.getPrimaryTextColor(requireContext(), isLight)
else else
ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal) ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal)
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, iconColor, requireActivity()) ToolbarContentTintHelper.colorizeToolbar(playerToolbar, iconColor, requireActivity())
if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) { if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
colorize(color) colorize(color.backgroundColor)
} }
} }

View file

@ -197,9 +197,9 @@ class FullPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
return Color.WHITE return Color.WHITE
} }
override fun onColorChanged(color: Int) { override fun onColorChanged(color: MediaNotificationProcessor) {
lastColor = color lastColor = color.backgroundColor
fullPlaybackControlsFragment.setDark(color) fullPlaybackControlsFragment.setDark(color.backgroundColor)
callbacks?.onPaletteColorChanged() callbacks?.onPaletteColorChanged()
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, Color.WHITE, activity) ToolbarContentTintHelper.colorizeToolbar(playerToolbar, Color.WHITE, activity)
} }

View file

@ -13,6 +13,7 @@ import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
import code.name.monkey.retromusic.fragments.player.normal.PlayerFragment import code.name.monkey.retromusic.fragments.player.normal.PlayerFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_material.* import kotlinx.android.synthetic.main.fragment_material.*
/** /**
@ -48,9 +49,9 @@ class MaterialFragment : AbsPlayerFragment() {
return ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal) return ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal)
} }
override fun onColorChanged(color: Int) { override fun onColorChanged(color: MediaNotificationProcessor) {
playbackControlsFragment.setDark(color) playbackControlsFragment.setDark(color.backgroundColor)
lastColor = color lastColor = color.backgroundColor
callbacks?.onPaletteColorChanged() callbacks?.onPaletteColorChanged()
ToolbarContentTintHelper.colorizeToolbar( ToolbarContentTintHelper.colorizeToolbar(

View file

@ -17,6 +17,7 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.ViewUtil import code.name.monkey.retromusic.util.ViewUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import code.name.monkey.retromusic.views.DrawableGradient import code.name.monkey.retromusic.views.DrawableGradient
import kotlinx.android.synthetic.main.fragment_player.* import kotlinx.android.synthetic.main.fragment_player.*
@ -73,9 +74,9 @@ class PlayerFragment : AbsPlayerFragment() {
return ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal) return ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal)
} }
override fun onColorChanged(color: Int) { override fun onColorChanged(color: MediaNotificationProcessor) {
playbackControlsFragment.setDark(color) playbackControlsFragment.setDark(color.backgroundColor)
lastColor = color lastColor = color.backgroundColor
callbacks?.onPaletteColorChanged() callbacks?.onPaletteColorChanged()
ToolbarContentTintHelper.colorizeToolbar( ToolbarContentTintHelper.colorizeToolbar(
@ -85,7 +86,7 @@ class PlayerFragment : AbsPlayerFragment() {
) )
if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) { if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
colorize(color) colorize(color.backgroundColor)
} }
} }

View file

@ -100,9 +100,9 @@ class PeakPlayerFragment : AbsPlayerFragment() {
override val paletteColor: Int override val paletteColor: Int
get() = lastColor get() = lastColor
override fun onColorChanged(color: Int) { override fun onColorChanged(color: MediaNotificationProcessor) {
playbackControlsFragment.setDark(color) playbackControlsFragment.setDark(color.backgroundColor)
lastColor = color lastColor = color.backgroundColor
callbacks?.onPaletteColorChanged() callbacks?.onPaletteColorChanged()
} }

View file

@ -12,6 +12,7 @@ import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_plain_player.* import kotlinx.android.synthetic.main.fragment_plain_player.*
class PlainPlayerFragment : AbsPlayerFragment() { class PlainPlayerFragment : AbsPlayerFragment() {
@ -93,9 +94,9 @@ class PlainPlayerFragment : AbsPlayerFragment() {
return ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal) return ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal)
} }
override fun onColorChanged(color: Int) { override fun onColorChanged(color: MediaNotificationProcessor) {
plainPlaybackControlsFragment.setDark(color) plainPlaybackControlsFragment.setDark(color.backgroundColor)
lastColor = color lastColor = color.backgroundColor
callbacks!!.onPaletteColorChanged() callbacks!!.onPaletteColorChanged()
ToolbarContentTintHelper.colorizeToolbar( ToolbarContentTintHelper.colorizeToolbar(
playerToolbar, playerToolbar,

View file

@ -12,6 +12,7 @@ import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_simple_player.* import kotlinx.android.synthetic.main.fragment_simple_player.*
/** /**
@ -68,10 +69,10 @@ class SimplePlayerFragment : AbsPlayerFragment() {
return ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal) return ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal)
} }
override fun onColorChanged(color: Int) { override fun onColorChanged(color: MediaNotificationProcessor) {
lastColor = color lastColor = color.backgroundColor
callbacks?.onPaletteColorChanged() callbacks?.onPaletteColorChanged()
simplePlaybackControlsFragment.setDark(color) simplePlaybackControlsFragment.setDark(color.backgroundColor)
ToolbarContentTintHelper.colorizeToolbar( ToolbarContentTintHelper.colorizeToolbar(
playerToolbar, playerToolbar,
ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal), ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal),

View file

@ -25,6 +25,7 @@ import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.ViewUtil import code.name.monkey.retromusic.util.ViewUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_tiny_player.* import kotlinx.android.synthetic.main.fragment_tiny_player.*
class TinyPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Callback { class TinyPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Callback {
@ -71,10 +72,10 @@ class TinyPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
private var textColorPrimary = 0 private var textColorPrimary = 0
private var textColorPrimaryDisabled = 0 private var textColorPrimaryDisabled = 0
override fun onColorChanged(color: Int) { override fun onColorChanged(color: MediaNotificationProcessor) {
val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) { val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
color color.backgroundColor
} else { } else {
ThemeStore.accentColor(requireContext()) ThemeStore.accentColor(requireContext())
} }

View file

@ -36,24 +36,12 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<com.google.android.material.card.MaterialCardView <fragment
android:id="@+id/playerAlbumCoverFragment"
android:name="code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_margin="12dp" tools:layout="@layout/fragment_album_cover" />
app:cardCornerRadius="8dp"
app:cardElevation="8dp"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="true">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/playerImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
tools:srcCompat="@tools:sample/backgrounds/scenic[10]" />
</com.google.android.material.card.MaterialCardView>
</code.name.monkey.retromusic.views.HeightFitSquareLayout> </code.name.monkey.retromusic.views.HeightFitSquareLayout>
<LinearLayout <LinearLayout

View file

@ -27,26 +27,19 @@
<include layout="@layout/status_bar" /> <include layout="@layout/status_bar" />
</FrameLayout> </FrameLayout>
<code.name.monkey.retromusic.views.WidthFitSquareCardView <code.name.monkey.retromusic.views.WidthFitSquareLayout
android:id="@+id/playerAlbumCoverContainer"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="16dp" android:layout_weight="0">
android:layout_marginEnd="16dp"
app:cardCornerRadius="8dp"
app:cardElevation="4dp"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="true">
<fragment
<androidx.appcompat.widget.AppCompatImageView android:id="@+id/playerAlbumCoverFragment"
android:id="@+id/playerImage" android:name="code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:scaleType="centerCrop" tools:layout="@layout/fragment_album_cover" />
tools:ignore="ContentDescription,UnusedAttribute" </code.name.monkey.retromusic.views.WidthFitSquareLayout>
tools:srcCompat="@tools:sample/backgrounds/scenic[10]" />
</code.name.monkey.retromusic.views.WidthFitSquareCardView>
<FrameLayout <FrameLayout
android:layout_width="match_parent" android:layout_width="match_parent"