diff --git a/k9mail/src/main/java/com/fsck/k9/mailstore/CryptoResultAnnotation.java b/k9mail/src/main/java/com/fsck/k9/mailstore/CryptoResultAnnotation.java
index 177ec6bd6..70615ebf4 100644
--- a/k9mail/src/main/java/com/fsck/k9/mailstore/CryptoResultAnnotation.java
+++ b/k9mail/src/main/java/com/fsck/k9/mailstore/CryptoResultAnnotation.java
@@ -130,6 +130,10 @@ public final class CryptoResultAnnotation {
return openPgpPendingIntent;
}
+ public boolean hasOpenPgpInsecureWarningPendingIntent() {
+ return openPgpInsecureWarningPendingIntent != null;
+ }
+
@Nullable
public PendingIntent getOpenPgpInsecureWarningPendingIntent() {
return openPgpInsecureWarningPendingIntent;
@@ -171,7 +175,6 @@ public final class CryptoResultAnnotation {
return encapsulatedResult;
}
-
public enum CryptoError {
OPENPGP_OK,
OPENPGP_UI_CANCELED,
diff --git a/k9mail/src/main/java/com/fsck/k9/ui/messageview/CryptoInfoDialog.java b/k9mail/src/main/java/com/fsck/k9/ui/messageview/CryptoInfoDialog.java
index a83cf8a6e..41c5be943 100644
--- a/k9mail/src/main/java/com/fsck/k9/ui/messageview/CryptoInfoDialog.java
+++ b/k9mail/src/main/java/com/fsck/k9/ui/messageview/CryptoInfoDialog.java
@@ -28,6 +28,7 @@ import com.fsck.k9.view.ThemeUtils;
public class CryptoInfoDialog extends DialogFragment {
public static final String ARG_DISPLAY_STATUS = "display_status";
+ public static final String ARG_HAS_SECURITY_WARNING = "has_security_warning";
public static final int ICON_ANIM_DELAY = 400;
public static final int ICON_ANIM_DURATION = 350;
@@ -46,11 +47,12 @@ public class CryptoInfoDialog extends DialogFragment {
private TextView bottomText;
- public static CryptoInfoDialog newInstance(MessageCryptoDisplayStatus displayStatus) {
+ public static CryptoInfoDialog newInstance(MessageCryptoDisplayStatus displayStatus, boolean hasSecurityWarning) {
CryptoInfoDialog frag = new CryptoInfoDialog();
Bundle args = new Bundle();
args.putString(ARG_DISPLAY_STATUS, displayStatus.toString());
+ args.putBoolean(ARG_HAS_SECURITY_WARNING, hasSecurityWarning);
frag.setArguments(args);
return frag;
@@ -85,7 +87,19 @@ public class CryptoInfoDialog extends DialogFragment {
dismiss();
}
});
- if (displayStatus.hasAssociatedKey()) {
+ boolean hasSecurityWarning = getArguments().getBoolean(ARG_HAS_SECURITY_WARNING);
+ if (hasSecurityWarning) {
+ b.setNeutralButton(R.string.crypto_info_view_security_warning, new OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ Fragment frag = getTargetFragment();
+ if (! (frag instanceof OnClickShowCryptoKeyListener)) {
+ throw new AssertionError("Displaying activity must implement OnClickShowCryptoKeyListener!");
+ }
+ ((OnClickShowCryptoKeyListener) frag).onClickShowSecurityWarning();
+ }
+ });
+ } else if (displayStatus.hasAssociatedKey()) {
b.setNeutralButton(R.string.crypto_info_view_key, new OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
@@ -190,5 +204,6 @@ public class CryptoInfoDialog extends DialogFragment {
public interface OnClickShowCryptoKeyListener {
void onClickShowCryptoKey();
+ void onClickShowSecurityWarning();
}
}
diff --git a/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageCryptoPresenter.java b/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageCryptoPresenter.java
index 3ee983468..a1e549258 100644
--- a/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageCryptoPresenter.java
+++ b/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageCryptoPresenter.java
@@ -24,6 +24,7 @@ import timber.log.Timber;
public class MessageCryptoPresenter implements OnCryptoClickListener {
public static final int REQUEST_CODE_UNKNOWN_KEY = 123;
+ public static final int REQUEST_CODE_SECURITY_WARNING = 124;
// injected state
@@ -161,7 +162,7 @@ public class MessageCryptoPresenter implements OnCryptoClickListener {
return;
}
Drawable providerIcon = getOpenPgpApiProviderIcon(messageView.getContext());
- boolean showDetailButton = cryptoResultAnnotation.getOpenPgpInsecureWarningPendingIntent() != null;
+ boolean showDetailButton = cryptoResultAnnotation.hasOpenPgpInsecureWarningPendingIntent();
messageView.showMessageCryptoWarning(messageViewInfo, providerIcon, warningStringRes, showDetailButton);
}
@@ -187,19 +188,27 @@ public class MessageCryptoPresenter implements OnCryptoClickListener {
@SuppressWarnings("UnusedParameters") // for consistency with Activity.onActivityResult
public void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (requestCode != REQUEST_CODE_UNKNOWN_KEY) {
+ if (requestCode == REQUEST_CODE_UNKNOWN_KEY) {
+ if (resultCode != Activity.RESULT_OK) {
+ return;
+ }
+
+ messageCryptoMvpView.restartMessageCryptoProcessing();
+ } else if (requestCode == REQUEST_CODE_SECURITY_WARNING) {
+ if (overrideCryptoWarning || resultCode != Activity.RESULT_OK) {
+ return;
+ }
+
+ overrideCryptoWarning = true;
+ messageCryptoMvpView.redisplayMessage();
+ } else {
throw new IllegalStateException("got an activity result that wasn't meant for us. this is a bug!");
}
-
- if (resultCode != Activity.RESULT_OK) {
- return;
- }
-
- messageCryptoMvpView.restartMessageCryptoProcessing();
}
private void displayCryptoInfoDialog(MessageCryptoDisplayStatus displayStatus) {
- messageCryptoMvpView.showCryptoInfoDialog(displayStatus);
+ messageCryptoMvpView.showCryptoInfoDialog(
+ displayStatus, cryptoResultAnnotation.hasOpenPgpInsecureWarningPendingIntent());
}
private void launchPendingIntent(CryptoResultAnnotation cryptoResultAnnotation) {
@@ -240,7 +249,7 @@ public class MessageCryptoPresenter implements OnCryptoClickListener {
PendingIntent pendingIntent = cryptoResultAnnotation.getOpenPgpInsecureWarningPendingIntent();
if (pendingIntent != null) {
messageCryptoMvpView.startPendingIntentForCryptoPresenter(
- pendingIntent.getIntentSender(), null, null, 0, 0, 0);
+ pendingIntent.getIntentSender(), REQUEST_CODE_SECURITY_WARNING, null, 0, 0, 0);
}
} catch (IntentSender.SendIntentException e) {
Timber.e(e, "SendIntentException");
@@ -279,7 +288,7 @@ public class MessageCryptoPresenter implements OnCryptoClickListener {
void startPendingIntentForCryptoPresenter(IntentSender si, Integer requestCode, Intent fillIntent,
int flagsMask, int flagValues, int extraFlags) throws IntentSender.SendIntentException;
- void showCryptoInfoDialog(MessageCryptoDisplayStatus displayStatus);
+ void showCryptoInfoDialog(MessageCryptoDisplayStatus displayStatus, boolean hasSecurityWarning);
void showCryptoConfigDialog();
}
}
diff --git a/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageViewFragment.java b/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageViewFragment.java
index fd88083e7..cf69e17fb 100644
--- a/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageViewFragment.java
+++ b/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageViewFragment.java
@@ -689,8 +689,8 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
}
@Override
- public void showCryptoInfoDialog(MessageCryptoDisplayStatus displayStatus) {
- CryptoInfoDialog dialog = CryptoInfoDialog.newInstance(displayStatus);
+ public void showCryptoInfoDialog(MessageCryptoDisplayStatus displayStatus, boolean hasSecurityWarning) {
+ CryptoInfoDialog dialog = CryptoInfoDialog.newInstance(displayStatus, hasSecurityWarning);
dialog.setTargetFragment(MessageViewFragment.this, 0);
dialog.show(getFragmentManager(), "crypto_info_dialog");
}
@@ -707,6 +707,11 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
}
};
+ @Override
+ public void onClickShowSecurityWarning() {
+ messageCryptoPresenter.onClickShowCryptoWarningDetails();
+ }
+
@Override
public void onClickShowCryptoKey() {
messageCryptoPresenter.onClickShowCryptoKey();
diff --git a/k9mail/src/main/res/values/strings.xml b/k9mail/src/main/res/values/strings.xml
index 6d173542a..dd21aa3af 100644
--- a/k9mail/src/main/res/values/strings.xml
+++ b/k9mail/src/main/res/values/strings.xml
@@ -1194,6 +1194,7 @@ Please submit bug reports, contribute new features and ask questions at
OK
View Signer
+ Details
Unlock
This part was not encrypted, and may be insecure.
Unprotected Attachment