Fix toolbar color in Playlist and Genre details
This commit is contained in:
parent
66c9f19ab9
commit
38feb21568
11 changed files with 377 additions and 405 deletions
|
@ -128,15 +128,7 @@ class GenreDetailsActivity : AbsSlidingMusicPanelActivity(), CabHolder, GenreDet
|
|||
|
||||
override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab {
|
||||
if (cab != null && cab!!.isActive) cab!!.finish()
|
||||
cab = MaterialCab(this, R.id.cab_stub).setMenu(menuRes)
|
||||
.setCloseDrawableRes(R.drawable.ic_close_white_24dp).setBackgroundColor(
|
||||
RetroColorUtil.shiftBackgroundColorForLightText(
|
||||
ATHUtil.resolveColor(
|
||||
this,
|
||||
R.attr.colorPrimary
|
||||
)
|
||||
)
|
||||
).start(callback)
|
||||
cab = MaterialCab(this, R.id.cab_stub).setMenu(menuRes).setCloseDrawableRes(R.drawable.ic_close_white_24dp).setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(ATHUtil.resolveColor(this, R.attr.colorSurface))).start(callback)
|
||||
return cab!!
|
||||
}
|
||||
|
||||
|
|
|
@ -2,18 +2,22 @@ package code.name.monkey.retromusic.activities
|
|||
|
||||
import android.app.KeyguardManager
|
||||
import android.content.Context
|
||||
import android.os.*
|
||||
import android.view.*
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import androidx.core.view.ViewCompat
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity
|
||||
import code.name.monkey.retromusic.fragments.player.lockscreen.LockScreenPlayerControlsFragment
|
||||
import code.name.monkey.retromusic.glide.*
|
||||
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
|
||||
import code.name.monkey.retromusic.glide.SongGlideRequest
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import com.bumptech.glide.Glide
|
||||
import com.r0adkll.slidr.Slidr
|
||||
import com.r0adkll.slidr.model.*
|
||||
import com.r0adkll.slidr.model.SlidrConfig
|
||||
import com.r0adkll.slidr.model.SlidrListener
|
||||
import com.r0adkll.slidr.model.SlidrPosition
|
||||
import kotlinx.android.synthetic.main.activity_lock_screen.*
|
||||
|
||||
class LockScreenActivity : AbsMusicServiceActivity() {
|
||||
|
@ -25,13 +29,10 @@ class LockScreenActivity : AbsMusicServiceActivity() {
|
|||
setShowWhenLocked(true)
|
||||
setTurnScreenOn(true)
|
||||
} else {
|
||||
this.window.addFlags(
|
||||
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD or WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
|
||||
)
|
||||
this.window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD or WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON)
|
||||
}
|
||||
setDrawUnderStatusBar()
|
||||
setContentView(R.layout.activity_lock_screen)
|
||||
|
||||
hideStatusBar()
|
||||
setStatusbarColorAuto()
|
||||
setNavigationbarColorAuto()
|
||||
|
@ -70,12 +71,6 @@ class LockScreenActivity : AbsMusicServiceActivity() {
|
|||
alpha = 0f
|
||||
ViewCompat.animate(this).translationY(0f).alpha(1f).setDuration(1500).start()
|
||||
}
|
||||
|
||||
findViewById<View>(R.id.root_layout).setBackgroundColor(
|
||||
ATHUtil.resolveColor(
|
||||
this, R.attr.colorPrimary
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun onPlayingMetaChanged() {
|
||||
|
|
|
@ -140,15 +140,7 @@ class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, Playli
|
|||
if (cab != null && cab!!.isActive) {
|
||||
cab!!.finish()
|
||||
}
|
||||
cab = MaterialCab(this, R.id.cab_stub).setMenu(menuRes)
|
||||
.setCloseDrawableRes(R.drawable.ic_close_white_24dp).setBackgroundColor(
|
||||
RetroColorUtil.shiftBackgroundColorForLightText(
|
||||
ATHUtil.resolveColor(
|
||||
this,
|
||||
R.attr.colorPrimary
|
||||
)
|
||||
)
|
||||
).start(callback)
|
||||
cab = MaterialCab(this, R.id.cab_stub).setMenu(menuRes).setCloseDrawableRes(R.drawable.ic_close_white_24dp).setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(ATHUtil.resolveColor(this, R.attr.colorSurface))).start(callback)
|
||||
return cab!!
|
||||
}
|
||||
|
||||
|
|
|
@ -1,167 +1,170 @@
|
|||
package code.name.monkey.retromusic.adapter.song
|
||||
|
||||
import android.graphics.*
|
||||
import android.view.*
|
||||
import android.graphics.Color
|
||||
import android.graphics.PorterDuff
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.util.*
|
||||
import com.h6ah4i.android.widget.advrecyclerview.draggable.*
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.ViewUtil
|
||||
import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemAdapter
|
||||
import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemViewHolder
|
||||
import com.h6ah4i.android.widget.advrecyclerview.draggable.ItemDraggableRange
|
||||
import com.h6ah4i.android.widget.advrecyclerview.draggable.annotation.DraggableItemStateFlags
|
||||
import java.util.*
|
||||
|
||||
class PlayingQueueAdapter(
|
||||
activity: AppCompatActivity,
|
||||
dataSet: ArrayList<Song>,
|
||||
private var current: Int,
|
||||
itemLayoutRes: Int
|
||||
activity: AppCompatActivity,
|
||||
dataSet: ArrayList<Song>,
|
||||
private var current: Int,
|
||||
itemLayoutRes: Int
|
||||
) : SongAdapter(
|
||||
activity, dataSet, itemLayoutRes, false, null
|
||||
activity, dataSet, itemLayoutRes, false, null
|
||||
), DraggableItemAdapter<PlayingQueueAdapter.ViewHolder> {
|
||||
|
||||
private var color = -1
|
||||
private var color = -1
|
||||
|
||||
override fun createViewHolder(view: View): SongAdapter.ViewHolder {
|
||||
return ViewHolder(view)
|
||||
}
|
||||
override fun createViewHolder(view: View): SongAdapter.ViewHolder {
|
||||
return ViewHolder(view)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: SongAdapter.ViewHolder, position: Int) {
|
||||
super.onBindViewHolder(holder, position)
|
||||
holder.imageText?.text = (position - current).toString()
|
||||
holder.time?.text = MusicUtil.getReadableDurationString(dataSet[position].duration)
|
||||
if (holder.itemViewType == HISTORY || holder.itemViewType == CURRENT) {
|
||||
setAlpha(holder, 0.5f)
|
||||
}
|
||||
if (usePalette) {
|
||||
setColor(holder, Color.WHITE)
|
||||
}
|
||||
}
|
||||
override fun onBindViewHolder(holder: SongAdapter.ViewHolder, position: Int) {
|
||||
super.onBindViewHolder(holder, position)
|
||||
holder.imageText?.text = (position - current).toString()
|
||||
holder.time?.text = MusicUtil.getReadableDurationString(dataSet[position].duration)
|
||||
if (holder.itemViewType == HISTORY || holder.itemViewType == CURRENT) {
|
||||
setAlpha(holder, 0.5f)
|
||||
}
|
||||
if (usePalette) {
|
||||
setColor(holder, Color.WHITE)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setColor(holder: SongAdapter.ViewHolder, white: Int) {
|
||||
private fun setColor(holder: SongAdapter.ViewHolder, white: Int) {
|
||||
|
||||
if (holder.title != null) {
|
||||
holder.title!!.setTextColor(white)
|
||||
if (color != -1) {
|
||||
holder.title!!.setTextColor(color)
|
||||
}
|
||||
}
|
||||
if (holder.title != null) {
|
||||
holder.title!!.setTextColor(white)
|
||||
if (color != -1) {
|
||||
holder.title!!.setTextColor(color)
|
||||
}
|
||||
}
|
||||
|
||||
holder.text?.setTextColor(white)
|
||||
holder.time?.setTextColor(white)
|
||||
holder.imageText?.setTextColor(white)
|
||||
if (holder.menu != null) {
|
||||
(holder.menu as ImageView).setColorFilter(white, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
}
|
||||
holder.text?.setTextColor(white)
|
||||
holder.time?.setTextColor(white)
|
||||
holder.imageText?.setTextColor(white)
|
||||
if (holder.menu != null) {
|
||||
(holder.menu as ImageView).setColorFilter(white, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
}
|
||||
|
||||
override fun usePalette(usePalette: Boolean) {
|
||||
super.usePalette(usePalette)
|
||||
this.usePalette = usePalette
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
override fun usePalette(usePalette: Boolean) {
|
||||
super.usePalette(usePalette)
|
||||
this.usePalette = usePalette
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
if (position < current) {
|
||||
return HISTORY
|
||||
} else if (position > current) {
|
||||
return UP_NEXT
|
||||
}
|
||||
return CURRENT
|
||||
}
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
if (position < current) {
|
||||
return HISTORY
|
||||
} else if (position > current) {
|
||||
return UP_NEXT
|
||||
}
|
||||
return CURRENT
|
||||
}
|
||||
|
||||
override fun loadAlbumCover(song: Song, holder: SongAdapter.ViewHolder) {
|
||||
// We don't want to load it in this adapter
|
||||
}
|
||||
override fun loadAlbumCover(song: Song, holder: SongAdapter.ViewHolder) {
|
||||
// We don't want to load it in this adapter
|
||||
}
|
||||
|
||||
fun swapDataSet(dataSet: ArrayList<Song>, position: Int) {
|
||||
this.dataSet = dataSet
|
||||
current = position
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
fun swapDataSet(dataSet: ArrayList<Song>, position: Int) {
|
||||
this.dataSet = dataSet
|
||||
current = position
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
fun setCurrent(current: Int) {
|
||||
this.current = current
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
fun setCurrent(current: Int) {
|
||||
this.current = current
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
private fun setAlpha(holder: SongAdapter.ViewHolder, alpha: Float) {
|
||||
holder.image?.alpha = alpha
|
||||
holder.title?.alpha = alpha
|
||||
holder.text?.alpha = alpha
|
||||
holder.imageText?.alpha = alpha
|
||||
holder.paletteColorContainer?.alpha = alpha
|
||||
}
|
||||
private fun setAlpha(holder: SongAdapter.ViewHolder, alpha: Float) {
|
||||
holder.image?.alpha = alpha
|
||||
holder.title?.alpha = alpha
|
||||
holder.text?.alpha = alpha
|
||||
holder.imageText?.alpha = alpha
|
||||
holder.paletteColorContainer?.alpha = alpha
|
||||
holder.dragView?.alpha = alpha
|
||||
holder.menu?.alpha = alpha
|
||||
}
|
||||
|
||||
override fun onCheckCanStartDrag(holder: ViewHolder, position: Int, x: Int, y: Int): Boolean {
|
||||
return ViewUtil.hitTest(holder.imageText!!, x, y) || ViewUtil.hitTest(
|
||||
holder.dragView!!,
|
||||
x,
|
||||
y
|
||||
)
|
||||
}
|
||||
override fun onCheckCanStartDrag(holder: ViewHolder, position: Int, x: Int, y: Int): Boolean {
|
||||
return ViewUtil.hitTest(holder.imageText!!, x, y) || ViewUtil.hitTest(holder.dragView!!, x, y)
|
||||
}
|
||||
|
||||
override fun onGetItemDraggableRange(holder: ViewHolder, position: Int): ItemDraggableRange? {
|
||||
return null
|
||||
}
|
||||
override fun onGetItemDraggableRange(holder: ViewHolder, position: Int): ItemDraggableRange? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun onMoveItem(fromPosition: Int, toPosition: Int) {
|
||||
MusicPlayerRemote.moveSong(fromPosition, toPosition)
|
||||
}
|
||||
override fun onMoveItem(fromPosition: Int, toPosition: Int) {
|
||||
MusicPlayerRemote.moveSong(fromPosition, toPosition)
|
||||
}
|
||||
|
||||
override fun onCheckCanDrop(draggingPosition: Int, dropPosition: Int): Boolean {
|
||||
return true
|
||||
}
|
||||
override fun onCheckCanDrop(draggingPosition: Int, dropPosition: Int): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onItemDragStarted(position: Int) {
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
override fun onItemDragStarted(position: Int) {
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onItemDragFinished(fromPosition: Int, toPosition: Int, result: Boolean) {
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
override fun onItemDragFinished(fromPosition: Int, toPosition: Int, result: Boolean) {
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
inner class ViewHolder(itemView: View) : SongAdapter.ViewHolder(itemView), DraggableItemViewHolder {
|
||||
inner class ViewHolder(itemView: View) : SongAdapter.ViewHolder(itemView), DraggableItemViewHolder {
|
||||
|
||||
@DraggableItemStateFlags
|
||||
private var mDragStateFlags: Int = 0
|
||||
@DraggableItemStateFlags
|
||||
private var mDragStateFlags: Int = 0
|
||||
|
||||
override var songMenuRes: Int
|
||||
get() = R.menu.menu_item_playing_queue_song
|
||||
set(value: Int) {
|
||||
super.songMenuRes = value
|
||||
}
|
||||
override var songMenuRes: Int
|
||||
get() = R.menu.menu_item_playing_queue_song
|
||||
set(value) {
|
||||
super.songMenuRes = value
|
||||
}
|
||||
|
||||
init {
|
||||
imageText?.visibility = View.VISIBLE
|
||||
dragView?.visibility = View.VISIBLE
|
||||
}
|
||||
init {
|
||||
imageText?.visibility = View.VISIBLE
|
||||
dragView?.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
override fun onSongMenuItemClick(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.action_remove_from_playing_queue -> {
|
||||
MusicPlayerRemote.removeFromQueue(adapterPosition)
|
||||
return true
|
||||
}
|
||||
}
|
||||
return super.onSongMenuItemClick(item)
|
||||
}
|
||||
override fun onSongMenuItemClick(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.action_remove_from_playing_queue -> {
|
||||
MusicPlayerRemote.removeFromQueue(adapterPosition)
|
||||
return true
|
||||
}
|
||||
}
|
||||
return super.onSongMenuItemClick(item)
|
||||
}
|
||||
|
||||
@DraggableItemStateFlags
|
||||
override fun getDragStateFlags(): Int {
|
||||
return mDragStateFlags
|
||||
}
|
||||
@DraggableItemStateFlags
|
||||
override fun getDragStateFlags(): Int {
|
||||
return mDragStateFlags
|
||||
}
|
||||
|
||||
override fun setDragStateFlags(@DraggableItemStateFlags flags: Int) {
|
||||
mDragStateFlags = flags
|
||||
}
|
||||
}
|
||||
override fun setDragStateFlags(@DraggableItemStateFlags flags: Int) {
|
||||
mDragStateFlags = flags
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
companion object {
|
||||
|
||||
private const val HISTORY = 0
|
||||
private const val CURRENT = 1
|
||||
private const val UP_NEXT = 2
|
||||
}
|
||||
private const val HISTORY = 0
|
||||
private const val CURRENT = 1
|
||||
private const val UP_NEXT = 2
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ import androidx.appcompat.app.AppCompatActivity
|
|||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.adapter.base.AbsMultiSelectAdapter
|
||||
import code.name.monkey.retromusic.adapter.base.MediaEntryViewHolder
|
||||
import code.name.monkey.retromusic.extensions.hide
|
||||
import code.name.monkey.retromusic.extensions.show
|
||||
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
|
||||
import code.name.monkey.retromusic.glide.SongGlideRequest
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
|
@ -31,181 +33,182 @@ import java.util.*
|
|||
*/
|
||||
|
||||
open class SongAdapter(
|
||||
protected val activity: AppCompatActivity,
|
||||
dataSet: ArrayList<Song>,
|
||||
protected var itemLayoutRes: Int,
|
||||
usePalette: Boolean,
|
||||
cabHolder: CabHolder?,
|
||||
showSectionName: Boolean = true
|
||||
protected val activity: AppCompatActivity,
|
||||
dataSet: ArrayList<Song>,
|
||||
protected var itemLayoutRes: Int,
|
||||
usePalette: Boolean,
|
||||
cabHolder: CabHolder?,
|
||||
showSectionName: Boolean = true
|
||||
) : AbsMultiSelectAdapter<SongAdapter.ViewHolder, Song>(
|
||||
activity, cabHolder, R.menu.menu_media_selection
|
||||
activity, cabHolder, R.menu.menu_media_selection
|
||||
), MaterialCab.Callback, FastScrollRecyclerView.SectionedAdapter {
|
||||
var dataSet: ArrayList<Song>
|
||||
var dataSet: ArrayList<Song>
|
||||
|
||||
protected var usePalette = false
|
||||
private var showSectionName = true
|
||||
protected var usePalette = false
|
||||
private var showSectionName = true
|
||||
|
||||
init {
|
||||
this.dataSet = dataSet
|
||||
this.usePalette = usePalette
|
||||
this.showSectionName = showSectionName
|
||||
this.setHasStableIds(true)
|
||||
}
|
||||
init {
|
||||
this.dataSet = dataSet
|
||||
this.usePalette = usePalette
|
||||
this.showSectionName = showSectionName
|
||||
this.setHasStableIds(true)
|
||||
}
|
||||
|
||||
open fun swapDataSet(dataSet: ArrayList<Song>) {
|
||||
this.dataSet = dataSet
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
open fun swapDataSet(dataSet: ArrayList<Song>) {
|
||||
this.dataSet = dataSet
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
open fun usePalette(usePalette: Boolean) {
|
||||
this.usePalette = usePalette
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
open fun usePalette(usePalette: Boolean) {
|
||||
this.usePalette = usePalette
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun getItemId(position: Int): Long {
|
||||
return dataSet[position].id.toLong()
|
||||
}
|
||||
override fun getItemId(position: Int): Long {
|
||||
return dataSet[position].id.toLong()
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val view = LayoutInflater.from(activity).inflate(itemLayoutRes, parent, false)
|
||||
return createViewHolder(view)
|
||||
}
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val view = LayoutInflater.from(activity).inflate(itemLayoutRes, parent, false)
|
||||
return createViewHolder(view)
|
||||
}
|
||||
|
||||
protected open fun createViewHolder(view: View): ViewHolder {
|
||||
return ViewHolder(view)
|
||||
}
|
||||
protected open fun createViewHolder(view: View): ViewHolder {
|
||||
return ViewHolder(view)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val song = dataSet[position]
|
||||
val isChecked = isChecked(song)
|
||||
holder.itemView.isActivated = isChecked
|
||||
holder.title?.text = getSongTitle(song)
|
||||
holder.text?.text = getSongText(song)
|
||||
loadAlbumCover(song, holder)
|
||||
}
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val song = dataSet[position]
|
||||
val isChecked = isChecked(song)
|
||||
holder.itemView.isActivated = isChecked
|
||||
if (isChecked) {
|
||||
holder.menu?.hide()
|
||||
} else {
|
||||
holder.menu?.show()
|
||||
}
|
||||
holder.title?.text = getSongTitle(song)
|
||||
holder.text?.text = getSongText(song)
|
||||
loadAlbumCover(song, holder)
|
||||
}
|
||||
|
||||
private fun setColors(color: Int, holder: ViewHolder) {
|
||||
if (holder.paletteColorContainer != null) {
|
||||
holder.paletteColorContainer?.setBackgroundColor(color)
|
||||
//holder.title?.setTextColor(MaterialValueHelper.getPrimaryTextColor(activity, ColorUtil.isColorLight(color)))
|
||||
//holder.text?.setTextColor(MaterialValueHelper.getSecondaryTextColor(activity, ColorUtil.isColorLight(color)))
|
||||
}
|
||||
}
|
||||
private fun setColors(color: Int, holder: ViewHolder) {
|
||||
if (holder.paletteColorContainer != null) {
|
||||
holder.paletteColorContainer?.setBackgroundColor(color)
|
||||
//holder.title?.setTextColor(MaterialValueHelper.getPrimaryTextColor(activity, ColorUtil.isColorLight(color)))
|
||||
//holder.text?.setTextColor(MaterialValueHelper.getSecondaryTextColor(activity, ColorUtil.isColorLight(color)))
|
||||
}
|
||||
}
|
||||
|
||||
protected open fun loadAlbumCover(song: Song, holder: ViewHolder) {
|
||||
if (holder.image == null) {
|
||||
return
|
||||
}
|
||||
SongGlideRequest.Builder.from(Glide.with(activity), song).checkIgnoreMediaStore(activity)
|
||||
.generatePalette(activity).build()
|
||||
.into(object : RetroMusicColoredTarget(holder.image!!) {
|
||||
override fun onLoadCleared(placeholder: Drawable?) {
|
||||
super.onLoadCleared(placeholder)
|
||||
setColors(defaultFooterColor, holder)
|
||||
}
|
||||
protected open fun loadAlbumCover(song: Song, holder: ViewHolder) {
|
||||
if (holder.image == null) {
|
||||
return
|
||||
}
|
||||
SongGlideRequest.Builder.from(Glide.with(activity), song).checkIgnoreMediaStore(activity)
|
||||
.generatePalette(activity).build()
|
||||
.into(object : RetroMusicColoredTarget(holder.image!!) {
|
||||
override fun onLoadCleared(placeholder: Drawable?) {
|
||||
super.onLoadCleared(placeholder)
|
||||
setColors(defaultFooterColor, holder)
|
||||
}
|
||||
|
||||
override fun onColorReady(color: Int) {
|
||||
if (usePalette) setColors(color, holder)
|
||||
else setColors(defaultFooterColor, holder)
|
||||
}
|
||||
})
|
||||
}
|
||||
override fun onColorReady(color: Int) {
|
||||
if (usePalette) setColors(color, holder)
|
||||
else setColors(defaultFooterColor, holder)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun getSongTitle(song: Song): String? {
|
||||
return song.title
|
||||
}
|
||||
private fun getSongTitle(song: Song): String? {
|
||||
return song.title
|
||||
}
|
||||
|
||||
private fun getSongText(song: Song): String? {
|
||||
return song.artistName
|
||||
}
|
||||
private fun getSongText(song: Song): String? {
|
||||
return song.artistName
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return dataSet.size
|
||||
}
|
||||
override fun getItemCount(): Int {
|
||||
return dataSet.size
|
||||
}
|
||||
|
||||
override fun getIdentifier(position: Int): Song? {
|
||||
return dataSet[position]
|
||||
}
|
||||
override fun getIdentifier(position: Int): Song? {
|
||||
return dataSet[position]
|
||||
}
|
||||
|
||||
override fun getName(song: Song): String {
|
||||
return song.title
|
||||
}
|
||||
override fun getName(song: Song): String {
|
||||
return song.title
|
||||
}
|
||||
|
||||
override fun onMultipleItemAction(
|
||||
menuItem: MenuItem, selection: ArrayList<Song>
|
||||
) {
|
||||
SongsMenuHelper.handleMenuClick(activity, selection, menuItem.itemId)
|
||||
}
|
||||
override fun onMultipleItemAction(menuItem: MenuItem, selection: ArrayList<Song>) {
|
||||
SongsMenuHelper.handleMenuClick(activity, selection, menuItem.itemId)
|
||||
}
|
||||
|
||||
override fun getSectionName(position: Int): String {
|
||||
if (!showSectionName) {
|
||||
return ""
|
||||
}
|
||||
val sectionName: String? = when (PreferenceUtil.getInstance(activity).songSortOrder) {
|
||||
SortOrder.SongSortOrder.SONG_A_Z, SortOrder.SongSortOrder.SONG_Z_A -> dataSet[position].title
|
||||
SortOrder.SongSortOrder.SONG_ALBUM -> dataSet[position].albumName
|
||||
SortOrder.SongSortOrder.SONG_ARTIST -> dataSet[position].artistName
|
||||
SortOrder.SongSortOrder.SONG_YEAR -> return MusicUtil.getYearString(
|
||||
dataSet[position].year
|
||||
)
|
||||
SortOrder.SongSortOrder.COMPOSER -> dataSet[position].composer
|
||||
else -> {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
return MusicUtil.getSectionName(sectionName)
|
||||
}
|
||||
override fun getSectionName(position: Int): String {
|
||||
if (!showSectionName) {
|
||||
return ""
|
||||
}
|
||||
val sectionName: String? = when (PreferenceUtil.getInstance(activity).songSortOrder) {
|
||||
SortOrder.SongSortOrder.SONG_A_Z, SortOrder.SongSortOrder.SONG_Z_A -> dataSet[position].title
|
||||
SortOrder.SongSortOrder.SONG_ALBUM -> dataSet[position].albumName
|
||||
SortOrder.SongSortOrder.SONG_ARTIST -> dataSet[position].artistName
|
||||
SortOrder.SongSortOrder.SONG_YEAR -> return MusicUtil.getYearString(dataSet[position].year)
|
||||
SortOrder.SongSortOrder.COMPOSER -> dataSet[position].composer
|
||||
else -> {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
return MusicUtil.getSectionName(sectionName)
|
||||
}
|
||||
|
||||
open inner class ViewHolder(itemView: View) : MediaEntryViewHolder(itemView) {
|
||||
protected open var songMenuRes = SongMenuHelper.MENU_RES
|
||||
protected open val song: Song
|
||||
get() = dataSet[adapterPosition]
|
||||
open inner class ViewHolder(itemView: View) : MediaEntryViewHolder(itemView) {
|
||||
protected open var songMenuRes = SongMenuHelper.MENU_RES
|
||||
protected open val song: Song
|
||||
get() = dataSet[adapterPosition]
|
||||
|
||||
init {
|
||||
setImageTransitionName(activity.getString(R.string.transition_album_art))
|
||||
menu?.setOnClickListener(object : SongMenuHelper.OnClickSongMenu(activity) {
|
||||
override val song: Song
|
||||
get() = this@ViewHolder.song
|
||||
init {
|
||||
setImageTransitionName(activity.getString(R.string.transition_album_art))
|
||||
menu?.setOnClickListener(object : SongMenuHelper.OnClickSongMenu(activity) {
|
||||
override val song: Song
|
||||
get() = this@ViewHolder.song
|
||||
|
||||
override val menuRes: Int
|
||||
get() = songMenuRes
|
||||
override val menuRes: Int
|
||||
get() = songMenuRes
|
||||
|
||||
override fun onMenuItemClick(item: MenuItem): Boolean {
|
||||
return onSongMenuItemClick(item) || super.onMenuItemClick(item)
|
||||
}
|
||||
})
|
||||
}
|
||||
override fun onMenuItemClick(item: MenuItem): Boolean {
|
||||
return onSongMenuItemClick(item) || super.onMenuItemClick(item)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
protected open fun onSongMenuItemClick(item: MenuItem): Boolean {
|
||||
if (image != null && image!!.visibility == View.VISIBLE) {
|
||||
when (item.itemId) {
|
||||
R.id.action_go_to_album -> {
|
||||
val options: ActivityOptions = ActivityOptions.makeSceneTransitionAnimation(
|
||||
activity, image, activity.getString(R.string.transition_album_art)
|
||||
)
|
||||
NavigationUtil.goToAlbumOptions(activity, song.albumId, options)
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
protected open fun onSongMenuItemClick(item: MenuItem): Boolean {
|
||||
if (image != null && image!!.visibility == View.VISIBLE) {
|
||||
when (item.itemId) {
|
||||
R.id.action_go_to_album -> {
|
||||
val options: ActivityOptions = ActivityOptions.makeSceneTransitionAnimation(
|
||||
activity, image, activity.getString(R.string.transition_album_art)
|
||||
)
|
||||
NavigationUtil.goToAlbumOptions(activity, song.albumId, options)
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
if (isInQuickSelectMode) {
|
||||
toggleChecked(adapterPosition)
|
||||
} else {
|
||||
MusicPlayerRemote.openQueue(dataSet, adapterPosition, true)
|
||||
}
|
||||
}
|
||||
override fun onClick(v: View?) {
|
||||
if (isInQuickSelectMode) {
|
||||
toggleChecked(adapterPosition)
|
||||
} else {
|
||||
MusicPlayerRemote.openQueue(dataSet, adapterPosition, true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onLongClick(v: View?): Boolean {
|
||||
return toggleChecked(adapterPosition)
|
||||
}
|
||||
}
|
||||
override fun onLongClick(v: View?): Boolean {
|
||||
return toggleChecked(adapterPosition)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
companion object {
|
||||
|
||||
val TAG: String = SongAdapter::class.java.simpleName
|
||||
}
|
||||
val TAG: String = SongAdapter::class.java.simpleName
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,14 +58,14 @@ class LockScreenPlayerControlsFragment : AbsPlayerControlsFragment() {
|
|||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
val view = inflater.inflate(R.layout.fragment_lock_screen_playback_controls, container, false)
|
||||
|
||||
return view
|
||||
return inflater.inflate(R.layout.fragment_lock_screen_playback_controls, container, false)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
setUpMusicControllers()
|
||||
title.isSelected = true
|
||||
}
|
||||
|
||||
private fun updateSong() {
|
||||
|
|
|
@ -18,4 +18,4 @@ import android.os.Parcelable
|
|||
import kotlinx.android.parcel.Parcelize
|
||||
|
||||
@Parcelize
|
||||
class Genre(val id: Int = -1, val name: String, val songCount: Int) : Parcelable
|
||||
data class Genre(val id: Int = -1, val name: String, val songCount: Int) : Parcelable
|
|
@ -2,9 +2,9 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/root_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/colorSurface"
|
||||
android:orientation="vertical">
|
||||
|
||||
<FrameLayout
|
||||
|
@ -30,31 +30,26 @@
|
|||
tools:layout="@layout/fragment_lock_screen_playback_controls" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<code.name.monkey.retromusic.views.WidthFitSquareLayout
|
||||
<code.name.monkey.retromusic.views.WidthFitSquareCardView
|
||||
android:id="@+id/albumCoverContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0">
|
||||
android:layout_margin="16dp"
|
||||
android:transitionName="@string/transition_album_art"
|
||||
app:cardCornerRadius="24dp"
|
||||
app:cardElevation="8dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
app:cardCornerRadius="8dp"
|
||||
app:cardElevation="8dp">
|
||||
android:scaleType="centerCrop"
|
||||
tools:srcCompat="@tools:sample/backgrounds/scenic[0]" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:contentDescription="TODO"
|
||||
android:scaleType="centerCrop"
|
||||
tools:srcCompat="@tools:sample/backgrounds/scenic[0]" />
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
</code.name.monkey.retromusic.views.WidthFitSquareLayout>
|
||||
</code.name.monkey.retromusic.views.WidthFitSquareCardView>
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/slide"
|
||||
|
@ -63,5 +58,6 @@
|
|||
android:layout_weight="0"
|
||||
android:gravity="center"
|
||||
android:padding="16dp"
|
||||
android:text="@string/swipe_to_unlock" />
|
||||
android:text="@string/swipe_to_unlock"
|
||||
android:textColor="?android:attr/textColorPrimary" />
|
||||
</LinearLayout>
|
|
@ -28,7 +28,7 @@
|
|||
android:gravity="center_vertical|left|end"
|
||||
android:paddingLeft="8dp"
|
||||
android:singleLine="true"
|
||||
android:textColor="?colorOnSecondary"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="12sp"
|
||||
tools:ignore="RtlHardcoded,RtlSymmetry"
|
||||
tools:text="00:22" />
|
||||
|
@ -42,7 +42,7 @@
|
|||
android:gravity="center_vertical|right|end"
|
||||
android:paddingRight="8dp"
|
||||
android:singleLine="true"
|
||||
android:textColor="?colorOnSecondary"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="12sp"
|
||||
tools:ignore="RtlHardcoded,RtlSymmetry"
|
||||
tools:text="00:22" />
|
||||
|
@ -97,7 +97,7 @@
|
|||
android:maxLines="1"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Body1"
|
||||
android:textAppearance="@style/TextViewBody1"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
app:layout_constraintBottom_toTopOf="@+id/playerMediaControllerContainer"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -7,85 +7,77 @@
|
|||
android:background="?rectSelector"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:minHeight="72dp"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="64dp"
|
||||
android:orientation="horizontal"
|
||||
tools:ignore="MissingPrefix">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/drag_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
android:layout_gravity="center_vertical|start"
|
||||
android:padding="8dp"
|
||||
android:visibility="gone"
|
||||
app:srcCompat="@drawable/ic_drag_vertical_white_24dp"
|
||||
app:tint="?colorOnBackground"
|
||||
tools:ignore="ContentDescription"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/drag_view"
|
||||
<FrameLayout
|
||||
android:id="@+id/imageContainer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0">
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/imageText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_vertical|start"
|
||||
android:padding="8dp"
|
||||
android:fontFeatureSettings="onum"
|
||||
android:gravity="center"
|
||||
android:maxLines="1"
|
||||
android:minWidth="36dp"
|
||||
android:minHeight="40dp"
|
||||
android:textAppearance="@style/TextViewSubtitle1"
|
||||
android:visibility="gone"
|
||||
app:srcCompat="@drawable/ic_drag_vertical_white_24dp"
|
||||
app:tint="?colorOnBackground"
|
||||
tools:ignore="ContentDescription"
|
||||
tools:text="1"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/imageContainer"
|
||||
</FrameLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/title_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1.0"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0">
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/imageText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:fontFeatureSettings="onum"
|
||||
android:gravity="center"
|
||||
android:maxLines="1"
|
||||
android:minWidth="36dp"
|
||||
android:minHeight="40dp"
|
||||
android:textAppearance="@style/TextViewSubtitle1"
|
||||
android:visibility="gone"
|
||||
tools:text="1"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/title_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:layout_weight="1.0"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp">
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textAppearance="@style/TextViewHeadline6"
|
||||
android:textSize="16sp"
|
||||
tools:text="Song name" />
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
tools:text="Song details" />
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/menu"
|
||||
style="@style/OverFlowButton"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="0"
|
||||
app:tint="?attr/colorControlNormal" />
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textAppearance="@style/TextViewSubtitle1"
|
||||
android:textSize="16sp"
|
||||
tools:text="Song name" />
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
tools:text="Song details" />
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/menu"
|
||||
style="@style/OverFlowButton"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="0"
|
||||
app:tint="?attr/colorControlNormal" />
|
||||
|
||||
</LinearLayout>
|
|
@ -5,7 +5,6 @@
|
|||
<item name="md_font_title">@font/circular</item>
|
||||
<item name="md_font_body">@font/circular</item>
|
||||
<item name="md_font_button">@font/circular</item>
|
||||
<item name="md_background_color">@color/md_red_500</item>
|
||||
<item name="android:windowActionBarOverlay">true</item>
|
||||
<item name="android:windowActivityTransitions">true</item>
|
||||
<item name="android:fontFamily">@font/circular</item>
|
||||
|
|
Loading…
Reference in a new issue