diff options
Diffstat (limited to '')
3 files changed, 39 insertions, 6 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java index bb85439a..42252ede 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java @@ -54,6 +54,7 @@ import eu.siacs.conversations.entities.Contact; import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.entities.Transferable; +import eu.siacs.conversations.persistance.FileBackend; import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate; import eu.siacs.conversations.services.XmppConnectionService.OnConversationUpdate; @@ -1298,12 +1299,31 @@ public class ConversationActivity extends XmppActivity } } } else if (requestCode == ATTACHMENT_CHOICE_CHOOSE_FILE || requestCode == ATTACHMENT_CHOICE_RECORD_VOICE) { - mPendingFileUris.clear(); - mPendingFileUris.addAll(extractUriFromIntent(data)); - if (xmppConnectionServiceBound) { - for (Iterator<Uri> i = mPendingFileUris.iterator(); i.hasNext(); i.remove()) { - attachFileToConversation(getSelectedConversation(), i.next()); + final List<Uri> uris = extractUriFromIntent(data); + final Conversation c = getSelectedConversation(); + final long max = c.getAccount() + .getXmppConnection() + .getFeatures() + .getMaxHttpUploadSize(); + final OnPresenceSelected callback = new OnPresenceSelected() { + @Override + public void onPresenceSelected() { + mPendingFileUris.clear(); + mPendingFileUris.addAll(uris); + if (xmppConnectionServiceBound) { + for (Iterator<Uri> i = mPendingFileUris.iterator(); i.hasNext(); i.remove()) { + attachFileToConversation(c, i.next()); + } + } } + }; + if (max <= 0 + || c.getMode() == Conversation.MODE_MULTI + || FileBackend.allFilesUnderSize(this, uris, max) + || c.getNextEncryption() == Message.ENCRYPTION_OTR) { + callback.onPresenceSelected(); + } else { + selectPresence(c, callback); } } else if (requestCode == ATTACHMENT_CHOICE_TAKE_PHOTO) { if (mPendingImageUris.size() == 1) { diff --git a/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java b/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java index ae722081..90333cfe 100644 --- a/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java @@ -24,6 +24,7 @@ import eu.siacs.conversations.R; import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.Message; +import eu.siacs.conversations.persistance.FileBackend; import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.ui.adapter.ConversationAdapter; import eu.siacs.conversations.xmpp.jid.InvalidJidException; @@ -259,6 +260,7 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer } private void share(final Conversation conversation) { + final Account account = conversation.getAccount(); mListView.setEnabled(false); if (conversation.getNextEncryption() == Message.ENCRYPTION_PGP && !hasPgp()) { if (share.uuid == null) { @@ -270,6 +272,9 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer return; } if (share.uris.size() != 0) { + final long max = account.getXmppConnection() + .getFeatures() + .getMaxHttpUploadSize(); OnPresenceSelected callback = new OnPresenceSelected() { @Override public void onPresenceSelected() { @@ -290,7 +295,11 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer } } }; - if (conversation.getAccount().httpUploadAvailable()) { + if (account.httpUploadAvailable() + && ( + (share.image && !neverCompressPictures()) + || conversation.getMode() == Conversation.MODE_MULTI + || FileBackend.allFilesUnderSize(this, share.uris, max))) { callback.onPresenceSelected(); } else { selectPresence(conversation, callback); diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java index fe3a3031..7d70b20f 100644 --- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java @@ -1002,6 +1002,10 @@ public abstract class XmppActivity extends Activity { } } + protected boolean neverCompressPictures() { + return getPreferences().getString("picture_compression", "auto").equals("never"); + } + protected void unregisterNdefPushMessageCallback() { NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this); if (nfcAdapter != null && nfcAdapter.isEnabled()) { |