From 62cb97eb3c63518d6fc491b0075fd7a32020b8be Mon Sep 17 00:00:00 2001 From: Dimitris Dafnis <68849116+jim-daf@users.noreply.github.com> Date: Sat, 25 Apr 2026 21:11:32 +0200 Subject: [PATCH 1/2] feat(theme): add forSystemNightMode helper on AwfulTheme Refs #534 --- .../src/main/java/com/ferg/awfulapp/provider/AwfulTheme.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Awful.apk/src/main/java/com/ferg/awfulapp/provider/AwfulTheme.java b/Awful.apk/src/main/java/com/ferg/awfulapp/provider/AwfulTheme.java index bca8d1b9d..5ef4cb9ec 100644 --- a/Awful.apk/src/main/java/com/ferg/awfulapp/provider/AwfulTheme.java +++ b/Awful.apk/src/main/java/com/ferg/awfulapp/provider/AwfulTheme.java @@ -4,6 +4,7 @@ import android.annotation.SuppressLint; import android.content.Context; import android.content.pm.PackageManager; +import android.content.res.Configuration; import android.content.res.Resources; import android.os.Environment; import androidx.annotation.NonNull; From 0b3a3d93137214fdd5e6ae6eac0f99fe9821555c Mon Sep 17 00:00:00 2001 From: Dimitris Dafnis <68849116+jim-daf@users.noreply.github.com> Date: Sat, 25 Apr 2026 21:11:34 +0200 Subject: [PATCH 2/2] feat(theme): add forSystemNightMode helper on AwfulTheme Refs #534 --- .../ferg/awfulapp/provider/AwfulTheme.java | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/Awful.apk/src/main/java/com/ferg/awfulapp/provider/AwfulTheme.java b/Awful.apk/src/main/java/com/ferg/awfulapp/provider/AwfulTheme.java index 5ef4cb9ec..545447310 100644 --- a/Awful.apk/src/main/java/com/ferg/awfulapp/provider/AwfulTheme.java +++ b/Awful.apk/src/main/java/com/ferg/awfulapp/provider/AwfulTheme.java @@ -4,7 +4,6 @@ import android.annotation.SuppressLint; import android.content.Context; import android.content.pm.PackageManager; -import android.content.res.Configuration; import android.content.res.Resources; import android.os.Environment; import androidx.annotation.NonNull; @@ -137,6 +136,34 @@ public static String getCustomThemePath() { } + /** + * Issue #534: pick the night-mode counterpart of the user-selected + * light theme when the system reports it is currently night. + * + * Returns the supplied light theme unchanged when the system is in + * day mode or in the unspecified state. Mapping is conservative, + * only the standard app themes are translated. Custom themes are + * returned as-is so users keep their explicit choice. + */ + @NonNull + public static AwfulTheme forSystemNightMode(@NonNull Context context, @NonNull AwfulTheme lightTheme) { + int mode = context.getResources().getConfiguration().uiMode + & Configuration.UI_MODE_NIGHT_MASK; + if (mode != Configuration.UI_MODE_NIGHT_YES) { + return lightTheme; + } + switch (lightTheme) { + case DEFAULT: + case CLASSIC: + return DARK; + case CUSTOM_DEFAULT: + return CUSTOM_DARK; + default: + return lightTheme; + } + } + + /** * Get a forum's specific theme, if it has one. *