show attach button in conferences when http upload is available

This commit is contained in:
Daniel Gultsch 2015-06-28 13:14:21 +02:00
parent 9eb9a52205
commit 7e11570f2c
4 changed files with 14 additions and 7 deletions

View File

@ -44,6 +44,10 @@ public class Account extends AbstractEntity {
public static final int OPTION_REGISTER = 2; public static final int OPTION_REGISTER = 2;
public static final int OPTION_USECOMPRESSION = 3; public static final int OPTION_USECOMPRESSION = 3;
public boolean httpUploadAvailable() {
return xmppConnection != null && xmppConnection.getFeatures().httpUpload();
}
public static enum State { public static enum State {
DISABLED, DISABLED,
OFFLINE, OFFLINE,

View File

@ -145,6 +145,7 @@ public class HttpUploadConnection implements Downloadable {
Message.ImageParams params = message.getImageParams(); Message.ImageParams params = message.getImageParams();
message.setBody(mGetUrl.toString()+"|"+String.valueOf(params.size)+"|"+String.valueOf(params.width)+"|"+String.valueOf(params.height)); message.setBody(mGetUrl.toString()+"|"+String.valueOf(params.size)+"|"+String.valueOf(params.width)+"|"+String.valueOf(params.height));
message.setDownloadable(null); message.setDownloadable(null);
message.setCounterpart(message.getConversation().getJid().toBareJid());
mXmppConnectionService.resendMessage(message); mXmppConnectionService.resendMessage(message);
} else { } else {
fail(); fail();

View File

@ -692,7 +692,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
if (account.getStatus() == Account.State.ONLINE if (account.getStatus() == Account.State.ONLINE
&& account.getXmppConnection() != null) { && account.getXmppConnection() != null) {
if (message.needsUploading()) { if (message.needsUploading()) {
if (message.getCounterpart() != null) { if (message.getCounterpart() != null || account.httpUploadAvailable()) {
if (message.getEncryption() == Message.ENCRYPTION_OTR) { if (message.getEncryption() == Message.ENCRYPTION_OTR) {
if (!conv.hasValidOtrSession()) { if (!conv.hasValidOtrSession()) {
conv.startOtrSession(message.getCounterpart().getResourcepart(),true); conv.startOtrSession(message.getCounterpart().getResourcepart(),true);
@ -834,8 +834,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
} else if (message.needsUploading()) { } else if (message.needsUploading()) {
Contact contact = message.getConversation().getContact(); Contact contact = message.getConversation().getContact();
Presences presences = contact.getPresences(); Presences presences = contact.getPresences();
if ((message.getCounterpart() != null) if (account.httpUploadAvailable() || (message.getCounterpart() != null && presences.has(message.getCounterpart().getResourcepart()))) {
&& (presences.has(message.getCounterpart().getResourcepart()))) {
this.sendFileMessage(message); this.sendFileMessage(message);
} else { } else {
if (presences.size() == 1) { if (presences.size() == 1) {

View File

@ -35,6 +35,7 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import eu.siacs.conversations.R; import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Blockable; import eu.siacs.conversations.entities.Blockable;
import eu.siacs.conversations.entities.Contact; import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.Conversation;
@ -382,7 +383,7 @@ public class ConversationActivity extends XmppActivity
} }
if (this.getSelectedConversation().getMode() == Conversation.MODE_MULTI) { if (this.getSelectedConversation().getMode() == Conversation.MODE_MULTI) {
menuContactDetails.setVisible(false); menuContactDetails.setVisible(false);
menuAttach.setVisible(false); menuAttach.setVisible(getSelectedConversation().getAccount().httpUploadAvailable());
menuInviteContact.setVisible(getSelectedConversation().getMucOptions().canInvite()); menuInviteContact.setVisible(getSelectedConversation().getMucOptions().canInvite());
} else { } else {
menuMucDetails.setVisible(false); menuMucDetails.setVisible(false);
@ -398,6 +399,8 @@ public class ConversationActivity extends XmppActivity
} }
private void selectPresenceToAttachFile(final int attachmentChoice, final int encryption) { private void selectPresenceToAttachFile(final int attachmentChoice, final int encryption) {
final Conversation conversation = getSelectedConversation();
final Account account = conversation.getAccount();
final OnPresenceSelected callback = new OnPresenceSelected() { final OnPresenceSelected callback = new OnPresenceSelected() {
@Override @Override
@ -449,11 +452,11 @@ public class ConversationActivity extends XmppActivity
} }
} }
}; };
if (attachmentChoice == ATTACHMENT_CHOICE_LOCATION && encryption != Message.ENCRYPTION_OTR) { if ((account.httpUploadAvailable() || attachmentChoice == ATTACHMENT_CHOICE_LOCATION) && encryption != Message.ENCRYPTION_OTR) {
getSelectedConversation().setNextCounterpart(null); conversation.setNextCounterpart(null);
callback.onPresenceSelected(); callback.onPresenceSelected();
} else { } else {
selectPresence(getSelectedConversation(),callback); selectPresence(conversation,callback);
} }
} }