Skip to content

Commit afaf89f

Browse files
Android UI Kit v2.0.2
1 parent 4b2c62e commit afaf89f

File tree

89 files changed

+7274
-749
lines changed

Some content is hidden

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

89 files changed

+7274
-749
lines changed

app/build.gradle

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ android {
1515
manifestPlaceholders = [file_provider: "com.cometchat.pro.androiduikit"]
1616

1717
ndk {
18-
abiFilters "armeabi-v7a", "x86"
18+
abiFilters "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
1919
}
2020
}
2121
dataBinding {
@@ -55,8 +55,11 @@ dependencies {
5555
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
5656
implementation project(path: ':uikit')
5757

58+
implementation 'androidx.emoji:emoji:1.1.0-rc01'
59+
implementation 'androidx.emoji:emoji-bundled:1.1.0'
60+
5861
implementation 'com.google.android.material:material:1.2.0-alpha05'
5962
implementation 'com.facebook.shimmer:shimmer:0.4.0'
6063
//
61-
implementation 'com.cometchat:pro-android-chat-sdk:2.0.6'
64+
implementation 'com.cometchat:pro-android-chat-sdk:2.0.7'
6265
}

app/src/main/java/com/cometchat/pro/androiduikit/CreateUserActivity.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ public void onSuccess(User user) {
6565

6666
@Override
6767
public void onError(CometChatException e) {
68-
progressBar.setVisibility(View.GONE);
6968
createUserBtn.setClickable(true);
7069
Toast.makeText(CreateUserActivity.this,"Failed to create user",Toast.LENGTH_LONG).show();
7170
}
@@ -111,7 +110,6 @@ public void onSuccess(User user) {
111110

112111
@Override
113112
public void onError(CometChatException e) {
114-
progressBar.setVisibility(View.GONE);
115113
if (uid!=null)
116114
Snackbar.make(uid.getRootView(),"Unable to login",Snackbar.LENGTH_INDEFINITE).setAction("Try Again", new View.OnClickListener() {
117115
@Override

app/src/main/java/com/cometchat/pro/androiduikit/MainActivity.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ public class MainActivity extends AppCompatActivity {
4040
protected void onCreate(Bundle savedInstanceState) {
4141
super.onCreate(savedInstanceState);
4242
setContentView(R.layout.activity_main);
43-
43+
if (CometChat.getLoggedInUser()!=null)
44+
{
45+
startActivity(new Intent(MainActivity.this,SelectActivity.class));
46+
}
4447
loginBtn = findViewById(R.id.login);
4548
superhero1 = findViewById(R.id.superhero1);
4649
superhero2 = findViewById(R.id.superhero2);

app/src/main/java/com/cometchat/pro/androiduikit/UIKitApplication.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,17 @@
1111
import android.util.Log;
1212
import android.view.WindowManager;
1313
import android.widget.Toast;
14+
15+
import androidx.emoji.bundled.BundledEmojiCompatConfig;
16+
import androidx.emoji.text.EmojiCompat;
17+
1418
import com.cometchat.pro.core.AppSettings;
1519
import com.cometchat.pro.core.CometChat;
1620
import com.cometchat.pro.exceptions.CometChatException;
1721
import com.cometchat.pro.androiduikit.constants.AppConfig;
1822
import com.cometchat.pro.helpers.Logger;
1923

24+
import constant.StringContract;
2025
import listeners.CometChatCallListener;
2126
import utils.PreferenceUtil;
2227

@@ -27,13 +32,16 @@ public class UIKitApplication extends Application {
2732
@Override
2833
public void onCreate() {
2934
super.onCreate();
30-
AppSettings appSettings = new AppSettings.AppSettingsBuilder().subscribePresenceForAllUsers().setRegion(AppConfig.AppDetails.REGION).build();
31-
CometChat.init(this, AppConfig.AppDetails.APP_ID, appSettings, new CometChat.CallbackListener<String>() {
35+
EmojiCompat.Config config = new BundledEmojiCompatConfig(this);
36+
EmojiCompat.init(config);
37+
AppSettings appSettings = new AppSettings.AppSettingsBuilder().
38+
subscribePresenceForAllUsers().setRegion(AppConfig.AppDetails.REGION).build();
39+
CometChat.init(this, AppConfig.AppDetails.APP_ID, appSettings,
40+
new CometChat.CallbackListener<String>() {
3241
@Override
3342
public void onSuccess(String s) {
34-
PreferenceUtil preferenceUtil = PreferenceUtil.getInstance(UIKitApplication.this);
35-
preferenceUtil.saveString("apikey",AppConfig.AppDetails.API_KEY);
36-
CometChat.setSource("ui-kit-sampleapp","android","java");
43+
StringContract.AppInfo.API_KEY = AppConfig.AppDetails.API_KEY;
44+
CometChat.setSource("ui-kit","android","java");
3745
Log.d(TAG, "onSuccess: "+s);
3846
}
3947

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ public class AppConfig {
44

55
public class AppDetails {
66

7-
public static final String APP_ID = "XXXXXXXXXXX";
7+
public static final String APP_ID = "XXXXXXXXXXXXXXXX";
88

9-
public static final String API_KEY = "XXXXXXXXXXXXXXXXXXXXXXXXX";
9+
public static final String API_KEY = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
1010

1111
public static final String REGION = "XX";
1212
}

uikit/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,5 @@ dependencies {
6161
implementation 'com.facebook.shimmer:shimmer:0.4.0'
6262

6363
//cometchat
64-
compileOnly 'com.cometchat:pro-android-chat-sdk:2.0.6'
64+
compileOnly 'com.cometchat:pro-android-chat-sdk:2.0.7'
6565
}

uikit/src/main/AndroidManifest.xml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
android:usesCleartextTraffic="true"
1717
tools:node="merge"
1818
tools:targetApi="m">
19-
<activity android:name="screen.banmembers.CometChatBanMemberScreenActivity"/>
19+
<activity android:name="screen.threadconversation.CometChatThreadMessageActivity"
20+
android:windowSoftInputMode="adjustResize"/>
21+
<activity android:name="screen.banmembers.CometChatBanMemberScreenActivity" />
2022
<activity
2123
android:name="screen.CometChatCallActivity"
2224
android:screenOrientation="portrait"
@@ -32,9 +34,10 @@
3234
<activity
3335
android:name="screen.creategroup.CometChatCreateGroupScreenActivity"
3436
android:screenOrientation="portrait"
35-
android:windowSoftInputMode="adjustPan"/>
36-
<activity android:name="screen.CometChatMorePrivacyScreenActivity"
37-
android:screenOrientation="portrait"/>
37+
android:windowSoftInputMode="adjustPan" />
38+
<activity
39+
android:name="screen.CometChatMorePrivacyScreenActivity"
40+
android:screenOrientation="portrait" />
3841
<activity
3942
android:name="screen.blockuserlist.CometChatBlockUserListScreenActivity"
4043
android:screenOrientation="portrait" />
@@ -49,7 +52,18 @@
4952
android:screenOrientation="portrait" />
5053
<activity
5154
android:name="screen.CometChatForwardMessageScreenActivity"
52-
android:screenOrientation="portrait" />
55+
android:screenOrientation="portrait">
56+
<intent-filter>
57+
<action android:name="android.intent.action.SEND" />
58+
<category android:name="android.intent.category.DEFAULT" />
59+
<data android:mimeType="image/*" />
60+
</intent-filter>
61+
<intent-filter>
62+
<action android:name="android.intent.action.SEND" />
63+
<category android:name="android.intent.category.DEFAULT" />
64+
<data android:mimeType="text/plain" />
65+
</intent-filter>
66+
</activity>
5367
<activity
5468
android:name="screen.groupmemberlist.CometChatGroupMemberListScreenActivity"
5569
android:screenOrientation="portrait" />

uikit/src/main/java/adapter/ConversationListAdapter.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.ArrayList;
2828
import java.util.List;
2929

30+
import utils.Extensions;
3031
import utils.FontUtils;
3132
import utils.Utils;
3233

@@ -111,6 +112,7 @@ public void onBindViewHolder(@NonNull ConversationViewHolder conversationViewHol
111112

112113
String avatar;
113114
String name;
115+
String status;
114116
String lastMessageText = null;
115117
BaseMessage baseMessage = conversation.getLastMessage();
116118
conversationViewHolder.conversationListRowBinding.setConversation(conversation);
@@ -133,16 +135,29 @@ public void onBindViewHolder(@NonNull ConversationViewHolder conversationViewHol
133135
conversationViewHolder.conversationListRowBinding.messageTime.setVisibility(View.GONE);
134136
}
135137
conversationViewHolder.conversationListRowBinding.txtUserMessage.setText(lastMessageText);
138+
if (baseMessage!=null) {
139+
boolean isSentimentNegative = Extensions.checkSentiment(baseMessage);
140+
if (isSentimentNegative && !baseMessage.getSender().getUid().equals(CometChat.getLoggedInUser().getUid())) {
141+
conversationViewHolder.conversationListRowBinding.txtUserMessage.setText(context.getResources().getString(R.string.sentimment_content));
142+
}
143+
}
136144
conversationViewHolder.conversationListRowBinding.txtUserMessage.setTypeface(fontUtils.getTypeFace(FontUtils.robotoRegular));
137145
conversationViewHolder.conversationListRowBinding.txtUserName.setTypeface(fontUtils.getTypeFace(FontUtils.robotoMedium));
138146
conversationViewHolder.conversationListRowBinding.messageTime.setTypeface(fontUtils.getTypeFace(FontUtils.robotoRegular));
139147

140148
if (conversation.getConversationType().equals(CometChatConstants.RECEIVER_TYPE_USER)) {
141149
name = ((User) conversation.getConversationWith()).getName();
142150
avatar = ((User) conversation.getConversationWith()).getAvatar();
151+
status = ((User)conversation.getConversationWith()).getStatus();
152+
if (status.equals(CometChatConstants.USER_STATUS_ONLINE)) {
153+
conversationViewHolder.conversationListRowBinding.userStatus.setVisibility(View.VISIBLE);
154+
conversationViewHolder.conversationListRowBinding.userStatus.setUserStatus(status);
155+
} else
156+
conversationViewHolder.conversationListRowBinding.userStatus.setVisibility(View.GONE);
143157
} else {
144158
name = ((Group) conversation.getConversationWith()).getName();
145159
avatar = ((Group) conversation.getConversationWith()).getIcon();
160+
conversationViewHolder.conversationListRowBinding.userStatus.setVisibility(View.GONE);
146161
}
147162

148163
conversationViewHolder.conversationListRowBinding.messageCount.setCount(conversation.getUnreadMessageCount());

uikit/src/main/java/adapter/GroupListAdapter.java

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package adapter;
22

33
import android.content.Context;
4+
import android.content.res.ColorStateList;
45
import android.view.LayoutInflater;
56
import android.view.ViewGroup;
67

78
import androidx.annotation.NonNull;
89
import androidx.databinding.DataBindingUtil;
910
import androidx.recyclerview.widget.RecyclerView;
1011

12+
import com.cometchat.pro.constants.CometChatConstants;
1113
import com.cometchat.pro.uikit.R;
1214
import com.cometchat.pro.uikit.databinding.GroupListRowBinding;
1315
import com.cometchat.pro.models.Group;
@@ -81,16 +83,28 @@ public GroupViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewTyp
8183
public void onBindViewHolder(@NonNull GroupViewHolder groupViewHolder, int position) {
8284
Group group = groupList.get(position);
8385
groupViewHolder.groupListRowBinding.setGroup(group);
86+
groupViewHolder.groupListRowBinding.executePendingBindings();
87+
groupViewHolder.groupListRowBinding.txtUserMessage.setText("Members: "+group.getMembersCount());
88+
89+
if (group.getGroupType().equals(CometChatConstants.GROUP_TYPE_PRIVATE))
90+
groupViewHolder.groupListRowBinding.txtUserName.setCompoundDrawablesWithIntrinsicBounds(0,0,R.drawable.ic_security_24dp,0);
91+
else if (group.getGroupType().equals(CometChatConstants.GROUP_TYPE_PASSWORD))
92+
groupViewHolder.groupListRowBinding.txtUserName.setCompoundDrawablesWithIntrinsicBounds(0,0,R.drawable.ic_lock_24dp,0);
93+
else
94+
groupViewHolder.groupListRowBinding.txtUserName.setCompoundDrawablesWithIntrinsicBounds(0,0,0,0);
95+
8496
groupViewHolder.groupListRowBinding.executePendingBindings();
8597
groupViewHolder.groupListRowBinding.avGroup.setBackgroundColor(context.getResources().getColor(R.color.colorPrimary));
8698
groupViewHolder.groupListRowBinding.getRoot().setTag(R.string.group, group);
8799
groupViewHolder.groupListRowBinding.txtUserMessage.setTypeface(fontUtils.getTypeFace(FontUtils.robotoRegular));
88100
groupViewHolder.groupListRowBinding.txtUserName.setTypeface(fontUtils.getTypeFace(FontUtils.robotoMedium));
89101

90102
if(Utils.isDarkMode(context)) {
103+
groupViewHolder.groupListRowBinding.txtUserName.setCompoundDrawableTintList(ColorStateList.valueOf(context.getResources().getColor(R.color.grey)));
91104
groupViewHolder.groupListRowBinding.txtUserName.setTextColor(context.getResources().getColor(R.color.textColorWhite));
92105
groupViewHolder.groupListRowBinding.tvSeprator.setBackgroundColor(context.getResources().getColor(R.color.grey));
93106
} else {
107+
groupViewHolder.groupListRowBinding.txtUserName.setCompoundDrawableTintList(ColorStateList.valueOf(context.getResources().getColor(R.color.message_bubble_grey)));
94108
groupViewHolder.groupListRowBinding.txtUserName.setTextColor(context.getResources().getColor(R.color.primaryTextColor));
95109
groupViewHolder.groupListRowBinding.tvSeprator.setBackgroundColor(context.getResources().getColor(R.color.light_grey));
96110
}
@@ -103,7 +117,7 @@ public void onBindViewHolder(@NonNull GroupViewHolder groupViewHolder, int posit
103117
public void updateGroupList(List<Group> groupList) {
104118

105119
for (int i = 0; i <groupList.size() ; i++) {
106-
updateGroup(groupList.get(i));
120+
updateGroup(groupList.get(i),i);
107121
}
108122
}
109123

@@ -112,12 +126,12 @@ public void updateGroupList(List<Group> groupList) {
112126
*
113127
* @param group is an object of Group. It will be updated with previous group in a list.
114128
*/
115-
public void updateGroup(Group group) {
129+
public void updateGroup(Group group,int i) {
116130
if (group != null) {
117131
if (groupList.contains(group)) {
118-
int index = groupList.indexOf(group);
132+
int index = groupList.indexOf(groupList.get(i));
119133
groupList.remove(index);
120-
groupList.add(group);
134+
groupList.add(index,group);
121135
notifyItemChanged(index);
122136
} else {
123137
groupList.add(group);
@@ -172,7 +186,8 @@ public void searchGroup(List<Group> groups) {
172186
*/
173187
public void add(Group group) {
174188
if (group != null) {
175-
updateGroup(group);
189+
groupList.add(group);
190+
notifyItemInserted(getItemCount()-1);
176191
}
177192
}
178193

0 commit comments

Comments
 (0)