Search in sources :

Example 1 with Message

use of cn.wildfirechat.message.Message in project android-chat by wildfirechat.

the class ForwardMessageAction method forwardOneByOne.

private void forwardOneByOne(List<UiMessage> messages) {
    ArrayList<Message> msgs = messages.stream().map(uiMessage -> uiMessage.message).collect(Collectors.toCollection(ArrayList::new));
    Intent intent = new Intent(fragment.getContext(), ForwardActivity.class);
    intent.putExtra("messages", msgs);
    fragment.startActivity(intent);
}
Also used : Context(android.content.Context) Message(cn.wildfirechat.message.Message) ChatManager(cn.wildfirechat.remote.ChatManager) Conversation(cn.wildfirechat.model.Conversation) R(cn.wildfire.chat.kit.R) UiMessage(cn.wildfire.chat.kit.conversation.message.model.UiMessage) Intent(android.content.Intent) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) List(java.util.List) ForwardActivity(cn.wildfire.chat.kit.conversation.forward.ForwardActivity) Toast(android.widget.Toast) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) CompositeMessageContent(cn.wildfirechat.message.CompositeMessageContent) UserInfo(cn.wildfirechat.model.UserInfo) Message(cn.wildfirechat.message.Message) UiMessage(cn.wildfire.chat.kit.conversation.message.model.UiMessage) Intent(android.content.Intent)

Example 2 with Message

use of cn.wildfirechat.message.Message in project android-chat by wildfirechat.

the class FavAudioContentViewHolder method playAudio.

@OnClick(R2.id.audioContentLayout)
void playAudio() {
    Message message = favoriteItem.toMessage();
    uiMessage = new UiMessage(message);
    MessageViewModel messageViewModel = ViewModelProviders.of(fragment).get(MessageViewModel.class);
    File file = messageViewModel.mediaMessageContentFile(message);
    if (file == null) {
        return;
    }
    if (file.exists()) {
        messageViewModel.playAudioMessage(uiMessage);
    } else {
        if (uiMessage.isDownloading) {
            return;
        }
        messageViewModel.downloadMedia(uiMessage, file);
    }
}
Also used : Message(cn.wildfirechat.message.Message) UiMessage(cn.wildfire.chat.kit.conversation.message.model.UiMessage) UiMessage(cn.wildfire.chat.kit.conversation.message.model.UiMessage) MessageViewModel(cn.wildfire.chat.kit.viewmodel.MessageViewModel) File(java.io.File) OnClick(butterknife.OnClick)

Example 3 with Message

use of cn.wildfirechat.message.Message in project android-chat by wildfirechat.

the class ConversationViewHolder method onBind.

