This commit is contained in:
h4h13 2019-12-15 11:04:47 +05:30
parent eabfebe0c8
commit a08d896121
5 changed files with 19 additions and 44 deletions

View file

@ -13,8 +13,8 @@ android {
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true
applicationId "code.name.monkey.retromusic" applicationId "code.name.monkey.retromusic"
versionCode 393 versionCode 394
versionName '3.4.800' versionName '3.4.850'
multiDexEnabled true multiDexEnabled true

File diff suppressed because one or more lines are too long

View file

@ -1,14 +1,12 @@
package code.name.monkey.retromusic.fragments.player.color package code.name.monkey.retromusic.fragments.player.color
import android.animation.ValueAnimator import android.animation.ValueAnimator
import android.graphics.Color
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import androidx.palette.graphics.Palette
import code.name.monkey.appthemehelper.util.ATHUtil import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ColorUtil import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.appthemehelper.util.MaterialValueHelper
@ -16,7 +14,7 @@ import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
import code.name.monkey.retromusic.glide.SongGlideRequest import code.name.monkey.retromusic.glide.SongGlideRequest.Builder
import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
@ -80,10 +78,7 @@ class ColorFragment : AbsPlayerFragment() {
} }
} }
override fun onCreateView( override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_color_player, container, false) return inflater.inflate(R.layout.fragment_color_player, container, false)
} }
@ -120,8 +115,10 @@ class ColorFragment : AbsPlayerFragment() {
} }
private fun updateSong() { private fun updateSong() {
SongGlideRequest.Builder.from(Glide.with(requireActivity()), MusicPlayerRemote.currentSong) Builder.from(Glide.with(requireActivity()), MusicPlayerRemote.currentSong)
.checkIgnoreMediaStore(requireContext()).generatePalette(requireContext()).build() .checkIgnoreMediaStore(requireContext())
.generatePalette(requireContext())
.build()
.into(object : RetroMusicColoredTarget(playerImage) { .into(object : RetroMusicColoredTarget(playerImage) {
override fun onColorReady(color: Int) { override fun onColorReady(color: Int) {
@ -147,25 +144,21 @@ class ColorFragment : AbsPlayerFragment() {
override fun onLoadFailed(e: Exception?, errorDrawable: Drawable?) { override fun onLoadFailed(e: Exception?, errorDrawable: Drawable?) {
super.onLoadFailed(e, errorDrawable) super.onLoadFailed(e, errorDrawable)
val backgroundColor = defaultFooterColor val backgroundColor = defaultFooterColor
val textColor = if (ColorUtil.isColorLight(defaultFooterColor)) MaterialValueHelper.getPrimaryTextColor( val textColor = if (ColorUtil.isColorLight(defaultFooterColor)) MaterialValueHelper.getPrimaryTextColor(requireContext(), true)
context, else MaterialValueHelper.getPrimaryTextColor(requireContext(), false)
true
)
else MaterialValueHelper.getPrimaryTextColor(context, false)
setColors(backgroundColor, textColor) setColors(backgroundColor, textColor)
} }
}) })
} }
private fun setColors(backgroundColor: Int, textColor: Int) { private fun setColors(backgroundColor: Int, componentsColor: Int) {
playbackControlsFragment.setDark(textColor, backgroundColor) this.lastColor = componentsColor
colorGradientBackground?.setBackgroundColor(backgroundColor)
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, textColor, activity)
lastColor = textColor
this.backgroundColor = backgroundColor this.backgroundColor = backgroundColor
playbackControlsFragment.setDark(componentsColor, backgroundColor)
colorGradientBackground?.setBackgroundColor(backgroundColor)
playerActivity?.setLightNavigationBar(ColorUtil.isColorLight(backgroundColor)) playerActivity?.setLightNavigationBar(ColorUtil.isColorLight(backgroundColor))
callbacks?.onPaletteColorChanged() callbacks?.onPaletteColorChanged()
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, componentsColor, requireActivity())
} }
companion object { companion object {
@ -177,12 +170,3 @@ class ColorFragment : AbsPlayerFragment() {
} }
} }
} }
fun Palette.getColor(): Int {
return when {
darkMutedSwatch != null -> darkMutedSwatch!!.rgb
mutedSwatch != null -> mutedSwatch!!.rgb
lightMutedSwatch != null -> lightMutedSwatch!!.rgb
else -> Palette.Swatch(Color.BLACK, 1).rgb
}
}

View file

@ -54,7 +54,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0" android:layout_weight="0"
android:fontFeatureSettings="onum" android:fontFeatureSettings="onum"
android:padding="4dp" android:padding="8dp"
android:textColor="?android:attr/textColorSecondary" android:textColor="?android:attr/textColorSecondary"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/menu" app:layout_constraintEnd_toStartOf="@+id/menu"

View file

@ -29,16 +29,7 @@ class ATEPreferenceCategory @JvmOverloads constructor(
) : PreferenceCategory(context, attrs, defStyleAttr, defStyleRes) { ) : PreferenceCategory(context, attrs, defStyleAttr, defStyleRes) {
override fun onBindViewHolder(holder: PreferenceViewHolder) { override fun onBindViewHolder(holder: PreferenceViewHolder) {
super.onBindViewHolder(holder) super.onBindViewHolder(holder)
val mTitle = holder.itemView.findViewById<TextView>(android.R.id.title) val title = holder.itemView.findViewById<TextView>(android.R.id.title)
mTitle.setTextColor(ThemeStore.accentColor(holder.itemView.context)) title.setTextColor(ThemeStore.accentColor(context))
/*mTitle.textSize = dip2px(context, 4f)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
mTitle.setTextAppearance(R.style.TextAppearance_MaterialComponents_Overline)
}*/
}
fun dip2px(context: Context, dpVale: Float): Float {
val scale = context.resources.displayMetrics.density
return (dpVale * scale + 0.5f)
} }
} }