From 3af69a5eda010d2d6efaed87b80127c191ff0793 Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Mon, 30 Sep 2024 20:22:57 -0400 Subject: [PATCH 1/3] Have duplicates filtering respect search text options. --- app/src/main/java/dnd/jon/spellbook/SpellFilter.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/dnd/jon/spellbook/SpellFilter.java b/app/src/main/java/dnd/jon/spellbook/SpellFilter.java index 1f15f074..2c39f0ca 100644 --- a/app/src/main/java/dnd/jon/spellbook/SpellFilter.java +++ b/app/src/main/java/dnd/jon/spellbook/SpellFilter.java @@ -211,7 +211,9 @@ protected FilterResults performFiltering(CharSequence constraint) { // I'd rather avoid a second pass, but since linked spells won't necessarily // have the same data, we can't generally know whether we need to filter a spell // as a duplicate on the first pass - if (hideDuplicates) { + final boolean searchTextOnly = isText && !sortFilterStatus.getApplyFiltersToSearch(); + final boolean doDuplicatesFilter = hideDuplicates && !searchTextOnly; + if (doDuplicatesFilter) { final Ruleset rulesetToIgnore = sortFilterStatus.getPrefer2024Duplicates() ? Ruleset.RULES_2014 : Ruleset.RULES_2024; filteredSpellList.removeIf((spell) -> { if (spell.getRuleset() != rulesetToIgnore) { From dd6ca5be9a9d386b3c0ad6e7c52d4141da6e60e9 Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Mon, 30 Sep 2024 20:31:21 -0400 Subject: [PATCH 2/3] Catch any errors that pop up when enabling/disabling the switch. --- .../main/java/dnd/jon/spellbook/SortFilterFragment.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/dnd/jon/spellbook/SortFilterFragment.java b/app/src/main/java/dnd/jon/spellbook/SortFilterFragment.java index e0b46e93..a9b0973f 100644 --- a/app/src/main/java/dnd/jon/spellbook/SortFilterFragment.java +++ b/app/src/main/java/dnd/jon/spellbook/SortFilterFragment.java @@ -217,8 +217,12 @@ private void setupFilterOptions() { filterOptions.filterSearchLayout.optionChooser.setOnCheckedChangeListener((chooser, isChecked) -> sortFilterStatus.setApplyFiltersToSearch(isChecked)); filterOptions.useExpandedLayout.optionChooser.setOnCheckedChangeListener((chooser, isChecked) -> sortFilterStatus.setUseTashasExpandedLists(isChecked)); filterOptions.hideDuplicatesLayout.optionChooser.setOnCheckedChangeListener((chooser, isChecked) -> { - sortFilterStatus.setHideDuplicateSpells(isChecked); - filterOptions.prefer2024Layout.optionChooser.setEnabled(isChecked); + try { + sortFilterStatus.setHideDuplicateSpells(isChecked); + filterOptions.prefer2024Layout.optionChooser.setEnabled(isChecked); + } catch (Exception e) { + e.printStackTrace(); + } }); filterOptions.prefer2024Layout.optionChooser.setOnCheckedChangeListener((chooser, isChecked) -> sortFilterStatus.setPrefer2024Duplicates(isChecked)); From a73b37ffc63608c71ebff72eefe7356f4ce764f6 Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Mon, 30 Sep 2024 20:31:44 -0400 Subject: [PATCH 3/3] Attempt to fix a NPE that showed up in the crash logs. --- app/src/main/java/dnd/jon/spellbook/MainActivity.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/dnd/jon/spellbook/MainActivity.java b/app/src/main/java/dnd/jon/spellbook/MainActivity.java index 60288d0e..55ee769e 100755 --- a/app/src/main/java/dnd/jon/spellbook/MainActivity.java +++ b/app/src/main/java/dnd/jon/spellbook/MainActivity.java @@ -1287,7 +1287,8 @@ private void openSpellWindow(Spell spell) { if (onTablet || spell == null) { return; } final Bundle args = new Bundle(); args.putParcelable(SpellWindowFragment.SPELL_KEY, spell); - args.putBoolean(SpellWindowFragment.USE_EXPANDED_KEY, viewModel.getUseExpanded()); + final boolean useExpanded = viewModel != null && viewModel.getUseExpanded(); + args.putBoolean(SpellWindowFragment.USE_EXPANDED_KEY, useExpanded); final FragmentTransaction transaction = getSupportFragmentManager() .beginTransaction() .setCustomAnimations(anim.right_to_left_enter, anim.identity);