Skip to content

Commit d9b3d28

Browse files
committed
Fixed unit test and updated to latest libraries
1 parent 1910e3a commit d9b3d28

File tree

13 files changed

+74
-34
lines changed

13 files changed

+74
-34
lines changed

.travis.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ android:
1919
# https://github.com/travis-ci/travis-ci/issues/6193
2020
# Required to get the newest platform-tools.
2121
- platform-tools
22-
- build-tools-25.0.0
22+
- build-tools-26.0.1
2323
- extra-android-m2repository
2424
- extra-google-m2repository
25-
- android-24
25+
- android-26
2626
licenses:
2727
- '.+'
2828
before_install:
2929
- pwd
3030
- ls -la
31-
- wget http://services.gradle.org/distributions/gradle-3.3-bin.zip
32-
- unzip gradle-3.3-bin.zip
33-
- export GRADLE_HOME=$PWD/gradle-3.3
31+
- wget http://services.gradle.org/distributions/gradle-4.1-rc-1-bin.zip
32+
- unzip gradle-4.1-rc-1-bin.zip
33+
- export GRADLE_HOME=$PWD/gradle-4.1-rc-1
3434
- export PATH=$GRADLE_HOME/bin:$PATH
3535
- cd OneSignalSDK/unittest
3636
script: gradle build

OneSignalSDK/app/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
22

