mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-14 05:52:52 +00:00
Minor fixes for group chips, remove remnants of filter menu item
This commit is contained in:
parent
40fbe39474
commit
778000aa24
33 changed files with 44 additions and 112 deletions
|
@ -116,8 +116,6 @@ public class EditEntryActivity extends AegisActivity {
|
|||
setTitle(R.string.add_new_entry);
|
||||
}
|
||||
|
||||
String selectedGroup = intent.getStringExtra("selectedGroup");
|
||||
|
||||
// set up fields
|
||||
_iconView = findViewById(R.id.profile_drawable);
|
||||
_kropView = findViewById(R.id.krop_view);
|
||||
|
@ -211,7 +209,6 @@ public class EditEntryActivity extends AegisActivity {
|
|||
// automatically open advanced settings since 'Secret' is required.
|
||||
if (_isNew) {
|
||||
openAdvancedSettings();
|
||||
setGroup(selectedGroup);
|
||||
}
|
||||
|
||||
_dropdownGroup.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
|
@ -221,13 +218,12 @@ public class EditEntryActivity extends AegisActivity {
|
|||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (position == _dropdownGroupList.size() - 1) {
|
||||
Dialogs.showTextInputDialog(EditEntryActivity.this, R.string.set_group, R.string.group_name_hint, text -> {
|
||||
String str = new String(text);
|
||||
if (str.isEmpty()) {
|
||||
return;
|
||||
String groupName = new String(text);
|
||||
if (!groupName.isEmpty()) {
|
||||
_groups.add(groupName);
|
||||
updateGroupDropdownList();
|
||||
_dropdownGroup.setText(groupName, false);
|
||||
}
|
||||
_groups.add(str);
|
||||
updateGroupDropdownList();
|
||||
_dropdownGroup.setText(_dropdownGroupList.get(position), false);
|
||||
});
|
||||
_dropdownGroup.setText(_dropdownGroupList.get(prevPosition), false);
|
||||
} else {
|
||||
|
|
|
@ -249,7 +249,6 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
|||
} else {
|
||||
intent.putExtra("entryUUID", entry.getUUID());
|
||||
}
|
||||
intent.putExtra("selectedGroup", (ArrayList<String>) _selectedGroups);
|
||||
startActivityForResult(intent, requestCode);
|
||||
}
|
||||
|
||||
|
@ -326,11 +325,6 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
|||
_menu.findItem(category.getMenuItem()).setChecked(true);
|
||||
}
|
||||
|
||||
private void setGroupFilter(List<String> group) {
|
||||
_selectedGroups = group;
|
||||
_entryListView.setGroupFilter(group, true);
|
||||
}
|
||||
|
||||
private void onDoIntroResult() {
|
||||
_vault = _app.getVaultManager();
|
||||
loadEntries();
|
||||
|
@ -460,10 +454,8 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
|||
if (_app.isVaultLocked()) {
|
||||
startAuthActivity(false);
|
||||
} else if (_loaded) {
|
||||
// update the list of groups in the filter menu
|
||||
if (_menu != null) {
|
||||
_entryListView.setGroups(_vault.getGroups());
|
||||
}
|
||||
// update the list of groups in the entry list view so that the chip gets updated
|
||||
_entryListView.setGroups(_vault.getGroups());
|
||||
|
||||
// refresh all codes to prevent showing old ones
|
||||
_entryListView.refresh(false);
|
||||
|
@ -485,8 +477,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
|||
_entryListView.setSearchFilter(null);
|
||||
|
||||
collapseSearchView();
|
||||
setTitle("Aegis");
|
||||
setGroupFilter(_selectedGroups);
|
||||
setTitle(R.string.app_name);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -566,16 +557,6 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
|||
_app.lock(true);
|
||||
return true;
|
||||
default:
|
||||
/*if (item.getGroupId() == R.id.action_filter_group) {
|
||||
item.setChecked(true);
|
||||
|
||||
String group = null;
|
||||
if (item.getItemId() != R.id.menu_filter_all) {
|
||||
group = item.getTitle().toString();
|
||||
}
|
||||
setGroupFilter(group);
|
||||
}*/
|
||||
|
||||
if (item.getGroupId() == R.id.action_sort_category) {
|
||||
item.setChecked(true);
|
||||
|
||||
|
|
|
@ -237,7 +237,7 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
|
|||
}
|
||||
|
||||
public void setGroupFilter(List<String> groups, boolean apply) {
|
||||
if(groups == null) {
|
||||
if (groups == null) {
|
||||
groups = new ArrayList<>();
|
||||
}
|
||||
|
||||
|
|
|
@ -86,6 +86,7 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
|
|||
View view = inflater.inflate(R.layout.fragment_entry_list_view, container, false);
|
||||
_progressBar = view.findViewById(R.id.progressBar);
|
||||
_groupChip = view.findViewById(R.id.chip_group);
|
||||
initializeGroupChip();
|
||||
|
||||
// set up the recycler view
|
||||
_recyclerView = view.findViewById(R.id.rvKeyProfiles);
|
||||
|
@ -141,8 +142,9 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
|
|||
super.onDestroyView();
|
||||
}
|
||||
|
||||
public void setGroupFilter(List<String> group, boolean apply) {
|
||||
_adapter.setGroupFilter(group, apply);
|
||||
public void setGroupFilter(List<String> groups, boolean apply) {
|
||||
_groupFilter = groups;
|
||||
_adapter.setGroupFilter(groups, apply);
|
||||
_touchCallback.setIsLongPressDragEnabled(_adapter.isDragAndDropAllowed());
|
||||
|
||||
if (apply) {
|
||||
|
@ -285,6 +287,7 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
|
|||
|
||||
public void addEntry(VaultEntry entry) {
|
||||
addEntry(entry, false);
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
|
@ -352,44 +355,11 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
|
|||
}
|
||||
|
||||
private void initializeGroupChip() {
|
||||
if (_groups.isEmpty()) {
|
||||
_groupChip.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
|
||||
View view = getLayoutInflater().inflate(R.layout.dialog_select_groups, null);
|
||||
BottomSheetDialog dialog = new BottomSheetDialog(getContext());
|
||||
dialog.setContentView(view);
|
||||
|
||||
ColorStateList colorStateList = ContextCompat.getColorStateList(getContext(), R.color.bg_chip_text_color);
|
||||
|
||||
ChipGroup chipGroup = view.findViewById(R.id.groupChipGroup);
|
||||
String groupChipText = _groupChip.getText().toString();
|
||||
chipGroup.removeAllViews();
|
||||
for (String group : _groups) {
|
||||
Chip chip = new Chip(getContext());
|
||||
chip.setText(group);
|
||||
chip.setCheckable(true);
|
||||
chip.setCheckedIconVisible(false);
|
||||
chip.setChipBackgroundColorResource(R.color.bg_chip_color);
|
||||
chip.setTextColor(colorStateList);
|
||||
chip.setOnCheckedChangeListener((group1, checkedId) -> {
|
||||
List<String> groupFilter = chipGroup.getCheckedChipIds().stream()
|
||||
.map(i -> ((Chip) view.findViewById(i)).getText().toString())
|
||||
.collect(Collectors.toList());
|
||||
_groupFilter = groupFilter;
|
||||
setGroupFilter(groupFilter, true);
|
||||
|
||||
if (_groupFilter.isEmpty()) {
|
||||
_groupChip.setText(groupChipText);
|
||||
} else {
|
||||
_groupChip.setText(String.format("%s (%d)", getString(R.string.groups), _groupFilter.size()));
|
||||
}
|
||||
});
|
||||
|
||||
chipGroup.addView(chip);
|
||||
}
|
||||
|
||||
Button clearButton = view.findViewById(R.id.btnClear);
|
||||
clearButton.setOnClickListener(v -> {
|
||||
chipGroup.clearCheck();
|
||||
|
@ -398,6 +368,33 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
|
|||
});
|
||||
|
||||
_groupChip.setOnClickListener(v -> {
|
||||
ColorStateList colorStateList = ContextCompat.getColorStateList(getContext(), R.color.bg_chip_text_color);
|
||||
chipGroup.removeAllViews();
|
||||
|
||||
for (String group : _groups) {
|
||||
Chip chip = new Chip(getContext());
|
||||
chip.setText(group);
|
||||
chip.setCheckable(true);
|
||||
chip.setChecked(_groupFilter != null && _groupFilter.contains(group));
|
||||
chip.setCheckedIconVisible(false);
|
||||
chip.setChipBackgroundColorResource(R.color.bg_chip_color);
|
||||
chip.setTextColor(colorStateList);
|
||||
chip.setOnCheckedChangeListener((group1, checkedId) -> {
|
||||
List<String> groupFilter = chipGroup.getCheckedChipIds().stream()
|
||||
.map(i -> ((Chip) view.findViewById(i)).getText().toString())
|
||||
.collect(Collectors.toList());
|
||||
setGroupFilter(groupFilter, true);
|
||||
|
||||
if (groupFilter.isEmpty()) {
|
||||
_groupChip.setText(R.string.groups);
|
||||
} else {
|
||||
_groupChip.setText(String.format("%s (%d)", getString(R.string.groups), groupFilter.size()));
|
||||
}
|
||||
});
|
||||
|
||||
chipGroup.addView(chip);
|
||||
}
|
||||
|
||||
Dialogs.showSecureDialog(dialog);
|
||||
});
|
||||
}
|
||||
|
@ -409,7 +406,7 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
|
|||
|
||||
public void setGroups(TreeSet<String> groups) {
|
||||
_groups = groups;
|
||||
initializeGroupChip();
|
||||
_groupChip.setVisibility(_groups.isEmpty() ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
|
||||
private void updateDividerDecoration() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue