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:

dependencies {
implementation 'com.drivequant.drivekit:drivekit-driver-achievement-ui:1.10.0'
}

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
Kotlin
class MyApplication: Application() {
override fun onCreate() {
super.onCreate()
DriveKitUI.initialize()
DriverAchievementUI.initialize()
...
}
}
Java
public class DriveQuantApplication {
@Override
public void onCreate() {
super.onCreate();
DriveKit.INSTANCE.initialize();
DriveKitUI.INSTANCE.initialize();
DriverAchievementUI.INSTANCE.initialize();
...
}}

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
Kotlin
DriverAchievementUI.configureStreakThemes(streakThemes : List<StreakTheme>)
Java
DriverAchievementUI.INSTANCE.configureStreakThemes(List<StreakTheme> streakThemes)

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
Kotlin
val categories = listOf(
BadgeCategory.GENERIC,
BadgeCategory.ECO_DRIVING,
BadgeCategory.SAFETY,
BadgeCategory.PHONE_DISTRACTION)
DriverAchievementUI.configureBadgeCategories(categories)
Java
DriverAchievementUI.INSTANCE.configureBadgeCategories(List<BadgeCategory> badgeCategories)

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
Kotlin
val rankingTypes = listOf(
RankingType.SAFETY,
RankingType.ECO_DRIVING,
RankingType.DISTRACTION)
DriverAchievementUI.configureRankingTypes(rankingTypes)
Java
List<RankingType> rankingTypes = Arrays.asList(
RankingType.SAFETY,
RankingType.ECO_DRIVING,
RankingType.DISTRACTION);
DriverAchievementUI.INSTANCE.configureRankingTypes(rankingTypes);

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
Kotlin
val rankingPeriods = listOf(
RankingPeriod.WEEKLY,
RankingPeriod.MONTHLY,
RankingPeriod.ALL_TIME)
val rankingSelectorType = RankingSelectorType.PERIOD(rankingPeriods)
DriverAchievementUI.configureRankingSelector(rankingSelectorType)
Java
List<RankingPeriod> rankingPeriods = Arrays.asList(
RankingPeriod.WEEKLY,
RankingPeriod.MONTHLY,
RankingPeriod.ALL_TIME);
RankingSelectorType rankingSelectorType = new RankingSelectorType.PERIOD(rankingPeriods);
DriverAchievementUI.INSTANCE.configureRankingSelector(rankingSelectorType);

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
Kotlin
val rankingSelectorType = RankingSelectorType.NONE
DriverAchievementUI.configureRankingSelector(rankingSelectorType)
Java
RankingSelectorType rankingSelectorType = RankingSelectorType.NONE.INSTANCE;
DriverAchievementUI.INSTANCE.configureRankingSelector(rankingSelectorType);

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
Kotlin
val rankingDepthValue = 20
DriverAchievementUI.configureRankingDepth(rankingDepthValue)
Java
int rankingDepthValue = 20;
DriverAchievementUI.INSTANCE.configureRankingDepth(rankingDepthValue);

Accepted values: from 5 to 20

Default value: 5