1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-23 18:02:15 -05:00

always show OpenPgpHeader if crypto-provider is set

This commit is contained in:
Vincent Breitmoser 2015-01-28 18:11:38 +01:00
parent 4827b4c437
commit bcd570f884
4 changed files with 43 additions and 35 deletions

View File

@ -435,9 +435,7 @@ public class LocalMessageExtractor {
// TODO correctly extract OpenPgpSignatureResult and add to MessageViewContainer // TODO correctly extract OpenPgpSignatureResult and add to MessageViewContainer
OpenPgpSignatureResult result = null; OpenPgpSignatureResult result = null;
result = new OpenPgpSignatureResult(OpenPgpSignatureResult.SIGNATURE_SUCCESS_CERTIFIED, "lul", false, 0x123, containers.add(new MessageViewContainer(viewable.html, attachmentInfos, result, false, null));
new ArrayList<String>());
containers.add(new MessageViewContainer(viewable.html, attachmentInfos, result, true, null));
} }

View File

@ -103,10 +103,13 @@ public class MessageContainerView extends LinearLayout implements OnClickListene
private ClipboardManager mClipboardManager; private ClipboardManager mClipboardManager;
private String mText; private String mText;
private Map<AttachmentViewInfo, AttachmentView> attachments = new HashMap<AttachmentViewInfo, AttachmentView>(); private Map<AttachmentViewInfo, AttachmentView> attachments = new HashMap<AttachmentViewInfo, AttachmentView>();
private boolean displayPgpData;
private OpenPgpHeaderView openPgpHeaderView;
public void initialize(Fragment fragment, AttachmentViewCallback attachmentCallback, public void initialize(Fragment fragment, AttachmentViewCallback attachmentCallback,
OpenPgpHeaderViewCallback openPgpHeaderViewCallback) { OpenPgpHeaderViewCallback openPgpHeaderViewCallback,
boolean displayPgpData) {
this.attachmentCallback = attachmentCallback; this.attachmentCallback = attachmentCallback;
this.openPgpHeaderViewCallback = openPgpHeaderViewCallback; this.openPgpHeaderViewCallback = openPgpHeaderViewCallback;
@ -137,6 +140,13 @@ public class MessageContainerView extends LinearLayout implements OnClickListene
mInflater = ((MessageViewFragment) fragment).getFragmentLayoutInflater(); mInflater = ((MessageViewFragment) fragment).getFragmentLayoutInflater();
mMessageContentView.setVisibility(View.VISIBLE); mMessageContentView.setVisibility(View.VISIBLE);
this.displayPgpData = displayPgpData;
if (displayPgpData) {
openPgpHeaderView = (OpenPgpHeaderView) mOpenPgpHeaderStub.inflate();
openPgpHeaderView.initialize();
}
// the HTC version of WebView tries to force the background of the // the HTC version of WebView tries to force the background of the
// titlebar, which is really unfair. // titlebar, which is really unfair.
TypedValue outValue = new TypedValue(); TypedValue outValue = new TypedValue();
@ -435,14 +445,6 @@ public class MessageContainerView extends LinearLayout implements OnClickListene
throws MessagingException { throws MessagingException {
resetView(); resetView();
// mHasOpenPgpInfo = (messageViewContainer.signatureResult != null
// || messageViewContainer.encrypted);
// if (mHasOpenPgpInfo) {
renderOpenPgpHeader(messageViewContainer);
mSidebar.setVisibility(View.VISIBLE);
// }
// Save the text so we can reset the WebView when the user clicks the "Show pictures" button // Save the text so we can reset the WebView when the user clicks the "Show pictures" button
mText = messageViewContainer.text; mText = messageViewContainer.text;
@ -487,6 +489,14 @@ public class MessageContainerView extends LinearLayout implements OnClickListene
} }
*/ */
if (displayPgpData) {
openPgpHeaderView.setOpenPgpData(messageViewContainer.signatureResult, messageViewContainer.encrypted,
messageViewContainer.pgpPendingIntent);
openPgpHeaderView.setCallback(openPgpHeaderViewCallback);
}
mSidebar.setVisibility(View.VISIBLE);
if (mText != null) { if (mText != null) {
loadBodyFromText(mText); loadBodyFromText(mText);
} else { } else {
@ -503,14 +513,6 @@ public class MessageContainerView extends LinearLayout implements OnClickListene
mMessageContentView.setText(emailText); mMessageContentView.setText(emailText);
} }
public void renderOpenPgpHeader(MessageViewContainer messageContainer) {
// inflate real header into stub
OpenPgpHeaderView view = (OpenPgpHeaderView) mOpenPgpHeaderStub.inflate();
view.setCallback(openPgpHeaderViewCallback);
view.setOpenPgpData(messageContainer.signatureResult, messageContainer.encrypted,
messageContainer.pgpPendingIntent);
}
public void renderAttachments(MessageViewContainer messageContainer) throws MessagingException { public void renderAttachments(MessageViewContainer messageContainer) throws MessagingException {
for (AttachmentViewInfo attachment : messageContainer.attachments) { for (AttachmentViewInfo attachment : messageContainer.attachments) {
AttachmentView view = (AttachmentView) mInflater.inflate(R.layout.message_view_attachment, null); AttachmentView view = (AttachmentView) mInflater.inflate(R.layout.message_view_attachment, null);

View File

@ -69,7 +69,8 @@ public class MessageTopView extends LinearLayout {
for (MessageViewContainer container : messageViewInfo.containers) { for (MessageViewContainer container : messageViewInfo.containers) {
MessageContainerView view = (MessageContainerView) mInflater.inflate(R.layout.message_container, null); MessageContainerView view = (MessageContainerView) mInflater.inflate(R.layout.message_container, null);
view.initialize(fragment, attachmentCallback, openPgpHeaderViewCallback); view.initialize(fragment, attachmentCallback, openPgpHeaderViewCallback,
!Account.NO_OPENPGP_PROVIDER.equals(account.getOpenPgpProvider()));
view.setMessage(container); view.setMessage(container);
containerViews.addView(view); containerViews.addView(view);
} }

View File

@ -38,6 +38,17 @@ public class OpenPgpHeaderView extends LinearLayout {
mContext = context; mContext = context;
} }
public void initialize () {
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);
mResultSignatureButton = (Button) findViewById(R.id.result_signature_button);
}
public void setOpenPgpData(OpenPgpSignatureResult signatureResult, public void setOpenPgpData(OpenPgpSignatureResult signatureResult,
boolean encrypted, PendingIntent pendingIntent) { boolean encrypted, PendingIntent pendingIntent) {
this.signatureResult = signatureResult; this.signatureResult = signatureResult;
@ -52,21 +63,17 @@ public class OpenPgpHeaderView extends LinearLayout {
} }
public void displayOpenPgpView() { public void displayOpenPgpView() {
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);
mResultSignatureButton = (Button) findViewById(R.id.result_signature_button);
mResultSignatureButton.setOnClickListener(new OnClickListener() { if (pendingIntent != null) {
@Override mResultSignatureButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) { @Override
callback.onPgpSignatureButtonClick(pendingIntent); public void onClick(View v) {
} callback.onPgpSignatureButtonClick(pendingIntent);
}); }
});
} else {
mResultSignatureButton.setOnClickListener(null);
}
if (encrypted) { if (encrypted) {
setStatusImage(mContext, mResultEncryptionIcon, mResultEncryptionText, STATE_ENCRYPTED); setStatusImage(mContext, mResultEncryptionIcon, mResultEncryptionText, STATE_ENCRYPTED);