Skip to content

Commit

Permalink
Merge pull request #326 from CleverTap/develop
Browse files Browse the repository at this point in the history
Core 4.6.2 and push templates 1.0.5
  • Loading branch information
root-ansh-ct authored Sep 13, 2022
2 parents 4bd82f2 + c7bbc82 commit 8bdca67
Show file tree
Hide file tree
Showing 18 changed files with 135 additions and 104 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## CHANGE LOG.

### September 13, 2022
* [CleverTap Android SDK v4.6.2](https://github.com/CleverTap/clevertap-android-sdk/blob/master/docs/CTCORECHANGELOG.md)
* [CleverTap Push Templates SDK v1.0.5](https://github.com/CleverTap/clevertap-android-sdk/blob/master/docs/CTPUSHTEMPLATESCHANGELOG.md)


### September 6, 2022

* [CleverTap Android SDK v4.6.1](https://github.com/CleverTap/clevertap-android-sdk/blob/master/docs/CTCORECHANGELOG.md)
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,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.1"
implementation "com.clevertap.android:clevertap-android-sdk:4.6.2"
}
```

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.1", ext: 'aar')
implementation (name: "clevertap-android-sdk-4.6.2", ext: 'aar')
}
```

Expand All @@ -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.1"
implementation "com.clevertap.android:clevertap-android-sdk:4.6.2"
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 Down Expand Up @@ -88,9 +88,9 @@ apply plugin: 'com.google.gms.google-services'
Interstitial InApp Notification templates support Audio and Video with the help of ExoPlayer. To enable Audio/Video in your Interstitial InApp Notifications, add the following dependencies in your `build.gradle` file :

```groovy
implementation "com.google.android.exoplayer:exoplayer:2.15.1"
implementation "com.google.android.exoplayer:exoplayer-hls:2.15.1"
implementation "com.google.android.exoplayer:exoplayer-ui:2.15.1"
implementation "com.google.android.exoplayer:exoplayer:2.17.1"
implementation "com.google.android.exoplayer:exoplayer-hls:2.17.1"
implementation "com.google.android.exoplayer:exoplayer-ui:2.17.1"
```

Once you've updated your module `build.gradle` file, make sure you have specified `mavenCentral()` and `google()` as a repositories in your project `build.gradle` and then sync your project in File -> Sync Project with Gradle Files.
Expand Down
4 changes: 2 additions & 2 deletions clevertap-core/consumer-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
-keep class com.clevertap.android.hms.HmsPushProvider{*;}
-keep class com.google.firebase.messaging.FirebaseMessagingService{*;}
-keep class com.clevertap.android.sdk.pushnotification.CTNotificationIntentService{*;}
-keep class com.google.android.exoplayer2.SimpleExoPlayer{*;}
-keep class com.google.android.exoplayer2.ExoPlayer{*;}
-keep class com.google.android.exoplayer2.source.hls.HlsMediaSource{*;}
-keep class com.google.android.exoplayer2.ui.PlayerView{*;}
-keep class com.google.android.exoplayer2.ui.StyledPlayerView{*;}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient{*;}
-keep class com.google.android.gms.common.GooglePlayServicesUtil{*;}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -613,9 +613,10 @@ private static boolean checkForExoPlayer() {
boolean exoPlayerPresent = false;
Class className = null;
try {
className = Class.forName("com.google.android.exoplayer2.SimpleExoPlayer");
className = Class.forName("com.google.android.exoplayer2.ExoPlayer");
className = Class.forName("com.google.android.exoplayer2.source.hls.HlsMediaSource");
className = Class.forName("com.google.android.exoplayer2.ui.PlayerView");
className = Class.forName("com.google.android.exoplayer2.ui.StyledPlayerView");

Logger.d("ExoPlayer is present");
exoPlayerPresent = true;
} catch (Throwable t) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package com.clevertap.android.sdk.customviews;

import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Color;
Expand All @@ -18,26 +17,26 @@
import com.clevertap.android.sdk.R;
import com.clevertap.android.sdk.inbox.CTInboxActivity;
import com.clevertap.android.sdk.inbox.CTInboxBaseMessageViewHolder;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import com.google.android.exoplayer2.trackselection.ExoTrackSelection;
import com.google.android.exoplayer2.trackselection.TrackSelector;
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
import com.google.android.exoplayer2.ui.PlayerView;
import com.google.android.exoplayer2.ui.StyledPlayerView;

@RestrictTo(Scope.LIBRARY)
public class MediaPlayerRecyclerView extends RecyclerView {

SimpleExoPlayer player;
ExoPlayer player;

private Context appContext;

private CTInboxBaseMessageViewHolder playingHolder;

//surface view for playing video
private PlayerView videoSurfaceView;
private StyledPlayerView videoSurfaceView;

/**
* {@inheritDoc}
Expand Down Expand Up @@ -125,6 +124,7 @@ public void release() {
videoSurfaceView = null;
}

@SuppressWarnings("unused")
public void removePlayer() {
if (videoSurfaceView != null) {
removeVideoView();
Expand Down Expand Up @@ -172,7 +172,7 @@ private CTInboxBaseMessageViewHolder findBestVisibleMediaHolder() {

private void initialize(Context context) {
appContext = context.getApplicationContext();
videoSurfaceView = new PlayerView(appContext);
videoSurfaceView = new StyledPlayerView(appContext);
videoSurfaceView.setBackgroundColor(Color.TRANSPARENT);
if (CTInboxActivity.orientation == Configuration.ORIENTATION_LANDSCAPE) {
videoSurfaceView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FILL);
Expand All @@ -188,7 +188,7 @@ private void initialize(Context context) {
TrackSelector trackSelector =
new DefaultTrackSelector(appContext, videoTrackSelectionFactory);

player = new SimpleExoPlayer.Builder(context).setTrackSelector(trackSelector).build();
player = new ExoPlayer.Builder(context).setTrackSelector(trackSelector).build();
player.setVolume(0f); // start off muted
videoSurfaceView.setUseController(true);
videoSurfaceView.setControllerAutoShow(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.clevertap.android.sdk.inapp;

import static com.google.android.exoplayer2.ui.PlayerView.SHOW_BUFFERING_WHEN_PLAYING;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.util.TypedValue;
Expand All @@ -24,6 +24,7 @@
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
Expand All @@ -32,18 +33,20 @@
import com.clevertap.android.sdk.R;
import com.clevertap.android.sdk.customviews.CloseImageView;
import com.clevertap.android.sdk.gif.GifImageView;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.source.hls.HlsMediaSource;
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import com.google.android.exoplayer2.trackselection.ExoTrackSelection;
import com.google.android.exoplayer2.trackselection.TrackSelector;
import com.google.android.exoplayer2.ui.PlayerView;
import com.google.android.exoplayer2.ui.StyledPlayerView;
import com.google.android.exoplayer2.upstream.BandwidthMeter;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
import com.google.android.exoplayer2.upstream.DefaultDataSource;
import com.google.android.exoplayer2.upstream.DefaultHttpDataSource;
import com.google.android.exoplayer2.upstream.TransferListener;
import com.google.android.exoplayer2.util.Util;
import java.util.ArrayList;
Expand All @@ -60,9 +63,9 @@ public class CTInAppNativeInterstitialFragment extends CTInAppBaseFullNativeFrag

private GifImageView gifImageView;

private SimpleExoPlayer player;
private ExoPlayer player;

private PlayerView playerView;
private StyledPlayerView playerView;

private RelativeLayout relativeLayout;

Expand All @@ -73,15 +76,15 @@ public class CTInAppNativeInterstitialFragment extends CTInAppBaseFullNativeFrag
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
Bundle savedInstanceState) {
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {

ArrayList<Button> inAppButtons = new ArrayList<>();

View inAppView;
if (inAppNotification.isTablet() && isTablet()) {
inAppView = inflater.inflate(R.layout.tab_inapp_interstitial, container, false);
} else {
}
else {
inAppView = inflater.inflate(R.layout.inapp_interstitial, container, false);
}

Expand Down Expand Up @@ -213,16 +216,13 @@ public void onGlobalLayout() {

fl.setBackground(new ColorDrawable(0xBB000000));

closeImageView.setOnClickListener(new View.OnClickListener() {
@SuppressWarnings("ConstantConditions")
@Override
public void onClick(View v) {
didDismiss(null);
if (gifImageView != null) {
gifImageView.clear();
}
getActivity().finish();
closeImageView.setOnClickListener(v -> {
didDismiss(null);
if (gifImageView != null) {
gifImageView.clear();
}
Activity activity = getActivity();
if(activity!=null) activity.finish();
});

if (!inAppNotification.isHideCloseButton()) {
Expand All @@ -247,8 +247,7 @@ public void onStart() {
public void onResume() {
super.onResume();
if (!inAppNotification.getMediaList().isEmpty()) {
if (player == null && (inAppNotification.getMediaList().get(0).isVideo() || inAppNotification
.getMediaList().get(0).isAudio())) {
if (player == null && (inAppNotification.getMediaList().get(0).isVideo() || inAppNotification.getMediaList().get(0).isAudio())) {
prepareMedia();
playMedia();
}
Expand Down Expand Up @@ -339,8 +338,7 @@ private void openFullscreenDialog() {
((ViewGroup) playerView.getParent()).removeView(playerView);
((ViewGroup) fullScreenIcon.getParent()).removeView(fullScreenIcon);
((ViewGroup) videoFrameLayout.getParent()).removeView(videoFrameLayout);
fullScreenDialog.addContentView(playerView,
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
fullScreenDialog.addContentView(playerView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
exoPlayerFullscreen = true;
fullScreenDialog.show();
}
Expand All @@ -356,18 +354,15 @@ private void prepareMedia() {
videoFrameLayout = relativeLayout.findViewById(R.id.video_frame);
videoFrameLayout.setVisibility(View.VISIBLE);

playerView = new PlayerView(this.context);
playerView = new StyledPlayerView(this.context);
fullScreenIcon = new ImageView(this.context);
fullScreenIcon.setImageDrawable(
ResourcesCompat.getDrawable(this.context.getResources(), R.drawable.ct_ic_fullscreen_expand, null));
fullScreenIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!exoPlayerFullscreen) {
openFullscreenDialog();
} else {
closeFullscreenDialog();
}
fullScreenIcon.setOnClickListener(v -> {
if (!exoPlayerFullscreen) {
openFullscreenDialog();
} else {
closeFullscreenDialog();
}
});
if (inAppNotification.isTablet() && isTablet()) {
Expand Down Expand Up @@ -410,7 +405,7 @@ public void onClick(View v) {
layoutParams.setMargins(0, iconTop, iconRight, 0);
fullScreenIcon.setLayoutParams(layoutParams);
}
playerView.setShowBuffering(SHOW_BUFFERING_WHEN_PLAYING);
playerView.setShowBuffering(StyledPlayerView.SHOW_BUFFERING_WHEN_PLAYING);
playerView.setUseArtwork(true);
playerView.setControllerAutoShow(false);
videoFrameLayout.addView(playerView);
Expand All @@ -424,16 +419,19 @@ public void onClick(View v) {
TrackSelector trackSelector = new DefaultTrackSelector(this.context,
videoTrackSelectionFactory);
// 2. Create the player
player = new SimpleExoPlayer.Builder(this.context).setTrackSelector(trackSelector).build();
player = new ExoPlayer.Builder(this.context).setTrackSelector(trackSelector).build();
// 3. Produces DataSource instances through which media data is loaded.
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this.context,
Util.getUserAgent(this.context, this.context.getApplicationContext().getPackageName()),
(TransferListener) bandwidthMeter);
HlsMediaSource hlsMediaSource;
hlsMediaSource = new HlsMediaSource.Factory(dataSourceFactory)
.createMediaSource(Uri.parse(inAppNotification.getMediaList().get(0).getMediaUrl()));
Context ctx = this.context;
String userAgent = Util.getUserAgent(ctx,ctx.getPackageName());
String url = inAppNotification.getMediaList().get(0).getMediaUrl();
TransferListener listener = bandwidthMeter.getTransferListener();
DefaultHttpDataSource.Factory dsf = new DefaultHttpDataSource.Factory().setUserAgent(userAgent).setTransferListener(listener);
DataSource.Factory dataSourceFactory = new DefaultDataSource.Factory(ctx,dsf);
MediaItem mediaItem = MediaItem.fromUri(url);
HlsMediaSource hlsMediaSource = new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(mediaItem);
player.setMediaSource(hlsMediaSource);
// 4. Prepare the player with the source.
player.prepare(hlsMediaSource);
player.prepare();
player.setRepeatMode(Player.REPEAT_MODE_ONE);
player.seekTo(mediaPosition);
}
Expand Down
Loading

0 comments on commit 8bdca67

Please sign in to comment.