1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-23 09:52:16 -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
OpenPgpSignatureResult result = null;
result = new OpenPgpSignatureResult(OpenPgpSignatureResult.SIGNATURE_SUCCESS_CERTIFIED, "lul", false, 0x123,
new ArrayList<String>());
containers.add(new MessageViewContainer(viewable.html, attachmentInfos, result, true, null));
containers.add(new MessageViewContainer(viewable.html, attachmentInfos, result, false, null));
}

View File

@ -103,10 +103,13 @@ public class MessageContainerView extends LinearLayout implements OnClickListene
private ClipboardManager mClipboardManager;
private String mText;
private Map<AttachmentViewInfo, AttachmentView> attachments = new HashMap<AttachmentViewInfo, AttachmentView>();
private boolean displayPgpData;
private OpenPgpHeaderView openPgpHeaderView;
public void initialize(Fragment fragment, AttachmentViewCallback attachmentCallback,
OpenPgpHeaderViewCallback openPgpHeaderViewCallback) {
OpenPgpHeaderViewCallback openPgpHeaderViewCallback,
boolean displayPgpData) {
this.attachmentCallback = attachmentCallback;
this.openPgpHeaderViewCallback = openPgpHeaderViewCallback;
@ -137,6 +140,13 @@ public class MessageContainerView extends LinearLayout implements OnClickListene
mInflater = ((MessageViewFragment) fragment).getFragmentLayoutInflater();
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
// titlebar, which is really unfair.
TypedValue outValue = new TypedValue();
@ -435,14 +445,6 @@ public class MessageContainerView extends LinearLayout implements OnClickListene
throws MessagingException {
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
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) {
loadBodyFromText(mText);
} else {
@ -503,14 +513,6 @@ public class MessageContainerView extends LinearLayout implements OnClickListene
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 {
for (AttachmentViewInfo attachment : messageContainer.attachments) {
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) {
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);
containerViews.addView(view);
}

View File

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