Fixed incorrect theme

This commit is contained in:
Prathamesh More 2022-01-17 20:11:28 +05:30
parent c7f7f9d695
commit 959235ad02
5 changed files with 10 additions and 14 deletions

View file

@ -46,8 +46,8 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable {
} }
private fun updateTheme() { private fun updateTheme() {
setTheme(ThemeManager.getThemeResValue(this)) setTheme(ThemeManager.getThemeResValue())
setDefaultNightMode(ThemeManager.getNightMode(this)) setDefaultNightMode(ThemeManager.getNightMode())
if (PreferenceUtil.isCustomFont) { if (PreferenceUtil.isCustomFont) {
setTheme(R.style.FontThemeOverlay) setTheme(R.style.FontThemeOverlay)

View file

@ -53,7 +53,7 @@ class RestoreActivity : AppCompatActivity() {
} }
private fun updateTheme() { private fun updateTheme() {
AppCompatDelegate.setDefaultNightMode(ThemeManager.getNightMode(this)) AppCompatDelegate.setDefaultNightMode(ThemeManager.getNightMode())
// Apply dynamic colors to activity if enabled // Apply dynamic colors to activity if enabled
if (PreferenceUtil.materialYou) { if (PreferenceUtil.materialYou) {

View file

@ -79,7 +79,7 @@ object PreferenceUtil {
fun getGeneralThemeValue(isSystemDark: Boolean): ThemeMode { fun getGeneralThemeValue(isSystemDark: Boolean): ThemeMode {
val themeMode: String = val themeMode: String =
sharedPreferences.getStringOrDefault(GENERAL_THEME, "auto") sharedPreferences.getStringOrDefault(GENERAL_THEME, "auto")
return if (isBlackMode && isSystemDark) { return if (isBlackMode && isSystemDark && themeMode != "light") {
ThemeMode.BLACK ThemeMode.BLACK
} else { } else {
if (isBlackMode && themeMode == "dark") { if (isBlackMode && themeMode == "dark") {

View file

@ -1,8 +1,8 @@
package code.name.monkey.retromusic.util.theme package code.name.monkey.retromusic.util.theme
import android.content.Context
import androidx.annotation.StyleRes import androidx.annotation.StyleRes
import androidx.appcompat.app.AppCompatDelegate import androidx.appcompat.app.AppCompatDelegate
import code.name.monkey.retromusic.App
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.extensions.generalThemeValue import code.name.monkey.retromusic.extensions.generalThemeValue
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
@ -11,23 +11,19 @@ import code.name.monkey.retromusic.util.theme.ThemeMode.*
object ThemeManager { object ThemeManager {
@StyleRes @StyleRes
fun getThemeResValue( fun getThemeResValue(): Int =
context: Context
): Int =
if (PreferenceUtil.materialYou) { if (PreferenceUtil.materialYou) {
R.style.Theme_RetroMusic_MD3 R.style.Theme_RetroMusic_MD3
} else { } else {
when (context.generalThemeValue) { when (App.getContext().generalThemeValue) {
LIGHT -> R.style.Theme_RetroMusic_Light LIGHT -> R.style.Theme_RetroMusic_Light
DARK -> R.style.Theme_RetroMusic_Base DARK -> R.style.Theme_RetroMusic_Base
BLACK -> R.style.Theme_RetroMusic_Black BLACK -> R.style.Theme_RetroMusic_Black
AUTO -> R.style.Theme_RetroMusic_FollowSystem AUTO -> R.style.Theme_RetroMusic_FollowSystem
}
} }
}
fun getNightMode( fun getNightMode(): Int = when (App.getContext().generalThemeValue) {
context: Context
): Int = when (context.generalThemeValue) {
LIGHT -> AppCompatDelegate.MODE_NIGHT_NO LIGHT -> AppCompatDelegate.MODE_NIGHT_NO
DARK -> AppCompatDelegate.MODE_NIGHT_YES DARK -> AppCompatDelegate.MODE_NIGHT_YES
BLACK -> { BLACK -> {

View file

@ -35,7 +35,7 @@
<item name="popupMenuBackground">@drawable/popup_background</item> <item name="popupMenuBackground">@drawable/popup_background</item>
</style> </style>
<style name="Theme.RetroMusic.Base" parent="Theme.Material3.DayNight.NoActionBar"> <style name="Theme.RetroMusic.Base" parent="Theme.Material3.Dark.NoActionBar">
<item name="md_background_color">@color/darkColorPrimary</item> <item name="md_background_color">@color/darkColorPrimary</item>
<item name="android:windowActionBarOverlay">true</item> <item name="android:windowActionBarOverlay">true</item>
<item name="android:windowActivityTransitions">true</item> <item name="android:windowActivityTransitions">true</item>