EmbeddedPhotoPickerState

@ExperimentalPhotoPickerComposeApi
interface EmbeddedPhotoPickerState

Known direct subclasses
AbstractEmbeddedPhotoPickerState

Abstract base class for managing the state of an embedded photo picker.


State model of a EmbeddedPhotoPickerSession. This interface models the state and session management lifecycle of the Embedded Photopicker between the client application and the remote service.

A default implementation is provided via the rememberEmbeddedPhotoPickerState composable which can be used to obtain an implementation that should work for most use cases. This object can be passed to the EmbeddedPhotopicker composable which provides the display layer for the Embedded PhotoPicker.

Callbacks to the underlying session are exposed here to push Compose state into the remote view.

Summary

Public functions

open suspend Unit

Request the EmbeddedPhotoPickerSession deselect the media item with the provided Uri.

suspend Unit

Request the EmbeddedPhotoPickerSession deselect media items with the provided list of Uris from its interface.

Unit

Notify the underlying EmbeddedPhotoPickerSession that the current Configuration has changed.

Unit

Notify the underlying EmbeddedPhotoPickerSession that its parent view has been resized.

Unit

Receiver for when the user is done with their selection and the picker should be collapsed.

Unit

Receiver for when the Photopicker Session encounters a terminal error.

Unit

Receiver for when URI permission has been granted to item(s) selected by the user.

Unit

Receiver for when URI permission has been revoked of an item deselected by the user.

suspend Unit
@RequiresExtension(extension = 34, version = 15)
runSession(
    provider: EmbeddedPhotoPickerProvider,
    featureInfo: EmbeddedPhotoPickerFeatureInfo,
    onReceiveSession: (EmbeddedPhotoPickerSession) -> Unit
)

Run a EmbeddedPhotoPickerSession using the state provided by this state object.

Unit

Sets the isExpanded state of the current session.

Public properties

Int

The current Context#displayId

Boolean

The current expanded state of this state object.

Boolean

The current ready state of this state object.

Set<Uri>

A set of currently selected media items that have been selected by the user during the current Photopicker session.

IBinder?

The current SurfaceView#hostToken

Public functions

deselectUri

Added in 1.0.0-alpha01
open suspend fun deselectUri(uri: Uri): Unit

Request the EmbeddedPhotoPickerSession deselect the media item with the provided Uri.

NOTE: The Uri should have been received from the PhotoPicker. Regular MediaStore uris, or other Uris passed here will be ignored by the Photopicker.

Parameters
uri: Uri

the Uri that should be deselected in the PhotoPicker's interface.

deselectUris

suspend fun deselectUris(uris: List<Uri>): Unit

Request the EmbeddedPhotoPickerSession deselect media items with the provided list of Uris from its interface.

NOTE: The Uri should have been received from the PhotoPicker. Regular MediaStore uris, or other Uris passed here will be ignored by the PhotoPicker.

Parameters
uris: List<Uri>

the List of Uri that should be deselected in the PhotoPicker's interface.

notifyConfigurationChanged

Added in 1.0.0-alpha01
fun notifyConfigurationChanged(config: Configuration): Unit

Notify the underlying EmbeddedPhotoPickerSession that the current Configuration has changed.

notifyResized

fun notifyResized(size: IntSize): Unit

Notify the underlying EmbeddedPhotoPickerSession that its parent view has been resized.

Parameters
size: IntSize

The new size of the parent view.

onSelectionComplete

Added in 1.0.0-alpha01
fun onSelectionComplete(): Unit

Receiver for when the user is done with their selection and the picker should be collapsed.

See also
EmbeddedPhotoPickerClient

#onSelectionComplete

onSessionError

Added in 1.0.0-alpha01
fun onSessionError(throwable: Throwable): Unit

Receiver for when the Photopicker Session encounters a terminal error.

See also
EmbeddedPhotoPickerClient

#onSessionError

onUriPermissionGranted

fun onUriPermissionGranted(uris: List<Uri>): Unit

Receiver for when URI permission has been granted to item(s) selected by the user.

See also
EmbeddedPhotoPickerClient

#onUriPermissionGranted

onUriPermissionRevoked

fun onUriPermissionRevoked(uris: List<Uri>): Unit

Receiver for when URI permission has been revoked of an item deselected by the user.

See also
EmbeddedPhotoPickerClient

#onUriPermissionRevoked

runSession

Added in 1.0.0-alpha01
@RequiresExtension(extension = 34, version = 15)
suspend fun runSession(
    provider: EmbeddedPhotoPickerProvider,
    featureInfo: EmbeddedPhotoPickerFeatureInfo,
    onReceiveSession: (EmbeddedPhotoPickerSession) -> Unit
): Unit

Run a EmbeddedPhotoPickerSession using the state provided by this state object.

This suspended function should be started from a LaunchedEffect in the composable hosting the SurfaceView the EmbeddedPhotoPicker is drawing to. The function should perform the necessary startup logic with the EmbeddedPhotoPickerProvider, and then run the provided client in a child scope of the current CoroutineScope. Throughout the entire session, and then close / cleanup any resources being used when the suspended function is cancelled.

Parameters
provider: EmbeddedPhotoPickerProvider

The provider that should be used for this session.

featureInfo: EmbeddedPhotoPickerFeatureInfo

The client provided EmbeddedPhotoPickerFeatureInfo to configure the Embedded PhotoPicker.

onReceiveSession: (EmbeddedPhotoPickerSession) -> Unit

A callback from the display layer, which can be used to pass the opened Session back to the display layer so it can be attached to the SurfaceView.

setCurrentExpanded

Added in 1.0.0-alpha01
fun setCurrentExpanded(expanded: Boolean): Unit

Sets the isExpanded state of the current session.

Public properties

displayId

Added in 1.0.0-alpha01
var displayIdInt

The current Context#displayId

isExpanded

Added in 1.0.0-alpha01
var isExpandedBoolean

The current expanded state of this state object. Signifies whether the underlying EmbeddedPhotopicker session is expanded or collapsed.

isReady

Added in 1.0.0-alpha01
var isReadyBoolean

The current ready state of this state object. Signifies whether this state object is ready to run a Embedded Photopicker session.

selectedMedia

Added in 1.0.0-alpha01
val selectedMediaSet<Uri>

A set of currently selected media items that have been selected by the user during the current Photopicker session.

surfaceHostToken

Added in 1.0.0-alpha01
var surfaceHostTokenIBinder?

The current SurfaceView#hostToken