Fix color in Album and Artist list

This commit is contained in:
Hemanth S 2020-05-09 19:11:20 +05:30
parent 2d3ad54ab5
commit 2f42ce1638
4 changed files with 17 additions and 37 deletions

View file

@ -8,8 +8,6 @@ import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
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.adapter.base.AbsMultiSelectAdapter
import code.name.monkey.retromusic.adapter.base.MediaEntryViewHolder
@ -83,23 +81,13 @@ open class AlbumAdapter(
loadAlbumCover(album, holder)
}
protected open fun setColors(color: Int, holder: ViewHolder) {
protected open fun setColors(color: MediaNotificationProcessor, holder: ViewHolder) {
if (holder.paletteColorContainer != null) {
holder.title?.setTextColor(
MaterialValueHelper.getPrimaryTextColor(
activity,
ColorUtil.isColorLight(color)
)
)
holder.text?.setTextColor(
MaterialValueHelper.getSecondaryTextColor(
activity,
ColorUtil.isColorLight(color)
)
)
holder.paletteColorContainer?.setBackgroundColor(color)
holder.title?.setTextColor(color.primaryTextColor)
holder.text?.setTextColor(color.secondaryTextColor)
holder.paletteColorContainer?.setBackgroundColor(color.backgroundColor)
}
holder.mask?.backgroundTintList = ColorStateList.valueOf(color)
holder.mask?.backgroundTintList = ColorStateList.valueOf(color.primaryTextColor)
}
protected open fun loadAlbumCover(album: Album, holder: ViewHolder) {
@ -118,7 +106,7 @@ open class AlbumAdapter(
}
override fun onColorReady(colors: MediaNotificationProcessor) {
setColors(colors.backgroundColor, holder)
setColors(colors, holder)
}
})
}

View file

@ -28,7 +28,7 @@ class HorizontalAlbumAdapter(
return ViewHolder(view)
}
override fun setColors(color: Int, holder: ViewHolder) {
fun setColors(color: Int, holder: ViewHolder) {
holder.title?.setTextColor(ATHUtil.resolveColor(activity, android.R.attr.textColorPrimary))
holder.text?.setTextColor(ATHUtil.resolveColor(activity, android.R.attr.textColorSecondary))
}
@ -46,7 +46,7 @@ class HorizontalAlbumAdapter(
}
override fun onColorReady(colors: MediaNotificationProcessor) {
setColors(colors.backgroundColor,holder)
setColors(colors, holder)
}
})
}

View file

@ -8,8 +8,6 @@ import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
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.adapter.base.AbsMultiSelectAdapter
import code.name.monkey.retromusic.adapter.base.MediaEntryViewHolder
@ -67,19 +65,13 @@ class ArtistAdapter(
loadArtistImage(artist, holder)
}
fun setColors(color: Int, holder: ViewHolder) {
fun setColors(processor: MediaNotificationProcessor, holder: ViewHolder) {
if (holder.paletteColorContainer != null) {
holder.paletteColorContainer?.setBackgroundColor(color)
holder.title?.setTextColor(
MaterialValueHelper.getPrimaryTextColor(
activity, ColorUtil.isColorLight(
color
)
)
)
holder.paletteColorContainer?.setBackgroundColor(processor.backgroundColor)
holder.title?.setTextColor(processor.primaryTextColor)
}
holder.imageContainerCard?.setCardBackgroundColor(color)
holder.mask?.backgroundTintList = ColorStateList.valueOf(color)
holder.imageContainerCard?.setCardBackgroundColor(processor.backgroundColor)
holder.mask?.backgroundTintList = ColorStateList.valueOf(processor.backgroundColor)
}
private fun loadArtistImage(artist: Artist, holder: ViewHolder) {
@ -92,11 +84,11 @@ class ArtistAdapter(
.into(object : RetroMusicColoredTarget(holder.image!!) {
override fun onLoadCleared(placeholder: Drawable?) {
super.onLoadCleared(placeholder)
setColors(defaultFooterColor, holder)
//setColors(defaultFooterColor, holder)
}
override fun onColorReady(colors: MediaNotificationProcessor) {
setColors(colors.backgroundColor,holder)
setColors(colors, holder)
}
})
}

View file

@ -74,7 +74,7 @@ public class PlaylistsUtil {
}
} catch (SecurityException e) {
e.printStackTrace();
Toast.makeText(context, "Don't have permission for adding to playlist", Toast.LENGTH_SHORT).show();
Toast.makeText(context, "Unable to add music to playlist due to Android 10 limitations", Toast.LENGTH_SHORT).show();
}
}
if (id == -1) {
@ -140,7 +140,7 @@ public class PlaylistsUtil {
}
} catch (SecurityException ignored) {
ignored.printStackTrace();
Toast.makeText(context, "Don't have permission for adding to playlist", Toast.LENGTH_SHORT).show();
Toast.makeText(context, "Unable to add music to playlist due to Android 10 limitations", Toast.LENGTH_SHORT).show();
}
}