From a715cfcda925c3930233ae37d758b54559c34658 Mon Sep 17 00:00:00 2001 From: Jakob Nixdorf Date: Mon, 14 Jun 2021 21:20:05 +0200 Subject: [PATCH] Don't modify the String set in the preferences directly Fixes #856 --- .../org/shadowice/flocke/andotp/Utilities/Settings.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/Settings.java b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/Settings.java index 0f41d53e..c0298313 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/Settings.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/Settings.java @@ -522,9 +522,12 @@ public class Settings { } public void setTagToggle(String tag, Boolean value) { - Set toggledTags = settings.getStringSet(getResString(R.string.settings_key_tags_toggles), Collections.emptySet()); + Set 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 toggledTags = Collections.emptySet(); + + if (toggledTagsPref != null) + toggledTags = new HashSet<>(toggledTagsPref); if (value) toggledTags.remove(tag); @@ -561,12 +564,10 @@ public class Settings { } - @SuppressWarnings("BooleanMethodIsAlwaysInverted") public boolean getScreenshotsEnabled() { return getBoolean(R.string.settings_key_enable_screenshot, false); } - @SuppressWarnings("BooleanMethodIsAlwaysInverted") public boolean getUsedTokensDialogShown() { return getBoolean(R.string.settings_key_last_used_dialog_shown, false); }