mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 11:42:16 -05:00
Callback to execute signature button click
This commit is contained in:
parent
fdc597aadf
commit
6f156498ed
@ -97,6 +97,7 @@ public class MessageContainerView extends LinearLayout implements OnClickListene
|
||||
private LayoutInflater mInflater;
|
||||
private Contacts mContacts;
|
||||
private AttachmentViewCallback attachmentCallback;
|
||||
private OpenPgpHeaderViewCallback openPgpHeaderViewCallback;
|
||||
private View mAttachmentsContainer;
|
||||
private SavedState mSavedState;
|
||||
private ClipboardManager mClipboardManager;
|
||||
@ -104,8 +105,10 @@ public class MessageContainerView extends LinearLayout implements OnClickListene
|
||||
private Map<AttachmentViewInfo, AttachmentView> attachments = new HashMap<AttachmentViewInfo, AttachmentView>();
|
||||
|
||||
|
||||
public void initialize(Fragment fragment, AttachmentViewCallback attachmentCallback) {
|
||||
public void initialize(Fragment fragment, AttachmentViewCallback attachmentCallback,
|
||||
OpenPgpHeaderViewCallback openPgpHeaderViewCallback) {
|
||||
this.attachmentCallback = attachmentCallback;
|
||||
this.openPgpHeaderViewCallback = openPgpHeaderViewCallback;
|
||||
|
||||
mOpenPgpHeaderStub = (ViewStub) findViewById(R.id.openpgp_header_stub);
|
||||
mSidebar = findViewById(R.id.message_sidebar);
|
||||
@ -437,6 +440,7 @@ public class MessageContainerView extends LinearLayout implements OnClickListene
|
||||
// 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
|
||||
@ -502,8 +506,9 @@ public class MessageContainerView extends LinearLayout implements OnClickListene
|
||||
public void renderOpenPgpHeader(MessageViewContainer messageContainer) {
|
||||
// inflate real header into stub
|
||||
OpenPgpHeaderView view = (OpenPgpHeaderView) mOpenPgpHeaderStub.inflate();
|
||||
// view.setCallback(attachmentCallback);
|
||||
view.setOpenPgpData(messageContainer.signatureResult, messageContainer.encrypted);
|
||||
view.setCallback(openPgpHeaderViewCallback);
|
||||
view.setOpenPgpData(messageContainer.signatureResult, messageContainer.encrypted,
|
||||
messageContainer.pgpPendingIntent);
|
||||
}
|
||||
|
||||
public void renderAttachments(MessageViewContainer messageContainer) throws MessagingException {
|
||||
|
@ -31,14 +31,17 @@ public class MessageTopView extends LinearLayout {
|
||||
private Fragment fragment;
|
||||
private Button mDownloadRemainder;
|
||||
private AttachmentViewCallback attachmentCallback;
|
||||
private OpenPgpHeaderViewCallback openPgpHeaderViewCallback;
|
||||
|
||||
public MessageTopView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public void initialize (Fragment fragment, AttachmentViewCallback attachmentCallback) {
|
||||
public void initialize (Fragment fragment, AttachmentViewCallback attachmentCallback,
|
||||
OpenPgpHeaderViewCallback openPgpHeaderViewCallback) {
|
||||
this.fragment = fragment;
|
||||
this.attachmentCallback = attachmentCallback;
|
||||
this.openPgpHeaderViewCallback = openPgpHeaderViewCallback;
|
||||
|
||||
mHeaderContainer = (MessageHeader) findViewById(R.id.header_container);
|
||||
// mHeaderContainer.setOnLayoutChangedListener(this);
|
||||
@ -66,7 +69,7 @@ public class MessageTopView extends LinearLayout {
|
||||
|
||||
for (MessageViewContainer container : messageViewInfo.containers) {
|
||||
MessageContainerView view = (MessageContainerView) mInflater.inflate(R.layout.message_container, null);
|
||||
view.initialize(fragment, attachmentCallback);
|
||||
view.initialize(fragment, attachmentCallback, openPgpHeaderViewCallback);
|
||||
view.setMessage(container);
|
||||
containerViews.addView(view);
|
||||
}
|
||||
|
@ -10,8 +10,10 @@ import android.app.Fragment;
|
||||
import android.app.FragmentManager;
|
||||
import android.app.LoaderManager;
|
||||
import android.app.LoaderManager.LoaderCallbacks;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentSender;
|
||||
import android.content.Loader;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
@ -52,7 +54,7 @@ import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||
|
||||
|
||||
public class MessageViewFragment extends Fragment implements ConfirmationDialogFragmentListener,
|
||||
AttachmentViewCallback {
|
||||
AttachmentViewCallback, OpenPgpHeaderViewCallback {
|
||||
|
||||
private static final String ARG_REFERENCE = "reference";
|
||||
|
||||
@ -147,7 +149,7 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
|
||||
|
||||
mMessageView = (MessageTopView) view.findViewById(R.id.message_view);
|
||||
|
||||
mMessageView.initialize(this, this);
|
||||
mMessageView.initialize(this, this, this);
|
||||
mMessageView.setOnToggleFlagClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@ -697,6 +699,17 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
|
||||
// mMessageView.refreshAttachmentThumbnail(attachment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPgpSignatureButtonClick(PendingIntent pendingIntent) {
|
||||
try {
|
||||
getActivity().startIntentSenderForResult(
|
||||
pendingIntent.getIntentSender(),
|
||||
42, null, 0, 0, 0);
|
||||
} catch (IntentSender.SendIntentException e) {
|
||||
Log.e(K9.LOG_TAG, "SendIntentException", e);
|
||||
}
|
||||
}
|
||||
|
||||
public interface MessageViewFragmentListener {
|
||||
public void onForward(LocalMessage mMessage, PgpData mPgpData);
|
||||
public void disableDeleteAction();
|
||||
|
@ -1,6 +1,7 @@
|
||||
|
||||
package com.fsck.k9.ui.messageview;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.util.AttributeSet;
|
||||
@ -16,10 +17,12 @@ import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||
|
||||
public class OpenPgpHeaderView extends LinearLayout {
|
||||
private Context mContext;
|
||||
private OpenPgpHeaderViewCallback callback;
|
||||
|
||||
private OpenPgpSignatureResult signatureResult;
|
||||
private boolean encrypted;
|
||||
|
||||
private Context mContext;
|
||||
private PendingIntent pendingIntent;
|
||||
|
||||
private ImageView mResultEncryptionIcon;
|
||||
private TextView mResultEncryptionText;
|
||||
@ -30,22 +33,24 @@ public class OpenPgpHeaderView extends LinearLayout {
|
||||
private TextView mResultSignatureEmail;
|
||||
private Button mResultSignatureButton;
|
||||
|
||||
// private PendingIntent mMissingKeyPI;
|
||||
// private static final int REQUEST_CODE_DECRYPT_VERIFY = 12;
|
||||
|
||||
public OpenPgpHeaderView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
public void setOpenPgpData(OpenPgpSignatureResult signatureResult,
|
||||
boolean encrypted) {
|
||||
boolean encrypted, PendingIntent pendingIntent) {
|
||||
this.signatureResult = signatureResult;
|
||||
this.encrypted = encrypted;
|
||||
this.pendingIntent = pendingIntent;
|
||||
|
||||
displayOpenPgpView();
|
||||
}
|
||||
|
||||
public void setCallback(OpenPgpHeaderViewCallback callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
public void displayOpenPgpView() {
|
||||
mResultEncryptionIcon = (ImageView) findViewById(R.id.result_encryption_icon);
|
||||
mResultEncryptionText = (TextView) findViewById(R.id.result_encryption_text);
|
||||
@ -56,17 +61,12 @@ public class OpenPgpHeaderView extends LinearLayout {
|
||||
mResultSignatureEmail = (TextView) findViewById(R.id.result_signature_email);
|
||||
mResultSignatureButton = (Button) findViewById(R.id.result_signature_button);
|
||||
|
||||
// mGetKeyButton.setOnClickListener(new OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// getMissingKey();
|
||||
// }
|
||||
// });
|
||||
|
||||
// public void setFragment(Fragment fragment) {
|
||||
// mFragment = (MessageViewFragment) fragment;
|
||||
// }
|
||||
|
||||
mResultSignatureButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
callback.onPgpSignatureButtonClick(pendingIntent);
|
||||
}
|
||||
});
|
||||
|
||||
if (encrypted) {
|
||||
setStatusImage(mContext, mResultEncryptionIcon, mResultEncryptionText, STATE_ENCRYPTED);
|
||||
@ -95,6 +95,7 @@ public class OpenPgpHeaderView extends LinearLayout {
|
||||
mResultSignatureText.setText(R.string.openpgp_result_signature_certified);
|
||||
|
||||
setUserId(signatureResult);
|
||||
mResultSignatureButton.setText(R.string.openpgp_result_action_show);
|
||||
mResultSignatureButton.setVisibility(View.VISIBLE);
|
||||
mResultSignatureLayout.setVisibility(View.VISIBLE);
|
||||
|
||||
@ -105,6 +106,7 @@ public class OpenPgpHeaderView extends LinearLayout {
|
||||
mResultSignatureText.setText(R.string.openpgp_result_signature_missing_key);
|
||||
|
||||
setUserId(signatureResult);
|
||||
mResultSignatureButton.setText(R.string.openpgp_result_action_lookup);
|
||||
mResultSignatureButton.setVisibility(View.VISIBLE);
|
||||
mResultSignatureLayout.setVisibility(View.VISIBLE);
|
||||
|
||||
@ -115,6 +117,7 @@ public class OpenPgpHeaderView extends LinearLayout {
|
||||
mResultSignatureText.setText(R.string.openpgp_result_signature_uncertified);
|
||||
|
||||
setUserId(signatureResult);
|
||||
mResultSignatureButton.setText(R.string.openpgp_result_action_show);
|
||||
mResultSignatureButton.setVisibility(View.VISIBLE);
|
||||
mResultSignatureLayout.setVisibility(View.VISIBLE);
|
||||
|
||||
@ -125,6 +128,7 @@ public class OpenPgpHeaderView extends LinearLayout {
|
||||
mResultSignatureText.setText(R.string.openpgp_result_signature_expired_key);
|
||||
|
||||
setUserId(signatureResult);
|
||||
mResultSignatureButton.setText(R.string.openpgp_result_action_show);
|
||||
mResultSignatureButton.setVisibility(View.VISIBLE);
|
||||
mResultSignatureLayout.setVisibility(View.VISIBLE);
|
||||
|
||||
@ -135,6 +139,7 @@ public class OpenPgpHeaderView extends LinearLayout {
|
||||
mResultSignatureText.setText(R.string.openpgp_result_signature_revoked_key);
|
||||
|
||||
setUserId(signatureResult);
|
||||
mResultSignatureButton.setText(R.string.openpgp_result_action_show);
|
||||
mResultSignatureButton.setVisibility(View.VISIBLE);
|
||||
mResultSignatureLayout.setVisibility(View.VISIBLE);
|
||||
|
||||
@ -153,12 +158,12 @@ public class OpenPgpHeaderView extends LinearLayout {
|
||||
if (splitUserId[0] != null) {
|
||||
mResultSignatureName.setText(splitUserId[0]);
|
||||
} else {
|
||||
mResultSignatureName.setText("no name");
|
||||
mResultSignatureName.setText(R.string.openpgp_result_no_name);
|
||||
}
|
||||
if (splitUserId[1] != null) {
|
||||
mResultSignatureEmail.setText(splitUserId[1]);
|
||||
} else {
|
||||
mResultSignatureEmail.setText("no email");
|
||||
mResultSignatureEmail.setText(R.string.openpgp_result_no_email);
|
||||
}
|
||||
}
|
||||
|
||||
@ -288,14 +293,4 @@ public class OpenPgpHeaderView extends LinearLayout {
|
||||
}
|
||||
}
|
||||
|
||||
// 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);
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,9 @@
|
||||
package com.fsck.k9.ui.messageview;
|
||||
|
||||
|
||||
import android.app.PendingIntent;
|
||||
|
||||
|
||||
interface OpenPgpHeaderViewCallback {
|
||||
void onPgpSignatureButtonClick(PendingIntent pendingIntent);
|
||||
}
|
@ -1127,7 +1127,9 @@ Please submit bug reports, contribute new features and ask questions at
|
||||
<string name="openpgp_result_encrypted">"Encrypted"</string>
|
||||
<string name="openpgp_result_not_encrypted">"Not Encrypted"</string>
|
||||
<string name="openpgp_result_action_show">"Show"</string>
|
||||
<string name="openpgp_result_action_Lookup">"Lookup"</string>
|
||||
<string name="openpgp_result_action_lookup">"Lookup"</string>
|
||||
<string name="openpgp_result_no_name">"No name"</string>
|
||||
<string name="openpgp_result_no_email">"No email"</string>
|
||||
|
||||
<!-- === Client certificates specific ================================================================== -->
|
||||
<string name="account_setup_basics_client_certificate">Use client certificate</string>
|
||||
|
Loading…
Reference in New Issue
Block a user