STWAttachmentManager

open class STWAttachmentManager

This class represent the API for all actions/event related to the attachment

This class offers several possible operations defined in the following list :

  • Get attachment from DB
  • Register to the attachment events/action

Functions

Link copied to clipboard
open fun addAttachmentOperationListener(    @NonNull context: Context,     @NonNull attachmentId: String,     @Nullable cloudServiceListener: CloudServiceListener): Boolean
Call this method to add a listener to an attachment for a single operation (download or upload).
Link copied to clipboard
open fun cancelAttachmentOperation(@NonNull context: Context, @NonNull attachmentId: String)
Call this method to cancel downloading or uploading an attachment.
Link copied to clipboard
open fun cancelRecordingAudio()
Call this method to cancel recording an audio clips
Link copied to clipboard
open fun clearPendingAttachment(@NonNull context: Context, @Nullable operationCallback: STWOperationCallback<MessagingError>)
Call this method to delete pending (non downloaded) attachments.
Link copied to clipboard
open fun createCopyOfAttachmentForUpload(@NonNull context: Context, @NonNull attachmentId: String): BaseAttachment
This method create a COPY of attachment and fix thumbnails creation for Image and Video attachments if not exist or corrupted
Link copied to clipboard
open fun deleteAttachment(    @NonNull context: Context,     @NonNull attachmentId: String,     @Nullable operationCallback: STWOperationCallback)
Call this method to delete an attachment This method is automatically deletes the attachment and its message.
Link copied to clipboard
open fun deleteAttachments(    @NonNull context: Context,     @NonNull attachmentIds: List<String>,     @Nullable operationCallback: STWOperationCallback<MessagingError>)
Call this method to delete an attachments.
Link copied to clipboard
open fun downloadAttachment(    @NonNull context: Context,     @NonNull attachmentId: String,     @Nullable operationCallback: STWOperationCallback<MessagingError>)
Call this method to download an attachment (except location attachment) given attachment Id.
Link copied to clipboard
open fun downloadLocationAttachmentAsynchronous(    @NonNull context: Context,     latitude: Double,     longitude: Double,     @NonNull markerColor: String,     addMarker: Boolean,     @Nullable listener: STWDownloadAttachmentLocationListener)
Call this method to download a location attachment asynchronously.
Link copied to clipboard
open fun getAttachmentBitmapFromPath(@NonNull attachmentPath: String): Bitmap
Link copied to clipboard
open fun getAttachmentById(@NonNull context: Context, @NonNull attachmentId: String): BaseAttachment
Call this method to retrieve the attachment represented by BaseAttachment object given a attachmentId.
Link copied to clipboard
open fun getCalendarListInMonth(    @NonNull context: Context,     year: Int,     month: Int): List<CalendarEventModel>
Link copied to clipboard
open fun getDocsAttachmentsByConversationId(@NonNull context: Context, @NonNull conversationId: String): List<BaseAttachment>
Call this method to retrieve all documents and files for a given conversation.
Link copied to clipboard
open fun getInstance(): STWAttachmentManager
Link copied to clipboard
open fun getLinksAttachmentsByConversationId(@NonNull context: Context, @NonNull conversationId: String): List<BaseAttachment>
Call this method to retrieve all links in a given conversation.
Link copied to clipboard
open fun getMediaAttachmentsByConversationId(@NonNull context: Context, @NonNull conversationId: String): List<BaseAttachment>
Call this method to retrieve all images, videos and GIFs for a given conversation.
Link copied to clipboard
open fun getMessageAttachmentMaxSize(@NonNull context: Context): Long
Call this method to get the maximum size of message attachment
Link copied to clipboard
open fun getSizeOfReceivedAttachments(@NonNull context: Context, date: Long): Double
Call this method to get size (bytes) of the received attachments starting from the given date from local Database.
Link copied to clipboard
open fun getSizeOfSentAttachments(@NonNull context: Context, date: Long): Double
Call this method to get size (bytes) of the sent attachments starting from a given date from local Database.
Link copied to clipboard
open fun isRecordingAudio(): Boolean
Link copied to clipboard
open fun loadAudioAttachment(    @NonNull context: Context,     @NonNull intent: Intent,     @Nullable callback: IAttachmentLoaderCallback)
open fun loadAudioAttachment(    @NonNull context: Context,     @Nullable lifecycle: Lifecycle,     @NonNull intent: Intent,     @Nullable callback: IAttachmentLoaderCallback)
Call this method to load an audio attachment presented by com.streamwide.smartms.lib.core.data.item.AudioAttachment.
Link copied to clipboard
open fun loadCalendarAttachment(    @NonNull context: Context,     @NonNull intent: Intent,     @Nullable callback: IAttachmentLoaderCallback)
open fun loadCalendarAttachment(    @NonNull context: Context,     @Nullable lifecycle: Lifecycle,     @NonNull intent: Intent,     @Nullable callback: IAttachmentLoaderCallback)
Call this method to load a event from Calendar presented by com.streamwide.smartms.lib.core.data.item.CalendarAttachment.
Link copied to clipboard
open fun loadFileAttachment(    @NonNull context: Context,     @NonNull intent: Intent,     @Nullable callback: IAttachmentLoaderCallback)
open fun loadFileAttachment(    @NonNull context: Context,     @Nullable lifecycle: Lifecycle,     @NonNull intent: Intent,     @Nullable callback: IAttachmentLoaderCallback)
Call this method to load a file attachment presented by com.streamwide.smartms.lib.core.data.item.FileAttachment.
Link copied to clipboard
open fun loadGIFAttachment(    @NonNull context: Context,     @NonNull intent: Intent,     @Nullable callback: IAttachmentLoaderCallback)
open fun loadGIFAttachment(    @NonNull context: Context,     @Nullable lifecycle: Lifecycle,     @NonNull intent: Intent,     @Nullable callback: IAttachmentLoaderCallback)
Call this method to load a GIF presented by com.streamwide.smartms.lib.core.data.item.GifAttachment..
Link copied to clipboard
open fun loadImageAttachment(    @NonNull context: Context,     @NonNull intent: Intent,     @Nullable extraKey: String,     needCompress: Boolean,     @Nullable callback: IAttachmentLoaderCallback)
open fun loadImageAttachment(    @NonNull context: Context,     @Nullable lifecycle: Lifecycle,     @NonNull intent: Intent,     @Nullable extraKey: String,     needCompress: Boolean,     @Nullable callback: IAttachmentLoaderCallback)
Call this method to load an image presented by com.streamwide.smartms.lib.core.data.item.ImageAttachment.
Link copied to clipboard
open fun loadUserSettingAttachment(    @NonNull context: Context,     @NonNull intent: Intent,     @Nullable callback: IAttachmentLoaderCallback)
open fun loadUserSettingAttachment(    @NonNull context: Context,     @Nullable lifecycle: Lifecycle,     @NonNull intent: Intent,     @Nullable callback: IAttachmentLoaderCallback)
Call this method to load user's settings presented by com.streamwide.smartms.lib.core.data.item.SettingAttachment.
Link copied to clipboard
open fun loadVcardAttachment(    @NonNull context: Context,     @NonNull intent: Intent,     @Nullable callback: IAttachmentLoaderCallback)
open fun loadVcardAttachment(    @NonNull context: Context,     @Nullable lifecycle: Lifecycle,     @NonNull intent: Intent,     @Nullable callback: IAttachmentLoaderCallback)
Call this method to load a contact presented by com.streamwide.smartms.lib.core.data.item.VCardAttachment.
Link copied to clipboard
open fun loadVideoAttachment(    @NonNull context: Context,     @NonNull intent: Intent,     @Nullable extraKey: String,     @Nullable callback: IAttachmentLoaderCallback)
open fun loadVideoAttachment(    @NonNull context: Context,     @Nullable lifecycle: Lifecycle,     @NonNull intent: Intent,     @Nullable extraKey: String,     @Nullable callback: IAttachmentLoaderCallback)
Call this method to load a video from uri presented by com.streamwide.smartms.lib.core.data.item.VideoAttachment.
Link copied to clipboard
open fun pauseAttachmentOperation(@NonNull context: Context, @NonNull attachmentId: String)
Call this method to pause downloading or uploading an attachment.
Link copied to clipboard
open fun registerToAttachmentEvent(@NonNull listener: IAttachmentCallback)
Register to all events related to the attachment
Link copied to clipboard
open fun removeAttachmentOperationListener(    @NonNull context: Context,     @NonNull attachmentId: String,     @Nullable cloudServiceListener: CloudServiceListener)
Call this method if no longer needed to listen for upload or download operation.
Link copied to clipboard
open fun retryDownloadAttachmentThumbnail(    @NonNull context: Context,     @NonNull attachmentId: String,     @Nullable callback: STWOperationCallback<MessagingError>)
Call this method to get the thumbnail path of an attachment.
Link copied to clipboard
open fun sendPurgeAttachmentRequest(@NonNull context: Context, @Nullable callback: STWOperationCallback)
Call this method to send purge attachment request This method send purge attachment request to the server
Link copied to clipboard
open fun startRecordingAudio(@Nullable audioAttachmentListener: STWAudioAttachmentListener)
Call this method to start recording an audio clips Recording of audio clips stops when the maximum period or maximum size is achieved
Link copied to clipboard
open fun stopRecordingAudio(@Nullable audioAttachmentListener: STWAudioAttachmentListener)
Call this method to stop recording an audio clips An audio clip whose period is less than 1 second cannot be recorded
Link copied to clipboard
open fun uploadAttachment(    @NonNull context: Context,     @NonNull attachmentId: String,     @Nullable operationCallback: STWOperationCallback<MessagingError>)
Call this method to upload an attachment given attachment Id.