|
1 | | -package com.cometchat.javasampleapp; |
2 | | - |
3 | | -import android.content.Context; |
4 | | -import android.content.res.Configuration; |
5 | | - |
6 | | -import androidx.annotation.NonNull; |
7 | | -import androidx.appcompat.app.AppCompatDelegate; |
8 | | - |
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; |
13 | | -import com.cometchat.chatuikit.shared.resources.utils.Utils; |
14 | | -import com.cometchat.chat.core.CometChat; |
15 | | - |
16 | | - |
17 | | -public class Application extends android.app.Application { |
18 | | - private static String LISTENER_ID; |
19 | | - |
20 | | - @Override |
21 | | - public void onCreate() { |
22 | | - super.onCreate(); |
23 | | - LISTENER_ID = System.currentTimeMillis() + ""; |
24 | | - if(AppUtils.isNightMode(this)){ |
25 | | - Palette.getInstance(this).mode(CometChatTheme.MODE.DARK); |
26 | | - } |
27 | | - } |
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 | | - |
63 | | - @Override |
64 | | - public void onTerminate() { |
65 | | - super.onTerminate(); |
66 | | - } |
67 | | -} |
| 1 | +package com.cometchat.javasampleapp; |
| 2 | + |
| 3 | +import android.content.Context; |
| 4 | +import android.content.res.Configuration; |
| 5 | + |
| 6 | +import androidx.annotation.NonNull; |
| 7 | + |
| 8 | +import com.cometchat.chat.core.Call; |
| 9 | +import com.cometchat.chatuikit.calls.CometChatCallActivity; |
| 10 | +import com.cometchat.chatuikit.shared.resources.theme.CometChatTheme; |
| 11 | +import com.cometchat.chatuikit.shared.resources.theme.Palette; |
| 12 | +import com.cometchat.chat.core.CometChat; |
| 13 | + |
| 14 | + |
| 15 | +public class Application extends android.app.Application { |
| 16 | + private static String LISTENER_ID; |
| 17 | + |
| 18 | + @Override |
| 19 | + public void onCreate() { |
| 20 | + super.onCreate(); |
| 21 | + LISTENER_ID = System.currentTimeMillis() + ""; |
| 22 | + if (AppUtils.isNightMode(this)) { |
| 23 | + Palette.getInstance(this).mode(CometChatTheme.MODE.DARK); |
| 24 | + } |
| 25 | + } |
| 26 | + |
| 27 | + public static void addCallListener(Context context) { |
| 28 | + CometChat.addCallListener(LISTENER_ID, new CometChat.CallListener() { |
| 29 | + @Override |
| 30 | + public void onIncomingCallReceived(Call call) { |
| 31 | + CometChatCallActivity.launchIncomingCallScreen(context, call, null); |
| 32 | + } |
| 33 | + |
| 34 | + @Override |
| 35 | + public void onOutgoingCallAccepted(Call call) { |
| 36 | + |
| 37 | + } |
| 38 | + |
| 39 | + @Override |
| 40 | + public void onOutgoingCallRejected(Call call) { |
| 41 | + |
| 42 | + } |
| 43 | + |
| 44 | + @Override |
| 45 | + public void onIncomingCallCancelled(Call call) { |
| 46 | + |
| 47 | + } |
| 48 | + }); |
| 49 | + } |
| 50 | + |
| 51 | + @Override |
| 52 | + public void onConfigurationChanged(@NonNull Configuration newConfig) { |
| 53 | + super.onConfigurationChanged(newConfig); |
| 54 | + if (AppUtils.isNightMode(this)) { |
| 55 | + Palette.getInstance(this).mode(CometChatTheme.MODE.DARK); |
| 56 | + } else { |
| 57 | + Palette.getInstance(this).mode(CometChatTheme.MODE.LIGHT); |
| 58 | + } |
| 59 | + } |
| 60 | + |
| 61 | + @Override |
| 62 | + public void onTerminate() { |
| 63 | + super.onTerminate(); |
| 64 | + } |
| 65 | +} |
0 commit comments