mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-04-26 00:36:11 +00:00
Display export groups selection as dropdown
This commit is contained in:
parent
51698947aa
commit
1c9931b1c8
3 changed files with 36 additions and 42 deletions
|
@ -9,7 +9,6 @@ import android.view.View;
|
|||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -30,6 +29,7 @@ import com.beemdevelopment.aegis.otp.OtpInfo;
|
|||
import com.beemdevelopment.aegis.otp.TotpInfo;
|
||||
import com.beemdevelopment.aegis.ui.ImportEntriesActivity;
|
||||
import com.beemdevelopment.aegis.ui.TransferEntriesActivity;
|
||||
import com.beemdevelopment.aegis.ui.components.DropdownCheckBoxes;
|
||||
import com.beemdevelopment.aegis.ui.dialogs.Dialogs;
|
||||
import com.beemdevelopment.aegis.ui.tasks.ExportTask;
|
||||
import com.beemdevelopment.aegis.ui.tasks.ImportFileTask;
|
||||
|
@ -41,6 +41,7 @@ import com.beemdevelopment.aegis.vault.VaultRepository;
|
|||
import com.beemdevelopment.aegis.vault.VaultRepositoryException;
|
||||
import com.beemdevelopment.aegis.vault.slots.PasswordSlot;
|
||||
import com.beemdevelopment.aegis.vault.slots.SlotException;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
|
@ -162,8 +163,8 @@ public class ImportExportPreferencesFragment extends PreferencesFragment {
|
|||
CheckBox checkBoxEncrypt = view.findViewById(R.id.checkbox_export_encrypt);
|
||||
CheckBox checkBoxAccept = view.findViewById(R.id.checkbox_accept);
|
||||
CheckBox checkBoxExportAllGroups = view.findViewById(R.id.export_selected_groups);
|
||||
LinearLayout groupsSelection = view.findViewById(R.id.select_groups);
|
||||
TextView groupsSelectionDescriptor = view.findViewById(R.id.select_groups_hint);
|
||||
TextInputLayout groupsSelectionLayout = view.findViewById(R.id.group_selection_layout);
|
||||
DropdownCheckBoxes groupsSelection = view.findViewById(R.id.group_selection_dropdown);
|
||||
TextView passwordInfoText = view.findViewById(R.id.text_separate_password);
|
||||
passwordInfoText.setVisibility(checkBoxEncrypt.isChecked() && isBackupPasswordSet ? View.VISIBLE : View.GONE);
|
||||
AutoCompleteTextView dropdown = view.findViewById(R.id.dropdown_export_format);
|
||||
|
@ -179,12 +180,13 @@ public class ImportExportPreferencesFragment extends PreferencesFragment {
|
|||
TreeSet<String> groups = _vaultManager.getVault().getGroups();
|
||||
if (groups.size() > 0) {
|
||||
checkBoxExportAllGroups.setVisibility(View.VISIBLE);
|
||||
for (String group: groups) {
|
||||
CheckBox box = new CheckBox(requireContext());
|
||||
box.setText(group);
|
||||
box.setChecked(false);
|
||||
groupsSelection.addView(box);
|
||||
}
|
||||
|
||||
ArrayList<String> groupsArray = new ArrayList<>();
|
||||
groupsArray.add(getString(R.string.no_group));
|
||||
groupsArray.addAll(groups);
|
||||
|
||||
groupsSelection.setCheckedItemsCountTextRes(R.plurals.export_groups_selected_count);
|
||||
groupsSelection.addItems(groupsArray, false);
|
||||
}
|
||||
|
||||
AlertDialog dialog = new AlertDialog.Builder(requireContext())
|
||||
|
@ -215,8 +217,7 @@ public class ImportExportPreferencesFragment extends PreferencesFragment {
|
|||
|
||||
checkBoxExportAllGroups.setOnCheckedChangeListener((button, isChecked) -> {
|
||||
int visibility = isChecked ? View.GONE : View.VISIBLE;
|
||||
groupsSelection.setVisibility(visibility);
|
||||
groupsSelectionDescriptor.setVisibility(visibility);
|
||||
groupsSelectionLayout.setVisibility(visibility);
|
||||
});
|
||||
|
||||
btnPos.setOnClickListener(v -> {
|
||||
|
@ -303,14 +304,13 @@ public class ImportExportPreferencesFragment extends PreferencesFragment {
|
|||
Dialogs.showSecureDialog(dialog);
|
||||
}
|
||||
|
||||
private Vault.EntryFilter getVaultEntryFilter(LinearLayout view) {
|
||||
private Vault.EntryFilter getVaultEntryFilter(DropdownCheckBoxes dropdownCheckBoxes) {
|
||||
Set<String> groups = new HashSet<>();
|
||||
for (int i=0; i<view.getChildCount(); i++) {
|
||||
CheckBox group = (CheckBox) view.getChildAt(i);
|
||||
if (group.isChecked() && group.getText().toString().equals(getString(R.string.no_group))) {
|
||||
for (String group: dropdownCheckBoxes.getCheckedItems()) {
|
||||
if (group.equals(getString(R.string.no_group))) {
|
||||
groups.add(null);
|
||||
} else if (group.isChecked()) {
|
||||
groups.add(group.getText().toString());
|
||||
} else {
|
||||
groups.add(group);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingTop="10dp">
|
||||
|
@ -76,31 +76,21 @@
|
|||
android:checked="true"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/select_groups_hint"
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/group_selection_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingHorizontal="30dp"
|
||||
android:text="@string/export_choose_groups"
|
||||
android:visibility="gone"/>
|
||||
android:layout_marginStart="25dp"
|
||||
android:layout_marginEnd="25dp"
|
||||
android:layout_marginTop="15dp"
|
||||
android:hint="@string/export_choose_groups"
|
||||
android:visibility="gone"
|
||||
style="?attr/dropdownStyle">
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingHorizontal="20dp">
|
||||
<LinearLayout
|
||||
android:id="@+id/select_groups"
|
||||
<com.beemdevelopment.aegis.ui.components.DropdownCheckBoxes
|
||||
android:id="@+id/group_selection_dropdown"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingHorizontal="20dp"
|
||||
android:visibility="gone">
|
||||
|
||||
<CheckBox
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/no_group"
|
||||
android:checked="false"/>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
app:allow_filtering="false" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
</LinearLayout>
|
||||
|
|
|
@ -108,7 +108,11 @@
|
|||
<string name="export_format_html">Web page (.HTML)</string>
|
||||
<string name="export_format_hint">Export format</string>
|
||||
<string name="export_all_groups">Export all groups</string>
|
||||
<string name="export_choose_groups">Select which groups to export:</string>
|
||||
<string name="export_choose_groups">Select which groups to export</string>
|
||||
<plurals name="export_groups_selected_count">
|
||||
<item quantity="one">%d group selected</item>
|
||||
<item quantity="other">%d groups selected</item>
|
||||
</plurals>
|
||||
<string name="export_no_groups_selected">No groups selected to export</string>
|
||||
<string name="export_html_title" context="The title of an HTML export document">Aegis Authenticator Export</string>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue