|
23 | 23 |
|
24 | 24 | import android.app.Activity; |
25 | 25 | import android.content.Context; |
| 26 | +import android.drm.DrmStore; |
26 | 27 | import android.location.Location; |
27 | 28 | import android.os.AsyncTask; |
28 | 29 | import android.support.annotation.VisibleForTesting; |
@@ -1337,24 +1338,46 @@ public static void triggerMessageDisplayed(ActionContext actionContext) { |
1337 | 1338 | ActionManager.getInstance().recordMessageImpression(actionContext.getMessageId()); |
1338 | 1339 | synchronized (messageDisplayedHandlers) { |
1339 | 1340 | for (MessageDisplayedCallback callback : messageDisplayedHandlers) { |
1340 | | - String messageID = actionContext.getMessageId(); |
1341 | | - String messageBody = ""; |
1342 | | - try { |
1343 | | - messageBody = (String) actionContext.getArgs().get("Message"); |
1344 | | - } catch (Throwable t) { |
1345 | | - Util.handleException(t); |
1346 | | - } |
1347 | | - String recipientUserID = Leanplum.getUserId(); |
1348 | | - Date deliveryDateTime = new Date(); |
1349 | | - |
1350 | | - MessageArchiveData messageArchiveData = new MessageArchiveData(messageID, |
1351 | | - messageBody, recipientUserID, deliveryDateTime); |
| 1341 | + MessageArchiveData messageArchiveData = messageArchiveDataFromContext(actionContext); |
1352 | 1342 | callback.setMessageArchiveData(messageArchiveData); |
1353 | 1343 | OsHandler.getInstance().post(callback); |
1354 | 1344 | } |
1355 | 1345 | } |
1356 | 1346 | } |
1357 | 1347 |
|
| 1348 | + private static MessageArchiveData messageArchiveDataFromContext(ActionContext actionContext) { |
| 1349 | + String messageID = actionContext.getMessageId(); |
| 1350 | + String messageBody = ""; |
| 1351 | + try { |
| 1352 | + messageBody = messageBodyFromContext(actionContext); |
| 1353 | + } catch (Throwable t) { |
| 1354 | + Util.handleException(t); |
| 1355 | + } |
| 1356 | + String recipientUserID = Leanplum.getUserId(); |
| 1357 | + Date deliveryDateTime = new Date(); |
| 1358 | + |
| 1359 | + return new MessageArchiveData(messageID, messageBody, recipientUserID, deliveryDateTime); |
| 1360 | + } |
| 1361 | + |
| 1362 | + @VisibleForTesting |
| 1363 | + public static String messageBodyFromContext(ActionContext actionContext) { |
| 1364 | + Object messageObject = actionContext.getArgs().get("Message"); |
| 1365 | + if (messageObject instanceof String) { |
| 1366 | + return (String) messageObject; |
| 1367 | + } else { |
| 1368 | + HashMap<String, String> messageDict = (HashMap<String, String>) messageObject; |
| 1369 | + if (messageDict.get("Text") != null && |
| 1370 | + messageDict.get("Text") instanceof String) { |
| 1371 | + return messageDict.get("Text"); |
| 1372 | + } |
| 1373 | + if (messageDict.get("Text value") != null && |
| 1374 | + messageDict.get("Text value") instanceof String) { |
| 1375 | + return messageDict.get("Text value"); |
| 1376 | + } |
| 1377 | + } |
| 1378 | + return null; |
| 1379 | + } |
| 1380 | + |
1358 | 1381 | /** |
1359 | 1382 | * Add a callback to call ONCE when no more file downloads are pending (either when no files |
1360 | 1383 | * needed to be downloaded or all downloads have been completed). |
|
0 commit comments