Skip to content

Commit 6a056f1

Browse files
authored
Merge pull request #28 from Iterable/bugfix/ITBL-4138-notification-image-load-fix
Android image load fix
2 parents 46df0fb + 875533b commit 6a056f1

File tree

7 files changed

+114
-83
lines changed

7 files changed

+114
-83
lines changed

.idea/libraries/picasso_2_5_2.xml

-11
This file was deleted.

app/app.iml

+2-3
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@
8686
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
8787
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
8888
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
89-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-manifest" />
9089
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
9190
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
9291
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaPrecompile" />
@@ -97,12 +96,13 @@
9796
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
9897
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/splits-support" />
9998
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
99+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/tmp" />
100100
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
101101
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
102102
<excludeFolder url="file://$MODULE_DIR$/build/reports" />
103103
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
104104
</content>
105-
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
105+
<orderEntry type="jdk" jdkName="Android API 26 Platform" jdkType="Android SDK" />
106106
<orderEntry type="sourceFolder" forTests="false" />
107107
<orderEntry type="library" name="com.android.support:recyclerview-v7-26.0.2" level="project" />
108108
<orderEntry type="library" name="com.android.support:support-media-compat-26.0.2" level="project" />
@@ -137,6 +137,5 @@
137137
<orderEntry type="library" name="com.google.android.gms:play-services-base-11.8.0" level="project" />
138138
<orderEntry type="library" name="com.google.android.gms:play-services-tasks-license-11.8.0" level="project" />
139139
<orderEntry type="module" module-name="iterableapi" />
140-
<orderEntry type="library" name="android-android-23" level="project" />
141140
</component>
142141
</module>

iterableapi/iterableapi.iml

+4-3
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@
8787
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
8888
<excludeFolder url="file://$MODULE_DIR$/build/docs" />
8989
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations" />
90+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
9091
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/attr" />
9192
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
9293
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
93-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-manifest" />
9494
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
9595
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
9696
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/intermediate-jars" />
@@ -99,6 +99,8 @@
9999
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
100100
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
101101
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
102+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
103+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/tmp" />
102104
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
103105
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/typedefs.txt" />
104106
<excludeFolder url="file://$MODULE_DIR$/build/libs" />
@@ -108,7 +110,7 @@
108110
<excludeFolder url="file://$MODULE_DIR$/build/test-results" />
109111
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
110112
</content>
111-
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
113+
<orderEntry type="jdk" jdkName="Android API 26 Platform" jdkType="Android SDK" />
112114
<orderEntry type="sourceFolder" forTests="false" />
113115
<orderEntry type="library" name="com.android.support:support-media-compat-26.0.2" level="project" />
114116
<orderEntry type="library" name="com.google.firebase:firebase-iid-11.8.0" level="project" />
@@ -139,6 +141,5 @@
139141
<orderEntry type="library" name="com.google.android.gms:play-services-gcm-11.8.0" level="project" />
140142
<orderEntry type="library" name="com.google.android.gms:play-services-base-11.8.0" level="project" />
141143
<orderEntry type="library" name="com.google.android.gms:play-services-tasks-license-11.8.0" level="project" />
142-
<orderEntry type="library" name="android-android-23" level="project" />
143144
</component>
144145
</module>

iterableapi/src/androidTest/java/com/iterable/iterableapi/IterableNotificationTest.java

+31-9
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public IterableNotificationTest() {
2525
String itbl_ghost = "{\"templateId\":1,\"campaignId\":1,\"messageId\":\"11111111111111111111111111111111\",\"isGhostPush\":true}";
2626
String itbl1 = "{\"templateId\":1,\"campaignId\":1,\"messageId\":\"11111111111111111111111111111111\",\"isGhostPush\":false}";
2727
String itbl2 = "{\"templateId\":2,\"campaignId\":2,\"messageId\":\"22222222222222222222222222222222\",\"isGhostPush\":false}}";
28+
String itbl_image = "{\"templateId\":1,\"campaignId\":1,\"messageId\":\"11111111111111111111111111111111\",\"isGhostPush\":false,\"attachment-url\":\"http://via.placeholder.com/350x150\"}";
2829

2930
public void setUp() throws Exception {
3031
super.setUp();
@@ -36,21 +37,42 @@ public void setUp() throws Exception {
3637
}
3738

3839
public void testEmptyBundle() throws Exception {
39-
IterableNotification iterableNotification = IterableNotification.createNotification(getContext(), new Bundle(), Application.class);
40+
IterableNotificationBuilder iterableNotification = IterableNotificationBuilder.createNotification(getContext(), new Bundle(), Application.class);
4041
assertTrue(iterableNotification.requestCode < System.currentTimeMillis());
4142
}
4243

4344
public void testGhostPush() throws Exception {
4445
Bundle notif1 = new Bundle();
4546
notif1.putString(IterableConstants.ITERABLE_DATA_KEY, itbl_ghost);
46-
IterableNotification iterableNotification = IterableNotification.createNotification(getContext(), notif1, Application.class);
47-
IterableNotification.postNotificationOnDevice(appContext, iterableNotification);
47+
IterableNotificationBuilder iterableNotification = IterableNotificationBuilder.createNotification(getContext(), notif1, Application.class);
48+
IterableNotificationBuilder.postNotificationOnDevice(appContext, iterableNotification);
4849
assertTrue(iterableNotification.iterableNotificationData.getIsGhostPush());
4950
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
5051
assertEquals(0, mNotificationManager.getActiveNotifications().length);
5152
}
5253
}
5354

55+
/**
56+
* Tests loading a notification with an image.
57+
* @throws Exception
58+
*/
59+
public void testNotificationImage() throws Exception {
60+
Bundle notif = new Bundle();
61+
notif.putString(IterableConstants.ITERABLE_DATA_KEY, itbl_image);
62+
notif.putString(IterableConstants.ITERABLE_DATA_BODY, body);
63+
64+
getContext().getApplicationInfo().icon = android.R.drawable.sym_def_app_icon;
65+
66+
IterableNotificationBuilder iterableNotification = IterableNotificationBuilder.createNotification(getContext(), notif, Application.class);
67+
IterableNotificationBuilder.postNotificationOnDevice(appContext, iterableNotification);
68+
assertEquals("IterableAPI", iterableNotification.mContentTitle);
69+
// It looks like mNotificationManager.notify(iterableNotification.requestCode, iterableNotification.build());
70+
// is the culprit here for the flaky tests. This thread is spun up by the android system. Unless we do dependency injection and mock the notificationManager, it'll be hard to make this unflake.
71+
Thread.sleep(1000);
72+
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
73+
assertEquals(1, mNotificationManager.getActiveNotifications().length);
74+
}
75+
}
5476

