Search in sources :

Example 11 with BaseMessage

use of com.cometchat.pro.models.BaseMessage in project android-java-chat-push-notification-app by cometchat-pro.

the class MessageAdapter method setReadReceipts.

/**
 * This method is used to set real time read receipt of particular message in messageList
 * of adapter by updating message.
 *
 * @param messageReceipt is a object of MessageReceipt.
 * @see MessageReceipt
 */
public void setReadReceipts(MessageReceipt messageReceipt) {
    for (int i = messageList.size() - 1; i >= 0; i--) {
        BaseMessage baseMessage = messageList.get(i);
        if (baseMessage.getReadAt() == 0) {
            int index = messageList.indexOf(baseMessage);
            messageList.get(index).setReadAt(messageReceipt.getReadAt());
        }
    }
    notifyDataSetChanged();
}
Also used : BaseMessage(com.cometchat.pro.models.BaseMessage)

Example 12 with BaseMessage

use of com.cometchat.pro.models.BaseMessage in project android-java-chat-push-notification-app by cometchat-pro.

the class MessageAdapter method setGroupCallMessageData.

private void setGroupCallMessageData(GroupCallMessageViewHolder viewHolder, int i) {
    BaseMessage baseMessage = messageList.get(i);
    if (baseMessage != null) {
        if (!baseMessage.getSender().getUid().equals(loggedInUser.getUid())) {
            if (baseMessage.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_USER)) {
                viewHolder.tvUser.setVisibility(View.GONE);
                viewHolder.ivUser.setVisibility(View.GONE);
            } else if (baseMessage.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_GROUP)) {
                if (isUserDetailVisible) {
                    viewHolder.tvUser.setVisibility(View.VISIBLE);
                    viewHolder.ivUser.setVisibility(View.VISIBLE);
                } else {
                    viewHolder.tvUser.setVisibility(View.GONE);
                    viewHolder.ivUser.setVisibility(View.INVISIBLE);
                }
                setAvatar(viewHolder.ivUser, baseMessage.getSender().getAvatar(), baseMessage.getSender().getName());
                viewHolder.tvUser.setText(baseMessage.getSender().getName());
            }
            viewHolder.groupCallMessage.setText(baseMessage.getSender().getName() + " " + context.getString(R.string.has_shared_group_call));
        } else {
            viewHolder.groupCallMessage.setText(context.getString(R.string.you_created_group_call));
        }
        viewHolder.joinBtn.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (((CustomMessage) baseMessage).getCustomData() != null) {
                    if (CometChat.getActiveCall() == null)
                        CallUtils.startDirectCall(context, Utils.getDirectCallData(baseMessage));
                    else {
                        AlertDialog.Builder alert = new AlertDialog.Builder(context);
                        alert.setTitle(context.getResources().getString(R.string.ongoing_call)).setMessage(context.getResources().getString(R.string.ongoing_call_message)).setPositiveButton(context.getResources().getString(R.string.join), new DialogInterface.OnClickListener() {

                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                CallUtils.joinOnGoingCall(context, CometChat.getActiveCall());
                            }
                        }).setNegativeButton(context.getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() {

                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.dismiss();
                            }
                        }).create().show();
                    }
                }
            }
        });
        if (baseMessage.getReplyCount() != 0) {
            viewHolder.tvThreadReplyCount.setVisibility(View.VISIBLE);
            viewHolder.tvThreadReplyCount.setText(baseMessage.getReplyCount() + " " + context.getResources().getString(R.string.replies));
        } else {
            viewHolder.tvThreadReplyCount.setVisibility(View.GONE);
        }
        viewHolder.tvThreadReplyCount.setOnClickListener(view -> {
            Intent intent = new Intent(context, CometChatThreadMessageListActivity.class);
            intent.putExtra(UIKitConstants.IntentStrings.NAME, baseMessage.getSender().getName());
            intent.putExtra(UIKitConstants.IntentStrings.AVATAR, baseMessage.getSender().getAvatar());
            intent.putExtra(UIKitConstants.IntentStrings.REPLY_COUNT, baseMessage.getReplyCount());
            intent.putExtra(UIKitConstants.IntentStrings.UID, baseMessage.getSender().getName());
            intent.putExtra(UIKitConstants.IntentStrings.PARENT_ID, baseMessage.getId());
            intent.putExtra(UIKitConstants.IntentStrings.MESSAGE_TYPE, baseMessage.getType());
            intent.putExtra(UIKitConstants.IntentStrings.REACTION_INFO, Extensions.getReactionsOnMessage(baseMessage));
            intent.putExtra(UIKitConstants.IntentStrings.SENTAT, baseMessage.getSentAt());
            intent.putExtra(UIKitConstants.IntentStrings.TEXTMESSAGE, Extensions.getWriteBoardUrl(baseMessage));
            intent.putExtra(UIKitConstants.IntentStrings.MESSAGE_CATEGORY, baseMessage.getCategory());
            intent.putExtra(UIKitConstants.IntentStrings.TYPE, baseMessage.getReceiverType());
            if (baseMessage.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_GROUP)) {
                intent.putExtra(UIKitConstants.IntentStrings.GUID, baseMessage.getReceiverUid());
            } else {
                if (baseMessage.getReceiverUid().equals(loggedInUser.getUid()))
                    intent.putExtra(UIKitConstants.IntentStrings.UID, baseMessage.getSender().getUid());
                else
                    intent.putExtra(UIKitConstants.IntentStrings.UID, baseMessage.getReceiverUid());
            }
            context.startActivity(intent);
        });
        showMessageTime(viewHolder, baseMessage);
        viewHolder.txtTime.setVisibility(View.VISIBLE);
        setColorFilter(baseMessage, viewHolder.messageContainer);
        viewHolder.rlMessageBubble.setOnClickListener(view -> {
            if (baseMessage.getSender().getUid().equals(loggedInUser.getUid())) {
                if (isLongClickEnabled && !isImageMessageClick) {
                    setLongClickSelectedItem(baseMessage);
                    messageLongClick.setLongMessageClick(longselectedItemList);
                } else {
                    setSelectedMessage(baseMessage.getId());
                }
                notifyItemChanged(i);
            }
        });
        viewHolder.rlMessageBubble.setOnLongClickListener(new View.OnLongClickListener() {

            @Override
            public boolean onLongClick(View view) {
                if (!isImageMessageClick && !isTextMessageClick) {
                    isLongClickEnabled = true;
                    setLongClickSelectedItem(baseMessage);
                    messageLongClick.setLongMessageClick(longselectedItemList);
                    notifyItemChanged(i);
                }
                return true;
            }
        });
        setReactionSupport(baseMessage, viewHolder.reactionLayout);
    }
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) CardView(androidx.cardview.widget.CardView) TextView(android.widget.TextView) MaterialCardView(com.google.android.material.card.MaterialCardView) BaseMessage(com.cometchat.pro.models.BaseMessage) CustomMessage(com.cometchat.pro.models.CustomMessage)

