commit
16d256e210
40 changed files with 514 additions and 327 deletions
|
@ -34,6 +34,7 @@ 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 code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||
import com.bumptech.glide.Glide
|
||||
import kotlinx.android.synthetic.main.activity_drive_mode.*
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
|
@ -217,7 +218,7 @@ class DriveModeActivity : AbsMusicServiceActivity(), Callback {
|
|||
.build()
|
||||
.transform(BlurTransformation.Builder(this).build())
|
||||
.into(object : RetroMusicColoredTarget(image) {
|
||||
override fun onColorReady(color: Int) {
|
||||
override fun onColorReady(color: MediaNotificationProcessor) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -246,7 +246,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
|
|||
TINY -> TinyPlayerFragment()
|
||||
PEAK -> PeakPlayerFragment()
|
||||
CIRCLE -> CirclePlayerFragment()
|
||||
EXAMPLE -> ClassicPlayerFragment()
|
||||
CLASSIC -> ClassicPlayerFragment()
|
||||
else -> PlayerFragment()
|
||||
} // must implement AbsPlayerFragment
|
||||
supportFragmentManager.beginTransaction().replace(R.id.playerFragmentContainer, fragment)
|
||||
|
|
|
@ -9,6 +9,7 @@ import androidx.fragment.app.Fragment
|
|||
import androidx.fragment.app.FragmentManager
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.fragments.AlbumCoverStyle
|
||||
import code.name.monkey.retromusic.fragments.NowPlayingScreen
|
||||
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
|
||||
import code.name.monkey.retromusic.glide.SongGlideRequest
|
||||
import code.name.monkey.retromusic.misc.CustomFragmentStatePagerAdapter
|
||||
|
@ -63,7 +64,7 @@ class AlbumCoverPagerAdapter(
|
|||
|
||||
lateinit var albumCover: ImageView
|
||||
private var isColorReady: Boolean = false
|
||||
private var color: Int = 0
|
||||
private lateinit var color: MediaNotificationProcessor
|
||||
private lateinit var song: Song
|
||||
private var colorReceiver: ColorReceiver? = null
|
||||
private var request: Int = 0
|
||||
|
@ -94,12 +95,7 @@ class AlbumCoverPagerAdapter(
|
|||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
val finalLayout = when {
|
||||
PreferenceUtil.getInstance(requireContext())
|
||||
.carouselEffect() -> R.layout.fragment_album_carousel_cover
|
||||
else -> layout
|
||||
}
|
||||
val view = inflater.inflate(finalLayout, container, false)
|
||||
val view = inflater.inflate(getLayoutWithPlayerTheme(), container, false)
|
||||
albumCover = view.findViewById(R.id.player_image)
|
||||
albumCover.setOnClickListener {
|
||||
NavigationUtil.goToLyrics(requireActivity())
|
||||
|
@ -107,6 +103,35 @@ class AlbumCoverPagerAdapter(
|
|||
return view
|
||||
}
|
||||
|
||||
private fun getLayoutWithPlayerTheme(): Int {
|
||||
return when (PreferenceUtil.getInstance(requireContext()).nowPlayingScreen) {
|
||||
NowPlayingScreen.CARD,
|
||||
NowPlayingScreen.FIT,
|
||||
NowPlayingScreen.TINY,
|
||||
NowPlayingScreen.CLASSIC,
|
||||
NowPlayingScreen.MATERIAL,
|
||||
NowPlayingScreen.FULL -> R.layout.fragment_album_full_cover
|
||||
else -> {
|
||||
if (PreferenceUtil.getInstance(requireContext())
|
||||
.carouselEffect()
|
||||
) {
|
||||
R.layout.fragment_album_carousel_cover
|
||||
} else {
|
||||
when (PreferenceUtil.getInstance(requireContext()).albumCoverStyle) {
|
||||
AlbumCoverStyle.NORMAL -> R.layout.fragment_album_cover
|
||||
AlbumCoverStyle.FLAT -> R.layout.fragment_album_flat_cover
|
||||
AlbumCoverStyle.CIRCLE -> R.layout.fragment_album_circle_cover
|
||||
AlbumCoverStyle.CARD -> R.layout.fragment_album_card_cover
|
||||
AlbumCoverStyle.MATERIAL -> R.layout.fragment_album_material_cover
|
||||
AlbumCoverStyle.FULL -> R.layout.fragment_album_full_cover
|
||||
AlbumCoverStyle.FULL_CARD -> R.layout.fragment_album_full_card_cover
|
||||
else -> R.layout.fragment_album_cover
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
loadAlbumCover()
|
||||
|
@ -123,12 +148,12 @@ class AlbumCoverPagerAdapter(
|
|||
.generatePalette(requireContext()).build()
|
||||
.into(object : RetroMusicColoredTarget(albumCover) {
|
||||
override fun onColorReady(colors: MediaNotificationProcessor) {
|
||||
setColor(colors.backgroundColor)
|
||||
setColor(colors)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun setColor(color: Int) {
|
||||
private fun setColor(color: MediaNotificationProcessor) {
|
||||
this.color = color
|
||||
isColorReady = true
|
||||
if (colorReceiver != null) {
|
||||
|
@ -147,7 +172,7 @@ class AlbumCoverPagerAdapter(
|
|||
}
|
||||
|
||||
interface ColorReceiver {
|
||||
fun onColorReady(color: Int, request: Int)
|
||||
fun onColorReady(color: MediaNotificationProcessor, request: Int)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -20,30 +20,25 @@ import androidx.fragment.app.DialogFragment
|
|||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.loaders.PlaylistLoader
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.room.playlist.PlaylistDatabaseModel
|
||||
import code.name.monkey.retromusic.room.playlist.PlaylistEntity
|
||||
import code.name.monkey.retromusic.util.PlaylistsUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.afollestad.materialdialogs.LayoutMode
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||
import com.afollestad.materialdialogs.list.listItems
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class AddToPlaylistDialog : DialogFragment() {
|
||||
|
||||
override fun onCreateDialog(
|
||||
savedInstanceState: Bundle?
|
||||
): Dialog {
|
||||
|
||||
val names = requireArguments().getParcelableArrayList<PlaylistEntity>("names")
|
||||
val playlists = PlaylistLoader.getAllPlaylists(requireContext())
|
||||
val playlistNames: MutableList<String> = mutableListOf()
|
||||
playlistNames.add(requireContext().resources.getString(R.string.action_new_playlist))
|
||||
for (p in names!!) {
|
||||
playlistNames.add(p.playlistName)
|
||||
for (p in playlists) {
|
||||
playlistNames.add(p.name)
|
||||
}
|
||||
|
||||
|
||||
return MaterialDialog(requireContext()).show {
|
||||
title(R.string.add_playlist_title)
|
||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
|
@ -57,18 +52,12 @@ class AddToPlaylistDialog : DialogFragment() {
|
|||
}
|
||||
} else {
|
||||
dialog.dismiss()
|
||||
/*PlaylistsUtil.addToPlaylist(
|
||||
PlaylistsUtil.addToPlaylist(
|
||||
requireContext(),
|
||||
songs,
|
||||
playlists[index - 1].id,
|
||||
true
|
||||
)*/
|
||||
|
||||
GlobalScope.launch(Dispatchers.IO) {
|
||||
PlaylistDatabaseModel().also {
|
||||
it.addSongsToPlaylist(songs, names[index - 1])
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -89,17 +78,5 @@ class AddToPlaylistDialog : DialogFragment() {
|
|||
dialog.arguments = args
|
||||
return dialog
|
||||
}
|
||||
|
||||
fun create(
|
||||
songs: ArrayList<Song>,
|
||||
names: List<PlaylistEntity>
|
||||
): AddToPlaylistDialog {
|
||||
val dialog = AddToPlaylistDialog()
|
||||
val args = Bundle()
|
||||
args.putParcelableArrayList("songs", ArrayList(songs))
|
||||
args.putParcelableArrayList("names", ArrayList(names))
|
||||
dialog.arguments = args
|
||||
return dialog
|
||||
}
|
||||
}
|
||||
}
|
|
@ -24,10 +24,7 @@ import code.name.monkey.retromusic.R
|
|||
import code.name.monkey.retromusic.R.layout
|
||||
import code.name.monkey.retromusic.R.string
|
||||
import code.name.monkey.retromusic.extensions.appHandleColor
|
||||
import code.name.monkey.retromusic.fragments.playlists.PlaylistViewModel
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.room.playlist.PlaylistDatabaseModel
|
||||
import code.name.monkey.retromusic.room.playlist.PlaylistEntity
|
||||
import code.name.monkey.retromusic.util.PlaylistsUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.afollestad.materialdialogs.LayoutMode
|
||||
|
@ -60,14 +57,13 @@ class CreatePlaylistDialog : DialogFragment() {
|
|||
?: return@positiveButton
|
||||
|
||||
if (playlistView.text.toString().trim { it <= ' ' }.isNotEmpty()) {
|
||||
/*val playlistId = PlaylistsUtil.createPlaylist(
|
||||
val playlistId = PlaylistsUtil.createPlaylist(
|
||||
requireContext(),
|
||||
playlistView.text.toString()
|
||||
)
|
||||
if (playlistId != -1) {
|
||||
PlaylistsUtil.addToPlaylist(requireContext(), songs, playlistId, true)
|
||||
}*/
|
||||
PlaylistDatabaseModel().savePlaylist(PlaylistEntity(playlistView.text.toString()))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,5 +26,5 @@ enum class NowPlayingScreen constructor(
|
|||
PLAIN(R.string.plain, R.drawable.np_plain, 3),
|
||||
SIMPLE(R.string.simple, R.drawable.np_simple, 8),
|
||||
TINY(R.string.tiny, R.drawable.np_tiny, 7),
|
||||
EXAMPLE(R.string.tiny, R.drawable.np_tiny, 16),
|
||||
CLASSIC(R.string.classic, R.drawable.np_tiny, 16),
|
||||
}
|
||||
|
|
|
@ -62,11 +62,9 @@ abstract class AbsPlayerControlsFragment : AbsMusicServiceFragment(),
|
|||
|
||||
private fun hideVolumeIfAvailable() {
|
||||
if (PreferenceUtil.getInstance(requireContext()).volumeToggle) {
|
||||
childFragmentManager.beginTransaction()
|
||||
.replace(R.id.volumeFragmentContainer, VolumeFragment()).commit()
|
||||
childFragmentManager.beginTransaction().replace(R.id.volumeFragmentContainer, VolumeFragment()).commit()
|
||||
childFragmentManager.executePendingTransactions()
|
||||
volumeFragment =
|
||||
childFragmentManager.findFragmentById(R.id.volumeFragmentContainer) as VolumeFragment?
|
||||
volumeFragment = childFragmentManager.findFragmentById(R.id.volumeFragmentContainer) as VolumeFragment?
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,13 +14,14 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
|||
import code.name.monkey.retromusic.transform.CarousalPagerTransformer
|
||||
import code.name.monkey.retromusic.transform.ParallaxPagerTransformer
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||
import kotlinx.android.synthetic.main.fragment_player_album_cover.*
|
||||
|
||||
class PlayerAlbumCoverFragment : AbsMusicServiceFragment(), ViewPager.OnPageChangeListener {
|
||||
private var callbacks: Callbacks? = null
|
||||
private var currentPosition: Int = 0
|
||||
private val colorReceiver = object : AlbumCoverFragment.ColorReceiver {
|
||||
override fun onColorReady(color: Int, request: Int) {
|
||||
override fun onColorReady(color: MediaNotificationProcessor, request: Int) {
|
||||
if (currentPosition == request) {
|
||||
notifyColorChange(color)
|
||||
}
|
||||
|
@ -103,7 +104,7 @@ class PlayerAlbumCoverFragment : AbsMusicServiceFragment(), ViewPager.OnPageChan
|
|||
override fun onPageScrollStateChanged(state: Int) {
|
||||
}
|
||||
|
||||
private fun notifyColorChange(color: Int) {
|
||||
private fun notifyColorChange(color: MediaNotificationProcessor) {
|
||||
callbacks?.onColorChanged(color)
|
||||
}
|
||||
|
||||
|
@ -117,7 +118,7 @@ class PlayerAlbumCoverFragment : AbsMusicServiceFragment(), ViewPager.OnPageChan
|
|||
|
||||
interface Callbacks {
|
||||
|
||||
fun onColorChanged(color: Int)
|
||||
fun onColorChanged(color: MediaNotificationProcessor)
|
||||
|
||||
fun onFavoriteToggled()
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
|
|||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.model.lyrics.AbsSynchronizedLyrics
|
||||
import code.name.monkey.retromusic.model.lyrics.Lyrics
|
||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||
import kotlinx.android.synthetic.main.fragment_adaptive_player.*
|
||||
|
||||
class AdaptiveFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Callback {
|
||||
|
@ -194,9 +195,9 @@ class AdaptiveFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Call
|
|||
toggleFavorite(MusicPlayerRemote.currentSong)
|
||||
}
|
||||
|
||||
override fun onColorChanged(color: Int) {
|
||||
playbackControlsFragment.setDark(color)
|
||||
lastColor = color
|
||||
override fun onColorChanged(color: MediaNotificationProcessor) {
|
||||
playbackControlsFragment.setDark(color.backgroundColor)
|
||||
lastColor = color.backgroundColor
|
||||
callbacks?.onPaletteColorChanged()
|
||||
ToolbarContentTintHelper.colorizeToolbar(
|
||||
playerToolbar,
|
||||
|
|
|
@ -65,9 +65,9 @@ class BlurPlayerFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPrefer
|
|||
toggleFavorite(MusicPlayerRemote.currentSong)
|
||||
}
|
||||
|
||||
override fun onColorChanged(color: Int) {
|
||||
playbackControlsFragment.setDark(color)
|
||||
lastColor = color
|
||||
override fun onColorChanged(color: MediaNotificationProcessor) {
|
||||
playbackControlsFragment.setDark(color.backgroundColor)
|
||||
lastColor = color.backgroundColor
|
||||
callbacks?.onPaletteColorChanged()
|
||||
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, Color.WHITE, activity)
|
||||
}
|
||||
|
|
|
@ -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.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||
import kotlinx.android.synthetic.main.fragment_card_player.*
|
||||
|
||||
class CardFragment : AbsPlayerFragment() {
|
||||
|
@ -43,9 +44,9 @@ class CardFragment : AbsPlayerFragment() {
|
|||
return Color.WHITE
|
||||
}
|
||||
|
||||
override fun onColorChanged(color: Int) {
|
||||
playbackControlsFragment.setDark(color)
|
||||
lastColor = color
|
||||
override fun onColorChanged(color: MediaNotificationProcessor) {
|
||||
playbackControlsFragment.setDark(color.backgroundColor)
|
||||
lastColor = color.backgroundColor
|
||||
callbacks!!.onPaletteColorChanged()
|
||||
|
||||
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, Color.WHITE, activity)
|
||||
|
|
|
@ -50,9 +50,9 @@ class CardBlurFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPreferen
|
|||
return Color.WHITE
|
||||
}
|
||||
|
||||
override fun onColorChanged(color: Int) {
|
||||
playbackControlsFragment.setDark(color)
|
||||
lastColor = color
|
||||
override fun onColorChanged(color: MediaNotificationProcessor) {
|
||||
playbackControlsFragment.setDark(color.backgroundColor)
|
||||
lastColor = color.backgroundColor
|
||||
callbacks!!.onPaletteColorChanged()
|
||||
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, Color.WHITE, activity)
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
|
|||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
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.OnSeekArcChangeListener
|
||||
import code.name.monkey.retromusic.volume.AudioVolumeObserver
|
||||
|
@ -161,7 +162,7 @@ class CirclePlayerFragment : AbsPlayerFragment(), Callback, OnAudioVolumeChanged
|
|||
override val paletteColor: Int
|
||||
get() = Color.BLACK
|
||||
|
||||
override fun onColorChanged(color: Int) {
|
||||
override fun onColorChanged(color: MediaNotificationProcessor) {
|
||||
}
|
||||
|
||||
override fun onFavoriteToggled() {
|
||||
|
|
|
@ -30,6 +30,7 @@ import code.name.monkey.retromusic.service.MusicService
|
|||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
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.card.MaterialCardView
|
||||
import kotlinx.android.synthetic.main.fragment_clasic_player.*
|
||||
|
@ -116,6 +117,11 @@ class ClassicPlayerFragment : AbsPlayerFragment(), View.OnLayoutChangeListener,
|
|||
}
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
getQueuePanel().removeBottomSheetCallback(bottomSheetCallbackList)
|
||||
}
|
||||
|
||||
private fun updateSong() {
|
||||
val song = MusicPlayerRemote.currentSong
|
||||
title.text = song.title
|
||||
|
@ -175,7 +181,7 @@ class ClassicPlayerFragment : AbsPlayerFragment(), View.OnLayoutChangeListener,
|
|||
MusicPlayerRemote.position,
|
||||
R.layout.item_queue
|
||||
)
|
||||
recyclerView .apply {
|
||||
recyclerView.apply {
|
||||
adapter = queueAdapter
|
||||
layoutManager = LinearLayoutManager(requireContext())
|
||||
}
|
||||
|
@ -225,8 +231,8 @@ class ClassicPlayerFragment : AbsPlayerFragment(), View.OnLayoutChangeListener,
|
|||
override val paletteColor: Int
|
||||
get() = lastColor
|
||||
|
||||
override fun onColorChanged(color: Int) {
|
||||
lastColor = color
|
||||
override fun onColorChanged(color: MediaNotificationProcessor) {
|
||||
lastColor = color.backgroundColor
|
||||
ToolbarContentTintHelper.colorizeToolbar(
|
||||
playerToolbar,
|
||||
Color.WHITE,
|
||||
|
@ -246,7 +252,7 @@ class ClassicPlayerFragment : AbsPlayerFragment(), View.OnLayoutChangeListener,
|
|||
}
|
||||
|
||||
val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
|
||||
color
|
||||
color.backgroundColor
|
||||
} else {
|
||||
ThemeStore.accentColor(requireContext())
|
||||
}.ripAlpha()
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package code.name.monkey.retromusic.fragments.player.color
|
||||
|
||||
import android.animation.ValueAnimator
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
|
@ -9,19 +8,13 @@ import android.view.ViewGroup
|
|||
import androidx.appcompat.widget.Toolbar
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
||||
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
|
||||
import code.name.monkey.retromusic.glide.SongGlideRequest.Builder
|
||||
import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper
|
||||
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.util.NavigationUtil
|
||||
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.*
|
||||
|
||||
class ColorFragment : AbsPlayerFragment() {
|
||||
|
@ -38,12 +31,22 @@ class ColorFragment : AbsPlayerFragment() {
|
|||
override val paletteColor: Int
|
||||
get() = backgroundColor
|
||||
|
||||
override fun onColorChanged(color: Int) {
|
||||
override fun onColorChanged(color: MediaNotificationProcessor) {
|
||||
playbackControlsFragment.setDark(color)
|
||||
lastColor = color.backgroundColor
|
||||
callbacks?.onPaletteColorChanged()
|
||||
|
||||
ToolbarContentTintHelper.colorizeToolbar(
|
||||
playerToolbar,
|
||||
color.secondaryTextColor,
|
||||
requireActivity()
|
||||
)
|
||||
colorGradientBackground?.setBackgroundColor(color.backgroundColor)
|
||||
playerActivity?.setLightNavigationBar(ColorUtil.isColorLight(color.backgroundColor))
|
||||
}
|
||||
|
||||
override fun onFavoriteToggled() {
|
||||
//toggleFavorite(MusicPlayerRemote.currentSong)
|
||||
toggleFavorite(MusicPlayerRemote.currentSong)
|
||||
}
|
||||
|
||||
override fun onShow() {
|
||||
|
@ -90,9 +93,9 @@ class ColorFragment : AbsPlayerFragment() {
|
|||
super.onViewCreated(view, savedInstanceState)
|
||||
setUpSubFragments()
|
||||
setUpPlayerToolbar()
|
||||
playerImage.setOnClickListener {
|
||||
NavigationUtil.goToLyrics(requireActivity())
|
||||
}
|
||||
val playerAlbumCoverFragment =
|
||||
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
||||
playerAlbumCoverFragment.setCallbacks(this)
|
||||
}
|
||||
|
||||
private fun setUpSubFragments() {
|
||||
|
@ -113,70 +116,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) {
|
||||
this.lastColor = colors.backgroundColor
|
||||
this.backgroundColor = colors.backgroundColor
|
||||
|
@ -193,10 +132,7 @@ class ColorFragment : AbsPlayerFragment() {
|
|||
|
||||
companion object {
|
||||
fun newInstance(): ColorFragment {
|
||||
val args = Bundle()
|
||||
val fragment = ColorFragment()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
return ColorFragment()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||
import kotlinx.android.synthetic.main.fragment_fit.*
|
||||
|
||||
class FitFragment : AbsPlayerFragment() {
|
||||
|
@ -42,9 +43,9 @@ class FitFragment : AbsPlayerFragment() {
|
|||
return ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal)
|
||||
}
|
||||
|
||||
override fun onColorChanged(color: Int) {
|
||||
playbackControlsFragment.setDark(color)
|
||||
lastColor = color
|
||||
override fun onColorChanged(color: MediaNotificationProcessor) {
|
||||
playbackControlsFragment.setDark(color.backgroundColor)
|
||||
lastColor = color.backgroundColor
|
||||
callbacks?.onPaletteColorChanged()
|
||||
ToolbarContentTintHelper.colorizeToolbar(
|
||||
playerToolbar,
|
||||
|
|
|
@ -19,6 +19,7 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
|||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.ViewUtil
|
||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||
import code.name.monkey.retromusic.views.DrawableGradient
|
||||
import kotlinx.android.synthetic.main.fragment_flat_player.*
|
||||
|
||||
|
@ -103,18 +104,18 @@ class FlatPlayerFragment : AbsPlayerFragment() {
|
|||
ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal)
|
||||
}
|
||||
|
||||
override fun onColorChanged(color: Int) {
|
||||
lastColor = color
|
||||
flatPlaybackControlsFragment.setDark(color)
|
||||
override fun onColorChanged(color: MediaNotificationProcessor) {
|
||||
lastColor = color.backgroundColor
|
||||
flatPlaybackControlsFragment.setDark(color.backgroundColor)
|
||||
callbacks?.onPaletteColorChanged()
|
||||
val isLight = ColorUtil.isColorLight(color)
|
||||
val isLight = ColorUtil.isColorLight(color.backgroundColor)
|
||||
val iconColor = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor)
|
||||
MaterialValueHelper.getPrimaryTextColor(requireContext(), isLight)
|
||||
else
|
||||
ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal)
|
||||
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, iconColor, requireActivity())
|
||||
if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
|
||||
colorize(color)
|
||||
colorize(color.backgroundColor)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -197,9 +197,9 @@ class FullPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
|
|||
return Color.WHITE
|
||||
}
|
||||
|
||||
override fun onColorChanged(color: Int) {
|
||||
lastColor = color
|
||||
fullPlaybackControlsFragment.setDark(color)
|
||||
override fun onColorChanged(color: MediaNotificationProcessor) {
|
||||
lastColor = color.backgroundColor
|
||||
fullPlaybackControlsFragment.setDark(color.backgroundColor)
|
||||
callbacks?.onPaletteColorChanged()
|
||||
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, Color.WHITE, activity)
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.extensions.hide
|
||||
|
@ -99,24 +98,22 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() {
|
|||
}
|
||||
|
||||
override fun setDark(color: Int) {
|
||||
val colorBg = ATHUtil.resolveColor(requireContext(), R.attr.colorSurface)
|
||||
if (ColorUtil.isColorLight(colorBg)) {
|
||||
lastPlaybackControlsColor =
|
||||
MaterialValueHelper.getSecondaryTextColor(requireContext(), true)
|
||||
lastDisabledPlaybackControlsColor =
|
||||
MaterialValueHelper.getSecondaryDisabledTextColor(requireContext(), true)
|
||||
} else {
|
||||
if (ATHUtil.isWindowBackgroundDark(requireContext())) {
|
||||
lastPlaybackControlsColor =
|
||||
MaterialValueHelper.getPrimaryTextColor(requireContext(), false)
|
||||
lastDisabledPlaybackControlsColor =
|
||||
MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false)
|
||||
}else{
|
||||
lastPlaybackControlsColor =
|
||||
MaterialValueHelper.getSecondaryTextColor(requireContext(), true)
|
||||
lastDisabledPlaybackControlsColor =
|
||||
MaterialValueHelper.getSecondaryDisabledTextColor(requireContext(), true)
|
||||
}
|
||||
|
||||
updateRepeatState()
|
||||
updateShuffleState()
|
||||
|
||||
val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
|
||||
color
|
||||
lastPlaybackControlsColor
|
||||
} else {
|
||||
textColorSecondary(requireContext())
|
||||
}.ripAlpha()
|
||||
|
@ -126,12 +123,14 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() {
|
|||
|
||||
volumeFragment?.setTintable(colorFinal)
|
||||
|
||||
updatePlayPauseColor(colorFinal)
|
||||
updatePrevNextColor(colorFinal)
|
||||
updateRepeatState()
|
||||
updateShuffleState()
|
||||
updatePlayPauseColor()
|
||||
updatePrevNextColor()
|
||||
}
|
||||
|
||||
private fun updatePlayPauseColor(color: Int) {
|
||||
playPauseButton.setColorFilter(color, PorterDuff.Mode.SRC_IN)
|
||||
private fun updatePlayPauseColor() {
|
||||
playPauseButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
|
||||
private fun setUpPlayPauseFab() {
|
||||
|
@ -140,9 +139,9 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() {
|
|||
|
||||
private fun updatePlayPauseDrawableState() {
|
||||
if (MusicPlayerRemote.isPlaying) {
|
||||
playPauseButton.setImageResource(R.drawable.ic_pause_white_64dp)
|
||||
playPauseButton.setImageResource(R.drawable.ic_pause_sharp_white_64dp)
|
||||
} else {
|
||||
playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_64dp)
|
||||
playPauseButton.setImageResource(R.drawable.ic_play_arrow_sharp_white_64dp)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,14 +154,14 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() {
|
|||
}
|
||||
|
||||
private fun setUpPrevNext() {
|
||||
updatePrevNextColor(textColorSecondary(requireContext()))
|
||||
updatePrevNextColor()
|
||||
nextButton.setOnClickListener { MusicPlayerRemote.playNextSong() }
|
||||
previousButton.setOnClickListener { MusicPlayerRemote.back() }
|
||||
}
|
||||
|
||||
private fun updatePrevNextColor(color: Int) {
|
||||
nextButton.setColorFilter(color, PorterDuff.Mode.SRC_IN)
|
||||
previousButton.setColorFilter(color, PorterDuff.Mode.SRC_IN)
|
||||
private fun updatePrevNextColor() {
|
||||
nextButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
previousButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
|
||||
private fun setUpShuffleButton() {
|
||||
|
@ -189,18 +188,18 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() {
|
|||
override fun updateRepeatState() {
|
||||
when (MusicPlayerRemote.repeatMode) {
|
||||
MusicService.REPEAT_MODE_NONE -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_sharp_white_24dp)
|
||||
repeatButton.setColorFilter(
|
||||
lastDisabledPlaybackControlsColor,
|
||||
PorterDuff.Mode.SRC_IN
|
||||
)
|
||||
}
|
||||
MusicService.REPEAT_MODE_ALL -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_sharp_white_24dp)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
MusicService.REPEAT_MODE_THIS -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one_sharp_white_24dp)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,21 +4,57 @@ import android.os.Bundle
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||
import code.name.monkey.retromusic.CustomBottomSheetBehavior
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity
|
||||
import code.name.monkey.retromusic.adapter.song.PlayingQueueAdapter
|
||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
||||
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
||||
import code.name.monkey.retromusic.fragments.player.normal.PlayerFragment
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import kotlinx.android.synthetic.main.fragment_material.*
|
||||
import kotlinx.android.synthetic.main.status_bar.*
|
||||
|
||||
/**
|
||||
* @author Hemanth S (h4h13).
|
||||
*/
|
||||
class MaterialFragment : AbsPlayerFragment() {
|
||||
class MaterialFragment : AbsPlayerFragment(), View.OnLayoutChangeListener {
|
||||
private lateinit var queueAdapter: PlayingQueueAdapter
|
||||
private val bottomSheetCallbackList = object : BottomSheetBehavior.BottomSheetCallback() {
|
||||
override fun onSlide(bottomSheet: View, slideOffset: Float) {
|
||||
(requireActivity() as AbsSlidingMusicPanelActivity).getBottomSheetBehavior()
|
||||
.setAllowDragging(false)
|
||||
|
||||
sheetContent.setPadding(
|
||||
sheetContent.paddingLeft,
|
||||
(slideOffset * status_bar.height).toInt(),
|
||||
sheetContent.paddingRight,
|
||||
sheetContent.paddingBottom
|
||||
)
|
||||
|
||||
playerControlsContainer.layoutParams.height = playerContainer.width
|
||||
}
|
||||
|
||||
override fun onStateChanged(bottomSheet: View, newState: Int) {
|
||||
val activity = requireActivity() as AbsSlidingMusicPanelActivity
|
||||
if (newState == BottomSheetBehavior.STATE_EXPANDED || newState == BottomSheetBehavior.STATE_DRAGGING) {
|
||||
activity.getBottomSheetBehavior().setAllowDragging(false)
|
||||
} else {
|
||||
activity.getBottomSheetBehavior().setAllowDragging(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun playerToolbar(): Toolbar {
|
||||
return playerToolbar
|
||||
|
@ -48,9 +84,12 @@ class MaterialFragment : AbsPlayerFragment() {
|
|||
return ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal)
|
||||
}
|
||||
|
||||
override fun onColorChanged(color: Int) {
|
||||
playbackControlsFragment.setDark(color)
|
||||
lastColor = color
|
||||
override fun onColorChanged(color: MediaNotificationProcessor) {
|
||||
val darkColor = ColorUtil.darkenColorTheme(color.backgroundColor)
|
||||
playerContainer?.setBackgroundColor(ColorUtil.darkenColorTheme(color.backgroundColor))
|
||||
upComing?.setBackgroundColor(ColorUtil.darkenColorTheme(darkColor))
|
||||
playbackControlsFragment.setDark(color.backgroundColor)
|
||||
lastColor = color.backgroundColor
|
||||
callbacks?.onPaletteColorChanged()
|
||||
|
||||
ToolbarContentTintHelper.colorizeToolbar(
|
||||
|
@ -82,6 +121,40 @@ class MaterialFragment : AbsPlayerFragment() {
|
|||
super.onViewCreated(view, savedInstanceState)
|
||||
setUpSubFragments()
|
||||
setUpPlayerToolbar()
|
||||
setupPanel()
|
||||
setUpQueue()
|
||||
getQueuePanel().addBottomSheetCallback(bottomSheetCallbackList)
|
||||
|
||||
playerQueueSheet.setOnTouchListener { _, _ ->
|
||||
(requireActivity() as AbsSlidingMusicPanelActivity).getBottomSheetBehavior()
|
||||
.setAllowDragging(false)
|
||||
getQueuePanel().setAllowDragging(true)
|
||||
return@setOnTouchListener false
|
||||
}
|
||||
}
|
||||
|
||||
private fun setUpQueue() {
|
||||
queueAdapter = PlayingQueueAdapter(
|
||||
requireActivity() as AppCompatActivity, mutableListOf(),
|
||||
MusicPlayerRemote.position,
|
||||
R.layout.item_queue
|
||||
)
|
||||
recyclerView.apply {
|
||||
adapter = queueAdapter
|
||||
layoutManager = LinearLayoutManager(requireContext())
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupPanel() {
|
||||
if (!ViewCompat.isLaidOut(playerContainer) || playerContainer.isLayoutRequested) {
|
||||
playerContainer.addOnLayoutChangeListener(this)
|
||||
return
|
||||
}
|
||||
val height = playerContainer?.height ?: 0
|
||||
val width = playerContainer?.width ?: 0
|
||||
val finalHeight = height - (playerControlsContainer.height - width)
|
||||
val panel = getQueuePanel()
|
||||
panel.peekHeight = finalHeight
|
||||
}
|
||||
|
||||
private fun setUpSubFragments() {
|
||||
|
@ -107,6 +180,7 @@ class MaterialFragment : AbsPlayerFragment() {
|
|||
|
||||
override fun onServiceConnected() {
|
||||
updateIsFavorite()
|
||||
queueAdapter.swapDataSet(MusicPlayerRemote.playingQueue)
|
||||
}
|
||||
|
||||
override fun onPlayingMetaChanged() {
|
||||
|
@ -119,4 +193,32 @@ class MaterialFragment : AbsPlayerFragment() {
|
|||
return PlayerFragment()
|
||||
}
|
||||
}
|
||||
|
||||
private fun getQueuePanel(): CustomBottomSheetBehavior<FrameLayout> {
|
||||
return CustomBottomSheetBehavior.from(playerQueueSheet) as CustomBottomSheetBehavior<FrameLayout>
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
getQueuePanel().removeBottomSheetCallback(bottomSheetCallbackList)
|
||||
}
|
||||
|
||||
override fun onLayoutChange(
|
||||
v: View?,
|
||||
left: Int,
|
||||
top: Int,
|
||||
right: Int,
|
||||
bottom: Int,
|
||||
oldLeft: Int,
|
||||
oldTop: Int,
|
||||
oldRight: Int,
|
||||
oldBottom: Int
|
||||
) {
|
||||
val height = playerContainer?.height ?: 0
|
||||
val width = playerContainer?.width ?: 0
|
||||
val finalHeight = height - width
|
||||
playerControlsContainer.layoutParams.height = height - width
|
||||
val panel = getQueuePanel()
|
||||
panel.peekHeight = finalHeight
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
|||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.ViewUtil
|
||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||
import code.name.monkey.retromusic.views.DrawableGradient
|
||||
import kotlinx.android.synthetic.main.fragment_player.*
|
||||
|
||||
|
@ -73,9 +74,9 @@ class PlayerFragment : AbsPlayerFragment() {
|
|||
return ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal)
|
||||
}
|
||||
|
||||
override fun onColorChanged(color: Int) {
|
||||
playbackControlsFragment.setDark(color)
|
||||
lastColor = color
|
||||
override fun onColorChanged(color: MediaNotificationProcessor) {
|
||||
playbackControlsFragment.setDark(color.backgroundColor)
|
||||
lastColor = color.backgroundColor
|
||||
callbacks?.onPaletteColorChanged()
|
||||
|
||||
ToolbarContentTintHelper.colorizeToolbar(
|
||||
|
@ -85,7 +86,7 @@ class PlayerFragment : AbsPlayerFragment() {
|
|||
)
|
||||
|
||||
if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
|
||||
colorize(color)
|
||||
colorize(color.backgroundColor)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -100,9 +100,9 @@ class PeakPlayerFragment : AbsPlayerFragment() {
|
|||
override val paletteColor: Int
|
||||
get() = lastColor
|
||||
|
||||
override fun onColorChanged(color: Int) {
|
||||
playbackControlsFragment.setDark(color)
|
||||
lastColor = color
|
||||
override fun onColorChanged(color: MediaNotificationProcessor) {
|
||||
playbackControlsFragment.setDark(color.backgroundColor)
|
||||
lastColor = color.backgroundColor
|
||||
callbacks?.onPaletteColorChanged()
|
||||
}
|
||||
|
||||
|
|
|
@ -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.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||
import kotlinx.android.synthetic.main.fragment_plain_player.*
|
||||
|
||||
class PlainPlayerFragment : AbsPlayerFragment() {
|
||||
|
@ -93,9 +94,9 @@ class PlainPlayerFragment : AbsPlayerFragment() {
|
|||
return ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal)
|
||||
}
|
||||
|
||||
override fun onColorChanged(color: Int) {
|
||||
plainPlaybackControlsFragment.setDark(color)
|
||||
lastColor = color
|
||||
override fun onColorChanged(color: MediaNotificationProcessor) {
|
||||
plainPlaybackControlsFragment.setDark(color.backgroundColor)
|
||||
lastColor = color.backgroundColor
|
||||
callbacks!!.onPaletteColorChanged()
|
||||
ToolbarContentTintHelper.colorizeToolbar(
|
||||
playerToolbar,
|
||||
|
|
|
@ -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.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||
import kotlinx.android.synthetic.main.fragment_simple_player.*
|
||||
|
||||
/**
|
||||
|
@ -68,10 +69,10 @@ class SimplePlayerFragment : AbsPlayerFragment() {
|
|||
return ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal)
|
||||
}
|
||||
|
||||
override fun onColorChanged(color: Int) {
|
||||
lastColor = color
|
||||
override fun onColorChanged(color: MediaNotificationProcessor) {
|
||||
lastColor = color.backgroundColor
|
||||
callbacks?.onPaletteColorChanged()
|
||||
simplePlaybackControlsFragment.setDark(color)
|
||||
simplePlaybackControlsFragment.setDark(color.backgroundColor)
|
||||
ToolbarContentTintHelper.colorizeToolbar(
|
||||
playerToolbar,
|
||||
ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal),
|
||||
|
|
|
@ -25,6 +25,7 @@ import code.name.monkey.retromusic.model.Song
|
|||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.ViewUtil
|
||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||
import kotlinx.android.synthetic.main.fragment_tiny_player.*
|
||||
|
||||
class TinyPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Callback {
|
||||
|
@ -71,10 +72,10 @@ class TinyPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
|
|||
private var textColorPrimary = 0
|
||||
private var textColorPrimaryDisabled = 0
|
||||
|
||||
override fun onColorChanged(color: Int) {
|
||||
override fun onColorChanged(color: MediaNotificationProcessor) {
|
||||
|
||||
val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
|
||||
color
|
||||
color.backgroundColor
|
||||
} else {
|
||||
ThemeStore.accentColor(requireContext())
|
||||
}
|
||||
|
|
|
@ -29,17 +29,12 @@ import code.name.monkey.retromusic.dialogs.SongDetailDialog
|
|||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.interfaces.PaletteColorHolder
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.room.playlist.PlaylistDatabaseModel
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.NavigationUtil
|
||||
import code.name.monkey.retromusic.util.RingtoneManager
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
object SongMenuHelper {
|
||||
val MENU_RES = R.menu.menu_item_song
|
||||
const val MENU_RES = R.menu.menu_item_song
|
||||
|
||||
fun handleMenuClick(activity: FragmentActivity, song: Song, menuItemId: Int): Boolean {
|
||||
when (menuItemId) {
|
||||
|
@ -66,15 +61,8 @@ object SongMenuHelper {
|
|||
return true
|
||||
}
|
||||
R.id.action_add_to_playlist -> {
|
||||
/* AddToPlaylistDialog.create(song)
|
||||
.show(activity.supportFragmentManager, "ADD_PLAYLIST")*/
|
||||
|
||||
GlobalScope.launch(Dispatchers.IO) {
|
||||
val names = async { PlaylistDatabaseModel().getPlaylistNames() }.await()
|
||||
println(names.toString())
|
||||
AddToPlaylistDialog.create(arrayListOf(song), names)
|
||||
.show(activity.supportFragmentManager, "ADD_PLAYLIST")
|
||||
}
|
||||
AddToPlaylistDialog.create(song)
|
||||
.show(activity.supportFragmentManager, "ADD_PLAYLIST")
|
||||
return true
|
||||
}
|
||||
R.id.action_play_next -> {
|
||||
|
|
|
@ -21,11 +21,6 @@ import code.name.monkey.retromusic.dialogs.AddToPlaylistDialog
|
|||
import code.name.monkey.retromusic.dialogs.DeleteSongsDialog
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.room.playlist.PlaylistDatabaseModel
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.*
|
||||
|
||||
|
||||
|
@ -45,12 +40,8 @@ object SongsMenuHelper {
|
|||
return true
|
||||
}
|
||||
R.id.action_add_to_playlist -> {
|
||||
GlobalScope.launch(Dispatchers.IO) {
|
||||
val names = async { PlaylistDatabaseModel().getPlaylistNames() }.await()
|
||||
println(names.toString())
|
||||
/*AddToPlaylistDialog.create(songs, names.await())
|
||||
.show(activity.supportFragmentManager, "ADD_PLAYLIST")*/
|
||||
}
|
||||
AddToPlaylistDialog.create(songs)
|
||||
.show(activity.supportFragmentManager, "ADD_PLAYLIST")
|
||||
return true
|
||||
}
|
||||
R.id.action_delete_from_device -> {
|
||||
|
|
24
app/src/main/res/drawable/ic_pause_sharp_white_64dp.xml
Normal file
24
app/src/main/res/drawable/ic_pause_sharp_white_64dp.xml
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright (c) 2019 Hemanth Savarala.
|
||||
~
|
||||
~ Licensed under the GNU General Public License v3
|
||||
~
|
||||
~ This is free software: you can redistribute it and/or modify it under
|
||||
~ the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
~
|
||||
~ This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
~ without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
~ See the GNU General Public License for more details.
|
||||
-->
|
||||
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="64dp"
|
||||
android:height="64dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:fillColor="@color/md_white_1000"
|
||||
android:pathData="M6 19h4V5H6v14zm8-14v14h4V5h-4z" />
|
||||
</vector>
|
24
app/src/main/res/drawable/ic_play_arrow_sharp_white_64dp.xml
Normal file
24
app/src/main/res/drawable/ic_play_arrow_sharp_white_64dp.xml
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright (c) 2020 Hemanth Savarala.
|
||||
~
|
||||
~ Licensed under the GNU General Public License v3
|
||||
~
|
||||
~ This is free software: you can redistribute it and/or modify it under
|
||||
~ the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
~
|
||||
~ This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
~ without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
~ See the GNU General Public License for more details.
|
||||
-->
|
||||
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="64dp"
|
||||
android:height="64dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:fillColor="@color/md_white_1000"
|
||||
android:pathData="M8 5v14l11-7L8 5z" />
|
||||
</vector>
|
11
app/src/main/res/drawable/ic_repeat_one_sharp_white_24dp.xml
Normal file
11
app/src/main/res/drawable/ic_repeat_one_sharp_white_24dp.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:fillColor="@color/md_white_1000"
|
||||
android:pathData="M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4zm-4-2V9h-1l-2 1v1h1.5v4H13z" />
|
||||
</vector>
|
11
app/src/main/res/drawable/ic_repeat_sharp_white_24dp.xml
Normal file
11
app/src/main/res/drawable/ic_repeat_sharp_white_24dp.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:fillColor="@color/md_white_1000"
|
||||
android:pathData="M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z" />
|
||||
</vector>
|
11
app/src/main/res/drawable/ic_shuffle_sharp_white_24dp.xml
Normal file
11
app/src/main/res/drawable/ic_shuffle_sharp_white_24dp.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:fillColor="@color/md_white_1000"
|
||||
android:pathData="M10.59 9.17L5.41 4 4 5.41l5.17 5.17 1.42-1.41zM14.5 4l2.04 2.04L4 18.59 5.41 20 17.96 7.46 20 9.5V4h-5.5zm0.33 9.41l-1.41 1.41 3.13 3.13L14.5 20H20v-5.5l-2.04 2.04-3.13-3.13z" />
|
||||
</vector>
|
11
app/src/main/res/drawable/ic_skip_next_sharp_white_24dp.xml
Normal file
11
app/src/main/res/drawable/ic_skip_next_sharp_white_24dp.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="@dimen/icon_notification_dimen"
|
||||
android:height="@dimen/icon_notification_dimen"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:fillColor="@color/md_white_1000"
|
||||
android:pathData="M6 18l8.5-6L6 6v12zM16 6v12h2V6h-2z" />
|
||||
</vector>
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="@dimen/icon_notification_dimen"
|
||||
android:height="@dimen/icon_notification_dimen"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:fillColor="@color/md_white_1000"
|
||||
android:pathData="M6 6h2v12H6V6zm3.5 6l8.5 6V6l-8.5 6z" />
|
||||
</vector>
|
|
@ -36,24 +36,12 @@
|
|||
android:layout_width="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_height="match_parent"
|
||||
android:layout_margin="12dp"
|
||||
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>
|
||||
|
||||
tools:layout="@layout/fragment_album_cover" />
|
||||
</code.name.monkey.retromusic.views.HeightFitSquareLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
<FrameLayout
|
||||
android:id="@+id/playerContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -43,7 +43,7 @@
|
|||
app:navigationIcon="@drawable/ic_keyboard_arrow_down_black_24dp" />
|
||||
</LinearLayout>
|
||||
</code.name.monkey.retromusic.views.WidthFitSquareLayout>
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/playerQueueSheet"
|
||||
|
@ -51,7 +51,6 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:gravity="bottom"
|
||||
android:orientation="vertical"
|
||||
android:tag="nested_bottom_sheet"
|
||||
app:behavior_hideable="false"
|
||||
app:cardCornerRadius="0dp"
|
||||
app:layout_behavior="code.name.monkey.retromusic.CustomBottomSheetBehavior">
|
||||
|
@ -92,7 +91,6 @@
|
|||
android:background="?attr/colorSurface"
|
||||
tools:listitem="@layout/item_list" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
@ -27,26 +27,19 @@
|
|||
<include layout="@layout/status_bar" />
|
||||
</FrameLayout>
|
||||
|
||||
<code.name.monkey.retromusic.views.WidthFitSquareCardView
|
||||
<code.name.monkey.retromusic.views.WidthFitSquareLayout
|
||||
android:id="@+id/playerAlbumCoverContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
app:cardCornerRadius="8dp"
|
||||
app:cardElevation="4dp"
|
||||
app:cardPreventCornerOverlap="false"
|
||||
app:cardUseCompatPadding="true">
|
||||
android:layout_weight="0">
|
||||
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/playerImage"
|
||||
<fragment
|
||||
android:id="@+id/playerAlbumCoverFragment"
|
||||
android:name="code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop"
|
||||
tools:ignore="ContentDescription,UnusedAttribute"
|
||||
tools:srcCompat="@tools:sample/backgrounds/scenic[10]" />
|
||||
|
||||
</code.name.monkey.retromusic.views.WidthFitSquareCardView>
|
||||
tools:layout="@layout/fragment_album_cover" />
|
||||
</code.name.monkey.retromusic.views.WidthFitSquareLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout 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"
|
||||
|
@ -7,25 +7,14 @@
|
|||
android:clickable="true"
|
||||
android:focusable="true">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/colorSurface" />
|
||||
|
||||
<include layout="@layout/shadow_statusbar_toolbar" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/playerContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<include layout="@layout/status_bar" />
|
||||
</FrameLayout>
|
||||
|
||||
<code.name.monkey.retromusic.views.WidthFitSquareLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
@ -35,33 +24,101 @@
|
|||
android:name="code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:layout="@layout/fragment_album_cover" />
|
||||
tools:layout="@layout/fragment_album_full_cover" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<include layout="@layout/status_bar" />
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/playerToolbar"
|
||||
style="@style/Toolbar"
|
||||
android:layout_gravity="bottom"
|
||||
android:navigationIcon="@drawable/ic_keyboard_arrow_down_black_24dp"
|
||||
app:navigationIcon="@drawable/ic_keyboard_arrow_down_black_24dp" />
|
||||
</FrameLayout>
|
||||
</code.name.monkey.retromusic.views.WidthFitSquareLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1">
|
||||
</LinearLayout>
|
||||
|
||||
<fragment
|
||||
android:id="@+id/playbackControlsFragment"
|
||||
android:name="code.name.monkey.retromusic.fragments.player.material.MaterialControlsFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:layout="@layout/fragment_material_playback_controls" />
|
||||
</FrameLayout>
|
||||
<FrameLayout
|
||||
android:id="@+id/playerQueueSheet"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="bottom"
|
||||
app:behavior_hideable="false"
|
||||
app:layout_behavior="code.name.monkey.retromusic.CustomBottomSheetBehavior">
|
||||
|
||||
<FrameLayout
|
||||
<LinearLayout
|
||||
android:id="@+id/sheetContent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0">
|
||||
android:background="?attr/colorSurface"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/playerToolbar"
|
||||
style="@style/Toolbar"
|
||||
android:layout_gravity="bottom"
|
||||
android:navigationIcon="@drawable/ic_keyboard_arrow_down_black_24dp"
|
||||
app:navigationIcon="@drawable/ic_keyboard_arrow_down_black_24dp" />
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/playerControlsContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/playbackControlsFragment"
|
||||
android:name="code.name.monkey.retromusic.fragments.player.material.MaterialControlsFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="match_parent"
|
||||
tools:layout="@layout/fragment_material_playback_controls" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_weight="0"
|
||||
android:id="@+id/upComing"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="end"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp"
|
||||
app:srcCompat="@drawable/ic_shuffle_sharp_white_24dp" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/player_queue_sub_header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/listPreferredItemHeightSmall"
|
||||
android:background="?attr/colorSurface"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:text="@string/up_next"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
|
||||
android:textColor="?android:attr/textColorSecondary" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/colorSurface"
|
||||
tools:listitem="@layout/item_list" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
|
|
@ -30,9 +30,10 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
app:labelBehavior="gone"
|
||||
app:layout_constraintBottom_toTopOf="@id/playPauseButton"
|
||||
app:layout_constraintEnd_toStartOf="@id/songTotalTime"
|
||||
app:layout_constraintStart_toEndOf="@id/songCurrentProgress"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/songInfo"
|
||||
app:thumbRadius="@dimen/slider_thumb_radius"
|
||||
app:trackHeight="@dimen/slider_track_height"
|
||||
tools:ignore="RtlHardcoded,UnusedAttribute"
|
||||
|
@ -61,7 +62,7 @@
|
|||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/progressSlider">
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/title"
|
||||
|
@ -114,7 +115,10 @@
|
|||
android:paddingEnd="16dp"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/playPauseButton"
|
||||
app:layout_constraintBottom_toTopOf="@+id/progressSlider"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/text"
|
||||
tools:text="@tools:sample/lorem/random" />
|
||||
|
||||
|
@ -146,7 +150,7 @@
|
|||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/repeatButton"
|
||||
app:layout_constraintTop_toTopOf="@+id/playPauseButton"
|
||||
app:srcCompat="@drawable/ic_skip_previous_white_24dp"
|
||||
app:srcCompat="@drawable/ic_skip_previous_sharp_white_24dp"
|
||||
tools:ignore="MissingPrefix"
|
||||
tools:tint="@color/md_black_1000" />
|
||||
|
||||
|
@ -155,12 +159,12 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/roundSelector"
|
||||
app:layout_constraintBottom_toTopOf="@+id/volumeFragmentContainer"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/nextButton"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/previousButton"
|
||||
app:layout_constraintTop_toBottomOf="@+id/songInfo"
|
||||
app:srcCompat="@drawable/ic_pause_white_64dp"
|
||||
app:layout_constraintTop_toBottomOf="@+id/progressSlider"
|
||||
app:srcCompat="@drawable/ic_pause_sharp_white_64dp"
|
||||
tools:tint="@color/md_black_1000" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageButton
|
||||
|
@ -175,7 +179,7 @@
|
|||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/playPauseButton"
|
||||
app:layout_constraintTop_toTopOf="@+id/playPauseButton"
|
||||
app:srcCompat="@drawable/ic_skip_next_white_24dp"
|
||||
app:srcCompat="@drawable/ic_skip_next_sharp_white_24dp"
|
||||
tools:ignore="MissingPrefix"
|
||||
tools:tint="@color/md_black_1000" />
|
||||
|
||||
|
@ -190,19 +194,16 @@
|
|||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/nextButton"
|
||||
app:layout_constraintTop_toTopOf="@+id/nextButton"
|
||||
app:srcCompat="@drawable/ic_shuffle_white_24dp"
|
||||
app:srcCompat="@drawable/ic_shuffle_sharp_white_24dp"
|
||||
tools:ignore="MissingPrefix"
|
||||
tools:tint="@color/md_black_1000" />
|
||||
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/volumeFragmentContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
tools:backgroundTint="@color/md_red_400"
|
||||
tools:layout_height="52dp" />
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
|
@ -33,13 +33,19 @@ object ColorUtil {
|
|||
return shiftColor(color, 0.9f)
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
fun darkenColorTheme(@ColorInt color: Int): Int {
|
||||
return shiftColor(color, 0.8f)
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
fun lightenColor(@ColorInt color: Int): Int {
|
||||
return shiftColor(color, 1.1f)
|
||||
}
|
||||
|
||||
fun isColorLight(@ColorInt color: Int): Boolean {
|
||||
val darkness = 1 - (0.299 * Color.red(color) + 0.587 * Color.green(color) + 0.114 * Color.blue(color)) / 255
|
||||
val darkness =
|
||||
1 - (0.299 * Color.red(color) + 0.587 * Color.green(color) + 0.114 * Color.blue(color)) / 255
|
||||
return darkness < 0.4
|
||||
}
|
||||
|
||||
|
@ -94,8 +100,14 @@ object ColorUtil {
|
|||
}
|
||||
|
||||
fun isColorSaturated(@ColorInt color: Int): Boolean {
|
||||
val max = Math.max(0.299 * Color.red(color), Math.max(0.587 * Color.green(color), 0.114 * Color.blue(color)))
|
||||
val min = Math.min(0.299 * Color.red(color), Math.min(0.587 * Color.green(color), 0.114 * Color.blue(color)))
|
||||
val max = Math.max(
|
||||
0.299 * Color.red(color),
|
||||
Math.max(0.587 * Color.green(color), 0.114 * Color.blue(color))
|
||||
)
|
||||
val min = Math.min(
|
||||
0.299 * Color.red(color),
|
||||
Math.min(0.587 * Color.green(color), 0.114 * Color.blue(color))
|
||||
)
|
||||
val diff = Math.abs(max - min)
|
||||
return diff > 20
|
||||
}
|
||||
|
@ -122,12 +134,17 @@ object ColorUtil {
|
|||
}
|
||||
|
||||
@ColorInt
|
||||
fun getReadableText(@ColorInt textColor: Int, @ColorInt backgroundColor: Int, difference: Int): Int {
|
||||
fun getReadableText(
|
||||
@ColorInt textColor: Int,
|
||||
@ColorInt backgroundColor: Int,
|
||||
difference: Int
|
||||
): Int {
|
||||
var textColorFinal = textColor
|
||||
val isLight = isColorLight(backgroundColor)
|
||||
var i = 0
|
||||
while (getDifference(textColorFinal, backgroundColor) < difference && i < 100) {
|
||||
textColorFinal = getMixedColor(textColorFinal, if (isLight) Color.BLACK else Color.WHITE)
|
||||
textColorFinal =
|
||||
getMixedColor(textColorFinal, if (isLight) Color.BLACK else Color.WHITE)
|
||||
i++
|
||||
}
|
||||
|
||||
|
@ -137,7 +154,8 @@ object ColorUtil {
|
|||
@ColorInt
|
||||
fun getContrastColor(@ColorInt color: Int): Int {
|
||||
// Counting the perceptive luminance - human eye favors green color...
|
||||
val a = 1 - (0.299 * Color.red(color) + 0.587 * Color.green(color) + 0.114 * Color.blue(color)) / 255
|
||||
val a =
|
||||
1 - (0.299 * Color.red(color) + 0.587 * Color.green(color) + 0.114 * Color.blue(color)) / 255
|
||||
return if (a < 0.5) Color.BLACK else Color.WHITE
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue