Don't modify the String set in the preferences directly

Fixes #856
This commit is contained in:
Jakob Nixdorf 2021-06-14 21:20:05 +02:00
parent 089825905a
commit a715cfcda9
No known key found for this signature in database
GPG key ID: BE99BF86574A7DBC

View file

@ -522,9 +522,12 @@ public class Settings {
} }
public void setTagToggle(String tag, Boolean value) { public void setTagToggle(String tag, Boolean value) {
Set<String> toggledTags = settings.getStringSet(getResString(R.string.settings_key_tags_toggles), Collections.emptySet()); Set<String> toggledTagsPref = settings.getStringSet(getResString(R.string.settings_key_tags_toggles), Collections.emptySet());
assert toggledTags != null; // At least an empty set should always be present Set<String> toggledTags = Collections.emptySet();
if (toggledTagsPref != null)
toggledTags = new HashSet<>(toggledTagsPref);
if (value) if (value)
toggledTags.remove(tag); toggledTags.remove(tag);
@ -561,12 +564,10 @@ public class Settings {
} }
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public boolean getScreenshotsEnabled() { public boolean getScreenshotsEnabled() {
return getBoolean(R.string.settings_key_enable_screenshot, false); return getBoolean(R.string.settings_key_enable_screenshot, false);
} }
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public boolean getUsedTokensDialogShown() { public boolean getUsedTokensDialogShown() {
return getBoolean(R.string.settings_key_last_used_dialog_shown, false); return getBoolean(R.string.settings_key_last_used_dialog_shown, false);
} }