mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-04-21 14:29:13 +00:00
Show some additional warning info in the entry deletion dialog
Close #565.
This commit is contained in:
parent
68436fba9c
commit
22c93bf5c6
5 changed files with 38 additions and 20 deletions
|
@ -10,6 +10,7 @@ import android.content.res.ColorStateList;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.text.method.PasswordTransformationMethod;
|
import android.text.method.PasswordTransformationMethod;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -28,6 +29,7 @@ import android.widget.TextView;
|
||||||
import androidx.activity.ComponentActivity;
|
import androidx.activity.ComponentActivity;
|
||||||
import androidx.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import androidx.core.text.HtmlCompat;
|
||||||
|
|
||||||
import com.beemdevelopment.aegis.Preferences;
|
import com.beemdevelopment.aegis.Preferences;
|
||||||
import com.beemdevelopment.aegis.R;
|
import com.beemdevelopment.aegis.R;
|
||||||
|
@ -64,28 +66,25 @@ public class Dialogs {
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showDeleteEntryDialog(Activity activity, DialogInterface.OnClickListener onDelete) {
|
public static void showDeleteEntriesDialog(Activity activity, List<String> services, DialogInterface.OnClickListener onDelete) {
|
||||||
showSecureDialog(new AlertDialog.Builder(activity)
|
View view = activity.getLayoutInflater().inflate(R.layout.dialog_delete_entry, null);
|
||||||
.setTitle(activity.getString(R.string.delete_entry))
|
TextView textMessage = view.findViewById(R.id.text_message);
|
||||||
.setMessage(activity.getString(R.string.delete_entry_description))
|
TextView textExplanation = view.findViewById(R.id.text_explanation);
|
||||||
.setPositiveButton(android.R.string.yes, onDelete)
|
textExplanation.setText(HtmlCompat.fromHtml(activity.getString(R.string.delete_entry_explanation, TextUtils.join(", ", services)), HtmlCompat.FROM_HTML_MODE_COMPACT));
|
||||||
.setNegativeButton(android.R.string.no, null)
|
|
||||||
.create());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void showDeleteEntriesDialog(Activity activity, DialogInterface.OnClickListener onDelete, int totalEntries) {
|
|
||||||
String title, message;
|
String title, message;
|
||||||
if (totalEntries > 1) {
|
if (services.size() > 1) {
|
||||||
title = activity.getString(R.string.delete_entries);
|
title = activity.getString(R.string.delete_entries);
|
||||||
message = activity.getResources().getQuantityString(R.plurals.delete_entries_description, totalEntries, totalEntries);
|
message = activity.getResources().getQuantityString(R.plurals.delete_entries_description, services.size(), services.size());
|
||||||
} else {
|
} else {
|
||||||
title = activity.getString(R.string.delete_entry);
|
title = activity.getString(R.string.delete_entry);
|
||||||
message = activity.getString(R.string.delete_entry_description);
|
message = activity.getString(R.string.delete_entry_description);
|
||||||
}
|
}
|
||||||
|
textMessage.setText(message);
|
||||||
|
|
||||||
showSecureDialog(new AlertDialog.Builder(activity)
|
showSecureDialog(new AlertDialog.Builder(activity)
|
||||||
.setTitle(title)
|
.setTitle(title)
|
||||||
.setMessage(message)
|
.setView(view)
|
||||||
.setPositiveButton(android.R.string.yes, onDelete)
|
.setPositiveButton(android.R.string.yes, onDelete)
|
||||||
.setNegativeButton(android.R.string.no, null)
|
.setNegativeButton(android.R.string.no, null)
|
||||||
.create());
|
.create());
|
||||||
|
|
|
@ -30,8 +30,8 @@ import com.avito.android.krop.KropView;
|
||||||
import com.beemdevelopment.aegis.R;
|
import com.beemdevelopment.aegis.R;
|
||||||
import com.beemdevelopment.aegis.encoding.Base32;
|
import com.beemdevelopment.aegis.encoding.Base32;
|
||||||
import com.beemdevelopment.aegis.encoding.EncodingException;
|
import com.beemdevelopment.aegis.encoding.EncodingException;
|
||||||
import com.beemdevelopment.aegis.helpers.EditTextHelper;
|
|
||||||
import com.beemdevelopment.aegis.helpers.DropdownHelper;
|
import com.beemdevelopment.aegis.helpers.DropdownHelper;
|
||||||
|
import com.beemdevelopment.aegis.helpers.EditTextHelper;
|
||||||
import com.beemdevelopment.aegis.helpers.TextDrawableHelper;
|
import com.beemdevelopment.aegis.helpers.TextDrawableHelper;
|
||||||
import com.beemdevelopment.aegis.otp.GoogleAuthInfo;
|
import com.beemdevelopment.aegis.otp.GoogleAuthInfo;
|
||||||
import com.beemdevelopment.aegis.otp.HotpInfo;
|
import com.beemdevelopment.aegis.otp.HotpInfo;
|
||||||
|
@ -51,6 +51,7 @@ import com.google.android.material.textfield.TextInputLayout;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -345,7 +346,7 @@ public class EditEntryActivity extends AegisActivity {
|
||||||
onSave();
|
onSave();
|
||||||
break;
|
break;
|
||||||
case R.id.action_delete:
|
case R.id.action_delete:
|
||||||
Dialogs.showDeleteEntryDialog(this, (dialog, which) -> {
|
Dialogs.showDeleteEntriesDialog(this, Collections.singletonList(_origEntry.getIssuer()), (dialog, which) -> {
|
||||||
deleteAndFinish(_origEntry);
|
deleteAndFinish(_origEntry);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -13,7 +13,6 @@ import android.provider.Settings;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.SubMenu;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
@ -41,8 +40,6 @@ import com.beemdevelopment.aegis.vault.VaultManager;
|
||||||
import com.beemdevelopment.aegis.vault.VaultManagerException;
|
import com.beemdevelopment.aegis.vault.VaultManagerException;
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
import com.google.android.material.chip.Chip;
|
|
||||||
import com.google.android.material.chip.ChipGroup;
|
|
||||||
import com.google.zxing.BinaryBitmap;
|
import com.google.zxing.BinaryBitmap;
|
||||||
import com.google.zxing.ChecksumException;
|
import com.google.zxing.ChecksumException;
|
||||||
import com.google.zxing.FormatException;
|
import com.google.zxing.FormatException;
|
||||||
|
@ -58,7 +55,6 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.TreeSet;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -777,7 +773,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case R.id.action_delete:
|
case R.id.action_delete:
|
||||||
Dialogs.showDeleteEntriesDialog(MainActivity.this, (d, which) -> {
|
Dialogs.showDeleteEntriesDialog(MainActivity.this, _selectedEntries.stream().map(VaultEntry::getIssuer).collect(Collectors.toList()), (d, which) -> {
|
||||||
deleteEntries(_selectedEntries);
|
deleteEntries(_selectedEntries);
|
||||||
|
|
||||||
for (VaultEntry entry : _selectedEntries) {
|
for (VaultEntry entry : _selectedEntries) {
|
||||||
|
@ -789,7 +785,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
||||||
}
|
}
|
||||||
|
|
||||||
mode.finish();
|
mode.finish();
|
||||||
}, _selectedEntries.size());
|
});
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
|
21
app/src/main/res/layout/dialog_delete_entry.xml
Normal file
21
app/src/main/res/layout/dialog_delete_entry.xml
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingStart="25dp"
|
||||||
|
android:paddingBottom="10dp"
|
||||||
|
android:paddingEnd="25dp"
|
||||||
|
android:paddingTop="10dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text_message"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="16sp"/>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text_explanation"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:textSize="16sp"/>
|
||||||
|
</LinearLayout>
|
|
@ -150,6 +150,7 @@
|
||||||
<string name="exporting_vault">Exporting the vault</string>
|
<string name="exporting_vault">Exporting the vault</string>
|
||||||
<string name="delete_entry">Delete entry</string>
|
<string name="delete_entry">Delete entry</string>
|
||||||
<string name="delete_entry_description">Are you sure you want to delete this entry?</string>
|
<string name="delete_entry_description">Are you sure you want to delete this entry?</string>
|
||||||
|
<string name="delete_entry_explanation">This action does not disable 2FA for <b>%s</b>. To prevent losing access, make sure that you have disabled 2FA or that you have an alternative way to generate codes for this service.</string>
|
||||||
<string name="delete_entries">Delete entries</string>
|
<string name="delete_entries">Delete entries</string>
|
||||||
<plurals name="delete_entries_description">
|
<plurals name="delete_entries_description">
|
||||||
<item quantity="one">Are you sure you want to delete %d entry?</item>
|
<item quantity="one">Are you sure you want to delete %d entry?</item>
|
||||||
|
|
Loading…
Add table
Reference in a new issue