From 9bac4b751f3935a3812c9fa22694edc96d38828a Mon Sep 17 00:00:00 2001 From: dwarsh Date: Tue, 1 Jun 2021 14:56:40 +0530 Subject: [PATCH] Android UIKit v2.3.4-1 --- README.md | 4 +- uikit/build.gradle | 4 +- uikit/src/main/AndroidManifest.xml | 2 +- .../calls/call_list/AllCall.java | 66 +- .../calls/call_list/CometChatCallList.java | 41 +- .../calls/call_list/CometChatNewCallList.java | 79 +- .../calls/call_list/MissedCall.java | 2 + .../call_manager/CometChatCallActivity.java | 17 +- .../CometChatStartCallActivity.java | 15 +- .../ongoing_call/OngoingCallService.java | 4 +- .../chats/CometChatConversationList.java | 100 +- .../cometchat_ui/CometChatUI.java | 234 ++-- .../add_members/CometChatAddMembers.java | 4 +- .../CometChatAddMembersActivity.java | 6 +- .../CometChatAdminModeratorList.java | 36 +- .../CometChatAdminModeratorListActivity.java | 6 +- .../banned_members/CometChatBanMembers.java | 12 +- .../CometChatBanMembersActivity.java | 6 +- .../create_group/CometChatCreateGroup.java | 46 +- .../CometChatCreateGroupActivity.java | 6 +- .../CometChatGroupDetailActivity.java | 247 ++-- .../groups/group_list/CometChatGroupList.java | 86 +- .../CometChatGroupMemberListActivity.java | 6 +- ...ity.java => CometChatWebViewActivity.java} | 23 +- .../messages/extensions/Extensions.java | 75 +- .../CometChatForwardMessageActivity.java | 86 +- .../CometChatMediaViewActivity.java | 16 +- .../CometChatMessageActions.java | 10 +- .../CometChatMessageInfoScreenActivity.java | 6 +- .../CometChatReceiptsAdapter.java | 4 +- .../message_list/CometChatMessageList.java | 789 +++++++++---- .../CometChatMessageListActivity.java | 11 +- .../messages/message_list/MessageAdapter.java | 286 +++-- .../CometChatThreadMessageList.java | 328 ++++-- .../CometChatThreadMessageListActivity.java | 6 +- .../thread_message_list/ThreadAdapter.java | 32 +- .../shared/CometChatSnackBar.java | 1 - .../cometchatAvatar/CometChatAvatar.java | 12 +- .../cometchatCalls/CometChatCallsAdapter.java | 17 +- .../CometChatComposeBox.java | 106 +- .../CometChatComposeBoxActions.java | 18 - .../CometChatConversations.java | 6 + .../CometChatConversationsAdapter.java | 43 +- .../CometChatConversationsViewModel.java | 6 + .../CometChatGroupsAdapter.java | 4 +- .../CometChatSharedMedia.java | 12 +- .../shared/cometchatStickers/StickerView.java | 12 +- .../cometchatUsers/CometChatUsersAdapter.java | 2 - .../userprofile/CometChatUserProfile.java | 9 +- .../CometChatMorePrivacyActivity.java | 9 +- .../block_users/CometChatBlockUserList.java | 13 +- .../CometChatBlockUserListActivity.java | 6 +- .../CometChatUserDetailScreenActivity.java | 213 ++-- .../users/user_list/CometChatUserList.java | 40 +- .../constants/UIKitConstants.java | 10 +- .../uikit/ui_resources/utils/CallUtils.java | 2 + .../ui_resources/utils/CometChatError.java | 268 +---- .../uikit/ui_resources/utils/MediaUtils.java | 282 +++-- .../pro/uikit/ui_resources/utils/Utils.java | 71 +- .../utils/pattern_utils/PatternUtils.java | 8 +- .../recycler_touch/RecyclerTouchListener.java | 67 +- .../RecyclerViewSwipeListener.java | 255 +++++ .../pro/uikit/ui_settings/Feature.java | 98 ++ .../uikit/ui_settings/FeatureRestriction.java | 1002 +++++++++++++++++ .../pro/uikit/ui_settings/UIKitSettings.java | 768 +++++++++++-- .../pro/uikit/ui_settings/UISettings.java | 267 ----- .../ui_settings/enums/ConversationMode.java | 12 + .../uikit/ui_settings/enums/GroupMode.java | 12 + .../pro/uikit/ui_settings/enums/UserMode.java | 12 + .../calls/layout/fragment_cometchat_calls.xml | 2 +- .../cometchat_conversation_list_row.xml | 106 +- .../chats/layout/conversation_shimmer.xml | 4 +- .../fragment_cometchat_conversationlist.xml | 2 +- .../layout/activity_cometchat_unified.xml | 5 +- .../activity_cometchat_group_detail.xml | 25 - .../layout/cometchat_group_member_row.xml | 5 +- .../layout/cometchat_update_group_dialog.xml | 5 +- .../layout/fragment_cometchat_grouplist.xml | 23 +- .../layout/activity_cometchat_media_view.xml | 2 +- .../layout/activity_cometchat_webview.xml | 31 +- .../layout/cometchat_composebox_actions.xml | 14 - .../layout/cometchat_messagelist_toolbar.xml | 79 +- .../fragment_cometchat_message_actions.xml | 60 +- .../shared/layout/cometchat_compose_box.xml | 8 +- .../fragment_cometchat_user_profile.xml | 2 +- .../users/drawable/ic_audiocall.xml | 6 + .../drawable/ic_baseline_in_thread_24.xml | 15 + .../res-components/users/drawable/ic_info.xml | 12 + .../users/drawable/ic_videocall.xml | 6 + .../layout/activity_cometchat_user_detail.xml | 30 +- .../users/layout/cometchat_user_list_row.xml | 5 +- .../layout/fragment_cometchat_userlist.xml | 2 +- .../users/layout/user_shimmer.xml | 2 +- uikit/src/main/res/drawable-hdpi/ic_edit.png | Bin 0 -> 793 bytes .../main/res/drawable-hdpi/ic_info_image.png | Bin 440 -> 0 bytes .../main/res/drawable-mdpi/ic_info_image.png | Bin 303 -> 0 bytes .../main/res/drawable-xhdpi/ic_info_image.png | Bin 558 -> 0 bytes .../res/drawable-xxhdpi/ic_info_image.png | Bin 940 -> 0 bytes .../res/drawable-xxxhdpi/ic_info_image.png | Bin 1384 -> 0 bytes .../main/res/drawable/bottom_curve_border.xml | 14 - uikit/src/main/res/drawable/copy.png | Bin 0 -> 942 bytes .../main/res/drawable/curve_progress_bar.xml | 17 - uikit/src/main/res/drawable/forward.png | Bin 0 -> 715 bytes .../res/drawable/ic_archive_white_24dp.xml | 5 - uikit/src/main/res/drawable/ic_arrow.xml | 9 - .../main/res/drawable/ic_baseline_edit_24.xml | 10 - uikit/src/main/res/drawable/ic_chats.png | Bin 0 -> 623 bytes uikit/src/main/res/drawable/ic_contacts.png | Bin 0 -> 673 bytes .../{ic_contacts.xml => ic_contacts_24dp.xml} | 2 +- uikit/src/main/res/drawable/ic_delete.png | Bin 0 -> 907 bytes uikit/src/main/res/drawable/ic_info_image.png | Bin 0 -> 927 bytes uikit/src/main/res/drawable/info.png | Bin 0 -> 927 bytes uikit/src/main/res/drawable/reply.png | Bin 0 -> 700 bytes .../src/main/res/drawable/reply_privately.png | Bin 0 -> 720 bytes uikit/src/main/res/drawable/share.png | Bin 0 -> 735 bytes uikit/src/main/res/drawable/thread.png | Bin 0 -> 884 bytes .../res/menu/cometchat_navigation_bottom.xml | 2 +- uikit/src/main/res/values-ar/strings.xml | 66 +- uikit/src/main/res/values-de/strings.xml | 8 + uikit/src/main/res/values-es/strings.xml | 8 + uikit/src/main/res/values-fr/strings.xml | 10 +- uikit/src/main/res/values-hi/strings.xml | 7 + uikit/src/main/res/values-lt/strings.xml | 11 + uikit/src/main/res/values-ms/strings.xml | 8 + uikit/src/main/res/values-pt/strings.xml | 8 + uikit/src/main/res/values-ru/strings.xml | 8 + .../res/{values-sw => values-sv}/strings.xml | 12 +- uikit/src/main/res/values-zh-rTW/strings.xml | 9 + uikit/src/main/res/values-zh/strings.xml | 9 + uikit/src/main/res/values/dimen.xml | 3 +- uikit/src/main/res/values/strings.xml | 80 +- 131 files changed, 4857 insertions(+), 2264 deletions(-) rename uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/extensions/Collaborative/{CometChatCollaborativeActivity.java => CometChatWebViewActivity.java} (59%) create mode 100644 uikit/src/main/java/com/cometchat/pro/uikit/ui_resources/utils/recycler_touch/RecyclerViewSwipeListener.java create mode 100644 uikit/src/main/java/com/cometchat/pro/uikit/ui_settings/Feature.java create mode 100644 uikit/src/main/java/com/cometchat/pro/uikit/ui_settings/FeatureRestriction.java delete mode 100644 uikit/src/main/java/com/cometchat/pro/uikit/ui_settings/UISettings.java create mode 100644 uikit/src/main/java/com/cometchat/pro/uikit/ui_settings/enums/ConversationMode.java create mode 100644 uikit/src/main/java/com/cometchat/pro/uikit/ui_settings/enums/GroupMode.java create mode 100644 uikit/src/main/java/com/cometchat/pro/uikit/ui_settings/enums/UserMode.java create mode 100644 uikit/src/main/res-components/users/drawable/ic_audiocall.xml create mode 100644 uikit/src/main/res-components/users/drawable/ic_baseline_in_thread_24.xml create mode 100644 uikit/src/main/res-components/users/drawable/ic_info.xml create mode 100644 uikit/src/main/res-components/users/drawable/ic_videocall.xml create mode 100644 uikit/src/main/res/drawable-hdpi/ic_edit.png delete mode 100644 uikit/src/main/res/drawable-hdpi/ic_info_image.png delete mode 100644 uikit/src/main/res/drawable-mdpi/ic_info_image.png delete mode 100644 uikit/src/main/res/drawable-xhdpi/ic_info_image.png delete mode 100644 uikit/src/main/res/drawable-xxhdpi/ic_info_image.png delete mode 100644 uikit/src/main/res/drawable-xxxhdpi/ic_info_image.png delete mode 100644 uikit/src/main/res/drawable/bottom_curve_border.xml create mode 100644 uikit/src/main/res/drawable/copy.png delete mode 100644 uikit/src/main/res/drawable/curve_progress_bar.xml create mode 100644 uikit/src/main/res/drawable/forward.png delete mode 100644 uikit/src/main/res/drawable/ic_archive_white_24dp.xml delete mode 100644 uikit/src/main/res/drawable/ic_arrow.xml delete mode 100644 uikit/src/main/res/drawable/ic_baseline_edit_24.xml create mode 100644 uikit/src/main/res/drawable/ic_chats.png create mode 100644 uikit/src/main/res/drawable/ic_contacts.png rename uikit/src/main/res/drawable/{ic_contacts.xml => ic_contacts_24dp.xml} (89%) create mode 100644 uikit/src/main/res/drawable/ic_delete.png create mode 100644 uikit/src/main/res/drawable/ic_info_image.png create mode 100644 uikit/src/main/res/drawable/info.png create mode 100644 uikit/src/main/res/drawable/reply.png create mode 100644 uikit/src/main/res/drawable/reply_privately.png create mode 100644 uikit/src/main/res/drawable/share.png create mode 100644 uikit/src/main/res/drawable/thread.png rename uikit/src/main/res/{values-sw => values-sv}/strings.xml (97%) diff --git a/README.md b/README.md index 00db22e..d5e208f 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ The UI Kit is developed to keep developers in mind and aims to reduce developmen [![Platform](https://img.shields.io/badge/Language-Java-yellowgreen.svg)](#) ![GitHub contributors](https://img.shields.io/github/contributors/cometchat-pro/android-java-chat-ui-kit) -![Version](https://shields.io/badge/version-v2.3.1--1-orange) +![Version](https://shields.io/badge/version-v2.3.4--1-orange) ![GitHub stars](https://img.shields.io/github/stars/cometchat-pro/android-java-chat-ui-kit?style=social) ![Twitter Follow](https://img.shields.io/twitter/follow/cometchat?style=social) @@ -71,7 +71,7 @@ allprojects { ```groovy dependencies { - implementation 'com.cometchat:pro-android-chat-sdk:2.3.1' + implementation 'com.cometchat:pro-android-chat-sdk:2.3.4' } ``` diff --git a/uikit/build.gradle b/uikit/build.gradle index 3bb177d..892bd80 100644 --- a/uikit/build.gradle +++ b/uikit/build.gradle @@ -6,7 +6,7 @@ android { minSdkVersion 21 targetSdkVersion 29 versionCode 1 - versionName "1.0" + versionName "2.3.4-1" multiDexEnabled true vectorDrawables.useSupportLibrary = true renderscriptSupportModeEnabled true @@ -90,7 +90,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.3.1' + compileOnly 'com.cometchat:pro-android-chat-sdk:2.3.4' implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.0' } diff --git a/uikit/src/main/AndroidManifest.xml b/uikit/src/main/AndroidManifest.xml index 8b7bf1c..2cba428 100644 --- a/uikit/src/main/AndroidManifest.xml +++ b/uikit/src/main/AndroidManifest.xml @@ -20,7 +20,7 @@ android:usesCleartextTraffic="true" tools:node="merge" tools:targetApi="m"> - + diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/calls/call_list/AllCall.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/calls/call_list/AllCall.java index 218d034..71960f7 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/calls/call_list/AllCall.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/calls/call_list/AllCall.java @@ -16,6 +16,7 @@ import androidx.recyclerview.widget.LinearLayoutManager; 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; @@ -28,6 +29,7 @@ import com.cometchat.pro.uikit.R; import com.cometchat.pro.uikit.ui_resources.utils.CometChatError; import com.cometchat.pro.uikit.ui_resources.utils.Utils; +import com.cometchat.pro.uikit.ui_settings.FeatureRestriction; import com.google.android.material.snackbar.Snackbar; import java.util.Arrays; @@ -57,9 +59,15 @@ public class AllCall extends Fragment { private MessagesRequest messagesRequest; private LinearLayoutManager linearLayoutManager; + + private boolean videoCallEnabled; + private boolean audioCallEnabled; + @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_cometchat_all_call, container, false); + fetchSettings(); + CometChatError.init(getContext()); rvCallList = view.findViewById(R.id.callList_rv); linearLayoutManager = new LinearLayoutManager(getContext(),LinearLayoutManager.VERTICAL,false ); @@ -68,7 +76,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c rvCallList.setItemClickListener(new OnItemClickListener() { @Override public void OnItemClick(Call var, int position) { - if (var.getReceiverType().equals(com.cometchat.pro.constants.CometChatConstants.RECEIVER_TYPE_USER)) { + if (var.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_USER)) { User user; if (((User)var.getCallInitiator()).getUid().equals(CometChat.getLoggedInUser().getUid())) { user = ((User)var.getCallReceiver()); @@ -81,6 +89,7 @@ public void OnItemClick(Call var, int position) { intent.putExtra(UIKitConstants.IntentStrings.NAME, user.getName()); intent.putExtra(UIKitConstants.IntentStrings.AVATAR, user.getAvatar()); intent.putExtra(UIKitConstants.IntentStrings.STATUS, user.getStatus()); + intent.putExtra(UIKitConstants.IntentStrings.LINK,user.getLink()); intent.putExtra(UIKitConstants.IntentStrings.IS_BLOCKED_BY_ME, user.isBlockedByMe()); intent.putExtra(UIKitConstants.IntentStrings.FROM_CALL_LIST,true); startActivity(intent); @@ -121,7 +130,7 @@ public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newStat } private void checkOnGoingCall(Call var) { - if(CometChat.getActiveCall()!=null && CometChat.getActiveCall().getCallStatus().equals(com.cometchat.pro.constants.CometChatConstants.CALL_STATUS_ONGOING) && CometChat.getActiveCall().getSessionId()!=null) + if(CometChat.getActiveCall()!=null && CometChat.getActiveCall().getCallStatus().equals(CometChatConstants.CALL_STATUS_ONGOING) && CometChat.getActiveCall().getSessionId()!=null) { AlertDialog.Builder alert = new AlertDialog.Builder(getContext()); alert.setTitle(getContext().getResources().getString(R.string.ongoing_call)) @@ -139,22 +148,28 @@ public void onClick(DialogInterface dialog, int which) { }).create().show(); } else { - AlertDialog.Builder alertDialog = new AlertDialog.Builder(getContext()); - alertDialog.setMessage(getString(R.string.initiate_a_call)); - alertDialog.setPositiveButton(getString(R.string.audio_call), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - initiateCall(var, com.cometchat.pro.constants.CometChatConstants.CALL_TYPE_AUDIO); + if (audioCallEnabled || videoCallEnabled) { + AlertDialog.Builder alertDialog = new AlertDialog.Builder(getContext()); + alertDialog.setMessage(getString(R.string.initiate_a_call)); + if (audioCallEnabled) { + alertDialog.setPositiveButton(getString(R.string.audio_call), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + initiateCall(var, CometChatConstants.CALL_TYPE_AUDIO); + } + }); } - }); - alertDialog.setNegativeButton(getString(R.string.video_call), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - initiateCall(var, com.cometchat.pro.constants.CometChatConstants.CALL_TYPE_VIDEO); + if (videoCallEnabled) { + alertDialog.setNegativeButton(getString(R.string.video_call), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + initiateCall(var, CometChatConstants.CALL_TYPE_VIDEO); + } + }); } - }); - alertDialog.create(); - alertDialog.show(); + alertDialog.create(); + alertDialog.show(); + } } } @@ -164,7 +179,7 @@ private void initiateCall(Call var,String callType) { @Override public void onSuccess(Call call) { Log.e("onSuccess: ", call.toString()); - if (call.getReceiverType().equals(com.cometchat.pro.constants.CometChatConstants.RECEIVER_TYPE_USER)) { + if (call.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_USER)) { User user; if (((User) call.getCallInitiator()).getUid().equals(CometChat.getLoggedInUser().getUid())) { user = ((User) call.getCallReceiver()); @@ -192,7 +207,7 @@ private void getCallList() { if (messagesRequest == null) { messagesRequest = new MessagesRequest.MessagesRequestBuilder(). - setCategories(Arrays.asList(com.cometchat.pro.constants.CometChatConstants.CATEGORY_CALL)).setLimit(30).build(); + setCategories(Arrays.asList(CometChatConstants.CATEGORY_CALL)).setLimit(30).build(); } messagesRequest.fetchPrevious(new CometChat.CallbackListener>() { @@ -229,4 +244,19 @@ public void setMenuVisibility(boolean menuVisible) { public void onResume() { super.onResume(); } + + private void fetchSettings() { + FeatureRestriction.isOneOnOneVideoCallEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + videoCallEnabled = booleanVal; + } + }); + FeatureRestriction.isOneOnOneAudioCallEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + audioCallEnabled = booleanVal; + } + }); + } } diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/calls/call_list/CometChatCallList.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/calls/call_list/CometChatCallList.java index e61fc05..96a71d5 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/calls/call_list/CometChatCallList.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/calls/call_list/CometChatCallList.java @@ -20,6 +20,7 @@ import com.cometchat.pro.core.MessagesRequest; import com.cometchat.pro.uikit.R; import com.cometchat.pro.uikit.ui_components.shared.cometchatCalls.CometChatCalls; +import com.cometchat.pro.uikit.ui_resources.utils.CometChatError; import com.facebook.shimmer.ShimmerFrameLayout; import com.google.android.material.tabs.TabLayout; @@ -28,7 +29,7 @@ import com.cometchat.pro.uikit.ui_resources.utils.item_clickListener.OnItemClickListener; -import com.cometchat.pro.uikit.ui_settings.UISettings; +import com.cometchat.pro.uikit.ui_settings.FeatureRestriction; import com.cometchat.pro.uikit.ui_resources.utils.Utils; @@ -68,6 +69,10 @@ public class CometChatCallList extends Fragment { private ImageView phoneAddIv; + private boolean oneOnoneCallEnabled; + + private boolean oneOnoneVideoCallEnabled; + public CometChatCallList() { // Required empty public constructor } @@ -78,7 +83,14 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, // Inflate the layout for this fragment view = inflater.inflate(R.layout.fragment_cometchat_calls, container, false); tvTitle = view.findViewById(R.id.tv_title); + fetchSettings(); + CometChatError.init(getContext()); phoneAddIv = view.findViewById(R.id.add_phone_iv); + if (oneOnoneCallEnabled || oneOnoneVideoCallEnabled) + phoneAddIv.setVisibility(View.VISIBLE); + else + phoneAddIv.setVisibility(View.GONE); + phoneAddIv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -94,13 +106,13 @@ public void onClick(View v) { viewPager.setAdapter(tabAdapter); } tabLayout.setupWithViewPager(viewPager); - if (UISettings.getColor()!=null) { - phoneAddIv.setImageTintList(ColorStateList.valueOf(Color.parseColor(UISettings.getColor()))); + if (FeatureRestriction.getColor()!=null) { + phoneAddIv.setImageTintList(ColorStateList.valueOf(Color.parseColor(FeatureRestriction.getColor()))); Drawable wrappedDrawable = DrawableCompat.wrap(getResources(). getDrawable(R.drawable.tab_layout_background_active)); - DrawableCompat.setTint(wrappedDrawable, Color.parseColor(UISettings.getColor())); + DrawableCompat.setTint(wrappedDrawable, Color.parseColor(FeatureRestriction.getColor())); tabLayout.getTabAt(tabLayout.getSelectedTabPosition()).view.setBackground(wrappedDrawable); - tabLayout.setSelectedTabIndicatorColor(Color.parseColor(UISettings.getColor())); + tabLayout.setSelectedTabIndicatorColor(Color.parseColor(FeatureRestriction.getColor())); } else { tabLayout.getTabAt(tabLayout.getSelectedTabPosition()). view.setBackgroundColor(getResources().getColor(R.color.colorPrimary)); @@ -109,10 +121,10 @@ public void onClick(View v) { tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { @Override public void onTabSelected(TabLayout.Tab tab) { - if (UISettings.getColor()!=null) { + if (FeatureRestriction.getColor()!=null) { Drawable wrappedDrawable = DrawableCompat.wrap(getResources(). getDrawable(R.drawable.tab_layout_background_active)); - DrawableCompat.setTint(wrappedDrawable, Color.parseColor(UISettings.getColor())); + DrawableCompat.setTint(wrappedDrawable, Color.parseColor(FeatureRestriction.getColor())); tab.view.setBackground(wrappedDrawable); } else @@ -133,6 +145,21 @@ public void onTabReselected(TabLayout.Tab tab) { return view; } + private void fetchSettings() { + FeatureRestriction.isOneOnOneAudioCallEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + oneOnoneCallEnabled = booleanVal; + } + }); + FeatureRestriction.isOneOnOneVideoCallEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + oneOnoneVideoCallEnabled = booleanVal; + } + }); + } + private void checkDarkMode() { if(Utils.isDarkMode(getContext())) { tvTitle.setTextColor(getResources().getColor(R.color.textColorWhite)); diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/calls/call_list/CometChatNewCallList.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/calls/call_list/CometChatNewCallList.java index 4f22fad..f98782d 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/calls/call_list/CometChatNewCallList.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/calls/call_list/CometChatNewCallList.java @@ -33,7 +33,6 @@ import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView; -import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -49,9 +48,7 @@ import com.cometchat.pro.uikit.R; import com.cometchat.pro.uikit.ui_components.shared.CometChatSnackBar; import com.cometchat.pro.uikit.ui_resources.utils.CometChatError; -import com.cometchat.pro.uikit.ui_resources.utils.Utils; import com.facebook.shimmer.ShimmerFrameLayout; -import com.google.android.material.snackbar.Snackbar; import java.util.List; @@ -59,7 +56,7 @@ import com.cometchat.pro.uikit.ui_resources.utils.CallUtils; import com.cometchat.pro.uikit.ui_resources.utils.FontUtils; import com.cometchat.pro.uikit.ui_resources.utils.item_clickListener.OnItemClickListener; -import com.cometchat.pro.uikit.ui_settings.UISettings; +import com.cometchat.pro.uikit.ui_settings.FeatureRestriction; /** @@ -93,6 +90,9 @@ public class CometChatNewCallList extends AppCompatActivity { private RelativeLayout rlSearchBox; + private boolean audioCallEnabled; + private boolean videoCallEnabled; + public CometChatNewCallList() { // Required empty public constructor } @@ -102,16 +102,18 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fragment_cometchat_userlist); title = findViewById(R.id.tv_title); + CometChatError.init(this); ImageView imageView = new ImageView(this); imageView.setImageDrawable(getResources().getDrawable(R.drawable.ic_close_24dp)); - if (UISettings.getColor()!=null) { - getWindow().setStatusBarColor(Color.parseColor(UISettings.getColor())); + if (FeatureRestriction.getColor()!=null) { + getWindow().setStatusBarColor(Color.parseColor(FeatureRestriction.getColor())); imageView.setImageTintList(ColorStateList.valueOf( - Color.parseColor(UISettings.getColor()))); + Color.parseColor(FeatureRestriction.getColor()))); } else imageView.setImageTintList( ColorStateList.valueOf(getResources().getColor(R.color.colorPrimary))); + fetchSettings(); imageView.setClickable(true); imageView.setPadding(8,8,8,8); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); @@ -199,29 +201,35 @@ public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newStat } }); - // Used to trigger event on click of user item in rvUserList (RecyclerView) - rvUserList.setItemClickListener(new OnItemClickListener() { - @Override - public void OnItemClick(User var, int position) { - User user = var; - AlertDialog.Builder alertDialog = new AlertDialog.Builder(CometChatNewCallList.this); - alertDialog.setMessage(getString(R.string.initiate_a_call)); - alertDialog.setPositiveButton(getString(R.string.audio_call), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - initiateCall(user.getUid(), CometChatConstants.RECEIVER_TYPE_USER,CometChatConstants.CALL_TYPE_AUDIO); + if (audioCallEnabled || videoCallEnabled) { + // Used to trigger event on click of user item in rvUserList (RecyclerView) + rvUserList.setItemClickListener(new OnItemClickListener() { + @Override + public void OnItemClick(User var, int position) { + User user = var; + AlertDialog.Builder alertDialog = new AlertDialog.Builder(CometChatNewCallList.this); + alertDialog.setMessage(getString(R.string.initiate_a_call)); + if (audioCallEnabled) { + alertDialog.setPositiveButton(getString(R.string.audio_call), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + initiateCall(user.getUid(), CometChatConstants.RECEIVER_TYPE_USER, CometChatConstants.CALL_TYPE_AUDIO); + } + }); } - }); - alertDialog.setNegativeButton(getString(R.string.video_call), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - initiateCall(user.getUid(), CometChatConstants.RECEIVER_TYPE_USER,CometChatConstants.CALL_TYPE_VIDEO); + if (videoCallEnabled) { + alertDialog.setNegativeButton(getString(R.string.video_call), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + initiateCall(user.getUid(), CometChatConstants.RECEIVER_TYPE_USER, CometChatConstants.CALL_TYPE_VIDEO); + } + }); } - }); - alertDialog.create(); - alertDialog.show(); - } - }); + alertDialog.create(); + alertDialog.show(); + } + }); + } fetchUsers(); } @@ -290,4 +298,19 @@ public void initiateCall(String receiverID, String receiverType, String callType { CallUtils.initiateCall(CometChatNewCallList.this,receiverID,receiverType,callType); } + + private void fetchSettings() { + FeatureRestriction.isOneOnOneVideoCallEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + videoCallEnabled = booleanVal; + } + }); + FeatureRestriction.isOneOnOneAudioCallEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + audioCallEnabled = booleanVal; + } + }); + } } diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/calls/call_list/MissedCall.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/calls/call_list/MissedCall.java index 5df691b..8956966 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/calls/call_list/MissedCall.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/calls/call_list/MissedCall.java @@ -66,6 +66,7 @@ public class MissedCall extends Fragment { public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_cometchat_missed_call, container, false); rvCallList = view.findViewById(R.id.callList_rv); + CometChatError.init(getContext()); linearLayoutManager = new LinearLayoutManager(getContext(),LinearLayoutManager.VERTICAL,false); rvCallList.setLayoutManager(linearLayoutManager); noCallView = view.findViewById(R.id.no_call_vw); @@ -85,6 +86,7 @@ public void OnItemClick(Call var, int position) { intent.putExtra(UIKitConstants.IntentStrings.UID, user.getUid()); intent.putExtra(UIKitConstants.IntentStrings.NAME, user.getName()); intent.putExtra(UIKitConstants.IntentStrings.AVATAR, user.getAvatar()); + intent.putExtra(UIKitConstants.IntentStrings.LINK,user.getLink()); intent.putExtra(UIKitConstants.IntentStrings.STATUS, user.getStatus()); intent.putExtra(UIKitConstants.IntentStrings.IS_BLOCKED_BY_ME, user.isBlockedByMe()); intent.putExtra(UIKitConstants.IntentStrings.FROM_CALL_LIST,true); diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/calls/call_manager/CometChatCallActivity.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/calls/call_manager/CometChatCallActivity.java index 3c3290f..28fbc7c 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/calls/call_manager/CometChatCallActivity.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/calls/call_manager/CometChatCallActivity.java @@ -31,7 +31,7 @@ import com.cometchat.pro.uikit.ui_components.calls.call_manager.helper.OutgoingAudioHelper; import com.cometchat.pro.uikit.ui_resources.utils.CallUtils; import com.cometchat.pro.uikit.ui_resources.utils.camera_preview.CameraPreview; -import com.cometchat.pro.uikit.ui_settings.UISettings; +import com.cometchat.pro.uikit.ui_settings.FeatureRestriction; import com.cometchat.pro.uikit.ui_resources.utils.Utils; /** @@ -175,11 +175,16 @@ private void initView() { hangUp.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.red_600))); mainView = findViewById(R.id.main_view); cometChatAudioHelper = new CometChatAudioHelper(this); - if (UISettings.isEnableCallSounds()) { - cometChatAudioHelper.initAudio(); - String packageName = getPackageName(); - notification = Uri.parse("android.resource://" + packageName + "/" + R.raw.incoming_call); - } + FeatureRestriction.isCallsSoundEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (booleanVal) { + cometChatAudioHelper.initAudio(); + 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)) { requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO,Manifest.permission.CAMERA},REQUEST_PERMISSION); diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/calls/call_manager/CometChatStartCallActivity.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/calls/call_manager/CometChatStartCallActivity.java index e867863..7884292 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/calls/call_manager/CometChatStartCallActivity.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/calls/call_manager/CometChatStartCallActivity.java @@ -65,6 +65,8 @@ public class CometChatStartCallActivity extends AppCompatActivity { private Intent mServiceIntent; + private boolean isDefaultCall; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -73,7 +75,8 @@ protected void onCreate(Bundle savedInstanceState) { ongoingCallService = new OngoingCallService(); mServiceIntent = new Intent(this,ongoingCallService.getClass()); - if (!isMyServiceRunning(ongoingCallService.getClass())) { + isDefaultCall = getIntent().getBooleanExtra(UIKitConstants.IntentStrings.IS_DEFAULT_CALL,false); + if (isDefaultCall && !isMyServiceRunning(ongoingCallService.getClass())) { startService(mServiceIntent); } @@ -90,17 +93,17 @@ protected void onCreate(Bundle savedInstanceState) { callSettings = new CallSettings.CallSettingsBuilder(this,mainView) .setSessionId(sessionID) .build(); + Log.e( "startCallActivity: ",sessionID+" "+type); CometChat.startCall(callSettings, new CometChat.OngoingCallListener() { - @Override - public void onUserListUpdated(List list) { - Log.e( "onUserListUpdated: ",list.toString() ); + public void onAudioModesUpdated(List list) { + Log.e( "onAudioModesUpdated: ",list.toString() ); } @Override - public void onAudioModesUpdated(List list) { - Log.e( "onAudioModeUpdated: ",list.toString() ); + public void onUserListUpdated(List list) { + Log.e( "onUserListUpdated: ",list.toString() ); } @Override diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/calls/call_manager/ongoing_call/OngoingCallService.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/calls/call_manager/ongoing_call/OngoingCallService.java index 264d990..cf28b17 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/calls/call_manager/ongoing_call/OngoingCallService.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/calls/call_manager/ongoing_call/OngoingCallService.java @@ -33,7 +33,7 @@ public void onCreate() { if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) startMyOwnForeground(); else - startForeground(1,new Notification()); + this.startForeground(1,new Notification()); } @Nullable @@ -63,7 +63,7 @@ private void startMyOwnForeground() { .setContentIntent(pendingIntent) .setCategory(Notification.CATEGORY_CALL) .build(); - notificationManager.notify(1,notification); + startForeground(1,notification); } private Intent getCallIntent(String title) { diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/chats/CometChatConversationList.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/chats/CometChatConversationList.java index d4feab3..ec7ce8f 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/chats/CometChatConversationList.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/chats/CometChatConversationList.java @@ -2,14 +2,17 @@ import android.app.ProgressDialog; -import android.content.Context; +import android.content.DialogInterface; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; import android.os.Bundle; import androidx.annotation.NonNull; -import androidx.annotation.VisibleForTesting; +import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.RecyclerView; +import android.os.Handler; import android.text.Editable; import android.text.TextWatcher; import android.util.Log; @@ -17,13 +20,12 @@ import android.view.View; import android.view.ViewGroup; import android.view.inputmethod.EditorInfo; -import android.view.inputmethod.InputMethodManager; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; -import android.widget.Toast; +import com.cometchat.pro.constants.CometChatConstants; import com.cometchat.pro.core.CometChat; import com.cometchat.pro.core.ConversationsRequest; import com.cometchat.pro.exceptions.CometChatException; @@ -41,6 +43,10 @@ import com.cometchat.pro.models.MediaMessage; import com.cometchat.pro.models.TextMessage; import com.cometchat.pro.uikit.ui_resources.utils.CometChatError; +import com.cometchat.pro.uikit.ui_resources.utils.custom_alertDialog.CustomAlertDialogHelper; +import com.cometchat.pro.uikit.ui_resources.utils.custom_alertDialog.OnAlertDialogButtonClickListener; +import com.cometchat.pro.uikit.ui_resources.utils.recycler_touch.RecyclerViewSwipeListener; +import com.cometchat.pro.uikit.ui_settings.UIKitSettings; import com.facebook.shimmer.ShimmerFrameLayout; import java.util.ArrayList; @@ -61,13 +67,13 @@ */ -public class CometChatConversationList extends Fragment implements TextWatcher { +public class CometChatConversationList extends Fragment implements TextWatcher, OnAlertDialogButtonClickListener { private CometChatConversations rvConversationList; //Uses to display list of conversations. private ConversationsRequest conversationsRequest; //Uses to fetch Conversations. - private String conversationListType = null; + private String conversationListType = UIKitSettings.getConversationsMode().toString(); private static OnItemClickListener events; @@ -114,6 +120,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, checkDarkMode(); + CometChatError.init(getContext()); + searchEdit.setOnEditorActionListener((textView, i, keyEvent) -> { if (i == EditorInfo.IME_ACTION_SEARCH) { if (!textView.getText().toString().isEmpty()) { @@ -173,6 +181,75 @@ public void OnItemClick(Conversation conversation, int position) { } }); + RecyclerViewSwipeListener swipeHelper = new RecyclerViewSwipeListener(getContext()) { + @Override + public void instantiateUnderlayButton(RecyclerView.ViewHolder viewHolder, List underlayButtons) { + Bitmap deleteBitmap = BitmapFactory.decodeResource(getResources(),R.drawable.ic_delete); + underlayButtons.add(new RecyclerViewSwipeListener.UnderlayButton( + "Delete", + deleteBitmap, + getResources().getColor(R.color.red), + new RecyclerViewSwipeListener.UnderlayButtonClickListener() { + @Override + public void onClick(final int pos) { + Conversation conversation = rvConversationList.getConversation(pos); + if (conversation!=null) { + String conversationUid = ""; + String type = ""; + if (conversation.getConversationType() + .equalsIgnoreCase(CometChatConstants.CONVERSATION_TYPE_GROUP)) { + conversationUid = ((Group)conversation.getConversationWith()).getGuid(); + type = CometChatConstants.CONVERSATION_TYPE_GROUP; + } else { + conversationUid = ((User)conversation.getConversationWith()).getUid(); + type = CometChatConstants.CONVERSATION_TYPE_USER; + } + String finalConversationUid = conversationUid; + String finalType = type; + new CustomAlertDialogHelper(getContext(), + getString(R.string.delete_conversation_message), + null, + getString(R.string.yes), + "", getString(R.string.no), new OnAlertDialogButtonClickListener() { + @Override + public void onButtonClick(AlertDialog alertDialog, View v, int which, int popupId) { + if (which==DialogInterface.BUTTON_POSITIVE) { + ProgressDialog progressDialog = ProgressDialog.show(getContext(),null, + getString(R.string.deleting_conversation)); + CometChat.deleteConversation( + finalConversationUid, finalType, + new CometChat.CallbackListener() { + @Override + public void onSuccess(String s) { + Handler handler = new Handler(); + handler.postDelayed(new Runnable() { + public void run() { + alertDialog.dismiss(); + progressDialog.dismiss(); + } + }, 1500); + rvConversationList.remove(conversation); + } + + @Override + public void onError(CometChatException e) { + progressDialog.dismiss(); + e.printStackTrace(); + } + }); + } else if (which==DialogInterface.BUTTON_NEGATIVE) { + alertDialog.dismiss(); + } + } + }, 1, true); + + } + } + } + )); + } + }; + swipeHelper.attachToRecyclerView(rvConversationList); return view; } @@ -255,7 +332,7 @@ public void onError(CometChatException e) { stopHideShimmer(); if (getActivity()!=null) CometChatSnackBar.show(getContext(),rvConversationList, - CometChatError.localized(e),CometChatSnackBar.ERROR); + getString(R.string.err_default_message),CometChatSnackBar.ERROR); Log.d(TAG, "onError: "+e.getMessage()); } }); @@ -473,4 +550,13 @@ public void afterTextChanged(Editable s) { rvConversationList.searchConversation(s.toString()); } } + + @Override + public void onButtonClick(AlertDialog alertDialog, View v, int which, int popupId) { + if (which== DialogInterface.BUTTON_NEGATIVE) + alertDialog.dismiss(); + else if (which==DialogInterface.BUTTON_POSITIVE) { + + } + } } diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/cometchat_ui/CometChatUI.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/cometchat_ui/CometChatUI.java index 7acc376..ea259ad 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/cometchat_ui/CometChatUI.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/cometchat_ui/CometChatUI.java @@ -1,10 +1,13 @@ package com.cometchat.pro.uikit.ui_components.cometchat_ui; 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.content.res.Configuration; +import android.content.res.Resources; import android.graphics.Color; import android.os.Build; import android.os.Bundle; @@ -22,7 +25,6 @@ import androidx.emoji.bundled.BundledEmojiCompatConfig; import androidx.emoji.text.EmojiCompat; import androidx.fragment.app.Fragment; -import androidx.fragment.app.FragmentManager; import com.cometchat.pro.constants.CometChatConstants; import com.cometchat.pro.core.CometChat; @@ -44,6 +46,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Locale; import com.cometchat.pro.uikit.ui_components.calls.call_list.CometChatCallList; import com.cometchat.pro.uikit.ui_components.calls.call_manager.listener.CometChatCallListener; @@ -57,7 +60,7 @@ import com.cometchat.pro.uikit.ui_resources.utils.custom_alertDialog.OnAlertDialogButtonClickListener; import com.cometchat.pro.uikit.ui_resources.utils.item_clickListener.OnItemClickListener; import com.cometchat.pro.uikit.ui_resources.utils.Utils; -import com.cometchat.pro.uikit.ui_settings.UISettings; +import com.cometchat.pro.uikit.ui_settings.FeatureRestriction; /** * Purpose - CometChatUnified class is main class used to launch the fully working chat application. @@ -93,6 +96,12 @@ public class CometChatUI extends AppCompatActivity implements private Fragment active = new CometChatConversationList(); + private boolean isUserListVisible; + private boolean isConversationVisible; + private boolean isSettingsVisible; + private boolean isCallsListVisible; + private boolean isGroupsListVisible; + @VisibleForTesting public static AppCompatActivity activity; @@ -101,7 +110,7 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); activity = this; - + CometChatError.init(this); if (!CometChatCallListener.isInitialized) CometChatCallListener.addCallListener(TAG,this); @@ -121,7 +130,6 @@ protected void onCreate(Bundle savedInstanceState) { //It performs action on click of conversation item in CometChatConversationListScreen //Based on conversation item type it will perform the actions like open message screen for user and groups.. setConversationClickListener(); - } private void setConversationClickListener() { @@ -140,20 +148,26 @@ private void setGroupClickListener() { CometChatGroupList.setItemClickListener(new OnItemClickListener() { @Override public void OnItemClick(Group g, int position) { - group = g; - if (group.isJoined()) { - startGroupIntent(group); - } else { - if (group.getGroupType().equals(CometChatConstants.GROUP_TYPE_PASSWORD)) { - View dialogview = getLayoutInflater().inflate(R.layout.cc_dialog, null); - TextView tvTitle = dialogview.findViewById(R.id.textViewDialogueTitle); - tvTitle.setText(String.format(getResources().getString(R.string.enter_password_to_join),group.getName())); - new CustomAlertDialogHelper(CometChatUI.this, getResources().getString(R.string.password), dialogview, getResources().getString(R.string.join), - "", getResources().getString(R.string.cancel), CometChatUI.this, 1, false); - } else if (group.getGroupType().equals(CometChatConstants.GROUP_TYPE_PUBLIC)) { - joinGroup(group); + FeatureRestriction.isGroupChatEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + group = g; + if (group.isJoined()) { + startGroupIntent(group); + } else { + if (group.getGroupType().equals(CometChatConstants.GROUP_TYPE_PASSWORD)) { + View dialogview = getLayoutInflater().inflate(R.layout.cc_dialog, null); + TextView tvTitle = dialogview.findViewById(R.id.textViewDialogueTitle); + tvTitle.setText(String.format(getResources().getString(R.string.enter_password_to_join),group.getName())); + new CustomAlertDialogHelper(CometChatUI.this, getResources().getString(R.string.password), dialogview, getResources().getString(R.string.join), + "", getResources().getString(R.string.cancel), CometChatUI.this, 1, false); + } else if (group.getGroupType().equals(CometChatConstants.GROUP_TYPE_PUBLIC)) { + joinGroup(group); + } + } + } - } + }); } }); } @@ -162,7 +176,13 @@ private void setUserClickListener() { CometChatUserList.setItemClickListener(new OnItemClickListener() { @Override public void OnItemClick(User user, int position) { - startUserIntent(user); + FeatureRestriction.isOneOnOneChatEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (booleanVal) + startUserIntent(user); + } + }); } }); } @@ -186,9 +206,9 @@ 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()); + if (FeatureRestriction.getColor()!=null && !FeatureRestriction.getColor().isEmpty()) { + getWindow().setStatusBarColor(Color.parseColor(FeatureRestriction.getColor())); + int widgetColor = Color.parseColor(FeatureRestriction.getColor()); ColorStateList colorStateList = new ColorStateList(new int[][] { { -android.R.attr.state_selected }, {} }, new int[] { Color.GRAY, widgetColor }); @@ -196,30 +216,63 @@ private void initViewComponent() { } // 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()); + FeatureRestriction.isConversationListEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + isConversationVisible = booleanVal; + activityCometChatUnifiedBinding.bottomNavigation.getMenu().findItem(R.id.menu_conversation) + .setVisible(booleanVal); + } + }); + FeatureRestriction.isUserListEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + isUserListVisible = booleanVal; + activityCometChatUnifiedBinding.bottomNavigation.getMenu().findItem(R.id.menu_users) + .setVisible(booleanVal); + } + }); + + FeatureRestriction.isGroupListEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + isGroupsListVisible = booleanVal; + activityCometChatUnifiedBinding.bottomNavigation.getMenu().findItem(R.id.menu_group) + .setVisible(booleanVal); + + } + }); + + FeatureRestriction.isCallListEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + isCallsListVisible = booleanVal; + activityCometChatUnifiedBinding.bottomNavigation.getMenu().findItem(R.id.menu_call) + .setVisible(booleanVal); + } + }); + + FeatureRestriction.isUserSettingsEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + isSettingsVisible = booleanVal; + activityCometChatUnifiedBinding.bottomNavigation.getMenu().findItem(R.id.menu_more) + .setVisible(booleanVal); + } + }); badgeDrawable.setVisible(false); - if (UISettings.isShowChatsBB()) + if (isConversationVisible) loadFragment(new CometChatConversationList()); - else if (UISettings.isShowCallsBB()) + else if (isCallsListVisible) loadFragment(new CometChatCallList()); - else if (UISettings.isShowUsersBB()) + else if (isUserListVisible) loadFragment(new CometChatUserList()); - else if (UISettings.isShowGroupsBB()) + else if (isGroupsListVisible) loadFragment(new CometChatGroupList()); - else if (UISettings.isShowUserSettingsBB()) + else if (isSettingsVisible) loadFragment(new CometChatUserProfile()); - } /** @@ -231,30 +284,35 @@ else if (UISettings.isShowUserSettingsBB()) * */ private void joinGroup(Group group) { - 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); - } - - @Override - public void onError(CometChatException e) { - if (progressDialog != null) - progressDialog.dismiss(); - - CometChatSnackBar.show(CometChatUI.this, - activityCometChatUnifiedBinding.bottomNavigation, - CometChatError.localized(e),CometChatSnackBar.ERROR); + FeatureRestriction.isJoinOrLeaveGroupEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (booleanVal) { + progressDialog = ProgressDialog.show(CometChatUI.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); + } + + @Override + public void onError(CometChatException e) { + if (progressDialog != null) + progressDialog.dismiss(); + + CometChatSnackBar.show(CometChatUI.this, + activityCometChatUnifiedBinding.bottomNavigation, + CometChatError.localized(e), CometChatSnackBar.ERROR); + } + }); } - }); - } + } + }); } /** @@ -275,27 +333,34 @@ private boolean loadFragment(Fragment fragment) { * @see CometChat#getUnreadMessageCount(CometChat.CallbackListener) */ public void getUnreadConversationCount() { - CometChat.getUnreadMessageCount(new CometChat.CallbackListener>>() { + FeatureRestriction.isUnreadCountEnabled(new FeatureRestriction.OnSuccessListener() { @Override - public void onSuccess(HashMap> stringHashMapHashMap) { - Log.e(TAG, "onSuccess: " + stringHashMapHashMap); - unreadCount.clear(); - unreadCount.addAll(stringHashMapHashMap.get("user").keySet()); //Add users whose messages are unread. - unreadCount.addAll(stringHashMapHashMap.get("group").keySet()); //Add groups whose messages are unread. - - if (unreadCount.size() == 0) { - badgeDrawable.setVisible(false); - } else { - badgeDrawable.setVisible(true); + public void onSuccess(Boolean booleanVal) { + if (booleanVal) { + CometChat.getUnreadMessageCount(new CometChat.CallbackListener>>() { + @Override + public void onSuccess(HashMap> stringHashMapHashMap) { + Log.e(TAG, "onSuccess: " + stringHashMapHashMap); + unreadCount.clear(); + unreadCount.addAll(stringHashMapHashMap.get("user").keySet()); //Add users whose messages are unread. + unreadCount.addAll(stringHashMapHashMap.get("group").keySet()); //Add groups whose messages are unread. + + if (unreadCount.size() == 0) { + badgeDrawable.setVisible(false); + } else { + badgeDrawable.setVisible(true); + } + if (unreadCount.size() != 0) { + badgeDrawable.setNumber(unreadCount.size()); //add total count of users and groups whose messages are unread in BadgeDrawable + } + } + + @Override + public void onError(CometChatException e) { + Log.e("CometChatUI : onError: ", e.getMessage()); //Logs the error if the error occurs. + } + }); } - if (unreadCount.size() != 0) { - badgeDrawable.setNumber(unreadCount.size()); //add total count of users and groups whose messages are unread in BadgeDrawable - } - } - - @Override - public void onError(CometChatException e) { - Log.e("CometChatUI : onError: ", e.getMessage()); //Logs the error if the error occurs. } }); } @@ -369,6 +434,7 @@ private void startUserIntent(User user) { intent.putExtra(UIKitConstants.IntentStrings.AVATAR, user.getAvatar()); intent.putExtra(UIKitConstants.IntentStrings.STATUS, user.getStatus()); intent.putExtra(UIKitConstants.IntentStrings.NAME, user.getName()); + intent.putExtra(UIKitConstants.IntentStrings.LINK,user.getLink()); intent.putExtra(UIKitConstants.IntentStrings.TYPE, CometChatConstants.RECEIVER_TYPE_USER); startActivity(intent); } @@ -477,4 +543,14 @@ public static ActivityCometchatUnifiedBinding getBinding() { public static AppCompatActivity getCometChatUIActivity() { return activity; } + + public static void setLocale(Activity activity, String languageCode) { + Locale locale = new Locale(languageCode); + Locale.setDefault(locale); + Resources resources = activity.getResources(); + Configuration config = resources.getConfiguration(); + config.setLocale(locale); + resources.updateConfiguration(config, resources.getDisplayMetrics()); + } + } \ No newline at end of file diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/add_members/CometChatAddMembers.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/add_members/CometChatAddMembers.java index ae8a973..5932691 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/add_members/CometChatAddMembers.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/add_members/CometChatAddMembers.java @@ -94,7 +94,7 @@ public void init(View view) etSearch = view.findViewById(R.id.search_bar); toolbar = view.findViewById(R.id.add_member_toolbar); - + CometChatError.init(getContext()); setToolbar(toolbar); checkDarkMode(); @@ -167,6 +167,7 @@ public void onClick(View var1, int var2) { intent.putExtra(UIKitConstants.IntentStrings.NAME, user.getName()); intent.putExtra(UIKitConstants.IntentStrings.AVATAR, user.getAvatar()); intent.putExtra(UIKitConstants.IntentStrings.STATUS, user.getStatus()); + intent.putExtra(UIKitConstants.IntentStrings.LINK,user.getLink()); intent.putExtra(UIKitConstants.IntentStrings.IS_BLOCKED_BY_ME, user.isBlockedByMe()); intent.putExtra(UIKitConstants.IntentStrings.TYPE, CometChatConstants.RECEIVER_TYPE_GROUP); intent.putExtra(UIKitConstants.IntentStrings.GUID, guid); @@ -231,7 +232,6 @@ private void fetchUsers() { int LIMIT = 30; usersRequest = new UsersRequest.UsersRequestBuilder().setLimit(LIMIT).build(); } - makeUserRequest(usersRequest); } diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/add_members/CometChatAddMembersActivity.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/add_members/CometChatAddMembersActivity.java index 9266516..3fa7c43 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/add_members/CometChatAddMembersActivity.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/add_members/CometChatAddMembersActivity.java @@ -12,7 +12,7 @@ import com.cometchat.pro.uikit.R; import com.cometchat.pro.uikit.ui_resources.constants.UIKitConstants; -import com.cometchat.pro.uikit.ui_settings.UISettings; +import com.cometchat.pro.uikit.ui_settings.FeatureRestriction; public class CometChatAddMembersActivity extends AppCompatActivity { @@ -23,8 +23,8 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_screen); handleIntent(); - if (UISettings.getColor()!=null) - getWindow().setStatusBarColor(Color.parseColor(UISettings.getColor())); + if (FeatureRestriction.getColor()!=null) + getWindow().setStatusBarColor(Color.parseColor(FeatureRestriction.getColor())); } private void handleIntent() { diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/admin_moderator_list/CometChatAdminModeratorList.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/admin_moderator_list/CometChatAdminModeratorList.java index 7bfb7b4..9695990 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/admin_moderator_list/CometChatAdminModeratorList.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/admin_moderator_list/CometChatAdminModeratorList.java @@ -1,5 +1,6 @@ package com.cometchat.pro.uikit.ui_components.groups.admin_moderator_list; +import android.app.ProgressDialog; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; @@ -17,7 +18,6 @@ import android.view.ViewGroup; import android.widget.RelativeLayout; import android.widget.TextView; -import android.widget.Toast; import com.cometchat.pro.constants.CometChatConstants; import com.cometchat.pro.core.CometChat; @@ -32,7 +32,6 @@ import com.cometchat.pro.uikit.ui_resources.utils.CometChatError; import com.google.android.material.appbar.MaterialToolbar; import com.google.android.material.dialog.MaterialAlertDialogBuilder; -import com.google.android.material.snackbar.Snackbar; import java.util.ArrayList; import java.util.Arrays; @@ -111,6 +110,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, addAs = view.findViewById(R.id.add_as_tv); MaterialToolbar toolbar = view.findViewById(R.id.admin_toolbar); setToolbar(toolbar); + CometChatError.init(getContext()); if (showModerators) { toolbar.setTitle(getResources().getString(R.string.moderators)); addAs.setText(getResources().getString(R.string.assign_as_moderator)); @@ -227,24 +227,34 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) { } private void updateMemberScope(GroupMember groupMember, View view) { + ProgressDialog progressDialog; + if (showModerators) + progressDialog = ProgressDialog.show(getContext(),null, + groupMember.getName()+" "+ + getResources().getString(R.string.remove_from_moderator_privilege)); + else + progressDialog = ProgressDialog.show(getContext(),null, + groupMember.getName()+" "+ + getResources().getString(R.string.removed_from_admin)); CometChat.updateGroupMemberScope(groupMember.getUid(), guid, CometChatConstants.SCOPE_PARTICIPANT, new CometChat.CallbackListener() { @Override public void onSuccess(String s) { + progressDialog.dismiss(); if (adapter != null) adapter.removeGroupMember(groupMember); - if (showModerators) { - CometChatSnackBar.show(getContext(),view, - groupMember.getName()+" "+getResources().getString(R.string.remove_from_moderator_privilege), - CometChatSnackBar.SUCCESS); - } - else { - CometChatSnackBar.show(getContext(),view, - groupMember.getName()+" "+ - getResources().getString(R.string.removed_from_admin), - CometChatSnackBar.SUCCESS); - } +// if (showModerators) { +// CometChatSnackBar.show(getContext(),view, +// groupMember.getName()+" "+getResources().getString(R.string.remove_from_moderator_privilege), +// CometChatSnackBar.SUCCESS); +// } +// else { +// CometChatSnackBar.show(getContext(),view, +// groupMember.getName()+" "+ +// getResources().getString(R.string.removed_from_admin), +// CometChatSnackBar.SUCCESS); +// } } @Override diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/admin_moderator_list/CometChatAdminModeratorListActivity.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/admin_moderator_list/CometChatAdminModeratorListActivity.java index 900cc55..add9ea4 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/admin_moderator_list/CometChatAdminModeratorListActivity.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/admin_moderator_list/CometChatAdminModeratorListActivity.java @@ -12,7 +12,7 @@ import com.cometchat.pro.uikit.R; import com.cometchat.pro.uikit.ui_resources.constants.UIKitConstants; -import com.cometchat.pro.uikit.ui_settings.UISettings; +import com.cometchat.pro.uikit.ui_settings.FeatureRestriction; public class CometChatAdminModeratorListActivity extends AppCompatActivity { @@ -29,8 +29,8 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_screen); handleIntent(); - if (UISettings.getColor()!=null) - getWindow().setStatusBarColor(Color.parseColor(UISettings.getColor())); + if (FeatureRestriction.getColor()!=null) + getWindow().setStatusBarColor(Color.parseColor(FeatureRestriction.getColor())); } private void handleIntent() { diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/banned_members/CometChatBanMembers.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/banned_members/CometChatBanMembers.java index edfeb18..4756663 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/banned_members/CometChatBanMembers.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/banned_members/CometChatBanMembers.java @@ -1,5 +1,6 @@ package com.cometchat.pro.uikit.ui_components.groups.banned_members; +import android.app.ProgressDialog; import android.os.Bundle; import android.view.ContextMenu; import android.view.LayoutInflater; @@ -51,6 +52,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, groupMemberAdapter = new GroupMemberAdapter(getContext()); bannedMemberRv.setAdapter(groupMemberAdapter); handleArguments(); + CometChatError.init(getContext()); getBannedMembers(); bannedMemberRv.addOnItemTouchListener(new RecyclerTouchListener(getContext(), bannedMemberRv, new ClickListener() { @Override @@ -124,12 +126,16 @@ public boolean onContextItemSelected(@NonNull MenuItem item) { } private void unBanMember() { + ProgressDialog progressDialog = ProgressDialog.show(getContext(),null, + groupMember.getName()+" "+ + getResources().getString(R.string.unbanned_successfully)); CometChat.unbanGroupMember(groupMember.getUid(), guid, new CometChat.CallbackListener() { @Override public void onSuccess(String s) { - if (bannedMemberRv!=null) - CometChatSnackBar.show(getContext(),bannedMemberRv, - groupMember.getName()+" "+getResources().getString(R.string.unbanned_successfully),CometChatSnackBar.SUCCESS); + progressDialog.dismiss(); +// if (bannedMemberRv!=null) +// CometChatSnackBar.show(getContext(),bannedMemberRv, +// ,CometChatSnackBar.SUCCESS); groupMemberAdapter.removeGroupMember(groupMember); } diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/banned_members/CometChatBanMembersActivity.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/banned_members/CometChatBanMembersActivity.java index 54a1f15..4867131 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/banned_members/CometChatBanMembersActivity.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/banned_members/CometChatBanMembersActivity.java @@ -13,7 +13,7 @@ import com.google.android.material.appbar.MaterialToolbar; import com.cometchat.pro.uikit.ui_resources.constants.UIKitConstants; -import com.cometchat.pro.uikit.ui_settings.UISettings; +import com.cometchat.pro.uikit.ui_settings.FeatureRestriction; public class CometChatBanMembersActivity extends AppCompatActivity { @@ -32,8 +32,8 @@ public void onClick(View v) { } }); handleIntent(); - if (UISettings.getColor()!=null) - getWindow().setStatusBarColor(Color.parseColor(UISettings.getColor())); + if (FeatureRestriction.getColor()!=null) + getWindow().setStatusBarColor(Color.parseColor(FeatureRestriction.getColor())); CometChatBanMembers banFragment = new CometChatBanMembers(); Bundle bundle = new Bundle(); bundle.putString(UIKitConstants.IntentStrings.GUID,guid); diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/create_group/CometChatCreateGroup.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/create_group/CometChatCreateGroup.java index 8fbe38c..f158b5e 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/create_group/CometChatCreateGroup.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/create_group/CometChatCreateGroup.java @@ -2,6 +2,7 @@ import androidx.fragment.app.Fragment; +import android.app.ProgressDialog; import android.content.Intent; import android.content.res.ColorStateList; import android.os.Bundle; @@ -12,6 +13,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; +import android.widget.ArrayAdapter; import android.widget.Spinner; import android.widget.TextView; @@ -22,11 +24,13 @@ import com.cometchat.pro.uikit.R; import com.cometchat.pro.uikit.ui_components.shared.CometChatSnackBar; import com.cometchat.pro.uikit.ui_resources.utils.CometChatError; +import com.cometchat.pro.uikit.ui_settings.FeatureRestriction; import com.google.android.material.button.MaterialButton; import com.google.android.material.textfield.TextInputEditText; import com.google.android.material.textfield.TextInputLayout; import java.security.SecureRandom; +import java.util.ArrayList; import com.cometchat.pro.uikit.ui_components.messages.message_list.CometChatMessageListActivity; import com.cometchat.pro.uikit.ui_resources.constants.UIKitConstants; @@ -56,6 +60,8 @@ public class CometChatCreateGroup extends Fragment { private MaterialButton createGroupBtn; + private ArrayList types = new ArrayList<>(); + private Spinner groupTypeSpinner; private String groupType; @@ -67,7 +73,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view= inflater.inflate(R.layout.fragment_cometchat_create_group, container, false); - + types.add(getString(R.string.public_group)); + types.add(getString(R.string.private_group)); + types.add(getString(R.string.password_protected_group)); etGroupName = view.findViewById(R.id.group_name); etGroupDesc = view.findViewById(R.id.group_desc); etGroupPassword = view.findViewById(R.id.group_pwd); @@ -95,6 +103,7 @@ public void afterTextChanged(Editable s) { des2 = view.findViewById(R.id.tvDes2); + CometChatError.init(getContext()); groupNameLayout = view.findViewById(R.id.input_group_name); groupDescLayout = view.findViewById(R.id.input_group_desc); groupPasswordLayout = view.findViewById(R.id.input_group_pwd); @@ -123,6 +132,38 @@ public void onNothingSelected(AdapterView parent) { } }); + + ArrayAdapter adapter = new ArrayAdapter( + getContext(),android.R.layout.simple_list_item_1 ,types); + + FeatureRestriction.isPublicGroupEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (!booleanVal) { + types.remove(getString(R.string.public_group)); + adapter.notifyDataSetChanged(); + } + } + }); + + FeatureRestriction.isPrivateGroupEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (!booleanVal) { + types.remove(getString(R.string.private_group)); + adapter.notifyDataSetChanged(); } + } + }); + + FeatureRestriction.isPasswordGroupEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (!booleanVal) { + types.remove(getString(R.string.password_protected_group)); + adapter.notifyDataSetChanged(); } + } + }); + groupTypeSpinner.setAdapter(adapter); createGroupBtn = view.findViewById(R.id.btn_create_group); createGroupBtn.setOnClickListener(new View.OnClickListener() { @@ -206,9 +247,12 @@ else if(etGroupPassword.getText().toString().equals(etGroupCnfPassword.getText() } private void createGroup(Group group) { + ProgressDialog progressDialog = ProgressDialog.show(getContext(),null, + getString(R.string.creating_group)); CometChat.createGroup(group, new CometChat.CallbackListener() { @Override public void onSuccess(Group group) { + progressDialog.dismiss(); Intent intent = new Intent(getActivity(), CometChatMessageListActivity.class); intent.putExtra(UIKitConstants.IntentStrings.NAME,group.getName()); intent.putExtra(UIKitConstants.IntentStrings.GROUP_OWNER,group.getOwner()); diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/create_group/CometChatCreateGroupActivity.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/create_group/CometChatCreateGroupActivity.java index d7c6144..3b02b83 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/create_group/CometChatCreateGroupActivity.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/create_group/CometChatCreateGroupActivity.java @@ -11,7 +11,7 @@ import com.cometchat.pro.uikit.R; -import com.cometchat.pro.uikit.ui_settings.UISettings; +import com.cometchat.pro.uikit.ui_settings.FeatureRestriction; public class CometChatCreateGroupActivity extends AppCompatActivity { @@ -26,8 +26,8 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_screen); Fragment fragment = new CometChatCreateGroup(); getSupportFragmentManager().beginTransaction().replace(R.id.frame_fragment,fragment).commit(); - if (UISettings.getColor()!=null) - getWindow().setStatusBarColor(Color.parseColor(UISettings.getColor())); + if (FeatureRestriction.getColor()!=null) + getWindow().setStatusBarColor(Color.parseColor(FeatureRestriction.getColor())); } diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/group_details/CometChatGroupDetailActivity.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/group_details/CometChatGroupDetailActivity.java index 88d5b72..78ec891 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/group_details/CometChatGroupDetailActivity.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/group_details/CometChatGroupDetailActivity.java @@ -6,6 +6,7 @@ import androidx.recyclerview.widget.RecyclerView; import android.app.AlertDialog; +import android.app.ProgressDialog; import android.content.DialogInterface; import android.content.Intent; import android.content.res.ColorStateList; @@ -65,11 +66,9 @@ import com.cometchat.pro.uikit.ui_components.groups.group_members.CometChatGroupMemberListActivity; import com.cometchat.pro.uikit.ui_resources.utils.CallUtils; import com.cometchat.pro.uikit.ui_resources.utils.FontUtils; -import com.cometchat.pro.uikit.ui_settings.UISettings; +import com.cometchat.pro.uikit.ui_settings.FeatureRestriction; import com.cometchat.pro.uikit.ui_resources.utils.Utils; -import okhttp3.internal.Util; - import static com.cometchat.pro.uikit.ui_resources.utils.Utils.UserToGroupMember; @@ -143,10 +142,6 @@ public class CometChatGroupDetailActivity extends AppCompatActivity { private LinearLayout sharedMediaLayout; - private ImageView videoCallBtn; - - private ImageView callBtn; - private TextView dividerAdmin,dividerBan,dividerModerator,divider2; private BannedGroupMembersRequest banMemberRequest; @@ -159,6 +154,7 @@ protected void onCreate(Bundle savedInstanceState) { fontUtils= FontUtils.getInstance(this); initComponent(); + CometChatError.init(this); } private void initComponent() { @@ -184,8 +180,6 @@ public void onClick(View v) { tvLoadMore = findViewById(R.id.tv_load_more); tvLoadMore.setText(String.format(getResources().getString(R.string.load_more_members),LIMIT)); TextView tvAddMember = findViewById(R.id.tv_add_member); - callBtn = findViewById(R.id.callBtn_iv); - videoCallBtn = findViewById(R.id.video_callBtn_iv); rlBanMembers = findViewById(R.id.rlBanView); rlBanMembers.setOnClickListener(new View.OnClickListener() { @Override @@ -272,58 +266,68 @@ public void onClick(View view) { tvExit.setOnClickListener(view -> createDialog(getResources().getString(R.string.leave_group), getResources().getString(R.string.leave_group_message), getResources().getString(R.string.leave_group), getResources().getString(R.string.cancel), R.drawable.ic_exit_to_app)); - callBtn.setOnClickListener(view -> { - callBtn.setClickable(false); - checkOnGoingCall(CometChatConstants.CALL_TYPE_AUDIO); - }); - - videoCallBtn.setOnClickListener(view -> { - videoCallBtn.setClickable(false); - checkOnGoingCall(CometChatConstants.CALL_TYPE_VIDEO); - }); tvDelete.setOnClickListener(view -> createDialog(getResources().getString(R.string.delete_group), getResources().getString(R.string.delete_group_message), - getResources().getString(R.string.delete_group), getResources().getString(R.string.cancel), R.drawable.ic_delete_24dp)); + getResources().getString(R.string.delete_group), getResources().getString(R.string.cancel), R.drawable.ic_delete)); // - if (!UISettings.isJoinOrLeaveGroup()) - tvExit.setVisibility(View.GONE); - - if (!UISettings.isAllowDeleteGroups()) - tvDelete.setVisibility(View.GONE); - - if (!UISettings.isViewSharedMedia()) { - sharedMediaLayout.setVisibility(View.GONE); - } + FeatureRestriction.isJoinOrLeaveGroupEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (!booleanVal) + tvExit.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); - } + FeatureRestriction.isGroupDeletionEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (!booleanVal) + tvDelete.setVisibility(View.GONE); + } + }); - callBtn.setVisibility(View.GONE); - videoCallBtn.setVisibility(View.GONE); + FeatureRestriction.isSharedMediaEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (!booleanVal) { + sharedMediaLayout.setVisibility(View.GONE); + } + } + }); - if (!UISettings.isAllowBanKickMembers()) - rlBanMembers.setVisibility(View.GONE); + FeatureRestriction.isViewGroupMemberInGroupDetails(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (!booleanVal) { + rvMemberList.setVisibility(View.GONE); + tvLoadMore.setVisibility(View.GONE); + rlAddMemberView.setVisibility(View.GONE); + tvMemberCount.setVisibility(View.GONE); + divider2.setVisibility(View.GONE); + } + } + }); + FeatureRestriction.isChangingMemberScopeEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (!booleanVal) { + rlModeratorView.setVisibility(View.GONE); + rlAdminListView.setVisibility(View.GONE); + dividerAdmin.setVisibility(View.GONE); + dividerModerator.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()))); - } + FeatureRestriction.isBanningGroupMembersEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (!booleanVal) + rlBanMembers.setVisibility(View.GONE); + } + }); } private void checkDarkMode() { @@ -344,29 +348,6 @@ private void checkDarkMode() { } } - private void checkOnGoingCall(String callType) { - if(CometChat.getActiveCall()!=null && CometChat.getActiveCall().getCallStatus().equals(CometChatConstants.CALL_STATUS_ONGOING) && CometChat.getActiveCall().getSessionId()!=null) { - AlertDialog.Builder alert = new AlertDialog.Builder(this); - alert.setTitle(getResources().getString(R.string.ongoing_call)) - .setMessage(getResources().getString(R.string.ongoing_call_message)) - .setPositiveButton(getResources().getString(R.string.join), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - CallUtils.joinOnGoingCall(CometChatGroupDetailActivity.this,CometChat.getActiveCall()); - } - }).setNegativeButton(getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - callBtn.setClickable(true); - videoCallBtn.setClickable(true); - dialog.dismiss(); - } - }).create().show(); - } - else { - CallUtils.initiateCall(CometChatGroupDetailActivity.this,guid, CometChatConstants.RECEIVER_TYPE_GROUP,callType); - } - } @Override public boolean onCreateOptionsMenu(Menu menu) { @@ -571,36 +552,46 @@ public void openAdminListScreen(boolean showModerators) { * @see CometChatAddMembersActivity */ public void addMembers() { - if (UISettings.isAllowAddMembers()) { - Intent intent = new Intent(this, CometChatAddMembersActivity.class); - intent.putExtra(UIKitConstants.IntentStrings.GUID, guid); - intent.putExtra(UIKitConstants.IntentStrings.GROUP_MEMBER, groupMemberUids); - intent.putExtra(UIKitConstants.IntentStrings.GROUP_NAME, gName); - intent.putExtra(UIKitConstants.IntentStrings.MEMBER_SCOPE, loggedInUserScope); - intent.putExtra(UIKitConstants.IntentStrings.IS_ADD_MEMBER, true); - startActivity(intent); - } + FeatureRestriction.isAddingGroupMembersEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (booleanVal) { + Intent intent = new Intent(CometChatGroupDetailActivity.this, CometChatAddMembersActivity.class); + intent.putExtra(UIKitConstants.IntentStrings.GUID, guid); + intent.putExtra(UIKitConstants.IntentStrings.GROUP_MEMBER, groupMemberUids); + intent.putExtra(UIKitConstants.IntentStrings.GROUP_NAME, gName); + intent.putExtra(UIKitConstants.IntentStrings.MEMBER_SCOPE, loggedInUserScope); + intent.putExtra(UIKitConstants.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() { - if (UISettings.isAllowDeleteGroups()) { - CometChat.deleteGroup(guid, new CometChat.CallbackListener() { - @Override - public void onSuccess(String s) { - launchUnified(); - } + FeatureRestriction.isGroupDeletionEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (booleanVal) { + CometChat.deleteGroup(guid, new CometChat.CallbackListener() { + @Override + public void onSuccess(String s) { + launchUnified(); + } - @Override - public void onError(CometChatException e) { - CometChatSnackBar.show(CometChatGroupDetailActivity.this, - rvMemberList, CometChatError.localized(e),CometChatSnackBar.ERROR); - Log.e(TAG, "onError: " + e.getMessage()); + @Override + public void onError(CometChatException e) { + CometChatSnackBar.show(CometChatGroupDetailActivity.this, + rvMemberList, CometChatError.localized(e),CometChatSnackBar.ERROR); + Log.e(TAG, "onError: " + e.getMessage()); + } + }); } - }); - } + } + }); } private void launchUnified() { @@ -617,9 +608,13 @@ private void launchUnified() { * @see CometChat#kickGroupMember(String, String, CometChat.CallbackListener) */ private void kickMember() { + ProgressDialog progressDialog = ProgressDialog.show(CometChatGroupDetailActivity.this, + null, + String.format(getString(R.string.user_removed_from_group),groupMember.getName(),gName)); CometChat.kickGroupMember(groupMember.getUid(), guid, new CometChat.CallbackListener() { @Override public void onSuccess(String s) { + progressDialog.dismiss(); Log.e(TAG, "onSuccess: " + s); tvMemberCount.setText((groupMemberCount-1)+" "+getString(R.string.members)); groupMemberUids.remove(groupMember.getUid()); @@ -642,9 +637,13 @@ public void onError(CometChatException e) { * @see CometChat#banGroupMember(String, String, CometChat.CallbackListener) */ private void banMember() { + ProgressDialog progressDialog = ProgressDialog.show(CometChatGroupDetailActivity.this, + null, + groupMember.getName()+" "+getString(R.string.banned_successfully)); CometChat.banGroupMember(groupMember.getUid(), guid, new CometChat.CallbackListener() { @Override public void onSuccess(String s) { + progressDialog.dismiss(); Log.e(TAG, "onSuccess: " + s); tvMemberCount.setText((groupMemberCount-1)+" "+getString(R.string.members)); // int count = Integer.parseInt(tvBanMemberCount.getText().toString()); @@ -765,21 +764,26 @@ public void onUserOffline(User user) { * @see CometChat#leaveGroup(String, CometChat.CallbackListener) */ private void leaveGroup() { - if (UISettings.isJoinOrLeaveGroup()) { - CometChat.leaveGroup(guid, new CometChat.CallbackListener() { - @Override - public void onSuccess(String s) { - launchUnified(); - } + FeatureRestriction.isJoinOrLeaveGroupEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (booleanVal) { + CometChat.leaveGroup(guid, new CometChat.CallbackListener() { + @Override + public void onSuccess(String s) { + launchUnified(); + } - @Override - public void onError(CometChatException e) { - CometChatSnackBar.show(CometChatGroupDetailActivity.this, - rlAddMemberView, CometChatError.localized(e), CometChatSnackBar.ERROR); - Log.e(TAG, "onError: " + e.getMessage()); - } - }); - } + @Override + public void onError(CometChatException e) { + CometChatSnackBar.show(CometChatGroupDetailActivity.this, + rlAddMemberView, CometChatError.localized(e), CometChatSnackBar.ERROR); + Log.e(TAG, "onError: " + e.getMessage()); + } + }); + } + } + }); } /** @@ -1107,13 +1111,22 @@ protected void onResume() { } // getBannedMemberCount(); - if (UISettings.isShowUserPresence()) - getUserStatus(); - if (UISettings.isViewGroupMember()) - getGroupMembers(); + FeatureRestriction.isUserPresenceEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (booleanVal) + getUserStatus(); + } + }); + + FeatureRestriction.isViewGroupMemberInGroupDetails(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (booleanVal) + getGroupMembers(); + } + }); addGroupListener(); - callBtn.setClickable(true); - videoCallBtn.setClickable(true); } diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/group_list/CometChatGroupList.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/group_list/CometChatGroupList.java index de3de48..d1e9582 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/group_list/CometChatGroupList.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/group_list/CometChatGroupList.java @@ -10,7 +10,6 @@ import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.RecyclerView; -import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import android.text.Editable; import android.text.TextWatcher; @@ -31,9 +30,7 @@ import com.cometchat.pro.core.CometChat; import com.cometchat.pro.core.GroupsRequest; import com.cometchat.pro.exceptions.CometChatException; -import com.cometchat.pro.helpers.CometChatHelper; import com.cometchat.pro.models.Action; -import com.cometchat.pro.models.Conversation; import com.cometchat.pro.models.User; import com.cometchat.pro.uikit.R; import com.cometchat.pro.models.Group; @@ -47,8 +44,9 @@ import com.cometchat.pro.uikit.ui_resources.utils.item_clickListener.OnItemClickListener; import com.cometchat.pro.uikit.ui_components.groups.create_group.CometChatCreateGroupActivity; import com.cometchat.pro.uikit.ui_resources.utils.FontUtils; -import com.cometchat.pro.uikit.ui_settings.UISettings; +import com.cometchat.pro.uikit.ui_settings.FeatureRestriction; import com.cometchat.pro.uikit.ui_resources.utils.Utils; +import com.cometchat.pro.uikit.ui_settings.UIKitSettings; /* @@ -77,12 +75,14 @@ public class CometChatGroupList extends Fragment { private LinearLayout noGroupLayout; - private SwipeRefreshLayout swipeRefreshLayout; - private List groupList = new ArrayList<>(); private static final String TAG = "CometChatGroupList"; + private boolean isPublicGroupEnabled; + private boolean isPrivateGroupEnabled; + private boolean isPasswordGroupEnabled; + public CometChatGroupList() { // Required empty public constructor } @@ -98,15 +98,30 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, noGroupLayout = view.findViewById(R.id.no_group_layout); etSearch = view.findViewById(R.id.search_bar); clearSearch = view.findViewById(R.id.clear_search); - swipeRefreshLayout = view.findViewById(R.id.swipeToRefresh); + CometChatError.init(getContext()); ivCreateGroup = view.findViewById(R.id.create_group); - ivCreateGroup.setImageTintList(ColorStateList.valueOf(Color.parseColor(UISettings.getColor()))); + ivCreateGroup.setImageTintList(ColorStateList.valueOf(Color.parseColor(FeatureRestriction.getColor()))); - if(UISettings.isGroupCreate()) - ivCreateGroup.setVisibility(View.VISIBLE); - else - ivCreateGroup.setVisibility(View.GONE); + FeatureRestriction.isGroupSearchEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (booleanVal) + etSearch.setVisibility(View.VISIBLE); + else + etSearch.setVisibility(View.GONE); + } + }); + FeatureRestriction.isGroupCreationEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (booleanVal) + ivCreateGroup.setVisibility(View.VISIBLE); + else + ivCreateGroup.setVisibility(View.GONE); + + } + }); if(Utils.isDarkMode(getContext())) { title.setTextColor(getResources().getColor(R.color.textColorWhite)); @@ -114,6 +129,28 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, title.setTextColor(getResources().getColor(R.color.primaryTextColor)); } + FeatureRestriction.isPublicGroupEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + isPublicGroupEnabled = booleanVal; + checkGroups(); + } + }); + FeatureRestriction.isPrivateGroupEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + isPrivateGroupEnabled = booleanVal; + checkGroups(); + } + }); + FeatureRestriction.isPasswordGroupEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + isPasswordGroupEnabled = booleanVal; + checkGroups(); + } + }); + ivCreateGroup.setOnClickListener(view1 -> { Intent intent = new Intent(getContext(), CometChatCreateGroupActivity.class); startActivity(intent); @@ -187,17 +224,15 @@ public void OnItemClick(Group group, int position) { event.OnItemClick(group,position); } }); - swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { - @Override - public void onRefresh() { - groupsRequest=null; - rvGroupList.clear(); - fetchGroup(); - } - }); return view; } + private void checkGroups() { + if (isPublicGroupEnabled || isPasswordGroupEnabled || isPrivateGroupEnabled) { + ivCreateGroup.setVisibility(View.VISIBLE); + } else + ivCreateGroup.setVisibility(View.GONE); + } @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); @@ -217,8 +252,7 @@ private void fetchGroup(){ groupsRequest.fetchNext(new CometChat.CallbackListener>() { @Override public void onSuccess(List groups) { - List filteredList = filterGroup(groups); - rvGroupList.setGroupList(filteredList); // sets the groups in rvGroupList i.e CometChatGroupList Component. + rvGroupList.setGroupList(groups); // sets the groups in rvGroupList i.e CometChatGroupList Component. groupList.addAll(groups); if (groupList.size()==0) { noGroupLayout.setVisibility(View.VISIBLE); @@ -227,8 +261,6 @@ public void onSuccess(List groups) { noGroupLayout.setVisibility(View.GONE); rvGroupList.setVisibility(View.VISIBLE); } - if (swipeRefreshLayout.isRefreshing()) - swipeRefreshLayout.setRefreshing(false); } @Override public void onError(CometChatException e) { @@ -244,15 +276,15 @@ private List filterGroup(List groups) { if (group.isJoined()) { resultList.add(group); } - if (UISettings.getGroupListing() + if (UIKitSettings.getGroupsMode().toString() .equalsIgnoreCase("public_groups") && group.getGroupType().equalsIgnoreCase(CometChatConstants.GROUP_TYPE_PUBLIC)) { resultList.add(group); - } else if (UISettings.getGroupListing() + } else if (UIKitSettings.getGroupsMode().toString() .equalsIgnoreCase("password_protected_groups") && group.getGroupType().equalsIgnoreCase(CometChatConstants.GROUP_TYPE_PASSWORD)) { resultList.add(group); - } else if (UISettings.getGroupListing() + } else if (UIKitSettings.getGroupsMode().toString() .equalsIgnoreCase("public_and_password_protected_groups")) { resultList.add(group); } diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/group_members/CometChatGroupMemberListActivity.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/group_members/CometChatGroupMemberListActivity.java index 9d93d9a..f792fdf 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/group_members/CometChatGroupMemberListActivity.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/groups/group_members/CometChatGroupMemberListActivity.java @@ -12,7 +12,7 @@ import com.cometchat.pro.uikit.R; import com.cometchat.pro.uikit.ui_resources.constants.UIKitConstants; -import com.cometchat.pro.uikit.ui_settings.UISettings; +import com.cometchat.pro.uikit.ui_settings.FeatureRestriction; public class CometChatGroupMemberListActivity extends AppCompatActivity { @@ -42,8 +42,8 @@ protected void onCreate(Bundle savedInstanceState) { bundle.putBoolean(UIKitConstants.IntentStrings.TRANSFER_OWNERSHIP,transferOwnerShip); fragment.setArguments(bundle); getSupportFragmentManager().beginTransaction().replace(R.id.frame_fragment,fragment).commit(); - if (UISettings.getColor()!=null) - getWindow().setStatusBarColor(Color.parseColor(UISettings.getColor())); + if (FeatureRestriction.getColor()!=null) + getWindow().setStatusBarColor(Color.parseColor(FeatureRestriction.getColor())); } diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/extensions/Collaborative/CometChatCollaborativeActivity.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/extensions/Collaborative/CometChatWebViewActivity.java similarity index 59% rename from uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/extensions/Collaborative/CometChatCollaborativeActivity.java rename to uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/extensions/Collaborative/CometChatWebViewActivity.java index f098932..7bc087d 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/extensions/Collaborative/CometChatCollaborativeActivity.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/extensions/Collaborative/CometChatWebViewActivity.java @@ -3,8 +3,11 @@ import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; +import android.view.View; import android.webkit.WebSettings; import android.webkit.WebView; +import android.webkit.WebViewClient; +import android.widget.ImageView; import com.cometchat.pro.uikit.R; @@ -17,22 +20,40 @@ * Created On - 26 November 2020 * */ -public class CometChatCollaborativeActivity extends AppCompatActivity { +public class CometChatWebViewActivity extends AppCompatActivity { private WebView webView; private String url = null; + private ImageView mBackIcon; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_cometchat_webview); webView = findViewById(R.id.webview); + mBackIcon = findViewById(R.id.back_icon); + mBackIcon.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + onBackPressed(); + } + }); if (getIntent().hasExtra(UIKitConstants.IntentStrings.URL)) { url = getIntent().getStringExtra(UIKitConstants.IntentStrings.URL); } if (url!=null) { WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptEnabled(true); + webSettings.setAppCacheEnabled(true); + webView.setWebViewClient(new WebViewClient() + { + @Override + public boolean shouldOverrideUrlLoading(WebView view, String url) + { + //view.loadUrl(url); + return false; + } + }); webView.loadUrl(url); } } diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/extensions/Extensions.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/extensions/Extensions.java index ed0e6b7..18085a0 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/extensions/Extensions.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/extensions/Extensions.java @@ -20,20 +20,31 @@ import java.util.List; import java.util.Locale; -import com.cometchat.pro.uikit.R; -import com.cometchat.pro.uikit.ui_components.messages.extensions.Collaborative.CometChatCollaborativeActivity; +import com.cometchat.pro.uikit.ui_components.messages.extensions.Collaborative.CometChatWebViewActivity; import com.cometchat.pro.uikit.ui_components.shared.cometchatReaction.ReactionUtils; import com.cometchat.pro.uikit.ui_components.shared.cometchatReaction.model.Reaction; import com.cometchat.pro.uikit.ui_components.shared.cometchatStickers.model.Sticker; import com.cometchat.pro.uikit.ui_resources.constants.UIKitConstants; import com.cometchat.pro.uikit.ui_resources.utils.CometChatError; -import com.cometchat.pro.uikit.ui_resources.utils.Utils; -import com.google.android.material.snackbar.Snackbar; +import com.cometchat.pro.uikit.ui_settings.Feature; public class Extensions { private static final String TAG = "Extensions"; + private static String linkPreview = Feature.Extension.linkPreview; + private static String smartReply = Feature.Extension.smartReply; + private static String imageModeration = Feature.Extension.imageModeration; + private static String thumbnailGeneration = Feature.Extension.thumbnailGeneration; + private static String dataMasking = Feature.Extension.dataMasking; + private static String reactions = Feature.Extension.reactions; + private static String polls = Feature.Extension.polls; + private static String profanityFilter = Feature.Extension.profanityFilter; + private static String whiteboard = Feature.Extension.whiteboard; + private static String document = Feature.Extension.document; + private static String sentimentAnalysis = Feature.Extension.sentimentalAnalysis; + private static String messageTranslation = Feature.Extension.messageTranslation; + private static String stickers = Feature.Extension.stickers; public static boolean getImageModeration(Context context, BaseMessage baseMessage) { boolean result = false; @@ -107,47 +118,47 @@ public static HashMap extensionCheck(BaseMessage baseMessage) JSONObject injectedObject = metadata.getJSONObject("@injected"); if (injectedObject != null && injectedObject.has("extensions")) { JSONObject extensionsObject = injectedObject.getJSONObject("extensions"); - if (extensionsObject != null && extensionsObject.has("link-preview")) { - JSONObject linkPreviewObject = extensionsObject.getJSONObject("link-preview"); + if (extensionsObject != null && extensionsObject.has(linkPreview)) { + JSONObject linkPreviewObject = extensionsObject.getJSONObject(linkPreview); JSONArray linkPreview = linkPreviewObject.getJSONArray("links"); if (linkPreview.length() > 0) { extensionMap.put("linkPreview",linkPreview.getJSONObject(0)); } } - if (extensionsObject !=null && extensionsObject.has("smart-reply")) { - extensionMap.put("smartReply",extensionsObject.getJSONObject("smart-reply")); + if (extensionsObject !=null && extensionsObject.has(smartReply)) { + extensionMap.put("smartReply",extensionsObject.getJSONObject(smartReply)); } - if (extensionsObject!=null && extensionsObject.has("message-translation")) { - extensionMap.put("messageTranslation",extensionsObject.getJSONObject("message-translation")); + if (extensionsObject!=null && extensionsObject.has(messageTranslation)) { + extensionMap.put("messageTranslation",extensionsObject.getJSONObject(messageTranslation)); } - if (extensionsObject!=null && extensionsObject.has("profanity-filter")) { - extensionMap.put("profanityFilter",extensionsObject.getJSONObject("profanity-filter")); + if (extensionsObject!=null && extensionsObject.has(profanityFilter)) { + extensionMap.put("profanityFilter",extensionsObject.getJSONObject(profanityFilter)); } - if (extensionsObject!=null && extensionsObject.has("image-moderation")) { - extensionMap.put("imageModeration",extensionsObject.getJSONObject("image-moderation")); + if (extensionsObject!=null && extensionsObject.has(imageModeration)) { + extensionMap.put("imageModeration",extensionsObject.getJSONObject(imageModeration)); } - if (extensionsObject!=null && extensionsObject.has("thumbnail-generator")) { - extensionMap.put("thumbnailGeneration",extensionsObject.getJSONObject("thumbnail-generator")); + if (extensionsObject!=null && extensionsObject.has(thumbnailGeneration)) { + extensionMap.put("thumbnailGeneration",extensionsObject.getJSONObject(thumbnailGeneration)); } - if (extensionsObject!=null && extensionsObject.has("sentiment-analysis")) { - extensionMap.put("sentimentAnalysis",extensionsObject.getJSONObject("sentiment-analysis")); + if (extensionsObject!=null && extensionsObject.has(sentimentAnalysis)) { + extensionMap.put("sentimentAnalysis",extensionsObject.getJSONObject(sentimentAnalysis)); } - if (extensionsObject!=null && extensionsObject.has("polls")) { - extensionMap.put("polls",extensionsObject.getJSONObject("polls")); + if (extensionsObject!=null && extensionsObject.has(polls)) { + extensionMap.put("polls",extensionsObject.getJSONObject(polls)); } - if (extensionsObject!=null && extensionsObject.has("reactions")) { - if (extensionsObject.get("reactions") instanceof JSONObject) - extensionMap.put("reactions",extensionsObject.getJSONObject("reactions")); + if (extensionsObject!=null && extensionsObject.has(reactions)) { + if (extensionsObject.get(reactions) instanceof JSONObject) + extensionMap.put("reactions",extensionsObject.getJSONObject(reactions)); } - if (extensionsObject!=null && extensionsObject.has("whiteboard")) { - extensionMap.put("whiteboard",extensionsObject.getJSONObject("whiteboard")); + if (extensionsObject!=null && extensionsObject.has(whiteboard)) { + extensionMap.put("whiteboard",extensionsObject.getJSONObject(whiteboard)); } - if (extensionsObject!=null && extensionsObject.has("document")) { - extensionMap.put("document",extensionsObject.getJSONObject("document")); + if (extensionsObject!=null && extensionsObject.has(document)) { + extensionMap.put("document",extensionsObject.getJSONObject(document)); } - if (extensionsObject!=null && extensionsObject.has("data-masking")) { - extensionMap.put("dataMasking",extensionsObject.getJSONObject("data-masking")); + if (extensionsObject!=null && extensionsObject.has(dataMasking)) { + extensionMap.put("dataMasking",extensionsObject.getJSONObject(dataMasking)); } } return extensionMap; @@ -308,7 +319,7 @@ public static ArrayList getVoterInfo(BaseMessage baseMessage,int totalOp } public static void fetchStickers(ExtensionResponseListener extensionResponseListener) { - if(CometChat.isExtensionEnabled("stickers")) { + if(CometChat.isExtensionEnabled(stickers)) { CometChat.callExtension("stickers", "GET", "/v1/fetch", null, new CometChat.CallbackListener() { @Override public void onSuccess(JSONObject jsonObject) { @@ -523,7 +534,7 @@ public static void openWhiteBoard(BaseMessage baseMessage, Context context) { String userName = CometChat.getLoggedInUser().getName().replace("//s+","_"); boardUrl = boardUrl+"&username="+userName; Log.e(TAG, "openWhiteBoard: after "+boardUrl); - Intent intent = new Intent(context, CometChatCollaborativeActivity.class); + Intent intent = new Intent(context, CometChatWebViewActivity.class); intent.putExtra(UIKitConstants.IntentStrings.URL, boardUrl); context.startActivity(intent); } @@ -541,7 +552,7 @@ public static void openWriteBoard(BaseMessage baseMessage, Context context) { JSONObject whiteBoardData = extensionCheck.get("document"); if (whiteBoardData.has("document_url")) { boardUrl = whiteBoardData.getString("document_url"); - Intent intent = new Intent(context, CometChatCollaborativeActivity.class); + Intent intent = new Intent(context, CometChatWebViewActivity.class); intent.putExtra(UIKitConstants.IntentStrings.URL, boardUrl); context.startActivity(intent); } diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/forward_message/CometChatForwardMessageActivity.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/forward_message/CometChatForwardMessageActivity.java index 60fa69a..31a41b9 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/forward_message/CometChatForwardMessageActivity.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/forward_message/CometChatForwardMessageActivity.java @@ -15,7 +15,6 @@ import android.view.inputmethod.InputMethodManager; import android.widget.EditText; import android.widget.ImageView; -import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -38,8 +37,16 @@ import com.cometchat.pro.models.TextMessage; import com.cometchat.pro.models.User; import com.cometchat.pro.uikit.R; +import com.cometchat.pro.uikit.ui_components.cometchat_ui.CometChatUI; import com.cometchat.pro.uikit.ui_components.shared.CometChatSnackBar; +import com.cometchat.pro.uikit.ui_components.shared.cometchatConversations.CometChatConversations; +import com.cometchat.pro.uikit.ui_components.shared.cometchatConversations.CometChatConversationsAdapter; +import com.cometchat.pro.uikit.ui_resources.constants.UIKitConstants; import com.cometchat.pro.uikit.ui_resources.utils.CometChatError; +import com.cometchat.pro.uikit.ui_resources.utils.FontUtils; +import com.cometchat.pro.uikit.ui_resources.utils.MediaUtils; +import com.cometchat.pro.uikit.ui_resources.utils.Utils; +import com.cometchat.pro.uikit.ui_resources.utils.item_clickListener.OnItemClickListener; import com.google.android.material.appbar.MaterialToolbar; import com.google.android.material.button.MaterialButton; import com.google.android.material.chip.Chip; @@ -49,23 +56,10 @@ import org.json.JSONObject; import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import com.cometchat.pro.uikit.ui_components.cometchat_ui.CometChatUI; -import com.cometchat.pro.uikit.ui_components.shared.cometchatConversations.CometChatConversations; -import com.cometchat.pro.uikit.ui_components.shared.cometchatConversations.CometChatConversationsAdapter; -import com.cometchat.pro.uikit.ui_resources.constants.UIKitConstants; -import com.cometchat.pro.uikit.ui_resources.utils.item_clickListener.OnItemClickListener; -import com.cometchat.pro.uikit.ui_resources.utils.FontUtils; -import com.cometchat.pro.uikit.ui_resources.utils.MediaUtils; -import com.cometchat.pro.uikit.ui_resources.utils.Utils; - /** * Purpose - CometChatForwardMessageScreenActivity class is a fragment used to display list of users to which * we will forward the message. @@ -80,7 +74,7 @@ public class CometChatForwardMessageActivity extends AppCompatActivity { private CometChatConversations rvConversationList; - private HashMap userList = new HashMap<>(); + private HashMap userList = new HashMap<>(); private CometChatConversationsAdapter conversationListAdapter; @@ -132,12 +126,21 @@ void handleSendText(Intent intent) { void handleSendImage(Intent intent) { Uri imageUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM); if (imageUri != null) { - messageType = UIKitConstants.IntentStrings.INTENT_MEDIA_MESSAGE; + messageType = UIKitConstants.IntentStrings.INTENT_MEDIA_IMAGE_MESSAGE; mediaMessageUrl = imageUri.toString(); Log.e(TAG, "handleSendImage: "+mediaMessageUrl+"\n"+imageUri.getHost()); } } + void handleSendVideo(Intent intent) { + Uri videoUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM); + if (videoUri!=null) { + messageType = UIKitConstants.IntentStrings.INTENT_MEDIA_VIDEO_MESSAGE; + mediaMessageUrl = videoUri.toString(); + Log.e(TAG, "handleSendVideo: "+mediaMessageUrl); + } + } + /** * This method is used to handle parameter passed to this class. */ @@ -153,6 +156,8 @@ private void handleIntent() { handleSendText(intent); // Handle text being sent } else if (type.startsWith("image/")) { handleSendImage(intent); // Handle single image being sent + } else if (type.startsWith("video/")) { + handleSendVideo(intent); } } @@ -268,7 +273,7 @@ public void OnItemClick(Conversation conversation, int position) { avatar = ((Group) conversation.getConversationWith()).getIcon(); } chip.setText(name); - Glide.with(CometChatForwardMessageActivity.this).load(avatar).placeholder(R.drawable.ic_contacts).transform(new CircleCrop()).into(new SimpleTarget() { + Glide.with(CometChatForwardMessageActivity.this).load(avatar).placeholder(R.drawable.ic_contacts_24dp).transform(new CircleCrop()).into(new SimpleTarget() { @Override public void onResourceReady(@NonNull Drawable resource, @Nullable Transition transition) { chip.setChipIcon(resource); @@ -291,7 +296,7 @@ public void onClick(View vw) { else { CometChatSnackBar.show(CometChatForwardMessageActivity.this, selectedUsers, - getString(R.string.forward_to_5_at_a_time),CometChatSnackBar.WARNING); + getString(R.string.forward_to_5_at_a_time), CometChatSnackBar.WARNING); } } @@ -328,7 +333,7 @@ public void onClick(View view) { } }).start(); - } else if (messageType != null && !messageType.equals(UIKitConstants.IntentStrings.INTENT_MEDIA_MESSAGE)) { + } else if (messageType != null && messageType.equals(CometChatConstants.MESSAGE_TYPE_IMAGE)) { new Thread(() -> { for (int i = 0; i <= userList.size() - 1; i++) { Conversation conversation = new ArrayList<>(userList.values()).get(i); @@ -362,7 +367,7 @@ public void onClick(View view) { } }).start(); - } else { + } else if (messageType!=null && messageType.equalsIgnoreCase(UIKitConstants.IntentStrings.INTENT_MEDIA_IMAGE_MESSAGE)){ new Thread(() -> { for (int i = 0; i <= userList.size() - 1; i++) { Conversation conversation = new ArrayList<>(userList.values()).get(i); @@ -377,7 +382,9 @@ public void onClick(View view) { uid = ((Group) conversation.getConversationWith()).getGuid(); type = CometChatConstants.RECEIVER_TYPE_GROUP; } - File file = MediaUtils.getRealPath(CometChatForwardMessageActivity.this, Uri.parse(mediaMessageUrl)); + File file = MediaUtils.getRealPath( + CometChatForwardMessageActivity.this, + Uri.parse(mediaMessageUrl),true); message = new MediaMessage(uid, file, CometChatConstants.MESSAGE_TYPE_IMAGE, type); try { JSONObject jsonObject = new JSONObject(); @@ -397,6 +404,43 @@ public void onClick(View view) { }).start(); } + else if (messageType!=null && messageType.equalsIgnoreCase(UIKitConstants.IntentStrings.INTENT_MEDIA_VIDEO_MESSAGE)){ + new Thread(() -> { + for (int i = 0; i <= userList.size() - 1; i++) { + Conversation conversation = new ArrayList<>(userList.values()).get(i); + MediaMessage message; + String uid; + String type; + Log.e(TAG, "run: " + conversation.getConversationId()); + if (conversation.getConversationType().equals(CometChatConstants.CONVERSATION_TYPE_USER)) { + uid = ((User) conversation.getConversationWith()).getUid(); + type = CometChatConstants.RECEIVER_TYPE_USER; + } else { + uid = ((Group) conversation.getConversationWith()).getGuid(); + type = CometChatConstants.RECEIVER_TYPE_GROUP; + } + File file = MediaUtils.saveDriveFile( + CometChatForwardMessageActivity.this, + Uri.parse(mediaMessageUrl)); + message = new MediaMessage(uid, file, CometChatConstants.MESSAGE_TYPE_VIDEO, type); + try { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("path", mediaMessageUrl); + message.setMetadata(jsonObject); + } catch (Exception e) { + Log.e(TAG, "onError: " + e.getMessage()); + } + sendMediaMessage(message); + if (i == userList.size() - 1) { + Intent intent = new Intent(CometChatForwardMessageActivity.this, CometChatUI.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); + startActivity(intent); + finish(); + } + } + + }).start(); + } } else { if (messageType!=null && messageType.equalsIgnoreCase(UIKitConstants.IntentStrings.LOCATION)) { new Thread(() -> { diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/media_view/CometChatMediaViewActivity.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/media_view/CometChatMediaViewActivity.java index c663aac..c807727 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/media_view/CometChatMediaViewActivity.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/media_view/CometChatMediaViewActivity.java @@ -33,7 +33,7 @@ public class CometChatMediaViewActivity extends AppCompatActivity { - private ZoomImageView imageMessage; + private ImageView imageMessage; private VideoView videoMessage; private Toolbar toolbar; private String senderName; @@ -58,7 +58,7 @@ protected void onCreate(Bundle savedInstanceState) { toolbar = findViewById(R.id.toolbar); toolbar.getNavigationIcon().setTint(getResources().getColor(R.color.textColorWhite)); toolbar.setTitle(senderName); - toolbar.setSubtitle(Utils.getLastMessageDate(sentAt)); + toolbar.setSubtitle(Utils.getLastMessageDate(this,sentAt)); imageMessage = findViewById(R.id.image_message); videoMessage = findViewById(R.id.video_message); audioMessage = findViewById(R.id.audio_message); @@ -66,17 +66,7 @@ protected void onCreate(Bundle savedInstanceState) { playBtn = findViewById(R.id.playBtn); if (mediaType.equals(CometChatConstants.MESSAGE_TYPE_IMAGE)) { Glide.with(this).asBitmap().load(mediaUrl) - .diskCacheStrategy(DiskCacheStrategy.NONE).into(new CustomTarget() { - @Override - public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition transition) { - imageMessage.setImageBitmap(resource); - } - - @Override - public void onLoadCleared(@Nullable Drawable placeholder) { - - } - }); + .diskCacheStrategy(DiskCacheStrategy.NONE).into(imageMessage); imageMessage.setVisibility(View.VISIBLE); } else if (mediaType.equals(CometChatConstants.MESSAGE_TYPE_VIDEO)) { MediaController mediacontroller = new MediaController(this); diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/message_actions/CometChatMessageActions.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/message_actions/CometChatMessageActions.java index cdd48dd..80f62e0 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/message_actions/CometChatMessageActions.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/message_actions/CometChatMessageActions.java @@ -48,9 +48,7 @@ public class CometChatMessageActions extends BottomSheetDialogFragment { private TextView translateMessage; private TextView retryMessage; - private RelativeLayout messagePrivately; - private CometChatAvatar senderAvatar; - private TextView senderName; + private TextView messagePrivately; private String userName; private String userAvatar; @@ -86,8 +84,6 @@ public void onCreate(Bundle savedInstanceState) { private void fetchArguments() { if (getArguments()!=null) { isPrivateReplyVisible = getArguments().getBoolean("privateReplyVisible"); - userAvatar = getArguments().getString("userAvatar"); - userName = getArguments().getString("userName"); isCopyVisible = getArguments().getBoolean("copyVisible"); isThreadVisible = getArguments().getBoolean("threadVisible"); isEditVisible = getArguments().getBoolean("editVisible"); @@ -121,8 +117,7 @@ public void onGlobalLayout() { } }); - messagePrivately = view.findViewById(R.id.message_privately_layout); - senderAvatar = view.findViewById(R.id.sender_avatar); + messagePrivately = view.findViewById(R.id.reply_privately); if ((userName!=null && userName.isEmpty()) || (userAvatar!=null && userAvatar.isEmpty())) @@ -132,7 +127,6 @@ public void onGlobalLayout() { messagePrivately.setVisibility(View.VISIBLE); else messagePrivately.setVisibility(View.GONE); - senderAvatar.setAvatar(userAvatar); } messagePrivately.setOnClickListener(v-> { diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/message_information/CometChatMessageInfoScreenActivity.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/message_information/CometChatMessageInfoScreenActivity.java index a4ce964..e334178 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/message_information/CometChatMessageInfoScreenActivity.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/message_information/CometChatMessageInfoScreenActivity.java @@ -32,7 +32,7 @@ import com.cometchat.pro.uikit.ui_resources.constants.UIKitConstants; import com.cometchat.pro.uikit.ui_resources.utils.Utils; -import com.cometchat.pro.uikit.ui_components.messages.extensions.Collaborative.CometChatCollaborativeActivity; +import com.cometchat.pro.uikit.ui_components.messages.extensions.Collaborative.CometChatWebViewActivity; public class CometChatMessageInfoScreenActivity extends AppCompatActivity { @@ -246,7 +246,7 @@ private void handleIntent() { @Override public void onClick(View view) { String boardUrl = getIntent().getStringExtra(UIKitConstants.IntentStrings.TEXTMESSAGE); - Intent intent = new Intent(CometChatMessageInfoScreenActivity.this, CometChatCollaborativeActivity.class); + Intent intent = new Intent(CometChatMessageInfoScreenActivity.this, CometChatWebViewActivity.class); intent.putExtra(UIKitConstants.IntentStrings.URL, boardUrl); startActivity(intent); } @@ -258,7 +258,7 @@ public void onClick(View view) { @Override public void onClick(View view) { String boardUrl = getIntent().getStringExtra(UIKitConstants.IntentStrings.TEXTMESSAGE); - Intent intent = new Intent(CometChatMessageInfoScreenActivity.this, CometChatCollaborativeActivity.class); + Intent intent = new Intent(CometChatMessageInfoScreenActivity.this, CometChatWebViewActivity.class); intent.putExtra(UIKitConstants.IntentStrings.URL, boardUrl); startActivity(intent); } diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/message_information/Message_Receipts/CometChatReceiptsAdapter.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/message_information/Message_Receipts/CometChatReceiptsAdapter.java index 9ea7b3b..1c05a08 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/message_information/Message_Receipts/CometChatReceiptsAdapter.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/message_information/Message_Receipts/CometChatReceiptsAdapter.java @@ -43,9 +43,9 @@ public void onBindViewHolder(@NonNull ReceiptsHolder receiptsHolder, int i) { receiptsHolder.tvName.setText(messageReceipt.getSender().getName()); if (messageReceipt.getReadAt()!=0) - receiptsHolder.tvRead.setText(Utils.getReceiptDate(messageReceipt.getReadAt())); + receiptsHolder.tvRead.setText(Utils.getReceiptDate(context,messageReceipt.getReadAt())); if (messageReceipt.getDeliveredAt()!=0) - receiptsHolder.tvDelivery.setText(Utils.getReceiptDate(messageReceipt.getDeliveredAt())); + receiptsHolder.tvDelivery.setText(Utils.getReceiptDate(context,messageReceipt.getDeliveredAt())); if (messageReceipt.getSender().getAvatar()!=null) receiptsHolder.ivAvatar.setAvatar(messageReceipt.getSender().getAvatar()); else diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/message_list/CometChatMessageList.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/message_list/CometChatMessageList.java index 1868660..7e6c18c 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/message_list/CometChatMessageList.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/message_list/CometChatMessageList.java @@ -59,6 +59,7 @@ 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; import com.cometchat.pro.core.CometChat; import com.cometchat.pro.core.GroupMembersRequest; import com.cometchat.pro.core.MessagesRequest; @@ -74,21 +75,41 @@ import com.cometchat.pro.models.TextMessage; import com.cometchat.pro.models.TypingIndicator; import com.cometchat.pro.models.User; - +import com.cometchat.pro.uikit.R; +import com.cometchat.pro.uikit.ui_components.groups.group_details.CometChatGroupDetailActivity; +import com.cometchat.pro.uikit.ui_components.messages.extensions.ExtensionResponseListener; import com.cometchat.pro.uikit.ui_components.messages.extensions.Extensions; import com.cometchat.pro.uikit.ui_components.messages.forward_message.CometChatForwardMessageActivity; +import com.cometchat.pro.uikit.ui_components.messages.live_reaction.LiveReactionListener; +import com.cometchat.pro.uikit.ui_components.messages.live_reaction.ReactionClickListener; import com.cometchat.pro.uikit.ui_components.messages.message_actions.CometChatMessageActions; import com.cometchat.pro.uikit.ui_components.messages.message_actions.listener.MessageActionCloseListener; +import com.cometchat.pro.uikit.ui_components.messages.message_actions.listener.OnMessageLongClick; +import com.cometchat.pro.uikit.ui_components.messages.message_information.CometChatMessageInfoScreenActivity; +import com.cometchat.pro.uikit.ui_components.messages.thread_message_list.CometChatThreadMessageListActivity; import com.cometchat.pro.uikit.ui_components.shared.CometChatSnackBar; +import com.cometchat.pro.uikit.ui_components.shared.cometchatAvatar.CometChatAvatar; import com.cometchat.pro.uikit.ui_components.shared.cometchatComposeBox.CometChatComposeBox; -import com.cometchat.pro.uikit.R; -import com.cometchat.pro.uikit.ui_components.shared.cometchatReaction.listener.OnReactionClickListener; +import com.cometchat.pro.uikit.ui_components.shared.cometchatComposeBox.listener.ComposeActionListener; import com.cometchat.pro.uikit.ui_components.shared.cometchatReaction.CometChatReactionDialog; +import com.cometchat.pro.uikit.ui_components.shared.cometchatReaction.listener.OnReactionClickListener; import com.cometchat.pro.uikit.ui_components.shared.cometchatReaction.model.Reaction; +import com.cometchat.pro.uikit.ui_components.shared.cometchatSmartReplies.CometChatSmartReplies; import com.cometchat.pro.uikit.ui_components.shared.cometchatStickers.StickerView; import com.cometchat.pro.uikit.ui_components.shared.cometchatStickers.listener.StickerClickListener; import com.cometchat.pro.uikit.ui_components.shared.cometchatStickers.model.Sticker; +import com.cometchat.pro.uikit.ui_components.users.user_details.CometChatUserDetailScreenActivity; +import com.cometchat.pro.uikit.ui_resources.constants.UIKitConstants; +import com.cometchat.pro.uikit.ui_resources.utils.CallUtils; import com.cometchat.pro.uikit.ui_resources.utils.CometChatError; +import com.cometchat.pro.uikit.ui_resources.utils.FontUtils; +import com.cometchat.pro.uikit.ui_resources.utils.MediaUtils; +import com.cometchat.pro.uikit.ui_resources.utils.Utils; +import com.cometchat.pro.uikit.ui_resources.utils.item_clickListener.OnItemClickListener; +import com.cometchat.pro.uikit.ui_resources.utils.keyboard_utils.KeyBoardUtils; +import com.cometchat.pro.uikit.ui_resources.utils.pattern_utils.PatternUtils; +import com.cometchat.pro.uikit.ui_resources.utils.sticker_header.StickyHeaderDecoration; +import com.cometchat.pro.uikit.ui_settings.FeatureRestriction; import com.facebook.shimmer.ShimmerFrameLayout; import com.google.android.gms.location.FusedLocationProviderClient; import com.google.android.gms.location.LocationServices; @@ -109,28 +130,6 @@ import java.util.Timer; import java.util.TimerTask; -import com.cometchat.pro.uikit.ui_components.groups.group_details.CometChatGroupDetailActivity; -import com.cometchat.pro.uikit.ui_components.shared.cometchatAvatar.CometChatAvatar; -import com.cometchat.pro.uikit.ui_components.shared.cometchatSmartReplies.CometChatSmartReplies; -import com.cometchat.pro.uikit.ui_components.users.user_details.CometChatUserDetailScreenActivity; -import com.cometchat.pro.uikit.ui_resources.constants.UIKitConstants; -import com.cometchat.pro.uikit.ui_components.shared.cometchatComposeBox.listener.ComposeActionListener; -import com.cometchat.pro.uikit.ui_components.messages.extensions.ExtensionResponseListener; -import com.cometchat.pro.uikit.ui_components.messages.live_reaction.LiveReactionListener; -import com.cometchat.pro.uikit.ui_resources.utils.item_clickListener.OnItemClickListener; -import com.cometchat.pro.uikit.ui_components.messages.message_actions.listener.OnMessageLongClick; -import com.cometchat.pro.uikit.ui_components.messages.live_reaction.ReactionClickListener; -import com.cometchat.pro.uikit.ui_resources.utils.pattern_utils.PatternUtils; -import com.cometchat.pro.uikit.ui_resources.utils.sticker_header.StickyHeaderDecoration; -import com.cometchat.pro.uikit.ui_resources.utils.CallUtils; -import com.cometchat.pro.uikit.ui_resources.utils.FontUtils; -import com.cometchat.pro.uikit.ui_resources.utils.keyboard_utils.KeyBoardUtils; -import com.cometchat.pro.uikit.ui_resources.utils.MediaUtils; -import com.cometchat.pro.uikit.ui_resources.utils.Utils; -import com.cometchat.pro.uikit.ui_settings.UISettings; -import com.cometchat.pro.uikit.ui_components.messages.message_information.CometChatMessageInfoScreenActivity; -import com.cometchat.pro.uikit.ui_components.messages.thread_message_list.CometChatThreadMessageListActivity; - import static android.app.Activity.RESULT_OK; import static android.view.View.GONE; @@ -201,6 +200,8 @@ public class CometChatMessageList extends Fragment implements View.OnClickListen private String avatarUrl; + private String profileLink; + private Toolbar toolbar; private String type; @@ -299,6 +300,27 @@ public class CometChatMessageList extends Fragment implements View.OnClickListen private TextView newMessageLayoutText; private int newMessageCount = 0; + boolean shareVisible; + boolean copyVisible; + boolean forwardVisible; + boolean threadVisible; + boolean replyVisible; + boolean translateVisible; + boolean reactionVisible; + boolean editVisible; + boolean retryVisible = false; + boolean replyPrivately; + boolean deleteVisible; + + + boolean hideDeleteMessage; + + private ImageView infoAction; + private ImageView audioCallAction; + private ImageView videoCallAction; + + private ImageView backIcon; + public CometChatMessageList() { // Required empty public constructor } @@ -320,6 +342,7 @@ private void handleArguments() { avatarUrl = getArguments().getString(UIKitConstants.IntentStrings.AVATAR); status = getArguments().getString(UIKitConstants.IntentStrings.STATUS); name = getArguments().getString(UIKitConstants.IntentStrings.NAME); + profileLink = getArguments().getString(UIKitConstants.IntentStrings.LINK); type = getArguments().getString(UIKitConstants.IntentStrings.TYPE); if (type != null && type.equals(CometChatConstants.RECEIVER_TYPE_GROUP)) { Id = getArguments().getString(UIKitConstants.IntentStrings.GUID); @@ -348,6 +371,18 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa private void initViewComponent(View view) { setHasOptionsMenu(true); + + CometChatError.init(getContext()); + backIcon = view.findViewById(R.id.back_action); + infoAction = view.findViewById(R.id.info_action); + audioCallAction = view.findViewById(R.id.audio_call_action); + videoCallAction = view.findViewById(R.id.video_call_action); + + backIcon.setOnClickListener(this); + infoAction.setOnClickListener(this); + audioCallAction.setOnClickListener(this); + videoCallAction.setOnClickListener(this); + bottomLayout = view.findViewById(R.id.bottom_layout); messageShimmer = view.findViewById(R.id.shimmer_layout); composeBox = view.findViewById(R.id.message_box); @@ -356,8 +391,7 @@ private void initViewComponent(View view) { composeBox.hideGroupCallOption(true); setComposeBoxListener(); - if (UISettings.isEnableSendingMessage()) - composeBox.setVisibility(View.VISIBLE); + composeBox.setVisibility(View.VISIBLE); container = view.findViewById(R.id.reactions_container); composeBox.liveReactionBtn.setOnTouchListener(new LiveReactionListener(700, 1000, new ReactionClickListener() { @@ -470,8 +504,6 @@ public void onClickListener(Sticker sticker) { rvChatListView.setLayoutManager(linearLayoutManager); - ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar); - ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); if (Utils.isDarkMode(context)) { bottomLayout.setBackgroundColor(getResources().getColor(R.color.darkModeBackground)); toolbar.setBackgroundColor(getResources().getColor(R.color.grey)); @@ -501,13 +533,18 @@ public void onClickListener(Sticker sticker) { composeBox.ivMic.setVisibility(GONE); composeBox.ivSend.setVisibility(View.VISIBLE); }else { - if (UISettings.isSendVoiceNotes()) { - composeBox.ivMic.setVisibility(View.VISIBLE); - composeBox.ivSend.setVisibility(GONE); - } else { - composeBox.ivMic.setVisibility(GONE); - composeBox.ivSend.setVisibility(View.VISIBLE); - } + FeatureRestriction.isVoiceNotesEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (booleanVal) { + composeBox.ivMic.setVisibility(View.VISIBLE); + composeBox.ivSend.setVisibility(GONE); + } else { + composeBox.ivMic.setVisibility(GONE); + composeBox.ivSend.setVisibility(View.VISIBLE); + } + } + }); } } }); @@ -548,6 +585,7 @@ public void OnItemClick(String var, int position) { } } }); + fetchSettings(); //Check Ongoing Call onGoingCallView = view.findViewById(R.id.ongoing_call_view); @@ -556,6 +594,51 @@ public void OnItemClick(String var, int position) { checkOnGoingCall(); } + private void checkOnGoingCall(String callType) { + if(CometChat.getActiveCall()!=null && CometChat.getActiveCall().getCallStatus().equals(CometChatConstants.CALL_STATUS_ONGOING) && CometChat.getActiveCall().getSessionId()!=null) { + AlertDialog.Builder alert = new AlertDialog.Builder(context); + alert.setTitle(getResources().getString(R.string.ongoing_call)) + .setMessage(getResources().getString(R.string.ongoing_call_message)) + .setPositiveButton(getResources().getString(R.string.join), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + CallUtils.joinOnGoingCall(context,CometChat.getActiveCall()); + } + }).setNegativeButton(getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); + audioCallAction.setClickable(true); + videoCallAction.setClickable(true); + } + }).create().show(); + } + else { + Call call = null; + if (type.equalsIgnoreCase(CometChatConstants.RECEIVER_TYPE_GROUP)) + call = new Call(Id, CometChatConstants.RECEIVER_TYPE_GROUP,callType); + else + call = new Call(Id, CometChatConstants.RECEIVER_TYPE_USER,callType); + CometChat.initiateCall(call, new CometChat.CallbackListener() { + @Override + public void onSuccess(Call call) { + CallUtils.startCallIntent(context, + ((User)call.getCallReceiver()),call.getType(),true, + call.getSessionId()); + } + + @Override + public void onError(CometChatException e) { + audioCallAction.setClickable(true); + videoCallAction.setClickable(true); + Log.e(TAG, "onError: "+e.getMessage()); + CometChatSnackBar.show(context, + rvChatListView, + CometChatError.localized(e),CometChatSnackBar.ERROR); + } + }); + } + } /** * This method is used to check if the app has ongoing call or not and based on it show the view * through which user can join ongoing call. @@ -692,30 +775,35 @@ public void onSendActionClicked(EditText editText) { String filterEmojiMessage = PatternUtils.removeEmojiAndSymbol(message); editText.setText(""); editText.setHint(getString(R.string.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(); + FeatureRestriction.isEmojisEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (!booleanVal) { + 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 (isEdit) { + editMessage(baseMessage, message); + editMessageLayout.setVisibility(GONE); + } else if (isReply) { + replyMessage(baseMessage, message); + replyMessageLayout.setVisibility(GONE); + } else if (!message.isEmpty()) + sendMessage(message); + } } - } 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 @@ -758,7 +846,7 @@ public void OnResponseSuccess(Object var) { } @Override public void OnResponseFailed(CometChatException e) { - CometChatSnackBar.show(context,stickersView,CometChatError.localized(e),CometChatSnackBar.ERROR); + CometChatSnackBar.show(context,stickersView, CometChatError.localized(e), CometChatSnackBar.ERROR); } }); } @@ -773,7 +861,7 @@ public void OnResponseSuccess(Object var) { @Override public void OnResponseFailed(CometChatException e) { - CometChatSnackBar.show(context,rvChatListView,CometChatError.localized(e),CometChatSnackBar.ERROR); + CometChatSnackBar.show(context,rvChatListView, CometChatError.localized(e), CometChatSnackBar.ERROR); } }); } @@ -788,28 +876,16 @@ public void OnResponseSuccess(Object var) { @Override public void OnResponseFailed(CometChatException e) { - CometChatSnackBar.show(context,rvChatListView,CometChatError.localized(e),CometChatSnackBar.ERROR); + CometChatSnackBar.show(context,rvChatListView, CometChatError.localized(e), CometChatSnackBar.ERROR); } }); } - @Override - public void onVideoMeetingClicked() { - JSONObject customData = new JSONObject(); - try { - customData.put("callType", CometChatConstants.CALL_TYPE_VIDEO); - customData.put("sessionID",Id); - } catch (JSONException e) { - e.printStackTrace(); - } - sendCustomMessage(UIKitConstants.IntentStrings.GROUP_CALL,customData); - - } }); } private void createPollDialog() { - AlertDialog.Builder alertDialog = new AlertDialog.Builder(context,R.style.MyDialogTheme); + AlertDialog.Builder alertDialog = new AlertDialog.Builder(context, R.style.MyDialogTheme); View view = LayoutInflater.from(context).inflate(R.layout.add_polls_layout,null); alertDialog.setView(view); Dialog dialog = alertDialog.create(); @@ -822,7 +898,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())); + addPoll.setBackgroundColor(Color.parseColor(FeatureRestriction.getColor())); ImageView cancelPoll = view.findViewById(R.id.close_poll); addOption.setOnClickListener(new View.OnClickListener() { @Override @@ -886,7 +962,7 @@ public void onError(CometChatException e) { if (view!=null) CometChatSnackBar.show(context,view, CometChatError.Extension.localized(e,"polls") - ,CometChatSnackBar.ERROR); + , CometChatSnackBar.ERROR); } }); } catch (Exception e) { @@ -943,7 +1019,7 @@ private void initAlert(JSONObject customData) { e.printStackTrace(); } TextView address = view.findViewById(R.id.address); - address.setText("Address: "+Utils.getAddress(context,LATITUDE,LONGITUDE)); + address.setText("Address: "+ Utils.getAddress(context,LATITUDE,LONGITUDE)); ImageView mapView = view.findViewById(R.id.map_vw); String mapUrl = UIKitConstants.MapUrl.MAPS_URL +LATITUDE+","+LONGITUDE+"&key="+ UIKitConstants.MapUrl.MAP_ACCESS_KEY; @@ -979,12 +1055,28 @@ private void sendCustomMessage(String customType, JSONObject customData) { else customMessage = new CustomMessage(Id, CometChatConstants.RECEIVER_TYPE_GROUP, customType, customData); + if (customType.equalsIgnoreCase(UIKitConstants.IntentStrings.LOCATION)) { + try { + JSONObject jsonObject = customMessage.getMetadata(); + if (jsonObject==null) { + jsonObject = new JSONObject(); + jsonObject.put("incrementUnreadCount", true); + } else { + jsonObject.accumulate("incrementUnreadCount", true); + } + customMessage.setMetadata(jsonObject); + } catch(Exception e) { + Toast.makeText(context,e.getMessage(),Toast.LENGTH_LONG).show(); + } + } CometChat.sendCustomMessage(customMessage, new CometChat.CallbackListener() { @Override public void onSuccess(CustomMessage customMessage) { - if (customType.equalsIgnoreCase(UIKitConstants.IntentStrings.GROUP_CALL)) - if (CometChat.getActiveCall()==null) - CallUtils.startDirectCall(context,Utils.getDirectCallData(customMessage)); + Log.e(TAG, "onSuccessCustomMesage: "+customMessage.toString()); + if (customType.equalsIgnoreCase(UIKitConstants.IntentStrings.GROUP_CALL)) { + if (CometChat.getActiveCall() == null) + CallUtils.startDirectCall(context, Utils.getDirectCallData(customMessage)); + } if (messageAdapter != null) { messageAdapter.addMessage(customMessage); @@ -1086,25 +1178,7 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis } private void showPermissionSnackBar(View view, String message) { - CometChatSnackBar.show(context,view,message,CometChatSnackBar.WARNING); - } - - @Override - public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) { - super.onCreateOptionsMenu(menu, inflater); - } - - @Override - public boolean onOptionsItemSelected(@NonNull MenuItem item) { - - if (item.getItemId() == android.R.id.home) { - if (getActivity() != null) { - getActivity().onBackPressed(); - } - - return true; - } - return super.onOptionsItemSelected(item); + CometChatSnackBar.show(context,view,message, CometChatSnackBar.WARNING); } /** @@ -1153,7 +1227,7 @@ private void unblockUser() { @Override public void onSuccess(HashMap stringStringHashMap) { CometChatSnackBar.show(context,rvChatListView, - name+" "+getResources().getString(R.string.unblocked_successfully),CometChatSnackBar.SUCCESS); + name+" "+getResources().getString(R.string.unblocked_successfully), CometChatSnackBar.SUCCESS); blockUserLayout.setVisibility(GONE); composeBox.setVisibility(View.VISIBLE); isBlockedByMe = false; @@ -1201,16 +1275,17 @@ private void fetchMessage() { if (messagesRequest == null) { if (type != null) { + if (type.equals(CometChatConstants.RECEIVER_TYPE_USER)) messagesRequest = new MessagesRequest.MessagesRequestBuilder().setLimit(LIMIT) .setTypes(UIKitConstants.MessageRequest.messageTypesForUser) .setCategories(UIKitConstants.MessageRequest.messageCategoriesForUser) - .hideReplies(true).setUID(Id).build(); + .hideReplies(true).hideDeletedMessages(hideDeleteMessage).setUID(Id).build(); else messagesRequest = new MessagesRequest.MessagesRequestBuilder().setLimit(LIMIT) .setTypes(UIKitConstants.MessageRequest.messageTypesForGroup) .setCategories(UIKitConstants.MessageRequest.messageCategoriesForGroup) - .hideReplies(true).setGUID(Id).hideMessagesFromBlockedUsers(true).build(); + .hideReplies(true).hideDeletedMessages(hideDeleteMessage).setGUID(Id).build(); } } messagesRequest.fetchPrevious(new CometChat.CallbackListener>() { @@ -1341,7 +1416,7 @@ public void onActivityResult(int requestCode, int resultCode, @Nullable Intent d case UIKitConstants.RequestCode.AUDIO: if (data != null) { resultIntentCode = UIKitConstants.RequestCode.AUDIO; - File file = MediaUtils.getRealPath(getContext(), data.getData()); + File file = MediaUtils.getRealPath(getContext(), data.getData(),false); ContentResolver cr = getActivity().getContentResolver(); sendMediaMessage(file, CometChatConstants.MESSAGE_TYPE_AUDIO); } @@ -1349,19 +1424,24 @@ public void onActivityResult(int requestCode, int resultCode, @Nullable Intent d case UIKitConstants.RequestCode.GALLERY: if (data != null) { resultIntentCode = UIKitConstants.RequestCode.GALLERY; - File file = MediaUtils.getRealPath(getContext(), data.getData()); + File file = MediaUtils.getRealPath(getContext(), data.getData(),false); ContentResolver cr = getActivity().getContentResolver(); String mimeType = cr.getType(data.getData()); if (mimeType != null && mimeType.contains("image")) { if (file.exists()) sendMediaMessage(file, CometChatConstants.MESSAGE_TYPE_IMAGE); else - Snackbar.make(rvChatListView, R.string.file_not_exist, Snackbar.LENGTH_LONG).show(); - } else { + CometChatSnackBar.show(context,rvChatListView, getString(R.string.file_not_exist), CometChatSnackBar.WARNING); + } else if (mimeType!=null && mimeType.contains("video")){ if (file.exists()) sendMediaMessage(file, CometChatConstants.MESSAGE_TYPE_VIDEO); else - Snackbar.make(rvChatListView, R.string.file_not_exist, Snackbar.LENGTH_LONG).show(); + CometChatSnackBar.show(context,rvChatListView, getString(R.string.file_not_exist), CometChatSnackBar.WARNING); + } else { + if (file.exists()) + sendMediaMessage(file,CometChatConstants.MESSAGE_TYPE_FILE); + else + CometChatSnackBar.show(context,rvChatListView, getString(R.string.file_not_exist), CometChatSnackBar.WARNING); } } @@ -1370,7 +1450,7 @@ public void onActivityResult(int requestCode, int resultCode, @Nullable Intent d File file; resultIntentCode = UIKitConstants.RequestCode.CAMERA; if (Build.VERSION.SDK_INT >= 29) { - file = MediaUtils.getRealPath(getContext(), MediaUtils.uri); + file = MediaUtils.getRealPath(getContext(), MediaUtils.uri,false); } else { file = new File(MediaUtils.pictureImagePath); } @@ -1383,7 +1463,7 @@ public void onActivityResult(int requestCode, int resultCode, @Nullable Intent d case UIKitConstants.RequestCode.FILE: if (data != null) { resultIntentCode = UIKitConstants.RequestCode.FILE; - sendMediaMessage(MediaUtils.getRealPath(getActivity(), data.getData()), CometChatConstants.MESSAGE_TYPE_FILE); + sendMediaMessage(MediaUtils.getRealPath(getActivity(), data.getData(),false), CometChatConstants.MESSAGE_TYPE_FILE); } break; case UIKitConstants.RequestCode.BLOCK_USER: @@ -1474,7 +1554,7 @@ public void onError(CometChatException e) { messageAdapter.updateChangedMessage(mediaMessage); } if (getActivity() != null) { - CometChatSnackBar.show(context,rvChatListView,e.getMessage(),CometChatSnackBar.ERROR); + CometChatSnackBar.show(context,rvChatListView,e.getMessage(), CometChatSnackBar.ERROR); } } }); @@ -1518,16 +1598,21 @@ public void onSuccess(User user) { composeBox.setVisibility(View.VISIBLE); blockUserLayout.setVisibility(GONE); avatarUrl = user.getAvatar(); + profileLink = user.getLink(); if (user.getStatus().equals(CometChatConstants.USER_STATUS_ONLINE)) { tvStatus.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary)); } - if (UISettings.isShowUserPresence()) { - status = user.getStatus().toString(); - tvStatus.setText(status); - } + FeatureRestriction.isUserPresenceEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (booleanVal) { + status = user.getStatus().toString(); + tvStatus.setText(status); + } + } + }); setAvatar(); - } name = user.getName(); tvName.setText(name); @@ -1604,7 +1689,7 @@ private void sendMessage(String message) { textMessage.setSender(loggedInUser); textMessage.setMuid(System.currentTimeMillis()+""); if (messageAdapter != null) { - MediaUtils.playSendSound(context,R.raw.outgoing_message); + MediaUtils.playSendSound(context, R.raw.outgoing_message); messageAdapter.addMessage(textMessage); scrollToBottom(); } @@ -1648,8 +1733,12 @@ private void deleteMessage(BaseMessage baseMessage) { CometChat.deleteMessage(baseMessage.getId(), new CometChat.CallbackListener() { @Override public void onSuccess(BaseMessage baseMessage) { - if (messageAdapter != null) - messageAdapter.setUpdatedMessage(baseMessage); + if (messageAdapter != null) { + if (hideDeleteMessage) + messageAdapter.remove(baseMessage); + else + messageAdapter.setUpdatedMessage(baseMessage); + } } @Override @@ -1754,7 +1843,7 @@ private void replyMessage(BaseMessage baseMessage, String message) { @Override public void onSuccess(TextMessage textMessage) { if (messageAdapter != null) { - MediaUtils.playSendSound(context,R.raw.outgoing_message); + MediaUtils.playSendSound(context, R.raw.outgoing_message); messageAdapter.addMessage(textMessage); scrollToBottom(); } @@ -1960,7 +2049,12 @@ public void onMessageEdited(BaseMessage message) { @Override public void onMessageDeleted(BaseMessage message) { Log.d(TAG, "onMessageDeleted: "); - updateMessage(message); + if (messageAdapter!=null) { + if (hideDeleteMessage) + messageAdapter.remove(message); + else + updateMessage(message); + } } }); } @@ -1993,7 +2087,7 @@ private void setTypingIndicator(TypingIndicator typingIndicator,boolean isShow) private void onMessageReceived(BaseMessage message) { - 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); @@ -2076,15 +2170,25 @@ private void typingIndicator(TypingIndicator typingIndicator, boolean show) { if (show) { if (typingIndicator.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_USER)) { if (typingIndicator.getMetadata() == null) { - if (UISettings.isShowTypingIndicators()) - tvStatus.setText("is Typing..."); + FeatureRestriction.isTypingIndicatorsEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (booleanVal) + tvStatus.setText(getString(R.string.is_typing)); + } + }); } else setLiveReaction(); } else { if (typingIndicator.getMetadata() == null) { - if (UISettings.isShowTypingIndicators()) - tvStatus.setText(typingIndicator.getSender().getName() + " is Typing..."); + FeatureRestriction.isTypingIndicatorsEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (booleanVal) + tvStatus.setText(typingIndicator.getSender().getName() + getString(R.string.is_typing)); + } + }); } else setLiveReaction(); @@ -2182,18 +2286,26 @@ public void onResume() { } addMessageListener(); + audioCallAction.setClickable(true); + videoCallAction.setClickable(true); + if (messageActionFragment!=null && messageActionFragment.getFragmentManager()!=null) messageActionFragment.dismiss(); if (type != null) { if (type.equals(CometChatConstants.RECEIVER_TYPE_USER)) { - if (UISettings.isShowUserPresence()) { - addUserListener(); - tvStatus.setText(status); - } + FeatureRestriction.isUserPresenceEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (booleanVal) { + addUserListener(); + tvStatus.setText(status); + } + } + }); new Thread(this::getUser).start(); } else { - if (!UISettings.isGroupNotificationHidden()) + if (!FeatureRestriction.isGroupActionMessagesEnabled()) addGroupListener(); new Thread(this::getGroup).start(); new Thread(this::getMember).start(); @@ -2238,12 +2350,13 @@ else if (id == R.id.iv_reply_close) { else if (id == R.id.btn_unblock_user) { unblockUser(); } - else if (id == R.id.chatList_toolbar) { + else if (id == R.id.info_action) { if (type.equals(CometChatConstants.RECEIVER_TYPE_USER)) { Intent intent = new Intent(getContext(), CometChatUserDetailScreenActivity.class); intent.putExtra(UIKitConstants.IntentStrings.UID, Id); intent.putExtra(UIKitConstants.IntentStrings.NAME, name); intent.putExtra(UIKitConstants.IntentStrings.AVATAR, avatarUrl); + intent.putExtra(UIKitConstants.IntentStrings.LINK,profileLink); intent.putExtra(UIKitConstants.IntentStrings.IS_BLOCKED_BY_ME, isBlockedByMe); intent.putExtra(UIKitConstants.IntentStrings.STATUS, status); intent.putExtra(UIKitConstants.IntentStrings.TYPE, type); @@ -2263,6 +2376,28 @@ else if (id == R.id.chatList_toolbar) { startActivity(intent); } } + else if (id==R.id.audio_call_action) { + audioCallAction.setClickable(false); + checkOnGoingCall(CometChatConstants.CALL_TYPE_AUDIO); + } + else if (id==R.id.video_call_action) { + if (type.equalsIgnoreCase(CometChatConstants.RECEIVER_TYPE_GROUP)) { + JSONObject customData = new JSONObject(); + try { + customData.put("callType", CometChatConstants.CALL_TYPE_VIDEO); + customData.put("sessionID",Id); + } catch (JSONException e) { + e.printStackTrace(); + } + sendCustomMessage(UIKitConstants.IntentStrings.GROUP_CALL,customData); + } else { + checkOnGoingCall(CometChatConstants.CALL_TYPE_VIDEO); + } + } + else if (id==R.id.back_action) { + if (getActivity()!=null) + getActivity().onBackPressed(); + } } private void startForwardMessageActivity() { @@ -2308,7 +2443,7 @@ private void shareMessage() { shareIntent.setType("text/plain"); Intent intent = Intent.createChooser(shareIntent, getResources().getString(R.string.share_message)); startActivity(intent); - } else if (baseMessage!=null && baseMessage.getType().equals(CometChatConstants.MESSAGE_TYPE_IMAGE)) { + } else if (baseMessage!=null && baseMessage.getType().equals(CometChatConstants.MESSAGE_TYPE_IMAGE)) { String mediaName = ((MediaMessage)baseMessage).getAttachment().getFileName(); Glide.with(context).asBitmap().load(((MediaMessage)baseMessage).getAttachment().getFileUrl()).into(new SimpleTarget() { @Override @@ -2322,8 +2457,16 @@ public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition baseMessagesList) { messageActionFragment = new CometChatMessageActions(); replyMessageLayout.setVisibility(GONE); editMessageLayout.setVisibility(GONE); - 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(); - boolean reactionVisible = UISettings.isReactionVisible(); - boolean translateVisible = UISettings.isTranslationAllowed(); - boolean retryVisible = false; - boolean replyPrivately = UISettings.isShowReplyPrivately(); - + fetchSettings(); List textMessageList = new ArrayList<>(); List mediaMessageList = new ArrayList<>(); List locationMessageList = new ArrayList<>(); @@ -2438,22 +2570,29 @@ public void setLongMessageClick(List baseMessagesList) { } } if (textMessageList.size() == 1) { - translateVisible = UISettings.isTranslationAllowed(); BaseMessage basemessage = textMessageList.get(0); if (basemessage != null && basemessage.getSender() != null) { if (!(basemessage instanceof Action) && 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(); - editVisible = UISettings.isEnableEditingMessage(); + FeatureRestriction.isDeleteMessageEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + deleteVisible = booleanVal; + } + }); } else { editVisible = false; if (loggedInUserScope!=null && (loggedInUserScope.equals(CometChatConstants.SCOPE_ADMIN) || loggedInUserScope.equals(CometChatConstants.SCOPE_MODERATOR))) { - deleteVisible = (UISettings.isEnableDeleteMessage() || UISettings.isAllowModeratorToDeleteMessages()); + FeatureRestriction.isDeleteMemberMessageEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + deleteVisible = booleanVal; + } + }); } else { deleteVisible = false; } @@ -2482,20 +2621,29 @@ public void setLongMessageClick(List baseMessagesList) { baseMessage = basemessage; if (basemessage.getReplyCount()>0) threadVisible = false; - else - threadVisible = UISettings.isEnableThreadedReplies(); + copyVisible = false; - if (basemessage.getType().equalsIgnoreCase(CometChatConstants.MESSAGE_TYPE_FILE)|| - basemessage.getType().equalsIgnoreCase(CometChatConstants.MESSAGE_TYPE_AUDIO) || - basemessage.getType().equalsIgnoreCase(CometChatConstants.MESSAGE_TYPE_VIDEO)) { - shareVisible = false; - } +// if (basemessage.getType().equalsIgnoreCase(CometChatConstants.MESSAGE_TYPE_FILE)|| +// basemessage.getType().equalsIgnoreCase(CometChatConstants.MESSAGE_TYPE_AUDIO) || +// basemessage.getType().equalsIgnoreCase(CometChatConstants.MESSAGE_TYPE_VIDEO)) { +// shareVisible = false; +// } if (basemessage.getSender().getUid().equals(CometChat.getLoggedInUser().getUid())) { - deleteVisible = UISettings.isEnableDeleteMessage(); + FeatureRestriction.isDeleteMessageEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + deleteVisible = booleanVal; + } + }); editVisible = false; } else { if (loggedInUserScope!=null && (loggedInUserScope.equals(CometChatConstants.SCOPE_ADMIN) || loggedInUserScope.equals(CometChatConstants.SCOPE_MODERATOR))){ - deleteVisible = UISettings.isEnableDeleteMessage(); + FeatureRestriction.isDeleteMemberMessageEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + deleteVisible = booleanVal; + } + }); } else { deleteVisible = false; } @@ -2524,18 +2672,44 @@ public void setLongMessageClick(List baseMessagesList) { baseMessage = basemessage; if (basemessage.getReplyCount()>0) threadVisible = false; - else - threadVisible = UISettings.isEnableThreadedReplies(); + else { + FeatureRestriction.isThreadedMessagesEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + threadVisible = booleanVal; + } + }); + } copyVisible = false; - replyVisible = UISettings.isEnableReplyToMessage(); + FeatureRestriction.isMessageRepliesEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + replyVisible = booleanVal; + } + }); shareVisible = false; - forwardVisible = UISettings.isEnableShareCopyForward(); + FeatureRestriction.isShareCopyForwardMessageEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + forwardVisible = booleanVal; + } + }); if (basemessage.getSender().getUid().equals(CometChat.getLoggedInUser().getUid())) { - deleteVisible = UISettings.isEnableDeleteMessage(); + FeatureRestriction.isDeleteMessageEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + deleteVisible = booleanVal; + } + }); editVisible = false; } else { if (loggedInUserScope!=null && (loggedInUserScope.equals(CometChatConstants.SCOPE_ADMIN) || loggedInUserScope.equals(CometChatConstants.SCOPE_MODERATOR))){ - deleteVisible = (UISettings.isEnableDeleteMessage() || UISettings.isAllowModeratorToDeleteMessages()); + FeatureRestriction.isDeleteMemberMessageEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + deleteVisible = booleanVal; + } + }); } else { deleteVisible = false; } @@ -2562,20 +2736,35 @@ public void setLongMessageClick(List baseMessagesList) { copyVisible = false; editVisible = false; shareVisible = false; - replyVisible = UISettings.isEnableReplyToMessage(); BaseMessage basemessage = pollsMessageList.get(0); if (basemessage != null && basemessage.getSender() != null) { if (!(basemessage instanceof Action) && basemessage.getDeletedAt() == 0) { baseMessage = basemessage; if (basemessage.getReplyCount()>0) threadVisible = false; - else - threadVisible = UISettings.isEnableThreadedReplies(); + else { + FeatureRestriction.isThreadedMessagesEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + threadVisible = booleanVal; + } + }); + } if (basemessage.getSender().getUid().equals(CometChat.getLoggedInUser().getUid())) { - deleteVisible = UISettings.isEnableDeleteMessage(); + FeatureRestriction.isDeleteMessageEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + deleteVisible = booleanVal; + } + }); } else { if (loggedInUserScope!=null && (loggedInUserScope.equals(CometChatConstants.SCOPE_ADMIN) || loggedInUserScope.equals(CometChatConstants.SCOPE_MODERATOR))){ - deleteVisible = (UISettings.isEnableDeleteMessage() || UISettings.isAllowModeratorToDeleteMessages()); + FeatureRestriction.isDeleteMemberMessageEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + deleteVisible = booleanVal; + } + }); } else { deleteVisible = false; } @@ -2589,20 +2778,36 @@ public void setLongMessageClick(List baseMessagesList) { editVisible = false; translateVisible = false; shareVisible = false; - replyVisible = UISettings.isEnableReplyToMessage(); 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 { + FeatureRestriction.isThreadedMessagesEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + threadVisible = booleanVal; + } + }); + } + if (basemessage.getSender().getUid().equals(CometChat.getLoggedInUser().getUid())) { + FeatureRestriction.isDeleteMessageEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + deleteVisible = booleanVal; + } + }); + } else { if (loggedInUserScope!=null && (loggedInUserScope.equals(CometChatConstants.SCOPE_ADMIN) || loggedInUserScope.equals(CometChatConstants.SCOPE_MODERATOR))){ - deleteVisible = (UISettings.isEnableDeleteMessage() || UISettings.isAllowModeratorToDeleteMessages()); + FeatureRestriction.isDeleteMemberMessageEnabled(new FeatureRestriction.OnSuccessListener(){ + @Override + public void onSuccess(Boolean booleanVal) { + deleteVisible = booleanVal; + } + }); } else { deleteVisible = false; } @@ -2616,20 +2821,36 @@ public void setLongMessageClick(List baseMessagesList) { translateVisible = false; editVisible = false; shareVisible = false; - replyVisible = UISettings.isEnableReplyToMessage(); BaseMessage basemessage = whiteBoardMessageList.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 { + FeatureRestriction.isThreadedMessagesEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + threadVisible = booleanVal; + } + }); + } + if (basemessage.getSender().getUid().equals(CometChat.getLoggedInUser().getUid())) { + FeatureRestriction.isDeleteMessageEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + deleteVisible = booleanVal; + } + }); + } else { if (loggedInUserScope!=null && (loggedInUserScope.equals(CometChatConstants.SCOPE_ADMIN) || loggedInUserScope.equals(CometChatConstants.SCOPE_MODERATOR))){ - deleteVisible = (UISettings.isEnableDeleteMessage() || UISettings.isAllowModeratorToDeleteMessages()); + FeatureRestriction.isDeleteMemberMessageEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + deleteVisible = booleanVal; + } + }); } else { deleteVisible = false; } @@ -2644,20 +2865,36 @@ public void setLongMessageClick(List baseMessagesList) { editVisible = false; translateVisible = false; shareVisible = false; - replyVisible = UISettings.isEnableReplyToMessage(); BaseMessage basemessage = writeBoardMessageList.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 { + FeatureRestriction.isThreadedMessagesEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + threadVisible = booleanVal; + } + }); + } + if (basemessage.getSender().getUid().equals(CometChat.getLoggedInUser().getUid())) { + FeatureRestriction.isDeleteMessageEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + deleteVisible = booleanVal; + } + }); + } else { if (loggedInUserScope!=null && (loggedInUserScope.equals(CometChatConstants.SCOPE_ADMIN) || loggedInUserScope.equals(CometChatConstants.SCOPE_MODERATOR))){ - deleteVisible = (UISettings.isEnableDeleteMessage() || UISettings.isAllowModeratorToDeleteMessages()); + FeatureRestriction.isDeleteMemberMessageEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + deleteVisible = booleanVal; + } + }); } else { deleteVisible = false; } @@ -2678,11 +2915,22 @@ public void setLongMessageClick(List baseMessagesList) { if (basemessage!=null && basemessage.getSender()!=null) { if (basemessage.getDeletedAt() == 0) { baseMessage = basemessage; - if (basemessage.getSender().getUid().equals(CometChat.getLoggedInUser().getUid())) - deleteVisible = UISettings.isEnableDeleteMessage(); + if (basemessage.getSender().getUid().equals(CometChat.getLoggedInUser().getUid())) { + FeatureRestriction.isDeleteMessageEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + deleteVisible = booleanVal; + } + }); + } else { if (loggedInUserScope!=null && (loggedInUserScope.equals(CometChatConstants.SCOPE_ADMIN) || loggedInUserScope.equals(CometChatConstants.SCOPE_MODERATOR))){ - deleteVisible = (UISettings.isEnableDeleteMessage() || UISettings.isAllowModeratorToDeleteMessages()); + FeatureRestriction.isDeleteMemberMessageEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + deleteVisible = booleanVal; + } + }); } else { deleteVisible = false; } @@ -2706,8 +2954,6 @@ public void setLongMessageClick(List baseMessagesList) { if (baseMessage.getReceiverType().equalsIgnoreCase(CometChatConstants.RECEIVER_TYPE_GROUP) && !baseMessage.getSender().getUid().equalsIgnoreCase(loggedInUser.getUid())) { bundle.putBoolean("privateReplyVisible", replyPrivately); - bundle.putString("userAvatar",baseMessage.getSender().getAvatar()); - bundle.putString("userName",baseMessage.getSender().getName()); } if(CometChat.isExtensionEnabled("reactions")) { bundle.putBoolean("isReactionVisible", true); @@ -2716,8 +2962,15 @@ public void setLongMessageClick(List baseMessagesList) { } if (baseMessage.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_GROUP) && - baseMessage.getSender().getUid().equals(loggedInUser.getUid())) - bundle.putBoolean("messageInfoVisible",true); + baseMessage.getSender().getUid().equals(loggedInUser.getUid())) { + FeatureRestriction.isDeliveryReceiptsEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (booleanVal) + bundle.putBoolean("messageInfoVisible", true); + } + }); + } bundle.putString("type", CometChatMessageListActivity.class.getName()); messageActionFragment.setArguments(bundle); if (baseMessage.getSentAt()!=0) { @@ -2731,14 +2984,16 @@ public void setLongMessageClick(List baseMessagesList) { public void onPrivateReplyToUser() { if (baseMessage!=null) { User user = baseMessage.getSender(); - Intent intent = new Intent(context,CometChatMessageListActivity.class); + Intent intent = new Intent(context, CometChatMessageListActivity.class); intent.putExtra(UIKitConstants.IntentStrings.UID, user.getUid()); intent.putExtra(UIKitConstants.IntentStrings.AVATAR, user.getAvatar()); intent.putExtra(UIKitConstants.IntentStrings.STATUS, user.getStatus()); + intent.putExtra(UIKitConstants.IntentStrings.LINK,user.getLink()); intent.putExtra(UIKitConstants.IntentStrings.NAME, user.getName()); intent.putExtra(UIKitConstants.IntentStrings.TYPE, CometChatConstants.RECEIVER_TYPE_USER); startActivity(intent); - getActivity().finish(); + if (getActivity()!=null) + getActivity().finish(); } } @@ -2789,7 +3044,7 @@ public void onCopyMessageClick() { String message = ""; for (BaseMessage bMessage : baseMessages) { if (bMessage.getDeletedAt() == 0 && bMessage instanceof TextMessage) { - message = message + "[" + Utils.getLastMessageDate(bMessage.getSentAt()) + "] " + bMessage.getSender().getName() + ": " + ((TextMessage) bMessage).getText(); + message = message + "[" + Utils.getLastMessageDate(context,bMessage.getSentAt()) + "] " + bMessage.getSender().getName() + ": " + ((TextMessage) bMessage).getText(); } } Log.e(TAG, "onCopy: " + message); @@ -2827,11 +3082,11 @@ public void onMessageInfoClick() { } else if (baseMessage.getType().equals(UIKitConstants.IntentStrings.WHITEBOARD)) { intent.putExtra(UIKitConstants.IntentStrings.MESSAGE_TYPE, UIKitConstants.IntentStrings.WHITEBOARD); - intent.putExtra(UIKitConstants.IntentStrings.TEXTMESSAGE,Extensions.getWhiteBoardUrl(baseMessage)); + intent.putExtra(UIKitConstants.IntentStrings.TEXTMESSAGE, Extensions.getWhiteBoardUrl(baseMessage)); } else if (baseMessage.getType().equals(UIKitConstants.IntentStrings.WRITEBOARD)) { intent.putExtra(UIKitConstants.IntentStrings.MESSAGE_TYPE, UIKitConstants.IntentStrings.WRITEBOARD); - intent.putExtra(UIKitConstants.IntentStrings.TEXTMESSAGE,Extensions.getWriteBoardUrl(baseMessage)); + intent.putExtra(UIKitConstants.IntentStrings.TEXTMESSAGE, Extensions.getWriteBoardUrl(baseMessage)); } else if (baseMessage.getType().equals(UIKitConstants.IntentStrings.GROUP_CALL)) { intent.putExtra(UIKitConstants.IntentStrings.MESSAGE_TYPE, UIKitConstants.IntentStrings.GROUP_CALL); @@ -2902,7 +3157,7 @@ public void onSuccess(JSONObject jsonObject) { } } else { CometChatSnackBar.show(context,rvChatListView, - context.getString(R.string.no_translation_available),CometChatSnackBar.WARNING); + context.getString(R.string.no_translation_available), CometChatSnackBar.WARNING); } } @@ -3036,10 +3291,8 @@ private void sendLiveReaction() { } private void setLiveReaction() { - if (UISettings.showLiveReaction()) { - container.setAlpha(1.0f); - flyEmoji(R.drawable.heart_reaction); - } + container.setAlpha(1.0f); + flyEmoji(R.drawable.heart_reaction); } private void flyEmoji(final int resId) { @@ -3069,4 +3322,118 @@ public void handleDialogClose(DialogInterface dialog) { messageAdapter.clearLongClickSelectedItem(); dialog.dismiss(); } + + private void fetchSettings() { + if (type.equalsIgnoreCase(CometChatConstants.RECEIVER_TYPE_GROUP)) { + + FeatureRestriction.isGroupVideoCallEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (booleanVal) + videoCallAction.setVisibility(View.VISIBLE); + else + videoCallAction.setVisibility(View.GONE); + } + }); + audioCallAction.setVisibility(View.GONE); + } + else { + FeatureRestriction.isOneOnOneVideoCallEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (booleanVal) + videoCallAction.setVisibility(View.VISIBLE); + else + videoCallAction.setVisibility(View.GONE); + } + }); + + FeatureRestriction.isOneOnOneAudioCallEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (booleanVal) + audioCallAction.setVisibility(View.VISIBLE); + else + audioCallAction.setVisibility(View.GONE); + } + }); + } + + if (FeatureRestriction.getColor()!=null) { + audioCallAction.setImageTintList(ColorStateList.valueOf( + Color.parseColor(FeatureRestriction.getColor()))); + videoCallAction.setImageTintList(ColorStateList.valueOf( + Color.parseColor(FeatureRestriction.getColor()))); + infoAction.setImageTintList(ColorStateList.valueOf( + Color.parseColor(FeatureRestriction.getColor()))); + } + + FeatureRestriction.isShareCopyForwardMessageEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + shareVisible = booleanVal; + copyVisible = booleanVal; + forwardVisible = booleanVal; + } + }); + FeatureRestriction.isThreadedMessagesEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + threadVisible = booleanVal; + } + }); + FeatureRestriction.isMessageRepliesEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + replyVisible = booleanVal; + } + }); + FeatureRestriction.isEditMessageEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + editVisible = booleanVal; + } + }); + FeatureRestriction.isDeleteMessageEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + deleteVisible = booleanVal; + } + }); + FeatureRestriction.isReactionEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + reactionVisible = booleanVal; + } + }); + FeatureRestriction.isMessageTranslationEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + translateVisible = booleanVal; + } + }); + FeatureRestriction.isShowReplyPrivately(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + replyPrivately = booleanVal; + } + }); + + FeatureRestriction.isLiveReactionEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (!booleanVal) + composeBox.liveReactionBtn.setVisibility(View.GONE); + } + }); + + FeatureRestriction.isHideDeleteMessageEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + hideDeleteMessage = booleanVal; + } + }); + + } + } diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/message_list/CometChatMessageListActivity.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/message_list/CometChatMessageListActivity.java index 5f18377..1c776b3 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/message_list/CometChatMessageListActivity.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/message_list/CometChatMessageListActivity.java @@ -1,7 +1,10 @@ package com.cometchat.pro.uikit.ui_components.messages.message_list; +import android.app.Activity; import android.content.DialogInterface; import android.content.Intent; +import android.content.res.Configuration; +import android.content.res.Resources; import android.graphics.Color; import android.os.Bundle; import android.util.Log; @@ -21,11 +24,12 @@ import com.cometchat.pro.uikit.R; import java.util.List; +import java.util.Locale; import com.cometchat.pro.uikit.ui_resources.constants.UIKitConstants; import com.cometchat.pro.uikit.ui_components.messages.message_actions.listener.MessageActionCloseListener; import com.cometchat.pro.uikit.ui_components.messages.message_actions.listener.OnMessageLongClick; -import com.cometchat.pro.uikit.ui_settings.UISettings; +import com.cometchat.pro.uikit.ui_settings.FeatureRestriction; /** @@ -59,9 +63,6 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_cometchat_message_list); activity = this; - if (UISettings.getColor() !=null) { - getWindow().setStatusBarColor(Color.parseColor(UISettings.getColor())); - } EmojiCompat.Config config = new BundledEmojiCompatConfig(this); EmojiCompat.init(config); @@ -75,7 +76,7 @@ protected void onCreate(Bundle savedInstanceState) { if (getIntent().hasExtra(UIKitConstants.IntentStrings.TYPE)&& getIntent().getStringExtra(UIKitConstants.IntentStrings.TYPE).equals(CometChatConstants.RECEIVER_TYPE_USER)) { - + bundle.putString(UIKitConstants.IntentStrings.LINK,getIntent().getStringExtra(UIKitConstants.IntentStrings.LINK)); bundle.putString(UIKitConstants.IntentStrings.UID, getIntent().getStringExtra(UIKitConstants.IntentStrings.UID)); bundle.putString(UIKitConstants.IntentStrings.STATUS, getIntent().getStringExtra(UIKitConstants.IntentStrings.STATUS)); diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/message_list/MessageAdapter.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/message_list/MessageAdapter.java index e75f643..588bed6 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/message_list/MessageAdapter.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/message_list/MessageAdapter.java @@ -54,9 +54,8 @@ import com.cometchat.pro.models.TextMessage; import com.cometchat.pro.models.User; -import com.cometchat.pro.uikit.ui_components.users.user_details.CometChatUserDetailScreenActivity; import com.cometchat.pro.uikit.ui_resources.utils.pattern_utils.PatternUtils; -import com.cometchat.pro.uikit.ui_settings.UISettings; +import com.cometchat.pro.uikit.ui_settings.FeatureRestriction; import com.google.android.material.button.MaterialButton; import com.google.android.material.chip.Chip; import com.google.android.material.chip.ChipGroup; @@ -576,12 +575,17 @@ private void setPollsData(PollMessageViewHolder viewHolder, int i) { viewHolder.tvUser.setText(baseMessage.getSender().getName()); } } - if (baseMessage.getReplyCount()!=0 && UISettings.isEnableThreadedReplies()) { - viewHolder.tvThreadReplyCount.setVisibility(View.VISIBLE); - viewHolder.tvThreadReplyCount.setText(baseMessage.getReplyCount()+" Replies"); - } else { - viewHolder.tvThreadReplyCount.setVisibility(View.GONE); - } + FeatureRestriction.isThreadedMessagesEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (baseMessage.getReplyCount()!=0 && booleanVal) { + viewHolder.tvThreadReplyCount.setVisibility(View.VISIBLE); + viewHolder.tvThreadReplyCount.setText(baseMessage.getReplyCount()+" Replies"); + } else { + viewHolder.tvThreadReplyCount.setVisibility(View.GONE); + } + } + }); viewHolder.tvThreadReplyCount.setOnClickListener(view -> { Intent intent = new Intent(context, CometChatThreadMessageListActivity.class); // intent.putExtra(StringContract.IntentStrings.PARENT_BASEMESSAGE,baseMessage.toString()); @@ -632,7 +636,7 @@ private void setPollsData(PollMessageViewHolder viewHolder, int i) { .LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); linearLayout.setPadding(8,8,8,8); - linearLayout.setBackgroundColor(Color.parseColor(UISettings.getColor())); + linearLayout.setBackgroundColor(Color.parseColor(FeatureRestriction.getColor())); linearLayout.setBackgroundTintList(ColorStateList.valueOf(context.getResources() .getColor(R.color.textColorWhite))); layoutParams.bottomMargin = (int) Utils.dpToPx(context, 8); @@ -1090,12 +1094,18 @@ private void setLocationData(LocationMessageViewHolder viewHolder, int i) { viewHolder.tvUser.setText(baseMessage.getSender().getName()); } } - if (baseMessage.getReplyCount()!=0 && UISettings.isEnableThreadedReplies()) { - viewHolder.tvThreadReplyCount.setVisibility(View.VISIBLE); - viewHolder.tvThreadReplyCount.setText(baseMessage.getReplyCount()+" Replies"); - } else { - viewHolder.tvThreadReplyCount.setVisibility(View.GONE); - } + FeatureRestriction.isThreadedMessagesEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (baseMessage.getReplyCount()!=0 && booleanVal) { + viewHolder.tvThreadReplyCount.setVisibility(View.VISIBLE); + viewHolder.tvThreadReplyCount.setText(baseMessage.getReplyCount()+" Replies"); + } else { + viewHolder.tvThreadReplyCount.setVisibility(View.GONE); + } + } + }); + viewHolder.tvThreadReplyCount.setOnClickListener(view -> { Intent intent = new Intent(context, CometChatThreadMessageListActivity.class); // intent.putExtra(StringContract.IntentStrings.PARENT_BASEMESSAGE,baseMessage.toString()); @@ -1232,15 +1242,20 @@ private void setAudioData(AudioMessageViewHolder viewHolder, int i) { viewHolder.tvUser.setText(baseMessage.getSender().getName()); } } else { - viewHolder.playBtn.setImageTintList(ColorStateList.valueOf(Color.parseColor(UISettings.getColor()))); + viewHolder.playBtn.setImageTintList(ColorStateList.valueOf(Color.parseColor(FeatureRestriction.getColor()))); } - if (baseMessage.getReplyCount()!=0 && UISettings.isEnableThreadedReplies()) { - viewHolder.tvThreadReplyCount.setVisibility(View.VISIBLE); - viewHolder.tvThreadReplyCount.setText(baseMessage.getReplyCount()+" Replies"); - } else { - viewHolder.tvThreadReplyCount.setVisibility(View.GONE); - } + FeatureRestriction.isThreadedMessagesEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (baseMessage.getReplyCount()!=0 && booleanVal) { + viewHolder.tvThreadReplyCount.setVisibility(View.VISIBLE); + viewHolder.tvThreadReplyCount.setText(baseMessage.getReplyCount()+" Replies"); + } else { + viewHolder.tvThreadReplyCount.setVisibility(View.GONE); + } + } + }); viewHolder.tvThreadReplyCount.setOnClickListener(view -> { Intent intent = new Intent(context, CometChatThreadMessageListActivity.class); // intent.putExtra(StringContract.IntentStrings.PARENT_BASEMESSAGE,baseMessage.toString()); @@ -1362,12 +1377,18 @@ private void setFileData(FileMessageViewHolder viewHolder, int i) { viewHolder.fileExt.setText("-"); viewHolder.fileSize.setText("-"); } - if (baseMessage.getReplyCount()!=0 && UISettings.isEnableThreadedReplies()) { - viewHolder.tvThreadReplyCount.setVisibility(View.VISIBLE); - viewHolder.tvThreadReplyCount.setText(baseMessage.getReplyCount()+" Replies"); - } else { - viewHolder.tvThreadReplyCount.setVisibility(View.GONE); - } + + FeatureRestriction.isThreadedMessagesEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (baseMessage.getReplyCount()!=0 && booleanVal) { + viewHolder.tvThreadReplyCount.setVisibility(View.VISIBLE); + viewHolder.tvThreadReplyCount.setText(baseMessage.getReplyCount()+" Replies"); + } else { + viewHolder.tvThreadReplyCount.setVisibility(View.GONE); + } + } + }); viewHolder.tvThreadReplyCount.setOnClickListener(view -> { Intent intent = new Intent(context, CometChatThreadMessageListActivity.class); // intent.putExtra(StringContract.IntentStrings.PARENT_BASEMESSAGE,baseMessage.toString()); @@ -1492,12 +1513,17 @@ private void setImageData(ImageMessageViewHolder viewHolder, int i) { viewHolder.sensitiveLayout.setVisibility(View.GONE); } - if (baseMessage.getReplyCount()!=0 && UISettings.isEnableThreadedReplies()) { - viewHolder.tvThreadReplyCount.setVisibility(View.VISIBLE); - viewHolder.tvThreadReplyCount.setText(baseMessage.getReplyCount()+" Replies"); - } else { - viewHolder.tvThreadReplyCount.setVisibility(View.GONE); - } + FeatureRestriction.isThreadedMessagesEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (baseMessage.getReplyCount()!=0 && booleanVal) { + viewHolder.tvThreadReplyCount.setVisibility(View.VISIBLE); + viewHolder.tvThreadReplyCount.setText(baseMessage.getReplyCount()+" Replies"); + } else { + viewHolder.tvThreadReplyCount.setVisibility(View.GONE); + } + } + }); if (baseMessage.getMetadata()!=null) { try { String filePath = baseMessage.getMetadata().getString("path"); @@ -1665,12 +1691,19 @@ private void setStickerData(StickerMessageViewHolder viewHolder, int i) { } catch (JSONException e) { e.printStackTrace(); } - if (baseMessage.getReplyCount()!=0 && UISettings.isEnableThreadedReplies()) { - viewHolder.tvThreadReplyCount.setVisibility(View.VISIBLE); - viewHolder.tvThreadReplyCount.setText(baseMessage.getReplyCount()+" Replies"); - } else { - viewHolder.tvThreadReplyCount.setVisibility(View.GONE); - } + + FeatureRestriction.isThreadedMessagesEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (baseMessage.getReplyCount()!=0 && booleanVal) { + viewHolder.tvThreadReplyCount.setVisibility(View.VISIBLE); + viewHolder.tvThreadReplyCount.setText(baseMessage.getReplyCount()+" Replies"); + } else { + viewHolder.tvThreadReplyCount.setVisibility(View.GONE); + } + } + }); + viewHolder.tvThreadReplyCount.setOnClickListener(view -> { Intent intent = new Intent(context, CometChatThreadMessageListActivity.class); // intent.putExtra(StringContract.IntentStrings.PARENT_BASEMESSAGE,baseMessage.toString()); @@ -1752,12 +1785,20 @@ 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 && UISettings.isEnableThreadedReplies()) { - viewHolder.tvThreadReplyCount.setVisibility(View.VISIBLE); - viewHolder.tvThreadReplyCount.setText(baseMessage.getReplyCount()+" Replies"); - } else { - viewHolder.tvThreadReplyCount.setVisibility(View.GONE); - } + + + FeatureRestriction.isThreadedMessagesEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (baseMessage.getReplyCount()!=0 && booleanVal) { + viewHolder.tvThreadReplyCount.setVisibility(View.VISIBLE); + viewHolder.tvThreadReplyCount.setText(baseMessage.getReplyCount()+" Replies"); + } else { + viewHolder.tvThreadReplyCount.setVisibility(View.GONE); + } + } + }); + viewHolder.tvThreadReplyCount.setOnClickListener(view -> { Intent intent = new Intent(context, CometChatThreadMessageListActivity.class); // intent.putExtra(StringContract.IntentStrings.PARENT_BASEMESSAGE,baseMessage.toString()); @@ -2016,40 +2057,45 @@ private void showMessageTime(RecyclerView.ViewHolder viewHolder, BaseMessage bas * @see BaseMessage */ private void setStatusIcon(ProgressBar progressBar,TextView txtTime, BaseMessage baseMessage) { - if (UISettings.isShowReadDeliveryReceipts()) { - if (baseMessage.getSender().getUid().equals(loggedInUser.getUid())) { - if (baseMessage.getReceiverType()!=null && baseMessage.getReceiverType() - .equals(CometChatConstants.RECEIVER_TYPE_USER)) { - if (progressBar!=null) - progressBar.setVisibility(View.GONE); - 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 if (baseMessage.getSentAt()>0){ - txtTime.setText(Utils.getHeaderDate(baseMessage.getSentAt() * 1000)); - txtTime.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_check_black_24dp, 0); - txtTime.setCompoundDrawablePadding(10); - } else if (baseMessage.getSentAt()==-1) { - txtTime.setText(""); - txtTime.setCompoundDrawablesWithIntrinsicBounds(0,0,R.drawable.ic_info_red,0); + FeatureRestriction.isDeliveryReceiptsEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (booleanVal) { + if (baseMessage.getSender().getUid().equals(loggedInUser.getUid())) { + if (baseMessage.getReceiverType()!=null && baseMessage.getReceiverType() + .equals(CometChatConstants.RECEIVER_TYPE_USER)) { + if (progressBar!=null) + progressBar.setVisibility(View.GONE); + 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 if (baseMessage.getSentAt()>0){ + txtTime.setText(Utils.getHeaderDate(baseMessage.getSentAt() * 1000)); + txtTime.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_check_black_24dp, 0); + txtTime.setCompoundDrawablePadding(10); + } else if (baseMessage.getSentAt()==-1) { + txtTime.setText(""); + txtTime.setCompoundDrawablesWithIntrinsicBounds(0,0,R.drawable.ic_info_red,0); + } else { + txtTime.setCompoundDrawablesWithIntrinsicBounds(0,0,0,0); + txtTime.setText(""); + if (progressBar!=null) + progressBar.setVisibility(View.VISIBLE); + } + } else { + txtTime.setText(Utils.getHeaderDate(baseMessage.getSentAt() * 1000)); + } } else { - txtTime.setCompoundDrawablesWithIntrinsicBounds(0,0,0,0); - txtTime.setText(""); - if (progressBar!=null) - progressBar.setVisibility(View.VISIBLE); + txtTime.setText(Utils.getHeaderDate(baseMessage.getSentAt() * 1000)); } - } else { - txtTime.setText(Utils.getHeaderDate(baseMessage.getSentAt() * 1000)); } - } else { - txtTime.setText(Utils.getHeaderDate(baseMessage.getSentAt() * 1000)); } - } + }); } /** @@ -2116,9 +2162,9 @@ public void onClick(DialogInterface dialog, int which) { } }); } - if (baseMessage.getMetadata()!=null) {// && baseMessage.getMetadata().has("reply")) { + if (baseMessage.getMetadata()!=null) { try { - JSONObject metaData = baseMessage.getMetadata();//.getJSONObject("reply"); + JSONObject metaData = baseMessage.getMetadata(); String messageType = metaData.getString("type"); String message = metaData.getString("message"); viewHolder.replyLayout.setVisibility(View.VISIBLE); @@ -2129,6 +2175,11 @@ public void onClick(DialogInterface dialog, int which) { } else { viewHolder.replyUser.setVisibility(View.GONE); } + }catch (Exception e) { + Log.e(TAG, "setTextData: "+e.getMessage()); + } + } + // if (messageType.equals(CometChatConstants.MESSAGE_TYPE_TEXT)) { // } else if (messageType.equals(CometChatConstants.MESSAGE_TYPE_IMAGE)) { // viewHolder.replyMessage.setText(context.getResources().getString(R.string.shared_a_image)); @@ -2172,18 +2223,20 @@ public boolean onLongClick(View view) { return true; } }); - }catch (Exception e) { - Log.e(TAG, "setTextData: "+e.getMessage()); - } - } - if (baseMessage.getReplyCount()!=0 && UISettings.isEnableThreadedReplies()) { - viewHolder.tvThreadReplyCount.setVisibility(View.VISIBLE); - viewHolder.tvThreadReplyCount.setText(baseMessage.getReplyCount()+" Replies"); - } else { - viewHolder.tvThreadReplyCount.setVisibility(View.GONE); - } - viewHolder.tvThreadReplyCount.setOnClickListener(view -> { + + FeatureRestriction.isThreadedMessagesEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (baseMessage.getReplyCount()!=0 && booleanVal) { + viewHolder.tvThreadReplyCount.setVisibility(View.VISIBLE); + viewHolder.tvThreadReplyCount.setText(baseMessage.getReplyCount()+" Replies"); + } else { + viewHolder.tvThreadReplyCount.setVisibility(View.GONE); + } + } + }); + viewHolder.tvThreadReplyCount.setOnClickListener(view -> { Intent intent = new Intent(context, CometChatThreadMessageListActivity.class); // intent.putExtra(StringContract.IntentStrings.PARENT_BASEMESSAGE,baseMessage.toString()); intent.putExtra(UIKitConstants.IntentStrings.NAME,baseMessage.getSender().getName()); @@ -2219,17 +2272,24 @@ public boolean onLongClick(View view) { Spannable spannable = (Spannable) processed; count = spannable.getSpans(0, spannable.length() - 1, EmojiSpan.class).length; if (PatternUtils.removeEmojiAndSymbol(txtMessage).trim().length() == 0) { - 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)); + int tempcount = count; + FeatureRestriction.isLargeSizeEmojisEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (booleanVal) { + if (tempcount == 1) { + viewHolder.txtMessage.setTextSize((int) Utils.dpToPx(context, 32)); + } else if (tempcount == 2) { + viewHolder.txtMessage.setTextSize((int) Utils.dpToPx(context, 24)); + } + } } - } + }); } } String message = txtMessage; + if(CometChat.isExtensionEnabled("profanity-filter")) { message = Extensions.checkProfanityMessage(context,baseMessage); } @@ -2327,7 +2387,7 @@ private void setReactionSupport(BaseMessage baseMessage, ChipGroup reactionLayou Chip chip = new Chip(context); chip.setChipStrokeWidth(2f); chip.setChipBackgroundColor(ColorStateList.valueOf(context.getResources().getColor(android.R.color.transparent))); - chip.setChipStrokeColor(ColorStateList.valueOf(Color.parseColor(UISettings.getColor()))); + chip.setChipStrokeColor(ColorStateList.valueOf(Color.parseColor(FeatureRestriction.getColor()))); chip.setText(str + " " + reactionOnMessage.get(str)); reactionLayout.addView(chip); chip.setOnLongClickListener(new View.OnLongClickListener() { @@ -2425,12 +2485,12 @@ private void setColorFilter(BaseMessage baseMessage,View view){ { if (baseMessage.getSender().equals(CometChat.getLoggedInUser())) { if (view instanceof CardView) { - ((CardView)view).setCardBackgroundColor(Color.parseColor(UISettings.getColor())); + ((CardView)view).setCardBackgroundColor(Color.parseColor(FeatureRestriction.getColor())); } else { if (Build.VERSION.SDK_INT >= 29) { - view.getBackground().setColorFilter(new PorterDuffColorFilter(Color.parseColor(UISettings.getColor()), PorterDuff.Mode.SRC_ATOP)); + view.getBackground().setColorFilter(new PorterDuffColorFilter(Color.parseColor(FeatureRestriction.getColor()), PorterDuff.Mode.SRC_ATOP)); } else { - view.getBackground().setColorFilter(Color.parseColor(UISettings.getColor()), PorterDuff.Mode.SRC_ATOP); + view.getBackground().setColorFilter(Color.parseColor(FeatureRestriction.getColor()), PorterDuff.Mode.SRC_ATOP); } } } else { @@ -2442,11 +2502,7 @@ private void setColorFilter(BaseMessage baseMessage,View view){ } } } else { - if (baseMessage.getSentAt()>0 && (UISettings.isEnableEditingMessage() && - UISettings.isEnableDeleteMessage()) || - UISettings.isEnableShareCopyForward() || - UISettings.isEnableThreadedReplies() || - UISettings.isEnableReplyToMessage()) { + if (baseMessage.getSentAt()>0) { if (baseMessage.getSender().equals(CometChat.getLoggedInUser())) view.getBackground().setColorFilter(context.getResources().getColor(R.color.colorPrimaryDark), PorterDuff.Mode.SRC_ATOP); else @@ -2519,12 +2575,18 @@ private void setLinkData(LinkMessageViewHolder viewHolder, int i) { } } - if (baseMessage.getReplyCount()!=0 && UISettings.isEnableThreadedReplies()) { - viewHolder.tvThreadReplyCount.setVisibility(View.VISIBLE); - viewHolder.tvThreadReplyCount.setText(baseMessage.getReplyCount()+" Replies"); - } else { - viewHolder.tvThreadReplyCount.setVisibility(View.GONE); - } + FeatureRestriction.isThreadedMessagesEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (baseMessage.getReplyCount()!=0 && booleanVal) { + viewHolder.tvThreadReplyCount.setVisibility(View.VISIBLE); + viewHolder.tvThreadReplyCount.setText(baseMessage.getReplyCount()+" Replies"); + } else { + viewHolder.tvThreadReplyCount.setVisibility(View.GONE); + } + } + }); + viewHolder.tvThreadReplyCount.setOnClickListener(view -> { Intent intent = new Intent(context, CometChatThreadMessageListActivity.class); // intent.putExtra(StringContract.IntentStrings.PARENT_BASEMESSAGE,baseMessage.toString()); @@ -2676,8 +2738,8 @@ public void onBindHeaderViewHolder(DateItemHolder var1, int var2, long var3) { BaseMessage baseMessage = messageList.get(var2); var1.txtMessageDate.setBackground(context.getResources().getDrawable(R.drawable.cc_rounded_date_button)); if (baseMessage.getSentAt()>0) { - Date date = new Date(baseMessage.getSentAt() * 1000L); - String formattedDate = Utils.getDate(date.getTime()); + Date date = new Date(baseMessage.getSentAt()); + String formattedDate = Utils.getDate(context,date.getTime()); var1.txtMessageDate.setText(formattedDate); } else { var1.txtMessageDate.setText(context.getString(R.string.updating)); diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/thread_message_list/CometChatThreadMessageList.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/thread_message_list/CometChatThreadMessageList.java index 9143df1..b763802 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/thread_message_list/CometChatThreadMessageList.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/thread_message_list/CometChatThreadMessageList.java @@ -74,21 +74,37 @@ import com.cometchat.pro.models.TextMessage; import com.cometchat.pro.models.TypingIndicator; import com.cometchat.pro.models.User; - +import com.cometchat.pro.uikit.R; +import com.cometchat.pro.uikit.ui_components.groups.group_details.CometChatGroupDetailActivity; +import com.cometchat.pro.uikit.ui_components.messages.extensions.Collaborative.CometChatWebViewActivity; import com.cometchat.pro.uikit.ui_components.messages.extensions.Extensions; import com.cometchat.pro.uikit.ui_components.messages.forward_message.CometChatForwardMessageActivity; +import com.cometchat.pro.uikit.ui_components.messages.live_reaction.LiveReactionListener; +import com.cometchat.pro.uikit.ui_components.messages.live_reaction.ReactionClickListener; import com.cometchat.pro.uikit.ui_components.messages.message_actions.CometChatMessageActions; +import com.cometchat.pro.uikit.ui_components.messages.message_actions.listener.MessageActionCloseListener; +import com.cometchat.pro.uikit.ui_components.messages.message_actions.listener.OnMessageLongClick; +import com.cometchat.pro.uikit.ui_components.messages.message_information.CometChatMessageInfoScreenActivity; import com.cometchat.pro.uikit.ui_components.messages.message_list.CometChatMessageListActivity; import com.cometchat.pro.uikit.ui_components.shared.CometChatSnackBar; import com.cometchat.pro.uikit.ui_components.shared.cometchatAvatar.CometChatAvatar; import com.cometchat.pro.uikit.ui_components.shared.cometchatComposeBox.CometChatComposeBox; -import com.cometchat.pro.uikit.R; -import com.cometchat.pro.uikit.ui_components.shared.cometchatReaction.listener.OnReactionClickListener; +import com.cometchat.pro.uikit.ui_components.shared.cometchatComposeBox.listener.ComposeActionListener; import com.cometchat.pro.uikit.ui_components.shared.cometchatReaction.CometChatReactionDialog; +import com.cometchat.pro.uikit.ui_components.shared.cometchatReaction.listener.OnReactionClickListener; import com.cometchat.pro.uikit.ui_components.shared.cometchatReaction.model.Reaction; -import com.cometchat.pro.uikit.ui_resources.utils.CometChatError; -import com.cometchat.pro.uikit.ui_settings.UISettings; import com.cometchat.pro.uikit.ui_components.shared.cometchatSmartReplies.CometChatSmartReplies; +import com.cometchat.pro.uikit.ui_components.users.user_details.CometChatUserDetailScreenActivity; +import com.cometchat.pro.uikit.ui_resources.constants.UIKitConstants; +import com.cometchat.pro.uikit.ui_resources.utils.CallUtils; +import com.cometchat.pro.uikit.ui_resources.utils.CometChatError; +import com.cometchat.pro.uikit.ui_resources.utils.FontUtils; +import com.cometchat.pro.uikit.ui_resources.utils.MediaUtils; +import com.cometchat.pro.uikit.ui_resources.utils.Utils; +import com.cometchat.pro.uikit.ui_resources.utils.item_clickListener.OnItemClickListener; +import com.cometchat.pro.uikit.ui_resources.utils.keyboard_utils.KeyBoardUtils; +import com.cometchat.pro.uikit.ui_resources.utils.sticker_header.StickyHeaderDecoration; +import com.cometchat.pro.uikit.ui_settings.FeatureRestriction; import com.facebook.shimmer.ShimmerFrameLayout; import com.google.android.gms.location.FusedLocationProviderClient; import com.google.android.gms.location.LocationServices; @@ -111,24 +127,6 @@ import java.util.Timer; import java.util.TimerTask; -import com.cometchat.pro.uikit.ui_resources.constants.UIKitConstants; -import com.cometchat.pro.uikit.ui_components.shared.cometchatComposeBox.listener.ComposeActionListener; -import com.cometchat.pro.uikit.ui_components.messages.live_reaction.LiveReactionListener; -import com.cometchat.pro.uikit.ui_components.messages.message_actions.listener.MessageActionCloseListener; -import com.cometchat.pro.uikit.ui_resources.utils.item_clickListener.OnItemClickListener; -import com.cometchat.pro.uikit.ui_components.messages.message_actions.listener.OnMessageLongClick; -import com.cometchat.pro.uikit.ui_components.messages.live_reaction.ReactionClickListener; -import com.cometchat.pro.uikit.ui_resources.utils.sticker_header.StickyHeaderDecoration; -import com.cometchat.pro.uikit.ui_components.groups.group_details.CometChatGroupDetailActivity; -import com.cometchat.pro.uikit.ui_components.messages.message_information.CometChatMessageInfoScreenActivity; -import com.cometchat.pro.uikit.ui_components.users.user_details.CometChatUserDetailScreenActivity; -import com.cometchat.pro.uikit.ui_components.messages.extensions.Collaborative.CometChatCollaborativeActivity; -import com.cometchat.pro.uikit.ui_resources.utils.CallUtils; -import com.cometchat.pro.uikit.ui_resources.utils.FontUtils; -import com.cometchat.pro.uikit.ui_resources.utils.keyboard_utils.KeyBoardUtils; -import com.cometchat.pro.uikit.ui_resources.utils.MediaUtils; -import com.cometchat.pro.uikit.ui_resources.utils.Utils; - import static android.view.View.GONE; import static android.view.View.VISIBLE; @@ -279,6 +277,20 @@ public class CometChatThreadMessageList extends Fragment implements View.OnClick private ChipGroup reactionLayout; private HashMap reactionInfo = new HashMap<>(); + boolean shareVisible; + boolean copyVisible; + boolean forwardVisible; + boolean threadVisible = false; + boolean replyVisible; + boolean translateVisible; + boolean reactionVisible; + boolean editVisible; + boolean retryVisible = false; + boolean replyPrivately; + boolean deleteVisible; + + boolean hideDeleteMessages; + public CometChatThreadMessageList() { // Required empty public constructor } @@ -352,6 +364,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa private void initViewComponent(View view) { setHasOptionsMenu(true); + + CometChatError.init(getContext()); nestedScrollView = view.findViewById(R.id.nested_scrollview); noReplyMessages = view.findViewById(R.id.no_reply_layout); ivMoreOption = view.findViewById(R.id.ic_more_option); @@ -419,7 +433,7 @@ private void initViewComponent(View view) { @Override public void onClick(View view) { String boardUrl = message; - Intent intent = new Intent(context, CometChatCollaborativeActivity.class); + Intent intent = new Intent(context, CometChatWebViewActivity.class); intent.putExtra(UIKitConstants.IntentStrings.URL, boardUrl); startActivity(intent); } @@ -435,7 +449,7 @@ public void onClick(View view) { @Override public void onClick(View view) { String boardUrl = message; - Intent intent = new Intent(context, CometChatCollaborativeActivity.class); + Intent intent = new Intent(context, CometChatWebViewActivity.class); intent.putExtra(UIKitConstants.IntentStrings.URL, boardUrl); startActivity(intent); } @@ -508,7 +522,7 @@ public void onSuccess(JSONObject jsonObject) { // Voted successfully Log.e(TAG, "onSuccess: "+jsonObject.toString()); CometChatSnackBar.show(context,rvChatListView, - context.getString(R.string.voted_success),CometChatSnackBar.SUCCESS); + context.getString(R.string.voted_success), CometChatSnackBar.SUCCESS); } @Override @@ -587,7 +601,7 @@ public void onError(CometChatException e) { composeBox.hideWhiteBoardOption(true); composeBox.hideGroupCallOption(true); composeBox.hideRecordOption(true); - composeBox.hideSendButton(!UISettings.isEnableSendingMessage()); + composeBox.hideSendButton(false); container = view.findViewById(R.id.reactions_container); composeBox.liveReactionBtn.setOnTouchListener(new LiveReactionListener(700, 1000, new ReactionClickListener() { @@ -658,7 +672,7 @@ public void run() { senderName = view.findViewById(R.id.tv_sender_name); senderName.setText(name); sentAt = view.findViewById(R.id.tv_message_time); - sentAt.setText(String.format(getString(R.string.sentattxt),Utils.getLastMessageDate(messageSentAt))); + sentAt.setText(String.format(getString(R.string.sentattxt), Utils.getLastMessageDate(context,messageSentAt))); tvReplyCount = view.findViewById(R.id.thread_reply_count); rvChatListView = view.findViewById(R.id.rv_message_list); if (parentMessageCategory.equals(CometChatConstants.CATEGORY_CUSTOM)) { @@ -761,7 +775,7 @@ private void setReactionForParentMessage() { Chip chip = new Chip(context); chip.setChipStrokeWidth(2f); chip.setChipBackgroundColor(ColorStateList.valueOf(context.getResources().getColor(android.R.color.transparent))); - chip.setChipStrokeColor(ColorStateList.valueOf(Color.parseColor(UISettings.getColor()))); + chip.setChipStrokeColor(ColorStateList.valueOf(Color.parseColor(FeatureRestriction.getColor()))); chip.setText(key + " " + reactionInfo.get(key)); reactionLayout.addView(chip); chip.setOnClickListener(new View.OnClickListener() { @@ -794,6 +808,8 @@ public void onError(CometChatException e) { } }); } + + fetchSettings(); } private void checkOnGoingCall() { @@ -805,7 +821,7 @@ private void checkOnGoingCall() { @Override public void onClick(View v) { onGoingCallView.setVisibility(View.GONE); - CallUtils.joinOnGoingCall(getContext(),CometChat.getActiveCall()); + CallUtils.joinOnGoingCall(getContext(), CometChat.getActiveCall()); } }); } @@ -820,7 +836,7 @@ public void onClick(View v) { } else if (CometChat.getActiveCall()!=null){ if (onGoingCallView!=null) onGoingCallView.setVisibility(GONE); - Log.e(TAG, "checkOnGoingCall: "+CometChat.getActiveCall().toString()); + Log.e(TAG, "checkOnGoingCall: "+ CometChat.getActiveCall().toString()); } } @@ -965,7 +981,7 @@ private void initAlert(JSONObject customData) { e.printStackTrace(); } TextView address = view.findViewById(R.id.address); - address.setText("Address: "+Utils.getAddress(context,LATITUDE,LONGITUDE)); + address.setText("Address: "+ Utils.getAddress(context,LATITUDE,LONGITUDE)); ImageView mapView = view.findViewById(R.id.map_vw); String mapUrl = UIKitConstants.MapUrl.MAPS_URL +LATITUDE+","+LONGITUDE+"&key="+ UIKitConstants.MapUrl.MAP_ACCESS_KEY; @@ -1012,7 +1028,7 @@ public void onSuccess(CustomMessage customMessage) { @Override public void onError(CometChatException e) { if (getActivity() != null) { - CometChatSnackBar.show(context,rvChatListView,CometChatError.localized(e),CometChatSnackBar.ERROR); + CometChatSnackBar.show(context,rvChatListView, CometChatError.localized(e), CometChatSnackBar.ERROR); } } }); @@ -1070,7 +1086,7 @@ public void onSuccess(BaseMessage baseMessage) { @Override public void onError(CometChatException e) { - CometChatSnackBar.show(context,rvChatListView,CometChatError.localized(e),CometChatSnackBar.ERROR); + CometChatSnackBar.show(context,rvChatListView, CometChatError.localized(e), CometChatSnackBar.ERROR); Log.d(TAG, "onError: " + e.getMessage()); } }); @@ -1110,7 +1126,7 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis } private void showPermissionSnackBar(View view, String message) { - CometChatSnackBar.show(context,view,message,CometChatSnackBar.WARNING); + CometChatSnackBar.show(context,view,message, CometChatSnackBar.WARNING); } @Override @@ -1143,7 +1159,7 @@ private void unblockUser() { @Override public void onSuccess(HashMap stringStringHashMap) { CometChatSnackBar.show(context,rvChatListView, - name+" "+getResources().getString(R.string.unblocked_successfully),CometChatSnackBar.SUCCESS); + name+" "+getResources().getString(R.string.unblocked_successfully), CometChatSnackBar.SUCCESS); blockUserLayout.setVisibility(GONE); isBlockedByMe = false; messagesRequest=null; @@ -1151,8 +1167,8 @@ public void onSuccess(HashMap stringStringHashMap) { @Override public void onError(CometChatException e) { - CometChatSnackBar.show(context,rvChatListView,CometChatError.localized(e) - ,CometChatSnackBar.ERROR); + CometChatSnackBar.show(context,rvChatListView, CometChatError.localized(e) + , CometChatSnackBar.ERROR); } }); } @@ -1171,16 +1187,18 @@ private void fetchMessage() { if (messagesRequest == null) { if (type.equals(CometChatConstants.RECEIVER_TYPE_USER)) messagesRequest = new MessagesRequest.MessagesRequestBuilder().setLimit(LIMIT) - .setParentMessageId(parentId) - .setTypes(UIKitConstants.MessageRequest.messageTypesForUser) - .setCategories(UIKitConstants.MessageRequest.messageCategoriesForUser) - .hideMessagesFromBlockedUsers(true).build(); + .setParentMessageId(parentId) + .setCategories(UIKitConstants.MessageRequest.messageCategoriesForUser) + .setTypes(UIKitConstants.MessageRequest.messageTypesForUser) + .hideDeletedMessages(hideDeleteMessages) + .build(); else messagesRequest = new MessagesRequest.MessagesRequestBuilder().setLimit(LIMIT) .setParentMessageId(parentId) - .setTypes(UIKitConstants.MessageRequest.messageTypesForGroup) .setCategories(UIKitConstants.MessageRequest.messageCategoriesForGroup) - .hideMessagesFromBlockedUsers(true).build(); + .setTypes(UIKitConstants.MessageRequest.messageTypesForGroup) + .hideDeletedMessages(hideDeleteMessages) + .build(); } messagesRequest.fetchPrevious(new CometChat.CallbackListener>() { @@ -1190,7 +1208,6 @@ public void onSuccess(List baseMessages) { initMessageAdapter(baseMessages); if (baseMessages.size() != 0) { stopHideShimmer(); - noReplyMessages.setVisibility(GONE); BaseMessage baseMessage = baseMessages.get(baseMessages.size() - 1); markMessageAsRead(baseMessage); } @@ -1203,7 +1220,7 @@ public void onSuccess(List baseMessages) { @Override public void onError(CometChatException e) { - CometChatSnackBar.show(context,rvChatListView,CometChatError.localized(e),CometChatSnackBar.ERROR); + CometChatSnackBar.show(context,rvChatListView, CometChatError.localized(e), CometChatSnackBar.ERROR); Log.d(TAG, "onError: " + e.getMessage()); } }); @@ -1304,7 +1321,7 @@ public void onActivityResult(int requestCode, int resultCode, @Nullable Intent d case UIKitConstants.RequestCode.AUDIO: if (data!=null) { resultIntentCode = UIKitConstants.RequestCode.AUDIO; - File file = MediaUtils.getRealPath(getContext(),data.getData()); + File file = MediaUtils.getRealPath(getContext(),data.getData(),false); ContentResolver cr = getActivity().getContentResolver(); sendMediaMessage(file, CometChatConstants.MESSAGE_TYPE_AUDIO); } @@ -1312,7 +1329,7 @@ public void onActivityResult(int requestCode, int resultCode, @Nullable Intent d case UIKitConstants.RequestCode.GALLERY: if (data != null) { resultIntentCode = UIKitConstants.RequestCode.GALLERY; - File file = MediaUtils.getRealPath(getContext(), data.getData()); + File file = MediaUtils.getRealPath(getContext(), data.getData(),false); ContentResolver cr = getActivity().getContentResolver(); String mimeType = cr.getType(data.getData()); if (mimeType!=null && mimeType.contains("image")) { @@ -1334,20 +1351,20 @@ public void onActivityResult(int requestCode, int resultCode, @Nullable Intent d File file; resultIntentCode = UIKitConstants.RequestCode.CAMERA; if (Build.VERSION.SDK_INT >= 29) { - file = MediaUtils.getRealPath(getContext(), MediaUtils.uri); + file = MediaUtils.getRealPath(getContext(), MediaUtils.uri,false); } else { file = new File(MediaUtils.pictureImagePath); } if (file.exists()) sendMediaMessage(file, CometChatConstants.MESSAGE_TYPE_IMAGE); else - Snackbar.make(rvChatListView,R.string.file_not_exist,Snackbar.LENGTH_LONG).show(); + Snackbar.make(rvChatListView, R.string.file_not_exist,Snackbar.LENGTH_LONG).show(); break; case UIKitConstants.RequestCode.FILE: if (data != null) { resultIntentCode = UIKitConstants.RequestCode.FILE; - sendMediaMessage(MediaUtils.getRealPath(getActivity(), data.getData()), CometChatConstants.MESSAGE_TYPE_FILE); + sendMediaMessage(MediaUtils.getRealPath(getActivity(), data.getData(),false), CometChatConstants.MESSAGE_TYPE_FILE); } break; case UIKitConstants.RequestCode.BLOCK_USER: @@ -1420,8 +1437,8 @@ public void onError(CometChatException e) { messageAdapter.updateChangedMessage(mediaMessage); } if (getActivity() != null) { - CometChatSnackBar.show(context,rvChatListView,CometChatError.localized(e) - ,CometChatSnackBar.ERROR); + CometChatSnackBar.show(context,rvChatListView, CometChatError.localized(e) + , CometChatSnackBar.ERROR); } } }); @@ -1519,7 +1536,7 @@ private void sendMessage(String message) { textMessage.setSender(loggedInUser); textMessage.setMuid(System.currentTimeMillis()+""); if (messageAdapter != null) { - MediaUtils.playSendSound(context,R.raw.outgoing_message); + MediaUtils.playSendSound(context, R.raw.outgoing_message); messageAdapter.addMessage(textMessage); scrollToBottom(); } @@ -1544,7 +1561,7 @@ public void onError(CometChatException e) { } if (getActivity() != null) { CometChatSnackBar.show(context,rvChatListView, - CometChatError.localized(e),CometChatSnackBar.ERROR); + CometChatError.localized(e), CometChatSnackBar.ERROR); } Log.d(TAG, "onError: " + e.getMessage()); } @@ -1571,7 +1588,7 @@ public void onSuccess(BaseMessage baseMessage) { public void onError(CometChatException e) { CometChatSnackBar.show(context,rvChatListView, - CometChatError.localized(e),CometChatSnackBar.ERROR); + CometChatError.localized(e), CometChatSnackBar.ERROR); Log.d(TAG, "onError: " + e.getMessage()); } }); @@ -1610,7 +1627,7 @@ public void onSuccess(BaseMessage message) { @Override public void onError(CometChatException e) { CometChatSnackBar.show(context,rvChatListView, - CometChatError.localized(e),CometChatSnackBar.ERROR); + CometChatError.localized(e), CometChatSnackBar.ERROR); Log.d(TAG, "onError: " + e.getMessage()); } }); @@ -1658,7 +1675,7 @@ private void replyMessage(BaseMessage baseMessage, String message) { @Override public void onSuccess(TextMessage textMessage) { if (messageAdapter != null) { - MediaUtils.playSendSound(context,R.raw.outgoing_message); + MediaUtils.playSendSound(context, R.raw.outgoing_message); messageAdapter.addMessage(textMessage); scrollToBottom(); } @@ -1772,7 +1789,12 @@ public void onMessageEdited(BaseMessage message) { @Override public void onMessageDeleted(BaseMessage message) { Log.d(TAG, "onMessageDeleted: "); - updateMessage(message); + if (messageAdapter!=null) { + if (hideDeleteMessages) + messageAdapter.remove(message); + else + updateMessage(message); + } } }); } @@ -1790,7 +1812,7 @@ private void setMessageReciept(MessageReceipt messageReceipt) { } } - private void setTypingIndicator(TypingIndicator typingIndicator,boolean isShow) { + 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())) { @@ -1805,7 +1827,7 @@ private void setTypingIndicator(TypingIndicator typingIndicator,boolean isShow) private void onMessageReceived(BaseMessage message) { noReplyMessages.setVisibility(GONE); - 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())) { if (message.getParentMessageId()==parentId) @@ -1882,15 +1904,25 @@ private void typingIndicator(TypingIndicator typingIndicator, boolean show) { if (show) { if (typingIndicator.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_USER)) { if (typingIndicator.getMetadata() == null) { - if (UISettings.isShowTypingIndicators()) - tvTypingIndicator.setText("is Typing..."); + FeatureRestriction.isTypingIndicatorsEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (booleanVal) + tvTypingIndicator.setText("is Typing..."); + } + }); } else setLiveReaction(); } else { if (typingIndicator.getMetadata() == null) { - if (UISettings.isShowTypingIndicators()) - tvTypingIndicator.setText(typingIndicator.getSender().getName() + " is Typing..."); + FeatureRestriction.isTypingIndicatorsEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (booleanVal) + tvTypingIndicator.setText(typingIndicator.getSender().getName() + " is Typing..."); + } + }); } else setLiveReaction(); @@ -1953,7 +1985,7 @@ public void onResume() { Log.d(TAG, "onResume: "); if (!(resultIntentCode== UIKitConstants.RequestCode.GALLERY || resultIntentCode== UIKitConstants.RequestCode.CAMERA || - resultIntentCode==UIKitConstants.RequestCode.FILE || + resultIntentCode== UIKitConstants.RequestCode.FILE || resultIntentCode== UIKitConstants.RequestCode.AUDIO)) { messagesRequest = null; messageAdapter = null; @@ -1992,13 +2024,7 @@ public void onDetach() { public void onClick(View view) { int id = view.getId(); - if (id == R.id.iv_close_message_action) { - if (messageAdapter != null) { - messageAdapter.clearLongClickSelectedItem(); - messageAdapter.notifyDataSetChanged(); - } - } - else if (id == R.id.ic_more_option) { + if (id == R.id.ic_more_option) { CometChatMessageActions messageActionFragment = new CometChatMessageActions(); Bundle bundle = new Bundle(); if (messageType.equals(CometChatConstants.MESSAGE_TYPE_TEXT)) { @@ -2077,14 +2103,7 @@ public void setLongMessageClick(List baseMessagesList) { messageActionFragment = new CometChatMessageActions(); replyMessageLayout.setVisibility(GONE); editMessageLayout.setVisibility(GONE); - boolean copyVisible = UISettings.isEnableShareCopyForward(); - boolean threadVisible = false; - boolean replyVisible = false; - boolean editVisible = UISettings.isEnableEditingMessage(); - boolean deleteVisible = UISettings.isEnableDeleteMessage(); - boolean forwardVisible = UISettings.isEnableShareCopyForward(); - boolean reactionVisible = UISettings.isReactionVisible(); - boolean translateVisible = UISettings.isTranslationAllowed(); + fetchSettings(); List textMessageList = new ArrayList<>(); List mediaMessageList = new ArrayList<>(); List locationMessageList = new ArrayList<>(); @@ -2103,21 +2122,39 @@ else if (baseMessage.getType().equals(CometChatConstants.MESSAGE_TYPE_IMAGE) || } } if (textMessageList.size() == 1) { - translateVisible = UISettings.isTranslationAllowed(); + FeatureRestriction.isMessageTranslationEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + translateVisible = booleanVal; + } + }); BaseMessage basemessage = textMessageList.get(0); if (basemessage != null && basemessage.getSender() != null) { if (!(basemessage instanceof Action) && basemessage.getDeletedAt() == 0) { baseMessage = basemessage; threadVisible = false; if (basemessage.getSender().getUid().equals(CometChat.getLoggedInUser().getUid())) { - deleteVisible = true; - editVisible = true; - forwardVisible = true; + FeatureRestriction.isDeleteMessageEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + deleteVisible = booleanVal; + } + }); + FeatureRestriction.isEditMessageEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + editVisible = booleanVal; + } + }); } else { editVisible = false; - forwardVisible = true; if (loggedInUserScope!=null && (loggedInUserScope.equals(CometChatConstants.SCOPE_ADMIN) || loggedInUserScope.equals(CometChatConstants.SCOPE_MODERATOR))) { - deleteVisible = true; + FeatureRestriction.isDeleteMemberMessageEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + deleteVisible = booleanVal; + } + }); } else { deleteVisible = false; } @@ -2135,16 +2172,24 @@ else if (baseMessage.getType().equals(CometChatConstants.MESSAGE_TYPE_IMAGE) || copyVisible = false; threadVisible = false; if (basemessage.getSender().getUid().equals(CometChat.getLoggedInUser().getUid())) { - deleteVisible = true; + FeatureRestriction.isDeleteMessageEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + deleteVisible = booleanVal; + } + }); editVisible = false; - forwardVisible = true; } else { if (loggedInUserScope!=null && (loggedInUserScope.equals(CometChatConstants.SCOPE_ADMIN) || loggedInUserScope.equals(CometChatConstants.SCOPE_MODERATOR))){ - deleteVisible = true; + FeatureRestriction.isDeleteMemberMessageEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + deleteVisible = booleanVal; + } + }); } else { deleteVisible = false; } - forwardVisible = true; editVisible = false; } } @@ -2159,13 +2204,22 @@ else if (baseMessage.getType().equals(CometChatConstants.MESSAGE_TYPE_IMAGE) || threadVisible = false; copyVisible = false; replyVisible = false; - forwardVisible = true; if (basemessage.getSender().getUid().equals(CometChat.getLoggedInUser().getUid())) { - deleteVisible = true; + FeatureRestriction.isDeleteMessageEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + deleteVisible = booleanVal; + } + }); editVisible = false; } else { if (loggedInUserScope!=null && (loggedInUserScope.equals(CometChatConstants.SCOPE_ADMIN) || loggedInUserScope.equals(CometChatConstants.SCOPE_MODERATOR))){ - deleteVisible = true; + FeatureRestriction.isDeleteMemberMessageEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + deleteVisible = booleanVal; + } + }); } else { deleteVisible = false; } @@ -2189,13 +2243,18 @@ else if (baseMessage.getType().equals(CometChatConstants.MESSAGE_TYPE_IMAGE) || if (!baseMessage.getSender().getUid().equalsIgnoreCase(loggedInUser.getUid())) { bundle.putBoolean("privateReplyVisible", true); - bundle.putString("userAvatar",baseMessage.getSender().getAvatar()); - bundle.putString("userName",baseMessage.getSender().getName()); } if (baseMessage.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_GROUP) && - baseMessage.getSender().getUid().equals(loggedInUser.getUid())) - bundle.putBoolean("messageInfoVisible",true); + baseMessage.getSender().getUid().equals(loggedInUser.getUid())) { + FeatureRestriction.isDeliveryReceiptsEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (booleanVal) + bundle.putBoolean("messageInfoVisible", true); + } + }); + } bundle.putString("type", CometChatThreadMessageListActivity.class.getName()); messageActionFragment.setArguments(bundle); if (baseMessage.getSentAt()!=0) { @@ -2206,6 +2265,63 @@ else if (baseMessage.getType().equals(CometChatConstants.MESSAGE_TYPE_IMAGE) || } } + private void fetchSettings() { + FeatureRestriction.isShareCopyForwardMessageEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + shareVisible = booleanVal; + copyVisible = booleanVal; + forwardVisible = booleanVal; + } + }); + FeatureRestriction.isMessageRepliesEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + replyVisible = booleanVal; + } + }); + FeatureRestriction.isEditMessageEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + editVisible = booleanVal; + } + }); + FeatureRestriction.isDeleteMessageEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + deleteVisible = booleanVal; + } + }); + FeatureRestriction.isReactionEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + reactionVisible = booleanVal; + } + }); + FeatureRestriction.isMessageTranslationEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + translateVisible = booleanVal; + } + }); + FeatureRestriction.isLiveReactionEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (booleanVal) { + composeBox.liveReactionBtn.setVisibility(VISIBLE); + } else { + composeBox.liveReactionBtn.setVisibility(GONE); + } + } + }); + FeatureRestriction.isHideDeleteMessageEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + hideDeleteMessages = booleanVal; + } + }); + } + private void showBottomSheet(CometChatMessageActions messageActionFragment) { messageActionFragment.show(getFragmentManager(),messageActionFragment.getTag()); messageActionFragment.setMessageActionListener(new CometChatMessageActions.MessageActionListener() { @@ -2218,9 +2334,11 @@ public void onPrivateReplyToUser() { intent.putExtra(UIKitConstants.IntentStrings.AVATAR, user.getAvatar()); intent.putExtra(UIKitConstants.IntentStrings.STATUS, user.getStatus()); intent.putExtra(UIKitConstants.IntentStrings.NAME, user.getName()); + intent.putExtra(UIKitConstants.IntentStrings.LINK,user.getLink()); intent.putExtra(UIKitConstants.IntentStrings.TYPE, CometChatConstants.RECEIVER_TYPE_USER); startActivity(intent); - getActivity().finish(); + if (getActivity()!=null) + getActivity().finish(); } } @@ -2268,7 +2386,7 @@ public void onCopyMessageClick() { } else { for (BaseMessage bMessage : baseMessages) { if (bMessage.getDeletedAt() == 0 && bMessage instanceof TextMessage) { - copyMessage = copyMessage + "[" + Utils.getLastMessageDate(bMessage.getSentAt()) + "] " + bMessage.getSender().getName() + ": " + ((TextMessage) bMessage).getText(); + copyMessage = copyMessage + "[" + Utils.getLastMessageDate(context,bMessage.getSentAt()) + "] " + bMessage.getSender().getName() + ": " + ((TextMessage) bMessage).getText(); } } isParent = false; @@ -2370,7 +2488,7 @@ public void onSuccess(JSONObject jsonObject) { textMessage.setText(translatedMessage); } else { CometChatSnackBar.show(context,rvChatListView, - getString(R.string.no_translation_available),CometChatSnackBar.INFO); + getString(R.string.no_translation_available), CometChatSnackBar.INFO); } } else { if (Extensions.isMessageTranslated(jsonObject,((TextMessage)baseMessage).getText())) { @@ -2389,7 +2507,7 @@ public void onSuccess(JSONObject jsonObject) { } } else { CometChatSnackBar.show(context,rvChatListView, - getString(R.string.no_translation_available),CometChatSnackBar.INFO); + getString(R.string.no_translation_available), CometChatSnackBar.INFO); } } } @@ -2608,10 +2726,8 @@ private void sendLiveReaction() { } private void setLiveReaction() { - if (UISettings.showLiveReaction()) { - container.setAlpha(1.0f); - flyEmoji(R.drawable.heart_reaction); - } + container.setAlpha(1.0f); + flyEmoji(R.drawable.heart_reaction); } private void flyEmoji(final int resId) { diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/thread_message_list/CometChatThreadMessageListActivity.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/thread_message_list/CometChatThreadMessageListActivity.java index ee3263c..4867c44 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/thread_message_list/CometChatThreadMessageListActivity.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/thread_message_list/CometChatThreadMessageListActivity.java @@ -27,7 +27,7 @@ import com.cometchat.pro.uikit.ui_components.messages.message_actions.listener.MessageActionCloseListener; import com.cometchat.pro.uikit.ui_components.messages.message_actions.listener.OnMessageLongClick; -import com.cometchat.pro.uikit.ui_settings.UISettings; +import com.cometchat.pro.uikit.ui_settings.FeatureRestriction; /** @@ -109,8 +109,8 @@ 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())); + if (FeatureRestriction.getColor() !=null) { + getWindow().setStatusBarColor(Color.parseColor(FeatureRestriction.getColor())); } EmojiCompat.Config config = new BundledEmojiCompatConfig(this); EmojiCompat.init(config); diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/thread_message_list/ThreadAdapter.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/thread_message_list/ThreadAdapter.java index b0886ea..6a5dede 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/thread_message_list/ThreadAdapter.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/messages/thread_message_list/ThreadAdapter.java @@ -50,7 +50,7 @@ import com.cometchat.pro.uikit.R; import com.cometchat.pro.uikit.ui_resources.utils.pattern_utils.PatternUtils; -import com.cometchat.pro.uikit.ui_settings.UISettings; +import com.cometchat.pro.uikit.ui_settings.FeatureRestriction; import com.google.android.material.button.MaterialButton; import com.google.android.material.chip.Chip; import com.google.android.material.chip.ChipGroup; @@ -990,7 +990,7 @@ private void setReactionSupport(BaseMessage baseMessage, ChipGroup reactionLayou Chip chip = new Chip(context); chip.setChipStrokeWidth(2f); chip.setChipBackgroundColor(ColorStateList.valueOf(context.getResources().getColor(android.R.color.transparent))); - chip.setChipStrokeColor(ColorStateList.valueOf(Color.parseColor(UISettings.getColor()))); + chip.setChipStrokeColor(ColorStateList.valueOf(Color.parseColor(FeatureRestriction.getColor()))); chip.setText(str + " " + reactionOnMessage.get(str)); reactionLayout.addView(chip); chip.setOnLongClickListener(new View.OnLongClickListener() { @@ -1181,29 +1181,11 @@ public int getItemCount() { return messageList.size(); } -// @Override -// public long getHeaderId(int var1) { -// -// BaseMessage baseMessage = messageList.get(var1); -// return Long.parseLong(Utils.getDateId(baseMessage.getSentAt() * 1000)); -// } -// -// @Override -// public DateItemHolder onCreateHeaderViewHolder(ViewGroup var1) { -// View view = LayoutInflater.from(var1.getContext()).inflate(R.layout.cc_message_list_header, -// var1, false); -// -// return new DateItemHolder(view); -// } -// -// @Override -// public void onBindHeaderViewHolder(DateItemHolder var1, int var2, long var3) { -// BaseMessage baseMessage = messageList.get(var2); -// Date date = new Date(baseMessage.getSentAt() * 1000L); -// String formattedDate = Utils.getDate(date.getTime()); -// var1.txtMessageDate.setBackground(context.getResources().getDrawable(R.drawable.cc_rounded_date_button)); -// var1.txtMessageDate.setText(formattedDate); -// } + public void remove(BaseMessage baseMessage) { + int index = messageList.indexOf(baseMessage); + messageList.remove(baseMessage); + notifyItemRemoved(index); + } /** * This method is used to maintain different viewType based on message category and type and diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/CometChatSnackBar.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/CometChatSnackBar.java index 4ad3894..e398c6c 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/CometChatSnackBar.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/CometChatSnackBar.java @@ -22,7 +22,6 @@ public class CometChatSnackBar { public static void show(Context context, View parentLayout, String message, String type) { customSnackBar(context,parentLayout,message,type); } - private static void customSnackBar(Context context,View parentLayout,String message, String type) { Snackbar snackbar = Snackbar.make(parentLayout, "", Snackbar.LENGTH_INDEFINITE); // Get the Snackbar's layout view diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatAvatar/CometChatAvatar.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatAvatar/CometChatAvatar.java index f14682e..c43af79 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatAvatar/CometChatAvatar.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatAvatar/CometChatAvatar.java @@ -32,7 +32,7 @@ import com.cometchat.pro.models.User; import com.cometchat.pro.uikit.R; -import com.cometchat.pro.uikit.ui_settings.UISettings; +import com.cometchat.pro.uikit.ui_settings.FeatureRestriction; import com.cometchat.pro.uikit.ui_resources.utils.Utils; /** @@ -242,8 +242,8 @@ protected void init() { cornerRadius = (int) Utils.dpToPixel(2, getResources()); paint = new Paint(Paint.ANTI_ALIAS_FLAG); - if (UISettings.getColor()!=null && !UISettings.getColor().isEmpty()) { - paint.setColor(Color.parseColor(UISettings.getColor())); + if (FeatureRestriction.getColor()!=null && !FeatureRestriction.getColor().isEmpty()) { + paint.setColor(Color.parseColor(FeatureRestriction.getColor())); } else paint.setColor(getResources().getColor(R.color.colorPrimary)); @@ -255,15 +255,13 @@ protected void init() { borderPaint = new Paint(); borderPaint.setStyle(Paint.Style.STROKE); borderPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER)); - // borderPaint.setColor(ContextCompat.getColor(context, R.color.border_color)); - // borderPaint.setStrokeWidth(context.getResources().getDimension(R.dimen.border_width)); borderPaint.setColor(borderColor); borderPaint.setAntiAlias(true); borderPaint.setStrokeWidth(borderWidth); - if (UISettings.getColor()!=null && UISettings.getColor().isEmpty()) - color = Color.parseColor(UISettings.getColor()); + if (FeatureRestriction.getColor()!=null && FeatureRestriction.getColor().isEmpty()) + color = Color.parseColor(FeatureRestriction.getColor()); else color = getResources().getColor(R.color.colorPrimary); diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatCalls/CometChatCallsAdapter.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatCalls/CometChatCallsAdapter.java index 5e8449e..ebedb86 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatCalls/CometChatCallsAdapter.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatCalls/CometChatCallsAdapter.java @@ -25,7 +25,7 @@ import com.cometchat.pro.uikit.databinding.CometchatCallListRowBinding; import com.cometchat.pro.uikit.ui_resources.utils.FontUtils; -import com.cometchat.pro.uikit.ui_settings.UISettings; +import com.cometchat.pro.uikit.ui_settings.FeatureRestriction; import com.cometchat.pro.uikit.ui_resources.utils.Utils; /** @@ -187,16 +187,19 @@ public void onBindViewHolder(@NonNull CallViewHolder callViewHolder, int positio callViewHolder.callListRowBinding.callMessage.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_call_outgoing_24dp,0,0,0); } } - callViewHolder.callListRowBinding.calltimeTv.setText(Utils.getLastMessageDate(call.getInitiatedAt())); + callViewHolder.callListRowBinding.calltimeTv.setText(Utils.getLastMessageDate(context,call.getInitiatedAt())); callViewHolder.callListRowBinding.callMessage.setText(callMessageText); callViewHolder.callListRowBinding.getRoot().setTag(R.string.call, call); - if (UISettings.isEnableVoiceCalling() || UISettings.isEnableVideoCalling()) - callViewHolder.callListRowBinding.callIv.setVisibility(View.VISIBLE); - else - callViewHolder.callListRowBinding.callIv.setVisibility(View.GONE); + if (call.getReceiverType().equalsIgnoreCase(CometChatConstants.RECEIVER_TYPE_USER)) { +// if(FeatureRestriction.isOneOnOneAudioCallEnabled() || +// FeatureRestriction.isOneOnOneVideoCallEnabled()) + callViewHolder.callListRowBinding.callIv.setVisibility(View.VISIBLE); +// else +// callViewHolder.callListRowBinding.callIv.setVisibility(View.GONE); + } callViewHolder.callListRowBinding.callIv.setImageTintList( - ColorStateList.valueOf(Color.parseColor(UISettings.getColor()))); + ColorStateList.valueOf(Color.parseColor(FeatureRestriction.getColor()))); } diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatComposeBox/CometChatComposeBox.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatComposeBox/CometChatComposeBox.java index 722794d..a72c03c 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatComposeBox/CometChatComposeBox.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatComposeBox/CometChatComposeBox.java @@ -31,7 +31,6 @@ import androidx.fragment.app.FragmentManager; import com.cometchat.pro.core.CometChat; -import com.cometchat.pro.exceptions.CometChatException; import com.cometchat.pro.uikit.R; import java.io.File; @@ -42,11 +41,9 @@ import com.cometchat.pro.uikit.ui_resources.constants.UIKitConstants; import com.cometchat.pro.uikit.ui_components.shared.cometchatComposeBox.listener.ComposeActionListener; import com.cometchat.pro.uikit.ui_resources.utils.audio_visualizer.AudioRecordView; -import com.cometchat.pro.uikit.ui_settings.UISettings; +import com.cometchat.pro.uikit.ui_settings.FeatureRestriction; import com.cometchat.pro.uikit.ui_resources.utils.Utils; -import okhttp3.internal.Util; - public class CometChatComposeBox extends RelativeLayout implements View.OnClickListener { private static final String TAG = CometChatComposeBox.class.getName(); @@ -222,10 +219,6 @@ public void onWriteBoardClick() { composeActionListener.onWriteboardClicked(); } - @Override - public void onVideoMeetingClick() { - composeActionListener.onVideoMeetingClicked(); - } }); etComposeBox.addTextChangedListener(new TextWatcher() { @Override @@ -284,38 +277,83 @@ 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()); + if (FeatureRestriction.getColor()!=null) { + int settingsColor = Color.parseColor(FeatureRestriction.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(); - isWhiteBoardVisible = UISettings.isWhiteBoardVisible(); - isWriteBoardVisible = UISettings.isWriteBoardVisible(); - isGroupCallVisible = UISettings.isEnableVideoCalling(); - - if (UISettings.isSendVoiceNotes()) { - ivMic.setVisibility(View.VISIBLE); - } else { - ivMic.setVisibility(GONE); - } - if (!UISettings.isEnableVideoCalling() && - !UISettings.isSendPolls() && - !UISettings.isSendFiles() && - !UISettings.isSendPhotosVideo() && - !UISettings.isSendVoiceNotes() && - !UISettings.isShareLocation() && - !UISettings.isStickerVisible() && - !UISettings.isWhiteBoardVisible() && !UISettings.isWriteBoardVisible()) { + fetchSettings(); + + if (!isGroupCallVisible && + !isPollVisible && + !isFileVisible && + !isGalleryVisible && + !isAudioVisible && + !isLocationVisible && + !isStickerVisible && + !isWhiteBoardVisible && !isWriteBoardVisible) { ivArrow.setVisibility(GONE); } a.recycle(); } + + private void fetchSettings() { + FeatureRestriction.isPollsEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + isPollVisible = booleanVal; + } + }); + FeatureRestriction.isFilesEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + isFileVisible = booleanVal; + } + }); + FeatureRestriction.isPhotosVideoEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + isGalleryVisible = booleanVal; + isCameraVisible = booleanVal; + } + }); + FeatureRestriction.isVoiceNotesEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + isAudioVisible = booleanVal; + } + }); + FeatureRestriction.isLocationSharingEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + isLocationVisible = booleanVal; + } + }); + FeatureRestriction.isStickersEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + isStickerVisible = booleanVal; + } + }); + FeatureRestriction.isCollaborativeWhiteBoardEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + isWhiteBoardVisible = booleanVal; + } + }); + FeatureRestriction.isCollaborativeDocumentEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + isWriteBoardVisible = booleanVal; + } + }); + FeatureRestriction.isGroupVideoCallEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + isGroupCallVisible = booleanVal; + } + }); + } + public void setText(String text) { etComposeBox.setText(text); diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatComposeBox/CometChatComposeBoxActions.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatComposeBox/CometChatComposeBoxActions.java index f9e4694..86e7899 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatComposeBox/CometChatComposeBoxActions.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatComposeBox/CometChatComposeBoxActions.java @@ -24,7 +24,6 @@ public class CometChatComposeBoxActions extends BottomSheetDialogFragment { private TextView stickerMessage; private TextView whiteBoardMessage; private TextView writeBoardMessage; - private TextView groupCallMessage; private boolean isGalleryVisible; private boolean isCameraVisible; @@ -35,7 +34,6 @@ public class CometChatComposeBoxActions extends BottomSheetDialogFragment { private boolean isStickerVisible; private boolean isWhiteBoardVisible; private boolean isWriteBoardVisible; - private boolean isGroupCallVisible; private ComposeBoxActionListener composeBoxActionListener; @@ -54,7 +52,6 @@ public void onCreate(Bundle savedInstanceState) { isStickerVisible = getArguments().getBoolean("isStickerVisible"); isWhiteBoardVisible = getArguments().getBoolean("isWhiteBoardVisible"); isWriteBoardVisible = getArguments().getBoolean("isWriteBoardVisible"); - isGroupCallVisible = getArguments().getBoolean("isGroupCallVisible"); } } @@ -84,12 +81,6 @@ public void onGlobalLayout() { locationMessage = view.findViewById(R.id.location_message); whiteBoardMessage = view.findViewById(R.id.vw_whiteboard_message); writeBoardMessage = view.findViewById(R.id.writeboard_message); - groupCallMessage = view.findViewById(R.id.group_call_message); - - if (isGroupCallVisible) - groupCallMessage.setVisibility(View.VISIBLE); - else - groupCallMessage.setVisibility(View.GONE); if (isWriteBoardVisible) writeBoardMessage.setVisibility(View.VISIBLE); @@ -128,14 +119,6 @@ public void onGlobalLayout() { else locationMessage.setVisibility(View.GONE); - groupCallMessage.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if (composeBoxActionListener!=null) - composeBoxActionListener.onVideoMeetingClick(); - dismiss(); - } - }); writeBoardMessage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { @@ -227,7 +210,6 @@ public interface ComposeBoxActionListener { void onStickerClick(); void onWhiteBoardClick(); void onWriteBoardClick(); - void onVideoMeetingClick(); } } \ No newline at end of file diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatConversations/CometChatConversations.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatConversations/CometChatConversations.java index 7f5464f..c5d4d21 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatConversations/CometChatConversations.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatConversations/CometChatConversations.java @@ -155,6 +155,12 @@ public void refreshConversation(BaseMessage message) { } + public Conversation getConversation(int position) { + Conversation conversation = null; + if (conversationViewModel!=null) + conversation = conversationViewModel.getConversation(position); + return conversation; + } /** * This method is used to update Reciept of conversation from conversationList. * @param messageReceipt is object of MessageReceipt which is recieved in real-time. diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatConversations/CometChatConversationsAdapter.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatConversations/CometChatConversationsAdapter.java index 5142b07..f907f46 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatConversations/CometChatConversationsAdapter.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatConversations/CometChatConversationsAdapter.java @@ -29,9 +29,11 @@ import com.cometchat.pro.uikit.databinding.CometchatConversationListRowBinding; import com.cometchat.pro.uikit.ui_components.messages.extensions.Extensions; +import com.cometchat.pro.uikit.ui_resources.constants.UIKitConstants; import com.cometchat.pro.uikit.ui_resources.utils.FontUtils; -import com.cometchat.pro.uikit.ui_settings.UISettings; +import com.cometchat.pro.uikit.ui_settings.FeatureRestriction; import com.cometchat.pro.uikit.ui_resources.utils.Utils; +import com.cometchat.pro.uikit.ui_settings.UIKitSettings; /** * Purpose - ConversationListAdapter is a subclass of RecyclerView Adapter which is used to display @@ -127,8 +129,25 @@ public void onBindViewHolder(@NonNull ConversationViewHolder conversationViewHol category = baseMessage.getCategory(); setStatusIcon(conversationViewHolder.conversationListRowBinding.messageTime,baseMessage); conversationViewHolder.conversationListRowBinding.messageTime.setVisibility(View.VISIBLE); - conversationViewHolder.conversationListRowBinding.messageTime.setText(Utils.getLastMessageDate(baseMessage.getSentAt())); + conversationViewHolder.conversationListRowBinding.messageTime.setText(Utils.getLastMessageDate(context,baseMessage.getSentAt())); lastMessageText=Utils.getLastMessage(context,baseMessage); + + if (conversation.getLastMessage().getParentMessageId()!=0) { + conversationViewHolder.conversationListRowBinding.txtInThread.setVisibility(View.VISIBLE); + } else { + conversationViewHolder.conversationListRowBinding.txtInThread.setVisibility(View.GONE); + } + + if (UIKitSettings.isHideDeleteMessage() && baseMessage.getDeletedAt()>0) { + conversationViewHolder.conversationListRowBinding.txtInThread.setVisibility(View.GONE); + conversationViewHolder.conversationListRowBinding.txtUserMessage + .setVisibility(View.GONE); + lastMessageText = ""; + } else { + conversationViewHolder.conversationListRowBinding.txtUserMessage + .setVisibility(View.VISIBLE); + } + } else { lastMessageText = context.getResources().getString(R.string.tap_to_start_conversation); conversationViewHolder.conversationListRowBinding.txtUserMessage.setMarqueeRepeatLimit(100); @@ -136,6 +155,11 @@ public void onBindViewHolder(@NonNull ConversationViewHolder conversationViewHol conversationViewHolder.conversationListRowBinding.txtUserMessage.setSingleLine(true); conversationViewHolder.conversationListRowBinding.messageTime.setVisibility(View.GONE); } + + + if (lastMessageText.trim().isEmpty()) + conversationViewHolder.conversationListRowBinding.txtInThread.setVisibility(View.GONE); + conversationViewHolder.conversationListRowBinding.txtUserMessage.setText(lastMessageText); if (baseMessage!=null) { boolean isSentimentNegative = Extensions.checkSentiment(baseMessage); @@ -164,8 +188,7 @@ public void onBindViewHolder(@NonNull ConversationViewHolder conversationViewHol conversationViewHolder.conversationListRowBinding.messageCount.setCount(conversation.getUnreadMessageCount()); conversationViewHolder.conversationListRowBinding.txtUserName.setText(name); - conversationViewHolder.conversationListRowBinding.avUser.setBackgroundColor(Color.parseColor(UISettings.getColor())); - conversationViewHolder.conversationListRowBinding.messageCount.setCountBackground(Color.parseColor(UISettings.getColor())); + conversationViewHolder.conversationListRowBinding.messageCount.setCountBackground(Color.parseColor(FeatureRestriction.getColor())); if (avatar != null && !avatar.isEmpty()) { @@ -190,7 +213,7 @@ private void setStatusIcon(TextView txtTime, BaseMessage baseMessage) { baseMessage.getSender().getUid().equals(CometChat.getLoggedInUser().getUid())) { if (baseMessage.getReadAt() != 0) { - txtTime.setText(Utils.getLastMessageDate(baseMessage.getSentAt())); + txtTime.setText(Utils.getLastMessageDate(context,baseMessage.getSentAt())); txtTime.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_double_tick, 0, 0, 0); txtTime.setCompoundDrawablePadding(10); } else if (baseMessage.getDeliveredAt() != 0) { @@ -299,7 +322,7 @@ public void update(Conversation conversation) { if (filterConversationList.contains(conversation)) { Conversation oldConversation = filterConversationList.get(filterConversationList.indexOf(conversation)); filterConversationList.remove(oldConversation); - if (conversation.getLastMessage().getCategory().equalsIgnoreCase(CometChatConstants.CATEGORY_MESSAGE)) + if (conversation.getLastMessage().getType().equalsIgnoreCase(UIKitConstants.IntentStrings.LOCATION) || conversation.getLastMessage().getCategory().equalsIgnoreCase(CometChatConstants.CATEGORY_MESSAGE)) conversation.setUnreadMessageCount(oldConversation.getUnreadMessageCount() + 1); filterConversationList.add(0, conversation); } else { @@ -359,7 +382,7 @@ protected FilterResults performFiltering(CharSequence charSequence) { conversation.getLastMessage().getCategory().equals(CometChatConstants.CATEGORY_MESSAGE) && conversation.getLastMessage().getType().equals(CometChatConstants.MESSAGE_TYPE_TEXT) && ((TextMessage)conversation.getLastMessage()).getText()!=null - && ((TextMessage)conversation.getLastMessage()).getText().toLowerCase().contains(searchKeyword.toLowerCase())) { + && ((TextMessage)conversation.getLastMessage()).getText().contains(searchKeyword)) { tempFilter.add(conversation); } } @@ -379,7 +402,11 @@ protected void publishResults(CharSequence charSequence, FilterResults filterRes }; } - class ConversationViewHolder extends RecyclerView.ViewHolder { + public Conversation getItemAtPosition(int position) { + return filterConversationList.get(position); + } + + static class ConversationViewHolder extends RecyclerView.ViewHolder { CometchatConversationListRowBinding conversationListRowBinding; diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatConversations/CometChatConversationsViewModel.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatConversations/CometChatConversationsViewModel.java index 8ed8b3b..f74dd59 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatConversations/CometChatConversationsViewModel.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatConversations/CometChatConversationsViewModel.java @@ -82,6 +82,12 @@ public void clear() { conversationListAdapter.resetAdapterList(); } + public Conversation getConversation(int position) { + Conversation conversation = null; + if (conversationListAdapter!=null) + conversation = conversationListAdapter.getItemAtPosition(position); + return conversation; + } public int size() { return conversationListAdapter.getItemCount(); } diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatGroups/CometChatGroupsAdapter.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatGroups/CometChatGroupsAdapter.java index db24ee2..637fac8 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatGroups/CometChatGroupsAdapter.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatGroups/CometChatGroupsAdapter.java @@ -12,7 +12,7 @@ import com.cometchat.pro.constants.CometChatConstants; import com.cometchat.pro.uikit.R; -import com.cometchat.pro.uikit.ui_settings.UISettings; +import com.cometchat.pro.uikit.ui_settings.FeatureRestriction; import com.cometchat.pro.uikit.databinding.GroupListRowBinding; import com.cometchat.pro.models.Group; @@ -96,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(Color.parseColor(UISettings.getColor())); + groupViewHolder.groupListRowBinding.avGroup.setBackgroundColor(Color.parseColor(FeatureRestriction.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/com/cometchat/pro/uikit/ui_components/shared/cometchatSharedMedia/CometChatSharedMedia.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatSharedMedia/CometChatSharedMedia.java index 346d16c..a16860b 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatSharedMedia/CometChatSharedMedia.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatSharedMedia/CometChatSharedMedia.java @@ -22,7 +22,7 @@ import com.cometchat.pro.uikit.ui_components.shared.cometchatSharedMedia.fragments.CometChatSharedVideos; import com.google.android.material.tabs.TabLayout; -import com.cometchat.pro.uikit.ui_settings.UISettings; +import com.cometchat.pro.uikit.ui_settings.FeatureRestriction; import com.cometchat.pro.uikit.ui_resources.utils.Utils; @@ -90,12 +90,12 @@ private void initViewComponent(Context context,AttributeSet attributeSet,int def viewPager.setOffscreenPageLimit(3); tabLayout.setupWithViewPager(viewPager); - if (UISettings.getColor()!=null) { + if (FeatureRestriction.getColor()!=null) { Drawable wrappedDrawable = DrawableCompat.wrap(getResources(). getDrawable(R.drawable.tab_layout_background_active)); - DrawableCompat.setTint(wrappedDrawable, Color.parseColor(UISettings.getColor())); + DrawableCompat.setTint(wrappedDrawable, Color.parseColor(FeatureRestriction.getColor())); tabLayout.getTabAt(tabLayout.getSelectedTabPosition()).view.setBackground(wrappedDrawable); - tabLayout.setSelectedTabIndicatorColor(Color.parseColor(UISettings.getColor())); + tabLayout.setSelectedTabIndicatorColor(Color.parseColor(FeatureRestriction.getColor())); } else { tabLayout.getTabAt(tabLayout.getSelectedTabPosition()). view.setBackgroundColor(getResources().getColor(R.color.colorPrimary)); @@ -104,10 +104,10 @@ private void initViewComponent(Context context,AttributeSet attributeSet,int def tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { @Override public void onTabSelected(TabLayout.Tab tab) { - if (UISettings.getColor()!=null) { + if (FeatureRestriction.getColor()!=null) { Drawable wrappedDrawable = DrawableCompat.wrap(getResources(). getDrawable(R.drawable.tab_layout_background_active)); - DrawableCompat.setTint(wrappedDrawable, Color.parseColor(UISettings.getColor())); + DrawableCompat.setTint(wrappedDrawable, Color.parseColor(FeatureRestriction.getColor())); tab.view.setBackground(wrappedDrawable); } else diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatStickers/StickerView.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatStickers/StickerView.java index db0d69c..f34a4de 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatStickers/StickerView.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/shared/cometchatStickers/StickerView.java @@ -17,7 +17,7 @@ import com.bumptech.glide.Glide; import com.cometchat.pro.uikit.R; -import com.cometchat.pro.uikit.ui_settings.UISettings; +import com.cometchat.pro.uikit.ui_settings.FeatureRestriction; import com.cometchat.pro.uikit.ui_components.shared.cometchatStickers.listener.StickerClickListener; import com.cometchat.pro.uikit.ui_components.shared.cometchatStickers.model.Sticker; import com.google.android.material.tabs.TabLayout; @@ -98,12 +98,12 @@ private void initViewComponent(Context context,AttributeSet attributeSet,int def for (int i=0;i uids = new ArrayList<>(); uids.add(user.getUid()); CometChat.unblockUsers(uids, new CometChat.CallbackListener>() { @@ -146,15 +149,17 @@ public void onSuccess(HashMap stringStringHashMap) { if (userList.contains(user)) userList.remove(user); blockedUserAdapter.removeUser(user); - CometChatSnackBar.show(getContext(),var1, - user.getName()+" "+getResources().getString(R.string.unblocked_successfully),CometChatSnackBar.SUCCESS); + progressDialog.dismiss(); +// CometChatSnackBar.show(getContext(),var1, +// ,CometChatSnackBar.SUCCESS); checkIfNoUserVisible(); } @Override public void onError(CometChatException e) { + progressDialog.dismiss(); CometChatSnackBar.show(getContext(),var1, - CometChatError.localized(e),CometChatSnackBar.ERROR); + CometChatError.localized(e),CometChatSnackBar.ERROR); Log.e(TAG, "onError: "+e.getMessage()); } }); diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/users/block_users/CometChatBlockUserListActivity.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/users/block_users/CometChatBlockUserListActivity.java index 92fa56c..cb0c047 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/users/block_users/CometChatBlockUserListActivity.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/users/block_users/CometChatBlockUserListActivity.java @@ -11,7 +11,7 @@ import com.cometchat.pro.uikit.R; -import com.cometchat.pro.uikit.ui_settings.UISettings; +import com.cometchat.pro.uikit.ui_settings.FeatureRestriction; public class CometChatBlockUserListActivity extends AppCompatActivity { @@ -26,8 +26,8 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_screen); Fragment fragment = new CometChatBlockUserList(); getSupportFragmentManager().beginTransaction().replace(R.id.frame_fragment,fragment).commit(); - if (UISettings.getColor()!=null) - getWindow().setStatusBarColor(Color.parseColor(UISettings.getColor())); + if (FeatureRestriction.getColor()!=null) + getWindow().setStatusBarColor(Color.parseColor(FeatureRestriction.getColor())); } diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/users/user_details/CometChatUserDetailScreenActivity.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/users/user_details/CometChatUserDetailScreenActivity.java index f10e6d3..b59b52e 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/users/user_details/CometChatUserDetailScreenActivity.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/users/user_details/CometChatUserDetailScreenActivity.java @@ -1,6 +1,7 @@ package com.cometchat.pro.uikit.ui_components.users.user_details; import android.app.AlertDialog; +import android.app.ProgressDialog; import android.content.DialogInterface; import android.content.Intent; import android.content.res.ColorStateList; @@ -13,7 +14,6 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; -import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -32,6 +32,7 @@ import com.cometchat.pro.models.GroupMember; import com.cometchat.pro.models.User; +import com.cometchat.pro.uikit.ui_components.messages.extensions.Collaborative.CometChatWebViewActivity; import com.cometchat.pro.uikit.ui_components.messages.message_list.CometChatMessageListActivity; import com.cometchat.pro.uikit.ui_components.shared.CometChatSnackBar; import com.cometchat.pro.uikit.ui_components.shared.cometchatAvatar.CometChatAvatar; @@ -48,11 +49,9 @@ import com.cometchat.pro.uikit.ui_resources.constants.UIKitConstants; import com.cometchat.pro.uikit.ui_resources.utils.CallUtils; import com.cometchat.pro.uikit.ui_resources.utils.FontUtils; -import com.cometchat.pro.uikit.ui_settings.UISettings; +import com.cometchat.pro.uikit.ui_settings.FeatureRestriction; import com.cometchat.pro.uikit.ui_resources.utils.Utils; -import okhttp3.internal.Util; - public class CometChatUserDetailScreenActivity extends AppCompatActivity { private CometChatAvatar userAvatar; @@ -74,8 +73,6 @@ public class CometChatUserDetailScreenActivity extends AppCompatActivity { private boolean isAlreadyAdded; - private TextView tvSendMessage; - private LinearLayout blockUserLayout; private TextView tvBlockUser; @@ -86,10 +83,6 @@ public class CometChatUserDetailScreenActivity extends AppCompatActivity { private FontUtils fontUtils; - private ImageView callBtn; - - private ImageView videoCallBtn; - private LinearLayout historyView; private RecyclerView historyRv; @@ -102,12 +95,18 @@ public class CometChatUserDetailScreenActivity extends AppCompatActivity { private LinearLayout sharedMediaLayout; + private TextView viewProfile; + + private String profileLink = ""; + private boolean inProgress; private boolean fromCallList; private View divider1,divider2,divider3; + private LinearLayout preferenceLayout; + private List callList = new ArrayList<>(); @Override @@ -126,21 +125,21 @@ private void initComponent() { userAvatar = findViewById(R.id.iv_user); userName = findViewById(R.id.tv_name); userStatus = findViewById(R.id.tv_status); - callBtn = findViewById(R.id.callBtn_iv); - videoCallBtn = findViewById(R.id.video_callBtn_iv); + preferenceLayout = findViewById(R.id.preference_layout); addBtn = findViewById(R.id.btn_add); - tvSendMessage = findViewById(R.id.tv_send_message); toolbar= findViewById(R.id.user_detail_toolbar); divider1 = findViewById(R.id.divider_1); divider2 = findViewById(R.id.divider_2); divider3 = findViewById(R.id.divider_3); + CometChatError.init(this); + viewProfile = findViewById(R.id.tv_view_profile); + setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); addBtn.setTypeface(fontUtils.getTypeFace(FontUtils.robotoRegular)); - blockUserLayout = findViewById(R.id.block_user_layout); tvBlockUser = findViewById(R.id.tv_blockUser); @@ -158,8 +157,28 @@ private void initComponent() { sharedMediaView.setRecieverType(CometChatConstants.RECEIVER_TYPE_USER); sharedMediaView.reload(); - if (!UISettings.isViewSharedMedia()) - sharedMediaLayout.setVisibility(View.GONE); + if (profileLink==null || profileLink.isEmpty()) { + preferenceLayout.setVisibility(View.GONE); + viewProfile.setVisibility(View.GONE); + } + + if(isAddMember) + preferenceLayout.setVisibility(View.VISIBLE); + + viewProfile.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + openProfile(); + } + }); + + FeatureRestriction.isSharedMediaEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (!booleanVal) + sharedMediaLayout.setVisibility(View.GONE); + } + }); checkDarkMode(); addBtn.setOnClickListener(view -> { @@ -174,56 +193,21 @@ private void initComponent() { } }); - tvSendMessage.setOnClickListener(view -> { - if (isAddMember || fromCallList){ - Intent intent=new Intent(CometChatUserDetailScreenActivity.this, CometChatMessageListActivity.class); - intent.putExtra(UIKitConstants.IntentStrings.TYPE, CometChatConstants.RECEIVER_TYPE_USER); - intent.putExtra(UIKitConstants.IntentStrings.UID,uid); - intent.putExtra(UIKitConstants.IntentStrings.NAME,name); - intent.putExtra(UIKitConstants.IntentStrings.AVATAR,avatar); - intent.putExtra(UIKitConstants.IntentStrings.STATUS, CometChatConstants.USER_STATUS_OFFLINE); - startActivity(intent); - }else - onBackPressed(); + FeatureRestriction.isBlockUserEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (!booleanVal) { + blockUserLayout.setVisibility(View.GONE); + } + } }); - if (!UISettings.isBlockUser()) - blockUserLayout.setVisibility(View.GONE); - tvBlockUser.setOnClickListener(view -> { if (isBlocked) unblockUser(); else 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); - }); - videoCallBtn.setOnClickListener(view ->{ - videoCallBtn.setClickable(false); - checkOnGoingCall(CometChatConstants.CALL_TYPE_VIDEO); - }); } private void checkDarkMode() { @@ -240,50 +224,6 @@ private void checkDarkMode() { } } - private void checkOnGoingCall(String callType) { - if(CometChat.getActiveCall()!=null && CometChat.getActiveCall().getCallStatus().equals(CometChatConstants.CALL_STATUS_ONGOING) && CometChat.getActiveCall().getSessionId()!=null) { - AlertDialog.Builder alert = new AlertDialog.Builder(this); - alert.setTitle(getResources().getString(R.string.ongoing_call)) - .setMessage(getResources().getString(R.string.ongoing_call_message)) - .setPositiveButton(getResources().getString(R.string.join), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - CallUtils.joinOnGoingCall(CometChatUserDetailScreenActivity.this,CometChat.getActiveCall()); - } - }).setNegativeButton(getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - dialog.dismiss(); - callBtn.setClickable(true); - videoCallBtn.setClickable(true); - } - }).create().show(); - } - else { -// 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()); - CometChatSnackBar.show(CometChatUserDetailScreenActivity.this, - getWindow().getDecorView().getRootView(), - CometChatError.localized(e),CometChatSnackBar.ERROR); - } - }); - } - } - - private void handleIntent() { if (getIntent().hasExtra(UIKitConstants.IntentStrings.IS_ADD_MEMBER)) { @@ -314,6 +254,9 @@ private void handleIntent() { userName.setText(name); } + if (getIntent().hasExtra(UIKitConstants.IntentStrings.LINK)) { + profileLink = getIntent().getStringExtra(UIKitConstants.IntentStrings.LINK); + } if (getIntent().hasExtra(UIKitConstants.IntentStrings.AVATAR)) { avatar = getIntent().getStringExtra(UIKitConstants.IntentStrings.AVATAR); } @@ -339,6 +282,7 @@ private void handleIntent() { if (isAddMember) { addBtn.setText(String.format(getResources().getString(R.string.add_user_to_group),name,groupName)); historyView.setVisibility(View.GONE); + addBtn.setVisibility(View.VISIBLE); } else { fetchCallHistory(); addBtn.setVisibility(View.GONE); @@ -409,22 +353,28 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) { } private void addMember() { + ProgressDialog progressDialog = ProgressDialog.show(this, null, + String.format(getResources().getString(R.string.user_added_to_group), + userName.getText().toString(), groupName)); List userList = new ArrayList<>(); userList.add(new GroupMember(uid, CometChatConstants.SCOPE_PARTICIPANT)); CometChat.addMembersToGroup(guid, userList, null, new CometChat.CallbackListener>() { @Override public void onSuccess(HashMap stringStringHashMap) { Log.e(TAG, "onSuccess: " + uid + "Group" + guid); - if(tvBlockUser!=null) - CometChatSnackBar.show(CometChatUserDetailScreenActivity.this, - tvBlockUser,String.format(getResources().getString(R.string.user_added_to_group),userName.getText().toString(), groupName), - CometChatSnackBar.SUCCESS); + progressDialog.dismiss(); +// if(tvBlockUser!=null) { +// CometChatSnackBar.show(CometChatUserDetailScreenActivity.this, +// tvBlockUser, String.format(getResources().getString(R.string.user_added_to_group), userName.getText().toString(), groupName), +// CometChatSnackBar.SUCCESS); +// } addBtn.setText(String.format(getResources().getString(R.string.remove_from_group),groupName)); isAlreadyAdded = true; } @Override public void onError(CometChatException e) { + progressDialog.dismiss(); CometChatSnackBar.show(CometChatUserDetailScreenActivity.this, historyRv,CometChatError.localized(e),CometChatSnackBar.ERROR); } @@ -432,15 +382,13 @@ public void onError(CometChatException e) { } private void kickGroupMember() { - + ProgressDialog progressDialog = ProgressDialog.show(this, null, + String.format(getResources().getString(R.string.user_removed_from_group), + userName.getText().toString(),groupName)); CometChat.kickGroupMember(uid, guid, new CometChat.CallbackListener() { @Override public void onSuccess(String s) { - if (tvBlockUser!=null) - CometChatSnackBar.show(CometChatUserDetailScreenActivity.this, - tvBlockUser, - String.format(getResources().getString(R.string.user_removed_from_group),userName.getText().toString(),groupName), - CometChatSnackBar.SUCCESS); + progressDialog.dismiss(); addBtn.setText(String.format(getResources().getString(R.string.add_in),groupName)); addBtn.setVisibility(View.VISIBLE); isAlreadyAdded = false; @@ -448,6 +396,7 @@ public void onSuccess(String s) { @Override public void onError(CometChatException e) { + progressDialog.dismiss(); if (tvBlockUser!=null) CometChatSnackBar.show(CometChatUserDetailScreenActivity.this, tvBlockUser, CometChatError.localized(e), @@ -458,16 +407,20 @@ public void onError(CometChatException e) { private void unblockUser() { + ProgressDialog progressDialog = ProgressDialog.show(CometChatUserDetailScreenActivity.this, + null, + userName.getText().toString()+" "+getString(R.string.unblocked_successfully)); ArrayList uids = new ArrayList<>(); uids.add(uid); CometChat.unblockUsers(uids, new CometChat.CallbackListener>() { @Override public void onSuccess(HashMap stringStringHashMap) { - if (tvBlockUser!=null) - CometChatSnackBar.show(CometChatUserDetailScreenActivity.this, - tvBlockUser, - userName.getText().toString()+" "+getResources().getString(R.string.unblocked_successfully),CometChatSnackBar.SUCCESS); +// if (tvBlockUser!=null) +// CometChatSnackBar.show(CometChatUserDetailScreenActivity.this, +// tvBlockUser, +// userName.getText().toString()+" "+getResources().getString(R.string.unblocked_successfully),CometChatSnackBar.SUCCESS); + progressDialog.dismiss(); isBlocked=false; setBlockUnblock(); } @@ -477,25 +430,28 @@ public void onError(CometChatException e) { Log.d(TAG, "onError: "+e.getMessage()); if (tvBlockUser!=null) CometChatSnackBar.show(CometChatUserDetailScreenActivity.this, - tvBlockUser,CometChatError.localized(e),CometChatSnackBar.ERROR); + tvBlockUser,getString(R.string.unblock_user_error),CometChatSnackBar.ERROR); } }); } private void blockUser() { - + ProgressDialog progressDialog = ProgressDialog.show(CometChatUserDetailScreenActivity.this, + null, + String.format(getResources().getString(R.string.user_is_blocked),userName.getText().toString())); ArrayList uids = new ArrayList<>(); uids.add(uid); CometChat.blockUsers(uids, new CometChat.CallbackListener>() { @Override public void onSuccess(HashMap stringStringHashMap) { - if (tvBlockUser!=null) - CometChatSnackBar.show(CometChatUserDetailScreenActivity.this, - tvBlockUser, - String.format(getResources().getString(R.string.user_is_blocked),userName.getText().toString()), - CometChatSnackBar.SUCCESS); +// if (tvBlockUser!=null) +// CometChatSnackBar.show(CometChatUserDetailScreenActivity.this, +// tvBlockUser, +// String.format(getResources().getString(R.string.user_is_blocked),userName.getText().toString()), +// CometChatSnackBar.SUCCESS); isBlocked=true; + progressDialog.dismiss(); setBlockUnblock(); } @@ -504,8 +460,7 @@ public void onError(CometChatException e) { if (tvBlockUser!=null) CometChatSnackBar.show(CometChatUserDetailScreenActivity.this, tvBlockUser, - String.format(getResources().getString(R.string.block_user_error),userName.getText().toString()) - +","+ CometChatError.localized(e), + getResources().getString(R.string.block_user_error), CometChatSnackBar.ERROR); Log.d(TAG, "onError: "+e.getMessage()); } @@ -516,8 +471,6 @@ public void onError(CometChatException e) { protected void onResume() { super.onResume(); groupListener(); - callBtn.setClickable(true); - videoCallBtn.setClickable(true); } @Override @@ -551,6 +504,12 @@ public void onMemberAddedToGroup(Action action, User addedby, User userAdded, Gr }); } + private void openProfile() { + Intent intent = new Intent(CometChatUserDetailScreenActivity.this, CometChatWebViewActivity.class); + intent.putExtra(UIKitConstants.IntentStrings.URL,profileLink); + startActivity(intent); + } + private void updateBtn(User user, int resource_string) { if (user.getUid().equals(uid)) addBtn.setText(String.format(getResources().getString(resource_string), groupName )); diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/users/user_list/CometChatUserList.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/users/user_list/CometChatUserList.java index 7a7493c..dd196ba 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/users/user_list/CometChatUserList.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_components/users/user_list/CometChatUserList.java @@ -32,13 +32,11 @@ import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; -import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.RecyclerView; -import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import com.cometchat.pro.core.CometChat; import com.cometchat.pro.core.UsersRequest; @@ -47,6 +45,8 @@ import com.cometchat.pro.models.User; import com.cometchat.pro.uikit.ui_components.shared.CometChatSnackBar; import com.cometchat.pro.uikit.ui_resources.utils.CometChatError; +import com.cometchat.pro.uikit.ui_settings.UIKitSettings; +import com.cometchat.pro.uikit.ui_settings.enums.UserMode; import com.facebook.shimmer.ShimmerFrameLayout; import java.util.ArrayList; @@ -56,7 +56,7 @@ import com.cometchat.pro.uikit.ui_components.shared.cometchatUsers.CometChatUsersAdapter; import com.cometchat.pro.uikit.ui_resources.utils.item_clickListener.OnItemClickListener; import com.cometchat.pro.uikit.ui_resources.utils.FontUtils; -import com.cometchat.pro.uikit.ui_settings.UISettings; +import com.cometchat.pro.uikit.ui_settings.FeatureRestriction; import com.cometchat.pro.uikit.ui_resources.utils.Utils; /* @@ -86,6 +86,8 @@ public class CometChatUserList extends Fragment { private boolean isSearching; + private CometChatUsersAdapter userListAdapter; + private UsersRequest usersRequest; // Use to fetch users private CometChatUsers rvUserList; // Use to display list of users @@ -102,8 +104,6 @@ public class CometChatUserList extends Fragment { private LinearLayout noUserLayout; - private SwipeRefreshLayout swipeRefreshLayout; - private List userList = new ArrayList<>(); public CometChatUserList() { @@ -117,13 +117,13 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, View view = inflater.inflate(R.layout.fragment_cometchat_userlist, container, false); title = view.findViewById(R.id.tv_title); title.setTypeface(FontUtils.getInstance(getActivity()).getTypeFace(FontUtils.robotoMedium)); - swipeRefreshLayout = view.findViewById(R.id.swipeToRefresh); rvUserList = view.findViewById(R.id.rv_user_list); noUserLayout = view.findViewById(R.id.no_user_layout); etSearch = view.findViewById(R.id.search_bar); clearSearch = view.findViewById(R.id.clear_search); rlSearchBox=view.findViewById(R.id.rl_search_box); + CometChatError.init(getContext()); shimmerFrameLayout=view.findViewById(R.id.shimmer_layout); if(Utils.isDarkMode(getContext())) { @@ -132,6 +132,16 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, title.setTextColor(getResources().getColor(R.color.primaryTextColor)); } + FeatureRestriction.isUserSearchEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + if (booleanVal) + etSearch.setVisibility(View.VISIBLE); + else + etSearch.setVisibility(View.GONE); + } + }); + etSearch.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @@ -200,16 +210,6 @@ public void OnItemClick(User user, int position) { events.OnItemClick(user,position); } }); - - swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { - @Override - public void onRefresh() { - usersRequest=null; - rvUserList.clear(); - fetchUsers(); - } - }); - return view; } @@ -237,12 +237,10 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat private void fetchUsers() { if (usersRequest == null) { - if (UISettings.getUserListing() - .equalsIgnoreCase("friends")) + if (UIKitSettings.getUsersMode()==UserMode.FRIENDS) usersRequest = new UsersRequest.UsersRequestBuilder().setLimit(30) .friendsOnly(true).build(); - else if (UISettings.getUserListing() - .equalsIgnoreCase("all_users")) + else if (UIKitSettings.getUsersMode()==UserMode.ALL_USER) usersRequest = new UsersRequest.UsersRequestBuilder().setLimit(30).build(); } usersRequest.fetchNext(new CometChat.CallbackListener>() { @@ -260,8 +258,6 @@ public void onSuccess(List users) { rvUserList.setVisibility(View.VISIBLE); noUserLayout.setVisibility(View.GONE); } - if (swipeRefreshLayout.isRefreshing()) - swipeRefreshLayout.setRefreshing(false); } @Override diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_resources/constants/UIKitConstants.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_resources/constants/UIKitConstants.java index a5ed4de..002667e 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_resources/constants/UIKitConstants.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_resources/constants/UIKitConstants.java @@ -93,7 +93,7 @@ public static class IntentStrings { public static final String CUSTOM_MESSAGE = "custom_message" ; - public static final String LOCATION = "LOCATION" ; + public static final String LOCATION = "location" ; public static final String LOCATION_LATITUDE = "latitude"; @@ -123,6 +123,14 @@ public static class IntentStrings { public static final String GROUP_CALL_TYPE = "group_call_type"; + public static final String IS_DEFAULT_CALL = "is_default_call"; + + public static final String INTENT_MEDIA_IMAGE_MESSAGE = "intent_media_image_message"; + + public static final String INTENT_MEDIA_VIDEO_MESSAGE = "intent_media_video_message"; + + public static final String LINK = "link"; + public static String POLL_QUESTION = "poll_question"; public static String POLL_OPTION = "poll_option"; diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_resources/utils/CallUtils.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_resources/utils/CallUtils.java index 88c96ec..5cb5bfc 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_resources/utils/CallUtils.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_resources/utils/CallUtils.java @@ -132,6 +132,7 @@ public static void startCall(Context context, Call call) { intent.putExtra(UIKitConstants.IntentStrings.TYPE,call.getReceiverType()); intent.putExtra(UIKitConstants.IntentStrings.SESSION_ID,call.getSessionId()); ((Activity)context).finish(); + intent.putExtra(UIKitConstants.IntentStrings.IS_DEFAULT_CALL,true); context.startActivity(intent); } @@ -141,6 +142,7 @@ public static void startDirectCall(Context context, Call call) { intent.putExtra(UIKitConstants.IntentStrings.TYPE,call.getReceiverType()); intent.putExtra(UIKitConstants.IntentStrings.SESSION_ID,call.getSessionId()); intent.putExtra(UIKitConstants.IntentStrings.GROUP_CALL_TYPE,call.getType()); + intent.putExtra(UIKitConstants.IntentStrings.IS_DEFAULT_CALL,false); context.startActivity(intent); } diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_resources/utils/CometChatError.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_resources/utils/CometChatError.java index d21e017..7487941 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_resources/utils/CometChatError.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_resources/utils/CometChatError.java @@ -19,80 +19,16 @@ public class CometChatError { private static final String ERR_NO_OPTIONS = "ERR_NO_OPTIONS"; private static final String ERR_POLL_NOT_FOUND = "ERR_POLL_NOT_FOUND"; - private static final String ERROR_INIT_NOT_CALLED = "ERROR_INIT_NOT_CALLED"; private static final String ERROR_PASSWORD_MISSING_MESSAGE = "ERROR_PASSWORD_MISSING_MESSAGE"; - private static final String ERROR_LIMIT_EXCEEDED_MESSAGE = "ERROR_LIMIT_EXCEEDED_MESSAGE"; - private static final String ERROR_USER_NOT_LOGGED_IN_MESSAGE = "ERROR_USER_NOT_LOGGED_IN_MESSAGE"; private static final String ERROR_INVALID_GUID_MESSAGE = "ERROR_INVALID_GUID_MESSAGE"; private static final String ERROR_INVALID_UID_MESSAGE = "ERROR_INVALID_UID_MESSAGE"; private static final String ERROR_BLANK_UID_MESSAGE = "ERROR_BLANK_UID_MESSAGE"; private static final String ERROR_UID_WITH_SPACE_MESSAGE = "ERROR_UID_WITH_SPACE_MESSAGE"; private static final String ERROR_DEFAULT_MESSAGE = "ERROR_DEFAULT_MESSAGE"; - private static final String ERROR_CALL_NOT_INITIATED_MESSAGE = "ERROR_CALL_NOT_INITIATED_MESSAGE"; - private static final String ERROR_CALL_MESSAGE = "ERROR_CALL_MESSAGE"; - private static final String ERROR_CALL_SESSION_MISMATCH_MESSAGE = "ERROR_CALL_SESSION_MISMATCH_MESSAGE"; - private static final String ERROR_INIT_NOT_CALLED_MESSAGE = "ERROR_INIT_NOT_CALLED_MESSAGE"; private static final String ERROR_UID_GUID_NOT_SPECIFIED_MESSAGE = "ERROR_UID_GUID_NOT_SPECIFIED_MESSAGE"; private static final String ERROR_INTERNET_UNAVAILABLE_MESSAGE = "ERROR_INTERNET_UNAVAILABLE_MESSAGE"; private static final String ERROR_REQUEST_IN_PROGRESS_MESSAGE = "ERROR_REQUEST_IN_PROGRESS_MESSAGE"; - private static final String ERROR_FILTERS_MISSING_MESSAGE = "ERROR_FILTERS_MISSING_MESSAGE"; - private static final String ERROR_BLANK_AUTHTOKEN_MESSAGE = "ERROR_BLANK_AUTHTOKEN_MESSAGE"; - private static final String ERROR_EXTENSION_DISABLED_MESSAGE = "ERROR_EXTENSION_DISABLED_MESSAGE"; - private static final String ERROR_INVALID_MESSAGEID_MESSAGE = "ERROR_INVALID_MESSAGEID_MESSAGE"; - private static final String ERROR_INVALID_MESSAGE_TYPE_MESSAGE = "ERROR_INVALID_MESSAGE_TYPE_MESSAGE"; - private static final String ERROR_LIST_EMPTY_MESSAGE = "ERROR_LIST_EMPTY_MESSAGE"; - private static final String ERROR_UPDATESONLY_WITHOUT_UPDATEDAFTER_MESSAGE = "ERROR_UPDATESONLY_WITHOUT_UPDATEDAFTER_MESSAGE"; - private static final String ERROR_JSON_MESSAGE = "ERROR_JSON_MESSAGE"; - private static final String ERROR_LOGOUT_FAIL_MESSAGE = "ERROR_LOGOUT_FAIL_MESSAGE"; - private static final String ERROR_EMPTY_APPID_MESSAGE = "ERROR_EMPTY_APPID_MESSAGE"; - private static final String ERROR_NON_POSITIVE_LIMIT_MESSSAGE = "ERROR_NON_POSITIVE_LIMIT_MESSSAGE"; - private static final String ERROR_REGION_MISSING_MESSAGE = "ERROR_REGION_MISSING_MESSAGE"; - private static final String ERROR_APP_SETTING_NULL_MESSAGE = "ERROR_APP_SETTING_NULL_MESSAGE"; - private static final String ERROR_API_KEY_NOT_FOUND_MESSAGE = "ERROR_API_KEY_NOT_FOUND_MESSAGE"; - private static final String ERROR_INVALID_SENDING_MESSAGE_TYPE_MESSAGE = "ERROR_INVALID_SENDING_MESSAGE_TYPE_MESSAGE"; - private static final String ERROR_MESSAGE_TEXT_EMPTY_MESSAGE = "ERROR_MESSAGE_TEXT_EMPTY_MESSAGE"; - private static final String ERROR_FILE_OBJECT_INVALID_MESSAGE = "ERROR_MESSAGE_TEXT_EMPTY_MESSAGE"; - private static final String ERROR_FILE_URL_EMPTY_MESSAGE = "ERROR_FILE_URL_EMPTY_MESSAGE"; - private static final String ERROR_EMPTY_CUSTOM_DATA_MESSAGE = "ERROR_EMPTY_CUSTOM_DATA_MESSAGE"; private static final String ERROR_EMPTY_GROUP_NAME_MESSAGE = "ERROR_EMPTY_GROUP_NAME_MESSAGE"; - private static final String ERROR_EMPTY_GROUP_TYPE_MESSAGE = "ERROR_EMPTY_GROUP_TYPE_MESSAGE"; - private static final String ERROR_LOGIN_IN_PROGRESS_MESSAGE = "ERROR_LOGIN_IN_PROGRESS_MESSAGE"; - private static final String ERROR_INVALID_MESSAGE_MESSAGE = "ERROR_INVALID_MESSAGE_MESSAGE"; - private static final String ERROR_INVALID_GROUP_MESSAGE = "ERROR_INVALID_GROUP_MESSAGE"; - private static final String ERROR_INVALID_CALL_MESSAGE = "ERROR_INVALID_CALL_MESSAGE"; - private static final String ERROR_INVALID_CALL_TYPE_MESSAGE = "ERROR_INVALID_CALL_TYPE_MESSAGE"; - private static final String ERROR_INVALID_RECEIVER_TYPE_MESSAGE = "ERROR_INVALID_RECEIVER_TYPE_MESSAGE"; - private static final String ERROR_INVALID_SESSION_ID_MESSAGE = "ERROR_INVALID_SESSION_ID_MESSAGE"; - private static final String ERROR_ACTIVITY_NULL_MESSAGE = "ERROR_ACTIVITY_NULL_MESSAGE"; - private static final String ERROR_VIEW_NULL_MESSAGE = "ERROR_VIEW_NULL_MESSAGE"; - private static final String ERROR_INVALID_FCM_TOKEN_MESSAGE = "ERROR_INVALID_FCM_TOKEN_MESSAGE"; - private static final String ERROR_INVALID_GROUP_TYPE_MESSAGE = "ERROR_INVALID_FCM_TOKEN_MESSAGE"; - private static final String ERROR_CALL_IN_PROGRESS_MESSAGE = "ERROR_CALL_IN_PROGRESS_MESSAGE"; - private static final String ERROR_INCORRECT_INITIATOR_MESSAGE = "ERROR_INCORRECT_INITIATOR_MESSAGE"; - private static final String ERROR_INVALID_USER_NAME_MESSAGE = "ERROR_INVALID_USER_NAME_MESSAGE"; - private static final String ERROR_INVALID_USER_MESSAGE = "ERROR_INVALID_USER_MESSAGE"; - private static final String ERROR_INVALID_GROUP_NAME_MESSAGE = "ERROR_INVALID_GROUP_NAME_MESSAGE"; - private static final String ERROR_INVALID_TIMESTAMP_MESSAGE = "ERROR_INVALID_TIMESTAMP_MESSAGE"; - private static final String ERROR_INVALID_CATEGORY_MESSAGE = "ERROR_INVALID_CATEGORY_MESSAGE"; - private static final String ERROR_EMPTY_ICON_MESSAGE = "ERROR_EMPTY_ICON_MESSAGE"; - private static final String ERROR_EMPTY_DESCRIPTION_MESSAGE = "ERROR_EMPTY_DESCRIPTION_MESSAGE"; - private static final String ERROR_EMPTY_METADATA_MESSAGE = "ERROR_EMPTY_METADATA_MESSAGE"; - private static final String ERROR_EMPTY_SCOPE_MESSAGE = "ERROR_EMPTY_SCOPE_MESSAGE"; - private static final String ERROR_INVALID_SCOPE_MESSAGE = "ERROR_INVALID_SCOPE_MESSAGE"; - private static final String ERROR_INVALID_CONVERSATION_WITH_MESSAGE = "ERROR_INVALID_CONVERSATION_WITH_MESSAGE"; - private static final String ERROR_INVALID_CONVERSATION_TYPE_MESSAGE = "ERROR_INVALID_CONVERSATION_TYPE_MESSAGE"; - private static final String ERROR_INVALID_MEDIA_MESSAGE_MESSAGE = "ERROR_INVALID_MEDIA_MESSAGE_MESSAGE"; - private static final String ERROR_INVALID_ATTACHMENT_MESSAGE = "ERROR_INVALID_ATTACHMENT_MESSAGE"; - private static final String ERROR_INVALID_FILE_NAME_MESSAGE = "ERROR_INVALID_FILE_NAME_MESSAGE"; - private static final String ERROR_INVALID_FILE_EXTENSION_MESSAGE = "ERROR_INVALID_FILE_EXTENSION_MESSAGE"; - private static final String ERROR_INVALID_FILE_MIME_TYPE_MESSAGE = "ERROR_INVALID_FILE_MIME_TYPE_MESSAGE"; - private static final String ERROR_INVALID_FILE_URL_MESSAGE = "ERROR_INVALID_FILE_URL_MESSAGE"; - private static final String ERROR_CONVERSATION_NOT_FOUND_MESSAGE = "ERROR_CONVERSATION_NOT_FOUND_MESSAGE"; - private static final String ERROR_SETTINGS_NOT_FOUND_MESSAGE = "ERROR_SETTINGS_NOT_FOUND_MESSAGE"; - private static final String ERROR_INVALID_FEATURE_MESSAGE = "ERROR_INVALID_FEATURE_MESSAGE"; - private static final String ERROR_INVALID_EXTENSION_MESSAGE = "ERROR_INVALID_EXTENSION_MESSAGE"; - private static final String ERROR_FEATURE_NOT_FOUND_MESSAGE = "ERROR_FEATURE_NOT_FOUND_MESSAGE"; - private static final String ERROR_EXTENSION_NOT_FOUND_MESSAGE = "ERROR_EXTENSION_NOT_FOUND_MESSAGE"; private static Context errorContext; public static void init(Context context) { @@ -100,38 +36,11 @@ public static void init(Context context) { } public static String localized(CometChatException e) { - if (e.getCode().equalsIgnoreCase(ERROR_INIT_NOT_CALLED) || - e.getCode().equalsIgnoreCase(ERROR_INIT_NOT_CALLED_MESSAGE)) { - return new CometChatException(ERROR_INIT_NOT_CALLED, - errorContext.getString(R.string.err_init_not_called)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_EMPTY_APPID_MESSAGE)) { - return new CometChatException(ERROR_EMPTY_APPID_MESSAGE, - errorContext.getString(R.string.err_empty_appid_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_NON_POSITIVE_LIMIT_MESSSAGE)) { - return new CometChatException(ERROR_NON_POSITIVE_LIMIT_MESSSAGE, - errorContext.getString(R.string.err_non_positive_limit_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_REGION_MISSING_MESSAGE)) { - return new CometChatException(ERROR_REGION_MISSING_MESSAGE, - errorContext.getString(R.string.err_region_missing_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_APP_SETTING_NULL_MESSAGE)) { - return new CometChatException(ERROR_APP_SETTING_NULL_MESSAGE, - errorContext.getString(R.string.err_app_settings_null_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_API_KEY_NOT_FOUND_MESSAGE)) { - return new CometChatException(ERROR_API_KEY_NOT_FOUND_MESSAGE, - errorContext.getString(R.string.err_api_key_not_found_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_LOGIN_IN_PROGRESS_MESSAGE)) { - return new CometChatException(ERROR_LOGIN_IN_PROGRESS_MESSAGE, - errorContext.getString(R.string.err_login_in_progress_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_PASSWORD_MISSING_MESSAGE)) { + if (e.getCode().equalsIgnoreCase(ERROR_PASSWORD_MISSING_MESSAGE)) { return new CometChatException(ERROR_PASSWORD_MISSING_MESSAGE, errorContext.getString(R.string.err_password_missing_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_LIMIT_EXCEEDED_MESSAGE)) { - return new CometChatException(ERROR_LIMIT_EXCEEDED_MESSAGE, - errorContext.getString(R.string.err_limit_exceed_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_USER_NOT_LOGGED_IN_MESSAGE)) { - return new CometChatException(ERROR_USER_NOT_LOGGED_IN_MESSAGE, - errorContext.getString(R.string.err_user_not_logged_in_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_INVALID_GUID_MESSAGE)) { + } + else if (e.getCode().equalsIgnoreCase(ERROR_INVALID_GUID_MESSAGE)) { return new CometChatException(ERROR_INVALID_GUID_MESSAGE, errorContext.getString(R.string.err_invalid_guid_message)).getMessage(); } else if (e.getCode().equalsIgnoreCase(ERROR_INVALID_UID_MESSAGE)) { @@ -143,18 +52,6 @@ public static String localized(CometChatException e) { } else if (e.getCode().equalsIgnoreCase(ERROR_UID_WITH_SPACE_MESSAGE)) { return new CometChatException(ERROR_UID_WITH_SPACE_MESSAGE, errorContext.getString(R.string.err_uid_with_space_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_DEFAULT_MESSAGE)) { - return new CometChatException(ERROR_DEFAULT_MESSAGE, - errorContext.getString(R.string.err_default_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_CALL_NOT_INITIATED_MESSAGE)) { - return new CometChatException(ERROR_CALL_NOT_INITIATED_MESSAGE, - errorContext.getString(R.string.err_call_not_initiated_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_CALL_MESSAGE)) { - return new CometChatException(ERROR_CALL_MESSAGE, - errorContext.getString(R.string.err_call_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_CALL_SESSION_MISMATCH_MESSAGE)) { - return new CometChatException(ERROR_CALL_SESSION_MISMATCH_MESSAGE, - errorContext.getString(R.string.err_call_session_mismatch_message)).getMessage(); } else if (e.getCode().equalsIgnoreCase(ERROR_UID_GUID_NOT_SPECIFIED_MESSAGE)) { return new CometChatException(ERROR_UID_GUID_NOT_SPECIFIED_MESSAGE, errorContext.getString(R.string.err_uid_guid_not_specified_message)).getMessage(); @@ -164,173 +61,20 @@ public static String localized(CometChatException e) { } else if (e.getCode().equalsIgnoreCase(ERROR_REQUEST_IN_PROGRESS_MESSAGE)) { return new CometChatException(ERROR_REQUEST_IN_PROGRESS_MESSAGE, errorContext.getString(R.string.err_request_in_progress_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_FILTERS_MISSING_MESSAGE)) { - return new CometChatException(ERROR_FILTERS_MISSING_MESSAGE, - errorContext.getString(R.string.err_filters_missing_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_BLANK_AUTHTOKEN_MESSAGE)) { - return new CometChatException(ERROR_BLANK_AUTHTOKEN_MESSAGE, - errorContext.getString(R.string.err_blank_auth_token_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_EXTENSION_DISABLED_MESSAGE)) { - return new CometChatException(ERROR_EXTENSION_DISABLED_MESSAGE, - errorContext.getString(R.string.extension_is_not_enabled)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_INVALID_MESSAGEID_MESSAGE)) { - return new CometChatException(ERROR_INVALID_MESSAGEID_MESSAGE, - errorContext.getString(R.string.err_invalid_messageid_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_INVALID_MESSAGE_TYPE_MESSAGE)) { - return new CometChatException(ERROR_INVALID_MESSAGE_TYPE_MESSAGE, - errorContext.getString(R.string.err_invalid_message_type_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_LIST_EMPTY_MESSAGE)) { - return new CometChatException(ERROR_LIST_EMPTY_MESSAGE, - errorContext.getString(R.string.err_list_empty_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_UPDATESONLY_WITHOUT_UPDATEDAFTER_MESSAGE)) { - return new CometChatException(ERROR_UPDATESONLY_WITHOUT_UPDATEDAFTER_MESSAGE, - errorContext.getString(R.string.err_updatesonly_without_updatedafter_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_JSON_MESSAGE)) { - return new CometChatException(ERROR_JSON_MESSAGE, - errorContext.getString(R.string.err_json_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_LOGOUT_FAIL_MESSAGE)) { - return new CometChatException(ERROR_LOGOUT_FAIL_MESSAGE, - errorContext.getString(R.string.err_logout_fail_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_INVALID_SENDING_MESSAGE_TYPE_MESSAGE)) { - return new CometChatException(ERROR_INVALID_SENDING_MESSAGE_TYPE_MESSAGE, - errorContext.getString(R.string.err_invalid_sending_message_type_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_MESSAGE_TEXT_EMPTY_MESSAGE)) { - return new CometChatException(ERROR_MESSAGE_TEXT_EMPTY_MESSAGE, - errorContext.getString(R.string.err_message_text_empty_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_FILE_OBJECT_INVALID_MESSAGE)) { - return new CometChatException(ERROR_FILE_OBJECT_INVALID_MESSAGE, - errorContext.getString(R.string.err_file_object_invalid_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_FILE_URL_EMPTY_MESSAGE)) { - return new CometChatException(ERROR_FILE_URL_EMPTY_MESSAGE, - errorContext.getString(R.string.err_file_url_empty_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_EMPTY_CUSTOM_DATA_MESSAGE)) { - return new CometChatException(ERROR_EMPTY_CUSTOM_DATA_MESSAGE, - errorContext.getString(R.string.err_empty_custom_data_message)).getMessage(); } else if (e.getCode().equalsIgnoreCase(ERROR_EMPTY_GROUP_NAME_MESSAGE)) { return new CometChatException(ERROR_EMPTY_GROUP_NAME_MESSAGE, errorContext.getString(R.string.err_empty_group_name_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_EMPTY_GROUP_TYPE_MESSAGE)) { - return new CometChatException(ERROR_EMPTY_GROUP_TYPE_MESSAGE, - errorContext.getString(R.string.err_empty_group_type_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_INVALID_MESSAGE_MESSAGE)) { - return new CometChatException(ERROR_INVALID_MESSAGE_MESSAGE, - errorContext.getString(R.string.err_invalid_message_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_INVALID_GROUP_MESSAGE)) { - return new CometChatException(ERROR_INVALID_GROUP_MESSAGE, - errorContext.getString(R.string.err_invalid_group_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_INVALID_CALL_MESSAGE)) { - return new CometChatException(ERROR_INVALID_CALL_MESSAGE, - errorContext.getString(R.string.err_invalid_call_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_INVALID_CALL_TYPE_MESSAGE)) { - return new CometChatException(ERROR_INVALID_CALL_TYPE_MESSAGE, - errorContext.getString(R.string.err_invalid_call_type_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_INVALID_RECEIVER_TYPE_MESSAGE)) { - return new CometChatException(ERROR_INVALID_RECEIVER_TYPE_MESSAGE, - errorContext.getString(R.string.err_invalid_receiver_type_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_INVALID_SESSION_ID_MESSAGE)) { - return new CometChatException(ERROR_INVALID_SESSION_ID_MESSAGE, - errorContext.getString(R.string.err_invalid_session_id_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_ACTIVITY_NULL_MESSAGE)) { - return new CometChatException(ERROR_ACTIVITY_NULL_MESSAGE, - errorContext.getString(R.string.err_activity_null_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_VIEW_NULL_MESSAGE)) { - return new CometChatException(ERROR_VIEW_NULL_MESSAGE, - errorContext.getString(R.string.err_view_null_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_INVALID_FCM_TOKEN_MESSAGE)) { - return new CometChatException(ERROR_INVALID_FCM_TOKEN_MESSAGE, - errorContext.getString(R.string.err_invalid_fcm_token_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_INVALID_GROUP_TYPE_MESSAGE)) { - return new CometChatException(ERROR_INVALID_GROUP_TYPE_MESSAGE, - errorContext.getString(R.string.err_invalid_group_type_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_CALL_IN_PROGRESS_MESSAGE)) { - return new CometChatException(ERROR_CALL_IN_PROGRESS_MESSAGE, - errorContext.getString(R.string.err_call_in_progress_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_INCORRECT_INITIATOR_MESSAGE)) { - return new CometChatException(ERROR_INCORRECT_INITIATOR_MESSAGE, - errorContext.getString(R.string.err_incorrect_initiator_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_INVALID_USER_NAME_MESSAGE)) { - return new CometChatException(ERROR_INVALID_USER_NAME_MESSAGE, - errorContext.getString(R.string.err_invalid_user_name_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_INVALID_USER_MESSAGE)) { - return new CometChatException(ERROR_INVALID_USER_MESSAGE, - errorContext.getString(R.string.err_invalid_user_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_INVALID_GROUP_NAME_MESSAGE)) { - return new CometChatException(ERROR_INVALID_GROUP_NAME_MESSAGE, - errorContext.getString(R.string.err_invalid_group_name_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_INVALID_TIMESTAMP_MESSAGE)) { - return new CometChatException(ERROR_INVALID_TIMESTAMP_MESSAGE, - errorContext.getString(R.string.err_invalid_timestamp_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_INVALID_CATEGORY_MESSAGE)) { - return new CometChatException(ERROR_INVALID_CATEGORY_MESSAGE, - errorContext.getString(R.string.err_invalid_category_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_EMPTY_ICON_MESSAGE)) { - return new CometChatException(ERROR_EMPTY_ICON_MESSAGE, - errorContext.getString(R.string.err_empty_icon_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_EMPTY_DESCRIPTION_MESSAGE)) { - return new CometChatException(ERROR_EMPTY_DESCRIPTION_MESSAGE, - errorContext.getString(R.string.err_empty_description_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_EMPTY_METADATA_MESSAGE)) { - return new CometChatException(ERROR_EMPTY_METADATA_MESSAGE, - errorContext.getString(R.string.err_empty_metadata_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_EMPTY_SCOPE_MESSAGE)) { - return new CometChatException(ERROR_EMPTY_SCOPE_MESSAGE, - errorContext.getString(R.string.err_empty_scope_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_INVALID_SCOPE_MESSAGE)) { - return new CometChatException(ERROR_INVALID_SCOPE_MESSAGE, - errorContext.getString(R.string.err_invalid_scope_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_INVALID_CONVERSATION_WITH_MESSAGE)) { - return new CometChatException(ERROR_INVALID_CONVERSATION_WITH_MESSAGE, - errorContext.getString(R.string.err_invalid_conversation_with_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_INVALID_CONVERSATION_TYPE_MESSAGE)) { - return new CometChatException(ERROR_INVALID_CONVERSATION_TYPE_MESSAGE, - errorContext.getString(R.string.err_invalid_conversation_type_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_INVALID_MEDIA_MESSAGE_MESSAGE)) { - return new CometChatException(ERROR_INVALID_MEDIA_MESSAGE_MESSAGE, - errorContext.getString(R.string.err_invalid_media_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_INVALID_ATTACHMENT_MESSAGE)) { - return new CometChatException(ERROR_INVALID_ATTACHMENT_MESSAGE, - errorContext.getString(R.string.err_invalid_attachment_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_INVALID_FILE_NAME_MESSAGE)) { - return new CometChatException(ERROR_INVALID_FILE_NAME_MESSAGE, - errorContext.getString(R.string.err_invalid_file_name_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_INVALID_FILE_EXTENSION_MESSAGE)) { - return new CometChatException(ERROR_INVALID_FILE_EXTENSION_MESSAGE, - errorContext.getString(R.string.err_invalid_file_extension_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_INVALID_FILE_MIME_TYPE_MESSAGE)) { - return new CometChatException(ERROR_INVALID_FILE_MIME_TYPE_MESSAGE, - errorContext.getString(R.string.err_invalid_file_mime_type_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_INVALID_FILE_URL_MESSAGE)) { - return new CometChatException(ERROR_INVALID_FILE_URL_MESSAGE, - errorContext.getString(R.string.err_invalid_file_url_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_CONVERSATION_NOT_FOUND_MESSAGE)) { - return new CometChatException(ERROR_CONVERSATION_NOT_FOUND_MESSAGE, - errorContext.getString(R.string.err_conversation_not_found_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_SETTINGS_NOT_FOUND_MESSAGE)) { - return new CometChatException(ERROR_SETTINGS_NOT_FOUND_MESSAGE, - errorContext.getString(R.string.err_settings_not_found_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_INVALID_FEATURE_MESSAGE)) { - return new CometChatException(ERROR_INVALID_FEATURE_MESSAGE, - errorContext.getString(R.string.err_invalid_feature_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_INVALID_EXTENSION_MESSAGE)) { - return new CometChatException(ERROR_INVALID_EXTENSION_MESSAGE, - errorContext.getString(R.string.err_invalid_extension_message)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_FEATURE_NOT_FOUND_MESSAGE)) { - return new CometChatException(ERROR_FEATURE_NOT_FOUND_MESSAGE, - errorContext.getString(R.string.err_feature_not_found)).getMessage(); - } else if (e.getCode().equalsIgnoreCase(ERROR_EXTENSION_NOT_FOUND_MESSAGE)) { - return new CometChatException(ERROR_EXTENSION_NOT_FOUND_MESSAGE, - errorContext.getString(R.string.extension_not_found)).getMessage(); } -// else if (e.getCode().equalsIgnoreCase()) else { - return e.getMessage(); + return new CometChatException(ERROR_DEFAULT_MESSAGE, + errorContext.getString(R.string.err_default_message)).getMessage(); } } public static class Extension { public static String localized(CometChatException e,String extensionId) { if (e.getCode().equalsIgnoreCase(ERR_EXTENSION_NOT_FOUND)) { return new CometChatException(ERR_EXTENSION_NOT_FOUND, - extensionId+":"+errorContext.getString(R.string.extension_not_found)).getMessage(); + extensionId+":"+errorContext.getString(R.string.extension_not_found)).getMessage(); } else if (e.getCode().equalsIgnoreCase(ERR_EXTENSION_NOT_ENABLED)) { return new CometChatException(ERR_EXTENSION_NOT_ENABLED, errorContext.getString(R.string.extension_is_not_enabled)).getMessage(); diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_resources/utils/MediaUtils.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_resources/utils/MediaUtils.java index c8c3021..7403332 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_resources/utils/MediaUtils.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_resources/utils/MediaUtils.java @@ -2,11 +2,13 @@ import android.annotation.SuppressLint; import android.app.Activity; +import android.app.ProgressDialog; import android.content.ComponentName; import android.content.ContentResolver; import android.content.ContentUris; import android.content.ContentValues; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; @@ -17,21 +19,27 @@ import android.media.AudioManager; import android.media.MediaPlayer; import android.net.Uri; +import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; import android.os.Environment; import android.os.Parcelable; +import android.os.PowerManager; import android.os.Vibrator; import android.provider.DocumentsContract; import android.provider.MediaStore; +import android.provider.OpenableColumns; import android.util.Log; import android.widget.Toast; import androidx.core.content.FileProvider; import androidx.loader.content.CursorLoader; +import com.cometchat.pro.models.BaseMessage; +import com.cometchat.pro.models.MediaMessage; import com.cometchat.pro.uikit.BuildConfig; -import com.cometchat.pro.uikit.ui_settings.UISettings; +import com.cometchat.pro.uikit.R; +import com.cometchat.pro.uikit.ui_settings.FeatureRestriction; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; @@ -41,6 +49,8 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URL; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; @@ -56,8 +66,13 @@ public class MediaUtils { public static String pictureImagePath; + private static ProgressDialog mProgressDialog; + + private static BaseMessage baseMessage; + public static Uri uri; + static String TAG = "MediaUtils"; public static Intent getPickImageChooserIntent(Activity a) { activity = a; // Determine Uri of camera image to save. @@ -67,7 +82,7 @@ public static Intent getPickImageChooserIntent(Activity a) { PackageManager packageManager = activity.getPackageManager(); // collect all camera intents - Intent captureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); + Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); List listCam = packageManager.queryIntentActivities(captureIntent, 0); for (ResolveInfo res : listCam) { Intent intent = new Intent(captureIntent); @@ -295,31 +310,27 @@ private static File createFileFromBitmap(Bitmap bitmap) { return f; } - public static File getRealPath(Context context, Uri fileUri) { + public static File getRealPath(Context context, Uri fileUri,boolean isThirdParty) { Log.d("", "getRealPath: " + fileUri.getPath()); String realPath; if (isGoogleDrive(fileUri)) { return saveDriveFile(context, fileUri); } - else if (isWhatsAppMedia(fileUri)) { - return getWhatsAppImage(context, fileUri); - } - // SDK < API11 - else if (Build.VERSION.SDK_INT < 11) { - realPath = getRealPathFromURI_BelowAPI11(context, fileUri); - } - // SDK >= 11 && SDK < 19 - else if (Build.VERSION.SDK_INT < 19) { - realPath = getRealPathFromURI_API11to18(context, fileUri); + else if (isThirdParty) { + return downloadImage(context, fileUri); } // SDK > 19 (Android 4.4) and up + else if (Build.VERSION.SDK_INT < 28){ + realPath = getRealPathFromURI(context, fileUri); + } else { - realPath = getRealPathFromURI_API19(context, fileUri); + realPath = getFilePathForN(fileUri,context); } + return new File(realPath); } - public static File getWhatsAppImage(Context context,Uri imageUri) { + public static File downloadImage(Context context, Uri imageUri) { // Uri imageUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM); File file = null; try { @@ -352,6 +363,45 @@ public static File getWhatsAppImage(Context context,Uri imageUri) { return file; } + private static String getFilePathForN(Uri uri, Context context) { + Uri returnUri = uri; + Cursor returnCursor = context.getContentResolver().query(returnUri, null, null, null, null); + /* + * Get the column indexes of the data in the Cursor, + * * move to the first row in the Cursor, get the data, + * * and display it. + * */ + int nameIndex = returnCursor.getColumnIndex(OpenableColumns.DISPLAY_NAME); + int sizeIndex = returnCursor.getColumnIndex(OpenableColumns.SIZE); + returnCursor.moveToFirst(); + String name = (returnCursor.getString(nameIndex)); + String size = (Long.toString(returnCursor.getLong(sizeIndex))); + File file = new File(context.getFilesDir(), name); + try { + InputStream inputStream = context.getContentResolver().openInputStream(uri); + FileOutputStream outputStream = new FileOutputStream(file); + int read = 0; + int maxBufferSize = 1 * 1024 * 1024; + int bytesAvailable = inputStream.available(); + + //int bufferSize = 1024; + int bufferSize = Math.min(bytesAvailable, maxBufferSize); + + final byte[] buffers = new byte[bufferSize]; + while ((read = inputStream.read(buffers)) != -1) { + outputStream.write(buffers, 0, read); + } + Log.e("File Size", "Size " + file.length()); + inputStream.close(); + outputStream.close(); + Log.e("File Path", "Path " + file.getPath()); + Log.e("File Size", "Size " + file.length()); + } catch (Exception e) { + Log.e("Exception", e.getMessage()); + } + return file.getPath(); + } + public static File saveDriveFile(Context context, Uri uri) { try { @@ -390,37 +440,6 @@ public static File makeEmptyFileWithTitle(String title) { return new File(root, title); } - @SuppressLint("NewApi") - private static String getRealPathFromURI_API11to18(Context context, Uri contentUri) { - String[] proj = {MediaStore.Images.Media.DATA}; - String result = null; - - CursorLoader cursorLoader = new CursorLoader(context, contentUri, proj, null, null, null); - Cursor cursor = cursorLoader.loadInBackground(); - - if (cursor != null) { - int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); - cursor.moveToFirst(); - result = cursor.getString(column_index); - cursor.close(); - } - return result; - } - - private static String getRealPathFromURI_BelowAPI11(Context context, Uri contentUri) { - String[] proj = {MediaStore.Images.Media.DATA}; - Cursor cursor = context.getContentResolver().query(contentUri, proj, null, null, null); - int column_index = 0; - String result = ""; - if (cursor != null) { - column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); - cursor.moveToFirst(); - result = cursor.getString(column_index); - cursor.close(); - return result; - } - return result; - } /** * Get a file path from a Uri. This will get the the path for Storage Access @@ -431,7 +450,7 @@ private static String getRealPathFromURI_BelowAPI11(Context context, Uri content * @param uri The Uri to query. * @author paulburke */ - private static String getRealPathFromURI_API19(final Context context, final Uri uri) { + private static String getRealPathFromURI(final Context context, final Uri uri) { final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT; @@ -530,7 +549,7 @@ else if ("file".equalsIgnoreCase(uri.getScheme())) { return null; } - private static void saveFileFromUri(Context context, Uri uri, String destinationPath) { + public static void saveFileFromUri(Context context, Uri uri, String destinationPath) { InputStream is = null; BufferedOutputStream bos = null; try { @@ -654,22 +673,27 @@ public static Camera openFrontCam() } public static void playSendSound(Context context ,int ringId) { - 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; - } + FeatureRestriction.isMessagesSoundEnabled(new FeatureRestriction.OnSuccessListener() { + @Override + public void onSuccess(Boolean booleanVal) { + + if (booleanVal) { + 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) { @@ -677,4 +701,136 @@ public static void vibrate(Context context) vibrator.vibrate(100); } + + public static void downloadAndShareFile(Context context, MediaMessage mediaMessage) { + if (mediaMessage.getAttachment()!=null) { + mProgressDialog = new ProgressDialog(context); + mProgressDialog.setMessage(context.getString(R.string.downloading)); + mProgressDialog.setIndeterminate(true); + mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); + mProgressDialog.setCancelable(true); + + baseMessage = mediaMessage; +// execute this when the downloader must be fired + final DownloadTask downloadTask = new DownloadTask(context); + downloadTask.execute(mediaMessage.getAttachment().getFileUrl(), + mediaMessage.getAttachment().getFileName()); + + mProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { + + @Override + public void onCancel(DialogInterface dialog) { + downloadTask.cancel(true); //cancel the task + } + }); + } + } + + //Download Media File before sharing + + static class DownloadTask extends AsyncTask { + + private Context context; + private PowerManager.WakeLock mWakeLock; + + public DownloadTask(Context context) { + this.context = context; + } + + @Override + protected String doInBackground(String... sUrl) { + InputStream input = null; + OutputStream output = null; + HttpURLConnection connection = null; + try { + URL url = new URL(sUrl[0]); + String fileName = sUrl[1]; + connection = (HttpURLConnection) url.openConnection(); + connection.connect(); + + // expect HTTP 200 OK, so we don't mistakenly save error report + // instead of the file + if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) { + return "Server returned HTTP " + connection.getResponseCode() + + " " + connection.getResponseMessage(); + } + + // this will be useful to display download percentage + // might be -1: server did not report the length + int fileLength = connection.getContentLength(); + + // download the file + input = connection.getInputStream(); + File file = MediaUtils.makeEmptyFileWithTitle(fileName); + output = new FileOutputStream(file); + byte data[] = new byte[4096]; + long total = 0; + int count; + while ((count = input.read(data)) != -1) { + // allow canceling with back button + if (isCancelled()) { + input.close(); + return null; + } + total += count; + // publishing the progress.... + if (fileLength > 0) // only if total length is known + publishProgress((int) (total * 100 / fileLength)); + output.write(data, 0, count); + } + return file.getAbsolutePath(); + } catch (Exception e) { + Log.e(TAG, "doInBackground:Exception "+e ); + return e.toString(); + } finally { + try { + if (output != null) + output.close(); + if (input != null) + input.close(); + } catch (IOException ignored) { + } + + if (connection != null) + connection.disconnect(); + } + } + + @Override + protected void onPreExecute() { + super.onPreExecute(); + // take CPU lock to prevent CPU from going off if the user + // presses the power button during download + PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); + mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, + getClass().getName()); + mWakeLock.acquire(); + mProgressDialog.show(); + } + + @Override + protected void onProgressUpdate(Integer... progress) { + super.onProgressUpdate(progress); + // if we get here, length is known, now set indeterminate to false + mProgressDialog.setIndeterminate(false); + mProgressDialog.setMax(100); + mProgressDialog.setProgress(progress[0]); + } + + @Override + protected void onPostExecute(String result) { + mWakeLock.release(); + mProgressDialog.dismiss(); + try { + Intent shareIntent = new Intent(); + shareIntent.setAction(Intent.ACTION_SEND); + shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(result)); + shareIntent.setType(((MediaMessage)baseMessage).getAttachment().getFileMimeType()); + Intent intent = Intent.createChooser(shareIntent, context.getResources().getString(R.string.share_message)); + context.startActivity(intent); + } catch (Exception e) { + Toast.makeText(context, context.getString(R.string.error) +":"+ e.getMessage(), Toast.LENGTH_LONG).show(); + } + } + } } \ No newline at end of file diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_resources/utils/Utils.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_resources/utils/Utils.java index 54e4f7d..b04a785 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_resources/utils/Utils.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_resources/utils/Utils.java @@ -40,6 +40,7 @@ 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.helpers.Logger; @@ -139,10 +140,21 @@ public static String getCallDate(long var0) { return DateFormat.format("dd MMM yy", var2).toString(); } - public static String getDate(long var0) { + public static String getDate(Context context,long var0) { Calendar var2 = Calendar.getInstance(Locale.ENGLISH); - var2.setTimeInMillis(var0); - return DateFormat.format("dd MMMM yyyy", var2).toString(); + var2.setTimeInMillis(var0*1000L); + + long currentTimeStamp = System.currentTimeMillis(); + + long diffTimeStamp = currentTimeStamp - var0 * 1000; + if (diffTimeStamp < 24 * 60 * 60 * 1000) { + return context.getString(R.string.today); + + } else if (diffTimeStamp < 48 * 60 * 60 * 1000) { + + return context.getString(R.string.yesterday); + } else + return DateFormat.format("dd MMMM yyyy", var2).toString(); } public static List userSort(List userList) { @@ -179,7 +191,7 @@ public static String getLastMessage(Context context,BaseMessage lastMessage) { switch (lastMessage.getCategory()) { - case com.cometchat.pro.constants.CometChatConstants.CATEGORY_MESSAGE: + case CometChatConstants.CATEGORY_MESSAGE: if (lastMessage instanceof TextMessage) { @@ -187,17 +199,18 @@ public static String getLastMessage(Context context,BaseMessage lastMessage) { message = context.getString(R.string.you) +": "+ (((TextMessage) lastMessage).getText()==null ?context.getString(R.string.this_message_deleted):((TextMessage) lastMessage).getText()); else - message = lastMessage.getSender().getName() + ": " + ((TextMessage) lastMessage).getText(); + message = lastMessage.getSender().getName() + ": " + (((TextMessage) lastMessage).getText()==null + ?context.getString(R.string.this_message_deleted):((TextMessage) lastMessage).getText()); } else if (lastMessage instanceof MediaMessage) { if (lastMessage.getDeletedAt()==0) { - if (lastMessage.getType().equals(com.cometchat.pro.constants.CometChatConstants.MESSAGE_TYPE_IMAGE)) + if (lastMessage.getType().equals(CometChatConstants.MESSAGE_TYPE_IMAGE)) message = context.getString(R.string.message_image); - else if (lastMessage.getType().equals(com.cometchat.pro.constants.CometChatConstants.MESSAGE_TYPE_VIDEO)) + else if (lastMessage.getType().equals(CometChatConstants.MESSAGE_TYPE_VIDEO)) message = context.getString(R.string.message_video); - else if (lastMessage.getType().equals(com.cometchat.pro.constants.CometChatConstants.MESSAGE_TYPE_FILE)) + else if (lastMessage.getType().equals(CometChatConstants.MESSAGE_TYPE_FILE)) message = context.getString(R.string.message_file); - else if (lastMessage.getType().equals(com.cometchat.pro.constants.CometChatConstants.MESSAGE_TYPE_AUDIO)) + else if (lastMessage.getType().equals(CometChatConstants.MESSAGE_TYPE_AUDIO)) message = context.getString(R.string.message_audio); } else message = context.getString(R.string.this_message_deleted); @@ -211,7 +224,7 @@ else if (lastMessage.getType().equals(com.cometchat.pro.constants.CometChatConst // } } break; - case com.cometchat.pro.constants.CometChatConstants.CATEGORY_CUSTOM: + case CometChatConstants.CATEGORY_CUSTOM: if (lastMessage.getDeletedAt()==0) { if (lastMessage.getType().equals(UIKitConstants.IntentStrings.LOCATION)) message = context.getString(R.string.custom_message_location); @@ -231,23 +244,23 @@ else if (lastMessage.getType().equalsIgnoreCase(UIKitConstants.IntentStrings.GRO message = context.getString(R.string.this_message_deleted); break; - case com.cometchat.pro.constants.CometChatConstants.CATEGORY_ACTION: + case CometChatConstants.CATEGORY_ACTION: message = ((Action) lastMessage).getMessage(); break; - case com.cometchat.pro.constants.CometChatConstants.CATEGORY_CALL: - if (((Call)lastMessage).getCallStatus().equalsIgnoreCase(com.cometchat.pro.constants.CometChatConstants.CALL_STATUS_ENDED) || - ((Call) lastMessage).getCallStatus().equalsIgnoreCase(com.cometchat.pro.constants.CometChatConstants.CALL_STATUS_CANCELLED)) { - if (lastMessage.getType().equalsIgnoreCase(com.cometchat.pro.constants.CometChatConstants.CALL_TYPE_AUDIO)) + case CometChatConstants.CATEGORY_CALL: + if (((Call)lastMessage).getCallStatus().equalsIgnoreCase(CometChatConstants.CALL_STATUS_ENDED) || + ((Call) lastMessage).getCallStatus().equalsIgnoreCase(CometChatConstants.CALL_STATUS_CANCELLED)) { + if (lastMessage.getType().equalsIgnoreCase(CometChatConstants.CALL_TYPE_AUDIO)) message = context.getString(R.string.incoming_audio_call); else message = context.getString(R.string.incoming_video_call); - } else if (((Call)lastMessage).getCallStatus().equalsIgnoreCase(com.cometchat.pro.constants.CometChatConstants.CALL_STATUS_ONGOING)) { + } else if (((Call)lastMessage).getCallStatus().equalsIgnoreCase(CometChatConstants.CALL_STATUS_ONGOING)) { message = context.getString(R.string.ongoing_call); - } else if (((Call) lastMessage).getCallStatus().equalsIgnoreCase(com.cometchat.pro.constants.CometChatConstants.CALL_STATUS_CANCELLED) || - ((Call) lastMessage).getCallStatus().equalsIgnoreCase(com.cometchat.pro.constants.CometChatConstants.CALL_STATUS_UNANSWERED) || - ((Call) lastMessage).getCallStatus().equalsIgnoreCase(com.cometchat.pro.constants.CometChatConstants.CALL_STATUS_BUSY)) { - if (lastMessage.getType().equalsIgnoreCase(com.cometchat.pro.constants.CometChatConstants.CALL_TYPE_AUDIO)) + } else if (((Call) lastMessage).getCallStatus().equalsIgnoreCase(CometChatConstants.CALL_STATUS_CANCELLED) || + ((Call) lastMessage).getCallStatus().equalsIgnoreCase(CometChatConstants.CALL_STATUS_UNANSWERED) || + ((Call) lastMessage).getCallStatus().equalsIgnoreCase(CometChatConstants.CALL_STATUS_BUSY)) { + if (lastMessage.getType().equalsIgnoreCase(CometChatConstants.CALL_TYPE_AUDIO)) message = context.getString(R.string.missed_voice_call); else message = context.getString(R.string.missed_video_call); @@ -280,7 +293,7 @@ public static GroupMember UserToGroupMember(User user, boolean isScopeUpdate, St if (isScopeUpdate) groupMember = new GroupMember(user.getUid(), newScope); else - groupMember = new GroupMember(user.getUid(), com.cometchat.pro.constants.CometChatConstants.SCOPE_PARTICIPANT); + groupMember = new GroupMember(user.getUid(), CometChatConstants.SCOPE_PARTICIPANT); groupMember.setAvatar(user.getAvatar()); groupMember.setName(user.getName()); @@ -299,7 +312,7 @@ public static String getHeaderDate(long timestamp) { // } } - public static String getLastMessageDate(long timestamp) { + public static String getLastMessageDate(Context context,long timestamp) { String lastMessageTime = new SimpleDateFormat("h:mm a").format(new java.util.Date(timestamp * 1000)); String lastMessageDate = new SimpleDateFormat("dd MMM yyyy").format(new java.util.Date(timestamp * 1000)); String lastMessageWeek = new SimpleDateFormat("EEE").format(new java.util.Date(timestamp * 1000)); @@ -313,7 +326,7 @@ public static String getLastMessageDate(long timestamp) { } else if (diffTimeStamp < 48 * 60 * 60 * 1000) { - return "Yesterday"; + return context.getString(R.string.yesterday); } else if (diffTimeStamp < 7 * 24 * 60 * 60 * 1000) { return lastMessageWeek; } else { @@ -349,7 +362,7 @@ public static String generateRandomString(int length) { return sb.toString(); } - public static String getReceiptDate(long timestamp) { + public static String getReceiptDate(Context context,long timestamp) { String lastMessageTime = new SimpleDateFormat("h:mm a").format(new java.util.Date(timestamp * 1000)); String lastMessageDate = new SimpleDateFormat("dd MMMM h:mm a").format(new java.util.Date(timestamp * 1000)); String lastMessageWeek = new SimpleDateFormat("EEE h:mm a").format(new java.util.Date(timestamp * 1000)); @@ -363,7 +376,7 @@ public static String getReceiptDate(long timestamp) { } else if (diffTimeStamp < 48 * 60 * 60 * 1000) { - return "Yesterday"; + return context.getString(R.string.yesterday); } else if (diffTimeStamp < 7 * 24 * 60 * 60 * 1000) { return lastMessageWeek; } else { @@ -576,12 +589,6 @@ public static File getDocumentCacheDir(@NonNull Context context) { return dir; } - public static String getPath(Context context, String folder) { - - return Environment.getExternalStorageDirectory().toString() + "/" + - context.getResources().getString(R.string.app_name) + "/" + folder + "/"; - } - public static String getPath(final Context context, final Uri uri) { String absolutePath = getImagePathFromUri(context, uri); return absolutePath != null ? absolutePath : uri.toString(); @@ -728,7 +735,7 @@ public static void showKeyBoard(Context context,View mainLayout) { public static Call getDirectCallData(BaseMessage baseMessage) { Call call = null; - String callType = com.cometchat.pro.constants.CometChatConstants.CALL_TYPE_VIDEO; + String callType = CometChatConstants.CALL_TYPE_VIDEO; try { if (((CustomMessage)baseMessage).getCustomData() != null) { JSONObject customObject = ((CustomMessage)baseMessage).getCustomData(); diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_resources/utils/pattern_utils/PatternUtils.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_resources/utils/pattern_utils/PatternUtils.java index c63577b..ab5c82f 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_resources/utils/pattern_utils/PatternUtils.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_resources/utils/pattern_utils/PatternUtils.java @@ -10,7 +10,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import com.cometchat.pro.uikit.ui_settings.UISettings; +import com.cometchat.pro.uikit.ui_settings.FeatureRestriction; public class PatternUtils { public static void setHyperLinkSupport(Context context, TextView txtMessage) { @@ -18,7 +18,7 @@ public static void setHyperLinkSupport(Context context, TextView txtMessage) { addPattern(Pattern.compile("(^|[\\s.:;?\\-\\]<\\(])" + "((https?://|www\\.|pic\\.)[-\\w;/?:@&=+$\\|\\_.!~*\\|'()\\[\\]%#,☺]+[\\w/#](\\(\\))?)" + "(?=$|[\\s',\\|\\(\\).:;?\\-\\[\\]>\\)])"), - context.getResources().getColor(UISettings.getUrlColor()), + context.getResources().getColor(FeatureRestriction.getUrlColor()), new PatternBuilder.SpannableClickedListener() { @Override public void onSpanClicked(String text) { @@ -31,7 +31,7 @@ public void onSpanClicked(String text) { } }).into(txtMessage); new PatternBuilder(). - addPattern(Patterns.PHONE, context.getResources().getColor(UISettings.getPhoneColor()), + addPattern(Patterns.PHONE, context.getResources().getColor(FeatureRestriction.getPhoneColor()), new PatternBuilder.SpannableClickedListener() { @Override public void onSpanClicked(String text) { @@ -42,7 +42,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(UISettings.getEmailColor()), + context.getResources().getColor(FeatureRestriction.getEmailColor()), new PatternBuilder.SpannableClickedListener() { @Override public void onSpanClicked(String text) { diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_resources/utils/recycler_touch/RecyclerTouchListener.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_resources/utils/recycler_touch/RecyclerTouchListener.java index cfb2499..3a689b8 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_resources/utils/recycler_touch/RecyclerTouchListener.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_resources/utils/recycler_touch/RecyclerTouchListener.java @@ -1,17 +1,28 @@ package com.cometchat.pro.uikit.ui_resources.utils.recycler_touch; import android.content.Context; +import android.graphics.Canvas; import android.view.GestureDetector; import android.view.MotionEvent; import android.view.View; +import androidx.recyclerview.widget.ItemTouchHelper; import androidx.recyclerview.widget.RecyclerView; -public class RecyclerTouchListener implements RecyclerView.OnItemTouchListener { +import com.cometchat.pro.uikit.R; + +public class RecyclerTouchListener extends ItemTouchHelper.SimpleCallback implements RecyclerView.OnItemTouchListener { private ClickListener clickListener; private GestureDetector gestureDetector; + private RecyclerItemSwipeListener swipeListener; + + public RecyclerTouchListener(RecyclerView recyclerView, int dragDirs, int swipeDirs, RecyclerItemSwipeListener listener) { + super(dragDirs, swipeDirs); + this.swipeListener = listener; + } public RecyclerTouchListener(Context var1, final RecyclerView var2, final ClickListener var3) { + super(0,0); this.clickListener = var3; this.gestureDetector = new GestureDetector(var1, new GestureDetector.SimpleOnGestureListener() { public boolean onSingleTapUp(MotionEvent var1) { @@ -44,5 +55,59 @@ public void onRequestDisallowInterceptTouchEvent(boolean var1) { } + @Override + public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) { + return true; + } + + @Override + public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) { + if (viewHolder != null) { + final View foregroundView = viewHolder.itemView.findViewById(R.id.view_foreground); + if (foregroundView!=null) + getDefaultUIUtil().onSelected(foregroundView); + } + } + + @Override + public void onChildDrawOver(Canvas c, RecyclerView recyclerView, + RecyclerView.ViewHolder viewHolder, float dX, float dY, + int actionState, boolean isCurrentlyActive) { + final View foregroundView = viewHolder.itemView.findViewById(R.id.view_foreground); + if (foregroundView!=null) + getDefaultUIUtil().onDrawOver(c, recyclerView, foregroundView, dX, dY, + actionState, isCurrentlyActive); + } + + @Override + public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { + final View foregroundView = viewHolder.itemView.findViewById(R.id.view_foreground); + if (foregroundView!=null) + getDefaultUIUtil().clearView(foregroundView); + } + + @Override + public void onChildDraw(Canvas c, RecyclerView recyclerView, + RecyclerView.ViewHolder viewHolder, float dX, float dY, + int actionState, boolean isCurrentlyActive) { + final View foregroundView = viewHolder.itemView.findViewById(R.id.view_foreground); + if (foregroundView!=null) + getDefaultUIUtil().onDraw(c, recyclerView, foregroundView, dX, dY, + actionState, isCurrentlyActive); + } + + @Override + public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { + swipeListener.onSwiped(viewHolder, direction, viewHolder.getAdapterPosition()); + } + + @Override + public int convertToAbsoluteDirection(int flags, int layoutDirection) { + return super.convertToAbsoluteDirection(flags, layoutDirection); + } + + public interface RecyclerItemSwipeListener { + void onSwiped(RecyclerView.ViewHolder viewHolder, int direction, int position); + } } diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_resources/utils/recycler_touch/RecyclerViewSwipeListener.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_resources/utils/recycler_touch/RecyclerViewSwipeListener.java new file mode 100644 index 0000000..1ea597a --- /dev/null +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_resources/utils/recycler_touch/RecyclerViewSwipeListener.java @@ -0,0 +1,255 @@ +package com.cometchat.pro.uikit.ui_resources.utils.recycler_touch; + +import android.content.Context; +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.graphics.Point; +import android.graphics.Rect; +import android.graphics.RectF; +import android.view.GestureDetector; +import android.view.MotionEvent; +import android.view.View; + +import androidx.recyclerview.widget.ItemTouchHelper; +import androidx.recyclerview.widget.RecyclerView; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Queue; + +public abstract class RecyclerViewSwipeListener extends ItemTouchHelper.SimpleCallback { + + public static final int BUTTON_WIDTH = 200; + private RecyclerView recyclerView; + private List buttons; + private GestureDetector gestureDetector; + private int swipedPos = -1; + private float swipeThreshold = 0.5f; + private Map> buttonsBuffer; + private Queue recoverQueue; + + private GestureDetector.SimpleOnGestureListener gestureListener = new GestureDetector.SimpleOnGestureListener() { + @Override + public boolean onSingleTapConfirmed(MotionEvent e) { + for (UnderlayButton button : buttons) { + if (button.onClick(e.getX(), e.getY())) + break; + } + return true; + } + }; + + private View.OnTouchListener onTouchListener = new View.OnTouchListener() { + @Override + public boolean onTouch(View view, MotionEvent e) { + if (swipedPos < 0) return false; + Point point = new Point((int) e.getRawX(), (int) e.getRawY()); + + RecyclerView.ViewHolder swipedViewHolder = recyclerView.findViewHolderForAdapterPosition(swipedPos); + View swipedItem = swipedViewHolder.itemView; + Rect rect = new Rect(); + swipedItem.getGlobalVisibleRect(rect); + + if (e.getAction() == MotionEvent.ACTION_DOWN || e.getAction() == MotionEvent.ACTION_UP || e.getAction() == MotionEvent.ACTION_MOVE) { + if (rect.top < point.y && rect.bottom > point.y) + gestureDetector.onTouchEvent(e); + else { + recoverQueue.add(swipedPos); + swipedPos = -1; + recoverSwipedItem(); + } + } + return false; + } + }; + + public RecyclerViewSwipeListener(Context context) { + super(0, ItemTouchHelper.LEFT); + this.buttons = new ArrayList<>(); + this.gestureDetector = new GestureDetector(context, gestureListener); + buttonsBuffer = new HashMap<>(); + recoverQueue = new LinkedList() { + @Override + public boolean add(Integer o) { + if (contains(o)) + return false; + else + return super.add(o); + } + }; + } + + + @Override + public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) { + return false; + } + + @Override + public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { + int pos = viewHolder.getAdapterPosition(); + + if (swipedPos != pos) + recoverQueue.add(swipedPos); + + swipedPos = pos; + + if (buttonsBuffer.containsKey(swipedPos)) + buttons = buttonsBuffer.get(swipedPos); + else + buttons.clear(); + + buttonsBuffer.clear(); + swipeThreshold = 0.5f * buttons.size() * BUTTON_WIDTH; + recoverSwipedItem(); + } + + @Override + public float getSwipeThreshold(RecyclerView.ViewHolder viewHolder) { + return swipeThreshold; + } + + @Override + public float getSwipeEscapeVelocity(float defaultValue) { + return 0.1f * defaultValue; + } + + @Override + public float getSwipeVelocityThreshold(float defaultValue) { + return 5.0f * defaultValue; + } + + @Override + public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) { + int pos = viewHolder.getAdapterPosition(); + float translationX = dX; + View itemView = viewHolder.itemView; + + if (pos < 0) { + swipedPos = pos; + return; + } + + if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) { + if (dX < 0) { + List buffer = new ArrayList<>(); + + if (!buttonsBuffer.containsKey(pos)) { + instantiateUnderlayButton(viewHolder, buffer); + buttonsBuffer.put(pos, buffer); + } else { + buffer = buttonsBuffer.get(pos); + } + + translationX = dX * buffer.size() * BUTTON_WIDTH / itemView.getWidth(); + drawButtons(c, itemView, buffer, pos, translationX); + } + } + + super.onChildDraw(c, recyclerView, viewHolder, translationX, dY, actionState, isCurrentlyActive); + } + + private synchronized void recoverSwipedItem() { + while (!recoverQueue.isEmpty()) { + int pos = recoverQueue.poll(); + if (pos > -1) { + recyclerView.getAdapter().notifyItemChanged(pos); + } + } + } + + private void drawButtons(Canvas c, View itemView, List buffer, int pos, float dX) { + float right = itemView.getRight(); + float dButtonWidth = (-1) * dX / buffer.size(); + + for (UnderlayButton button : buffer) { + float left = right - dButtonWidth; + button.onDraw( + c, + new RectF( + left, + itemView.getTop(), + right, + itemView.getBottom() + ), + pos + ); + + right = left; + } + } + + public void attachToRecyclerView(RecyclerView recyclerView) { + this.recyclerView = recyclerView; + this.recyclerView.setOnTouchListener(onTouchListener); + ItemTouchHelper itemTouchHelper = new ItemTouchHelper(this); + itemTouchHelper.attachToRecyclerView(this.recyclerView); + } + + public abstract void instantiateUnderlayButton(RecyclerView.ViewHolder viewHolder, List underlayButtons); + + public interface UnderlayButtonClickListener { + void onClick(int pos); + } + + public static class UnderlayButton { + private String text; + private Bitmap imageBitmap; + private int color; + private int pos; + private RectF clickRegion; + private UnderlayButtonClickListener clickListener; + + public UnderlayButton(String text, Bitmap imageBitmap, int color, UnderlayButtonClickListener clickListener) { + this.text = text; + this.imageBitmap = imageBitmap; + this.color = color; + this.clickListener = clickListener; + } + + public boolean onClick(float x, float y) { + if (clickRegion != null && clickRegion.contains(x, y)) { + clickListener.onClick(pos); + return true; + } + + return false; + } + + public void onDraw(Canvas c, RectF rect, int pos) { + Paint p = new Paint(); + + // Draw background + p.setColor(color); + c.drawRect(rect, p); + + // Draw Text + p.setColor(Color.WHITE); + //p.setTextSize(LayoutHelper.getPx(MyApplication.getAppContext(), 12)); + p.setTextSize(Resources.getSystem().getDisplayMetrics().density * 12); + + Rect r = new Rect(); + float cHeight = rect.height(); + float cWidth = rect.width(); + p.setTextAlign(Paint.Align.LEFT); + p.getTextBounds(text, 0, text.length(), r); + float x = cWidth / 2f - r.width() / 2f - r.left; + float y = cHeight / 2f + r.height() / 2f - r.bottom; + if (!text.isEmpty()) + c.drawText(text, rect.left + x, rect.top+y/0.72f, p); + if (imageBitmap!=null) { + c.drawBitmap(imageBitmap,rect.left+x/0.9f,rect.top+y/3f,p); + } + + clickRegion = rect; + this.pos = pos; + } + } +} \ No newline at end of file diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_settings/Feature.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_settings/Feature.java new file mode 100644 index 0000000..395a05c --- /dev/null +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_settings/Feature.java @@ -0,0 +1,98 @@ +package com.cometchat.pro.uikit.ui_settings; + +public class Feature { +// public static final String FEATURE_CHAT_ENABLED = "core.chat.enabled"; + public static final String chat_one_on_one_enabled = "core.chat.one-on-one.enabled"; + public static final String chat_groups_enabled = "core.chat.groups.enabled"; + public static final String chat_groups_public_enabled = "core.chat.groups.public.enabled"; + public static final String chat_groups_private_enabled = "core.chat.groups.private.enabled"; + public static final String chat_groups_password_enabled = "core.chat.groups.password.enabled"; + public static final String chat_users_list_enabled = "core.chat.users.list.enabled"; + public static final String chat_users_presence_enabled = "core.chat.users.presence.enabled"; + public static final String chat_typing_indicator_enabled = "core.chat.typing-indicator.enabled"; + public static final String chat_messages_receipts_enabled = "core.chat.messages.receipts.enabled"; + public static final String chat_messages_custom_enabled = "core.chat.messages.custom.enabled"; + public static final String chat_messages_media_enabled = "core.chat.messages.media.enabled"; + public static final String chat_messages_replies_enabled = "core.chat.messages.replies.enabled"; + public static final String chat_voice_notes_enabled = "core.chat.voice-notes.enabled"; + public static final String chat_messages_history_enabled = "core.chat.messages.history.enabled"; + public static final String chat_messages_unread_count_enabled = "core.chat.messages.unread-count.enabled"; + public static final String chat_users_search_enabled = "core.chat.users.search.enabled"; + public static final String chat_groups_search_enabled = "core.chat.groups.search.enabled"; + public static final String chat_messages_search_enabled = "core.chat.messages.search.enabled"; + public static final String FEATURE_CALL_ENABLED = "core.call.enabled"; + public static final String call_one_on_one_audio_enabled = "core.call.one-on-one.audio.enabled"; + public static final String call_one_on_one_video_enabled = "core.call.one-on-one.video.enabled"; + public static final String call_groups_audio_enabled = "core.call.groups.audio.enabled"; + public static final String call_groups_video_enabled = "core.call.groups.video.enabled"; + public static final String call_recording_enabled = "core.call.recording.enabled"; + public static final String call_live_streaming_enabled = "core.call.live-streaming.enabled"; + public static final String call_transcript_enabled = "core.call.transcript.enabled"; + public static final String FEATURE_UX_ENABLED = "features.ux.enabled"; + public static final String thumbnail_generation_enabled = "features.ux.thumbnail-generation.enabled"; + public static final String link_preview_enabled = "features.ux.link-preview.enabled"; + public static final String messages_saved_enabled = "features.ux.messages.saved.enabled"; + public static final String messages_pinned_enabled = "features.ux.messages.pinned.enabled"; + public static final String rich_media_preview_enabled = "features.ux.rich-media-preview.enabled"; + public static final String voice_transcription_enabled = "features.ux.voice-transcription.enabled"; + public static final String FEATURE_UE_ENABLED = "features.ue.enabled"; + public static final String emojis_enabled = "features.ue.emojis.enabled"; + public static final String mentions_enabled = "features.ue.mentions.enabled"; + public static final String stickers_enabled = "features.ue.stickers.enabled"; + public static final String reactions_enabled = "features.ue.reactions.enabled"; + public static final String live_reactions_enabled = "features.ue.live-reactions.enabled"; + public static final String message_translation_enabled = "features.ue.message-translation.enabled"; + public static final String email_replies_enabled = "features.ue.email-replies.enabled"; + public static final String smart_replies_enabled = "features.ue.smart-replies.enabled"; + public static final String polls_enabled = "features.ue.polls.enabled"; + public static final String FEATURE_COLLABORATION_ENABLED = "features.collaboration.enabled"; + public static final String collaboration_whiteboard_enabled = "features.collaboration.whiteboard.enabled"; + public static final String collaboration_document_enabled = "features.collaboration.document.enabled"; + public static final String FEATURE_NOTIFICATION_ENABLED = "features.notifications.enabled"; + public static final String FEATURE_NOTIFICATION_PUSH_NOTIFICATION_ENABLED = "features.notifications.push-notification.enabled"; + public static final String FEATURE_NOTIFICATION_EMAIL_NOTIFICATION_ENABLED = "features.notifications.email-notification.enabled"; + public static final String FEATURE_NOTIFICATION_SMS_NOTIFICATION_ENABLED = "features.notifications.sms-notification.enabled"; + public static final String FEATURE_MODERATION_ENABLED = "features.moderation.enabled"; + public static final String moderation_users_block_enabled = "features.moderation.users.block.enabled"; + public static final String moderation_groups_moderators_enabled = "features.moderation.groups.moderators.enabled"; + public static final String moderation_groups_kick_enabled = "features.moderation.groups.kick.enabled"; + public static final String moderation_groups_ban_enabled = "features.moderation.groups.ban.enabled"; + public static final String moderation_xss_filter_enabled = "features.moderation.xss-filter.enabled"; + public static final String moderation_profanity_filter_enabled = "features.moderation.profanity-filter.enabled"; + public static final String moderation_image_moderation_enabled = "features.moderation.image-moderation.enabled"; + public static final String moderation_data_masking_enabled = "features.moderation.data-masking.enabled"; + public static final String moderation_malware_scanner_enabled = "features.moderation.malware-scanner.enabled"; + public static final String moderation_sentiment_analysis_enabled = "features.moderation.sentiment-analysis.enabled"; + public static final String FEATURE_MODERATION_IN_FLIGHT_MESSAGE_MODERATION_ENABLED = "features.moderation.inflight-message-moderation.enabled"; + public static final String FEATURE_WEBHOOKS_ENABLED = "features.webhooks.enabled"; + public static final String FEATURE_BOTS_ENABLED = "features.bots.enabled"; + public static final String FEATURE_DATA_ENABLED = "features.data.enabled"; + public static final String FEATURE_DATA_CROSS_PLATFORM_SYNC_ENABLED = "features.data.cross-platform-sync.enabled"; + public static final String FEATURE_DATA_MULTI_DEVICE_SUPPORT_ENABLED = "features.data.multi-device-support.enabled"; + public static final String FEATURE_INTEGRATION_ENABLED = "integrations.enabled"; + public static final String FEATURE_INTEGRATION_CHAT_WIDGET_ENABLED = "integrations.chat-widget.enabled"; + public static final String FEATURE_INTEGRATION_UI_KIT_ENABLED = "integrations.ui-kit.enabled"; + public static final String FEATURE_INTEGRATION_CLIENT_SDK_ENABLED = "integrations.client-sdk.enabled"; + + public static class Extension { + public static final String linkPreview = "link-preview"; + public static final String smartReply = "smart-reply"; + public static final String messageTranslation = "message-translation"; + public static final String profanityFilter = "profanity-filter"; + public static final String imageModeration = "image-moderation"; + public static final String thumbnailGeneration = "thumbnail-generator"; + public static final String sentimentalAnalysis = "sentiment-analysis"; + public static final String polls = "polls"; + public static final String reactions = "reactions"; + public static final String whiteboard = "whiteboard"; + public static final String document = "document"; + public static final String dataMasking = "data-masking"; + public static final String stickers = "stickers"; + public static final String saveMessage = "save-message"; + public static final String pinMessage = "pin-message"; + public static final String voiceTranscription = "voice-transcription"; + public static final String richMedia = "rich-media"; + public static final String malwareScanner = "virus-malware-scanner"; + public static final String mentions = "mentions"; + } +} diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_settings/FeatureRestriction.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_settings/FeatureRestriction.java new file mode 100644 index 0000000..dd40a44 --- /dev/null +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_settings/FeatureRestriction.java @@ -0,0 +1,1002 @@ +package com.cometchat.pro.uikit.ui_settings; + +import com.cometchat.pro.core.CometChat; +import com.cometchat.pro.exceptions.CometChatException; +import com.cometchat.pro.uikit.R; + +public class FeatureRestriction { + public static boolean isGroupActionMessagesEnabled() { + return UIKitSettings.isGroupNotifications(); + } + + public static boolean isCallActionMessageEnabled() { + return UIKitSettings.isCallNotification(); + } + + public static String getColor() { + return UIKitSettings.color; + } + + + public static void isUserListEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.chat_users_list_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean) + UIKitSettings.users(false); + onSuccessListener.onSuccess(UIKitSettings.isUsers()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + + public static void isGroupListEnabled(OnSuccessListener onSuccessListener) { + onSuccessListener.onSuccess(UIKitSettings.isGroups()); + } + + public static void isConversationListEnabled(OnSuccessListener onSuccessListener) { + onSuccessListener.onSuccess(UIKitSettings.isConversations()); + } + + public static void isCallListEnabled(OnSuccessListener onSuccessListener) { + onSuccessListener.onSuccess(UIKitSettings.isCalls()); + } + + public static void isUserSettingsEnabled(OnSuccessListener onSuccessListener) { + onSuccessListener.onSuccess(UIKitSettings.isUserSettings()); + } + + public static void isOneOnOneChatEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.chat_one_on_one_enabled, + new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean) + UIKitSettings.sendMessageInOneOneOne(false); + onSuccessListener.onSuccess(UIKitSettings.isSendMessageInOneOneOne()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isGroupChatEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.chat_groups_enabled, + new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean) + UIKitSettings.sendMessageInGroup(false); + onSuccessListener.onSuccess(UIKitSettings.isSendMessageInGroup()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isDeliveryReceiptsEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.chat_messages_receipts_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean) + UIKitSettings.showReadDeliveryReceipts(false); + onSuccessListener.onSuccess(UIKitSettings.isShowReadDeliveryReceipts()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isGifsEnabled(OnSuccessListener onSuccessListener) { + onSuccessListener.onSuccess(UIKitSettings.isSendGifs()); + } + public static void isLargeSizeEmojisEnabled(OnSuccessListener onSuccessListener) { + onSuccessListener.onSuccess(UIKitSettings.isSendEmojisLargeSize()); + } + + public static void isEmojisEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.emojis_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean) + UIKitSettings.sendEmojis(false); + onSuccessListener.onSuccess(UIKitSettings.isSendEmojis()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isVoiceNotesEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.chat_voice_notes_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean) + UIKitSettings.sendVoiceNotes(false); + onSuccessListener.onSuccess(UIKitSettings.isSendVoiceNotes()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isFilesEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.chat_messages_media_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean) + UIKitSettings.sendFiles(false); + onSuccessListener.onSuccess(UIKitSettings.isSendFiles()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isPollsEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.polls_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean || !CometChat.isExtensionEnabled(Feature.Extension.polls)) + UIKitSettings.sendPolls(false); + else { + UIKitSettings.sendPolls(true); + } + onSuccessListener.onSuccess(UIKitSettings.isSendPolls()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isStickersEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.stickers_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean || !CometChat.isExtensionEnabled(Feature.Extension.stickers)) + UIKitSettings.sendStickers(false); + else { + UIKitSettings.sendStickers(true); + } + onSuccessListener.onSuccess(UIKitSettings.isSendStickers()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isHideDeleteMessageEnabled(OnSuccessListener onSuccessListener) { + onSuccessListener.onSuccess(UIKitSettings.isHideDeleteMessage()); + } + public static void isPhotosVideoEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.chat_messages_media_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean) + UIKitSettings.sendPhotosVideo(false); + onSuccessListener.onSuccess(UIKitSettings.isSendPhotosVideo()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isThreadedMessagesEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.chat_messages_replies_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean) + UIKitSettings.threadedChats(false); + onSuccessListener.onSuccess(UIKitSettings.isThreadedChats()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isMessageRepliesEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.chat_messages_replies_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean) + UIKitSettings.replyingToMessage(false); + onSuccessListener.onSuccess(UIKitSettings.isReplyingToMessage()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isShareCopyForwardMessageEnabled(OnSuccessListener onSuccessListener) { + onSuccessListener.onSuccess(UIKitSettings.isShareCopyForwardMessage()); + } + + public static void isDeleteMessageEnabled(OnSuccessListener onSuccessListener) { + onSuccessListener.onSuccess(UIKitSettings.isDeleteMessage()); + } + + public static void isEditMessageEnabled(OnSuccessListener onSuccessListener) { + onSuccessListener.onSuccess(UIKitSettings.isEditMessage()); + } + + public static void isLocationSharingEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.chat_messages_custom_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean) + UIKitSettings.shareLocation(false); + onSuccessListener.onSuccess(UIKitSettings.isShareLocation()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isBlockUserEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.moderation_users_block_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean) + UIKitSettings.blockUser(false); + onSuccessListener.onSuccess(UIKitSettings.isBlockUser()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isTypingIndicatorsEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.chat_typing_indicator_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean) + UIKitSettings.sendTypingIndicators(false); + onSuccessListener.onSuccess(UIKitSettings.isSendTypingIndicators()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isSharedMediaEnabled(OnSuccessListener onSuccessListener) { + onSuccessListener.onSuccess(UIKitSettings.isViewSharedMedia()); + } + + public static void isUserPresenceEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.chat_users_presence_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean) + UIKitSettings.showUserPresence(false); + onSuccessListener.onSuccess(UIKitSettings.isShowUserPresence()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isChangingMemberScopeEnabled(OnSuccessListener onSuccessListener) { + onSuccessListener.onSuccess(UIKitSettings.isAllowPromoteDemoteMembers()); + } + +// public static boolean isAllowBanKickMembers() { +// return allowBanKickMembers; +// } + + public static void isBanningGroupMembersEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.moderation_groups_ban_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean) + UIKitSettings.banMember(false); + onSuccessListener.onSuccess(UIKitSettings.isBanMember()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isKickingGroupMembersEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.moderation_groups_kick_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean) + UIKitSettings.kickMember(false); + onSuccessListener.onSuccess(UIKitSettings.isKickMember()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isAddingGroupMembersEnabled(OnSuccessListener onSuccessListener) { + onSuccessListener.onSuccess(UIKitSettings.isAllowAddMembers()); + } + + public static void isDeleteMemberMessageEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.moderation_groups_moderators_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean) + UIKitSettings.allowModeratorToDeleteMemberMessages(false); + onSuccessListener.onSuccess(UIKitSettings.isAllowModeratorToDeleteMemberMessages()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isGroupDeletionEnabled(OnSuccessListener onSuccessListener) { + onSuccessListener.onSuccess(UIKitSettings.isAllowDeleteGroups()); + } + + public static void isViewGroupMemberInGroupDetails(OnSuccessListener onSuccessListener) { + onSuccessListener.onSuccess(UIKitSettings.isViewGroupMember()); + } + + public static void isJoinOrLeaveGroupEnabled(OnSuccessListener onSuccessListener) { + onSuccessListener.onSuccess(UIKitSettings.isJoinOrLeaveGroup()); + } + + public static void isGroupCreationEnabled(OnSuccessListener onSuccessListener) { + onSuccessListener.onSuccess(UIKitSettings.isGroupCreate()); + } + + public static void isGroupActionMessagesEnabled(OnSuccessListener onSuccessListener) { + onSuccessListener.onSuccess(UIKitSettings.isHideJoinLeaveNotifications()); + } + + public static void isOneOnOneVideoCallEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.call_one_on_one_video_enabled, + new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean) + UIKitSettings.userVideoCall(false); + onSuccessListener.onSuccess(UIKitSettings.isUserVideoCall()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isOneOnOneAudioCallEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.call_one_on_one_audio_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean) + UIKitSettings.userAudioCall(false); + onSuccessListener.onSuccess(UIKitSettings.isUserAudioCall()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isGroupVideoCallEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.call_groups_video_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean) + UIKitSettings.groupVideoCall(false); + onSuccessListener.onSuccess(UIKitSettings.isGroupVideoCall()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isGroupAudioCallEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.call_groups_audio_enabled, + new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean) + UIKitSettings.groupAudioCall(false); + onSuccessListener.onSuccess(UIKitSettings.isGroupAudioCall()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isMessagesSoundEnabled(OnSuccessListener onSuccessListener) { + onSuccessListener.onSuccess(UIKitSettings.isEnableSoundForMessages()); + } + + public static void isCallsSoundEnabled(OnSuccessListener onSuccessListener) { + onSuccessListener.onSuccess(UIKitSettings.isEnableSoundForCalls()); + } + + public static int getEmailColor() { + return UIKitSettings.emailColor; + } + + public static int getPhoneColor() { + return UIKitSettings.phoneColor; + } + + public static int getUrlColor() { + return UIKitSettings.urlColor; + } + + public static void isLiveReactionEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.live_reactions_enabled, + new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean) + UIKitSettings.sendLiveReaction(false); + onSuccessListener.onSuccess(UIKitSettings.isSendLiveReaction()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isReactionEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.reactions_enabled, + new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean || !CometChat.isExtensionEnabled(Feature.Extension.reactions)) + UIKitSettings.sendMessageReaction(false); + else { + UIKitSettings.sendMessageReaction(true); + } + onSuccessListener.onSuccess(UIKitSettings.isSendMessageReaction()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isCollaborativeWhiteBoardEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.collaboration_whiteboard_enabled, + new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean || !CometChat.isExtensionEnabled(Feature.Extension.whiteboard)) + UIKitSettings.collaborativeWhiteBoard(false); + onSuccessListener.onSuccess(UIKitSettings.isCollaborativeWhiteboard()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isCollaborativeDocumentEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.collaboration_document_enabled, + new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean || !CometChat.isExtensionEnabled(Feature.Extension.document)) + UIKitSettings.collaborativeDocument(false); + else + UIKitSettings.collaborativeDocument(true); + onSuccessListener.onSuccess(UIKitSettings.isCollaborativeDocument()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isMessageTranslationEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.message_translation_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean || !CometChat.isExtensionEnabled(Feature.Extension.messageTranslation)) + UIKitSettings.allowMessageTranslation(false); + else + UIKitSettings.allowMessageTranslation(true); + onSuccessListener.onSuccess(UIKitSettings.isAllowMessageTranslation()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isShowReplyPrivately(OnSuccessListener onSuccessListener) { + onSuccessListener.onSuccess(UIKitSettings.isShowReplyPrivately()); + } + + public static void isPublicGroupEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.chat_groups_public_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean) + UIKitSettings.publicGroup(false); + onSuccessListener.onSuccess(UIKitSettings.isPublicGroup()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isPasswordGroupEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.chat_groups_password_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean) + UIKitSettings.passwordGroup(false); + onSuccessListener.onSuccess(UIKitSettings.isPasswordGroup()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isPrivateGroupEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.chat_groups_private_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean) + UIKitSettings.privateGroup(false); + onSuccessListener.onSuccess(UIKitSettings.isPrivateGroup()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isUnreadCountEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.chat_messages_unread_count_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean) + UIKitSettings.unreadCount(false); + onSuccessListener.onSuccess(UIKitSettings.isUnreadCount()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isSmartRepliesEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.smart_replies_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean || !CometChat.isExtensionEnabled(Feature.Extension.smartReply)) + UIKitSettings.smartReplies(false); + onSuccessListener.onSuccess(UIKitSettings.isSmartReplies()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isUserSearchEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.chat_users_search_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean) + UIKitSettings.searchUser(false); + onSuccessListener.onSuccess(UIKitSettings.isSearchUser()); + + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isGroupSearchEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.chat_groups_search_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean) + UIKitSettings.searchGroup(false); + onSuccessListener.onSuccess(UIKitSettings.isSearchGroup()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isMessageSearchEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.chat_messages_search_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean) + UIKitSettings.searchMessage(false); + onSuccessListener.onSuccess(UIKitSettings.isSearchMessage()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isCallRecordingEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.call_recording_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean) + UIKitSettings.callRecording(false); + onSuccessListener.onSuccess(UIKitSettings.isCallRecording()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isCallLiveStreamingEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.call_live_streaming_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean) + UIKitSettings.callLiveStreaming(false); + onSuccessListener.onSuccess(UIKitSettings.isCallLiveStreaming()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isCallTranscriptEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.call_transcript_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean) + UIKitSettings.callTranscription(false); + onSuccessListener.onSuccess(UIKitSettings.isCallTranscription()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isThumbnailGenerationEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.thumbnail_generation_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean || !CometChat.isExtensionEnabled(Feature.Extension.thumbnailGeneration)) + UIKitSettings.thumbnailGeneration(false); + else + UIKitSettings.thumbnailGeneration(true); + onSuccessListener.onSuccess(UIKitSettings.isThumbnailGeneration()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isLinkPreviewEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.link_preview_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean || !CometChat.isExtensionEnabled(Feature.Extension.linkPreview)) + UIKitSettings.linkPreview(false); + else + UIKitSettings.linkPreview(true); + onSuccessListener.onSuccess(UIKitSettings.isLinkPreview()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isSaveMessagesEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.messages_saved_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean || !CometChat.isExtensionEnabled(Feature.Extension.saveMessage)) + UIKitSettings.saveMessage(false); + else + UIKitSettings.saveMessage(true); + onSuccessListener.onSuccess(UIKitSettings.isSaveMessage()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isPinMessageEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.messages_pinned_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean || !CometChat.isExtensionEnabled(Feature.Extension.pinMessage)) + UIKitSettings.pinMessage(false); + else + UIKitSettings.pinMessage(true); + onSuccessListener.onSuccess(UIKitSettings.isPinMessage()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isRichMediaPreviewEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.rich_media_preview_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean || !CometChat.isExtensionEnabled(Feature.Extension.richMedia)) + UIKitSettings.richMedia(false); + else + UIKitSettings.pinMessage(true); + onSuccessListener.onSuccess(UIKitSettings.isRichMedia()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isVoiceTranscriptionEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.voice_transcription_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean || !CometChat.isExtensionEnabled(Feature.Extension.voiceTranscription)) + UIKitSettings.voiceTranscription(false); + else + UIKitSettings.voiceTranscription(true); + onSuccessListener.onSuccess(UIKitSettings.isVoiceTranscription()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isMentionsEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.mentions_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean || !CometChat.isExtensionEnabled(Feature.Extension.mentions)) + UIKitSettings.mentions(false); + else + UIKitSettings.mentions(true); + onSuccessListener.onSuccess(UIKitSettings.isMentions()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isProfanityFilterEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.moderation_profanity_filter_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean || !CometChat.isExtensionEnabled(Feature.Extension.profanityFilter)) + UIKitSettings.profanityFilter(false); + else + UIKitSettings.profanityFilter(true); + onSuccessListener.onSuccess(UIKitSettings.isProfanityFilter()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isImageModerationEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.moderation_image_moderation_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean || !CometChat.isExtensionEnabled(Feature.Extension.imageModeration)) + UIKitSettings.imageModeration(false); + else + UIKitSettings.imageModeration(true); + + onSuccessListener.onSuccess(UIKitSettings.isImageModeration()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isDataMaskingEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.moderation_data_masking_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean || !CometChat.isExtensionEnabled(Feature.Extension.dataMasking)) + UIKitSettings.dataMasking(false); + else + UIKitSettings.dataMasking(true); + + onSuccessListener.onSuccess(UIKitSettings.isDataMasking()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isMalwareScannerEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.moderation_malware_scanner_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean || !CometChat.isExtensionEnabled(Feature.Extension.malwareScanner)) + UIKitSettings.malwareScanner(false); + onSuccessListener.onSuccess(UIKitSettings.isMalwareScanner()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isSentimentAnalysisEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.moderation_sentiment_analysis_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean || !CometChat.isExtensionEnabled(Feature.Extension.sentimentalAnalysis)) + UIKitSettings.sentimentAnalysis(false); + else + UIKitSettings.sentimentAnalysis(true); + + onSuccessListener.onSuccess(UIKitSettings.isSentimentAnalysis()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public static void isMessageHistoryEnabled(OnSuccessListener onSuccessListener) { + CometChat.isFeatureEnabled(Feature.chat_messages_history_enabled, new CometChat.CallbackListener() { + @Override + public void onSuccess(Boolean aBoolean) { + if (!aBoolean) + UIKitSettings.messageHistory(false); + onSuccessListener.onSuccess(UIKitSettings.isMessageHistory()); + } + + @Override + public void onError(CometChatException e) { + e.printStackTrace(); + } + }); + } + + public interface OnSuccessListener { + void onSuccess(Boolean booleanVal); + } +} diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_settings/UIKitSettings.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_settings/UIKitSettings.java index e6823df..6fa6d0e 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_settings/UIKitSettings.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_settings/UIKitSettings.java @@ -3,8 +3,11 @@ import android.app.Activity; import android.content.Context; import android.content.Intent; +import android.content.res.Configuration; +import android.content.res.Resources; import android.widget.Toast; +import com.cometchat.pro.constants.CometChatConstants; import com.cometchat.pro.core.CometChat; import com.cometchat.pro.exceptions.CometChatException; import com.cometchat.pro.models.Group; @@ -12,24 +15,126 @@ import com.cometchat.pro.uikit.R; import com.cometchat.pro.uikit.ui_components.messages.message_list.CometChatMessageListActivity; -import com.cometchat.pro.uikit.ui_components.shared.CometChatSnackBar; import com.cometchat.pro.uikit.ui_resources.constants.UIKitConstants; +import com.cometchat.pro.uikit.ui_settings.enums.ConversationMode; +import com.cometchat.pro.uikit.ui_settings.enums.GroupMode; +import com.cometchat.pro.uikit.ui_settings.enums.UserMode; + +import java.util.Locale; 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"; + //style + protected static String color = "#03A9F4"; + //BottomBar + private static boolean users = true; + private static boolean groups = true; + private static boolean conversations = true; + private static boolean calls = true; + private static boolean userSettings = true; + + //main + @Deprecated private static boolean enableSendingMessage = true; + + private static boolean sendMessageInOneOneOne = true; + private static boolean sendMessageInGroup = true; + + private static boolean userVideoCall = true; + private static boolean groupVideoCall = true; + + private static boolean userAudioCall = true; + private static boolean groupAudioCall = true; + + private static boolean banMember = true; + private static boolean kickMember = true; + + private static boolean publicGroup = true; + private static boolean passwordGroup = true; + private static boolean privateGroup = true; + + private static boolean messageHistory = true; + private static boolean searchUser = true; + private static boolean searchGroup = true; + private static boolean searchMessage = true; + + private static boolean callRecording = true; + private static boolean callLiveStreaming = true; + private static boolean callTranscription = true; + + + private static boolean hideDeleteMessage = false; + + private static boolean linkPreview = true; + private static boolean pinMessage = true; + private static boolean saveMessage = true; + private static boolean smartReplies = true; + private static boolean voiceTranscription = true; + private static boolean mentions = true; + private static boolean profanityFilter = true; + private static boolean malwareScanner = true; + private static boolean dataMasking = true; + private static boolean sentimentAnalysis = true; + private static boolean imageModeration = true; + private static boolean thumbnailGeneration = true; + private static boolean richMedia = true; + + private static boolean unreadCount = true; + + private static boolean showReadDeliveryReceipts = true; + private static boolean sendEmojisLargeSize = true; + private static boolean sendEmojis = true; + private static boolean sendGifs = true; + private static boolean sendVoiceNotes = true; + private static boolean sendFiles = true; + private static boolean sendPolls = true; + private static boolean sendPhotosVideo = true; + private static boolean threadedChats = true; + private static boolean replyingToMessage = true; + private static boolean shareCopyForwardMessage = true; + private static boolean deleteMessage = true; + private static boolean editMessage = true; + private static boolean shareLocation = true; + private static boolean sendStickers = true; + private static boolean collaborativeWhiteboard = true; + private static boolean collaborativeDocument = true; + private static boolean blockUser = true; + private static boolean sendTypingIndicators = true; + private static boolean viewSharedMedia = true; + private static boolean showUserPresence = true; + private static boolean allowPromoteDemoteMembers = true; + private static boolean allowAddMembers = true; + private static boolean allowModeratorToDeleteMemberMessages; + private static boolean allowDeleteGroups = true; + private static boolean viewGroupMember = true; + private static boolean joinOrLeaveGroup = true; + private static boolean groupCreate = true; + private static boolean hideJoinLeaveNotifications = false; + private static boolean enableSoundForMessages = true; + private static boolean enableSoundForCalls = true; + private static boolean callNotification = false; + private static boolean sendLiveReaction = true; + private static boolean sendMessageReaction = true; + private static boolean allowMessageTranslation = true; + private static boolean showReplyPrivately = true; + + protected static int emailColor = R.color.primaryTextColor; + protected static int phoneColor = R.color.purple; + protected static int urlColor = R.color.dark_blue; + + + + protected static ConversationMode conversationInMode = ConversationMode.ALL_CHATS; + protected static GroupMode groupInMode = GroupMode.ALL_GROUP; + protected static UserMode userInMode = UserMode.ALL_USER; + public Context context; public UIKitSettings(Context context) { this.context = context; } - public static void setMessagingSoundEnable(boolean isEnable) { - UISettings.enableMessageSounds = isEnable; + public static void enableSoundForMessages(boolean isEnable) { + enableSoundForMessages = isEnable; } public static void setAppID(String appID) { @@ -41,29 +146,41 @@ public static void setAppID(String appID) { public static void setAuthKey(String authKey) { UIKitConstants.AppInfo.AUTH_KEY = authKey; } - public static void setCallSoundEnable(boolean isEnable) { - UISettings.enableCallSounds = isEnable; + + public static void enableSoundForCalls(boolean isEnable) { + enableSoundForCalls = isEnable; } - public static void enableLiveReaction(boolean isEnable) { - UISettings.liveReaction = isEnable; + public static void sendLiveReaction(boolean isEnable) { + sendLiveReaction = isEnable; } public static void setHyperLinkEmailColor(int color) { - UISettings.emailColor = color; + emailColor = color; } public static void setHyperLinkPhoneColor(int color) { - UISettings.phoneColor = color; + phoneColor = color; } public static void setHyperLinkUrlColor(int color) { - UISettings.urlColor = color; + urlColor = color; + } + + public static ConversationMode getConversationsMode() { + return conversationInMode; + } + public static GroupMode getGroupsMode() { + return groupInMode; + } + public static UserMode getUsersMode() { + return userInMode; } - public void showReplyPrivately(boolean isVisible) { - UISettings.showReplyPrivately = isVisible; + public static void showReplyPrivately(boolean isEnable) { + showReplyPrivately = isEnable; } + public void addConnectionListener(String TAG) { CometChat.addConnectionListener(TAG, new CometChat.ConnectionListener() { @Override @@ -87,54 +204,53 @@ public void onFeatureThrottled() { } }); } - @Deprecated - public static void showCallNotification(boolean isVisible) { + public static void callNotification(boolean isVisible) { + callNotification = isVisible; if (!isVisible) { UIKitConstants.MessageRequest.messageCategoriesForGroup - .remove(com.cometchat.pro.constants.CometChatConstants.CATEGORY_CALL); - UIKitConstants.MessageRequest.messageTypesForUser - .remove(com.cometchat.pro.constants.CometChatConstants.CATEGORY_CALL); + .remove(CometChatConstants.CATEGORY_CALL); + UIKitConstants.MessageRequest.messageCategoriesForUser + .remove(CometChatConstants.CATEGORY_CALL); } else { if (!UIKitConstants.MessageRequest.messageCategoriesForGroup - .contains(com.cometchat.pro.constants.CometChatConstants.CATEGORY_CALL)) { + .contains(CometChatConstants.CATEGORY_CALL)) { UIKitConstants.MessageRequest.messageCategoriesForGroup - .add(com.cometchat.pro.constants.CometChatConstants.CATEGORY_CALL); + .add(CometChatConstants.CATEGORY_CALL); } if (!UIKitConstants.MessageRequest.messageCategoriesForUser - .contains(com.cometchat.pro.constants.CometChatConstants.CATEGORY_CALL)) { + .contains(CometChatConstants.CATEGORY_CALL)) { UIKitConstants.MessageRequest.messageCategoriesForUser - .add(com.cometchat.pro.constants.CometChatConstants.CATEGORY_CALL); + .add(CometChatConstants.CATEGORY_CALL); } } } + @Deprecated public static void hideCallActions(boolean isHidden) { - UISettings.hideCallNotification = isHidden; if (isHidden) { UIKitConstants.MessageRequest.messageCategoriesForGroup - .remove(com.cometchat.pro.constants.CometChatConstants.CATEGORY_CALL); - UIKitConstants.MessageRequest.messageTypesForUser - .remove(com.cometchat.pro.constants.CometChatConstants.CATEGORY_CALL); + .remove(CometChatConstants.CATEGORY_CALL); + UIKitConstants.MessageRequest.messageCategoriesForUser + .remove(CometChatConstants.CATEGORY_CALL); } else { if (!UIKitConstants.MessageRequest.messageCategoriesForGroup - .contains(com.cometchat.pro.constants.CometChatConstants.CATEGORY_CALL)) { + .contains(CometChatConstants.CATEGORY_CALL)) { UIKitConstants.MessageRequest.messageCategoriesForGroup - .add(com.cometchat.pro.constants.CometChatConstants.CATEGORY_CALL); + .add(CometChatConstants.CATEGORY_CALL); } if (!UIKitConstants.MessageRequest.messageCategoriesForUser - .contains(com.cometchat.pro.constants.CometChatConstants.CATEGORY_CALL)) { + .contains(CometChatConstants.CATEGORY_CALL)) { UIKitConstants.MessageRequest.messageCategoriesForUser - .add(com.cometchat.pro.constants.CometChatConstants.CATEGORY_CALL); + .add(CometChatConstants.CATEGORY_CALL); } - } } - @Deprecated - public static void showGroupNotification(boolean isVisible) { + public static void groupNotifications(boolean isVisible) { + hideJoinLeaveNotifications = isVisible; if (!isVisible) { UIKitConstants.MessageRequest.messageTypesForGroup .remove(com.cometchat.pro.constants.CometChatConstants.ActionKeys.ACTION_TYPE_GROUP_MEMBER); @@ -147,8 +263,8 @@ public static void showGroupNotification(boolean isVisible) { } } + @Deprecated public static void hideGroupActions(boolean isHidden) { - UISettings.hideGroupNotification = isHidden; if (isHidden) { UIKitConstants.MessageRequest.messageTypesForGroup .remove(com.cometchat.pro.constants.CometChatConstants.ActionKeys.ACTION_TYPE_GROUP_MEMBER); @@ -170,6 +286,7 @@ public void onSuccess(User user) { intent.putExtra(UIKitConstants.IntentStrings.AVATAR, user.getAvatar()); intent.putExtra(UIKitConstants.IntentStrings.STATUS, user.getStatus()); intent.putExtra(UIKitConstants.IntentStrings.NAME, user.getName()); + intent.putExtra(UIKitConstants.IntentStrings.LINK,user.getLink()); intent.putExtra(UIKitConstants.IntentStrings.TYPE, com.cometchat.pro.constants.CometChatConstants.RECEIVER_TYPE_USER); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); @@ -212,165 +329,582 @@ public void onError(CometChatException e) { } public static void setColor(String color) { - UISettings.color = color; + color = color; + } + + public static void users(boolean showUsers) { + users = showUsers; + } + + public static void groups(boolean showGroups) { + groups = showGroups; + } + + public static void conversations(boolean showChats) { + conversations = showChats; + } + + public static void calls(boolean showCalls) { + calls = showCalls; + } + + public static void userSettings(boolean showUserSettings) { + userSettings = showUserSettings; + } + + public static void setConversationsMode(ConversationMode conversationMode) { + conversationInMode = conversationMode; + } + + public static void setGroupsMode(GroupMode groupListing) { + groupInMode = groupListing; + } + + public static void publicGroup(boolean isEnable) { publicGroup = isEnable; } + public static void passwordGroup(boolean isEnable) { passwordGroup = isEnable; } + public static void privateGroup(boolean isEnable) { privateGroup = isEnable; } + + public static void setUsersMode(UserMode userListing) { + userInMode = userListing; + } + + public static void sendMessageInOneOneOne(boolean isEnable) { + sendMessageInOneOneOne = isEnable; + } + + public static void hideDeleteMessage(boolean isEnable) { + hideDeleteMessage = isEnable; + } + + public static void sendMessageInGroup(boolean isEnable) { + sendMessageInGroup = isEnable; + } + + public static void showReadDeliveryReceipts(boolean isEnable) { + showReadDeliveryReceipts = isEnable; + } + + public static void sendGifs(boolean isEnable) { sendGifs = isEnable; } + + public static void sendEmojisInLargeSize(boolean isEnable) { + sendEmojisLargeSize = isEnable; + } + + public static void sendEmojis(boolean isEnable) { + sendEmojis = isEnable; + } + + public static void smartReplies(boolean isEnable) { + smartReplies = isEnable; + } + + public static void linkPreview(boolean isEnable) { + linkPreview = isEnable; + } + + public static void dataMasking(boolean isEnable) { + dataMasking = isEnable; } - public static void showUsersInNavigation(boolean showUsers) { - UISettings.showUsersBB = showUsers; + public static void pinMessage(boolean isEnable) { + pinMessage = isEnable; } - public static void showGroupsInNavigation(boolean showGroups) { - UISettings.showGroupsBB = showGroups; + public static void saveMessage(boolean isEnable) { + saveMessage = isEnable; } - public static void showChatsInNavigation(boolean showChats) { - UISettings.showChatsBB = showChats; + public static void sentimentAnalysis(boolean isEnable) { + sentimentAnalysis = isEnable; } - public static void showCallsInNavigation(boolean showCalls) { - UISettings.showCallsBB = showCalls; + public static void profanityFilter(boolean isEnable) { + profanityFilter = isEnable; } - public static void showSettingsInNavigation(boolean showUserSettings) { - UISettings.showUserSettingsBB = showUserSettings; + public static void voiceTranscription(boolean isEnable) { + voiceTranscription = isEnable; } - public static void setGroupType(String groupListing) { - UISettings.groupListing = groupListing; + public static void malwareScanner(boolean isEnable) { + malwareScanner = isEnable; } - public static void setUsersType(String userListing) { - UISettings.userListing = userListing; + public static void mentions(boolean isEnable) { + mentions = isEnable; } - public static void allowSendingMessage(boolean enableSendingMessage) { - UISettings.enableSendingMessage = enableSendingMessage; + public static void imageModeration(boolean isEnable) { + imageModeration = isEnable; } - public static void showReadDeliveryReceipts(boolean showReadDeliveryReceipts) { - UISettings.showReadDeliveryReceipts = showReadDeliveryReceipts; + public static void thumbnailGeneration(boolean isEnable) { + thumbnailGeneration = isEnable; } - public static void allowEmojisInLargeSize(boolean sendEmojisLargeSize) { - UISettings.sendEmojisLargeSize = sendEmojisLargeSize; + public static void richMedia(boolean isEnable) { + richMedia = isEnable; } - public static void allowSendingEmojis(boolean sendEmojis) { - UISettings.sendEmojis = sendEmojis; + + public static void sendStickers(boolean isEnable) { + sendStickers = isEnable; } + public static void unreadCount(boolean isEnable) { unreadCount = isEnable; } - public static void allowSendingVoiceNotes(boolean sendVoiceNotes) { - UISettings.sendVoiceNotes = sendVoiceNotes; + public static void sendVoiceNotes(boolean isEnable) { + sendVoiceNotes = isEnable; } - public static void allowSendingFiles(boolean sendFiles) { - UISettings.sendFiles = sendFiles; + public static void sendFiles(boolean isEnable) { + sendFiles = isEnable; + } + + public static void sendPolls(boolean isEnable) { + sendPolls = isEnable; } - public static void allowSendingPolls(boolean sendPolls) { - UISettings.sendPolls = sendPolls; + public static void sendPhotosVideo(boolean isEnable) { + sendPhotosVideo = isEnable; } - public static void allowSendingPhotosVideo(boolean sendPhotosVideo) { - UISettings.sendPhotosVideo = sendPhotosVideo; + public static void threadedChats(boolean isEnable) { + threadedChats = isEnable; } - public static void enableThreadedReplies(boolean enableThreadedReplies) { - UISettings.enableThreadedReplies = enableThreadedReplies; + public static void replyingToMessage(boolean isEnable) { + replyingToMessage = isEnable; } - public static void enableReplyToMessage(boolean enableReplyToMessage) { - UISettings.enableReplyToMessage = enableReplyToMessage; + public static void shareCopyForwardMessage(boolean isEnable) { + shareCopyForwardMessage = isEnable; } - public static void setEnableShareCopyForward(boolean enableShareCopyForward) { - UISettings.enableShareCopyForward = enableShareCopyForward; + public static void deleteMessage(boolean isEnable) { + deleteMessage = isEnable; } - public static void allowDeletingMessage(boolean enableDeleteMessage) { - UISettings.enableDeleteMessage = enableDeleteMessage; + public static void editMessage(boolean isEnable) { + editMessage = isEnable; } - public static void allowEditingMessage(boolean enableEditingMessage) { - UISettings.enableEditingMessage = enableEditingMessage; + public static void shareLocation(boolean isEnable) { + shareLocation = isEnable; } - public static void allowShareLocation(boolean shareLocation) { - UISettings.shareLocation = shareLocation; + public static void blockUser(boolean isEnable) { + blockUser = isEnable; } - public static void allowUsersToBlock(boolean allowUserToblockUser) { - UISettings.blockUser = allowUserToblockUser; + public static void sendTypingIndicators(boolean isEnable) { + sendTypingIndicators = isEnable; } - public static void showTypingIndicators(boolean showTypingIndicators) { - UISettings.showTypingIndicators = showTypingIndicators; + public static void viewSharedMedia(boolean isEnable) { + viewSharedMedia = isEnable; } - public static void showSharedMedia(boolean showSharedMedia) { - UISettings.viewSharedMedia = showSharedMedia; + public static void showUserPresence(boolean isEnable) { + showUserPresence = isEnable; } - public static void setShowUserPresence(boolean showUserPresence) { - UISettings.showUserPresence = showUserPresence; + public static void allowPromoteDemoteMembers(boolean isEnable) { + allowPromoteDemoteMembers = isEnable; } - public static void allowPromoteDemoteMembers(boolean allowPromoteDemoteMembers) { - UISettings.allowPromoteDemoteMembers = allowPromoteDemoteMembers; + public static void kickMember(boolean isEnable) { + kickMember = isEnable; } - public static void allowBanKickMembers(boolean allowBanKickMembers) { - UISettings.allowBanKickMembers = allowBanKickMembers; + public static void banMember(boolean isEnable) { + banMember = isEnable; } - public static void allowAddMembersInGroup(boolean allowAddMembersInGroup) { - UISettings.allowAddMembers = allowAddMembersInGroup; + public static void allowAddMembers(boolean isEnable) { + allowAddMembers = isEnable; } - public static void allowModeratorToDeleteMessages(boolean allowModeratorToDeleteMessages) { - UISettings.allowModeratorToDeleteMessages = allowModeratorToDeleteMessages; + public static void allowModeratorToDeleteMemberMessages(boolean isEnable) { + allowModeratorToDeleteMemberMessages = isEnable; } - public static void allowDeleteGroups(boolean allowDeleteGroups) { - UISettings.allowDeleteGroups = allowDeleteGroups; + public static void allowDeleteGroups(boolean isEnable) { + allowDeleteGroups = isEnable; } - public static void showGroupMembers(boolean showGroupMembers) { - UISettings.viewGroupMember = showGroupMembers; + public static void viewGroupMembers(boolean isEnable) { + viewGroupMember = isEnable; } - public static void allowJoinOrLeaveGroup(boolean joinOrLeaveGroup) { - UISettings.joinOrLeaveGroup = joinOrLeaveGroup; + public static void joinOrLeaveGroup(boolean isEnable) { + joinOrLeaveGroup = isEnable; } - public static void showGroupCreate(boolean groupCreate) { - UISettings.groupCreate = groupCreate; + public static void groupCreate(boolean isEnable) { + groupCreate = isEnable; + } + + public static void userVideoCall(boolean isEnable) { + userVideoCall = isEnable; + } + + public static void userAudioCall(boolean isEnable) { + userAudioCall = isEnable; } - public static void enableVideoCalling(boolean enableVideoCalling) { - UISettings.enableVideoCalling = enableVideoCalling; + public static void groupVideoCall(boolean isEnable) { + groupVideoCall = isEnable; } - public static void enableVoiceCalling(boolean enableVoiceCalling) { - UISettings.enableVoiceCalling = enableVoiceCalling; + public static void groupAudioCall(boolean isEnable) { + groupAudioCall = isEnable; } - public static void enableReactionsOnMessage(boolean enableReactionOnMessage) { - UISettings.allowReactionOnMessage = enableReactionOnMessage; + public static void callRecording(boolean isEnable) { + callRecording = isEnable; } - public static void enableCollaborativeWhiteBoard(boolean enableWhiteBoardSharing) { - UISettings.sendWhiteBoard = enableWhiteBoardSharing; + public static void callLiveStreaming(boolean isEnable) { + callLiveStreaming = isEnable; } - public static void enableCollaborativeWriteBoard(boolean enableWriteBoardSharing) { - UISettings.sendWriteBoard = enableWriteBoardSharing; + public static void callTranscription(boolean isEnable) { + callTranscription = isEnable; } - public static void enableMessageTranslation(boolean enableMessageTranslation) { - UISettings.allowMessageTranslation = enableMessageTranslation; + public static void messageHistory(boolean isEnable) { + messageHistory = isEnable; } + + public static void searchUser(boolean isEnable) { + searchUser = isEnable; + } + + public static void searchGroup(boolean isEnable) { + searchGroup = isEnable; + } + + public static void searchMessage(boolean isEnable) { + searchMessage = isEnable; + } + + public static void sendMessageReaction(boolean isEnable) { + sendMessageReaction = isEnable; + } + + public static void collaborativeWhiteBoard(boolean isEnable) { + collaborativeWhiteboard = isEnable; + } + + public static void collaborativeDocument(boolean isEnable) { + collaborativeDocument = isEnable; + } + + public static void allowMessageTranslation(boolean isEnable) { + allowMessageTranslation = isEnable; + } + + public static boolean isUsers() { + return users; + } + + public static boolean isGroups() { + return groups; + } + + public static boolean isConversations() { + return conversations; + } + + public static boolean isCalls() { + return calls; + } + + public static boolean isUserSettings() { + return userSettings; + } + + public static boolean isSendMessageInOneOneOne() { + return sendMessageInOneOneOne; + } + + public static boolean isSendMessageInGroup() { + return sendMessageInGroup; + } + + public static boolean isUserVideoCall() { + return userVideoCall; + } + + public static boolean isGroupVideoCall() { + return groupVideoCall; + } + + public static boolean isUserAudioCall() { + return userAudioCall; + } + + public static boolean isGroupAudioCall() { + return groupAudioCall; + } + + public static boolean isBanMember() { + return banMember; + } + + public static boolean isKickMember() { + return kickMember; + } + + public static boolean isPublicGroup() { + return publicGroup; + } + + public static boolean isPasswordGroup() { + return passwordGroup; + } + + public static boolean isPrivateGroup() { + return privateGroup; + } + + public static boolean isMessageHistory() { + return messageHistory; + } + + public static boolean isSearchUser() { + return searchUser; + } + + public static boolean isSearchGroup() { + return searchGroup; + } + + public static boolean isSearchMessage() { + return searchMessage; + } + + public static boolean isCallRecording() { + return callRecording; + } + + public static boolean isCallLiveStreaming() { + return callLiveStreaming; + } + + public static boolean isCallTranscription() { + return callTranscription; + } + + public static boolean isLinkPreview() { + return linkPreview; + } + + public static boolean isPinMessage() { + return pinMessage; + } + + public static boolean isSaveMessage() { + return saveMessage; + } + + public static boolean isSmartReplies() { + return smartReplies; + } + + public static boolean isVoiceTranscription() { + return voiceTranscription; + } + + public static boolean isMentions() { + return mentions; + } + + public static boolean isProfanityFilter() { + return profanityFilter; + } + + public static boolean isMalwareScanner() { + return malwareScanner; + } + + public static boolean isDataMasking() { + return dataMasking; + } + + public static boolean isSentimentAnalysis() { + return sentimentAnalysis; + } + + public static boolean isImageModeration() { + return imageModeration; + } + + public static boolean isThumbnailGeneration() { + return thumbnailGeneration; + } + + public static boolean isRichMedia() { + return richMedia; + } + + public static boolean isUnreadCount() { + return unreadCount; + } + + public static boolean isShowReadDeliveryReceipts() { + return showReadDeliveryReceipts; + } + + public static boolean isSendEmojisLargeSize() { + return sendEmojisLargeSize; + } + + public static boolean isSendEmojis() { + return sendEmojis; + } + + public static boolean isSendGifs() { + return sendGifs; + } + + public static boolean isSendVoiceNotes() { + return sendVoiceNotes; + } + + public static boolean isSendFiles() { + return sendFiles; + } + + public static boolean isSendPolls() { + return sendPolls; + } + + public static boolean isSendPhotosVideo() { + return sendPhotosVideo; + } + + public static boolean isThreadedChats() { + return threadedChats; + } + + public static boolean isReplyingToMessage() { + return replyingToMessage; + } + + public static boolean isShareCopyForwardMessage() { + return shareCopyForwardMessage; + } + + public static boolean isDeleteMessage() { + return deleteMessage; + } + + public static boolean isEditMessage() { + return editMessage; + } + + public static boolean isShareLocation() { + return shareLocation; + } + + public static boolean isSendStickers() { + return sendStickers; + } + + public static boolean isCollaborativeWhiteboard() { + return collaborativeWhiteboard; + } + + public static boolean isCollaborativeDocument() { + return collaborativeDocument; + } + + public static boolean isBlockUser() { + return blockUser; + } + + public static boolean isSendTypingIndicators() { + return sendTypingIndicators; + } + + public static boolean isViewSharedMedia() { + return viewSharedMedia; + } + + public static boolean isShowUserPresence() { + return showUserPresence; + } + + public static boolean isAllowPromoteDemoteMembers() { + return allowPromoteDemoteMembers; + } + + public static boolean isAllowAddMembers() { + return allowAddMembers; + } + + public static boolean isAllowModeratorToDeleteMemberMessages() { + return allowModeratorToDeleteMemberMessages; + } + + 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 isEnableSoundForMessages() { + return enableSoundForMessages; + } + + public static boolean isEnableSoundForCalls() { + return enableSoundForCalls; + } + + public static boolean isGroupNotifications() { + return hideJoinLeaveNotifications; + } + + public static boolean isCallNotification() { + return callNotification; + } + + public static boolean isSendLiveReaction() { + return sendLiveReaction; + } + + public static boolean isSendMessageReaction() { + return sendMessageReaction; + } + + public static boolean isAllowMessageTranslation() { + return allowMessageTranslation; + } + + public static boolean isShowReplyPrivately() { + return showReplyPrivately; + } + + public static boolean isHideDeleteMessage() { + return hideDeleteMessage; + } + } diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_settings/UISettings.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_settings/UISettings.java deleted file mode 100644 index cc5ce72..0000000 --- a/uikit/src/main/java/com/cometchat/pro/uikit/ui_settings/UISettings.java +++ /dev/null @@ -1,267 +0,0 @@ -package com.cometchat.pro.uikit.ui_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 = "public_and_password_protected_groups"; - 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 sendWhiteBoard = true; - protected static boolean sendWriteBoard = 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 boolean liveReaction = true; - protected static boolean allowReactionOnMessage = true; - protected static boolean allowMessageTranslation = true; - protected static boolean showReplyPrivately = 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; - } - - public static boolean showLiveReaction() { - return liveReaction; - } - - public static boolean isReactionVisible() { - return allowReactionOnMessage; - } - - public static boolean isWhiteBoardVisible() { - return sendWhiteBoard; - } - - public static boolean isWriteBoardVisible() { - return sendWriteBoard; - } - - public static boolean isTranslationAllowed() { return allowMessageTranslation; } - - public static boolean isShowReplyPrivately() { - return showReplyPrivately; - } -} diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_settings/enums/ConversationMode.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_settings/enums/ConversationMode.java new file mode 100644 index 0000000..4e0f1b0 --- /dev/null +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_settings/enums/ConversationMode.java @@ -0,0 +1,12 @@ +package com.cometchat.pro.uikit.ui_settings.enums; + +public enum ConversationMode { + ALL_CHATS("all_chats"), + GROUP("groups"), + USER("users"); + + private String label; + ConversationMode(String label) { + this.label = label; + } +} diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_settings/enums/GroupMode.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_settings/enums/GroupMode.java new file mode 100644 index 0000000..1dad52f --- /dev/null +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_settings/enums/GroupMode.java @@ -0,0 +1,12 @@ +package com.cometchat.pro.uikit.ui_settings.enums; + +public enum GroupMode { + PUBLIC_GROUP("public_groups"), + PASSWORD_GROUP("password_protected_groups"), + ALL_GROUP("public_and_password_protected_groups"); + + private String label; + GroupMode(String label) { + this.label = label; + } +} diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/ui_settings/enums/UserMode.java b/uikit/src/main/java/com/cometchat/pro/uikit/ui_settings/enums/UserMode.java new file mode 100644 index 0000000..a3ac44c --- /dev/null +++ b/uikit/src/main/java/com/cometchat/pro/uikit/ui_settings/enums/UserMode.java @@ -0,0 +1,12 @@ +package com.cometchat.pro.uikit.ui_settings.enums; + +public enum UserMode { + ALL_USER("all_users"), + FRIENDS("friends"); + + + private String label; + UserMode(String label) { + this.label = label; + } +} diff --git a/uikit/src/main/res-components/calls/layout/fragment_cometchat_calls.xml b/uikit/src/main/res-components/calls/layout/fragment_cometchat_calls.xml index da8c302..c3d33b9 100644 --- a/uikit/src/main/res-components/calls/layout/fragment_cometchat_calls.xml +++ b/uikit/src/main/res-components/calls/layout/fragment_cometchat_calls.xml @@ -12,7 +12,7 @@ android:layout_height="wrap_content"> + + + + + + android:layout_height="wrap_content"> + android:layout_height="48dp" /> - - - - - + android:layout_height="wrap_content"> + + + + @@ -107,6 +144,7 @@ + diff --git a/uikit/src/main/res-components/chats/layout/conversation_shimmer.xml b/uikit/src/main/res-components/chats/layout/conversation_shimmer.xml index d20a84f..a124c76 100644 --- a/uikit/src/main/res-components/chats/layout/conversation_shimmer.xml +++ b/uikit/src/main/res-components/chats/layout/conversation_shimmer.xml @@ -23,13 +23,13 @@ android:orientation="vertical"> diff --git a/uikit/src/main/res-components/groups/layout/activity_cometchat_group_detail.xml b/uikit/src/main/res-components/groups/layout/activity_cometchat_group_detail.xml index 7c0743f..f6f0162 100644 --- a/uikit/src/main/res-components/groups/layout/activity_cometchat_group_detail.xml +++ b/uikit/src/main/res-components/groups/layout/activity_cometchat_group_detail.xml @@ -38,7 +38,6 @@ tools:src="@tools:sample/avatars" /> - - diff --git a/uikit/src/main/res-components/groups/layout/cometchat_update_group_dialog.xml b/uikit/src/main/res-components/groups/layout/cometchat_update_group_dialog.xml index 2459767..dbb46c8 100644 --- a/uikit/src/main/res-components/groups/layout/cometchat_update_group_dialog.xml +++ b/uikit/src/main/res-components/groups/layout/cometchat_update_group_dialog.xml @@ -28,6 +28,7 @@ android:layout_height="100dp"/> - + + - - \ No newline at end of file + tools:context="com.cometchat.pro.uikit.ui_components.messages.extensions.Collaborative.CometChatWebViewActivity" + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools"> + + + + + + \ No newline at end of file diff --git a/uikit/src/main/res-components/messages/layout/cometchat_composebox_actions.xml b/uikit/src/main/res-components/messages/layout/cometchat_composebox_actions.xml index 3670835..474c4de 100644 --- a/uikit/src/main/res-components/messages/layout/cometchat_composebox_actions.xml +++ b/uikit/src/main/res-components/messages/layout/cometchat_composebox_actions.xml @@ -7,20 +7,6 @@ android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> - - - - + + + + + - - \ No newline at end of file diff --git a/uikit/src/main/res-components/messages/layout/fragment_cometchat_message_actions.xml b/uikit/src/main/res-components/messages/layout/fragment_cometchat_message_actions.xml index 628daf7..b3211b1 100644 --- a/uikit/src/main/res-components/messages/layout/fragment_cometchat_message_actions.xml +++ b/uikit/src/main/res-components/messages/layout/fragment_cometchat_message_actions.xml @@ -21,36 +21,21 @@ android:layout_height="wrap_content"/> - - - - + + android:src="@drawable/ic_delete" + android:tint="@color/grey" + android:layout_width="24dp" + android:layout_height="24dp"/> diff --git a/uikit/src/main/res-components/users/drawable/ic_audiocall.xml b/uikit/src/main/res-components/users/drawable/ic_audiocall.xml new file mode 100644 index 0000000..e516b4c --- /dev/null +++ b/uikit/src/main/res-components/users/drawable/ic_audiocall.xml @@ -0,0 +1,6 @@ + + + diff --git a/uikit/src/main/res-components/users/drawable/ic_baseline_in_thread_24.xml b/uikit/src/main/res-components/users/drawable/ic_baseline_in_thread_24.xml new file mode 100644 index 0000000..60f7768 --- /dev/null +++ b/uikit/src/main/res-components/users/drawable/ic_baseline_in_thread_24.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/uikit/src/main/res-components/users/drawable/ic_info.xml b/uikit/src/main/res-components/users/drawable/ic_info.xml new file mode 100644 index 0000000..b1dae71 --- /dev/null +++ b/uikit/src/main/res-components/users/drawable/ic_info.xml @@ -0,0 +1,12 @@ + + + diff --git a/uikit/src/main/res-components/users/drawable/ic_videocall.xml b/uikit/src/main/res-components/users/drawable/ic_videocall.xml new file mode 100644 index 0000000..9dc81c0 --- /dev/null +++ b/uikit/src/main/res-components/users/drawable/ic_videocall.xml @@ -0,0 +1,6 @@ + + + diff --git a/uikit/src/main/res-components/users/layout/activity_cometchat_user_detail.xml b/uikit/src/main/res-components/users/layout/activity_cometchat_user_detail.xml index 6d57136..cd1400c 100644 --- a/uikit/src/main/res-components/users/layout/activity_cometchat_user_detail.xml +++ b/uikit/src/main/res-components/users/layout/activity_cometchat_user_detail.xml @@ -37,7 +37,6 @@ - - @@ -143,7 +118,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content"/> diff --git a/uikit/src/main/res-components/users/layout/cometchat_user_list_row.xml b/uikit/src/main/res-components/users/layout/cometchat_user_list_row.xml index 20da4f8..520981f 100644 --- a/uikit/src/main/res-components/users/layout/cometchat_user_list_row.xml +++ b/uikit/src/main/res-components/users/layout/cometchat_user_list_row.xml @@ -56,11 +56,12 @@ tools:visibility="visible" android:visibility="gone" android:id="@+id/unblockUser" - android:src="@drawable/ic_delete_24dp" + android:src="@drawable/ic_delete" + android:tint="@color/grey" android:layout_width="wrap_content" android:layout_centerVertical="true" android:layout_marginStart="8dp" - android:layout_height="wrap_content" + android:layout_height="24dp" android:layout_alignParentRight="true" android:layout_marginEnd="16dp"/> diff --git a/uikit/src/main/res-components/users/layout/fragment_cometchat_userlist.xml b/uikit/src/main/res-components/users/layout/fragment_cometchat_userlist.xml index a679318..1375ca1 100644 --- a/uikit/src/main/res-components/users/layout/fragment_cometchat_userlist.xml +++ b/uikit/src/main/res-components/users/layout/fragment_cometchat_userlist.xml @@ -11,7 +11,7 @@ android:visibility="gone" tools:visibility="visible" android:textColor="@color/primaryTextColor" - android:textSize="22sp" + android:textAppearance="@style/TextAppearance.AppCompat.Display1" android:textStyle="bold" android:layout_margin="16dp" android:layout_width="wrap_content" diff --git a/uikit/src/main/res-components/users/layout/user_shimmer.xml b/uikit/src/main/res-components/users/layout/user_shimmer.xml index 1859796..d990cd1 100644 --- a/uikit/src/main/res-components/users/layout/user_shimmer.xml +++ b/uikit/src/main/res-components/users/layout/user_shimmer.xml @@ -29,7 +29,7 @@ android:layout_height="wrap_content" android:layout_margin="16dp" android:textColor="@color/shimmer" - android:textSize="22sp" + android:textAppearance="@style/TextAppearance.AppCompat.Display1" android:textStyle="bold" /> ^aokZU<`C_h8q@(*7D(XmS!Ho$XsC)nvTExNMuU)06@lbYAXXm~ z;{UqKHfYP8A?nX?wR)gXFAXF+ME?&;L|K5!U4d?Cl~RD{f7pYuO@6WPU@Rd%6jU8R z!t4!I7mzp90H6&-y|zqX)O=U!1p@Obl9d8<&*u#F=~Ul7R_P)lclv~a0g0~9Nz&!ROenyCJp=Eob(MUGj)viS}(kz8%reySWk+AU~MtiT7+J z2l||;lG6U&PN2%J-G9GQW8CtE*Z8tmSFxY`XP}m7pru`@(%7}KTRJ1 zHY$_v&7wgg?_O*8pJOI_$9$7Tq9}5A8y&9F;Rb#Mzl_^`ry9iME&Mb7o-LCyhSHPF<5*4 z18)eS<=*q|0@6JA4J~;uzosvD?^>-UnppMFTDQRf#2^C-L%$!uTBox0|(5!FZ99)BML0%{kinafUB|;f<;k%)~so(;< z3xqO>kYW^k1?!c(Gl7tj2<41|Kj0D^gDuKC5eVh3g~~DXEu?A?Qm&iYR!G#;qZ))n zul;~I^VkT5(ye1+DEJKa!7kXOygq$CGVFu0t%Hj18H(P4wI#XR;M3XWS}Hs?tkh57 zp~540aXx;KPzT&P+`sGwG?MB%lCmFRD^F@{G31{*8}b)4`b2OHntC|~Em#tEXz^Tj iP>gFiC^pf=e~4cpn`X%e2yD>+0000U1>!$Y`T$g%pAy5vfcWKq`~V~$MvmbXK>YVVaR8*Qf)vBU zaTvZ8h+TpBG!9F`i4AjH!4d*hQ-&wF_z781fF~$!0C7DKKf|M@fRF_TaA*Xjo)=J8 z;)|ODge-WALt{UZnpt=(cuUBFKR7gg1>zGx%mu{lcr5rst`9)qI}q~{u;4AZaX_pE z1mhqdhsK{kd>@E;fVc{ePYI?XK4@w|2U%$9*ns#Q$@u`PITTA$1Q~V~3125GCnH%> zMzgXA%_lDi82*B+(iAOD@_=|hj{1OawAQ2u006>Nq`}B#D2D(5002ovPDHLkV1hT% BbyWZW diff --git a/uikit/src/main/res/drawable-xhdpi/ic_info_image.png b/uikit/src/main/res/drawable-xhdpi/ic_info_image.png deleted file mode 100644 index 0fcc27062754a6473e0e140df8bb7afd439dd139..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 558 zcmV+}0@3}6P)KIT5W2Y8R(t^waq>Ua+9fmrA%rZ_p9oiBh}VOE291sk0&f=`i-262mNcRm*B zDo(`&O&isJ{sCNoH^xX5Oc$)`oIe8-)P4%wF=`@b%0P`V6@sA{+l&}BQ_p$Myq_M5 zv&pQ7K-WN>S&S!Aj7f0Kj8oU$9&|OHC=GB9UNvHL+1m~@tOz$$;Ti}XF%WVMTr!f~ zgLSYXu?4;~3`AT5Ek?4Pe`1|#7-(?~^ccymz#>=xc`4R`hJhZ}Kwoq2)(six+Z=&3 z46sL_>4*V#4MdI@h{m-Jm@>d#2g;5ZsOap4I%77#-wQDlKY}A_SCZna(szS%p%*K= zQA(T#-wFxm6U1Dy_C7!fs|p6z62#lE_C_YvLL*_)U+_dzX%x>1S9o*p#AIR)yj$8n zn?03~Oe`zbgFEL!LnhK1iH}q}FPWHCsEMSyN%90UeIHOYFr|LLuGQ1&5$nW0Xfy8z wW?Z_VDbY$B(N=ua4Nd6O4ULzVmzS3Q00Gs0!yLe0kdh(*677tR}{sB!-9z^u+kJc2@ zvx1-p@dw0IDO3cb)+!opI(~;dA*@L&oA-8Shxx(>3ZeVne%YCw_hvR0b8>QWa&mHV za&mHtfRs`RkOD&>2MVAB%Af*%f{)-0{WbwIpiBR+&8F-JV`PS3Y12mOS_vDBX$MC^ z9#j>ds&q|#?e-`d(*}CM6j)JmTA>&^R$Ele=>S*2k_t{s6tly0bCTep3QszA(nMq8 zAPtHtd=)8|xJl+50Sn3;El^Hz6AVflW=_3HX%pt0BGcRGE8WxwS}<}Aw`7=at31=1 z<{mge3(C#l447v!DIfUTjn+BCOgHcdY-2V@V>r-t5`y(Hu5->diLn7ZW?U!r z1zA2!Gft)_R*5ym7-u?=vIIc}nahU@P2y|;&zQ@S!62&g8RpmV3((mhPL^69oSG5s z0#H#{Rs4DaPJun32V4bT1mfu2dnFAT7p}|~!4KgD)abIvAdzAgQWrJ_cN(=u zjW$t&reM2hHQ0tWjTCJwE z9c+>RFSlskU%(5&60jcZ0e=8T!5LZ~X5{||9mF7ePvvR#2xqfjz2EPh?3mhl67#BOL@+I)4;B(;jIkfFjV@B*@ zyGqj>{0eZdj9PreEwQg6jiZ|y@EABveq&nftVzvi363;^!!eF-;utNly^U!Y{l!TYfQ`RO$p+isoWwT2F~N8KQcpr-V)_K>z=oCD>NzD5*q@rD3^l)qvBSLs zUXk9j>rl}Xk+F%LC=0kck_jQ6_~ayuWcHYUgCPl7iT zaz|a>%nu}``06zo&bd;uG|4Up6&_D)8gDU~{TkJE~?;`kIH1(s!J_C+JxwZg1z)KeU3^)!u zv;}A-y{ZOIE&K~!UWVi3cCDG?(5fv!r;>9V*muF5;Pz$6Pvi5_6x?wnLZ`L>eM*iU zS%XcFI~^kH~fJtourWBpy{QfEM>kxN&Ccu=o0JG#4?|UY|Y?_~dBnY7X1WcF!3oxNAz?cc( zb`&&d0=S(A^qK$*(5o##hY8>|7t}&-_jvgvfRk(}??4|l0o<(za5`YX1js;tMNFLS zF#$5rUlR^3OU|1B?y4fVF6cy_3*fXah%4iED08ljVEM*mQ8w-_6DNl)9~q z6NjGwe~mHtS171IdWC{QfGq1)XcohN_bLU|bN|F(o7>vZP<3>7Ou_#fd@0vEjDr0O zug8$VbzdDV4pzyX8a2L+YIuk5*-SxsdsOgae?aId*hA6R=I{w7nG`uHeb#V<=oD96zsN7@5#AKwhYWwtg~J`$wPUh( q$QTR;gTY`h7z_r3!C){L42HXe^GWLtWm*3K0000 - - - - - - - - - \ No newline at end of file diff --git a/uikit/src/main/res/drawable/copy.png b/uikit/src/main/res/drawable/copy.png new file mode 100644 index 0000000000000000000000000000000000000000..de1e6721fd5623f697ea4ba15a0fb804615ab01a GIT binary patch literal 942 zcmWktdrVVz6h6JTFZ#U5s~~|NoRYzAuPq`&eQB?{biY(my(TZ?0cgf>LS80u|{ za5YMJMR}NkE=)`oW{DU_2ok+DAl)RoMPtHaHN=U3K$B%DfxxbReCNwaPR{vG&UY@+ zgHvq_^K0pBdH$GGdzcH2>0etPvo1b^{ zIXY=FmjN`T12A5IjUArf0i4+fuxbVPq!%ErzUzelGXOHJw8&W5_}ad;vtuAth~O^a zIytus2NWFgU%^{yb`U}?^rMnnbHx)BRv`IZs|p?87(D3Iuz9ZD$3WpL2b-6H+jNI> zs9%La5^pJ2o5Uj(LHDberw^r^8#gB}AO;?-cpW3}%Rzrgl@~R1y1n4t3;YW+szOY! zvnBCB&y>^Qx>Ky$yQbg<+~G8;f(TYr>8#%8>9pi65t5;HB6u4FLfLJt_KUe} z6k8%&>Z4t8_nd3q%k^L{XMh;KRe}c`?l7XBNrK;*M&}5-8f~k%8+cO9zM0NGY5j)? zno&N%z3lMFqXU1_gEb(eW}f8Gbxiv3(bkEdWBV74Ry8FjeJRvZ>hk+C5OBo!21zYV zcbor!kQOb9uU;3?$6gD3vfOOjavU{aJU1exu&&V@-L%>y$|GH02J8LtFBoBxB zIwgqdP}ZbrOOK0#8Z_x>f7!rU8RqPf4~@e9sEImk%Qq1b@SUwj-$+BFC7> zwuu+>W0IbxN6dqS>(#uFf@#l7I>EshaxJ!t3+h^%l<35t#<0mZck_2_(N#&Vnhs|^ z5ebLRh+9PUuucFzX+*KMjnG7}5$pnP7GV5&Wm#zyp z|9X3j2+J$86i0>jj5=j5zmNO=w^N04XREaqH90txeL~Ge%?C*p5DIXJ(z|9K*B;=1 O3rdU2i$)8qp8o;o^Hu5q literal 0 HcmV?d00001 diff --git a/uikit/src/main/res/drawable/curve_progress_bar.xml b/uikit/src/main/res/drawable/curve_progress_bar.xml deleted file mode 100644 index 025dc7c..0000000 --- a/uikit/src/main/res/drawable/curve_progress_bar.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/uikit/src/main/res/drawable/forward.png b/uikit/src/main/res/drawable/forward.png new file mode 100644 index 0000000000000000000000000000000000000000..a4701de62940886b103146c9905096b0bbf6cf10 GIT binary patch literal 715 zcmV;+0yO=JP)z@;j(q!3lK=n!AY({UO#lFTB>(_`g8%^e{{R4h=>PzA zFaQARU;qF*m;eA5Z<1fdMgRZ;K}keGRCwBA{Qv(y0|`JCh|_@h1`sa*;=hD600a;N z$O01ZqW=gm3y3)g=>Z5JCK6l^QY#K+e*)rEAYKB*eE2j01Q00}Acti%5bp!xU?5%% z#G<$~0R#}KL9`7TJla6a1;l%x{4+qTgiQ}X01+|}6vom}&6ZGuK)?Vh&j-XCpkg8poN$)5Z427IuNq~@joEG z2E>nm_#+U1h0>3a^!x$eL0_+HsMe0yrJcII=LCYo# zJpcj30L@hAp$b7kBaSDMcS6-QKvM~ - - diff --git a/uikit/src/main/res/drawable/ic_arrow.xml b/uikit/src/main/res/drawable/ic_arrow.xml deleted file mode 100644 index c346c29..0000000 --- a/uikit/src/main/res/drawable/ic_arrow.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - diff --git a/uikit/src/main/res/drawable/ic_baseline_edit_24.xml b/uikit/src/main/res/drawable/ic_baseline_edit_24.xml deleted file mode 100644 index ca662b7..0000000 --- a/uikit/src/main/res/drawable/ic_baseline_edit_24.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/uikit/src/main/res/drawable/ic_chats.png b/uikit/src/main/res/drawable/ic_chats.png new file mode 100644 index 0000000000000000000000000000000000000000..6324266bd9cfd116654e29fe3021ccf4c2484145 GIT binary patch literal 623 zcmeAS@N?(olHy`uVBq!ia0vp^Vn8gy!3HEdYt9+~DaPU;cPEB*=VV?2IWDOYo@u_m z3|c@o2Loe!CIbsd2@p#GF#`kh0!9XAAk7F8TfhXD6Eak- zA-Hymy+?GQ$g%y!@r#ldU~8oD`!MSXf2$#NOHLHL;J2@83$R2pOXe zg^*a87@aE%c621Lf0Sp5dYiCPEdJiha(Uk!D+L!-iXXClzUTd)qI)~v#~id>o$XiM zEObffMc{&|o0c>EdHApSpPk6;vvSk+@ti8uW!ZXlb+X%U3CV}+_x?H=+g~3QbaYet zgxlv%Om7{=WRH5{k5ij#Rt6r=ZZuR zwOqa2h6^9t7Kkkp_*S>5IxIfodda!WNe9=IO2y_Ze$GB)o6O>+84LUZIiuI)x}M^6 zOV$c%Tb{oEqQ`W$3{!y^cQ4hRt8udnx|GybKbZaSi;nx5y;CK^cz=JKSgYs8nlA0e z%^YMRbNK$6UH8w`vV6EZ&8%j_oPtjlZPF%2U+V3|&K=t3BQx`C_@nRx*KWv7I{#74 zX8D2-0u?`&HGMxnPa(8Id->BlAB425%lyw}FM5)EzW3@DR_hkMPYXV6TmC;gDX*ct z(B^~T(_=Ggj`|n1nV&J_e`aG~AoJ{X3{U`jMHPzUBrQGgI wU0-II)!QFtJZQJP@F;WI&F_b+6tzopr06)$BWB>pF literal 0 HcmV?d00001 diff --git a/uikit/src/main/res/drawable/ic_contacts.png b/uikit/src/main/res/drawable/ic_contacts.png new file mode 100644 index 0000000000000000000000000000000000000000..181df131b92c5d125dd10dd908aeded4fe375c80 GIT binary patch literal 673 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VV{wqX6T`Z5GB1G~m(&Q)G+$o^ zEg+kNfw4W4fd!-lh^2s-fq{7eBLg##W(0{XV1mnvEMP{kK?*nB{qUE8fr;DG#WBP} zaA~Nak4T`v+@DE~MPidy2v|Sy*|K3`u8+qCgODb*BSFH8Zrr%3IrmuKBqxO#7os*e zB(5=;lyPQmFKcVSq=YF=EJ7TO()XkP-M{npAIpUKZ_d`|r``K^bLQRP&Ncu1uWj3_ z^?i-v_lJH3r9U^6-k4=IbM+UGUq83KtF|+r_5P3A%x$}SnI+lRh}E+0d35f?=Ud6K zInQDl(w6NF{w9^g{h&`MIcn<0Gl_W@GP!4`M8z#UGM!QWx)J-%nB+evr_|20iOkWp zp2}$@rF8ztlPDdIr~I30Qkl2aoiu9lN_~{K|MvM)y-NlEdQXhrTvnJLUN`IH(vBCW zcCIeEyK%Om;rtJZ9fI|>E9w*Ms^Tw(tbF<>Lu77y#L~Sl4!rb==~yVX`;29`o(jK; z@io~w=J#)j+I+QUbkAADajR*uP+{7XRcjUsZe~&Y#PO`?S;zmJ=fx6VS8tH?ev~p< z{K$TWe3xX~la^0jhrBY_A>v*YRKH4>sn)nGF+G0S2aC2nZkr>^cVzFK`B3ihr?tQL z@ch^4xOjYB_$s5Gx8;uxt+Kq6xz2&>RQ1PyjdD{e{68#iaO~R~s_E@lxFmGSbzzo* zLw!%?ma@rg?zMfH@sQv2(wnQV=WcPFQ?gI>K?_5F-U_=_+>z6FHh!8dob}}4nWb!< yH91*}jlS700)}P)dtU7FzXztVXx7i#-%xLoyX`{fdxl@2 + android:viewportWidth="20" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> diff --git a/uikit/src/main/res/drawable/ic_delete.png b/uikit/src/main/res/drawable/ic_delete.png new file mode 100644 index 0000000000000000000000000000000000000000..31bae4ba6e0aebf87dcbf9709086e985c371c4ae GIT binary patch literal 907 zcmV;619bd}P)z@;j(q!3lK=n!AY({UO#lFTB>(_`g8%^e{{R4h=>PzA zFaQARU;qF*m;eA5Z<1fdMgRZ<0ZBwbRCwBA{Qv(y10G-s#5q8$0mSS;3{%Vq#NUAU zJP=O;;+wb(00aU#?qg18I;2q2IJTtF;^6uvN^1f_+6 zSRTzW|Dl){$_L3S0x=Vs8IJ)1h!Gf0$D!W*1;qb=m>FuA2$I4VP;mw{OT>_Z>^+o5 zHsb_90D*|VPzf=p1SoZU0OBW5LqI8p6{-;(z|=57)qxzv2E;#M76Jqi$Ojxih9nU8 z1F=64cLVVhs3zoO$v}Yr7ivZ@H1a{_JOv0KkPm(U@qHkE4psaeh#xVK2Yy3okp2fC z20#EIN6I%SEr2988Hj7p_)SRsJ|J#J;`1Om5)1$W2-$)!P#TspxPjOYhy#!`2SUX_ zfD?#=fY=ks3^p{g7ytqY*@DkV2E$UuXDH2p0U`I<8 ztWb<@0V~vkpGf*(dSPM=00D$-!4D*tAQx(^ILa&*XvX}3WB~`7SquOHglxf2q}0KQ z<^vWyLG%+TXgQ#KxDNmV2$v5yhzKGUsD5;PKaec|2q0t&V1*qAQbhkkaw!9rIABGx zfDM}k00D&VgCA%<_<>Y167m5ol2I%G2q1JH{6O=;52WlfC1eCfB-^IML(dfXGe-;E~o{6(JW^}%T(-W4g~{%0Aj&n0RxhYS3|`gL-Pcv zoc{=wy9312fp{01o}Wm$n*ktzkee7BKzs(;6!FH>oWX_Dpn7*Aivt7@3tAk!hO(=n zspkWhiX0t)f=&X63t<&KvLrwNp}WHOKV{$>5St*I2@pVxSelNYdN~TI*+L8eWzZWy hJRgV;AWHxQ7yytbp-hwdch&#^002ovPDHLkV1f{ILUsTE literal 0 HcmV?d00001 diff --git a/uikit/src/main/res/drawable/ic_info_image.png b/uikit/src/main/res/drawable/ic_info_image.png new file mode 100644 index 0000000000000000000000000000000000000000..055c2fca24a53b691cb2e60fb5939d00e39e2593 GIT binary patch literal 927 zcmV;Q17Q4#P)z@;j(q!3lK=n!AY({UO#lFTB>(_`g8%^e{{R4h=>PzA zFaQARU;qF*m;eA5Z<1fdMgRZ<6-h)vRCwBA{Qv(y10KK##HK*34#Z+WEC|G(fcPa4 z-v;6{K>Q1z0RRES0I~oJ<_F?zAU+1fU;bkUKY;i&5SIh7Fb;DV00M{+iw|6ZxEYAe zk;F~|@gpGq48&YOEDQA+3sn9h5H|wxdUV480tns4WFYV9u?gnCGs0*2(YCw(> z0AhV0t_R|$Q1w57xC|-}HxnR$&<+0$RlFUDb#Zwc4J!lja-^UuMV1E$AQ;0Ah(ACT zECga6ECvMv@f;xb!Xn24#C=fx-+R zVFltWV;O009IN+yoVv zMIfxjfY=#`#R;fuftq&`h}i%F2qf?di2nkyACZwt2pdCF6e$0g0t65fG+n;~;*&V? zq9_nA1mYt=ybFla81RGpKzs#=xq(;(Ab?n)#ld?ZevLx|2M`-Viwibrk+B?_>97Hi z_+ub80;vTEASS5b7a;zJLjy>$6%e}t@oykz24Yq`J^-ot3T5*G1Q5&u0jNe?;0v^X z1806H#sxsWh z%K-!svLZKVB?AJNf!G(RlEH`VkxFAwH5!U64-i1;id}&C4pLaJ2I5#CR)CiIpxTNV zh^2uz42b7J4F!Sc(2^O&On?Bw<{~X1UIxT}kSux&jp$2I2fRjW0BivjY}kAV5I~H0 znk~*i90tT5(1>F~lKTg3zU&3!)j+%jSMCM~FaQQTP~Qk322B6}002ovPDHLkV1kWg BQ&9i_ literal 0 HcmV?d00001 diff --git a/uikit/src/main/res/drawable/info.png b/uikit/src/main/res/drawable/info.png new file mode 100644 index 0000000000000000000000000000000000000000..055c2fca24a53b691cb2e60fb5939d00e39e2593 GIT binary patch literal 927 zcmV;Q17Q4#P)z@;j(q!3lK=n!AY({UO#lFTB>(_`g8%^e{{R4h=>PzA zFaQARU;qF*m;eA5Z<1fdMgRZ<6-h)vRCwBA{Qv(y10KK##HK*34#Z+WEC|G(fcPa4 z-v;6{K>Q1z0RRES0I~oJ<_F?zAU+1fU;bkUKY;i&5SIh7Fb;DV00M{+iw|6ZxEYAe zk;F~|@gpGq48&YOEDQA+3sn9h5H|wxdUV480tns4WFYV9u?gnCGs0*2(YCw(> z0AhV0t_R|$Q1w57xC|-}HxnR$&<+0$RlFUDb#Zwc4J!lja-^UuMV1E$AQ;0Ah(ACT zECga6ECvMv@f;xb!Xn24#C=fx-+R zVFltWV;O009IN+yoVv zMIfxjfY=#`#R;fuftq&`h}i%F2qf?di2nkyACZwt2pdCF6e$0g0t65fG+n;~;*&V? zq9_nA1mYt=ybFla81RGpKzs#=xq(;(Ab?n)#ld?ZevLx|2M`-Viwibrk+B?_>97Hi z_+ub80;vTEASS5b7a;zJLjy>$6%e}t@oykz24Yq`J^-ot3T5*G1Q5&u0jNe?;0v^X z1806H#sxsWh z%K-!svLZKVB?AJNf!G(RlEH`VkxFAwH5!U64-i1;id}&C4pLaJ2I5#CR)CiIpxTNV zh^2uz42b7J4F!Sc(2^O&On?Bw<{~X1UIxT}kSux&jp$2I2fRjW0BivjY}kAV5I~H0 znk~*i90tT5(1>F~lKTg3zU&3!)j+%jSMCM~FaQQTP~Qk322B6}002ovPDHLkV1kWg BQ&9i_ literal 0 HcmV?d00001 diff --git a/uikit/src/main/res/drawable/reply.png b/uikit/src/main/res/drawable/reply.png new file mode 100644 index 0000000000000000000000000000000000000000..61346496098eee79c6fd6d078be0211670b5e47c GIT binary patch literal 700 zcmWksdq`7p6h6Cqx<}r&<;>T9nND=RN(Bwm>s&d}ncB)y(&b1cie)88OuaMHsgcee zN`)j88i=N-V1Jn6H4TXtSV%tnxH%8oJ*(e1ebG4eb9DR3mX^> zuZwOHpM;{0H#USd%j;YATE%K$Q1xYUC4LO-k*HQwwNV_Opdj3AOC9D2L)$*#ZP5fc5!(p3(R}_no7y}j4Z|D(sN0+RVRpsF zpO~8TLSyM4xHy4S;&4+8W600?WnM@*i2wm5>)EU$YM2Fdb*?xSsNu(IBwhu(qA#hA zT$CtwTy}vjn9QEGR_s-()ZC&Dl@_r6#m&T zFYmWKn=NlXu+Sfe4$~|0qSlDy@S-|<#@$L? z;C}o!r!)hN(Os@CDSO5|YpX8ABA_ivZ8o3BjD#CHuKRmed fY-Y&vdtmv(+ri20tgog7`qLouNRE0yrLX@F5kL5M literal 0 HcmV?d00001 diff --git a/uikit/src/main/res/drawable/reply_privately.png b/uikit/src/main/res/drawable/reply_privately.png new file mode 100644 index 0000000000000000000000000000000000000000..3d758fc070b7158990d8a57d677b7475aef0908d GIT binary patch literal 720 zcmWlXZAepb6o=2fcW=6;*VH*@vA;`u8CgR`G}NxI&6%3p#k5wgo0V3k7Db8W-88!s z5ivCpF$Du5k*3uLAuYRB3gxJXG$b1&WI?Q;CJpWS;ddU+InRgl;W!TEA5i$K{Q*Fc zW5_fKR0&baBtl)dZs7#@RU1k!0my?lf6GLkiltsa7tP)&Aj#i#Bj4a6b7auK+VmV%e zk&_K8DRSPVzs7=n*DPyX!`uh8itLxORGs?l8$Yxxb`T=ckS^sW)1#+m;Mg53T&b`QEFJh_tCMvLEO86 zAB%vAnmv~Cme0Tx>IPAc|^(LY| zc}&+3x2Rd-mZOZQd~>yK zs}%bnix3ry6;UZ@2}UDt^zkG6Q6v(5EE**JX!yfLjoaOia~>X^!#Ot#;3U1y?S7;76Y8?P0-6#HTy`plox4NMg z;CLwj2?G34RQw5WWI4c`2Vh+vK%Vb%^NT6~dYjwjXgoG6CKY7^)7z9MbwHvK#ckUK z4B3aCRPtYvJ+PVd_2fSV%60Kul{YjM6;Zr&SU^N)ZOfD&4|4rftP}q$aJLrmhS(|w zk>A!fliV@LRWLCWVHe0uhV;<+V>>mnc3A*u-SuyUc(UkV)Q;ku=v$&x@BwOMDZk-N zI5##5h&1It3JQ3Vl?3Xrk?&;1wn$+PKTjuGP&X5+L6zsG3ONEIvfT(d_xvrEN~I54 z9>1#mN{bG(pAoAfGacv@B`b%Y^yEsnNuTwNqWv(>NlKRnXo)Sen&e)5pB+1sU3RKa zI!TgiOom0LlZX#Ei>QVLvouX7_VGp@m)8gL&;)IjmVecvl-Vl|;roo-jel`GMr>{U zlp}kBk+x6?ArgOC@B2=pj}~WeF6;fmTinXZ?E@O%@qm;xU7E~j4DYiKuWwfk_6^vB zQ9CzBn(<`T8;e$l7MGl#&V0`ZgR56zu%C56nQi{xI z%8q8JYOX8MIZHZlYkCPnO>nlKk;O*+o%wh7l8Z2*;O;2rv9^qTR-X~v8|z#ToSv@# DJ<9v_ literal 0 HcmV?d00001 diff --git a/uikit/src/main/res/drawable/thread.png b/uikit/src/main/res/drawable/thread.png new file mode 100644 index 0000000000000000000000000000000000000000..7b9ad8b68a44ade86e64d267bc0eb35f444357ae GIT binary patch literal 884 zcmWktZA=>l7=C-#>-B?n2RJ@kdvhJbwGj}qFp}B3!L~M7JgZp>tKmb$x)@6_jg0}h z(rrCPgE+GVNg3_3Y!a985r4EM%9h?HZZtvTR&`lm6_>E!M@^Uo8tU=md7r$``{d1= zCwT{%rsGO^i5viwW>bSz;G!K!B|=^P=x|yfS+}YALjXno4n!~(+;NECr7bkT%y944 z>z@lf`L@Yw0r+?y0P6$T$O^m);I0IC+6GWJ3Q*`g-+KEP0P@t_K)>nvts|4o8c|{% zbx8>voiPv!w5po$?HhyumC)y}Dsj?84&%u_VIAaL zj#HUkTq$+yC}!BjUt`n7#1@E&d0b9qq@0$F1~l9{Yg2Rmzo$g`HEUXO6~7(RkPjr7 zk%AfO+h@g`k>1Vn3v2}El!F1^DrIMNl9xYKb{^a@yp<|EM=xuMrL%YZMY%7^bp4oR zt>R~U7YiNqQ28iU!Fn|42Ag~8uYN(gwdV(vFQW`fe(s+l@m;-8gbb2z6b|mrxlj zj$dcAm5--|6AQjHY{>}9u&A39S*oUMBa(P+!1L3#R^1Z{=tb^d8d*T1$>#|L{f6or z(VT19=oxqf+u};ImiqxJ12%!7c8onH42t@57QOsa}*TJo27|g@NXq()$aD+q}OfnV_qG zeAUr|HAiw@<74NyoHjWsgrGCq#Gm*}?x5~NIAJ`q*;Z-|5*Q%TlTBUzmJoKqi12?h zF|$O-|0_csC|_VYo3NyB<>EsSiHFelDP&Br_=ATENQwT-%wiT-ZkL%@8rso} + android:icon="@drawable/ic_chats" /> لا يمكن أن يكون المعرف الفريد فارغًا. يرجى تقديم UID صالح لا يمكن أن يحتوي المعرف الفريد على مسافات. يرجى تقديم UID صالح هناك خطأ ما - لا يمكن إلغاء المكالمة دون بدء المكالمة - حدث خطأ ما أثناء الاتصال - عدم تطابق جلسة الاتصال. يرجى التحقق من معرف الجلسة - لم يتم تحديد كل من UID و GUID يرجى تحديد المعرف الفريد العمومي (UID) أو المعرف الفريد العمومي (GUID) التي تحتاج الرسالة إلى جلبها - لا يوجد اتصال بالإنترنت الرجاء المحاولة مرة أخرى - الطلب قيد التقدم بالفعل - الطابع الزمني "أو" MessageId "أو" updatedAfter "مطلوبان لاستخدام طريقة" fetchNext () " - Auth token لايمكن ان يكون فارغا يرجى تقديم ملف صالح auth token التمديد معطل. يرجى تمكين الامتداد من CometChat Dashboard - معرف الرسالة المقدم غير صالح يرجى تقديم معرف رسالة صالح - يمكن تحرير TextMessage أو CustomMessage فقط. يرجى تقديم رسالة صالحة - القائمة المقدمة فارغة. الرجاء تقديم قائمة صالحة - لا يمكن استخدام الطريقة `updatesOnly()` بدون الطريقة `setUpdatedAfter()` - خطأ أثناء تحليل JSON - خطأ أثناء تسجيل الخروج - لا يمكن أن يكون معرف التطبيق فارغًا. الرجاء تحديد معرف تطبيق صالح - يجب أن يكون الحد المحدد رقمًا موجبًا - المنطقة غير محددة. يرجى تحديد المنطقة في فئة AppSettingsBuilder باستخدام طريقة `setRegion()` - لا يمكن أن تكون AppSettings خالية - لا يمكن أن يكون ApiKey فارغًا أو فارغًا. يرجى تقديم مفتاح Api صالح - نوع الرسالة الذي أدخلته غير صالح للإجراء التالي لا يمكن أن يكون نص الرسالة فارغًا - لا يمكن أن يكون كائن الملف فارغًا أو أن مسار الملف غير موجود - تم تعيين عنوان URL لرسالة الوسائط على أنه فارغ أو فارغ - لا يمكن أن يكون حقل البيانات المخصصة فارغًا أو فارغًا لا يمكن أن يكون اسم المجموعة فارغًا أو فارغًا - لا يمكن أن يكون نوع المجموعة فارغًا أو فارغًا - تسجيل الدخول قيد التقدم. يرجى الانتظار حتى ينتهي طلب تسجيل الدخول لا يمكن أن تكون الرسالة فارغة. الرجاء تمرير كائن "BaseMessage" صالح - لا يمكن أن تكون المجموعة فارغة. الرجاء تمرير كائن "Group" صالح - لا يمكن أن تكون المكالمة خالية. الرجاء تمرير كائن "Call" صالح - نوع المكالمة غير صالح. يرجى تقديم نوع اتصال صالح - نوع جهاز الاستقبال غير صالح. يرجى تقديم نوع جهاز استقبال صالح - نوع معرف جلسة غير صالح. يرجى تقديم معرف جلسة صالح - لا يمكن أن يكون النشاط المقدم فارغًا. - لا يمكن أن يكون مخطط RelativeLayout المقدم فارغًا - لا يمكن أن يكون رمز FCM المميز المقدم فارغًا أو فارغًا. يرجى تقديم رمز FCM مميز صالح - لا يمكن أن يكون نوع المجموعة المقدم فارغًا أو فارغًا - الاتصال قيد التقدم. يرجى إنهاء المكالمة السابقة لإجراء هذه العملية - لا يمكن إلغاء المكالمة التي بدأها شخص آخر. الرجاء استخدام الحالة "مرفوض" بدلاً من ذلك تم توفير اسم غير صالح للمستخدم. الرجاء إدخال اسم صالح - لا يمكن أن يكون كائن المستخدم فارغًا. يرجى تقديم كائن مستخدم صالح لا يمكن أن يكون اسم المجموعة فارغًا. يرجى تقديم اسم مجموعة صالح - يجب أن يكون الطابع الزمني موجبًا. يرجى تقديم طابع زمني صالح - فئة غير صالحة. الرجاء تقديم فئة صالحة - أيقونة فارغة. الرجاء تقديم رمز صالح - وصف فارغ. الرجاء تقديم وصف صحيح - البيانات الوصفية الفارغة. يرجى تقديم بيانات وصفية صالحة - النطاق غير صالح. يرجى تقديم نطاق صالح - النطاق غير صالح. يرجى تقديم نطاق صالح - محادثة غير صحيحة مع. يرجى تقديم قيمة صالحة لـ ConversWith - نوع محادثة غير صالح. يرجى تقديم قيمة صالحة لـ ConversWith - رسالة وسائط غير صالحة. الرجاء توفير كائن ملف صالح أو تفاصيل المرفق. - لا يمكن أن يكون المرفق فارغًا. يرجى تقديم تفاصيل صحيحة للمرفقات - اسم الملف غير صالح. الرجاء إدخال اسم ملف صالح - ملحق الملف غير صالح. يرجى تقديم امتداد ملف صالح - نوع ملف Mime غير صالح. الرجاء تقديم نوع ملف mime صالح - URL ملف غير صالح. يرجى تقديم عنوان URL صالح للملف - لم يتم العثور على محادثة لـ conversationWith ٪s و ConverstionType ٪s - الإعدادات غير موجودة. - لا يمكن أن يكون العنصر المقدم فارغًا أو فارغًا. الرجاء تقديم ميزة صالحة - لا يمكن أن يكون الامتداد المقدم فارغًا أو فارغًا. - الميزة المقدمة غير موجودة. تعذر العثور على الامتداد المقدم. + ركل + غادر + جارى التحميل + إنشاء المجموعة + إرسال الرسالة بشكل خاص + عرض الصفحة الشخصية + مسح المحادثة + هل ترغب في حذف هذه المحادثة؟ + حذف المحادثة \ No newline at end of file diff --git a/uikit/src/main/res/values-de/strings.xml b/uikit/src/main/res/values-de/strings.xml index 372a902..43aca14 100644 --- a/uikit/src/main/res/values-de/strings.xml +++ b/uikit/src/main/res/values-de/strings.xml @@ -443,5 +443,13 @@ Die angegebene Erweiterung darf nicht null oder leer sein. Bereitgestellte Funktion nicht gefunden. Die bereitgestellte Erweiterung konnte nicht gefunden werden. + verließ die + wird heruntergeladen + Gruppe erstellen + Nachricht privat senden + Profil anzeigen + Konversation löschen + Möchten Sie diese Konversation löschen? + Gespräch löschen \ No newline at end of file diff --git a/uikit/src/main/res/values-es/strings.xml b/uikit/src/main/res/values-es/strings.xml index 8ad5ca6..82e6247 100644 --- a/uikit/src/main/res/values-es/strings.xml +++ b/uikit/src/main/res/values-es/strings.xml @@ -451,5 +451,13 @@ La extensión proporcionada no puede ser nula ni estar vacía. Característica proporcionada no encontrada. No se pudo encontrar la extensión proporcionada. + dejó el grupo + descargando + creando grupo + Enviar mensaje de forma privada + Ver perfil + eliminar la conversación + ¿Quieres eliminar esta conversación? + Eliminar conversación \ No newline at end of file diff --git a/uikit/src/main/res/values-fr/strings.xml b/uikit/src/main/res/values-fr/strings.xml index 6434167..92cde4f 100644 --- a/uikit/src/main/res/values-fr/strings.xml +++ b/uikit/src/main/res/values-fr/strings.xml @@ -450,7 +450,15 @@ L\'extension fournie ne peut pas être nulle ou vide. Fonction fournie introuvable. L\'extension fournie est introuvable. - + frappé + la gauche + Téléchargement + création d\'un groupe + Envoyer un message en privé + Voir le profil + supprimer la conversation + Souhaitez-vous supprimer cette conversation? + Suppression de la conversation \ No newline at end of file diff --git a/uikit/src/main/res/values-hi/strings.xml b/uikit/src/main/res/values-hi/strings.xml index 01bf92c..05f10e2 100644 --- a/uikit/src/main/res/values-hi/strings.xml +++ b/uikit/src/main/res/values-hi/strings.xml @@ -444,4 +444,11 @@ बशर्ते विस्तार शून्य या रिक्त न हो। बशर्ते सुविधा नहीं मिली। प्रदान किया गया एक्सटेंशन नहीं मिला। + डाउनलोड + समूह बनाना + निजी तौर पर संदेश भेजें + प्रोफ़ाइल देखें + बातचीत मिटा दो + क्या आप इस वार्तालाप को हटाना चाहेंगे? + वार्तालाप हटाना \ No newline at end of file diff --git a/uikit/src/main/res/values-lt/strings.xml b/uikit/src/main/res/values-lt/strings.xml index e0b5503..d348c2e 100644 --- a/uikit/src/main/res/values-lt/strings.xml +++ b/uikit/src/main/res/values-lt/strings.xml @@ -413,5 +413,16 @@ Funkcija netinkama. Šis plėtinys neteisingas. Patikrinkite informacijos suvestinėje. ​​Funkcija nerasta. + grupp + užblokuotas vartotojas + atsisiųsti + kurianti grupė + Siųsti pranešimą privačiai + Peržiūrėti vartotojo profilį + Ištrinti pokalbį + šiandien + Ar norėtumėte ištrinti šį pokalbį? + Ištrinamas pokalbis + rašo .. \ No newline at end of file diff --git a/uikit/src/main/res/values-ms/strings.xml b/uikit/src/main/res/values-ms/strings.xml index 56063a4..6311554 100644 --- a/uikit/src/main/res/values-ms/strings.xml +++ b/uikit/src/main/res/values-ms/strings.xml @@ -444,4 +444,12 @@ Sambungan yang disediakan tidak boleh kosong atau kosong. Ciri yang disediakan tidak dijumpai. Sambungan yang disediakan tidak dapat dijumpai. + meninggalkan kumpulan + memuat turun + mewujudkan kumpulan + Hantar Mesej secara tertutup + Lihat profil + padamkan perbualan + Adakah anda mahu memadamkan perbualan ini? + Memadamkan Perbualan \ No newline at end of file diff --git a/uikit/src/main/res/values-pt/strings.xml b/uikit/src/main/res/values-pt/strings.xml index c6dbd07..a0fd27b 100644 --- a/uikit/src/main/res/values-pt/strings.xml +++ b/uikit/src/main/res/values-pt/strings.xml @@ -444,5 +444,13 @@ A extensão fornecida não pode ser nula ou vazia. Recurso fornecido não encontrado. A extensão fornecida não foi encontrada. + deixou o grupo + baixando + criando grupo + Enviar mensagem em particular + Ver perfil + apagar conversa + Você gostaria de excluir esta conversa? + Excluindo a conversa \ No newline at end of file diff --git a/uikit/src/main/res/values-ru/strings.xml b/uikit/src/main/res/values-ru/strings.xml index 73328bc..d49a30f 100644 --- a/uikit/src/main/res/values-ru/strings.xml +++ b/uikit/src/main/res/values-ru/strings.xml @@ -446,5 +446,13 @@ Предоставленное расширение не может быть пустым или пустым. Предоставленная функция не найдена. Предоставленное расширение не может быть найдено. + покинул группу + скачивание + создание группы + Отправить сообщение в частном порядке + Просмотреть профиль + удалить беседу + Вы хотите удалить этот разговор? + Удаление разговора \ No newline at end of file diff --git a/uikit/src/main/res/values-sw/strings.xml b/uikit/src/main/res/values-sv/strings.xml similarity index 97% rename from uikit/src/main/res/values-sw/strings.xml rename to uikit/src/main/res/values-sv/strings.xml index 18a0fa2..40c6882 100644 --- a/uikit/src/main/res/values-sw/strings.xml +++ b/uikit/src/main/res/values-sv/strings.xml @@ -306,7 +306,7 @@ initierad lagt till sparkade - vänster + lämnade gruppen gick med Unban gjort @@ -414,5 +414,15 @@ Funktionen är inte giltig. Detta tillägg är ogiltigt. Kontrollera från instrumentpanelen. ​​Funktionen hittades inte. + grupp + laddar ner + skapa grupp + Skicka meddelande privat + Visa profil + radera konversation + i dag + Vill du radera den här konversationen? + Tar bort konversation + skriver.. \ No newline at end of file diff --git a/uikit/src/main/res/values-zh-rTW/strings.xml b/uikit/src/main/res/values-zh-rTW/strings.xml index 978b070..a0fcfa6 100644 --- a/uikit/src/main/res/values-zh-rTW/strings.xml +++ b/uikit/src/main/res/values-zh-rTW/strings.xml @@ -443,4 +443,13 @@ 提供的擴展名不能為null或為空。 找不到提供的功能。 找不到提供的擴展名。 + + 剩下 + 正在下載 + 建立小组 + 私下发送消息 + 查看資料 + 刪除對話 + 您要删除此对话吗? + 删除对话 \ No newline at end of file diff --git a/uikit/src/main/res/values-zh/strings.xml b/uikit/src/main/res/values-zh/strings.xml index 932a141..660b7ca 100644 --- a/uikit/src/main/res/values-zh/strings.xml +++ b/uikit/src/main/res/values-zh/strings.xml @@ -442,4 +442,13 @@ 提供的扩展名不能为null或为空。 找不到提供的功能。 找不到提供的扩展名。 + + 剩下 + 正在下载 + 建立小组 + 私下发送消息 + 查看资料 + 删除对话 + 您要删除此对话吗? + 删除对话 \ No newline at end of file diff --git a/uikit/src/main/res/values/dimen.xml b/uikit/src/main/res/values/dimen.xml index 20c7b70..a2041c3 100644 --- a/uikit/src/main/res/values/dimen.xml +++ b/uikit/src/main/res/values/dimen.xml @@ -4,5 +4,6 @@ 16sp 14sp 12sp - 30dp + 11sp + 24dp \ No newline at end of file diff --git a/uikit/src/main/res/values/strings.xml b/uikit/src/main/res/values/strings.xml index 98e45ea..b6aad7c 100644 --- a/uikit/src/main/res/values/strings.xml +++ b/uikit/src/main/res/values/strings.xml @@ -259,10 +259,10 @@ Unable to get your location Ended Ongoing - Share WhiteBoard - Shared a WhiteBoard - Share WriteBoard - Shared a WriteBoard + Share Whiteboard + Shared a Whiteboard + Share Document + Shared a Document You sent a %1$s You received a %1$s Initiate a call @@ -335,7 +335,7 @@ Uploading Voted Success Updating - Conversations + Chats Updated User Successfully "User Left " User Joined @@ -365,69 +365,23 @@ Please provide a valid UID UID cannot be blank. Please provide a valid UID UID cannot contain spaces. Please provide a valid UID - Something went wrong - Call cannot be cancelled without initiating a call - Something went wrong while connecting - Call session mismatch. Please check the session ID - Both UID and GUID not specified. Please specify the UID or the GUID for which the messages need to be fetched - No internet connection. Please try again later - Request already in progress - Timestamp\' or \'MessageId\' or `updatedAfter` is required to use the \'fetchNext()\' method - Auth token cannot be empty. Please provide a valid auth token - The message ID provided is invalid. Please provide a valid Message ID - Only TextMessage or CustomMessage can be edited. Please provide a valid message - The list provided is empty. Please provide a valid list - The `updatesOnly()` method cannot be used without the `setUpdatedAfter()` method - Error while parsing JSON - Error while logging out - AppID cannot be empty. Please specify a valid appID - The limit specified must be a positive number - Region not specified. Please specify the region in the AppSettingsBuilder class using the `setRegion()` method - The AppSettings cannot be null - ApiKey cannot be null or empty. Please provide a valid Api Key - Login in progress. Please wait for the login request to finish - The Message type you have entered is invalid for following action + Something went wrong, please try again Message text cannot be empty - File object cannot be null or File path doesn\'t exist - Media Message URL is set as null or blank - Custom data field cannot be null or empty Group Name cannot be null or empty - Group Type cannot be null or empty Message cannot be null. Please pass a valid `BaseMessage` object - Group cannot be null. Please pass a valid `Group` object - Call cannot be null. Please pass a valid `Call` object - Invalid Call Type. Please provide a valid Call type - Invalid Receiver Type. Please provide a valid Receiver type - Invalid sessionId Type. Please provide a valid session id - Provided Activity cannot be null. - Provided RelativeLayout cannot be null - The FCM token provided cannot be null or empty. Please provide a valid FCM token - The group type provided cannot be null or empty - Call is in progress. Please end the previous call to perform this operation - Cannot cancel call initiated by someone else. Please use status `rejected` instead Invalid name provided for the user. Please provide a valid name - User object cannot be null. Please provide a valid user object Group name cannot be empty. Please provide a valid group name - Timestamp has to be positive. Please provide a valid timestamp - Invalid Category. Please provide a valid category - Empty Icon. Please provide a valid icon - Empty Description. Please provide a valid description - Empty Metatdata. Please provide a valid metadata - Invalid Scope. Please provide a valid scope - Invalid Scope. Please provide a valid scope - Invalid conversationWith. Please provide a valid value for conversationWith - Invalid conversationType. Please provide a valid value for conversationWith - Invalid Media Message.Please provide a valid File object or Attachment details. - Attachment cannot be null. Please provide valid attachment details - Invalid File Name. Please provide a valid file name - Invalid File Extension. Please provide a valid file extension - Invalid File Mime Type. Please provide a valid file mime type - Invalid File URL. Please provide a valid file URL - Conversation not found - Settings not found. - Feature is not valid. - This extension is invalid. Please check from Dashboard. - Feature not found. + + Downloading + Creating Group + Send Message Privately + View Profile + Delete this conversation + Today + In a thread + Would you like to delete this conversation? + Deleting Conversation + is typing..