Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect allowMultipleSelection flag for media-text block #10597

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ public void onMediaItemSelected(int localMediaId, boolean isLongClick) {
if (mBrowserType.isBrowser() && !isLongClick
|| mBrowserType.isPicker() && isLongClick) {
showMediaSettings(media);
} else if (mBrowserType.isSingleImagePicker() && !isLongClick) {
} else if ((mBrowserType.isSingleImagePicker() || mBrowserType.isSingleMediaPicker()) && !isLongClick) {
// if we're picking a single image, we're done
Intent intent = new Intent();
ArrayList<Long> remoteMediaIds = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ public enum MediaBrowserType {
GRAVATAR_IMAGE_PICKER, // select a single image as a gravatar
SITE_ICON_PICKER, // select a single image as a site icon
GUTENBERG_IMAGE_PICKER, // select image from Gutenberg editor
GUTENBERG_VIDEO_PICKER; // select video from Gutenberg editor
GUTENBERG_VIDEO_PICKER, // select video from Gutenberg editor
GUTENBERG_SINGLE_MEDIA_PICKER; // select multiple images or videos to insert into a post

public boolean isPicker() {
return this != BROWSER;
Expand All @@ -22,6 +23,10 @@ public boolean isSingleImagePicker() {
return this == FEATURED_IMAGE_PICKER || this == GRAVATAR_IMAGE_PICKER || this == SITE_ICON_PICKER;
}

public boolean isSingleMediaPicker() {
return this == GUTENBERG_SINGLE_MEDIA_PICKER;
}

public boolean canMultiselect() {
return this == EDITOR_PICKER
|| this == AZTEC_EDITOR_PICKER
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3539,7 +3539,11 @@ public void onAddMediaVideoClicked(boolean allowMultipleSelection) {
@Override
public void onAddLibraryMediaClicked(boolean allowMultipleSelection) {
mAllowMultipleSelection = allowMultipleSelection;
ActivityLauncher.viewMediaPickerForResult(this, mSite, MediaBrowserType.EDITOR_PICKER);
if (mAllowMultipleSelection) {
ActivityLauncher.viewMediaPickerForResult(this, mSite, MediaBrowserType.EDITOR_PICKER);
} else {
ActivityLauncher.viewMediaPickerForResult(this, mSite, MediaBrowserType.GUTENBERG_SINGLE_MEDIA_PICKER);
}
}

@Override
Expand Down