Skip to content

Commit 0fcaf20

Browse files
committed
Fix settings switches are not red anymore
Reverts part of 731c65c
1 parent c7efa8c commit 0fcaf20

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

app/src/main/java/org/schabi/newpipe/settings/SettingsActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public static void initSettings(final Context context) {
4848

4949
@Override
5050
protected void onCreate(final Bundle savedInstanceBundle) {
51-
ThemeHelper.setTheme(this);
51+
setTheme(ThemeHelper.getSettingsThemeStyle(this));
5252
assureCorrectAppLanguage(this);
5353
super.onCreate(savedInstanceBundle);
5454

app/src/main/java/org/schabi/newpipe/util/ThemeHelper.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,39 @@ public static int getThemeForService(final Context context, final int serviceId)
169169
return baseTheme;
170170
}
171171

172+
@StyleRes
173+
public static int getSettingsThemeStyle(final Context context) {
174+
final Resources res = context.getResources();
175+
final String lightTheme = res.getString(R.string.light_theme_key);
176+
final String blackTheme = res.getString(R.string.black_theme_key);
177+
final String automaticDeviceTheme = res.getString(R.string.auto_device_theme_key);
178+
179+
180+
final String selectedTheme = getSelectedThemeKey(context);
181+
182+
if (selectedTheme.equals(lightTheme)) {
183+
return R.style.LightSettingsTheme;
184+
} else if (selectedTheme.equals(blackTheme)) {
185+
return R.style.BlackSettingsTheme;
186+
} else if (selectedTheme.equals(automaticDeviceTheme)) {
187+
if (isDeviceDarkThemeEnabled(context)) {
188+
// use the dark theme variant preferred by the user
189+
final String selectedNightTheme = getSelectedNightThemeKey(context);
190+
if (selectedNightTheme.equals(blackTheme)) {
191+
return R.style.BlackSettingsTheme;
192+
} else {
193+
return R.style.DarkSettingsTheme;
194+
}
195+
} else {
196+
// there is only one day theme
197+
return R.style.LightSettingsTheme;
198+
}
199+
} else {
200+
// default to dark theme
201+
return R.style.DarkSettingsTheme;
202+
}
203+
}
204+
172205
/**
173206
* Get a resource id from a resource styled according to the context's theme.
174207
*

0 commit comments

Comments
 (0)