5577
public void testNotificationText() throws Exception {
5678
Bundle notif = new Bundle();
@@ -60,8 +82,8 @@ public void testNotificationText() throws Exception {
6082

6183
getContext().getApplicationInfo().icon = android.R.drawable.sym_def_app_icon;
6284

63-
IterableNotification iterableNotification = IterableNotification.createNotification(getContext(), notif, Application.class);
64-
IterableNotification.postNotificationOnDevice(appContext, iterableNotification);
85+
IterableNotificationBuilder iterableNotification = IterableNotificationBuilder.createNotification(getContext(), notif, Application.class);
86+
IterableNotificationBuilder.postNotificationOnDevice(appContext, iterableNotification);
6587
assertEquals("IterableAPI", iterableNotification.mContentTitle);
6688
// It looks like mNotificationManager.notify(iterableNotification.requestCode, iterableNotification.build());
6789
// is the culprit here for the flaky tests. This thread is spun up by the android system. Unless we do dependency injection and mock the notificationManager, it'll be hard to make this unflake.
@@ -78,8 +100,8 @@ public void testMessage() throws Exception {
78100
notif1.putString(IterableConstants.ITERABLE_DATA_KEY, itbl1);
79101
getContext().getApplicationInfo().icon = android.R.drawable.sym_def_app_icon;
80102

81-
IterableNotification iterableNotification = IterableNotification.createNotification(getContext(), notif1, Application.class);
82-
IterableNotification.postNotificationOnDevice(appContext, iterableNotification);
103+
IterableNotificationBuilder iterableNotification = IterableNotificationBuilder.createNotification(getContext(), notif1, Application.class);
104+
IterableNotificationBuilder.postNotificationOnDevice(appContext, iterableNotification);
83105
// It looks like mNotificationManager.notify(iterableNotification.requestCode, iterableNotification.build());
84106
// is the culprit here for the flaky tests. This thread is spun up by the android system. Unless we do dependency injection and mock the notificationManager, it'll be hard to make this unflake.
85107
Thread.sleep(100);
@@ -96,8 +118,8 @@ public void testMessage() throws Exception {
96118
notif2.putString(IterableConstants.ITERABLE_DATA_KEY, itbl2);
97119
getContext().getApplicationInfo().icon = android.R.drawable.sym_def_app_icon;
98120

99-
IterableNotification iterableNotification2 = IterableNotification.createNotification(getContext(), notif2, Application.class);
100-
IterableNotification.postNotificationOnDevice(appContext, iterableNotification2);
121+
IterableNotificationBuilder iterableNotification2 = IterableNotificationBuilder.createNotification(getContext(), notif2, Application.class);
122+
IterableNotificationBuilder.postNotificationOnDevice(appContext, iterableNotification2);
101123
// It looks like mNotificationManager.notify(iterableNotification.requestCode, iterableNotification.build());
102124
// is the culprit here for the flaky tests. This thread is spun up by the android system. Unless we do dependency injection and mock the notificationManager, it'll be hard to make this unflake.
103125
Thread.sleep(100);

iterableapi/src/main/java/com/iterable/iterableapi/IterableApi.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ boolean getDebugMode() {
108108
*/
109109
void setPayloadData(Intent intent) {
110110
Bundle extras = intent.getExtras();
111-
if (extras != null && extras.containsKey(IterableConstants.ITERABLE_DATA_KEY) && !IterableNotification.isGhostPush(extras)) {
111+
if (extras != null && extras.containsKey(IterableConstants.ITERABLE_DATA_KEY) && !IterableNotificationBuilder.isGhostPush(extras)) {
112112
setPayloadData(extras);
113113
}
114114
}

0 commit comments

Comments
 (0)