Last active
August 20, 2021 13:17
-
-
Save hamzabasrai/692d4c7c7862d4ba771009cca81a644b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onConfigurationChanged(Configuration configuration) { | |
super.onConfigurationChanged(configuration); | |
this.updateDarkMode(configuration); | |
} | |
private void updateDarkMode(Configuration configuration) { | |
// read the new night mode value | |
int currentNightMode = configuration.uiMode & Configuration.UI_MODE_NIGHT_MASK; | |
switch (currentNightMode) { | |
case Configuration.UI_MODE_NIGHT_NO: | |
forceDarkMode(WebSettingsCompat.FORCE_DARK_AUTO); | |
setDarkNavigationBar(); | |
System.out.println("LIGHT THEME"); | |
break; | |
case Configuration.UI_MODE_NIGHT_YES: | |
forceDarkMode(WebSettingsCompat.FORCE_DARK_ON); | |
setLightNavigationBar(); | |
System.out.println("DARK THEME"); | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment