Change the layout of the entry delete dialog and include more info

This commit is contained in:
Praveen Kumar 2021-11-04 16:59:19 +05:30 committed by Alexander Bakker
parent adfc472a39
commit c0020684de
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))