diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-05-14 21:25:23 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-05-14 21:25:23 +0200 |
commit | 81509da8e679e88bb2205ce106370ca574aa3bf1 (patch) | |
tree | 7f85684c5292abdbea038e7bbdae08e28fdec5ee /src/main/java | |
parent | 982c24329758c122c32619907f039d2bab5aaa65 (diff) |
fix taking video
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ConversationFragment.java | 26 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java | 6 |
2 files changed, 24 insertions, 8 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index 4e4ae8ee9..ebe02fe4b 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -146,6 +146,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke public static final String STATE_CONVERSATION_UUID = ConversationFragment.class.getName() + ".uuid"; public static final String STATE_SCROLL_POSITION = ConversationFragment.class.getName() + ".scroll_position"; public static final String STATE_PHOTO_URI = ConversationFragment.class.getName() + ".take_photo_uri"; + public static final String STATE_VIDEO_URI = ConversationFragment.class.getName() + ".take_video_uri"; private static final String STATE_LAST_MESSAGE_UUID = "state_last_message_uuid"; @@ -157,6 +158,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke private final PendingItem<String> pendingConversationsUuid = new PendingItem<>(); private final PendingItem<Bundle> pendingExtras = new PendingItem<>(); private final PendingItem<Uri> pendingTakePhotoUri = new PendingItem<>(); + private final PendingItem<Uri> pendingTakeVideoUri = new PendingItem<>(); private final PendingItem<ScrollState> pendingScrollState = new PendingItem<>(); private final PendingItem<String> pendingLastMessageUuid = new PendingItem<>(); private final PendingItem<Message> pendingMessage = new PendingItem<>(); @@ -1001,6 +1003,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke } private void handlePositiveActivityResult(int requestCode, final Intent data) { + final String type = data == null ? null : data.getType(); switch (requestCode) { case REQUEST_TRUST_KEYS_TEXT: final String body = binding.textinput.getText().toString(); @@ -1028,16 +1031,18 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke break; case ATTACHMENT_CHOICE_TAKE_FROM_CAMERA: final Uri takePhotoUri = pendingTakePhotoUri.pop(); + final Uri takeVideoUri = pendingTakeVideoUri.pop(); if (takePhotoUri != null) { attachPhotoToConversation(conversation, takePhotoUri); + } else if (takeVideoUri != null) { + attachFileToConversation(conversation, takeVideoUri, type); } else { - Log.d(Config.LOGTAG, "lost take photo uri. unable to to attach"); + Log.d(Config.LOGTAG, "lost take uri. unable to to attach"); } break; case ATTACHMENT_CHOICE_CHOOSE_FILE: case ATTACHMENT_CHOICE_RECORD_VOICE: final List<Uri> fileUris = AttachmentTool.extractUriFromIntent(data); - final String type = data == null ? null : data.getType(); final PresenceSelector.OnPresenceSelected callback = () -> { for (Iterator<Uri> i = fileUris.iterator(); i.hasNext(); i.remove()) { Log.d(Config.LOGTAG, "ConversationsActivity.onActivityResult() - attaching file to conversations. CHOOSE_FILE/RECORD_VOICE"); @@ -1724,6 +1729,9 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke }); builder.setPositiveButton(getString(R.string.action_take_video), (dialog, which) -> { + final Uri uri = activity.xmppConnectionService.getFileBackend().getTakeVideoUri(); + pendingTakeVideoUri.push(uri); + intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.setAction(MediaStore.ACTION_VIDEO_CAPTURE); @@ -1959,9 +1967,13 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke if (conversation != null) { outState.putString(STATE_CONVERSATION_UUID, conversation.getUuid()); outState.putString(STATE_LAST_MESSAGE_UUID, lastMessageUuid); - final Uri uri = pendingTakePhotoUri.peek(); - if (uri != null) { - outState.putString(STATE_PHOTO_URI, uri.toString()); + final Uri PhotoUri = pendingTakePhotoUri.peek(); + final Uri VideoUri = pendingTakeVideoUri.peek(); + if (PhotoUri != null) { + outState.putString(STATE_PHOTO_URI, PhotoUri.toString()); + } + if (VideoUri != null) { + outState.putString(STATE_VIDEO_URI, VideoUri.toString()); } final ScrollState scrollState = getScrollPosition(); if (scrollState != null) { @@ -1985,6 +1997,10 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke if (takePhotoUri != null) { pendingTakePhotoUri.push(Uri.parse(takePhotoUri)); } + String takeVideoUri = savedInstanceState.getString(STATE_VIDEO_URI); + if (takeVideoUri != null) { + pendingTakeVideoUri.push(Uri.parse(takeVideoUri)); + } pendingScrollState.push(savedInstanceState.getParcelable(STATE_SCROLL_POSITION)); } } diff --git a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java index 2e602102e..9666ee1d0 100644 --- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java +++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java @@ -324,14 +324,14 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie } else { isResendable = false; viewHolder.resend_button.setVisibility(View.VISIBLE); + viewHolder.resend_button.setText(R.string.send_again); + viewHolder.resend_button.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_resend_grey600_48dp, 0, 0, 0); + viewHolder.resend_button.setOnClickListener(v -> mConversationFragment.resendMessage(message)); } } else { isResendable = false; viewHolder.resend_button.setVisibility(View.GONE); } - viewHolder.resend_button.setText(R.string.send_again); - viewHolder.resend_button.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_resend_grey600_48dp, 0, 0, 0); - viewHolder.resend_button.setOnClickListener(v -> mConversationFragment.resendMessage(message)); } else { if (darkBackground) { viewHolder.time.setTextAppearance(getContext(), R.style.TextAppearance_Conversations_Caption_OnDark); |