aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/ui/ShareWithActivity.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/ui/ShareWithActivity.java')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ui/ShareWithActivity.java62
1 files changed, 33 insertions, 29 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/ShareWithActivity.java b/src/main/java/de/thedevstack/conversationsplus/ui/ShareWithActivity.java
index 55a19b42..e73b7cbe 100644
--- a/src/main/java/de/thedevstack/conversationsplus/ui/ShareWithActivity.java
+++ b/src/main/java/de/thedevstack/conversationsplus/ui/ShareWithActivity.java
@@ -14,21 +14,23 @@ import android.widget.Toast;
import java.net.URLConnection;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
-import de.thedevstack.conversationsplus.Config;
+import de.thedevstack.conversationsplus.ConversationsPlusPreferences;
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.ui.adapter.ConversationAdapter;
+import de.thedevstack.conversationsplus.ui.dialogs.UserDecisionDialog;
+import de.thedevstack.conversationsplus.ui.listeners.ResizePictureUserDecisionListener;
+import de.thedevstack.conversationsplus.ui.listeners.ShareWithResizePictureUserDecisionListener;
import de.thedevstack.conversationsplus.xmpp.jid.InvalidJidException;
import de.thedevstack.conversationsplus.xmpp.jid.Jid;
public class ShareWithActivity extends XmppActivity {
- private class Share {
+ public class Share {
public List<Uri> uris = new ArrayList<>();
public boolean image;
public String account;
@@ -193,34 +195,36 @@ public class ShareWithActivity extends XmppActivity {
private void share(final Conversation conversation) {
if (share.uris.size() != 0) {
- OnPresenceSelected callback = new OnPresenceSelected() {
- @Override
- public void onPresenceSelected() {
- if (share.image) {
- Toast.makeText(getApplicationContext(),
- getText(R.string.preparing_image),
- Toast.LENGTH_LONG).show();
- for (Iterator<Uri> i = share.uris.iterator(); i.hasNext(); i.remove()) {
- ShareWithActivity.this.xmppConnectionService
- .attachImageToConversation(conversation, i.next(),
- attachFileCallback);
- }
- } else {
- Toast.makeText(getApplicationContext(),
- getText(R.string.preparing_file),
- Toast.LENGTH_LONG).show();
- ShareWithActivity.this.xmppConnectionService
- .attachFileToConversation(conversation, share.uris.get(0),
- attachFileCallback);
- }
- switchToConversation(conversation, null, true);
- finish();
- }
- };
+ OnPresenceSelected callback;
+ if (this.share.image) {
+ callback = new OnPresenceSelected() {
+ @Override
+ public void onPresenceSelected() {
+ ResizePictureUserDecisionListener userDecisionListener = new ShareWithResizePictureUserDecisionListener(ShareWithActivity.this, conversation, xmppConnectionService, share.uris);
+ UserDecisionDialog userDecisionDialog = new UserDecisionDialog(ShareWithActivity.this, R.string.userdecision_question_resize_picture, userDecisionListener);
+ userDecisionDialog.decide(ConversationsPlusPreferences.resizePicture());
+ }
+ };
+ } else {
+ callback = new OnPresenceSelected() {
+ @Override
+ public void onPresenceSelected() {
+ Toast.makeText(getApplicationContext(),
+ getText(R.string.preparing_file),
+ Toast.LENGTH_LONG).show();
+ ShareWithActivity.this.xmppConnectionService
+ .attachFileToConversation(conversation, share.uris.get(0),
+ attachFileCallback);
+ switchToConversation(conversation, null, true);
+ finish();
+ }
+ };
+ }
+
if (conversation.getAccount().httpUploadAvailable()) {
- callback.onPresenceSelected();
+ callback.onPresenceSelected();
} else {
- selectPresence(conversation, callback);
+ selectPresence(conversation, callback);
}
} else {
switchToConversation(conversation, this.share.text, true);