33
android {
44
compileSdkVersion 26
5-
buildToolsVersion '26.0.0'
5+
buildToolsVersion '26.0.1'
66

77
defaultConfig {
88
applicationId "com.onesignal.example"
@@ -30,7 +30,7 @@ android {
3030

3131
dependencies {
3232
compile fileTree(dir: 'libs', include: ['*.jar'])
33-
compile 'com.android.support:appcompat-v7:26.0.0-beta2'
33+
compile 'com.android.support:appcompat-v7:26.0.0'
3434

3535
// Use for SDK Development
3636
compile(project(':onesignal')) {
@@ -70,7 +70,7 @@ dependencies {
7070
// compile 'com.android.support:support-core-utils:24.2.1'
7171

7272
// For Chrome tabs
73-
compile 'com.android.support:customtabs:26.0.0-beta2'
73+
compile 'com.android.support:customtabs:26.0.0'
7474

7575

7676
// debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5'

OneSignalSDK/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
buildscript {
44
repositories {
55
jcenter()
6+
67
maven { url 'https://maven.google.com' }
78
}
89
dependencies {
9-
classpath 'com.android.tools.build:gradle:3.0.0-alpha7'
10+
classpath 'com.android.tools.build:gradle:3.0.0-alpha8'
1011

1112
// NOTE: Do not place your application dependencies here; they belong
1213
// in the individual module build.gradle files

OneSignalSDK/gradle.properties

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,9 @@
1515
# When configured, Gradle will run in incubating parallel mode.
1616
# This option should only be used with decoupled projects. More details, visit
1717
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18-
# org.gradle.parallel=true
18+
# org.gradle.parallel=true
19+
20+
# Work around for robolectric-3.4-RC4 bug
21+
# https://github.com/robolectric/robolectric/issues/3169
22+
# org.robolectric.res.ResourceTableFactory.parseResourceFiles
23+
android.enableAapt2=false

OneSignalSDK/onesignal/build.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
22

33
android {
44
compileSdkVersion 26
5-
buildToolsVersion '26.0.0'
5+
buildToolsVersion '26.0.1'
66

77
defaultConfig {
88
minSdkVersion 15
@@ -28,12 +28,14 @@ android {
2828
dependencies {
2929
provided fileTree(dir: 'libs', include: ['*.jar'])
3030

31+
compile 'com.android.support:support-v4:26.0.0'
32+
3133
// NOTE: Starting with play-services 10.2.0, minSdkVersion is now 14
3234
compile 'com.google.android.gms:play-services-gcm:11.0.2'
3335
compile 'com.google.android.gms:play-services-location:11.0.2'
3436

3537
// NOTE: customtabs sets minSdkVersion to 15.
36-
compile 'com.android.support:customtabs:26.0.0-beta2'
38+
compile 'com.android.support:customtabs:26.0.0'
3739
}
3840

3941
// Remove OnActivityPausedListener class.

OneSignalSDK/onesignal/src/main/java/com/onesignal/BadgeCountUpdater.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,12 @@ private static boolean areBadgeSettingsEnabled(Context context) {
4848
try {
4949
ApplicationInfo ai = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
5050
Bundle bundle = ai.metaData;
51-
String defaultStr = bundle.getString("com.onesignal.BadgeCount");
52-
badgesEnabled = "DISABLE".equals(defaultStr) ? 0 : 1;
51+
if (bundle != null) {
52+
String defaultStr = bundle.getString("com.onesignal.BadgeCount");
53+
badgesEnabled = "DISABLE".equals(defaultStr) ? 0 : 1;
54+
}
55+
else
56+
badgesEnabled = 1;
5357
} catch (Throwable t) {
5458
badgesEnabled = 0;
5559
OneSignal.Log(OneSignal.LOG_LEVEL.ERROR, "Error reading meta-data tag 'com.onesignal.BadgeCount'. Disabling badge setting.", t);

OneSignalSDK/onesignal/src/main/java/com/onesignal/GcmBroadcastReceiver.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,17 @@ private static void startGCMService(Context context, Bundle bundle) {
134134
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
135135
ComponentName componentName = new ComponentName(context.getPackageName(),
136136
GcmIntentJobService.class.getName());
137-
138137
Random random = new Random();
139138
JobInfo jobInfo = new JobInfo.Builder(random.nextInt(), componentName)
140-
.setOverrideDeadline(100)
139+
.setOverrideDeadline(0)
141140
.setExtras((PersistableBundle)taskExtras.getBundle())
142141
.build();
143142
JobScheduler jobScheduler = (JobScheduler)context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
143+
144+
// TODO: Might want to use enqueue in the future. This will process one notification
145+
// sequentially like an IntentService
146+
// JobIntentService can be used instead, however app developer would have to use
147+
// Android support library 26+
144148
jobScheduler.schedule(jobInfo);
145149
}
146150
else {

OneSignalSDK/onesignal/src/main/java/com/onesignal/NotificationBundleProcessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,8 +412,8 @@ private static boolean startExtenderService(Context context, Bundle bundle, Proc
412412
intent.putExtra("json_payload", bundleAsJSONObject(bundle).toString());
413413
intent.putExtra("timestamp", System.currentTimeMillis() / 1000L);
414414

415-
// Using Alarm with a short delay for Android O compatibility
416-
long atTime = System.currentTimeMillis() + 100;
415+
// Using Alarm for Android O compatibility
416+
long atTime = System.currentTimeMillis();
417417
PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
418418
AlarmManager alarm = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
419419
alarm.set(AlarmManager.RTC_WAKEUP, atTime, pendingIntent);

OneSignalSDK/onesignal/src/main/java/com/onesignal/NotificationRestorer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ static void startRestoreTaskFromReceiver(WakefulBroadcastReceiver receiver, Cont
157157

158158
Random random = new Random();
159159
JobInfo jobInfo = new JobInfo.Builder(random.nextInt(), componentName)
160-
.setOverrideDeadline(100)
160+
.setOverrideDeadline(0)
161161
.build();
162162
JobScheduler jobScheduler = (JobScheduler)context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
163163
jobScheduler.schedule(jobInfo);

OneSignalSDK/unittest/build.gradle

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
22

33
android {
44
compileSdkVersion 26
5-
buildToolsVersion '26.0.0'
5+
buildToolsVersion '26.0.1'
66

77
defaultConfig {
88
applicationId "com.onesignal.example"
@@ -37,6 +37,15 @@ repositories {
3737
dependencies {
3838
compile fileTree(dir: 'libs', include: ['*.jar'])
3939

40+
compile 'com.android.support:support-v4:26.0.0'
41+
42+
// compile 'com.android.support:support-compat:26.0.0'
43+
// compile 'com.android.support:support-media-compat:26.0.0'
44+
// compile 'com.android.support:support-fragment:26.0.0'
45+
// compile 'com.android.support:support-core-ui:26.0.0'
46+
// compile 'com.android.support:support-core-utils:26.0.0'
47+
48+
4049
// Use for SDK Development
4150
compile(project(':onesignal')) {
4251
exclude group: 'com.android.support', module: 'support-v4'
@@ -63,7 +72,7 @@ dependencies {
6372

6473
// compile 'com.google.android.gms:play-services-analytics:7.0.0'
6574

66-
compile 'com.android.support:customtabs:26.0.0-beta2'
75+
compile 'com.android.support:customtabs:26.0.0'
6776

6877
testCompile 'junit:junit:4.12'
6978
testCompile('org.robolectric:robolectric:3.4-rc5') {

0 commit comments

Comments
 (0)