wait with presence selection until attachment commit
This commit is contained in:
		
							parent
							
								
									b2ea91909b
								
							
						
					
					
						commit
						bcab77a044
					
				| @ -877,7 +877,10 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke | |||||||
|             mediaPreviewAdapter.notifyDataSetChanged(); |             mediaPreviewAdapter.notifyDataSetChanged(); | ||||||
|             toggleInputMethod(); |             toggleInputMethod(); | ||||||
|         }; |         }; | ||||||
|         if (conversation == null || conversation.getMode() == Conversation.MODE_MULTI || FileBackend.allFilesUnderSize(getActivity(), attachments, getMaxHttpUploadSize(conversation))) { |         if (conversation == null | ||||||
|  |                 || conversation.getMode() == Conversation.MODE_MULTI | ||||||
|  |                 || Attachment.canBeSendInband(attachments) | ||||||
|  |                 || (conversation.getAccount().httpUploadAvailable() && FileBackend.allFilesUnderSize(getActivity(), attachments, getMaxHttpUploadSize(conversation)))) { | ||||||
|             callback.onPresenceSelected(); |             callback.onPresenceSelected(); | ||||||
|         } else { |         } else { | ||||||
|             activity.selectPresence(conversation, callback); |             activity.selectPresence(conversation, callback); | ||||||
| @ -1329,7 +1332,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke | |||||||
| 
 | 
 | ||||||
|                                 @Override |                                 @Override | ||||||
|                                 public void success(Contact contact) { |                                 public void success(Contact contact) { | ||||||
|                                     selectPresenceToAttachFile(attachmentChoice); |                                     invokeAttachFileIntent(attachmentChoice); | ||||||
|                                 } |                                 } | ||||||
| 
 | 
 | ||||||
|                                 @Override |                                 @Override | ||||||
| @ -1343,19 +1346,19 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke | |||||||
|                         warning.setGravity(Gravity.CENTER_VERTICAL, 0, 0); |                         warning.setGravity(Gravity.CENTER_VERTICAL, 0, 0); | ||||||
|                         warning.show(); |                         warning.show(); | ||||||
|                     } |                     } | ||||||
|                     selectPresenceToAttachFile(attachmentChoice); |                     invokeAttachFileIntent(attachmentChoice); | ||||||
|                 } else { |                 } else { | ||||||
|                     showNoPGPKeyDialog(false, (dialog, which) -> { |                     showNoPGPKeyDialog(false, (dialog, which) -> { | ||||||
|                         conversation.setNextEncryption(Message.ENCRYPTION_NONE); |                         conversation.setNextEncryption(Message.ENCRYPTION_NONE); | ||||||
|                         activity.xmppConnectionService.updateConversation(conversation); |                         activity.xmppConnectionService.updateConversation(conversation); | ||||||
|                         selectPresenceToAttachFile(attachmentChoice); |                         invokeAttachFileIntent(attachmentChoice); | ||||||
|                     }); |                     }); | ||||||
|                 } |                 } | ||||||
|             } else { |             } else { | ||||||
|                 activity.showInstallPgpDialog(); |                 activity.showInstallPgpDialog(); | ||||||
|             } |             } | ||||||
|         } else { |         } else { | ||||||
|             selectPresenceToAttachFile(attachmentChoice); |             invokeAttachFileIntent(attachmentChoice); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -1509,9 +1512,8 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke | |||||||
|         getActivity().invalidateOptionsMenu(); |         getActivity().invalidateOptionsMenu(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     protected void selectPresenceToAttachFile(final int attachmentChoice) { | 
 | ||||||
|         final Account account = conversation.getAccount(); |     protected void invokeAttachFileIntent(final int attachmentChoice) { | ||||||
|         final PresenceSelector.OnPresenceSelected callback = () -> { |  | ||||||
|         Intent intent = new Intent(); |         Intent intent = new Intent(); | ||||||
|         boolean chooser = false; |         boolean chooser = false; | ||||||
|         switch (attachmentChoice) { |         switch (attachmentChoice) { | ||||||
| @ -1559,12 +1561,6 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke | |||||||
|                 startActivityForResult(intent, attachmentChoice); |                 startActivityForResult(intent, attachmentChoice); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         }; |  | ||||||
|         if (account.httpUploadAvailable() || attachmentChoice == ATTACHMENT_CHOICE_LOCATION) { |  | ||||||
|             callback.onPresenceSelected(); |  | ||||||
|         } else { |  | ||||||
|             activity.selectPresence(conversation, callback); |  | ||||||
|         } |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|  | |||||||
| @ -111,6 +111,15 @@ public class Attachment implements Parcelable { | |||||||
|         this.uuid = UUID.randomUUID(); |         this.uuid = UUID.randomUUID(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public static boolean canBeSendInband(final List<Attachment> attachments) { | ||||||
|  |         for(Attachment attachment : attachments) { | ||||||
|  |             if (attachment.type != Type.LOCATION) { | ||||||
|  |                 return false; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         return true; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     public static List<Attachment> of(final Context context, Uri uri, Type type) { |     public static List<Attachment> of(final Context context, Uri uri, Type type) { | ||||||
|         final String mime = type == Type.LOCATION ?null :MimeUtils.guessMimeTypeFromUri(context, uri); |         final String mime = type == Type.LOCATION ?null :MimeUtils.guessMimeTypeFromUri(context, uri); | ||||||
|         return Collections.singletonList(new Attachment(uri, type, mime)); |         return Collections.singletonList(new Attachment(uri, type, mime)); | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Daniel Gultsch
						Daniel Gultsch