feat(theme): add forSystemNightMode helper on AwfulTheme (#534)#807
Open
jim-daf wants to merge 2 commits intoAwful:developfrom
Open
feat(theme): add forSystemNightMode helper on AwfulTheme (#534)#807jim-daf wants to merge 2 commits intoAwful:developfrom
jim-daf wants to merge 2 commits intoAwful:developfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a theme-selection helper to bridge Awful’s forum-aware theming system with Android’s system night mode state, enabling callers to opt into “use dark variant at night” without changing existing call sites yet.
Changes:
- Added
AwfulTheme.forSystemNightMode(Context, AwfulTheme)to map selected light themes to dark counterparts whenuiModereports night. - Documented the intended conservative mapping behavior and rationale in
AwfulTheme.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+150
to
+152
| int mode = context.getResources().getConfiguration().uiMode | ||
| & Configuration.UI_MODE_NIGHT_MASK; | ||
| if (mode != Configuration.UI_MODE_NIGHT_YES) { |
Comment on lines
+144
to
+160
| * 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; |
Comment on lines
+155
to
+159
| switch (lightTheme) { | ||
| case DEFAULT: | ||
| case CLASSIC: | ||
| return DARK; | ||
| case CUSTOM_DEFAULT: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Towards #534.
The issue notes that the existing AppCompat day/night helper does not fit, because Awful's theme system already chooses a forum-aware theme rather than just a parent style. The plumbing the author asked for is "given the current user-selected theme, return the dark variant when the system reports night".
This PR adds exactly that helper on
AwfulTheme. It is conservative, only translates the standardDEFAULTandCUSTOM_DEFAULTlight themes to theirDARKcounterparts, and returns the input theme unchanged for everything else (including custom CSS the user picked deliberately). Activities and the WebView host can call this in a follow-up wherever they currently look upforForum.Wiring the call sites is intentionally a separate change so this PR stays small and reviewable.