Customization

The Customizations section of the OpenWeb Android SDK empowers developers to tailor the user interface and interaction elements to align with their brand identity and user experience goals.

By leveraging the customization APIs, publishers can:

  • Define sorting behaviors and labels for comment threads.
  • Control the theme (light, dark, or custom) to match the application's aesthetic.
  • Customize the appearance of comment actions, such as button colors and fonts.
  • Add accessory views to extend or enhance predefined UI components.
  • Integrate Giphy for engaging gif selections within comments.

Customizations are handled through a set of structured APIs under the OWCustomizations interface, offering flexibility and ease of integration without compromising the core functionality of the SDK.

This section guides you through key customization capabilities, with examples and references to ensure seamless implementation.


Sorting

Sorting options let you customize the initial sorting order and labels for comment threads.

Properties and Methods
  • initialSortOption: Specifies the default sorting order. Possible values include:

    • BEST: (Default).
    • NEWEST
    • OLDEST
  • setTitle(title: String, sortOption: OWSortOption): Assigns a custom title for a sort option.

Example:

val sortingCustomizations: OWSortingCustomizations = OpenWeb.manager.ui.customizations.sorting

// Set the default sorting option to NEWEST
sortingCustomizations.initialSortOption = OWSortOption.NEWEST

// Customize the title for "BEST"
sortingCustomizations.setTitle("Top Comments", OWSortOption.BEST)

Theme

With the OpenWeb SDK, you can define light, dark, or fully customized themes to match your application's design.

Theme Enforcement

Theme Enforcement allows developers to set the theme mode and customize the color scheme for dark mode.

Properties and Methods
  • themeMode: Defines the theme mode. Options include:

    • LIGHT (Default)
    • DARK
  • darkColor: Allows setting a custom dark color scheme.

Example:

val customizations = OpenWeb.manager.ui.customizations

// Enable dark mode
customizations.themeEnforcement.themeMode = OWThemeMode.DARK

Customized Theme

Customized Theme provides complete control over colors for both light and dark modes. Developers can specify colors for various UI components using the OWTheme class.

Warning

When customizing an OWTheme property, both lightColor and darkColor must be defined.

Example:

customizations.customizedTheme = OWTheme(
    primaryBackgroundColor = UIColor(0xFF000000),
    secondaryTextColor = UIColor(0xFF888888),
    brandColor = UIColor(0xFFFF5722)
)
OWTheme
PropertyDescription
skeletonColorColor for loading skeletons.
skeletonShimmeringColorShimmer effect color for loading skeletons.
primarySeparatorColorPrimary separator line color.
secondarySeparatorColorSecondary separator line color.
tertiarySeparatorColorTertiary separator line color.
primaryTextColorPrimary text color for main content.
secondaryTextColorSecondary text color for supporting content.
tertiaryTextColorTertiary text color for less prominent content.
primaryBackgroundColorBackground color for primary views.
secondaryBackgroundColorBackground color for secondary views.
tertiaryBackgroundColorBackground color for tertiary views.
primaryBorderColorBorder color for primary elements.
secondaryBorderColorBorder color for secondary elements.
loaderColorColor of loading indicators.
brandColorBrand's primary color.
voteUpSelectedColorColor for the "upvote" button when selected.
voteUpUnselectedColorColor for the "upvote" button when unselected.
voteDownSelectedColorColor for the "downvote" button when selected.
voteDownUnselectedColorColor for the "downvote" button when unselected.
statusBarColor (deprecated)Status bar color. Deprecated in API level 35; use primaryBackgroundColor.
navigationBarColor (deprecated)Navigation bar color. Deprecated in API level 35; use primaryBackgroundColor.

Comment Action

Control the appearance of comment action buttons, such as their colors and fonts.

Properties and Methods
  • commentActionsButtonsColor: Options include:

    • DEFAULT
    • BRAND_COLOR
  • commentActionsButtonsFont: Options include:

    • DEFAULT
    • SEMI_BOLD

Example:

val customizations = OpenWeb.manager.ui.customizations

// Customize comment action buttons
customizations.commentActions = OWCommentActionsCustomizations(
    commentActionsButtonsColor = CommentActionsButtonsColor.BRAND_COLOR,
    commentActionsButtonsFont = CommentActionsButtonsFont.SEMI_BOLD
)

