Skip to content

Commit 2f50519

Browse files
committed
Merge branch 'release/3.0.2'
2 parents a32d109 + 3c4781d commit 2f50519

33 files changed

+368
-299
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ $RECYCLE.BIN/
7070
.idea/**/workspace.xml
7171
.idea/**/tasks.xml
7272
.idea/dictionaries
73+
.idea/**
7374

7475
# Sensitive or high-churn files:
7576
.idea/**/dataSources/

.idea/compiler.xml

Lines changed: 0 additions & 22 deletions
This file was deleted.

.idea/misc.xml

Lines changed: 0 additions & 36 deletions
This file was deleted.

.idea/modules.xml

Lines changed: 0 additions & 10 deletions
This file was deleted.

.idea/runConfigurations.xml

Lines changed: 0 additions & 12 deletions
This file was deleted.

AndroidSDK/build.gradle

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ apply plugin: 'com.android.library'
22
apply plugin: 'com.jfrog.artifactory'
33
apply plugin: 'maven-publish'
44

5-
def COMPILE_SDK_VERSION=26
6-
def BUILD_TOOLS_VERSION='26.0.1'
7-
def SUPPORT_LIBRARY_VERSION='26.1.0'
5+
def COMPILE_SDK_VERSION=27
6+
def BUILD_TOOLS_VERSION='27.0.2'
7+
def SUPPORT_LIBRARY_VERSION='27.0.2'
88

