Skip to content

Commit daa64f5

Browse files
Merge pull request #51 from cometchat-pro/dev
v4.0.0
2 parents bde7b75 + bc7bee2 commit daa64f5

51 files changed

Lines changed: 1034 additions & 262 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ android {
3030
}
3131

3232
dependencies {
33-
implementation 'com.cometchat:chat-uikit-android:4.0.0-beta.1'
33+
implementation 'com.cometchat:chat-uikit-android:4.0.0'
3434
implementation 'androidx.appcompat:appcompat:1.6.1'
3535
implementation 'com.google.android.material:material:1.8.0'
3636
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
3737
testImplementation 'junit:junit:4.13.2'
3838
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
3939
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
40-
implementation 'com.cometchat:pro-android-calls-sdk:3.0.0'
40+
implementation 'com.cometchat:calls-sdk-android:4.0.0'
4141
}

app/src/main/java/com/cometchat/javasampleapp/AppConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ public class AppConstants {
44

55
public static final String APP_ID = "XXXXXXXXXXXXXXXXX";
66

7-
public static final String AUTH_KEY = "XXXXXXXXXXXXXXXXXXXXXXXXX";
7+
public static final String AUTH_KEY = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
88

99
public static final String REGION = "XX";
1010

app/src/main/java/com/cometchat/javasampleapp/AppUtils.java

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
package com.cometchat.javasampleapp;
22

3-
import com.cometchat.pro.core.CometChat;
4-
import com.cometchat.pro.exceptions.CometChatException;
5-
import com.cometchat.pro.models.Group;
6-
import com.cometchat.pro.models.User;
3+
import android.content.Context;
4+
import android.content.res.ColorStateList;
5+
import android.content.res.Configuration;
6+
import android.widget.ImageView;
7+
import android.widget.TextView;
8+
9+
import androidx.appcompat.app.AppCompatDelegate;
10+
import androidx.core.content.ContextCompat;
11+
12+
import com.cometchat.chat.core.CometChat;
13+
import com.cometchat.chat.exceptions.CometChatException;
14+
import com.cometchat.chat.models.Group;
15+
import com.cometchat.chat.models.TextMessage;
16+
import com.cometchat.chat.models.User;
717

818
public class AppUtils {
919
private static Group group;
@@ -42,4 +52,33 @@ public static User getDefaultUser() {
4252
return user;
4353
}
4454

55+
public static void switchLightMode() {
56+
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
57+
}
58+
59+
public static void switchDarkMode() {
60+
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
61+
}
62+
63+
public static boolean isNightMode(Context context) {
64+
int currentNightMode = context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
65+
return currentNightMode == Configuration.UI_MODE_NIGHT_YES;
66+
}
67+
68+
public static void changeIconTintToWhite(Context context, ImageView imageView) {
69+
imageView.setImageTintList(ColorStateList.valueOf(ContextCompat.getColor(context, R.color.white)));
70+
}
71+
72+
public static void changeIconTintToBlack(Context context, ImageView imageView) {
73+
imageView.setImageTintList(ColorStateList.valueOf(ContextCompat.getColor(context, R.color.black)));
74+
}
75+
76+
public static void changeTextColorToWhite(Context context, TextView textView) {
77+
textView.setTextColor(ContextCompat.getColor(context, R.color.white));
78+
}
79+
80+
public static void changeTextColorToBlack(Context context, TextView textView) {
81+
textView.setTextColor(ContextCompat.getColor(context, R.color.black));
82+
}
83+
4584
}

app/src/main/java/com/cometchat/javasampleapp/Application.java

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,15 @@
66
import androidx.appcompat.app.AppCompatDelegate;
77

88
import com.cometchat.chatuikit.shared.resources.utils.Utils;
9-
import com.cometchat.pro.core.CometChat;
9+
import com.cometchat.chat.core.CometChat;
1010

1111

1212
public class Application extends android.app.Application {
13-
1413
private static final String TAG = "UIKitApplication";
15-
1614
@Override
1715
public void onCreate() {
1816
super.onCreate();
19-
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
20-
}
21-
22-
@Override
23-
public void onConfigurationChanged(@NonNull Configuration newConfig) {
24-
super.onConfigurationChanged(newConfig);
25-
setTheme();
26-
}
27-
28-
private void setTheme() {
29-
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
3017
}
31-
3218
@Override
3319
public void onTerminate() {
3420
super.onTerminate();

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

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
package com.cometchat.javasampleapp.activity;
22

3+
import android.content.res.ColorStateList;
34
import android.os.Bundle;
5+
import android.view.View;
6+
import android.widget.LinearLayout;
47

58
import androidx.appcompat.app.AppCompatActivity;
9+
import androidx.core.content.ContextCompat;
610
import androidx.fragment.app.Fragment;
711

812
import com.cometchat.chatuikit.shared.resources.utils.Utils;
13+
import com.cometchat.javasampleapp.AppUtils;
914
import com.cometchat.javasampleapp.R;
1015
import com.cometchat.javasampleapp.fragments.calls.CallButtonFragment;
16+
import com.cometchat.javasampleapp.fragments.conversations.ContactsFragment;
1117
import com.cometchat.javasampleapp.fragments.conversations.ConversationsFragment;
1218
import com.cometchat.javasampleapp.fragments.conversations.ConversationsWithMessagesFragment;
1319
import com.cometchat.javasampleapp.fragments.groups.AddMemberFragment;
@@ -21,6 +27,7 @@
2127
import com.cometchat.javasampleapp.fragments.groups.TransferOwnershipFragment;
2228
import com.cometchat.javasampleapp.fragments.messages.MessageComposerFragment;
2329
import com.cometchat.javasampleapp.fragments.messages.MessageHeaderFragment;
30+
import com.cometchat.javasampleapp.fragments.messages.MessageInformationFragment;
2431
import com.cometchat.javasampleapp.fragments.messages.MessageListFragment;
2532
import com.cometchat.javasampleapp.fragments.messages.MessagesFragment;
2633
import com.cometchat.javasampleapp.fragments.shared.resources.LocalizeFragment;
@@ -32,6 +39,7 @@
3239
import com.cometchat.javasampleapp.fragments.shared.views.FileBubbleFragment;
3340
import com.cometchat.javasampleapp.fragments.shared.views.ImageBubbleFragment;
3441
import com.cometchat.javasampleapp.fragments.shared.views.ListItemFragment;
42+
import com.cometchat.javasampleapp.fragments.shared.views.MediaRecorderFragment;
3543
import com.cometchat.javasampleapp.fragments.shared.views.MessageReceiptFragment;
3644
import com.cometchat.javasampleapp.fragments.shared.views.StatusIndicatorFragment;
3745
import com.cometchat.javasampleapp.fragments.shared.views.TextBubbleFragment;
@@ -41,14 +49,14 @@
4149
import com.cometchat.javasampleapp.fragments.users.UsersWithMessagesFragment;
4250

4351
public class ComponentLaunchActivity extends AppCompatActivity {
44-
52+
private LinearLayout parentView;
4553
@Override
4654
protected void onCreate(Bundle savedInstanceState) {
4755
super.onCreate(savedInstanceState);
4856
setContentView(R.layout.activity_component_launch);
49-
Utils.setStatusBarColor(this, getResources().getColor(R.color.app_background));
5057
int id = getIntent().getIntExtra("component", 0);
51-
58+
parentView = findViewById(R.id.container);
59+
setUpUI();
5260
if (id == R.id.conversationWithMessages) {
5361
loadFragment(new ConversationsWithMessagesFragment());
5462
} else if (id == R.id.conversations) {
@@ -113,6 +121,21 @@ protected void onCreate(Bundle savedInstanceState) {
113121
loadFragment(new AudioBubbleFragment());
114122
} else if (id == R.id.files_bubble) {
115123
loadFragment(new FileBubbleFragment());
124+
} else if (id == R.id.media_recorder) {
125+
loadFragment(new MediaRecorderFragment());
126+
} else if (id == R.id.contacts) {
127+
loadFragment(new ContactsFragment());
128+
}else if (id == R.id.messageInformation) {
129+
loadFragment(new MessageInformationFragment());
130+
}
131+
}
132+
private void setUpUI() {
133+
if(AppUtils.isNightMode(this)){
134+
Utils.setStatusBarColor(this, ContextCompat.getColor(this,R.color.app_background_dark));
135+
parentView.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this,R.color.app_background_dark)));
136+
}else {
137+
Utils.setStatusBarColor(this, getResources().getColor(R.color.app_background));
138+
parentView.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.app_background)));
116139
}
117140
}
118141

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

