Skip to content

Commit fffa2cb

Browse files
committed
release: SDK 1.19.0
1 parent dddf764 commit fffa2cb

File tree

108 files changed

+13021
-861
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+13021
-861
lines changed

.editorconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
7+
[*.java]
8+
charset = utf-8
9+
indent_style = space
10+
indent_size = 4
11+
continuation_indent_size = 8

Sources/.idea/fileTemplates/Kotlin Android Test.kt

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Sources/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ buildscript {
99
google()
1010
}
1111
dependencies {
12-
classpath 'com.android.tools.build:gradle:7.0.3'
12+
classpath 'com.android.tools.build:gradle:7.1.2'
1313
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.21.1"
1414
// NOTE: Do not place your application dependencies here; they belong
1515
// in the individual module build.gradle files
1616
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
17-
classpath 'com.google.gms:google-services:4.3.3'
17+
classpath 'com.google.gms:google-services:4.3.10'
1818
}
1919
}
2020

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.1.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

Sources/sdk-lint/build.gradle

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
apply plugin: 'java-library'
22

3+
ext {
4+
lintVersion = '30.1.2'
5+
}
6+
37
dependencies {
4-
compileOnly 'com.android.tools.lint:lint-api:30.0.3'
5-
compileOnly 'com.android.tools.lint:lint-checks:30.0.3'
8+
compileOnly "com.android.tools.lint:lint-api:$lintVersion"
9+
compileOnly "com.android.tools.lint:lint-checks:$lintVersion"
610

711
testImplementation "junit:junit:4.12"
8-
testImplementation "com.android.tools.lint:lint:30.0.3"
9-
testImplementation "com.android.tools.lint:lint-tests:30.0.3"
10-
testImplementation "com.android.tools:testutils:30.0.3"
12+
testImplementation "com.android.tools.lint:lint:$lintVersion"
13+
testImplementation "com.android.tools.lint:lint-tests:$lintVersion"
14+
testImplementation "com.android.tools:testutils:$lintVersion"
1115
}
1216

1317

Sources/sdk/build.gradle

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ ext {
1717
}
1818

1919
android {
20-
compileSdkVersion 31
20+
compileSdkVersion 32
2121
defaultPublishConfig "release"
2222

2323
resourcePrefix "com_batchsdk_"
2424

2525
defaultConfig {
2626
minSdkVersion 15
27-
targetSdkVersion 31
27+
targetSdkVersion 32
2828
versionCode 1
29-
versionName "1.18.2"
29+
versionName "1.19.0"
3030
buildConfigField "String", SDK_VERSION, "\"$versionName\""
31-
buildConfigField "Integer", API_LEVEL, '40'
32-
buildConfigField "Integer", MESSAGING_API_LEVEL, '11'
31+
buildConfigField "Integer", API_LEVEL, '50'
32+
buildConfigField "Integer", MESSAGING_API_LEVEL, '12'
3333
buildConfigField "String", WS_DOMAIN, '"ws.batch.com"'
3434

3535
consumerProguardFiles 'proguard-consumer-rules.txt'
@@ -62,11 +62,6 @@ android {
6262
}
6363
}
6464

65-
lintOptions {
66-
abortOnError true
67-
baseline file("lint-baseline.xml")
68-
lintConfig file("lint.xml")
69-
}
7065

7166
testOptions {
7267
execution 'ANDROIDX_TEST_ORCHESTRATOR'
@@ -80,6 +75,11 @@ android {
8075
}
8176
}
8277
}
78+
lint {
79+
abortOnError true
80+
baseline file('lint-baseline.xml')
81+
lintConfig file('lint.xml')
82+
}
8383
}
8484

8585
// Prevent from having accidental kotlin in production code

