Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions Awful.apk/src/main/java/com/ferg/awfulapp/provider/AwfulTheme.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,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) {
Comment on lines +150 to +152
return lightTheme;
}
switch (lightTheme) {
case DEFAULT:
case CLASSIC:
return DARK;
case CUSTOM_DEFAULT:
Comment on lines +155 to +159
return CUSTOM_DARK;
Comment on lines +144 to +160
default:
return lightTheme;
}
}


/**
* Get a forum's specific theme, if it has one.
*
Expand Down
Loading