Android

Get the framework

To add the Driver Achievement UI module to your app, add the following lines to your dependencies in your application build.gradle file:
1
dependencies {
2
implementation 'com.drivequant.drivekit:drivekit-driver-achievement-ui:1.16.0'
3
}
Copied!
On a Github repository, you also have a demo app and source code of Driver Achievement UI that you can use as an example.

Initialize

An initialization phase is required to use the feature included in the Driver Achievement UI SDK.
‌Then, to initialize the Driver Achievement UI SDK in your app, you must call the initialization method in onCreate method of your Application class:
Kotlin
Java
1
class MyApplication: Application() {
2
3
override fun onCreate() {
4
super.onCreate()
5
DriveKitUI.initialize()
6
DriverAchievementUI.initialize()
7
...
8
}
9
}
Copied!
1
public class DriveQuantApplication {
2
@Override
3
public void onCreate() {
4
super.onCreate();
5
DriveKit.INSTANCE.initialize();
6
DriveKitUI.INSTANCE.initialize();
7
DriverAchievementUI.INSTANCE.initialize();
8
...
9
}}
Copied!

Override colors and texts

To override colors and texts in the Driver Achievement UI SDK, see Common UI configuration.

Select Streak themes

You can choose which streak theme you want to display in which order, by calling the following method:
Kotlin
Java
1
DriverAchievementUI.configureStreakThemes(streakThemes : List<StreakTheme>)
Copied!
1
DriverAchievementUI.INSTANCE.configureStreakThemes(List<StreakTheme> streakThemes)
Copied!
Accepted values:
    PHONE_DISTRACTION
    SAFETY
    ACCELERATION
    BRAKE
    ADHERENCE
    SPEEDING
Default value:
listOf(PHONE_DISTRACTION, SAFETY, ACCELERATION, BRAKE, ADHERENCE)
For SPEEDING streaks, make sure that the service is activated on your DriveQuant account.

Select Badges categories

You can choose which badge category you want to display in which order, by calling the following method:
Kotlin
Java
1
val categories = listOf(
2
BadgeCategory.GENERIC,
3
BadgeCategory.ECO_DRIVING,
4
BadgeCategory.SAFETY,
5
BadgeCategory.PHONE_DISTRACTION)
6
7
DriverAchievementUI.configureBadgeCategories(categories)
Copied!
1
DriverAchievementUI.INSTANCE.configureBadgeCategories(List<BadgeCategory> badgeCategories)
Copied!
Accepted values:
    GENERIC
    SAFETY
    ECO_DRIVING
    PHONE_DISTRACTION
Default value:
listOf(GENERIC, PHONE_DISTRACTION, SAFETY, ECO_DRIVING)

Get Badge UI

To show the badge UI you can choose between calling :
    A fragment : BadgesListFragment()
    An Activity : BadgesListActivity

Select ranking themes

By calling the following method, you can choose which rank type you want to display:
Kotlin
Java
1
val rankingTypes = listOf(
2
RankingType.SAFETY,
3
RankingType.ECO_DRIVING,
4
RankingType.DISTRACTION)
5
6
DriverAchievementUI.configureRankingTypes(rankingTypes)
Copied!
1
List<RankingType> rankingTypes = Arrays.asList(
2
RankingType.SAFETY,
3
RankingType.ECO_DRIVING,
4
RankingType.DISTRACTION);
5
6
DriverAchievementUI.INSTANCE.configureRankingTypes(rankingTypes);
Copied!
Accepted values:
    RankingType.SAFETY
    RankingType.ECO_DRIVING
    RankingType.DISTRACTION
    RankingType.SPEEDING
Default values [RankingType.SAFETY, RankingType.ECO_DRIVING, RankingType.DISTRACTION]

Set ranking selectors

You can have many periods displayed on the ranking screen. This way, the user can see his ranking on many periods. The following method allows you to selected the order of the displayed periods:
Kotlin
Java
1
val rankingPeriods = listOf(
2
RankingPeriod.WEEKLY,
3
RankingPeriod.MONTHLY,
4
RankingPeriod.ALL_TIME)
5
6
val rankingSelectorType = RankingSelectorType.PERIOD(rankingPeriods)
7
DriverAchievementUI.configureRankingSelector(rankingSelectorType)
Copied!
1
List<RankingPeriod> rankingPeriods = Arrays.asList(
2
RankingPeriod.WEEKLY,
3
RankingPeriod.MONTHLY,
4
RankingPeriod.ALL_TIME);
5
6
RankingSelectorType rankingSelectorType = new RankingSelectorType.PERIOD(rankingPeriods);
7
DriverAchievementUI.INSTANCE.configureRankingSelector(rankingSelectorType);
Copied!
Accepted values :
    RankingPeriod.WEEKLY,
    RankingPeriod.MONTHLY,
    RankingPeriod.ALL_TIME
Default value: [RankingPeriod.WEEKLY, RankingPeriod.MONTHLY, RankingPeriod.ALL_TIME]
If you don’t need any kind of selectors you can use the following method:
Kotlin
Java
1
val rankingSelectorType = RankingSelectorType.NONE
2
DriverAchievementUI.configureRankingSelector(rankingSelectorType)
Copied!
1
RankingSelectorType rankingSelectorType = RankingSelectorType.NONE.INSTANCE;
2
DriverAchievementUI.INSTANCE.configureRankingSelector(rankingSelectorType);
Copied!
In this case, the period of the ranking is weekly

Configure ranking depth

This method allows you to choose the ranking depth you want to display:
Kotlin
Java
1
val rankingDepthValue = 20
2
DriverAchievementUI.configureRankingDepth(rankingDepthValue)
Copied!
1
int rankingDepthValue = 20;
2
DriverAchievementUI.INSTANCE.configureRankingDepth(rankingDepthValue);
Copied!
Accepted values: from 5 to 20
Default value: 5
Last modified 1mo ago