Fixed default night mode on Android 10

This commit is contained in:
Sylvain Berfini 2019-09-27 11:59:08 +02:00
parent 4a8c391e00
commit 8e4c2ceaef

View file

@ -22,6 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import android.Manifest; import android.Manifest;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.res.Configuration;
import androidx.appcompat.app.AppCompatDelegate; import androidx.appcompat.app.AppCompatDelegate;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
@ -1175,12 +1176,19 @@ public class LinphonePreferences {
public boolean isDarkModeEnabled() { public boolean isDarkModeEnabled() {
if (getConfig() == null) return false; if (getConfig() == null) return false;
return getConfig()
.getBool( boolean useNightModeDefault =
"app", AppCompatDelegate.getDefaultNightMode() == AppCompatDelegate.MODE_NIGHT_YES;
"dark_mode", if (mContext != null) {
AppCompatDelegate.getDefaultNightMode() int nightMode =
== AppCompatDelegate.MODE_NIGHT_YES); mContext.getResources().getConfiguration().uiMode
& Configuration.UI_MODE_NIGHT_MASK;
if (nightMode == Configuration.UI_MODE_NIGHT_YES) {
useNightModeDefault = true;
}
}
return getConfig().getBool("app", "dark_mode", useNightModeDefault);
} }
public void enableDarkMode(boolean enable) { public void enableDarkMode(boolean enable) {