Merge pull request #845 from Hacker437/Dialog

Updated Delete Dialog
This commit is contained in:
Alexander Bakker 2022-02-27 18:18:56 +01:00 committed by GitHub
commit 927f5f2bd5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 38 additions and 46 deletions

View file

@ -71,11 +71,8 @@ public class Dialogs {
TextView textMessage = view.findViewById(R.id.text_message);
TextView textExplanation = view.findViewById(R.id.text_explanation);
String entries = services.stream()
.map(entry -> !entry.getIssuer().isEmpty() ? entry.getIssuer()
: !entry.getName().isEmpty() ? entry.getName()
: activity.getString(R.string.unknown_issuer)
)
.collect(Collectors.joining(", "));
.map(entry -> String.format("• %s", getVaultEntryName(activity, entry)))
.collect(Collectors.joining("\n"));
textExplanation.setText(activity.getString(R.string.delete_entry_explanation, entries));
String title, message;
@ -96,6 +93,18 @@ public class Dialogs {
.create());
}
private static String getVaultEntryName(Context context, VaultEntry entry) {
if (!entry.getIssuer().isEmpty() && !entry.getName().isEmpty()) {
return String.format("%s (%s)", entry.getIssuer(), entry.getName());
} else if (entry.getIssuer().isEmpty() && entry.getName().isEmpty()) {
return context.getString(R.string.unknown_issuer);
} else if (entry.getIssuer().isEmpty()) {
return entry.getName();
} else {
return entry.getIssuer();
}
}
public static void showDiscardDialog(Activity activity, DialogInterface.OnClickListener onSave, DialogInterface.OnClickListener onDiscard) {
showSecureDialog(new AlertDialog.Builder(activity)
.setTitle(activity.getString(R.string.discard_changes))