Components ᴺᴱᵂ


The OWUIComponents interface is the primary entry point for embedding conversation experiences in your Android app as of SDK version 3.0.0. It replaces the deprecated OWUIFlows and OWUIViews APIs and provides a unified, simplified surface for displaying pre-conversation summaries, full conversations, and routed deep links into specific comment threads or creation flows.

Accessing OWUIComponents

Retrieve the interface from the SDK manager:

val components: OWUIComponents = OpenWeb.manager.ui.components

Methods

getPreConversation()

Returns a Fragment displaying the pre-conversation summary widget — comment count, top comments, and a prompt to open the full conversation. Embed it in any FragmentActivity or FragmentManager host.

components.getPreConversation(
    postId = "POST_ID",
    articleSettings = OWArticleSettings(),
    conversationNavigation = OWConversationNavigationMode.ConversationFullScreen(),
    additionalSettings = OWAdditionalSettings(),
    actionCallbacks = null,
    completion = object : SpotCallback<Fragment>() {
        override fun onSuccess(fragment: Fragment) {
            supportFragmentManager.beginTransaction()
                .replace(R.id.container, fragment)
                .commit()
        }
        override fun onFailure(exception: SpotException) {
            // handle error
        }
    }
)

Parameter notes:

  • postId — Identifies the content item. Pass both a postId string and your spotId.
  • articleSettings — Describes the article the conversation belongs to and how its header is displayed. See OWArticleSettings.
  • conversationNavigation — Controls how the full conversation opens when the user taps the widget. Use ConversationFullScreen for default SDK-managed navigation, or ConversationCustom to intercept the tap and handle navigation yourself via OWPreConversationActionsCallbacks.
  • additionalSettings — Per-surface appearance and behaviour overrides for the pre-conversation, conversation, comment thread, and comment creation screens. See OWAdditionalSettings.
  • actionCallbacks — Optional. Receives SDK flow events via OWFlowEventCallbacks — currently fired when the user taps a publisher profile or dismisses the conversation. See OWFlowEventCallbacks.

getConversation()

Returns a Fragment containing the full conversation experience. Embed it directly in your layout when you want the conversation to live inside your own scrollable container or tab structure.

components.getConversation(
    postId = "POST_ID",
    articleSettings = OWArticleSettings(),
    route = null,
    additionalSettings = OWAdditionalSettings(),
    actionCallbacks = null,
    completion = object : SpotCallback<Fragment>() {
        override fun onSuccess(fragment: Fragment) {
            supportFragmentManager.beginTransaction()
                .replace(R.id.container, fragment)
                .commit()
        }
        override fun onFailure(exception: SpotException) {
            // handle error
        }
    }
)

Parameter notes:

  • route — Optional. Pass an OWConversationRoute to open the conversation at a specific location, such as a comment thread or a new comment creation screen. When null, the conversation opens at the top.

openConversation()

Launches the conversation as a full-screen SDK-managed activity. Use this method when you do not want to manage the Fragment lifecycle yourself.

components.openConversation(
    postId = "POST_ID",
    articleSettings = OWArticleSettings(),
    route = null,
    additionalSettings = OWAdditionalSettings(),
    actionCallbacks = null,
    completion = object : SpotCallback<Unit>() {
        override fun onSuccess(unit: Unit) {
            // launched successfully
        }
        override fun onFailure(exception: SpotException) {
            // handle error
        }
    }
)

Note: The completion callback is optional. Omit it if you only need fire-and-forget navigation.

Settings

Every OWUIComponents method takes two settings objects. Both default to sensible values — pass OWArticleSettings() / OWAdditionalSettings() when you don't need to customize anything.

  • articleSettings (OWArticleSettings) — the article the conversation belongs to and how its header is shown.
  • additionalSettings (OWAdditionalSettings) — per-surface appearance and behaviour for each SDK screen.
