Skip to content

Commit

Permalink
Merge pull request #317 from CleverTap/develop
Browse files Browse the repository at this point in the history
SDK Releases for : Core , HMS, XPS
  • Loading branch information
root-ansh-ct authored Sep 6, 2022
2 parents 27d1f29 + e612e81 commit 4bd82f2
Show file tree
Hide file tree
Showing 54 changed files with 792 additions and 169 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## CHANGE LOG.

### September 6, 2022

* [CleverTap Android SDK v4.6.1](https://github.com/CleverTap/clevertap-android-sdk/blob/master/docs/CTCORECHANGELOG.md)
* [CleverTap Xiaomi Push SDK v1.5.0](https://github.com/CleverTap/clevertap-android-sdk/blob/master/docs/CTXIAOMIPUSHCHANGELOG.md)
* [CleverTap Huawei Push SDK v1.3.1](https://github.com/CleverTap/clevertap-android-sdk/blob/master/docs/CTHUAWEIPUSHCHANGELOG.md)

### August 4, 2022

* [CleverTap Android SDK v4.6.0](https://github.com/CleverTap/clevertap-android-sdk/blob/master/docs/CTCORECHANGELOG.md)
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

# CleverTap Android SDKs
[![Build Status](https://app.bitrise.io/app/09efc6b9404a6341/status.svg?token=TejL3E1NHyTiR5ajHKGJ6Q)](https://app.bitrise.io/app/09efc6b9404a6341)
[![build - pr raised against develop](https://github.com/CleverTap/clevertap-android-sdk/actions/workflows/on_pr_from_task_to_develop.yml/badge.svg)](https://github.com/CleverTap/clevertap-android-sdk/actions/workflows/on_pr_from_task_to_develop.yml)
[![build - master](https://github.com/CleverTap/clevertap-android-sdk/actions/workflows/on_pr_merged_in_master.yml/badge.svg)](https://github.com/CleverTap/clevertap-android-sdk/actions/workflows/on_pr_merged_in_master.yml)
[![Download](https://api.bintray.com/packages/clevertap/Maven/CleverTapAndroidSDK/images/download.svg) ](https://bintray.com/clevertap/Maven/CleverTapAndroidSDK/_latestVersion)

## 👋 Introduction
Expand All @@ -24,15 +26,15 @@ We publish the SDK to `mavenCentral` as an `AAR` file. Just declare it as depend

```groovy
dependencies {
implementation "com.clevertap.android:clevertap-android-sdk:4.6.0"
implementation "com.clevertap.android:clevertap-android-sdk:4.6.1"
}
```

Alternatively, you can download and add the AAR file included in this repo in your Module libs directory and tell gradle to install it like this:

```groovy
dependencies {
implementation (name: "clevertap-android-sdk-4.6.0", ext: 'aar')
implementation (name: "clevertap-android-sdk-4.6.1", ext: 'aar')
}
```

Expand All @@ -44,7 +46,7 @@ Add the Firebase Messaging library and Android Support Library v4 as dependencie

```groovy
dependencies {
implementation "com.clevertap.android:clevertap-android-sdk:4.6.0"
implementation "com.clevertap.android:clevertap-android-sdk:4.6.1"
implementation "androidx.core:core:1.3.0"
implementation "com.google.firebase:firebase-messaging:21.0.0"
implementation "com.google.android.gms:play-services-ads:19.4.0" // Required only if you enable Google ADID collection in the SDK (turned off by default).
Expand All @@ -69,7 +71,7 @@ Also be sure to include the `google-services.json` classpath in your Project lev
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.1"
classpath "com.android.tools.build:gradle:7.2.1"
classpath "com.google.gms:google-services:4.3.3"
// NOTE: Do not place your application dependencies here; they belong
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import android.location.Location;
import android.net.Uri;
import android.os.Bundle;

import androidx.annotation.NonNull;
import com.clevertap.android.sdk.displayunits.model.CleverTapDisplayUnit;
import com.clevertap.android.sdk.events.BaseEventQueueManager;
Expand Down Expand Up @@ -629,6 +628,7 @@ public void pushNotificationViewedEvent(Bundle extras) {
} catch (Throwable ignored) {
//no-op
}
coreMetaData.setLastNotificationId(extras.getString(Constants.WZRK_PUSH_ID));
baseEventQueueManager.queueEvent(context, event, Constants.NV_EVENT);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
Expand Down Expand Up @@ -139,6 +140,8 @@ public int intValue() {

private WeakReference<InboxMessageButtonListener> inboxMessageButtonListener;

private WeakReference<InboxMessageListener> inboxMessageListener;

/**
* This method is used to change the credentials of CleverTap account Id and token programmatically
*
Expand Down Expand Up @@ -1273,6 +1276,7 @@ public ArrayList<CleverTapDisplayUnit> getAllDisplayUnits() {
*/
@SuppressWarnings({"unused", "WeakerAccess"})
public ArrayList<CTInboxMessage> getAllInboxMessages() {
Logger.d("CleverTapAPI:getAllInboxMessages: called" );
ArrayList<CTInboxMessage> inboxMessageArrayList = new ArrayList<>();
synchronized (coreState.getCTLockManager().getInboxControllerLock()) {
if (coreState.getControllerManager().getCTInboxController() != null) {
Expand Down Expand Up @@ -1626,6 +1630,7 @@ public int getInboxMessageCount() {
*/
@SuppressWarnings({"unused", "WeakerAccess"})
public CTInboxMessage getInboxMessageForId(String messageId) {
Logger.d("CleverTapAPI:getInboxMessageForId() called with: messageId = [" + messageId + "]");
synchronized (coreState.getCTLockManager().getInboxControllerLock()) {
if (coreState.getControllerManager().getCTInboxController() != null) {
CTMessageDAO message = coreState.getControllerManager().getCTInboxController()
Expand Down Expand Up @@ -1860,25 +1865,32 @@ public void markReadInboxMessage(String messageId) {
}

@Override
public void messageDidClick(CTInboxActivity ctInboxActivity, CTInboxMessage inboxMessage, Bundle data,
HashMap<String, String> keyValue) {
public void messageDidClick(CTInboxActivity ctInboxActivity, CTInboxMessage inboxMessage, Bundle data, HashMap<String, String> keyValue, boolean isBodyClick) {

coreState.getAnalyticsManager().pushInboxMessageStateEvent(true, inboxMessage, data);

if (keyValue != null && !keyValue.isEmpty()) {
if (inboxMessageButtonListener != null && inboxMessageButtonListener.get() != null) {
inboxMessageButtonListener.get().onInboxButtonClick(keyValue);
}
}
else{
if (isBodyClick && inboxMessageListener != null && inboxMessageListener.get() != null) {
inboxMessageListener.get().onInboxItemClicked(inboxMessage);
}
}
}

//Session

@Override
public void messageDidShow(CTInboxActivity ctInboxActivity, final CTInboxMessage inboxMessage,
final Bundle data) {
public void messageDidShow(CTInboxActivity ctInboxActivity, final CTInboxMessage inboxMessage, final Bundle data) {
Task<Void> task = CTExecutorFactory.executors(coreState.getConfig()).postAsyncSafelyTask();
task.execute("handleMessageDidShow", new Callable<Void>() {
@Override
public Void call() {
Logger.d("CleverTapAPI:messageDidShow() called in async with: messageId = [" + inboxMessage.getMessageId() + "]");

CTInboxMessage message = getInboxMessageForId(inboxMessage.getMessageId());
if (!message.isRead()) {
markReadInboxMessage(inboxMessage);
Expand Down Expand Up @@ -2152,6 +2164,8 @@ public void pushHuaweiRegistrationId(String regId, boolean register) {
*/
@SuppressWarnings("unused")
public void pushInboxNotificationClickedEvent(String messageId) {
Logger.v( "CleverTapAPI:pushInboxNotificationClickedEvent() called with: messageId = [" +messageId + "]");

CTInboxMessage message = getInboxMessageForId(messageId);
coreState.getAnalyticsManager().pushInboxMessageStateEvent(true, message, null);
}
Expand All @@ -2163,6 +2177,7 @@ public void pushInboxNotificationClickedEvent(String messageId) {
*/
@SuppressWarnings("unused")
public void pushInboxNotificationViewedEvent(String messageId) {
Logger.v( "CleverTapAPI:pushInboxNotificationViewedEvent() called with: messageId = [" +messageId + "]");
CTInboxMessage message = getInboxMessageForId(messageId);
coreState.getAnalyticsManager().pushInboxMessageStateEvent(false, message, null);
}
Expand Down Expand Up @@ -2229,14 +2244,22 @@ public void pushProfile(final Map<String, Object> profile) {
* Sends the Xiaomi registration ID to CleverTap.
*
* @param regId The Xiaomi registration ID
* @param region The Server room region provided by Xiaomi. Value must be not null or empty
* @param register Boolean indicating whether to register
* or not for receiving push messages from CleverTap.
* Set this to true to receive push messages from CleverTap,
* and false to not receive any messages from CleverTap.
*/
@SuppressWarnings("unused")
public void pushXiaomiRegistrationId(String regId, boolean register) {
coreState.getPushProviders().handleToken(regId, PushType.XPS, register);
public void pushXiaomiRegistrationId(String regId,@NonNull String region, boolean register) {
if(TextUtils.isEmpty(region)){
Logger.d("CleverTapApi : region must not be null or empty , use MiPushClient.getAppRegion(context) to provide appropriate region");
}else{
Logger.d("CleverTapAPI: client called pushXiaomiRegistrationId called with region:"+region);
PushType.XPS.setServerRegion(region);
coreState.getPushProviders().handleToken(regId, PushType.XPS, register);
}

}

/**
Expand Down Expand Up @@ -2387,6 +2410,11 @@ public void setInboxMessageButtonListener(InboxMessageButtonListener listener) {
this.inboxMessageButtonListener = new WeakReference<>(listener);
}

@SuppressWarnings("unused")
public void setCTInboxMessageListener(InboxMessageListener listener){
this.inboxMessageListener = new WeakReference<>(listener);
}

@RestrictTo(Scope.LIBRARY_GROUP)
public void setNotificationRenderedListener(final NotificationRenderedListener notificationRenderedListener) {
coreState.getCallbackManager().setNotificationRenderedListener(notificationRenderedListener);
Expand Down Expand Up @@ -2919,4 +2947,3 @@ public static void enableXiaomiPushOn(@XiaomiPush int xpsRunningDevices) {
return PushType.XPS.getRunningDevices();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ public interface Constants {
String KEY_ALLOWED_PUSH_TYPES = "allowedPushTypes";
String KEY_IDENTITY_TYPES = "identityTypes";
String WZRK_PUSH_ID = "wzrk_pid";
String WZRK_PUSH_SILENT = "wzrk_pn_s";
String EXTRAS_FROM = "extras_from";
String NOTIF_MSG = "nm";
String NOTIF_TITLE = "nt";
Expand Down Expand Up @@ -309,4 +310,7 @@ public interface Constants {
String WZRK_HEALTH_STATE_GOOD = "true";
String WZRK_HEALTH_STATE_BAD = "false";

String REGION_INDIA = "in1";
String REGION_EUROPE = "eu1";

}
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,14 @@ public class CoreMetaData extends CleverTapMetaData {

private boolean offline;

/**
* Last notification received on device from CleverTap in an active session of a process(before process is killed)
*/
private String lastNotificationId;

private final Object optOutFlagLock = new Object();

private HashMap<String,Integer> customSdkVersions = new HashMap<>();
private HashMap<String, Integer> customSdkVersions = new HashMap<>();

private long referrerClickTime = 0;

Expand All @@ -71,6 +76,14 @@ public static Activity getCurrentActivity() {
return (currentActivity == null) ? null : currentActivity.get();
}

public String getLastNotificationId() {
return lastNotificationId;
}

void setLastNotificationId(final String lastNotificationId) {
this.lastNotificationId = lastNotificationId;
}

static int getInitialAppEnteredForegroundTime() {
return initialAppEnteredForegroundTime;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.clevertap.android.sdk;

import com.clevertap.android.sdk.inbox.CTInboxMessage;

public interface InboxMessageListener {
/**
* callback to transfer payload when an inbox item is clicked
*/
void onInboxItemClicked(CTInboxMessage message);
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ boolean enableBeta() {
return beta;
}

String getAccountRegion() {
@RestrictTo(RestrictTo.Scope.LIBRARY)
public String getAccountRegion() {
Logger.v("ManifestInfo: getAccountRegion called, returning region:"+accountRegion);
return accountRegion;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ QueueCursor getQueueCursor(final Context context, final Table table, final int b
}
}

// note : only works with Queue Cursor of Events table. for other cursors, will override its data with Event table's data
@Override
QueueCursor getQueuedDBEvents(final Context context, final int batchSize, final QueueCursor previousCursor) {

Expand Down Expand Up @@ -153,6 +154,14 @@ public void queuePushNotificationViewedEventToDB(final Context context, final JS
queueEventInternal(context, event, DBAdapter.Table.PUSH_NOTIFICATION_VIEWED);
}

/* calling this function Will set items from jsonObject to queue cursor.
* if jsonObject is null, will return the queue cursor as it is
* else
* - it will try taking the first key and set it at as cursor's Last Id
* - it will try taking the value of first key, cast it as jsonArray and set it as cursor's data
*
* therefore, the json must be of format : {string : jsonArray }
* */
@Override
QueueCursor updateCursorForDBObject(final JSONObject dbObject, final QueueCursor cursor) {
if (dbObject == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void configureWithMessage(final CTInboxMessage inboxMessage, final CTInboxListVi
this.imageViewPager.addOnPageChangeListener(carouselPageChangeListener);

this.clickLayout.setOnClickListener(
new CTInboxButtonClickListener(position, inboxMessage, null, parentWeak, this.imageViewPager));
new CTInboxButtonClickListener(position, inboxMessage, null, parentWeak, this.imageViewPager,true));

Runnable carouselRunnable = new Runnable() {
@Override
Expand All @@ -136,7 +136,6 @@ public void run() {
parentWeak.didShow(null, position);
}
}
carouselReadDot.setVisibility(View.GONE);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void configureWithMessage(final CTInboxMessage inboxMessage, final CTInboxListVi
this.imageViewPager.addOnPageChangeListener(carouselPageChangeListener);

this.clickLayout.setOnClickListener(
new CTInboxButtonClickListener(position, inboxMessage, null, parentWeak, this.imageViewPager));
new CTInboxButtonClickListener(position, inboxMessage, null, parentWeak, this.imageViewPager,true));

Runnable carouselRunnable = new Runnable() {
@Override
Expand All @@ -160,14 +160,12 @@ public void run() {
parentWeak.didShow(null, position);
}
}
carouselReadDot.setVisibility(View.GONE);
} else {
if (readDot.getVisibility() == View.VISIBLE) {
if (parentWeak != null) {
parentWeak.didShow(null, position);
}
}
readDot.setVisibility(View.GONE);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void addImageAndSetClick(ImageView imageView, View view, final int position, Vie
public void onClick(View v) {
CTInboxListViewFragment parent = getParent();
if (parent != null) {
parent.handleViewPagerClick(row, position);
parent.handleViewPagerClick(row, position,true);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void configureWithMessage(final CTInboxMessage inboxMessage, final CTInboxListVi
hideTwoButtons(this.cta1, this.cta2, this.cta3);
if (parentWeak != null) {
this.cta1.setOnClickListener(new CTInboxButtonClickListener(position, inboxMessage,
this.cta1.getText().toString(), cta1Object, parentWeak));
this.cta1.getText().toString(), cta1Object, parentWeak,false));
}
break;
case 2:
Expand All @@ -122,9 +122,9 @@ void configureWithMessage(final CTInboxMessage inboxMessage, final CTInboxListVi
hideOneButton(this.cta1, this.cta2, this.cta3);
if (parentWeak != null) {
this.cta1.setOnClickListener(new CTInboxButtonClickListener(position, inboxMessage,
this.cta1.getText().toString(), cta1Object, parentWeak));
this.cta1.getText().toString(), cta1Object, parentWeak,false));
this.cta2.setOnClickListener(new CTInboxButtonClickListener(position, inboxMessage,
this.cta2.getText().toString(), cta2Object, parentWeak));
this.cta2.getText().toString(), cta2Object, parentWeak,false));
}
break;
case 3:
Expand All @@ -145,11 +145,11 @@ void configureWithMessage(final CTInboxMessage inboxMessage, final CTInboxListVi
this.cta3.setBackgroundColor(Color.parseColor(content.getLinkBGColor(cta3Object)));
if (parentWeak != null) {
this.cta1.setOnClickListener(new CTInboxButtonClickListener(position, inboxMessage,
this.cta1.getText().toString(), cta1Object, parentWeak));
this.cta1.getText().toString(), cta1Object, parentWeak,false));
this.cta2.setOnClickListener(new CTInboxButtonClickListener(position, inboxMessage,
this.cta2.getText().toString(), cta2Object, parentWeak));
this.cta2.getText().toString(), cta2Object, parentWeak,false));
this.cta3.setOnClickListener(new CTInboxButtonClickListener(position, inboxMessage,
this.cta3.getText().toString(), cta3Object, parentWeak));
this.cta3.getText().toString(), cta3Object, parentWeak,false));
}
break;
}
Expand Down Expand Up @@ -387,7 +387,6 @@ public void run() {
if (readDot.getVisibility() == View.VISIBLE) {
parent.didShow(null, position);
}
readDot.setVisibility(View.GONE);
}
});
}
Expand Down Expand Up @@ -422,7 +421,7 @@ public void run() {

if (parentWeak != null) {
clickLayout.setOnClickListener(
new CTInboxButtonClickListener(position, inboxMessage, null, null, parentWeak));
new CTInboxButtonClickListener(position, inboxMessage, null, null, parentWeak,true));
}
}
}
Loading

0 comments on commit 4bd82f2

Please sign in to comment.