Example 13 with BaseMessage

use of com.cometchat.pro.models.BaseMessage in project android-java-chat-push-notification-app by cometchat-pro.

the class CometChatThreadMessageList method showBottomSheet.

private void showBottomSheet(CometChatMessageActions messageActionFragment) {
    messageActionFragment.show(getFragmentManager(), messageActionFragment.getTag());
    messageActionFragment.setMessageActionListener(new CometChatMessageActions.MessageActionListener() {

        @Override
        public void onPrivateReplyToUser() {
            if (baseMessage != null) {
                User user = baseMessage.getSender();
                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.NAME, user.getName());
                intent.putExtra(UIKitConstants.IntentStrings.LINK, user.getLink());
                intent.putExtra(UIKitConstants.IntentStrings.TYPE, CometChatConstants.RECEIVER_TYPE_USER);
                startActivity(intent);
                if (getActivity() != null)
                    getActivity().finish();
            }
        }

        @Override
        public void onThreadMessageClick() {
        }

        @Override
        public void onEditMessageClick() {
            if (isParent)
                editParentMessage();
            else
                editThreadMessage();
        }

        @Override
        public void onReplyMessageClick() {
        }

        @Override
        public void onReplyMessagePrivately() {
        }

        @Override
        public void onForwardMessageClick() {
            if (isParent)
                startForwardThreadActivity();
            else
                startForwardMessageActivity();
        }

        @Override
        public void onDeleteMessageClick() {
            deleteMessage(baseMessage);
            if (messageAdapter != null) {
                messageAdapter.clearLongClickSelectedItem();
                messageAdapter.notifyDataSetChanged();
            }
        }

        @Override
        public void onCopyMessageClick() {
            String copyMessage = "";
            if (isParent) {
                copyMessage = message;
                isParent = true;
            } else {
                for (BaseMessage bMessage : baseMessages) {
                    if (bMessage.getDeletedAt() == 0 && bMessage instanceof TextMessage) {
                        copyMessage = copyMessage + "[" + Utils.getLastMessageDate(context, bMessage.getSentAt()) + "] " + bMessage.getSender().getName() + ": " + ((TextMessage) bMessage).getText();
                    }
                }
                isParent = false;
            }
            Log.e(TAG, "onCopy: " + message);
            ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
            ClipData clipData = ClipData.newPlainText("ThreadMessageAdapter", copyMessage);
            clipboardManager.setPrimaryClip(clipData);
            Toast.makeText(context, getResources().getString(R.string.text_copied), Toast.LENGTH_LONG).show();
            if (messageAdapter != null) {
                messageAdapter.clearLongClickSelectedItem();
                messageAdapter.notifyDataSetChanged();
            }
        }

        @Override
        public void onShareMessageClick() {
            shareMessage();
        }

        @Override
        public void onMessageInfoClick() {
            Intent intent = new Intent(context, CometChatMessageInfoScreenActivity.class);
            if (isParent) {
            } else {
                intent.putExtra(UIKitConstants.IntentStrings.ID, baseMessage.getId());
                intent.putExtra(UIKitConstants.IntentStrings.MESSAGE_TYPE, baseMessage.getType());
                intent.putExtra(UIKitConstants.IntentStrings.SENTAT, baseMessage.getSentAt());
                if (baseMessage.getType().equals(CometChatConstants.MESSAGE_TYPE_TEXT)) {
                    intent.putExtra(UIKitConstants.IntentStrings.TEXTMESSAGE, Extensions.checkProfanityMessage(context, baseMessage));
                } else if (baseMessage.getCategory().equals(CometChatConstants.CATEGORY_CUSTOM)) {
                    if (((CustomMessage) baseMessage).getCustomData() != null)
                        intent.putExtra(UIKitConstants.IntentStrings.CUSTOM_MESSAGE, ((CustomMessage) baseMessage).getCustomData().toString());
                    if (baseMessage.getType().equals(UIKitConstants.IntentStrings.LOCATION)) {
                        intent.putExtra(UIKitConstants.IntentStrings.MESSAGE_TYPE, UIKitConstants.IntentStrings.LOCATION);
                    }
                } else {
                    boolean isImageNotSafe = Extensions.getImageModeration(context, baseMessage);
                    intent.putExtra(UIKitConstants.IntentStrings.MESSAGE_TYPE_IMAGE_URL, ((MediaMessage) baseMessage).getAttachment().getFileUrl());
                    intent.putExtra(UIKitConstants.IntentStrings.MESSAGE_TYPE_IMAGE_NAME, ((MediaMessage) baseMessage).getAttachment().getFileName());
                    intent.putExtra(UIKitConstants.IntentStrings.MESSAGE_TYPE_IMAGE_SIZE, ((MediaMessage) baseMessage).getAttachment().getFileSize());
                    intent.putExtra(UIKitConstants.IntentStrings.MESSAGE_TYPE_IMAGE_EXTENSION, ((MediaMessage) baseMessage).getAttachment().getFileExtension());
                    intent.putExtra(UIKitConstants.IntentStrings.IMAGE_MODERATION, isImageNotSafe);
                }
            }
            context.startActivity(intent);
        }

        @Override
        public void onReactionClick(Reaction reaction) {
            if (reaction.getName().equals("add_emoji")) {
                CometChatReactionDialog reactionDialog = new CometChatReactionDialog();
                reactionDialog.setOnEmojiClick(new OnReactionClickListener() {

                    @Override
                    public void onEmojiClicked(Reaction emojicon) {
                        sendReaction(emojicon);
                        reactionDialog.dismiss();
                    }
                });
                reactionDialog.show(getFragmentManager(), "ReactionDialog");
            } else {
                sendReaction(reaction);
            }
        }

        @Override
        public void onTranslateMessageClick() {
            try {
                String localeLanguage = Locale.getDefault().getLanguage();
                JSONObject body = new JSONObject();
                JSONArray languages = new JSONArray();
                languages.put(localeLanguage);
                if (isParent) {
                    body.put("msgId", parentId);
                    body.put("text", textMessage.getText().toString());
                } else {
                    body.put("msgId", baseMessage.getId());
                    body.put("text", ((TextMessage) baseMessage).getText());
                }
                body.put("languages", languages);
                CometChat.callExtension("message-translation", "POST", "/v2/translate", body, new CometChat.CallbackListener<JSONObject>() {

                    @Override
                    public void onSuccess(JSONObject jsonObject) {
                        if (isParent) {
                            if (Extensions.isMessageTranslated(jsonObject, textMessage.getText().toString())) {
                                String translatedMessage = Extensions.getTextFromTranslatedMessage(jsonObject, textMessage.getText().toString());
                                textMessage.setText(translatedMessage);
                            } else {
                                CometChatSnackBar.show(context, rvChatListView, getString(R.string.no_translation_available), CometChatSnackBar.INFO);
                            }
                        } else {
                            if (Extensions.isMessageTranslated(jsonObject, ((TextMessage) baseMessage).getText())) {
                                if (baseMessage.getMetadata() != null) {
                                    JSONObject meta = baseMessage.getMetadata();
                                    try {
                                        meta.accumulate("values", jsonObject);
                                        baseMessage.setMetadata(meta);
                                        updateMessage(baseMessage);
                                    } catch (JSONException e) {
                                        e.printStackTrace();
                                    }
                                } else {
                                    baseMessage.setMetadata(jsonObject);
                                    updateMessage(baseMessage);
                                }
                            } else {
                                CometChatSnackBar.show(context, rvChatListView, getString(R.string.no_translation_available), CometChatSnackBar.INFO);
                            }
                        }
                    }

                    @Override
                    public void onError(CometChatException e) {
                        CometChatSnackBar.show(context, rvChatListView, CometChatError.Extension.localized(e, "message-translation"), CometChatSnackBar.ERROR);
                    }
                });
            } catch (Exception e) {
                Toast.makeText(context, e.getMessage(), Toast.LENGTH_LONG).show();
            }
        }

        @Override
        public void onRetryClick() {
        }
    });
}
Also used : ClipboardManager(android.content.ClipboardManager) OnReactionClickListener(com.cometchat.pro.uikit.ui_components.shared.cometchatReaction.listener.OnReactionClickListener) CometChatException(com.cometchat.pro.exceptions.CometChatException) User(com.cometchat.pro.models.User) MediaMessage(com.cometchat.pro.models.MediaMessage) CometChatMessageListActivity(com.cometchat.pro.uikit.ui_components.messages.message_list.CometChatMessageListActivity) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) Intent(android.content.Intent) Reaction(com.cometchat.pro.uikit.ui_components.shared.cometchatReaction.model.Reaction) CometChatException(com.cometchat.pro.exceptions.CometChatException) JSONException(org.json.JSONException) CometChatReactionDialog(com.cometchat.pro.uikit.ui_components.shared.cometchatReaction.CometChatReactionDialog) BaseMessage(com.cometchat.pro.models.BaseMessage) JSONObject(org.json.JSONObject) CometChatMessageInfoScreenActivity(com.cometchat.pro.uikit.ui_components.messages.message_information.CometChatMessageInfoScreenActivity) CometChatMessageActions(com.cometchat.pro.uikit.ui_components.messages.message_actions.CometChatMessageActions) ClipData(android.content.ClipData) TextMessage(com.cometchat.pro.models.TextMessage)