// Compact pre-conversation, conversation without pull-to-refresh, floating composer
val additionalSettings = OWAdditionalSettings(
    preConversationSettings = OWPreConversationSettings(OWPreConversationStyle.Compact),
    conversationSettings = OWConversationSettings(
        conversationStyle = OWConversationStyle.Regular,
        allowPullToRefresh = false
    ),
    commentCreationSettings = OWCommentCreationSettings(OWCommentCreationStyle.Floating)
)

components.getConversation(
    postId = "POST_ID",
    additionalSettings = additionalSettings,
    completion = completion
)

OWAdditionalSettings

A container holding one settings object per SDK surface.

PropertyPurpose
preConversationSettingsStyle of the pre-conversation widget. (OWPreConversationSettings)
conversationSettingsStyle and behaviour of the full conversation. (OWConversationSettings)
commentThreadSettingsBehaviour of a focused comment thread. (OWCommentThreadSettings)
commentCreationSettingsStyle of the comment editor. (OWCommentCreationSettings)

OWPreConversationSettings

PropertyPurpose
preConversationStyleLayout of the pre-conversation widget. (OWPreConversationStyle, default Regular)

OWPreConversationStyle values:

ValueDescription
RegularDefault. Shows up to 2 comments with the summary, guidelines, and question.
CompactCondensed layout showing a single comment.
CtaButtonOnlyShows only the call-to-action button — no comments or summary.
CtaWithSummaryShows the summary and call-to-action button, no comment previews.
Custom(…)Fully configurable layout. See parameters below.

Custom parameters:

ParameterPurpose
numberOfCommentsComment previews to show. Coerced to the range 1–8. (Int, default 2)
collapsableTextLineLimitLines shown before a comment collapses behind "read more". (Int, default 4)
preConversationSummaryStyleSummary display. (OWPreConversationSummaryStyle, default Regular)
communityGuidelinesStyleGuidelines display. (OWCommunityGuidelinesStyle, default Regular)
communityQuestionStyleCommunity question display. (OWCommunityQuestionsStyle, default Regular)

OWConversationSettings

PropertyPurpose
conversationStyleLayout of the full conversation. (OWConversationStyle, default Regular)
allowPullToRefreshEnables pull-to-refresh in the conversation. (Boolean, default true)

OWConversationStyle values:

ValueDescription
RegularDefault spacing, with the guidelines and community question shown in full.
CompactCondensed spacing and compact guidelines/question.
Custom(…)Configurable communityGuidelinesStyle, communityQuestionsStyle, and spacing.

OWCommentThreadSettings

PropertyPurpose
allowPullToRefreshEnables pull-to-refresh in the comment thread. (Boolean, default true)

OWCommentCreationSettings

PropertyPurpose
commentCreationStyleLayout of the comment editor. (OWCommentCreationStyle, default Floating)

OWCommentCreationStyle values:

ValueDescription
FloatingDefault. Editor floats above the keyboard.
RegularStandard full-screen editor.
LightLightweight inline editor.

Shared Style Enums

OWPreConversationSummaryStyle, OWCommunityGuidelinesStyle, and OWCommunityQuestionsStyle each accept:

ValueDescription
RegularStandard display (default).
CompactCondensed display.
NoneHidden.

OWConversationSpacing (used by OWConversationStyle.Custom):

ValueDescription
RegularDefault spacing.
CompactCondensed spacing.
Custom(…)Set betweenComments, belowCommunityGuidelines, and belowCommunityQuestions in dp.

OWArticleSettings

PropertyPurpose
articleInformationStrategySource of article metadata. (OWArticleInformationStrategy, default Server)
additionalSettingsHeader, read-only, and rating options. (OWArticleAdditionalSettings)

OWArticleInformationStrategy values:

ValueDescription
ServerDefault. The SDK fetches article metadata from the OpenWeb backend.
Local(article)You supply the article metadata locally via an Article instance.

OWArticleAdditionalSettings properties:

