Added destauration accent color
This commit is contained in:
parent
694e78e92e
commit
576201bfd5
5 changed files with 20 additions and 20 deletions
|
@ -45,13 +45,8 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
view.setOnTouchListener(FlingPlayBackController(requireContext()))
|
||||
//view.setOnClickListener(v -> NavigationUtil.gotoNowPlayingActivity(getContext()));
|
||||
setUpMiniPlayer()
|
||||
|
||||
miniPlayerImage.setOnClickListener {
|
||||
//toggleFavorite(MusicPlayerRemote.currentSong)
|
||||
}
|
||||
|
||||
if (RetroUtil.isTablet()) {
|
||||
actionNext.visibility = View.VISIBLE
|
||||
actionPrevious.visibility = View.VISIBLE
|
||||
|
|
|
@ -34,6 +34,14 @@ import code.name.monkey.appthemehelper.util.ColorUtil;
|
|||
import code.name.monkey.retromusic.R;
|
||||
|
||||
public class RetroColorUtil {
|
||||
public static int desaturateColor(int color, float ratio) {
|
||||
float[] hsv = new float[3];
|
||||
Color.colorToHSV(color, hsv);
|
||||
|
||||
hsv[1] = ( hsv[1] / 1 * ratio ) + ( 0.2f * (1.0f - ratio) );
|
||||
|
||||
return Color.HSVToColor(hsv);
|
||||
}
|
||||
public static int toolbarColor(@NonNull Context context) {
|
||||
return ATHUtil.INSTANCE.resolveColor(context, R.attr.colorSurface);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import androidx.appcompat.widget.AppCompatImageView
|
|||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.util.RetroColorUtil
|
||||
|
||||
|
||||
class ColorIconsImageView : AppCompatImageView {
|
||||
|
@ -49,7 +50,7 @@ class ColorIconsImageView : AppCompatImageView {
|
|||
private fun setIconBackgroundColor(color: Int) {
|
||||
setBackgroundResource(R.drawable.color_circle_gradient)
|
||||
if (ATHUtil.isWindowBackgroundDark(context)) {
|
||||
val desaturatedColor = desaturateColor(color, 0.4f)
|
||||
val desaturatedColor = RetroColorUtil.desaturateColor(color, 0.4f)
|
||||
backgroundTintList = ColorStateList.valueOf(desaturatedColor)
|
||||
imageTintList = ColorStateList.valueOf(ATHUtil.resolveColor(context, R.attr.colorPrimary))
|
||||
} else {
|
||||
|
@ -60,12 +61,5 @@ class ColorIconsImageView : AppCompatImageView {
|
|||
invalidate()
|
||||
}
|
||||
|
||||
private fun desaturateColor(color: Int, ratio: Float): Int {
|
||||
val hsv = FloatArray(3)
|
||||
Color.colorToHSV(color, hsv)
|
||||
|
||||
hsv[1] = hsv[1] / 1 * ratio + 0.2f * (1.0f - ratio)
|
||||
|
||||
return Color.HSVToColor(hsv)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,14 +4,9 @@ import android.annotation.SuppressLint
|
|||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.graphics.Color
|
||||
import androidx.annotation.AttrRes
|
||||
import androidx.annotation.CheckResult
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.annotation.ColorRes
|
||||
import androidx.annotation.*
|
||||
import androidx.annotation.IntRange
|
||||
import androidx.annotation.StyleRes
|
||||
import androidx.core.content.ContextCompat
|
||||
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
|
||||
|
@ -211,7 +206,8 @@ private constructor(private val mContext: Context) : ThemeStorePrefKeys, ThemeSt
|
|||
@CheckResult
|
||||
@ColorInt
|
||||
fun accentColor(context: Context): Int {
|
||||
return prefs(context).getInt(ThemeStorePrefKeys.KEY_ACCENT_COLOR, ATHUtil.resolveColor(context, R.attr.colorAccent, Color.parseColor("#263238")))
|
||||
val color = prefs(context).getInt(ThemeStorePrefKeys.KEY_ACCENT_COLOR, ATHUtil.resolveColor(context, R.attr.colorAccent, Color.parseColor("#263238")))
|
||||
return if (ATHUtil.isWindowBackgroundDark(context)) ColorUtil.desaturateColor(color, 0.4f) else color
|
||||
}
|
||||
|
||||
@CheckResult
|
||||
|
|
|
@ -6,7 +6,14 @@ import androidx.annotation.FloatRange
|
|||
|
||||
|
||||
object ColorUtil {
|
||||
fun desaturateColor(color: Int, ratio: Float): Int {
|
||||
val hsv = FloatArray(3)
|
||||
Color.colorToHSV(color, hsv)
|
||||
|
||||
hsv[1] = hsv[1] / 1 * ratio + 0.2f * (1.0f - ratio)
|
||||
|
||||
return Color.HSVToColor(hsv)
|
||||
}
|
||||
fun stripAlpha(@ColorInt color: Int): Int {
|
||||
return -0x1000000 or color
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue