Skip to content

Commit e0b8d2f

Browse files
v1.0.6
1 parent 1a404a3 commit e0b8d2f

29 files changed

Lines changed: 239 additions & 252 deletions

README.md

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
<p align="center">
2-
<img alt="CometChat" src="https://assets.cometchat.io/website/images/logos/banner.png">
3-
</p>
4-
5-
61
# Android Sample App by CometChat
72

83
This is a reference application showcasing the integration of [**CometChat's Android UI Kit**](https://www.cometchat.com/docs/v4/android-uikit/overview) within an Android framework. It provides developers with examples of implementing real-time messaging and voice and video calling features in their own Android-based applications.
94

105
## Prerequisites
116

12-
- Android Studio
7+
- Android Studio
138
- Android Device or emulator with Android version 6.0 or above.
149
- Java 8 or above.
1510
- Sign up for a [CometChat](https://app.cometchat.com/) account to get your app credentials: _`App ID`_, _`Region`_, and _`Auth Key`_
@@ -22,12 +17,9 @@ This is a reference application showcasing the integration of [**CometChat's And
2217
```
2318
2. In Android Studio, open the project cometchat-sample-app-android-java
2419
25-
3. Enter your CometChat _`App ID`_, _`Region`_, and _`Auth Key`_ in the [app/src/main/java/com/cometchat/javasampleapp/AppConstants.java](https://github.com/cometchat/cometchat-sample-app-android-java/blob/v4/app/src/main/java/com/cometchat/javasampleapp/AppConstants.java) file:
26-
```java
27-
public static final String APP_ID = "XXXXXXXXXXXXXXXXX";
28-
public static final String AUTH_KEY = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
29-
public static final String REGION = "XX";
30-
```
20+
3. Enter your CometChat _`App ID`_, _`Region`_, and _`Auth Key`_ in the [AppConstants.java](https://github.com/cometchat/cometchat-sample-app-android-java/blob/v4/app/src/main/java/com/cometchat/javasampleapp/AppConstants.java) file:
21+
https://github.com/cometchat/cometchat-sample-app-android-java/blob/1a404a36789639fa6198dc69452718f246cd082c/app/src/main/java/com/cometchat/javasampleapp/AppConstants.java#L3-L11
22+
3123
4. Run the app on a device or emulator.
3224
3325
<div style="

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ android {
99
applicationId "com.cometchat.javasampleapp"
1010
minSdk 21
1111
targetSdk 33
12-
versionCode 6
13-
versionName "1.0.5"
12+
versionCode 7
13+
versionName "1.0.6"
1414

1515
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1616
manifestPlaceholders = [file_provider: "com.cometchat.javasampleapp"]
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
package com.cometchat.javasampleapp;
2-
3-
public class AppConstants {
4-
5-
public static final String APP_ID = "XXXXXXXXXXXXXXXXX";
6-
7-
public static final String AUTH_KEY = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
8-
9-
public static final String REGION = "XX";
10-
1+
package com.cometchat.javasampleapp;
2+
3+
public class AppConstants {
4+
5+
public static final String APP_ID = "XXXXXXXXXXXXXXXXX";
6+
7+
public static final String AUTH_KEY = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
8+
9+
public static final String REGION = "XX";
10+
1111
}
Lines changed: 65 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,65 @@
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+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public void onError(CometChatException e) {
9494
if (Utils.isDarkMode(this)) {
9595
ivLogo.setImageTintList(ColorStateList.valueOf(getResources().getColor(R.color.white)));
9696
} else {
97-
ivLogo.setImageTintList(ColorStateList.valueOf(getResources().getColor(R.color.primaryTextColor)));
97+
ivLogo.setImageTintList(ColorStateList.valueOf(getResources().getColor(com.cometchat.chatuikit.R.color.cometchat_primary_text_color)));
9898
}
9999
setUpUI();
100100
}

app/src/main/java/com/cometchat/javasampleapp/fragments/shared/resources/ThemeFragment.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
6565
private void setTheme(boolean isDefault) {
6666

6767
if (isDefault) {
68-
accent = getResources().getColor(com.cometchat.chatuikit.R.color.accent);
68+
accent = getResources().getColor(com.cometchat.chatuikit.R.color.cometchat_accent);
6969
background = getResources().getColor(R.color.white);
70-
primary = getResources().getColor(com.cometchat.chatuikit.R.color.primary);
70+
primary = getResources().getColor(com.cometchat.chatuikit.R.color.cometchat_accent);
7171
heading = com.cometchat.chatuikit.R.style.Heading;
7272
name = R.style.Name;
7373
text1 = R.style.Text1;
7474
text2 = R.style.Text2;
7575
} else {
76-
accent = getResources().getColor(com.cometchat.chatuikit.R.color.online_green);
76+
accent = getResources().getColor(com.cometchat.chatuikit.R.color.cometchat_online_green);
7777
background = Color.parseColor("#021E20");
7878
primary = getResources().getColor(android.R.color.black);
7979
heading = R.style.AppHeading;
@@ -93,7 +93,7 @@ private void setTheme(boolean isDefault) {
9393
palette.accent600(ColorUtils.setAlphaComponent(accent, 148));
9494
palette.accent700(ColorUtils.setAlphaComponent(accent, 176));
9595
palette.accent800(ColorUtils.setAlphaComponent(accent, 209));
96-
palette.secondary(getResources().getColor(com.cometchat.chatuikit.R.color.secondary));
96+
palette.secondary(getResources().getColor(com.cometchat.chatuikit.R.color.cometchat_secondary));
9797
palette.accent900(ColorUtils.setAlphaComponent(accent, 255));
9898

9999
Typography typography = Typography.getInstance();

app/src/main/java/com/cometchat/javasampleapp/fragments/shared/views/ImageBubbleFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
1919

2020
CometChatImageBubble imageBubble = view.findViewById(R.id.image_bubble);
2121
imageBubble.setImageUrl("https://data-us.cometchat.io/2379614bd4db65dd/media/1682517838_2050398854_08d684e835e3c003f70f2478f937ed57.jpeg", R.drawable.ic_launcher_background, false);
22-
imageBubble.setStyle(new ImageBubbleStyle().setCornerRadius(18).setTextColor(getResources().getColor(R.color.black)).setBackground(getResources().getColor(com.cometchat.chatuikit.R.color.accent100)));
22+
imageBubble.setStyle(new ImageBubbleStyle().setCornerRadius(18).setTextColor(getResources().getColor(R.color.black)).setBackground(getResources().getColor(com.cometchat.chatuikit.R.color.cometchat_accent100)));
2323
imageBubble.setCaption("This is a simple representation of CometChat Image Bubble");
2424
return view;
2525
}

app/src/main/java/com/cometchat/javasampleapp/fragments/shared/views/ListItemFragment.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
4242
userListItem.setAvatar(CometChatUIKit.getLoggedInUser().getAvatar(), name);
4343
userListItem.setSubtitleView(getTextView(CometChatUIKit.getLoggedInUser().getStatus()));
4444
userListItem.setTitle(name);
45-
userListItem.setStatusIndicatorColor(getResources().getColor(com.cometchat.chatuikit.R.color.online_green));
45+
userListItem.setStatusIndicatorColor(getResources().getColor(com.cometchat.chatuikit.R.color.cometchat_online_green));
4646

4747
CometChatListItem conversationListItem = view.findViewById(R.id.conversation_list_item);
4848
ConversationTailView tailView = new ConversationTailView(getContext());
@@ -54,7 +54,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
5454
conversationListItem.setAvatar(CometChatUIKit.getLoggedInUser().getAvatar(), name);
5555
conversationListItem.setTailView(tailView);
5656
conversationListItem.setSubtitleView(getTextView("Hey, How are you?"));
57-
conversationListItem.setStatusIndicatorColor(getResources().getColor(com.cometchat.chatuikit.R.color.online_green));
57+
conversationListItem.setStatusIndicatorColor(getResources().getColor(com.cometchat.chatuikit.R.color.cometchat_online_green));
5858
setUpUI(view);
5959
return view;
6060
}

app/src/main/java/com/cometchat/javasampleapp/fragments/shared/views/StatusIndicatorFragment.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
3131
View view = inflater.inflate(R.layout.fragment_status_indicator, container, false);
3232
CometChatStatusIndicator statusIndicator = view.findViewById(R.id.statusIndicator);
3333
parentView= view.findViewById(R.id.parent_view);
34-
statusIndicator.setBackgroundColor(getResources().getColor(com.cometchat.chatuikit.R.color.online_green));
34+
statusIndicator.setBackgroundColor(getResources().getColor(com.cometchat.chatuikit.R.color.cometchat_online_green));
3535
RadioGroup statusChangeGroup = view.findViewById(R.id.toggle);
3636
statusIndicator.setBorderWidth(0);
3737
statusChangeGroup.setOnCheckedChangeListener((radioGroup, i) -> {
3838
if (i == R.id.online) {
39-
statusIndicator.setBackgroundColor(getResources().getColor(com.cometchat.chatuikit.R.color.online_green));
39+
statusIndicator.setBackgroundColor(getResources().getColor(com.cometchat.chatuikit.R.color.cometchat_online_green));
4040
} else if (i == R.id.offline) {
4141
statusIndicator.setBackgroundColor(getResources().getColor(android.R.color.darker_gray));
4242
}

app/src/main/java/com/cometchat/javasampleapp/fragments/shared/views/VideoBubbleFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
2020
View view = inflater.inflate(R.layout.fragment_video_bubble, container, false);
2121

2222
CometChatVideoBubble videoBubble = view.findViewById(R.id.video_bubble);
23-
videoBubble.setStyle(new VideoBubbleStyle().setCornerRadius(18).setBackground(getResources().getColor(com.cometchat.chatuikit.R.color.accent100)));
23+
videoBubble.setStyle(new VideoBubbleStyle().setCornerRadius(18).setBackground(getResources().getColor(com.cometchat.chatuikit.R.color.cometchat_accent100)));
2424
videoBubble.setVideoUrl("https://data-us.cometchat.io/2379614bd4db65dd/media/1682517886_527585446_3e8e02fc506fa535eecfe0965e1a2024.mp4", R.drawable.ic_launcher_background);
2525
return view;
2626
}

0 commit comments

Comments
 (0)