PropertyPurpose
sectionContent section the article belongs to. (String?, default null)
headerStyleArticle header display. (OWArticleHeaderStyle, default Regular)
readOnlyModeRead-only behaviour. (OWReadOnlyMode, default SERVER)
starRatingEnables the star-rating widget. (Boolean, default false)

OWArticleHeaderStyle values:

ValueDescription
RegularDefault. Shows the article header.
NoneHides the article header.

OWReadOnlyMode values:

ValueDescription
SERVERDefault. Follows the read-only state from the server.
ENABLEForces read-only mode on.
DISABLEForces read-only mode off.

Enumerations and Types

OWConversationNavigationMode

Controls how the full conversation screen is opened from within getPreConversation().

SubclassWhen to use
ConversationFullScreen(callbacks)SDK manages navigation; callbacks is an optional OWFlowEventCallbacks for action events.
ConversationCustom(preConversationActionsCallbacks)You intercept navigation; implement OWPreConversationActionsCallbacks.openConversationFlow(route) to push your own screen.

OWConversationRoute

A sealed class that deep-links the conversation to a specific entry point. Pass as the route parameter to getConversation() or openConversation().

SubclassPurpose
OWCommentThreadRoute(commentId: String)Opens the conversation scrolled to a specific comment thread.
OWCommentCreationRoute(type: OWCommentCreationType)Opens the conversation with the comment editor pre-focused.

OWFlowEventCallbacks

Implement this interface to be notified when the SDK reports a flow-level event. The callback method receives the event type, the source surface that fired it, and the postId it relates to.

val callbacks = object : OWFlowEventCallbacks {
    override fun callback(
        type: OWFlowActionCallbackType,
        source: OWFlowSourceType,
        postId: OWPostId
    ) {
        when (type) {
            is OWFlowActionCallbackType.OpenPublisherProfile -> {
                // user tapped a publisher's profile — use type.context, type.ssoPublisherId, type.type
            }
            is OWFlowActionCallbackType.ConversationDismissed -> {
                // user dismissed the conversation screen
            }
        }
    }
}

OWFlowActionCallbackType

A sealed class enumerating the flow events delivered to OWFlowEventCallbacks.

SubclassWhen it fires
OpenPublisherProfile(context, ssoPublisherId, type)User tapped a publisher's profile within the conversation. context is an Android Context, ssoPublisherId identifies the publisher, and type is an OWUserProfileType.
ConversationDismissedThe conversation screen was dismissed by the user.

OWFlowSourceType

Identifies which UI surface produced the event.

ValueSurface
PreConversationThe pre-conversation summary widget.
ConversationThe full conversation screen.
CommentThreadA focused comment thread inside the conversation.

OWCommentCreationType

Pass an instance to OWConversationRoute.OWCommentCreationRoute to control which editor opens.

ValueOpens
CommentThe editor for posting a new top-level comment.
Edit(commentId)The editor for editing the specified existing comment.
ReplyTo(commentId)The editor for posting a reply under the specified comment.
NoneNo editor — the conversation opens without focusing an editor.

OWPreConversationActionsCallbacks

Implement this interface when using ConversationCustom navigation mode to handle conversation open events yourself. The SDK builds the route for you (comment thread, comment creation, etc.); you decide where and how to render it.

The typical pattern is to forward the route into OWUIComponents.openConversation() from your own navigation point:

val navCallbacks = object : OWPreConversationActionsCallbacks {
    override fun openConversationFlow(route: OWConversationRoute) {
        OpenWeb.manager.ui.components.openConversation(
            postId = "POST_ID",
            articleSettings = OWArticleSettings(),
            route = route,
            additionalSettings = OWAdditionalSettings(),
            actionCallbacks = null
        )
    }
}

Alternatively, push your own screen and ignore route if you render the conversation entirely outside the SDK.

Note: Migrating from Flows or Views? See the migration guide.