/TelematicsApp-Android-Dashboard

Dashboard module of TelematicsApp-Android

Primary LanguageKotlin

TelematicsApp-Android-Dashboard

Dashboard module of TelematicsApp-Android

Description

This module is created by DATA MOTION PTE. LTD. and allows you to integrate with our UserStatistic API and Dashboard view in a few steps.

Credentials

Before you start using this module, make sure you registered a company account in DataHub. If you are new, please refer to the documentation and register your company account in DataHub. Sing Up

Setup

  1. Download from this repository dashboard_module folder
  2. Move this folder to the project folder next to the app folder
  3. In your settings.gradle (Project settings) add include ':dashboard_module'
  4. Import module:
    dependencies {
        ...
        implementation project(':dashboard_module')
    }

Methods

Initialize

Getting the object and setting the context for the module.

    val dashboardModule = DashboardModule.getInstance()
    dashboardModule.initialize(context)  

Set Here Map Api key

You will need an api key to display a preview of the last trip on the map.

    dashboardModule.setHereMapApiKey(hereApiKey)

Instructions on how to get api key:

Step 1: After creating your HERE account, open your project in https://developer.here.com/projects
In the REST table click "Generate App".

Step 2: Click "Create API key"

Copy API KEY and paste it to setHereMapApiKey method.

Set credentials

    val credentials = Credentials(deviceToken, accessToken)
    dashboardModule.setCredentials(credentials)

deviceToken - is the main individual SDK user identifier. This identifier is used as a key across all our services.

accessToken - or JSON Web Token (JWT) is the main UserService API key, that allows you to get user individual statistics and user scoring by UserStatistics API calls.

Set Dashboard mileage limit

A value that determines when the dashboard will be unlocked to display statistics and scorings.

    dashboardModule.setDashboardMileageLimitKm(10)

Get Dashboard fragment

Getting a fragment to display in your container.

    val fragment = dashboardModule.getDashboardFragment()

Here's an example of using the DashboardModule.

    private fun showDashboard(deviceToken: String, accessToken: String, hereMapKey: String) {
    
        //initialize
        val dashboardModule = DashboardModule.getInstance()
        dashboardModule.initialize(this)
        
        //set here map api key
        dashboardModule.setHereMapApiKey(hereMapKey)
        
        //set credentials
        val credentials = Credentials(deviceToken, accessToken)
        dashboardModule.setCredentials(credentials)
        
        //set distance limit
        dashboardModule.setDashboardMileageLimitKm(10)
        
        //get dashboard fragment
        val dashboardFragment = dashboardModule.getDashboardFragment()
        
        // show fragment
        val container = R.id.container
        val manager: FragmentManager = supportFragmentManager
        val transaction: FragmentTransaction = manager.beginTransaction()
        transaction.replace(container, dashboardFragment)
        transaction.commit()
    }

You can also check full exaple in this repository: DashboardDemoApp

Happy coding!

Links

Official product Web-page

Official API services web-page

Official API references

Official ZenRoad web-page

Official ZenRoad app for iOS

Official ZenRoad app for Android

Official ZenRoad app for Huawei

Copyright © 2020-2022 DATA MOTION PTE. LTD. All rights reserved.