messageview: add canceled CryptoError state

Conflicts:
	k9mail/src/main/java/com/fsck/k9/ui/crypto/MessageCryptoHelper.java
	k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageTopView.java
This commit is contained in:
Vincent Breitmoser 2016-05-24 10:09:22 +02:00
parent b57ef10e90
commit b0b269a736
2 changed files with 14 additions and 4 deletions

View file

@ -68,6 +68,10 @@ public final class CryptoResultAnnotation {
return new CryptoResultAnnotation(error, replacementData, null, null, null, null);
}
public static CryptoResultAnnotation createOpenPgpCanceledAnnotation() {
return new CryptoResultAnnotation(CryptoError.OPENPGP_UI_CANCELED, null, null, null, null, null);
}
public static CryptoResultAnnotation createOpenPgpErrorAnnotation(OpenPgpError error) {
return new CryptoResultAnnotation(CryptoError.OPENPGP_API_RETURNED_ERROR, null, null, null, null, error);
}
@ -131,6 +135,7 @@ public final class CryptoResultAnnotation {
public enum CryptoError {
NONE,
OPENPGP_UI_CANCELED,
OPENPGP_API_RETURNED_ERROR,
SIGNED_BUT_INCOMPLETE,
ENCRYPTED_BUT_INCOMPLETE,

View file

@ -20,7 +20,6 @@ import android.util.Log;
import com.fsck.k9.Account;
import com.fsck.k9.K9;
import com.fsck.k9.R;
import com.fsck.k9.crypto.MessageDecryptVerifier;
import com.fsck.k9.mail.Body;
import com.fsck.k9.mail.BodyPart;
@ -440,7 +439,7 @@ public class MessageCryptoHelper {
Log.w(K9.LOG_TAG, "OpenPGP API error: " + error.getMessage());
}
onCryptoFailed(error);
onCryptoOperationFailed(error);
}
private void handleCryptoOperationSuccess(MimeBodyPart outputPart) {
@ -465,7 +464,7 @@ public class MessageCryptoHelper {
userInteractionResultIntent = data;
decryptOrVerifyNextPart();
} else {
onCryptoFailed(new OpenPgpError(OpenPgpError.CLIENT_SIDE_ERROR, context.getString(R.string.openpgp_canceled_by_user)));
onCryptoOperationCanceled();
}
}
@ -485,7 +484,13 @@ public class MessageCryptoHelper {
}
}
private void onCryptoFailed(OpenPgpError error) {
private void onCryptoOperationCanceled() {
CryptoResultAnnotation errorPart = CryptoResultAnnotation.createOpenPgpCanceledAnnotation();
addCryptoResultAnnotationToMessage(errorPart);
onCryptoFinished();
}
private void onCryptoOperationFailed(OpenPgpError error) {
CryptoResultAnnotation errorPart = CryptoResultAnnotation.createOpenPgpErrorAnnotation(error);
addCryptoResultAnnotationToMessage(errorPart);
onCryptoFinished();