Changed override color

This commit is contained in:
Hemanth S 2020-05-18 12:52:18 +05:30
parent defee853c7
commit 0b16b1f5c4
35 changed files with 167 additions and 218 deletions

View file

@ -93,7 +93,7 @@ class LockScreenActivity : AbsMusicServiceActivity() {
.generatePalette(this).build().dontAnimate() .generatePalette(this).build().dontAnimate()
.into(object : RetroMusicColoredTarget(image) { .into(object : RetroMusicColoredTarget(image) {
override fun onColorReady(colors: MediaNotificationProcessor) { override fun onColorReady(colors: MediaNotificationProcessor) {
fragment?.setDark(colors.backgroundColor) fragment?.setColor(colors)
} }
}) })
} }

View file

@ -95,6 +95,7 @@ class AlbumCoverPagerAdapter(
Fit, Fit,
Tiny, Tiny,
Classic, Classic,
Peak,
Gradient, Gradient,
Full -> R.layout.fragment_album_full_cover Full -> R.layout.fragment_album_full_cover
else -> { else -> {

View file

@ -8,6 +8,7 @@ import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.fragments.VolumeFragment import code.name.monkey.retromusic.fragments.VolumeFragment
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
/** /**
* Created by hemanths on 24/09/17. * Created by hemanths on 24/09/17.
@ -26,7 +27,7 @@ abstract class AbsPlayerControlsFragment : AbsMusicServiceFragment(),
protected abstract fun setUpProgressSlider() protected abstract fun setUpProgressSlider()
abstract fun setDark(color: Int) abstract fun setColor(color: MediaNotificationProcessor)
fun showBonceAnimation(view: View) { fun showBonceAnimation(view: View) {
view.apply { view.apply {

View file

@ -196,7 +196,7 @@ class AdaptiveFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Call
} }
override fun onColorChanged(color: MediaNotificationProcessor) { override fun onColorChanged(color: MediaNotificationProcessor) {
playbackControlsFragment.setDark(color.primaryTextColor) playbackControlsFragment.setColor(color)
lastColor = color.primaryTextColor lastColor = color.primaryTextColor
callbacks?.onPaletteColorChanged() callbacks?.onPaletteColorChanged()
ToolbarContentTintHelper.colorizeToolbar( ToolbarContentTintHelper.colorizeToolbar(

View file

@ -23,6 +23,7 @@ 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.SliderReadTimeLabelFormatter import code.name.monkey.retromusic.util.SliderReadTimeLabelFormatter
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_adaptive_player_playback_controls.* import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.*
class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() { class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() {
@ -104,7 +105,7 @@ class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() {
updateShuffleState() updateShuffleState()
} }
override fun setDark(color: Int) { override fun setColor(color: MediaNotificationProcessor) {
if (ColorUtil.isColorLight( if (ColorUtil.isColorLight(
ATHUtil.resolveColor( ATHUtil.resolveColor(
requireContext(), requireContext(),
@ -127,7 +128,7 @@ class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() {
updatePlayPauseColor() updatePlayPauseColor()
val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) { val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
color color.primaryTextColor
} else { } else {
ThemeStore.accentColor(requireContext()) ThemeStore.accentColor(requireContext())
}.ripAlpha() }.ripAlpha()

View file

@ -22,6 +22,7 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
import code.name.monkey.retromusic.service.MusicService 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.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.* import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.*
class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() { class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
@ -106,7 +107,7 @@ class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
updateShuffleState() updateShuffleState()
} }
override fun setDark(color: Int) { override fun setColor(color: MediaNotificationProcessor) {
lastPlaybackControlsColor = Color.WHITE lastPlaybackControlsColor = Color.WHITE
lastDisabledPlaybackControlsColor = lastDisabledPlaybackControlsColor =
ContextCompat.getColor(requireContext(), R.color.md_grey_500) ContextCompat.getColor(requireContext(), R.color.md_grey_500)

View file

@ -66,7 +66,7 @@ class BlurPlayerFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPrefer
} }
override fun onColorChanged(color: MediaNotificationProcessor) { override fun onColorChanged(color: MediaNotificationProcessor) {
playbackControlsFragment.setDark(color.backgroundColor) playbackControlsFragment.setColor(color)
lastColor = color.backgroundColor lastColor = color.backgroundColor
callbacks?.onPaletteColorChanged() callbacks?.onPaletteColorChanged()
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, Color.WHITE, activity) ToolbarContentTintHelper.colorizeToolbar(playerToolbar, Color.WHITE, activity)

View file

@ -45,7 +45,7 @@ class CardFragment : AbsPlayerFragment() {
} }
override fun onColorChanged(color: MediaNotificationProcessor) { override fun onColorChanged(color: MediaNotificationProcessor) {
playbackControlsFragment.setDark(color.primaryTextColor) playbackControlsFragment.setColor(color)
lastColor = color.primaryTextColor lastColor = color.primaryTextColor
callbacks?.onPaletteColorChanged() callbacks?.onPaletteColorChanged()
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, Color.WHITE, activity) ToolbarContentTintHelper.colorizeToolbar(playerToolbar, Color.WHITE, activity)

View file

@ -25,6 +25,7 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.service.MusicService 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.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_card_player_playback_controls.* import kotlinx.android.synthetic.main.fragment_card_player_playback_controls.*
import kotlinx.android.synthetic.main.media_button.* import kotlinx.android.synthetic.main.media_button.*
@ -109,14 +110,8 @@ class CardPlaybackControlsFragment : AbsPlayerControlsFragment() {
updateShuffleState() updateShuffleState()
} }
override fun setDark(color: Int) { override fun setColor(color: MediaNotificationProcessor) {
if (ATHUtil.isWindowBackgroundDark(requireContext())
if (ColorUtil.isColorLight(
ATHUtil.resolveColor(
requireContext(),
android.R.attr.windowBackground
)
)
) { ) {
lastPlaybackControlsColor = MaterialValueHelper.getSecondaryTextColor(activity, true) lastPlaybackControlsColor = MaterialValueHelper.getSecondaryTextColor(activity, true)
lastDisabledPlaybackControlsColor = lastDisabledPlaybackControlsColor =
@ -134,7 +129,7 @@ class CardPlaybackControlsFragment : AbsPlayerControlsFragment() {
updateProgressTextColor() updateProgressTextColor()
val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) { val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
color color.primaryTextColor
} else { } else {
ThemeStore.accentColor(requireContext()).ripAlpha() ThemeStore.accentColor(requireContext()).ripAlpha()
} }

View file

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

View file

@ -21,6 +21,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 kotlinx.android.synthetic.main.fragment_card_blur_player_playback_controls.* import kotlinx.android.synthetic.main.fragment_card_blur_player_playback_controls.*
import kotlinx.android.synthetic.main.media_button.* import kotlinx.android.synthetic.main.media_button.*
@ -52,7 +53,7 @@ class CardBlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
setUpMusicControllers() setUpMusicControllers()
} }
override fun setDark(color: Int) { override fun setColor(color: MediaNotificationProcessor) {
lastPlaybackControlsColor = Color.WHITE lastPlaybackControlsColor = Color.WHITE
lastDisabledPlaybackControlsColor = ColorUtil.withAlpha(Color.WHITE, 0.3f) lastDisabledPlaybackControlsColor = ColorUtil.withAlpha(Color.WHITE, 0.3f)

View file

@ -34,7 +34,7 @@ class ColorFragment : AbsPlayerFragment() {
override fun onColorChanged(color: MediaNotificationProcessor) { override fun onColorChanged(color: MediaNotificationProcessor) {
lastColor = color.secondaryTextColor lastColor = color.secondaryTextColor
playbackControlsFragment.setDark(color) playbackControlsFragment.setColor(color)
navigationColor = color.backgroundColor navigationColor = color.backgroundColor
callbacks?.onPaletteColorChanged() callbacks?.onPaletteColorChanged()
colorGradientBackground?.setBackgroundColor(color.backgroundColor) colorGradientBackground?.setBackgroundColor(color.backgroundColor)

View file

@ -96,23 +96,20 @@ class ColorPlaybackControlsFragment : AbsPlayerControlsFragment() {
updateShuffleState() updateShuffleState()
} }
fun setDark(colors: MediaNotificationProcessor) { override fun setColor(color: MediaNotificationProcessor) {
setDark(colors.secondaryTextColor) TintHelper.setTintAuto(playPauseButton, color.primaryTextColor, true)
TintHelper.setTintAuto(playPauseButton, colors.primaryTextColor, true) TintHelper.setTintAuto(playPauseButton, color.backgroundColor, false)
TintHelper.setTintAuto(playPauseButton, colors.backgroundColor, false)
title.setTextColor(colors.primaryTextColor) title.setTextColor(color.primaryTextColor)
text.setTextColor(colors.secondaryTextColor) text.setTextColor(color.secondaryTextColor)
songInfo.setTextColor(colors.secondaryTextColor) songInfo.setTextColor(color.secondaryTextColor)
ViewUtil.setProgressDrawable(progressSlider, colors.primaryTextColor, true) ViewUtil.setProgressDrawable(progressSlider, color.primaryTextColor, true)
songCurrentProgress.setTextColor(colors.secondaryTextColor) songCurrentProgress.setTextColor(color.secondaryTextColor)
songTotalTime.setTextColor(colors.secondaryTextColor) songTotalTime.setTextColor(color.secondaryTextColor)
volumeFragment?.setTintableColor(colors.primaryTextColor) volumeFragment?.setTintableColor(color.primaryTextColor)
}
override fun setDark(color: Int) { lastPlaybackControlsColor = color.secondaryTextColor
lastPlaybackControlsColor = color lastDisabledPlaybackControlsColor = ColorUtil.withAlpha(color.secondaryTextColor, 0.25f)
lastDisabledPlaybackControlsColor = ColorUtil.withAlpha(color, 0.25f)
updateRepeatState() updateRepeatState()
updateShuffleState() updateShuffleState()

View file

@ -44,7 +44,7 @@ class FitFragment : AbsPlayerFragment() {
} }
override fun onColorChanged(color: MediaNotificationProcessor) { override fun onColorChanged(color: MediaNotificationProcessor) {
playbackControlsFragment.setDark(color.primaryTextColor) playbackControlsFragment.setColor(color)
lastColor = color.primaryTextColor lastColor = color.primaryTextColor
callbacks?.onPaletteColorChanged() callbacks?.onPaletteColorChanged()
ToolbarContentTintHelper.colorizeToolbar( ToolbarContentTintHelper.colorizeToolbar(

View file

@ -27,6 +27,7 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.service.MusicService 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.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_fit_playback_controls.* import kotlinx.android.synthetic.main.fragment_fit_playback_controls.*
class FitPlaybackControlsFragment : AbsPlayerControlsFragment() { class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
@ -112,10 +113,11 @@ class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
updateShuffleState() updateShuffleState()
} }
override fun setDark(color: Int) { override fun setColor(color: MediaNotificationProcessor) {
val colorBg = ATHUtil.resolveColor(requireContext(), android.R.attr.colorBackground) val colorBg = ATHUtil.resolveColor(requireContext(), android.R.attr.colorBackground)
if (ColorUtil.isColorLight(colorBg)) { if (ColorUtil.isColorLight(colorBg)) {
lastPlaybackControlsColor = MaterialValueHelper.getSecondaryTextColor(requireContext(), true) lastPlaybackControlsColor =
MaterialValueHelper.getSecondaryTextColor(requireContext(), true)
lastDisabledPlaybackControlsColor = lastDisabledPlaybackControlsColor =
MaterialValueHelper.getSecondaryDisabledTextColor(requireContext(), true) MaterialValueHelper.getSecondaryDisabledTextColor(requireContext(), true)
} else { } else {
@ -125,7 +127,7 @@ class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
} }
val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) { val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
color color.primaryTextColor
} else { } else {
ThemeStore.accentColor(requireContext()).ripAlpha() ThemeStore.accentColor(requireContext()).ripAlpha()
} }
@ -239,7 +241,6 @@ class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
} }
private fun showBonceAnimation() { private fun showBonceAnimation() {
playPauseButton.apply { playPauseButton.apply {
clearAnimation() clearAnimation()
@ -262,6 +263,7 @@ class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
}.start() }.start()
} }
} }
override fun setUpProgressSlider() { override fun setUpProgressSlider() {
progressSlider.setOnSeekBarChangeListener(object : SimpleOnSeekbarChangeListener() { progressSlider.setOnSeekBarChangeListener(object : SimpleOnSeekbarChangeListener() {
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) { override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
@ -275,6 +277,7 @@ class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
} }
}) })
} }
override fun onUpdateProgressViews(progress: Int, total: Int) { override fun onUpdateProgressViews(progress: Int, total: Int) {
progressSlider.max = total progressSlider.max = total

View file

@ -24,6 +24,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 kotlinx.android.synthetic.main.fragment_flat_player_playback_controls.* import kotlinx.android.synthetic.main.fragment_flat_player_playback_controls.*
class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback { class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback {
@ -77,10 +78,8 @@ class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback {
} }
} }
override fun setDark(color: Int) { override fun setColor(color: MediaNotificationProcessor) {
val colorBg = ATHUtil.resolveColor(requireContext(), android.R.attr.colorBackground) if (ATHUtil.isWindowBackgroundDark(requireContext())) {
val isDark = ColorUtil.isColorLight(colorBg)
if (isDark) {
lastPlaybackControlsColor = lastPlaybackControlsColor =
MaterialValueHelper.getSecondaryTextColor(requireContext(), true) MaterialValueHelper.getSecondaryTextColor(requireContext(), true)
lastDisabledPlaybackControlsColor = lastDisabledPlaybackControlsColor =
@ -93,7 +92,7 @@ class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback {
} }
val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) { val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
color color.primaryTextColor
} else { } else {
ThemeStore.accentColor(requireContext()).ripAlpha() ThemeStore.accentColor(requireContext()).ripAlpha()
} }

View file

@ -106,7 +106,7 @@ class FlatPlayerFragment : AbsPlayerFragment() {
override fun onColorChanged(color: MediaNotificationProcessor) { override fun onColorChanged(color: MediaNotificationProcessor) {
lastColor = color.backgroundColor lastColor = color.backgroundColor
controlsFragment.setDark(color.primaryTextColor) controlsFragment.setColor(color)
callbacks?.onPaletteColorChanged() callbacks?.onPaletteColorChanged()
val isLight = ColorUtil.isColorLight(color.backgroundColor) val isLight = ColorUtil.isColorLight(color.backgroundColor)
val iconColor = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) val iconColor = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor)

View file

@ -12,14 +12,10 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.animation.DecelerateInterpolator import android.view.animation.DecelerateInterpolator
import android.widget.PopupMenu import android.widget.PopupMenu
import androidx.core.content.ContextCompat
import code.name.monkey.appthemehelper.ThemeStore
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.TintHelper import code.name.monkey.appthemehelper.util.TintHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.extensions.hide import code.name.monkey.retromusic.extensions.hide
import code.name.monkey.retromusic.extensions.ripAlpha
import code.name.monkey.retromusic.extensions.show import code.name.monkey.retromusic.extensions.show
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
@ -93,7 +89,7 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(),
} }
} }
fun setDark(color: MediaNotificationProcessor) { override fun setColor(color: MediaNotificationProcessor) {
lastPlaybackControlsColor = color.primaryTextColor lastPlaybackControlsColor = color.primaryTextColor
lastDisabledPlaybackControlsColor = ColorUtil.withAlpha(color.primaryTextColor, 0.3f) lastDisabledPlaybackControlsColor = ColorUtil.withAlpha(color.primaryTextColor, 0.3f)
@ -116,34 +112,6 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(),
updatePrevNextColor() updatePrevNextColor()
} }
override fun setDark(color: Int) {
lastPlaybackControlsColor = Color.WHITE
lastDisabledPlaybackControlsColor =
ContextCompat.getColor(requireContext(), R.color.md_grey_500)
val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
color
} else {
ThemeStore.accentColor(requireContext()).ripAlpha()
}
volumeFragment?.setTintableColor(colorFinal)
text.setTextColor(colorFinal)
ViewUtil.setProgressDrawable(progressSlider, colorFinal, true)
playPauseButton.backgroundTintList = ColorStateList.valueOf(colorFinal)
playPauseButton.imageTintList = ColorStateList.valueOf(
MaterialValueHelper.getPrimaryTextColor(
context,
ColorUtil.isColorLight(colorFinal)
)
)
updateRepeatState()
updateShuffleState()
updatePrevNextColor()
}
override fun onServiceConnected() { override fun onServiceConnected() {
updatePlayPauseDrawableState() updatePlayPauseDrawableState()
updateRepeatState() updateRepeatState()

View file

@ -201,7 +201,7 @@ class FullPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
override fun onColorChanged(color: MediaNotificationProcessor) { override fun onColorChanged(color: MediaNotificationProcessor) {
lastColor = color.backgroundColor lastColor = color.backgroundColor
mask.backgroundTintList = ColorStateList.valueOf(color.backgroundColor) mask.backgroundTintList = ColorStateList.valueOf(color.backgroundColor)
controlsFragment.setDark(color) controlsFragment.setColor(color)
callbacks?.onPaletteColorChanged() callbacks?.onPaletteColorChanged()
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, Color.WHITE, activity) ToolbarContentTintHelper.colorizeToolbar(playerToolbar, Color.WHITE, activity)
} }

View file

@ -35,6 +35,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 kotlinx.android.synthetic.main.fragment_lock_screen_playback_controls.* import kotlinx.android.synthetic.main.fragment_lock_screen_playback_controls.*
/** /**
@ -105,7 +106,7 @@ class LockScreenPlayerControlsFragment : AbsPlayerControlsFragment() {
updateShuffleState() updateShuffleState()
} }
override fun setDark(color: Int) { override fun setColor(color: MediaNotificationProcessor) {
val colorBg = ATHUtil.resolveColor(requireContext(), android.R.attr.colorBackground) val colorBg = ATHUtil.resolveColor(requireContext(), android.R.attr.colorBackground)
if (ColorUtil.isColorLight(colorBg)) { if (ColorUtil.isColorLight(colorBg)) {
@ -121,7 +122,7 @@ class LockScreenPlayerControlsFragment : AbsPlayerControlsFragment() {
} }
val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) { val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
color color.primaryTextColor
} else { } else {
textColorSecondary(requireContext()) textColorSecondary(requireContext())
}.ripAlpha() }.ripAlpha()

View file

@ -20,6 +20,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 kotlinx.android.synthetic.main.fragment_material_playback_controls.* import kotlinx.android.synthetic.main.fragment_material_playback_controls.*
/** /**
@ -97,7 +98,7 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() {
updateShuffleState() updateShuffleState()
} }
override fun setDark(color: Int) { override fun setColor(color: MediaNotificationProcessor) {
if (ATHUtil.isWindowBackgroundDark(requireContext())) { if (ATHUtil.isWindowBackgroundDark(requireContext())) {
lastPlaybackControlsColor = lastPlaybackControlsColor =
MaterialValueHelper.getPrimaryTextColor(requireContext(), false) MaterialValueHelper.getPrimaryTextColor(requireContext(), false)

View file

@ -50,7 +50,7 @@ class MaterialFragment : AbsPlayerFragment() {
} }
override fun onColorChanged(color: MediaNotificationProcessor) { override fun onColorChanged(color: MediaNotificationProcessor) {
playbackControlsFragment.setDark(color.backgroundColor) playbackControlsFragment.setColor(color)
lastColor = color.backgroundColor lastColor = color.backgroundColor
callbacks?.onPaletteColorChanged() callbacks?.onPaletteColorChanged()

View file

@ -75,7 +75,7 @@ class PlayerFragment : AbsPlayerFragment() {
} }
override fun onColorChanged(color: MediaNotificationProcessor) { override fun onColorChanged(color: MediaNotificationProcessor) {
controlsFragment.setDark(color.primaryTextColor) controlsFragment.setColor(color)
lastColor = color.backgroundColor lastColor = color.backgroundColor
callbacks?.onPaletteColorChanged() callbacks?.onPaletteColorChanged()

View file

@ -23,6 +23,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 kotlinx.android.synthetic.main.fragment_player_playback_controls.* import kotlinx.android.synthetic.main.fragment_player_playback_controls.*
class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment() { class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment() {
@ -58,7 +59,7 @@ class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment() {
} }
override fun setDark(color: Int) { override fun setColor(color: MediaNotificationProcessor) {
val colorBg = ATHUtil.resolveColor(requireContext(), android.R.attr.colorBackground) val colorBg = ATHUtil.resolveColor(requireContext(), android.R.attr.colorBackground)
if (ColorUtil.isColorLight(colorBg)) { if (ColorUtil.isColorLight(colorBg)) {
lastPlaybackControlsColor = lastPlaybackControlsColor =
@ -73,7 +74,7 @@ class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment() {
} }
val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) { val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
color color.primaryTextColor
} else { } else {
ThemeStore.accentColor(requireContext()) ThemeStore.accentColor(requireContext())
}.ripAlpha() }.ripAlpha()

View file

@ -83,10 +83,10 @@ class PeakPlayerControlFragment : AbsPlayerControlsFragment() {
override fun hide() { override fun hide() {
} }
fun setDark(color: MediaNotificationProcessor) { override fun setColor(color: MediaNotificationProcessor) {
val controlsColor = val controlsColor =
if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) { if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
color.secondaryTextColor color.primaryTextColor
} else { } else {
ThemeStore.accentColor(requireContext()) ThemeStore.accentColor(requireContext())
} }
@ -111,9 +111,6 @@ class PeakPlayerControlFragment : AbsPlayerControlsFragment() {
updateShuffleState() updateShuffleState()
} }
override fun setDark(color: Int) {
}
private fun updatePlayPauseDrawableState() { private fun updatePlayPauseDrawableState() {
if (MusicPlayerRemote.isPlaying) { if (MusicPlayerRemote.isPlaying) {
playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp) playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp)

View file

@ -25,13 +25,10 @@ import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.extensions.hide import code.name.monkey.retromusic.extensions.hide
import code.name.monkey.retromusic.extensions.show import code.name.monkey.retromusic.extensions.show
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
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.util.NavigationUtil
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import com.bumptech.glide.Glide
import kotlinx.android.synthetic.main.fragment_peak_player.* import kotlinx.android.synthetic.main.fragment_peak_player.*
/** /**
@ -56,14 +53,16 @@ class PeakPlayerFragment : AbsPlayerFragment() {
setUpPlayerToolbar() setUpPlayerToolbar()
setUpSubFragments() setUpSubFragments()
title.isSelected = true title.isSelected = true
playerImage.setOnClickListener {
NavigationUtil.goToLyrics(requireActivity())
}
} }
private fun setUpSubFragments() { private fun setUpSubFragments() {
controlsFragment = controlsFragment =
childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as PeakPlayerControlFragment childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as PeakPlayerControlFragment
val coverFragment =
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
coverFragment.setCallbacks(this)
} }
private fun setUpPlayerToolbar() { private fun setUpPlayerToolbar() {
@ -103,6 +102,7 @@ class PeakPlayerFragment : AbsPlayerFragment() {
override fun onColorChanged(color: MediaNotificationProcessor) { override fun onColorChanged(color: MediaNotificationProcessor) {
lastColor = color.primaryTextColor lastColor = color.primaryTextColor
callbacks?.onPaletteColorChanged() callbacks?.onPaletteColorChanged()
controlsFragment.setColor(color)
} }
override fun onFavoriteToggled() { override fun onFavoriteToggled() {
@ -119,16 +119,6 @@ class PeakPlayerFragment : AbsPlayerFragment() {
} else { } else {
songInfo.hide() songInfo.hide()
} }
SongGlideRequest.Builder.from(Glide.with(requireActivity()), MusicPlayerRemote.currentSong)
.checkIgnoreMediaStore(requireContext())
.generatePalette(requireContext())
.build()
.into(object : RetroMusicColoredTarget(playerImage) {
override fun onColorReady(colors: MediaNotificationProcessor) {
controlsFragment.setDark(colors)
}
})
} }
override fun onServiceConnected() { override fun onServiceConnected() {

View file

@ -15,7 +15,6 @@ import code.name.monkey.appthemehelper.util.TintHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.extensions.hide import code.name.monkey.retromusic.extensions.hide
import code.name.monkey.retromusic.extensions.ripAlpha import code.name.monkey.retromusic.extensions.ripAlpha
import code.name.monkey.retromusic.extensions.setRange
import code.name.monkey.retromusic.extensions.show import code.name.monkey.retromusic.extensions.show
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
@ -25,6 +24,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 kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.songInfo import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.songInfo
import kotlinx.android.synthetic.main.fragment_plain_controls_fragment.nextButton import kotlinx.android.synthetic.main.fragment_plain_controls_fragment.nextButton
import kotlinx.android.synthetic.main.fragment_plain_controls_fragment.playPauseButton import kotlinx.android.synthetic.main.fragment_plain_controls_fragment.playPauseButton
@ -139,28 +139,33 @@ class PlainPlaybackControlsFragment : AbsPlayerControlsFragment() {
previousButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN) previousButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
override fun setDark(color: Int) { override fun setColor(color: MediaNotificationProcessor) {
val colorBg = ATHUtil.resolveColor(context!!, android.R.attr.colorBackground) val colorBg = ATHUtil.resolveColor(requireContext(), android.R.attr.colorBackground)
if (ColorUtil.isColorLight(colorBg)) { if (ColorUtil.isColorLight(colorBg)) {
lastPlaybackControlsColor = MaterialValueHelper.getSecondaryTextColor(context!!, true) lastPlaybackControlsColor =
MaterialValueHelper.getSecondaryTextColor(requireContext(), true)
lastDisabledPlaybackControlsColor = lastDisabledPlaybackControlsColor =
MaterialValueHelper.getSecondaryDisabledTextColor(context!!, true) MaterialValueHelper.getSecondaryDisabledTextColor(requireContext(), true)
} else { } else {
lastPlaybackControlsColor = MaterialValueHelper.getPrimaryTextColor(context!!, false) lastPlaybackControlsColor =
MaterialValueHelper.getPrimaryTextColor(requireContext(), false)
lastDisabledPlaybackControlsColor = lastDisabledPlaybackControlsColor =
MaterialValueHelper.getPrimaryDisabledTextColor(context!!, false) MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false)
} }
val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) { val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
color color.primaryTextColor
} else { } else {
ThemeStore.accentColor(context!!) ThemeStore.accentColor(requireContext())
} }
volumeFragment?.setTintable(colorFinal) volumeFragment?.setTintable(colorFinal)
TintHelper.setTintAuto( TintHelper.setTintAuto(
playPauseButton, playPauseButton,
MaterialValueHelper.getPrimaryTextColor(context!!, ColorUtil.isColorLight(colorFinal)), MaterialValueHelper.getPrimaryTextColor(
requireContext(),
ColorUtil.isColorLight(colorFinal)
),
false false
) )
TintHelper.setTintAuto(playPauseButton, colorFinal, true) TintHelper.setTintAuto(playPauseButton, colorFinal, true)

View file

@ -95,7 +95,7 @@ class PlainPlayerFragment : AbsPlayerFragment() {
} }
override fun onColorChanged(color: MediaNotificationProcessor) { override fun onColorChanged(color: MediaNotificationProcessor) {
plainPlaybackControlsFragment.setDark(color.primaryTextColor) plainPlaybackControlsFragment.setColor(color)
lastColor = color.primaryTextColor lastColor = color.primaryTextColor
callbacks!!.onPaletteColorChanged() callbacks!!.onPaletteColorChanged()
ToolbarContentTintHelper.colorizeToolbar( ToolbarContentTintHelper.colorizeToolbar(

View file

@ -21,6 +21,7 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
import code.name.monkey.retromusic.service.MusicService 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.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_simple_controls_fragment.* import kotlinx.android.synthetic.main.fragment_simple_controls_fragment.*
/** /**
@ -197,29 +198,34 @@ class SimplePlaybackControlsFragment : AbsPlayerControlsFragment() {
) )
} }
override fun setDark(color: Int) { override fun setColor(color: MediaNotificationProcessor) {
val colorBg = ATHUtil.resolveColor(context!!, android.R.attr.colorBackground) val colorBg = ATHUtil.resolveColor(requireContext(), android.R.attr.colorBackground)
if (ColorUtil.isColorLight(colorBg)) { if (ColorUtil.isColorLight(colorBg)) {
lastPlaybackControlsColor = MaterialValueHelper.getSecondaryTextColor(context!!, true) lastPlaybackControlsColor =
MaterialValueHelper.getSecondaryTextColor(requireContext(), true)
lastDisabledPlaybackControlsColor = lastDisabledPlaybackControlsColor =
MaterialValueHelper.getSecondaryDisabledTextColor(context!!, true) MaterialValueHelper.getSecondaryDisabledTextColor(requireContext(), true)
} else { } else {
lastPlaybackControlsColor = MaterialValueHelper.getPrimaryTextColor(context!!, false) lastPlaybackControlsColor =
MaterialValueHelper.getPrimaryTextColor(requireContext(), false)
lastDisabledPlaybackControlsColor = lastDisabledPlaybackControlsColor =
MaterialValueHelper.getPrimaryDisabledTextColor(context!!, false) MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false)
} }
val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) { val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
color color.primaryTextColor
} else { } else {
ThemeStore.accentColor(context!!) ThemeStore.accentColor(requireContext())
} }
volumeFragment?.setTintable(colorFinal) volumeFragment?.setTintable(colorFinal)
TintHelper.setTintAuto( TintHelper.setTintAuto(
playPauseButton, playPauseButton,
MaterialValueHelper.getPrimaryTextColor(context!!, ColorUtil.isColorLight(colorFinal)), MaterialValueHelper.getPrimaryTextColor(
requireContext(),
ColorUtil.isColorLight(colorFinal)
),
false false
) )
TintHelper.setTintAuto(playPauseButton, colorFinal, true) TintHelper.setTintAuto(playPauseButton, colorFinal, true)

View file

@ -72,7 +72,7 @@ class SimplePlayerFragment : AbsPlayerFragment() {
override fun onColorChanged(color: MediaNotificationProcessor) { override fun onColorChanged(color: MediaNotificationProcessor) {
lastColor = color.backgroundColor lastColor = color.backgroundColor
callbacks?.onPaletteColorChanged() callbacks?.onPaletteColorChanged()
controlsFragment.setDark(color.primaryTextColor) controlsFragment.setColor(color)
ToolbarContentTintHelper.colorizeToolbar( ToolbarContentTintHelper.colorizeToolbar(
playerToolbar, playerToolbar,
ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal), ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal),

View file

@ -6,11 +6,11 @@ import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
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.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_tiny_controls_fragment.* import kotlinx.android.synthetic.main.fragment_tiny_controls_fragment.*
class TinyPlaybackControlsFragment : AbsPlayerControlsFragment() { class TinyPlaybackControlsFragment : AbsPlayerControlsFragment() {
@ -24,18 +24,9 @@ class TinyPlaybackControlsFragment : AbsPlayerControlsFragment() {
override fun setUpProgressSlider() { override fun setUpProgressSlider() {
} }
override fun setDark(color: Int) { override fun setColor(color: MediaNotificationProcessor) {
if (ColorUtil.isColorLight(color)) { lastPlaybackControlsColor = color.secondaryTextColor
lastPlaybackControlsColor = lastDisabledPlaybackControlsColor = ColorUtil.withAlpha(color.secondaryTextColor, 0.25f)
MaterialValueHelper.getSecondaryTextColor(requireContext(), true)
lastDisabledPlaybackControlsColor =
MaterialValueHelper.getSecondaryDisabledTextColor(requireContext(), true)
} else {
lastPlaybackControlsColor =
MaterialValueHelper.getPrimaryTextColor(requireContext(), false)
lastDisabledPlaybackControlsColor =
MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false)
}
updateRepeatState() updateRepeatState()
updateShuffleState() updateShuffleState()

View file

@ -3,14 +3,12 @@ package code.name.monkey.retromusic.fragments.player.tiny
import android.animation.AnimatorSet import android.animation.AnimatorSet
import android.animation.ObjectAnimator import android.animation.ObjectAnimator
import android.os.Bundle import android.os.Bundle
import android.os.Handler
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.animation.LinearInterpolator import android.view.animation.LinearInterpolator
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import code.name.monkey.appthemehelper.ThemeStore
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.extensions.hide import code.name.monkey.retromusic.extensions.hide
@ -27,6 +25,7 @@ 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.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_tiny_player.* import kotlinx.android.synthetic.main.fragment_tiny_player.*
import kotlinx.android.synthetic.main.fragment_tiny_player.playerToolbar
class TinyPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Callback { class TinyPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Callback {
override fun onUpdateProgressViews(progress: Int, total: Int) { override fun onUpdateProgressViews(progress: Int, total: Int) {
@ -62,55 +61,41 @@ class TinyPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
} }
override fun toolbarIconColor(): Int { override fun toolbarIconColor(): Int {
return textColorPrimary return lastColor
} }
private var lastColor: Int = 0 private var lastColor: Int = 0
override val paletteColor: Int override val paletteColor: Int
get() = lastColor get() = lastColor
private var textColorPrimary = 0
private var textColorPrimaryDisabled = 0
override fun onColorChanged(color: MediaNotificationProcessor) { override fun onColorChanged(color: MediaNotificationProcessor) {
lastColor = color.backgroundColor
val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) { controlsFragment.setColor(color)
color.primaryTextColor
} else {
ThemeStore.accentColor(requireContext())
}
if (ColorUtil.isColorLight(colorFinal)) {
textColorPrimary = MaterialValueHelper.getSecondaryTextColor(requireContext(), true)
textColorPrimaryDisabled =
MaterialValueHelper.getSecondaryTextColor(requireContext(), true)
} else {
textColorPrimary = MaterialValueHelper.getPrimaryTextColor(requireContext(), false)
textColorPrimaryDisabled =
MaterialValueHelper.getSecondaryTextColor(requireContext(), false)
}
this.lastColor = colorFinal
callbacks?.onPaletteColorChanged() callbacks?.onPaletteColorChanged()
tinyPlaybackControlsFragment.setDark(colorFinal) title.setTextColor(color.primaryTextColor)
playerSongTotalTime.setTextColor(color.primaryTextColor)
text.setTextColor(color.secondaryTextColor)
songInfo.setTextColor(color.secondaryTextColor)
ViewUtil.setProgressDrawable(progressBar, color.backgroundColor)
ViewUtil.setProgressDrawable(progressBar, colorFinal)
title.setTextColor(textColorPrimary) Handler().post {
text.setTextColor(textColorPrimaryDisabled) ToolbarContentTintHelper.colorizeToolbar(
songInfo.setTextColor(textColorPrimaryDisabled) playerToolbar,
playerSongTotalTime.setTextColor(textColorPrimary) color.secondaryTextColor,
requireActivity()
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, textColorPrimary, requireActivity()) )
}
} }
override fun onFavoriteToggled() { override fun onFavoriteToggled() {
toggleFavorite(MusicPlayerRemote.currentSong) toggleFavorite(MusicPlayerRemote.currentSong)
} }
private lateinit var tinyPlaybackControlsFragment: TinyPlaybackControlsFragment private lateinit var controlsFragment: TinyPlaybackControlsFragment
private lateinit var progressViewUpdateHelper: MusicProgressViewUpdateHelper private lateinit var progressViewUpdateHelper: MusicProgressViewUpdateHelper
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
@ -160,7 +145,7 @@ class TinyPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
} }
private fun setUpSubFragments() { private fun setUpSubFragments() {
tinyPlaybackControlsFragment = controlsFragment =
childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as TinyPlaybackControlsFragment childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as TinyPlaybackControlsFragment
val playerAlbumCoverFragment = val playerAlbumCoverFragment =
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment

View file

@ -33,6 +33,7 @@ import java.util.List;
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.retromusic.R;
import static androidx.core.graphics.ColorUtils.RGBToXYZ; import static androidx.core.graphics.ColorUtils.RGBToXYZ;
@ -82,6 +83,7 @@ public class MediaNotificationProcessor {
* A bit less then the above value, since it looks better on dark backgrounds. * A bit less then the above value, since it looks better on dark backgrounds.
*/ */
private static final int LIGHTNESS_TEXT_DIFFERENCE_DARK = -10; private static final int LIGHTNESS_TEXT_DIFFERENCE_DARK = -10;
private static final String TAG = "ColorPicking";
private float[] mFilteredBackgroundHsl = null; private float[] mFilteredBackgroundHsl = null;
private Palette.Filter mBlackWhiteFilter = new Palette.Filter() { private Palette.Filter mBlackWhiteFilter = new Palette.Filter() {
@Override @Override
@ -103,13 +105,13 @@ public class MediaNotificationProcessor {
getMediaPalette(); getMediaPalette();
} }
public MediaNotificationProcessor(Context context, Bitmap bitmap) { public MediaNotificationProcessor(Context context, Bitmap bitmap) {
this.context = context; this.context = context;
this.drawable = new BitmapDrawable(context.getResources(), bitmap); this.drawable = new BitmapDrawable(context.getResources(), bitmap);
getMediaPalette(); getMediaPalette();
} }
public MediaNotificationProcessor(Context context) { public MediaNotificationProcessor(Context context) {
this.context = context; this.context = context;
} }
@ -462,7 +464,6 @@ public class MediaNotificationProcessor {
backgroundColor); backgroundColor);
} }
public int getPrimaryTextColor() { public int getPrimaryTextColor() {
return primaryTextColor; return primaryTextColor;
} }
@ -479,16 +480,26 @@ public class MediaNotificationProcessor {
return backgroundColor; return backgroundColor;
} }
public int getMightyColor() { boolean isWhiteColor(int color) {
if (ATHUtil.INSTANCE.isWindowBackgroundDark(context)) { return calculateLuminance(color) > 0.6f;
if (!ColorUtil.INSTANCE.isColorLight(primaryTextColor)) {
return NotificationColorUtil.ensureTextContrastOnBlack(primaryTextColor);
}
return NotificationColorUtil.ensureTextBackgroundColor(backgroundColor, primaryTextColor, secondaryTextColor);
}
return primaryTextColor;
} }
public int getMightyColor() {
boolean isDarkBg = ColorUtil.INSTANCE.isColorLight(ATHUtil.INSTANCE.resolveColor(context, R.attr.colorSurface));
if (isDarkBg) {
if (isColorLight(backgroundColor)) {
return primaryTextColor;
} else {
return backgroundColor;
}
} else {
if (isColorLight(backgroundColor)) {
return backgroundColor;
} else {
return primaryTextColor;
}
}
}
public interface OnPaletteLoadedListener { public interface OnPaletteLoadedListener {
void onPaletteLoaded(MediaNotificationProcessor mediaNotificationProcessor); void onPaletteLoaded(MediaNotificationProcessor mediaNotificationProcessor);

View file

@ -46,23 +46,16 @@
app:navigationIcon="@drawable/ic_keyboard_arrow_down_black_24dp" /> app:navigationIcon="@drawable/ic_keyboard_arrow_down_black_24dp" />
</FrameLayout> </FrameLayout>
<code.name.monkey.retromusic.views.WidthFitSquareCardView
android:id="@+id/imageContainer" <androidx.fragment.app.FragmentContainerView
android:id="@+id/playerAlbumCoverFragment"
android:name="code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment"
android:layout_width="72dp" android:layout_width="72dp"
android:layout_height="72dp" android:layout_height="72dp"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
app:cardCornerRadius="8dp" app:layout_constraintHeight_percent="0.5"
app:cardUseCompatPadding="true"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/toolbarContainer"> app:layout_constraintTop_toBottomOf="@id/toolbarContainer" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/playerImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
tools:src="@tools:sample/avatars" />
</code.name.monkey.retromusic.views.WidthFitSquareCardView>
<LinearLayout <LinearLayout
android:id="@+id/titleContainer" android:id="@+id/titleContainer"
@ -70,7 +63,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@+id/text" app:layout_constraintBottom_toTopOf="@+id/text"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/imageContainer" app:layout_constraintStart_toEndOf="@id/playerAlbumCoverFragment"
app:layout_constraintTop_toBottomOf="@+id/toolbarContainer"> app:layout_constraintTop_toBottomOf="@+id/toolbarContainer">
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
@ -101,7 +94,7 @@
android:textColor="?android:attr/textColorSecondary" android:textColor="?android:attr/textColorSecondary"
app:layout_constraintBottom_toTopOf="@+id/songInfo" app:layout_constraintBottom_toTopOf="@+id/songInfo"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/imageContainer" app:layout_constraintStart_toEndOf="@id/playerAlbumCoverFragment"
app:layout_constraintTop_toBottomOf="@+id/titleContainer" app:layout_constraintTop_toBottomOf="@+id/titleContainer"
tools:text="@tools:sample/lorem" /> tools:text="@tools:sample/lorem" />
@ -115,24 +108,21 @@
android:maxLines="1" android:maxLines="1"
android:textColor="?android:attr/textColorSecondary" android:textColor="?android:attr/textColorSecondary"
android:textSize="12sp" android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="@id/imageContainer" app:layout_constraintBottom_toBottomOf="@id/playerAlbumCoverFragment"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/imageContainer" app:layout_constraintStart_toEndOf="@id/playerAlbumCoverFragment"
app:layout_constraintTop_toBottomOf="@+id/text" app:layout_constraintTop_toBottomOf="@+id/text"
tools:text="@tools:sample/lorem/random" /> tools:text="@tools:sample/lorem/random" />
<FrameLayout <androidx.fragment.app.FragmentContainerView
android:id="@+id/playbackControlsFragmentContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@+id/songInfo">
<fragment
android:id="@+id/playbackControlsFragment" android:id="@+id/playbackControlsFragment"
android:name="code.name.monkey.retromusic.fragments.player.peak.PeakPlayerControlFragment" android:name="code.name.monkey.retromusic.fragments.player.peak.PeakPlayerControlFragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/songInfo"
tools:layout="@layout/fragment_peak_control_player" /> tools:layout="@layout/fragment_peak_control_player" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -7,7 +7,7 @@
android:clickable="true" android:clickable="true"
android:focusable="true"> android:focusable="true">
<fragment <androidx.fragment.app.FragmentContainerView
android:id="@+id/playerAlbumCoverFragment" android:id="@+id/playerAlbumCoverFragment"
android:name="code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment" android:name="code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -105,7 +105,7 @@
app:layout_constraintBottom_toTopOf="@id/toolbarContainer" app:layout_constraintBottom_toTopOf="@id/toolbarContainer"
app:layout_constraintEnd_toEndOf="parent"> app:layout_constraintEnd_toEndOf="parent">
<fragment <androidx.fragment.app.FragmentContainerView
android:id="@+id/playbackControlsFragment" android:id="@+id/playbackControlsFragment"
android:name="code.name.monkey.retromusic.fragments.player.tiny.TinyPlaybackControlsFragment" android:name="code.name.monkey.retromusic.fragments.player.tiny.TinyPlaybackControlsFragment"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -128,6 +128,8 @@
android:singleLine="true" android:singleLine="true"
android:textAppearance="@style/TextViewHeadline3" android:textAppearance="@style/TextViewHeadline3"
android:textStyle="bold" android:textStyle="bold"
app:layout_constrainedHeight="true"
app:layout_constrainedWidth="true"
app:layout_constraintBottom_toTopOf="@id/toolbarContainer" app:layout_constraintBottom_toTopOf="@id/toolbarContainer"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/status_bar" app:layout_constraintTop_toBottomOf="@id/status_bar"
@ -139,12 +141,14 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="0dp" android:layout_height="0dp"
android:ellipsize="end" android:ellipsize="end"
android:fadingEdge="horizontal"
android:gravity="start" android:gravity="start"
android:maxLines="1" android:maxLines="2"
android:paddingStart="16dp" android:paddingStart="16dp"
android:paddingEnd="16dp" android:paddingEnd="16dp"
android:rotation="0" android:rotation="0"
android:textAppearance="@style/TextViewHeadline6" android:textAppearance="@style/TextViewHeadline6"
app:layout_constrainedHeight="true"
app:layout_constrainedWidth="true" app:layout_constrainedWidth="true"
app:layout_constraintBottom_toTopOf="@id/toolbarContainer" app:layout_constraintBottom_toTopOf="@id/toolbarContainer"
app:layout_constraintStart_toEndOf="@+id/title" app:layout_constraintStart_toEndOf="@+id/title"