@@ -278,6 +278,7 @@ public void setGroups(Collection<VaultGroup> groups) {
278
278
279
279
private void initializeGroups () {
280
280
_groupChip .removeAllViews ();
281
+ _groupChip .setSingleSelection (!_prefs .isGroupMultiselectEnabled ());
281
282
282
283
for (VaultGroup group : _groups ) {
283
284
addChipTo (_groupChip , new VaultGroupModel (group ));
@@ -317,29 +318,24 @@ private void addChipTo(ChipGroup chipGroup, VaultGroupModel group) {
317
318
}
318
319
319
320
chip .setOnCheckedChangeListener ((group1 , isChecked ) -> {
320
- Set <UUID > groupFilter = new HashSet <>();
321
321
if (_actionMode != null ) {
322
322
_actionMode .finish ();
323
323
}
324
324
325
325
setSaveChipVisibility (true );
326
326
327
- if (!isChecked ) {
328
- group1 .setChecked (false );
327
+ // Reset group filter if last checked group gets unchecked
328
+ if (!isChecked && _groupFilter .size () == 1 ) {
329
+ Set <UUID > groupFilter = new HashSet <>();
330
+
331
+ chipGroup .clearCheck ();
329
332
_groupFilter = groupFilter ;
330
333
_entryListView .setGroupFilter (groupFilter );
331
334
return ;
332
335
}
333
336
334
- Object chipTag = group1 .getTag ();
335
- if (chipTag == GroupPlaceholderType .NO_GROUP ) {
336
- groupFilter .add (null );
337
- } else {
338
- groupFilter = getGroupFilter (chipGroup );
339
- }
340
-
341
- _groupFilter = groupFilter ;
342
- _entryListView .setGroupFilter (groupFilter );
337
+ _groupFilter = getGroupFilter (chipGroup );
338
+ _entryListView .setGroupFilter (_groupFilter );
343
339
});
344
340
345
341
chipGroup .addView (chip );
@@ -372,16 +368,17 @@ private void setSaveChipVisibility(boolean visible) {
372
368
373
369
private static Set <UUID > getGroupFilter (ChipGroup chipGroup ) {
374
370
return chipGroup .getCheckedChipIds ().stream ()
371
+ .filter (Objects ::nonNull )
375
372
.map (i -> {
376
373
Chip chip = chipGroup .findViewById (i );
374
+
377
375
if (chip .getTag () instanceof VaultGroupModel ) {
378
376
VaultGroupModel group = (VaultGroupModel ) chip .getTag ();
379
377
return group .getUUID ();
380
378
}
381
379
382
380
return null ;
383
381
})
384
- .filter (Objects ::nonNull )
385
382
.collect (Collectors .toSet ());
386
383
}
387
384
0 commit comments