Message partview
com.imimobile.connect.ui.conversation
This package contains the following classes and interfaces.
Classes
- ICConversationActivity
- ICConversationCategory
- ICConversationMessageViewFactory
- ICConversationMessageViewHolder
- ICConversationRecyclerView
Interfaces
- ICMessageDisplayedListener
- ICRetryClickListener
ICConversationActivity
This activity leverages the functionality of the lower level components and provides the necessary wiring to combine them into a full-featured, in-app chat experience with minimal code.
The activity supports the display of the user conversation list and provides a means to open them or create new conversations. Selecting a conversation displays the conversation view and allows users to read, compose and send messages.
Prerequisites
This component requires that a valid ICMessageStore
instance is set within the Core SDK by calling ICMessaging.setMessageStore
.
Modes of operation
Depending on how the activity is started, there are two distinct modes of operation. Each provided to cover different scenarios. The standard mode of operation presents the conversation listing and allows the user to open an existing conversation or create a new one.
Alternatively, the activity may be started to display a specific conversation directly. This is useful when you need to take your user directly to a specific conversation. Perhaps they have navigated to another area within the application, or even to another application, starting with a conversation id allows you to take your user back to the conversation.
Adaptive Layout
The layout of the activity adapts to the device display, typically when running on a phone the activity will display the conversation list in full screen. When a conversation is displayed this replaces the conversation list display. Navigating back from the conversation will cause the conversation list to be re-displayed.
When running on a wide layout (greater than 700dp in landscape), the layout is split into two sections. The conversation list is shown on the left and the active conversation presented on the right.
Launching the activity
The activity provides two helper methods to start the activity in each of the supported modes of operation
start
Starts the activity to display a specific conversation.
Syntax: void start(Context context, String conversationId, Bundle extArgs)
Parameters:
Parameter | Type | Description |
---|---|---|
context | Context | Android context |
conversationId | String | conversation Id |
extArgs | Bundle | Bundle with extra arguments |
start
Starts the activity to display a list of conversations.
Syntax: void start(Context context, ArrayList<ICConversationCategory> categories, ICCustomerDetails customerDetails, Bundle extArgs)
Parameters:
Parameter | Type | Description |
---|---|---|
context | Context | Android context |
categories | ICConversationCategory | conversation categories |
customerDetails | ICCustomerDetails | customer details object |
extArgs | Bundle | Bundle with extra arguments |
Styling
The activity is customised to match the look and feel of your application, this is accomplished by setting styling attributes via XML.
To style the activity you must first declare styles that inherit from the default styles provided by the SDK and specify these custom styles within your app theme. Internally, the activity leverages the ICConversationsFragment and ICConversationFragment,
ICConversationCategory
Organisations typically have multiple contact points to which a customer may be directed depending on their query. Conversation categories provide the means to drive users to the correct contact point.
The information contained in ICConversationCategory
instance is also used to establish the correct communication stream for a conversation. Within IMIconnect, real time messages are sent over a stream, the stream is used to direct messages to the correct service to process the message.
Constructors
ICConversationCategory |
---|
public ICConversationCategory(java.lang.String title, java.lang.String streamName, android.net.Uri imageUri) |
public ICConversationCategory(java.lang.String title, java.util.ArrayList subCategories, android.net.Uri imageUri) |
getImageUri
This Method is used to get uri to an image representing the category, must be a local uri.
Syntax: android.net.Uri getImageUri()
Returns value: Returns a uri to an image representing the category, must be a local uri.
setImageUri
This method is used to set uri to an image representing the category, must be a local uri.
Syntax: void setImageUri(Uri imageUri)
Parameters:
Parameters | Type | Description |
---|---|---|
imageUri | Uri | image, local uri for representing the category |
getTitle
This Method is used to get Conversation Category Title
Syntax: jjava.lang.String getTitle()
Returns value: Returns Conversation Category Title
setTitle
This Method is used to set Conversation Category Title
Syntax: void setTitle(java.lang.String title)
Parameters:
Parameters | Type | Description |
---|---|---|
title | java.lang.String | Conversation Category Title |
getSubCategories
This Method is used to get An array list of subcategories.
Syntax: java.util.ArrayList<ICConversationCategory> getSubCategories()
Returns value: Returns, an array list of sub categories.
setSubCategories
This Method is used to set an array list of subcategories
Syntax: void setSubCategories(java.util.ArrayList<ICConversationCategory> subcategories)
Parameters
Description | Type | Description |
---|---|---|
subcategories | java.util.ArrayList | An array list of sub categories |
addSubCategory
This method is used to add Conversation category to SubCategories.
Syntax: void addSubCategory(ICConversationCategory category)
Parameters:
Description | Type | Description |
---|---|---|
category | (ICConversationCategory | Conversation category |
hasSubCategories
This Method is used to verify subcategories size is >0 or not
Syntax: boolean hasSubCategories()
Returns value: returns true if subcategories size is >0, false otherwise.
ICConversationMessageViewFactory
Factory class that inherits from ICMessageViewFactory
and creates ICConversationMessageViewHolder
instances. Used as the default message view factory within ICConversationRecyclerView
.
Refer ICMessageViewFactory
, for details of the base methods, that are overridden by this class.
ICConversationMessageViewHolder
Concrete implementation of ICMessageViewHolder
for use with ICConversationRecyclerView
.
Refer ICMessageViewFactory
, for details of the base methods, that are overridden by this class. In addition to the base, method overrides this class exposes the following methods.
setTimeVisibility
This method sets the visibility of the time display
Syntax: boolean setTimeVisibilty(int visibility)
setStatusVisibility
This method sets the visibility of the status display
Syntax: boolean setStatusVisibility(int visibility)
setOnRetryClickListener
This method Sets the listener which will be invoked when the retry message publication button is pressed.
Syntax: boolean setOnRetryClickListener(ICRetryClickListener listener)
ICConversationRecyclerView
Concrete implementation of ICMessageRecyclerView
that obtains i'ts data through ICMessageDataProvider
and uses ICConversationMessageViewHolder
instances to display.
registerOnRetryClickListener
This method registers a listener that will receive retry click events.
Syntax: void registerOnRetryClickListener(ICRetryClickListener listener)
unregisterOnRetryClickListener
This method Unregisters a previously registered listener.
Syntax: void unregisterOnRetryClickListener(ICRetryClickListener listener)
registerOnMessageDisplayedListener
This method Registers a listener that will receive message display events.
Syntax: void registerOnMessageDisplayedListener(ICMessageDisplayedListener listener)
unregisterOnMessageDisplayedListener
This method Unregisters a previously registered listener..
Syntax: void unregisterOnMessageDisplayedListener(ICMessageDisplayedListener listener)
ICMessageDisplayedListener
This interface is used to listen for message display events that are generated as a message is displayed to the user.
onMessageDisplayed
This method is invoked as a message is displayed to the user.
Syntax: void onMessageDisplayed(ICMessageData messageData)
ICRetryClickListener
This interface is used to listen for events that signal the retry message publication button has been pressed.
onRetry
This method is invoked when the retry message publication button is pressed by the user.
Syntax: void onRetry(ICMessageData messageData)
com.imimobile.connect.ui.conversation. composer
ICMessageComposerView
This class handles display of message composer view. register/Unregister message composer plugins for building message.
Constructors
ICMessageComposerVieww | |
---|---|
public ICMessageComposerView(Context context) | Simple constructor to use when creating a MessagecomposerView from code. |
public ICMessageComposerView(Context context, AttributeSet attrs) | Constructor that is called when inflating a MessagecomposerView from XML. |
public ICMessageComposerView(Context context, AttributeSet attrs, int defStyleAttr) | Perform inflation from XML and apply a class-specific base style from a theme attribute. |
setEnabled
This method used to enable/disable Message composer view. enabled by default
Syntax: void setEnabled(boolean enabled)
Overrides:: setEnabled in class View
Parameters:
Parameter | Type | Description |
---|---|---|
enabled | boolean | true for enable , false otherwise |
registerPlugin
This method used to registers a Message composer plugin
Syntax: void registerPlugin(ICMessageComposerPlugin plugin)
Parameters:
Parameter | Type | Description |
---|---|---|
plugin | ICMessageComposerPlugin | a plugin that will be registered |
onActivityResult
This method must be called from Activity's onActivityResult
to allow attachment senders to manage results from. (e.g. selecting a gallery photo or taking a camera image.)
Syntax: void onActivityResult(int requestCode, int resultCode, android.content.Intent data)
Parameters:
Parameter | Type | Description |
---|---|---|
requestCode | int | Request code from the Activity's onActivityResult. |
resultCode | int | Result code from the Activity's onActivityResult. |
data | android.content.Intent | Intent data from the Activity's onActivityResult. |
buildMessage
This method builds message based on message instance from the attachment selected by the user and the input text.
Syntax: com.imimobile.connect.core.messaging.ICMessage buildMessage()
``
Returns value: Returns the composed message.
setCallBack
This method allows to register an object, which implements the ICMessageComposerViewCallback
to listen for message composed events, start Typing and stop typing events which occur while composing a message.
Syntax: void setCallBack(ICMessageComposerViewCallback callback)
``
Parameters:
Parameter | Type | Description |
---|---|---|
callback | ICMessageComposerViewCallback | message composer view callback |
ICMessageComposerViewCallback
This interface represents call back methods implemented in message composer view to listen for message composed events, start Typing and stop typing events which occur while composing the message
onMessageComposed
This method is invoked when a user composed message.
Syntax: void onMessageComposed(com.imimobile.connect.core.messaging.ICMessage message, ICMessagePart[] messageParts)
``
Parameters:
Parameter | Type | Description |
---|---|---|
message | com.imimobile.connect.core.messaging.ICMessage | ICMessage instance |
messageParts | ICMessagePart[] | Aan Array of ICMessage parts |
onStartTyping
This method is invoked when user starts typing on message composer view.
Syntax: void onStopTyping()
onStopTyping
This method is invoked when user stops typing on message composer view.
Syntax: void onStopTyping()
com.imimobile.connect.ui.conversation. composer.plugins
ICMessageComposerPlugin
This abstract class represents all the methods needed to create the composer plugin. Creates a message instance from the message parts selected by the user and the input text also allows to register an object which implements the ICMessageComposerPluginCallback interface to listen for message composer plugin created message part and associated thumbnail.
ICMessageComposerPlugin
This method is invoked when a user composed message.
Syntax: ICMessageComposerPlugin(String displayName, @DrawableRes Integer iconResId)
Parameters:
Parameter | Type | Description |
---|---|---|
displayName | string | message composer plugin display name |
iconResId | integer | message composer plugin icon resource Id |
getDisplayName
This method is used to return message composer plugin display name.
Syntax: String getDisplayName()
``
Returns value: Return message composer plugin display name
getIconResId
This method is used to return message composer plugin icon resource id
Syntax: Integer getIconResId()
``
Returns value: Return message composer plugin icon resource Id.
execute
This method is used to execute message composer plugin implementation. Also allows to register an object, which implements the ICMessageComposerPluginCallback interface to listen for message composer plugin created message part and associated thumbnail
Syntax: void execute(ICMessageComposerPluginCallback callback)
``
Parameters:
Parameter | Type | Description |
---|---|---|
callback - | ICMessageComposerPluginCallback | MessageComposerPlugin Callback |
onActivityResult
This method is used to execute message composer plugin implementation. Also allows to register an object, which implements the ICMessageComposerPluginCallback interface to listen for message composer plugin created message part and associated thumbnail
Syntax: boolean onActivityResult(int requestCode, int resultCode, Intent data)
Override to handle results from onActivityResult
Parameters:
Parameter | Type | Description |
---|---|---|
requestCode | int | Request code from the Activity's onActivityResult. |
resultCode | int | Result code from the Activity's onActivityResult. |
data | int | Intent data from the Activity's onActivityResult. |
Returns value: Returns 'true' if the result was handled, or 'false' otherwise.
composeMessage
Creates a message instance from the message parts selected by the user and the input text
Syntax: void composeMessage(ICMessage message, ICMessagePart[] messageParts) )
Parameters:
Parameter | Type | Description |
---|---|---|
message | CMessage | An ICMessage instance |
messageParts | ICMessagePart[] | An Array of ICMessage parts |
ICMessageComposerAudioPlugin
This class implements the ICMessageComposerPlugin and is responsible for creation of message instance from the audio attachment message parts selected/recorded by the user.
ICMessageComposerAudioPlugin
Syntax: ICMessageComposerAudioPlugin(String displayName, @DrawableRes Integer iconResId, Activity activity)
Parameters:
Parameter | Type | Description |
---|---|---|
displayName | string | Message composer plugin display name |
iconResId | integer | Message composer plugin icon resource Id |
activity | activity | Android Activity |
ICMessageComposerFilePlugin
This class implements the ICMessageComposerPlugin and is responsible for creation of message instance from the File document attachment message parts selected by the user.
ICMessageComposerFilePlugin
Syntax: ICMessageComposerFilePlugin(String displayName, @DrawableRes Integer iconResId, Activity activity)
Parameters:
Parameter | Type | Descriptionv |
---|---|---|
displayName | string | message composer plugin display name |
iconResId | integer | message composer plugin icon resource Id |
activity | activity | android Activity |
ICMessageComposerGalleryPlugin
This class implements the ICMessageComposerPlugin and is responsible for creation of message instance from the attachment message parts selected by the user in gallery
ICMessageComposerFilePlugin
Syntax: ``ICMessageComposerGalleryPlugin(String displayName,
@DrawableRes
Integer iconResId,
Activity activity)
Parameters:
Parameter | Type | Description |
---|---|---|
displayName | string | message composer plugin display name |
iconResId | integer | message composer plugin icon resource Id |
plugin icon resource Id activity | activity | android Activity |
ICMessageComposerImageCameraPlugin
This class implements the ICMessageComposerPlugin and is responsible for creation of message instance from the message image attachment parts captured by the user
ICMessageComposerImageCameraPlugin
Syntax: ICMessageComposerImageCameraPlugin(String displayName, @DrawableRes Integer iconResId, Activity activity)
Parameters:
Parameter | Type | Description |
---|---|---|
displayName | string | message composer plugin display name |
iconResId | integer | message composer plugin icon resource Id |
activity | activity | android Activity |
ICMessageComposerLocationPlugin
This class implements the ICMessageComposerPlugin and is responsible for creation of message instance from the location message parts picked by the user
ICMessageComposerLocationPlugin
Syntax: ICMessageComposerLocationPlugin(String displayName, @DrawableRes Integer iconResId, Activity activity)
Parameters:
Parameter | Type | Description |
---|---|---|
displayName | string | message composer plugin display name |
iconResId | integer | message composer plugin icon resource Id |
activity | activity | android Activity |
ICMessageComposerVideoCameraPlugin
This class implements the ICMessageComposerPlugin and is responsible for creation of Creates a message instance from the video message parts captured/video message parts attached by the user
ICMessageComposerVideoCameraPlugin
Syntax: IICMessageComposerVideoCameraPlugin(String displayName, @DrawableRes Integer iconResId, Activity activity)
Parameters:
Parameter | Type | Description |
---|---|---|
displayName | string | message composer plugin display name |
iconResId - message composer plugin icon resource Id | integer | message composer plugin icon resource Id |
activity | activiry | android Activity |
ICMessageComposerPluginCallback
onPartCreated
This method is invoked when a message composer plugin created message part and associated thumbnail
Syntax: void onPartCreated(ICMessageComposerPlugin plugin, ICMessagePart part, Bitmap thumbnail)
Parameters:
Parameter | Type | Description |
---|---|---|
plugin | ICMessageComposerPlugin | The plugin that created the message part and the thumbnail |
part | ICMessagePart | The message part to be added |
thumbnail | Bitmap | The thumbnail associated to the message part |
com.imimobile.connect.ui.conversation.fragments
ICConversationsFragment
Displays a list of conversations of the current user and a floating action button for creating a new conversation, use this fragment when you wish to integrate a conversation list within your own layouts.
The fragment does not open or create new conversations directly, instead, events are raised through the ICConversationsFragmentListener interface and it is your responsibility to write the code in response to those events.
Message data is lazily loaded from a local ICMessageStore and remotely from the IMIconnect backend services. To achieve the best possible user experience it is recommended that you configure an appropriate message synchronisation policy within the Core SDK in order to pre-fetch data.
Activities that contain this fragment must implement the ICConversationsFragmentListener interface to handle interaction events. Use the newInstance(boolean) factory method to create an instance of this fragment.
Prerequisites
This component loads data from ICMessageStore
and therefore requires that a valid instance is set within the Core SDK, please refer to ICMessaging.setMessageStore
.
The activity that displays the fragment must implement the ICConversationsFragmentListener otherwise an exception will be thrown.
Instantiation
The fragment provides a helper method to instantiate the fragment with the correct arguments bundle.
newInstance
Makes use of this factory method to create a new instance of this fragment using the provided parameters and multi selection disabled
Syntax: ICConversationsFragment newInstance(boolean canShowConnectionIndicator)
Retutn value: Returns a new instance of fragment ICConversationsFragment.
newInstance
Use this factory method to create a new instance of this fragment using the provided parameters.
Syntax: ICConversationsFragment newInstance(boolean canShowConnectionIndicator, boolean allowMultiSelect)
Retutn value: Returns A new instance of fragment ICConversationsFragment.
newInstance
Use this factory method to create a new instance of this fragment with connection indicator and multi- select disabled
Syntax: ICConversationsFragment newInstance()
Retutn value: A new instance of fragment ICConversationsFragment.
Responding to events
Whenever a user selects a conversation or taps the create conversation button, the appropriate event is raised through the ICConversationsFragmentListener interface. The activity that host the fragment must implement this interface in order to respond to those events.
Styling
The style of the fragment can be set by configuring the appropriate style attributes within your apps styles.xml.
Internally the fragment leverages the lower level component ICInboxRecyclerView and it is this component which utilises the style attributes. Therefore, the style is applied to that component rather than the fragment itself.
First, define styles which inherit from the defaults provided by the SDK and set the appropriate attributes:
<style name="ICInboxRecyclerViewChild" parent="@style/ICInboxRecyclerView">
<item name="readTitleTextColor">@android:color/holo_orange_dark</item>
<item name="readTextColor">@android:color/holo_blue_dark</item>
<item name="readTextSize">16sp</item>
<item name="unReadTitleTextColor">@android:color/holo_orange_dark</item>
<item name="unReadTextStyle">bold</item>
<item name="unReadTextTypeface">bold</item>
<item name="unReadTextSize">20sp</item>
<item name="unReadTextColor">@android:color/holo_purple</item>
</style>
Finally, apply the style within the app theme,
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="ICInboxRecyclerView">@style/ICInboxRecyclerViewChild</item>
…..
</style>
Style attributes
ICInboxRecyclerView
Name | Description | Example | Supported Values |
---|---|---|---|
readTitleTextColor | Text color for the message title for read messages | Ex: @color/default_text_color | A color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb". |
readTitleTextSize | Text size for the message title for read messages | Ex : @dimen/default_title_text_size | A dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters). |
readTitleTextTypeface | Typeface for the message title for read messages | Ex: normal | Must be one of the following constant values monospace(3),normal(0),sans(1),serif (2) |
readTitleTextStyle | Text style for the message title for read messages | Ex: normal | Must be one or more (separated by '|') of the following constant values bold(1),italic(2),normal(0). |
readTextColor | Text color for the message body for read messages | Ex: @color/befault_text_color | A color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb". |
readTextSize | Text size for the message body for read messages | Ex: @dimen/default_text_size | A dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters). |
readTextTypeface | Typeface for the message body for read messages | Ex: normal | Must be one of the following constant values monospace(3),normal(0),sans(1),serif (2) |
readTextStyle | Text style for the message body for read messages | Ex: normal | Must be one or more (separated by '|') of the following constant values bold(1),italic(2),normal(0). |
readBgColor | Background colour for read messages | Ex: @color/default_bg_color | May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name". May be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb". |
readCornerRadius | Corner radius for read messages | Ex: @dimen/default_corner_radius | May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters). |
unReadTitleTextColor | Text color for the message title for unread messages | Ex: @color/inbox_text_color | May be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb". |
unReadTitleTextSize | Text size for the message title for unread messages | Ex: @dimen/default_title_text_size | May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters). |
unReadTitleTextTypeface | Typeface for the message title for unread messages | Ex: normal | Must be one of the following constant values monospace(3),normal(0),sans(1),serif (2) |
unReadTitleTextStyle | Text style for the message title for unread messages | Ex:bold | Must be one or more (separated by '|') of the following constant values bold(1),italic(2),normal(0). |
unReadTextColor | Text color for the message body for unread messages | Ex: @color/unread_text_color | May be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb". |
unReadTextSize | Text size for the message body for unread messages | Ex: @dimen/default_text_size | May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters). |
unReadTextTypeface | Typeface for the message body for unread messages | Ex:normal | Must be one of the following constant values monospace(3),normal(0),sans(1),serif (2) |
unReadTextStyle | Text style for the message body for unread messages | Ex:normal | Must be one or more (separated by '|') of the following constant values bold(1),italic(2),normal(0). |
unReadBgColor | Background colour for unread messages | Ex: @color/inbox_bg_color | May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name". May be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb". |
unReadCornerRadius | Corner radius for unread messages | Ex: @dimen/default_corner_radius | May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters). |
timeTextSize | Size of the text which displays the message time | Ex: @dimen/default_text_size | May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters). |
timeTextColor | Color of the text that displays the message time | Ex: @color/inbox_text_color | May be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb". |
badgeBackgroundResource | Background resource for the message badge | Ex: @drawable/badge | Reference to a drawable resource to use for the Badge. |
badgeTextSize | Size of the text for the message badge | Ex: @dimen/default_text_size | May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters). |
badgeTextColor | Color of the text for the message badge | Ex: @color/connectui_white | May be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb". |
badgeTextTypeface | Typeface of the text for the message badge | Ex: normal | Must be one of the following constant values monospace(3),normal(0),sans(1),serif (2) |
badgeTextStyle | Style of the text for the message badge | Ex: normal | Must be one or more (separated by '|') of the following constant values bold(1),italic(2),normal(0). |
ICConversationFragment
Displays messages within a conversation and provides a message composer.
Messages are displayed to the user in chronological order and new messages can be composed and published directly from the fragment. Supports typing indicators, delivery and read receipts, message attachments and connection indicator.
Message data is lazily loaded from a local ICMessageStore
and remotely from the IMIconnect backend services. To achieve the best possible user experience, it is recommended that you configure an appropriate message synchronisation policy within the Core SDK in order to pre-fetch data.
Prerequisites
This component loads data from ICMessageStore
and therefore requires that a valid instance is set within the Core SDK, For more information, refer to ICMessaging.setMessageStore
.
Instantiation
The fragment provides a helper method to instantiate the fragment with the correct arguments bundle.
newInstance
This factory method is used to create a new instance of this fragment using the provided parameters.
Syntax: ICConversationFragment newInstance(String threadId)
Parameters:
Parameter | Type | |
---|---|---|
threadId | String | threadId for conversation. |
Return value: A new instance of fragment ICConversationFragment.
Styling
The style of the fragment is set by configuring the appropriate style attributes within your apps styles.xml.
Internally, the fragment leverages the lower level component ICConversationRecyclerView
and it is this component which utilises the style attributes. Therefore, the style is applied to that component rather than the fragment itself.
At first, define styles which inherit from the defaults provided by the SDK and set the appropriate attributes:
<style name="ICConversationRecyclerViewChild" parent="@style/ICConversationRecyclerView">
<item name="myBackgroundResource">@drawable/my_message_bubble</item>
<item name="myBubbleColor">@android:color/holo_blue_light</item>
<item name="myCornerRadius">@dimen/default_corner_radius</item>
<item name="myTimeTextSize">@dimen/default_text_size</item>
<item name="myTimeTextColor">@android:color/darker_gray</item>
<item name="myTextColor">@android:color/white</item>
<item name="myTextLinkColor">@android:color/white</item>
<item name="myTextSize">@dimen/default_text_size</item>
<item name="myTextTypeface">normal</item>
<item name="myTextStyle">normal</item>
<item name="theirBackgroundResource">@drawable/their_message_bubble</item>
<item name="theirBubbleColor">@android:color/white</item>
<item name="theirCornerRadius">@dimen/default_corner_radius</item>
<item name="theirTimeTextSize">@dimen/default_text_size</item>
<item name="theirTimeTextColor">@android:color/darker_gray</item>
<item name="theirTextColor">@android:color/white</item>
<item name="theirTextLinkColor">@android:color/holo_blue_dark</item>
<item name="theirTextSize">@dimen/default_text_size</item>
<item name="theirTextTypeface">normal</item>
<item name="theirTextStyle">normal</item>
</style>
Finally, apply the style within the app theme:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="ICConversationRecyclerView">@style/ICConversationRecyclerViewChild</item>
…..
</style>
Style attributes
Attributes are based on a ‘my’ and ‘their’ system, any messages which originate from the user will have ‘my’ style attributes applied, other messages will have ‘their’ style applied. The exception is for ‘alert’ type messages which have their own style.
Additionally, a ‘myUnread’ style variant exists which allows a separate style to be applied when an outgoing message from the user has not been read. Once a read receipt has been received for the message the style will switch to the standard variant.
ICConversationRecyclerView
Name | Description | Example | Supported Values |
---|---|---|---|
myBackgroundResource | Background Resource for my messages | Ex: @drawable/my_message_bubble | Drawable reference. If not specified myBubbleColor is used instead |
myBubbleColor | Bubble color for my messages | Ex: @color/my_message_bubble_color | May be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb". |
myCornerRadius | Corner radius for my messages | Ex: @dimen/default_corner_radius | May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters). |
myTimeTextSize | Size of the time text for my messages | Ex: @dimen/default_text_size | May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters). |
myTimeTextColor | Color of the time text for my messages | Ex: @color/default_text_color | May be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb". |
myTextColor | Color of the text for my messages | Ex: @color/default_text_color | May be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb". |
myTextLinkColor | Color of the text used for links within my messages | Ex: @color/default_text_link_color | May be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb". |
myTextSize | Size of the text for my messages | Ex: @dimen/default_text_size | May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters). |
myTextTypeface | Typeface of the text for my messages | Ex: normal | Must be one of the following constant values monospace(3),normal(0),sans(1),serif (2) |
myTextStyle | Style of the text for my messages | Ex: normal | Must be one or more (separated by '|') of the following constant values bold(1),italic(2),normal(0). |
theirBackgroundResource | Background resource for their messages | Ex: @drawable/their_message_bubble | Drawable reference. If not specified, theirBubbleColor is used instead |
theirBubbleColor | Color of the bubble for their messages | Ex: @color/their_message_bubble_color | May be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb". |
theirCornerRadius | Corner radius of the bubble for their messages | Ex: @dimen/default_corner_radius | May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters). |
theirTimeTextSize | Size of the time text for their messages | Ex: @dimen/default_text_size | May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters). |
theirTimeTextColor | Color of the time text for their messages | Ex: @color/default_text_color | May be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb". |
theirTextColor | Color of the text for their messages | Ex: @color/default_text_color | May be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb". |
theirTextLinkColor | Color of the text for links within their messages | Ex: @color/default_text_color | May be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb". |
theirTextSize | Size of the text for their messages | Ex: @dimen/default_text_size | May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters). |
theirTextTypeface | Typeface of the text for their messages | Ex: normal | Must be one of the following constant values monospace(3),normal(0),sans(1),serif (2) |
theirTextStyle | Style of the text for their messages | Ex: normal | Must be one or more (separated by '|') of the following constant values bold(1),italic(2),normal(0). |
myUnreadBackgroundResource | Background resource for my unread messages | Ex: @drawable/my_unread_message_bubble | Drawable reference |
myUnreadBubbleColor | Bubble color for my unread messages | Ex: @color/connectui_dark_blue | May be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb". |
myUnreadCornerRadius | Corner radius for the background for my unread messages | Ex: @dimen/default_corner_radius | May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters). |
myUnreadTimeTextSize | Size of the time text for my unread messages | Ex: @dimen/default_text_size | May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters). |
myUnreadTimeTextColor | Color of the time text for my unread messages | Ex: @color/connectui_text_lightgrey | May be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb". |
myUnreadTextColor | Color of the text for my unread messages | Ex: @color/connectui_white | May be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb". |
myUnreadTextLinkColor | Color of any links within the text of my unread messages | Ex: @color/connectui_white | May be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb". |
myUnreadTextSize | Size of the text for my unread messages. | Ex: @dimen/default_text_size | May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters). |
myUnreadTextTypeface | Typeface of the text for my unread messages | Ex: normal | Must be one of the following constant values monospace(3),normal(0),sans(1),serif (2) |
myUnreadTextStyle | Style of the text for my unread messages | Ex: normal | Must be one or more (separated by '|') of the following constant values bold(1),italic(2),normal(0). |
alertBubbleColor | Color of the bubble for alerts | Ex: @android:color/transparent | May be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb". |
alertCornerRadius | Corner radius of the bubble for alerts | Ex: @dimen/default_corner_radius | May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters). |
alertTextColor | Color of the alert text | Ex: @color/connectui_text_darkgrey | May be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb". |
alertTextSize | Size of the alert text | Ex: @dimen/default_text_size | May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters). |
alertTextTypeface | Typeface of the alert text | Ex: normal | Must be one of the following constant values monospace(3),normal(0),sans(1),serif (2) |
alertTextStyle | Style of the alert text | Ex: bold | Must be one or more (separated by '|') of the following constant values bold(1),italic(2),normal(0). |
conversationBackgroundColor | Background color of the component | Ex: @color/conversation_bg_color | May be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb". |
ICConversationCategoryDialogFragment
This class displays a list of conversation categories.
Categories are represented by ICConversationCategory instances, these instances may be nested to create a hierarchy of categories. The fragment displays one level of categories at a time, when the user taps a category the fragment with either:
a. Where the category has sub-categories, displays the list of sub-categories
b. Where the category does not have sub-categories, raise an event via the ICConversationCategoryFragmentListener
Prerequisites
Must be hosted inside another fragment or an activity that implements the ICConversationCategoryFragmentListener interface.
Instantiation
The fragment provides a helper method which instantiates the fragment with the required arguments bundle. Once instantiated the fragment may either be displayed as a dialog or embedded in a layout.
newInstance
This factory method is used to create a new instance of this fragment using the provided parameters.
Syntax: ICConversationCategoryDialogFragment newInstance(ArrayList<ICConversationCategory> categories)
Return value: Returns a new instance of fragment ICConversationCategoryDialogFragment.
Interaction
The fragment displays a single level of categories at a time, if a category is selected which has sub-categories then the sub-category list replaces that which is currently shown. Pressing the back button will navigate up one level in the hierarchy.
When a final selection is made the selection is raised as an event through the ICConversationCategoryFragmentListener. A final selection is determined as a category that has no sub-categories.
onCategorySelected
This method is invoked when a user selected category which does not have sub-categories
Syntax: void onCategorySelected(ICConversationCategory category, ICConversationCategory parentCategory)
Parameter:
Parameter | Type | Description |
---|---|---|
category | ICConversationCategory | selected conversation category |
parentCategory | ICConversationCategory | parent conversation category |
com.imimobile.connect.ui.conversation.fragments.listeners
ICConversationsFragmentListener
Used to listen to ICConversationsFragment events.
void onThreadSelected(ICThread thread)
Invoked when a user selects a conversation within the fragment. Conversations are represented by an ICThread object, please refer to the Core SDK documentation for details. Typically, you will use the id within ICThread to open the conversation within an instance of ICConversationFragment.
void onCreateThreadSelected()
Invoked when a user taps the create conversation button. You are responsible for creating the new thread and displaying the conversation UI to the user. If you have multiple contact points you may wish to consider using ICConversationCategoryDialogFragment as an easy way to present these.
Use the ICMessaging.createThread method within the Core SDK to create a new thread, please refer to the Core SDK documentation for more information.
ICConversationCategoryFragmentListener
Used to listen to ICConversationCategoryFragment events.
void onCategorySelected(ICConversationCategory category, ICConversationCategory parentCategory)
Invoked when a user makes a final selection within the ICConversationCategoryFragment.
The parentCategory parameter will be null if the category has no parent.
Updated almost 2 years ago