# Customizing the Android SDK
# Debugging
To enable viewing SDK logs, use the following code:
// default is 'false'
val cbrSdk = CBRMobileSDK.Builder(this).withDebug(true)
CBRMobileSDK.SDK cbrSdk = new CBRMobileSDK.Builder(requireActivity()).withDebug(true);
Disable debugging before building the release version of your application.
# Logging
The SDK allows integration with a custom logger by using the .withLogTree method.
class CustomTree : Logger {
override fun d(tag: String, message: String, throwable: Throwable?) {
Log.d(tag, message, throwable)
}
override fun e(tag: String, message: String, throwable: Throwable?) {
Log.e(tag, message, throwable)
}
override fun i(tag: String, message: String, throwable: Throwable?) {
Log.i(tag, message, throwable)
}
override fun v(tag: String, message: String, throwable: Throwable?) {
Log.v(tag, message, throwable)
}
override fun w(tag: String, message: String, throwable: Throwable?) {
Log.w(tag, message, throwable)
}
}
To use your custom logger:
val cbrSdk = CBRMobileSDK.Builder(this).withLogTree(CustomTree())
# Analytics
The SDK collects and sends usage statistics to IDnGO servers. We do not track sensitive data; only general usage information are sent. This includes screen navigation events, interactions with UI elements, and so on.
This data is used exclusively to improve IDnGO. It is not shared with third parties and is not used for advertising.
To disable data analytics, use the following code:
val cbrSdk = CBRMobileSDK.Builder(this).withAnalyticsEnabled(false)
# Android SDK configuration
# Theme
For SDK version 1.30.1 and above, you can use the Android theme API.
Example of creating a theme:
// create a theme using CBRTheme
val customTheme = CBRTheme {
// configure theme parameters
colors.backgroundCommon = CBRThemeColor(resources.getColor(R.color.owl_yellow_200))
fonts.headline1 = CBRThemeFont(Typeface.MONOSPACE, 40)
metrics.activityIndicatorStyle = CBRThemeMetric.Size.LARGE
// ... other parameters
colors {
backgroundNeutral = CBRThemeColor(Color.RED)
// ... other parameters
}
fonts {
headline1 = CBRThemeFont(Typeface.MONOSPACE, 40)
subtitle2 = CBRThemeFont(Typeface.MONOSPACE, 10)
// ... other parameters
}
metrics {
screenHorizontalMargin = resources.getDimension(R.dimen.cbr_margin_large)
screenHeaderAlignment = CBRThemeMetric.TextAlignment.RIGHT
bottomSheetHandleSize = SizeF(20f, 20f)
// ... other parameters
}
}
val cbrSdk = CBRMobileSDK.Builder(this, apiUrl).withTheme(customTheme)
CBRThemeHolder theme = CBRThemeKt.newCBRTheme();
// get parameter areas
ColorsScope colorsScope = theme.getColorsScope();
MetricsScope metricsScope = theme.getMetricsScope();
FontsScope fontsScope = theme.getFontsScope();
// configure theme parameters
colorsScope.setBackgroundCommon(new CBRThemeColor(Color.RED, Color.GREEN));
metricsScope.setSectionHeaderAlignment(CBRThemeMetric.TextAlignment.CENTER);
fontsScope.setHeadline2(new CBRThemeFont(Typeface.SERIF, 15));
// ... other parameters
CBRMobileSDK.Builder cbrSdk = new CBRMobileSDK.Builder(this).withTheme(theme);
# Theme attributes for Android SDK
The SDK uses a Material Components theme for widgets. To configure the theme via the .withTheme() method, use the following attributes.
Theme color attributes:
colorPrimary— primary color for the application.colorPrimaryVariant— variant of the primary color for visual contrast.colorSecondary— secondary color for buttons and other elements.colorSurface— background color for surfaces.colorError— color for errors.colorOnPrimary— text color displayed on top of the primary color.colorOnSecondary— text color displayed on top of the secondary color.colorOnBackground— color used for text and other content placed over the background color.colorOnSurface— color used for text and other content placed over the surface color.colorOnError— color used for text and other content placed over the error color.colorControlNormal— default color used for UI controls such as checkboxes and switches.
# Text appearance attributes:
textAppearanceHeadline*— styles for headlines,textAppearanceSubtitle*— styles for subtitles,textAppearanceBody*— styles for multi-line body text,textAppearanceButton— style for button text,textAppearanceCaption— style for secondary text (supporting labels, hints, etc.),textAppearanceOverline— style for secondary headings.
# Shape appearance attributes:
shapeAppearanceSmallComponent— shape appearance for small components.shapeAppearanceMediumComponent— shape appearance for medium components.shapeAppearanceLargeComponent— shape appearance for large components.
# Additional color attributes:
cbr_colorInit— background color for the «init» state.cbr_colorOnInit— text (or icon) color for the «init» state.cbr_colorPending— background color for the «pending» state.cbr_colorOnPending— text (or icon) color for the «pending» state.cbr_colorSuccess— background color for the «success» state.cbr_colorOnSuccess— text (or icon) color for the «success» state.cbr_colorRejected— background color for the «rejected» state.cbr_colorOnRejected— text (or icon) color for the «rejected» state.cbr_colorProcessing— background color for the «processing» state.cbr_colorOnProcessing— text (or icon) color for the «processing» state.
# Default SDK theme example
<style name="Base.Theme.CBRCore" parent="Base.Theme.MaterialThemeBuilder">
<item name="colorPrimary">@color/cbr_color_primary_50</item>
<item name="colorPrimaryVariant">@color/cbr_color_primary_60</item>
<item name="colorSecondary">@color/cbr_color_primary_50</item>
<item name="colorSecondaryVariant">@color/cbr_color_primary_60</item>
<item name="android:colorBackground">@color/cbr_color_white_100</item>
<item name="colorSurface">@color/cbr_color_neutral_5</item>
<item name="colorError">@color/cbr_color_critical_50</item>
<item name="colorOnPrimary">@color/cbr_color_white_100</item>
<item name="colorOnSecondary">@color/cbr_color_white_100</item>
<item name="colorOnBackground">@color/cbr_color_neutral_80</item>
<item name="colorOnSurface">@color/cbr_color_neutral_80</item>
<item name="colorOnError">@color/cbr_color_critical_50</item>
<item name="android:textColorPrimary">@color/cbr_color_neutral_80</item>
<item name="android:textColorSecondary">@color/cbr_color_neutral_60</item>
<item name="cbr_colorInit">@color/cbr_color_neutral_5</item>
<item name="cbr_colorPending">@color/cbr_color_warning_10</item>
<item name="cbr_colorSuccess">@color/cbr_color_success_10</item>
<item name="cbr_colorRejected">@color/cbr_color_critical_10</item>
<item name="cbr_colorProcessing">@color/cbr_color_primary_5</item>
<item name="cbr_colorOnInit">@color/cbr_color_neutral_40</item>
<item name="cbr_colorOnPending">@color/cbr_color_warning_50</item>
<item name="cbr_colorOnSuccess">@color/cbr_color_success_50</item>
<item name="cbr_colorOnRejected">@color/cbr_color_critical_50</item>
<item name="cbr_colorOnProcessing">@color/cbr_color_primary_50</item>
<item name="colorControlNormal">@color/cbr_color_neutral_40</item>
<item name="textAppearanceHeadline1">@style/TextAppearance.CBRCore.Headline1</item>
<item name="textAppearanceHeadline2">@style/TextAppearance.CBRCore.Headline2</item>
<item name="textAppearanceHeadline3">@style/TextAppearance.CBRCore.Headline3</item>
<item name="textAppearanceHeadline4">@style/TextAppearance.CBRCore.Headline4</item>
<item name="textAppearanceHeadline5">@style/TextAppearance.CBRCore.Headline5</item>
<item name="textAppearanceHeadline6">@style/TextAppearance.CBRCore.Headline6</item>
<item name="textAppearanceSubtitle1">@style/TextAppearance.CBRCore.Subtitle1</item>
<item name="textAppearanceSubtitle2">@style/TextAppearance.CBRCore.Subtitle2</item>
<item name="textAppearanceBody1">@style/TextAppearance.CBRCore.Body1</item>
<item name="textAppearanceBody2">@style/TextAppearance.CBRCore.Body2</item>
<item name="textAppearanceButton">@style/TextAppearance.CBRCore.Button</item>
<item name="textAppearanceCaption">@style/TextAppearance.CBRCore.Caption</item>
<item name="textAppearanceOverline">@style/TextAppearance.CBRCore.Overline</item>
<item name="android:textAppearance">@style/TextAppearance.CBRCore.Body1</item>
</style>
# Translations
The .withLocale(Locale("ru")) method allows switching between translations during initialization.
In the «MSDK» tab of the «SDK Translations» section, you can edit the available translations for SDK text.
# Text strings
Some text strings are stored locally and are not affected by SDK language settings. For example, if the translation server is unavailable due to no internet connection, local strings will still be displayed.
To modify the strings, use the withConf property.
val config = CBRInitConfig(
email = "user@domain.ru",
phone = "+7 987 654321",
strings = mapOf(
"sns_oops_network_title" to "Oops! Seems like the network is down.",
"sns_oops_network_html" to "Please check your internet connection and try again.",
"sns_oops_action_retry" to "Try again",
)
)
cbrSdk.withConf(config)
Map<String, String> strings = new HashMap<>();
strings.put("sns_oops_network_title", "Oops! Seems like the network is down.");
strings.put("sns_oops_network_html", "Please check your internet connection and try again.");
strings.put("sns_oops_action_retry", "Try again");
CBRInitConfig config = new CBRInitConfig("user@email.ru", "+7987654321", strings);
CBRMobileSDK.SDK cbrSdk = new CBRMobileSDK.Builder(requireActivity())
...
.withConf(config)
.build();
Warning:
withLocale does not affect text strings set locally, so you need to add translations yourself depending on the user's language.
# Contact methods
Support items define the ways users can contact your support team. By default, an item for sending an email request is automatically created. The support email address can be configured in the «Integration» section.
private val DEFAULT_SUPPORT_ITEM = CBRSupportItem(
"Support email title",
"Support email description",
CBRSupportItem.Type.Email, // item type
"support@company.ru",
null, // or provide your own drawable
CBRIconHandler.CBRCommonIcons.MAIL.imageName
)
CBRSupportItem defaultItem = new CBRSupportItem(
"Support email title",
"Support email description",
CBRSupportItem.Type.Email,
"support@company.ru",
null,
CBRIconHandler.CBRCommonIcons.MAIL.getImageName(),
null
);
A support item can be one of three types:
enum class Type {
Url,
Email,
Custom
}
If you want to use Type.Custom, make sure an onClick handler is set up.
# Other contact methods
If you want to modify support items, create a new list.
val cbrSdk = CBRMobileSDK.Builder(this, apiUrl).withSupportItems(listOf(DEFAULT_SUPPORT_ITEM))
CBRMobileSDK.Builder cbrSdk = new CBRMobileSDK.Builder(this)
.withSupportItems(Collections.singletonList(defaultItem));
Each item must have a title (title), subtitle (subtitle), and icon (icon). The onClick handler is optional.
# Click handler
The SDK handles clicks by default if the support item is Type.Email or Type.Url. If you want to customize the click behavior, you can implement your own onClick handler.
val supportItems = listOf(CBRSupportItem(
"Support email title",
"Support email description",
CBRSupportItem.Type.Email,
"support@company.com",
null,
CBRIconHandler.CBRCommonIcons.MAIL.imageName,
onClick = { item ->
// actions on click
})
)
val cbrSdk = CBRMobileSDK.Builder(this, apiUrl)
.withSupportItems(supportItems)
CBRSupportItem defaultItem = new CBRSupportItem(
"Support email title",
"Support email description",
CBRSupportItem.Type.Email,
"support@company.com",
null,
CBRIconHandler.CBRCommonIcons.MAIL.getImageName(),
cbrSupportItem -> {
return null;
}
);
CBRMobileSDK.Builder cbrSdk = new CBRMobileSDK.Builder(this)
.withSupportItems(defaultItem);
# Terms of Use and Privacy policy
You can specify your Terms of Use and Privacy Policy using HTML or a URL with the following keys:
To provide HTML:
sns_tos_GTC_html(Terms of Use)sns_tos_PP_html(Privacy Policy)
To load from a URL:
sns_tos_GTC_url(Terms of Use)sns_tos_PP_url(Privacy Policy)