Skip to content

Commit

Permalink
Merge changes (#594)
Browse files Browse the repository at this point in the history
* Merge changes

* updates minSdkVersion

* Revert "updates minSdkVersion"

This reverts commit c4ca0aa.

---------

Co-authored-by: “Akshay <“[email protected]”>
Co-authored-by: [email protected] <[email protected]>
  • Loading branch information
3 people authored Jul 12, 2023
1 parent 47b9a9a commit e2981db
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public void onInboxUpdated() {

@Override
public void onListItemTapped(@NonNull IterableInAppMessage message) {
IterableApi.getInstance().getInAppManager().setRead(message, true, null);
IterableApi.getInstance().getInAppManager().setRead(message, true, null, null);

if (inboxMode == InboxMode.ACTIVITY) {
startActivity(new Intent(getContext(), IterableInboxMessageActivity.class).putExtra(IterableInboxMessageActivity.ARG_MESSAGE_ID, message.getMessageId()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,16 @@ public synchronized int getUnreadInboxMessagesCount() {
return unreadInboxMessageCount;
}

public synchronized void setRead(@NonNull IterableInAppMessage message, boolean read) {
setRead(message, read, null, null);
}
/**
* Set the read flag on an inbox message
* @param message Inbox message object retrieved from {@link IterableInAppManager#getInboxMessages()}
* @param read Read state flag. true = read, false = unread
* @param successHandler The callback which returns `success`.
*/
public synchronized void setRead(@NonNull IterableInAppMessage message, boolean read, @Nullable IterableHelper.SuccessHandler successHandler) {
public synchronized void setRead(@NonNull IterableInAppMessage message, boolean read, @Nullable IterableHelper.SuccessHandler successHandler, @Nullable IterableHelper.FailureHandler failureHandler) {
message.setRead(read);
if (successHandler != null) {
successHandler.onSuccess(new JSONObject()); // passing blank json object here as onSuccess is @Nonnull
Expand Down Expand Up @@ -243,7 +246,7 @@ public void execute(Uri url) {
scheduleProcessing();
}
})) {
setRead(message, true, null);
setRead(message, true, null, null);
if (consume) {
message.markForDeletion(true);
}
Expand All @@ -253,16 +256,30 @@ public void execute(Uri url) {
/**
* Remove message from the list
* @param message The message to be removed
* @param successHandler The callback which returns `success`.
* @param failureHandler The callback which returns `failure`.
*/
public synchronized void removeMessage(@NonNull IterableInAppMessage message, @Nullable IterableHelper.SuccessHandler successHandler, @Nullable IterableHelper.FailureHandler failureHandler) {
message.setConsumed(true);
api.inAppConsume(message.getMessageId(), successHandler, failureHandler);
notifyOnChange();
public synchronized void removeMessage(@NonNull IterableInAppMessage message) {
removeMessage(message, null, null, null, null);
}

public synchronized void removeMessage(@NonNull IterableInAppMessage message, @NonNull IterableInAppDeleteActionType source, @NonNull IterableInAppLocation clickLocation, @Nullable IterableHelper.SuccessHandler successHandler, @Nullable IterableHelper.FailureHandler failureHandler) {
/**
* Remove message from the list
* @param message The message to be removed
* @param source Source from where the message removal occured. Use IterableInAppDeleteActionType for available sources
* @param clickLocation Where was the message clicked. Use IterableInAppLocation for available Click Locations
*/
public synchronized void removeMessage(@NonNull IterableInAppMessage message, @NonNull IterableInAppDeleteActionType source, @NonNull IterableInAppLocation clickLocation) {
removeMessage(message, source, clickLocation, null, null);
}

/**
* Remove message from the list
* @param message The message to be removed
* @param source Source from where the message removal occured. Use IterableInAppDeleteActionType for available sources
* @param clickLocation Where was the message clicked. Use IterableInAppLocation for available Click Locations
* @param successHandler The callback which returns `success`.
* @param failureHandler The callback which returns `failure`.
*/
public synchronized void removeMessage(@NonNull IterableInAppMessage message, @Nullable IterableInAppDeleteActionType source, @Nullable IterableInAppLocation clickLocation, @Nullable IterableHelper.SuccessHandler successHandler, @Nullable IterableHelper.FailureHandler failureHandler) {
IterableLogger.printInfo();
message.setConsumed(true);
api.inAppConsume(message, source, clickLocation, successHandler, failureHandler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public IterableNotificationBuilder createNotification(Context context, Bundle ex
trampolineActivityIntent.setClass(context, IterableTrampolineActivity.class);
trampolineActivityIntent.putExtras(extras);
trampolineActivityIntent.putExtra(IterableConstants.ITERABLE_DATA_ACTION_IDENTIFIER, IterableConstants.ITERABLE_ACTION_DEFAULT);
trampolineActivityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
trampolineActivityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);

// Action buttons
if (notificationData.getActionButtons() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void testRemoveMessageSuccessCallbackOnSuccessfulResponse() throws Except
final JSONObject responseData = new JSONObject("{\"key\":\"value\"}");
dispatcher.enqueueResponse("/events/inAppConsume", new MockResponse().setResponseCode(200).setBody(responseData.toString()));

inAppManager.removeMessage(inboxMessages.get(0), new IterableHelper.SuccessHandler() {
inAppManager.removeMessage(inboxMessages.get(0), null, null, new IterableHelper.SuccessHandler() {
@Override
public void onSuccess(@NonNull JSONObject data) {
signal.countDown();
Expand Down Expand Up @@ -127,7 +127,7 @@ public void testRemoveMessageFailureCallbackOnFailedResponse() throws Exception
final JSONObject responseData = new JSONObject("{\"key\":\"value\"}");
dispatcher.enqueueResponse("/events/inAppConsume", new MockResponse().setResponseCode(500).setBody(responseData.toString()));

inAppManager.removeMessage(inboxMessages.get(0), new IterableHelper.SuccessHandler() {
inAppManager.removeMessage(inboxMessages.get(0), null, null, new IterableHelper.SuccessHandler() {
@Override
public void onSuccess(@NonNull JSONObject data) {
assertFalse(true);
Expand Down Expand Up @@ -169,6 +169,11 @@ public void onSuccess(@NonNull JSONObject data) {
callbackCalled[0] = true;
assertTrue(callbackCalled[0]);
}
}, new IterableHelper.FailureHandler() {
@Override
public void onFailure(@NonNull String reason, @Nullable JSONObject data) {
assertFalse(true);
}
});

// Wait for callback to be called
Expand Down

0 comments on commit e2981db

Please sign in to comment.