Skip to content

Commit

Permalink
release: SDK 1.19.0
Browse files Browse the repository at this point in the history
  • Loading branch information
abarisain committed Mar 31, 2022
1 parent dddf764 commit fffa2cb
Show file tree
Hide file tree
Showing 108 changed files with 13,021 additions and 861 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true

[*.java]
charset = utf-8
indent_style = space
indent_size = 4
continuation_indent_size = 8
17 changes: 17 additions & 0 deletions Sources/.idea/fileTemplates/Kotlin Android Test.kt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Sources/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.3'
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.21.1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.google.gms:google-services:4.3.10'
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
14 changes: 9 additions & 5 deletions Sources/sdk-lint/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
apply plugin: 'java-library'

ext {
lintVersion = '30.1.2'
}

dependencies {
compileOnly 'com.android.tools.lint:lint-api:30.0.3'
compileOnly 'com.android.tools.lint:lint-checks:30.0.3'
compileOnly "com.android.tools.lint:lint-api:$lintVersion"
compileOnly "com.android.tools.lint:lint-checks:$lintVersion"

testImplementation "junit:junit:4.12"
testImplementation "com.android.tools.lint:lint:30.0.3"
testImplementation "com.android.tools.lint:lint-tests:30.0.3"
testImplementation "com.android.tools:testutils:30.0.3"
testImplementation "com.android.tools.lint:lint:$lintVersion"
testImplementation "com.android.tools.lint:lint-tests:$lintVersion"
testImplementation "com.android.tools:testutils:$lintVersion"
}


Expand Down
20 changes: 10 additions & 10 deletions Sources/sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ ext {
}

android {
compileSdkVersion 31
compileSdkVersion 32
defaultPublishConfig "release"

resourcePrefix "com_batchsdk_"

defaultConfig {
minSdkVersion 15
targetSdkVersion 31
targetSdkVersion 32
versionCode 1
versionName "1.18.2"
versionName "1.19.0"
buildConfigField "String", SDK_VERSION, "\"$versionName\""
buildConfigField "Integer", API_LEVEL, '40'
buildConfigField "Integer", MESSAGING_API_LEVEL, '11'
buildConfigField "Integer", API_LEVEL, '50'
buildConfigField "Integer", MESSAGING_API_LEVEL, '12'
buildConfigField "String", WS_DOMAIN, '"ws.batch.com"'

consumerProguardFiles 'proguard-consumer-rules.txt'
Expand Down Expand Up @@ -62,11 +62,6 @@ android {
}
}

lintOptions {
abortOnError true
baseline file("lint-baseline.xml")
lintConfig file("lint.xml")
}

testOptions {
execution 'ANDROIDX_TEST_ORCHESTRATOR'
Expand All @@ -80,6 +75,11 @@ android {
}
}
}
lint {
abortOnError true
baseline file('lint-baseline.xml')
lintConfig file('lint.xml')
}
}

