diff options
author | lookshe <github@lookshe.org> | 2016-04-05 23:35:38 +0200 |
---|---|---|
committer | lookshe <github@lookshe.org> | 2016-04-05 23:35:38 +0200 |
commit | 0beb3ca30b31f07e374b870e6a659256f6960170 (patch) | |
tree | 82a389561691afa508433d338e3f87aa6c8a5c7b /src/main/java/de/thedevstack/conversationsplus/ui | |
parent | 6899b9b01e416da95b9006d9f23bf1e1214f607d (diff) | |
parent | d6a076e11281d4c3fb6b9504fe99d799b04ebbbb (diff) |
Merge branch 'trz/rebase' into trz/rename
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/ui')
6 files changed, 43 insertions, 10 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/ConversationActivity.java b/src/main/java/de/thedevstack/conversationsplus/ui/ConversationActivity.java index c78d5951..5942bac6 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/ConversationActivity.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/ConversationActivity.java @@ -66,6 +66,7 @@ import de.thedevstack.conversationsplus.services.XmppConnectionService.OnConvers import de.thedevstack.conversationsplus.services.XmppConnectionService.OnRosterUpdate; import de.thedevstack.conversationsplus.ui.adapter.ConversationAdapter; import de.thedevstack.conversationsplus.utils.ExceptionHelper; +import de.thedevstack.conversationsplus.utils.FileUtils; import de.thedevstack.conversationsplus.xmpp.OnUpdateBlocklist; import de.thedevstack.conversationsplus.xmpp.jid.InvalidJidException; import de.thedevstack.conversationsplus.xmpp.jid.Jid; @@ -1306,12 +1307,30 @@ 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 (c.getMode() == Conversation.MODE_MULTI + || FileUtils.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/de/thedevstack/conversationsplus/ui/ConversationFragment.java b/src/main/java/de/thedevstack/conversationsplus/ui/ConversationFragment.java index 5a8bd3db..7c5f6ffa 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/ConversationFragment.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/ConversationFragment.java @@ -466,13 +466,13 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa highlightInConference(user); } } else { - activity.switchToContactDetails(message.getContact(), message.getAxolotlFingerprint()); + activity.switchToContactDetails(message.getContact(), message.getFingerprint()); } } else { Account account = message.getConversation().getAccount(); Intent intent = new Intent(activity, EditAccountActivity.class); intent.putExtra("jid", account.getJid().toBareJid().toString()); - intent.putExtra("fingerprint", message.getAxolotlFingerprint()); + intent.putExtra("fingerprint", message.getFingerprint()); startActivity(intent); } } diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/EditAccountActivity.java b/src/main/java/de/thedevstack/conversationsplus/ui/EditAccountActivity.java index abb43c4e..2b8e619f 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/EditAccountActivity.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/EditAccountActivity.java @@ -691,7 +691,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate } else { this.mServerInfoPep.setText(R.string.server_info_unavailable); } - if (features.httpUpload()) { + if (features.httpUpload(0)) { this.mServerInfoHttpUpload.setText(R.string.server_info_available); } else { this.mServerInfoHttpUpload.setText(R.string.server_info_unavailable); diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/ShareWithActivity.java b/src/main/java/de/thedevstack/conversationsplus/ui/ShareWithActivity.java index 3446bfbd..51fe92bb 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/ShareWithActivity.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/ShareWithActivity.java @@ -28,8 +28,10 @@ import de.thedevstack.conversationsplus.R; import de.thedevstack.conversationsplus.entities.Account; import de.thedevstack.conversationsplus.entities.Conversation; import de.thedevstack.conversationsplus.entities.Message; +import de.thedevstack.conversationsplus.persistance.FileBackend; import de.thedevstack.conversationsplus.services.XmppConnectionService; import de.thedevstack.conversationsplus.ui.adapter.ConversationAdapter; +import de.thedevstack.conversationsplus.utils.FileUtils; import de.thedevstack.conversationsplus.xmpp.jid.InvalidJidException; import de.thedevstack.conversationsplus.xmpp.jid.Jid; @@ -263,6 +265,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) { @@ -274,6 +277,9 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer return; } if (share.uris.size() != 0) { + final long max = account.getXmppConnection() + .getFeatures() + .getMaxHttpUploadSize(); OnPresenceSelected callback; if (this.share.image) { // TODO: attachementCounter should be set and decremented correctly @@ -299,7 +305,11 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer } }; } - if (conversation.getAccount().httpUploadAvailable()) { + if (account.httpUploadAvailable() + && ((share.image && !neverCompressPictures()) + || conversation.getMode() == Conversation.MODE_MULTI + || FileUtils.allFilesUnderSize(this, share.uris, max)) + && conversation.getNextEncryption() != Message.ENCRYPTION_OTR) { callback.onPresenceSelected(); } else { selectPresence(conversation, callback); diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/XmppActivity.java b/src/main/java/de/thedevstack/conversationsplus/ui/XmppActivity.java index f7856a9c..f2ee20a0 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/XmppActivity.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/XmppActivity.java @@ -957,6 +957,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()) { diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/adapter/MessageAdapter.java b/src/main/java/de/thedevstack/conversationsplus/ui/adapter/MessageAdapter.java index 9311674b..b2dca6b9 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/adapter/MessageAdapter.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/adapter/MessageAdapter.java @@ -197,7 +197,7 @@ public class MessageAdapter extends ArrayAdapter<Message> { if (message.getEncryption() == Message.ENCRYPTION_AXOLOTL) { XmppAxolotlSession.Trust trust = message.getConversation() .getAccount().getAxolotlService().getFingerprintTrust( - message.getAxolotlFingerprint()); + message.getFingerprint()); if(trust == null || (!trust.trusted() && !trust.trustedInactive())) { viewHolder.indicator.setColorFilter(ConversationsPlusColors.warning()); |