diff --git a/CHANGELOG.md b/CHANGELOG.md index c7fb695b1..5c0955969 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ ## CHANGE LOG. +### October 31, 2022 +* [CleverTap Android SDK v4.6.6](https://github.com/CleverTap/clevertap-android-sdk/blob/master/docs/CTCORECHANGELOG.md) + ### October 21, 2022 * [CleverTap Android SDK v4.6.5](https://github.com/CleverTap/clevertap-android-sdk/blob/master/docs/CTCORECHANGELOG.md) diff --git a/README.md b/README.md index 8bbef7a5e..c274af797 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ 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.5" + implementation "com.clevertap.android:clevertap-android-sdk:4.6.6" } ``` @@ -34,7 +34,7 @@ Alternatively, you can download and add the AAR file included in this repo in yo ```groovy dependencies { - implementation (name: "clevertap-android-sdk-4.6.5", ext: 'aar') + implementation (name: "clevertap-android-sdk-4.6.6", ext: 'aar') } ``` @@ -46,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.5" + implementation "com.clevertap.android:clevertap-android-sdk:4.6.6" 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). diff --git a/clevertap-core/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java b/clevertap-core/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java index 1eede6a62..800f3243c 100644 --- a/clevertap-core/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java +++ b/clevertap-core/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java @@ -1861,11 +1861,13 @@ public void messageDidClick(CTInboxActivity ctInboxActivity, CTInboxMessage inbo coreState.getAnalyticsManager().pushInboxMessageStateEvent(true, inboxMessage, data); if (keyValue != null && !keyValue.isEmpty()) { + Logger.v("clicked button of an inbox notification."); if (inboxMessageButtonListener != null && inboxMessageButtonListener.get() != null) { inboxMessageButtonListener.get().onInboxButtonClick(keyValue); } } else{ + Logger.v("clicked inbox notification."); if (isBodyClick && inboxMessageListener != null && inboxMessageListener.get() != null) { inboxMessageListener.get().onInboxItemClicked(inboxMessage); } diff --git a/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTCarouselImageViewHolder.java b/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTCarouselImageViewHolder.java index df297c6af..1f73ba0da 100644 --- a/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTCarouselImageViewHolder.java +++ b/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTCarouselImageViewHolder.java @@ -1,9 +1,7 @@ package com.clevertap.android.sdk.inbox; -import android.app.Activity; import android.content.Context; import android.graphics.Color; -import android.os.Handler; import android.view.View; import android.widget.ImageView; import android.widget.LinearLayout; @@ -60,8 +58,6 @@ public void onPageSelected(int position) { } } - private final ImageView carouselReadDot; - private final TextView carouselTimestamp; private final RelativeLayout clickLayout; @@ -75,7 +71,6 @@ public void onPageSelected(int position) { imageViewPager = itemView.findViewById(R.id.image_carousel_viewpager); sliderDots = itemView.findViewById(R.id.sliderDots); carouselTimestamp = itemView.findViewById(R.id.carousel_timestamp); - carouselReadDot = itemView.findViewById(R.id.carousel_read_circle); clickLayout = itemView.findViewById(R.id.body_linear_layout); } @@ -89,9 +84,9 @@ void configureWithMessage(final CTInboxMessage inboxMessage, final CTInboxListVi CTInboxMessageContent content = inboxMessage.getInboxMessageContents().get(0); this.carouselTimestamp.setVisibility(View.VISIBLE); if (inboxMessage.isRead()) { - this.carouselReadDot.setVisibility(View.GONE); + this.readDot.setVisibility(View.GONE); } else { - this.carouselReadDot.setVisibility(View.VISIBLE); + this.readDot.setVisibility(View.VISIBLE); } String carouselImageDisplayTimestamp = calculateDisplayTimestamp(inboxMessage.getDate()); this.carouselTimestamp.setText(carouselImageDisplayTimestamp); @@ -121,26 +116,6 @@ void configureWithMessage(final CTInboxMessage inboxMessage, final CTInboxListVi this.clickLayout.setOnClickListener( new CTInboxButtonClickListener(position, inboxMessage, null, parentWeak, this.imageViewPager,true)); - Runnable carouselRunnable = new Runnable() { - @Override - public void run() { - Activity activity = parent.getActivity(); - if (activity == null) { - return; - } - activity.runOnUiThread(new Runnable() { - @Override - public void run() { - if (carouselReadDot.getVisibility() == View.VISIBLE) { - if (parentWeak != null) { - parentWeak.didShow(null, position); - } - } - } - }); - } - }; - Handler carouselHandler = new Handler(); - carouselHandler.postDelayed(carouselRunnable, 2000); + markItemAsRead(inboxMessage, position); } } diff --git a/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTCarouselMessageViewHolder.java b/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTCarouselMessageViewHolder.java index a93ac9f81..907871772 100644 --- a/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTCarouselMessageViewHolder.java +++ b/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTCarouselMessageViewHolder.java @@ -1,9 +1,7 @@ package com.clevertap.android.sdk.inbox; -import android.app.Activity; import android.content.Context; import android.graphics.Color; -import android.os.Handler; import android.view.View; import android.widget.ImageView; import android.widget.LinearLayout; @@ -72,9 +70,6 @@ public void onPageSelected(int position) { private final CTCarouselViewPager imageViewPager; - private final ImageView readDot; - - private ImageView carouselReadDot; private final LinearLayout sliderDots; @@ -93,7 +88,6 @@ public void onPageSelected(int position) { title = itemView.findViewById(R.id.messageTitle); message = itemView.findViewById(R.id.messageText); timestamp = itemView.findViewById(R.id.timestamp); - readDot = itemView.findViewById(R.id.read_circle); clickLayout = itemView.findViewById(R.id.body_linear_layout); } @@ -144,34 +138,6 @@ void configureWithMessage(final CTInboxMessage inboxMessage, final CTInboxListVi this.clickLayout.setOnClickListener( new CTInboxButtonClickListener(position, inboxMessage, null, parentWeak, this.imageViewPager,true)); - Runnable carouselRunnable = new Runnable() { - @Override - public void run() { - Activity activity = parent.getActivity(); - if (activity == null) { - return; - } - activity.runOnUiThread(new Runnable() { - @Override - public void run() { - if (inboxMessage.getType() == CTInboxMessageType.CarouselImageMessage) { - if (carouselReadDot.getVisibility() == View.VISIBLE) { - if (parentWeak != null) { - parentWeak.didShow(null, position); - } - } - } else { - if (readDot.getVisibility() == View.VISIBLE) { - if (parentWeak != null) { - parentWeak.didShow(null, position); - } - } - } - } - }); - } - }; - Handler carouselHandler = new Handler(); - carouselHandler.postDelayed(carouselRunnable, 2000); + markItemAsRead(inboxMessage, position); } } diff --git a/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTIconMessageViewHolder.java b/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTIconMessageViewHolder.java index 0308598b8..a27864b16 100644 --- a/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTIconMessageViewHolder.java +++ b/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTIconMessageViewHolder.java @@ -1,10 +1,8 @@ package com.clevertap.android.sdk.inbox; -import android.app.Activity; import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Color; -import android.os.Handler; import android.view.View; import android.widget.Button; import android.widget.ImageView; @@ -37,8 +35,6 @@ class CTIconMessageViewHolder extends CTInboxBaseMessageViewHolder { private final LinearLayout ctaLinearLayout; - private final ImageView readDot; - private final ImageView iconImage; private final TextView title; @@ -54,7 +50,6 @@ class CTIconMessageViewHolder extends CTInboxBaseMessageViewHolder { message = itemView.findViewById(R.id.messageText); mediaImage = itemView.findViewById(R.id.media_image); iconImage = itemView.findViewById(R.id.image_icon); - readDot = itemView.findViewById(R.id.read_circle); timestamp = itemView.findViewById(R.id.timestamp); cta1 = itemView.findViewById(R.id.cta_button_1); cta2 = itemView.findViewById(R.id.cta_button_2); @@ -372,28 +367,8 @@ void configureWithMessage(final CTInboxMessage inboxMessage, final CTInboxListVi this.progressBarFrameLayout.setLayoutParams(new RelativeLayout.LayoutParams(width, height)); //New thread to remove the Read dot, mark message as read and raise Notification Viewed - Runnable iconRunnable = new Runnable() { - @Override - public void run() { - final CTInboxListViewFragment parent = getParent(); - if (parent != null) { - Activity activity = parent.getActivity(); - if (activity == null) { - return; - } - activity.runOnUiThread(new Runnable() { - @Override - public void run() { - if (readDot.getVisibility() == View.VISIBLE) { - parent.didShow(null, position); - } - } - }); - } - } - }; - Handler iconHandler = new Handler(); - iconHandler.postDelayed(iconRunnable, 2000); + markItemAsRead(inboxMessage, position); + try { if (!content.getIcon().isEmpty()) { iconImage.setVisibility(View.VISIBLE); diff --git a/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTInboxActivity.java b/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTInboxActivity.java index 546a50132..78c36c3b5 100644 --- a/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTInboxActivity.java +++ b/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTInboxActivity.java @@ -33,7 +33,7 @@ * This activity shows the {@link CTInboxMessage} objects as per {@link CTInboxStyleConfig} style parameters */ @RestrictTo(Scope.LIBRARY) -public class CTInboxActivity extends FragmentActivity implements CTInboxListViewFragment.InboxListener, CTInboxListener { +public class CTInboxActivity extends FragmentActivity implements CTInboxListViewFragment.InboxListener { public interface InboxActivityListener { @@ -57,7 +57,6 @@ void messageDidClick(CTInboxActivity ctInboxActivity, CTInboxMessage inboxMessag private WeakReference listenerWeakReference; private CleverTapAPI cleverTapAPI; - private CTInboxListener inboxContentUpdatedListener = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -74,8 +73,6 @@ public void onCreate(Bundle savedInstanceState) { cleverTapAPI = CleverTapAPI.instanceWithConfig(getApplicationContext(), config); if (cleverTapAPI != null) { setListener(cleverTapAPI); - inboxContentUpdatedListener = cleverTapAPI.getCTNotificationInboxListener(); - cleverTapAPI.setCTNotificationInboxListener(this); } orientation = getResources().getConfiguration().orientation; } catch (Throwable t) { @@ -179,7 +176,6 @@ public void onTabReselected(TabLayout.Tab tab) { public void onTabSelected(TabLayout.Tab tab) { CTInboxListViewFragment fragment = (CTInboxListViewFragment) inboxTabAdapter .getItem(tab.getPosition()); - fragment.updateAdapterContent(); if (fragment.getMediaRecyclerView() != null) { fragment.getMediaRecyclerView().onRestartPlayer(); } @@ -213,54 +209,6 @@ protected void onDestroy() { } - @Override - public void inboxDidInitialize() { - - Logger.d("CTInboxActivity: called inboxDidInitialize"); - if(inboxContentUpdatedListener !=null) { - inboxContentUpdatedListener.inboxDidInitialize(); - } - - - } - - @Override - public void inboxMessagesDidUpdate() { - Logger.v("CTInboxActivity|inboxMessagesDidUpdate called"); - try { - boolean isCUListenerAvailable = inboxContentUpdatedListener != null; - Logger.v("CTInboxActivity|inboxMessagesDidUpdate: inboxContentUpdatedListener available:" + isCUListenerAvailable); - - boolean isUsingMultipleTabs = styleConfig.isUsingTabs(); - Logger.v("CTInboxActivity|inboxMessagesDidUpdate: isUsingMultipleTabs : " + isUsingMultipleTabs); - - if (isCUListenerAvailable) { - inboxContentUpdatedListener.inboxMessagesDidUpdate(); - } - if (isUsingMultipleTabs) { - int position = viewPager.getCurrentItem(); - CTInboxListViewFragment fragment = (CTInboxListViewFragment) inboxTabAdapter.getItem(position); - fragment.updateAdapterContent(); - } - else { - List fragments = getSupportFragmentManager().getFragments(); - String singleTabTag = getFragmentTag(); - for (Fragment f : fragments) { - String currentFTag = f.getTag(); - if (f instanceof CTInboxListViewFragment && currentFTag != null && currentFTag.equalsIgnoreCase(singleTabTag)) { - ((CTInboxListViewFragment) f).updateAdapterContent(); - } - } - - } - - } catch (Throwable t) { - Logger.i("Something Went Wrong", t); - } - - - } - @Override public void messageDidClick(Context baseContext, CTInboxMessage inboxMessage, Bundle data, HashMap keyValue, boolean isBodyClick) { diff --git a/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTInboxBaseMessageViewHolder.java b/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTInboxBaseMessageViewHolder.java index abc93376b..810190d14 100644 --- a/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTInboxBaseMessageViewHolder.java +++ b/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTInboxBaseMessageViewHolder.java @@ -1,10 +1,12 @@ package com.clevertap.android.sdk.inbox; import android.annotation.SuppressLint; +import android.app.Activity; import android.content.Context; import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Color; +import android.os.Handler; import android.util.DisplayMetrics; import android.util.TypedValue; import android.view.Gravity; @@ -15,13 +17,11 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.RelativeLayout; - import androidx.annotation.NonNull; import androidx.annotation.RestrictTo; import androidx.annotation.RestrictTo.Scope; import androidx.core.content.res.ResourcesCompat; import androidx.recyclerview.widget.RecyclerView; - import com.clevertap.android.sdk.R; import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.MediaItem; @@ -63,8 +63,11 @@ public class CTInboxBaseMessageViewHolder extends RecyclerView.ViewHolder { private boolean requiresMediaPlayer; + protected final ImageView readDot; + CTInboxBaseMessageViewHolder(@NonNull View itemView) { super(itemView); + readDot = itemView.findViewById(R.id.read_circle); } public boolean addMediaPlayer(StyledPlayerView videoSurfaceView) { @@ -306,4 +309,32 @@ public boolean shouldAutoPlay() { private FrameLayout getLayoutForMediaPlayer() { return frameLayout; } + + protected void markItemAsRead(final CTInboxMessage inboxMessage, + final int position) { + Runnable runnable = new Runnable() { + @Override + public void run() { + final CTInboxListViewFragment parent = getParent(); + if (parent != null) { + Activity activity = parent.getActivity(); + if (activity == null) { + return; + } + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + if (readDot.getVisibility() == View.VISIBLE) { + parent.didShow(null, position); + } + readDot.setVisibility(View.GONE); + inboxMessage.setRead(true); + } + }); + } + } + }; + Handler handler = new Handler(); + handler.postDelayed(runnable, 2000); + } } diff --git a/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTInboxListViewFragment.java b/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTInboxListViewFragment.java index 291e0f805..e293fb42d 100644 --- a/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTInboxListViewFragment.java +++ b/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTInboxListViewFragment.java @@ -95,12 +95,6 @@ private void updateInboxMessages(){ } } - void updateAdapterContent(){ - updateInboxMessages(); - if(inboxMessageAdapter==null || inboxMessages==null || config ==null ) return; - inboxMessageAdapter.updateInboxMessages(inboxMessages); - } - @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, diff --git a/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTInboxMessage.java b/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTInboxMessage.java index 4f0d0d8cc..1cf76c165 100644 --- a/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTInboxMessage.java +++ b/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTInboxMessage.java @@ -81,7 +81,6 @@ public CTInboxMessage(JSONObject jsonObject) { this.expires = jsonObject.has(Constants.KEY_WZRK_TTL) ? jsonObject.getLong(Constants.KEY_WZRK_TTL) : System.currentTimeMillis() + 1000 * 60 * 60 * 24; this.isRead = jsonObject.has(Constants.KEY_IS_READ) && jsonObject.getBoolean(Constants.KEY_IS_READ); - Logger.d("CTInboxMessage:"+"constructor called at "+new Date()+" | setting inbox isread= "+isRead() +" for id:"+messageId ); JSONArray tagsArray = jsonObject.has(Constants.KEY_TAGS) ? jsonObject.getJSONArray(Constants.KEY_TAGS) : null; if (tagsArray != null) { diff --git a/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTInboxMessageAdapter.java b/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTInboxMessageAdapter.java index 416f2610f..9f6ea2f42 100644 --- a/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTInboxMessageAdapter.java +++ b/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTInboxMessageAdapter.java @@ -28,17 +28,11 @@ class CTInboxMessageAdapter extends RecyclerView.Adapter { private ArrayList inboxMessages; CTInboxMessageAdapter(ArrayList inboxMessages, CTInboxListViewFragment fragment) { - Logger.v( "CTInboxMessageAdapter: called at "+new Date()); Logger.v("CTInboxMessageAdapter: messages="+inboxMessages); this.inboxMessages = inboxMessages; this.fragment = fragment; } - protected synchronized void updateInboxMessages(ArrayList newList) { - this.inboxMessages.clear(); - this.inboxMessages.addAll(newList); - this.notifyDataSetChanged(); - } @Override public int getItemCount() { diff --git a/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTSimpleMessageViewHolder.java b/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTSimpleMessageViewHolder.java index afdf6a0c8..a64b9d3bd 100644 --- a/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTSimpleMessageViewHolder.java +++ b/clevertap-core/src/main/java/com/clevertap/android/sdk/inbox/CTSimpleMessageViewHolder.java @@ -1,10 +1,8 @@ package com.clevertap.android.sdk.inbox; -import android.app.Activity; import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Color; -import android.os.Handler; import android.view.View; import android.widget.Button; import android.widget.ImageView; @@ -35,8 +33,6 @@ class CTSimpleMessageViewHolder extends CTInboxBaseMessageViewHolder { private final TextView message; - private final ImageView readDot; - private final TextView timestamp; private final TextView title; @@ -47,7 +43,6 @@ class CTSimpleMessageViewHolder extends CTInboxBaseMessageViewHolder { title = itemView.findViewById(R.id.messageTitle); message = itemView.findViewById(R.id.messageText); timestamp = itemView.findViewById(R.id.timestamp); - readDot = itemView.findViewById(R.id.read_circle); cta1 = itemView.findViewById(R.id.cta_button_1); cta2 = itemView.findViewById(R.id.cta_button_2); cta3 = itemView.findViewById(R.id.cta_button_3); @@ -363,29 +358,8 @@ void configureWithMessage(final CTInboxMessage inboxMessage, final CTInboxListVi this.progressBarFrameLayout.setLayoutParams(new RelativeLayout.LayoutParams(width, height)); //New thread to remove the Read dot, mark message as read and raise Notification Viewed - Runnable simpleRunnable = new Runnable() { - @Override - public void run() { - final CTInboxListViewFragment parent = getParent(); - if (parent != null) { - Activity activity = parent.getActivity(); - if (activity == null) { - return; - } - activity.runOnUiThread(new Runnable() { - @Override - public void run() { - if (readDot.getVisibility() == View.VISIBLE) { - parent.didShow(null, position); - } - } - }); - } + markItemAsRead(inboxMessage, position); - } - }; - Handler simpleHandler = new Handler(); - simpleHandler.postDelayed(simpleRunnable, 2000); if (parentWeak != null) { this.clickLayout.setOnClickListener( new CTInboxButtonClickListener(position, inboxMessage, null, null, parentWeak,true)); diff --git a/clevertap-core/src/main/res/layout-land/inbox_carousel_layout.xml b/clevertap-core/src/main/res/layout-land/inbox_carousel_layout.xml index 402a09edc..ba374558a 100644 --- a/clevertap-core/src/main/res/layout-land/inbox_carousel_layout.xml +++ b/clevertap-core/src/main/res/layout-land/inbox_carousel_layout.xml @@ -52,7 +52,7 @@ android:textColor="@android:color/darker_gray" />