Example 14 with BaseMessage

use of com.cometchat.pro.models.BaseMessage in project android-java-chat-push-notification-app by cometchat-pro.

the class CometChatThreadMessageList method editThread.

private void editThread(String editMessage) {
    isEdit = false;
    TextMessage textmessage;
    if (type.equalsIgnoreCase(CometChatConstants.RECEIVER_TYPE_USER))
        textmessage = new TextMessage(Id, editMessage, CometChatConstants.RECEIVER_TYPE_USER);
    else
        textmessage = new TextMessage(Id, editMessage, CometChatConstants.RECEIVER_TYPE_GROUP);
    sendTypingIndicator(true);
    textmessage.setId(parentId);
    CometChat.editMessage(textmessage, new CometChat.CallbackListener<BaseMessage>() {

        @Override
        public void onSuccess(BaseMessage baseMessage) {
            textMessage.setText(((TextMessage) baseMessage).getText());
            message = ((TextMessage) baseMessage).getText();
        }

        @Override
        public void onError(CometChatException e) {
            CometChatSnackBar.show(context, rvChatListView, CometChatError.localized(e), CometChatSnackBar.ERROR);
            Log.d(TAG, "onError: " + e.getMessage());
        }
    });
}
Also used : CometChatException(com.cometchat.pro.exceptions.CometChatException) BaseMessage(com.cometchat.pro.models.BaseMessage) CometChat(com.cometchat.pro.core.CometChat) TextMessage(com.cometchat.pro.models.TextMessage)

