diff --git a/images/drawables-pgp/status_lock_closed.svg b/images/drawables-pgp/status_lock_closed.svg new file mode 100644 index 000000000..286e89297 --- /dev/null +++ b/images/drawables-pgp/status_lock_closed.svg @@ -0,0 +1,12 @@ + + + + lock-closed + Created with Sketch. + + + + + + + \ No newline at end of file diff --git a/images/drawables-pgp/status_lock_error.svg b/images/drawables-pgp/status_lock_error.svg new file mode 100644 index 000000000..d3c4e1d1d --- /dev/null +++ b/images/drawables-pgp/status_lock_error.svg @@ -0,0 +1,12 @@ + + + + lock-error + Created with Sketch. + + + + + + + \ No newline at end of file diff --git a/images/drawables-pgp/status_lock_open.svg b/images/drawables-pgp/status_lock_open.svg new file mode 100644 index 000000000..9beb127af --- /dev/null +++ b/images/drawables-pgp/status_lock_open.svg @@ -0,0 +1,12 @@ + + + + lock-open + Created with Sketch. + + + + + + + \ No newline at end of file diff --git a/images/drawables-pgp/status_signature_expired_cutout.svg b/images/drawables-pgp/status_signature_expired_cutout.svg new file mode 100644 index 000000000..61ac8fdd0 --- /dev/null +++ b/images/drawables-pgp/status_signature_expired_cutout.svg @@ -0,0 +1,12 @@ + + + + signature-expired-cutout + Created with Sketch. + + + + + + + \ No newline at end of file diff --git a/images/drawables-pgp/status_signature_invalid_cutout.svg b/images/drawables-pgp/status_signature_invalid_cutout.svg new file mode 100644 index 000000000..61fd2ace0 --- /dev/null +++ b/images/drawables-pgp/status_signature_invalid_cutout.svg @@ -0,0 +1,12 @@ + + + + signature-invalid-cutout + Created with Sketch. + + + + + + + \ No newline at end of file diff --git a/images/drawables-pgp/status_signature_revoked_cutout.svg b/images/drawables-pgp/status_signature_revoked_cutout.svg new file mode 100644 index 000000000..0421286fe --- /dev/null +++ b/images/drawables-pgp/status_signature_revoked_cutout.svg @@ -0,0 +1,12 @@ + + + + signature-revoked-cutout + Created with Sketch. + + + + + + + \ No newline at end of file diff --git a/images/drawables-pgp/status_signature_unknown_cutout.svg b/images/drawables-pgp/status_signature_unknown_cutout.svg new file mode 100644 index 000000000..402bffcaa --- /dev/null +++ b/images/drawables-pgp/status_signature_unknown_cutout.svg @@ -0,0 +1,12 @@ + + + + signature-unknown-cutout + Created with Sketch. + + + + + + + \ No newline at end of file diff --git a/images/drawables-pgp/status_signature_unverified_cutout.svg b/images/drawables-pgp/status_signature_unverified_cutout.svg new file mode 100644 index 000000000..ffa98580a --- /dev/null +++ b/images/drawables-pgp/status_signature_unverified_cutout.svg @@ -0,0 +1,12 @@ + + + + signature-unverified-cutout + Created with Sketch. + + + + + + + \ No newline at end of file diff --git a/images/drawables-pgp/status_signature_verified_cutout.svg b/images/drawables-pgp/status_signature_verified_cutout.svg new file mode 100644 index 000000000..04356a977 --- /dev/null +++ b/images/drawables-pgp/status_signature_verified_cutout.svg @@ -0,0 +1,12 @@ + + + + signature-verified-cutout + Created with Sketch. + + + + + + + \ No newline at end of file diff --git a/images/update-drawables-pgp.sh b/images/update-drawables-pgp.sh new file mode 100755 index 000000000..45220ebc5 --- /dev/null +++ b/images/update-drawables-pgp.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +APP_DIR=../k9mail/src/main +MDPI_DIR=$APP_DIR/res/drawable-mdpi +HDPI_DIR=$APP_DIR/res/drawable-hdpi +XDPI_DIR=$APP_DIR/res/drawable-xhdpi +XXDPI_DIR=$APP_DIR/res/drawable-xxhdpi +XXXDPI_DIR=$APP_DIR/res/drawable-xxxhdpi +SRC_DIR=./drawables-pgp/ + + +for NAME in "status_lock_closed" "status_lock_error" "status_lock_open" "status_signature_expired_cutout" "status_signature_invalid_cutout" "status_signature_revoked_cutout" "status_signature_unknown_cutout" "status_signature_unverified_cutout" "status_signature_verified_cutout" +do +echo $NAME +inkscape -w 24 -h 24 -e "$MDPI_DIR/$NAME.png" "$SRC_DIR/$NAME.svg" +inkscape -w 32 -h 32 -e "$HDPI_DIR/$NAME.png" "$SRC_DIR/$NAME.svg" +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 diff --git a/k9mail/src/main/java/com/fsck/k9/activity/MessageList.java b/k9mail/src/main/java/com/fsck/k9/activity/MessageList.java index a1a817863..d85217683 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/MessageList.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/MessageList.java @@ -51,7 +51,7 @@ import com.fsck.k9.search.SearchSpecification.Attribute; import com.fsck.k9.search.SearchSpecification.SearchCondition; import com.fsck.k9.search.SearchSpecification.Searchfield; import com.fsck.k9.view.MessageHeader; -import com.fsck.k9.ui.messageview.MessageOpenPgpView; +import com.fsck.k9.ui.messageview.MessageOpenPgpViewOld; import com.fsck.k9.view.MessageTitleView; import com.fsck.k9.view.ViewSwitcher; import com.fsck.k9.view.ViewSwitcher.OnSwitchCompleteListener; @@ -1564,7 +1564,7 @@ public class MessageList extends K9Activity implements MessageListFragmentListen // handle OpenPGP results from PendingIntents in OpenPGP view // must be handled in this main activity, because startIntentSenderForResult() does not support Fragments - MessageOpenPgpView openPgpView = (MessageOpenPgpView) findViewById(R.id.layout_decrypt_openpgp); + MessageOpenPgpViewOld openPgpView = (MessageOpenPgpViewOld) findViewById(R.id.layout_decrypt_openpgp); if (openPgpView != null && openPgpView.handleOnActivityResult(requestCode, resultCode, data)) { return; } diff --git a/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageOpenPgpView.java b/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageOpenPgpView.java index 8cddbe7e4..73a8ec91f 100644 --- a/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageOpenPgpView.java +++ b/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageOpenPgpView.java @@ -1,201 +1,143 @@ package com.fsck.k9.ui.messageview; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.nio.charset.Charset; - -import android.app.Activity; -import android.app.Fragment; import android.app.PendingIntent; import android.content.Context; -import android.content.Intent; -import android.content.IntentSender.SendIntentException; +import android.graphics.PorterDuff; import android.util.AttributeSet; -import android.util.Log; -import android.view.View; -import android.widget.Button; import android.widget.ImageView; import android.widget.LinearLayout; -import android.widget.ProgressBar; -import android.widget.RelativeLayout; import android.widget.TextView; -import android.widget.Toast; -import com.fsck.k9.Account; -import com.fsck.k9.Identity; -import com.fsck.k9.K9; import com.fsck.k9.R; -import com.fsck.k9.crypto.CryptoHelper; -import com.fsck.k9.crypto.OpenPgpApiHelper; -import com.fsck.k9.helper.IdentityHelper; -import com.fsck.k9.mail.Message; -import com.fsck.k9.mail.MessagingException; -import com.fsck.k9.mail.Part; -import com.fsck.k9.mail.internet.MessageExtractor; -import com.fsck.k9.mail.internet.MimeUtility; -import org.openintents.openpgp.OpenPgpError; import org.openintents.openpgp.OpenPgpSignatureResult; -import org.openintents.openpgp.util.OpenPgpApi; -import org.openintents.openpgp.util.OpenPgpServiceConnection; public class MessageOpenPgpView extends LinearLayout { private Context mContext; - private MessageViewFragment mFragment; - private RelativeLayout mSignatureLayout = null; - private ImageView mSignatureStatusImage = null; - private TextView mSignatureUserId = null; - private TextView mText = null; - private ProgressBar mProgress; - private Button mGetKeyButton; - private OpenPgpServiceConnection mOpenPgpServiceConnection; - private OpenPgpApi mOpenPgpApi; + private ImageView mResultEncryptionIcon; + private TextView mResultEncryptionText; + private ImageView mResultSignatureIcon; + private TextView mResultSignatureText; + private LinearLayout mResultSignatureLayout; + private TextView mResultSignatureName; + private TextView mResultSignatureEmail; - private String mOpenPgpProvider; - private Message mMessage; - - private PendingIntent mMissingKeyPI; +// private PendingIntent mMissingKeyPI; private static final int REQUEST_CODE_DECRYPT_VERIFY = 12; - String mData; - Account mAccount; - public MessageOpenPgpView(Context context, AttributeSet attrs) { super(context, attrs); mContext = context; } public void setupChildViews() { - mSignatureLayout = (RelativeLayout) findViewById(R.id.openpgp_signature_layout); - mSignatureStatusImage = (ImageView) findViewById(R.id.openpgp_signature_status); - mSignatureUserId = (TextView) findViewById(R.id.openpgp_user_id); - mText = (TextView) findViewById(R.id.openpgp_text); - mProgress = (ProgressBar) findViewById(R.id.openpgp_progress); - mGetKeyButton = (Button) findViewById(R.id.openpgp_get_key); + mResultEncryptionIcon = (ImageView) findViewById(R.id.result_encryption_icon); + mResultEncryptionText = (TextView) findViewById(R.id.result_encryption_text); + mResultSignatureIcon = (ImageView) findViewById(R.id.result_signature_icon); + mResultSignatureText = (TextView) findViewById(R.id.result_signature_text); + mResultSignatureLayout = (LinearLayout) findViewById(R.id.result_signature_layout); + mResultSignatureName = (TextView) findViewById(R.id.result_signature_name); + mResultSignatureEmail = (TextView) findViewById(R.id.result_signature_email); - mGetKeyButton.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - getMissingKey(); - } - }); +// mGetKeyButton.setOnClickListener(new OnClickListener() { +// @Override +// public void onClick(View v) { +// getMissingKey(); +// } +// }); } - public void setFragment(Fragment fragment) { - mFragment = (MessageViewFragment) fragment; - } +// public void setFragment(Fragment fragment) { +// mFragment = (MessageViewFragment) fragment; +// } /** * Fill the decrypt layout with signature data, if known, make controls * visible, if they should be visible. */ - public void updateLayout(Account account, String decryptedData, - final OpenPgpSignatureResult signatureResult, - final Message message) { + public void updateLayout(final OpenPgpSignatureResult signatureResult, + boolean decryptedData, + PendingIntent getMissingKeyIntent) { - // set class variables - mAccount = account; - mOpenPgpProvider = mAccount.getOpenPgpProvider(); - mMessage = message; - - // only use this view if a OpenPGP Provider is set - if (mOpenPgpProvider == null) { - return; - } - - Activity activity = mFragment.getActivity(); - if (activity == null) { - return; - } - // bind to service - mOpenPgpServiceConnection = new OpenPgpServiceConnection(activity, - mOpenPgpProvider); - mOpenPgpServiceConnection.bindToService(); - - if ((message == null) && (decryptedData == null)) { - this.setVisibility(View.GONE); - - // don't process further - return; - } - if (decryptedData != null && signatureResult == null) { + if (decryptedData) { // encrypted-only + setStatusImage(mContext, mResultEncryptionIcon, mResultEncryptionText, STATE_ENCRYPTED); - MessageOpenPgpView.this.setBackgroundColor(mFragment.getResources().getColor( - R.color.openpgp_blue)); - mText.setText(R.string.openpgp_successful_decryption); +// MessageOpenPgpView.this.setBackgroundColor(mContext.getResources().getColor( +// R.color.openpgp_blue)); +// mText.setText(R.string.openpgp_successful_decryption); - // don't process further - return; - } else if (decryptedData != null && signatureResult != null) { - // signed-only and signed-and-encrypted + } + if (signatureResult != null) { switch (signatureResult.getStatus()) { case OpenPgpSignatureResult.SIGNATURE_ERROR: - // TODO: signature error but decryption works? - mText.setText(R.string.openpgp_signature_invalid); - MessageOpenPgpView.this.setBackgroundColor(mFragment.getResources().getColor( - R.color.openpgp_red)); - - mGetKeyButton.setVisibility(View.GONE); - mSignatureStatusImage.setImageResource(R.drawable.overlay_error); - mSignatureLayout.setVisibility(View.GONE); + setStatusImage(mContext, mResultSignatureIcon, mResultSignatureText, STATE_INVALID); +// // TODO: signature error but decryption works? +// mText.setText(R.string.openpgp_signature_invalid); +// MessageOpenPgpView.this.setBackgroundColor(mContext.getResources().getColor( +// R.color.openpgp_red)); +// +// mGetKeyButton.setVisibility(View.GONE); +// mSignatureStatusImage.setImageResource(R.drawable.overlay_error); +// mSignatureLayout.setVisibility(View.GONE); break; case OpenPgpSignatureResult.SIGNATURE_SUCCESS_CERTIFIED: - if (signatureResult.isSignatureOnly()) { - mText.setText(R.string.openpgp_signature_valid_certified); - } - else { - mText.setText(R.string.openpgp_successful_decryption_valid_signature_certified); - } - MessageOpenPgpView.this.setBackgroundColor(mFragment.getResources().getColor( - R.color.openpgp_green)); + setStatusImage(mContext, mResultSignatureIcon, mResultSignatureText, STATE_VERIFIED); - mGetKeyButton.setVisibility(View.GONE); - mSignatureUserId.setText(signatureResult.getUserId()); - mSignatureStatusImage.setImageResource(R.drawable.overlay_ok); - mSignatureLayout.setVisibility(View.VISIBLE); +// if (signatureResult.isSignatureOnly()) { +// mText.setText(R.string.openpgp_signature_valid_certified); +// } else { +// mText.setText(R.string.openpgp_successful_decryption_valid_signature_certified); +// } +// MessageOpenPgpView.this.setBackgroundColor(mFragment.getResources().getColor( +// R.color.openpgp_green)); +// +// mGetKeyButton.setVisibility(View.GONE); +// mSignatureUserId.setText(signatureResult.getUserId()); +// mSignatureStatusImage.setImageResource(R.drawable.overlay_ok); +// mSignatureLayout.setVisibility(View.VISIBLE); break; case OpenPgpSignatureResult.SIGNATURE_UNKNOWN_PUB_KEY: - if (signatureResult.isSignatureOnly()) { - mText.setText(R.string.openpgp_signature_unknown_text); - } - else { - mText.setText(R.string.openpgp_successful_decryption_unknown_signature); - } - MessageOpenPgpView.this.setBackgroundColor(mFragment.getResources().getColor( - R.color.openpgp_orange)); - - mGetKeyButton.setVisibility(View.VISIBLE); - mSignatureUserId.setText(R.string.openpgp_signature_unknown); - mSignatureStatusImage.setImageResource(R.drawable.overlay_error); - mSignatureLayout.setVisibility(View.VISIBLE); + setStatusImage(mContext, mResultSignatureIcon, mResultSignatureText, STATE_UNKNOWN_KEY); + +// if (signatureResult.isSignatureOnly()) { +// mText.setText(R.string.openpgp_signature_unknown_text); +// } else { +// mText.setText(R.string.openpgp_successful_decryption_unknown_signature); +// } +// MessageOpenPgpView.this.setBackgroundColor(mFragment.getResources().getColor( +// R.color.openpgp_orange)); +// +// mGetKeyButton.setVisibility(View.VISIBLE); +// mSignatureUserId.setText(R.string.openpgp_signature_unknown); +// mSignatureStatusImage.setImageResource(R.drawable.overlay_error); +// mSignatureLayout.setVisibility(View.VISIBLE); break; case OpenPgpSignatureResult.SIGNATURE_SUCCESS_UNCERTIFIED: - if (signatureResult.isSignatureOnly()) { - mText.setText(R.string.openpgp_signature_valid_uncertified); - } - else { - mText.setText(R.string.openpgp_successful_decryption_valid_signature_uncertified); - } - MessageOpenPgpView.this.setBackgroundColor(mFragment.getResources().getColor( - R.color.openpgp_orange)); + setStatusImage(mContext, mResultSignatureIcon, mResultSignatureText, STATE_UNVERIFIED); - mGetKeyButton.setVisibility(View.GONE); - mSignatureUserId.setText(signatureResult.getUserId()); - mSignatureStatusImage.setImageResource(R.drawable.overlay_ok); - mSignatureLayout.setVisibility(View.VISIBLE); +// if (signatureResult.isSignatureOnly()) { +// mText.setText(R.string.openpgp_signature_valid_uncertified); +// } else { +// mText.setText(R.string.openpgp_successful_decryption_valid_signature_uncertified); +// } +// MessageOpenPgpView.this.setBackgroundColor(mFragment.getResources().getColor( +// R.color.openpgp_orange)); +// +// mGetKeyButton.setVisibility(View.GONE); +// mSignatureUserId.setText(signatureResult.getUserId()); +// mSignatureStatusImage.setImageResource(R.drawable.overlay_ok); +// mSignatureLayout.setVisibility(View.VISIBLE); break; @@ -203,221 +145,149 @@ public class MessageOpenPgpView extends LinearLayout { break; } - // don't process further - return; - } - - // Start new decryption/verification - CryptoHelper helper = new CryptoHelper(); - if (helper.isEncrypted(message) || helper.isSigned(message)) { - // start automatic decrypt - decryptAndVerify(message); - } else { - try { - // check for PGP/MIME encryption - Part pgp = MimeUtility.findFirstPartByMimeType(message, "application/pgp-encrypted"); - if (pgp != null) { - Toast.makeText(mContext, R.string.pgp_mime_unsupported, Toast.LENGTH_LONG) - .show(); - } - } catch (MessagingException e) { - // nothing to do... - } } } - private void decryptAndVerify(final Message message) { - this.setVisibility(View.VISIBLE); - mProgress.setVisibility(View.VISIBLE); - MessageOpenPgpView.this.setBackgroundColor(mFragment.getResources().getColor( - R.color.openpgp_orange)); - mText.setText(R.string.openpgp_decrypting_verifying); + public static final int STATE_REVOKED = 1; + public static final int STATE_EXPIRED = 2; + public static final int STATE_VERIFIED = 3; + public static final int STATE_UNAVAILABLE = 4; + public static final int STATE_ENCRYPTED = 5; + public static final int STATE_NOT_ENCRYPTED = 6; + public static final int STATE_UNVERIFIED = 7; + public static final int STATE_UNKNOWN_KEY = 8; + public static final int STATE_INVALID = 9; + public static final int STATE_NOT_SIGNED = 10; - // waiting in a new thread - Runnable r = new Runnable() { - - @Override - public void run() { - try { - // get data String - Part part = MimeUtility.findFirstPartByMimeType(message, "text/plain"); - if (part == null) { - part = MimeUtility.findFirstPartByMimeType(message, "text/html"); - } - if (part != null) { - mData = MessageExtractor.getTextFromPart(part); - } - - // wait for service to be bound - while (!mOpenPgpServiceConnection.isBound()) { - try { - Thread.sleep(100); - } catch (InterruptedException e) { - } - } - - mOpenPgpApi = new OpenPgpApi(getContext(), - mOpenPgpServiceConnection.getService()); - - decryptVerify(new Intent()); - - } catch (MessagingException me) { - Log.e(K9.LOG_TAG, "Unable to decrypt email.", me); - } - - } - }; - - new Thread(r).start(); - } - - private void decryptVerify(Intent intent) { - intent.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY); - intent.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true); - - Identity identity = IdentityHelper.getRecipientIdentityFromMessage(mAccount, mMessage); - String accName = OpenPgpApiHelper.buildAccountName(identity); - intent.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, accName); - - InputStream is = new ByteArrayInputStream(mData.getBytes(Charset.forName("UTF-8"))); - final ByteArrayOutputStream os = new ByteArrayOutputStream(); - - DecryptVerifyCallback callback = new DecryptVerifyCallback(os, REQUEST_CODE_DECRYPT_VERIFY); - - mOpenPgpApi.executeApiAsync(intent, is, os, callback); - } - - private void getMissingKey() { - try { - mFragment.getActivity().startIntentSenderForResult( - mMissingKeyPI.getIntentSender(), - REQUEST_CODE_DECRYPT_VERIFY, null, 0, 0, 0); - } catch (SendIntentException e) { - Log.e(K9.LOG_TAG, "SendIntentException", e); - } + public static void setStatusImage(Context context, ImageView statusIcon, int state) { + setStatusImage(context, statusIcon, null, state); } /** - * Called on successful decrypt/verification + * Sets status image based on constant */ - private class DecryptVerifyCallback implements OpenPgpApi.IOpenPgpCallback { - ByteArrayOutputStream os; - int requestCode; - - private DecryptVerifyCallback(ByteArrayOutputStream os, int requestCode) { - this.os = os; - this.requestCode = requestCode; - } - - @Override - public void onReturn(Intent result) { - switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) { - case OpenPgpApi.RESULT_CODE_SUCCESS: { - try { - final String output = os.toString("UTF-8"); - - OpenPgpSignatureResult sigResult = null; - if (result.hasExtra(OpenPgpApi.RESULT_SIGNATURE)) { - sigResult = result.getParcelableExtra(OpenPgpApi.RESULT_SIGNATURE); - } - - if (K9.DEBUG) - Log.d(K9.LOG_TAG, "result: " + os.toByteArray().length - + " str=" + output); - - // missing key -> PendingIntent to get keys - mMissingKeyPI = result.getParcelableExtra(OpenPgpApi.RESULT_INTENT); - - mProgress.setVisibility(View.GONE); - mFragment.setMessageWithOpenPgp(output, sigResult); - } catch (UnsupportedEncodingException e) { - Log.e(K9.LOG_TAG, "UnsupportedEncodingException", e); - } - break; + public static void setStatusImage(Context context, ImageView statusIcon, TextView statusText, + int state) { + switch (state) { + /** GREEN: everything is good **/ + case STATE_VERIFIED: { + statusIcon.setImageDrawable( + context.getResources().getDrawable(R.drawable.status_signature_verified_cutout)); + int color = R.color.openpgp_green; + statusIcon.setColorFilter(context.getResources().getColor(color), + PorterDuff.Mode.SRC_IN); + if (statusText != null) { + statusText.setTextColor(context.getResources().getColor(color)); } - case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: { - PendingIntent pi = result.getParcelableExtra(OpenPgpApi.RESULT_INTENT); - try { - mFragment.getActivity().startIntentSenderForResult( - pi.getIntentSender(), - requestCode, null, 0, 0, 0); - } catch (SendIntentException e) { - Log.e(K9.LOG_TAG, "SendIntentException", e); - } - break; + break; + } + case STATE_ENCRYPTED: { + statusIcon.setImageDrawable( + context.getResources().getDrawable(R.drawable.status_lock_closed)); + int color = R.color.openpgp_green; + statusIcon.setColorFilter(context.getResources().getColor(color), + PorterDuff.Mode.SRC_IN); + if (statusText != null) { + statusText.setTextColor(context.getResources().getColor(color)); } - case OpenPgpApi.RESULT_CODE_ERROR: { - OpenPgpError error = result.getParcelableExtra(OpenPgpApi.RESULT_ERROR); - handleError(error); - break; + break; + } + /** ORANGE: mostly bad... **/ + case STATE_UNVERIFIED: { + statusIcon.setImageDrawable( + context.getResources().getDrawable(R.drawable.status_signature_unverified_cutout)); + int color = R.color.openpgp_orange; + statusIcon.setColorFilter(context.getResources().getColor(color), + PorterDuff.Mode.SRC_IN); + if (statusText != null) { + statusText.setTextColor(context.getResources().getColor(color)); } + break; + } + case STATE_UNKNOWN_KEY: { + statusIcon.setImageDrawable( + context.getResources().getDrawable(R.drawable.status_signature_unknown_cutout)); + int color = R.color.openpgp_orange; + statusIcon.setColorFilter(context.getResources().getColor(color), + PorterDuff.Mode.SRC_IN); + if (statusText != null) { + statusText.setTextColor(context.getResources().getColor(color)); + } + break; + } + /** RED: really bad... **/ + case STATE_REVOKED: { + statusIcon.setImageDrawable( + context.getResources().getDrawable(R.drawable.status_signature_revoked_cutout)); + int color = R.color.openpgp_red; +// if (unobtrusive) { +// color = R.color.bg_gray; +// } + statusIcon.setColorFilter(context.getResources().getColor(color), + PorterDuff.Mode.SRC_IN); + if (statusText != null) { + statusText.setTextColor(context.getResources().getColor(color)); + } + break; + } + case STATE_EXPIRED: { + statusIcon.setImageDrawable( + context.getResources().getDrawable(R.drawable.status_signature_expired_cutout)); + int color = R.color.openpgp_red; +// if (unobtrusive) { +// color = R.color.bg_gray; +// } + statusIcon.setColorFilter(context.getResources().getColor(color), + PorterDuff.Mode.SRC_IN); + if (statusText != null) { + statusText.setTextColor(context.getResources().getColor(color)); + } + break; + } + case STATE_NOT_ENCRYPTED: { + statusIcon.setImageDrawable( + context.getResources().getDrawable(R.drawable.status_lock_open)); + int color = R.color.openpgp_red; + statusIcon.setColorFilter(context.getResources().getColor(color), + PorterDuff.Mode.SRC_IN); + if (statusText != null) { + statusText.setTextColor(context.getResources().getColor(color)); + } + break; + } + case STATE_NOT_SIGNED: { + statusIcon.setImageDrawable( + context.getResources().getDrawable(R.drawable.status_signature_unknown_cutout)); + int color = R.color.openpgp_red; + statusIcon.setColorFilter(context.getResources().getColor(color), + PorterDuff.Mode.SRC_IN); + if (statusText != null) { + statusText.setTextColor(context.getResources().getColor(color)); + } + break; + } + case STATE_INVALID: { + statusIcon.setImageDrawable( + context.getResources().getDrawable(R.drawable.status_signature_invalid_cutout)); + int color = R.color.openpgp_red; + statusIcon.setColorFilter(context.getResources().getColor(color), + PorterDuff.Mode.SRC_IN); + if (statusText != null) { + statusText.setTextColor(context.getResources().getColor(color)); + } + break; } } } - public boolean handleOnActivityResult(int requestCode, int resultCode, Intent data) { - if (K9.DEBUG) - Log.d(K9.LOG_TAG, "onActivityResult resultCode: " + resultCode); - - // try again after user interaction - if (resultCode == Activity.RESULT_OK && requestCode == REQUEST_CODE_DECRYPT_VERIFY) { - /* - * The data originally given to the decryptVerify() method, is again - * returned here to be used when calling decryptVerify() after user - * interaction. The Intent now also contains results from the user - * interaction, for example selected key ids. - */ - decryptVerify(data); - - return true; - } - - return false; - } - - private void handleError(final OpenPgpError error) { - Activity activity = mFragment.getActivity(); - if (activity == null) { - return; - } - activity.runOnUiThread(new Runnable() { - - @Override - public void run() { - mProgress.setVisibility(View.GONE); - - if (K9.DEBUG) { - Log.d(K9.LOG_TAG, "OpenPGP Error ID:" + error.getErrorId()); - Log.d(K9.LOG_TAG, "OpenPGP Error Message:" + error.getMessage()); - } - - mText.setText(mFragment.getString(R.string.openpgp_error) + " " - + error.getMessage()); - MessageOpenPgpView.this.setBackgroundColor(mFragment.getResources().getColor( - R.color.openpgp_red)); - } - }); - } - - @Override - protected void onAttachedToWindow() { - super.onAttachedToWindow(); - - // bind to service if a OpenPGP Provider is available - if (mOpenPgpProvider != null) { - mOpenPgpServiceConnection = new OpenPgpServiceConnection(mFragment.getActivity(), - mOpenPgpProvider); - mOpenPgpServiceConnection.bindToService(); - } - } - - @Override - protected void onDetachedFromWindow() { - super.onDetachedFromWindow(); - - if (mOpenPgpServiceConnection != null) { - mOpenPgpServiceConnection.unbindFromService(); - } - } +// private void getMissingKey() { +// try { +// mFragment.getActivity().startIntentSenderForResult( +// mMissingKeyPI.getIntentSender(), +// REQUEST_CODE_DECRYPT_VERIFY, null, 0, 0, 0); +// } catch (SendIntentException e) { +// Log.e(K9.LOG_TAG, "SendIntentException", e); +// } +// } } diff --git a/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageOpenPgpViewOld.java b/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageOpenPgpViewOld.java new file mode 100644 index 000000000..107e1a315 --- /dev/null +++ b/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageOpenPgpViewOld.java @@ -0,0 +1,423 @@ + +package com.fsck.k9.ui.messageview; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.nio.charset.Charset; + +import android.app.Activity; +import android.app.Fragment; +import android.app.PendingIntent; +import android.content.Context; +import android.content.Intent; +import android.content.IntentSender.SendIntentException; +import android.util.AttributeSet; +import android.util.Log; +import android.view.View; +import android.widget.Button; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.ProgressBar; +import android.widget.RelativeLayout; +import android.widget.TextView; +import android.widget.Toast; + +import com.fsck.k9.Account; +import com.fsck.k9.Identity; +import com.fsck.k9.K9; +import com.fsck.k9.R; +import com.fsck.k9.crypto.CryptoHelper; +import com.fsck.k9.crypto.OpenPgpApiHelper; +import com.fsck.k9.helper.IdentityHelper; +import com.fsck.k9.mail.Message; +import com.fsck.k9.mail.MessagingException; +import com.fsck.k9.mail.Part; + +import com.fsck.k9.mail.internet.MessageExtractor; +import com.fsck.k9.mail.internet.MimeUtility; +import org.openintents.openpgp.OpenPgpError; +import org.openintents.openpgp.OpenPgpSignatureResult; +import org.openintents.openpgp.util.OpenPgpApi; +import org.openintents.openpgp.util.OpenPgpServiceConnection; + +public class MessageOpenPgpViewOld extends LinearLayout { + + private Context mContext; + private MessageViewFragment mFragment; + private RelativeLayout mSignatureLayout = null; + private ImageView mSignatureStatusImage = null; + private TextView mSignatureUserId = null; + private TextView mText = null; + private ProgressBar mProgress; + private Button mGetKeyButton; + + private OpenPgpServiceConnection mOpenPgpServiceConnection; + private OpenPgpApi mOpenPgpApi; + + private String mOpenPgpProvider; + private Message mMessage; + + private PendingIntent mMissingKeyPI; + + private static final int REQUEST_CODE_DECRYPT_VERIFY = 12; + + String mData; + Account mAccount; + + public MessageOpenPgpViewOld(Context context, AttributeSet attrs) { + super(context, attrs); + mContext = context; + } + + public void setupChildViews() { + mSignatureLayout = (RelativeLayout) findViewById(R.id.openpgp_signature_layout); + mSignatureStatusImage = (ImageView) findViewById(R.id.openpgp_signature_status); + mSignatureUserId = (TextView) findViewById(R.id.openpgp_user_id); + mText = (TextView) findViewById(R.id.openpgp_text); + mProgress = (ProgressBar) findViewById(R.id.openpgp_progress); + mGetKeyButton = (Button) findViewById(R.id.openpgp_get_key); + + mGetKeyButton.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + getMissingKey(); + } + }); + } + + public void setFragment(Fragment fragment) { + mFragment = (MessageViewFragment) fragment; + } + + /** + * Fill the decrypt layout with signature data, if known, make controls + * visible, if they should be visible. + */ + public void updateLayout(Account account, String decryptedData, + final OpenPgpSignatureResult signatureResult, + final Message message) { + + // set class variables + mAccount = account; + mOpenPgpProvider = mAccount.getOpenPgpProvider(); + mMessage = message; + + // only use this view if a OpenPGP Provider is set + if (mOpenPgpProvider == null) { + return; + } + + Activity activity = mFragment.getActivity(); + if (activity == null) { + return; + } + // bind to service + mOpenPgpServiceConnection = new OpenPgpServiceConnection(activity, + mOpenPgpProvider); + mOpenPgpServiceConnection.bindToService(); + + if ((message == null) && (decryptedData == null)) { + this.setVisibility(View.GONE); + + // don't process further + return; + } + if (decryptedData != null && signatureResult == null) { + // encrypted-only + + MessageOpenPgpViewOld.this.setBackgroundColor(mFragment.getResources().getColor( + R.color.openpgp_blue)); + mText.setText(R.string.openpgp_successful_decryption); + + // don't process further + return; + } else if (decryptedData != null && signatureResult != null) { + // signed-only and signed-and-encrypted + + switch (signatureResult.getStatus()) { + case OpenPgpSignatureResult.SIGNATURE_ERROR: + // TODO: signature error but decryption works? + mText.setText(R.string.openpgp_signature_invalid); + MessageOpenPgpViewOld.this.setBackgroundColor(mFragment.getResources().getColor( + R.color.openpgp_red)); + + mGetKeyButton.setVisibility(View.GONE); + mSignatureStatusImage.setImageResource(R.drawable.overlay_error); + mSignatureLayout.setVisibility(View.GONE); + break; + + case OpenPgpSignatureResult.SIGNATURE_SUCCESS_CERTIFIED: + if (signatureResult.isSignatureOnly()) { + mText.setText(R.string.openpgp_signature_valid_certified); + } + else { + mText.setText(R.string.openpgp_successful_decryption_valid_signature_certified); + } + MessageOpenPgpViewOld.this.setBackgroundColor(mFragment.getResources().getColor( + R.color.openpgp_green)); + + mGetKeyButton.setVisibility(View.GONE); + mSignatureUserId.setText(signatureResult.getUserId()); + mSignatureStatusImage.setImageResource(R.drawable.overlay_ok); + mSignatureLayout.setVisibility(View.VISIBLE); + + break; + + case OpenPgpSignatureResult.SIGNATURE_UNKNOWN_PUB_KEY: + if (signatureResult.isSignatureOnly()) { + mText.setText(R.string.openpgp_signature_unknown_text); + } + else { + mText.setText(R.string.openpgp_successful_decryption_unknown_signature); + } + MessageOpenPgpViewOld.this.setBackgroundColor(mFragment.getResources().getColor( + R.color.openpgp_orange)); + + mGetKeyButton.setVisibility(View.VISIBLE); + mSignatureUserId.setText(R.string.openpgp_signature_unknown); + mSignatureStatusImage.setImageResource(R.drawable.overlay_error); + mSignatureLayout.setVisibility(View.VISIBLE); + + break; + + case OpenPgpSignatureResult.SIGNATURE_SUCCESS_UNCERTIFIED: + if (signatureResult.isSignatureOnly()) { + mText.setText(R.string.openpgp_signature_valid_uncertified); + } + else { + mText.setText(R.string.openpgp_successful_decryption_valid_signature_uncertified); + } + MessageOpenPgpViewOld.this.setBackgroundColor(mFragment.getResources().getColor( + R.color.openpgp_orange)); + + mGetKeyButton.setVisibility(View.GONE); + mSignatureUserId.setText(signatureResult.getUserId()); + mSignatureStatusImage.setImageResource(R.drawable.overlay_ok); + mSignatureLayout.setVisibility(View.VISIBLE); + + break; + + default: + break; + } + + // don't process further + return; + } + + // Start new decryption/verification + CryptoHelper helper = new CryptoHelper(); + if (helper.isEncrypted(message) || helper.isSigned(message)) { + // start automatic decrypt + decryptAndVerify(message); + } else { + try { + // check for PGP/MIME encryption + Part pgp = MimeUtility.findFirstPartByMimeType(message, "application/pgp-encrypted"); + if (pgp != null) { + Toast.makeText(mContext, R.string.pgp_mime_unsupported, Toast.LENGTH_LONG) + .show(); + } + } catch (MessagingException e) { + // nothing to do... + } + } + } + + private void decryptAndVerify(final Message message) { + this.setVisibility(View.VISIBLE); + mProgress.setVisibility(View.VISIBLE); + MessageOpenPgpViewOld.this.setBackgroundColor(mFragment.getResources().getColor( + R.color.openpgp_orange)); + mText.setText(R.string.openpgp_decrypting_verifying); + + // waiting in a new thread + Runnable r = new Runnable() { + + @Override + public void run() { + try { + // get data String + Part part = MimeUtility.findFirstPartByMimeType(message, "text/plain"); + if (part == null) { + part = MimeUtility.findFirstPartByMimeType(message, "text/html"); + } + if (part != null) { + mData = MessageExtractor.getTextFromPart(part); + } + + // wait for service to be bound + while (!mOpenPgpServiceConnection.isBound()) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + } + } + + mOpenPgpApi = new OpenPgpApi(getContext(), + mOpenPgpServiceConnection.getService()); + + decryptVerify(new Intent()); + + } catch (MessagingException me) { + Log.e(K9.LOG_TAG, "Unable to decrypt email.", me); + } + + } + }; + + new Thread(r).start(); + } + + private void decryptVerify(Intent intent) { + intent.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY); + intent.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true); + + Identity identity = IdentityHelper.getRecipientIdentityFromMessage(mAccount, mMessage); + String accName = OpenPgpApiHelper.buildAccountName(identity); + intent.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, accName); + + InputStream is = new ByteArrayInputStream(mData.getBytes(Charset.forName("UTF-8"))); + final ByteArrayOutputStream os = new ByteArrayOutputStream(); + + DecryptVerifyCallback callback = new DecryptVerifyCallback(os, REQUEST_CODE_DECRYPT_VERIFY); + + mOpenPgpApi.executeApiAsync(intent, is, os, callback); + } + + private void getMissingKey() { + try { + mFragment.getActivity().startIntentSenderForResult( + mMissingKeyPI.getIntentSender(), + REQUEST_CODE_DECRYPT_VERIFY, null, 0, 0, 0); + } catch (SendIntentException e) { + Log.e(K9.LOG_TAG, "SendIntentException", e); + } + } + + /** + * Called on successful decrypt/verification + */ + private class DecryptVerifyCallback implements OpenPgpApi.IOpenPgpCallback { + ByteArrayOutputStream os; + int requestCode; + + private DecryptVerifyCallback(ByteArrayOutputStream os, int requestCode) { + this.os = os; + this.requestCode = requestCode; + } + + @Override + public void onReturn(Intent result) { + switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) { + case OpenPgpApi.RESULT_CODE_SUCCESS: { + try { + final String output = os.toString("UTF-8"); + + OpenPgpSignatureResult sigResult = null; + if (result.hasExtra(OpenPgpApi.RESULT_SIGNATURE)) { + sigResult = result.getParcelableExtra(OpenPgpApi.RESULT_SIGNATURE); + } + + if (K9.DEBUG) + Log.d(K9.LOG_TAG, "result: " + os.toByteArray().length + + " str=" + output); + + // missing key -> PendingIntent to get keys + mMissingKeyPI = result.getParcelableExtra(OpenPgpApi.RESULT_INTENT); + + mProgress.setVisibility(View.GONE); + mFragment.setMessageWithOpenPgp(output, sigResult); + } catch (UnsupportedEncodingException e) { + Log.e(K9.LOG_TAG, "UnsupportedEncodingException", e); + } + break; + } + case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: { + PendingIntent pi = result.getParcelableExtra(OpenPgpApi.RESULT_INTENT); + try { + mFragment.getActivity().startIntentSenderForResult( + pi.getIntentSender(), + requestCode, null, 0, 0, 0); + } catch (SendIntentException e) { + Log.e(K9.LOG_TAG, "SendIntentException", e); + } + break; + } + case OpenPgpApi.RESULT_CODE_ERROR: { + OpenPgpError error = result.getParcelableExtra(OpenPgpApi.RESULT_ERROR); + handleError(error); + break; + } + } + } + } + + public boolean handleOnActivityResult(int requestCode, int resultCode, Intent data) { + if (K9.DEBUG) + Log.d(K9.LOG_TAG, "onActivityResult resultCode: " + resultCode); + + // try again after user interaction + if (resultCode == Activity.RESULT_OK && requestCode == REQUEST_CODE_DECRYPT_VERIFY) { + /* + * The data originally given to the decryptVerify() method, is again + * returned here to be used when calling decryptVerify() after user + * interaction. The Intent now also contains results from the user + * interaction, for example selected key ids. + */ + decryptVerify(data); + + return true; + } + + return false; + } + + private void handleError(final OpenPgpError error) { + Activity activity = mFragment.getActivity(); + if (activity == null) { + return; + } + activity.runOnUiThread(new Runnable() { + + @Override + public void run() { + mProgress.setVisibility(View.GONE); + + if (K9.DEBUG) { + Log.d(K9.LOG_TAG, "OpenPGP Error ID:" + error.getErrorId()); + Log.d(K9.LOG_TAG, "OpenPGP Error Message:" + error.getMessage()); + } + + mText.setText(mFragment.getString(R.string.openpgp_error) + " " + + error.getMessage()); + MessageOpenPgpViewOld.this.setBackgroundColor(mFragment.getResources().getColor( + R.color.openpgp_red)); + } + }); + } + + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + + // bind to service if a OpenPGP Provider is available + if (mOpenPgpProvider != null) { + mOpenPgpServiceConnection = new OpenPgpServiceConnection(mFragment.getActivity(), + mOpenPgpProvider); + mOpenPgpServiceConnection.bindToService(); + } + } + + @Override + protected void onDetachedFromWindow() { + super.onDetachedFromWindow(); + + if (mOpenPgpServiceConnection != null) { + mOpenPgpServiceConnection.unbindFromService(); + } + } + +} diff --git a/k9mail/src/main/java/com/fsck/k9/ui/messageview/SingleMessageView.java b/k9mail/src/main/java/com/fsck/k9/ui/messageview/SingleMessageView.java index ac9ed9953..e3d61764b 100644 --- a/k9mail/src/main/java/com/fsck/k9/ui/messageview/SingleMessageView.java +++ b/k9mail/src/main/java/com/fsck/k9/ui/messageview/SingleMessageView.java @@ -88,7 +88,7 @@ public class SingleMessageView extends LinearLayout implements OnClickListener, private static final int DISPLAY_NAME_INDEX = 1; - private MessageOpenPgpView mOpenPgpView; + private MessageOpenPgpViewOld mOpenPgpView; private MessageWebView mMessageContentView; private MessageHeader mHeaderContainer; private LinearLayout mAttachments; @@ -126,7 +126,7 @@ public class SingleMessageView extends LinearLayout implements OnClickListener, mHiddenAttachments.setVisibility(View.GONE); mShowHiddenAttachments = (Button) findViewById(R.id.show_hidden_attachments); mShowHiddenAttachments.setVisibility(View.GONE); - mOpenPgpView = (MessageOpenPgpView) findViewById(R.id.layout_decrypt_openpgp); + mOpenPgpView = (MessageOpenPgpViewOld) findViewById(R.id.layout_decrypt_openpgp); mOpenPgpView.setFragment(fragment); mOpenPgpView.setupChildViews(); mShowPicturesAction = findViewById(R.id.show_pictures); diff --git a/k9mail/src/main/res/drawable-hdpi/status_lock_closed.png b/k9mail/src/main/res/drawable-hdpi/status_lock_closed.png new file mode 100644 index 000000000..a1b090630 Binary files /dev/null and b/k9mail/src/main/res/drawable-hdpi/status_lock_closed.png differ diff --git a/k9mail/src/main/res/drawable-hdpi/status_lock_error.png b/k9mail/src/main/res/drawable-hdpi/status_lock_error.png new file mode 100644 index 000000000..e567055aa Binary files /dev/null and b/k9mail/src/main/res/drawable-hdpi/status_lock_error.png differ diff --git a/k9mail/src/main/res/drawable-hdpi/status_lock_open.png b/k9mail/src/main/res/drawable-hdpi/status_lock_open.png new file mode 100644 index 000000000..98e32eadc Binary files /dev/null and b/k9mail/src/main/res/drawable-hdpi/status_lock_open.png differ diff --git a/k9mail/src/main/res/drawable-hdpi/status_signature_expired_cutout.png b/k9mail/src/main/res/drawable-hdpi/status_signature_expired_cutout.png new file mode 100644 index 000000000..84ac9bec2 Binary files /dev/null and b/k9mail/src/main/res/drawable-hdpi/status_signature_expired_cutout.png differ diff --git a/k9mail/src/main/res/drawable-hdpi/status_signature_invalid_cutout.png b/k9mail/src/main/res/drawable-hdpi/status_signature_invalid_cutout.png new file mode 100644 index 000000000..967e00e80 Binary files /dev/null and b/k9mail/src/main/res/drawable-hdpi/status_signature_invalid_cutout.png differ diff --git a/k9mail/src/main/res/drawable-hdpi/status_signature_revoked_cutout.png b/k9mail/src/main/res/drawable-hdpi/status_signature_revoked_cutout.png new file mode 100644 index 000000000..244dd0708 Binary files /dev/null and b/k9mail/src/main/res/drawable-hdpi/status_signature_revoked_cutout.png differ diff --git a/k9mail/src/main/res/drawable-hdpi/status_signature_unknown_cutout.png b/k9mail/src/main/res/drawable-hdpi/status_signature_unknown_cutout.png new file mode 100644 index 000000000..82cc25a4b Binary files /dev/null and b/k9mail/src/main/res/drawable-hdpi/status_signature_unknown_cutout.png differ diff --git a/k9mail/src/main/res/drawable-hdpi/status_signature_unverified_cutout.png b/k9mail/src/main/res/drawable-hdpi/status_signature_unverified_cutout.png new file mode 100644 index 000000000..e752eaeab Binary files /dev/null and b/k9mail/src/main/res/drawable-hdpi/status_signature_unverified_cutout.png differ diff --git a/k9mail/src/main/res/drawable-hdpi/status_signature_verified_cutout.png b/k9mail/src/main/res/drawable-hdpi/status_signature_verified_cutout.png new file mode 100644 index 000000000..08a9f464c Binary files /dev/null and b/k9mail/src/main/res/drawable-hdpi/status_signature_verified_cutout.png differ diff --git a/k9mail/src/main/res/drawable-mdpi/status_lock_closed.png b/k9mail/src/main/res/drawable-mdpi/status_lock_closed.png new file mode 100644 index 000000000..cfc39f0e7 Binary files /dev/null and b/k9mail/src/main/res/drawable-mdpi/status_lock_closed.png differ diff --git a/k9mail/src/main/res/drawable-mdpi/status_lock_error.png b/k9mail/src/main/res/drawable-mdpi/status_lock_error.png new file mode 100644 index 000000000..824dc2672 Binary files /dev/null and b/k9mail/src/main/res/drawable-mdpi/status_lock_error.png differ diff --git a/k9mail/src/main/res/drawable-mdpi/status_lock_open.png b/k9mail/src/main/res/drawable-mdpi/status_lock_open.png new file mode 100644 index 000000000..9bca59ae3 Binary files /dev/null and b/k9mail/src/main/res/drawable-mdpi/status_lock_open.png differ diff --git a/k9mail/src/main/res/drawable-mdpi/status_signature_expired_cutout.png b/k9mail/src/main/res/drawable-mdpi/status_signature_expired_cutout.png new file mode 100644 index 000000000..bc91094b5 Binary files /dev/null and b/k9mail/src/main/res/drawable-mdpi/status_signature_expired_cutout.png differ diff --git a/k9mail/src/main/res/drawable-mdpi/status_signature_invalid_cutout.png b/k9mail/src/main/res/drawable-mdpi/status_signature_invalid_cutout.png new file mode 100644 index 000000000..bc2f56e2a Binary files /dev/null and b/k9mail/src/main/res/drawable-mdpi/status_signature_invalid_cutout.png differ diff --git a/k9mail/src/main/res/drawable-mdpi/status_signature_revoked_cutout.png b/k9mail/src/main/res/drawable-mdpi/status_signature_revoked_cutout.png new file mode 100644 index 000000000..2d2593194 Binary files /dev/null and b/k9mail/src/main/res/drawable-mdpi/status_signature_revoked_cutout.png differ diff --git a/k9mail/src/main/res/drawable-mdpi/status_signature_unknown_cutout.png b/k9mail/src/main/res/drawable-mdpi/status_signature_unknown_cutout.png new file mode 100644 index 000000000..0fc74d07e Binary files /dev/null and b/k9mail/src/main/res/drawable-mdpi/status_signature_unknown_cutout.png differ diff --git a/k9mail/src/main/res/drawable-mdpi/status_signature_unverified_cutout.png b/k9mail/src/main/res/drawable-mdpi/status_signature_unverified_cutout.png new file mode 100644 index 000000000..96a2d1413 Binary files /dev/null and b/k9mail/src/main/res/drawable-mdpi/status_signature_unverified_cutout.png differ diff --git a/k9mail/src/main/res/drawable-mdpi/status_signature_verified_cutout.png b/k9mail/src/main/res/drawable-mdpi/status_signature_verified_cutout.png new file mode 100644 index 000000000..9f7cf837c Binary files /dev/null and b/k9mail/src/main/res/drawable-mdpi/status_signature_verified_cutout.png differ diff --git a/k9mail/src/main/res/drawable-xhdpi/status_lock_closed.png b/k9mail/src/main/res/drawable-xhdpi/status_lock_closed.png new file mode 100644 index 000000000..7c6bb2d18 Binary files /dev/null and b/k9mail/src/main/res/drawable-xhdpi/status_lock_closed.png differ diff --git a/k9mail/src/main/res/drawable-xhdpi/status_lock_error.png b/k9mail/src/main/res/drawable-xhdpi/status_lock_error.png new file mode 100644 index 000000000..da4a5d89a Binary files /dev/null and b/k9mail/src/main/res/drawable-xhdpi/status_lock_error.png differ diff --git a/k9mail/src/main/res/drawable-xhdpi/status_lock_open.png b/k9mail/src/main/res/drawable-xhdpi/status_lock_open.png new file mode 100644 index 000000000..cd02fc1e4 Binary files /dev/null and b/k9mail/src/main/res/drawable-xhdpi/status_lock_open.png differ diff --git a/k9mail/src/main/res/drawable-xhdpi/status_signature_expired_cutout.png b/k9mail/src/main/res/drawable-xhdpi/status_signature_expired_cutout.png new file mode 100644 index 000000000..83f6fde35 Binary files /dev/null and b/k9mail/src/main/res/drawable-xhdpi/status_signature_expired_cutout.png differ diff --git a/k9mail/src/main/res/drawable-xhdpi/status_signature_invalid_cutout.png b/k9mail/src/main/res/drawable-xhdpi/status_signature_invalid_cutout.png new file mode 100644 index 000000000..29830f5ba Binary files /dev/null and b/k9mail/src/main/res/drawable-xhdpi/status_signature_invalid_cutout.png differ diff --git a/k9mail/src/main/res/drawable-xhdpi/status_signature_revoked_cutout.png b/k9mail/src/main/res/drawable-xhdpi/status_signature_revoked_cutout.png new file mode 100644 index 000000000..2f7695043 Binary files /dev/null and b/k9mail/src/main/res/drawable-xhdpi/status_signature_revoked_cutout.png differ diff --git a/k9mail/src/main/res/drawable-xhdpi/status_signature_unknown_cutout.png b/k9mail/src/main/res/drawable-xhdpi/status_signature_unknown_cutout.png new file mode 100644 index 000000000..2ce28c7ca Binary files /dev/null and b/k9mail/src/main/res/drawable-xhdpi/status_signature_unknown_cutout.png differ diff --git a/k9mail/src/main/res/drawable-xhdpi/status_signature_unverified_cutout.png b/k9mail/src/main/res/drawable-xhdpi/status_signature_unverified_cutout.png new file mode 100644 index 000000000..442c55eee Binary files /dev/null and b/k9mail/src/main/res/drawable-xhdpi/status_signature_unverified_cutout.png differ diff --git a/k9mail/src/main/res/drawable-xhdpi/status_signature_verified_cutout.png b/k9mail/src/main/res/drawable-xhdpi/status_signature_verified_cutout.png new file mode 100644 index 000000000..160ec7cbe Binary files /dev/null and b/k9mail/src/main/res/drawable-xhdpi/status_signature_verified_cutout.png differ diff --git a/k9mail/src/main/res/drawable-xxhdpi/status_lock_closed.png b/k9mail/src/main/res/drawable-xxhdpi/status_lock_closed.png new file mode 100644 index 000000000..5a9664d59 Binary files /dev/null and b/k9mail/src/main/res/drawable-xxhdpi/status_lock_closed.png differ diff --git a/k9mail/src/main/res/drawable-xxhdpi/status_lock_error.png b/k9mail/src/main/res/drawable-xxhdpi/status_lock_error.png new file mode 100644 index 000000000..608f065af Binary files /dev/null and b/k9mail/src/main/res/drawable-xxhdpi/status_lock_error.png differ diff --git a/k9mail/src/main/res/drawable-xxhdpi/status_lock_open.png b/k9mail/src/main/res/drawable-xxhdpi/status_lock_open.png new file mode 100644 index 000000000..ee34dd396 Binary files /dev/null and b/k9mail/src/main/res/drawable-xxhdpi/status_lock_open.png differ diff --git a/k9mail/src/main/res/drawable-xxhdpi/status_signature_expired_cutout.png b/k9mail/src/main/res/drawable-xxhdpi/status_signature_expired_cutout.png new file mode 100644 index 000000000..33a3efed1 Binary files /dev/null and b/k9mail/src/main/res/drawable-xxhdpi/status_signature_expired_cutout.png differ diff --git a/k9mail/src/main/res/drawable-xxhdpi/status_signature_invalid_cutout.png b/k9mail/src/main/res/drawable-xxhdpi/status_signature_invalid_cutout.png new file mode 100644 index 000000000..bc39d3496 Binary files /dev/null and b/k9mail/src/main/res/drawable-xxhdpi/status_signature_invalid_cutout.png differ diff --git a/k9mail/src/main/res/drawable-xxhdpi/status_signature_revoked_cutout.png b/k9mail/src/main/res/drawable-xxhdpi/status_signature_revoked_cutout.png new file mode 100644 index 000000000..58929661f Binary files /dev/null and b/k9mail/src/main/res/drawable-xxhdpi/status_signature_revoked_cutout.png differ diff --git a/k9mail/src/main/res/drawable-xxhdpi/status_signature_unknown_cutout.png b/k9mail/src/main/res/drawable-xxhdpi/status_signature_unknown_cutout.png new file mode 100644 index 000000000..3020357a4 Binary files /dev/null and b/k9mail/src/main/res/drawable-xxhdpi/status_signature_unknown_cutout.png differ diff --git a/k9mail/src/main/res/drawable-xxhdpi/status_signature_unverified_cutout.png b/k9mail/src/main/res/drawable-xxhdpi/status_signature_unverified_cutout.png new file mode 100644 index 000000000..3829bb3a0 Binary files /dev/null and b/k9mail/src/main/res/drawable-xxhdpi/status_signature_unverified_cutout.png differ diff --git a/k9mail/src/main/res/drawable-xxhdpi/status_signature_verified_cutout.png b/k9mail/src/main/res/drawable-xxhdpi/status_signature_verified_cutout.png new file mode 100644 index 000000000..3548ee2b6 Binary files /dev/null and b/k9mail/src/main/res/drawable-xxhdpi/status_signature_verified_cutout.png differ diff --git a/k9mail/src/main/res/layout/message_view_header.xml b/k9mail/src/main/res/layout/message_view_header.xml index 0e838158f..18f764e67 100644 --- a/k9mail/src/main/res/layout/message_view_header.xml +++ b/k9mail/src/main/res/layout/message_view_header.xml @@ -250,6 +250,6 @@ - + diff --git a/k9mail/src/main/res/layout/message_view_openpgp_layout.xml b/k9mail/src/main/res/layout/message_view_openpgp_layout.xml index 6d4a2ca06..5441c624d 100644 --- a/k9mail/src/main/res/layout/message_view_openpgp_layout.xml +++ b/k9mail/src/main/res/layout/message_view_openpgp_layout.xml @@ -3,71 +3,195 @@ android:id="@+id/layout_decrypt_openpgp" android:layout_width="match_parent" android:layout_height="wrap_content" - android:orientation="horizontal" - android:visibility="gone" > + android:orientation="horizontal"> + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingLeft="16dp" + android:paddingRight="16dp" + android:paddingTop="4dp" + android:paddingBottom="4dp"> - - - + android:layout_width="match_parent" + android:layout_height="wrap_content"> - - - - - - - - + + - + android:text="Not Encrypted (set in-code)" + android:layout_marginLeft="8dp" + android:layout_marginTop="8dp" + android:layout_marginBottom="8dp" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +