diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/de/pixart/messenger/crypto/PgpEngine.java | 18 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ConversationFragment.java | 2 | ||||
-rw-r--r-- | src/main/res/values/strings.xml | 1 |
3 files changed, 16 insertions, 5 deletions
diff --git a/src/main/java/de/pixart/messenger/crypto/PgpEngine.java b/src/main/java/de/pixart/messenger/crypto/PgpEngine.java index 3be5ceb23..7fb474429 100644 --- a/src/main/java/de/pixart/messenger/crypto/PgpEngine.java +++ b/src/main/java/de/pixart/messenger/crypto/PgpEngine.java @@ -2,6 +2,7 @@ package de.pixart.messenger.crypto; import android.app.PendingIntent; import android.content.Intent; +import android.support.annotation.StringRes; import android.util.Log; import org.openintents.openpgp.OpenPgpError; @@ -39,7 +40,8 @@ public class PgpEngine { private static void logError(Account account, OpenPgpError error) { if (error != null) { - Log.d(Config.LOGTAG, account.getJid().asBareJid().toString() + ": OpenKeychain error '" + error.getMessage() + "' code=" + error.getErrorId()); + error.describeContents(); + Log.d(Config.LOGTAG, account.getJid().asBareJid().toString() + ": OpenKeychain error '" + error.getMessage() + "' code=" + error.getErrorId() + " class=" + error.getClass().getName()); } else { Log.d(Config.LOGTAG, account.getJid().asBareJid().toString() + ": OpenKeychain error with no message"); } @@ -93,8 +95,16 @@ public class PgpEngine { callback.userInputRequried(result.getParcelableExtra(OpenPgpApi.RESULT_INTENT), message); break; case OpenPgpApi.RESULT_CODE_ERROR: - logError(conversation.getAccount(), result.getParcelableExtra(OpenPgpApi.RESULT_ERROR)); - callback.error(R.string.openpgp_error, message); + OpenPgpError error = result.getParcelableExtra(OpenPgpApi.RESULT_ERROR); + String errorMessage = error != null ? error.getMessage() : null; + @StringRes final int res; + if (errorMessage != null && errorMessage.startsWith("Bad key for encryption")) { + res = R.string.bad_key_for_encryption; + } else { + res = R.string.openpgp_error; + } + logError(conversation.getAccount(), error); + callback.error(res, message); break; } }); @@ -173,7 +183,7 @@ public class PgpEngine { case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: return 0; case OpenPgpApi.RESULT_CODE_ERROR: - logError(account, (OpenPgpError) result.getParcelableExtra(OpenPgpApi.RESULT_ERROR)); + logError(account, result.getParcelableExtra(OpenPgpApi.RESULT_ERROR)); return 0; } return 0; diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index 7edc309c9..be4ca8af4 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -2802,7 +2802,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke public void error(final int error, Message message) { getActivity().runOnUiThread(() -> { doneSendingPgpMessage(); - Toast.makeText(getActivity(), R.string.unable_to_connect_to_keychain, Toast.LENGTH_SHORT).show(); + Toast.makeText(getActivity(), error == 0 ? R.string.unable_to_connect_to_keychain : error, Toast.LENGTH_SHORT).show(); }); } diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 34c227331..ef6cddbfb 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -835,5 +835,6 @@ <string name="cancelled">cancelled</string> <string name="remote_server_timeout">Remote server timeout</string> <string name="already_drafting_message">You are already drafting a message.</string> + <string name="bad_key_for_encryption">Bad key for encryption.</string> </resources> |