Lines changed: 89 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
11
package com.cometchat.javasampleapp.activity;
22

33
import android.content.Intent;
4+
import android.content.res.ColorStateList;
45
import android.os.Bundle;
56
import android.view.View;
7+
import android.widget.LinearLayout;
68
import android.widget.TextView;
79

810
import androidx.appcompat.app.AppCompatActivity;
11+
import androidx.core.content.ContextCompat;
912

1013
import com.cometchat.chatuikit.shared.resources.utils.Utils;
14+
import com.cometchat.javasampleapp.AppUtils;
1115
import com.cometchat.javasampleapp.R;
1216
import com.cometchat.javasampleapp.constants.StringConstants;
1317

1418
public class ComponentListActivity extends AppCompatActivity {
19+
LinearLayout parentView;
1520
@Override
1621
protected void onCreate(Bundle savedInstanceState) {
1722
super.onCreate(savedInstanceState);
1823
setContentView(R.layout.activity_component_list);
19-
Utils.setStatusBarColor(this, getResources().getColor(R.color.app_background));
24+
parentView = findViewById(R.id.parent_view);
2025
TextView title = findViewById(R.id.title);
26+
setUpUI();
2127
if (getIntent() != null) {
2228
title.setText(getIntent().getStringExtra(StringConstants.MODULE));
2329
if (getIntent().getStringExtra(StringConstants.MODULE).equalsIgnoreCase(StringConstants.CONVERSATIONS)) {
@@ -40,6 +46,7 @@ protected void onCreate(Bundle savedInstanceState) {
4046
//chats
4147
findViewById(R.id.conversationWithMessages).setOnClickListener(view -> handleIntent(R.id.conversationWithMessages));
4248
findViewById(R.id.conversations).setOnClickListener(view -> handleIntent(R.id.conversations));
49+
findViewById(R.id.contacts).setOnClickListener(view -> handleIntent(R.id.contacts));
4350

4451
//users
4552
findViewById(R.id.userWithMessages).setOnClickListener(view -> handleIntent(R.id.userWithMessages));
@@ -62,6 +69,7 @@ protected void onCreate(Bundle savedInstanceState) {
6269
findViewById(R.id.messageList).setOnClickListener(view -> handleIntent(R.id.messageList));
6370
findViewById(R.id.messageHeader).setOnClickListener(view -> handleIntent(R.id.messageHeader));
6471
findViewById(R.id.messageComposer).setOnClickListener(view -> handleIntent(R.id.messageComposer));
72+
findViewById(R.id.messageInformation).setOnClickListener(view -> handleIntent(R.id.messageInformation));
6573

6674
//calls
6775
findViewById(R.id.call_button).setOnClickListener(view -> handleIntent(R.id.call_button));
@@ -79,15 +87,93 @@ protected void onCreate(Bundle savedInstanceState) {
7987
findViewById(R.id.video_bubble).setOnClickListener(view -> handleIntent(R.id.video_bubble));
8088
findViewById(R.id.audio_bubble).setOnClickListener(view -> handleIntent(R.id.audio_bubble));
8189
findViewById(R.id.files_bubble).setOnClickListener(view -> handleIntent(R.id.files_bubble));
90+
findViewById(R.id.media_recorder).setOnClickListener(view -> handleIntent(R.id.media_recorder));
8291

8392
//resources
8493
findViewById(R.id.soundManager).setOnClickListener(view -> handleIntent(R.id.soundManager));
8594
findViewById(R.id.theme).setOnClickListener(view -> handleIntent(R.id.theme));
8695
findViewById(R.id.localize).setOnClickListener(view -> handleIntent(R.id.localize));
87-
88-
8996
}
9097

98+
private void setUpUI() {
99+
if(AppUtils.isNightMode(this)){
100+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.backIcon));
101+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_cwm));
102+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_c));
103+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_contacts));
104+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_uwm));
105+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_u));
106+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_ud));
107+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_gwm));
108+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_g));
109+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_cg));
110+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_jp));
111+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_gm));
112+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_ad));
113+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_to));
114+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_bm));
115+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_gd));
116+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_message));
117+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_message_header));
118+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_message_list));
119+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_message_composer));
120+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_message_information));
121+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_call_button));
122+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_audio));
123+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_translate));
124+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_avatar));
125+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_badge_count));
126+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_message_receipt));
127+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_status_indicator));
128+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_text_bubble));
129+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_image_bubble));
130+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_video_bubble));
131+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_audio_bubble));
132+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_file_bubble));
133+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_mic));
134+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_list_item));
135+
Utils.setStatusBarColor(this, ContextCompat.getColor(this,R.color.app_background_dark));
136+
parentView.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this,R.color.app_background_dark)));
137+
}else {
138+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.backIcon));
139+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_cwm));
140+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_c));
141+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_contacts));
142+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_uwm));
143+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_u));
144+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_ud));
145+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_gwm));
146+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_g));
147+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_cg));
148+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_jp));
149+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_gm));
150+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_ad));
151+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_to));
152+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_bm));
153+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_gd));
154+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_message));
155+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_message_header));
156+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_message_list));
157+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_message_composer));
158+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_message_information));
159+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_call_button));
160+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_audio));
161+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_translate));
162+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_avatar));
163+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_badge_count));
164+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_message_receipt));
165+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_status_indicator));
166+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_text_bubble));
167+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_image_bubble));
168+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_video_bubble));
169+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_audio_bubble));
170+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_file_bubble));
171+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_mic));
172+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_list_item));
173+
Utils.setStatusBarColor(this, getResources().getColor(R.color.app_background));
174+
parentView.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.app_background)));
175+
}
176+
}
91177
private void handleIntent(int id) {
92178
Intent intent = new Intent(this, ComponentLaunchActivity.class);
93179
intent.putExtra("component", id);

0 commit comments

Comments
 (0)