Sources/sdk/maven-publish.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ publishing {
7171
url = "https://batch.com"
7272

7373
scm {
74-
url = "https://github.com/BatchLabs/android-sdk"
75-
connection = "scm:git:https://github.com/BatchLabs/android-sdk.git"
76-
developerConnection = "scm:git:https://github.com/BatchLabs/android-sdk.git"
74+
url = "https://github.com/BatchLabs/Batch-Android-SDK"
75+
connection = "scm:git:https://github.com/BatchLabs/Batch-Android-SDK.git"
76+
developerConnection = "scm:git:https://github.com/BatchLabs/Batch-Android-SDK.git"
7777
}
7878

7979
licenses {

Sources/sdk/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<uses-permission android:name="android.permission.WAKE_LOCK" />
77
<uses-permission android:name="android.permission.VIBRATE" />
88
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
9+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
910

1011
<permission
1112
android:name="${applicationId}.batch.permission.INTERNAL_BROADCAST"

Sources/sdk/src/main/java/com/batch/android/Batch.java

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.annotation.SuppressLint;
44
import android.app.Activity;
5+
import android.app.Application;
56
import android.app.PendingIntent;
67
import android.app.Service;
78
import android.content.BroadcastReceiver;
@@ -2125,15 +2126,6 @@ else if (lastStop == null && state == State.READY) {
21252126
runtimeManager.setActivity(activity);
21262127
}
21272128

2128-
/*
2129-
* Register the messaging lifecycle listener and session manager if we can
2130-
*/
2131-
android.app.Application app = activity.getApplication();
2132-
if (app != null) {
2133-
runtimeManager.registerSessionManagerIfNeeded(app, true);
2134-
runtimeManager.registerActivityListenerIfNeeded(app);
2135-
}
2136-
21372129
/*
21382130
* List the possible intents with push payload by priority :
21392131
* 1 - Intent from onNewIntent()
@@ -2200,19 +2192,24 @@ else if (lastStop == null && state == State.READY) {
22002192
return null;
22012193
}
22022194

2195+
final Context applicationContext = context.getApplicationContext();
2196+
22032197
/*
22042198
* Init stuff, if we were stopped
22052199
*/
22062200
if (state == State.OFF) {
22072201
/*
22082202
* Set context
22092203
*/
2210-
runtimeManager.setContext(context.getApplicationContext());
2204+
runtimeManager.setContext(applicationContext);
22112205

22122206
/*
22132207
* Warm up the local broadcast manager
22142208
*/
2215-
LocalBroadcastManagerProvider.get(context);
2209+
LocalBroadcastManagerProvider.get(applicationContext);
2210+
2211+
// Tell the modules about the context
2212+
moduleMaster.batchContextBecameAvailable(applicationContext);
22162213

22172214
/*
22182215
* Check for update migration stuff
@@ -2222,7 +2219,7 @@ else if (lastStop == null && state == State.READY) {
22222219
/*
22232220
* Check that we have mandatory permissions
22242221
*/
2225-
if (!GenericHelper.checkPermission("android.permission.INTERNET", runtimeManager.getContext())) {
2222+
if (!GenericHelper.checkPermission("android.permission.INTERNET", applicationContext)) {
22262223
Logger.error(
22272224
"Batch needs android.permission.INTERNET, please update your manifest, aborting start"
22282225
);
@@ -2246,10 +2243,10 @@ else if (lastStop == null && state == State.READY) {
22462243
Batch.advertisingID = advertisingID;
22472244
}
22482245
if (Batch.install == null) {
2249-
Batch.install = new Install(runtimeManager.getContext());
2246+
Batch.install = new Install(applicationContext);
22502247
}
22512248
if (Batch.user == null) {
2252-
Batch.user = new com.batch.android.User(runtimeManager.getContext());
2249+
Batch.user = new com.batch.android.User(applicationContext);
22532250
}
22542251

22552252
/*
@@ -2265,15 +2262,26 @@ else if (lastStop == null && state == State.READY) {
22652262
IntentFilter filter = new IntentFilter();
22662263
filter.addAction(TaskExecutor.INTENT_WORK_FINISHED);
22672264
filter.addAction(OptOutModule.INTENT_OPTED_OUT);
2268-
LocalBroadcastManagerProvider
2269-
.get(runtimeManager.getContext())
2270-
.registerReceiver(receiver, filter);
2265+
LocalBroadcastManagerProvider.get(applicationContext).registerReceiver(receiver, filter);
22712266
}
22722267

22732268
// Check if we have a pending opt-in event
22742269
OptOutModuleProvider.get().trackOptinEventIfNeeded(context, advertisingID);
22752270
}
22762271

2272+
/*
2273+
* Register the messaging lifecycle listener and session manager if we can
2274+
*/
2275+
if (applicationContext instanceof Application) {
2276+
final android.app.Application app = (Application) applicationContext;
2277+
runtimeManager.registerSessionManagerIfNeeded(app, true);
2278+
runtimeManager.registerActivityListenerIfNeeded(app);
2279+
} else {
2280+
// This should never happen, androidx relies on this
2281+
// https://android.googlesource.com/platform/frameworks/support/+/refs/heads/androidx-master-dev/lifecycle/lifecycle-process/src/main/java/androidx/lifecycle/ProcessLifecycleOwner.java
2282+
Logger.error("Context isn't an Application, could not register the session manager.");
2283+
}
2284+
22772285
/*
22782286
* Call modules
22792287
*/
@@ -2285,15 +2293,19 @@ else if (lastStop == null && state == State.READY) {
22852293
EventDispatcherModuleProvider.get().loadDispatcherFromContext(context);
22862294

22872295
try {
2288-
JSONObject startParams = null;
2289-
2296+
JSONObject startParams = new JSONObject();
22902297
if (userActivity) {
22912298
runtimeManager.updateLastUserStartDate();
22922299
} else {
2293-
startParams = new JSONObject();
22942300
startParams.put("silent", true);
22952301
}
2296-
2302+
startParams.putOpt(
2303+
"dispatchers",
2304+
EventDispatcherModuleProvider.get().getDispatchersAnalyticRepresentation()
2305+
);
2306+
if (startParams.length() == 0) {
2307+
startParams = null;
2308+
}
22972309
TrackerModuleProvider.get().track(InternalEvents.START, startParams);
22982310
} catch (JSONException e) {
22992311
Logger.internal("Could not track _START", e);

Sources/sdk/src/main/java/com/batch/android/BatchDisplayReceiptJobService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* JobService implementation of Batch Display Receipt
1515
*/
1616

17-
@RequiresApi(api = Build.VERSION_CODES.O)
17+
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
1818
public class BatchDisplayReceiptJobService extends JobService {
1919

2020
private static final String TAG = "BatchDisplayReceiptJobService";

0 commit comments

Comments
 (0)