Skip to content

Commit

Permalink
Merge pull request #34 from CleverTap/3.6.1
Browse files Browse the repository at this point in the history
3.6.1
  • Loading branch information
kumaratulismu authored Oct 16, 2019
2 parents 3019372 + ce86ae8 commit bd23f47
Show file tree
Hide file tree
Showing 22 changed files with 4,526 additions and 4,283 deletions.
2 changes: 1 addition & 1 deletion AndroidStarter/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation (name: 'clevertap-android-sdk-3.6.0', ext: 'aar') //CleverTap Android SDK, make sure the AAR file is in the libs folder
implementation (name: 'clevertap-android-sdk-3.6.1', ext: 'aar') //CleverTap Android SDK, make sure the AAR file is in the libs folder
implementation 'com.google.firebase:firebase-messaging:17.3.0' //Needed for FCM
implementation 'com.google.android.gms:play-services-ads:15.0.1' //Needed to use Google Ad Ids
//ExoPlayer Libraries for Audio/Video InApp Notifications
Expand Down
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## CHANGE LOG

### Version 3.6.1 (October 16, 2019)
* Bug fixes and performance improvements

### Version 3.6.0 (September 25, 2019)
* Adds support for AB Tests. (in closed Beta)
* Adds support for deep link query parameters in InApps.
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@ For more information check out our [website](https://clevertap.com "CleverTap")

```markdown
dependencies {
implementation 'com.clevertap.android:clevertap-android-sdk:3.6.0'
implementation 'com.clevertap.android:clevertap-android-sdk:3.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:

```markdown
dependencies {
implementation (name: 'clevertap-android-sdk-3.6.0', ext: 'aar')
implementation (name: 'clevertap-android-sdk-3.6.1', ext: 'aar')
}
```

Then add the Firebase Messaging library and Android Support Library v4 as dependencies to your Module `build.gradle` file.

```markdown
dependencies {
implementation 'com.clevertap.android:clevertap-android-sdk:3.6.0'
implementation 'com.clevertap.android:clevertap-android-sdk:3.6.1'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.google.firebase:firebase-messaging:17.3.0'
implementation 'com.google.android.gms:play-services-ads:15.0.1' // Required only if you enable Google ADID collection in the SDK (turned off by default).
Expand Down
Binary file removed clevertap-android-sdk-3.6.0.aar
Binary file not shown.
Binary file added clevertap-android-sdk-3.6.1.aar
Binary file not shown.
2 changes: 1 addition & 1 deletion clevertap-android-sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ext {
siteUrl = 'https://github.com/CleverTap/clevertap-android-sdk'
gitUrl = 'https://github.com/CleverTap/clevertap-android-sdk.git'

libraryVersion = '3.6.0'
libraryVersion = '3.6.1'

developerId = 'clevertap'
developerName = 'CleverTap'
Expand Down
4 changes: 2 additions & 2 deletions clevertap-android-sdk/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.clevertap.android.sdk"
android:versionCode="30600"
android:versionName="3.6.0">
android:versionCode="30601"
android:versionName="3.6.1">
<application>
<receiver
android:name="com.clevertap.android.sdk.InstallReferrerBroadcastReceiver"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@
import android.view.View;

import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;

public abstract class CTInAppBaseFragment extends Fragment {

interface InAppListener {
void inAppNotificationDidShow(Context context, CTInAppNotification inAppNotification, Bundle formData);
void inAppNotificationDidClick(Context context, CTInAppNotification inAppNotification, Bundle formData);
void inAppNotificationDidDismiss(Context context, CTInAppNotification inAppNotification, Bundle formData);
void didClick(Bundle data, HashMap<String, String> keyValueMap) {
InAppListener listener = getListener();
if (listener != null) {
listener.inAppNotificationDidClick(getActivity().getBaseContext(), inAppNotification, data, keyValueMap);
}
}

CTInAppNotification inAppNotification;
Expand Down Expand Up @@ -68,10 +70,25 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
didShow(null);
}

void didClick(Bundle data) {
InAppListener listener = getListener();
if (listener != null) {
listener.inAppNotificationDidClick(getActivity().getBaseContext(),inAppNotification, data);
void handleButtonClickAtIndex(int index) {
try {
CTInAppNotificationButton button = inAppNotification.getButtons().get(index);
Bundle data = new Bundle();

data.putString(Constants.NOTIFICATION_ID_TAG, inAppNotification.getCampaignId());
data.putString(Constants.KEY_C2A, button.getText());

didClick(data, button.getKeyValues());

String actionUrl = button.getActionUrl();
if (actionUrl != null) {
fireUrlThroughIntent(actionUrl, data);
return;
}
didDismiss(data);
} catch (Throwable t) {
config.getLogger().debug("Error handling notification button click: " + t.getCause());
didDismiss(null);
}
}

Expand Down Expand Up @@ -117,25 +134,12 @@ int getScaledPixels(int raw) {
raw, getResources().getDisplayMetrics());
}

void handleButtonClickAtIndex(int index) {
try {
CTInAppNotificationButton button = inAppNotification.getButtons().get(index);
Bundle data = new Bundle();
interface InAppListener {
void inAppNotificationDidShow(Context context, CTInAppNotification inAppNotification, Bundle formData);

data.putString(Constants.NOTIFICATION_ID_TAG,inAppNotification.getCampaignId());
data.putString(Constants.KEY_C2A, button.getText());
didClick(data);
void inAppNotificationDidClick(Context context, CTInAppNotification inAppNotification, Bundle formData, HashMap<String, String> keyValueMap);

String actionUrl = button.getActionUrl();
if (actionUrl != null) {
fireUrlThroughIntent(actionUrl, data);
return;
}
didDismiss(data);
} catch (Throwable t) {
config.getLogger().debug("Error handling notification button click: " + t.getCause());
didDismiss(null);
}
void inAppNotificationDidDismiss(Context context, CTInAppNotification inAppNotification, Bundle formData);
}

class CTInAppNativeButtonClickListener implements View.OnClickListener{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) {
}
}

didClick(formData);
didClick(formData, null);
Logger.d("Executing call to action for in-app: " + url);
fireUrlThroughIntent(url,formData);
} catch (Throwable t) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) {
}
}

didClick(formData);
didClick(formData, null);
Logger.d("Executing call to action for in-app: " + url);
fireUrlThroughIntent(url,formData);
} catch (Throwable t) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.HashMap;
import java.util.Iterator;

class CTInAppNotificationButton implements Parcelable {

private String text;
Expand All @@ -18,6 +22,11 @@ class CTInAppNotificationButton implements Parcelable {
private String borderColor;
private String borderRadius;

private HashMap<String, String> keyValues;

CTInAppNotificationButton() {
}

String getText() {
return text;
}
Expand Down Expand Up @@ -88,10 +97,30 @@ void setBorderRadius(String borderRadius) {
this.borderRadius = borderRadius;
}

CTInAppNotificationButton(){}
@SuppressWarnings("unchecked")
protected CTInAppNotificationButton(Parcel in) {
text = in.readString();
textColor = in.readString();
backgroundColor = in.readString();
actionUrl = in.readString();
borderColor = in.readString();
borderRadius = in.readString();

try {
jsonDescription = in.readByte() == 0x00 ? null : new JSONObject(in.readString());
} catch (JSONException e) {
e.printStackTrace();
}
error = in.readString();
keyValues = in.readHashMap(null);
}

public HashMap<String, String> getKeyValues() {
return keyValues;
}

CTInAppNotificationButton initWithJSON(JSONObject jsonObject){
try{
CTInAppNotificationButton initWithJSON(JSONObject jsonObject) {
try {
this.jsonDescription = jsonObject;
this.text = jsonObject.has("text") ? jsonObject.getString("text") : "";
this.textColor = jsonObject.has("color") ? jsonObject.getString("color") : Constants.BLUE;
Expand All @@ -100,34 +129,36 @@ CTInAppNotificationButton initWithJSON(JSONObject jsonObject){
this.borderRadius = jsonObject.has("radius") ? jsonObject.getString("radius") : "";

JSONObject actions = jsonObject.has("actions") ? jsonObject.getJSONObject("actions") : null;
if(actions!=null){
if (actions != null) {
String action = actions.has("android") ? actions.getString("android") : "";
if(!action.isEmpty()){
if (!action.isEmpty()) {
this.actionUrl = action;
}
}
}catch (JSONException e){
if (actions != null && actions.has(Constants.KEY_KV)) {
JSONObject keyValues = actions.getJSONObject(Constants.KEY_KV);
if (keyValues != null) {
Iterator<String> keys = keyValues.keys();
if (keys != null) {
String key, value;
while (keys.hasNext()) {
key = keys.next();
value = keyValues.getString(key);
if (!TextUtils.isEmpty(key)) {
if (this.keyValues == null)
this.keyValues = new HashMap<>();
this.keyValues.put(key, value);
}
}
}
}
}
} catch (JSONException e) {
this.error = "Invalid JSON";
}
return this;
}

protected CTInAppNotificationButton(Parcel in) {
text = in.readString();
textColor = in.readString();
backgroundColor = in.readString();
actionUrl = in.readString();
borderColor = in.readString();
borderRadius = in.readString();

try {
jsonDescription = in.readByte() == 0x00 ? null : new JSONObject(in.readString());
} catch (JSONException e) {
e.printStackTrace();
}
error = in.readString();
}

@Override
public int describeContents() {
return 0;
Expand All @@ -149,6 +180,7 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeString(jsonDescription.toString());
}
dest.writeString(error);
dest.writeMap(keyValues);
}

@SuppressWarnings("unused")
Expand Down
Loading

0 comments on commit bd23f47

Please sign in to comment.