Added play and shuffle buttons

This commit is contained in:
h4h13 2019-06-04 23:48:27 +05:30
parent 0f59221f4e
commit 02d9eb765d
22 changed files with 266 additions and 256 deletions

View file

@ -10,7 +10,6 @@ import android.view.animation.AnimationUtils
import android.widget.ImageView
import androidx.core.app.ActivityCompat
import androidx.core.util.Pair
import androidx.core.widget.NestedScrollView
import androidx.recyclerview.widget.DefaultItemAnimator
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
@ -20,6 +19,11 @@ import code.name.monkey.appthemehelper.util.MaterialValueHelper
import code.name.monkey.appthemehelper.util.TintHelper
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity
import code.name.monkey.retromusic.activities.tageditor.AbsTagEditorActivity
import code.name.monkey.retromusic.activities.tageditor.AlbumTagEditorActivity
import code.name.monkey.retromusic.adapter.album.HorizontalAlbumAdapter
import code.name.monkey.retromusic.adapter.song.SimpleSongAdapter
import code.name.monkey.retromusic.dialogs.AddToPlaylistDialog
import code.name.monkey.retromusic.dialogs.DeleteSongsDialog
import code.name.monkey.retromusic.glide.GlideApp
@ -32,11 +36,6 @@ import code.name.monkey.retromusic.misc.AppBarStateChangeListener
import code.name.monkey.retromusic.model.Album
import code.name.monkey.retromusic.mvp.contract.AlbumDetailsContract
import code.name.monkey.retromusic.mvp.presenter.AlbumDetailsPresenter
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity
import code.name.monkey.retromusic.activities.tageditor.AbsTagEditorActivity
import code.name.monkey.retromusic.activities.tageditor.AlbumTagEditorActivity
import code.name.monkey.retromusic.adapter.album.HorizontalAlbumAdapter
import code.name.monkey.retromusic.adapter.song.SimpleSongAdapter
import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.NavigationUtil
import code.name.monkey.retromusic.util.PreferenceUtil
@ -55,8 +54,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsContrac
private lateinit var simpleSongAdapter: SimpleSongAdapter
private var disposable = CompositeDisposable()
var album: Album? = null
private set
private lateinit var album: Album
private val savedSortOrder: String
get() = PreferenceUtil.getInstance().albumDetailSongSortOrder
@ -80,7 +78,6 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsContrac
setLightNavigationBar(true)
setNavigationbarColorAuto()
ActivityCompat.postponeEnterTransition(this)
val albumId = intent.getIntExtra(EXTRA_ALBUM_ID, -1)
@ -90,23 +87,16 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsContrac
setupRecyclerView()
setupToolbarMarginHeight()
contentContainer.setOnScrollChangeListener { _: NestedScrollView?, _: Int, scrollY: Int, _: Int, oldScrollY: Int ->
run {
if (scrollY > oldScrollY) {
actionShuffleAll.shrink(true)
}
if (scrollY < oldScrollY) {
actionShuffleAll.extend(true)
}
}
}
actionShuffleAll.setOnClickListener { MusicPlayerRemote.openAndShuffleQueue(album!!.songs!!, true) }
artistImage = findViewById(R.id.artistImage)
artistImage.setOnClickListener {
val artistPairs = arrayOf<Pair<*, *>>(Pair.create(image, resources.getString(R.string.transition_artist_image)))
NavigationUtil.goToArtist(this, album!!.artistId, *artistPairs)
NavigationUtil.goToArtist(this, album.artistId, *artistPairs)
}
playAction.apply {
setOnClickListener { MusicPlayerRemote.openQueue(album.songs!!, 0, true) }
}
shuffleAction.apply {
setOnClickListener { MusicPlayerRemote.openAndShuffleQueue(album.songs!!, true) }
}
}
@ -144,13 +134,13 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsContrac
appBarLayout?.apply {
addOnOffsetChangedListener(object : AppBarStateChangeListener() {
override fun onStateChanged(appBarLayout: AppBarLayout, state: AppBarStateChangeListener.State) {
override fun onStateChanged(appBarLayout: AppBarLayout, state: State) {
val color: Int = when (state) {
AppBarStateChangeListener.State.COLLAPSED -> {
State.COLLAPSED -> {
setLightStatusbar(ColorUtil.isColorLight(ThemeStore.primaryColor(this@AlbumDetailsActivity)))
ThemeStore.primaryColor(this@AlbumDetailsActivity)
}
AppBarStateChangeListener.State.EXPANDED, AppBarStateChangeListener.State.IDLE -> {
State.EXPANDED, State.IDLE -> {
setLightStatusbar(false)
Color.TRANSPARENT
}
@ -242,9 +232,9 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsContrac
private fun loadAlbumCover() {
GlideApp.with(this)
.asBitmapPalette()
.load(RetroGlideExtension.getSongModel(album!!.safeGetFirstSong()))
.load(RetroGlideExtension.getSongModel(album.safeGetFirstSong()))
.transition(RetroGlideExtension.getDefaultTransition())
.songOptions(album!!.safeGetFirstSong())
.songOptions(album.safeGetFirstSong())
.dontAnimate()
.into(object : RetroMusicColoredTarget(image as ImageView) {
override fun onColorReady(color: Int) {
@ -259,10 +249,14 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsContrac
songTitle.setTextColor(themeColor)
moreTitle.setTextColor(themeColor)
actionShuffleAll.backgroundTintList = ColorStateList.valueOf(themeColor)
playAction.backgroundTintList = ColorStateList.valueOf(themeColor)
shuffleAction.backgroundTintList = ColorStateList.valueOf(themeColor)
ColorStateList.valueOf(MaterialValueHelper.getPrimaryTextColor(this, ColorUtil.isColorLight(themeColor))).apply {
actionShuffleAll.setTextColor(this)
actionShuffleAll.iconTint = this
playAction.setTextColor(this)
playAction.iconTint = this
shuffleAction.setTextColor(this)
shuffleAction.iconTint = this
}
}
@ -304,12 +298,12 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsContrac
}
R.id.action_tag_editor -> {
val intent = Intent(this, AlbumTagEditorActivity::class.java)
intent.putExtra(AbsTagEditorActivity.EXTRA_ID, album!!.id)
intent.putExtra(AbsTagEditorActivity.EXTRA_ID, album.id)
startActivityForResult(intent, TAG_EDITOR_REQUEST)
return true
}
R.id.action_go_to_artist -> {
NavigationUtil.goToArtist(this, album!!.artistId)
NavigationUtil.goToArtist(this, album.artistId)
return true
}
/*Sort*/

View file

@ -4,6 +4,7 @@ import android.app.Activity
import android.content.Intent
import android.content.res.ColorStateList
import android.graphics.Color
import android.graphics.drawable.Drawable
import android.os.Build
import android.os.Bundle
import android.text.Html
@ -13,7 +14,6 @@ import android.view.*
import android.view.animation.AnimationUtils
import android.widget.Toast
import androidx.core.app.ActivityCompat
import androidx.core.widget.NestedScrollView
import androidx.recyclerview.widget.DefaultItemAnimator
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
@ -23,6 +23,10 @@ import code.name.monkey.appthemehelper.util.MaterialValueHelper
import code.name.monkey.appthemehelper.util.TintHelper
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity
import code.name.monkey.retromusic.adapter.album.AlbumAdapter
import code.name.monkey.retromusic.adapter.album.HorizontalAlbumAdapter
import code.name.monkey.retromusic.adapter.song.SimpleSongAdapter
import code.name.monkey.retromusic.dialogs.AddToPlaylistDialog
import code.name.monkey.retromusic.glide.GlideApp
import code.name.monkey.retromusic.glide.RetroGlideExtension
@ -34,10 +38,6 @@ import code.name.monkey.retromusic.mvp.contract.ArtistDetailContract
import code.name.monkey.retromusic.mvp.presenter.ArtistDetailsPresenter
import code.name.monkey.retromusic.rest.LastFMRestClient
import code.name.monkey.retromusic.rest.model.LastFmArtist
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity
import code.name.monkey.retromusic.adapter.album.AlbumAdapter
import code.name.monkey.retromusic.adapter.album.HorizontalAlbumAdapter
import code.name.monkey.retromusic.adapter.song.SimpleSongAdapter
import code.name.monkey.retromusic.util.*
import com.google.android.material.appbar.AppBarLayout
import kotlinx.android.synthetic.main.activity_artist_content.*
@ -53,7 +53,7 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailContrac
private var biography: Spanned? = null
private lateinit var artist: Artist
private var lastFMRestClient: LastFMRestClient? = null
private var artistDetailsPresenter: ArtistDetailsPresenter? = null
private lateinit var artistDetailsPresenter: ArtistDetailsPresenter
private lateinit var songAdapter: SimpleSongAdapter
private lateinit var albumAdapter: AlbumAdapter
private var forceDownload: Boolean = false
@ -64,7 +64,6 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailContrac
window.enterTransition = slide
}
override fun createContentView(): View {
return wrapSlidingMusicPanel(R.layout.activity_artist_details)
}
@ -85,17 +84,13 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailContrac
setUpViews()
artistDetailsPresenter = ArtistDetailsPresenter(this, intent.extras!!)
artistDetailsPresenter!!.subscribe()
artistDetailsPresenter.subscribe()
contentContainer.setOnScrollChangeListener { _: NestedScrollView?, _: Int, scrollY: Int, _: Int, oldScrollY: Int ->
run {
if (scrollY > oldScrollY) {
actionShuffleAll.shrink(true)
}
if (scrollY < oldScrollY) {
actionShuffleAll.extend(true)
}
playAction.apply {
setOnClickListener { MusicPlayerRemote.openQueue(artist.songs, 0, true) }
}
shuffleAction.apply {
setOnClickListener { MusicPlayerRemote.openAndShuffleQueue(artist.songs, true) }
}
biographyText.setOnClickListener {
@ -105,7 +100,6 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailContrac
biographyText.maxLines = 4
}
}
actionShuffleAll.setOnClickListener { MusicPlayerRemote.openAndShuffleQueue(getArtist().songs, true) }
}
private fun setUpViews() {
@ -125,17 +119,16 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailContrac
private fun setupToolbarMarginHeight() {
val primaryColor = ThemeStore.primaryColor(this)
TintHelper.setTintAuto(contentContainer!!, primaryColor, true)
if (collapsingToolbarLayout != null) {
collapsingToolbarLayout!!.setContentScrimColor(primaryColor)
collapsingToolbarLayout!!.setStatusBarScrimColor(ColorUtil.darkenColor(primaryColor))
collapsingToolbarLayout?.let {
it.setContentScrimColor(primaryColor)
it.setStatusBarScrimColor(ColorUtil.darkenColor(primaryColor))
}
toolbar!!.setNavigationIcon(R.drawable.ic_keyboard_backspace_black_24dp)
toolbar?.setNavigationIcon(R.drawable.ic_keyboard_backspace_black_24dp)
setSupportActionBar(toolbar)
supportActionBar!!.title = null
if (toolbar != null && !PreferenceUtil.getInstance().fullScreenMode) {
val params = toolbar!!.layoutParams as ViewGroup.MarginLayoutParams
params.topMargin = RetroUtil.getStatusBarHeight()
@ -158,6 +151,7 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailContrac
ToolbarContentTintHelper.setToolbarContentColorBasedOnToolbarColor(appBarLayout.context, toolbar, color)
}
})
setColors(ThemeStore.accentColor(this))
}
private fun setupRecyclerView() {
@ -190,7 +184,7 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailContrac
override fun onPause() {
super.onPause()
artistDetailsPresenter!!.unsubscribe()
artistDetailsPresenter.unsubscribe()
}
override fun loading() {}
@ -208,10 +202,7 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailContrac
}
private fun getArtist(): Artist {
if (artist == null) {
artist = Artist()
}
return this.artist!!
return this.artist;
}
private fun setArtist(artist: Artist) {
@ -283,6 +274,11 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailContrac
override fun onColorReady(color: Int) {
setColors(color)
}
override fun onLoadFailed(errorDrawable: Drawable?) {
super.onLoadFailed(errorDrawable)
setColors(defaultFooterColor)
}
})
forceDownload = false;
}
@ -295,10 +291,14 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailContrac
songTitle.setTextColor(textColor)
biographyTitle.setTextColor(textColor)
actionShuffleAll.backgroundTintList = ColorStateList.valueOf(textColor)
playAction.backgroundTintList = ColorStateList.valueOf(textColor)
shuffleAction.backgroundTintList = ColorStateList.valueOf(textColor)
ColorStateList.valueOf(MaterialValueHelper.getPrimaryTextColor(this, ColorUtil.isColorLight(textColor))).apply {
actionShuffleAll.setTextColor(this)
actionShuffleAll.iconTint = this
playAction.setTextColor(this)
playAction.iconTint = this
shuffleAction.setTextColor(this)
shuffleAction.iconTint = this
}
findViewById<View>(R.id.root).setBackgroundColor(ThemeStore.primaryColor(this))
@ -356,8 +356,8 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailContrac
}
private fun reload() {
artistDetailsPresenter!!.unsubscribe()
artistDetailsPresenter!!.subscribe()
artistDetailsPresenter.unsubscribe()
artistDetailsPresenter.subscribe()
}
companion object {

View file

@ -1,6 +1,5 @@
package code.name.monkey.retromusic.activities
import android.content.res.ColorStateList
import android.graphics.Color
import android.os.Bundle
import android.view.Menu
@ -11,13 +10,10 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.appthemehelper.util.MaterialValueHelper
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity
import code.name.monkey.retromusic.adapter.song.SongAdapter
import code.name.monkey.retromusic.extensions.applyToolbar
import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.helper.menu.GenreMenuHelper
import code.name.monkey.retromusic.interfaces.CabHolder
import code.name.monkey.retromusic.model.Genre
@ -27,12 +23,7 @@ import code.name.monkey.retromusic.mvp.presenter.GenreDetailsPresenter
import code.name.monkey.retromusic.util.RetroColorUtil
import code.name.monkey.retromusic.util.ViewUtil
import com.afollestad.materialcab.MaterialCab
import kotlinx.android.synthetic.main.activity_playing_queue.*
import kotlinx.android.synthetic.main.activity_playlist_detail.*
import kotlinx.android.synthetic.main.activity_playlist_detail.appBarLayout
import kotlinx.android.synthetic.main.activity_playlist_detail.empty
import kotlinx.android.synthetic.main.activity_playlist_detail.recyclerView
import kotlinx.android.synthetic.main.activity_playlist_detail.toolbar
import java.util.*
/**
@ -67,18 +58,14 @@ class GenreDetailsActivity : AbsSlidingMusicPanelActivity(), GenreDetailsContrac
setUpToolBar()
setupRecyclerView()
actionShuffleAll.setOnClickListener { MusicPlayerRemote.openAndShuffleQueue(songAdapter!!.dataSet, true) }
}
private fun setUpToolBar() {
val primaryColor = ThemeStore.primaryColor(this)
appBarLayout.setBackgroundColor(primaryColor)
applyToolbar(toolbar)
actionShuffleAll.backgroundTintList = ColorStateList.valueOf(ThemeStore.accentColor(this))
ColorStateList.valueOf(MaterialValueHelper.getPrimaryTextColor(this, ColorUtil.isColorLight(ThemeStore.accentColor(this)))).apply {
actionShuffleAll.setTextColor(this)
actionShuffleAll.iconTint = this
}
title = genre!!.name
}
@ -128,16 +115,7 @@ class GenreDetailsActivity : AbsSlidingMusicPanelActivity(), GenreDetailsContrac
itemAnimator = DefaultItemAnimator()
layoutManager = LinearLayoutManager(this@GenreDetailsActivity)
adapter = songAdapter
}.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy)
if (dy > 0) {
actionShuffleAll.shrink(true)
} else if (dy < 0) {
actionShuffleAll.extend(true)
}
}
})
songAdapter!!.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() {
override fun onChanged() {
super.onChanged()

View file

@ -1,7 +1,5 @@
package code.name.monkey.retromusic.activities
import android.content.res.ColorStateList
import android.graphics.Color
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
@ -9,15 +7,12 @@ import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import code.name.monkey.appthemehelper.ThemeStore
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.activities.base.AbsSlidingMusicPanelActivity
import code.name.monkey.retromusic.adapter.song.OrderablePlaylistSongAdapter
import code.name.monkey.retromusic.adapter.song.PlaylistSongAdapter
import code.name.monkey.retromusic.adapter.song.SongAdapter
import code.name.monkey.retromusic.extensions.applyToolbar
import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.helper.menu.PlaylistMenuHelper
import code.name.monkey.retromusic.interfaces.CabHolder
import code.name.monkey.retromusic.loaders.PlaylistLoader
@ -54,7 +49,6 @@ class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, Playli
setTaskDescriptionColorAuto()
setLightNavigationBar(true)
toggleBottomNavigationView(true)
playlist = intent.extras!!.getParcelable(EXTRA_PLAYLIST)
@ -100,22 +94,6 @@ class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, Playli
checkIsEmpty()
}
})
recyclerView!!.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy)
if (dy > 0) {
actionShuffleAll.shrink(true)
} else if (dy < 0) {
actionShuffleAll.extend(true)
}
}
})
actionShuffleAll.setOnClickListener {
if (adapter.dataSet.isEmpty()) {
return@setOnClickListener
}
MusicPlayerRemote.openAndShuffleQueue(adapter.dataSet, true)
}
}
override fun onResume() {
@ -124,13 +102,6 @@ class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, Playli
}
private fun setUpToolBar() {
actionShuffleAll.backgroundTintList = ColorStateList.valueOf(ThemeStore.accentColor(this))
ColorStateList.valueOf(MaterialValueHelper.getPrimaryTextColor(this, ColorUtil.isColorLight(ThemeStore.accentColor(this)))).apply {
actionShuffleAll.setTextColor(this)
actionShuffleAll.iconTint = this
}
applyToolbar(toolbar)
title = playlist!!.name
}

View file

@ -12,6 +12,8 @@ import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.TintHelper
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.dialogs.ClearSmartPlaylistDialog
import code.name.monkey.retromusic.dialogs.DeletePlaylistDialog
import code.name.monkey.retromusic.helper.menu.PlaylistMenuHelper
@ -23,8 +25,6 @@ import code.name.monkey.retromusic.model.Playlist
import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.model.smartplaylist.AbsSmartPlaylist
import code.name.monkey.retromusic.model.smartplaylist.LastAddedPlaylist
import code.name.monkey.retromusic.adapter.base.AbsMultiSelectAdapter
import code.name.monkey.retromusic.adapter.base.MediaEntryViewHolder
import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.NavigationUtil
import java.util.*

View file

@ -20,7 +20,7 @@ abstract class AbsOffsetSongAdapter : SongAdapter {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SongAdapter.ViewHolder {
if (viewType == OFFSET_ITEM) {
val view = LayoutInflater.from(activity).inflate(R.layout.item_list_single_row, parent, false)
val view = LayoutInflater.from(activity).inflate(R.layout.item_list_quick_actions, parent, false)
return createViewHolder(view)
}
return super.onCreateViewHolder(parent, viewType)

View file

@ -1,20 +1,29 @@
package code.name.monkey.retromusic.adapter.song
import android.content.res.ColorStateList
import android.view.MenuItem
import android.view.View
import androidx.annotation.LayoutRes
import androidx.appcompat.app.AppCompatActivity
import androidx.core.util.Pair
import code.name.monkey.appthemehelper.ThemeStore
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.helper.MusicPlayerRemote
import code.name.monkey.retromusic.interfaces.CabHolder
import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.NavigationUtil
import code.name.monkey.retromusic.util.RetroUtil
import com.google.android.material.button.MaterialButton
import java.util.*
open class PlaylistSongAdapter(activity: AppCompatActivity, dataSet: ArrayList<Song>, @LayoutRes itemLayoutRes: Int, usePalette: Boolean, cabHolder: CabHolder?) : AbsOffsetSongAdapter(activity, dataSet, itemLayoutRes, usePalette, cabHolder, false) {
open class PlaylistSongAdapter(activity: AppCompatActivity,
dataSet: ArrayList<Song>,
@LayoutRes itemLayoutRes: Int,
usePalette: Boolean,
cabHolder: CabHolder?) :
AbsOffsetSongAdapter(activity, dataSet, itemLayoutRes, usePalette, cabHolder, false) {
init {
this.setMultiSelectMenuRes(R.menu.menu_cannot_delete_single_songs_playlist_songs_selection)
@ -25,35 +34,30 @@ open class PlaylistSongAdapter(activity: AppCompatActivity, dataSet: ArrayList<S
}
override fun onBindViewHolder(holder: SongAdapter.ViewHolder, position: Int) {
if (holder.itemViewType == AbsOffsetSongAdapter.OFFSET_ITEM) {
val textColor = ThemeStore.textColorSecondary(activity)
if (holder.title != null) {
holder.title!!.text = MusicUtil.getPlaylistInfoString(activity, dataSet)
holder.title!!.setTextColor(textColor)
if (holder.itemViewType == OFFSET_ITEM) {
val buttonColor = RetroUtil.toolbarColor(activity)
val textColor = MaterialValueHelper.getPrimaryTextColor(activity, ColorUtil.isColorLight(buttonColor))
val viewHolder = holder as ViewHolder
viewHolder.playAction?.let {
it.backgroundTintList = ColorStateList.valueOf(buttonColor)
it.setTextColor(textColor)
it.iconTint = ColorStateList.valueOf(textColor)
it.setOnClickListener {
MusicPlayerRemote.openQueue(dataSet, 0, true)
}
}
viewHolder.shuffleAction?.let {
it.backgroundTintList = ColorStateList.valueOf(buttonColor)
it.setTextColor(textColor)
it.iconTint = ColorStateList.valueOf(textColor)
it.setOnClickListener {
MusicPlayerRemote.openAndShuffleQueue(dataSet, true)
}
}
if (holder.text != null) {
holder.text!!.visibility = View.GONE
}
if (holder.menu != null) {
holder.menu!!.visibility = View.GONE
}
if (holder.image != null) {
val padding = activity.resources.getDimensionPixelSize(R.dimen.default_item_margin) / 2
holder.image!!.setPadding(padding, padding, padding, padding)
holder.image!!.setColorFilter(textColor)
holder.image!!.setImageResource(R.drawable.ic_timer_white_24dp)
}
if (holder.dragView != null) {
holder.dragView!!.visibility = View.GONE
}
if (holder.separator != null) {
holder.separator!!.visibility = View.GONE
}
if (holder.shortSeparator != null) {
holder.shortSeparator!!.visibility = View.GONE
}
} else {
super.onBindViewHolder(holder, position - 1)
}
@ -61,6 +65,9 @@ open class PlaylistSongAdapter(activity: AppCompatActivity, dataSet: ArrayList<S
open inner class ViewHolder(itemView: View) : AbsOffsetSongAdapter.ViewHolder(itemView) {
val playAction: MaterialButton? = itemView.findViewById(R.id.playAction)
val shuffleAction: MaterialButton? = itemView.findViewById(R.id.shuffleAction)
override var songMenuRes: Int
get() = R.menu.menu_item_cannot_delete_single_songs_playlist_song
set(value) {
@ -78,7 +85,6 @@ open class PlaylistSongAdapter(activity: AppCompatActivity, dataSet: ArrayList<S
}
companion object {
val TAG = PlaylistSongAdapter::class.java.simpleName
val TAG: String = PlaylistSongAdapter::class.java.simpleName
}
}

View file

@ -1,13 +1,18 @@
package code.name.monkey.retromusic.adapter.song
import android.content.res.ColorStateList
import android.view.View
import androidx.annotation.LayoutRes
import androidx.appcompat.app.AppCompatActivity
import code.name.monkey.appthemehelper.ThemeStore
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.helper.MusicPlayerRemote
import code.name.monkey.retromusic.interfaces.CabHolder
import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.RetroUtil
import com.google.android.material.button.MaterialButton
import java.util.*
@ -22,8 +27,30 @@ class ShuffleButtonSongAdapter(activity: AppCompatActivity,
}
override fun onBindViewHolder(holder: SongAdapter.ViewHolder, position: Int) {
if (holder.itemViewType == AbsOffsetSongAdapter.OFFSET_ITEM) {
if (holder.itemViewType == OFFSET_ITEM) {
val accentColor = ThemeStore.accentColor(activity.applicationContext)
val buttonColor = RetroUtil.toolbarColor(activity)
val textColor = MaterialValueHelper.getPrimaryTextColor(activity, ColorUtil.isColorLight(buttonColor))
val viewHolder = holder as ViewHolder
viewHolder.playAction?.let {
it.backgroundTintList = ColorStateList.valueOf(buttonColor)
it.setTextColor(textColor)
it.iconTint = ColorStateList.valueOf(textColor)
it.setOnClickListener {
MusicPlayerRemote.openQueue(dataSet, 0, true)
}
}
viewHolder.shuffleAction?.let {
it.backgroundTintList = ColorStateList.valueOf(buttonColor)
it.setTextColor(textColor)
it.iconTint = ColorStateList.valueOf(textColor)
it.setOnClickListener {
MusicPlayerRemote.openAndShuffleQueue(dataSet, true)
}
}
if (holder.title != null) {
holder.title!!.text = activity.resources.getString(R.string.action_shuffle_all)
holder.title!!.setTextColor(accentColor)
@ -52,9 +79,11 @@ class ShuffleButtonSongAdapter(activity: AppCompatActivity,
}
inner class ViewHolder(itemView: View) : AbsOffsetSongAdapter.ViewHolder(itemView) {
val playAction: MaterialButton? = itemView.findViewById(R.id.playAction)
val shuffleAction: MaterialButton? = itemView.findViewById(R.id.shuffleAction)
override fun onClick(v: View?) {
if (itemViewType == AbsOffsetSongAdapter.OFFSET_ITEM) {
if (itemViewType == OFFSET_ITEM) {
MusicPlayerRemote.openAndShuffleQueue(dataSet, true)
return
}

View file

@ -1,7 +1,7 @@
<?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:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">

View file

@ -96,16 +96,5 @@
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</LinearLayout>
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/actionShuffleAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:text="@string/action_shuffle_all"
app:icon="@drawable/ic_clear_all_black_24dp" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<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:id="@+id/root"
android:layout_width="match_parent"
@ -97,12 +96,4 @@
android:layout_height="72dp"
android:background="@drawable/shadow_down_strong" />
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/actionShuffleAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:text="@string/action_shuffle_all"
app:icon="@drawable/ic_clear_all_black_24dp" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -122,16 +122,6 @@
</androidx.core.widget.NestedScrollView>
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/actionShuffleAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:text="@string/action_shuffle_all"
app:icon="@drawable/ic_clear_all_black_24dp" />
<View
android:layout_width="match_parent"
android:layout_height="72dp"

View file

@ -94,14 +94,4 @@
<include layout="@layout/activity_artist_content" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/actionShuffleAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:text="@string/action_shuffle_all"
app:icon="@drawable/ic_clear_all_black_24dp" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -129,13 +129,4 @@
android:layout_height="72dp"
android:background="@drawable/shadow_down_strong" />
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/actionShuffleAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:text="@string/action_shuffle_all"
app:icon="@drawable/ic_clear_all_black_24dp" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -1,10 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingStart="8dp"
android:paddingEnd="8dp">
<com.google.android.material.button.MaterialButton
android:id="@+id/playAction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="6dp"
android:layout_weight="1"
android:padding="10dp"
android:text="@string/action_play"
android:textAllCaps="false"
app:cornerRadius="6dp"
app:icon="@drawable/ic_play_arrow_white_24dp"
app:iconGravity="textStart"
tools:backgroundTint="@color/md_grey_900" />
<com.google.android.material.button.MaterialButton
android:id="@+id/shuffleAction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="4dp"
android:layout_weight="1"
android:padding="10dp"
android:text="@string/shuffle"
android:textAllCaps="false"
app:cornerRadius="6dp"
app:icon="@drawable/ic_shuffle_white_24dp"
app:iconGravity="textStart"
tools:backgroundTint="@color/md_grey_900" />
</LinearLayout>
<code.name.monkey.appthemehelper.common.views.ATEPrimaryTextView
android:id="@+id/biographyTitle"
style="@style/TextAppearance.MaterialComponents.Subtitle2"

View file

@ -19,8 +19,8 @@
android:background="@android:color/transparent">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
android:id="@+id/collapsingToolbarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
@ -97,13 +97,4 @@
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/actionShuffleAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:text="@string/action_shuffle_all"
app:icon="@drawable/ic_clear_all_black_24dp" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -109,16 +109,6 @@
<include layout="@layout/activity_album_content" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/actionShuffleAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:text="@string/action_shuffle_all"
app:icon="@drawable/ic_shuffle_white_24dp" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -1,9 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingStart="8dp"
android:paddingEnd="8dp">
<com.google.android.material.button.MaterialButton
android:id="@+id/playAction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginEnd="8dp"
android:layout_weight="1"
android:padding="10dp"
android:text="@string/action_play"
android:textAllCaps="false"
app:cornerRadius="6dp"
app:icon="@drawable/ic_play_arrow_white_24dp"
app:iconGravity="textStart"
tools:backgroundTint="@color/md_grey_900" />
<com.google.android.material.button.MaterialButton
android:id="@+id/shuffleAction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="4dp"
android:layout_weight="1"
android:padding="10dp"
android:text="@string/shuffle"
android:textAllCaps="false"
app:cornerRadius="6dp"
app:icon="@drawable/ic_shuffle_white_24dp"
app:iconGravity="textStart"
tools:backgroundTint="@color/md_grey_900" />
</LinearLayout>
<code.name.monkey.appthemehelper.common.views.ATEPrimaryTextView
android:id="@+id/songTitle"
style="@style/SubTitleTextAppearance"

View file

@ -1,15 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.constraintlayout.widget.ConstraintLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingStart="8dp"
android:paddingEnd="8dp">
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.button.MaterialButton
android:id="@+id/playAction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginEnd="8dp"
android:layout_weight="1"
android:padding="10dp"
android:text="@string/action_play"
android:textAllCaps="false"
app:cornerRadius="6dp"
app:icon="@drawable/ic_play_arrow_white_24dp"
app:iconGravity="textStart"
tools:backgroundTint="@color/md_grey_900" />
<com.google.android.material.button.MaterialButton
android:id="@+id/shuffleAction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="4dp"
android:layout_weight="1"
android:padding="10dp"
android:text="@string/shuffle"
android:textAllCaps="false"
app:cornerRadius="6dp"
app:icon="@drawable/ic_shuffle_white_24dp"
app:iconGravity="textStart"
tools:backgroundTint="@color/md_grey_900" />
</LinearLayout>
<code.name.monkey.appthemehelper.common.views.ATEPrimaryTextView
android:id="@+id/biographyTitle"
@ -20,13 +54,13 @@
<code.name.monkey.appthemehelper.common.views.ATEPrimaryTextView
android:id="@+id/biographyText"
style="@style/TextAppearance.MaterialComponents.Body1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="4"
android:lineSpacingExtra="5dp"
android:maxLines="4"
android:padding="16dp"
style="@style/TextAppearance.MaterialComponents.Body1"
android:visibility="gone"
tools:visibility="visible" />

View file

@ -97,14 +97,4 @@
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/actionShuffleAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:text="@string/action_shuffle_all"
app:icon="@drawable/ic_shuffle_white_24dp" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -84,14 +84,5 @@
android:visibility="gone"
tools:visibility="visible" />
</LinearLayout>
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/actionShuffleAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:text="@string/action_shuffle_all"
app:icon="@drawable/ic_shuffle_white_24dp" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</LinearLayout>

View file

@ -25,11 +25,13 @@
android:id="@+id/playAction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:layout_marginStart="4dp"
android:layout_marginEnd="8dp"
android:layout_weight="1"
android:padding="10dp"
android:text="@string/action_play"
android:padding="12dp"
android:textAllCaps="false"
app:cornerRadius="6dp"
app:icon="@drawable/ic_play_arrow_white_24dp"
app:iconGravity="textStart"
tools:backgroundTint="@color/md_grey_900" />
@ -38,11 +40,13 @@
android:id="@+id/shuffleAction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:layout_marginStart="4dp"
android:layout_marginEnd="8dp"
android:layout_weight="1"
android:padding="10dp"
android:text="@string/shuffle"
android:textAllCaps="false"
android:padding="12dp"
app:cornerRadius="6dp"
app:icon="@drawable/ic_shuffle_white_24dp"
app:iconGravity="textStart"
tools:backgroundTint="@color/md_grey_900" />