From 411e3ceff631864746ed09a7704d1564a79084b1 Mon Sep 17 00:00:00 2001 From: Buck Doyle Date: Mon, 3 Mar 2014 11:55:34 -0500 Subject: [PATCH] Support videos from other apps. Fixes #949 --- AndroidManifest.xml | 1 + .../securesms/ConversationActivity.java | 5 ++++- .../thoughtcrime/securesms/RoutingActivity.java | 14 ++++++++++---- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 8a03bb61c5..a79fca4e67 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -70,6 +70,7 @@ + diff --git a/src/org/thoughtcrime/securesms/ConversationActivity.java b/src/org/thoughtcrime/securesms/ConversationActivity.java index 11fb1b0f00..081076423a 100644 --- a/src/org/thoughtcrime/securesms/ConversationActivity.java +++ b/src/org/thoughtcrime/securesms/ConversationActivity.java @@ -137,6 +137,7 @@ public class ConversationActivity extends PassphraseRequiredSherlockFragmentActi public static final String DRAFT_TEXT_EXTRA = "draft_text"; public static final String DRAFT_IMAGE_EXTRA = "draft_image"; public static final String DRAFT_AUDIO_EXTRA = "draft_audio"; + public static final String DRAFT_VIDEO_EXTRA = "draft_video"; public static final String DISTRIBUTION_TYPE_EXTRA = "distribution_type"; private static final int PICK_CONTACT = 1; @@ -619,12 +620,14 @@ public class ConversationActivity extends PassphraseRequiredSherlockFragmentActi String draftText = getIntent().getStringExtra(DRAFT_TEXT_EXTRA); Uri draftImage = getIntent().getParcelableExtra(DRAFT_IMAGE_EXTRA); Uri draftAudio = getIntent().getParcelableExtra(DRAFT_AUDIO_EXTRA); + Uri draftVideo = getIntent().getParcelableExtra(DRAFT_VIDEO_EXTRA); if (draftText != null) composeText.setText(draftText); if (draftImage != null) addAttachmentImage(draftImage); if (draftAudio != null) addAttachmentAudio(draftAudio); + if (draftVideo != null) addAttachmentVideo(draftVideo); - if (draftText == null && draftImage == null && draftAudio == null) { + if (draftText == null && draftImage == null && draftAudio == null && draftVideo == null) { initializeDraftFromDatabase(); } } diff --git a/src/org/thoughtcrime/securesms/RoutingActivity.java b/src/org/thoughtcrime/securesms/RoutingActivity.java index 70e8ff8b72..19eabba159 100644 --- a/src/org/thoughtcrime/securesms/RoutingActivity.java +++ b/src/org/thoughtcrime/securesms/RoutingActivity.java @@ -141,6 +141,7 @@ public class RoutingActivity extends PassphraseRequiredSherlockActivity { intent.putExtra(ConversationActivity.DRAFT_TEXT_EXTRA, parameters.draftText); intent.putExtra(ConversationActivity.DRAFT_IMAGE_EXTRA, parameters.draftImage); intent.putExtra(ConversationActivity.DRAFT_AUDIO_EXTRA, parameters.draftAudio); + intent.putExtra(ConversationActivity.DRAFT_VIDEO_EXTRA, parameters.draftVideo); return intent; } @@ -200,7 +201,7 @@ public class RoutingActivity extends PassphraseRequiredSherlockActivity { recipients = null; } - return new ConversationParameters(threadId, recipients, null, null, null); + return new ConversationParameters(threadId, recipients, null, null, null, null); } private ConversationParameters getConversationParametersForShareAction() { @@ -208,6 +209,7 @@ public class RoutingActivity extends PassphraseRequiredSherlockActivity { String draftText = null; Uri draftImage = null; Uri draftAudio = null; + Uri draftVideo = null; if ("text/plain".equals(type)) { draftText = getIntent().getStringExtra(Intent.EXTRA_TEXT); @@ -215,16 +217,18 @@ public class RoutingActivity extends PassphraseRequiredSherlockActivity { draftImage = getIntent().getParcelableExtra(Intent.EXTRA_STREAM); } else if (type.startsWith("audio/")) { draftAudio = getIntent().getParcelableExtra(Intent.EXTRA_STREAM); + } else if (type.startsWith("video/")) { + draftVideo = getIntent().getParcelableExtra(Intent.EXTRA_STREAM); } - return new ConversationParameters(-1, null, draftText, draftImage, draftAudio); + return new ConversationParameters(-1, null, draftText, draftImage, draftAudio, draftVideo); } private ConversationParameters getConversationParametersForInternalAction() { long threadId = getIntent().getLongExtra("thread_id", -1); Recipients recipients = getIntent().getParcelableExtra("recipients"); - return new ConversationParameters(threadId, recipients, null, null, null); + return new ConversationParameters(threadId, recipients, null, null, null, null); } private boolean isShareAction() { @@ -241,15 +245,17 @@ public class RoutingActivity extends PassphraseRequiredSherlockActivity { public final String draftText; public final Uri draftImage; public final Uri draftAudio; + public final Uri draftVideo; public ConversationParameters(long thread, Recipients recipients, - String draftText, Uri draftImage, Uri draftAudio) + String draftText, Uri draftImage, Uri draftAudio, Uri draftVideo) { this.thread = thread; this.recipients = recipients; this.draftText = draftText; this.draftImage = draftImage; this.draftAudio = draftAudio; + this.draftVideo = draftVideo; } }