import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
+import android.content.res.Configuration;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
public Theme getSelectedTheme() {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(appContext);
- final String theme = prefs.getString(appContext.getString(R.string.themeKey), "themeLight");
+ final String theme = prefs.getString(appContext.getString(R.string.themeKey), "themeSystem");
if (theme.equals("themeLight")) {
return Theme.LIGHT;
+ } else if (theme.equals("themeSystem")) {
+ int mode = (appContext.getResources().getConfiguration().uiMode &
+ Configuration.UI_MODE_NIGHT_MASK);
+ return ((mode == Configuration.UI_MODE_NIGHT_NO) ?
+ Theme.LIGHT:
+ Theme.DEFAULT);
} else {
return Theme.DEFAULT;
}