Font Family

Customize the font style used throughout the SDK's UI components.

Property
  • fontFamily: Represents a font style resource ID that can be applied globally to text elements in the SDK.

Example:

val customizations = OpenWeb.manager.ui.customizations

// Set a custom font family
customizations.fontFamily.styleResId = R.font.my_custom_font

Accessory Views

Extend or replace predefined UI elements using accessory views.

Method
  • setAccessoryViewProvider(viewProvider: OWAccessoryViewProvider): Registers a custom view provider for the SDK.

Example:

customizations.setAccessoryViewProvider(object : OWAccessoryViewProvider {
    override fun provideView(
        viewType: OWAccessoryViewType,
        inflater: LayoutInflater,
        parent: ViewGroup?
    ): View? {
        if (viewType == OWAccessoryViewType.BottomToolbar) {
            return inflater.inflate(R.layout.custom_toolbar, parent, false)
        }
        return null
    }
})

Giphy Integration

Enable users to select and share GIFs using the Giphy SDK.

Method
  • setGiphyProvider(giphyProvider: SpotGiphyProvider): Connects the OpenWeb SDK with the Giphy SDK.

Example:

customizations.setGiphyProvider(object : SpotGiphyProvider {
    override fun configure(activityContext: Context, sdkKey: String) {
        // Giphy configuration logic
    }

    override fun showGiphyDialogFragment(
        giphySetting: GiphySetting,
        fragmentManager: FragmentManager,
        fragmentTag: String,
        selectionListener: GifSelectionListener
    ) {
        // Show the Giphy dialog fragment
    }
})

Custom UI Delegate

You can customize individual UI components by implementing a custom delegate.

Method
  • setCustomUIDelegate(customUIDelegate: CustomUIDelegate): Allows customization of specific views within the SDK.

Example:

customizations.setCustomUIDelegate(object : CustomUIDelegate {
    override fun customizeView(
        viewType: CustomizableViewType,
        view: View,
        isDarkModeEnabled: Boolean,
        postId: OWPostId
    ) {
        if (viewType == CustomizableViewType.NAVIGATION_TITLE_TEXT_VIEW) {
            (view as? TextView)?.apply {
                text = "Custom Navigation Title"
                setTextColor(Color.RED)
            }
        }
    }
})
CustomizableViewType
View TypeDescription
LOGIN_PROMPT_TEXT_VIEWCustomizes the login prompt text displayed for unauthenticated users.
SAY_CONTROL_IN_PRE_CONVERSATION_TEXT_VIEWCustomizes the "Say something" control in the pre-conversation view.
SAY_CONTROL_IN_CONVERSATION_TEXT_VIEWCustomizes the "Say something" control in the conversation view.
CONVERSATION_FOOTER_VIEWCustomizes the footer section of the conversation.
COMMUNITY_QUESTION_TEXT_VIEWCustomizes the community question text view.
NAVIGATION_TITLE_TEXT_VIEWCustomizes the navigation title text.
NAVIGATION_BACK_IMAGE_VIEWCustomizes the back button image in the navigation bar.
NAVIGATION_TOOLBAR_VIEWCustomizes the entire navigation toolbar.
COMMUNITY_GUIDELINES_TEXT_VIEWCustomizes the community guidelines text.
SHOW_COMMENTS_BUTTONCustomizes the "Show Comments" button.
PRE_CONVERSATION_HEADER_TEXT_VIEWCustomizes the header text in the pre-conversation view.
PRE_CONVERSATION_HEADER_COUNTER_TEXT_VIEWCustomizes the counter text in the pre-conversation header.
COMMENT_CREATION_ACTION_BUTTONCustomizes the action button for creating comments.
COMMENT_CREATION_ACTION_IMAGE_BUTTONCustomizes the image button for creating comments.
READ_ONLY_TEXT_VIEWCustomizes the text view displayed in read-only mode.
EMPTY_STATE_READ_ONLY_TEXT_VIEWCustomizes the text view displayed when there are no comments in read-only mode.

Navigation Bar Color

  • setUseWhiteNavigationColor(useWhiteNavigationColor: Boolean): Configures the navigation bar color to white.

Example:

customizations.setUseWhiteNavigationColor(true)

For additional examples or advanced use cases, refer to the specific customization APIs in the reference section.