Skip to content

Commit a2f2d56

Browse files
committed
Disabling night theme selection if auto theme is not used
1 parent aad5e26 commit a2f2d56

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@ public void onCreatePreferences(final Bundle savedInstanceState, final String ro
4444
return false;
4545
});
4646
} else {
47-
removePreference(nightThemeKey);
47+
// disable the night theme selection
48+
final Preference preference = findPreference(nightThemeKey);
49+
if (preference != null) {
50+
preference.setEnabled(false);
51+
preference.setSummary(getString(R.string.night_theme_available));
52+
}
4853
}
4954
}
5055

@@ -61,13 +66,6 @@ public boolean onPreferenceTreeClick(final Preference preference) {
6166
return super.onPreferenceTreeClick(preference);
6267
}
6368

64-
private void removePreference(final String preferenceKey) {
65-
final Preference preference = findPreference(preferenceKey);
66-
if (preference != null) {
67-
getPreferenceScreen().removePreference(preference);
68-
}
69-
}
70-
7169
private void applyThemeChange(final String beginningThemeKey,
7270
final String themeKey,
7371
final Object newValue) {

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,7 @@
714714
<string name="auto_device_theme_title">Automatic (device theme)</string>
715715
<string name="night_theme_summary">Select your favorite night theme — %s</string>
716716
<string name="select_night_theme_toast">You can select your favorite night theme below</string>
717+
<string name="night_theme_available">This option is only available if Automatic (Device Theme) is selected for Theme</string>
717718
<string name="download_has_started">Download has started</string>
718719
<string name="description_select_note">You can now select text inside the description. Note that the page may flicker and links may not be clickable while in selection mode.</string>
719720
<string name="description_select_enable">Enable selecting text in the description</string>

0 commit comments

Comments
 (0)