use of cn.wildfirechat.message.ImageMessageContent in project android-chat by wildfirechat.
the class MessageViewModel method sendImgMsg.
public void sendImgMsg(Conversation conversation, Uri imageFileThumbUri, Uri imageFileSourceUri) {
ImageMessageContent imgContent = new ImageMessageContent(imageFileSourceUri.getEncodedPath());
String thumbParam = ChatManager.Instance().getImageThumbPara();
if (!TextUtils.isEmpty(thumbParam)) {
imgContent.setThumbPara(ChatManager.Instance().getImageThumbPara());
}
sendMessage(conversation, imgContent);
}
use of cn.wildfirechat.message.ImageMessageContent in project android-chat by wildfirechat.
the class NormalMessageContentViewHolder method contextMenuItemFilter.
@Override
public boolean contextMenuItemFilter(UiMessage uiMessage, String tag) {
Message message = uiMessage.message;
if (message.conversation.type == Conversation.ConversationType.SecretChat) {
if (MessageContextMenuItemTags.TAG_FORWARD.equals(tag)) {
return true;
}
if (MessageContextMenuItemTags.TAG_FAV.equals(tag)) {
return true;
}
return false;
}
if (MessageContextMenuItemTags.TAG_RECALL.equals(tag)) {
String userId = ChatManager.Instance().getUserId();
if (message.conversation.type == Conversation.ConversationType.Group) {
GroupViewModel groupViewModel = ViewModelProviders.of(fragment).get(GroupViewModel.class);
GroupInfo groupInfo = groupViewModel.getGroupInfo(message.conversation.target, false);
if (groupInfo != null && userId.equals(groupInfo.owner)) {
return false;
}
GroupMember groupMember = groupViewModel.getGroupMember(message.conversation.target, ChatManager.Instance().getUserId());
if (groupMember != null && (groupMember.type == GroupMember.GroupMemberType.Manager || groupMember.type == GroupMember.GroupMemberType.Owner)) {
return false;
}
}
long delta = ChatManager.Instance().getServerDeltaTime();
long now = System.currentTimeMillis();
if (message.direction == MessageDirection.Send && TextUtils.equals(message.sender, ChatManager.Instance().getUserId()) && now - (message.serverTime - delta) < Config.RECALL_TIME_LIMIT * 1000) {
return false;
} else {
return true;
}
}
// 只有channel 主可以发起
if (MessageContextMenuItemTags.TAG_CHANEL_PRIVATE_CHAT.equals(tag)) {
if (uiMessage.message.conversation.type == Conversation.ConversationType.Channel && uiMessage.message.direction == MessageDirection.Receive) {
return false;
}
return true;
}
// 只有部分消息支持引用
if (MessageContextMenuItemTags.TAG_QUOTE.equals(tag)) {
MessageContent messageContent = message.content;
if (messageContent instanceof TextMessageContent || messageContent instanceof FileMessageContent || messageContent instanceof VideoMessageContent || messageContent instanceof StickerMessageContent || messageContent instanceof ImageMessageContent) {
return false;
}
return true;
}
// 只有部分消息支持收藏
if (MessageContextMenuItemTags.TAG_FAV.equals(tag)) {
MessageContent messageContent = message.content;
if (messageContent instanceof TextMessageContent || messageContent instanceof FileMessageContent || messageContent instanceof CompositeMessageContent || messageContent instanceof VideoMessageContent || messageContent instanceof SoundMessageContent || messageContent instanceof ImageMessageContent) {
return false;
}
return true;
}
return false;
}
use of cn.wildfirechat.message.ImageMessageContent in project android-chat by wildfirechat.
the class ImageMessageContentViewHolder method setSendStatus.
@Override
protected void setSendStatus(Message item) {
super.setSendStatus(item);
MessageContent msgContent = item.content;
if (msgContent instanceof ImageMessageContent) {
boolean isSend = item.direction == MessageDirection.Send;
if (isSend) {
MessageStatus sentStatus = item.status;
if (sentStatus == MessageStatus.Sending) {
imageView.setPercent(message.progress);
imageView.setProgressVisible(true);
imageView.showShadow(true);
} else if (sentStatus == MessageStatus.Send_Failure) {
imageView.setProgressVisible(false);
imageView.showShadow(false);
} else if (sentStatus == MessageStatus.Sent) {
imageView.setProgressVisible(false);
imageView.showShadow(false);
}
} else {
imageView.setProgressVisible(false);
imageView.showShadow(false);
}
}
}
use of cn.wildfirechat.message.ImageMessageContent in project android-chat by wildfirechat.
the class ImageMessageContentViewHolder method onBind.
@Override
public void onBind(UiMessage message) {
ImageMessageContent imageMessage = (ImageMessageContent) message.message.content;
Bitmap thumbnail = imageMessage.getThumbnail();
int[] imageSize = WeChatImageUtils.getImageSizeByOrgSizeToWeChat((int) imageMessage.getImageWidth(), (int) imageMessage.getImageHeight());
int width = imageSize[0] > 0 ? imageSize[0] : 200;
int height = imageSize[1] > 0 ? imageSize[1] : 200;
imageView.getLayoutParams().width = width;
imageView.getLayoutParams().height = height;
if (FileUtils.isFileExists(imageMessage.localPath)) {
imagePath = imageMessage.localPath;
} else {
imagePath = imageMessage.remoteUrl;
}
if (message.message.conversation.type == Conversation.ConversationType.SecretChat) {
imagePath += "?target=" + message.message.conversation.target + "&secret=true";
}
loadMedia(thumbnail, imagePath, imageView);
}
use of cn.wildfirechat.message.ImageMessageContent in project android-chat by wildfirechat.
the class ForwardActivity method forward.
private void forward(String targetName, String targetPortrait, Conversation targetConversation) {
ForwardPromptView view = new ForwardPromptView(this);
if (messages.size() == 1) {
Message message = messages.get(0);
if (message.content instanceof ImageMessageContent) {
view.bind(targetName, targetPortrait, ((ImageMessageContent) message.content).getThumbnail());
} else if (message.content instanceof VideoMessageContent) {
view.bind(targetName, targetPortrait, ((VideoMessageContent) message.content).getThumbnail());
} else if (message.content instanceof CompositeMessageContent) {
view.bind(targetName, targetPortrait, "[聊天记录]: " + ((CompositeMessageContent) message.content).getTitle());
} else {
view.bind(targetName, targetPortrait, WfcTextUtils.htmlToText(message.digest()));
}
} else {
view.bind(targetName, targetPortrait, "[逐条转发]共" + messages.size() + "条消息");
}
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;
}
if (extraMsg != null) {
messages.add(extraMsg);
}
forwardViewModel.forward(targetConversation, messages.toArray(new Message[0])).observe(ForwardActivity.this, new Observer<OperateResult<Integer>>() {
@Override
public void onChanged(@Nullable OperateResult<Integer> integerOperateResult) {
if (integerOperateResult.isSuccess()) {
Toast.makeText(ForwardActivity.this, "转发成功", Toast.LENGTH_SHORT).show();
finish();
} else {
Toast.makeText(ForwardActivity.this, "转发失败" + integerOperateResult.getErrorCode(), Toast.LENGTH_SHORT).show();
}
}
});
}
}).build();
dialog.show();
}
Aggregations