aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/ui
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2016-08-28 21:53:23 +0200
committerChristian Schneppe <christian@pix-art.de>2016-08-28 21:53:23 +0200
commit084faa3a6277f7270882209468e65dd38f10cdd5 (patch)
treede593d7dd066af3f4a0915f37afb5c3cbff5d996 /src/main/java/de/pixart/messenger/ui
parent1aca12fdfdcbb334e279583de0d70d611d22af6a (diff)
parentb3b3475e93a9b08f9e35edbf74673728b560ad3b (diff)
Merge remote-tracking branch 'refs/remotes/origin/video-compression'
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui')
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationActivity.java75
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationFragment.java21
2 files changed, 93 insertions, 3 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
index 073799b03..5b22bd0de 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
@@ -104,12 +104,14 @@ public class ConversationActivity extends XmppActivity
public static final int ATTACHMENT_CHOICE_CHOOSE_FILE = 0x0303;
public static final int ATTACHMENT_CHOICE_RECORD_VOICE = 0x0304;
public static final int ATTACHMENT_CHOICE_LOCATION = 0x0305;
- public static final int ATTACHMENT_CHOICE_INVALID = 0x0306;
+ public static final int ATTACHMENT_CHOICE_CHOOSE_VIDEO = 0x0306;
+ public static final int ATTACHMENT_CHOICE_INVALID = 0x0399;
private static final String STATE_OPEN_CONVERSATION = "state_open_conversation";
private static final String STATE_PANEL_OPEN = "state_panel_open";
private static final String STATE_PENDING_URI = "state_pending_uri";
final private List<Uri> mPendingImageUris = new ArrayList<>();
final private List<Uri> mPendingFileUris = new ArrayList<>();
+ final private List<Uri> mPendingVideoUris = new ArrayList<>();
private String mOpenConverstaion = null;
private boolean mPanelOpen = true;
private Uri mPendingGeoUri = null;
@@ -610,6 +612,11 @@ public class ConversationActivity extends XmppActivity
intent.setType("image/*");
chooser = true;
break;
+ case ATTACHMENT_CHOICE_CHOOSE_VIDEO:
+ intent.setAction(Intent.ACTION_GET_CONTENT);
+ intent.setType("video/*");
+ chooser = true;
+ break;
case ATTACHMENT_CHOICE_TAKE_PHOTO:
Uri uri = xmppConnectionService.getFileBackend().getTakePhotoUri();
intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
@@ -692,6 +699,9 @@ public class ConversationActivity extends XmppActivity
case ATTACHMENT_CHOICE_CHOOSE_IMAGE:
getPreferences().edit().putString("recently_used_quick_action", "picture").apply();
break;
+ case ATTACHMENT_CHOICE_CHOOSE_VIDEO:
+ getPreferences().edit().putString("recently_used_quick_action", "video").apply();
+ break;
}
final Conversation conversation = getSelectedConversation();
final int encryption = conversation.getNextEncryption();
@@ -932,6 +942,9 @@ public class ConversationActivity extends XmppActivity
case R.id.attach_take_picture:
attachFile(ATTACHMENT_CHOICE_TAKE_PHOTO);
break;
+ case R.id.attach_choose_video:
+ attachFile(ATTACHMENT_CHOICE_CHOOSE_VIDEO);
+ break;
case R.id.attach_choose_file:
attachFile(ATTACHMENT_CHOICE_CHOOSE_FILE);
break;
@@ -1407,6 +1420,10 @@ public class ConversationActivity extends XmppActivity
}
}
+ for (Iterator<Uri> i = mPendingVideoUris.iterator(); i.hasNext(); i.remove()) {
+ attachVideoToConversation(getSelectedConversation(), i.next());
+ }
+
for (Iterator<Uri> i = mPendingFileUris.iterator(); i.hasNext(); i.remove()) {
attachFileToConversation(getSelectedConversation(), i.next());
}
@@ -1563,6 +1580,28 @@ public class ConversationActivity extends XmppActivity
} else {
selectPresence(c, callback);
}
+ } else if (requestCode == ATTACHMENT_CHOICE_CHOOSE_VIDEO) {
+ final List<Uri> uris = extractUriFromIntent(data);
+ final Conversation c = getSelectedConversation();
+ final OnPresenceSelected callback = new OnPresenceSelected() {
+ @Override
+ public void onPresenceSelected() {
+ mPendingVideoUris.clear();
+ mPendingVideoUris.addAll(uris);
+ if (xmppConnectionServiceBound) {
+ for (Iterator<Uri> i = mPendingVideoUris.iterator(); i.hasNext(); i.remove()) {
+ attachVideoToConversation(c, i.next());
+ }
+ }
+ }
+ };
+ if (c == null || c.getMode() == Conversation.MODE_MULTI
+ || FileBackend.allFilesUnderSize(this, uris, getMaxHttpUploadSize(c))
+ || c.getNextEncryption() == Message.ENCRYPTION_OTR) {
+ callback.onPresenceSelected();
+ } else {
+ selectPresence(c, callback);
+ }
} else if (requestCode == ATTACHMENT_CHOICE_TAKE_PHOTO) {
if (mPendingImageUris.size() == 1) {
Uri uri = mPendingImageUris.get(0);
@@ -1576,7 +1615,7 @@ public class ConversationActivity extends XmppActivity
} else {
mPendingImageUris.clear();
}
- } else if (requestCode == ATTACHMENT_CHOICE_LOCATION) {
+ } else if (requestCode == ATTACHMENT_CHOICE_LOCATION) {
double latitude = data.getDoubleExtra("latitude", 0);
double longitude = data.getDoubleExtra("longitude", 0);
this.mPendingGeoUri = Uri.parse("geo:" + String.valueOf(latitude) + "," + String.valueOf(longitude));
@@ -1711,6 +1750,38 @@ public class ConversationActivity extends XmppActivity
});
}
+ private void attachVideoToConversation(Conversation conversation, Uri uri) {
+ if (conversation == null) {
+ return;
+ }
+ final Toast prepareFileToast = Toast.makeText(getApplicationContext(),getText(R.string.preparing_video), Toast.LENGTH_LONG);
+ prepareFileToast.show();
+ xmppConnectionService.attachVideoToConversation(conversation, uri, new UiCallback<Message>() {
+ @Override
+ public void success(Message message) {
+ hidePrepareFileToast(prepareFileToast);
+ xmppConnectionService.sendMessage(message);
+ }
+
+ @Override
+ public void error(final int errorCode, Message message) {
+ hidePrepareFileToast(prepareFileToast);
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ replaceToast(getString(errorCode));
+ }
+ });
+
+ }
+
+ @Override
+ public void userInputRequried(PendingIntent pi, Message message) {
+ hidePrepareFileToast(prepareFileToast);
+ }
+ });
+ }
+
private void attachImagesToConversation(Conversation conversation, Uri uri) {
if (conversation == null) {
return;
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
index b89e8351c..9bee75b5e 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
@@ -276,6 +276,9 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
case CHOOSE_PICTURE:
activity.attachFile(ConversationActivity.ATTACHMENT_CHOICE_CHOOSE_IMAGE);
break;
+ case CHOOSE_VIDEO:
+ activity.attachFile(ConversationActivity.ATTACHMENT_CHOICE_CHOOSE_VIDEO);
+ break;
case CANCEL:
if (conversation != null) {
if (conversation.getCorrectingMessage() != null) {
@@ -949,7 +952,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
mEditMessage.requestFocus();
}
- enum SendButtonAction {TEXT, TAKE_PHOTO, SEND_LOCATION, RECORD_VOICE, CANCEL, CHOOSE_PICTURE}
+ enum SendButtonAction {TEXT, TAKE_PHOTO, SEND_LOCATION, RECORD_VOICE, CANCEL, CHOOSE_PICTURE, CHOOSE_VIDEO}
private int getSendButtonImageResource(SendButtonAction action, Presence.Status status) {
switch (action) {
@@ -1031,6 +1034,19 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
default:
return R.drawable.ic_send_picture_offline;
}
+ case CHOOSE_VIDEO:
+ switch (status) {
+ case CHAT:
+ case ONLINE:
+ return R.drawable.ic_send_video_online;
+ case AWAY:
+ return R.drawable.ic_send_video_away;
+ case XA:
+ case DND:
+ return R.drawable.ic_send_video_dnd;
+ default:
+ return R.drawable.ic_send_video_offline;
+ }
}
return R.drawable.ic_send_text_offline;
}
@@ -1074,6 +1090,9 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
case "picture":
action = SendButtonAction.CHOOSE_PICTURE;
break;
+ case "video":
+ action = SendButtonAction.CHOOSE_VIDEO;
+ break;
default:
action = SendButtonAction.TEXT;
break;