-
public final class AttachmentStorageHelperHandles querying device storage for attachment metadata and converting between AttachmentMetaData and the SDK Attachment model.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classAttachmentStorageHelper.Companion
-
Constructor Summary
Constructors Constructor Description AttachmentStorageHelper(Context context, StorageHelper storageHelper, AttachmentFilter attachmentFilter)
-
Method Summary
Modifier and Type Method Description final List<AttachmentMetaData>getFileMetadata()Loads file metadata from the system, filtered against file types accepted by the backend. final List<AttachmentMetaData>getMediaMetadata()Loads media metadata from the system, filtered against file types accepted by the backend. final List<Attachment>toAttachments(List<AttachmentMetaData> metaData)Converts a list of AttachmentMetaData into lightweight Attachments for preview. final List<Attachment>resolveAttachmentFiles(List<Attachment> attachments)Resolves deferred attachments by copying their source content into local cache files. final List<AttachmentMetaData>resolveMetadata(List<Uri> uris)Resolves a list of file Uris into AttachmentMetaData. final Pair<List<AttachmentMetaData>, List<AttachmentMetaData>>partitionResolvable(List<AttachmentMetaData> metadata)Partitions metadata into resolvable and unresolvable items. -
-
Constructor Detail
-
AttachmentStorageHelper
AttachmentStorageHelper(Context context, StorageHelper storageHelper, AttachmentFilter attachmentFilter)
- Parameters:
context- The context of the app, used to fetch files and media.storageHelper- Queries the device's content providers for files and media.attachmentFilter- A filter that is used to filter out attachments that will not be accepted by the backend.
-
-
Method Detail
-
getFileMetadata
@WorkerThread() final List<AttachmentMetaData> getFileMetadata()
Loads file metadata from the system, filtered against file types accepted by the backend.
-
getMediaMetadata
@WorkerThread() final List<AttachmentMetaData> getMediaMetadata()
Loads media metadata from the system, filtered against file types accepted by the backend.
-
toAttachments
final List<Attachment> toAttachments(List<AttachmentMetaData> metaData)
Converts a list of AttachmentMetaData into lightweight Attachments for preview.
The original content URI from each metadata entry is stored under EXTRA_SOURCE_URI in Attachment.extraData. Attachment.upload is always
null; files are resolved later via resolveAttachmentFiles at send time.- Parameters:
metaData- The metadata to convert.
-
resolveAttachmentFiles
final List<Attachment> resolveAttachmentFiles(List<Attachment> attachments)
Resolves deferred attachments by copying their source content into local cache files.
Attachments that already have a non-null Attachment.upload are returned unchanged. For others, the original content URI is read from EXTRA_SOURCE_URI and copied to a local cache file. Attachments whose source URI cannot be resolved (e.g. the content URI is no longer accessible or the cache write fails) are dropped from the result.
- Parameters:
attachments- The attachments to resolve.
-
resolveMetadata
@WorkerThread() final List<AttachmentMetaData> resolveMetadata(List<Uri> uris)
Resolves a list of file Uris into AttachmentMetaData.
- Parameters:
uris- Selected file URIs to resolve.
-
partitionResolvable
@WorkerThread() final Pair<List<AttachmentMetaData>, List<AttachmentMetaData>> partitionResolvable(List<AttachmentMetaData> metadata)
Partitions metadata into resolvable and unresolvable items.
An item is considered resolvable if its content URI can be opened for reading. Metadata entries without a URI are treated as resolvable.
- Parameters:
metadata- The metadata to partition.
-
-
-
-