// Prevent from having accidental kotlin in production code
Expand Down
6 changes: 3 additions & 3 deletions Sources/sdk/maven-publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ publishing {
url = "https://batch.com"

scm {
url = "https://github.com/BatchLabs/android-sdk"
connection = "scm:git:https://github.com/BatchLabs/android-sdk.git"
developerConnection = "scm:git:https://github.com/BatchLabs/android-sdk.git"
url = "https://github.com/BatchLabs/Batch-Android-SDK"
connection = "scm:git:https://github.com/BatchLabs/Batch-Android-SDK.git"
developerConnection = "scm:git:https://github.com/BatchLabs/Batch-Android-SDK.git"
}

licenses {
Expand Down
1 change: 1 addition & 0 deletions Sources/sdk/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

<permission
android:name="${applicationId}.batch.permission.INTERNAL_BROADCAST"
Expand Down
54 changes: 33 additions & 21 deletions Sources/sdk/src/main/java/com/batch/android/Batch.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Application;
import android.app.PendingIntent;
import android.app.Service;
import android.content.BroadcastReceiver;
Expand Down Expand Up @@ -2125,15 +2126,6 @@ else if (lastStop == null && state == State.READY) {
runtimeManager.setActivity(activity);
}

/*
* Register the messaging lifecycle listener and session manager if we can
*/
android.app.Application app = activity.getApplication();
if (app != null) {
runtimeManager.registerSessionManagerIfNeeded(app, true);
runtimeManager.registerActivityListenerIfNeeded(app);
}

/*
* List the possible intents with push payload by priority :
* 1 - Intent from onNewIntent()
Expand Down Expand Up @@ -2200,19 +2192,24 @@ else if (lastStop == null && state == State.READY) {
return null;
}

final Context applicationContext = context.getApplicationContext();

/*
* Init stuff, if we were stopped
*/
if (state == State.OFF) {
/*
* Set context
*/
runtimeManager.setContext(context.getApplicationContext());
runtimeManager.setContext(applicationContext);

/*
* Warm up the local broadcast manager
*/
LocalBroadcastManagerProvider.get(context);
LocalBroadcastManagerProvider.get(applicationContext);

// Tell the modules about the context
moduleMaster.batchContextBecameAvailable(applicationContext);

/*
* Check for update migration stuff
Expand All @@ -2222,7 +2219,7 @@ else if (lastStop == null && state == State.READY) {
/*
* Check that we have mandatory permissions
*/
if (!GenericHelper.checkPermission("android.permission.INTERNET", runtimeManager.getContext())) {
if (!GenericHelper.checkPermission("android.permission.INTERNET", applicationContext)) {
Logger.error(
"Batch needs android.permission.INTERNET, please update your manifest, aborting start"
);
Expand All @@ -2246,10 +2243,10 @@ else if (lastStop == null && state == State.READY) {
Batch.advertisingID = advertisingID;
}
if (Batch.install == null) {
Batch.install = new Install(runtimeManager.getContext());
Batch.install = new Install(applicationContext);
}
if (Batch.user == null) {
Batch.user = new com.batch.android.User(runtimeManager.getContext());
Batch.user = new com.batch.android.User(applicationContext);
}

/*
Expand All @@ -2265,15 +2262,26 @@ else if (lastStop == null && state == State.READY) {
IntentFilter filter = new IntentFilter();
filter.addAction(TaskExecutor.INTENT_WORK_FINISHED);
filter.addAction(OptOutModule.INTENT_OPTED_OUT);
LocalBroadcastManagerProvider
.get(runtimeManager.getContext())
.registerReceiver(receiver, filter);
LocalBroadcastManagerProvider.get(applicationContext).registerReceiver(receiver, filter);
}

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

/*
* Register the messaging lifecycle listener and session manager if we can
*/
if (applicationContext instanceof Application) {
final android.app.Application app = (Application) applicationContext;
runtimeManager.registerSessionManagerIfNeeded(app, true);
runtimeManager.registerActivityListenerIfNeeded(app);
} else {
// This should never happen, androidx relies on this
// https://android.googlesource.com/platform/frameworks/support/+/refs/heads/androidx-master-dev/lifecycle/lifecycle-process/src/main/java/androidx/lifecycle/ProcessLifecycleOwner.java
Logger.error("Context isn't an Application, could not register the session manager.");
}

/*
* Call modules
*/
Expand All @@ -2285,15 +2293,19 @@ else if (lastStop == null && state == State.READY) {
EventDispatcherModuleProvider.get().loadDispatcherFromContext(context);

try {
JSONObject startParams = null;

JSONObject startParams = new JSONObject();
if (userActivity) {
runtimeManager.updateLastUserStartDate();
} else {
startParams = new JSONObject();
startParams.put("silent", true);
}

startParams.putOpt(
"dispatchers",
EventDispatcherModuleProvider.get().getDispatchersAnalyticRepresentation()
);
if (startParams.length() == 0) {
startParams = null;
}
TrackerModuleProvider.get().track(InternalEvents.START, startParams);
} catch (JSONException e) {
Logger.internal("Could not track _START", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* JobService implementation of Batch Display Receipt
*/

@RequiresApi(api = Build.VERSION_CODES.O)
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public class BatchDisplayReceiptJobService extends JobService {

private static final String TAG = "BatchDisplayReceiptJobService";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.batch.android;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.batch.android.annotation.PublicSDK;

/**
Expand All @@ -9,6 +10,25 @@
*/
@PublicSDK
public interface BatchEventDispatcher {
/**
* Get the name of the dispatcher
* This information is only used for analytics
* @return the name of the dispatcher
*/
@Nullable
default String getName() {
return null;
}

/**
* Get the version of the dispatcher
* This information is only used for analytics
* @return the version of the dispatcher
*/
default int getVersion() {
return 0;
}

/**
* Callback when a new events just happened in the Batch SDK
*
Expand Down
10 changes: 10 additions & 0 deletions Sources/sdk/src/main/java/com/batch/android/BatchInboxFetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ public void setFetchLimit(int fetchLimit) {
impl.setFetchLimit(fetchLimit);
}

/**
* Sets whether the SDK should filter silent notifications (pushes that don't result in a message
* being shown to the user).
*
* Default: true
*/
public void setFilterSilentNotifications(boolean filterSilentNotifications) {
impl.setFilterSilentNotifications(filterSilentNotifications);
}

/**
* Returns whether all of the user or installation's notifications have been fetched.
* If this method returns true, calling fetchNextPage will always return an error, as there is nothing left to fetch.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,21 @@ public Date getDate() {
return (Date) internalContent.date.clone();
}

/**
* Returns whether Batch considers this a silent notification.
*
* A silent notification is a notification with no title and message, which won't be displayed by
* Batch SDK.
* Warning: Other services listening to push messages might display it.
*/
public boolean isSilent() {
try {
return internalContent.body == null || getPushPayload().getInternalData().isSilent();
} catch (BatchPushPayload.ParsingException ignored) {
return true;
}
}

/**
* Get the payload in its raw JSON form. This might differ from what you're used to in other classes
* handling push payloads. If you want to simulate the push behaviour, call {@link BatchPushPayload#getPushBundle()} on the instance given by {@link #getPushPayload()} .
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,12 @@ private boolean shouldRegisterDefaultChannel() {
return channelOverride == null;
}

void registerBatchChannelIfNeeded(Context c) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O && shouldRegisterDefaultChannel()) {
void registerBatchChannelIfNeeded(Context c, boolean forceIfOverridden) {
if (!forceIfOverridden && !shouldRegisterDefaultChannel()) {
Logger.internal(PushModule.TAG, "Channel ID overriden, not registering Batch's channel.");
return;
}
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
Logger.internal(PushModule.TAG, "Registering default Batch notification channel");
//try {
NotificationChannel channel = new NotificationChannel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ public static String getChannelId(BatchNotificationChannelsManager manager) {
return manager.getChannelId(null);
}

public static void registerBatchChannelIfNeeded(BatchNotificationChannelsManager manager, Context context) {
manager.registerBatchChannelIfNeeded(context);
public static void registerBatchChannelIfNeeded(
BatchNotificationChannelsManager manager,
Context context,
boolean forceIfOverridden
) {
manager.registerBatchChannelIfNeeded(context, forceIfOverridden);
}
}
Loading

0 comments on commit fffa2cb

Please sign in to comment.