public void onBind(ConversationInfo conversationInfo) {
    secretChatIndicator.setVisibility(View.GONE);
    onBindConversationInfo(conversationInfo);
    timeTextView.setText(TimeUtils.getMsgFormatTime(conversationInfo.timestamp));
    silentImageView.setVisibility(conversationInfo.isSilent ? View.VISIBLE : View.GONE);
    statusImageView.setVisibility(View.GONE);
    itemView.setBackgroundResource(conversationInfo.isTop ? R.drawable.selector_stick_top_item : R.drawable.selector_common_item);
    redDotView.setVisibility(View.GONE);
    if (conversationInfo.isSilent) {
        if (conversationInfo.unreadCount.unread > 0) {
            // 显示红点
            unreadCountTextView.setText("");
            unreadCountTextView.setVisibility(View.GONE);
            redDotView.setVisibility(View.VISIBLE);
        } else {
            unreadCountTextView.setVisibility(View.GONE);
        }
    } else {
        if (conversationInfo.unreadCount.unread > 0) {
            unreadCountTextView.setVisibility(View.VISIBLE);
            unreadCountTextView.setText(conversationInfo.unreadCount.unread > 99 ? "99+" : conversationInfo.unreadCount.unread + "");
        } else {
            unreadCountTextView.setVisibility(View.GONE);
        }
    }
    Draft draft = Draft.fromDraftJson(conversationInfo.draft);
    if (draft != null) {
        String draftString = draft.getContent() != null ? draft.getContent() : "[草稿]";
        MoonUtils.identifyFaceExpression(fragment.getActivity(), contentTextView, draft.getContent(), ImageSpan.ALIGN_BOTTOM);
        setViewVisibility(R.id.promptTextView, View.VISIBLE);
        setViewVisibility(R.id.contentTextView, View.VISIBLE);
    } else {
        if (conversationInfo.unreadCount.unreadMentionAll > 0 || conversationInfo.unreadCount.unreadMention > 0) {
            promptTextView.setText("[有人@我]");
            promptTextView.setVisibility(View.VISIBLE);
        } else {
            promptTextView.setVisibility(View.GONE);
        }
        setViewVisibility(R.id.contentTextView, View.VISIBLE);
        if (conversationInfo.lastMessage != null && conversationInfo.lastMessage.content != null) {
            String content = "";
            Message lastMessage = conversationInfo.lastMessage;
            // the message maybe invalid
            try {
                if (conversationInfo.conversation.type == Conversation.ConversationType.Group && lastMessage.direction == MessageDirection.Receive && !(lastMessage.content instanceof NotificationMessageContent)) {
                    GroupViewModel groupViewModel = ViewModelProviders.of(fragment).get(GroupViewModel.class);
                    String senderDisplayName = groupViewModel.getGroupMemberDisplayName(conversationInfo.conversation.target, conversationInfo.lastMessage.sender);
                    content = senderDisplayName + ":" + lastMessage.digest();
                } else {
                    content = lastMessage.digest();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            content = WfcTextUtils.htmlToText(content);
            MoonUtils.identifyFaceExpression(fragment.getActivity(), contentTextView, content, ImageSpan.ALIGN_BOTTOM);
            switch(lastMessage.status) {
                case Sending:
                    statusImageView.setVisibility(View.VISIBLE);
                    // TODO update sending image resource
                    statusImageView.setImageResource(R.mipmap.ic_sending);
                    break;
                case Send_Failure:
                    statusImageView.setVisibility(View.VISIBLE);
                    statusImageView.setImageResource(R.mipmap.img_error);
                    break;
                default:
                    statusImageView.setVisibility(View.GONE);
                    break;
            }
        } else {
            contentTextView.setText("");
        }
    }
}
Also used : Draft(cn.wildfire.chat.kit.conversation.Draft) Message(cn.wildfirechat.message.Message) GroupViewModel(cn.wildfire.chat.kit.group.GroupViewModel) NotificationMessageContent(cn.wildfirechat.message.notification.NotificationMessageContent)

Example 4 with Message

use of cn.wildfirechat.message.Message in project android-chat by wildfirechat.

the class BaseConferenceFragment method onReceiveMessage.

@Override
public void onReceiveMessage(List<Message> messages, boolean hasMore) {
    if (AVEngineKit.Instance().getCurrentSession() != null && AVEngineKit.Instance().getCurrentSession().isConference()) {
        for (Message msg : messages) {
            if (msg.content instanceof ConferenceChangeModeContent) {
                ConferenceChangeModeContent content = (ConferenceChangeModeContent) msg.content;
                onChangeModeRequest(content.getCallId(), content.isAudience());
            }
        }
    }
}
Also used : Message(cn.wildfirechat.message.Message) ConferenceChangeModeContent(cn.wildfire.chat.kit.voip.conference.message.ConferenceChangeModeContent)

Example 5 with Message

use of cn.wildfirechat.message.Message in project android-chat by wildfirechat.

the class ConferenceInviteActivity method invite.

private void invite(String targetName, String targetPortrait, Conversation targetConversation) {
    ForwardPromptView view = new ForwardPromptView(this);
    view.bind(targetName, targetPortrait, "会议邀请");
    MaterialDialog dialog = new MaterialDialog.Builder(this).customView(view, false).negativeText("取消").positiveText("发送").onPositive(new MaterialDialog.SingleButtonCallback() {

        @Override
        public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
            Message extraMsg = null;
            if (!TextUtils.isEmpty(view.getEditText())) {
                TextMessageContent content = new TextMessageContent(view.getEditText());
                extraMsg = new Message();
                extraMsg.content = content;
            }
            messageViewModel.sendMessage(targetConversation, inviteMessage);
            Toast.makeText(ConferenceInviteActivity.this, "邀请成功", Toast.LENGTH_SHORT).show();
            finish();
        // .observe(ConferenceInviteActivity.this, new Observer<OperateResult<Integer>>() {
        // @Override
        // public void onChanged(@Nullable OperateResult<Integer> integerOperateResult) {
        // if (integerOperateResult.isSuccess()) {
        // Toast.makeText(ConferenceInviteActivity.this, "邀请成功", Toast.LENGTH_SHORT).show();
        // finish();
        // } else {
        // Toast.makeText(ConferenceInviteActivity.this, "邀请失败" + integerOperateResult.getErrorCode(), Toast.LENGTH_SHORT).show();
        // }
        // }
        // });
        }
    }).build();
    dialog.show();
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Message(cn.wildfirechat.message.Message) DialogAction(com.afollestad.materialdialogs.DialogAction) NonNull(androidx.annotation.NonNull) ForwardPromptView(cn.wildfire.chat.kit.conversation.forward.ForwardPromptView) TextMessageContent(cn.wildfirechat.message.TextMessageContent)

Aggregations

Message (cn.wildfirechat.message.Message)33 UiMessage (cn.wildfire.chat.kit.conversation.message.model.UiMessage)10 ArrayList (java.util.ArrayList)9 CompositeMessageContent (cn.wildfirechat.message.CompositeMessageContent)6 List (java.util.List)6 MutableLiveData (androidx.lifecycle.MutableLiveData)5 Intent (android.content.Intent)4 TextMessageContent (cn.wildfirechat.message.TextMessageContent)4 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)4 RemoteException (android.os.RemoteException)3 GroupViewModel (cn.wildfire.chat.kit.group.GroupViewModel)3 ImageMessageContent (cn.wildfirechat.message.ImageMessageContent)3 VideoMessageContent (cn.wildfirechat.message.VideoMessageContent)3 Conversation (cn.wildfirechat.model.Conversation)3 Context (android.content.Context)2 View (android.view.View)2 TextView (android.widget.TextView)2 Toast (android.widget.Toast)2 NonNull (androidx.annotation.NonNull)2 BindView (butterknife.BindView)2