1 year ago

#297767

test-img

Rubearen

MODE_NIGHT_FOLLOW_SYSTEM not working after MODE_NIGHT_YES

I have the next code to force dark mode depending the store of the user.

 if (storeProvider.shouldForceDarkMode) {
        appProvider.theme = AppProvider.AppTheme.DARK
        AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
    } else {
        // TODO: Uncomment when Dark Mode is fully implemented.
        appProvider.theme = AppProvider.AppTheme.AUTO
        AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
    }

But when I force dark mode (AppCompatDelegate.MODE_NIGHT_YES) and then switch to follow system, the app style stays dark even tough the phone is Light.

  1. Application started in follow system mode: app is light.

  2. I'm switching to night mode: app style is dark.

  3. I'm switching back to follow system mode: app style still dark.

If I don't kill the app, follow system is not working.

I have seen this was a bug in AppCompat but they marked it fixed in 1.1.0-alpha03 and I'm using 1.2.

https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0-alpha03

android

android-styles

darkmode

android-dark-theme

android-darkmode

0 Answers

Your Answer

Accepted video resources