[android] prevent crash when user has set theme to system default

on an API level that does not support it.
This commit is contained in:
Torsten Grote
2019-11-05 14:57:25 -03:00
parent 383367f0c8
commit 21eaab3259

View File

@@ -218,11 +218,17 @@ public class SettingsFragment extends PreferenceFragmentCompat
});
if (SDK_INT < 27) {
// remove System Default Theme option
// remove System Default Theme option from preference entries
// as it is not functional on this API anyway
List<CharSequence> entries =
new ArrayList<>(Arrays.asList(theme.getEntries()));
entries.remove(getString(R.string.pref_theme_system));
theme.setEntries(entries.toArray(new CharSequence[0]));
// also remove corresponding value
List<CharSequence> values =
new ArrayList<>(Arrays.asList(theme.getEntryValues()));
values.remove(getString(R.string.pref_theme_system_value));
theme.setEntryValues(values.toArray(new CharSequence[0]));
}
if (IS_DEBUG_BUILD) {
findPreference("pref_key_explode").setOnPreferenceClickListener(