Skip to content

Commit 6bcd6af

Browse files
feat: Update Android Gradle plugin to 8.0.2 (#189)
1 parent 66ac3c7 commit 6bcd6af

9 files changed

Lines changed: 513 additions & 417 deletions

File tree

build.gradle

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
buildscript {
2-
ext.kotlin_version = '1.8.10'
2+
ext.kotlin_version = '2.0.20'
33
if (!project.hasProperty('version') || project.version.equals('unspecified')) {
44
project.version = '+'
55
}
@@ -9,16 +9,17 @@ buildscript {
99
mavenLocal()
1010
mavenCentral()
1111
}
12+
1213
dependencies {
13-
classpath 'com.android.tools.build:gradle:7.4.1'
14+
classpath 'com.android.tools.build:gradle:8.1.4'
1415
classpath 'com.mparticle:android-kit-plugin:' + project.version
1516
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1617
}
1718
}
1819

1920
plugins {
2021
id "org.sonarqube" version "3.5.0.2730"
21-
id "org.jlleitschuh.gradle.ktlint" version "11.2.0"
22+
id "org.jlleitschuh.gradle.ktlint" version "13.0.0"
2223
}
2324

2425
sonarqube {
@@ -30,14 +31,30 @@ sonarqube {
3031
}
3132

3233
apply plugin: 'org.jlleitschuh.gradle.ktlint'
33-
apply plugin: 'com.mparticle.kit'
3434
apply plugin: 'kotlin-android'
35+
apply plugin: 'com.mparticle.kit'
3536

3637
android {
38+
namespace 'com.mparticle.kits.urbanairship'
3739
compileSdk = 33
40+
buildFeatures {
41+
buildConfig = true
42+
}
3843
defaultConfig {
3944
minSdkVersion 23
4045
}
46+
compileOptions {
47+
sourceCompatibility JavaVersion.VERSION_17
48+
targetCompatibility JavaVersion.VERSION_17
49+
}
50+
kotlinOptions {
51+
jvmTarget = '17'
52+
}
53+
testOptions {
54+
unitTests.all {
55+
jvmArgs += ['--add-opens', 'java.base/java.lang=ALL-UNNAMED']
56+
}
57+
}
4158
}
4259

4360
dependencies {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

src/main/AndroidManifest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<manifest package="com.mparticle.kits.urbanairship"
2-
xmlns:android="http://schemas.android.com/apk/res/android">
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
32

43
<application>
54

src/main/kotlin/com/mparticle/kits/MParticleAutopilot.kt

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package com.mparticle.kits
22

3-
import android.R
43
import android.content.Context
54
import android.graphics.Color
6-
import android.util.TypedValue
75
import com.mparticle.MParticle
86
import com.mparticle.internal.Logger
97
import com.mparticle.kits.UrbanAirshipKit.ChannelIdListener
@@ -18,17 +16,21 @@ import com.urbanairship.util.UAStringUtil
1816
class MParticleAutopilot : Autopilot() {
1917
override fun createAirshipConfigOptions(context: Context): AirshipConfigOptions {
2018
val preferences = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE)
21-
val optionsBuilder = AirshipConfigOptions.Builder()
22-
.setNotificationIcon(preferences.getInt(NOTIFICATION_ICON_NAME, 0))
23-
.setNotificationAccentColor(preferences.getInt(NOTIFICATION_COLOR, 0))
24-
.setCustomPushProvider(MParticlePushProvider.instance)
25-
.setIsPromptForPermissionOnUserNotificationsEnabled(false)
19+
val optionsBuilder =
20+
AirshipConfigOptions
21+
.Builder()
22+
.setNotificationIcon(preferences.getInt(NOTIFICATION_ICON_NAME, 0))
23+
.setNotificationAccentColor(preferences.getInt(NOTIFICATION_COLOR, 0))
24+
.setCustomPushProvider(MParticlePushProvider.instance)
25+
.setIsPromptForPermissionOnUserNotificationsEnabled(false)
2626
if (MParticle.getInstance()?.environment == MParticle.Environment.Development) {
27-
optionsBuilder.setDevelopmentAppKey(preferences.getString(APP_KEY, null))
27+
optionsBuilder
28+
.setDevelopmentAppKey(preferences.getString(APP_KEY, null))
2829
.setDevelopmentAppSecret(preferences.getString(APP_SECRET, null))
2930
.setInProduction(false)
3031
} else {
31-
optionsBuilder.setProductionAppKey(preferences.getString(APP_KEY, null))
32+
optionsBuilder
33+
.setProductionAppKey(preferences.getString(APP_KEY, null))
3234
.setProductionAppSecret(preferences.getString(APP_SECRET, null))
3335
.setInProduction(true)
3436
}
@@ -43,8 +45,10 @@ class MParticleAutopilot : Autopilot() {
4345
}
4446

4547
override fun onAirshipReady(airship: UAirship) {
46-
val preferences = UAirship.getApplicationContext()
47-
.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE)
48+
val preferences =
49+
UAirship
50+
.getApplicationContext()
51+
.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE)
4852
if (preferences.getBoolean(FIRST_RUN_KEY, true)) {
4953
preferences.edit().putBoolean(FIRST_RUN_KEY, false).apply()
5054
airship.pushManager.userNotificationsEnabled = true
@@ -68,11 +72,10 @@ class MParticleAutopilot : Autopilot() {
6872

6973
override fun allowEarlyTakeOff(context: Context): Boolean = false
7074

71-
7275
companion object {
7376
private const val PREFERENCE_NAME = "com.mparticle.kits.urbanairship"
7477

75-
//persistence keys
78+
// persistence keys
7679
private const val APP_KEY = "applicationKey"
7780
private const val APP_SECRET = "applicationSecret"
7881
private const val DOMAIN = "domain"
@@ -89,12 +92,18 @@ class MParticleAutopilot : Autopilot() {
8992
* @param context The application context.
9093
* @param configuration UrbanAirshipKit configuration.
9194
*/
92-
fun updateConfig(context: Context, configuration: UrbanAirshipConfiguration) {
93-
val editor = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE).edit()
94-
.putString(APP_KEY, configuration.applicationKey)
95-
.putString(APP_SECRET, configuration.applicationSecret)
96-
.putString(DOMAIN, configuration.domain)
97-
.putString(CUSTOM_DOMAIN_PROXY_URL, configuration.customDomainProxyUrl)
95+
fun updateConfig(
96+
context: Context,
97+
configuration: UrbanAirshipConfiguration,
98+
) {
99+
val editor =
100+
context
101+
.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE)
102+
.edit()
103+
.putString(APP_KEY, configuration.applicationKey)
104+
.putString(APP_SECRET, configuration.applicationSecret)
105+
.putString(DOMAIN, configuration.domain)
106+
.putString(CUSTOM_DOMAIN_PROXY_URL, configuration.customDomainProxyUrl)
98107

99108
// Convert accent color hex string to an int
100109
val accentColor = configuration.notificationColor
@@ -109,9 +118,12 @@ class MParticleAutopilot : Autopilot() {
109118
// Convert notification name to a drawable resource ID
110119
val notificationIconName = configuration.notificationIconName
111120
if (!UAStringUtil.isEmpty(notificationIconName)) {
112-
val id = context.resources.getIdentifier(
113-
notificationIconName, "drawable", context.packageName
114-
)
121+
val id =
122+
context.resources.getIdentifier(
123+
notificationIconName,
124+
"drawable",
125+
context.packageName,
126+
)
115127
if (id != 0) {
116128
editor.putInt(NOTIFICATION_ICON_NAME, id)
117129
} else {

src/main/kotlin/com/mparticle/kits/UrbanAirshipConfiguration.kt

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package com.mparticle.kits
22

33
import com.mparticle.MParticle.IdentityType
4-
import java.util.ArrayList
54
import org.json.JSONArray
65
import org.json.JSONException
76
import java.lang.Exception
7+
import java.util.ArrayList
88

9-
class UrbanAirshipConfiguration(settings: Map<String, String>) {
9+
class UrbanAirshipConfiguration(
10+
settings: Map<String, String>,
11+
) {
1012
val applicationKey: String?
1113
val applicationSecret: String?
1214
val domain: String?
@@ -27,7 +29,6 @@ class UrbanAirshipConfiguration(settings: Map<String, String>) {
2729
var notificationIconName: String? = null
2830
var notificationColor: String? = null
2931

30-
3132
private fun parseTagsJson(tagsJson: JSONArray) {
3233
for (i in 0 until tagsJson.length()) {
3334
try {
@@ -37,22 +38,22 @@ class UrbanAirshipConfiguration(settings: Map<String, String>) {
3738
val hash = tagMap.getInt("map")
3839
val eventMap: MutableMap<Int, ArrayList<String>>? =
3940
when (mapType) {
40-
"EventClass.Id" -> {
41-
eventClass
42-
}
43-
"EventClassDetails.Id" -> {
44-
eventClassDetails
45-
}
46-
"EventAttributeClass.Id" -> {
47-
eventAttributeClass
48-
}
49-
"EventAttributeClassDetails.Id" -> {
50-
eventAttributeClassDetails
41+
"EventClass.Id" -> {
42+
eventClass
43+
}
44+
"EventClassDetails.Id" -> {
45+
eventClassDetails
46+
}
47+
"EventAttributeClass.Id" -> {
48+
eventAttributeClass
49+
}
50+
"EventAttributeClassDetails.Id" -> {
51+
eventAttributeClassDetails
52+
}
53+
else -> {
54+
null
55+
}
5156
}
52-
else -> {
53-
null
54-
}
55-
}
5657
if (eventMap != null) {
5758
if (!eventMap.containsKey(hash)) {
5859
eventMap[hash] = ArrayList()
@@ -80,17 +81,19 @@ class UrbanAirshipConfiguration(settings: Map<String, String>) {
8081
private const val NAMED_USER_TYPE_CUSTOMER_ID = "customerId"
8182
private const val NAMED_USER_TYPE_EMAIL = "email"
8283
private const val NAMED_USER_TYPE_OTHER = "other"
83-
private fun parseNamedUserIdentityType(config: String?): IdentityType? {
84-
return if (config == null) {
84+
85+
private fun parseNamedUserIdentityType(config: String?): IdentityType? =
86+
if (config == null) {
8587
null
86-
} else when (config) {
87-
NAMED_USER_TYPE_OTHER -> IdentityType.Other
88-
NAMED_USER_TYPE_EMAIL -> IdentityType.Email
89-
NAMED_USER_TYPE_CUSTOMER_ID -> IdentityType.CustomerId
90-
NAMED_USER_TYPE_NONE -> null
91-
else -> null
88+
} else {
89+
when (config) {
90+
NAMED_USER_TYPE_OTHER -> IdentityType.Other
91+
NAMED_USER_TYPE_EMAIL -> IdentityType.Email
92+
NAMED_USER_TYPE_CUSTOMER_ID -> IdentityType.CustomerId
93+
NAMED_USER_TYPE_NONE -> null
94+
else -> null
95+
}
9296
}
93-
}
9497
}
9598

9699
init {

0 commit comments

Comments
 (0)