From dc20aa71d95b267138d9d8ad013fde242a4f2f45 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Fri, 25 Nov 2016 23:22:35 +0100 Subject: [PATCH] add org.autocrypt.PEER_ACTION intent-filter to MessageCompose --- k9mail/src/main/AndroidManifest.xml | 4 ++++ .../java/com/fsck/k9/activity/MessageCompose.java | 11 ++++++++++- .../fsck/k9/activity/compose/RecipientPresenter.java | 5 +++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/k9mail/src/main/AndroidManifest.xml b/k9mail/src/main/AndroidManifest.xml index 0b5ffeaf6..e5a064a40 100644 --- a/k9mail/src/main/AndroidManifest.xml +++ b/k9mail/src/main/AndroidManifest.xml @@ -247,6 +247,10 @@ + + + + diff --git a/k9mail/src/main/java/com/fsck/k9/activity/MessageCompose.java b/k9mail/src/main/java/com/fsck/k9/activity/MessageCompose.java index 84544f4bb..8182a9c37 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/MessageCompose.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/MessageCompose.java @@ -29,7 +29,6 @@ import android.support.annotation.Nullable; import android.support.annotation.StringRes; import android.text.TextUtils; import android.text.TextWatcher; -import timber.log.Timber; import android.util.TypedValue; import android.view.ContextThemeWrapper; import android.view.LayoutInflater; @@ -100,6 +99,8 @@ import com.fsck.k9.search.LocalSearch; import com.fsck.k9.ui.EolConvertingEditText; import com.fsck.k9.ui.compose.QuotedMessageMvpView; import com.fsck.k9.ui.compose.QuotedMessagePresenter; +import org.openintents.openpgp.util.OpenPgpApi; +import timber.log.Timber; @SuppressWarnings("deprecation") // TODO get rid of activity dialogs and indeterminate progress bars @@ -120,6 +121,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, public static final String ACTION_REPLY_ALL = "com.fsck.k9.intent.action.REPLY_ALL"; public static final String ACTION_FORWARD = "com.fsck.k9.intent.action.FORWARD"; public static final String ACTION_EDIT_DRAFT = "com.fsck.k9.intent.action.EDIT_DRAFT"; + private static final String ACTION_AUTOCRYPT_PEER = "org.autocrypt.PEER_ACTION"; public static final String EXTRA_ACCOUNT = "account"; public static final String EXTRA_MESSAGE_REFERENCE = "message_reference"; @@ -534,7 +536,14 @@ public class MessageCompose extends K9Activity implements OnClickListener, } recipientPresenter.initFromSendOrViewIntent(intent); + } + if (ACTION_AUTOCRYPT_PEER.equals(action)) { + String trustId = intent.getStringExtra(OpenPgpApi.EXTRA_AUTOCRYPT_PEER_ID); + if (trustId != null) { + recipientPresenter.initFromTrustIdAction(trustId); + startedByExternalIntent = true; + } } return startedByExternalIntent; diff --git a/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.java b/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.java index 07cf0fc0a..434fc63b3 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.java @@ -166,6 +166,11 @@ public class RecipientPresenter implements PermissionPingCallback { } } + public void initFromTrustIdAction(String trustId) { + addToAddresses(Address.parse(trustId)); + currentCryptoMode = CryptoMode.CHOICE_ENABLED; + } + public void initFromMailto(MailTo mailTo) { addToAddresses(mailTo.getTo()); addCcAddresses(mailTo.getCc());