Merge pull request #1296 from prathameshmm02/dev
Fixed Wallpaper theming #1264
This commit is contained in:
commit
1cb97f783b
19 changed files with 165 additions and 30 deletions
|
@ -14,7 +14,7 @@ android {
|
|||
vectorDrawables.useSupportLibrary = true
|
||||
|
||||
applicationId "code.name.monkey.retromusic"
|
||||
versionCode 10568
|
||||
versionCode 10569
|
||||
versionName '5.7.3'
|
||||
|
||||
buildConfigField("String", "GOOGLE_PLAY_LICENSING_KEY", "\"${getProperty(getProperties('../public.properties'), 'GOOGLE_PLAY_LICENSE_KEY')}\"")
|
||||
|
@ -126,7 +126,7 @@ dependencies {
|
|||
def retrofit_version = '2.9.0'
|
||||
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
|
||||
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
|
||||
implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.5'
|
||||
implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.6'
|
||||
|
||||
def material_dialog_version = "3.3.0"
|
||||
implementation "com.afollestad.material-dialogs:core:$material_dialog_version"
|
||||
|
|
|
@ -67,11 +67,13 @@
|
|||
<h2>v5.7.3</h2>
|
||||
<h3>What's New</h3>
|
||||
<ul>
|
||||
<li>Added adaptive color in Material now playing theme</li>
|
||||
<li>Added an option to share crash report</li>
|
||||
<li>Added options to clear, pause history</li>
|
||||
</ul>
|
||||
<h3>Fixed</h3>
|
||||
<ul>
|
||||
<li>Adapt Wallpaper accent for better readability</li>
|
||||
<li>Optimized search</li>
|
||||
<li>Made sleep timer precise</li>
|
||||
</ul>
|
||||
|
|
|
@ -187,7 +187,7 @@ class HomeFragment :
|
|||
}
|
||||
GlideApp.with(requireActivity())
|
||||
.load(RetroGlideExtension.getUserModel())
|
||||
.userProfileOptions(RetroGlideExtension.getUserModel())
|
||||
.userProfileOptions(RetroGlideExtension.getUserModel(), requireContext())
|
||||
.into(binding.userImage)
|
||||
}
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ class UserInfoFragment : Fragment() {
|
|||
}
|
||||
GlideApp.with(this)
|
||||
.load(RetroGlideExtension.getUserModel())
|
||||
.userProfileOptions(RetroGlideExtension.getUserModel())
|
||||
.userProfileOptions(RetroGlideExtension.getUserModel(), requireContext())
|
||||
.into(binding.userImage)
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
*/
|
||||
package code.name.monkey.retromusic.fragments.player.material
|
||||
|
||||
import android.animation.ArgbEvaluator
|
||||
import android.animation.ValueAnimator
|
||||
import android.graphics.drawable.GradientDrawable
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
|
@ -22,12 +25,16 @@ import code.name.monkey.retromusic.R
|
|||
import code.name.monkey.retromusic.databinding.FragmentMaterialBinding
|
||||
import code.name.monkey.retromusic.extensions.colorControlNormal
|
||||
import code.name.monkey.retromusic.extensions.drawAboveSystemBars
|
||||
import code.name.monkey.retromusic.extensions.surfaceColor
|
||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
||||
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
||||
import code.name.monkey.retromusic.fragments.player.normal.PlayerFragment
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.ViewUtil
|
||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||
import code.name.monkey.retromusic.views.DrawableGradient
|
||||
|
||||
/**
|
||||
* @author Hemanth S (h4h13).
|
||||
|
@ -48,6 +55,33 @@ class MaterialFragment : AbsPlayerFragment(R.layout.fragment_material) {
|
|||
private var _binding: FragmentMaterialBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
private var valueAnimator: ValueAnimator? = null
|
||||
|
||||
private fun colorize(i: Int) {
|
||||
if (valueAnimator != null) {
|
||||
valueAnimator?.cancel()
|
||||
}
|
||||
|
||||
valueAnimator = ValueAnimator.ofObject(
|
||||
ArgbEvaluator(),
|
||||
surfaceColor(),
|
||||
i
|
||||
)
|
||||
valueAnimator?.addUpdateListener { animation ->
|
||||
if (isAdded) {
|
||||
val drawable = DrawableGradient(
|
||||
GradientDrawable.Orientation.TOP_BOTTOM,
|
||||
intArrayOf(
|
||||
animation.animatedValue as Int,
|
||||
surfaceColor()
|
||||
), 0
|
||||
)
|
||||
binding.colorGradientBackground.background = drawable
|
||||
}
|
||||
}
|
||||
valueAnimator?.setDuration(ViewUtil.RETRO_MUSIC_ANIM_TIME.toLong())?.start()
|
||||
}
|
||||
|
||||
|
||||
override fun onShow() {
|
||||
playbackControlsFragment.show()
|
||||
|
@ -74,6 +108,10 @@ class MaterialFragment : AbsPlayerFragment(R.layout.fragment_material) {
|
|||
colorControlNormal(),
|
||||
requireActivity()
|
||||
)
|
||||
|
||||
if (PreferenceUtil.isAdaptiveColor) {
|
||||
colorize(color.backgroundColor)
|
||||
}
|
||||
}
|
||||
|
||||
override fun toggleFavorite(song: Song) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package code.name.monkey.retromusic.glide
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.Drawable
|
||||
import code.name.monkey.appthemehelper.ThemeStore.Companion.accentColor
|
||||
import code.name.monkey.appthemehelper.util.TintHelper
|
||||
|
@ -150,10 +151,11 @@ object RetroGlideExtension {
|
|||
@GlideOption
|
||||
fun userProfileOptions(
|
||||
baseRequestOptions: BaseRequestOptions<*>,
|
||||
file: File
|
||||
file: File,
|
||||
context: Context
|
||||
): BaseRequestOptions<*> {
|
||||
return baseRequestOptions.diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
|
||||
.error(getErrorUserProfile())
|
||||
.error(getErrorUserProfile(context))
|
||||
.signature(createSignature(file))
|
||||
}
|
||||
|
||||
|
@ -201,11 +203,11 @@ object RetroGlideExtension {
|
|||
return File(dir, USER_BANNER)
|
||||
}
|
||||
|
||||
private fun getErrorUserProfile(): Drawable {
|
||||
private fun getErrorUserProfile(context: Context): Drawable {
|
||||
return TintHelper.createTintedDrawable(
|
||||
getContext(),
|
||||
R.drawable.ic_account,
|
||||
accentColor(getContext())
|
||||
accentColor(context)
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -43,9 +43,7 @@ class WallpaperAccentManager(val context: Context) {
|
|||
.getWallpaperColors(WallpaperManager.FLAG_SYSTEM)
|
||||
if (colors != null) {
|
||||
val primaryColor = colors.primaryColor.toArgb()
|
||||
if (primaryColor != ThemeStore.wallpaperColor(context)) {
|
||||
ThemeStore.editTheme(context).wallpaperColor(primaryColor).commit()
|
||||
}
|
||||
ThemeStore.editTheme(context).wallpaperColor(context, primaryColor).commit()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,8 +125,14 @@ class PlayingNotificationImpl24(
|
|||
}
|
||||
|
||||
override fun updateMetadata(song: Song, onUpdate: () -> Unit) {
|
||||
setContentTitle(song.title)
|
||||
setContentText(
|
||||
setContentTitle(
|
||||
HtmlCompat.fromHtml(
|
||||
"<b>" + song.title + "</b>",
|
||||
HtmlCompat.FROM_HTML_MODE_LEGACY
|
||||
)
|
||||
)
|
||||
setContentText(song.artistName)
|
||||
setSubText(
|
||||
HtmlCompat.fromHtml(
|
||||
"<b>" + song.albumName + "</b>",
|
||||
HtmlCompat.FROM_HTML_MODE_LEGACY
|
||||
|
@ -169,10 +175,12 @@ class PlayingNotificationImpl24(
|
|||
}
|
||||
|
||||
override fun onLoadCleared(placeholder: Drawable?) {
|
||||
setLargeIcon(BitmapFactory.decodeResource(
|
||||
context.resources,
|
||||
R.drawable.default_audio_art
|
||||
))
|
||||
setLargeIcon(
|
||||
BitmapFactory.decodeResource(
|
||||
context.resources,
|
||||
R.drawable.default_audio_art
|
||||
)
|
||||
)
|
||||
onUpdate()
|
||||
}
|
||||
})
|
||||
|
|
|
@ -14,6 +14,15 @@
|
|||
|
||||
<include layout="@layout/shadow_statusbar_toolbar" />
|
||||
|
||||
<View
|
||||
android:id="@+id/colorGradientBackground"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
|
|
@ -10,6 +10,15 @@
|
|||
|
||||
<include layout="@layout/shadow_statusbar_toolbar" />
|
||||
|
||||
<View
|
||||
android:id="@+id/colorGradientBackground"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/statusBarContainer"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
android:id="@android:id/icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="0dp"
|
||||
android:paddingEnd="16dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:tint="?attr/colorControlNormal"
|
||||
|
@ -53,6 +55,8 @@
|
|||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="2dp"
|
||||
android:paddingStart="0dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:textAppearance="@style/TextViewNormal"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
app:layout_constrainedWidth="true"
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<bool name="wallpaper_accent_enabled">true</bool>
|
||||
<bool name="wallpaper_accent_visible">true</bool>
|
||||
</resources>
|
|
@ -4,6 +4,5 @@
|
|||
<bool name="md3_enabled">true</bool>
|
||||
|
||||
<integer name="overScrollMode">0</integer>
|
||||
<bool name="wallpaper_accent_enabled">false</bool>
|
||||
<bool name="wallpaper_accent_visible">false</bool>
|
||||
</resources>
|
|
@ -211,7 +211,7 @@
|
|||
<style name="SearchChipStyle" parent="Widget.Material3.Chip.Filter">
|
||||
<item name="android:checked">false</item>
|
||||
<item name="android:textSize">16sp</item>
|
||||
<item name="checkedIconEnabled">true</item>
|
||||
<item name="checkedIconVisible">false</item>
|
||||
<item name="chipEndPadding">10dp</item>
|
||||
<item name="chipMinHeight">40dp</item>
|
||||
<item name="chipStartPadding">10dp</item>
|
||||
|
|
|
@ -48,8 +48,7 @@
|
|||
android:key="wallpaper_accent"
|
||||
android:layout="@layout/list_item_view_switch"
|
||||
android:summary="@string/pref_summary_wallpaper_accent"
|
||||
android:title="@string/pref_title_wallpaper_accent"
|
||||
app:isPreferenceVisible="@bool/wallpaper_accent_visible" />
|
||||
android:title="@string/pref_title_wallpaper_accent" />
|
||||
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEColorPreference
|
||||
android:dependency="material_you"
|
||||
|
|
|
@ -59,8 +59,26 @@ private constructor(private val mContext: Context) : ThemeStorePrefKeys, ThemeSt
|
|||
return this
|
||||
}
|
||||
|
||||
override fun wallpaperColor(color: Int): ThemeStore {
|
||||
mEditor.putInt(ThemeStorePrefKeys.KEY_WALLPAPER_COLOR, color)
|
||||
override fun wallpaperColor(context: Context, color: Int): ThemeStore {
|
||||
if (ColorUtil.isColorLight(color)) {
|
||||
mEditor.putInt(ThemeStorePrefKeys.KEY_WALLPAPER_COLOR_DARK, color)
|
||||
mEditor.putInt(
|
||||
ThemeStorePrefKeys.KEY_WALLPAPER_COLOR_LIGHT,
|
||||
ColorUtil.getReadableColorLight(
|
||||
color,
|
||||
Color.WHITE
|
||||
)
|
||||
)
|
||||
} else {
|
||||
mEditor.putInt(ThemeStorePrefKeys.KEY_WALLPAPER_COLOR_LIGHT, color)
|
||||
mEditor.putInt(
|
||||
ThemeStorePrefKeys.KEY_WALLPAPER_COLOR_DARK,
|
||||
ColorUtil.getReadableColorDark(
|
||||
color,
|
||||
Color.parseColor("#202124")
|
||||
)
|
||||
)
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
|
@ -217,7 +235,7 @@ private constructor(private val mContext: Context) : ThemeStorePrefKeys, ThemeSt
|
|||
}
|
||||
val desaturatedColor = prefs(context).getBoolean("desaturated_color", false)
|
||||
val color = if (isWallpaperAccentEnabled(context)) {
|
||||
wallpaperColor(context)
|
||||
wallpaperColor(context, isWindowBackgroundDark(context))
|
||||
} else {
|
||||
prefs(context).getInt(
|
||||
ThemeStorePrefKeys.KEY_ACCENT_COLOR,
|
||||
|
@ -232,9 +250,9 @@ private constructor(private val mContext: Context) : ThemeStorePrefKeys, ThemeSt
|
|||
|
||||
@CheckResult
|
||||
@ColorInt
|
||||
fun wallpaperColor(context: Context): Int {
|
||||
fun wallpaperColor(context: Context, isDarkMode: Boolean): Int {
|
||||
return prefs(context).getInt(
|
||||
ThemeStorePrefKeys.KEY_WALLPAPER_COLOR,
|
||||
if (isDarkMode) ThemeStorePrefKeys.KEY_WALLPAPER_COLOR_DARK else ThemeStorePrefKeys.KEY_WALLPAPER_COLOR_LIGHT,
|
||||
resolveColor(context, R.attr.colorAccent, Color.parseColor("#263238"))
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package code.name.monkey.appthemehelper
|
||||
|
||||
import android.content.Context
|
||||
import androidx.annotation.AttrRes
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.annotation.ColorRes
|
||||
|
@ -34,7 +35,7 @@ internal interface ThemeStoreInterface {
|
|||
|
||||
fun accentColor(@ColorInt color: Int): ThemeStore
|
||||
|
||||
fun wallpaperColor(@ColorInt color: Int): ThemeStore
|
||||
fun wallpaperColor(context: Context, color: Int): ThemeStore
|
||||
|
||||
fun accentColorRes(@ColorRes colorRes: Int): ThemeStore
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ internal interface ThemeStorePrefKeys {
|
|||
const val KEY_AUTO_GENERATE_PRIMARYDARK = "auto_generate_primarydark"
|
||||
|
||||
const val KEY_MATERIAL_YOU = "material_you"
|
||||
const val KEY_WALLPAPER_COLOR = "wallpaper_color"
|
||||
const val KEY_WALLPAPER_COLOR_LIGHT = "wallpaper_color_light"
|
||||
const val KEY_WALLPAPER_COLOR_DARK = "wallpaper_color_dark"
|
||||
}
|
||||
}
|
|
@ -3,7 +3,11 @@ package code.name.monkey.appthemehelper.util
|
|||
import android.graphics.Color
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.annotation.FloatRange
|
||||
import kotlin.math.*
|
||||
import androidx.core.graphics.ColorUtils
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
object ColorUtil {
|
||||
fun desaturateColor(color: Int, ratio: Float): Int {
|
||||
|
@ -44,6 +48,50 @@ object ColorUtil {
|
|||
return shiftColor(color, 1.1f)
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
fun lightenColor(
|
||||
@ColorInt color: Int,
|
||||
value: Float
|
||||
): Int {
|
||||
val hsl = FloatArray(3)
|
||||
ColorUtils.colorToHSL(color, hsl)
|
||||
hsl[2] += value
|
||||
hsl[2] = hsl[2].coerceIn(0f, 1f)
|
||||
return ColorUtils.HSLToColor(hsl)
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
fun darkenColor(
|
||||
@ColorInt color: Int,
|
||||
value: Float
|
||||
): Int {
|
||||
val hsl = FloatArray(3)
|
||||
ColorUtils.colorToHSL(color, hsl)
|
||||
hsl[2] -= value
|
||||
hsl[2] = hsl[2].coerceIn(0f, 1f)
|
||||
return ColorUtils.HSLToColor(hsl)
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
fun getReadableColorLight(@ColorInt color: Int, @ColorInt bgColor: Int): Int {
|
||||
var foregroundColor = color
|
||||
while (ColorUtils.calculateContrast(foregroundColor, bgColor) <= 3.0
|
||||
) {
|
||||
foregroundColor = darkenColor(foregroundColor, 0.1F)
|
||||
}
|
||||
return foregroundColor
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
fun getReadableColorDark(@ColorInt color: Int, @ColorInt bgColor: Int): Int {
|
||||
var foregroundColor = color
|
||||
while (ColorUtils.calculateContrast(foregroundColor, bgColor) <= 3.0
|
||||
) {
|
||||
foregroundColor = lightenColor(foregroundColor, 0.1F)
|
||||
}
|
||||
return foregroundColor
|
||||
}
|
||||
|
||||
fun isColorLight(@ColorInt color: Int): Boolean {
|
||||
val darkness =
|
||||
1 - (0.299 * Color.red(color) + 0.587 * Color.green(color) + 0.114 * Color.blue(color)) / 255
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue