messageview: show crypto status icon in header

This commit is contained in:
Vincent Breitmoser 2016-05-23 16:15:33 +02:00
parent 8f568867a6
commit d92155e2b5
28 changed files with 813 additions and 16 deletions

View file

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:sketch="http://www.bohemiancoding.com/sketch/ns"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="150"
height="100"
viewBox="0 0 149.99999 99.999998"
id="svg3344"
version="1.1"
inkscape:version="0.48.5 r10040"
sodipodi:docname="status_check_dots_2.svg">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1056"
id="namedview11"
showgrid="false"
inkscape:zoom="2.18"
inkscape:cx="86.926606"
inkscape:cy="24.311927"
inkscape:window-x="0"
inkscape:window-y="24"
inkscape:window-maximized="0"
inkscape:current-layer="layer1" />
<defs
id="defs3346" />
<metadata
id="metadata3349">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
transform="translate(-17.144857,-22.362199)">
<circle
style="opacity:1;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="circle4219"
cx="138.57143"
cy="106.8622"
r="13" />
<g
transform="translate(14.034697,25.362197)"
style="fill:none;stroke:none"
id="Page-1-3"
sketch:type="MSPage">
<g
style="fill:#000000"
id="signature-verified-cutout"
sketch:type="MSArtboardGroup"
transform="translate(0.110156,0)">
<path
inkscape:connector-curvature="0"
d="M 50,97 C 75.957383,97 97,75.957383 97,50 97,24.042617 75.957383,3 50,3 24.042617,3 3,24.042617 3,50 3,75.957383 24.042617,97 50,97 z M 46.273291,77.5085 20,57.830916 27.91844,47.63497 43.309686,59.515226 70.31112,23 80.867825,30.778219 46.273291,77.5085 z"
sketch:type="MSShapeGroup"
id="path12-3" />
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

View file

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:sketch="http://www.bohemiancoding.com/sketch/ns"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="150"
height="100"
viewBox="0 0 149.99999 99.999998"
id="svg3344"
version="1.1"
inkscape:version="0.48.5 r10040"
sodipodi:docname="status_check_dots_2.svg">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1056"
id="namedview11"
showgrid="false"
inkscape:zoom="2.18"
inkscape:cx="86.926606"
inkscape:cy="24.311927"
inkscape:window-x="0"
inkscape:window-y="24"
inkscape:window-maximized="0"
inkscape:current-layer="layer1" />
<defs
id="defs3346" />
<metadata
id="metadata3349">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
transform="translate(-17.144857,-22.362199)">
<circle
style="opacity:1;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="circle4219"
cx="138.57143"
cy="106.8622"
r="13" />
<circle
r="13"
cy="72.362198"
cx="138.57143"
id="circle4741"
style="opacity:1;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<g
transform="translate(14.034697,25.362197)"
style="fill:none;stroke:none"
id="Page-1-3"
sketch:type="MSPage">
<g
style="fill:#000000"
id="signature-verified-cutout"
sketch:type="MSArtboardGroup"
transform="translate(0.110156,0)">
<path
inkscape:connector-curvature="0"
d="M 50,97 C 75.957383,97 97,75.957383 97,50 97,24.042617 75.957383,3 50,3 24.042617,3 3,24.042617 3,50 3,75.957383 24.042617,97 50,97 z M 46.273291,77.5085 20,57.830916 27.91844,47.63497 43.309686,59.515226 70.31112,23 80.867825,30.778219 46.273291,77.5085 z"
sketch:type="MSShapeGroup"
id="path12-3" />
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.9 KiB

