diff --git a/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java b/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java
index ea5e73d52..e91cc5767 100644
--- a/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java
+++ b/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java
@@ -79,7 +79,7 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab
* views are created. */
String theme = preferences.getString(APP_THEME, ThemeUtils.APP_THEME_DEFAULT);
Log.d("activeTheme", theme);
- if (theme.equals("black")) {
+ if (ThemeUtils.isBlack(getResources().getConfiguration(), theme)) {
setTheme(R.style.TuskyBlackTheme);
}
diff --git a/app/src/main/java/com/keylesspalace/tusky/settings/SettingsConstants.kt b/app/src/main/java/com/keylesspalace/tusky/settings/SettingsConstants.kt
index 5b9cfc323..4782601a5 100644
--- a/app/src/main/java/com/keylesspalace/tusky/settings/SettingsConstants.kt
+++ b/app/src/main/java/com/keylesspalace/tusky/settings/SettingsConstants.kt
@@ -5,7 +5,8 @@ enum class AppTheme(val value: String) {
DAY("day"),
BLACK("black"),
AUTO("auto"),
- AUTO_SYSTEM("auto_system");
+ AUTO_SYSTEM("auto_system"),
+ AUTO_SYSTEM_BLACK("auto_system_black");
companion object {
fun stringValues() = values().map { it.value }.toTypedArray()
diff --git a/app/src/main/java/com/keylesspalace/tusky/util/ThemeUtils.kt b/app/src/main/java/com/keylesspalace/tusky/util/ThemeUtils.kt
index 10f8df1a4..ae9847086 100644
--- a/app/src/main/java/com/keylesspalace/tusky/util/ThemeUtils.kt
+++ b/app/src/main/java/com/keylesspalace/tusky/util/ThemeUtils.kt
@@ -17,6 +17,7 @@
package com.keylesspalace.tusky.util
import android.content.Context
+import android.content.res.Configuration
import android.graphics.Color
import android.graphics.PorterDuff
import android.graphics.drawable.Drawable
@@ -35,6 +36,7 @@ const val THEME_DAY = "day"
const val THEME_BLACK = "black"
const val THEME_AUTO = "auto"
const val THEME_SYSTEM = "auto_system"
+const val THEME_SYSTEM_BLACK = "auto_system_black"
const val APP_THEME_DEFAULT = THEME_SYSTEM
fun getDimension(context: Context, @AttrRes attribute: Int): Int {
@@ -59,9 +61,21 @@ fun setAppNightMode(flavor: String?) {
THEME_AUTO -> AppCompatDelegate.setDefaultNightMode(
AppCompatDelegate.MODE_NIGHT_AUTO_TIME
)
- THEME_SYSTEM -> AppCompatDelegate.setDefaultNightMode(
+ THEME_SYSTEM, THEME_SYSTEM_BLACK -> AppCompatDelegate.setDefaultNightMode(
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
)
else -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
}
}
+
+fun isBlack(config: Configuration, theme: String?): Boolean {
+ return when (theme) {
+ THEME_BLACK -> true
+ THEME_SYSTEM_BLACK -> when (config.uiMode and Configuration.UI_MODE_NIGHT_MASK) {
+ Configuration.UI_MODE_NIGHT_NO -> false
+ Configuration.UI_MODE_NIGHT_YES -> true
+ else -> false
+ }
+ else -> false
+ }
+}
diff --git a/app/src/main/res/values/string-arrays.xml b/app/src/main/res/values/string-arrays.xml
index 1f0c46b71..4748a0cbb 100644
--- a/app/src/main/res/values/string-arrays.xml
+++ b/app/src/main/res/values/string-arrays.xml
@@ -7,6 +7,7 @@
- @string/app_theme_black
- @string/app_theme_auto
- @string/app_theme_system
+ - @string/app_theme_system_black
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 25729ae7f..19df7ed8f 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -302,6 +302,7 @@
Black
Automatic at sunset
Use System Design
+ Use System Design (black)
Browser
Use Chrome Custom Tabs