block send action while encrypting pgp message

This commit is contained in:
Daniel Gultsch 2017-03-03 11:56:08 +01:00
parent 469cf72e56
commit afa34ce15a
2 changed files with 15 additions and 0 deletions

View File

@ -1688,6 +1688,9 @@ public class ConversationActivity extends XmppActivity
).show();
}
});
if (mConversationFragment != null) {
mConversationFragment.doneSendingPgpMessage();
}
}
});
}

View File

@ -48,6 +48,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
@ -1071,6 +1072,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
}
protected void messageSent() {
mSendingPgpMessage.set(false);
mEditMessage.setText("");
updateChatMsgHint();
new Handler().post(new Runnable() {
@ -1086,6 +1088,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) {
@ -1299,6 +1305,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;
@ -1311,6 +1319,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,
@ -1340,6 +1351,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
).show();
}
});
mSendingPgpMessage.set(false);
}
});