99
allprojects {
1010
gradle.projectsEvaluated {
@@ -16,19 +16,17 @@ allprojects {
1616

1717
dependencies {
1818
// Compile dependencies will be added as dependency in pom file.
19-
//noinspection GradleDynamicVersion
20-
compile "com.android.support:support-v4:[22.0.0,${SUPPORT_LIBRARY_VERSION}]"
21-
//noinspection GradleDynamicVersion
22-
compile "com.android.support:appcompat-v7:[22.0.0,${SUPPORT_LIBRARY_VERSION}]"
19+
api "com.android.support:support-v4:[22.0.0,${SUPPORT_LIBRARY_VERSION}]"
20+
api "com.android.support:appcompat-v7:[22.0.0,${SUPPORT_LIBRARY_VERSION}]"
2321

2422
// Provided dependencies are optional dependencies and will not show up in pom file.
25-
provided('com.google.android.gms:play-services-gcm:[8.3.0,)') {
23+
compileOnly('com.google.android.gms:play-services-gcm:[8.3.0,)') {
2624
exclude module: 'support-v4'
2725
}
28-
provided('com.google.firebase:firebase-messaging:[10.0.0,)') {
26+
compileOnly('com.google.firebase:firebase-messaging:[10.0.0,)') {
2927
exclude module: 'support-v4'
3028
}
31-
provided('com.google.android.gms:play-services-location:[10.0.0,)') {
29+
compileOnly('com.google.android.gms:play-services-location:[10.0.0,)') {
3230
exclude module: 'support-v4'
3331
}
3432
}
@@ -37,7 +35,7 @@ android {
3735
compileSdkVersion COMPILE_SDK_VERSION
3836
buildToolsVersion BUILD_TOOLS_VERSION
3937
useLibrary 'org.apache.http.legacy'
40-
publishNonDefault true
38+
// publishNonDefault true
4139

4240
defaultConfig {
4341
consumerProguardFiles 'consumer-proguard-rules.pro'
@@ -119,7 +117,7 @@ publishing {
119117

120118
// Iterate over the compile dependencies (we don't want the test ones),
121119
// adding a <dependency> node for each.
122-
configurations.compile.allDependencies.each {
120+
configurations.api.allDependencies.each {
123121
if (it.group != null && it.name != null) {
124122
def dependencyNode = dependenciesNode.appendNode('dependency')
125123
dependencyNode.appendNode('groupId', it.group)
@@ -144,7 +142,7 @@ publishing {
144142

145143
// Iterate over the compile dependencies (we don't want the test ones),
146144
// adding a <dependency> node for each.
147-
configurations.compile.allDependencies.each {
145+
configurations.api.allDependencies.each {
148146
if (it.group != null && it.name != null) {
149147
def dependencyNode = dependenciesNode.appendNode('dependency')
150148
dependencyNode.appendNode('groupId', it.group)

AndroidSDK/src/com/leanplum/Leanplum.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,20 @@ public static void setDeviceId(String deviceId) {
295295
userSpecifiedDeviceId = true;
296296
}
297297

298+
/**
299+
* Gets the deviceId in the current Leanplum session. This should only be called after
300+
* {@link Leanplum#start}.
301+
*
302+
* @return String Returns the deviceId in the current Leanplum session.
303+
*/
304+
public static String getDeviceId() {
305+
if (!LeanplumInternal.hasCalledStart()) {
306+
Log.e("Leanplum.start() must be called before calling getDeviceId.");
307+
return null;
308+
}
309+
return Request.deviceId();
310+
}
311+
298312
/**
299313
* Sets the application context. This should be the first call to Leanplum.
300314
*/
@@ -1921,6 +1935,8 @@ public void response(JSONObject response) {
19211935
applyContentInResponse(response, false);
19221936
if (response.optBoolean(Constants.Keys.SYNC_INBOX, false)) {
19231937
LeanplumInbox.getInstance().downloadMessages();
1938+
} else {
1939+
LeanplumInbox.getInstance().triggerInboxSyncedWithStatus(true);
19241940
}
19251941
if (response.optBoolean(Constants.Keys.LOGGING_ENABLED, false)) {
19261942
Constants.loggingEnabled = true;
@@ -1940,6 +1956,7 @@ public void error(Exception e) {
19401956
if (callback != null) {
19411957
OsHandler.getInstance().post(callback);
19421958
}
1959+
LeanplumInbox.getInstance().triggerInboxSyncedWithStatus(false);
19431960
}
19441961
});
19451962
req.sendIfConnected();

AndroidSDK/src/com/leanplum/LeanplumInbox.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import android.content.SharedPreferences;
2626

2727
import com.leanplum.callbacks.InboxChangedCallback;
28+
import com.leanplum.callbacks.InboxSyncedCallback;
2829
import com.leanplum.callbacks.VariablesChangedCallback;
2930
import com.leanplum.internal.AESCrypt;
3031
import com.leanplum.internal.CollectionUtil;
@@ -65,13 +66,15 @@ public class LeanplumInbox {
6566
private boolean didLoad = false;
6667

6768
private final List<InboxChangedCallback> changedCallbacks;
69+
private final List<InboxSyncedCallback> syncedCallbacks;
6870
private final Object updatingLock = new Object();
6971

7072
private LeanplumInbox() {
7173
this.unreadCount = 0;
7274
this.messages = new HashMap<>();
7375
this.didLoad = false;
7476
this.changedCallbacks = new ArrayList<>();
77+
this.syncedCallbacks = new ArrayList<>();
7578
downloadedImageUrls = new HashSet<>();
7679
}
7780

@@ -178,6 +181,29 @@ public void removeChangedHandler(InboxChangedCallback handler) {
178181
}
179182
}
180183

184+
/**
185+
* Add a callback for when the forceContentUpdate was called.
186+
*
187+
* @param handler InboxSyncedCallback callback that need to be added.
188+
*/
189+
public void addSyncedHandler(InboxSyncedCallback handler) {
190+
synchronized (syncedCallbacks) {
191+
syncedCallbacks.add(handler);
192+
}
193+
}
194+
195+
196+
/**
197+
* Removes a inbox synced callback.
198+
*
199+
* @param handler InboxSyncedCallback callback that need to be removed.
200+
*/
201+
public void removeSyncedHandler(InboxSyncedCallback handler) {
202+
synchronized (syncedCallbacks) {
203+
syncedCallbacks.remove(handler);
204+
}
205+
}
206+
181207
/**
182208
* Static 'getInstance' method.
183209
*/
@@ -241,6 +267,19 @@ void triggerChanged() {
241267
}
242268
}
243269

270+
/**
271+
* Trigger InboxSyncedCallback with status of forceContentUpdate.
272+
* @param success True if forceContentUpdate was successful.
273+
*/
274+
void triggerInboxSyncedWithStatus(boolean success) {
275+
synchronized (changedCallbacks) {
276+
for (InboxSyncedCallback callback : syncedCallbacks) {
277+
callback.setSuccess(success);
278+
OsHandler.getInstance().post(callback);
279+
}
280+
}
281+
}
282+
244283
void load() {
245284
if (Constants.isNoop()) {
246285
return;
@@ -353,6 +392,7 @@ public void response(JSONObject response) {
353392

354393
if (!willDownladImages) {
355394
update(messages, unreadCount, true);
395+
triggerInboxSyncedWithStatus(true);
356396
return;
357397
}
358398

@@ -362,13 +402,21 @@ public void response(JSONObject response) {
362402
@Override
363403
public void variablesChanged() {
364404
update(messages, totalUnreadCount, true);
405+
triggerInboxSyncedWithStatus(true);
365406
}
366407
});
367408
} catch (Throwable t) {
409+
triggerInboxSyncedWithStatus(false);
368410
Util.handleException(t);
369411
}
370412
}
371413
});
414+
req.onError(new Request.ErrorCallback() {
415+
@Override
416+
public void error(Exception e) {
417+
triggerInboxSyncedWithStatus(false);
418+
}
419+
});
372420
req.sendIfConnected();
373421
}
374422

0 commit comments

Comments
 (0)