From e7a807ab5becc386edfaf2a8ba47551b77d5f196 Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Thu, 17 Jan 2019 11:42:01 -0800 Subject: [PATCH] Ensure body text is carried through to the media send screen. We were only doing it if you entered through the media rail. Now we also do it if you enter through the gallery. --- .../thoughtcrime/securesms/ConversationActivity.java | 2 +- .../securesms/mediasend/MediaSendActivity.java | 11 ++++++----- .../thoughtcrime/securesms/mms/AttachmentManager.java | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/org/thoughtcrime/securesms/ConversationActivity.java b/src/org/thoughtcrime/securesms/ConversationActivity.java index 4b80dadb91..e10e8f80fa 100644 --- a/src/org/thoughtcrime/securesms/ConversationActivity.java +++ b/src/org/thoughtcrime/securesms/ConversationActivity.java @@ -1549,7 +1549,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity Log.i(TAG, "Selected: " + type); switch (type) { case AttachmentTypeSelector.ADD_GALLERY: - AttachmentManager.selectGallery(this, MEDIA_SENDER, recipient, sendButton.getSelectedTransport()); break; + AttachmentManager.selectGallery(this, MEDIA_SENDER, recipient, composeText.getTextTrimmed(), sendButton.getSelectedTransport()); break; case AttachmentTypeSelector.ADD_DOCUMENT: AttachmentManager.selectDocument(this, PICK_DOCUMENT); break; case AttachmentTypeSelector.ADD_SOUND: diff --git a/src/org/thoughtcrime/securesms/mediasend/MediaSendActivity.java b/src/org/thoughtcrime/securesms/mediasend/MediaSendActivity.java index 4702399ed2..9cc6e144bb 100644 --- a/src/org/thoughtcrime/securesms/mediasend/MediaSendActivity.java +++ b/src/org/thoughtcrime/securesms/mediasend/MediaSendActivity.java @@ -55,16 +55,18 @@ public class MediaSendActivity extends PassphraseRequiredActionBarActivity imple private final DynamicLanguage dynamicLanguage = new DynamicLanguage(); private Recipient recipient; + private String body; private TransportOption transport; private MediaSendViewModel viewModel; /** * Get an intent to launch the media send flow starting with the picker. */ - public static Intent getIntent(@NonNull Context context, @NonNull Recipient recipient, @NonNull TransportOption transport) { + public static Intent getIntent(@NonNull Context context, @NonNull Recipient recipient, @NonNull String body, @NonNull TransportOption transport) { Intent intent = new Intent(context, MediaSendActivity.class); intent.putExtra(KEY_ADDRESS, recipient.getAddress().serialize()); intent.putExtra(KEY_TRANSPORT, transport); + intent.putExtra(KEY_BODY, body); return intent; } @@ -78,9 +80,8 @@ public class MediaSendActivity extends PassphraseRequiredActionBarActivity imple @NonNull String body, @NonNull TransportOption transport) { - Intent intent = getIntent(context, recipient, transport); + Intent intent = getIntent(context, recipient, body, transport); intent.putParcelableArrayListExtra(KEY_MEDIA, new ArrayList<>(media)); - intent.putExtra(KEY_BODY, body); return intent; } @@ -101,10 +102,10 @@ public class MediaSendActivity extends PassphraseRequiredActionBarActivity imple viewModel = ViewModelProviders.of(this, new MediaSendViewModel.Factory(new MediaRepository())).get(MediaSendViewModel.class); recipient = Recipient.from(this, Address.fromSerialized(getIntent().getStringExtra(KEY_ADDRESS)), true); + body = getIntent().getStringExtra(KEY_BODY); transport = getIntent().getParcelableExtra(KEY_TRANSPORT); List media = getIntent().getParcelableArrayListExtra(KEY_MEDIA); - String body = getIntent().getStringExtra(KEY_BODY); if (!Util.isEmpty(media)) { navigateToMediaSend(media, body, transport); @@ -145,7 +146,7 @@ public class MediaSendActivity extends PassphraseRequiredActionBarActivity imple @Override public void onMediaSelected(@NonNull String bucketId, @NonNull Collection media) { - MediaSendFragment fragment = MediaSendFragment.newInstance("", transport, dynamicLanguage.getCurrentLocale()); + MediaSendFragment fragment = MediaSendFragment.newInstance(body, transport, dynamicLanguage.getCurrentLocale()); getSupportFragmentManager().beginTransaction() .setCustomAnimations(R.anim.fade_in, R.anim.fade_out, R.anim.fade_in, R.anim.fade_out) .replace(R.id.mediapicker_fragment_container, fragment, TAG_SEND) diff --git a/src/org/thoughtcrime/securesms/mms/AttachmentManager.java b/src/org/thoughtcrime/securesms/mms/AttachmentManager.java index 37c349f8e9..6855152025 100644 --- a/src/org/thoughtcrime/securesms/mms/AttachmentManager.java +++ b/src/org/thoughtcrime/securesms/mms/AttachmentManager.java @@ -373,13 +373,13 @@ public class AttachmentManager { .execute(); } - public static void selectGallery(Activity activity, int requestCode, @NonNull Recipient recipient, @NonNull TransportOption transport) { + public static void selectGallery(Activity activity, int requestCode, @NonNull Recipient recipient, @NonNull String body, @NonNull TransportOption transport) { Permissions.with(activity) .request(Manifest.permission.WRITE_EXTERNAL_STORAGE) .ifNecessary() .withPermanentDenialDialog(activity.getString(R.string.AttachmentManager_signal_requires_the_external_storage_permission_in_order_to_attach_photos_videos_or_audio)) .onAllGranted(() -> selectMediaType(activity, "image/*", new String[] {"image/*", "video/*"}, requestCode)) - .onAllGranted(() -> activity.startActivityForResult(MediaSendActivity.getIntent(activity, recipient, transport), requestCode)) + .onAllGranted(() -> activity.startActivityForResult(MediaSendActivity.getIntent(activity, recipient, body, transport), requestCode)) .execute(); }