Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ dependencies {

implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.github.bumptech.glide:glide:4.9.0'

implementation 'com.github.duanhong169:drawabletoolbox:1.0.7'
implementation "io.noties.markwon:core:$markwon_version"
implementation "io.noties.markwon:linkify:$markwon_version"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private void configFileAttach() {
lv_attachment_file.setAdapter(attachAdapter);
lv_attachment_file.setOnItemClickListener((AdapterView<?> parent, View view,
int position, long id) -> {
Log.d(TAG, "Attach onClick: " + position);
Log.d(TAG, "Attach onMessageClick: " + position);

SelectAttachmentModel attachmentModel = new SelectAttachmentModel();
attachmentModel.setAttachmentIndex(position);
Expand Down Expand Up @@ -250,12 +250,12 @@ private void configMediaAttach() {

private void triggerLongClick(Message message, Attachment attachment) {
if (this.longClickListener != null) {
this.longClickListener.onClick(message, attachment);
this.longClickListener.onAttachmentClick(message, attachment);
}
}
private void triggerClick(Message message, Attachment attachment) {
if (this.clickListener != null) {
this.clickListener.onClick(message, attachment);
this.clickListener.onAttachmentClick(message, attachment);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ public void bind(Context context, MessageListItem messageListItem, Attachment at

private void triggerLongClick(Message message, Attachment attachment) {
if (this.longClickListener != null) {
this.longClickListener.onClick(message, attachment);
this.longClickListener.onAttachmentClick(message, attachment);
}
}

private void triggerClick(Message message, Attachment attachment) {
if (this.clickListener != null) {
this.clickListener.onClick(message, attachment);
this.clickListener.onAttachmentClick(message, attachment);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ private void configMediaAttach() {

private void triggerClick(Message message, Attachment attachment) {
if (this.clickListener != null) {
this.clickListener.onClick(message, attachment);
this.clickListener.onAttachmentClick(message, attachment);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public void bind(Context context, ChannelState channelState, int position) {
}

// read indicators
read_state.setReads(lastMessageReads);
read_state.setReads(lastMessageReads,true, style);

// apply unread style or read style
if (unreadCount == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
import io.noties.markwon.core.CorePlugin;
import io.noties.markwon.linkify.LinkifyPlugin;


public class MessageListItemViewHolder extends BaseMessageListItemViewHolder {

final String TAG = MessageListItemViewHolder.class.getSimpleName();

private ConstraintLayout cl_message, headerView;
Expand All @@ -54,7 +54,7 @@ public class MessageListItemViewHolder extends BaseMessageListItemViewHolder {
private TextView tv_username, tv_messagedate;

// Delivered Indicator
private ReadStateView view_read_indicator;
private ReadStateView read_state;
private TextView tv_indicator_initials, tv_read_count;
private ImageView cv_indicator_avatar;
private ProgressBar pb_indicator;
Expand Down Expand Up @@ -123,7 +123,7 @@ public MessageListItemViewHolder(int resId, ViewGroup viewGroup) {

alv_attachments = itemView.findViewById(R.id.cl_attachment);

view_read_indicator = itemView.findViewById(R.id.view_read_indicator);
read_state = itemView.findViewById(R.id.read_state);

tv_indicator_initials = itemView.findViewById(R.id.tv_indicator_initials);
tv_read_count = itemView.findViewById(R.id.tv_read_count);
Expand All @@ -149,7 +149,6 @@ public void bind(Context context, ChannelState channelState, MessageListItem mes
this.positions = messageListItem.getPositions();



if (this.message.getAttachments() == null || this.message.getAttachments().size() == 0) {
alv_attachments.setVisibility(View.GONE);
} else {
Expand All @@ -172,7 +171,6 @@ public void bind(Context context, ChannelState channelState, MessageListItem mes
this.applyPositionsStyle();



// TODO: hook up click and longclick

// Configure UIs
Expand All @@ -187,10 +185,11 @@ public void bind(Context context, ChannelState channelState, MessageListItem mes
configParamsDeletedMessage();
configParamsUserAvatar();
configParamsReactionRecycleView();
configPramsDeliveredIndicator();
configParamsDeliveredIndicator();
configParamsReactionTail();
configParamsMessageDate();
configParamsReply();
configParamsReadState();
// configParamsAttachment();
}
// endregion
Expand Down Expand Up @@ -262,7 +261,7 @@ private void configSendFailed() {
if (messageClickListener != null) {
String tag = TextUtils.isEmpty(message.getCommand()) ? Constant.TAG_MESSAGE_RESEND : Constant.TAG_MESSAGE_INVALID_COMMAND;
v.setTag(new MessageTagModel(tag, position));
messageClickListener.onClick(message);
messageClickListener.onMessageClick(message, position);
}
});

Expand Down Expand Up @@ -306,12 +305,11 @@ private void configMessageText() {
markwon.setMarkdown(tv_text, Global.getMentionedText(message));



// Set Click Listener
tv_text.setOnClickListener((View v) -> {
Log.d(TAG, "onClick: " + position);
Log.d(TAG, "onMessageClick: " + position);
if (messageClickListener != null) {
messageClickListener.onClick(message);
messageClickListener.onMessageClick(message, position);
}
});

Expand Down Expand Up @@ -368,9 +366,6 @@ private void configReplyView() {
}





// endregion

// region Layout Params
Expand Down Expand Up @@ -419,15 +414,14 @@ private void configParamsReactionRecycleView() {
}



private void configPramsDeliveredIndicator() {
private void configParamsDeliveredIndicator() {
List<ChannelUserRead> readBy = messageListItem.getMessageReadBy();

if (readBy.size() == 0) {
view_read_indicator.setVisibility(View.GONE);
read_state.setVisibility(View.GONE);
} else {
view_read_indicator.setReads(readBy);
view_read_indicator.setVisibility(View.VISIBLE);
read_state.setVisibility(View.VISIBLE);
read_state.setReads(readBy, messageListItem.isTheirs(), style);
}
}

Expand Down Expand Up @@ -493,7 +487,36 @@ private void configParamsReply() {
tv_reply.setLayoutParams(paramsText);
}

public void configParamsReadState(){
if (read_state.getVisibility() != View.VISIBLE) return;

ConstraintSet set = new ConstraintSet();
set.clone(cl_message);
set.clear(R.id.read_state, ConstraintSet.START);
set.clear(R.id.read_state, ConstraintSet.END);
set.applyTo(cl_message);

ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) read_state.getLayoutParams();

if (this.message.getAttachments() == null || this.message.getAttachments().isEmpty()) {
if (messageListItem.isMine()){
params.endToStart = alv_attachments.getId();
}else{
params.startToEnd = alv_attachments.getId();
}
}else {
if (messageListItem.isMine()){
params.endToStart = tv_text.getId();
}else{
params.startToEnd = tv_text.getId();
}
}
read_state.setLayoutParams(params);
}

public void setViewHolderFactory(MessageViewHolderFactory viewHolderFactory) {
this.viewHolderFactory = viewHolderFactory;
}


}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.getstream.sdk.chat.adapter;

import android.util.Log;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -19,6 +20,7 @@
import com.getstream.sdk.chat.rest.response.MessageResponse;
import com.getstream.sdk.chat.utils.StringUtility;
import com.getstream.sdk.chat.utils.Utils;
import com.getstream.sdk.chat.view.MessageListViewStyle;

import java.util.Arrays;
import java.util.List;
Expand All @@ -33,12 +35,14 @@ public class ReactionDialogAdapter extends RecyclerView.Adapter<ReactionDialogAd
private View.OnClickListener clickListener;
private boolean showAvatar;
private List<String> types = Arrays.asList("like", "love", "haha", "wow", "sad", "angry");

private MessageListViewStyle style;
public ReactionDialogAdapter(Channel channel, Message message,
boolean showAvatar,
MessageListViewStyle style,
View.OnClickListener clickListener) {
this.channel = channel;
this.message = message;
this.style = style;
this.clickListener = clickListener;
this.showAvatar = showAvatar;
}
Expand All @@ -56,6 +60,7 @@ public MyViewHolder onCreateViewHolder(ViewGroup parent,

@Override
public void onBindViewHolder(final MyViewHolder holder, int position) {
applyStyle(holder);
String type = types.get(position);
holder.tv_emoji.setText(ReactionEmoji.valueOf(type).get());

Expand Down Expand Up @@ -93,6 +98,9 @@ public void onBindViewHolder(final MyViewHolder holder, int position) {
holder.tv_count.setText("");
}

private void applyStyle(final MyViewHolder holder){
holder.tv_emoji.setTextSize(TypedValue.COMPLEX_UNIT_PX, style.getReactionDlgEmojiSize());
}
@Override
public int getItemCount() {
return types.size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import android.app.Dialog;
import android.content.Context;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.view.Gravity;
import android.view.View;
import android.view.Window;
Expand All @@ -16,27 +18,18 @@
import com.getstream.sdk.chat.rest.Message;
import com.getstream.sdk.chat.utils.Constant;
import com.getstream.sdk.chat.utils.Utils;
import com.getstream.sdk.chat.view.MessageListViewStyle;
import com.getstream.sdk.chat.view.ReactionDlgView;

public class ReactionFunction {
Channel channel;
public ReactionFunction(Channel channel){
this.channel = channel;
}

public void showReactionDialog(Context context, Message message, int originY) {
public static void showReactionDialog(Context context, Channel channel, Message message, MessageListViewStyle style, int originY) {
final Dialog dialog = new Dialog(context); // Context, this, etc.
dialog.setContentView(R.layout.dialog_reaction);
ReactionDlgView reactionDlgView = new ReactionDlgView(context);
reactionDlgView.setMessagewithStyle(channel, message, view -> dialog.dismiss(), style);
dialog.setContentView(reactionDlgView);
dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);

RecyclerView rv_reaction = dialog.findViewById(R.id.rv_reaction);
RecyclerView.LayoutManager mLayoutManager;
mLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false);
rv_reaction.setLayoutManager(mLayoutManager);
ReactionDialogAdapter reactionAdapter = new ReactionDialogAdapter(channel,message, true, (View v) -> {
dialog.dismiss();
});
rv_reaction.setAdapter(reactionAdapter);

dialog.show();

Window window = dialog.getWindow();
Expand All @@ -48,7 +41,7 @@ public void showReactionDialog(Context context, Message message, int originY) {
window.setAttributes(wlp);
}

public void showMoreActionDialog(Context context,
public static void showMoreActionDialog(Context context, Channel channel,
final Message message,
final View.OnClickListener clickListener) {
final Dialog dialog = new Dialog(context);
Expand Down Expand Up @@ -78,7 +71,7 @@ public void showMoreActionDialog(Context context,
RecyclerView.LayoutManager mLayoutManager;
mLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false);
rv_reaction.setLayoutManager(mLayoutManager);
ReactionDialogAdapter reactionAdapter = new ReactionDialogAdapter(channel, message, false, (View v) -> {
ReactionDialogAdapter reactionAdapter = new ReactionDialogAdapter(channel, message, false,null, (View v) -> {
dialog.dismiss();
});
rv_reaction.setAdapter(reactionAdapter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,6 @@ public UpdateMessageRequest(Message message, List<Attachment> attachments, List<
this.message.remove("differentTime");
this.message.remove("TimeElapsed");
this.message.remove("equals");
this.message.remove("getUserId");
}
}
Loading