Example 15 with BaseMessage

use of com.cometchat.pro.models.BaseMessage in project android-java-chat-push-notification-app by cometchat-pro.

the class CometChatThreadMessageList method setLongMessageClick.

@Override
public void setLongMessageClick(List<BaseMessage> baseMessagesList) {
    Log.e(TAG, "setLongMessageClick: " + baseMessagesList);
    isReply = false;
    isEdit = false;
    isParent = false;
    messageActionFragment = new CometChatMessageActions();
    replyMessageLayout.setVisibility(GONE);
    editMessageLayout.setVisibility(GONE);
    fetchSettings();
    List<BaseMessage> textMessageList = new ArrayList<>();
    List<BaseMessage> mediaMessageList = new ArrayList<>();
    List<BaseMessage> locationMessageList = new ArrayList<>();
    for (BaseMessage baseMessage : baseMessagesList) {
        if (baseMessage.getType().equals(CometChatConstants.MESSAGE_TYPE_TEXT)) {
            textMessageList.add(baseMessage);
        } else if (baseMessage.getType().equals(CometChatConstants.MESSAGE_TYPE_IMAGE) || baseMessage.getType().equals(CometChatConstants.MESSAGE_TYPE_VIDEO) || baseMessage.getType().equals(CometChatConstants.MESSAGE_TYPE_FILE) || baseMessage.getType().equals(CometChatConstants.MESSAGE_TYPE_AUDIO)) {
            mediaMessageList.add(baseMessage);
        } else {
            locationMessageList.add(baseMessage);
        }
    }
    if (textMessageList.size() == 1) {
        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())) {
                    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;
                    if (loggedInUserScope != null && (loggedInUserScope.equals(CometChatConstants.SCOPE_ADMIN) || loggedInUserScope.equals(CometChatConstants.SCOPE_MODERATOR))) {
                        FeatureRestriction.isDeleteMemberMessageEnabled(new FeatureRestriction.OnSuccessListener() {

                            @Override
                            public void onSuccess(Boolean booleanVal) {
                                deleteVisible = booleanVal;
                            }
                        });
                    } else {
                        deleteVisible = false;
                    }
                }
            }
        }
    }
    if (mediaMessageList.size() == 1) {
        translateVisible = false;
        BaseMessage basemessage = mediaMessageList.get(0);
        if (basemessage != null && basemessage.getSender() != null) {
            if (!(basemessage instanceof Action) && basemessage.getDeletedAt() == 0) {
                baseMessage = basemessage;
                copyVisible = false;
                threadVisible = false;
                if (basemessage.getSender().getUid().equals(CometChat.getLoggedInUser().getUid())) {
                    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))) {
                        FeatureRestriction.isDeleteMemberMessageEnabled(new FeatureRestriction.OnSuccessListener() {

                            @Override
                            public void onSuccess(Boolean booleanVal) {
                                deleteVisible = booleanVal;
                            }
                        });
                    } else {
                        deleteVisible = false;
                    }
                    editVisible = false;
                }
            }
        }
    }
    if (locationMessageList.size() == 1) {
        translateVisible = false;
        BaseMessage basemessage = locationMessageList.get(0);
        if (basemessage != null && basemessage.getSender() != null) {
            if (!(basemessage instanceof Action) && basemessage.getDeletedAt() == 0) {
                baseMessage = basemessage;
                threadVisible = false;
                copyVisible = false;
                replyVisible = false;
                if (basemessage.getSender().getUid().equals(CometChat.getLoggedInUser().getUid())) {
                    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))) {
                        FeatureRestriction.isDeleteMemberMessageEnabled(new FeatureRestriction.OnSuccessListener() {

                            @Override
                            public void onSuccess(Boolean booleanVal) {
                                deleteVisible = booleanVal;
                            }
                        });
                    } else {
                        deleteVisible = false;
                    }
                    editVisible = false;
                }
            }
        }
    }
    baseMessages = baseMessagesList;
    Bundle bundle = new Bundle();
    bundle.putBoolean("copyVisible", copyVisible);
    bundle.putBoolean("threadVisible", threadVisible);
    bundle.putBoolean("editVisible", editVisible);
    bundle.putBoolean("deleteVisible", deleteVisible);
    bundle.putBoolean("replyVisible", replyVisible);
    bundle.putBoolean("forwardVisible", forwardVisible);
    bundle.putBoolean("translateVisible", translateVisible);
    if (CometChat.isExtensionEnabled("reactions")) {
        bundle.putBoolean("isReactionVisible", reactionVisible);
    }
    if (!baseMessage.getSender().getUid().equalsIgnoreCase(loggedInUser.getUid())) {
        bundle.putBoolean("privateReplyVisible", true);
    }
    if (baseMessage.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_GROUP) && 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) {
        if (editVisible || copyVisible || threadVisible || deleteVisible || replyVisible || forwardVisible || reactionVisible) {
            showBottomSheet(messageActionFragment);
        }
    }
}
Also used : Action(com.cometchat.pro.models.Action) BaseMessage(com.cometchat.pro.models.BaseMessage) FeatureRestriction(com.cometchat.pro.uikit.ui_settings.FeatureRestriction) Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) CometChatMessageActions(com.cometchat.pro.uikit.ui_components.messages.message_actions.CometChatMessageActions)

Aggregations

BaseMessage (com.cometchat.pro.models.BaseMessage)53 View (android.view.View)19 ImageView (android.widget.ImageView)19 TextView (android.widget.TextView)19 CardView (androidx.cardview.widget.CardView)19 RecyclerView (androidx.recyclerview.widget.RecyclerView)19 MaterialCardView (com.google.android.material.card.MaterialCardView)19 Intent (android.content.Intent)18 MediaMessage (com.cometchat.pro.models.MediaMessage)14 JSONException (org.json.JSONException)14 CometChatException (com.cometchat.pro.exceptions.CometChatException)11 FeatureRestriction (com.cometchat.pro.uikit.ui_settings.FeatureRestriction)11 JSONObject (org.json.JSONObject)10 TextMessage (com.cometchat.pro.models.TextMessage)8 User (com.cometchat.pro.models.User)7 AlertDialog (android.app.AlertDialog)6 DialogInterface (android.content.DialogInterface)6 CustomMessage (com.cometchat.pro.models.CustomMessage)5 Call (com.cometchat.pro.core.Call)4 Attachment (com.cometchat.pro.models.Attachment)4