From 5cdad5c513fd1f5cb2d1d513cfe954fb006c409a Mon Sep 17 00:00:00 2001 From: darshanbhanushali Date: Tue, 17 Nov 2020 02:30:04 +0530 Subject: [PATCH] Android UI Kit v2.1.4 --- app/build.gradle | 2 +- .../pro/androiduikit/SelectActivity.java | 1 - .../pro/androiduikit/UIKitApplication.java | 9 +- uikit/build.gradle | 2 +- .../main/java/adapter/BlockedListAdapter.java | 1 - .../main/java/adapter/CallListAdapter.java | 13 +- .../java/adapter/ConversationListAdapter.java | 6 +- .../main/java/adapter/GroupListAdapter.java | 4 +- .../main/java/adapter/GroupMemberAdapter.java | 15 + .../src/main/java/adapter/MessageAdapter.java | 342 ++++++++++--- .../main/java/adapter/SharedMediaAdapter.java | 2 +- .../main/java/adapter/StickerTabAdapter.java | 89 ++++ .../main/java/adapter/StickersAdapter.java | 118 +++++ uikit/src/main/java/adapter/TabAdapter.java | 2 + .../src/main/java/adapter/ThreadAdapter.java | 3 +- .../java/com/cometchat/pro/uikit/Avatar.java | 16 +- .../pro/uikit/ComposeBox/ComposeBox.java | 45 +- .../ComposeBox/ComposeBoxActionFragment.java | 17 + .../pro/uikit/Settings/UIKitSettings.java | 331 ++++++++++++ .../pro/uikit/Settings/UISettings.java | 238 +++++++++ .../cometchat/pro/uikit/SharedMediaView.java | 40 +- .../pro/uikit/Sticker/StickerFragment.java | 71 +++ .../pro/uikit/Sticker/StickerView.java | 170 +++++++ .../listener/StickerClickListener.java | 7 + .../pro/uikit/Sticker/model/Sticker.java | 58 +++ .../cometchat/pro/uikit/UIKitSettings.java | 71 --- .../main/java/constant/StringContract.java | 29 +- .../java/listeners/CometChatCallListener.java | 10 +- .../java/listeners/ComposeActionListener.java | 3 + .../listeners/ExtensionResponseListener.java | 10 + .../java/listeners/ReactionClickListener.java | 8 + .../main/java/listeners/ReactionListener.java | 69 +++ .../java/screen/CometChatCallActivity.java | 32 +- .../CometChatGroupDetailScreenActivity.java | 151 ++++-- .../java/screen/CometChatGroupListScreen.java | 36 +- .../CometChatMessageInfoScreenActivity.java | 16 +- .../CometChatMorePrivacyScreenActivity.java | 5 + .../screen/CometChatStartCallActivity.java | 58 ++- .../CometChatUserCallListScreenActivity.java | 18 +- .../CometChatUserDetailScreenActivity.java | 60 ++- .../java/screen/CometChatUserInfoScreen.java | 20 +- .../java/screen/CometChatUserListScreen.java | 13 +- .../CometChatAddMemberScreenActivity.java | 4 + ...tChatAdminModeratorListScreenActivity.java | 4 + .../CometChatBanMemberScreenActivity.java | 19 +- .../CometChatBlockUserListScreenActivity.java | 6 +- .../screen/call/CometChatCallListScreen.java | 67 +-- .../CometChatCreateGroupScreenActivity.java | 6 +- ...ometChatGroupMemberListScreenActivity.java | 13 +- .../CometChatMessageListActivity.java | 11 +- .../messagelist/CometChatMessageScreen.java | 470 ++++++++++++++---- .../messagelist/MessageActionFragment.java | 2 + .../CometChatThreadMessageActivity.java | 11 +- .../CometChatThreadMessageScreen.java | 23 +- .../java/screen/unified/CometChatUnified.java | 80 ++- uikit/src/main/java/utils/CallUtils.java | 2 + uikit/src/main/java/utils/Extensions.java | 100 +++- uikit/src/main/java/utils/MediaUtils.java | 28 +- uikit/src/main/java/utils/Utils.java | 41 +- uikit/src/main/res/anim/animate_up_slide.xml | 7 + .../src/main/res/drawable/default_sticker.png | Bin 0 -> 427 bytes .../src/main/res/drawable/heart_reaction.png | Bin 0 -> 3475 bytes .../src/main/res/drawable/ic_close_circle.xml | 5 + uikit/src/main/res/drawable/ic_happy.xml | 44 ++ .../res/drawable/ic_keyboard_black_24dp.xml | 5 + ...ctivity_comet_chat_message_info_screen.xml | 8 +- .../layout/activity_user_detail_screen.xml | 3 +- .../res/layout/cometchat_sticker_view.xml | 30 ++ .../main/res/layout/fragment_chat_screen.xml | 26 +- .../layout/fragment_composebox_actions.xml | 14 + .../res/layout/fragment_stickers_view.xml | 12 + .../res/layout/fragment_thread_message.xml | 5 + .../main/res/layout/layout_compose_box.xml | 7 + .../res/layout/message_left_sticker_item.xml | 86 ++++ .../res/layout/message_right_sticker_item.xml | 64 +++ .../main/res/layout/reply_message_layout.xml | 4 +- uikit/src/main/res/layout/stickers_row.xml | 7 + uikit/src/main/res/values/color.xml | 2 + uikit/src/main/res/values/strings.xml | 60 ++- 79 files changed, 2941 insertions(+), 546 deletions(-) create mode 100644 uikit/src/main/java/adapter/StickerTabAdapter.java create mode 100644 uikit/src/main/java/adapter/StickersAdapter.java create mode 100644 uikit/src/main/java/com/cometchat/pro/uikit/Settings/UIKitSettings.java create mode 100644 uikit/src/main/java/com/cometchat/pro/uikit/Settings/UISettings.java create mode 100644 uikit/src/main/java/com/cometchat/pro/uikit/Sticker/StickerFragment.java create mode 100644 uikit/src/main/java/com/cometchat/pro/uikit/Sticker/StickerView.java create mode 100644 uikit/src/main/java/com/cometchat/pro/uikit/Sticker/listener/StickerClickListener.java create mode 100644 uikit/src/main/java/com/cometchat/pro/uikit/Sticker/model/Sticker.java delete mode 100644 uikit/src/main/java/com/cometchat/pro/uikit/UIKitSettings.java create mode 100644 uikit/src/main/java/listeners/ExtensionResponseListener.java create mode 100644 uikit/src/main/java/listeners/ReactionClickListener.java create mode 100644 uikit/src/main/java/listeners/ReactionListener.java create mode 100644 uikit/src/main/res/anim/animate_up_slide.xml create mode 100644 uikit/src/main/res/drawable/default_sticker.png create mode 100644 uikit/src/main/res/drawable/heart_reaction.png create mode 100644 uikit/src/main/res/drawable/ic_close_circle.xml create mode 100644 uikit/src/main/res/drawable/ic_happy.xml create mode 100644 uikit/src/main/res/drawable/ic_keyboard_black_24dp.xml create mode 100644 uikit/src/main/res/layout/cometchat_sticker_view.xml create mode 100644 uikit/src/main/res/layout/fragment_stickers_view.xml create mode 100644 uikit/src/main/res/layout/message_left_sticker_item.xml create mode 100644 uikit/src/main/res/layout/message_right_sticker_item.xml create mode 100644 uikit/src/main/res/layout/stickers_row.xml diff --git a/app/build.gradle b/app/build.gradle index 82255889..22bf38cc 100755 --- a/app/build.gradle +++ b/app/build.gradle @@ -58,5 +58,5 @@ dependencies { implementation 'com.google.android.material:material:1.2.0-alpha05' implementation 'com.facebook.shimmer:shimmer:0.4.0' // - implementation 'com.cometchat:pro-android-chat-sdk:2.1.3' + implementation 'com.cometchat:pro-android-chat-sdk:2.1.4' } diff --git a/app/src/main/java/com/cometchat/pro/androiduikit/SelectActivity.java b/app/src/main/java/com/cometchat/pro/androiduikit/SelectActivity.java index 717e6788..91e543de 100644 --- a/app/src/main/java/com/cometchat/pro/androiduikit/SelectActivity.java +++ b/app/src/main/java/com/cometchat/pro/androiduikit/SelectActivity.java @@ -12,7 +12,6 @@ import com.cometchat.pro.constants.CometChatConstants; import com.cometchat.pro.core.CometChat; import com.cometchat.pro.exceptions.CometChatException; -import com.cometchat.pro.uikit.UIKitSettings; import com.google.android.material.button.MaterialButton; import com.google.android.material.snackbar.Snackbar; diff --git a/app/src/main/java/com/cometchat/pro/androiduikit/UIKitApplication.java b/app/src/main/java/com/cometchat/pro/androiduikit/UIKitApplication.java index b25579ec..b8fcdb80 100644 --- a/app/src/main/java/com/cometchat/pro/androiduikit/UIKitApplication.java +++ b/app/src/main/java/com/cometchat/pro/androiduikit/UIKitApplication.java @@ -18,6 +18,7 @@ import com.cometchat.pro.exceptions.CometChatException; import com.cometchat.pro.androiduikit.constants.AppConfig; import com.cometchat.pro.helpers.Logger; +import com.cometchat.pro.uikit.Settings.UIKitSettings; import constant.StringContract; import listeners.CometChatCallListener; @@ -38,7 +39,8 @@ public void onCreate() { new CometChat.CallbackListener() { @Override public void onSuccess(String s) { - StringContract.AppInfo.API_KEY = AppConfig.AppDetails.API_KEY; + UIKitSettings.setAppID(AppConfig.AppDetails.APP_ID); + UIKitSettings.setAPIKey(AppConfig.AppDetails.API_KEY); CometChat.setSource("ui-kit","android","java"); Log.d(TAG, "onSuccess: "+s); } @@ -68,6 +70,11 @@ public void onConnecting() { public void onDisconnected() { Toast.makeText(getBaseContext(),"You have been disconnected.",Toast.LENGTH_LONG).show(); } + + @Override + public void onFeatureThrottled() { + + } }); } diff --git a/uikit/build.gradle b/uikit/build.gradle index 731aad04..9766cb68 100644 --- a/uikit/build.gradle +++ b/uikit/build.gradle @@ -68,7 +68,7 @@ dependencies { implementation 'com.google.android.gms:play-services-location:17.0.0' implementation 'com.google.android.gms:play-services-maps:17.0.0' //cometchat - compileOnly 'com.cometchat:pro-android-chat-sdk:2.1.3' + compileOnly 'com.cometchat:pro-android-chat-sdk:2.1.4' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.0" } repositories { diff --git a/uikit/src/main/java/adapter/BlockedListAdapter.java b/uikit/src/main/java/adapter/BlockedListAdapter.java index 77c42a90..da55a332 100644 --- a/uikit/src/main/java/adapter/BlockedListAdapter.java +++ b/uikit/src/main/java/adapter/BlockedListAdapter.java @@ -83,7 +83,6 @@ public void onBindViewHolder(@NonNull BlockedViewHolder blockedViewHolder, int i blockedViewHolder.userListRowBinding.tvSeprator.setVisibility(View.VISIBLE); } blockedViewHolder.userListRowBinding.txtUserName.setText(user.getName()); - blockedViewHolder.userListRowBinding.avUser.setBackgroundColor(context.getResources().getColor(R.color.colorPrimary)); blockedViewHolder.userListRowBinding.getRoot().setTag(R.string.user, user); blockedViewHolder.userListRowBinding.txtUserScope.setVisibility(View.GONE); blockedViewHolder.userListRowBinding.unblockUser.setVisibility(View.VISIBLE); diff --git a/uikit/src/main/java/adapter/CallListAdapter.java b/uikit/src/main/java/adapter/CallListAdapter.java index 74d15b41..0f0bb7ec 100644 --- a/uikit/src/main/java/adapter/CallListAdapter.java +++ b/uikit/src/main/java/adapter/CallListAdapter.java @@ -1,10 +1,11 @@ package adapter; import android.content.Context; +import android.content.res.ColorStateList; +import android.graphics.Color; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.Toast; import androidx.annotation.NonNull; import androidx.databinding.DataBindingUtil; @@ -13,7 +14,6 @@ import com.cometchat.pro.constants.CometChatConstants; import com.cometchat.pro.core.Call; import com.cometchat.pro.core.CometChat; -import com.cometchat.pro.exceptions.CometChatException; import com.cometchat.pro.models.BaseMessage; import com.cometchat.pro.models.Conversation; import com.cometchat.pro.models.Group; @@ -22,10 +22,10 @@ import com.cometchat.pro.uikit.databinding.CallListRowBinding; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import utils.FontUtils; +import com.cometchat.pro.uikit.Settings.UISettings; import utils.Utils; /** @@ -190,6 +190,13 @@ public void onBindViewHolder(@NonNull CallViewHolder callViewHolder, int positio callViewHolder.callListRowBinding.calltimeTv.setText(Utils.getLastMessageDate(call.getInitiatedAt())); callViewHolder.callListRowBinding.callMessage.setText(callMessageText); callViewHolder.callListRowBinding.getRoot().setTag(R.string.call, call); + if (UISettings.isEnableVoiceCalling()) + callViewHolder.callListRowBinding.callIv.setVisibility(View.VISIBLE); + else + callViewHolder.callListRowBinding.callIv.setVisibility(View.GONE); + + callViewHolder.callListRowBinding.callIv.setImageTintList( + ColorStateList.valueOf(Color.parseColor(UISettings.getColor()))); } diff --git a/uikit/src/main/java/adapter/ConversationListAdapter.java b/uikit/src/main/java/adapter/ConversationListAdapter.java index e65c499a..2584ea1c 100644 --- a/uikit/src/main/java/adapter/ConversationListAdapter.java +++ b/uikit/src/main/java/adapter/ConversationListAdapter.java @@ -2,6 +2,7 @@ import android.content.Context; +import android.graphics.Color; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -29,6 +30,7 @@ import utils.Extensions; import utils.FontUtils; +import com.cometchat.pro.uikit.Settings.UISettings; import utils.Utils; /** @@ -162,7 +164,9 @@ public void onBindViewHolder(@NonNull ConversationViewHolder conversationViewHol conversationViewHolder.conversationListRowBinding.messageCount.setCount(conversation.getUnreadMessageCount()); conversationViewHolder.conversationListRowBinding.txtUserName.setText(name); - conversationViewHolder.conversationListRowBinding.avUser.setBackgroundColor(context.getResources().getColor(R.color.colorPrimary)); + conversationViewHolder.conversationListRowBinding.avUser.setBackgroundColor(Color.parseColor(UISettings.getColor())); + conversationViewHolder.conversationListRowBinding.messageCount.setCountBackground(Color.parseColor(UISettings.getColor())); + if (avatar != null && !avatar.isEmpty()) { conversationViewHolder.conversationListRowBinding.avUser.setAvatar(avatar); diff --git a/uikit/src/main/java/adapter/GroupListAdapter.java b/uikit/src/main/java/adapter/GroupListAdapter.java index 0a332eab..7fe8614a 100644 --- a/uikit/src/main/java/adapter/GroupListAdapter.java +++ b/uikit/src/main/java/adapter/GroupListAdapter.java @@ -2,6 +2,7 @@ import android.content.Context; import android.content.res.ColorStateList; +import android.graphics.Color; import android.view.LayoutInflater; import android.view.ViewGroup; @@ -11,6 +12,7 @@ import com.cometchat.pro.constants.CometChatConstants; import com.cometchat.pro.uikit.R; +import com.cometchat.pro.uikit.Settings.UISettings; import com.cometchat.pro.uikit.databinding.GroupListRowBinding; import com.cometchat.pro.models.Group; @@ -94,7 +96,7 @@ else if (group.getGroupType().equals(CometChatConstants.GROUP_TYPE_PASSWORD)) groupViewHolder.groupListRowBinding.txtUserName.setCompoundDrawablesWithIntrinsicBounds(0,0,0,0); groupViewHolder.groupListRowBinding.executePendingBindings(); - groupViewHolder.groupListRowBinding.avGroup.setBackgroundColor(context.getResources().getColor(R.color.colorPrimary)); + groupViewHolder.groupListRowBinding.avGroup.setBackgroundColor(Color.parseColor(UISettings.getColor())); groupViewHolder.groupListRowBinding.getRoot().setTag(R.string.group, group); groupViewHolder.groupListRowBinding.txtUserMessage.setTypeface(fontUtils.getTypeFace(FontUtils.robotoRegular)); groupViewHolder.groupListRowBinding.txtUserName.setTypeface(fontUtils.getTypeFace(FontUtils.robotoMedium)); diff --git a/uikit/src/main/java/adapter/GroupMemberAdapter.java b/uikit/src/main/java/adapter/GroupMemberAdapter.java index 524605c1..04240d71 100644 --- a/uikit/src/main/java/adapter/GroupMemberAdapter.java +++ b/uikit/src/main/java/adapter/GroupMemberAdapter.java @@ -13,6 +13,7 @@ import com.cometchat.pro.core.CometChat; import com.cometchat.pro.models.GroupMember; import com.cometchat.pro.models.TypingIndicator; +import com.cometchat.pro.models.User; import com.cometchat.pro.uikit.R; import com.cometchat.pro.uikit.databinding.UserListRowBinding; @@ -121,6 +122,11 @@ public void onBindViewHolder(@NonNull GroupMemberViewHolder groupMemberViewHolde else groupMemberViewHolder.userListRowBinding.avUser.setAvatar(groupMember.getAvatar()); + if (groupMember.getStatus().equalsIgnoreCase(CometChatConstants.USER_STATUS_ONLINE)) + groupMemberViewHolder.userListRowBinding.statusIndicator.setVisibility(View.VISIBLE); + + groupMemberViewHolder.userListRowBinding.statusIndicator.setUserStatus(groupMember.getStatus()); + if (Utils.isDarkMode(context)) { groupMemberViewHolder.userListRowBinding.txtUserName.setTextColor(context.getResources().getColor(R.color.textColorWhite)); @@ -210,6 +216,15 @@ public void updateMember(GroupMember groupMember) { } } + public void updateMemberByStatus(User user) { + for (GroupMember groupMember : groupMemberList) { + if (groupMember.getUid().equalsIgnoreCase(user.getUid())) { + int index = groupMemberList.indexOf(groupMember); + groupMember.setStatus(user.getStatus()); + notifyItemChanged(index); + } + } + } public void resetAdapter() { groupMemberList.clear(); notifyDataSetChanged(); diff --git a/uikit/src/main/java/adapter/MessageAdapter.java b/uikit/src/main/java/adapter/MessageAdapter.java index 602943d7..d73ee890 100644 --- a/uikit/src/main/java/adapter/MessageAdapter.java +++ b/uikit/src/main/java/adapter/MessageAdapter.java @@ -1,7 +1,6 @@ package adapter; import android.app.AlertDialog; -import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; @@ -11,7 +10,6 @@ import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; import android.graphics.Typeface; -import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.media.MediaPlayer; import android.net.Uri; @@ -37,9 +35,7 @@ import com.bumptech.glide.Glide; import com.bumptech.glide.load.engine.DiskCacheStrategy; -import com.bumptech.glide.load.resource.gif.GifDrawable; import com.bumptech.glide.request.target.CustomTarget; -import com.bumptech.glide.request.target.SimpleTarget; import com.bumptech.glide.request.transition.Transition; import com.cometchat.pro.constants.CometChatConstants; import com.cometchat.pro.core.Call; @@ -54,6 +50,7 @@ import com.cometchat.pro.models.MessageReceipt; import com.cometchat.pro.models.TextMessage; import com.cometchat.pro.models.User; +import com.cometchat.pro.uikit.Settings.UISettings; import com.google.android.material.button.MaterialButton; import org.json.JSONException; @@ -73,7 +70,6 @@ import utils.FontUtils; import utils.MediaUtils; import utils.Utils; -import utils.ZoomIv; /** * Purpose - MessageAdapter is a subclass of RecyclerView Adapter which is used to display @@ -94,6 +90,10 @@ public class MessageAdapter extends RecyclerView.Adapter { + Intent intent = new Intent(context, CometChatThreadMessageActivity.class); +// intent.putExtra(StringContract.IntentStrings.PARENT_BASEMESSAGE,baseMessage.toString()); + intent.putExtra(StringContract.IntentStrings.NAME,baseMessage.getSender().getName()); + intent.putExtra(StringContract.IntentStrings.AVATAR,baseMessage.getSender().getAvatar()); + intent.putExtra(StringContract.IntentStrings.REPLY_COUNT,baseMessage.getReplyCount()); + intent.putExtra(StringContract.IntentStrings.UID,baseMessage.getSender().getName()); + intent.putExtra(StringContract.IntentStrings.PARENT_ID,baseMessage.getId()); + intent.putExtra(StringContract.IntentStrings.MESSAGE_TYPE,StringContract.IntentStrings.STICKERS); + intent.putExtra(StringContract.IntentStrings.SENTAT,baseMessage.getSentAt()); + try { + intent.putExtra(StringContract.IntentStrings.MESSAGE_TYPE_IMAGE_NAME,((CustomMessage)baseMessage).getCustomData().getString("name")); + intent.putExtra(StringContract.IntentStrings.MESSAGE_TYPE_IMAGE_URL,((CustomMessage)baseMessage).getCustomData().getString("url")); + } catch (JSONException e) { + e.printStackTrace(); + } + intent.putExtra(StringContract.IntentStrings.TYPE,baseMessage.getReceiverType()); + intent.putExtra(StringContract.IntentStrings.MESSAGE_CATEGORY,baseMessage.getCategory()); + if (baseMessage.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_GROUP)) { + intent.putExtra(StringContract.IntentStrings.GUID,baseMessage.getReceiverUid()); + } + else { + if (baseMessage.getReceiverUid().equals(loggedInUser.getUid())) + intent.putExtra(StringContract.IntentStrings.UID,baseMessage.getSender().getUid()); + else + intent.putExtra(StringContract.IntentStrings.UID,baseMessage.getReceiverUid()); + } + context.startActivity(intent); + }); + + + + showMessageTime(viewHolder, baseMessage); +// if (selectedItemList.contains(baseMessage.getId())) + viewHolder.txtTime.setVisibility(View.VISIBLE); +// else +// viewHolder.txtTime.setVisibility(View.GONE); + + + viewHolder.stickerView.setOnLongClickListener(new View.OnLongClickListener() { + @Override + public boolean onLongClick(View v) { + if (!isLongClickEnabled && !isTextMessageClick) { + isImageMessageClick = true; + setLongClickSelectedItem(baseMessage); + messageLongClick.setLongMessageClick(longselectedItemList); + notifyDataSetChanged(); + } + return true; + } + }); + } + + private void setVideoData(VideoMessageViewHolder viewHolder, int i) { @@ -1207,7 +1316,7 @@ private void setVideoData(VideoMessageViewHolder viewHolder, int i) { } if (((MediaMessage)baseMessage).getAttachment()!=null) Glide.with(context).load(((MediaMessage) baseMessage).getAttachment().getFileUrl()).into(viewHolder.imageView); - if (baseMessage.getReplyCount()!=0) { + if (baseMessage.getReplyCount()!=0 && UISettings.isEnableThreadedReplies()) { viewHolder.tvThreadReplyCount.setVisibility(View.VISIBLE); viewHolder.tvThreadReplyCount.setText(baseMessage.getReplyCount()+" Replies"); } else { @@ -1311,7 +1420,7 @@ private void setDeleteData(DeleteMessageViewHolder viewHolder, int i) { viewHolder.txtMessage.setTypeface(null, Typeface.ITALIC); } showMessageTime(viewHolder, baseMessage); - + setColorFilter(baseMessage,viewHolder.cardView); // if (selectedItemList.contains(baseMessage.getId())) viewHolder.txtTime.setVisibility(View.VISIBLE); // else @@ -1412,6 +1521,10 @@ private void showMessageTime(RecyclerView.ViewHolder viewHolder, BaseMessage bas setStatusIcon(((AudioMessageViewHolder)viewHolder).txtTime, baseMessage); } else if (viewHolder instanceof LocationMessageViewHolder){ setStatusIcon(((LocationMessageViewHolder) viewHolder).txtTime, baseMessage); + } else if (viewHolder instanceof PollMessageViewHolder) { + setStatusIcon(((PollMessageViewHolder) viewHolder).txtTime, baseMessage); + } else if (viewHolder instanceof StickerMessageViewHolder) { + setStatusIcon(((StickerMessageViewHolder) viewHolder).txtTime,baseMessage); } } @@ -1426,26 +1539,28 @@ private void showMessageTime(RecyclerView.ViewHolder viewHolder, BaseMessage bas * @see BaseMessage */ private void setStatusIcon(TextView txtTime, BaseMessage baseMessage) { - if (baseMessage.getSender().getUid().equals(loggedInUser.getUid())) { - if (baseMessage.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_USER)) { - if (baseMessage.getReadAt() != 0) { - txtTime.setText(Utils.getHeaderDate(baseMessage.getReadAt() * 1000)); - txtTime.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_double_tick, 0); - txtTime.setCompoundDrawablePadding(10); - } else if (baseMessage.getDeliveredAt() != 0) { - txtTime.setText(Utils.getHeaderDate(baseMessage.getDeliveredAt() * 1000)); - txtTime.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_done_all_black_24dp, 0); - txtTime.setCompoundDrawablePadding(10); + if (UISettings.isShowReadDeliveryReceipts()) { + if (baseMessage.getSender().getUid().equals(loggedInUser.getUid())) { + if (baseMessage.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_USER)) { + if (baseMessage.getReadAt() != 0) { + txtTime.setText(Utils.getHeaderDate(baseMessage.getReadAt() * 1000)); + txtTime.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_double_tick, 0); + txtTime.setCompoundDrawablePadding(10); + } else if (baseMessage.getDeliveredAt() != 0) { + txtTime.setText(Utils.getHeaderDate(baseMessage.getDeliveredAt() * 1000)); + txtTime.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_done_all_black_24dp, 0); + txtTime.setCompoundDrawablePadding(10); + } else { + txtTime.setText(Utils.getHeaderDate(baseMessage.getSentAt() * 1000)); + txtTime.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_check_black_24dp, 0); + txtTime.setCompoundDrawablePadding(10); + } } else { txtTime.setText(Utils.getHeaderDate(baseMessage.getSentAt() * 1000)); - txtTime.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_check_black_24dp, 0); - txtTime.setCompoundDrawablePadding(10); } } else { txtTime.setText(Utils.getHeaderDate(baseMessage.getSentAt() * 1000)); } - } else { - txtTime.setText(Utils.getHeaderDate(baseMessage.getSentAt() * 1000)); } } @@ -1542,13 +1657,29 @@ public void onClick(DialogInterface dialog, int which) { } else if (messageType.equals(StringContract.IntentStrings.POLLS)) { viewHolder.replyMessage.setText(String.format(context.getString(R.string.shared_a_polls),message)); viewHolder.replyMessage.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_poll_24dp,0,0,0); + } else if (messageType.equals(StringContract.IntentStrings.STICKERS)) { + viewHolder.replyMessage.setText(String.format(context.getString(R.string.shared_a_sticker))); + viewHolder.replyMessage.setCompoundDrawablesWithIntrinsicBounds(R.drawable.default_sticker,0,0,0); } + viewHolder.rlMessageBubble.setOnLongClickListener(new View.OnLongClickListener() { + @Override + public boolean onLongClick(View view) { + if (!isImageMessageClick) { + isLongClickEnabled = true; + isTextMessageClick = true; + setLongClickSelectedItem(baseMessage); + messageLongClick.setLongMessageClick(longselectedItemList); + notifyDataSetChanged(); + } + return true; + } + }); }catch (Exception e) { Log.e(TAG, "setTextData: "+e.getMessage()); } } - if (baseMessage.getReplyCount()!=0) { + if (baseMessage.getReplyCount()!=0 && UISettings.isEnableThreadedReplies()) { viewHolder.tvThreadReplyCount.setVisibility(View.VISIBLE); viewHolder.tvThreadReplyCount.setText(baseMessage.getReplyCount()+" Replies"); } else { @@ -1590,10 +1721,12 @@ public void onClick(DialogInterface dialog, int which) { Spannable spannable = (Spannable) processed; count = spannable.getSpans(0, spannable.length() - 1, EmojiSpan.class).length; if (Utils.removeEmojiAndSymbol(txtMessage).trim().length() == 0) { - if (count == 1) { - viewHolder.txtMessage.setTextSize((int) Utils.dpToPx(context, 32)); - } else if (count == 2) { - viewHolder.txtMessage.setTextSize((int) Utils.dpToPx(context, 24)); + if (UISettings.isSendEmojisLargeSize()) { + if (count == 1) { + viewHolder.txtMessage.setTextSize((int) Utils.dpToPx(context, 32)); + } else if (count == 2) { + viewHolder.txtMessage.setTextSize((int) Utils.dpToPx(context, 24)); + } } } } @@ -1633,7 +1766,7 @@ public boolean onLongClick(View view) { // else // viewHolder.txtTime.setVisibility(View.GONE); - setColorFilter(baseMessage,viewHolder.cardView); + setColorFilter(baseMessage,viewHolder.cvMessageView); // viewHolder.rlMessageBubble.setOnClickListener(view -> { // if (isLongClickEnabled && !isImageMessageClick) { @@ -1706,7 +1839,7 @@ private void setCustomData(CustomMessageViewHolder viewHolder, int i) { viewHolder.txtTime.setVisibility(View.VISIBLE); // else // viewHolder.txtTime.setVisibility(View.GONE); - + setColorFilter(baseMessage,viewHolder.cardView); viewHolder.rlMessageBubble.setOnClickListener(view -> { setSelectedMessage(baseMessage.getId()); notifyDataSetChanged(); @@ -1721,21 +1854,35 @@ private void setColorFilter(BaseMessage baseMessage,View view){ if (!longselectedItemList.contains(baseMessage)) { if (baseMessage.getSender().equals(CometChat.getLoggedInUser())) { - if (Build.VERSION.SDK_INT >= 29) - view.getBackground().setColorFilter(new PorterDuffColorFilter(context.getColor(R.color.colorPrimary),PorterDuff.Mode.SRC_ATOP)); - else - view.getBackground().setColorFilter(context.getResources().getColor(R.color.colorPrimary), PorterDuff.Mode.SRC_ATOP); + if (view instanceof CardView) { + ((CardView)view).setCardBackgroundColor(Color.parseColor(UISettings.getColor())); + } else { + if (Build.VERSION.SDK_INT >= 29) { + view.getBackground().setColorFilter(new PorterDuffColorFilter(Color.parseColor(UISettings.getColor()), PorterDuff.Mode.SRC_ATOP)); + } else { + view.getBackground().setColorFilter(Color.parseColor(UISettings.getColor()), PorterDuff.Mode.SRC_ATOP); + } + } } else { - if (Build.VERSION.SDK_INT>=29) - view.getBackground().setColorFilter(new PorterDuffColorFilter(context.getColor(R.color.message_bubble_grey),PorterDuff.Mode.SRC_ATOP)); - else - view.getBackground().setColorFilter(context.getResources().getColor(R.color.message_bubble_grey), PorterDuff.Mode.SRC_ATOP); + if (!(view instanceof CardView)) { + if (Build.VERSION.SDK_INT >= 29) + view.getBackground().setColorFilter(new PorterDuffColorFilter(context.getColor(R.color.message_bubble_grey), PorterDuff.Mode.SRC_ATOP)); + else + view.getBackground().setColorFilter(context.getResources().getColor(R.color.message_bubble_grey), PorterDuff.Mode.SRC_ATOP); + } } } else { - if (baseMessage.getSender().equals(CometChat.getLoggedInUser())) - view.getBackground().setColorFilter(context.getResources().getColor(R.color.colorPrimaryDark), PorterDuff.Mode.SRC_ATOP); - else - view.getBackground().setColorFilter(context.getResources().getColor(R.color.secondaryTextColor), PorterDuff.Mode.SRC_ATOP); + if ((UISettings.isEnableEditingMessage() && + UISettings.isEnableDeleteMessage()) || + UISettings.isEnableShareCopyForward() || + UISettings.isEnableThreadedReplies() || + UISettings.isEnableReplyToMessage()) { + if (baseMessage.getSender().equals(CometChat.getLoggedInUser())) + view.getBackground().setColorFilter(context.getResources().getColor(R.color.colorPrimaryDark), PorterDuff.Mode.SRC_ATOP); + else + view.getBackground().setColorFilter(context.getResources().getColor(R.color.secondaryTextColor), PorterDuff.Mode.SRC_ATOP); + + } } } @@ -1802,7 +1949,7 @@ private void setLinkData(LinkMessageViewHolder viewHolder, int i) { } } - if (baseMessage.getReplyCount()!=0) { + if (baseMessage.getReplyCount()!=0 && UISettings.isEnableThreadedReplies()) { viewHolder.tvThreadReplyCount.setVisibility(View.VISIBLE); viewHolder.tvThreadReplyCount.setText(baseMessage.getReplyCount()+" Replies"); } else { @@ -1866,6 +2013,7 @@ public void onClick(View v) { // } else // viewHolder.txtTime.setVisibility(View.VISIBLE); + setColorFilter(baseMessage,viewHolder.cvMessageView); viewHolder.rlMessageBubble.setOnClickListener(view -> { if (isLongClickEnabled && !isImageMessageClick) { setLongClickSelectedItem(baseMessage); @@ -2037,6 +2185,8 @@ else if (baseMessage.getMetadata()!=null && baseMessage.getMetadata().has("reply return RIGHT_LOCATION_CUSTOM_MESSAGE; else if (baseMessage.getType().equalsIgnoreCase(StringContract.IntentStrings.POLLS)) return RIGHT_POLLS_CUSTOM_MESSAGE; + else if (baseMessage.getType().equalsIgnoreCase(StringContract.IntentStrings.STICKERS)) + return RIGHT_STICKER_MESSAGE; else return RIGHT_CUSTOM_MESSAGE; } @@ -2045,6 +2195,8 @@ else if (baseMessage.getType().equalsIgnoreCase(StringContract.IntentStrings.POL return LEFT_LOCATION_CUSTOM_MESSAGE; else if (baseMessage.getType().equalsIgnoreCase(StringContract.IntentStrings.POLLS)) return LEFT_POLLS_CUSTOM_MESSAGE; + else if (baseMessage.getType().equalsIgnoreCase(StringContract.IntentStrings.STICKERS)) + return LEFT_STICKER_MESSAGE; else return LEFT_CUSTOM_MESSAGE; } @@ -2246,6 +2398,7 @@ public class FileMessageViewHolder extends RecyclerView.ViewHolder { private TextView tvUser; private View view; private Avatar ivUser; + private RelativeLayout cvMessageView; private RelativeLayout rlMessageBubble; private TextView tvThreadReplyCount; private LinearLayout lvReplyAvatar; @@ -2258,6 +2411,7 @@ public class FileMessageViewHolder extends RecyclerView.ViewHolder { fileExt = itemView.findViewById(R.id.tvFileExtension); txtTime = itemView.findViewById(R.id.txt_time); fileName = itemView.findViewById(R.id.tvFileName); + cvMessageView = itemView.findViewById(R.id.cv_message_container); rlMessageBubble = itemView.findViewById(R.id.rl_message); tvThreadReplyCount = itemView.findViewById(R.id.thread_reply_count); lvReplyAvatar = itemView.findViewById(R.id.reply_avatar_layout); @@ -2301,7 +2455,7 @@ public class DeleteMessageViewHolder extends RecyclerView.ViewHolder { public class TextMessageViewHolder extends RecyclerView.ViewHolder { private RelativeLayout rlMessageBubble; - private RelativeLayout cardView; + private RelativeLayout cvMessageView; private View view; private TextView txtMessage; //Text Message private TextView tvThreadReplyCount; //Thread Reply Count @@ -2326,7 +2480,7 @@ public class TextMessageViewHolder extends RecyclerView.ViewHolder { type = (int) view.getTag(); tvUser = view.findViewById(R.id.tv_user); txtMessage = view.findViewById(R.id.go_txt_message); - cardView = view.findViewById(R.id.cv_message_container); + cvMessageView = view.findViewById(R.id.cv_message_container); txtTime = view.findViewById(R.id.txt_time); imgStatus = view.findViewById(R.id.img_pending); ivUser = view.findViewById(R.id.iv_user); @@ -2371,6 +2525,31 @@ public class CustomMessageViewHolder extends RecyclerView.ViewHolder { } } + public class StickerMessageViewHolder extends RecyclerView.ViewHolder { + public ImageView stickerView; + public TextView tvThreadReplyCount; + public TextView txtTime; + public TextView tvUser; + public Avatar ivUser; + + public int type; + public View view; + + public StickerMessageViewHolder(View itemView) { + super(itemView); + + type = (int) itemView.getTag(); + + stickerView = itemView.findViewById(R.id.sticker_view); + tvUser = itemView.findViewById(R.id.tv_user); + ivUser = itemView.findViewById(R.id.iv_user); + tvThreadReplyCount = itemView.findViewById(R.id.thread_reply_count); + txtTime = itemView.findViewById(R.id.txt_time); + + this.view = itemView; + + } + } public class LocationMessageViewHolder extends RecyclerView.ViewHolder { public RelativeLayout rlMessageBubble; private View view; @@ -2381,6 +2560,8 @@ public class LocationMessageViewHolder extends RecyclerView.ViewHolder { public TextView senderTxt; public MaterialButton navigateBtn; + public CardView cvMessageView; + public TextView tvThreadReplyCount; public TextView txtTime; public TextView tvUser; @@ -2394,6 +2575,7 @@ public LocationMessageViewHolder(View itemView) { ivMap = itemView.findViewById(R.id.iv_map); tvAddress = itemView.findViewById(R.id.tv_place_name); txtTime = itemView.findViewById(R.id.txt_time); + cvMessageView = itemView.findViewById(R.id.cv_message_container); rlMessageBubble = itemView.findViewById(R.id.rl_message); tvUser = itemView.findViewById(R.id.tv_user); ivUser = itemView.findViewById(R.id.iv_user); @@ -2414,6 +2596,7 @@ public class PollMessageViewHolder extends RecyclerView.ViewHolder { public LinearLayout optionGroup; public ProgressBar loadingProgress; + public LinearLayout cvMessageView; public TextView tvThreadReplyCount; public TextView txtTime; public TextView tvUser; @@ -2429,6 +2612,7 @@ public PollMessageViewHolder(View itemView) { optionGroup = itemView.findViewById(R.id.options_group); txtTime = itemView.findViewById(R.id.txt_time); rlMessageBubble = itemView.findViewById(R.id.rl_message); + cvMessageView = itemView.findViewById(R.id.cv_message_container); tvUser = itemView.findViewById(R.id.tv_user); ivUser = itemView.findViewById(R.id.iv_user); loadingProgress = itemView.findViewById(R.id.loading_progressBar); @@ -2468,7 +2652,7 @@ public class LinkMessageViewHolder extends RecyclerView.ViewHolder { private TextView linkSubtitle; private TextView message; private ImageView videoLink; - private RelativeLayout cardView; + private CardView cvMessageView; private View view; public TextView txtTime; private ImageView imgStatus; @@ -2491,7 +2675,7 @@ public class LinkMessageViewHolder extends RecyclerView.ViewHolder { linkImg = view.findViewById(R.id.link_img); message = view.findViewById(R.id.message); videoLink = view.findViewById(R.id.videoLink); - cardView = view.findViewById(R.id.cv_message_container); + cvMessageView = view.findViewById(R.id.cv_link_message_container); txtTime = view.findViewById(R.id.txt_time); imgStatus = view.findViewById(R.id.img_pending); ivUser = view.findViewById(R.id.iv_user); diff --git a/uikit/src/main/java/adapter/SharedMediaAdapter.java b/uikit/src/main/java/adapter/SharedMediaAdapter.java index d65548b6..31f8bc67 100644 --- a/uikit/src/main/java/adapter/SharedMediaAdapter.java +++ b/uikit/src/main/java/adapter/SharedMediaAdapter.java @@ -74,7 +74,7 @@ public SharedMediaAdapter(Context context) { } /** - * It is constructor which takes userArrayList as parameter and bind it with userArrayList in adapter. + * It is constructor which takes messageArrayList as parameter and bind it with messageArrayList in adapter. * * @param context is a object of Context. * @param messageArrayList is a list of messages used in this adapter. diff --git a/uikit/src/main/java/adapter/StickerTabAdapter.java b/uikit/src/main/java/adapter/StickerTabAdapter.java new file mode 100644 index 00000000..d154240c --- /dev/null +++ b/uikit/src/main/java/adapter/StickerTabAdapter.java @@ -0,0 +1,89 @@ +package adapter; + +import android.content.Context; +import android.graphics.drawable.Drawable; +import android.text.SpannableStringBuilder; +import android.text.Spanned; +import android.text.style.DynamicDrawableSpan; +import android.text.style.ImageSpan; +import android.util.Log; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentStatePagerAdapter; + +import com.bumptech.glide.Glide; +import com.bumptech.glide.request.target.CustomTarget; +import com.bumptech.glide.request.transition.Transition; +import com.cometchat.pro.uikit.R; + +import java.util.ArrayList; +import java.util.List; + + +public class StickerTabAdapter extends FragmentStatePagerAdapter { + private Drawable myDrawable; + private SpannableStringBuilder sb; + private final List mFragmentList = new ArrayList<>(); + private final List mFragmentTitleList = new ArrayList<>(); + private final List mFragmentIconList = new ArrayList<>(); + private Context context; + public StickerTabAdapter(Context context,FragmentManager fm) { + super(fm); + this.context = context; + } + + @Override + public Fragment getItem(int position) { + return mFragmentList.get(position); + + } + public void addFragment(Fragment fragment, String title) { + mFragmentList.add(fragment); + mFragmentTitleList.add(title); + } + + public void addFragment(Fragment fragment, String title,String icon) { + mFragmentList.add(fragment); + mFragmentTitleList.add(title); + mFragmentIconList.add(icon); + } + + public String getPageIcon(int position) { return mFragmentIconList.get(position); } + @Nullable + @Override + public CharSequence getPageTitle(int position) { + sb = new SpannableStringBuilder(""); // space added before text for convenience +// myDrawable = context.getResources().getDrawable(R.drawable.default_sticker); +// myDrawable.setBounds(5, 15, myDrawable.getIntrinsicWidth(), myDrawable.getIntrinsicHeight()); +// ImageSpan span = new ImageSpan(myDrawable, DynamicDrawableSpan.ALIGN_BASELINE); +// sb.setSpan(span, 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); +// Glide.with(context).load(mFragmentIconList.get(position)).into(new CustomTarget() { +// @Override +// public void onResourceReady(@NonNull Drawable resource, @Nullable Transition transition) { +// myDrawable = resource; +// try { +// sb = new SpannableStringBuilder(" "); +// myDrawable.setBounds(5, 5, myDrawable.getIntrinsicWidth(), myDrawable.getIntrinsicHeight()); +// ImageSpan span = new ImageSpan(myDrawable, DynamicDrawableSpan.ALIGN_BASELINE); +// sb.setSpan(span, 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); +// } catch (Exception e) { +// Log.e("Icon: ", e.getMessage()); +// } +// } +// +// @Override +// public void onLoadCleared(@Nullable Drawable placeholder) { +// +// } +// }); + + return sb; + } + @Override + public int getCount() { + return mFragmentList.size(); + } +} diff --git a/uikit/src/main/java/adapter/StickersAdapter.java b/uikit/src/main/java/adapter/StickersAdapter.java new file mode 100644 index 00000000..1dcd8903 --- /dev/null +++ b/uikit/src/main/java/adapter/StickersAdapter.java @@ -0,0 +1,118 @@ +package adapter; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.bumptech.glide.Glide; +import com.cometchat.pro.uikit.R; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +import com.cometchat.pro.uikit.Sticker.model.Sticker; + +/** + * Purpose - UserListAdapter is a subclass of RecyclerView Adapter which is used to display + * the list of users. It helps to organize the users in recyclerView. + * + * Created on - 20th December 2019 + * + * Modified on - 23rd March 2020 + * + */ + +public class StickersAdapter extends RecyclerView.Adapter { + + private Context context; + + private List stickerArrayList = new ArrayList<>(); + + private static final String TAG = "StickerAdapter"; + + private static final int STICKER_IMAGE = 1; + + /** + * It is a contructor which is used to initialize wherever we needed. + * + * @param context is a object of Context. + */ + public StickersAdapter(Context context) { + this.context = context; + } + + /** + * It is constructor which takes stickerArrayList as parameter and bind it with stickerArrayList in adapter. + * + * @param context is a object of Context. + * @param stickerArrayList is a list of stickers used in this adapter. + */ + public StickersAdapter(Context context, List stickerArrayList) { + setStickerList(stickerArrayList); + this.context = context; + } + + private void setStickerList(List stickerArrayList) { + Collections.sort(stickerArrayList, new Comparator() { + @Override + public int compare(Sticker sticker, Sticker t1) { + return sticker.getSetName().compareTo(t1.getSetName()); + } + }); + this.stickerArrayList = stickerArrayList; + notifyDataSetChanged(); + } + + + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i) { + LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext()); + View view = layoutInflater.inflate(R.layout.stickers_row, parent, false); + return new ImageViewHolder(view); + + } + + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int i) { + setStickerData((ImageViewHolder) viewHolder, i); + + } + + + + private void setStickerData(ImageViewHolder viewHolder, int i) { + Sticker sticker = stickerArrayList.get(i); + Glide.with(context).asBitmap().load(sticker.getUrl()) + .into(viewHolder.imageView); + viewHolder.itemView.setTag(R.string.sticker, sticker); + } + + @Override + public int getItemCount() { + return stickerArrayList.size(); + } + + public void updateStickerList(List stickerList) { + setStickerList(stickerList); + } + + + class ImageViewHolder extends RecyclerView.ViewHolder { + + private ImageView imageView; + + public ImageViewHolder(@NonNull View itemView) { + super(itemView); + imageView = itemView.findViewById(R.id.imageView); + } + } +} diff --git a/uikit/src/main/java/adapter/TabAdapter.java b/uikit/src/main/java/adapter/TabAdapter.java index f107a547..d6a6afd1 100644 --- a/uikit/src/main/java/adapter/TabAdapter.java +++ b/uikit/src/main/java/adapter/TabAdapter.java @@ -12,6 +12,7 @@ public class TabAdapter extends FragmentStatePagerAdapter { private final List mFragmentList = new ArrayList<>(); private final List mFragmentTitleList = new ArrayList<>(); + private final List mFragmentIconList = new ArrayList<>(); public TabAdapter(FragmentManager fm) { super(fm); } @@ -25,6 +26,7 @@ public void addFragment(Fragment fragment, String title) { mFragmentList.add(fragment); mFragmentTitleList.add(title); } + @Nullable @Override public CharSequence getPageTitle(int position) { diff --git a/uikit/src/main/java/adapter/ThreadAdapter.java b/uikit/src/main/java/adapter/ThreadAdapter.java index 5e22cd60..0a41e92c 100644 --- a/uikit/src/main/java/adapter/ThreadAdapter.java +++ b/uikit/src/main/java/adapter/ThreadAdapter.java @@ -848,7 +848,8 @@ public void onClick(DialogInterface dialog, int which) { }); - viewHolder.rlMessageBubble.setOnLongClickListener(new View.OnLongClickListener() { + + viewHolder.txtMessage.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { if (!isImageMessageClick) { diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/Avatar.java b/uikit/src/main/java/com/cometchat/pro/uikit/Avatar.java index 9541acd8..fd169c20 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/Avatar.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/Avatar.java @@ -28,10 +28,10 @@ import androidx.databinding.BindingMethods; import com.bumptech.glide.Glide; -import com.cometchat.pro.uikit.R; import com.cometchat.pro.models.Group; import com.cometchat.pro.models.User; +import com.cometchat.pro.uikit.Settings.UISettings; import utils.Utils; /** @@ -241,7 +241,12 @@ protected void init() { cornerRadius = (int) Utils.dpToPixel(2, getResources()); paint = new Paint(Paint.ANTI_ALIAS_FLAG); - paint.setColor(getResources().getColor(R.color.colorPrimary)); + if (UISettings.getColor()!=null && !UISettings.getColor().isEmpty()) { + paint.setColor(Color.parseColor(UISettings.getColor())); + } + else + paint.setColor(getResources().getColor(R.color.colorPrimary)); + textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); textPaint.setTextSize(16f * getResources().getDisplayMetrics().scaledDensity); textPaint.setColor(Color.WHITE); @@ -255,7 +260,12 @@ protected void init() { borderPaint.setColor(borderColor); borderPaint.setAntiAlias(true); borderPaint.setStrokeWidth(borderWidth); - color = getResources().getColor(R.color.colorPrimary); + + if (UISettings.getColor()!=null && UISettings.getColor().isEmpty()) + color = Color.parseColor(UISettings.getColor()); + else + color = getResources().getColor(R.color.colorPrimary); + setOutlineProvider(new OutlineProvider()); } diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ComposeBox/ComposeBox.java b/uikit/src/main/java/com/cometchat/pro/uikit/ComposeBox/ComposeBox.java index f89f5fa1..7980a819 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ComposeBox/ComposeBox.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ComposeBox/ComposeBox.java @@ -2,10 +2,10 @@ import android.Manifest; import android.app.Activity; -import android.content.ContentResolver; import android.content.Context; import android.content.res.ColorStateList; import android.content.res.TypedArray; +import android.graphics.Color; import android.media.AudioManager; import android.media.MediaPlayer; import android.media.MediaRecorder; @@ -20,19 +20,13 @@ import android.util.Log; import android.view.View; import android.view.ViewGroup; -import android.view.inputmethod.EditorInfo; -import android.view.inputmethod.InputConnection; import android.widget.Chronometer; -import android.widget.EditText; import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.SeekBar; import android.widget.Toast; import androidx.appcompat.app.AppCompatActivity; -import androidx.core.os.BuildCompat; -import androidx.core.view.inputmethod.EditorInfoCompat; -import androidx.core.view.inputmethod.InputConnectionCompat; import androidx.core.view.inputmethod.InputContentInfoCompat; import androidx.fragment.app.FragmentManager; @@ -47,6 +41,7 @@ import constant.StringContract; import listeners.ComposeActionListener; import utils.AudioVisualizer.AudioRecordView; +import com.cometchat.pro.uikit.Settings.UISettings; import utils.Utils; public class ComposeBox extends RelativeLayout implements View.OnClickListener { @@ -95,10 +90,12 @@ public class ComposeBox extends RelativeLayout implements View.OnClickListener { private int color; + public ImageView liveReactionBtn; + private Bundle bundle = new Bundle(); public boolean isGalleryVisible = true,isAudioVisible = true,isCameraVisible = true, - isFileVisible = true,isLocationVisible = true,isPollVisible = true; + isFileVisible = true,isLocationVisible = true,isPollVisible = true,isStickerVisible = true; public ComposeBox(Context context) { super(context); @@ -153,6 +150,8 @@ public void onAudioFocusChange(int focusChange) { } }, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN); } + + liveReactionBtn = view.findViewById(R.id.live_reaction_btn); composeBox=this.findViewById(R.id.message_box); flBox=this.findViewById(R.id.flBox); ivMic=this.findViewById(R.id.ivMic); @@ -215,6 +214,9 @@ public void onLocationClick() { @Override public void onPollClick() { composeActionListener.onPollActionClicked(); } + + @Override + public void onStickerClick() { composeActionListener.onStickerClicked(); } }); etComposeBox.addTextChangedListener(new TextWatcher() { @Override @@ -273,6 +275,30 @@ public void OnMediaSelected(InputContentInfoCompat i) { ivCamera.setImageTintList(ColorStateList.valueOf(getResources().getColor(R.color.colorPrimary))); ivFile.setImageTintList(ColorStateList.valueOf(getResources().getColor(R.color.colorPrimary))); } + if (UISettings.getColor()!=null) { + int settingsColor = Color.parseColor(UISettings.getColor()); + ivSend.setImageTintList(ColorStateList.valueOf(settingsColor)); + } + isPollVisible = UISettings.isSendPolls(); + isFileVisible = UISettings.isSendFiles(); + isGalleryVisible = UISettings.isSendPhotosVideo(); + isCameraVisible = UISettings.isSendPhotosVideo(); + isAudioVisible = UISettings.isSendVoiceNotes(); + isLocationVisible = UISettings.isShareLocation(); + isStickerVisible = UISettings.isStickerVisible(); + if (UISettings.isSendVoiceNotes()) { + ivMic.setVisibility(View.VISIBLE); + } else { + ivMic.setVisibility(GONE); + } + if (!UISettings.isSendPolls() && + !UISettings.isSendFiles() && + !UISettings.isSendPhotosVideo() && + !UISettings.isSendVoiceNotes() && + !UISettings.isShareLocation() && + !UISettings.isStickerVisible()) { + ivArrow.setVisibility(GONE); + } a.recycle(); } public void setText(String text) @@ -356,6 +382,9 @@ public void onClick(View view) { bundle.putBoolean("isFileVisible",isFileVisible); bundle.putBoolean("isAudioVisible",isAudioVisible); bundle.putBoolean("isLocationVisible",isLocationVisible); + if (CometChat.isExtensionEnabled("stickers")) { + bundle.putBoolean("isStickerVisible",isStickerVisible); + } if (CometChat.isExtensionEnabled("polls")) bundle.putBoolean("isPollsVisible",isPollVisible); composeBoxActionFragment.setArguments(bundle); diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ComposeBox/ComposeBoxActionFragment.java b/uikit/src/main/java/com/cometchat/pro/uikit/ComposeBox/ComposeBoxActionFragment.java index 8f41455f..e57b45a5 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ComposeBox/ComposeBoxActionFragment.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ComposeBox/ComposeBoxActionFragment.java @@ -21,6 +21,7 @@ public class ComposeBoxActionFragment extends BottomSheetDialogFragment { private TextView audioMessage; private TextView locationMessage; private TextView pollsMessage; + private TextView stickerMessage; private boolean isGalleryVisible; private boolean isCameraVisible; @@ -28,6 +29,7 @@ public class ComposeBoxActionFragment extends BottomSheetDialogFragment { private boolean isFileVisible; private boolean isLocationVisible; private boolean isPollsVisible; + private boolean isStickerVisible; private ComposeBoxActionListener composeBoxActionListener; @@ -43,6 +45,7 @@ public void onCreate(Bundle savedInstanceState) { isAudioVisible = getArguments().getBoolean("isAudioVisible"); isLocationVisible = getArguments().getBoolean("isLocationVisible"); isPollsVisible = getArguments().getBoolean("isPollsVisible"); + isStickerVisible = getArguments().getBoolean("isStickerVisible"); } } @@ -63,6 +66,7 @@ public void onGlobalLayout() { behavior.setPeekHeight(0); } }); + stickerMessage = view.findViewById(R.id.sticker_message); pollsMessage = view.findViewById(R.id.polls_message); galleryMessage = view.findViewById(R.id.gallery_message); cameraMessage = view.findViewById(R.id.camera_message); @@ -70,6 +74,10 @@ public void onGlobalLayout() { audioMessage = view.findViewById(R.id.audio_message); locationMessage = view.findViewById(R.id.location_message); + if (isStickerVisible) + stickerMessage.setVisibility(View.VISIBLE); + else + stickerMessage.setVisibility(View.GONE); if (isPollsVisible) pollsMessage.setVisibility(View.VISIBLE); else @@ -95,6 +103,14 @@ public void onGlobalLayout() { else locationMessage.setVisibility(View.GONE); + stickerMessage.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (composeBoxActionListener!=null) + composeBoxActionListener.onStickerClick(); + dismiss(); + } + }); pollsMessage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -159,6 +175,7 @@ public interface ComposeBoxActionListener { void onAudioClick(); void onLocationClick(); void onPollClick(); + void onStickerClick(); } } \ No newline at end of file diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/Settings/UIKitSettings.java b/uikit/src/main/java/com/cometchat/pro/uikit/Settings/UIKitSettings.java new file mode 100644 index 00000000..77303925 --- /dev/null +++ b/uikit/src/main/java/com/cometchat/pro/uikit/Settings/UIKitSettings.java @@ -0,0 +1,331 @@ +package com.cometchat.pro.uikit.Settings; + +import android.app.Activity; +import android.content.Context; +import android.content.Intent; +import android.view.View; +import android.widget.TextView; + +import com.cometchat.pro.constants.CometChatConstants; +import com.cometchat.pro.core.CometChat; +import com.cometchat.pro.exceptions.CometChatException; +import com.cometchat.pro.models.Group; +import com.cometchat.pro.models.User; +import com.cometchat.pro.uikit.R; + +import constant.StringContract; +import listeners.CustomAlertDialogHelper; +import screen.messagelist.CometChatMessageListActivity; +import screen.unified.CometChatUnified; + +public class UIKitSettings { + + public static String PUBLIC_GROUP = "public_groups"; + public static String PASSWORD_GROUP = "password_protected_groups"; + public static String ALL_GROUP = "public_and_password_protected_groups"; + public static String ALL_USER = "all_users"; + public static String FRIENDS = "friends"; + public Context context; + + public UIKitSettings(Context context) { + this.context = context; + } + + public static void setMessagingSoundEnable(boolean isEnable) { + UISettings.enableMessageSounds = isEnable; + } + + public static void setAppID(String appID) { + StringContract.AppInfo.APP_ID = appID; + } + + public static void setAPIKey(String apiKey) { + StringContract.AppInfo.API_KEY = apiKey; + } + public static void setCallSoundEnable(boolean isEnable) { + UISettings.enableCallSounds = isEnable; + } + + public static void setHyperLinkEmailColor(int color) { + UISettings.emailColor = color; + } + + public static void setHyperLinkPhoneColor(int color) { + UISettings.phoneColor = color; + } + + public static void setHyperLinkUrlColor(int color) { + UISettings.urlColor = color; + } + + @Deprecated + public static void showCallNotification(boolean isVisible) { + if (!isVisible) { + StringContract.MessageRequest.messageCategoriesForGroup + .remove(CometChatConstants.CATEGORY_CALL); + StringContract.MessageRequest.messageTypesForUser + .remove(CometChatConstants.CATEGORY_CALL); + + } else { + if (!StringContract.MessageRequest.messageCategoriesForGroup + .contains(CometChatConstants.CATEGORY_CALL)) { + StringContract.MessageRequest.messageCategoriesForGroup + .add(CometChatConstants.CATEGORY_CALL); + } + if (!StringContract.MessageRequest.messageCategoriesForUser + .contains(CometChatConstants.CATEGORY_CALL)) { + StringContract.MessageRequest.messageCategoriesForUser + .add(CometChatConstants.CATEGORY_CALL); + } + + } + } + + public static void hideCallActions(boolean isHidden) { + UISettings.hideCallNotification = isHidden; + if (isHidden) { + StringContract.MessageRequest.messageCategoriesForGroup + .remove(CometChatConstants.CATEGORY_CALL); + StringContract.MessageRequest.messageTypesForUser + .remove(CometChatConstants.CATEGORY_CALL); + + } else { + if (!StringContract.MessageRequest.messageCategoriesForGroup + .contains(CometChatConstants.CATEGORY_CALL)) { + StringContract.MessageRequest.messageCategoriesForGroup + .add(CometChatConstants.CATEGORY_CALL); + } + if (!StringContract.MessageRequest.messageCategoriesForUser + .contains(CometChatConstants.CATEGORY_CALL)) { + StringContract.MessageRequest.messageCategoriesForUser + .add(CometChatConstants.CATEGORY_CALL); + } + + } + } + + @Deprecated + public static void showGroupNotification(boolean isVisible) { + if (!isVisible) { + StringContract.MessageRequest.messageTypesForGroup + .remove(CometChatConstants.ActionKeys.ACTION_TYPE_GROUP_MEMBER); + } else { + if (!StringContract.MessageRequest.messageTypesForGroup + .contains(CometChatConstants.ActionKeys.ACTION_TYPE_GROUP_MEMBER)) { + StringContract.MessageRequest.messageTypesForGroup + .add(CometChatConstants.ActionKeys.ACTION_TYPE_GROUP_MEMBER); + } + } + } + + public static void hideGroupActions(boolean isHidden) { + UISettings.hideGroupNotification = isHidden; + if (isHidden) { + StringContract.MessageRequest.messageTypesForGroup + .remove(CometChatConstants.ActionKeys.ACTION_TYPE_GROUP_MEMBER); + } else { + if (!StringContract.MessageRequest.messageTypesForGroup + .contains(CometChatConstants.ActionKeys.ACTION_TYPE_GROUP_MEMBER)) { + StringContract.MessageRequest.messageTypesForGroup + .add(CometChatConstants.ActionKeys.ACTION_TYPE_GROUP_MEMBER); + } + } + } + + public void chatWithUser(String uid, CometChat.CallbackListener callbackListener) { + CometChat.getUser(uid, new CometChat.CallbackListener() { + @Override + public void onSuccess(User user) { + Intent intent = new Intent(context, CometChatMessageListActivity.class); + intent.putExtra(StringContract.IntentStrings.UID, user.getUid()); + intent.putExtra(StringContract.IntentStrings.AVATAR, user.getAvatar()); + intent.putExtra(StringContract.IntentStrings.STATUS, user.getStatus()); + intent.putExtra(StringContract.IntentStrings.NAME, user.getName()); + intent.putExtra(StringContract.IntentStrings.TYPE, CometChatConstants.RECEIVER_TYPE_USER); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + context.startActivity(intent); + } + + @Override + public void onError(CometChatException e) { + callbackListener.onError(e); + } + }); + } + + public void chatWithGroup(String guid, CometChat.CallbackListener callbackListener) { + CometChat.getGroup(guid, new CometChat.CallbackListener() { + @Override + public void onSuccess(Group group) { + if (group.isJoined()) { + Intent intent = new Intent(context, CometChatMessageListActivity.class); + intent.putExtra(StringContract.IntentStrings.GUID, group.getGuid()); + intent.putExtra(StringContract.IntentStrings.AVATAR, group.getIcon()); + intent.putExtra(StringContract.IntentStrings.GROUP_OWNER,group.getOwner()); + intent.putExtra(StringContract.IntentStrings.NAME, group.getName()); + intent.putExtra(StringContract.IntentStrings.GROUP_TYPE,group.getGroupType()); + intent.putExtra(StringContract.IntentStrings.TYPE, CometChatConstants.RECEIVER_TYPE_GROUP); + intent.putExtra(StringContract.IntentStrings.MEMBER_COUNT,group.getMembersCount()); + intent.putExtra(StringContract.IntentStrings.GROUP_DESC,group.getDescription()); + intent.putExtra(StringContract.IntentStrings.GROUP_PASSWORD,group.getPassword()); + context.startActivity(intent); + } else { + callbackListener.onError(new CometChatException("ERR_NOT_A_MEMBER", + String.format(context.getString(R.string.not_a_member),group.getName()))); + } + } + + @Override + public void onError(CometChatException e) { + callbackListener.onError(e); + } + }); + } + + public static void setColor(String color) { + UISettings.color = color; + } + + public static void showUsersInNavigation(boolean showUsers) { + UISettings.showUsersBB = showUsers; + } + + public static void showGroupsInNavigation(boolean showGroups) { + UISettings.showGroupsBB = showGroups; + } + + public static void showChatsInNavigation(boolean showChats) { + UISettings.showChatsBB = showChats; + } + + public static void showCallsInNavigation(boolean showCalls) { + UISettings.showCallsBB = showCalls; + } + + public static void showSettingsInNavigation(boolean showUserSettings) { + UISettings.showUserSettingsBB = showUserSettings; + } + + public static void setGroupType(String groupListing) { + UISettings.groupListing = groupListing; + } + + public static void setUsersType(String userListing) { + UISettings.userListing = userListing; + } + + public static void allowSendingMessage(boolean enableSendingMessage) { + UISettings.enableSendingMessage = enableSendingMessage; + } + + public static void showReadDeliveryReceipts(boolean showReadDeliveryReceipts) { + UISettings.showReadDeliveryReceipts = showReadDeliveryReceipts; + } + + public static void allowEmojisInLargeSize(boolean sendEmojisLargeSize) { + UISettings.sendEmojisLargeSize = sendEmojisLargeSize; + } + + public static void allowSendingEmojis(boolean sendEmojis) { + UISettings.sendEmojis = sendEmojis; + } + + + public static void allowSendingVoiceNotes(boolean sendVoiceNotes) { + UISettings.sendVoiceNotes = sendVoiceNotes; + } + + + public static void allowSendingFiles(boolean sendFiles) { + UISettings.sendFiles = sendFiles; + } + + public static void allowSendingPolls(boolean sendPolls) { + UISettings.sendPolls = sendPolls; + } + + public static void allowSendingPhotosVideo(boolean sendPhotosVideo) { + UISettings.sendPhotosVideo = sendPhotosVideo; + } + + public static void enableThreadedReplies(boolean enableThreadedReplies) { + UISettings.enableThreadedReplies = enableThreadedReplies; + } + + public static void enableReplyToMessage(boolean enableReplyToMessage) { + UISettings.enableReplyToMessage = enableReplyToMessage; + } + + public static void setEnableShareCopyForward(boolean enableShareCopyForward) { + UISettings.enableShareCopyForward = enableShareCopyForward; + } + + public static void allowDeletingMessage(boolean enableDeleteMessage) { + UISettings.enableDeleteMessage = enableDeleteMessage; + } + + public static void allowEditingMessage(boolean enableEditingMessage) { + UISettings.enableEditingMessage = enableEditingMessage; + } + + public static void allowShareLocation(boolean shareLocation) { + UISettings.shareLocation = shareLocation; + } + + public static void allowUsersToBlock(boolean allowUserToblockUser) { + UISettings.blockUser = allowUserToblockUser; + } + + public static void showTypingIndicators(boolean showTypingIndicators) { + UISettings.showTypingIndicators = showTypingIndicators; + } + + public static void showSharedMedia(boolean showSharedMedia) { + UISettings.viewSharedMedia = showSharedMedia; + } + + public static void setShowUserPresence(boolean showUserPresence) { + UISettings.showUserPresence = showUserPresence; + } + + public static void allowPromoteDemoteMembers(boolean allowPromoteDemoteMembers) { + UISettings.allowPromoteDemoteMembers = allowPromoteDemoteMembers; + } + + public static void allowBanKickMembers(boolean allowBanKickMembers) { + UISettings.allowBanKickMembers = allowBanKickMembers; + } + + public static void allowAddMembersInGroup(boolean allowAddMembersInGroup) { + UISettings.allowAddMembers = allowAddMembersInGroup; + } + + public static void allowModeratorToDeleteMessages(boolean allowModeratorToDeleteMessages) { + UISettings.allowModeratorToDeleteMessages = allowModeratorToDeleteMessages; + } + + public static void allowDeleteGroups(boolean allowDeleteGroups) { + UISettings.allowDeleteGroups = allowDeleteGroups; + } + + public static void showGroupMembers(boolean showGroupMembers) { + UISettings.viewGroupMember = showGroupMembers; + } + + public static void allowJoinOrLeaveGroup(boolean joinOrLeaveGroup) { + UISettings.joinOrLeaveGroup = joinOrLeaveGroup; + } + + + public static void showGroupCreate(boolean groupCreate) { + UISettings.groupCreate = groupCreate; + } + + public static void enableVideoCalling(boolean enableVideoCalling) { + UISettings.enableVideoCalling = enableVideoCalling; + } + + public static void enableVoiceCalling(boolean enableVoiceCalling) { + UISettings.enableVoiceCalling = enableVoiceCalling; + } +} diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/Settings/UISettings.java b/uikit/src/main/java/com/cometchat/pro/uikit/Settings/UISettings.java new file mode 100644 index 00000000..f7651908 --- /dev/null +++ b/uikit/src/main/java/com/cometchat/pro/uikit/Settings/UISettings.java @@ -0,0 +1,238 @@ +package com.cometchat.pro.uikit.Settings; + +import com.cometchat.pro.uikit.R; + +public class UISettings { + + public UISettings() {} + + + //style + protected static String color = "#03A9F4"; + //BottomBar + protected static boolean showUsersBB = true; + protected static boolean showGroupsBB = true; + protected static boolean showChatsBB = true; + protected static boolean showCallsBB = true; + protected static boolean showUserSettingsBB = true; + protected static String groupListing = "all"; + protected static String userListing = "all_users"; + //main + protected static boolean enableSendingMessage = true; + protected static boolean showReadDeliveryReceipts = true; + protected static boolean sendEmojisLargeSize = true; + protected static boolean sendEmojis = true; + protected static boolean sendVoiceNotes = true; + protected static boolean sendFiles = true; + protected static boolean sendPolls = true; + protected static boolean sendPhotosVideo = true; + protected static boolean enableThreadedReplies = true; + protected static boolean enableReplyToMessage = true; + protected static boolean enableShareCopyForward = true; + protected static boolean enableDeleteMessage = true; + protected static boolean enableEditingMessage = true; + protected static boolean shareLocation = true; + protected static boolean sendStickers = true; + protected static boolean blockUser = true; + protected static boolean showTypingIndicators = true; + protected static boolean viewSharedMedia = true; + protected static boolean showUserPresence = true; + protected static boolean allowPromoteDemoteMembers = true; + protected static boolean allowBanKickMembers = true; + protected static boolean allowAddMembers = true; + protected static boolean allowModeratorToDeleteMessages; + protected static boolean allowDeleteGroups = true; + protected static boolean viewGroupMember = true; + protected static boolean joinOrLeaveGroup = true; + protected static boolean groupCreate = true; + protected static boolean hideJoinLeaveNotifications = false; + protected static boolean enableVideoCalling = true; + protected static boolean enableVoiceCalling = true; + protected static boolean enableMessageSounds = true; + protected static boolean enableCallSounds = true; + protected static boolean hideGroupNotification = false; + protected static boolean hideCallNotification = false; + protected static int emailColor = R.color.primaryTextColor; + protected static int phoneColor = R.color.purple; + protected static int urlColor = R.color.dark_blue; + + public static boolean isGroupNotificationHidden() { + return hideGroupNotification; + } + + public static boolean isCallNotificationHidden() { + return hideCallNotification; + } + + public static String getColor() { + return color; + } + + + public static boolean isShowUsersBB() { + return showUsersBB; + } + + + public static boolean isShowGroupsBB() { + return showGroupsBB; + } + + public static boolean isShowChatsBB() { + return showChatsBB; + } + + public static boolean isShowCallsBB() { + return showCallsBB; + } + + public static boolean isShowUserSettingsBB() { + return showUserSettingsBB; + } + + public static String getGroupListing() { + return groupListing; + } + + public static String getUserListing() { + return userListing; + } + + public static boolean isEnableSendingMessage() { + return enableSendingMessage; + } + + public static boolean isShowReadDeliveryReceipts() { + return showReadDeliveryReceipts; + } + + public static boolean isSendEmojisLargeSize() { + return sendEmojisLargeSize; + } + + public static boolean isSendEmojis() { + return sendEmojis; + } + + public static boolean isSendVoiceNotes() { + return sendVoiceNotes; + } + + public static boolean isSendFiles() { + return sendFiles; + } + + public static boolean isSendPolls() { + return sendPolls; + } + + public static boolean isStickerVisible() { return sendStickers; } + + public static boolean isSendPhotosVideo() { + return sendPhotosVideo; + } + + public static boolean isEnableThreadedReplies() { + return enableThreadedReplies; + } + + public static boolean isEnableReplyToMessage() { + return enableReplyToMessage; + } + + public static boolean isEnableShareCopyForward() { + return enableShareCopyForward; + } + + public static boolean isEnableDeleteMessage() { + return enableDeleteMessage; + } + + public static boolean isEnableEditingMessage() { + return enableEditingMessage; + } + + public static boolean isShareLocation() { + return shareLocation; + } + + public static boolean isBlockUser() { + return blockUser; + } + + public static boolean isShowTypingIndicators() { + return showTypingIndicators; + } + + public static boolean isViewSharedMedia() { + return viewSharedMedia; + } + + public static boolean isShowUserPresence() { + return showUserPresence; + } + + public static boolean isAllowPromoteDemoteMembers() { + return allowPromoteDemoteMembers; + } + + public static boolean isAllowBanKickMembers() { + return allowBanKickMembers; + } + + public static boolean isAllowAddMembers() { + return allowAddMembers; + } + + public static boolean isAllowModeratorToDeleteMessages() { + return allowModeratorToDeleteMessages; + } + + public static boolean isAllowDeleteGroups() { + return allowDeleteGroups; + } + + public static boolean isViewGroupMember() { + return viewGroupMember; + } + + public static boolean isJoinOrLeaveGroup() { + return joinOrLeaveGroup; + } + + public static boolean isGroupCreate() { + return groupCreate; + } + + public static boolean isHideJoinLeaveNotifications() { + return hideJoinLeaveNotifications; + } + + public static boolean isEnableVideoCalling() { + return enableVideoCalling; + } + + public static boolean isEnableVoiceCalling() { + return enableVoiceCalling; + } + + public static boolean isEnableMessageSounds() { + return enableMessageSounds; + } + + public static boolean isEnableCallSounds() { + return enableCallSounds; + } + + public static int getEmailColor() { + return emailColor; + } + + public static int getPhoneColor() { + return phoneColor; + } + + public static int getUrlColor() { + return urlColor; + } +} diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/SharedMediaView.java b/uikit/src/main/java/com/cometchat/pro/uikit/SharedMediaView.java index c7e503ce..f59a8f74 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/SharedMediaView.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/SharedMediaView.java @@ -3,11 +3,14 @@ import android.content.Context; import android.content.res.ColorStateList; import android.content.res.TypedArray; +import android.graphics.Color; +import android.graphics.drawable.Drawable; import android.os.Bundle; import android.util.AttributeSet; import android.view.View; import android.widget.RelativeLayout; +import androidx.core.graphics.drawable.DrawableCompat; import androidx.fragment.app.FragmentActivity; import androidx.viewpager.widget.ViewPager; @@ -17,7 +20,7 @@ import com.google.android.material.tabs.TabLayout; import adapter.TabAdapter; -import listeners.ComposeActionListener; +import com.cometchat.pro.uikit.Settings.UISettings; import utils.Utils; @@ -85,6 +88,41 @@ private void initViewComponent(Context context,AttributeSet attributeSet,int def viewPager.setOffscreenPageLimit(3); tabLayout.setupWithViewPager(viewPager); + if (UISettings.getColor()!=null) { + Drawable wrappedDrawable = DrawableCompat.wrap(getResources(). + getDrawable(R.drawable.tab_layout_background_active)); + DrawableCompat.setTint(wrappedDrawable, Color.parseColor(UISettings.getColor())); + tabLayout.getTabAt(tabLayout.getSelectedTabPosition()).view.setBackground(wrappedDrawable); + tabLayout.setSelectedTabIndicatorColor(Color.parseColor(UISettings.getColor())); + } else { + tabLayout.getTabAt(tabLayout.getSelectedTabPosition()). + view.setBackgroundColor(getResources().getColor(R.color.colorPrimary)); + tabLayout.setSelectedTabIndicatorColor(getResources().getColor(R.color.colorPrimary)); + } + tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { + @Override + public void onTabSelected(TabLayout.Tab tab) { + if (UISettings.getColor()!=null) { + Drawable wrappedDrawable = DrawableCompat.wrap(getResources(). + getDrawable(R.drawable.tab_layout_background_active)); + DrawableCompat.setTint(wrappedDrawable, Color.parseColor(UISettings.getColor())); + tab.view.setBackground(wrappedDrawable); + } + else + tab.view.setBackgroundColor(getResources().getColor(R.color.colorPrimary)); + } + + @Override + public void onTabUnselected(TabLayout.Tab tab) { + tab.view.setBackgroundColor(getResources().getColor(android.R.color.transparent)); + } + + @Override + public void onTabReselected(TabLayout.Tab tab) { + + } + }); + if(Utils.isDarkMode(context)) { tabLayout.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.grey))); tabLayout.setTabTextColors(getResources().getColor(R.color.light_grey),getResources().getColor(R.color.textColorWhite)); diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/Sticker/StickerFragment.java b/uikit/src/main/java/com/cometchat/pro/uikit/Sticker/StickerFragment.java new file mode 100644 index 00000000..fb0cdfb4 --- /dev/null +++ b/uikit/src/main/java/com/cometchat/pro/uikit/Sticker/StickerFragment.java @@ -0,0 +1,71 @@ +package com.cometchat.pro.uikit.Sticker; + +import android.os.Bundle; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; +import androidx.recyclerview.widget.GridLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.cometchat.pro.uikit.R; +import com.cometchat.pro.uikit.Sticker.listener.StickerClickListener; +import com.cometchat.pro.uikit.Sticker.model.Sticker; + +import java.util.ArrayList; +import java.util.List; + +import adapter.StickersAdapter; +import listeners.ClickListener; +import listeners.RecyclerTouchListener; + +/** + * Purpose - It is a Fragment which is used in StickerView to display stickers sent or received to a + * particular receiver. + * + * Created On - 20th March 2020 + * + * Modified On - 23rd March 2020 + * + */ +public class StickerFragment extends Fragment { + + private RecyclerView rvStickers; + private StickersAdapter adapter; + private String Id; + private String TAG = "StickerView"; + private String type; + private List stickers = new ArrayList<>(); + StickerClickListener stickerClickListener; + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.fragment_stickers_view,container,false); + rvStickers = view.findViewById(R.id.rvStickers); + rvStickers.setLayoutManager(new GridLayoutManager(getContext(),4)); + Id = this.getArguments().getString("Id"); + type = this.getArguments().getString("type"); + List list = this.getArguments().getParcelableArrayList("stickerList"); + stickers = list; + Log.e("onStickerView: ",stickers.get(0).getSetName()); + adapter = new StickersAdapter(getContext(),stickers); + rvStickers.setAdapter(adapter); + + rvStickers.addOnItemTouchListener(new RecyclerTouchListener(getContext(), rvStickers, new ClickListener() { + @Override + public void onClick(View var1, int var2) { + Sticker sticker = (Sticker)var1.getTag(R.string.sticker); + stickerClickListener.onClickListener(sticker); + } + })); + return view; + } + + public void setStickerClickListener(StickerClickListener stickerClickListener) { + this.stickerClickListener = stickerClickListener; + } +} diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/Sticker/StickerView.java b/uikit/src/main/java/com/cometchat/pro/uikit/Sticker/StickerView.java new file mode 100644 index 00000000..ccb09363 --- /dev/null +++ b/uikit/src/main/java/com/cometchat/pro/uikit/Sticker/StickerView.java @@ -0,0 +1,170 @@ +package com.cometchat.pro.uikit.Sticker; + +import android.content.Context; +import android.content.res.ColorStateList; +import android.content.res.TypedArray; +import android.graphics.Color; +import android.graphics.drawable.Drawable; +import android.os.Bundle; +import android.os.Parcelable; +import android.util.AttributeSet; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.RelativeLayout; + +import androidx.core.graphics.drawable.DrawableCompat; +import androidx.fragment.app.FragmentActivity; +import androidx.viewpager.widget.ViewPager; + +import com.bumptech.glide.Glide; +import com.cometchat.pro.uikit.R; +import com.cometchat.pro.uikit.Settings.UISettings; +import com.cometchat.pro.uikit.Sticker.listener.StickerClickListener; +import com.cometchat.pro.uikit.Sticker.model.Sticker; +import com.google.android.material.tabs.TabLayout; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import adapter.StickerTabAdapter; +import utils.Utils; + + +public class StickerView extends RelativeLayout implements StickerClickListener { + + private Context context; + + private ViewPager viewPager; + + private TabLayout tabLayout; + + private String Id; + + private String type; + + private AttributeSet attrs; + + private StickerTabAdapter adapter; + + private HashMap> stickerMap = new HashMap<>(); + + private StickerClickListener stickerClickListener; + + public StickerView(Context context) { + super(context); + this.context = context; + initViewComponent(context,null,-1,-1); + } + + public StickerView(Context context, AttributeSet attrs) { + super(context, attrs); + this.attrs = attrs; + this.context = context; + initViewComponent(context,attrs,-1,-1); + } + + public StickerView(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + this.context = context; + this.attrs = attrs; + initViewComponent(context,attrs,defStyleAttr,-1); + } + + + private void initViewComponent(Context context,AttributeSet attributeSet,int defStyleAttr,int defStyleRes){ + + View view =View.inflate(context, R.layout.cometchat_sticker_view,null); + + TypedArray a = getContext().getTheme().obtainStyledAttributes(attributeSet, R.styleable.SharedMediaView, 0, 0); + addView(view); + + + if (type!=null) { + viewPager = this.findViewById(R.id.viewPager); + tabLayout = view.findViewById(R.id.tabLayout); + adapter = new StickerTabAdapter(context,((FragmentActivity)context).getSupportFragmentManager()); + for (String str : stickerMap.keySet()) { + Bundle bundle = new Bundle(); + bundle.putString("Id",Id); + bundle.putString("type",type); + StickerFragment stickersFragment = new StickerFragment(); + bundle.putParcelableArrayList("stickerList", (ArrayList) stickerMap.get(str)); + stickersFragment.setArguments(bundle); + stickersFragment.setStickerClickListener(stickerClickListener); + adapter.addFragment(stickersFragment, str,stickerMap.get(str).get(0).getUrl()); + } + viewPager.setAdapter(adapter); + tabLayout.setupWithViewPager(viewPager); + + for (int i=0;i> stickers) { + this.Id = uid; + this.type = receiverType; + this.stickerMap = stickers; + reload(); + } + + + public void reload() { + initViewComponent(context,null,-1,-1); + } + + @Override + public void onClickListener(Sticker sticker) { + stickerClickListener.onClickListener(sticker); + } +} diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/Sticker/listener/StickerClickListener.java b/uikit/src/main/java/com/cometchat/pro/uikit/Sticker/listener/StickerClickListener.java new file mode 100644 index 00000000..93157ff1 --- /dev/null +++ b/uikit/src/main/java/com/cometchat/pro/uikit/Sticker/listener/StickerClickListener.java @@ -0,0 +1,7 @@ +package com.cometchat.pro.uikit.Sticker.listener; + +import com.cometchat.pro.uikit.Sticker.model.Sticker; + +public interface StickerClickListener { + void onClickListener(Sticker sticker); +} diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/Sticker/model/Sticker.java b/uikit/src/main/java/com/cometchat/pro/uikit/Sticker/model/Sticker.java new file mode 100644 index 00000000..79d31b49 --- /dev/null +++ b/uikit/src/main/java/com/cometchat/pro/uikit/Sticker/model/Sticker.java @@ -0,0 +1,58 @@ +package com.cometchat.pro.uikit.Sticker.model; + +import android.os.Parcel; +import android.os.Parcelable; + +public class Sticker implements Parcelable { + String name; + String url; + String setName; + + public Sticker(String name,String url,String setName) { + this.name = name; + this.url = url; + this.setName = setName; + } + + protected Sticker(Parcel in) { + name = in.readString(); + url = in.readString(); + setName = in.readString(); + } + + public static final Creator CREATOR = new Creator() { + @Override + public Sticker createFromParcel(Parcel in) { + return new Sticker(in); + } + + @Override + public Sticker[] newArray(int size) { + return new Sticker[size]; + } + }; + + public String getName() { + return name; + } + + public String getUrl() { + return url; + } + + public String getSetName() { + return setName; + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel parcel, int i) { + parcel.writeString(name); + parcel.writeString(url); + parcel.writeString(setName); + } +} \ No newline at end of file diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/UIKitSettings.java b/uikit/src/main/java/com/cometchat/pro/uikit/UIKitSettings.java deleted file mode 100644 index 79649896..00000000 --- a/uikit/src/main/java/com/cometchat/pro/uikit/UIKitSettings.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.cometchat.pro.uikit; - -import com.cometchat.pro.constants.CometChatConstants; - -import constant.StringContract; - -public class UIKitSettings { - - public static void setMessagingSoundEnable(boolean isEnable) { - StringContract.Sounds.enableMessageSounds = isEnable; - } - - public static void setCallSoundEnable(boolean isEnable) { - StringContract.Sounds.enableCallSounds = isEnable; - } - - public static boolean isMessageSoundEnable() { - return StringContract.Sounds.enableMessageSounds; - } - - public static boolean isCallSoundEnable() { - return StringContract.Sounds.enableCallSounds; - } - - public static void setHyperLinkEmailColor(int color) { - StringContract.HyperLink.emailColor = color; - } - - public static void setHyperLinkPhoneColor(int color) { - StringContract.HyperLink.phoneColor = color; - } - - public static void setHyperLinkUrlColor(int color) { - StringContract.HyperLink.urlColor = color; - } - - public static void showCallNotification(boolean isVisible) { - if (!isVisible) { - StringContract.MessageRequest.messageCategoriesForGroup - .remove(CometChatConstants.CATEGORY_CALL); - StringContract.MessageRequest.messageTypesForUser - .remove(CometChatConstants.CATEGORY_CALL); - - } else { - if (!StringContract.MessageRequest.messageCategoriesForGroup - .contains(CometChatConstants.CATEGORY_CALL)) { - StringContract.MessageRequest.messageCategoriesForGroup - .add(CometChatConstants.CATEGORY_CALL); - } - if (!StringContract.MessageRequest.messageCategoriesForUser - .contains(CometChatConstants.CATEGORY_CALL)) { - StringContract.MessageRequest.messageCategoriesForUser - .add(CometChatConstants.CATEGORY_CALL); - } - - } - } - - public static void showGroupNotification(boolean isVisible) { - if (!isVisible) { - StringContract.MessageRequest.messageTypesForGroup - .remove(CometChatConstants.ActionKeys.ACTION_TYPE_GROUP_MEMBER); - } else { - if (StringContract.MessageRequest.messageTypesForGroup - .contains(CometChatConstants.ActionKeys.ACTION_TYPE_GROUP_MEMBER)) { - StringContract.MessageRequest.messageTypesForGroup - .add(CometChatConstants.ActionKeys.ACTION_TYPE_GROUP_MEMBER); - } - } - } -} diff --git a/uikit/src/main/java/constant/StringContract.java b/uikit/src/main/java/constant/StringContract.java index a319cf56..d8567008 100644 --- a/uikit/src/main/java/constant/StringContract.java +++ b/uikit/src/main/java/constant/StringContract.java @@ -11,6 +11,8 @@ public class StringContract { public static class AppInfo { public static String API_KEY = ""; + + public static String APP_ID = ""; } public static class IntentStrings { @@ -106,6 +108,10 @@ public static class IntentStrings { public static final String POLLS = "extension_poll"; + public static final String TRANSFER_OWNERSHIP = "transfer_ownership"; + + public static final String STICKERS = "Sticker"; + public static String POLL_QUESTION = "poll_question"; public static String POLL_OPTION = "poll_option"; @@ -148,22 +154,7 @@ public static class MapUrl{ public static final String MAPS_URL = "https://maps.googleapis.com/maps/api/staticmap?zoom=16&size=380x220&markers=color:red|"; - public static final String MAP_ACCESS_KEY = "XXXXXXXXXXXXXXXXXXXXXXXXXXX"; //Replace with yout MAP_API_KEY - } - - public static class Sounds { - - public static boolean enableMessageSounds = true; - - public static boolean enableCallSounds = true; - } - - public static class HyperLink { - public static int emailColor = R.color.primaryTextColor; - - public static int phoneColor = R.color.purple; - - public static int urlColor = R.color.dark_blue; + public static final String MAP_ACCESS_KEY = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; } @@ -178,7 +169,8 @@ public static class MessageRequest { CometChatConstants.MESSAGE_TYPE_FILE, //Custom Messages StringContract.IntentStrings.LOCATION, - StringContract.IntentStrings.POLLS + StringContract.IntentStrings.POLLS, + StringContract.IntentStrings.STICKERS )) ; public static List messageTypesForGroup = new ArrayList<>(Arrays.asList( CometChatConstants.MESSAGE_TYPE_CUSTOM, @@ -191,7 +183,8 @@ public static class MessageRequest { CometChatConstants.ActionKeys.ACTION_TYPE_GROUP_MEMBER, //Custom Messages StringContract.IntentStrings.LOCATION, - StringContract.IntentStrings.POLLS + StringContract.IntentStrings.POLLS, + StringContract.IntentStrings.STICKERS )); public static List messageCategoriesForGroup = new ArrayList<>(Arrays.asList( diff --git a/uikit/src/main/java/listeners/CometChatCallListener.java b/uikit/src/main/java/listeners/CometChatCallListener.java index 87d1d0d7..2793a104 100644 --- a/uikit/src/main/java/listeners/CometChatCallListener.java +++ b/uikit/src/main/java/listeners/CometChatCallListener.java @@ -49,7 +49,9 @@ public void onIncomingCallReceived(Call call) { } else { CometChat.rejectCall(call.getSessionId(), CometChatConstants.CALL_STATUS_BUSY, new CometChat.CallbackListener() { @Override - public void onSuccess(Call call) {} + public void onSuccess(Call call) { + Toast.makeText(context,call.getSender().getName()+" tried to call you",Toast.LENGTH_LONG).show(); + } @Override public void onError(CometChatException e) { @@ -66,6 +68,12 @@ public void onOutgoingCallAccepted(Call call) { CometChatCallActivity.cometChatAudioHelper.stop(false); CallUtils.startCall(CometChatCallActivity.callActivity, call); } + } else { + CometChatStartCallActivity.activity.finish(); + if (CometChatCallActivity.callActivity != null) { + CometChatCallActivity.cometChatAudioHelper.stop(false); + CallUtils.startCall(CometChatCallActivity.callActivity, call); + } } } diff --git a/uikit/src/main/java/listeners/ComposeActionListener.java b/uikit/src/main/java/listeners/ComposeActionListener.java index 9328ed7e..1bf8e353 100644 --- a/uikit/src/main/java/listeners/ComposeActionListener.java +++ b/uikit/src/main/java/listeners/ComposeActionListener.java @@ -55,4 +55,7 @@ public void getLocationActionView(ImageView locationIcon) { public void onLocationActionClicked() { } + + public void onStickerClicked() { + } } diff --git a/uikit/src/main/java/listeners/ExtensionResponseListener.java b/uikit/src/main/java/listeners/ExtensionResponseListener.java new file mode 100644 index 00000000..09678be8 --- /dev/null +++ b/uikit/src/main/java/listeners/ExtensionResponseListener.java @@ -0,0 +1,10 @@ +package listeners; + +import com.cometchat.pro.exceptions.CometChatException; + +public abstract class ExtensionResponseListener { + + public abstract void OnResponseSuccess(T var); + + public abstract void OnResponseFailed(CometChatException e); +} diff --git a/uikit/src/main/java/listeners/ReactionClickListener.java b/uikit/src/main/java/listeners/ReactionClickListener.java new file mode 100644 index 00000000..ce3cf445 --- /dev/null +++ b/uikit/src/main/java/listeners/ReactionClickListener.java @@ -0,0 +1,8 @@ +package listeners; + +import android.view.View; + +public abstract class ReactionClickListener { + public void onClick(View var1){} + public void onCancel(View var1){} +} diff --git a/uikit/src/main/java/listeners/ReactionListener.java b/uikit/src/main/java/listeners/ReactionListener.java new file mode 100644 index 00000000..a9193fa2 --- /dev/null +++ b/uikit/src/main/java/listeners/ReactionListener.java @@ -0,0 +1,69 @@ +package listeners; + +import android.os.Handler; +import android.view.MotionEvent; +import android.view.View; + +public class ReactionListener implements View.OnTouchListener { + + private Handler handler = new Handler(); + + private int initialInterval; + private final int normalInterval; + private final ReactionClickListener clickListener; + private View touchedView; + + private Runnable handlerRunnable = new Runnable() { + @Override + public void run() { + if(touchedView.isEnabled()) { + handler.postDelayed(this, normalInterval); + clickListener.onClick(touchedView); + } else { + handler.removeCallbacks(handlerRunnable); + touchedView.setPressed(false); + touchedView = null; + } + } + }; + + + public ReactionListener(int initialInterval, int normalInterval, + ReactionClickListener clickListener) { + if (clickListener == null) + throw new IllegalArgumentException("null runnable"); + if (initialInterval < 0 || normalInterval < 0) + throw new IllegalArgumentException("negative interval"); + + this.initialInterval = initialInterval; + this.normalInterval = normalInterval; + this.clickListener = clickListener; + } + + public boolean onTouch(View view, MotionEvent motionEvent) { + switch (motionEvent.getAction()) { + case MotionEvent.ACTION_DOWN: + handler.removeCallbacks(handlerRunnable); + handler.postDelayed(handlerRunnable, initialInterval); + touchedView = view; + view.animate().scaleX(1.5f).setDuration(300).start(); + view.animate().scaleY(1.5f).setDuration(300).start(); + touchedView.setPressed(true); + clickListener.onClick(view); + return true; + case MotionEvent.ACTION_UP: + case MotionEvent.ACTION_CANCEL: + view.animate().cancel(); + view.animate().scaleX(1f).setDuration(300).start(); + view.animate().scaleY(1f).setDuration(300).start(); + handler.removeCallbacks(handlerRunnable); + touchedView.setPressed(false); + touchedView = null; + clickListener.onCancel(view); + return true; + } + + return false; + } + +} \ No newline at end of file diff --git a/uikit/src/main/java/screen/CometChatCallActivity.java b/uikit/src/main/java/screen/CometChatCallActivity.java index b3c3f179..5faf6a9b 100644 --- a/uikit/src/main/java/screen/CometChatCallActivity.java +++ b/uikit/src/main/java/screen/CometChatCallActivity.java @@ -1,14 +1,11 @@ package screen; -import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import android.Manifest; -import android.annotation.SuppressLint; import android.app.Activity; import android.content.Intent; import android.content.res.ColorStateList; -import android.media.RingtoneManager; import android.net.Uri; import android.os.Bundle; import android.util.Log; @@ -34,7 +31,7 @@ import helper.OutgoingAudioHelper; import utils.CallUtils; import utils.CameraPreview; -import utils.MediaUtils; +import com.cometchat.pro.uikit.Settings.UISettings; import utils.Utils; /** @@ -178,14 +175,13 @@ private void initView() { hangUp.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.red_600))); mainView = findViewById(R.id.main_view); cometChatAudioHelper = new CometChatAudioHelper(this); - if (StringContract.Sounds.enableCallSounds) + if (UISettings.isEnableCallSounds()) { cometChatAudioHelper.initAudio(); - String packageName = getPackageName(); - if (StringContract.Sounds.enableCallSounds) - notification = Uri.parse("android.resource://" + packageName + "/" +R.raw.incoming_call); + String packageName = getPackageName(); + notification = Uri.parse("android.resource://" + packageName + "/" + R.raw.incoming_call); + } setCallType(isVideo, isIncoming); - if (!Utils.hasPermissions(this, Manifest.permission.RECORD_AUDIO) && !Utils.hasPermissions(this,Manifest.permission.CAMERA)) - { + if (!Utils.hasPermissions(this, Manifest.permission.RECORD_AUDIO) && !Utils.hasPermissions(this,Manifest.permission.CAMERA)) { requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO,Manifest.permission.CAMERA},REQUEST_PERMISSION); } } @@ -202,12 +198,16 @@ private void setValues() { else onBackPressed(); } - userTv.setText(name); - callerName.setText(name); - userAv.setInitials(name); - callerAvatar.setInitials(name); - userAv.setAvatar(avatar); - callerAvatar.setAvatar(avatar); + if (name!=null) { + userTv.setText(name); + callerName.setText(name); + userAv.setInitials(name); + callerAvatar.setInitials(name); + } + if (avatar!=null) { + userAv.setAvatar(avatar); + callerAvatar.setAvatar(avatar); + } } /** diff --git a/uikit/src/main/java/screen/CometChatGroupDetailScreenActivity.java b/uikit/src/main/java/screen/CometChatGroupDetailScreenActivity.java index 5071620a..21a09977 100644 --- a/uikit/src/main/java/screen/CometChatGroupDetailScreenActivity.java +++ b/uikit/src/main/java/screen/CometChatGroupDetailScreenActivity.java @@ -8,6 +8,8 @@ import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; +import android.content.res.ColorStateList; +import android.graphics.Color; import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; @@ -20,6 +22,7 @@ import android.view.View; import android.widget.AdapterView; import android.widget.ImageView; +import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.Spinner; import android.widget.TextView; @@ -28,7 +31,6 @@ import com.bumptech.glide.Glide; import com.cometchat.pro.constants.CometChatConstants; import com.cometchat.pro.core.BannedGroupMembersRequest; -import com.cometchat.pro.core.Call; import com.cometchat.pro.core.CometChat; import com.cometchat.pro.core.GroupMembersRequest; import com.cometchat.pro.exceptions.CometChatException; @@ -57,13 +59,14 @@ import screen.addmember.CometChatAddMemberScreenActivity; import screen.adminAndModeratorList.CometChatAdminModeratorListScreenActivity; import screen.banmembers.CometChatBanMemberScreenActivity; +import screen.groupmemberlist.CometChatGroupMemberListScreenActivity; import screen.unified.CometChatUnified; import utils.CallUtils; import utils.FontUtils; +import com.cometchat.pro.uikit.Settings.UISettings; import utils.Utils; import static utils.Utils.UserToGroupMember; -import static utils.Utils.isLoggedInUser; public class CometChatGroupDetailScreenActivity extends AppCompatActivity { @@ -134,6 +137,8 @@ public class CometChatGroupDetailScreenActivity extends AppCompatActivity { private SharedMediaView sharedMediaView; + private LinearLayout sharedMediaLayout; + private ImageView videoCallBtn; private ImageView callBtn; @@ -223,6 +228,7 @@ public void onClick(View v) { handleIntent(); checkDarkMode(); + sharedMediaLayout = findViewById(R.id.shared_media_layout); sharedMediaView = findViewById(R.id.shared_media_view); sharedMediaView.setRecieverId(guid); sharedMediaView.setRecieverType(CometChatConstants.RECEIVER_TYPE_GROUP); @@ -258,6 +264,7 @@ public void onClick(View view) { getGroupMembers(); } }); + tvExit.setOnClickListener(view -> createDialog(getResources().getString(R.string.exit_group_title), getResources().getString(R.string.exit_group_message), getResources().getString(R.string.exit), getResources().getString(R.string.cancel), R.drawable.ic_exit_to_app)); @@ -274,6 +281,51 @@ public void onClick(View view) { tvDelete.setOnClickListener(view -> createDialog(getResources().getString(R.string.delete_group_title), getResources().getString(R.string.delete_group_message), getResources().getString(R.string.delete), getResources().getString(R.string.cancel), R.drawable.ic_delete_24dp)); + + // + if (!UISettings.isJoinOrLeaveGroup()) + tvExit.setVisibility(View.GONE); + + if (!UISettings.isAllowDeleteGroups()) + tvDelete.setVisibility(View.GONE); + + if (!UISettings.isViewSharedMedia()) { + sharedMediaLayout.setVisibility(View.GONE); + } + + if (!UISettings.isViewGroupMember()) { + rvMemberList.setVisibility(View.GONE); + tvLoadMore.setVisibility(View.GONE); + rlAddMemberView.setVisibility(View.GONE); + tvMemberCount.setVisibility(View.GONE); + divider2.setVisibility(View.GONE); + } + if (!UISettings.isAllowPromoteDemoteMembers()) { + rlModeratorView.setVisibility(View.GONE); + rlAdminListView.setVisibility(View.GONE); + dividerAdmin.setVisibility(View.GONE); + dividerModerator.setVisibility(View.GONE); + } + if (UISettings.isEnableVoiceCalling()) + callBtn.setVisibility(View.VISIBLE); + else + callBtn.setVisibility(View.GONE); + + if (!UISettings.isAllowBanKickMembers()) + rlBanMembers.setVisibility(View.GONE); + + if (UISettings.isEnableVideoCalling()) + videoCallBtn.setVisibility(View.VISIBLE); + else + videoCallBtn.setVisibility(View.GONE); + + if (UISettings.getColor()!=null) { + getWindow().setStatusBarColor(Color.parseColor(UISettings.getColor())); + callBtn.setImageTintList(ColorStateList.valueOf( + Color.parseColor(UISettings.getColor()))); + videoCallBtn.setImageTintList(ColorStateList.valueOf( + Color.parseColor(UISettings.getColor()))); + } } private void checkDarkMode() { @@ -373,10 +425,11 @@ private void createDialog(String title, String message, String positiveText, Str alert_dialog.setMessage(message); alert_dialog.setPositiveButton(positiveText, (dialogInterface, i) -> { - if (positiveText.equalsIgnoreCase(getResources().getString(R.string.exit))) + if (positiveText.equalsIgnoreCase(getResources().getString(R.string.exit))) { leaveGroup(); - else if (positiveText.equalsIgnoreCase(getResources().getString(R.string.delete)) + } + else if (positiveText.equalsIgnoreCase(getResources().getString(R.string.delete_group)) && loggedInUserScope.equalsIgnoreCase(CometChatConstants.SCOPE_ADMIN)) deleteGroup(); @@ -393,7 +446,6 @@ public void onClick(DialogInterface dialogInterface, int i) { } - /** * This method is used to handle the intent passed to this activity. */ @@ -493,31 +545,35 @@ public void openAdminListScreen(boolean showModerators) { * @see CometChatAddMemberScreenActivity */ public void addMembers() { - Intent intent = new Intent(this, CometChatAddMemberScreenActivity.class); - intent.putExtra(StringContract.IntentStrings.GUID, guid); - intent.putExtra(StringContract.IntentStrings.GROUP_MEMBER, groupMemberUids); - intent.putExtra(StringContract.IntentStrings.GROUP_NAME, gName); - intent.putExtra(StringContract.IntentStrings.MEMBER_SCOPE, loggedInUserScope); - intent.putExtra(StringContract.IntentStrings.IS_ADD_MEMBER, true); - startActivity(intent); + if (UISettings.isAllowAddMembers()) { + Intent intent = new Intent(this, CometChatAddMemberScreenActivity.class); + intent.putExtra(StringContract.IntentStrings.GUID, guid); + intent.putExtra(StringContract.IntentStrings.GROUP_MEMBER, groupMemberUids); + intent.putExtra(StringContract.IntentStrings.GROUP_NAME, gName); + intent.putExtra(StringContract.IntentStrings.MEMBER_SCOPE, loggedInUserScope); + intent.putExtra(StringContract.IntentStrings.IS_ADD_MEMBER, true); + startActivity(intent); + } } /** * This method is used to delete Group. It is used only if loggedIn user is admin. */ private void deleteGroup() { - CometChat.deleteGroup(guid, new CometChat.CallbackListener() { - @Override - public void onSuccess(String s) { - launchUnified(); - } + if (UISettings.isAllowDeleteGroups()) { + CometChat.deleteGroup(guid, new CometChat.CallbackListener() { + @Override + public void onSuccess(String s) { + launchUnified(); + } - @Override - public void onError(CometChatException e) { - Snackbar.make(rvMemberList, getResources().getString(R.string.group_delete_error), Snackbar.LENGTH_SHORT).show(); - Log.e(TAG, "onError: " + e.getMessage()); - } - }); + @Override + public void onError(CometChatException e) { + Snackbar.make(rvMemberList, getResources().getString(R.string.group_delete_error), Snackbar.LENGTH_SHORT).show(); + Log.e(TAG, "onError: " + e.getMessage()); + } + }); + } } private void launchUnified() { @@ -637,6 +693,20 @@ public void onError(CometChatException e) { }); } + private void getUserStatus() { + CometChat.addUserListener(TAG, new CometChat.UserListener() { + @Override + public void onUserOnline(User user) { + groupMemberAdapter.updateMemberByStatus(user); + } + + @Override + public void onUserOffline(User user) { + groupMemberAdapter.updateMemberByStatus(user); + } + }); + } + // private void getBannedMemberCount() { // banMemberRequest = new BannedGroupMembersRequest.BannedGroupMembersRequestBuilder(guid).setLimit(100).build(); // banMemberRequest.fetchNext(new CometChat.CallbackListener>() { @@ -662,18 +732,20 @@ public void onError(CometChatException e) { * @see CometChat#leaveGroup(String, CometChat.CallbackListener) */ private void leaveGroup() { - CometChat.leaveGroup(guid, new CometChat.CallbackListener() { - @Override - public void onSuccess(String s) { - launchUnified(); - } + if (UISettings.isJoinOrLeaveGroup()) { + CometChat.leaveGroup(guid, new CometChat.CallbackListener() { + @Override + public void onSuccess(String s) { + launchUnified(); + } - @Override - public void onError(CometChatException e) { - Snackbar.make(rlAddMemberView, getResources().getString(R.string.leave_group_error), Snackbar.LENGTH_SHORT).show(); - Log.e(TAG, "onError: " + e.getMessage()); - } - }); + @Override + public void onError(CometChatException e) { + Snackbar.make(rlAddMemberView, getResources().getString(R.string.leave_group_error), Snackbar.LENGTH_SHORT).show(); + Log.e(TAG, "onError: " + e.getMessage()); + } + }); + } } /** @@ -954,6 +1026,10 @@ public void removeGroupListener() { CometChat.removeGroupListener(TAG); } + public void removeUserListener() { + CometChat.removeUserListener(TAG); + } + /** * This method is used to get Group Details. * @@ -993,7 +1069,10 @@ protected void onResume() { } // getBannedMemberCount(); - getGroupMembers(); + if (UISettings.isShowUserPresence()) + getUserStatus(); + if (UISettings.isViewGroupMember()) + getGroupMembers(); addGroupListener(); callBtn.setClickable(true); videoCallBtn.setClickable(true); @@ -1005,11 +1084,13 @@ protected void onPause() { super.onPause(); Log.d(TAG, "onPause: "); removeGroupListener(); + removeUserListener(); } @Override protected void onStop() { super.onStop(); removeGroupListener(); + removeUserListener(); } } diff --git a/uikit/src/main/java/screen/CometChatGroupListScreen.java b/uikit/src/main/java/screen/CometChatGroupListScreen.java index 06156494..772e2d86 100644 --- a/uikit/src/main/java/screen/CometChatGroupListScreen.java +++ b/uikit/src/main/java/screen/CometChatGroupListScreen.java @@ -2,6 +2,8 @@ import android.content.Context; import android.content.Intent; +import android.content.res.ColorStateList; +import android.graphics.Color; import android.os.Bundle; import androidx.annotation.NonNull; @@ -23,6 +25,7 @@ import android.widget.LinearLayout; import android.widget.TextView; +import com.cometchat.pro.constants.CometChatConstants; import com.cometchat.pro.core.CometChat; import com.cometchat.pro.core.GroupsRequest; import com.cometchat.pro.exceptions.CometChatException; @@ -35,11 +38,10 @@ import java.util.List; import adapter.GroupListAdapter; -import listeners.ClickListener; import listeners.OnItemClickListener; -import listeners.RecyclerTouchListener; import screen.creategroup.CometChatCreateGroupScreenActivity; import utils.FontUtils; +import com.cometchat.pro.uikit.Settings.UISettings; import utils.Utils; /* @@ -92,6 +94,12 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, clearSearch = view.findViewById(R.id.clear_search); ivCreateGroup = view.findViewById(R.id.create_group); + ivCreateGroup.setImageTintList(ColorStateList.valueOf(Color.parseColor(UISettings.getColor()))); + + if(UISettings.isGroupCreate()) + ivCreateGroup.setVisibility(View.VISIBLE); + else + ivCreateGroup.setVisibility(View.GONE); if(Utils.isDarkMode(getContext())) { title.setTextColor(getResources().getColor(R.color.textColorWhite)); @@ -193,7 +201,8 @@ private void fetchGroup(){ groupsRequest.fetchNext(new CometChat.CallbackListener>() { @Override public void onSuccess(List groups) { - rvGroupList.setGroupList(groups); // sets the groups in rvGroupList i.e CometChatGroupList Component. + List filteredList = filterGroup(groups); + rvGroupList.setGroupList(filteredList); // sets the groups in rvGroupList i.e CometChatGroupList Component. groupList.addAll(groups); if (groupList.size()==0) { noGroupLayout.setVisibility(View.VISIBLE); @@ -210,6 +219,27 @@ public void onError(CometChatException e) { } }); } + private List filterGroup(List groups) { + List resultList = new ArrayList<>(); + for (Group group : groups) { + if (group.isJoined()) { + resultList.add(group); + } + if (UISettings.getGroupListing() + .equalsIgnoreCase("public_groups") && + group.getGroupType().equalsIgnoreCase(CometChatConstants.GROUP_TYPE_PUBLIC)) { + resultList.add(group); + } else if (UISettings.getGroupListing() + .equalsIgnoreCase("password_protected_groups") && + group.getGroupType().equalsIgnoreCase(CometChatConstants.GROUP_TYPE_PASSWORD)) { + resultList.add(group); + } else if (UISettings.getGroupListing() + .equalsIgnoreCase("public_and_password_protected_groups")) { + resultList.add(group); + } + } + return resultList; + } /** * This method is used to search groups present in your App_ID. diff --git a/uikit/src/main/java/screen/CometChatMessageInfoScreenActivity.java b/uikit/src/main/java/screen/CometChatMessageInfoScreenActivity.java index 7b666eb5..364f4cc9 100644 --- a/uikit/src/main/java/screen/CometChatMessageInfoScreenActivity.java +++ b/uikit/src/main/java/screen/CometChatMessageInfoScreenActivity.java @@ -39,6 +39,7 @@ public class CometChatMessageInfoScreenActivity extends AppCompatActivity { private View videoMessage; private View locationMessage; private View pollsMessage; + private View stickerMessage; private TextView question; private LinearLayout optionGroup; @@ -52,6 +53,8 @@ public class CometChatMessageInfoScreenActivity extends AppCompatActivity { private TextView txtTime; private RelativeLayout sensitiveLayout; + private ImageView messageSticker; + private TextView audioFileSize; private TextView fileName; @@ -86,12 +89,15 @@ protected void onCreate(Bundle savedInstanceState) { fileMessage = findViewById(R.id.vwFileMessage); locationMessage = findViewById(R.id.vwLocationMessage); pollsMessage = findViewById(R.id.polls_message); + stickerMessage = findViewById(R.id.vwStickerMessage); + messageSticker = findViewById(R.id.sticker_view); findViewById(R.id.total_votes).setVisibility(View.GONE); question = findViewById(R.id.tv_question); optionGroup = findViewById(R.id.options_group); messageText = findViewById(R.id.go_txt_message); txtTime = findViewById(R.id.txt_time); txtTime.setVisibility(View.VISIBLE); + messageSticker = findViewById(R.id.sticker_view); messageImage = findViewById(R.id.go_img_message); messageVideo = findViewById(R.id.go_video_message); sensitiveLayout = findViewById(R.id.sensitive_layout); @@ -188,7 +194,15 @@ private void handleIntent() { } else if (messageType.equals(CometChatConstants.MESSAGE_TYPE_IMAGE)) { imageMessage.setVisibility(View.VISIBLE); Glide.with(this).load(message).into(messageImage); - } else if (messageType.equals(CometChatConstants.MESSAGE_TYPE_VIDEO)) { + } else if (messageType.equals(StringContract.IntentStrings.STICKERS)) { + stickerMessage.setVisibility(View.VISIBLE); + try { + JSONObject jsonObject = new JSONObject(message); + Glide.with(this).load(jsonObject.getString("url")).into(messageSticker); + } catch (JSONException e) { + e.printStackTrace(); + } + }else if (messageType.equals(CometChatConstants.MESSAGE_TYPE_VIDEO)) { videoMessage.setVisibility(View.VISIBLE); Glide.with(this).load(message).into(messageVideo); } else if (messageType.equals(CometChatConstants.MESSAGE_TYPE_FILE)) { diff --git a/uikit/src/main/java/screen/CometChatMorePrivacyScreenActivity.java b/uikit/src/main/java/screen/CometChatMorePrivacyScreenActivity.java index eb7c50cb..046f24fc 100644 --- a/uikit/src/main/java/screen/CometChatMorePrivacyScreenActivity.java +++ b/uikit/src/main/java/screen/CometChatMorePrivacyScreenActivity.java @@ -4,6 +4,7 @@ import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; +import android.graphics.Color; import android.os.Bundle; import android.view.MenuItem; import android.view.View; @@ -22,6 +23,7 @@ import screen.blockuserlist.CometChatBlockUserListScreenActivity; import utils.FontUtils; +import com.cometchat.pro.uikit.Settings.UISettings; import utils.Utils; public class CometChatMorePrivacyScreenActivity extends AppCompatActivity { @@ -48,6 +50,9 @@ protected void onCreate(Bundle savedInstanceState) { if (getSupportActionBar()!=null) getSupportActionBar().setDisplayHomeAsUpEnabled(true); + if (UISettings.getColor()!=null) + getWindow().setStatusBarColor( + Color.parseColor(UISettings.getColor())); if (Utils.changeToolbarFont(toolbar)!=null){ Utils.changeToolbarFont(toolbar).setTypeface(FontUtils.getInstance(this).getTypeFace(FontUtils.robotoMedium)); } diff --git a/uikit/src/main/java/screen/CometChatStartCallActivity.java b/uikit/src/main/java/screen/CometChatStartCallActivity.java index 8ee1cb31..327e62fd 100644 --- a/uikit/src/main/java/screen/CometChatStartCallActivity.java +++ b/uikit/src/main/java/screen/CometChatStartCallActivity.java @@ -5,7 +5,9 @@ import android.os.Bundle; import android.util.Log; import android.widget.RelativeLayout; +import android.widget.Toast; +import com.cometchat.pro.constants.CometChatConstants; import com.cometchat.pro.core.Call; import com.cometchat.pro.core.CallSettings; import com.cometchat.pro.core.CometChat; @@ -33,6 +35,11 @@ public class CometChatStartCallActivity extends AppCompatActivity { private String sessionID; + private String type; + + private CallSettings callSettings; + + private boolean joinOnGoing; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -40,31 +47,40 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_comet_chat_start_call); mainView = findViewById(R.id.call_view); sessionID = getIntent().getStringExtra(StringContract.IntentStrings.SESSION_ID); - CallSettings callSettings = new CallSettings.CallSettingsBuilder(this,mainView) - .setSessionId(sessionID) - .build(); + type = getIntent().getStringExtra(StringContract.IntentStrings.TYPE); + if (type!=null && type.equalsIgnoreCase(CometChatConstants.RECEIVER_TYPE_USER)) + callSettings = new CallSettings.CallSettingsBuilder(this,mainView) + .setSessionId(sessionID) + .setMode(CallSettings.MODE_SINGLE) + .build(); + else + callSettings = new CallSettings.CallSettingsBuilder(this,mainView) + .setSessionId(sessionID) + .build(); + CometChat.startCall(callSettings, new CometChat.OngoingCallListener() { - @Override - public void onUserJoined(User user) { - Log.e("onUserJoined: ",user.getUid() ); - } + @Override + public void onUserJoined(User user) { + Log.e("onUserJoined: ", user.getUid()); + } - @Override - public void onUserLeft(User user) { - Snackbar.make(mainView,"User Left: "+user.getName(),Snackbar.LENGTH_LONG).show(); - Log.e( "onUserLeft: ",user.getUid() ); - } + @Override + public void onUserLeft(User user) { + Snackbar.make(mainView, "User Left: " + user.getName(), Snackbar.LENGTH_LONG).show(); + Log.e("onUserLeft: ", user.getUid()); + } - @Override - public void onError(CometChatException e) { - Log.e( "onError: ",e.getMessage() ); - } + @Override + public void onError(CometChatException e) { + Log.e("onstartcallError: ", e.getMessage()); + Toast.makeText(CometChatStartCallActivity.this,e.getMessage(),Toast.LENGTH_LONG).show(); + } - @Override - public void onCallEnded(Call call) { - Log.e("onCallEnded: ",call.toString() ); - finish(); - } + @Override + public void onCallEnded(Call call) { + Log.e("TAG", "onCallEnded: "); + finish(); + } }); } } \ No newline at end of file diff --git a/uikit/src/main/java/screen/CometChatUserCallListScreenActivity.java b/uikit/src/main/java/screen/CometChatUserCallListScreenActivity.java index 18292de3..d033566c 100644 --- a/uikit/src/main/java/screen/CometChatUserCallListScreenActivity.java +++ b/uikit/src/main/java/screen/CometChatUserCallListScreenActivity.java @@ -18,6 +18,7 @@ import android.content.Context; import android.content.res.ColorStateList; +import android.graphics.Color; import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; @@ -36,11 +37,9 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; -import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.RecyclerView; import com.cometchat.pro.constants.CometChatConstants; -import com.cometchat.pro.core.Call; import com.cometchat.pro.core.CometChat; import com.cometchat.pro.core.UsersRequest; import com.cometchat.pro.exceptions.CometChatException; @@ -52,14 +51,10 @@ import java.util.List; -import adapter.UserListAdapter; -import listeners.ClickListener; import listeners.OnItemClickListener; -import listeners.RecyclerTouchListener; -import listeners.StickyHeaderDecoration; import utils.CallUtils; import utils.FontUtils; -import utils.Utils; +import com.cometchat.pro.uikit.Settings.UISettings; /** @@ -104,7 +99,14 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { title = findViewById(R.id.tv_title); ImageView imageView = new ImageView(this); imageView.setImageDrawable(getResources().getDrawable(R.drawable.ic_close_24dp)); - imageView.setImageTintList(ColorStateList.valueOf(getResources().getColor(R.color.colorPrimary))); + if (UISettings.getColor()!=null) { + getWindow().setStatusBarColor(Color.parseColor(UISettings.getColor())); + imageView.setImageTintList(ColorStateList.valueOf( + Color.parseColor(UISettings.getColor()))); + } else + imageView.setImageTintList( + ColorStateList.valueOf(getResources().getColor(R.color.colorPrimary))); + imageView.setClickable(true); imageView.setPadding(8,8,8,8); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); diff --git a/uikit/src/main/java/screen/CometChatUserDetailScreenActivity.java b/uikit/src/main/java/screen/CometChatUserDetailScreenActivity.java index 0c14f6d3..0cb068cb 100644 --- a/uikit/src/main/java/screen/CometChatUserDetailScreenActivity.java +++ b/uikit/src/main/java/screen/CometChatUserDetailScreenActivity.java @@ -3,6 +3,8 @@ import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; +import android.content.res.ColorStateList; +import android.graphics.Color; import android.os.Bundle; import android.util.Log; import android.view.Menu; @@ -20,6 +22,7 @@ import androidx.recyclerview.widget.RecyclerView; import com.cometchat.pro.constants.CometChatConstants; +import com.cometchat.pro.core.Call; import com.cometchat.pro.core.CometChat; import com.cometchat.pro.core.MessagesRequest; import com.cometchat.pro.exceptions.CometChatException; @@ -44,6 +47,7 @@ import screen.messagelist.CometChatMessageListActivity; import utils.CallUtils; import utils.FontUtils; +import com.cometchat.pro.uikit.Settings.UISettings; import utils.Utils; public class CometChatUserDetailScreenActivity extends AppCompatActivity { @@ -69,6 +73,8 @@ public class CometChatUserDetailScreenActivity extends AppCompatActivity { private TextView tvSendMessage; + private LinearLayout blockUserLayout; + private TextView tvBlockUser; private MaterialToolbar toolbar; @@ -91,6 +97,8 @@ public class CometChatUserDetailScreenActivity extends AppCompatActivity { private SharedMediaView sharedMediaView; + private LinearLayout sharedMediaLayout; + private boolean inProgress; private boolean fromCallList; @@ -129,6 +137,9 @@ private void initComponent() { addBtn.setTypeface(fontUtils.getTypeFace(FontUtils.robotoRegular)); + + blockUserLayout = findViewById(R.id.block_user_layout); + tvBlockUser = findViewById(R.id.tv_blockUser); tvBlockUser.setTypeface(fontUtils.getTypeFace(FontUtils.robotoMedium)); @@ -138,12 +149,15 @@ private void initComponent() { handleIntent(); - + sharedMediaLayout = findViewById(R.id.shared_media_layout); sharedMediaView = findViewById(R.id.shared_media_view); sharedMediaView.setRecieverId(uid); sharedMediaView.setRecieverType(CometChatConstants.RECEIVER_TYPE_USER); sharedMediaView.reload(); - + + if (!UISettings.isViewSharedMedia()) + sharedMediaLayout.setVisibility(View.GONE); + checkDarkMode(); addBtn.setOnClickListener(view -> { @@ -170,6 +184,9 @@ private void initComponent() { onBackPressed(); }); + if (!UISettings.isBlockUser()) + blockUserLayout.setVisibility(View.GONE); + tvBlockUser.setOnClickListener(view -> { if (isBlocked) unblockUser(); @@ -177,6 +194,25 @@ private void initComponent() { blockUser(); }); + + if (UISettings.isEnableVideoCalling()) + videoCallBtn.setVisibility(View.VISIBLE); + else + videoCallBtn.setVisibility(View.GONE); + + if (UISettings.isEnableVoiceCalling()) + callBtn.setVisibility(View.VISIBLE); + else + callBtn.setVisibility(View.GONE); + + if (UISettings.getColor()!=null) { + getWindow().setStatusBarColor(Color.parseColor(UISettings.getColor())); + callBtn.setImageTintList(ColorStateList.valueOf( + Color.parseColor(UISettings.getColor()))); + videoCallBtn.setImageTintList(ColorStateList.valueOf( + Color.parseColor(UISettings.getColor()))); + } + callBtn.setOnClickListener(view -> { callBtn.setClickable(false); checkOnGoingCall(CometChatConstants.CALL_TYPE_AUDIO); @@ -221,7 +257,25 @@ public void onClick(DialogInterface dialog, int which) { }).create().show(); } else { - CallUtils.initiateCall(CometChatUserDetailScreenActivity.this,uid,CometChatConstants.RECEIVER_TYPE_USER,callType); +// CallUtils.initiateCall(CometChatUserDetailScreenActivity.this,uid,CometChatConstants.RECEIVER_TYPE_USER,callType); + Call call = new Call(uid,CometChatConstants.RECEIVER_TYPE_USER,callType); + CometChat.initiateCall(call, new CometChat.CallbackListener() { + @Override + public void onSuccess(Call call) { + CallUtils.startCallIntent(CometChatUserDetailScreenActivity.this, + ((User)call.getCallReceiver()),call.getType(),true, + call.getSessionId()); + } + + @Override + public void onError(CometChatException e) { + callBtn.setClickable(true); + videoCallBtn.setClickable(true); + Log.e(TAG, "onError: "+e.getMessage()); + Snackbar.make(getWindow().getDecorView().getRootView(), + getResources().getString(R.string.call_initiate_error)+":"+e.getMessage(),Snackbar.LENGTH_LONG).show(); + } + }); } } diff --git a/uikit/src/main/java/screen/CometChatUserInfoScreen.java b/uikit/src/main/java/screen/CometChatUserInfoScreen.java index 7e442774..622bf3c3 100644 --- a/uikit/src/main/java/screen/CometChatUserInfoScreen.java +++ b/uikit/src/main/java/screen/CometChatUserInfoScreen.java @@ -1,12 +1,12 @@ package screen; -import android.Manifest; import android.app.AlertDialog; -import android.content.ContentResolver; -import android.content.DialogInterface; import android.content.Intent; +import android.graphics.Color; +import android.graphics.drawable.Drawable; import android.os.Bundle; +import androidx.core.graphics.drawable.DrawableCompat; import androidx.databinding.DataBindingUtil; import androidx.fragment.app.Fragment; @@ -16,7 +16,6 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.CompoundButton; import android.widget.Toast; import com.bumptech.glide.Glide; @@ -29,12 +28,9 @@ import com.google.android.material.button.MaterialButton; import com.google.android.material.textfield.TextInputEditText; -import java.io.File; - import constant.StringContract; import utils.FontUtils; -import utils.MediaUtils; -import utils.PreferenceUtil; +import com.cometchat.pro.uikit.Settings.UISettings; import utils.Utils; public class CometChatUserInfoScreen extends Fragment { @@ -64,6 +60,14 @@ public void onClick(View view) { } }); + if (UISettings.getColor()!=null) { + int widgetColor = Color.parseColor(UISettings.getColor()); + Drawable wrappedDrawable = DrawableCompat.wrap(getResources(). + getDrawable(R.drawable.ic_security_24dp)); + wrappedDrawable.setTint(widgetColor); + DrawableCompat.setTint(wrappedDrawable, widgetColor); + moreInfoScreenBinding.ivSecurity.setImageDrawable(wrappedDrawable); + } if(Utils.isDarkMode(getContext())) { moreInfoScreenBinding.tvTitle.setTextColor(getResources().getColor(R.color.textColorWhite)); moreInfoScreenBinding.tvSeperator.setBackgroundColor(getResources().getColor(R.color.grey)); diff --git a/uikit/src/main/java/screen/CometChatUserListScreen.java b/uikit/src/main/java/screen/CometChatUserListScreen.java index e74e6731..c4b3b8c9 100644 --- a/uikit/src/main/java/screen/CometChatUserListScreen.java +++ b/uikit/src/main/java/screen/CometChatUserListScreen.java @@ -51,11 +51,9 @@ import java.util.List; import adapter.UserListAdapter; -import listeners.ClickListener; import listeners.OnItemClickListener; -import listeners.RecyclerTouchListener; -import listeners.StickyHeaderDecoration; import utils.FontUtils; +import com.cometchat.pro.uikit.Settings.UISettings; import utils.Utils; /* @@ -225,8 +223,13 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat private void fetchUsers() { if (usersRequest == null) { - Log.e(TAG, "newfetchUsers: " ); - usersRequest = new UsersRequest.UsersRequestBuilder().setLimit(30).build(); + if (UISettings.getUserListing() + .equalsIgnoreCase("friends")) + usersRequest = new UsersRequest.UsersRequestBuilder().setLimit(30) + .friendsOnly(true).build(); + else if (UISettings.getUserListing() + .equalsIgnoreCase("all_users")) + usersRequest = new UsersRequest.UsersRequestBuilder().setLimit(30).build(); } usersRequest.fetchNext(new CometChat.CallbackListener>() { @Override diff --git a/uikit/src/main/java/screen/addmember/CometChatAddMemberScreenActivity.java b/uikit/src/main/java/screen/addmember/CometChatAddMemberScreenActivity.java index 10ba1400..62b72681 100644 --- a/uikit/src/main/java/screen/addmember/CometChatAddMemberScreenActivity.java +++ b/uikit/src/main/java/screen/addmember/CometChatAddMemberScreenActivity.java @@ -1,5 +1,6 @@ package screen.addmember; +import android.graphics.Color; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; @@ -11,6 +12,7 @@ import com.cometchat.pro.uikit.R; import constant.StringContract; +import com.cometchat.pro.uikit.Settings.UISettings; public class CometChatAddMemberScreenActivity extends AppCompatActivity { @@ -21,6 +23,8 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_block_screen); handleIntent(); + if (UISettings.getColor()!=null) + getWindow().setStatusBarColor(Color.parseColor(UISettings.getColor())); } private void handleIntent() { diff --git a/uikit/src/main/java/screen/adminAndModeratorList/CometChatAdminModeratorListScreenActivity.java b/uikit/src/main/java/screen/adminAndModeratorList/CometChatAdminModeratorListScreenActivity.java index 71f168f8..b159d9f9 100644 --- a/uikit/src/main/java/screen/adminAndModeratorList/CometChatAdminModeratorListScreenActivity.java +++ b/uikit/src/main/java/screen/adminAndModeratorList/CometChatAdminModeratorListScreenActivity.java @@ -1,5 +1,6 @@ package screen.adminAndModeratorList; +import android.graphics.Color; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; @@ -11,6 +12,7 @@ import com.cometchat.pro.uikit.R; import constant.StringContract; +import com.cometchat.pro.uikit.Settings.UISettings; public class CometChatAdminModeratorListScreenActivity extends AppCompatActivity { @@ -27,6 +29,8 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_block_screen); handleIntent(); + if (UISettings.getColor()!=null) + getWindow().setStatusBarColor(Color.parseColor(UISettings.getColor())); } private void handleIntent() { diff --git a/uikit/src/main/java/screen/banmembers/CometChatBanMemberScreenActivity.java b/uikit/src/main/java/screen/banmembers/CometChatBanMemberScreenActivity.java index 8a857fec..9d4323e1 100644 --- a/uikit/src/main/java/screen/banmembers/CometChatBanMemberScreenActivity.java +++ b/uikit/src/main/java/screen/banmembers/CometChatBanMemberScreenActivity.java @@ -2,31 +2,18 @@ import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; +import android.graphics.Color; import android.os.Bundle; -import android.view.ContextMenu; import android.view.Menu; -import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; -import com.cometchat.pro.constants.CometChatConstants; -import com.cometchat.pro.core.BannedGroupMembersRequest; -import com.cometchat.pro.core.CometChat; -import com.cometchat.pro.exceptions.CometChatException; -import com.cometchat.pro.models.GroupMember; import com.cometchat.pro.uikit.R; import com.google.android.material.appbar.MaterialToolbar; -import com.google.android.material.snackbar.Snackbar; -import java.util.List; - -import adapter.GroupMemberAdapter; import constant.StringContract; -import listeners.ClickListener; -import listeners.RecyclerTouchListener; +import com.cometchat.pro.uikit.Settings.UISettings; public class CometChatBanMemberScreenActivity extends AppCompatActivity { @@ -45,6 +32,8 @@ public void onClick(View v) { } }); handleIntent(); + if (UISettings.getColor()!=null) + getWindow().setStatusBarColor(Color.parseColor(UISettings.getColor())); CometChatBanMemberScreen banFragment = new CometChatBanMemberScreen(); Bundle bundle = new Bundle(); bundle.putString(StringContract.IntentStrings.GUID,guid); diff --git a/uikit/src/main/java/screen/blockuserlist/CometChatBlockUserListScreenActivity.java b/uikit/src/main/java/screen/blockuserlist/CometChatBlockUserListScreenActivity.java index d74d0a5c..c0c0cc2d 100644 --- a/uikit/src/main/java/screen/blockuserlist/CometChatBlockUserListScreenActivity.java +++ b/uikit/src/main/java/screen/blockuserlist/CometChatBlockUserListScreenActivity.java @@ -1,5 +1,6 @@ package screen.blockuserlist; +import android.graphics.Color; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; @@ -10,6 +11,8 @@ import com.cometchat.pro.uikit.R; +import com.cometchat.pro.uikit.Settings.UISettings; + public class CometChatBlockUserListScreenActivity extends AppCompatActivity { private Fragment fragment; @@ -23,7 +26,8 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_block_screen); Fragment fragment = new CometChatBlockUserListScreen(); getSupportFragmentManager().beginTransaction().replace(R.id.frame_fragment,fragment).commit(); - + if (UISettings.getColor()!=null) + getWindow().setStatusBarColor(Color.parseColor(UISettings.getColor())); } diff --git a/uikit/src/main/java/screen/call/CometChatCallListScreen.java b/uikit/src/main/java/screen/call/CometChatCallListScreen.java index ae6e4347..ae7a2b7b 100644 --- a/uikit/src/main/java/screen/call/CometChatCallListScreen.java +++ b/uikit/src/main/java/screen/call/CometChatCallListScreen.java @@ -3,41 +3,21 @@ import android.content.Intent; import android.content.res.ColorStateList; +import android.graphics.Color; +import android.graphics.drawable.Drawable; import android.os.Bundle; -import android.text.Editable; -import android.text.TextWatcher; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.view.inputmethod.EditorInfo; -import android.widget.EditText; import android.widget.ImageView; -import android.widget.RelativeLayout; import android.widget.TextView; -import android.widget.Toast; -import androidx.annotation.NonNull; +import androidx.core.graphics.drawable.DrawableCompat; import androidx.fragment.app.Fragment; -import androidx.recyclerview.widget.RecyclerView; import androidx.viewpager.widget.ViewPager; -import com.cometchat.pro.constants.CometChatConstants; import com.cometchat.pro.core.Call; -import com.cometchat.pro.core.CometChat; -import com.cometchat.pro.core.ConversationsRequest; import com.cometchat.pro.core.MessagesRequest; -import com.cometchat.pro.exceptions.CometChatException; -import com.cometchat.pro.helpers.CometChatHelper; -import com.cometchat.pro.models.Action; -import com.cometchat.pro.models.BaseMessage; -import com.cometchat.pro.models.Conversation; -import com.cometchat.pro.models.CustomMessage; -import com.cometchat.pro.models.Group; -import com.cometchat.pro.models.MediaMessage; -import com.cometchat.pro.models.MessageReceipt; -import com.cometchat.pro.models.TextMessage; -import com.cometchat.pro.models.User; import com.cometchat.pro.uikit.CometChatCallList; import com.cometchat.pro.uikit.R; import com.facebook.shimmer.ShimmerFrameLayout; @@ -46,14 +26,10 @@ import java.util.ArrayList; import java.util.List; -import adapter.ConversationListAdapter; import adapter.TabAdapter; -import listeners.ClickListener; import listeners.OnItemClickListener; -import listeners.RecyclerTouchListener; -import screen.CometChatCallActivity; import screen.CometChatUserCallListScreenActivity; -import utils.FontUtils; +import com.cometchat.pro.uikit.Settings.UISettings; import utils.Utils; /** @@ -118,6 +94,41 @@ public void onClick(View v) { viewPager.setAdapter(tabAdapter); } tabLayout.setupWithViewPager(viewPager); + if (UISettings.getColor()!=null) { + phoneAddIv.setImageTintList(ColorStateList.valueOf(Color.parseColor(UISettings.getColor()))); + Drawable wrappedDrawable = DrawableCompat.wrap(getResources(). + getDrawable(R.drawable.tab_layout_background_active)); + DrawableCompat.setTint(wrappedDrawable, Color.parseColor(UISettings.getColor())); + tabLayout.getTabAt(tabLayout.getSelectedTabPosition()).view.setBackground(wrappedDrawable); + tabLayout.setSelectedTabIndicatorColor(Color.parseColor(UISettings.getColor())); + } else { + tabLayout.getTabAt(tabLayout.getSelectedTabPosition()). + view.setBackgroundColor(getResources().getColor(R.color.colorPrimary)); + tabLayout.setSelectedTabIndicatorColor(getResources().getColor(R.color.colorPrimary)); + } + tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { + @Override + public void onTabSelected(TabLayout.Tab tab) { + if (UISettings.getColor()!=null) { + Drawable wrappedDrawable = DrawableCompat.wrap(getResources(). + getDrawable(R.drawable.tab_layout_background_active)); + DrawableCompat.setTint(wrappedDrawable, Color.parseColor(UISettings.getColor())); + tab.view.setBackground(wrappedDrawable); + } + else + tab.view.setBackgroundColor(getResources().getColor(R.color.colorPrimary)); + } + + @Override + public void onTabUnselected(TabLayout.Tab tab) { + tab.view.setBackgroundColor(getResources().getColor(android.R.color.transparent)); + } + + @Override + public void onTabReselected(TabLayout.Tab tab) { + + } + }); checkDarkMode(); return view; } diff --git a/uikit/src/main/java/screen/creategroup/CometChatCreateGroupScreenActivity.java b/uikit/src/main/java/screen/creategroup/CometChatCreateGroupScreenActivity.java index a857d82c..9bbd6848 100644 --- a/uikit/src/main/java/screen/creategroup/CometChatCreateGroupScreenActivity.java +++ b/uikit/src/main/java/screen/creategroup/CometChatCreateGroupScreenActivity.java @@ -1,5 +1,6 @@ package screen.creategroup; +import android.graphics.Color; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; @@ -10,6 +11,8 @@ import com.cometchat.pro.uikit.R; +import com.cometchat.pro.uikit.Settings.UISettings; + public class CometChatCreateGroupScreenActivity extends AppCompatActivity { private Fragment fragment; @@ -23,7 +26,8 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_block_screen); Fragment fragment = new CometChatCreateGroupScreen(); getSupportFragmentManager().beginTransaction().replace(R.id.frame_fragment,fragment).commit(); - + if (UISettings.getColor()!=null) + getWindow().setStatusBarColor(Color.parseColor(UISettings.getColor())); } diff --git a/uikit/src/main/java/screen/groupmemberlist/CometChatGroupMemberListScreenActivity.java b/uikit/src/main/java/screen/groupmemberlist/CometChatGroupMemberListScreenActivity.java index 21c300b5..ac3f784c 100644 --- a/uikit/src/main/java/screen/groupmemberlist/CometChatGroupMemberListScreenActivity.java +++ b/uikit/src/main/java/screen/groupmemberlist/CometChatGroupMemberListScreenActivity.java @@ -1,5 +1,6 @@ package screen.groupmemberlist; +import android.graphics.Color; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; @@ -11,6 +12,7 @@ import com.cometchat.pro.uikit.R; import constant.StringContract; +import com.cometchat.pro.uikit.Settings.UISettings; public class CometChatGroupMemberListScreenActivity extends AppCompatActivity { @@ -22,15 +24,20 @@ public class CometChatGroupMemberListScreenActivity extends AppCompatActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_block_screen); - guid = getIntent().getStringExtra(StringContract.IntentStrings.GUID); - showModerators = getIntent().getBooleanExtra(StringContract.IntentStrings.SHOW_MODERATORLIST,showModerators); + + if (getIntent().hasExtra(StringContract.IntentStrings.GUID)) + guid = getIntent().getStringExtra(StringContract.IntentStrings.GUID); + if (getIntent().hasExtra(StringContract.IntentStrings.SHOW_MODERATORLIST)) + showModerators = getIntent().getBooleanExtra(StringContract.IntentStrings.SHOW_MODERATORLIST,false); + Fragment fragment = new CometChatGroupMemberListScreen(); Bundle bundle = new Bundle(); bundle.putString(StringContract.IntentStrings.GUID,guid); bundle.putBoolean(StringContract.IntentStrings.SHOW_MODERATORLIST,showModerators); fragment.setArguments(bundle); getSupportFragmentManager().beginTransaction().replace(R.id.frame_fragment,fragment).commit(); - + if (UISettings.getColor()!=null) + getWindow().setStatusBarColor(Color.parseColor(UISettings.getColor())); } diff --git a/uikit/src/main/java/screen/messagelist/CometChatMessageListActivity.java b/uikit/src/main/java/screen/messagelist/CometChatMessageListActivity.java index 08df6130..4917d6ee 100644 --- a/uikit/src/main/java/screen/messagelist/CometChatMessageListActivity.java +++ b/uikit/src/main/java/screen/messagelist/CometChatMessageListActivity.java @@ -2,6 +2,7 @@ import android.content.DialogInterface; import android.content.Intent; +import android.graphics.Color; import android.os.Bundle; import android.util.Log; import android.view.Menu; @@ -15,11 +16,7 @@ import androidx.fragment.app.Fragment; import com.cometchat.pro.constants.CometChatConstants; -import com.cometchat.pro.core.Call; -import com.cometchat.pro.core.CometChat; import com.cometchat.pro.models.BaseMessage; -import com.cometchat.pro.models.Group; -import com.cometchat.pro.models.User; import com.cometchat.pro.uikit.R; import java.util.List; @@ -28,8 +25,7 @@ import constant.StringContract; import listeners.MessageActionCloseListener; import listeners.OnMessageLongClick; -import screen.CometChatUserDetailScreenActivity; -import utils.Utils; +import com.cometchat.pro.uikit.Settings.UISettings; /** @@ -60,6 +56,9 @@ public class CometChatMessageListActivity extends AppCompatActivity implements M protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_cometchat_message_list); + if (UISettings.getColor() !=null) { + getWindow().setStatusBarColor(Color.parseColor(UISettings.getColor())); + } EmojiCompat.Config config = new BundledEmojiCompatConfig(this); EmojiCompat.init(config); diff --git a/uikit/src/main/java/screen/messagelist/CometChatMessageScreen.java b/uikit/src/main/java/screen/messagelist/CometChatMessageScreen.java index 7a2092b5..2da74591 100644 --- a/uikit/src/main/java/screen/messagelist/CometChatMessageScreen.java +++ b/uikit/src/main/java/screen/messagelist/CometChatMessageScreen.java @@ -1,6 +1,10 @@ package screen.messagelist; import android.Manifest; +import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; +import android.animation.ObjectAnimator; +import android.animation.ValueAnimator; import android.app.Dialog; import android.app.ProgressDialog; import android.content.ClipData; @@ -12,23 +16,31 @@ import android.content.pm.PackageManager; import android.content.res.ColorStateList; import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Color; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.net.Uri; import android.os.Build; import android.os.Bundle; +import android.os.Handler; import android.provider.MediaStore; import android.provider.Settings; import android.text.Editable; import android.util.Log; +import android.view.Gravity; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; +import android.view.animation.AccelerateDecelerateInterpolator; +import android.view.animation.Animation; +import android.view.animation.AnimationUtils; import android.widget.EditText; +import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.RelativeLayout; @@ -42,6 +54,7 @@ import androidx.appcompat.widget.Toolbar; import androidx.core.view.inputmethod.InputContentInfoCompat; import androidx.fragment.app.Fragment; +import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -68,6 +81,8 @@ import com.cometchat.pro.models.TypingIndicator; import com.cometchat.pro.models.User; import com.cometchat.pro.uikit.SmartReplyList; +import com.cometchat.pro.uikit.Sticker.listener.StickerClickListener; +import com.cometchat.pro.uikit.Sticker.StickerView; import com.facebook.shimmer.ShimmerFrameLayout; import com.google.android.gms.location.FusedLocationProviderClient; import com.google.android.gms.location.LocationServices; @@ -88,12 +103,19 @@ import java.util.TimerTask; import adapter.MessageAdapter; +import adapter.StickersAdapter; import constant.StringContract; +import listeners.ClickListener; import listeners.ComposeActionListener; +import listeners.ExtensionResponseListener; import listeners.MessageActionCloseListener; import listeners.OnItemClickListener; import listeners.OnMessageLongClick; +import listeners.ReactionClickListener; +import listeners.ReactionListener; +import listeners.RecyclerTouchListener; import listeners.StickyHeaderDecoration; +import com.cometchat.pro.uikit.Sticker.model.Sticker; import screen.CometChatForwardMessageScreenActivity; import screen.CometChatGroupDetailScreenActivity; import screen.CometChatMessageInfoScreenActivity; @@ -104,6 +126,7 @@ import utils.FontUtils; import utils.MediaUtils; import utils.KeyBoardUtils; +import com.cometchat.pro.uikit.Settings.UISettings; import utils.Utils; import static android.view.View.GONE; @@ -257,6 +280,17 @@ public class CometChatMessageScreen extends Fragment implements View.OnClickList private ArrayList optionsArrayList = new ArrayList<>(); + private StickerView stickersView; + private RelativeLayout stickerLayout; + private ImageView closeStickerView; + + private boolean isKeyboardVisible; + + private ImageView imageView; + private FrameLayout container; + public ObjectAnimator animation; + + public CometChatMessageScreen() { // Required empty public constructor } @@ -311,6 +345,53 @@ private void initViewComponent(View view) { composeBox = view.findViewById(R.id.message_box); composeBox.usedIn(CometChatMessageListActivity.class.getName()); setComposeBoxListener(); + if (UISettings.isEnableSendingMessage()) + composeBox.setVisibility(View.VISIBLE); + + container = view.findViewById(R.id.reactions_container); + composeBox.liveReactionBtn.setOnTouchListener(new ReactionListener(700, 1000, new ReactionClickListener() { + @Override + public void onClick(View var1) { + container.setAlpha(1.0f); + sendLiveReaction(); + } + + @Override + public void onCancel(View var1) { + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + if (imageView!=null && animation!=null && animation.isRunning()) { + ObjectAnimator animator = ObjectAnimator.ofFloat(container,"alpha",0.2f); + animator.setDuration(700); + animator.start(); + animator.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + super.onAnimationEnd(animation); + imageView.clearAnimation(); + container.removeAllViews(); + if (typingTimer!=null) + typingTimer.schedule(new TimerTask() { + @Override + public void run() { + JSONObject metaData = new JSONObject(); + try { + metaData.put("reaction", "heart"); + } catch (JSONException e) { + e.printStackTrace(); + } + TypingIndicator typingIndicator = new TypingIndicator(Id, type, metaData); + CometChat.endTyping(typingIndicator); + } + },2000); + } + }); + } + } + },1400); + } + })); rvSmartReply = view.findViewById(R.id.rv_smartReply); @@ -320,6 +401,32 @@ private void initViewComponent(View view) { ImageView ivMessageClose = view.findViewById(R.id.iv_message_close); ivMessageClose.setOnClickListener(this); + stickersView = view.findViewById(R.id.stickersView); + stickerLayout = view.findViewById(R.id.sticker_layout); + closeStickerView = view.findViewById(R.id.close_sticker_layout); + + closeStickerView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + stickerLayout.setVisibility(GONE); + } + }); + + stickersView.setStickerClickListener(new StickerClickListener() { + @Override + public void onClickListener(Sticker sticker) { + JSONObject stickerData = new JSONObject(); + try { + stickerData.put("url",sticker.getUrl()); + stickerData.put("name",sticker.getName()); + } catch (JSONException e) { + e.printStackTrace(); + } + sendCustomMessage(StringContract.IntentStrings.STICKERS,stickerData); + stickerLayout.setVisibility(GONE); + } + }); + replyMessageLayout = view.findViewById(R.id.replyMessageLayout); replyTitle = view.findViewById(R.id.tv_reply_layout_title); replyMessage = view.findViewById(R.id.tv_reply_layout_subtitle); @@ -366,6 +473,7 @@ private void initViewComponent(View view) { } KeyBoardUtils.setKeyboardVisibilityListener(getActivity(), (View) rvChatListView.getParent(), keyboardVisible -> { + isKeyboardVisible = keyboardVisible; if (keyboardVisible) { scrollToBottom(); composeBox.ivMic.setVisibility(GONE); @@ -375,8 +483,13 @@ private void initViewComponent(View view) { composeBox.ivMic.setVisibility(GONE); composeBox.ivSend.setVisibility(View.VISIBLE); }else { - composeBox.ivMic.setVisibility(View.VISIBLE); - composeBox.ivSend.setVisibility(GONE);; + if (UISettings.isSendVoiceNotes()) { + composeBox.ivMic.setVisibility(View.VISIBLE); + composeBox.ivSend.setVisibility(GONE); + } else { + composeBox.ivMic.setVisibility(GONE); + composeBox.ivSend.setVisibility(View.VISIBLE); + } } } }); @@ -422,7 +535,11 @@ public void OnItemClick(String var, int position) { } private void checkOnGoingCall() { - if(CometChat.getActiveCall()!=null && CometChat.getActiveCall().getCallStatus().equals(CometChatConstants.CALL_STATUS_ONGOING) && CometChat.getActiveCall().getSessionId()!=null) { + if(CometChat.getActiveCall()!=null && + CometChat.getActiveCall().getReceiverUid().equalsIgnoreCase(Id) && + CometChat.getActiveCall().getCallStatus(). + equals(CometChatConstants.CALL_STATUS_ONGOING) && + CometChat.getActiveCall().getSessionId()!=null) { if(onGoingCallView!=null) onGoingCallView.setVisibility(View.VISIBLE); if(onGoingCallTxt!=null) { @@ -454,8 +571,8 @@ private void setComposeBoxListener() { composeBox.setComposeBoxListener(new ComposeActionListener() { @Override public void onEditTextMediaSelected(InputContentInfoCompat inputContentInfo) { - Log.e(TAG, "onEditTextMediaSelected: Path="+inputContentInfo.getLinkUri().getPath() - +"\nHost="+inputContentInfo.getLinkUri().getFragment()); + Log.e(TAG, "onEditTextMediaSelected: Path=" + inputContentInfo.getLinkUri().getPath() + + "\nHost=" + inputContentInfo.getLinkUri().getFragment()); String messageType = inputContentInfo.getLinkUri().toString().substring(inputContentInfo.getLinkUri().toString().lastIndexOf('.')); MediaMessage mediaMessage = new MediaMessage(Id, null, CometChatConstants.MESSAGE_TYPE_IMAGE, type); Attachment attachment = new Attachment(); @@ -465,22 +582,7 @@ public void onEditTextMediaSelected(InputContentInfoCompat inputContentInfo) { attachment.setFileName(inputContentInfo.getDescription().getLabel().toString()); mediaMessage.setAttachment(attachment); Log.e(TAG, "onClick: " + attachment.toString()); - CometChat.sendMediaMessage(mediaMessage, new CometChat.CallbackListener() { - @Override - public void onSuccess(MediaMessage mediaMessage) { - if (messageAdapter != null) { - messageAdapter.addMessage(mediaMessage); - scrollToBottom(); - } - } - - @Override - public void onError(CometChatException e) { - if (getActivity() != null) { - Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show(); - } - } - }); + sendMediaMessage(mediaMessage); } @Override @@ -490,7 +592,7 @@ public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { - if (charSequence.length()>0) { + if (charSequence.length() > 0) { sendTypingIndicator(false); } else { sendTypingIndicator(true); @@ -507,10 +609,10 @@ public void afterTextChanged(Editable editable) { @Override public void onAudioActionClicked() { - if (Utils.hasPermissions(getContext(),Manifest.permission.WRITE_EXTERNAL_STORAGE)) { - startActivityForResult(MediaUtils.openAudio(getActivity()),StringContract.RequestCode.AUDIO); + if (Utils.hasPermissions(getContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE)) { + startActivityForResult(MediaUtils.openAudio(getActivity()), StringContract.RequestCode.AUDIO); } else { - requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},StringContract.RequestCode.AUDIO); + requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, StringContract.RequestCode.AUDIO); } } @@ -545,16 +647,33 @@ public void onFileActionClicked() { @Override public void onSendActionClicked(EditText editText) { String message = editText.getText().toString().trim(); + String filterEmojiMessage = Utils.removeEmojiAndSymbol(message); editText.setText(""); editText.setHint(getString(R.string.message)); - if (isEdit) { - editMessage(baseMessage, message); - editMessageLayout.setVisibility(GONE); - } else if(isReply){ - replyMessage(baseMessage,message); - replyMessageLayout.setVisibility(GONE); - } else if (!message.isEmpty()) - sendMessage(message); + if (!UISettings.isSendEmojis()) { + if (filterEmojiMessage.trim().length() > 0) { + if (isEdit) { + editMessage(baseMessage, message); + editMessageLayout.setVisibility(GONE); + } else if (isReply) { + replyMessage(baseMessage, message); + replyMessageLayout.setVisibility(GONE); + } else if (!message.isEmpty()) + sendMessage(message); + } else { + Toast.makeText(getContext(), "Emoji Support is not enabled", + Toast.LENGTH_LONG).show(); + } + } else if (UISettings.isSendEmojis()) { + if (isEdit) { + editMessage(baseMessage, message); + editMessageLayout.setVisibility(GONE); + } else if (isReply) { + replyMessage(baseMessage, message); + replyMessageLayout.setVisibility(GONE); + } else if (!message.isEmpty()) + sendMessage(message); + } } @Override @@ -568,13 +687,12 @@ public void onVoiceNoteComplete(String string) { @Override public void onLocationActionClicked() { if (Utils.hasPermissions(getContext(), Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION)) { - initLocation(); + initLocation(); // locationManager = (LocationManager) Objects.requireNonNull(getContext()).getSystemService(Context.LOCATION_SERVICE); boolean provider = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); if (!provider) { turnOnLocation(); - } - else { + } else { getLocation(); } } else { @@ -586,9 +704,29 @@ public void onLocationActionClicked() { public void onPollActionClicked() { createPollDialog(); } + + @Override + public void onStickerClicked() { + stickerLayout.setVisibility(View.VISIBLE); + if (CometChat.isExtensionEnabled("stickers")) { + Extensions.fetchStickers(new ExtensionResponseListener() { + @Override + public void OnResponseSuccess(Object var) { + JSONObject stickersJSON = (JSONObject) var; + stickersView.setData(Id, type, Extensions.extractStickersFromJSON(stickersJSON)); + } + + @Override + public void OnResponseFailed(CometChatException e) { + Toast.makeText(context, "Error:" + e.getCode(), Toast.LENGTH_SHORT).show(); + } + }); + } + } }); } + private void createPollDialog() { AlertDialog.Builder alertDialog = new AlertDialog.Builder(context,R.style.MyDialogTheme); View view = LayoutInflater.from(context).inflate(R.layout.add_polls_layout,null); @@ -603,6 +741,7 @@ private void createPollDialog() { MaterialCardView addOption = view.findViewById(R.id.add_options); LinearLayout optionLayout = view.findViewById(R.id.options_layout); MaterialButton addPoll = view.findViewById(R.id.add_poll); + addPoll.setBackgroundColor(Color.parseColor(UISettings.getColor())); ImageView cancelPoll = view.findViewById(R.id.close_poll); addOption.setOnClickListener(new View.OnClickListener() { @Override @@ -887,7 +1026,7 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) { * @see GroupMembersRequest */ private void getMember() { - GroupMembersRequest groupMembersRequest = new GroupMembersRequest.GroupMembersRequestBuilder(Id).setLimit(100).build(); + GroupMembersRequest groupMembersRequest = new GroupMembersRequest.GroupMembersRequestBuilder(Id).setLimit(30).build(); groupMembersRequest.fetchNext(new CometChat.CallbackListener>() { @Override @@ -1197,6 +1336,28 @@ public void onActivityResult(int requestCode, int resultCode, @Nullable Intent d } + /** + * This method is used to send media messages to other users and group + * @param mediaMessage is a MediaMessageObject + */ + private void sendMediaMessage(MediaMessage mediaMessage) { + CometChat.sendMediaMessage(mediaMessage, new CometChat.CallbackListener() { + @Override + public void onSuccess(MediaMessage mediaMessage) { + if (messageAdapter != null) { + messageAdapter.addMessage(mediaMessage); + scrollToBottom(); + } + } + + @Override + public void onError(CometChatException e) { + if (getActivity() != null) { + Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show(); + } + } + }); + } /** * This method is used to send media messages to other users and group. @@ -1270,9 +1431,12 @@ public void onSuccess(User user) { if (user.getStatus().equals(CometChatConstants.USER_STATUS_ONLINE)) { tvStatus.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary)); } - status = user.getStatus().toString(); + + if (UISettings.isShowUserPresence()) { + status = user.getStatus().toString(); + tvStatus.setText(status); + } setAvatar(); - tvStatus.setText(status); } name = user.getName(); @@ -1352,8 +1516,7 @@ public void onSuccess(TextMessage textMessage) { isSmartReplyClicked=false; rvSmartReply.setVisibility(GONE); if (messageAdapter != null) { - if (StringContract.Sounds.enableMessageSounds) - MediaUtils.playSendSound(context,R.raw.outgoing_message); + MediaUtils.playSendSound(context,R.raw.outgoing_message); messageAdapter.addMessage(textMessage); scrollToBottom(); } @@ -1465,6 +1628,9 @@ private void replyMessage(BaseMessage baseMessage, String message) { } else if (baseMessage.getType().equals(StringContract.IntentStrings.POLLS)) { replyObject.put("type",StringContract.IntentStrings.POLLS); replyObject.put("message",((CustomMessage)baseMessage).getCustomData().getString("question")); + } else if (baseMessage.getType().equals(StringContract.IntentStrings.STICKERS)) { + replyObject.put("type",StringContract.IntentStrings.STICKERS); + replyObject.put("message","Sticker"); } replyObject.put("name",baseMessage.getSender().getName()); replyObject.put("avatar",baseMessage.getSender().getAvatar()); @@ -1475,8 +1641,7 @@ private void replyMessage(BaseMessage baseMessage, String message) { @Override public void onSuccess(TextMessage textMessage) { if (messageAdapter != null) { - if (StringContract.Sounds.enableMessageSounds) - MediaUtils.playSendSound(context,R.raw.outgoing_message); + MediaUtils.playSendSound(context,R.raw.outgoing_message); messageAdapter.addMessage(textMessage); scrollToBottom(); } @@ -1704,8 +1869,7 @@ private void setTypingIndicator(TypingIndicator typingIndicator,boolean isShow) if (typingIndicator.getReceiverType().equalsIgnoreCase(CometChatConstants.RECEIVER_TYPE_USER)) { Log.e(TAG, "onTypingStarted: " + typingIndicator); if (Id != null && Id.equalsIgnoreCase(typingIndicator.getSender().getUid())) { - if (typingIndicator.getMetadata() == null) - typingIndicator(typingIndicator, isShow); + typingIndicator(typingIndicator, isShow); } } else { if (Id != null && Id.equalsIgnoreCase(typingIndicator.getReceiverId())) @@ -1714,8 +1878,8 @@ private void setTypingIndicator(TypingIndicator typingIndicator,boolean isShow) } private void onMessageReceived(BaseMessage message) { - if (StringContract.Sounds.enableMessageSounds) - MediaUtils.playSendSound(context,R.raw.incoming_message); + + MediaUtils.playSendSound(context,R.raw.incoming_message); if (message.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_USER)) { if (Id != null && Id.equalsIgnoreCase(message.getSender().getUid())) { setMessage(message); @@ -1780,15 +1944,53 @@ private void checkSmartReply(BaseMessage lastMessage) { private void typingIndicator(TypingIndicator typingIndicator, boolean show) { if (messageAdapter != null) { if (show) { - if (typingIndicator.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_USER)) - tvStatus.setText("is Typing..."); - else - tvStatus.setText(typingIndicator.getSender().getName() + " is Typing..."); + if (UISettings.isShowTypingIndicators()) { + if (typingIndicator.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_USER)) { + if (typingIndicator.getMetadata() == null) + tvStatus.setText("is Typing..."); + else + setLiveReaction(); + } else { + if (typingIndicator.getMetadata() == null) + tvStatus.setText(typingIndicator.getSender().getName() + " is Typing..."); + else + setLiveReaction(); + } + } } else { - if (typingIndicator.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_USER)) - tvStatus.setText(status); - else - tvStatus.setText(memberNames); + if (typingIndicator.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_USER)) { + if (typingIndicator.getMetadata() == null) + tvStatus.setText(status); + else { + ObjectAnimator animator = ObjectAnimator.ofFloat(container,"alpha",0.2f); + animator.setDuration(700); + animator.start(); + animator.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + super.onAnimationEnd(animation); + imageView.clearAnimation(); + container.removeAllViews(); + } + }); + } + } else{ + if (typingIndicator.getMetadata() == null) + tvStatus.setText(memberNames); + else { + ObjectAnimator animator = ObjectAnimator.ofFloat(container,"alpha",0.2f); + animator.setDuration(700); + animator.start(); + animator.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + super.onAnimationEnd(animation); + imageView.clearAnimation(); + container.removeAllViews(); + } + }); + } + } } } @@ -1813,6 +2015,7 @@ private void removeUserListener() { } + @Override public void onPause() { Log.d(TAG, "onPause: "); @@ -1845,11 +2048,14 @@ public void onResume() { if (type != null) { if (type.equals(CometChatConstants.RECEIVER_TYPE_USER)) { - addUserListener(); - tvStatus.setText(status); + if (UISettings.isShowUserPresence()) { + addUserListener(); + tvStatus.setText(status); + } new Thread(this::getUser).start(); } else { - addGroupListener(); + if (!UISettings.isGroupNotificationHidden()) + addGroupListener(); new Thread(this::getGroup).start(); new Thread(this::getMember).start(); } @@ -2008,6 +2214,10 @@ private void startThreadActivity() { ((CustomMessage) baseMessage).getCustomData().getDouble("latitude")); intent.putExtra(StringContract.IntentStrings.LOCATION_LONGITUDE, ((CustomMessage) baseMessage).getCustomData().getDouble("longitude")); + } else if (baseMessage.getType().equals(StringContract.IntentStrings.STICKERS)) { + intent.putExtra(StringContract.IntentStrings.MESSAGE_TYPE_IMAGE_NAME,((CustomMessage)baseMessage).getCustomData().getString("name")); + intent.putExtra(StringContract.IntentStrings.MESSAGE_TYPE_IMAGE_URL,((CustomMessage)baseMessage).getCustomData().getString("url")); + intent.putExtra(StringContract.IntentStrings.MESSAGE_TYPE,StringContract.IntentStrings.STICKERS); } else if (baseMessage.getType().equals(StringContract.IntentStrings.POLLS)) { JSONObject options = ((CustomMessage)baseMessage).getCustomData().getJSONObject("options"); intent.putExtra(StringContract.IntentStrings.POLL_QUESTION,((CustomMessage)baseMessage).getCustomData().getString("question")); @@ -2039,31 +2249,31 @@ public void setLongMessageClick(List baseMessagesList) { messageActionFragment = new MessageActionFragment(); replyMessageLayout.setVisibility(GONE); editMessageLayout.setVisibility(GONE); - boolean shareVisible = true; - boolean copyVisible = true; - boolean threadVisible = true; - boolean replyVisible = true; - boolean editVisible = true; - boolean deleteVisible = true; - boolean forwardVisible = true; - boolean mapVisible = false; + boolean shareVisible = UISettings.isEnableShareCopyForward(); + boolean copyVisible = UISettings.isEnableShareCopyForward(); + boolean threadVisible = UISettings.isEnableThreadedReplies(); + boolean replyVisible = UISettings.isEnableReplyToMessage(); + boolean editVisible = UISettings.isEnableEditingMessage(); + boolean deleteVisible = UISettings.isEnableDeleteMessage(); + boolean forwardVisible = UISettings.isEnableShareCopyForward(); List textMessageList = new ArrayList<>(); List mediaMessageList = new ArrayList<>(); List locationMessageList = new ArrayList<>(); List pollsMessageList = new ArrayList<>(); + List stickerMessageList = new ArrayList<>(); for (BaseMessage baseMessage : baseMessagesList) { if (baseMessage.getType().equals(CometChatConstants.MESSAGE_TYPE_TEXT)) { textMessageList.add(baseMessage); - } - else if (baseMessage.getType().equals(CometChatConstants.MESSAGE_TYPE_IMAGE) || + } else if (baseMessage.getType().equals(CometChatConstants.MESSAGE_TYPE_IMAGE) || baseMessage.getType().equals(CometChatConstants.MESSAGE_TYPE_VIDEO) || baseMessage.getType().equals(CometChatConstants.MESSAGE_TYPE_FILE) || baseMessage.getType().equals(CometChatConstants.MESSAGE_TYPE_AUDIO)){ mediaMessageList.add(baseMessage); - } - else if (baseMessage.getType().equals(StringContract.IntentStrings.LOCATION)) { + } else if (baseMessage.getType().equals(StringContract.IntentStrings.LOCATION)) { locationMessageList.add(baseMessage); - } else { + } else if (baseMessage.getType().equals(StringContract.IntentStrings.STICKERS)) { + stickerMessageList.add(baseMessage); + } else if (baseMessage.getType().equals(StringContract.IntentStrings.POLLS)) { pollsMessageList.add(baseMessage); } } @@ -2075,16 +2285,14 @@ else if (baseMessage.getType().equals(StringContract.IntentStrings.LOCATION)) { if (basemessage.getReplyCount()>0) threadVisible = false; else - threadVisible = true; + threadVisible = UISettings.isEnableThreadedReplies(); if (basemessage.getSender().getUid().equals(CometChat.getLoggedInUser().getUid())) { - deleteVisible = true; - editVisible = true; - forwardVisible = true; + deleteVisible = UISettings.isEnableDeleteMessage(); + editVisible = UISettings.isEnableEditingMessage(); } else { editVisible = false; - forwardVisible = true; if (loggedInUserScope!=null && (loggedInUserScope.equals(CometChatConstants.SCOPE_ADMIN) || loggedInUserScope.equals(CometChatConstants.SCOPE_MODERATOR))) { - deleteVisible = true; + deleteVisible = (UISettings.isEnableDeleteMessage() || UISettings.isAllowModeratorToDeleteMessages()); } else { deleteVisible = false; } @@ -2101,26 +2309,23 @@ else if (baseMessage.getType().equals(StringContract.IntentStrings.LOCATION)) { if (basemessage.getReplyCount()>0) threadVisible = false; else - threadVisible = true; + threadVisible = UISettings.isEnableThreadedReplies(); copyVisible = false; if (basemessage.getSender().getUid().equals(CometChat.getLoggedInUser().getUid())) { - deleteVisible = true; + deleteVisible = UISettings.isEnableDeleteMessage(); editVisible = false; - forwardVisible = true; } else { if (loggedInUserScope!=null && (loggedInUserScope.equals(CometChatConstants.SCOPE_ADMIN) || loggedInUserScope.equals(CometChatConstants.SCOPE_MODERATOR))){ - deleteVisible = true; + deleteVisible = UISettings.isEnableDeleteMessage(); } else { deleteVisible = false; } - forwardVisible = true; editVisible = false; } } } } if (locationMessageList.size() == 1){ - mapVisible = true; BaseMessage basemessage = locationMessageList.get(0); if (basemessage != null && basemessage.getSender() != null) { if (!(basemessage instanceof Action) && basemessage.getDeletedAt() == 0) { @@ -2128,34 +2333,31 @@ else if (baseMessage.getType().equals(StringContract.IntentStrings.LOCATION)) { if (basemessage.getReplyCount()>0) threadVisible = false; else - threadVisible = true; + threadVisible = UISettings.isEnableThreadedReplies(); copyVisible = false; - replyVisible = true; + replyVisible = UISettings.isEnableReplyToMessage(); shareVisible = false; - forwardVisible = true; + forwardVisible = UISettings.isEnableShareCopyForward(); if (basemessage.getSender().getUid().equals(CometChat.getLoggedInUser().getUid())) { - mapVisible = true; - deleteVisible = true; + deleteVisible = UISettings.isEnableDeleteMessage(); editVisible = false; } else { if (loggedInUserScope!=null && (loggedInUserScope.equals(CometChatConstants.SCOPE_ADMIN) || loggedInUserScope.equals(CometChatConstants.SCOPE_MODERATOR))){ - deleteVisible = true; + deleteVisible = (UISettings.isEnableDeleteMessage() || UISettings.isAllowModeratorToDeleteMessages()); } else { deleteVisible = false; } - mapVisible = true; editVisible = false; } } } } if (pollsMessageList.size() == 1){ - mapVisible = false; forwardVisible = false; copyVisible = false; editVisible = false; shareVisible = false; - replyVisible = true; + replyVisible = UISettings.isEnableReplyToMessage(); BaseMessage basemessage = pollsMessageList.get(0); if (basemessage != null && basemessage.getSender() != null) { if (!(basemessage instanceof Action) && basemessage.getDeletedAt() == 0) { @@ -2163,12 +2365,38 @@ else if (baseMessage.getType().equals(StringContract.IntentStrings.LOCATION)) { if (basemessage.getReplyCount()>0) threadVisible = false; else - threadVisible = true; + threadVisible = UISettings.isEnableThreadedReplies(); if (basemessage.getSender().getUid().equals(CometChat.getLoggedInUser().getUid())) { - deleteVisible = true; + deleteVisible = UISettings.isEnableDeleteMessage(); } else { if (loggedInUserScope!=null && (loggedInUserScope.equals(CometChatConstants.SCOPE_ADMIN) || loggedInUserScope.equals(CometChatConstants.SCOPE_MODERATOR))){ - deleteVisible = true; + deleteVisible = (UISettings.isEnableDeleteMessage() || UISettings.isAllowModeratorToDeleteMessages()); + } else { + deleteVisible = false; + } + } + } + } + } + if (stickerMessageList.size()==1) { + forwardVisible = false; + copyVisible = false; + editVisible = false; + shareVisible = false; + replyVisible = UISettings.isStickerVisible(); + BaseMessage basemessage = stickerMessageList.get(0); + if (basemessage!=null && basemessage.getSender()!=null) { + if (basemessage.getDeletedAt() == 0) { + baseMessage = basemessage; + if (basemessage.getReplyCount()>0) + threadVisible = false; + else + threadVisible = UISettings.isEnableThreadedReplies(); + if (basemessage.getSender().getUid().equals(CometChat.getLoggedInUser().getUid())) + deleteVisible = UISettings.isEnableDeleteMessage(); + else { + if (loggedInUserScope!=null && (loggedInUserScope.equals(CometChatConstants.SCOPE_ADMIN) || loggedInUserScope.equals(CometChatConstants.SCOPE_MODERATOR))){ + deleteVisible = (UISettings.isEnableDeleteMessage() || UISettings.isAllowModeratorToDeleteMessages()); } else { deleteVisible = false; } @@ -2185,13 +2413,14 @@ else if (baseMessage.getType().equals(StringContract.IntentStrings.LOCATION)) { bundle.putBoolean("deleteVisible",deleteVisible); bundle.putBoolean("replyVisible",replyVisible); bundle.putBoolean("forwardVisible",forwardVisible); - bundle.putBoolean("mapVisible",mapVisible); if (baseMessage.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_GROUP) && baseMessage.getSender().getUid().equals(loggedInUser.getUid())) bundle.putBoolean("messageInfoVisible",true); bundle.putString("type", CometChatMessageListActivity.class.getName()); messageActionFragment.setArguments(bundle); - messageActionFragment.show(getFragmentManager(),messageActionFragment.getTag()); + if (editVisible || copyVisible || threadVisible || shareVisible || deleteVisible + || replyVisible || forwardVisible) + messageActionFragment.show(getFragmentManager(),messageActionFragment.getTag()); messageActionFragment.setMessageActionListener(new MessageActionFragment.MessageActionListener() { @Override public void onThreadMessageClick() { @@ -2272,6 +2501,8 @@ public void onMessageInfoClick() { if (baseMessage.getType().equals(StringContract.IntentStrings.LOCATION)) { intent.putExtra(StringContract.IntentStrings.MESSAGE_TYPE, StringContract.IntentStrings.LOCATION); + } else if (baseMessage.getType().equals(StringContract.IntentStrings.STICKERS)) { + intent.putExtra(StringContract.IntentStrings.MESSAGE_TYPE,StringContract.IntentStrings.STICKERS); } else { intent.putExtra(StringContract.IntentStrings.MESSAGE_TYPE, StringContract.IntentStrings.POLLS); @@ -2328,6 +2559,13 @@ private void replyMessage() { }catch (Exception e) { Log.e(TAG, "replyMessageError: "+e.getMessage() ); } + } else if (baseMessage.getType().equals(StringContract.IntentStrings.STICKERS)) { + replyMessage.setText(getResources().getString(R.string.shared_a_sticker)); + try { + Glide.with(context).load(((CustomMessage) baseMessage).getCustomData().getString("url")).into(replyMedia); + } catch (JSONException e) { + e.printStackTrace(); + } } else if (baseMessage.getType().equals(StringContract.IntentStrings.POLLS)) { try { JSONObject jsonObject = ((CustomMessage) baseMessage).getCustomData(); @@ -2347,6 +2585,44 @@ private void replyMessage() { } } + //Live Reactions + private void sendLiveReaction() { + try { + JSONObject metaData = new JSONObject(); + metaData.put("reaction", "heart"); + TypingIndicator typingIndicator = new TypingIndicator(Id, type, metaData); + CometChat.startTyping(typingIndicator); + setLiveReaction(); + } catch (Exception e) { + Log.e(TAG, "sendLiveReaction: "+e.getMessage()); + } + } + + private void setLiveReaction() { + flyEmoji(R.drawable.heart_reaction); + } + + private void flyEmoji(final int resId) { + imageView = new ImageView(getContext()); + + FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); + layoutParams.gravity = Gravity.BOTTOM|Gravity.END; + layoutParams.rightMargin = 16; + imageView.setLayoutParams(layoutParams); + container.addView(imageView); + Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), resId); + if (bitmap!=null) { + Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, (int) (bitmap.getWidth() * 0.2f), (int) (bitmap.getHeight() * 0.2f), false); + imageView.setImageBitmap(scaledBitmap); + } + + animation = ObjectAnimator.ofFloat(imageView, "translationY", -700f); + animation.setInterpolator(new AccelerateDecelerateInterpolator()); + animation.setRepeatCount(ValueAnimator.INFINITE); + animation.setDuration(700); + animation.start(); + } + @Override public void handleDialogClose(DialogInterface dialog) { if (messageAdapter!=null) diff --git a/uikit/src/main/java/screen/messagelist/MessageActionFragment.java b/uikit/src/main/java/screen/messagelist/MessageActionFragment.java index 852af7e6..8330f053 100644 --- a/uikit/src/main/java/screen/messagelist/MessageActionFragment.java +++ b/uikit/src/main/java/screen/messagelist/MessageActionFragment.java @@ -214,6 +214,7 @@ public interface MessageActionListener { @Override public void onDismiss(@NonNull DialogInterface dialog) { + super.onDismiss(dialog); Activity activity = getActivity(); if (activity!=null) if (type!=null && type== CometChatMessageListActivity.class.getName()) @@ -224,6 +225,7 @@ public void onDismiss(@NonNull DialogInterface dialog) { @Override public void onCancel(@NonNull DialogInterface dialog) { + super.onCancel(dialog); Activity activity = getActivity(); if (activity!=null) if (type!=null && type==CometChatMessageListActivity.class.getName()) diff --git a/uikit/src/main/java/screen/threadconversation/CometChatThreadMessageActivity.java b/uikit/src/main/java/screen/threadconversation/CometChatThreadMessageActivity.java index 91ff9c73..8f8c223c 100644 --- a/uikit/src/main/java/screen/threadconversation/CometChatThreadMessageActivity.java +++ b/uikit/src/main/java/screen/threadconversation/CometChatThreadMessageActivity.java @@ -2,6 +2,7 @@ import android.content.DialogInterface; import android.content.Intent; +import android.graphics.Color; import android.os.Bundle; import android.util.Log; import android.view.Menu; @@ -25,6 +26,7 @@ import constant.StringContract; import listeners.MessageActionCloseListener; import listeners.OnMessageLongClick; +import com.cometchat.pro.uikit.Settings.UISettings; /** @@ -104,6 +106,9 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_cometchat_message_list); + if (UISettings.getColor() !=null) { + getWindow().setStatusBarColor(Color.parseColor(UISettings.getColor())); + } EmojiCompat.Config config = new BundledEmojiCompatConfig(this); EmojiCompat.init(config); @@ -185,8 +190,10 @@ else if (messageType.equals(StringContract.IntentStrings.LOCATION)) { bundle.putString(StringContract.IntentStrings.POLL_QUESTION,pollQuestion); bundle.putString(StringContract.IntentStrings.POLL_OPTION,pollOptions); bundle.putInt(StringContract.IntentStrings.POLL_VOTE_COUNT,voteCount); - } - else { + } else if (messageType.equals(StringContract.IntentStrings.STICKERS)) { + bundle.putString(StringContract.IntentStrings.MESSAGE_TYPE_IMAGE_URL,mediaUrl); + bundle.putString(StringContract.IntentStrings.MESSAGE_TYPE_IMAGE_NAME,messagefileName); + } else { bundle.putString(StringContract.IntentStrings.MESSAGE_TYPE_IMAGE_URL,mediaUrl); bundle.putString(StringContract.IntentStrings.MESSAGE_TYPE_IMAGE_NAME,messagefileName); bundle.putString(StringContract.IntentStrings.MESSAGE_TYPE_IMAGE_EXTENSION,mediaExtension); diff --git a/uikit/src/main/java/screen/threadconversation/CometChatThreadMessageScreen.java b/uikit/src/main/java/screen/threadconversation/CometChatThreadMessageScreen.java index c8731f40..72caa183 100644 --- a/uikit/src/main/java/screen/threadconversation/CometChatThreadMessageScreen.java +++ b/uikit/src/main/java/screen/threadconversation/CometChatThreadMessageScreen.java @@ -203,6 +203,7 @@ public class CometChatThreadMessageScreen extends Fragment implements View.OnCli private RelativeLayout fileMessage; private RelativeLayout locationMessage; private View pollMessage; + private ImageView stickerMessage; private TextView pollQuestionTv; private LinearLayout pollOptionsLL; @@ -234,6 +235,8 @@ public class CometChatThreadMessageScreen extends Fragment implements View.OnCli private ArrayList pollResult; private TextView totalCount; private int voteCount; + private MessageActionFragment messageActionFragment; + public CometChatThreadMessageScreen() { // Required empty public constructor } @@ -272,6 +275,9 @@ private void handleArguments() { pollOptions = getArguments().getString(StringContract.IntentStrings.POLL_OPTION); pollResult = getArguments().getStringArrayList(StringContract.IntentStrings.POLL_RESULT); voteCount = getArguments().getInt(StringContract.IntentStrings.POLL_VOTE_COUNT); + } else if (messageType.equals(StringContract.IntentStrings.STICKERS)) { + message = getArguments().getString(StringContract.IntentStrings.MESSAGE_TYPE_IMAGE_URL); + messageFileName = getArguments().getString(StringContract.IntentStrings.MESSAGE_TYPE_IMAGE_NAME); } else { message = getArguments().getString(StringContract.IntentStrings.MESSAGE_TYPE_IMAGE_URL); messageFileName = getArguments().getString(StringContract.IntentStrings.MESSAGE_TYPE_IMAGE_NAME); @@ -316,6 +322,8 @@ private void initViewComponent(View view) { fileSize = view.findViewById(R.id.tvFileSize); fileExtension = view.findViewById(R.id.tvFileExtension); + stickerMessage = view.findViewById(R.id.iv_stickerMessage); + pollMessage = view.findViewById(R.id.poll_message); pollQuestionTv = view.findViewById(R.id.tv_question); pollOptionsLL = view.findViewById(R.id.options_group); @@ -342,6 +350,10 @@ private void initViewComponent(View view) { } else if (messageType.equals(CometChatConstants.MESSAGE_TYPE_TEXT)) { textMessage.setVisibility(View.VISIBLE); textMessage.setText(message); + } else if (messageType.equals(StringContract.IntentStrings.STICKERS)) { + ivForwardMessage.setVisibility(GONE); + stickerMessage.setVisibility(View.VISIBLE); + Glide.with(context).load(message).into(stickerMessage); } else if (messageType.equals(StringContract.IntentStrings.LOCATION)) { initLocation(); locationMessage.setVisibility(VISIBLE); @@ -353,8 +365,6 @@ private void initViewComponent(View view) { .into(mapView); } else if (messageType.equals(StringContract.IntentStrings.POLLS)) { ivForwardMessage.setVisibility(GONE); - TextView threadReplyCount = view.findViewById(R.id.thread_reply_count); - threadReplyCount.setVisibility(GONE); pollMessage.setVisibility(VISIBLE); totalCount.setText(voteCount+" Votes"); pollQuestionTv.setText(pollQuestion); @@ -436,6 +446,7 @@ public void onError(CometChatException e) { composeBox = view.findViewById(R.id.message_box); composeBox.usedIn(CometChatThreadMessageActivity.class.getName()); composeBox.isPollVisible = false; + composeBox.isStickerVisible = false; composeBox.ivMic.setVisibility(GONE); composeBox.ivSend.setVisibility(VISIBLE); setComposeBoxListener(); @@ -464,8 +475,9 @@ public void onError(CometChatException e) { sentAt.setText(String.format(getString(R.string.sentAtTxt),Utils.getMessageDate(messageSentAt))); tvReplyCount = view.findViewById(R.id.thread_reply_count); rvChatListView = view.findViewById(R.id.rv_message_list); - if (parentMessageCategory.equals(CometChatConstants.CATEGORY_CUSTOM)) + if (parentMessageCategory.equals(CometChatConstants.CATEGORY_CUSTOM)) { ivMoreOption.setVisibility(GONE); + } if (replyCount>0) { tvReplyCount.setText(replyCount + " Replies"); noReplyMessages.setVisibility(GONE); @@ -1649,6 +1661,9 @@ public void onResume() { isNoMoreMessages = false; addMessageListener(); + if (messageActionFragment!=null) + messageActionFragment.dismiss(); + if (type != null) { if (type.equals(CometChatConstants.RECEIVER_TYPE_USER)) { new Thread(this::getUser).start(); @@ -1754,7 +1769,7 @@ public void setLongMessageClick(List baseMessagesList) { isReply = false; isEdit = false; isParent = false; - MessageActionFragment messageActionFragment = new MessageActionFragment(); + messageActionFragment = new MessageActionFragment(); replyMessageLayout.setVisibility(GONE); editMessageLayout.setVisibility(GONE); boolean copyVisible = true; diff --git a/uikit/src/main/java/screen/unified/CometChatUnified.java b/uikit/src/main/java/screen/unified/CometChatUnified.java index 5c438689..20d912a6 100644 --- a/uikit/src/main/java/screen/unified/CometChatUnified.java +++ b/uikit/src/main/java/screen/unified/CometChatUnified.java @@ -9,10 +9,11 @@ import androidx.fragment.app.Fragment; import android.Manifest; -import android.app.Activity; import android.app.ProgressDialog; import android.content.DialogInterface; import android.content.Intent; +import android.content.res.ColorStateList; +import android.graphics.Color; import android.os.Build; import android.os.Bundle; import android.util.Log; @@ -22,7 +23,6 @@ import android.widget.TextView; import com.cometchat.pro.constants.CometChatConstants; -import com.cometchat.pro.core.Call; import com.cometchat.pro.core.CometChat; import com.cometchat.pro.exceptions.CometChatException; import com.cometchat.pro.uikit.R; @@ -47,14 +47,13 @@ import listeners.CustomAlertDialogHelper; import listeners.OnAlertDialogButtonClickListener; import listeners.OnItemClickListener; -import screen.CometChatCallActivity; import screen.CometChatConversationListScreen; import screen.CometChatGroupListScreen; -import screen.CometChatUserDetailScreenActivity; import screen.call.CometChatCallListScreen; import screen.messagelist.CometChatMessageListActivity; import screen.CometChatUserInfoScreen; import screen.CometChatUserListScreen; +import com.cometchat.pro.uikit.Settings.UISettings; import utils.Utils; /** @@ -179,9 +178,40 @@ private void initViewComponent() { activityCometChatUnifiedBinding.bottomNavigation.setOnNavigationItemSelectedListener(this); + if (UISettings.getColor()!=null && !UISettings.getColor().isEmpty()) { + getWindow().setStatusBarColor(Color.parseColor(UISettings.getColor())); + int widgetColor = Color.parseColor(UISettings.getColor()); + ColorStateList colorStateList = new ColorStateList(new int[][] { + { -android.R.attr.state_selected }, {} }, new int[] { Color.GRAY, widgetColor }); + + activityCometChatUnifiedBinding.bottomNavigation.setItemIconTintList(colorStateList); + + } +// activityCometChatUnifiedBinding.bottomNavigation.getMenu().add(Menu.NONE,12,Menu.NONE,"Test").setIcon(R.drawable.ic_security_24dp); + activityCometChatUnifiedBinding.bottomNavigation.getMenu().findItem(R.id.menu_conversation) + .setVisible(UISettings.isShowChatsBB()); + activityCometChatUnifiedBinding.bottomNavigation.getMenu().findItem(R.id.menu_users) + .setVisible(UISettings.isShowUsersBB()); + activityCometChatUnifiedBinding.bottomNavigation.getMenu().findItem(R.id.menu_group) + .setVisible(UISettings.isShowGroupsBB()); + activityCometChatUnifiedBinding.bottomNavigation.getMenu().findItem(R.id.menu_call) + .setVisible(UISettings.isShowCallsBB()); + activityCometChatUnifiedBinding.bottomNavigation.getMenu().findItem(R.id.menu_more) + .setVisible(UISettings.isShowUserSettingsBB()); + + badgeDrawable.setVisible(false); + if (UISettings.isShowChatsBB()) + loadFragment(new CometChatConversationListScreen()); + else if (UISettings.isShowCallsBB()) + loadFragment(new CometChatCallListScreen()); + else if (UISettings.isShowUsersBB()) + loadFragment(new CometChatUserListScreen()); + else if (UISettings.isShowGroupsBB()) + loadFragment(new CometChatGroupListScreen()); + else if (UISettings.isShowUserSettingsBB()) + loadFragment(new CometChatUserInfoScreen()); - loadFragment(new CometChatConversationListScreen()); } /** @@ -193,28 +223,30 @@ private void initViewComponent() { * */ private void joinGroup(Group group) { - progressDialog = ProgressDialog.show(this, "", getResources().getString(R.string.joining)); - progressDialog.setCancelable(false); - CometChat.joinGroup(group.getGuid(), group.getGroupType(), groupPassword, new CometChat.CallbackListener() { - @Override - public void onSuccess(Group group) { - if (progressDialog!=null) - progressDialog.dismiss(); + if (UISettings.isJoinOrLeaveGroup()) { + progressDialog = ProgressDialog.show(this, "", getResources().getString(R.string.joining)); + progressDialog.setCancelable(false); + CometChat.joinGroup(group.getGuid(), group.getGroupType(), groupPassword, new CometChat.CallbackListener() { + @Override + public void onSuccess(Group group) { + if (progressDialog != null) + progressDialog.dismiss(); + + if (group != null) + startGroupIntent(group); + } - if(group!=null) - startGroupIntent(group); - } + @Override + public void onError(CometChatException e) { + if (progressDialog != null) + progressDialog.dismiss(); - @Override - public void onError(CometChatException e) { - if (progressDialog!=null) - progressDialog.dismiss(); - - Snackbar.make(activityCometChatUnifiedBinding.bottomNavigation,getResources().getString(R.string.unabl_to_join_message)+e.getMessage(), - Snackbar.LENGTH_SHORT).show(); + Snackbar.make(activityCometChatUnifiedBinding.bottomNavigation, getResources().getString(R.string.unabl_to_join_message) + e.getMessage(), + Snackbar.LENGTH_SHORT).show(); - } - }); + } + }); + } } /** diff --git a/uikit/src/main/java/utils/CallUtils.java b/uikit/src/main/java/utils/CallUtils.java index fec9f4ef..36592138 100644 --- a/uikit/src/main/java/utils/CallUtils.java +++ b/uikit/src/main/java/utils/CallUtils.java @@ -131,11 +131,13 @@ public static void startGroupCallIntent(Context context, Group group, String typ public static void startCall(Context context, Call call) { Intent intent = new Intent(context, CometChatStartCallActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent.putExtra(StringContract.IntentStrings.TYPE,call.getReceiverType()); intent.putExtra(StringContract.IntentStrings.SESSION_ID,call.getSessionId()); ((Activity)context).finish(); context.startActivity(intent); } + /** * This method is used to join an ongoing call. * @param context diff --git a/uikit/src/main/java/utils/Extensions.java b/uikit/src/main/java/utils/Extensions.java index 1251ba23..5dd7cc0a 100644 --- a/uikit/src/main/java/utils/Extensions.java +++ b/uikit/src/main/java/utils/Extensions.java @@ -4,18 +4,22 @@ import android.util.Log; import android.widget.Toast; -import com.cometchat.pro.models.AppEntity; +import com.cometchat.pro.core.CometChat; +import com.cometchat.pro.exceptions.CometChatException; import com.cometchat.pro.models.BaseMessage; import com.cometchat.pro.models.TextMessage; -import com.cometchat.pro.models.User; import org.json.JSONArray; +import org.json.JSONException; import org.json.JSONObject; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import listeners.ExtensionResponseListener; +import com.cometchat.pro.uikit.Sticker.model.Sticker; + public class Extensions { private static final String TAG = "Extensions"; @@ -113,6 +117,9 @@ public static HashMap extensionCheck(BaseMessage baseMessage) if (extensionsObject!=null && extensionsObject.has("image-moderation")) { extensionMap.put("imageModeration",extensionsObject.getJSONObject("image-moderation")); } + if (extensionsObject!=null && extensionsObject.has("thumbnail-generator")) { + extensionMap.put("thumbnailGeneration",extensionsObject.getJSONObject("thumbnail-generator")); + } if (extensionsObject!=null && extensionsObject.has("sentiment-analysis")) { extensionMap.put("sentimentAnalysis",extensionsObject.getJSONObject("sentiment-analysis")); } @@ -244,4 +251,93 @@ public static ArrayList getVoterInfo(BaseMessage baseMessage,int totalOp } return votes; } + + public static void fetchStickers(ExtensionResponseListener extensionResponseListener) { + CometChat.callExtension("stickers", "GET", "/v1/fetch", null, new CometChat.CallbackListener() { + @Override + public void onSuccess(JSONObject jsonObject) { + extensionResponseListener.OnResponseSuccess(jsonObject); + } + @Override + public void onError(CometChatException e) { + extensionResponseListener.OnResponseFailed(e); + } + }); + } + + public static HashMap> extractStickersFromJSON(JSONObject jsonObject) { + List stickers = new ArrayList<>(); + if (jsonObject != null) { + try { + JSONObject dataObject = jsonObject.getJSONObject("data"); + JSONArray defaultStickersArray = dataObject.getJSONArray("defaultStickers"); + Log.d(TAG, "getStickersList: defaultStickersArray "+defaultStickersArray.length()); + for (int i = 0; i < defaultStickersArray.length(); i++) { + JSONObject stickerObject = defaultStickersArray.getJSONObject(i); + String stickerOrder = stickerObject.getString("stickerOrder"); + String stickerSetId = stickerObject.getString("stickerSetId"); + String stickerUrl = stickerObject.getString("stickerUrl"); + String stickerSetName = stickerObject.getString("stickerSetName"); + String stickerName = stickerObject.getString("stickerName"); + Sticker sticker = new Sticker(stickerName,stickerUrl,stickerSetName); + stickers.add(sticker); + } + if (dataObject.has("customStickers")) { + JSONArray customSticker = dataObject.getJSONArray("customStickers"); + Log.d(TAG, "getStickersList: customStickersArray " + customSticker.length()); + for (int i = 0; i < customSticker.length(); i++) { + JSONObject stickerObject = defaultStickersArray.getJSONObject(i); + String stickerOrder = stickerObject.getString("stickerOrder"); + String stickerSetId = stickerObject.getString("stickerSetId"); + String stickerUrl = stickerObject.getString("stickerUrl"); + String stickerSetName = stickerObject.getString("stickerSetName"); + String stickerName = stickerObject.getString("stickerName"); + Sticker sticker = new Sticker(stickerName, stickerUrl, stickerSetName); + stickers.add(sticker); + } + } + + } catch (JSONException e) { + e.printStackTrace(); + } + } + + HashMap> stickerMap = new HashMap(); + for (int i=0;i list = new ArrayList<>(); + list.add(stickers.get(i)); + stickerMap.put(stickers.get(i).getSetName(),list); + } + } + return stickerMap; + } + + +// public static List extractStickersFromJSON(JSONObject jsonObject) { +// List stickers = new ArrayList<>(); +// if (jsonObject != null) { +// try { +// JSONObject dataObject = jsonObject.getJSONObject("data"); +// JSONArray defaultStickersArray = dataObject.getJSONArray("defaultStickers"); +// Log.d(TAG, "getStickersList: defaultStickersArray "+defaultStickersArray.length()); +// for (int i = 0; i < defaultStickersArray.length(); i++) { +// JSONObject stickerObject = defaultStickersArray.getJSONObject(i); +// String stickerOrder = stickerObject.getString("stickerOrder"); +// String stickerSetId = stickerObject.getString("stickerSetId"); +// String stickerUrl = stickerObject.getString("stickerUrl"); +// String stickerSetName = stickerObject.getString("stickerSetName"); +// String stickerName = stickerObject.getString("stickerName"); +// Sticker default_sticker = new Sticker(stickerName,stickerUrl,stickerSetName); +// stickers.add(default_sticker); +// } +// +// } catch (JSONException e) { +// e.printStackTrace(); +// } +// } +// return stickers; +// } } diff --git a/uikit/src/main/java/utils/MediaUtils.java b/uikit/src/main/java/utils/MediaUtils.java index fcecec6b..52f7f14f 100755 --- a/uikit/src/main/java/utils/MediaUtils.java +++ b/uikit/src/main/java/utils/MediaUtils.java @@ -30,12 +30,12 @@ import androidx.loader.content.CursorLoader; import com.cometchat.pro.uikit.BuildConfig; +import com.cometchat.pro.uikit.Settings.UISettings; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.ByteArrayOutputStream; import java.io.File; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; @@ -612,19 +612,21 @@ public static Camera openFrontCam() } public static void playSendSound(Context context ,int ringId) { - MediaPlayer mMediaPlayer = MediaPlayer.create(context, ringId); - mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); - mMediaPlayer.start(); - mMediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { - @Override - public void onCompletion(MediaPlayer mediaPlayer) { - if (mediaPlayer != null) { - mediaPlayer.stop(); - mediaPlayer.release(); - mediaPlayer = null; + if (UISettings.isEnableMessageSounds()) { + MediaPlayer mMediaPlayer = MediaPlayer.create(context, ringId); + mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); + mMediaPlayer.start(); + mMediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { + @Override + public void onCompletion(MediaPlayer mediaPlayer) { + if (mediaPlayer != null) { + mediaPlayer.stop(); + mediaPlayer.release(); + mediaPlayer = null; + } } - } - }); + }); + } } public static void vibrate(Context context) diff --git a/uikit/src/main/java/utils/Utils.java b/uikit/src/main/java/utils/Utils.java index f261ffe1..7708d4e9 100644 --- a/uikit/src/main/java/utils/Utils.java +++ b/uikit/src/main/java/utils/Utils.java @@ -1,8 +1,5 @@ package utils; -import android.app.Activity; -import android.app.Notification; -import android.app.PendingIntent; import android.content.ContentUris; import android.content.Context; import android.content.Intent; @@ -12,58 +9,43 @@ import android.database.Cursor; import android.graphics.Bitmap; import android.graphics.BitmapFactory; -import android.graphics.Typeface; import android.location.Address; import android.location.Geocoder; import android.media.AudioManager; -import android.media.RingtoneManager; import android.net.Uri; import android.os.Build; import android.os.Environment; import android.provider.DocumentsContract; import android.provider.MediaStore; import android.provider.OpenableColumns; -import android.provider.Settings; -import android.text.Spannable; -import android.text.TextPaint; import android.text.format.DateFormat; -import android.text.style.URLSpan; import android.util.DisplayMetrics; import android.util.Log; import android.util.Patterns; import android.view.View; -import android.widget.RelativeLayout; +import android.view.inputmethod.InputMethodManager; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.app.ActivityCompat; -import androidx.core.app.NotificationCompat; -import androidx.core.app.NotificationManagerCompat; -import androidx.databinding.BindingAdapter; import androidx.renderscript.Allocation; import androidx.renderscript.Element; import androidx.renderscript.RenderScript; import androidx.renderscript.ScriptIntrinsicBlur; import com.cometchat.pro.constants.CometChatConstants; -import com.cometchat.pro.core.Call; import com.cometchat.pro.core.CometChat; -import com.cometchat.pro.exceptions.CometChatException; import com.cometchat.pro.helpers.Logger; import com.cometchat.pro.models.Action; import com.cometchat.pro.models.BaseMessage; -import com.cometchat.pro.models.Group; import com.cometchat.pro.models.GroupMember; import com.cometchat.pro.models.MediaMessage; import com.cometchat.pro.models.TextMessage; import com.cometchat.pro.models.User; import com.cometchat.pro.uikit.R; +import com.cometchat.pro.uikit.Settings.UISettings; import com.google.android.material.appbar.MaterialToolbar; -import com.google.android.material.snackbar.Snackbar; - -import org.json.JSONArray; -import org.json.JSONObject; import java.io.BufferedOutputStream; import java.io.File; @@ -74,18 +56,14 @@ import java.net.HttpURLConnection; import java.net.URL; import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; import java.util.Date; -import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.regex.Matcher; import java.util.regex.Pattern; -import adapter.MessageAdapter; -import constant.StringContract; import kotlin.ranges.RangesKt; public class Utils { @@ -97,7 +75,7 @@ public static void setHyperLinkSupport(Context context,TextView txtMessage) { addPattern(Pattern.compile("(^|[\\s.:;?\\-\\]<\\(])" + "((https?://|www\\.|pic\\.)[-\\w;/?:@&=+$\\|\\_.!~*\\|'()\\[\\]%#,☺]+[\\w/#](\\(\\))?)" + "(?=$|[\\s',\\|\\(\\).:;?\\-\\[\\]>\\)])"), - context.getResources().getColor(StringContract.HyperLink.urlColor), + context.getResources().getColor(UISettings.getUrlColor()), new PatternBuilder.SpannableClickedListener() { @Override public void onSpanClicked(String text) { @@ -110,7 +88,7 @@ public void onSpanClicked(String text) { } }).into(txtMessage); new PatternBuilder(). - addPattern(Patterns.PHONE, context.getResources().getColor(StringContract.HyperLink.phoneColor), + addPattern(Patterns.PHONE, context.getResources().getColor(UISettings.getPhoneColor()), new PatternBuilder.SpannableClickedListener() { @Override public void onSpanClicked(String text) { @@ -121,7 +99,7 @@ public void onSpanClicked(String text) { }).into(txtMessage); new PatternBuilder(). addPattern(Pattern.compile("[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,6}"), - context.getResources().getColor(StringContract.HyperLink.emailColor), + context.getResources().getColor(UISettings.getEmailColor()), new PatternBuilder.SpannableClickedListener() { @Override public void onSpanClicked(String text) { @@ -724,4 +702,13 @@ public static String getAddress(Context context, double latitude, double longitu } return null; } + + public static void hideKeyBoard(Context context,View mainLayout) { + InputMethodManager imm = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE); + imm.hideSoftInputFromWindow(mainLayout.getWindowToken(), 0); + } + public static void showKeyBoard(Context context,View mainLayout) { + InputMethodManager imm = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE); + imm.toggleSoftInputFromWindow(mainLayout.getWindowToken(),InputMethodManager.SHOW_FORCED, 0); + } } diff --git a/uikit/src/main/res/anim/animate_up_slide.xml b/uikit/src/main/res/anim/animate_up_slide.xml new file mode 100644 index 00000000..4f321938 --- /dev/null +++ b/uikit/src/main/res/anim/animate_up_slide.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/uikit/src/main/res/drawable/default_sticker.png b/uikit/src/main/res/drawable/default_sticker.png new file mode 100644 index 0000000000000000000000000000000000000000..c8f15b494e8902874505e6b3f47e58ef78f18eee GIT binary patch literal 427 zcmV;c0aX5pP)W2t`z2Qh`kc#1%k<5LY^IN=ON$1D_F}ytP;fS(Yuc_{Ni# zo!wczH!~~@BOuT7En_U~``)2>P$`O%x~?0sq9}G<*X`*E0B@wVZ5tx`^P*{*lxBdg z>uYev$YQI(u=yq@4}zeg8Gx#k2snmmEA(V60*k;RK%~(`BuU~Jh7rPix%A;HwxtC? zo?v>vcW$x(;0$w$i2ue8{Nz4_Uq;{zkbnEW|HEyR&9*En#-20yB545uPL8r2LHfqm zXkMQX{+dN#c;QEw4v0?}8r_u&=#a5eU8JSE=M zOw(K=)sm*+7v!5uav^Ylzz%baRAYJ^WnI_kw!!I|lkrEEW&82neEP)90K~#90?VWp&97P?+KQsHhM=s%&5D-lY5P1d2EhUy#MQ{-* zL6lc=OMt>Pg2BJ|11zxwq^MG;LXnb^z*H=ZdmvOw!b5>k9->fk7Xg6?1PP!JNWvq@ z-R;iPKjt>MOKy7hc6WAX_WDz`Rl764?&-V!PCtL$t+=j>Wagr_I{}jRA_XwRkph_E zNCC`nl5Kl(AvX`#&4IHB*F6H)-3LY4hN5f*WiyHN1~R>WMbme-Esf2fnC}IS0QLdq z0JFzGp8)Ud`n2iqR9eytDD)qSV_%DHo{H zz!2~xn*L(=32uO5ei5()$N?wfWqvIs?Z;lz{uu^wB28 zJBj8CU|{ibY~y;Y$^!i2PNX0^8!|nBGPO-@JPX`_ra#z7Bz05Fp8;GAoD}ktMu7W) zo6+>)W=7mR0TlWdVi^x&jveJ|lgxM-pYCqXGj}rtT-P!oco}~UUNPTF9AFjjLp1%P zW<=Py017!3$GQ_^^kQ6R>bg!*pnE^a^fvaaVEzVN5?a;Z74@ruFNP9-?Q8|E0#>8x z4P{_s0vK34fLUIJZTRPGA`QIBpIlCz46<{TBBhd8Xs{x(`R-)yVd};4+R%;b1=)B zVwU;fW#A(e^XJtZ!n1vZcx67ocY*sT=Cid1sI3Gjm+WWnC}-E_zR%W{~3(Y)l*L5>=zxeN=XQh+`*wgDWb`Im8?J zlf;#GfWy)B3QQ~k9P1`w=7ab4%gm2EhX6~fKXwbiw$2C)nwb?!iX<)Ptm+p}0EJv1 zc4fXWNFwd|?n^p>uTsospeg{@{ywfNF5BDh-6Lrpy}*~DDgfJB78pbdpwl=Lb_u`` zuVzscNX2^CSF$%}0x0gX6V9c){a&GIs>}2Ck#rizsklzCyK^cQ&K{EKbG(Y{9ujD# zwr>@=Bvj_BxURVS2eSLuxy)C=*)Pyckpk#Y=BqePurq`#0XmiWDy}2;=u}kiBk4ru ztGKq<`9r?_oy>gsYR_;~l!PU;aB5y>D2X3iR1~!$G;y64rA5*PK2TAVkw7ykf=*?N zilS~0G?Udpr?N#wQGz!klqEo?vPA`DOQ4w)K&P@rMNxt`QF6o`1xak#qM|690?jNV z{G>?Q!Dbaj{e7UBEd|hlxWJG~Y4|k~De+i(pte%UPmHSyGxrV}xO=Zz$>U`hep6u9w&6hJ3n01s7v>=r<2 z_%%|Qw}nA%Qw|EnpS5WE*6NSRE@6rEF9U-cp&VW%X&rY={4rSoiu!ZZq`0LgtARMP z5ty`F`eXr=h8&U^T^NOJf+YuqV#=L+?iRYYS8yVEWng2l{7F+&C20vJ@S8m^?k#}Q z@Jl2!{}V=KjLI>A_^}R6e}B)5Q?Cn1rfv(2t{m)2D2WtzOm)%cpvS~dNuxd8GnWhRyAF)W9zle0@y;0bMJ#~9_4km75>a{xNT1mi>=XR}|z6aA2Kxz05Qr$lh+E^7i zHqbu4gQicbOE$eKpvw8j{u^`b2%$~9PZfl4t5+pR zTEQmZih2UpCxFt>d!)O?5424=K-3y+;9@j=M?Hb-pT!wme=F&pbwZoU4sY665++xo z>A`C{e5kJtFp=|*-H17MsNfMWYpy(UCLHcU(=To$g2v}@lbIZew7^x^g`HdEgi-T( z4!E?@NE#PFY3O58T}#B{0}kwXUwRNVkIlfh(DZVn5jDq?V{mwwbkAkNSwqKyogc`a zLE{*}*=V}hakoaA=gKp<{thxd;(Z3J3XBBrN+%KWJv9B9W<}O`BXCcaE_xPY^z%ZS zY#(&*+uY~Q3~ofzg&scBrTGE?IRDs}F~^P)+Vt!v&mx{4x1;HoH9OL9yg8GZ;{sjD zMz(p5B$8Sv0V~6ZIGhpyppeUAj=hOhIne*Fm(yi>_N z5%^d5YQmd1l4lc6#h-z%qv@fo#tl~h0EOIKjL|o+jb2|HHR&BqD;-HD@+^=?(?ea4 zAO4Dt($EK_yN(f#7CIK}*erJ++0Apn>0xI+v_b#?rQx?ocOOnN{jsl&W5f2%U^P6r z6?dKhzJjLv|F4=z>(+FYhTbF9y^v&PuO-U6s16y=+}^>1cyE4PQ@i!h+C_cdyukue z*|&UcTo-nHFcY_;8Kg<$`_rNIt2#?VWs=#$NOis9Z!|uGSZUdd&~APWEDx)zCnEe_ zfQY4wp1~MBNodo(4`gSzC_!!EXK4Bl+V$}EuIs+%#V?TQ{he?YarC3{RYx6%30&6B z%!hWD096JSucR_^E3WM?$jmHn{-85>A2=6Hf4bcXiG~0G2KrCL9DN+y?D4fpbwTd| zao><)2(PjC-*zViq9g!-LT(OLc|B%%p|4FM<%uAk^9O5y6|HXRi-?v0sw_S3evFZC z_}*6(=-D6A{)I)vu<^WiZ*F%&_9U8R={+x;MYiuM-zDkpcsDT~jl&OtuSGHQA*v-n zm4W^xn4^EfHnYAqsqA>WAko5v)yzx4S!nuy+MN(TqAdV`LT(;rc|BJ7AYU6b3B7Y6 z8L4)`TD%oIkzN@S%_?9brJ?spWe*|Umd zuE!X;8rSh3Im*m}o_z`2@H!l}0hgfZ547Xq^$;%s02KNcVU{1ms?7DZNu;57|5kSu zAHrLoAAA^hgovL2sw_MHE{u`oxUSEuu8hwk^o5<0oxl}n`jne7N1gZz0LFU>W9zUD z|6ERGy)lDud=8(+Yv@I`l^;a(8-XGQho2ptaRWv5dJ6t)6t@G{0k@**9l66r=L(=op??vUu~xW^O)}#-o9rGpaDm_A zowO0Fe*JXmd;wG$SiAyr>=)Q(x35jM54z^OfTA{a4StlFIRXGEX z#U+`22*)aL--a3Ejy$sjP^Hkn5X)GHId%*HsqCvL$+NlVd4a2XXEHMdP-S58c|d}} z^>?>BDeYor3qTU{pcFY0v-w002ovPDHLkV1lZs Bao7L= literal 0 HcmV?d00001 diff --git a/uikit/src/main/res/drawable/ic_close_circle.xml b/uikit/src/main/res/drawable/ic_close_circle.xml new file mode 100644 index 00000000..c35a0afc --- /dev/null +++ b/uikit/src/main/res/drawable/ic_close_circle.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/uikit/src/main/res/drawable/ic_happy.xml b/uikit/src/main/res/drawable/ic_happy.xml new file mode 100644 index 00000000..8e9c44ec --- /dev/null +++ b/uikit/src/main/res/drawable/ic_happy.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + diff --git a/uikit/src/main/res/drawable/ic_keyboard_black_24dp.xml b/uikit/src/main/res/drawable/ic_keyboard_black_24dp.xml new file mode 100644 index 00000000..4f594a10 --- /dev/null +++ b/uikit/src/main/res/drawable/ic_keyboard_black_24dp.xml @@ -0,0 +1,5 @@ + + + diff --git a/uikit/src/main/res/layout/activity_comet_chat_message_info_screen.xml b/uikit/src/main/res/layout/activity_comet_chat_message_info_screen.xml index c911d77f..5f5c004c 100644 --- a/uikit/src/main/res/layout/activity_comet_chat_message_info_screen.xml +++ b/uikit/src/main/res/layout/activity_comet_chat_message_info_screen.xml @@ -53,7 +53,13 @@ tools:visibility="visible" android:layout_width="match_parent" android:layout_height="wrap_content"/> - + + + + + + + + + \ No newline at end of file diff --git a/uikit/src/main/res/layout/fragment_chat_screen.xml b/uikit/src/main/res/layout/fragment_chat_screen.xml index 9399d3bd..6a40ffa9 100644 --- a/uikit/src/main/res/layout/fragment_chat_screen.xml +++ b/uikit/src/main/res/layout/fragment_chat_screen.xml @@ -31,6 +31,10 @@ + - + + + + diff --git a/uikit/src/main/res/layout/fragment_composebox_actions.xml b/uikit/src/main/res/layout/fragment_composebox_actions.xml index f0d311fc..8b694c58 100644 --- a/uikit/src/main/res/layout/fragment_composebox_actions.xml +++ b/uikit/src/main/res/layout/fragment_composebox_actions.xml @@ -90,5 +90,19 @@ android:padding="16dp" android:layout_width="match_parent" android:layout_height="wrap_content"/> + diff --git a/uikit/src/main/res/layout/fragment_stickers_view.xml b/uikit/src/main/res/layout/fragment_stickers_view.xml new file mode 100644 index 00000000..130a4a29 --- /dev/null +++ b/uikit/src/main/res/layout/fragment_stickers_view.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/uikit/src/main/res/layout/fragment_thread_message.xml b/uikit/src/main/res/layout/fragment_thread_message.xml index 916510fb..304baca3 100644 --- a/uikit/src/main/res/layout/fragment_thread_message.xml +++ b/uikit/src/main/res/layout/fragment_thread_message.xml @@ -66,6 +66,11 @@ tools:text="@string/loremIpsum" android:layout_width="match_parent" android:layout_height="wrap_content"/> + + \ No newline at end of file diff --git a/uikit/src/main/res/layout/message_left_sticker_item.xml b/uikit/src/main/res/layout/message_left_sticker_item.xml new file mode 100644 index 00000000..ae058d23 --- /dev/null +++ b/uikit/src/main/res/layout/message_left_sticker_item.xml @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/uikit/src/main/res/layout/message_right_sticker_item.xml b/uikit/src/main/res/layout/message_right_sticker_item.xml new file mode 100644 index 00000000..e70f5b66 --- /dev/null +++ b/uikit/src/main/res/layout/message_right_sticker_item.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + diff --git a/uikit/src/main/res/layout/reply_message_layout.xml b/uikit/src/main/res/layout/reply_message_layout.xml index 9b7b4d9f..4d94587b 100644 --- a/uikit/src/main/res/layout/reply_message_layout.xml +++ b/uikit/src/main/res/layout/reply_message_layout.xml @@ -32,6 +32,8 @@ android:layout_height="wrap_content"/> \ No newline at end of file diff --git a/uikit/src/main/res/layout/stickers_row.xml b/uikit/src/main/res/layout/stickers_row.xml new file mode 100644 index 00000000..a6904cc1 --- /dev/null +++ b/uikit/src/main/res/layout/stickers_row.xml @@ -0,0 +1,7 @@ + + diff --git a/uikit/src/main/res/values/color.xml b/uikit/src/main/res/values/color.xml index 0aead754..0634a484 100644 --- a/uikit/src/main/res/values/color.xml +++ b/uikit/src/main/res/values/color.xml @@ -24,5 +24,7 @@ #FFCDD2 #E53935 #B96B6B6B + #C4C4C4 + #9E9C9C #202124 diff --git a/uikit/src/main/res/values/strings.xml b/uikit/src/main/res/values/strings.xml index 1a2e05a8..c906ad25 100644 --- a/uikit/src/main/res/values/strings.xml +++ b/uikit/src/main/res/values/strings.xml @@ -1,5 +1,5 @@ - UI KIT + UI KIT Rectangle Online user @@ -20,7 +20,7 @@ Unable to join group You Owner - Admin + Admin Create Group Kindly, enter group details to proceed Enter Group Name @@ -49,11 +49,11 @@ Only group owner can remove admin. %1$s is removed from admin privilege Unable to update Group Member - Admin list retrieval failed + Admin list retrieval failed Would you like to unblock %1$s %1$s is unblocked Unblock User Failed - Blocked user retrieval failed + Blocked user retrieval failed Unable to create a group Make Admin Do you like to make %1$s as a Admin @@ -75,9 +75,9 @@ Outgoing Incoming Video Call - Audio Call + Audio Call History - All + All Missed New Call Incoming Audio Call @@ -86,15 +86,15 @@ Rejected Fill this Field Remove from %1$s - Add in Group \" %1$s \" + Add in Group \" %1$s \" Unblock User - Block User - Add %1$s to \" %2$s \" + Block User + Add %1$s to \" %2$s \" %1$s is added to \" %2$s \" %1$s is removed from \" %2$s \" Group Member Kicked Failed %1$s is Blocked - Unable to Block %1$s + Unable to Block %1$s Exit Group Exit from group ? Exit @@ -104,7 +104,7 @@ Group Deletion Failed Can\'t remove %1$s Unable to leave group - Blocked userlist retrieval failed + Blocked userlist retrieval failed Edit Message Preview Password @@ -112,32 +112,32 @@ Joining Incorrect ScaleType %1$s not supported. - adjustViewBounds not supported. + adjustViewBounds not supported. is null]]> is null]]> is null]]> is null]]> Send Details - Administrators + Administrators Members - Add Members + Add Members Send Message - Actions + Actions User - Blocked users + Blocked users Forward Message - Add - Add as Admin + Add + Add as Admin Groups More Preferences Users Shared Media No Media Available - baseMessage + baseMessage Load More Load more %1$s members Unable to fetch Group List @@ -157,9 +157,9 @@ Enter Url for avatar Enter user name Update User - Banned Members - Unable to fetch Banned Members List - Banned Members of %1$s + Banned Members + Unable to fetch Banned Members List + Banned Members of %1$s %1$s unbanned from %2$s Unable to unban %1$s @@ -176,7 +176,7 @@ Make Moderator Do you like to make %1$s as a Moderator %1$s is now Moderator - Add as Moderator + Add as Moderator Only Admin can remove moderator Moderator Update Group @@ -200,7 +200,7 @@ Would you like to view this message it may contains sensitive content. Reply a message Start a ThreadK - Ban + Ban Thread Thread in %1$s Sent at : %1$s @@ -229,15 +229,23 @@ Poll Sending Media Message Create a Poll - Add a Poll + Add a Poll Enter your option Shared a Polls : \n %1$s Enter your Question Question - Add a New Option + Add a New Option Unable to get your location Ended Ongoing + You are not a member of this group (%1$s) + sticker + Owner Alert + Please transfer group ownership to another member before leaving the group + Ok + Delete Group + Send Stickers + Shared a Sticker Public Group Private Group