From 822515623c6affa601d44b024124bfd8cfcccc1c Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 29 May 2019 09:52:14 +0200 Subject: [PATCH] Show PGP signature status --- .../java/eu/faircode/email/ActivityView.java | 16 ++++++++++++++++ app/src/main/res/values/strings.xml | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/app/src/main/java/eu/faircode/email/ActivityView.java b/app/src/main/java/eu/faircode/email/ActivityView.java index e40a0e3408..a36c43acd8 100644 --- a/app/src/main/java/eu/faircode/email/ActivityView.java +++ b/app/src/main/java/eu/faircode/email/ActivityView.java @@ -74,6 +74,7 @@ import com.google.android.material.snackbar.Snackbar; import org.json.JSONArray; import org.json.JSONObject; import org.openintents.openpgp.OpenPgpError; +import org.openintents.openpgp.OpenPgpSignatureResult; import org.openintents.openpgp.util.OpenPgpApi; import org.openintents.openpgp.util.OpenPgpServiceConnection; @@ -100,6 +101,9 @@ import javax.mail.Session; import javax.mail.internet.MimeMessage; import javax.net.ssl.HttpsURLConnection; +import static org.openintents.openpgp.OpenPgpSignatureResult.RESULT_NO_SIGNATURE; +import static org.openintents.openpgp.OpenPgpSignatureResult.RESULT_VALID_KEY_CONFIRMED; + public class ActivityView extends ActivityBilling implements FragmentManager.OnBackStackChangedListener { private String startup; @@ -1445,6 +1449,18 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB } } + // Check signature status + OpenPgpSignatureResult sigResult = result.getParcelableExtra(OpenPgpApi.RESULT_SIGNATURE); + int sresult = (sigResult == null ? RESULT_NO_SIGNATURE : sigResult.getResult()); + int resid; + if (sresult == RESULT_NO_SIGNATURE) + resid = R.string.title_signature_none; + else if (sresult == RESULT_VALID_KEY_CONFIRMED) + resid = R.string.title_signature_valid; + else + resid = R.string.title_signature_invalid; + Snackbar.make(getVisibleView(), resid, Snackbar.LENGTH_LONG).show(); + break; case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index de4ad42c9d..1b4b245dac 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -500,6 +500,10 @@ OpenKeychain not found Message is not encrypted + Message not signed + Message signature valid + Message signature invalid + Search Search in Searching \'%1$s\'