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 LayoutInflater mInflater;
|
||||||
private Contacts mContacts;
|
private Contacts mContacts;
|
||||||
private AttachmentViewCallback attachmentCallback;
|
private AttachmentViewCallback attachmentCallback;
|
||||||
|
private OpenPgpHeaderViewCallback openPgpHeaderViewCallback;
|
||||||
private View mAttachmentsContainer;
|
private View mAttachmentsContainer;
|
||||||
private SavedState mSavedState;
|
private SavedState mSavedState;
|
||||||
private ClipboardManager mClipboardManager;
|
private ClipboardManager mClipboardManager;
|
||||||
@ -104,8 +105,10 @@ public class MessageContainerView extends LinearLayout implements OnClickListene
|
|||||||
private Map<AttachmentViewInfo, AttachmentView> attachments = new HashMap<AttachmentViewInfo, AttachmentView>();
|
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.attachmentCallback = attachmentCallback;
|
||||||
|
this.openPgpHeaderViewCallback = openPgpHeaderViewCallback;
|
||||||
|
|
||||||
mOpenPgpHeaderStub = (ViewStub) findViewById(R.id.openpgp_header_stub);
|
mOpenPgpHeaderStub = (ViewStub) findViewById(R.id.openpgp_header_stub);
|
||||||
mSidebar = findViewById(R.id.message_sidebar);
|
mSidebar = findViewById(R.id.message_sidebar);
|
||||||
@ -437,6 +440,7 @@ public class MessageContainerView extends LinearLayout implements OnClickListene
|
|||||||
// if (mHasOpenPgpInfo) {
|
// if (mHasOpenPgpInfo) {
|
||||||
renderOpenPgpHeader(messageViewContainer);
|
renderOpenPgpHeader(messageViewContainer);
|
||||||
mSidebar.setVisibility(View.VISIBLE);
|
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
|
||||||
@ -502,8 +506,9 @@ public class MessageContainerView extends LinearLayout implements OnClickListene
|
|||||||
public void renderOpenPgpHeader(MessageViewContainer messageContainer) {
|
public void renderOpenPgpHeader(MessageViewContainer messageContainer) {
|
||||||
// inflate real header into stub
|
// inflate real header into stub
|
||||||
OpenPgpHeaderView view = (OpenPgpHeaderView) mOpenPgpHeaderStub.inflate();
|
OpenPgpHeaderView view = (OpenPgpHeaderView) mOpenPgpHeaderStub.inflate();
|
||||||
// view.setCallback(attachmentCallback);
|
view.setCallback(openPgpHeaderViewCallback);
|
||||||
view.setOpenPgpData(messageContainer.signatureResult, messageContainer.encrypted);
|
view.setOpenPgpData(messageContainer.signatureResult, messageContainer.encrypted,
|
||||||
|
messageContainer.pgpPendingIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderAttachments(MessageViewContainer messageContainer) throws MessagingException {
|
public void renderAttachments(MessageViewContainer messageContainer) throws MessagingException {
|
||||||
|
@ -31,14 +31,17 @@ public class MessageTopView extends LinearLayout {
|
|||||||
private Fragment fragment;
|
private Fragment fragment;
|
||||||
private Button mDownloadRemainder;
|
private Button mDownloadRemainder;
|
||||||
private AttachmentViewCallback attachmentCallback;
|
private AttachmentViewCallback attachmentCallback;
|
||||||
|
private OpenPgpHeaderViewCallback openPgpHeaderViewCallback;
|
||||||
|
|
||||||
public MessageTopView(Context context, AttributeSet attrs) {
|
public MessageTopView(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initialize (Fragment fragment, AttachmentViewCallback attachmentCallback) {
|
public void initialize (Fragment fragment, AttachmentViewCallback attachmentCallback,
|
||||||
|
OpenPgpHeaderViewCallback openPgpHeaderViewCallback) {
|
||||||
this.fragment = fragment;
|
this.fragment = fragment;
|
||||||
this.attachmentCallback = attachmentCallback;
|
this.attachmentCallback = attachmentCallback;
|
||||||
|
this.openPgpHeaderViewCallback = openPgpHeaderViewCallback;
|
||||||
|
|
||||||
mHeaderContainer = (MessageHeader) findViewById(R.id.header_container);
|
mHeaderContainer = (MessageHeader) findViewById(R.id.header_container);
|
||||||
// mHeaderContainer.setOnLayoutChangedListener(this);
|
// mHeaderContainer.setOnLayoutChangedListener(this);
|
||||||
@ -66,7 +69,7 @@ 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);
|
view.initialize(fragment, attachmentCallback, openPgpHeaderViewCallback);
|
||||||
view.setMessage(container);
|
view.setMessage(container);
|
||||||
containerViews.addView(view);
|
containerViews.addView(view);
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,10 @@ import android.app.Fragment;
|
|||||||
import android.app.FragmentManager;
|
import android.app.FragmentManager;
|
||||||
import android.app.LoaderManager;
|
import android.app.LoaderManager;
|
||||||
import android.app.LoaderManager.LoaderCallbacks;
|
import android.app.LoaderManager.LoaderCallbacks;
|
||||||
|
import android.app.PendingIntent;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.IntentSender;
|
||||||
import android.content.Loader;
|
import android.content.Loader;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -52,7 +54,7 @@ import org.openintents.openpgp.OpenPgpSignatureResult;
|
|||||||
|
|
||||||
|
|
||||||
public class MessageViewFragment extends Fragment implements ConfirmationDialogFragmentListener,
|
public class MessageViewFragment extends Fragment implements ConfirmationDialogFragmentListener,
|
||||||
AttachmentViewCallback {
|
AttachmentViewCallback, OpenPgpHeaderViewCallback {
|
||||||
|
|
||||||
private static final String ARG_REFERENCE = "reference";
|
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 = (MessageTopView) view.findViewById(R.id.message_view);
|
||||||
|
|
||||||
mMessageView.initialize(this, this);
|
mMessageView.initialize(this, this, this);
|
||||||
mMessageView.setOnToggleFlagClickListener(new OnClickListener() {
|
mMessageView.setOnToggleFlagClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@ -697,6 +699,17 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
|
|||||||
// mMessageView.refreshAttachmentThumbnail(attachment);
|
// 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 interface MessageViewFragmentListener {
|
||||||
public void onForward(LocalMessage mMessage, PgpData mPgpData);
|
public void onForward(LocalMessage mMessage, PgpData mPgpData);
|
||||||
public void disableDeleteAction();
|
public void disableDeleteAction();
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
package com.fsck.k9.ui.messageview;
|
package com.fsck.k9.ui.messageview;
|
||||||
|
|
||||||
|
import android.app.PendingIntent;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
@ -16,10 +17,12 @@ import org.openintents.openpgp.OpenPgpSignatureResult;
|
|||||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||||
|
|
||||||
public class OpenPgpHeaderView extends LinearLayout {
|
public class OpenPgpHeaderView extends LinearLayout {
|
||||||
|
private Context mContext;
|
||||||
|
private OpenPgpHeaderViewCallback callback;
|
||||||
|
|
||||||
private OpenPgpSignatureResult signatureResult;
|
private OpenPgpSignatureResult signatureResult;
|
||||||
private boolean encrypted;
|
private boolean encrypted;
|
||||||
|
private PendingIntent pendingIntent;
|
||||||
private Context mContext;
|
|
||||||
|
|
||||||
private ImageView mResultEncryptionIcon;
|
private ImageView mResultEncryptionIcon;
|
||||||
private TextView mResultEncryptionText;
|
private TextView mResultEncryptionText;
|
||||||
@ -30,22 +33,24 @@ public class OpenPgpHeaderView extends LinearLayout {
|
|||||||
private TextView mResultSignatureEmail;
|
private TextView mResultSignatureEmail;
|
||||||
private Button mResultSignatureButton;
|
private Button mResultSignatureButton;
|
||||||
|
|
||||||
// private PendingIntent mMissingKeyPI;
|
|
||||||
// private static final int REQUEST_CODE_DECRYPT_VERIFY = 12;
|
|
||||||
|
|
||||||
public OpenPgpHeaderView(Context context, AttributeSet attrs) {
|
public OpenPgpHeaderView(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
mContext = context;
|
mContext = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOpenPgpData(OpenPgpSignatureResult signatureResult,
|
public void setOpenPgpData(OpenPgpSignatureResult signatureResult,
|
||||||
boolean encrypted) {
|
boolean encrypted, PendingIntent pendingIntent) {
|
||||||
this.signatureResult = signatureResult;
|
this.signatureResult = signatureResult;
|
||||||
this.encrypted = encrypted;
|
this.encrypted = encrypted;
|
||||||
|
this.pendingIntent = pendingIntent;
|
||||||
|
|
||||||
displayOpenPgpView();
|
displayOpenPgpView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCallback(OpenPgpHeaderViewCallback callback) {
|
||||||
|
this.callback = callback;
|
||||||
|
}
|
||||||
|
|
||||||
public void displayOpenPgpView() {
|
public void displayOpenPgpView() {
|
||||||
mResultEncryptionIcon = (ImageView) findViewById(R.id.result_encryption_icon);
|
mResultEncryptionIcon = (ImageView) findViewById(R.id.result_encryption_icon);
|
||||||
mResultEncryptionText = (TextView) findViewById(R.id.result_encryption_text);
|
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);
|
mResultSignatureEmail = (TextView) findViewById(R.id.result_signature_email);
|
||||||
mResultSignatureButton = (Button) findViewById(R.id.result_signature_button);
|
mResultSignatureButton = (Button) findViewById(R.id.result_signature_button);
|
||||||
|
|
||||||
// mGetKeyButton.setOnClickListener(new OnClickListener() {
|
mResultSignatureButton.setOnClickListener(new OnClickListener() {
|
||||||
// @Override
|
@Override
|
||||||
// public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
// getMissingKey();
|
callback.onPgpSignatureButtonClick(pendingIntent);
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
|
|
||||||
// public void setFragment(Fragment fragment) {
|
|
||||||
// mFragment = (MessageViewFragment) fragment;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
if (encrypted) {
|
if (encrypted) {
|
||||||
setStatusImage(mContext, mResultEncryptionIcon, mResultEncryptionText, STATE_ENCRYPTED);
|
setStatusImage(mContext, mResultEncryptionIcon, mResultEncryptionText, STATE_ENCRYPTED);
|
||||||
@ -95,6 +95,7 @@ public class OpenPgpHeaderView extends LinearLayout {
|
|||||||
mResultSignatureText.setText(R.string.openpgp_result_signature_certified);
|
mResultSignatureText.setText(R.string.openpgp_result_signature_certified);
|
||||||
|
|
||||||
setUserId(signatureResult);
|
setUserId(signatureResult);
|
||||||
|
mResultSignatureButton.setText(R.string.openpgp_result_action_show);
|
||||||
mResultSignatureButton.setVisibility(View.VISIBLE);
|
mResultSignatureButton.setVisibility(View.VISIBLE);
|
||||||
mResultSignatureLayout.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);
|
mResultSignatureText.setText(R.string.openpgp_result_signature_missing_key);
|
||||||
|
|
||||||
setUserId(signatureResult);
|
setUserId(signatureResult);
|
||||||
|
mResultSignatureButton.setText(R.string.openpgp_result_action_lookup);
|
||||||
mResultSignatureButton.setVisibility(View.VISIBLE);
|
mResultSignatureButton.setVisibility(View.VISIBLE);
|
||||||
mResultSignatureLayout.setVisibility(View.VISIBLE);
|
mResultSignatureLayout.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
@ -115,6 +117,7 @@ public class OpenPgpHeaderView extends LinearLayout {
|
|||||||
mResultSignatureText.setText(R.string.openpgp_result_signature_uncertified);
|
mResultSignatureText.setText(R.string.openpgp_result_signature_uncertified);
|
||||||
|
|
||||||
setUserId(signatureResult);
|
setUserId(signatureResult);
|
||||||
|
mResultSignatureButton.setText(R.string.openpgp_result_action_show);
|
||||||
mResultSignatureButton.setVisibility(View.VISIBLE);
|
mResultSignatureButton.setVisibility(View.VISIBLE);
|
||||||
mResultSignatureLayout.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);
|
mResultSignatureText.setText(R.string.openpgp_result_signature_expired_key);
|
||||||
|
|
||||||
setUserId(signatureResult);
|
setUserId(signatureResult);
|
||||||
|
mResultSignatureButton.setText(R.string.openpgp_result_action_show);
|
||||||
mResultSignatureButton.setVisibility(View.VISIBLE);
|
mResultSignatureButton.setVisibility(View.VISIBLE);
|
||||||
mResultSignatureLayout.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);
|
mResultSignatureText.setText(R.string.openpgp_result_signature_revoked_key);
|
||||||
|
|
||||||
setUserId(signatureResult);
|
setUserId(signatureResult);
|
||||||
|
mResultSignatureButton.setText(R.string.openpgp_result_action_show);
|
||||||
mResultSignatureButton.setVisibility(View.VISIBLE);
|
mResultSignatureButton.setVisibility(View.VISIBLE);
|
||||||
mResultSignatureLayout.setVisibility(View.VISIBLE);
|
mResultSignatureLayout.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
@ -153,12 +158,12 @@ public class OpenPgpHeaderView extends LinearLayout {
|
|||||||
if (splitUserId[0] != null) {
|
if (splitUserId[0] != null) {
|
||||||
mResultSignatureName.setText(splitUserId[0]);
|
mResultSignatureName.setText(splitUserId[0]);
|
||||||
} else {
|
} else {
|
||||||
mResultSignatureName.setText("no name");
|
mResultSignatureName.setText(R.string.openpgp_result_no_name);
|
||||||
}
|
}
|
||||||
if (splitUserId[1] != null) {
|
if (splitUserId[1] != null) {
|
||||||
mResultSignatureEmail.setText(splitUserId[1]);
|
mResultSignatureEmail.setText(splitUserId[1]);
|
||||||
} else {
|
} 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_encrypted">"Encrypted"</string>
|
||||||
<string name="openpgp_result_not_encrypted">"Not Encrypted"</string>
|
<string name="openpgp_result_not_encrypted">"Not Encrypted"</string>
|
||||||
<string name="openpgp_result_action_show">"Show"</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 ================================================================== -->
|
<!-- === Client certificates specific ================================================================== -->
|
||||||
<string name="account_setup_basics_client_certificate">Use client certificate</string>
|
<string name="account_setup_basics_client_certificate">Use client certificate</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user