PickVisualMediaRequest.Builder


public final class PickVisualMediaRequest.Builder


A builder for constructing PickVisualMediaRequest instances.

Summary

Public constructors

Public methods

final @NonNull PickVisualMediaRequest

Build the PickVisualMediaRequest specified by this builder.

final @NonNull PickVisualMediaRequest.Builder
setAccentColor(long accentColor)

Set the accent color for the PickVisualMediaRequest.

final @NonNull PickVisualMediaRequest.Builder

Set the default tab for the PickVisualMediaRequest.

final @NonNull PickVisualMediaRequest.Builder

Sets parameters for highlighting a specific album's media in the photo picker.

final @NonNull PickVisualMediaRequest.Builder
setHighlightSearchResultsParams(
    HighlightSearchResultsParams highlightSearchResultsParams
)

Sets parameters for highlighting search results in the photo picker.

final @NonNull PickVisualMediaRequest.Builder
setLocationMetadataAccessRequested(
    boolean isLocationMetadataAccessRequested
)

Sets whether the caller requests access to location metadata for the selected media items.

final @NonNull PickVisualMediaRequest.Builder
setMaxItems(@IntRange(from = 2) int maxItems)

Limit the number of selectable items in the photo picker when using PickMultipleVisualMedia

final @NonNull PickVisualMediaRequest.Builder

Set the media capabilities for the PickVisualMediaRequest.

final @NonNull PickVisualMediaRequest.Builder

Set the media type for the PickVisualMediaRequest.

final @NonNull PickVisualMediaRequest.Builder
setOrderedSelection(boolean isOrderedSelection)

Set the ordered selection for the PickVisualMediaRequest.

final @NonNull PickVisualMediaRequest.Builder
@RequiresExtension(extension = 34, version = 22)
setSelectionParams(SelectionParams selectionParams)

Sets selection constraints for media items in the photo picker.

final @NonNull PickVisualMediaRequest.Builder

Public constructors

Builder

Added in 1.0.0-alpha03
public Builder()

Public methods

build

Added in 1.0.0-alpha03
public final @NonNull PickVisualMediaRequest build()

Build the PickVisualMediaRequest specified by this builder.

Returns
@NonNull PickVisualMediaRequest

the newly constructed PickVisualMediaRequest.

Throws
IllegalArgumentException

if both search results highlight and album highlight parameters are set.

setAccentColor

Added in 1.0.0-alpha03
public final @NonNull PickVisualMediaRequest.Builder setAccentColor(long accentColor)

Set the accent color for the PickVisualMediaRequest.

The accent color is used to change the main color in the photo picker. This feature was added in API level 35 / R ext 12 and applies the default behavior for older versions.

Parameters
long accentColor

color long to apply as accent to the main color in the picker

Returns
@NonNull PickVisualMediaRequest.Builder

This builder.

setDefaultTab

Added in 1.0.0-alpha03
public final @NonNull PickVisualMediaRequest.Builder setDefaultTab(@NonNull PickVisualMedia.DefaultTab defaultTab)

Set the default tab for the PickVisualMediaRequest.

The default tab is used to open the preferred view inside the photo picker at first such as, e.g. DefaultTab.PhotosTab, DefaultTab.AlbumsTab. This feature was added in API level 35 / R ext 12 and applies the default behavior for older versions.

Parameters
@NonNull PickVisualMedia.DefaultTab defaultTab

the tab to launch the picker in (defaults to DefaultTab.PhotosTab)

Returns
@NonNull PickVisualMediaRequest.Builder

This builder.

setHighlightAlbumParams

Added in 1.0.0-alpha03
public final @NonNull PickVisualMediaRequest.Builder setHighlightAlbumParams(HighlightAlbumParams highlightAlbumParams)

Sets parameters for highlighting a specific album's media in the photo picker.

This allows apps to highlight media results of an album in the photo picker UI whenever feasible based on the given input album (one of HighlightAlbumParams.HighlightAlbum). Only one of search results highlight or album highlight can be specified to either show a highlighted media section when the photopicker launches or to open the photopicker to show a highlighted media results grid based on the given input album. Specifying both album and search highlight will result in throwing IllegalArgumentException.

This feature was added in Android Tiramisu (API level 33 / T ext 19) and will be ignored on Android R and S.

Parameters
HighlightAlbumParams highlightAlbumParams

The album highlight configuration, or null to clear.

Returns
@NonNull PickVisualMediaRequest.Builder

This builder.

setHighlightSearchResultsParams

Added in 1.0.0-alpha03
public final @NonNull PickVisualMediaRequest.Builder setHighlightSearchResultsParams(
    HighlightSearchResultsParams highlightSearchResultsParams
)

