From 2ab35f4c9302371240184b90905d81f3238a9a46 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Sat, 4 Mar 2017 18:15:50 +0100 Subject: block send action while encrypting pgp message --- .../java/de/pixart/messenger/ui/ConversationActivity.java | 3 +++ .../java/de/pixart/messenger/ui/ConversationFragment.java | 11 +++++++++++ 2 files changed, 14 insertions(+) (limited to 'src/main/java/de/pixart/messenger/ui') diff --git a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java index 7864c9e12..8175d10bc 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java @@ -2009,6 +2009,9 @@ public class ConversationActivity extends XmppActivity ).show(); } }); + if (mConversationFragment != null) { + mConversationFragment.doneSendingPgpMessage(); + } } }); } diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index 19bee36ba..b91e90bbd 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -49,6 +49,7 @@ import java.util.Collections; import java.util.List; import java.util.Locale; import java.util.UUID; +import java.util.concurrent.atomic.AtomicBoolean; import de.pixart.messenger.Config; import de.pixart.messenger.R; @@ -1122,6 +1123,10 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa mEditMessage.requestFocus(); } + public void doneSendingPgpMessage() { + mSendingPgpMessage.set(false); + } + enum SendButtonAction {TEXT, TAKE_PHOTO, SEND_LOCATION, RECORD_VOICE, CANCEL, CHOOSE_PICTURE} private int getSendButtonImageResource(SendButtonAction action, Presence.Status status) { @@ -1343,6 +1348,8 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa messageSent(); } + private AtomicBoolean mSendingPgpMessage = new AtomicBoolean(false); + protected void sendPgpMessage(final Message message) { final ConversationActivity activity = (ConversationActivity) getActivity(); final XmppConnectionService xmppService = activity.xmppConnectionService; @@ -1355,6 +1362,9 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa activity.announcePgp(conversation.getAccount(), conversation, activity.onOpenPGPKeyPublished); return; } + if (!mSendingPgpMessage.compareAndSet(false, true)) { + Log.d(Config.LOGTAG, "sending pgp message already in progress"); + } if (conversation.getMode() == Conversation.MODE_SINGLE) { if (contact.getPgpKeyId() != 0) { xmppService.getPgpEngine().hasKey(contact, @@ -1384,6 +1394,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa ).show(); } }); + mSendingPgpMessage.set(false); } }); -- cgit v1.2.3