View file

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:sketch="http://www.bohemiancoding.com/sketch/ns"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="150"
height="100"
viewBox="0 0 149.99999 99.999998"
id="svg3344"
version="1.1"
inkscape:version="0.48.5 r10040"
sodipodi:docname="status_check_dots_3.svg">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1056"
id="namedview12"
showgrid="false"
inkscape:zoom="2.18"
inkscape:cx="75"
inkscape:cy="50"
inkscape:window-x="0"
inkscape:window-y="24"
inkscape:window-maximized="0"
inkscape:current-layer="Page-1-3" />
<defs
id="defs3346" />
<metadata
id="metadata3349">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
transform="translate(-17.144857,-22.362199)">
<circle
style="opacity:1;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="circle4219"
cx="138.57143"
cy="106.8622"
r="13"
d="m 151.57143,106.8622 c 0,7.1797 -5.8203,13 -13,13 -7.17971,0 -13,-5.8203 -13,-13 0,-7.179704 5.82029,-13.000002 13,-13.000002 7.1797,0 13,5.820298 13,13.000002 z" />
<circle
r="13"
cy="72.362198"
cx="138.57143"
id="circle4741"
style="opacity:1;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
d="m 151.57143,72.362198 c 0,7.179702 -5.8203,13 -13,13 -7.17971,0 -13,-5.820298 -13,-13 0,-7.179702 5.82029,-13 13,-13 7.1797,0 13,5.820298 13,13 z" />
<circle
style="opacity:1;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="circle4743"
cx="138.57143"
cy="37.862198"
r="13"
d="m 151.57143,37.862198 c 0,7.179702 -5.8203,13 -13,13 -7.17971,0 -13,-5.820298 -13,-13 0,-7.179702 5.82029,-13 13,-13 7.1797,0 13,5.820298 13,13 z" />
</g>
<g
transform="translate(-13.412913,81.651374)"
style="fill:none;stroke:none"
id="Page-1-3"
sketch:type="MSPage">
<g
style="fill:#000000"
id="signature-verified-cutout"
sketch:type="MSArtboardGroup"
transform="translate(10.412909,-78.651376)">
<path
inkscape:connector-curvature="0"
d="M 50,97 C 75.957383,97 97,75.957383 97,50 97,24.042617 75.957383,3 50,3 24.042617,3 3,24.042617 3,50 3,75.957383 24.042617,97 50,97 z M 46.273291,77.5085 20,57.830916 27.91844,47.63497 43.309686,59.515226 70.31112,23 80.867825,30.778219 46.273291,77.5085 z"
sketch:type="MSShapeGroup"
id="path12-3" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.6 KiB

View file

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:sketch="http://www.bohemiancoding.com/sketch/ns"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="150"
height="100"
viewBox="0 0 149.99999 99.999998"
id="svg3344"
version="1.1"
inkscape:version="0.48.5 r10040"
sodipodi:docname="status_lock_dots_1.svg">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1056"
id="namedview11"
showgrid="false"
inkscape:zoom="2.18"
inkscape:cx="75"
inkscape:cy="50"
inkscape:window-x="0"
inkscape:window-y="24"
inkscape:window-maximized="0"
inkscape:current-layer="layer1" />
<defs
id="defs3346" />
<metadata
id="metadata3349">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
transform="translate(-17.144857,-22.362199)">
<circle
style="opacity:1;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="circle4219"
cx="138.57143"
cy="106.8622"
r="13"
d="m 151.57143,106.8622 c 0,7.1797 -5.8203,13 -13,13 -7.17971,0 -13,-5.8203 -13,-13 0,-7.179704 5.82029,-13.000002 13,-13.000002 7.1797,0 13,5.820298 13,13.000002 z" />
<g
id="Page-1"
sketch:type="MSPage"
style="fill:none;fill-rule:evenodd;stroke:none;stroke-width:1"
transform="translate(17.144849,22.526199)">
<g
id="lock-closed"
sketch:type="MSArtboardGroup"
style="fill:#000000">
<path
d="m 81.502,45.132 -1.925,0 0,-15.653 C 79.479,10.285 66.387,-0.164 50.476,-0.164 34.57,-0.164 20.304,10.782 20.801,29.479 l -0.016,15.633 c 0,0 0.24,0.021 -0.96,0.021 -1.27,0 -9.64,1.473 -9.64,8.936 l 0,35.824 c 0,7.959 9.42,9.943 9.64,9.943 l 61.202,0 c 0.22,0 9.154,-0.993 9.154,-9.943 l 0,-35.329 c 0.001,-8.455 -8.454,-9.432 -8.679,-9.432 z m -47.241,0 0.016,-15.446 c 0,-9.949 6.071,-17.903 15.906,-17.903 9.741,0 15.905,6.958 15.905,17.903 l 0.01,15.446 -31.837,0 z"
sketch:type="MSShapeGroup"
id="path12" />
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.9 KiB

View file

