Send widget is a customizable component for entering and sending text and image messages.
To make the component work correctly, you need to perform the following steps.
<com.strv.chat.core.core.ui.chat.sending.SendWidget
android:id="@+id/w_send"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
Call type-safe init()
builder function in onCreate()
method of your
Activity that allows creating Kotlin-based domain-specific language
(DSL) suitable for configuring the component.
Minimum required properties that the component needs to be set:
conversationId: String
id
of the related conversation
newFileProvider: FileProvider
- Defines a way of retrieving file uri for saving the camera output that is used to send as an image message
sendWidget.init {
conversationId = chatViewModel.conversationId
newFileProvider = chatViewModel.newFileProvider
}
The Android Camera application encodes the result of an image capture
action to onActivityResult()
. Thus, it is your responsibility to
handle the REQUEST_IMAGE_CAPTURE
request code in onActivityResult()
method.
In case of successful processing of the image, Send widget API contains the
method uploadImage(uri: Uri)
, which will start a service that uploads
the image on the server and shows a notification that notifies about the
progress and the result of the upload.
app:sw_backgroundColor
- custom component background colorapp:sw_sendIconTint
- custom send button icon tintapp:sw_messageOptionIconColorNormal
- custom message option icons tint in an unselected stateapp:sw_messageOptionIconColorActivated
- custom message option icons tint in a selected stateapp:sw_sendIcon
- custom send button iconapp:sw_textOptionIcon
- custom text-message option button iconapp:sw_imageOptionIcon
- custom image-message option button iconapp:sw_hint
- custom hint for the input edit textapp:sw_imageOptionEnabled
- allow/disallow image messages,true
by defaultapp:sw_inputTextAppearance
- custom message input text appearance from the specified style resource
largeIconRes: Int
- custom large icon resource id that is shown in the ticker and notificationsmallIconProgressRes: Int
- custom small icon resource id to use in the notification layouts in a progress statesmallIconSuccessRes: Int
- custom small icon resource id to use in the notification layouts in a success statesmallIconErrorRes: Int
- custom small icon resource id to use in the notification layouts in an error state