Skip to content

Commit 59c3071

Browse files
v4.0.2
1 parent 0279ea9 commit 59c3071

2 files changed

Lines changed: 49 additions & 5 deletions

File tree

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,67 @@
11
package com.cometchat.javasampleapp;
22

3+
import android.content.Context;
34
import android.content.res.Configuration;
45

56
import androidx.annotation.NonNull;
67
import androidx.appcompat.app.AppCompatDelegate;
78

9+
import com.cometchat.chat.core.Call;
10+
import com.cometchat.chatuikit.calls.CometChatCallActivity;
11+
import com.cometchat.chatuikit.shared.resources.theme.CometChatTheme;
12+
import com.cometchat.chatuikit.shared.resources.theme.Palette;
813
import com.cometchat.chatuikit.shared.resources.utils.Utils;
914
import com.cometchat.chat.core.CometChat;
1015

1116

1217
public class Application extends android.app.Application {
13-
private static final String TAG = "UIKitApplication";
18+
private static String LISTENER_ID;
19+
1420
@Override
1521
public void onCreate() {
1622
super.onCreate();
23+
LISTENER_ID = System.currentTimeMillis() + "";
24+
if(AppUtils.isNightMode(this)){
25+
Palette.getInstance(this).mode(CometChatTheme.MODE.DARK);
26+
}
1727
}
28+
29+
public static void addCallListener(Context context) {
30+
CometChat.addCallListener(LISTENER_ID, new CometChat.CallListener() {
31+
@Override
32+
public void onIncomingCallReceived(Call call) {
33+
CometChatCallActivity.launchIncomingCallScreen(context, call, null);
34+
}
35+
36+
@Override
37+
public void onOutgoingCallAccepted(Call call) {
38+
39+
}
40+
41+
@Override
42+
public void onOutgoingCallRejected(Call call) {
43+
44+
}
45+
46+
@Override
47+
public void onIncomingCallCancelled(Call call) {
48+
49+
}
50+
});
51+
}
52+
53+
@Override
54+
public void onConfigurationChanged(@NonNull Configuration newConfig) {
55+
super.onConfigurationChanged(newConfig);
56+
if(AppUtils.isNightMode(this)){
57+
Palette.getInstance(this).mode(CometChatTheme.MODE.DARK);
58+
}else{
59+
Palette.getInstance(this).mode(CometChatTheme.MODE.LIGHT);
60+
}
61+
}
62+
1863
@Override
1964
public void onTerminate() {
2065
super.onTerminate();
21-
CometChat.removeConnectionListener(TAG);
2266
}
2367
}

app/src/main/java/com/cometchat/javasampleapp/activity/MainActivity.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import android.content.Intent;
44
import android.content.res.ColorStateList;
55
import android.os.Bundle;
6-
import android.util.Log;
76
import android.view.View;
87
import android.widget.LinearLayout;
98
import android.widget.Toast;
@@ -12,14 +11,14 @@
1211
import androidx.appcompat.widget.AppCompatImageView;
1312
import androidx.core.content.ContextCompat;
1413

15-
import com.cometchat.chatuikit.extensions.ExtensionConstants;
1614
import com.cometchat.chatuikit.shared.cometchatuikit.CometChatUIKit;
1715
import com.cometchat.chatuikit.shared.cometchatuikit.UIKitSettings;
1816
import com.cometchat.chatuikit.shared.resources.utils.Utils;
1917
import com.cometchat.chat.core.CometChat;
2018
import com.cometchat.chat.exceptions.CometChatException;
2119
import com.cometchat.javasampleapp.AppConstants;
2220
import com.cometchat.javasampleapp.AppUtils;
21+
import com.cometchat.javasampleapp.Application;
2322
import com.cometchat.javasampleapp.R;
2423
import com.cometchat.chat.models.User;
2524
import com.google.android.material.card.MaterialCardView;
@@ -49,11 +48,11 @@ protected void onCreate(Bundle savedInstanceState) {
4948
@Override
5049
public void onSuccess(String s) {
5150
if (CometChatUIKit.getLoggedInUser() != null) {
51+
Application.addCallListener(MainActivity.this);
5252
AppUtils.fetchDefaultObjects();
5353
startActivity(new Intent(MainActivity.this, HomeActivity.class));
5454
finish();
5555
}
56-
CometChat.setSource("ui-kit", "android", "java");
5756
}
5857

5958
@Override
@@ -97,6 +96,7 @@ private void login(String uid) {
9796
CometChatUIKit.login(uid, new CometChat.CallbackListener<User>() {
9897
@Override
9998
public void onSuccess(User user) {
99+
Application.addCallListener(MainActivity.this);
100100
AppUtils.fetchDefaultObjects();
101101
startActivity(new Intent(MainActivity.this, HomeActivity.class));
102102
finish();

0 commit comments

Comments
 (0)