No chat_bubble displayed, save this stage to go back and remove code to go forward step by step
This commit is contained in:
parent
4fe67b5a46
commit
3fe92f7f71
7 changed files with 327 additions and 328 deletions
|
@ -173,7 +173,9 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_above="@id/footer"/>
|
android:layout_above="@id/footer"/>
|
||||||
|
|
||||||
<ListView
|
<!--<ListView-->
|
||||||
|
<android.support.v7.widget.RecyclerView
|
||||||
|
|
||||||
android:id="@+id/chat_message_list"
|
android:id="@+id/chat_message_list"
|
||||||
android:divider="@android:color/transparent"
|
android:divider="@android:color/transparent"
|
||||||
android:choiceMode="multipleChoice"
|
android:choiceMode="multipleChoice"
|
||||||
|
|
|
@ -35,8 +35,9 @@ import org.linphone.R;
|
||||||
import org.linphone.core.ChatMessage;
|
import org.linphone.core.ChatMessage;
|
||||||
import org.linphone.core.ChatRoom;
|
import org.linphone.core.ChatRoom;
|
||||||
import org.linphone.core.EventLog;
|
import org.linphone.core.EventLog;
|
||||||
|
import org.linphone.core.LimeState;
|
||||||
|
|
||||||
public class ChatBubbleViewHolder extends RecyclerView.ViewHolder{
|
public class ChatBubbleViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
|
||||||
public String messageId;
|
public String messageId;
|
||||||
public EventLog mEvent;
|
public EventLog mEvent;
|
||||||
public ChatMessage message;
|
public ChatMessage message;
|
||||||
|
@ -67,9 +68,43 @@ public class ChatBubbleViewHolder extends RecyclerView.ViewHolder{
|
||||||
public Button openFileButton;
|
public Button openFileButton;
|
||||||
|
|
||||||
public CheckBox delete;
|
public CheckBox delete;
|
||||||
|
private ClickListener listener;
|
||||||
|
|
||||||
|
public ChatBubbleViewHolder(View view, ClickListener listener) {
|
||||||
|
super(view);
|
||||||
|
this.listener = listener;
|
||||||
|
eventLayout = view.findViewById(R.id.event);
|
||||||
|
//eventTime = view.findViewById(R.id.event_date);
|
||||||
|
eventMessage = view.findViewById(R.id.event_text);
|
||||||
|
|
||||||
|
bubbleLayout = view.findViewById(R.id.bubble);
|
||||||
|
background = view.findViewById(R.id.background);
|
||||||
|
contactPicture = view.findViewById(R.id.contact_picture);
|
||||||
|
contactPictureMask = view.findViewById(R.id.mask);
|
||||||
|
contactName = view.findViewById(R.id.contact_header);
|
||||||
|
|
||||||
|
messageStatus = view.findViewById(R.id.status);
|
||||||
|
messageSendingInProgress = view.findViewById(R.id.inprogress);
|
||||||
|
imdmLayout = view.findViewById(R.id.imdmLayout);
|
||||||
|
imdmIcon = view.findViewById(R.id.imdmIcon);
|
||||||
|
imdmLabel = view.findViewById(R.id.imdmText);
|
||||||
|
|
||||||
|
messageText = view.findViewById(R.id.message);
|
||||||
|
messageImage = view.findViewById(R.id.image);
|
||||||
|
|
||||||
|
fileTransferLayout = view.findViewById(R.id.file_transfer_layout);
|
||||||
|
fileTransferProgressBar = view.findViewById(R.id.progress_bar);
|
||||||
|
fileTransferAction = view.findViewById(R.id.file_transfer_action);
|
||||||
|
|
||||||
|
fileName = view.findViewById(R.id.file_name);
|
||||||
|
openFileButton = view.findViewById(R.id.open_file);
|
||||||
|
|
||||||
|
delete = view.findViewById(R.id.delete_message);
|
||||||
|
view.setOnClickListener(this);
|
||||||
|
}
|
||||||
public ChatBubbleViewHolder(View view) {
|
public ChatBubbleViewHolder(View view) {
|
||||||
super(view);
|
super(view);
|
||||||
|
this.listener = listener;
|
||||||
eventLayout = view.findViewById(R.id.event);
|
eventLayout = view.findViewById(R.id.event);
|
||||||
//eventTime = view.findViewById(R.id.event_date);
|
//eventTime = view.findViewById(R.id.event_date);
|
||||||
eventMessage = view.findViewById(R.id.event_text);
|
eventMessage = view.findViewById(R.id.event_text);
|
||||||
|
@ -98,25 +133,11 @@ public class ChatBubbleViewHolder extends RecyclerView.ViewHolder{
|
||||||
|
|
||||||
delete = view.findViewById(R.id.delete_message);
|
delete = view.findViewById(R.id.delete_message);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
listener.onItemClicked(getAdapterPosition()); }
|
||||||
|
|
||||||
public void bindEvent(EventLog event) {
|
public interface ClickListener {
|
||||||
|
public void onItemClicked(int position);
|
||||||
//Bind the data to the ViewHolder
|
|
||||||
this.mEvent = event;
|
|
||||||
this.message = event.getChatMessage();
|
|
||||||
this.messageId = message.getMessageId();
|
|
||||||
|
|
||||||
this.eventLayout.setVisibility(event.getType() == EventLog.Type.ConferenceChatMessage ? View.GONE : View.VISIBLE);
|
|
||||||
this.bubbleLayout.setVisibility(event.getType() == EventLog.Type.ConferenceChatMessage ? View.VISIBLE : View.GONE);
|
|
||||||
this.messageText.setVisibility(event.getType() == EventLog.Type.ConferenceChatMessage ? View.VISIBLE : View.GONE);
|
|
||||||
this.messageImage.setVisibility(View.GONE);
|
|
||||||
this.fileTransferLayout.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
this.lastMessageSenderView.setText(getSender(mRoom));
|
|
||||||
this.lastMessageView.setText(mRoom.getLastMessageInHistory() != null ? mRoom.getLastMessageInHistory().getTextContent(): "");
|
|
||||||
this.date.setText(mRoom.getLastMessageInHistory()!=null ? LinphoneUtils.timestampToHumanDate(this.mContext, mRoom.getLastUpdateTime(), R.string.messages_list_date_format) : "");
|
|
||||||
this.displayName.setText(getContact(mRoom));
|
|
||||||
this.unreadMessages.setText(String.valueOf(LinphoneManager.getInstance().getUnreadCountForChatRoom(mRoom)));
|
|
||||||
getAvatar(mRoom);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -64,6 +64,7 @@ import org.linphone.core.LimeState;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
import org.linphone.ui.ListSelectionAdapter;
|
import org.linphone.ui.ListSelectionAdapter;
|
||||||
import org.linphone.ui.ListSelectionHelper;
|
import org.linphone.ui.ListSelectionHelper;
|
||||||
|
import org.linphone.ui.SelectableAdapter;
|
||||||
import org.linphone.ui.SelectableHelper;
|
import org.linphone.ui.SelectableHelper;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -76,27 +77,28 @@ import java.util.List;
|
||||||
|
|
||||||
import static android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION;
|
import static android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION;
|
||||||
|
|
||||||
public class ChatEventsAdapter extends RecyclerView.Adapter<ChatBubbleViewHolder> {
|
public class ChatEventsAdapter extends SelectableAdapter<ChatBubbleViewHolder> {
|
||||||
|
//public class ChatEventsAdapter extends RecyclerView.Adapter<ChatBubbleViewHolder> {
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private List<EventLog> mHistory;
|
private List<EventLog> mHistory;
|
||||||
private List<LinphoneContact> mParticipants;
|
private List<LinphoneContact> mParticipants;
|
||||||
private LayoutInflater mLayoutInflater;
|
private LayoutInflater mLayoutInflater;
|
||||||
// private int itemResource;
|
|
||||||
private Bitmap mDefaultBitmap;
|
private Bitmap mDefaultBitmap;
|
||||||
private GroupChatFragment mFragment;
|
private GroupChatFragment mFragment;
|
||||||
private ChatMessageListenerStub mListener;
|
private ChatMessageListenerStub mListener;
|
||||||
|
private ChatBubbleViewHolder.ClickListener clickListener;
|
||||||
|
|
||||||
// public ChatEventsAdapter(GroupChatFragment fragment, ListSelectionHelper helper, LayoutInflater inflater, EventLog[] history, ArrayList<LinphoneContact> participants) {
|
// public ChatEventsAdapter(GroupChatFragment fragment, ListSelectionHelper helper, LayoutInflater inflater, EventLog[] history, ArrayList<LinphoneContact> participants) {
|
||||||
public ChatEventsAdapter(GroupChatFragment fragment, ListSelectionHelper helper, LayoutInflater inflater, EventLog[] history, ArrayList<LinphoneContact> participants) {
|
public ChatEventsAdapter(GroupChatFragment fragment, SelectableHelper helper, LayoutInflater inflater, ArrayList<EventLog> mHistory, ArrayList<LinphoneContact> participants, ChatBubbleViewHolder.ClickListener clickListener) {
|
||||||
// public ChatRoomsAdapter(Context context, int itemResource, List<ChatRoom > mRooms, ChatRoomViewHolder.ClickListener clickListener, SelectableHelper helper) {
|
// public ChatEventsAdapter(GroupChatFragment fragment, SelectableHelper helper, LayoutInflater inflater, ArrayList<EventLog> mHistory, ArrayList<LinphoneContact> participants, ChatBubbleViewHolder.ClickListener clickListener) {
|
||||||
|
|
||||||
super();
|
super(helper);
|
||||||
mFragment = fragment;
|
this.mFragment = fragment;
|
||||||
mContext = mFragment.getActivity();
|
this.mContext = mFragment.getActivity();
|
||||||
// itemResource = inflater.;
|
// itemResource = inflater.;
|
||||||
mLayoutInflater = inflater;
|
this.mLayoutInflater = inflater;
|
||||||
mHistory = new ArrayList<>(Arrays.asList(history));
|
this.mHistory = mHistory;
|
||||||
mParticipants = participants;
|
this.mParticipants = participants;
|
||||||
|
|
||||||
mListener = new ChatMessageListenerStub() {
|
mListener = new ChatMessageListenerStub() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -132,128 +134,12 @@ public class ChatEventsAdapter extends RecyclerView.Adapter<ChatBubbleViewHolder
|
||||||
@Override
|
@Override
|
||||||
public ChatBubbleViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
public ChatBubbleViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
View v = mLayoutInflater.inflate(R.layout.chat_bubble, parent, false);
|
View v = mLayoutInflater.inflate(R.layout.chat_bubble, parent, false);
|
||||||
return new ChatBubbleViewHolder(v);
|
return new ChatBubbleViewHolder(v, clickListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull ChatBubbleViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull ChatBubbleViewHolder holder, int position) {
|
||||||
EventLog event = (EventLog)getItem(position);
|
EventLog event = (EventLog)getItem(position);
|
||||||
final ChatMessage message = event.getChatMessage();
|
|
||||||
|
|
||||||
//Apply generic bindings
|
|
||||||
holder.bindEvent(event);
|
|
||||||
|
|
||||||
// holder.delete.setVisibility(this.isEditionEnabled() == true ? View.VISIBLE : View.INVISIBLE);
|
|
||||||
// holder.delete.setChecked(isSelected(position) ? true : false);
|
|
||||||
|
|
||||||
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
|
|
||||||
|
|
||||||
//If event is Chat Message
|
|
||||||
if(event.getType() == EventLog.Type.ConferenceChatMessage) {
|
|
||||||
|
|
||||||
|
|
||||||
//layoutParams Settings
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (isEditionEnabled()) {
|
|
||||||
layoutParams.addRule(RelativeLayout.LEFT_OF, holder.delete.getId());
|
|
||||||
layoutParams.setMargins(100, 10, 10, 10);
|
|
||||||
} else if (message.isOutgoing()) {
|
|
||||||
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
|
||||||
layoutParams.setMargins(100, 10, 10, 10);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
|
|
||||||
layoutParams.setMargins(10, 10, 100, 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//Display attached files
|
|
||||||
if (message.getAppdata() != null) {
|
|
||||||
displayAttachedFile(message, holder);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (message.getExternalBodyUrl() != null ) {
|
|
||||||
holder.fileTransferProgressBar.setVisibility(View.GONE);
|
|
||||||
holder.fileTransferLayout.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (message.isFileTransferInProgress()){
|
|
||||||
holder.fileTransferLayout.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getItemId(int i) {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemCount() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void addToHistory(EventLog log) {
|
|
||||||
mHistory.add(log);
|
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setContacts(ArrayList<LinphoneContact> participants) {
|
|
||||||
mParticipants = participants;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void refresh(EventLog[] history) {
|
|
||||||
mHistory = new ArrayList<>(Arrays.asList(history));
|
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clear() {
|
|
||||||
for (EventLog event : mHistory) {
|
|
||||||
if (event.getType() == EventLog.Type.ConferenceChatMessage) {
|
|
||||||
ChatMessage message = event.getChatMessage();
|
|
||||||
message.setListener(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mHistory.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
public int getCount() {
|
|
||||||
return mHistory.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
public Object getItem(int i) {
|
|
||||||
return mHistory.get(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void removeItem(int i) {
|
|
||||||
mHistory.remove(i);
|
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
|
||||||
ChatBubbleViewHolder holder;
|
|
||||||
if (view != null) {
|
|
||||||
holder = (ChatBubbleViewHolder) view.getTag();
|
|
||||||
} else {
|
|
||||||
view = mLayoutInflater.inflate(R.layout.chat_bubble, null);
|
|
||||||
holder = new ChatBubbleViewHolder(view);
|
|
||||||
view.setTag(holder);
|
|
||||||
}
|
|
||||||
|
|
||||||
holder.eventLayout.setVisibility(View.GONE);
|
holder.eventLayout.setVisibility(View.GONE);
|
||||||
holder.bubbleLayout.setVisibility(View.GONE);
|
holder.bubbleLayout.setVisibility(View.GONE);
|
||||||
|
@ -269,15 +155,16 @@ public class ChatEventsAdapter extends RecyclerView.Adapter<ChatBubbleViewHolder
|
||||||
holder.messageSendingInProgress.setVisibility(View.GONE);
|
holder.messageSendingInProgress.setVisibility(View.GONE);
|
||||||
holder.imdmLayout.setVisibility(View.INVISIBLE);
|
holder.imdmLayout.setVisibility(View.INVISIBLE);
|
||||||
holder.contactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
holder.contactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
||||||
|
//Apply generic bindings
|
||||||
|
|
||||||
if (isEditionEnabled()) {
|
if (isEditionEnabled()) {
|
||||||
holder.delete.setOnCheckedChangeListener(null);
|
holder.delete.setOnCheckedChangeListener(null);
|
||||||
holder.delete.setChecked(getSelectedItemsPosition().contains(i));
|
holder.delete.setChecked(isSelected(position));
|
||||||
holder.delete.setTag(i);
|
holder.delete.setTag(position);
|
||||||
holder.delete.setOnCheckedChangeListener(getDeleteListener());
|
holder.delete.setOnCheckedChangeListener(getDeleteListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
EventLog event = (EventLog)getItem(i);
|
//If event is Chat Message
|
||||||
if(event.getType() == EventLog.Type.ConferenceChatMessage) {
|
if(event.getType() == EventLog.Type.ConferenceChatMessage) {
|
||||||
holder.bubbleLayout.setVisibility(View.VISIBLE);
|
holder.bubbleLayout.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
@ -412,42 +299,42 @@ public class ChatEventsAdapter extends RecyclerView.Adapter<ChatBubbleViewHolder
|
||||||
holder.fileTransferAction.setVisibility(View.GONE);
|
holder.fileTransferAction.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
holder.fileTransferAction.setText(mContext.getString(R.string.accept));
|
holder.fileTransferAction.setText(mContext.getString(R.string.accept));
|
||||||
holder.fileTransferAction.setOnClickListener(new View.OnClickListener() {
|
// holder.fileTransferAction.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
// @Override
|
||||||
public void onClick(View v) {
|
// public void onClick(View v) {
|
||||||
if (mContext.getPackageManager().checkPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, mContext.getPackageName()) == PackageManager.PERMISSION_GRANTED) {
|
// if (mContext.getPackageManager().checkPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, mContext.getPackageName()) == PackageManager.PERMISSION_GRANTED) {
|
||||||
v.setEnabled(false);
|
// v.setEnabled(false);
|
||||||
String filename = message.getFileTransferInformation().getName();
|
// String filename = message.getFileTransferInformation().getName();
|
||||||
File file = new File(Environment.getExternalStorageDirectory(), filename);
|
// File file = new File(Environment.getExternalStorageDirectory(), filename);
|
||||||
int prefix = 1;
|
// int prefix = 1;
|
||||||
while (file.exists()) {
|
// while (file.exists()) {
|
||||||
file = new File(Environment.getExternalStorageDirectory(), prefix + "_" + filename);
|
// file = new File(Environment.getExternalStorageDirectory(), prefix + "_" + filename);
|
||||||
Log.w("File with that name already exists, renamed to " + prefix + "_" + filename);
|
// Log.w("File with that name already exists, renamed to " + prefix + "_" + filename);
|
||||||
prefix += 1;
|
// prefix += 1;
|
||||||
}
|
// }
|
||||||
message.setListener(mListener);
|
// message.setListener(mListener);
|
||||||
message.setFileTransferFilepath(file.getPath());
|
// message.setFileTransferFilepath(file.getPath());
|
||||||
message.downloadFile();
|
// message.downloadFile();
|
||||||
|
//
|
||||||
} else {
|
// } else {
|
||||||
Log.w("WRITE_EXTERNAL_STORAGE permission not granted, won't be able to store the downloaded file");
|
// Log.w("WRITE_EXTERNAL_STORAGE permission not granted, won't be able to store the downloaded file");
|
||||||
LinphoneActivity.instance().checkAndRequestExternalStoragePermission();
|
// LinphoneActivity.instance().checkAndRequestExternalStoragePermission();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
}
|
||||||
} else if (message.isFileTransferInProgress()) { // Outgoing file transfer in progress
|
} else if (message.isFileTransferInProgress()) { // Outgoing file transfer in progress
|
||||||
message.setListener(mListener); // add the listener for file upload progress display
|
message.setListener(mListener); // add the listener for file upload progress display
|
||||||
holder.messageSendingInProgress.setVisibility(View.GONE);
|
holder.messageSendingInProgress.setVisibility(View.GONE);
|
||||||
holder.fileTransferLayout.setVisibility(View.VISIBLE);
|
holder.fileTransferLayout.setVisibility(View.VISIBLE);
|
||||||
holder.fileTransferAction.setText(mContext.getString(R.string.cancel));
|
holder.fileTransferAction.setText(mContext.getString(R.string.cancel));
|
||||||
holder.fileTransferAction.setOnClickListener(new View.OnClickListener() {
|
// holder.fileTransferAction.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
// @Override
|
||||||
public void onClick(View v) {
|
// public void onClick(View v) {
|
||||||
message.cancelFileTransfer();
|
// message.cancelFileTransfer();
|
||||||
notifyDataSetChanged();
|
// notifyDataSetChanged();
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.bubbleLayout.setLayoutParams(layoutParams);
|
holder.bubbleLayout.setLayoutParams(layoutParams);
|
||||||
|
@ -498,11 +385,70 @@ public class ChatEventsAdapter extends RecyclerView.Adapter<ChatBubbleViewHolder
|
||||||
//TODO
|
//TODO
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return view;
|
@Override
|
||||||
|
public long getItemId(int i) {
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void addToHistory(EventLog log) {
|
||||||
|
mHistory.add(log);
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContacts(ArrayList<LinphoneContact> participants) {
|
||||||
|
mParticipants = participants;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refresh(EventLog[] history) {
|
||||||
|
// mHistory = new ArrayList<>(Arrays.asList(history));
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
for (EventLog event : mHistory) {
|
||||||
|
if (event.getType() == EventLog.Type.ConferenceChatMessage) {
|
||||||
|
ChatMessage message = event.getChatMessage();
|
||||||
|
message.setListener(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mHistory.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
public int getCount() {
|
||||||
|
return mHistory.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
public Object getItem(int i) {
|
||||||
|
return mHistory.get(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void removeItem(int i) {
|
||||||
|
mHistory.remove(i);
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void loadBitmap(String path, ImageView imageView) {
|
private void loadBitmap(String path, ImageView imageView) {
|
||||||
if (cancelPotentialWork(path, imageView)) {
|
if (cancelPotentialWork(path, imageView)) {
|
||||||
if (LinphoneUtils.isExtensionImage(path)) {
|
if (LinphoneUtils.isExtensionImage(path)) {
|
||||||
|
|
|
@ -92,10 +92,9 @@ public class ChatListFragment extends Fragment implements ContactsUpdatedListene
|
||||||
|
|
||||||
//Creation and affectation of adapter to the RecyclerView
|
//Creation and affectation of adapter to the RecyclerView
|
||||||
mSelectionHelper = new SelectableHelper(view, this);
|
mSelectionHelper = new SelectableHelper(view, this);
|
||||||
|
|
||||||
mChatRoomsAdapter = new ChatRoomsAdapter(mContext, R.layout.chatlist_cell, mRooms,this, mSelectionHelper);
|
mChatRoomsAdapter = new ChatRoomsAdapter(mContext, R.layout.chatlist_cell, mRooms,this, mSelectionHelper);
|
||||||
mChatRoomsList.setAdapter(mChatRoomsAdapter);
|
|
||||||
|
|
||||||
|
mChatRoomsList.setAdapter(mChatRoomsAdapter);
|
||||||
mSelectionHelper.setAdapter(mChatRoomsAdapter);
|
mSelectionHelper.setAdapter(mChatRoomsAdapter);
|
||||||
mSelectionHelper.setDialogMessage(R.string.chat_room_delete_dialog);
|
mSelectionHelper.setDialogMessage(R.string.chat_room_delete_dialog);
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,9 @@ import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
|
import android.support.v7.widget.DefaultItemAnimator;
|
||||||
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.view.ContextMenu;
|
import android.view.ContextMenu;
|
||||||
|
@ -77,15 +80,17 @@ import org.linphone.contacts.ContactsUpdatedListener;
|
||||||
import org.linphone.core.Reason;
|
import org.linphone.core.Reason;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
import org.linphone.ui.ListSelectionHelper;
|
import org.linphone.ui.ListSelectionHelper;
|
||||||
|
import org.linphone.ui.SelectableHelper;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static android.content.Context.INPUT_METHOD_SERVICE;
|
import static android.content.Context.INPUT_METHOD_SERVICE;
|
||||||
import static org.linphone.fragments.FragmentsAvailable.CHAT;
|
import static org.linphone.fragments.FragmentsAvailable.CHAT;
|
||||||
|
|
||||||
public class GroupChatFragment extends Fragment implements ChatRoomListener, ContactsUpdatedListener, ListSelectionHelper.DeleteListener {
|
public class GroupChatFragment extends Fragment implements ChatRoomListener, ContactsUpdatedListener, ChatBubbleViewHolder.ClickListener ,SelectableHelper.DeleteListener {
|
||||||
private static final int ADD_PHOTO = 1337;
|
private static final int ADD_PHOTO = 1337;
|
||||||
|
|
||||||
private ImageView mBackButton, mCallButton, mBackToCallButton, mGroupInfosButton;
|
private ImageView mBackButton, mCallButton, mBackToCallButton, mGroupInfosButton;
|
||||||
|
@ -93,11 +98,10 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
||||||
private TextView mRoomLabel, mParticipantsLabel, mRemoteComposing;
|
private TextView mRoomLabel, mParticipantsLabel, mRemoteComposing;
|
||||||
private EditText mMessageTextToSend;
|
private EditText mMessageTextToSend;
|
||||||
private LayoutInflater mInflater;
|
private LayoutInflater mInflater;
|
||||||
private ListView mChatEventsList;
|
private RecyclerView mChatEventsList;
|
||||||
private LinearLayout mFilesUploadLayout;
|
private LinearLayout mFilesUploadLayout;
|
||||||
private ListSelectionHelper mSelectionHelper;
|
private SelectableHelper mSelectionHelper;
|
||||||
// private ListSelectionHelper mSelectionHelper;
|
private Context mContext;
|
||||||
|
|
||||||
private ViewTreeObserver.OnGlobalLayoutListener mKeyboardListener;
|
private ViewTreeObserver.OnGlobalLayoutListener mKeyboardListener;
|
||||||
private Uri mImageToUploadUri;
|
private Uri mImageToUploadUri;
|
||||||
private ChatEventsAdapter mEventsAdapter;
|
private ChatEventsAdapter mEventsAdapter;
|
||||||
|
@ -105,6 +109,8 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
||||||
private Address mRemoteSipAddress, mRemoteParticipantAddress;
|
private Address mRemoteSipAddress, mRemoteParticipantAddress;
|
||||||
private ChatRoom mChatRoom;
|
private ChatRoom mChatRoom;
|
||||||
private ArrayList<LinphoneContact> mParticipants;
|
private ArrayList<LinphoneContact> mParticipants;
|
||||||
|
private ArrayList<EventLog> mHistory;
|
||||||
|
private LinearLayoutManager layoutManager;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
@ -116,11 +122,14 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
||||||
mRemoteSipUri = getArguments().getString("SipUri");
|
mRemoteSipUri = getArguments().getString("SipUri");
|
||||||
mRemoteSipAddress = LinphoneManager.getLc().createAddress(mRemoteSipUri);
|
mRemoteSipAddress = LinphoneManager.getLc().createAddress(mRemoteSipUri);
|
||||||
}
|
}
|
||||||
|
this.mContext = getActivity().getApplicationContext();
|
||||||
mInflater = inflater;
|
|
||||||
View view = inflater.inflate(R.layout.chat, container, false);
|
View view = inflater.inflate(R.layout.chat, container, false);
|
||||||
|
mChatEventsList = view.findViewById(R.id.chat_message_list);
|
||||||
|
mSelectionHelper = new SelectableHelper(view, this);
|
||||||
|
|
||||||
mSelectionHelper = new ListSelectionHelper(view, this);
|
|
||||||
|
layoutManager = new LinearLayoutManager(mContext);
|
||||||
|
mChatEventsList.setLayoutManager(layoutManager);
|
||||||
|
|
||||||
mBackButton = view.findViewById(R.id.back);
|
mBackButton = view.findViewById(R.id.back);
|
||||||
mBackButton.setOnClickListener(new View.OnClickListener() {
|
mBackButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@ -551,18 +560,26 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
||||||
private void displayChatRoomHistory() {
|
private void displayChatRoomHistory() {
|
||||||
if (mChatRoom == null) return;
|
if (mChatRoom == null) return;
|
||||||
if (mChatRoom.hasCapability(ChatRoomCapabilities.OneToOne.toInt())) {
|
if (mChatRoom.hasCapability(ChatRoomCapabilities.OneToOne.toInt())) {
|
||||||
mEventsAdapter = new ChatEventsAdapter(this, mSelectionHelper, mInflater, mChatRoom.getHistoryMessageEvents(0), mParticipants);
|
EventLog[] history = mChatRoom.getHistoryMessageEvents(0);
|
||||||
|
mHistory = new ArrayList<>(Arrays.asList(history));
|
||||||
|
mEventsAdapter = new ChatEventsAdapter(this, mSelectionHelper, mInflater, mHistory, mParticipants, this);
|
||||||
// mChatRoomsAdapter = new ChatRoomsAdapter(mContext, R.layout.chatlist_cell, mRooms,this, mSelectionHelper);
|
// mChatRoomsAdapter = new ChatRoomsAdapter(mContext, R.layout.chatlist_cell, mRooms,this, mSelectionHelper);
|
||||||
} else {
|
} else {
|
||||||
mEventsAdapter = new ChatEventsAdapter(this, mSelectionHelper, mInflater, mChatRoom.getHistoryEvents(0), mParticipants);
|
EventLog[] history = mChatRoom.getHistoryEvents(0);
|
||||||
|
mHistory = new ArrayList<>(Arrays.asList(history));
|
||||||
|
mEventsAdapter = new ChatEventsAdapter(this, mSelectionHelper, mInflater, mHistory, mParticipants, this);
|
||||||
}
|
}
|
||||||
mSelectionHelper.setAdapter(mEventsAdapter);
|
|
||||||
mChatEventsList.setAdapter(mEventsAdapter);
|
mChatEventsList.setAdapter(mEventsAdapter);
|
||||||
|
mSelectionHelper.setAdapter(mEventsAdapter);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void scrollToBottom() {
|
public void scrollToBottom() {
|
||||||
if (((mChatEventsList.getLastVisiblePosition() >= (mEventsAdapter.getCount() - 1)) && (mChatEventsList.getFirstVisiblePosition() <= (mEventsAdapter.getCount() - 1)))) {
|
if (((layoutManager.findLastVisibleItemPosition() >= (mEventsAdapter.getCount() - 1)) && (layoutManager.findFirstVisibleItemPosition() <= (mEventsAdapter.getCount() - 1)))) {
|
||||||
mChatEventsList.setSelection(mEventsAdapter.getCount() - 1);
|
// if (((mChatEventsList.getLastVisiblePosition() >= (mEventsAdapter.getCount() - 1)) && (mChatEventsList.getFirstVisiblePosition() <= (mEventsAdapter.getCount() - 1)))) {
|
||||||
|
mChatEventsList.getLayoutManager().scrollToPosition(mEventsAdapter.getCount() - 1);
|
||||||
|
// mChatEventsList.setSelection(mEventsAdapter.getCount() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -570,6 +587,20 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
||||||
return mRemoteSipUri;
|
return mRemoteSipUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
*if isEditionEnabled() true, select the message
|
||||||
|
* */
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onItemClicked(int position) {
|
||||||
|
if (mEventsAdapter.isEditionEnabled()) {
|
||||||
|
mEventsAdapter.toggleSelection(position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* File transfer related
|
* File transfer related
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -17,8 +17,8 @@ public abstract class SelectableAdapter<VH extends RecyclerView.ViewHolder> exte
|
||||||
public SelectableAdapter(SelectableHelper helper) {
|
public SelectableAdapter(SelectableHelper helper) {
|
||||||
mSelectedItems = new SparseBooleanArray();
|
mSelectedItems = new SparseBooleanArray();
|
||||||
mListHelper = helper;
|
mListHelper = helper;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private CompoundButton.OnCheckedChangeListener mDeleteCheckboxListener = new CompoundButton.OnCheckedChangeListener() {
|
private CompoundButton.OnCheckedChangeListener mDeleteCheckboxListener = new CompoundButton.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||||
|
|
Loading…
Reference in a new issue