Skip to content

Commit 98a996d

Browse files
Android UI Kit v2.1.0
1 parent afaf89f commit 98a996d

28 files changed

+219
-578
lines changed

.idea/jarRepositories.xml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,8 @@ 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-
6158
implementation 'com.google.android.material:material:1.2.0-alpha05'
6259
implementation 'com.facebook.shimmer:shimmer:0.4.0'
6360
//
64-
implementation 'com.cometchat:pro-android-chat-sdk:2.0.7'
61+
implementation 'com.cometchat:pro-android-chat-sdk:2.1.0'
6562
}

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
import android.view.WindowManager;
1313
import android.widget.Toast;
1414

15-
import androidx.emoji.bundled.BundledEmojiCompatConfig;
16-
import androidx.emoji.text.EmojiCompat;
1715

1816
import com.cometchat.pro.core.AppSettings;
1917
import com.cometchat.pro.core.CometChat;
@@ -24,6 +22,7 @@
2422
import constant.StringContract;
2523
import listeners.CometChatCallListener;
2624
import utils.PreferenceUtil;
25+
import utils.Utils;
2726

2827
public class UIKitApplication extends Application {
2928

@@ -32,8 +31,7 @@ public class UIKitApplication extends Application {
3231
@Override
3332
public void onCreate() {
3433
super.onCreate();
35-
EmojiCompat.Config config = new BundledEmojiCompatConfig(this);
36-
EmojiCompat.init(config);
34+
3735
AppSettings appSettings = new AppSettings.AppSettingsBuilder().
3836
subscribePresenceForAllUsers().setRegion(AppConfig.AppDetails.REGION).build();
3937
CometChat.init(this, AppConfig.AppDetails.APP_ID, appSettings,
@@ -50,7 +48,6 @@ public void onError(CometChatException e) {
5048
Toast.makeText(UIKitApplication.this, e.getMessage(), Toast.LENGTH_SHORT).show();
5149
}
5250
});
53-
addConnectionListener(TAG);
5451
CometChatCallListener.addCallListener(TAG,this);
5552
createNotificationChannel();
5653
}
@@ -95,6 +92,5 @@ private void createNotificationChannel() {
9592
public void onTerminate() {
9693
super.onTerminate();
9794
CometChatCallListener.removeCallListener(TAG);
98-
CometChat.removeConnectionListener(TAG);
9995
}
10096
}

uikit/build.gradle

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ dependencies {
5151

5252
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
5353

54+
implementation 'androidx.emoji:emoji:1.1.0-rc01'
55+
implementation 'androidx.emoji:emoji-bundled:1.1.0'
56+
5457
implementation 'androidx.emoji:emoji-appcompat:1.0.0'
5558
implementation 'androidx.annotation:annotation:1.1.0'
5659
implementation 'com.github.bumptech.glide:glide:4.9.0'
@@ -61,5 +64,8 @@ dependencies {
6164
implementation 'com.facebook.shimmer:shimmer:0.4.0'
6265

6366
//cometchat
64-
compileOnly 'com.cometchat:pro-android-chat-sdk:2.0.7'
67+
compileOnly 'com.cometchat:pro-android-chat-sdk:2.1.0'
68+
}
69+
repositories {
70+
mavenCentral()
6571
}

uikit/src/main/AndroidManifest.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616
android:usesCleartextTraffic="true"
1717
tools:node="merge"
1818
tools:targetApi="m">
19-
<activity android:name="screen.threadconversation.CometChatThreadMessageActivity"
20-
android:windowSoftInputMode="adjustResize"/>
19+
<activity android:name="screen.CometChatStartCallActivity"></activity>
20+
<activity
21+
android:name="screen.threadconversation.CometChatThreadMessageActivity"
22+
android:windowSoftInputMode="adjustResize" />
2123
<activity android:name="screen.banmembers.CometChatBanMemberScreenActivity" />
2224
<activity
2325
android:name="screen.CometChatCallActivity"
@@ -55,12 +57,16 @@
5557
android:screenOrientation="portrait">
5658
<intent-filter>
5759
<action android:name="android.intent.action.SEND" />
60+
5861
<category android:name="android.intent.category.DEFAULT" />
62+
5963
<data android:mimeType="image/*" />
6064
</intent-filter>
6165
<intent-filter>
6266
<action android:name="android.intent.action.SEND" />
67+
6368
<category android:name="android.intent.category.DEFAULT" />
69+
6470
<data android:mimeType="text/plain" />
6571
</intent-filter>
6672
</activity>

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,9 @@ protected FilterResults performFiltering(CharSequence charSequence) {
351351
} else if (conversation.getConversationType().equals(CometChatConstants.CONVERSATION_TYPE_GROUP) &&
352352
((Group) conversation.getConversationWith()).getName().toLowerCase().contains(searchKeyword)) {
353353
tempFilter.add(conversation);
354-
} else if (conversation.getLastMessage()!=null && conversation.getLastMessage().getType().equals(CometChatConstants.MESSAGE_TYPE_TEXT)
354+
} else if (conversation.getLastMessage()!=null &&
355+
conversation.getLastMessage().getCategory().equals(CometChatConstants.CATEGORY_MESSAGE) &&
356+
conversation.getLastMessage().getType().equals(CometChatConstants.MESSAGE_TYPE_TEXT)
355357
&& ((TextMessage)conversation.getLastMessage()).getText().contains(searchKeyword)) {
356358
tempFilter.add(conversation);
357359
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ else if (group.getGroupType().equals(CometChatConstants.GROUP_TYPE_PASSWORD))
117117
public void updateGroupList(List<Group> groupList) {
118118

119119
for (int i = 0; i <groupList.size() ; i++) {
120-
updateGroup(groupList.get(i),i);
120+
updateGroup(groupList.get(i));
121121
}
122122
}
123123

@@ -126,10 +126,10 @@ public void updateGroupList(List<Group> groupList) {
126126
*
127127
* @param group is an object of Group. It will be updated with previous group in a list.
128128
*/
129-
public void updateGroup(Group group,int i) {
129+
public void updateGroup(Group group) {
130130
if (group != null) {
131131
if (groupList.contains(group)) {
132-
int index = groupList.indexOf(groupList.get(i));
132+
int index = groupList.indexOf(group);
133133
groupList.remove(index);
134134
groupList.add(index,group);
135135
notifyItemChanged(index);

uikit/src/main/java/adapter/MessageAdapter.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,18 +1326,22 @@ public void onClick(DialogInterface dialog, int which) {
13261326
String txtMessage = ((TextMessage) baseMessage).getText().trim();
13271327
viewHolder.txtMessage.setTextSize(16f);
13281328
int count = 0;
1329-
CharSequence processed = EmojiCompat.get().process(txtMessage, 0,
1330-
txtMessage.length() -1, Integer.MAX_VALUE, EmojiCompat.REPLACE_STRATEGY_ALL);
1331-
if (processed instanceof Spannable) {
1332-
Spannable spannable = (Spannable) processed;
1333-
count = spannable.getSpans(0, spannable.length() - 1, EmojiSpan.class).length;
1334-
if (Utils.removeEmojiAndSymbol(txtMessage).trim().length() == 0) {
1335-
if (count == 1) {
1336-
viewHolder.txtMessage.setTextSize((int) Utils.dpToPx(context, 32));
1337-
} else if (count == 2) {
1338-
viewHolder.txtMessage.setTextSize((int) Utils.dpToPx(context, 24));
1329+
try {
1330+
CharSequence processed = EmojiCompat.get().process(txtMessage, 0,
1331+
txtMessage.length() - 1, Integer.MAX_VALUE, EmojiCompat.REPLACE_STRATEGY_ALL);
1332+
if (processed instanceof Spannable) {
1333+
Spannable spannable = (Spannable) processed;
1334+
count = spannable.getSpans(0, spannable.length() - 1, EmojiSpan.class).length;
1335+
if (Utils.removeEmojiAndSymbol(txtMessage).trim().length() == 0) {
1336+
if (count == 1) {
1337+
viewHolder.txtMessage.setTextSize((int) Utils.dpToPx(context, 32));
1338+
} else if (count == 2) {
1339+
viewHolder.txtMessage.setTextSize((int) Utils.dpToPx(context, 24));
1340+
}
13391341
}
13401342
}
1343+
} catch (Exception e ) {
1344+
Log.e(TAG, "setTextDataError: "+e.getMessage());
13411345
}
13421346

13431347
viewHolder.txtMessage.setText(txtMessage);

uikit/src/main/java/adapter/SharedMediaAdapter.java

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.content.Context;
55
import android.content.DialogInterface;
66
import android.graphics.Bitmap;
7+
import android.graphics.BitmapFactory;
78
import android.view.LayoutInflater;
89
import android.view.View;
910
import android.view.ViewGroup;
@@ -26,6 +27,7 @@
2627
import com.cometchat.pro.uikit.R;
2728
import com.cometchat.pro.uikit.databinding.UserListRowBinding;
2829

30+
import java.io.ByteArrayOutputStream;
2931
import java.util.ArrayList;
3032
import java.util.List;
3133

@@ -172,29 +174,16 @@ private void setImageData(ImageViewHolder viewHolder, int i) {
172174
String smallUrl = Extensions.getThumbnailGeneration(context,message);
173175

174176
if (smallUrl!=null) {
175-
Glide.with(context).asBitmap().load(smallUrl).into(new SimpleTarget<Bitmap>() {
176-
@Override
177-
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
178-
if (isImageNotSafe)
179-
viewHolder.imageView.setImageBitmap(Utils.blur(context,resource));
180-
else
181-
viewHolder.imageView.setImageBitmap(resource);
182-
}
183-
});
177+
Glide.with(context).asBitmap().load(smallUrl).into(viewHolder.imageView);
184178
} else {
185-
Glide.with(context).asBitmap().load(((MediaMessage)message).getAttachment().getFileUrl()).into(new SimpleTarget<Bitmap>() {
186-
@Override
187-
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
188-
if (isImageNotSafe)
189-
viewHolder.imageView.setImageBitmap(Utils.blur(context,resource));
190-
else
191-
viewHolder.imageView.setImageBitmap(resource);
192-
}
193-
});
179+
Glide.with(context).asBitmap().load(((MediaMessage)message).getAttachment().getFileUrl())
180+
.into(viewHolder.imageView);
194181
}
195182
if (isImageNotSafe) {
183+
viewHolder.imageView.setAlpha(0.3f);
196184
viewHolder.sensitiveLayout.setVisibility(View.VISIBLE);
197185
} else {
186+
viewHolder.imageView.setAlpha(1f);
198187
viewHolder.sensitiveLayout.setVisibility(View.GONE);
199188
}
200189
viewHolder.imageView.setOnClickListener(view -> {
@@ -219,7 +208,6 @@ public void onClick(DialogInterface dialog, int which) {
219208
} else {
220209
MediaUtils.openFile(((MediaMessage) message).getAttachment().getFileUrl(), context);
221210
}
222-
223211
});
224212
viewHolder.itemView.setTag(R.string.baseMessage, message);
225213
}

uikit/src/main/java/com/cometchat/pro/uikit/Avatar.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import android.util.AttributeSet;
2020
import android.view.View;
2121
import android.view.ViewOutlineProvider;
22+
import android.widget.Toast;
2223

2324
import androidx.annotation.ColorInt;
2425
import androidx.annotation.NonNull;
@@ -389,19 +390,21 @@ public Drawable getDrawable()
389390
* Set user specific fields in here
390391
* */
391392
private void setValues() {
392-
393-
394-
if (avatarUrl != null && !avatarUrl.isEmpty()) {
395-
if (context!=null) {
396-
Glide.with(context)
397-
.load(avatarUrl)
398-
.placeholder(drawable)
399-
.centerCrop()
400-
.override(imageSize, imageSize)
401-
.into(this);
393+
try {
394+
if (avatarUrl != null && !avatarUrl.isEmpty()) {
395+
if (context != null) {
396+
Glide.with(context)
397+
.load(avatarUrl)
398+
.placeholder(drawable)
399+
.centerCrop()
400+
.override(imageSize, imageSize)
401+
.into(this);
402+
}
403+
} else {
404+
setImageDrawable(drawable);
402405
}
403-
} else {
404-
setImageDrawable(drawable);
406+
} catch (Exception e) {
407+
Toast.makeText(context,e.getMessage(),Toast.LENGTH_LONG).show();
405408
}
406409
invalidate();
407410
}

0 commit comments

Comments
 (0)