Skip to content

Commit

Permalink
minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
B0pol committed Jun 6, 2020
1 parent 145b6b0 commit ad307f1
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions app/src/main/java/org/schabi/newpipe/util/ThemeHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static boolean isLightThemeSelected(final Context context) {
return selectedThemeString.equals(res.getString(R.string.light_theme_key))
|| (selectedThemeString.equals(res.getString(R.string.device_dark_theme_key))
|| selectedThemeString.equals(res.getString(R.string.device_black_theme_key))
&& !getDeviceTheme(context));
&& !isDeviceDarkThemeEnabled(context));
}


Expand Down Expand Up @@ -148,16 +148,14 @@ public static int getThemeForService(final Context context, final int serviceId)
defaultTheme = R.style.LightTheme;
} else if (selectedTheme.equals(blackTheme)) {
defaultTheme = R.style.BlackTheme;
} else if (selectedTheme.equals(darkTheme)) {
defaultTheme = R.style.DarkTheme;
} else if (selectedTheme.equals(deviceDarkTheme)) {
if (getDeviceTheme(context)) {
if (isDeviceDarkThemeEnabled(context)) {
defaultTheme = R.style.DarkTheme;
} else {
defaultTheme = R.style.LightTheme;
}
} else if (selectedTheme.equals(deviceBlackTheme)) {
if (getDeviceTheme(context)) {
if (isDeviceDarkThemeEnabled(context)) {
defaultTheme = R.style.BlackTheme;
} else {
defaultTheme = R.style.LightTheme;
Expand Down Expand Up @@ -214,13 +212,13 @@ public static int getSettingsThemeStyle(final Context context) {
} else if (selectedTheme.equals(darkTheme)) {
return R.style.DarkSettingsTheme;
} else if (selectedTheme.equals(deviceDarkTheme)) {
if (getDeviceTheme(context)) {
if (isDeviceDarkThemeEnabled(context)) {
return R.style.DarkSettingsTheme;
} else {
return R.style.LightSettingsTheme;
}
} else if (selectedTheme.equals(deviceBlackTheme)) {
if (getDeviceTheme(context)) {
if (isDeviceDarkThemeEnabled(context)) {
return R.style.BlackSettingsTheme;
} else {
return R.style.LightSettingsTheme;
Expand Down Expand Up @@ -280,7 +278,7 @@ private static String getSelectedThemeString(final Context context) {
* @param context the context to use
* @return true: dark theme, false: light or unknown
*/
private static boolean getDeviceTheme(final Context context) {
private static boolean isDeviceDarkThemeEnabled(final Context context) {
int deviceTheme = context.getResources().getConfiguration().uiMode
& Configuration.UI_MODE_NIGHT_MASK;
switch (deviceTheme) {
Expand Down

0 comments on commit ad307f1

Please sign in to comment.