main
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
applicationId "code.name.monkey.retromusic"
versionCode 393
versionName '3.4.800'
versionCode 394
versionName '3.4.850'
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
import android.animation.ValueAnimator
import android.graphics.Color
import android.graphics.drawable.Drawable
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar
import androidx.palette.graphics.Palette
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ColorUtil
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.fragments.base.AbsPlayerFragment
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.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.Song
@ -80,10 +78,7 @@ class ColorFragment : AbsPlayerFragment() {
}
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
): View? {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_color_player, container, false)
}
@ -120,8 +115,10 @@ class ColorFragment : AbsPlayerFragment() {
}
private fun updateSong() {
SongGlideRequest.Builder.from(Glide.with(requireActivity()), MusicPlayerRemote.currentSong)
.checkIgnoreMediaStore(requireContext()).generatePalette(requireContext()).build()
Builder.from(Glide.with(requireActivity()), MusicPlayerRemote.currentSong)
.checkIgnoreMediaStore(requireContext())
.generatePalette(requireContext())
.build()
.into(object : RetroMusicColoredTarget(playerImage) {
override fun onColorReady(color: Int) {
@ -147,25 +144,21 @@ class ColorFragment : AbsPlayerFragment() {
override fun onLoadFailed(e: Exception?, errorDrawable: Drawable?) {
super.onLoadFailed(e, errorDrawable)
val backgroundColor = defaultFooterColor
val textColor = if (ColorUtil.isColorLight(defaultFooterColor)) MaterialValueHelper.getPrimaryTextColor(
context,
true
)
else MaterialValueHelper.getPrimaryTextColor(context, false)
val textColor = if (ColorUtil.isColorLight(defaultFooterColor)) MaterialValueHelper.getPrimaryTextColor(requireContext(), true)
else MaterialValueHelper.getPrimaryTextColor(requireContext(), false)
setColors(backgroundColor, textColor)
}
})
}
private fun setColors(backgroundColor: Int, textColor: Int) {
playbackControlsFragment.setDark(textColor, backgroundColor)
colorGradientBackground?.setBackgroundColor(backgroundColor)
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, textColor, activity)
lastColor = textColor
private fun setColors(backgroundColor: Int, componentsColor: Int) {
this.lastColor = componentsColor
this.backgroundColor = backgroundColor
playbackControlsFragment.setDark(componentsColor, backgroundColor)
colorGradientBackground?.setBackgroundColor(backgroundColor)
playerActivity?.setLightNavigationBar(ColorUtil.isColorLight(backgroundColor))
callbacks?.onPaletteColorChanged()
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, componentsColor, requireActivity())
}
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_weight="0"
android:fontFeatureSettings="onum"
android:padding="4dp"
android:padding="8dp"
android:textColor="?android:attr/textColorSecondary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/menu"

View File

@ -29,16 +29,7 @@ class ATEPreferenceCategory @JvmOverloads constructor(
) : PreferenceCategory(context, attrs, defStyleAttr, defStyleRes) {
override fun onBindViewHolder(holder: PreferenceViewHolder) {
super.onBindViewHolder(holder)
val mTitle = holder.itemView.findViewById<TextView>(android.R.id.title)
mTitle.setTextColor(ThemeStore.accentColor(holder.itemView.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)
val title = holder.itemView.findViewById<TextView>(android.R.id.title)
title.setTextColor(ThemeStore.accentColor(context))
}
}