diff --git a/app/src/main/java/eu/faircode/email/ActivityBase.java b/app/src/main/java/eu/faircode/email/ActivityBase.java
index 49a61359a5..4f984abae3 100644
--- a/app/src/main/java/eu/faircode/email/ActivityBase.java
+++ b/app/src/main/java/eu/faircode/email/ActivityBase.java
@@ -51,6 +51,12 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
String theme = prefs.getString("theme", null);
+ if ("system".equals(theme)) {
+ int uiMode = getResources().getConfiguration().uiMode;
+ Log.i("UI mode=" + uiMode);
+ if ((uiMode & Configuration.UI_MODE_NIGHT_YES) != 0)
+ setTheme(R.style.AppThemeDark);
+ }
if ("dark".equals(theme))
setTheme(R.style.AppThemeDark);
else if ("black".equals(theme))
diff --git a/app/src/main/java/eu/faircode/email/ActivitySetup.java b/app/src/main/java/eu/faircode/email/ActivitySetup.java
index 4a70411de9..81034bf6fe 100644
--- a/app/src/main/java/eu/faircode/email/ActivitySetup.java
+++ b/app/src/main/java/eu/faircode/email/ActivitySetup.java
@@ -143,6 +143,7 @@ public class ActivitySetup extends ActivityBilling implements FragmentManager.On
case R.string.title_setup_light_theme:
case R.string.title_setup_dark_theme:
case R.string.title_setup_black_theme:
+ case R.string.title_setup_system_theme:
onMenuTheme(item.getId());
break;
case R.string.title_setup_notifications:
@@ -178,13 +179,15 @@ public class ActivitySetup extends ActivityBilling implements FragmentManager.On
drawerArray.add(new DrawerItem(this, R.layout.item_drawer, R.drawable.baseline_unarchive_24, R.string.title_setup_import));
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
- String theme = prefs.getString("theme", "light");
- if ("dark".equals(theme))
+ String theme = prefs.getString("theme", "system");
+ if ("light".equals(theme))
+ drawerArray.add(new DrawerItem(this, R.layout.item_drawer, R.drawable.baseline_palette_24, R.string.title_setup_dark_theme));
+ else if ("dark".equals(theme))
drawerArray.add(new DrawerItem(this, R.layout.item_drawer, R.drawable.baseline_palette_24, R.string.title_setup_black_theme));
else if ("black".equals(theme))
- drawerArray.add(new DrawerItem(this, R.layout.item_drawer, R.drawable.baseline_palette_24, R.string.title_setup_light_theme));
+ drawerArray.add(new DrawerItem(this, R.layout.item_drawer, R.drawable.baseline_palette_24, R.string.title_setup_system_theme));
else
- drawerArray.add(new DrawerItem(this, R.layout.item_drawer, R.drawable.baseline_palette_24, R.string.title_setup_dark_theme));
+ drawerArray.add(new DrawerItem(this, R.layout.item_drawer, R.drawable.baseline_palette_24, R.string.title_setup_light_theme));
if (getIntentNotifications(this).resolveActivity(pm) != null)
drawerArray.add(new DrawerItem(this, R.layout.item_drawer, R.drawable.baseline_notifications_24, R.string.title_setup_notifications));
@@ -375,6 +378,9 @@ public class ActivitySetup extends ActivityBilling implements FragmentManager.On
case R.string.title_setup_black_theme:
prefs.edit().putString("theme", "black").apply();
break;
+ case R.string.title_setup_system_theme:
+ prefs.edit().putString("theme", "system").apply();
+ break;
}
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 499a012a33..b5ff1c7bc4 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -128,6 +128,7 @@
Light theme
Dark theme
Black theme
+ System theme
Restore defaults
Advanced options