Added new theme for Material You & a toggle

This commit is contained in:
Prathamesh More 2021-09-26 15:59:32 +05:30
parent 289557898e
commit f23b102e41
34 changed files with 243 additions and 123 deletions

View file

@ -613,4 +613,7 @@ object PreferenceUtil {
val crossFadeDuration
get() = sharedPreferences
.getInt(CROSS_FADE_DURATION, 0)
val materialYou
get() = sharedPreferences.getBoolean(MATERIAL_YOU, false)
}

View file

@ -18,6 +18,7 @@ import code.name.monkey.appthemehelper.ThemeStore.Companion.accentColor
import code.name.monkey.appthemehelper.util.ColorUtil.isColorLight
import code.name.monkey.appthemehelper.util.MaterialValueHelper.getPrimaryTextColor
import code.name.monkey.appthemehelper.util.TintHelper
import code.name.monkey.appthemehelper.util.VersionUtils
import code.name.monkey.retromusic.views.PopupBackground
import me.zhanghai.android.fastscroll.FastScroller
import me.zhanghai.android.fastscroll.FastScrollerBuilder
@ -27,13 +28,17 @@ import me.zhanghai.android.fastscroll.R
object ThemedFastScroller {
fun create(view: ViewGroup): FastScroller {
val context = view.context
val color = accentColor(context)
val color = if (PreferenceUtil.materialYou && VersionUtils.hasS()) {
context.getColor(code.name.monkey.retromusic.R.color.m3_accent_color)
} else {
accentColor(context)
}
val textColor = getPrimaryTextColor(context, isColorLight(color))
val fastScrollerBuilder = FastScrollerBuilder(view)
fastScrollerBuilder.useMd2Style()
fastScrollerBuilder.setPopupStyle { popupText ->
PopupStyles.MD2.accept(popupText)
popupText.background = PopupBackground(context)
popupText.background = PopupBackground(context, color)
popupText.setTextColor(textColor)
}

View file

@ -5,6 +5,7 @@ import androidx.annotation.StyleRes
import androidx.appcompat.app.AppCompatDelegate
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.extensions.generalThemeValue
import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.theme.ThemeMode.*
object ThemeManager {
@ -12,11 +13,16 @@ object ThemeManager {
@StyleRes
fun getThemeResValue(
context: Context
): Int = when (context.generalThemeValue) {
LIGHT -> R.style.Theme_RetroMusic_Light
DARK -> R.style.Theme_RetroMusic_Base
BLACK -> R.style.Theme_RetroMusic_Black
AUTO -> R.style.Theme_RetroMusic_FollowSystem
): Int =
if (PreferenceUtil.materialYou) {
R.style.Theme_RetroMusic_MD3
} else {
when (context.generalThemeValue) {
LIGHT -> R.style.Theme_RetroMusic_Light
DARK -> R.style.Theme_RetroMusic_Base
BLACK -> R.style.Theme_RetroMusic_Black
AUTO -> R.style.Theme_RetroMusic_FollowSystem
}
}
fun getNightMode(