diff --git a/build.gradle b/build.gradle
index dfcaaab..44f3347 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,5 +1,5 @@
buildscript {
- ext.kotlin_version = '1.8.10'
+ ext.kotlin_version = '2.0.20'
if (!project.hasProperty('version') || project.version.equals('unspecified')) {
project.version = '+'
}
@@ -9,8 +9,9 @@ buildscript {
mavenLocal()
mavenCentral()
}
+
dependencies {
- classpath 'com.android.tools.build:gradle:7.4.1'
+ classpath 'com.android.tools.build:gradle:8.1.4'
classpath 'com.mparticle:android-kit-plugin:' + project.version
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
@@ -18,7 +19,7 @@ buildscript {
plugins {
id "org.sonarqube" version "3.5.0.2730"
- id "org.jlleitschuh.gradle.ktlint" version "11.2.0"
+ id "org.jlleitschuh.gradle.ktlint" version "13.0.0"
}
sonarqube {
@@ -30,5 +31,27 @@ sonarqube {
}
apply plugin: 'org.jlleitschuh.gradle.ktlint'
-apply plugin: 'com.mparticle.kit'
apply plugin: 'kotlin-android'
+apply plugin: 'com.mparticle.kit'
+
+android {
+ namespace 'com.mparticle.kits.tune'
+ buildFeatures {
+ buildConfig = true
+ }
+ defaultConfig {
+ minSdkVersion 21
+ }
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_17
+ targetCompatibility JavaVersion.VERSION_17
+ }
+ kotlinOptions {
+ jvmTarget = '17'
+ }
+ testOptions {
+ unitTests.all {
+ jvmArgs += ['--add-opens', 'java.base/java.lang=ALL-UNNAMED']
+ }
+ }
+}
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index ae04661..e1bef7e 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml
index 41a2fea..c4e6c98 100644
--- a/src/main/AndroidManifest.xml
+++ b/src/main/AndroidManifest.xml
@@ -1 +1 @@
-
+
diff --git a/src/main/kotlin/com/mparticle/kits/TuneKit.kt b/src/main/kotlin/com/mparticle/kits/TuneKit.kt
index c0c92ff..1ee4b12 100644
--- a/src/main/kotlin/com/mparticle/kits/TuneKit.kt
+++ b/src/main/kotlin/com/mparticle/kits/TuneKit.kt
@@ -1,35 +1,39 @@
package com.mparticle.kits
import android.content.Context
+import com.mparticle.AttributionError
+import com.mparticle.AttributionResult
import com.mparticle.kits.KitIntegration
-import com.mparticle.kits.mobileapptracker.MATDeeplinkListener
import com.mparticle.kits.KitIntegration.ApplicationStateListener
-import com.mparticle.kits.mobileapptracker.MATDeferredDplinkr
-import java.util.concurrent.atomic.AtomicBoolean
+import com.mparticle.kits.KitUtils
import com.mparticle.kits.ReportingMessage
-import com.mparticle.kits.mobileapptracker.MATUtils
import com.mparticle.kits.TuneKit
-import com.mparticle.kits.KitUtils
+import com.mparticle.kits.mobileapptracker.MATDeeplinkListener
+import com.mparticle.kits.mobileapptracker.MATDeferredDplinkr
import com.mparticle.kits.mobileapptracker.MATUrlRequester
-import com.mparticle.AttributionResult
-import com.mparticle.AttributionError
+import com.mparticle.kits.mobileapptracker.MATUtils
+import java.util.concurrent.atomic.AtomicBoolean
/**
* Tune Kit implementing Tune's post-install deep-link feature. Different from other Kits, the Tune Kit
* does not actually wrap the full Tune SDK - only a small subset of classes required to query the Tune server
* for deep links that match the given user.
*/
-class TuneKit : KitIntegration(), MATDeeplinkListener, ApplicationStateListener {
+class TuneKit :
+ KitIntegration(),
+ MATDeeplinkListener,
+ ApplicationStateListener {
private var settingAdvertiserId: String? = null
private var settingConversionKey: String? = null
var packageName: String? = null
private var deepLinker: MATDeferredDplinkr? = null
private val listenerWaiting = AtomicBoolean(false)
+
override fun getName(): String = KIT_NAME
override fun onKitCreate(
settings: Map,
- context: Context
+ context: Context,
): List {
if (MATUtils.firstInstall(getContext())) {
settingAdvertiserId = getSettings()[SETTING_ADVERTISER_ID]
@@ -38,11 +42,12 @@ class TuneKit : KitIntegration(), MATDeeplinkListener, ApplicationStateListener
if (KitUtils.isEmpty(packageName)) {
packageName = getContext().packageName
}
- deepLinker = MATDeferredDplinkr.initialize(
- settingAdvertiserId,
- settingConversionKey,
- packageName
- )
+ deepLinker =
+ MATDeferredDplinkr.initialize(
+ settingAdvertiserId,
+ settingConversionKey,
+ packageName,
+ )
deepLinker?.listener = this
checkForAttribution()
}
@@ -73,17 +78,19 @@ class TuneKit : KitIntegration(), MATDeeplinkListener, ApplicationStateListener
override fun didReceiveDeeplink(deeplink: String?) {
listenerWaiting.set(false)
- val result = AttributionResult()
- .setLink(deeplink)
- .setServiceProviderId(configuration.kitId)
+ val result =
+ AttributionResult()
+ .setLink(deeplink)
+ .setServiceProviderId(configuration.kitId)
kitManager.onResult(result)
}
override fun didFailDeeplink(error: String?) {
listenerWaiting.set(false)
- val deepLinkError = AttributionError()
- .setMessage(error)
- .setServiceProviderId(configuration.kitId)
+ val deepLinkError =
+ AttributionError()
+ .setMessage(error)
+ .setServiceProviderId(configuration.kitId)
kitManager.onError(deepLinkError)
}
@@ -99,4 +106,4 @@ class TuneKit : KitIntegration(), MATDeeplinkListener, ApplicationStateListener
private const val SETTING_PACKAGE_NAME_OVERRIDE = "overridePackageName"
private const val KIT_NAME = "Tune"
}
-}
\ No newline at end of file
+}
diff --git a/src/main/kotlin/com/mparticle/kits/mobileapptracker/MATConstants.kt b/src/main/kotlin/com/mparticle/kits/mobileapptracker/MATConstants.kt
index ab013a8..0b0b53f 100644
--- a/src/main/kotlin/com/mparticle/kits/mobileapptracker/MATConstants.kt
+++ b/src/main/kotlin/com/mparticle/kits/mobileapptracker/MATConstants.kt
@@ -10,4 +10,4 @@ object MATConstants {
// MAT Android SDK version number
const val SDK_VERSION = "3.11.4"
-}
\ No newline at end of file
+}
diff --git a/src/main/kotlin/com/mparticle/kits/mobileapptracker/MATDeeplinkListener.kt b/src/main/kotlin/com/mparticle/kits/mobileapptracker/MATDeeplinkListener.kt
index 653eec0..48ef90f 100644
--- a/src/main/kotlin/com/mparticle/kits/mobileapptracker/MATDeeplinkListener.kt
+++ b/src/main/kotlin/com/mparticle/kits/mobileapptracker/MATDeeplinkListener.kt
@@ -2,5 +2,6 @@ package com.mparticle.kits.mobileapptracker
interface MATDeeplinkListener {
fun didReceiveDeeplink(deeplink: String?)
+
fun didFailDeeplink(error: String?)
-}
\ No newline at end of file
+}
diff --git a/src/main/kotlin/com/mparticle/kits/mobileapptracker/MATDeferredDplinkr.kt b/src/main/kotlin/com/mparticle/kits/mobileapptracker/MATDeferredDplinkr.kt
index a4af461..85a29a9 100644
--- a/src/main/kotlin/com/mparticle/kits/mobileapptracker/MATDeferredDplinkr.kt
+++ b/src/main/kotlin/com/mparticle/kits/mobileapptracker/MATDeferredDplinkr.kt
@@ -10,7 +10,7 @@ class MATDeferredDplinkr private constructor() {
var conversionKey: String? = null
var packageName: String? = null
var googleAdvertisingId: String? = null
- private set
+ private set
var googleAdTrackingLimited = 0
@@ -18,18 +18,20 @@ class MATDeferredDplinkr private constructor() {
var userAgent: String? = null
var listener: MATDeeplinkListener? = null
-
-
- fun setGoogleAdvertisingId(googleAdvertisingId: String?, isLATEnabled: Int) {
+ fun setGoogleAdvertisingId(
+ googleAdvertisingId: String?,
+ isLATEnabled: Int,
+ ) {
dplinkr?.googleAdvertisingId = googleAdvertisingId
dplinkr?.googleAdTrackingLimited = isLATEnabled
}
-
-
-
- fun checkForDeferredDeeplink(context: Context?, urlRequester: MATUrlRequester) {
- Thread { // If advertiser ID, conversion key, or package name were not set, return
+ fun checkForDeferredDeeplink(
+ context: Context?,
+ urlRequester: MATUrlRequester,
+ ) {
+ Thread {
+ // If advertiser ID, conversion key, or package name were not set, return
if (dplinkr?.advertiserId == null || dplinkr?.conversionKey == null || dplinkr?.packageName == null) {
if (listener != null) {
listener?.didFailDeeplink("Advertiser ID, conversion key, or package name not set")
@@ -58,11 +60,12 @@ class MATDeferredDplinkr private constructor() {
companion object {
@Volatile
private var dplinkr: MATDeferredDplinkr? = null
+
@Synchronized
fun initialize(
advertiserId: String?,
conversionKey: String?,
- packageName: String?
+ packageName: String?,
): MATDeferredDplinkr? {
dplinkr = MATDeferredDplinkr()
dplinkr?.advertiserId = advertiserId
diff --git a/src/main/kotlin/com/mparticle/kits/mobileapptracker/MATUrlRequester.kt b/src/main/kotlin/com/mparticle/kits/mobileapptracker/MATUrlRequester.kt
index f8b3972..fa510e3 100644
--- a/src/main/kotlin/com/mparticle/kits/mobileapptracker/MATUrlRequester.kt
+++ b/src/main/kotlin/com/mparticle/kits/mobileapptracker/MATUrlRequester.kt
@@ -13,7 +13,8 @@ class MATUrlRequester {
// Construct deeplink endpoint url
val uri = Uri.Builder()
- uri.scheme("https")
+ uri
+ .scheme("https")
.authority(dplinkr.advertiserId + "." + MATConstants.DEEPLINK_DOMAIN)
.appendPath("v1")
.appendPath("link.txt")
@@ -23,13 +24,12 @@ class MATUrlRequester {
.appendQueryParameter("package_name", dplinkr.packageName)
.appendQueryParameter(
"ad_id",
- if (dplinkr.googleAdvertisingId != null) dplinkr.googleAdvertisingId else dplinkr.androidId
- )
- .appendQueryParameter("user_agent", dplinkr.userAgent)
+ if (dplinkr.googleAdvertisingId != null) dplinkr.googleAdvertisingId else dplinkr.androidId,
+ ).appendQueryParameter("user_agent", dplinkr.userAgent)
if (dplinkr.googleAdvertisingId != null) {
uri.appendQueryParameter(
"google_ad_tracking_disabled",
- dplinkr.googleAdTrackingLimited.toString()
+ dplinkr.googleAdTrackingLimited.toString(),
)
}
try {
diff --git a/src/main/kotlin/com/mparticle/kits/mobileapptracker/MATUtils.kt b/src/main/kotlin/com/mparticle/kits/mobileapptracker/MATUtils.kt
index da527e6..32d10d9 100644
--- a/src/main/kotlin/com/mparticle/kits/mobileapptracker/MATUtils.kt
+++ b/src/main/kotlin/com/mparticle/kits/mobileapptracker/MATUtils.kt
@@ -9,7 +9,11 @@ import android.webkit.WebSettings
import android.webkit.WebView
import com.mparticle.kits.KitUtils
import com.mparticle.kits.TuneKit
-import java.io.*
+import java.io.BufferedReader
+import java.io.IOException
+import java.io.InputStream
+import java.io.InputStreamReader
+import java.io.UnsupportedEncodingException
import java.lang.ref.WeakReference
object MATUtils {
@@ -38,7 +42,10 @@ object MATUtils {
/**
* Determine the device's user agent and set the corresponding field.
*/
- fun calculateUserAgent(context: Context?, tuneKit: TuneKit) {
+ fun calculateUserAgent(
+ context: Context?,
+ tuneKit: TuneKit,
+ ) {
val userAgent = System.getProperty("http.agent", "")
if (!KitUtils.isEmpty(userAgent)) {
tuneKit.setUserAgent(userAgent)
@@ -66,9 +73,13 @@ object MATUtils {
* Runnable for getting the WebView user agent
*/
@SuppressLint("NewApi")
- private class GetWebViewUserAgent(context: Context?, tuneKit: TuneKit) : Runnable {
+ private class GetWebViewUserAgent(
+ context: Context?,
+ tuneKit: TuneKit,
+ ) : Runnable {
private val weakContext: WeakReference
private val tuneKit: TuneKit
+
override fun run() {
try {
Class.forName("android.os.AsyncTask") // prevents WebView from crashing on certain devices
@@ -93,4 +104,4 @@ object MATUtils {
this.tuneKit = tuneKit
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/kotlin/com/mparticle/kits/TuneKitTest.kt b/src/test/kotlin/com/mparticle/kits/TuneKitTests.kt
similarity index 98%
rename from src/test/kotlin/com/mparticle/kits/TuneKitTest.kt
rename to src/test/kotlin/com/mparticle/kits/TuneKitTests.kt
index 122b0b6..5003e5e 100644
--- a/src/test/kotlin/com/mparticle/kits/TuneKitTest.kt
+++ b/src/test/kotlin/com/mparticle/kits/TuneKitTests.kt
@@ -8,7 +8,7 @@ import org.mockito.Mockito
class TuneKitTests {
private val kit: KitIntegration
- get() = TuneKit()
+ get() = TuneKit()
@Test
@Throws(Exception::class)
@@ -50,4 +50,4 @@ class TuneKitTests {
}
Assert.fail("$className not found as a known integration.")
}
-}
\ No newline at end of file
+}