Get started

Integration

The Common UI SDK is a core configuration module for all DriveKit UI SDKs.

To add Common UI module to your app, add the following line to your dependencies in your application build.gradle file:

build.gradle
build.gradle
dependencies {
implementation 'com.drivequant.drivekit:drivekit-common-ui:1.6.1'
}

On a Github repository, you have a demo app and source code that you can use as an example.

Initialization

An initialization phase is required to ensure that Common UI SDK works perfectly. To initialize Common UI SDK in your app, you must call the initialization method in onCreate method of your application class.

Kotlin
Java
Kotlin
class MyApplication: Application() {
override fun onCreate() {
super.onCreate()
DriveKitUI.initialize()
}
}
Java
public class DriveQuantApplication {
@Override
public void onCreate() {
super.onCreate();
DriveKitUI.INSTANCE.initialize();
}}

This method will initialize the SDK with the default configuration set up by DriveQuant.

Configurations

Colors

The colors that can be configured are listed in the table below:

Name

Description

Default value

primaryColor

Main app color

#0B4D6E

secondaryColor

Call to action color

#00EBB8

mainFontColor

Main font color

#161616

complementaryFontColor

Secondary font color

#9E9E9E

fontColorOnPrimaryColor

Color of a text displayed on an element whose color is primaryColor

#FFFFFF

fontColorOnSecondaryColor

Color of a text displayed on an element whose color is secondaryColor

#FFFFFF

backgroundViewColor

Background color

#FAFAFA

neutralColor

Color of the separating lines

#F0F0F0

warningColor

Warning color (non-critical hint)

#F7A334

criticalColor

Alert color (critical hint)

#E52027

To override the default colors configuration you just have to create a reference of DKColors and override the color that you want to change. Then pass it as a parameter to the initialize method.

Kotlin
Java
Kotlin
class ColorsConfig : DKColors() {
override fun primaryColor(): Int = Color.GREEN
override fun secondaryColor(): Int = Color.RED
}
Java
class ColorsConfig extends DKColors {
@Override
public int primaryColor() {
return Color.GREEN;
}
@Override
public int secondaryColor() {
return Color.RED;
}
}
Kotlin
Java
Kotlin
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
val colorsConfig = ColorsConfig()
DriveKitUI.initialize(colors = colorsConfig)
}
}
Java
public class DriveQuantApplication {
@Override
public void onCreate() {
super.onCreate();
ColorsConfig colorConfig = new ColorsConfig();
DriveKitUI.INSTANCE.initialize(colorsConfig);
...
}}

Fonts

The Common UI configuration module allows to set up two fonts:

  1. primaryFont: this is the main font used in the application. The default value is Roboto.

  2. secondaryFont: this the font used on the page titles or to emphasize a specific point. The default value is Roboto.

To override the font, you can add the primary and secondary fonts to the CommonUI SDK by calling the following method:

Kotlin
Java
Kotlin
class FontConfig : DKFonts() {
override fun primaryFont(): Int = R.font.sketchy
}
Java
class FontsConfig extends DKFonts {
@Override
public int primaryFont() {
return R.font.sketchy;
}
}
Kotlin
Java
Kotlin
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
val fontsConfig = FontsConfig()
DriveKitUI.initialize(fonts = fontsConfig)
}
}
Java
public class DriveQuantApplication {
@Override
public void onCreate() {
super.onCreate();
FontsConfig fontsConfig = new FontsConfig();
DriveKitUI.INSTANCE.initialize(fontsConfig);
...
}}

Text Localization

Contents of each DriveKit UI module are translated into 5 languages: English, French, German, Spanish and Italian.

DriveKit simplifies the internationalization of your application and it is possible to add other languages.

DriveKit Common UI contains a number of basic text keys used in other DriveKit UI modules. You can override these keys to customize your application.

To help make the text keys in the code easier to read, a specific nomenclature has been set up: dk_<module name>_<key description>.

For the Common UI module, all localizable keys are prefixed with: dk_common.

There are several files containing text keys:

  • A string.xml file in the common UI module containing generic keys to all modules.

  • One file per UI module containing module-specific text keys.

Text customization

You can override any texts to customize your application. To override a text key, simply define the keys to be modified in a string.xml file at the application level. The text keys can be directly retrieved on Github, in the src/main/res/values folder of each module.

Add language

The translation file can be retrieved from GitHub in the various DriveKit UI modules and integrated into the values-<Locale> folder of the app.