Default to 'All media' bucket for items from the rail.

This should give people a better multi-send experience when they want to
add more media.
This commit is contained in:
Greyson Parrelli 2019-01-16 13:18:16 -08:00
parent 557e6a800f
commit f70bf9c5bd
4 changed files with 6 additions and 6 deletions

View file

@ -2193,7 +2193,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
@Override
public void onQuickAttachment(Uri uri, String mimeType, String bucketId, long dateTaken, int width, int height) {
Media media = new Media(uri, mimeType, dateTaken, width, height, Optional.fromNullable(bucketId), Optional.absent());
Media media = new Media(uri, mimeType, dateTaken, width, height, Optional.of(Media.ALL_MEDIA_BUCKET_ID), Optional.absent());
startActivityForResult(MediaSendActivity.getIntent(ConversationActivity.this, Collections.singletonList(media), recipient, composeText.getTextTrimmed(), sendButton.getSelectedTransport()), MEDIA_SENDER);
}
}

View file

@ -12,6 +12,8 @@ import org.whispersystems.libsignal.util.guava.Optional;
*/
public class Media implements Parcelable {
public static final String ALL_MEDIA_BUCKET_ID = "org.thoughtcrime.securesms.ALL_MEDIA";
private final Uri uri;
private final String mimeType;
private final long date;

View file

@ -31,8 +31,6 @@ import java.util.Map;
*/
class MediaRepository {
private static final String ALL_MEDIA_BUCKET_ID = "org.thoughtcrime.securesms.ALL_MEDIA";
/**
* Retrieves a list of folders that contain media.
*/
@ -80,7 +78,7 @@ class MediaRepository {
allMediaCount += cameraFolder.getCount();
}
mediaFolders.add(0, new MediaFolder(allMediaThumbnail, context.getString(R.string.MediaRepository_all_media), allMediaCount, ALL_MEDIA_BUCKET_ID, MediaFolder.FolderType.NORMAL));
mediaFolders.add(0, new MediaFolder(allMediaThumbnail, context.getString(R.string.MediaRepository_all_media), allMediaCount, Media.ALL_MEDIA_BUCKET_ID, MediaFolder.FolderType.NORMAL));
}
if (cameraFolder != null) {
@ -150,7 +148,7 @@ class MediaRepository {
String[] projection = Build.VERSION.SDK_INT >= 16 ? new String[] { Images.Media._ID, Images.Media.MIME_TYPE, Images.Media.DATE_TAKEN, Images.Media.WIDTH, Images.Media.HEIGHT }
: new String[] { Images.Media._ID, Images.Media.MIME_TYPE, Images.Media.DATE_TAKEN };
if (ALL_MEDIA_BUCKET_ID.equals(bucketId)) {
if (Media.ALL_MEDIA_BUCKET_ID.equals(bucketId)) {
selection = Images.Media.DATA + " NOT NULL";
selectionArgs = null;
}

View file

@ -113,7 +113,7 @@ class MediaSendViewModel extends ViewModel {
String candidate = media.get(0).getBucketId().get();
for (int i = 1; i < media.size(); i++) {
if (!Util.equals(candidate, media.get(i).getBucketId().orNull())) {
return Optional.absent();
return Optional.of(Media.ALL_MEDIA_BUCKET_ID);
}
}