@ -18,7 +18,7 @@ inkscape -w 48 -h 48 -e "$XDPI_DIR/$NAME.png" "$SRC_DIR/$NAME.svg"
inkscape -w 64 -h 64 -e "$XXDPI_DIR/$NAME.png" "$SRC_DIR/$NAME.svg"
done
for NAME in "status_dots" "status_lock_none_dots_1" "status_lock_disabled_dots_1" "status_lock_error_dots_1" "status_lock_dots_2" "status_lock_dots_3"
for NAME in "status_check_dots_1" "status_check_dots_1" "status_check_dots_3" "status_dots" "status_lock_none_dots_1" "status_lock_disabled_dots_1" "status_lock_dots_1" "status_lock_error_dots_1" "status_lock_dots_2" "status_lock_dots_3"
do
echo $NAME
inkscape -w 36 -h 24 -e "$MDPI_DIR/$NAME.png" "$SRC_DIR/$NAME.svg"

View file

@ -90,7 +90,7 @@ public class MessageCryptoHelper {
private void runFirstPass() {
List<Part> encryptedParts = MessageDecryptVerifier.findEncryptedParts(currentMessage);
processFoundEncryptedParts(encryptedParts, MessageHelper.createEmptyPart());
processFoundEncryptedParts(encryptedParts);
decryptOrVerifyNextPart();
}
@ -98,16 +98,17 @@ public class MessageCryptoHelper {
private void runSecondPass() {
List<Part> signedParts = MessageDecryptVerifier.findSignedParts(currentMessage, messageAnnotations);
processFoundSignedParts(signedParts);
List<Part> inlineParts = MessageDecryptVerifier.findPgpInlineParts(currentMessage);
addFoundInlinePgpParts(inlineParts);
decryptOrVerifyNextPart();
}
private void processFoundEncryptedParts(List<Part> foundParts, MimeBodyPart replacementPart) {
private void processFoundEncryptedParts(List<Part> foundParts) {
for (Part part : foundParts) {
if (!MessageHelper.isCompletePartAvailable(part)) {
addErrorAnnotation(part, CryptoError.ENCRYPTED_BUT_INCOMPLETE, replacementPart);
addErrorAnnotation(part, CryptoError.ENCRYPTED_BUT_INCOMPLETE, MessageHelper.createEmptyPart());
continue;
}
if (MessageDecryptVerifier.isPgpMimeEncryptedOrSignedPart(part)) {
@ -115,7 +116,7 @@ public class MessageCryptoHelper {
partsToDecryptOrVerify.add(cryptoPart);
continue;
}
addErrorAnnotation(part, CryptoError.ENCRYPTED_BUT_UNSUPPORTED, replacementPart);
addErrorAnnotation(part, CryptoError.ENCRYPTED_BUT_UNSUPPORTED, MessageHelper.createEmptyPart());
}
}

View file

@ -94,6 +94,11 @@ public class MessageTopView extends LinearLayout implements ShowPicturesControll
containerView, false);
view.displayMessageViewContainer(messageViewInfo, automaticallyLoadPictures, this, attachmentCallback);
boolean displayPgpHeader = account.isOpenPgpProviderConfigured();
if (displayPgpHeader) {
mHeaderContainer.setCryptoStatus(messageViewInfo.cryptoResultAnnotation);
}
containerView.addView(view);
}

View file

@ -0,0 +1,141 @@
package com.fsck.k9.view;
import android.support.annotation.NonNull;
import com.fsck.k9.mailstore.CryptoResultAnnotation;
import com.fsck.k9.mailstore.CryptoResultAnnotation.CryptoError;
import org.openintents.openpgp.OpenPgpDecryptionResult;
import org.openintents.openpgp.OpenPgpSignatureResult;
public enum MessageCryptoDisplayStatus {
DISABLED,
UNENCRYPTED_SIGN_UNKNOWN,
UNENCRYPTED_SIGN_VERIFIED,
UNENCRYPTED_SIGN_UNVERIFIED,
UNENCRYPTED_SIGN_ERROR,
UNENCRYPTED_SIGN_MISMATCH,
UNENCRYPTED_SIGN_EXPIRED,
UNENCRYPTED_SIGN_REVOKED,
UNENCRYPTED_SIGN_INSECURE,
ENCRYPTED_UNSIGNED,
ENCRYPTED_SIGN_UNKNOWN,
ENCRYPTED_SIGN_VERIFIED,
ENCRYPTED_SIGN_UNVERIFIED,
ENCRYPTED_SIGN_ERROR,
ENCRYPTED_SIGN_MISMATCH,
ENCRYPTED_SIGN_EXPIRED,
ENCRYPTED_SIGN_REVOKED,
ENCRYPTED_SIGN_INSECURE,
ENCRYPTED_ERROR;
@NonNull
public static MessageCryptoDisplayStatus fromResultAnnotation(CryptoResultAnnotation cryptoResult) {
if (cryptoResult == null) {
return DISABLED;
}
if (cryptoResult.getErrorType() != CryptoError.NONE) {
return ENCRYPTED_ERROR;
}
if (cryptoResult.isOpenPgpResult()) {
return getDisplayStatusForPgpResult(cryptoResult);
}
throw new AssertionError("all cases must be handled, this is a bug!");
}
@NonNull
private static MessageCryptoDisplayStatus getDisplayStatusForPgpResult(CryptoResultAnnotation cryptoResult) {
OpenPgpSignatureResult signatureResult = cryptoResult.getOpenPgpSignatureResult();
OpenPgpDecryptionResult decryptionResult = cryptoResult.getOpenPgpDecryptionResult();
if (decryptionResult == null || signatureResult == null) {
throw new AssertionError("Both OpenPGP results must be non-null at this point!");
}
// TODO handle mismatched user id
switch (decryptionResult.getResult()) {
case OpenPgpDecryptionResult.RESULT_NOT_ENCRYPTED:
return getStatusForPgpUnencryptedResult(signatureResult);
case OpenPgpDecryptionResult.RESULT_ENCRYPTED:
return getStatusForPgpEncryptedResult(signatureResult);
case OpenPgpDecryptionResult.RESULT_INSECURE:
// TODO handle better?
return ENCRYPTED_ERROR;
}
throw new AssertionError("all cases must be handled, this is a bug!");
}
@NonNull
private static MessageCryptoDisplayStatus getStatusForPgpEncryptedResult(OpenPgpSignatureResult signatureResult) {
switch (signatureResult.getResult()) {
case OpenPgpSignatureResult.RESULT_NO_SIGNATURE:
return ENCRYPTED_UNSIGNED;
case OpenPgpSignatureResult.RESULT_VALID_CONFIRMED:
return ENCRYPTED_SIGN_VERIFIED;
case OpenPgpSignatureResult.RESULT_VALID_UNCONFIRMED:
return ENCRYPTED_SIGN_UNVERIFIED;
case OpenPgpSignatureResult.RESULT_KEY_MISSING:
return ENCRYPTED_SIGN_UNKNOWN;
case OpenPgpSignatureResult.RESULT_INVALID_SIGNATURE:
return ENCRYPTED_SIGN_ERROR;
case OpenPgpSignatureResult.RESULT_INVALID_KEY_EXPIRED:
return ENCRYPTED_SIGN_EXPIRED;
case OpenPgpSignatureResult.RESULT_INVALID_KEY_REVOKED:
return ENCRYPTED_SIGN_REVOKED;
case OpenPgpSignatureResult.RESULT_INVALID_INSECURE:
return ENCRYPTED_SIGN_INSECURE;
default:
throw new AssertionError("all cases must be handled, this is a bug!");
}
}
@NonNull
private static MessageCryptoDisplayStatus getStatusForPgpUnencryptedResult(OpenPgpSignatureResult signatureResult) {
switch (signatureResult.getResult()) {
case OpenPgpSignatureResult.RESULT_NO_SIGNATURE:
return DISABLED;
case OpenPgpSignatureResult.RESULT_VALID_CONFIRMED:
return UNENCRYPTED_SIGN_VERIFIED;
case OpenPgpSignatureResult.RESULT_VALID_UNCONFIRMED:
return UNENCRYPTED_SIGN_UNVERIFIED;
case OpenPgpSignatureResult.RESULT_KEY_MISSING:
return UNENCRYPTED_SIGN_UNKNOWN;
case OpenPgpSignatureResult.RESULT_INVALID_SIGNATURE:
return UNENCRYPTED_SIGN_ERROR;
case OpenPgpSignatureResult.RESULT_INVALID_KEY_EXPIRED:
return UNENCRYPTED_SIGN_EXPIRED;
case OpenPgpSignatureResult.RESULT_INVALID_KEY_REVOKED:
return UNENCRYPTED_SIGN_REVOKED;
case OpenPgpSignatureResult.RESULT_INVALID_INSECURE:
return UNENCRYPTED_SIGN_INSECURE;
default:
throw new AssertionError("all cases must be handled, this is a bug!");
}
}
}

View file

@ -0,0 +1,79 @@
package com.fsck.k9.view;
import android.content.Context;
import android.util.AttributeSet;
public class MessageCryptoStatusView extends ToolableViewAnimator {
private static final int STATUS_DISABLED = 0;
private static final int STATUS_SIGN_3_OK = 1;
private static final int STATUS_SIGN_2_WARNING = 2;
private static final int STATUS_SIGN_1_ERROR = 3;
private static final int STATUS_SIGN_0_UNKNOWN = 4;
private static final int STATUS_LOCK_3_OK = 5;
private static final int STATUS_LOCK_2_WARNING = 6;
private static final int STATUS_LOCK_1_ERROR = 7;
private static final int STATUS_LOCK_0_UNKNOWN = 8;
private static final int STATUS_LOCK_UNKNOWN = 9;
private static final int STATUS_LOCK_ERROR = 10;
public MessageCryptoStatusView(Context context) {
super(context);
}
public MessageCryptoStatusView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MessageCryptoStatusView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public void setCryptoDisplayStatus(MessageCryptoDisplayStatus displayStatus) {
int whichChild = displayStatusToChildIndex(displayStatus);
setDisplayedChild(whichChild);
}
private int displayStatusToChildIndex(MessageCryptoDisplayStatus displayStatus) {
switch (displayStatus) {
case DISABLED:
return STATUS_DISABLED;
case UNENCRYPTED_SIGN_UNKNOWN:
return STATUS_SIGN_0_UNKNOWN;
case UNENCRYPTED_SIGN_VERIFIED:
return STATUS_SIGN_3_OK;
case UNENCRYPTED_SIGN_UNVERIFIED:
return STATUS_SIGN_2_WARNING;
case UNENCRYPTED_SIGN_ERROR:
return STATUS_SIGN_1_ERROR;
case UNENCRYPTED_SIGN_MISMATCH:
case UNENCRYPTED_SIGN_EXPIRED:
case UNENCRYPTED_SIGN_REVOKED:
case UNENCRYPTED_SIGN_INSECURE:
return STATUS_SIGN_1_ERROR;
case ENCRYPTED_SIGN_UNKNOWN:
return STATUS_LOCK_0_UNKNOWN;
case ENCRYPTED_SIGN_VERIFIED:
return STATUS_LOCK_3_OK;
case ENCRYPTED_SIGN_UNVERIFIED:
return STATUS_LOCK_2_WARNING;
case ENCRYPTED_SIGN_ERROR:
case ENCRYPTED_SIGN_MISMATCH:
case ENCRYPTED_SIGN_EXPIRED:
case ENCRYPTED_SIGN_REVOKED:
case ENCRYPTED_SIGN_INSECURE:
return STATUS_LOCK_1_ERROR;
case ENCRYPTED_ERROR:
return STATUS_LOCK_ERROR;
case ENCRYPTED_UNSIGNED:
return STATUS_LOCK_UNKNOWN;
}
throw new AssertionError("all cases must be handled, this is a bug!");
}
}

View file

@ -41,7 +41,7 @@ import com.fsck.k9.mail.Flag;
import com.fsck.k9.mail.Message;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.internet.MimeUtility;
import com.fsck.k9.mailstore.CryptoResultAnnotation;
public class MessageHeader extends LinearLayout implements OnClickListener, OnLongClickListener {
@ -53,6 +53,7 @@ public class MessageHeader extends LinearLayout implements OnClickListener, OnLo
private TextView mCcView;
private TextView mCcLabel;
private TextView mSubjectView;
private MessageCryptoStatusView mCryptoStatusIcon;
private View mChip;
private CheckBox mFlagged;
@ -131,6 +132,8 @@ public class MessageHeader extends LinearLayout implements OnClickListener, OnLo
mToView.setOnLongClickListener(this);
mCcView.setOnLongClickListener(this);
mCryptoStatusIcon = (MessageCryptoStatusView) findViewById(R.id.crypto_status_icon);
mMessageHelper = MessageHelper.getInstance(mContext);
hideAdditionalHeaders();
@ -331,6 +334,12 @@ public class MessageHeader extends LinearLayout implements OnClickListener, OnLo
}
}
public void setCryptoStatus(CryptoResultAnnotation cryptoResult) {
MessageCryptoDisplayStatus displayStatus = MessageCryptoDisplayStatus.fromResultAnnotation(cryptoResult);
mCryptoStatusIcon.setVisibility(View.VISIBLE);
mCryptoStatusIcon.setCryptoDisplayStatus(displayStatus);
}
public void onShowAdditionalHeaders() {
int currentVisibility = mAdditionalHeadersView.getVisibility();
if (currentVisibility == View.VISIBLE) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 851 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 902 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 928 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 693 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 671 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 722 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 753 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 564 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 968 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -0,0 +1,213 @@
<?xml version="1.0" encoding="utf-8"?>
<com.fsck.k9.view.MessageCryptoStatusView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/crypto_status_icon"
android:layout_width="36dp"
android:layout_height="32dp"
android:visibility="gone"
custom:previewInitialChild="9"
android:background="@drawable/selectable_item_background"
tools:visibility="visible">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/status_lock_disabled"
android:tint="@color/openpgp_grey"
/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:src="@drawable/status_dots"
android:tint="@color/openpgp_grey"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:src="@drawable/status_check_dots_3"
android:tint="@color/openpgp_blue"
/>
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:src="@drawable/status_dots"
android:tint="@color/openpgp_grey"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:src="@drawable/status_check_dots_2"
android:tint="@color/openpgp_orange"
/>
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:src="@drawable/status_dots"
android:tint="@color/openpgp_grey"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:src="@drawable/status_check_dots_1"
android:tint="@color/openpgp_red"
/>
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:src="@drawable/status_dots"
android:tint="@color/openpgp_grey"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:src="@drawable/status_signature_unverified_cutout"
android:tint="@color/openpgp_grey"
/>
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:src="@drawable/status_dots"
android:tint="@color/openpgp_grey"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:src="@drawable/status_lock_dots_3"
android:tint="@color/openpgp_green"
/>
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:src="@drawable/status_dots"
android:tint="@color/openpgp_grey"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:src="@drawable/status_lock_dots_2"
android:tint="@color/openpgp_orange"
/>
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:src="@drawable/status_dots"
android:tint="@color/openpgp_grey"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:src="@drawable/status_lock_dots_1"
android:tint="@color/openpgp_red"
/>
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:src="@drawable/status_dots"
android:tint="@color/openpgp_grey"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:src="@drawable/status_lock_opportunistic"
android:tint="@color/openpgp_grey"
/>
</FrameLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/status_lock_opportunistic"
android:tint="@color/openpgp_grey"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/status_lock_disabled"
android:tint="@color/openpgp_red"
/>
</com.fsck.k9.view.MessageCryptoStatusView>

View file

@ -98,7 +98,8 @@
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/flagged"
android:layout_toLeftOf="@+id/status_icon_strip"
android:layout_alignBottom="@+id/status_icon_strip"
android:paddingTop="0dp"
android:paddingRight="6dip"
android:singleLine="true"
@ -106,7 +107,9 @@
android:textColor="?android:attr/textColorPrimary"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"
android:text="@string/general_no_sender" />
android:text="@string/general_no_sender"
android:gravity="center_vertical"
/>
<!-- To -->
<TextView
@ -128,7 +131,6 @@
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/to_label"
android:layout_below="@+id/from"
android:layout_toLeftOf="@+id/flagged"
android:maxLines="2"
android:ellipsize="end"
android:paddingTop="2dp"
@ -156,7 +158,6 @@
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/cc_label"
android:layout_below="@+id/to"
android:layout_toLeftOf="@+id/flagged"
android:maxLines="2"
android:ellipsize="end"
android:paddingTop="2dp"
@ -176,15 +177,27 @@
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary" />
<CheckBox
android:id="@+id/flagged"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignTop="@id/from"
android:focusable="false"
style="?android:attr/starStyle"
android:checked="false" />
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:id="@+id/status_icon_strip"
>
<CheckBox
android:id="@+id/flagged"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
style="?android:attr/starStyle"
android:checked="false" />
<include layout="@layout/message_crypto_status_view" />
</LinearLayout>
</RelativeLayout>