aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2015-06-28 13:14:21 +0200
committerDaniel Gultsch <daniel@gultsch.de>2015-06-29 15:21:41 +0200
commit7e11570f2c2eeeab17b4c024442bb849b40899df (patch)
tree68a005c26064fad3355f63afcc1737095c0d287e /src/main/java
parent9eb9a522050589e60bc7c76b2b040b1dadb7fd1d (diff)
show attach button in conferences when http upload is available
Diffstat (limited to '')
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Account.java4
-rw-r--r--src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java1
-rw-r--r--src/main/java/eu/siacs/conversations/services/XmppConnectionService.java5
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationActivity.java11
4 files changed, 14 insertions, 7 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Account.java b/src/main/java/eu/siacs/conversations/entities/Account.java
index 6e6dcb6a..f472361f 100644
--- a/src/main/java/eu/siacs/conversations/entities/Account.java
+++ b/src/main/java/eu/siacs/conversations/entities/Account.java
@@ -44,6 +44,10 @@ public class Account extends AbstractEntity {
public static final int OPTION_REGISTER = 2;
public static final int OPTION_USECOMPRESSION = 3;
+ public boolean httpUploadAvailable() {
+ return xmppConnection != null && xmppConnection.getFeatures().httpUpload();
+ }
+
public static enum State {
DISABLED,
OFFLINE,
diff --git a/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java b/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java
index e16d93e1..32e8cdff 100644
--- a/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java
+++ b/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java
@@ -145,6 +145,7 @@ public class HttpUploadConnection implements Downloadable {
Message.ImageParams params = message.getImageParams();
message.setBody(mGetUrl.toString()+"|"+String.valueOf(params.size)+"|"+String.valueOf(params.width)+"|"+String.valueOf(params.height));
message.setDownloadable(null);
+ message.setCounterpart(message.getConversation().getJid().toBareJid());
mXmppConnectionService.resendMessage(message);
} else {
fail();
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
index 90b2ee17..877806f3 100644
--- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
@@ -692,7 +692,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
if (account.getStatus() == Account.State.ONLINE
&& account.getXmppConnection() != null) {
if (message.needsUploading()) {
- if (message.getCounterpart() != null) {
+ if (message.getCounterpart() != null || account.httpUploadAvailable()) {
if (message.getEncryption() == Message.ENCRYPTION_OTR) {
if (!conv.hasValidOtrSession()) {
conv.startOtrSession(message.getCounterpart().getResourcepart(),true);
@@ -834,8 +834,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
} else if (message.needsUploading()) {
Contact contact = message.getConversation().getContact();
Presences presences = contact.getPresences();
- if ((message.getCounterpart() != null)
- && (presences.has(message.getCounterpart().getResourcepart()))) {
+ if (account.httpUploadAvailable() || (message.getCounterpart() != null && presences.has(message.getCounterpart().getResourcepart()))) {
this.sendFileMessage(message);
} else {
if (presences.size() == 1) {
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
index c48b5865..770129ab 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
@@ -35,6 +35,7 @@ import java.util.Iterator;
import java.util.List;
import eu.siacs.conversations.R;
+import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Blockable;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
@@ -382,7 +383,7 @@ public class ConversationActivity extends XmppActivity
}
if (this.getSelectedConversation().getMode() == Conversation.MODE_MULTI) {
menuContactDetails.setVisible(false);
- menuAttach.setVisible(false);
+ menuAttach.setVisible(getSelectedConversation().getAccount().httpUploadAvailable());
menuInviteContact.setVisible(getSelectedConversation().getMucOptions().canInvite());
} else {
menuMucDetails.setVisible(false);
@@ -398,6 +399,8 @@ public class ConversationActivity extends XmppActivity
}
private void selectPresenceToAttachFile(final int attachmentChoice, final int encryption) {
+ final Conversation conversation = getSelectedConversation();
+ final Account account = conversation.getAccount();
final OnPresenceSelected callback = new OnPresenceSelected() {
@Override
@@ -449,11 +452,11 @@ public class ConversationActivity extends XmppActivity
}
}
};
- if (attachmentChoice == ATTACHMENT_CHOICE_LOCATION && encryption != Message.ENCRYPTION_OTR) {
- getSelectedConversation().setNextCounterpart(null);
+ if ((account.httpUploadAvailable() || attachmentChoice == ATTACHMENT_CHOICE_LOCATION) && encryption != Message.ENCRYPTION_OTR) {
+ conversation.setNextCounterpart(null);
callback.onPresenceSelected();
} else {
- selectPresence(getSelectedConversation(),callback);
+ selectPresence(conversation,callback);
}
}