1
0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2024-11-26 04:52:29 +01:00

Fix settings switches are not red anymore

Reverts part of 731c65cd59
This commit is contained in:
Stypox 2021-03-24 10:16:24 +01:00
parent c7efa8c4f1
commit 0fcaf20221
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
2 changed files with 34 additions and 1 deletions

View File

@ -48,7 +48,7 @@ public class SettingsActivity extends AppCompatActivity
@Override
protected void onCreate(final Bundle savedInstanceBundle) {
ThemeHelper.setTheme(this);
setTheme(ThemeHelper.getSettingsThemeStyle(this));
assureCorrectAppLanguage(this);
super.onCreate(savedInstanceBundle);

View File

@ -169,6 +169,39 @@ public final class ThemeHelper {
return baseTheme;
}
@StyleRes
public static int getSettingsThemeStyle(final Context context) {
final Resources res = context.getResources();
final String lightTheme = res.getString(R.string.light_theme_key);
final String blackTheme = res.getString(R.string.black_theme_key);
final String automaticDeviceTheme = res.getString(R.string.auto_device_theme_key);
final String selectedTheme = getSelectedThemeKey(context);
if (selectedTheme.equals(lightTheme)) {
return R.style.LightSettingsTheme;
} else if (selectedTheme.equals(blackTheme)) {
return R.style.BlackSettingsTheme;
} else if (selectedTheme.equals(automaticDeviceTheme)) {
if (isDeviceDarkThemeEnabled(context)) {
// use the dark theme variant preferred by the user
final String selectedNightTheme = getSelectedNightThemeKey(context);
if (selectedNightTheme.equals(blackTheme)) {
return R.style.BlackSettingsTheme;
} else {
return R.style.DarkSettingsTheme;
}
} else {
// there is only one day theme
return R.style.LightSettingsTheme;
}
} else {
// default to dark theme
return R.style.DarkSettingsTheme;
}
}
/**
* Get a resource id from a resource styled according to the context's theme.
*