Get started

Integration

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

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

dependencies {
    implementation 'com.drivequant.drivekit:drivekit-common-ui:$drivekitui_version'
}

Replace $drivekitui_version with the DriveKit version you are using in your app

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

Initialization

If you have disabled the SDK auto-initialization, an initialization phase is required to ensure that Common UI module works perfectly. To initialize Common UI module in your app, you must call the initialization method in onCreate method of your application class.

class MyApplication: Application() {
    override fun onCreate() {
        super.onCreate()
        (…)
        DriveKitUI.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:

To override the default colors configuration you just have to create a reference of DKColors and override the color that you want to change.

class ColorsConfig : DKColors() {
   override fun primaryColor(): Int = Color.GREEN
   override fun secondaryColor(): Int = Color.RED
}
class MyApplication : Application() {
        override fun onCreate() {
            super.onCreate()
            (…)
            DriveKitUI.initialize()
            DriveKitUI.configureColors(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 module by calling the following method:

class FontConfig : DKFonts() {
   override fun primaryFont(): Int = R.font.sketchy
}
class MyApplication : Application() {
    override fun onCreate() {
            super.onCreate()        
            DriveKitUI.initialize()
            DriveKitUI.configureFonts(FontConfig())
    }
}

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.

Get analytics

You can retrieve some data and build analytics for any DriveKit UI component. To enable the feature, call the following method:

DriveKitUI.configureAnalytics(object: DriveKitAnalyticsListener{
   override fun trackScreen(screen: String, className: String) {
       // TODO: manage screen tracking here
   }

   override fun trackEvent(event: DKAnalyticsEvent, parameters: Map<DKAnalyticsEventKey, String>) {
       // TODO: manage event tracking here
    }
})

trackScreen() method is called when a screen is displayed (i.e. trips list, trip detail, etc.).

When the method is called, you just have to call your analytics solution like Google Analytics for Firebase. The screen String received in the trackScreen method is the value associated with one of the keys in this array, corresponding to the visited screen.

In order to customize screens values, you have to override keys you can find in dk_analytics.xml in each DriveKit UI component.

trackEvent() allows adding additional information that may be useful for analysis. For example, that method is triggered each time the user is opening the trip detail screen.

Last updated