Skip to content

Commit 2cd963b

Browse files
Merge pull request #39 from cometchat-pro/v3
V3
2 parents 69930da + 3218863 commit 2cd963b

File tree

6 files changed

+49
-20
lines changed

6 files changed

+49
-20
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 30
4+
compileSdkVersion 32
55
defaultConfig {
66
applicationId "com.cometchat.pro.androiduikit"
77
minSdkVersion 24
8-
targetSdkVersion 30
8+
targetSdkVersion 32
99
versionCode 1
1010
renderscriptSupportModeEnabled true
1111
multiDexEnabled true

app/src/main/java/com/cometchat/pro/androiduikit/constants/AppConfig.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public class AppDetails {
99
public static final String AUTH_KEY = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
1010

1111
public static final String REGION = "XX";
12+
1213
}
1314
}
1415

uikit/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
apply plugin: 'com.android.library'
22
android {
3-
compileSdkVersion 30
3+
compileSdkVersion 32
44

55
defaultConfig {
66
minSdkVersion 21
7-
targetSdkVersion 30
7+
targetSdkVersion 32
88
versionCode 1
9-
versionName "3.0.9-2"
9+
versionName "3.0.9-3"
1010
multiDexEnabled true
1111
vectorDrawables.useSupportLibrary = true
1212
renderscriptSupportModeEnabled true
@@ -90,7 +90,7 @@ dependencies {
9090
implementation 'com.google.android.gms:play-services-location:17.0.0'
9191
implementation 'com.google.android.gms:play-services-maps:17.0.0'
9292
//cometchat
93-
compileOnly 'com.cometchat:pro-android-chat-sdk:3.0.9'
94-
compileOnly 'com.cometchat:pro-android-calls-sdk:2.2.0'
93+
implementation 'com.cometchat:pro-android-chat-sdk:3.0.9'
94+
implementation 'com.cometchat:pro-android-calls-sdk:2.2.0'
9595
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.0'
9696
}

uikit/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@
136136

137137
<service
138138
android:name=".ui_components.calls.call_manager.ongoing_call.OngoingCallService"
139+
android:exported="true"
139140
android:enabled="true" />
140141
</application>
141142

uikit/src/main/java/com/cometchat/pro/uikit/ui_components/calls/call_manager/CometChatStartCallActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ protected void onCreate(Bundle savedInstanceState) {
8787
if (type!=null && type.equalsIgnoreCase(CometChatConstants.RECEIVER_TYPE_USER))
8888
callSettings = new CallSettings.CallSettingsBuilder(this,mainView)
8989
.setSessionId(sessionID)
90-
.setMode(CallSettings.MODE_SINGLE)
90+
.setMode(CallSettings.MODE_DEFAULT)
9191
.build();
9292
else
9393
callSettings = new CallSettings.CallSettingsBuilder(this,mainView)

uikit/src/main/java/com/cometchat/pro/uikit/ui_components/calls/call_manager/ongoing_call/OngoingCallService.java

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.app.NotificationManager;
55
import android.app.PendingIntent;
66
import android.app.Service;
7+
import android.app.TaskStackBuilder;
78
import android.content.Context;
89
import android.content.Intent;
910
import android.os.Build;
@@ -15,6 +16,7 @@
1516

1617
import com.cometchat.pro.core.CometChat;
1718
import com.cometchat.pro.uikit.R;
19+
import com.cometchat.pro.uikit.ui_components.calls.call_manager.CometChatStartCallActivity;
1820
import com.cometchat.pro.uikit.ui_components.cometchat_ui.CometChatUI;
1921
import com.cometchat.pro.uikit.ui_resources.constants.UIKitConstants;
2022

@@ -27,13 +29,14 @@ public class OngoingCallService extends Service {
2729
private int counter = 0;
2830

2931
NotificationManager notificationManager;
32+
3033
@Override
3134
public void onCreate() {
3235
super.onCreate();
3336
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O)
3437
startMyOwnForeground();
3538
else
36-
this.startForeground(1,new Notification());
39+
this.startForeground(1, new Notification());
3740
}
3841

3942
@Nullable
@@ -46,12 +49,35 @@ private void startMyOwnForeground() {
4649
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
4750
notificationManager.cancel(2);
4851
PendingIntent pendingIntent = null;
49-
if (CometChat.getActiveCall()!=null) {
50-
pendingIntent = PendingIntent.getBroadcast(getApplicationContext(),REQUEST_CODE,
51-
getCallIntent("Ongoing"),
52-
PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT);
52+
if (CometChat.getActiveCall() != null) {
53+
if (Build.VERSION.SDK_INT >= 31) {
54+
Intent joinOngoingIntent =
55+
new Intent(getApplicationContext(), CometChatStartCallActivity.class);
56+
joinOngoingIntent.putExtra(
57+
UIKitConstants.IntentStrings.SESSION_ID,
58+
CometChat.getActiveCall().getSessionId()
59+
);
60+
joinOngoingIntent.putExtra(
61+
UIKitConstants.IntentStrings.TYPE,
62+
CometChat.getActiveCall().getType()
63+
);
64+
joinOngoingIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
65+
66+
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
67+
stackBuilder.addNextIntent(joinOngoingIntent);
68+
pendingIntent= stackBuilder.getPendingIntent(
69+
REQUEST_CODE,
70+
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE
71+
);
72+
73+
} else {
74+
pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), REQUEST_CODE,
75+
getCallIntent("Ongoing"),
76+
PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT);
77+
}
5378
}
54-
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this,"2");
79+
Log.e("", "startMyOwnForeground: "+pendingIntent);
80+
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, "2");
5581
Notification notification = notificationBuilder.setOngoing(true)
5682
.setSmallIcon(R.drawable.cc)
5783
.setColor(getResources().getColor(R.color.colorPrimary))
@@ -60,13 +86,13 @@ private void startMyOwnForeground() {
6086
.setContentIntent(pendingIntent)
6187
.setCategory(Notification.CATEGORY_CALL)
6288
.build();
63-
startForeground(1,notification);
89+
startForeground(1, notification);
6490
}
6591

6692
private Intent getCallIntent(String title) {
6793
Intent callIntent;
68-
if (CometChat.getActiveCall()!=null) {
69-
callIntent = new Intent(getApplicationContext(),OngoingCallBroadcast.class);
94+
if (CometChat.getActiveCall() != null) {
95+
callIntent = new Intent(getApplicationContext(), OngoingCallBroadcast.class);
7096
callIntent.putExtra(UIKitConstants.IntentStrings.SESSION_ID, CometChat.getActiveCall().getSessionId());
7197
callIntent.putExtra(UIKitConstants.IntentStrings.TYPE, CometChat.getActiveCall().getType());
7298
callIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -101,21 +127,22 @@ public boolean stopService(Intent name) {
101127

102128
private Timer timer;
103129
private TimerTask timerTask;
130+
104131
public void startTimer() {
105132
timer = new Timer();
106133
timerTask = new TimerTask() {
107134
@Override
108135
public void run() {
109-
Log.d("AppInBackground: ",""+ counter++ );
136+
Log.d("AppInBackground: ", "" + counter++);
110137
}
111138
};
112139
timer.schedule(timerTask, 1000, 1000);
113140
}
114141

115142
public void stopTimer() {
116-
if (timer!=null) {
143+
if (timer != null) {
117144
timer.cancel();
118145
timer = null;
119146
}
120147
}
121-
}
148+
}

0 commit comments

Comments
 (0)