From 2ffbcd35007d8a067d9dec088b8d7f01f12b15ec Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 9 Feb 2020 19:22:07 +0100 Subject: [PATCH] Added signature failure result code, refactoring --- .../eu/faircode/email/FragmentMessages.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 02a4058087..7df6d30f18 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -4813,8 +4813,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. Log.w("PGP signature result missing"); else Log.i("PGP signature result=" + sresult); + if (sresult == RESULT_NO_SIGNATURE) - Snackbar.make(view, R.string.title_signature_none, Snackbar.LENGTH_LONG).show(); + args.putString("sigresult", context.getString(R.string.title_signature_none)); else if (sresult == RESULT_VALID_KEY_CONFIRMED || sresult == RESULT_VALID_KEY_UNCONFIRMED) { List users = sigResult.getConfirmedUserIds(); String text; @@ -4827,11 +4828,13 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. text = getString(sresult == RESULT_VALID_KEY_UNCONFIRMED ? R.string.title_signature_unconfirmed : R.string.title_signature_valid); - Snackbar.make(view, text, Snackbar.LENGTH_LONG).show(); + args.putString("sigresult", text); } else if (sresult == RESULT_KEY_MISSING) - Snackbar.make(view, R.string.title_signature_key_missing, Snackbar.LENGTH_LONG).show(); - else - Snackbar.make(view, R.string.title_signature_invalid, Snackbar.LENGTH_LONG).show(); + args.putString("sigresult", context.getString(R.string.title_signature_key_missing)); + else { + String text = getString(R.string.title_signature_invalid_reason, Integer.toString(sresult)); + args.putString("sigresult", text); + } break; @@ -4859,6 +4862,11 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. @Override protected void onExecuted(Bundle args, PendingIntent pi) { + if (args.containsKey("sigresult")) { + String text = args.getString("sigresult"); + Snackbar.make(view, text, Snackbar.LENGTH_LONG).show(); + } + if (pi != null) try { Log.i("Executing pi=" + pi);