ConversationOptions builder

Customize the appearance of the Conversation in your Android app.

The ConversationOptions.Builder() allows you to customize aspects of the appearance of the Pre-Conversation fragment and Conversation, such as the theme, article settings, and comment sort order.



Customize the appearance

Use the following steps to configure the appearance of the Pre-Conversation fragment and Conversation:

  1. In your Activity or Fragment, use ConversationOptions.Builder() to create and define a ConversationOptions object named options.
val themeMode = SpotImThemeMode.DARK
val backgroundColor = Color.parseColor("#000000")
val options = ConversationOptions.Builder()
    .addTheme(SpotImThemeParams(false, themeMode, backgroundColor))
    .configureArticle(
        Article(
            "URL", "THUMBNAIL_URL", "TITLE", "SUBTITLE")
        )
    .addSortType(SortType.SORT_NEWEST)
    .build()

  1. Add the options argument to the Pre-Conversation fragment, Conversation, or create a comment screen in the Activity.
SpotIm.getPreConversationFragment(CONVERSATION_ID, options, object : 
SpotCallback<Fragment> {
    override fun onSuccess(fragment: Fragment) {
        // doSomething...
    }

    override fun onFailure(exception: SpotException) {
        // doSomething...
    }
})
SpotIm.getConversationIntent(context, CONVERSATION_ID, options, object :
    SpotCallback<Intent> {
        override fun onSuccess(intent: Intent) {
            startActivity(intent)
        }
        override fun onFailure(exception: SpotException) {
            // Handle error here
    }
})
SpotIm.getCreateCommentIntent(context, CONVERSATION_ID, options, object :
    SpotCallback<Intent> {
        override fun onSuccess(intent: Intent) {
            startActivity(intent)
        }

        override fun onFailure(exception: SpotException) {
            // Handle error here
    }
})



Class ConversationOptions.Builder

Builder for ConversationOptions


addMaxCountOfPreConversationComments(counter)

Defines the number of comments shown in the Pre-Conversation fragment

val options = ConversationOptions.Builder()
    .addMaxCountOfPreConversationComments(4)
    .build()
ArgumentDescription
counter IntInteger between 0 - 16

Default: 2

If this argument is less than 0, two comments are displayed. If this argument is greater than 16, only a maximum of sixteen comments are displayed.


addSortType(sortOption)

Sets up a SortType parameter that defines the sort order of comments.

val options = ConversationOptions.Builder()
    .addSortType(SortType.SORT_NEWEST)
    .build()
ArgumentDescription
sortOption SortTypeType of sort order

Possible values include the following:
   • SortType.BEST
   • SortType.NEWEST
   • SortType.OLDEST


addTheme(SpotImThemeParams(isSupportSystemDarkMode, themeMode, backgroundColor))

Sets up a SpotImThemeParams class that defines the sorting background color and Spot.IM theme

val themeMode = SpotImThemeMode.DARK
val backgroundColor = parseColor("#000000")

val options = ConversationOptions.Builder()
    .addTheme(SpotImThemeParams(false, themeMode, backgroundColor))
    .build()
ArgumentDescription
isSupportSystemDarkMode BooleanDefines if the Partner app supports system dark mode

This should always be set to false to enable the themeMode argument to be defined by addTheme().
themeModeOpenWeb theme to be applied to the Pre-Conversation and Conversation

Possible values include the following:
   •SpotImThemeMode.DARK
   •SpotImThemeMode.LIGHT
backgroundColor IntBackground color for the Pre-Conversation fragment and Conversation when the themeMode is SpotImThemeMode.DARK

The value of this argument is ignored when the themeMode is SpotImThemeMode.LIGHT.


configureArticle(Article("URL", "THUMBNAIL_URL", "SUBTITLE"))

Sets up an Article class that defines the current article

val options = ConversationOptions.Builder()
    .configureArticle(
        Article(
            "URL", "THUMBNAIL_URL", "TITLE", "SUBTITLE")
    )
    .build()


configureArticleSection("SECTION_NAME")

Set article section name to display relevant comment labels.

Please contact your PSM to learn more about comment labels and request setting remote configure related to comment sections and labels info.

When custom labels are set up in the config, call configureArticleSection with a custom section name to enable or overide the existing default section.

In the following scenarios, configureArticleSection should not be called:

  • If the default comment label section is set up in the config, comment labels will be enabled on all Conversations. There is no need to call configureArticleSection.
  • If the comment label config is not set up, calling configureArticleSection will have no effect.
val options = ConversationOptions.Builder()
    .configureArticleSection("SECTION_NAME")
    .build()


setCustomSortByOptionText(sortOption, R.string.customTitle)

val options = ConversationOptions.Builder()
    .setCustomSortByOptionText(SpotImSortOption.BEST, R.string.customTitle)
ArgumentDescription
sortOption SpotImSortOptionType of sort order

Possible values include the following:
   • SpotImSortOption.BEST
   • SpotImSortOption.NEWEST
   • SpotImSortOption.OLDEST
r.string.customTitleCustom text for sorting options


setDisplayArticleHeader(false)

Determines if the article header is displayed

val options = ConversationOptions.Builder()
    .setDisplayArticleHeader(false)
    .build()

To hide the article header, set .setDisplayArticleHeader(false). To display the article header, set .setDisplayArticleHeader(true).



setInitialSort(sortOption)

Sets up a SpotImSortOption parameter that defines the initial sort order of comments.

val options = ConversationOptions.Builder()
    .setInitialSort(SpotImSortOption.BEST)
    .build()
ArgumentDescription
sortOption SpotImSortOptionType of sort order

Possible values include the following:
   • SpotImSortOption.BEST
   • SpotImSortOption.NEWEST
   • SpotImSortOption.OLDEST