mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 16:57:50 +00:00
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.
This commit is contained in:
parent
9ff8f8587b
commit
e7a807ab5b
@ -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:
|
||||
|
@ -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> 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> 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)
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user