Sets parameters for highlighting search results in the photo picker. This allows apps to highlight search results in the photopicker UI whenever feasible based on the given input text query. Only one of search results highlight or album highlight can be specified to either show a highlighted media section when the photopicker launches or to open the photopicker to show a highlighted media results grid based on the given input query. Specifying both album and search highlight will result in throwing IllegalArgumentException.

This feature was added in Android Tiramisu (API level 33 / T ext 19) and will be ignored on Android R and S.

Parameters
HighlightSearchResultsParams highlightSearchResultsParams

The search result highlight configuration, or null to clear.

Returns
@NonNull PickVisualMediaRequest.Builder

This builder.

setLocationMetadataAccessRequested

Added in 1.0.0-alpha03
public final @NonNull PickVisualMediaRequest.Builder setLocationMetadataAccessRequested(
    boolean isLocationMetadataAccessRequested
)

Sets whether the caller requests access to location metadata for the selected media items.

When set to true, this informs the Photopicker that the app is requesting location information (such as EXIF GPS data) for the media items selected by the user. The default value is false, meaning location metadata is redacted by default.

Requesting location metadata does not guarantee that the calling app will receive it. The Photopicker may prompt the user via the picker UI, and the user's choice to allow or deny location sharing is final. If granted, calling apps can access this metadata when the selected media files are opened via the returned URIs.

This feature was added in SDK extension 23 on Android Tiramisu (API level 33) and higher. If the underlying Photopicker implementation or device does not support this feature, this request is safely ignored.

Parameters
boolean isLocationMetadataAccessRequested

boolean whether to request location metadata access from the Photopicker

Returns
@NonNull PickVisualMediaRequest.Builder

This builder.

setMaxItems

Added in 1.0.0-alpha03
public final @NonNull PickVisualMediaRequest.Builder setMaxItems(@IntRange(from = 2) int maxItems)

Limit the number of selectable items in the photo picker when using PickMultipleVisualMedia

Parameters
@IntRange(from = 2) int maxItems

int type limiting the number of selectable items

Returns
@NonNull PickVisualMediaRequest.Builder

This builder.

setMediaCapabilitiesForTranscoding

Added in 1.0.0-alpha03
@RequiresApi(value = 33)
public final @NonNull PickVisualMediaRequest.Builder setMediaCapabilitiesForTranscoding(
    PickVisualMedia.MediaCapabilities mediaCapabilities
)

Set the media capabilities for the PickVisualMediaRequest.

This parameter allows you to specify the media capabilities that your application can handle, such as the HDR type of the media. This parameter might be not supported by the underlying photo picker implementation.

When the requested video format does not match the capabilities specified by the calling app and the video duration is within the range that photo picker can handle, photo picker will transcode the video into a default supported format, otherwise, the calling app will receive the original file.

Parameters
PickVisualMedia.MediaCapabilities mediaCapabilities

the MediaCapabilities to apply to the media selection.

Returns
@NonNull PickVisualMediaRequest.Builder

This builder.

setMediaType

Added in 1.0.0-alpha03
public final @NonNull PickVisualMediaRequest.Builder setMediaType(@NonNull PickVisualMedia.VisualMediaType mediaType)

Set the media type for the PickVisualMediaRequest.

The type is the mime type to filter by, e.g. PickVisualMedia.ImageOnly, PickVisualMedia.ImageAndVideo, PickVisualMedia.SingleMimeType("image/gif")

Parameters
@NonNull PickVisualMedia.VisualMediaType mediaType

type to go into the PickVisualMediaRequest

Returns
@NonNull PickVisualMediaRequest.Builder

This builder.

setOrderedSelection

Added in 1.0.0-alpha03
public final @NonNull PickVisualMediaRequest.Builder setOrderedSelection(boolean isOrderedSelection)

Set the ordered selection for the PickVisualMediaRequest.

Allow the user to control the order in which images are returned to the calling app. This parameter might be not supported by the underlying photo picker implementation.

Parameters
boolean isOrderedSelection

boolean to enable customisable selection order in the picker

Returns
@NonNull PickVisualMediaRequest.Builder

This builder.

setSelectionParams

Added in 1.0.0-alpha03
@RequiresExtension(extension = 34, version = 22)
public final @NonNull PickVisualMediaRequest.Builder setSelectionParams(SelectionParams selectionParams)

Sets selection constraints for media items in the photo picker. The items that do not satisfy these input constraints will not be selectable in the photopicker grid.

This feature was added for the system PhotoPicker in SDK extension version 22 (API level 34 / U ext 22) and is available starting from the same and higher. If the platform conditions are not met, this cannot be used. Callers of this must add this check before using.

Parameters
SelectionParams selectionParams

The selection constraint parameters, or null to clear.

Returns
@NonNull PickVisualMediaRequest.Builder

This builder.

setUiCustomizationParams

Added in 1.0.0-alpha03
public final @NonNull PickVisualMediaRequest.Builder setUiCustomizationParams(UiCustomizationParams uiCustomizationParams)