block send action while encrypting pgp message
This commit is contained in:
		
							parent
							
								
									469cf72e56
								
							
						
					
					
						commit
						afa34ce15a
					
				| @ -1688,6 +1688,9 @@ public class ConversationActivity extends XmppActivity | |||||||
| 								).show(); | 								).show(); | ||||||
| 							} | 							} | ||||||
| 						}); | 						}); | ||||||
|  | 						if (mConversationFragment != null) { | ||||||
|  | 							mConversationFragment.doneSendingPgpMessage(); | ||||||
|  | 						} | ||||||
| 					} | 					} | ||||||
| 				}); | 				}); | ||||||
| 	} | 	} | ||||||
|  | |||||||
| @ -48,6 +48,7 @@ import java.util.ArrayList; | |||||||
| import java.util.Collections; | import java.util.Collections; | ||||||
| import java.util.List; | import java.util.List; | ||||||
| import java.util.UUID; | import java.util.UUID; | ||||||
|  | import java.util.concurrent.atomic.AtomicBoolean; | ||||||
| 
 | 
 | ||||||
| import eu.siacs.conversations.Config; | import eu.siacs.conversations.Config; | ||||||
| import eu.siacs.conversations.R; | import eu.siacs.conversations.R; | ||||||
| @ -1071,6 +1072,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	protected void messageSent() { | 	protected void messageSent() { | ||||||
|  | 		mSendingPgpMessage.set(false); | ||||||
| 		mEditMessage.setText(""); | 		mEditMessage.setText(""); | ||||||
| 		updateChatMsgHint(); | 		updateChatMsgHint(); | ||||||
| 		new Handler().post(new Runnable() { | 		new Handler().post(new Runnable() { | ||||||
| @ -1086,6 +1088,10 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa | |||||||
| 		mEditMessage.requestFocus(); | 		mEditMessage.requestFocus(); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	public void doneSendingPgpMessage() { | ||||||
|  | 		mSendingPgpMessage.set(false); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	enum SendButtonAction {TEXT, TAKE_PHOTO, SEND_LOCATION, RECORD_VOICE, CANCEL, CHOOSE_PICTURE} | 	enum SendButtonAction {TEXT, TAKE_PHOTO, SEND_LOCATION, RECORD_VOICE, CANCEL, CHOOSE_PICTURE} | ||||||
| 
 | 
 | ||||||
| 	private int getSendButtonImageResource(SendButtonAction action, Presence.Status status) { | 	private int getSendButtonImageResource(SendButtonAction action, Presence.Status status) { | ||||||
| @ -1299,6 +1305,8 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa | |||||||
| 		messageSent(); | 		messageSent(); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	private AtomicBoolean mSendingPgpMessage = new AtomicBoolean(false); | ||||||
|  | 
 | ||||||
| 	protected void sendPgpMessage(final Message message) { | 	protected void sendPgpMessage(final Message message) { | ||||||
| 		final ConversationActivity activity = (ConversationActivity) getActivity(); | 		final ConversationActivity activity = (ConversationActivity) getActivity(); | ||||||
| 		final XmppConnectionService xmppService = activity.xmppConnectionService; | 		final XmppConnectionService xmppService = activity.xmppConnectionService; | ||||||
| @ -1311,6 +1319,9 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa | |||||||
| 			activity.announcePgp(conversation.getAccount(), conversation, activity.onOpenPGPKeyPublished); | 			activity.announcePgp(conversation.getAccount(), conversation, activity.onOpenPGPKeyPublished); | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
|  | 		if (!mSendingPgpMessage.compareAndSet(false,true)) { | ||||||
|  | 			Log.d(Config.LOGTAG,"sending pgp message already in progress"); | ||||||
|  | 		} | ||||||
| 		if (conversation.getMode() == Conversation.MODE_SINGLE) { | 		if (conversation.getMode() == Conversation.MODE_SINGLE) { | ||||||
| 			if (contact.getPgpKeyId() != 0) { | 			if (contact.getPgpKeyId() != 0) { | ||||||
| 				xmppService.getPgpEngine().hasKey(contact, | 				xmppService.getPgpEngine().hasKey(contact, | ||||||
| @ -1340,6 +1351,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa | |||||||
| 										).show(); | 										).show(); | ||||||
| 									} | 									} | ||||||
| 								}); | 								}); | ||||||
|  | 								mSendingPgpMessage.set(false); | ||||||
| 							} | 							} | ||||||
| 						}); | 						}); | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Daniel Gultsch
						Daniel Gultsch