Black theme switching possible only when dark or system dark theme is enabled
App dark theme -> Black System dark -> Black
This commit is contained in:
parent
54e6a8fb81
commit
82a19b5462
6 changed files with 32 additions and 18 deletions
|
@ -496,9 +496,11 @@ public final class PreferenceUtil {
|
|||
}
|
||||
|
||||
@NonNull
|
||||
public ThemeMode getGeneralThemeValue() {
|
||||
public ThemeMode getGeneralThemeValue(boolean isSystemDark) {
|
||||
String themeMode = mPreferences.getString(GENERAL_THEME, "dark");
|
||||
if (isBlackMode() && themeMode.equals("dark")) {
|
||||
if (isBlackMode() && isSystemDark) {
|
||||
return ThemeMode.BLACK;
|
||||
} else if (isBlackMode() && themeMode.equals("dark")) {
|
||||
return ThemeMode.BLACK;
|
||||
} else {
|
||||
switch (themeMode) {
|
||||
|
|
|
@ -54,6 +54,7 @@ object ViewUtil {
|
|||
}
|
||||
val colorWithAlpha = ColorUtil.withAlpha(color, 0.25f)
|
||||
progressSlider.haloColor = ColorStateList.valueOf(colorWithAlpha)
|
||||
progressSlider.haloRadius = 0
|
||||
progressSlider.trackColorActive = ColorStateList.valueOf(color)
|
||||
progressSlider.trackColorInactive = ColorStateList.valueOf(colorWithAlpha)
|
||||
}
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package code.name.monkey.retromusic.util.theme
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.Configuration
|
||||
import android.os.PowerManager
|
||||
import androidx.annotation.StyleRes
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.theme.ThemeManager.isSystemDarkModeEnabled
|
||||
import code.name.monkey.retromusic.util.theme.ThemeMode.*
|
||||
|
||||
object ThemeManager {
|
||||
|
@ -27,7 +30,19 @@ object ThemeManager {
|
|||
BLACK -> AppCompatDelegate.MODE_NIGHT_YES
|
||||
AUTO -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
||||
}
|
||||
|
||||
fun isSystemDarkModeEnabled(context: Context): Boolean {
|
||||
val isBatterySaverEnabled =
|
||||
(context.getSystemService(Context.POWER_SERVICE) as PowerManager?)?.isPowerSaveMode
|
||||
?: false
|
||||
val isDarkModeEnabled =
|
||||
(context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES
|
||||
|
||||
return isBatterySaverEnabled or isDarkModeEnabled
|
||||
}
|
||||
}
|
||||
|
||||
val Context.generalThemeValue: ThemeMode
|
||||
get() = PreferenceUtil.getInstance(this).generalThemeValue
|
||||
get() {
|
||||
return PreferenceUtil.getInstance(this).getGeneralThemeValue(isSystemDarkModeEnabled(this))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue