Skip to content

Commit

Permalink
release: SDK 1.17.2
Browse files Browse the repository at this point in the history
  • Loading branch information
abarisain committed Jun 15, 2021
1 parent af04acf commit 7c9353a
Show file tree
Hide file tree
Showing 20 changed files with 9,035 additions and 51 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The Batch Android SDK allows you to build meaningful communication experience in
Our [📕 setup documentation](https://doc.batch.com/ios/prerequisites) details the steps to take for an easy and successful integration.

# Prerequisites
The Batch iOS SDK requires Android Studio 4 and Android API 14.
The Batch Android SDK requires Android Studio 4 and Android API 15.

# Documentation
- [Setup guide](https://doc.batch.com/android/prerequisites): start your implementation here!
Expand Down
7 changes: 6 additions & 1 deletion Sources/.idea/compiler.xml

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

10 changes: 10 additions & 0 deletions Sources/.idea/runConfigurations.xml

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

2 changes: 1 addition & 1 deletion Sources/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath 'com.android.tools.build:gradle:4.2.0'
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
Expand Down
Binary file modified Sources/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 1 addition & 2 deletions Sources/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Tue Jun 02 12:12:04 CEST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
70 changes: 43 additions & 27 deletions Sources/gradlew
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
#!/usr/bin/env bash
#!/usr/bin/env sh

#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

##############################################################################
##
Expand Down Expand Up @@ -28,16 +44,16 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

warn ( ) {
warn () {
echo "$*"
}

die ( ) {
die () {
echo
echo "$*"
echo
Expand Down Expand Up @@ -66,6 +82,7 @@ esac

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar


# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
Expand Down Expand Up @@ -109,10 +126,11 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi

# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`

JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
Expand All @@ -138,32 +156,30 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
i=`expr $i + 1`
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi

# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
APP_ARGS=`save "$@"`

# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [[ "$(uname)" == "Darwin" ]] && [[ "$HOME" == "$PWD" ]]; then
cd "$(dirname "$0")"
fi
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"

exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
exec "$JAVACMD" "$@"
22 changes: 21 additions & 1 deletion Sources/gradlew.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
Expand All @@ -13,8 +29,11 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
Expand Down Expand Up @@ -65,6 +84,7 @@ set CMD_LINE_ARGS=%*

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar


@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

Expand Down
4 changes: 2 additions & 2 deletions Sources/sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ android {
minSdkVersion 15
targetSdkVersion 30
versionCode 1
versionName "1.17.1"
versionName "1.17.2"
buildConfigField "String", SDK_VERSION, "\"$versionName\""
buildConfigField "Integer", API_LEVEL, '35'
buildConfigField "Integer", API_LEVEL, '36'
buildConfigField "Integer", MESSAGING_API_LEVEL, '10'
buildConfigField "String", WS_DOMAIN, '"ws.batch.com"'

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 @@ -14,6 +14,7 @@
<uses-permission android:name="${applicationId}.batch.permission.INTERNAL_BROADCAST" />

<queries>
<package android:name="com.android.vending" />
<package android:name="com.huawei.appmarket" />
</queries>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void markAsDeleted(BatchInboxNotificationContent notification)
/**
* Returns a copy of all notifications that have been fetched until now, ordered by reverse chronological order (meaning that the first message is the newest one, and the last one the oldest).
* Note that this array will be empty until you call {@link #fetchNewNotifications(OnNewNotificationsFetchedListener)}, and will only grow on subsequent fetches.
* On this beta, this operation is quite extensive: you should cache this result until you call fetch*.
* This operation is quite extensive: you should cache this result until you call fetch*.
*/
@NonNull
public List<BatchInboxNotificationContent> getFetchedNotifications()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public BatchUserDataEditor setRegion(final @Nullable String region)

/**
* Set the user identifier.<br>
* Be careful: you should make sure the identifier uniquely identifies a user. When pushing an identifier, all installations with that identifier will get the Push, which can cause some privacy issues if done wrong. Also affects Unlock offer delivery and restore.
* Be careful: you should make sure the identifier uniquely identifies a user. When pushing an identifier, all installations with that identifier will get the Push, which can cause some privacy issues if done wrong.
*
* @param identifier Identifier string
* @return This object instance, for method chaining
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ public class UserEventBuiltinActionRunnable implements UserActionRunnable

private Date parseDate(String date)
{
DateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX", Locale.US);
DateFormat isoFormat = null;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
isoFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX", Locale.US);
} else {
isoFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.US);
// Java 6 doesn't parse dates with timezones well
date = date.replaceAll("Z$", "+0000");
}
try {
return isoFormat.parse(date);
} catch (ParseException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;

import com.batch.android.core.Logger;
import com.batch.android.date.TimezoneAwareDate;
Expand All @@ -27,6 +28,7 @@
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.UUID;

/**
* Response for {@link LocalCampaignsQuery}
Expand Down Expand Up @@ -125,12 +127,11 @@ private void parseResponse(JSONObject response) throws JSONException
//TODO: This should manually be done, not on class instaniation!
if (autosave) {
JSONObject responseCopy = new JSONObject();
//TODO: Temporary fix for ch24046
responseCopy.put("id", response.reallyOptString("id", "dummy_id"));
responseCopy.put("campaigns", new JSONArray(persistCampaigns));

// Save response
CampaignManagerProvider.get().saveCampaignsResponseAsync(
getContext(),
responseCopy);
saveResponse(responseCopy);
}
}

Expand Down Expand Up @@ -291,4 +292,11 @@ private LocalCampaign.Trigger parseTrigger(JSONObject json) throws JSONException
throw new JSONException("Unknown campaign triggers \"" + type + "\"");
}
}

@VisibleForTesting
protected void saveResponse(@NonNull JSONObject response) {
CampaignManagerProvider.get().saveCampaignsResponseAsync(
getContext(),
response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import androidx.test.filters.MediumTest;

import com.batch.android.Batch;
import com.batch.android.Config;
import com.batch.android.di.DITestUtils;
import com.batch.android.di.providers.RuntimeManagerProvider;
import com.batch.android.json.JSONException;
Expand All @@ -29,9 +28,12 @@
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.rule.PowerMockRule;
import org.robolectric.annotation.Config;
import org.robolectric.res.android.Asset;
import org.robolectric.shadows.ShadowLog;

import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR2;
import static android.os.Build.VERSION_CODES.P;
import static org.mockito.ArgumentMatchers.eq;

@RunWith(AndroidJUnit4.class)
Expand Down Expand Up @@ -138,6 +140,7 @@ public void testTrackEventWithTagsAction() throws JSONException
}

@Test
@Config(sdk = {JELLY_BEAN_MR2, P})
public void testTrackEventWithAttrAction() throws JSONException
{
ActionModule actionModule = new ActionModule();
Expand Down
Loading

0 comments on commit 7c9353a

Please sign in to comment.