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 add the colors you want to change in the file res/values/colors.xml in your app:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="primaryColor">#0B4D6E</color>
    <color name="secondaryColor">#77E2B0</color>
    <color name="mainFontColor">#161616</color>
    <color name="complementaryFontColor">#9E9E9E</color>
    <color name="fontColorOnPrimaryColor">@android:color/white</color>
    <color name="fontColorOnSecondaryColor">@android:color/white</color>
    <color name="backgroundViewColor">#FAFAFA</color>
    <color name="neutralColor">#F0F0F0</color>
    <color name="warningColor">#F7A334</color>
    <color name="criticalColor">#E52027</color>
</resources>

The flavor "colorsTest" of the demo application is an example of colors customization.

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 font is used on the page titles or to emphasize a specific point. The default value is Roboto.

To override the primary font, define your font family in the file res/font/dkprimary.xml in your app:

<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:app="http://schemas.android.com/apk/res-auto">
    <font
        app:font="@font/sketchy"
        app:fontStyle="normal"
        app:fontWeight="400" /> <!-- Weight 400 = Normal (Regular) -->
    <font
        app:font="@font/deadknight"
        app:fontStyle="normal"
        app:fontWeight="700" /> <!-- Weight 700 = Bold -->
</font-family>

To override the secondary font, define your font family in the file res/font/dksecondary.xml in your app:

<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:app="http://schemas.android.com/apk/res-auto">
    <font app:font="@font/stocky" />
</font-family>

The flavor "fontsTest" of the demo application customizes the fonts to test and see where the different fonts are used.

Text Localization

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

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