Skip to content

Commit 76daa6a

Browse files
RD-967: Add MTConfig object
1 parent fdb0801 commit 76daa6a

File tree

9 files changed

+139
-6
lines changed

9 files changed

+139
-6
lines changed

MapTilerSDK/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ plugins {
22
id("com.android.library")
33
id("org.jetbrains.kotlin.android")
44
id("org.jlleitschuh.gradle.ktlint")
5+
id("org.jetbrains.dokka")
56
}
67

78
tasks.named("ktlintFormat") {

MapTilerSDK/src/main/java/com/maptiler/maptilersdk/MTConfig.kt

Lines changed: 105 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Copyright (c) 2025, MapTiler
33
* All rights reserved.
44
* SPDX-License-Identifier: BSD 3-Clause
@@ -14,8 +14,112 @@ import com.maptiler.maptilersdk.logging.MTLogLevel
1414
* Exposes properties and options such as API Key and caching preferences.
1515
*/
1616
object MTConfig {
17+
private var apiKey: String = ""
18+
private var unit: MTUnit = MTUnit.METRIC
19+
1720
/**
1821
* SDK log level.
1922
*/
2023
var logLevel: MTLogLevel = MTLogLevel.None
24+
private set
25+
26+
/**
27+
* Boolean indicating whether caching is enabled.
28+
*
29+
* Defaults to true.
30+
*/
31+
var isCachingEnabled: Boolean = true
32+
private set
33+
34+
/**
35+
* Boolean indicating whether session logic is enabled.
36+
*
37+
* This allows MapTiler to enable "session based billing".
38+
* Defaults to true.
39+
* For more information about sessions, see [Map Sessions](https://docs.maptiler.com/guides/maps-apis/maps-platform/what-is-map-session-in-maptiler-cloud/).
40+
*/
41+
var isSessionLogicEnabled: Boolean = true
42+
private set
43+
44+
/**
45+
* Boolean indicating whether telemetry is enabled.
46+
*
47+
* The telemetry is very valuable to the team at MapTiler because it shares information about
48+
* where to add the extra effort. It also helps spotting some incompatibility issues that may
49+
* arise between the SDK and a specific version of a module. It consist in sending the SDK version,
50+
* API Key, MapTiler session ID, if tile caching is enabled, if language specified at initialization,
51+
* if terrain is activated at initialization, if globe projection is activated at initialization.
52+
* Defaults to true.
53+
* @see 'https://docs.maptiler.com/guides/maps-apis/maps-platform/what-is-map-session-in-maptiler-cloud/'
54+
*/
55+
var isTelemetryEnabled: Boolean = true
56+
private set
57+
58+
/**
59+
* Sets the MapTiler API key.
60+
*
61+
* @param apiKey The MapTiler API Key.
62+
*/
63+
fun setAPIKey(apiKey: String) {
64+
this.apiKey = apiKey
65+
}
66+
67+
/**
68+
* Returns the MapTiler API key.
69+
*/
70+
fun getAPIKey(): String {
71+
return this.apiKey
72+
}
73+
74+
/**
75+
* Sets the caching mechanism.
76+
*
77+
* Enabled by default.
78+
*
79+
* @param isEnabled Boolean indicating whether caching is enabled.
80+
*/
81+
fun setCaching(isEnabled: Boolean) {
82+
this.isCachingEnabled = isEnabled
83+
}
84+
85+
/**
86+
* Sets the session logic.
87+
*
88+
* Make sure to call before map init or use MTMapOptions to supply before map init.
89+
* Enabled by default.
90+
*
91+
* @param isEnabled Boolean indicating whether session logic is enabled.
92+
*/
93+
fun setSessionLogic(isEnabled: Boolean) {
94+
this.isSessionLogicEnabled = isEnabled
95+
}
96+
97+
/**
98+
* Sets the unit of measurement.
99+
*
100+
* Defaults to METRIC.
101+
*
102+
* @param unit The MTUnit type.
103+
*/
104+
fun setUnit(unit: MTUnit) {
105+
this.unit = unit
106+
}
107+
108+
/**
109+
* Returns the unit of measurement.
110+
*/
111+
fun getUnit(): MTUnit {
112+
return this.unit
113+
}
114+
115+
/**
116+
* Sets the telemetry.
117+
*
118+
* Enabled by default.
119+
*
120+
* @param isEnabled Boolean indicating whether telemetry is enabled.
121+
*/
122+
fun setTelemetry(isEnabled: Boolean) {
123+
this.isTelemetryEnabled = isEnabled
124+
}
21125
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (c) 2025, MapTiler
3+
* All rights reserved.
4+
* SPDX-License-Identifier: BSD 3-Clause
5+
*/
6+
7+
package com.maptiler.maptilersdk
8+
9+
/**
10+
* Units of measurement used in MTMapView object.
11+
*/
12+
enum class MTUnit {
13+
/**
14+
* Imperical units.
15+
*/
16+
IMPERIAL,
17+
18+
/**
19+
* Metric units.
20+
*/
21+
METRIC,
22+
23+
/**
24+
* Nautical units.
25+
*/
26+
NAUTICAL,
27+
}

MapTilerSDK/src/main/java/com/maptiler/maptilersdk/logging/MTLog.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Copyright (c) 2025, MapTiler
33
* All rights reserved.
44
* SPDX-License-Identifier: BSD 3-Clause

MapTilerSDK/src/main/java/com/maptiler/maptilersdk/logging/MTLogLevel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Copyright (c) 2025, MapTiler
33
* All rights reserved.
44
* SPDX-License-Identifier: BSD 3-Clause

MapTilerSDK/src/main/java/com/maptiler/maptilersdk/logging/MTLogType.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Copyright (c) 2025, MapTiler
33
* All rights reserved.
44
* SPDX-License-Identifier: BSD 3-Clause

MapTilerSDK/src/main/java/com/maptiler/maptilersdk/logging/MTLogger.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Copyright (c) 2025, MapTiler
33
* All rights reserved.
44
* SPDX-License-Identifier: BSD 3-Clause

MapTilerSDK/src/main/java/com/maptiler/maptilersdk/logging/OSLogger.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Copyright (c) 2025, MapTiler
33
* All rights reserved.
44
* SPDX-License-Identifier: BSD 3-Clause

settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pluginManagement {
1616
id("com.android.application") version "8.6.1"
1717
id("org.jetbrains.kotlin.android") version "2.0.0"
1818
id("org.jlleitschuh.gradle.ktlint") version "12.3.0"
19+
id("org.jetbrains.dokka") version "2.0.0"
1920
}
2021
}
2122
dependencyResolutionManagement {

0 commit comments

Comments
 (0)