Use context menu to go to message's IDMN view instead of clicking on delivery state + improved IMDN view to display incoming messages state as well
This commit is contained in:
parent
c0359eabd8
commit
7e613d5401
5 changed files with 74 additions and 18 deletions
14
res/menu/chat_bubble_menu.xml
Normal file
14
res/menu/chat_bubble_menu.xml
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<item android:id="@+id/copy_text"
|
||||||
|
android:title="@string/copy_text" />
|
||||||
|
|
||||||
|
<item android:id="@+id/imdn_infos"
|
||||||
|
android:title="@string/imdn_info" />
|
||||||
|
|
||||||
|
<item android:id="@+id/delete_message"
|
||||||
|
android:title="@string/delete" />
|
||||||
|
|
||||||
|
</menu>
|
|
@ -220,6 +220,7 @@
|
||||||
<string name="chat_room_leave_button">Leave</string>
|
<string name="chat_room_leave_button">Leave</string>
|
||||||
<string name="chat_room_delete_dialog">Do you want to delete and leave the selected conversations?</string>
|
<string name="chat_room_delete_dialog">Do you want to delete and leave the selected conversations?</string>
|
||||||
<string name="separator">: </string>
|
<string name="separator">: </string>
|
||||||
|
<string name="imdn_info">Infos</string>
|
||||||
|
|
||||||
<!-- Status Bar -->
|
<!-- Status Bar -->
|
||||||
<string name="status_connected">Registered</string>
|
<string name="status_connected">Registered</string>
|
||||||
|
|
|
@ -252,12 +252,6 @@ public class ChatEventsAdapter extends ListSelectionAdapter {
|
||||||
holder.imdmLabel.setText(R.string.file_transfer_error);
|
holder.imdmLabel.setText(R.string.file_transfer_error);
|
||||||
holder.imdmLabel.setTextColor(mContext.getResources().getColor(R.color.colorI));
|
holder.imdmLabel.setTextColor(mContext.getResources().getColor(R.color.colorI));
|
||||||
}
|
}
|
||||||
holder.imdmLayout.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
LinphoneActivity.instance().goToChatMessageImdnInfos(mFragment.getRemoteSipUri(), message.getMessageId());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (isEditionEnabled()) {
|
if (isEditionEnabled()) {
|
||||||
layoutParams.addRule(RelativeLayout.LEFT_OF, holder.delete.getId());
|
layoutParams.addRule(RelativeLayout.LEFT_OF, holder.delete.getId());
|
||||||
|
|
|
@ -33,12 +33,16 @@ import android.os.Parcelable;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
|
import android.view.ContextMenu;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewTreeObserver;
|
import android.view.ViewTreeObserver;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
import android.widget.AdapterView;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
@ -62,6 +66,7 @@ import org.linphone.core.ChatRoomCapabilities;
|
||||||
import org.linphone.core.ChatRoomListener;
|
import org.linphone.core.ChatRoomListener;
|
||||||
import org.linphone.core.Content;
|
import org.linphone.core.Content;
|
||||||
import org.linphone.core.Core;
|
import org.linphone.core.Core;
|
||||||
|
import org.linphone.core.Event;
|
||||||
import org.linphone.core.EventLog;
|
import org.linphone.core.EventLog;
|
||||||
import org.linphone.core.Factory;
|
import org.linphone.core.Factory;
|
||||||
import org.linphone.core.LimeState;
|
import org.linphone.core.LimeState;
|
||||||
|
@ -206,6 +211,7 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
||||||
mRemoteComposing = view.findViewById(R.id.remote_composing);
|
mRemoteComposing = view.findViewById(R.id.remote_composing);
|
||||||
|
|
||||||
mChatEventsList = view.findViewById(R.id.chat_message_list);
|
mChatEventsList = view.findViewById(R.id.chat_message_list);
|
||||||
|
registerForContextMenu(mChatEventsList);
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
@ -320,6 +326,38 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
|
||||||
|
super.onCreateContextMenu(menu, v, menuInfo);
|
||||||
|
MenuInflater inflater = getActivity().getMenuInflater();
|
||||||
|
inflater.inflate(R.menu.chat_bubble_menu, menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onContextItemSelected(MenuItem item) {
|
||||||
|
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
|
||||||
|
|
||||||
|
EventLog event = (EventLog) mEventsAdapter.getItem(info.position);
|
||||||
|
if (event.getType() != EventLog.Type.ConferenceChatMessage) {
|
||||||
|
return super.onContextItemSelected(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
ChatMessage message = event.getChatMessage();
|
||||||
|
String messageId = message.getMessageId();
|
||||||
|
|
||||||
|
switch(item.getItemId()) {
|
||||||
|
case R.id.imdn_infos:
|
||||||
|
LinphoneActivity.instance().goToChatMessageImdnInfos(getRemoteSipUri(), messageId);
|
||||||
|
return true;
|
||||||
|
case R.id.copy_text:
|
||||||
|
return true;
|
||||||
|
case R.id.delete_message:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return super.onContextItemSelected(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keyboard management
|
* Keyboard management
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -111,16 +111,25 @@ public class ImdnFragment extends Fragment {
|
||||||
mBubble.imdmLayout.setVisibility(View.INVISIBLE);
|
mBubble.imdmLayout.setVisibility(View.INVISIBLE);
|
||||||
mBubble.contactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
mBubble.contactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
||||||
|
|
||||||
|
ChatMessage message = mRoom.findMessage(mMessageId);
|
||||||
|
|
||||||
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
|
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
|
||||||
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
||||||
layoutParams.setMargins(100, 10, 10, 10);
|
layoutParams.setMargins(100, 10, 10, 10);
|
||||||
mBubble.background.setBackgroundResource(R.drawable.resizable_chat_bubble_outgoing);
|
if (message.isOutgoing()) {
|
||||||
Compatibility.setTextAppearance(mBubble.contactName, getActivity(), R.style.font3);
|
mBubble.background.setBackgroundResource(R.drawable.resizable_chat_bubble_outgoing);
|
||||||
Compatibility.setTextAppearance(mBubble.fileTransferAction, getActivity(), R.style.font15);
|
Compatibility.setTextAppearance(mBubble.contactName, getActivity(), R.style.font3);
|
||||||
mBubble.fileTransferAction.setBackgroundResource(R.drawable.resizable_confirm_delete_button);
|
Compatibility.setTextAppearance(mBubble.fileTransferAction, getActivity(), R.style.font15);
|
||||||
mBubble.contactPictureMask.setImageResource(R.drawable.avatar_chat_mask_outgoing);
|
mBubble.fileTransferAction.setBackgroundResource(R.drawable.resizable_confirm_delete_button);
|
||||||
|
mBubble.contactPictureMask.setImageResource(R.drawable.avatar_chat_mask_outgoing);
|
||||||
|
} else {
|
||||||
|
mBubble.background.setBackgroundResource(R.drawable.resizable_chat_bubble_incoming);
|
||||||
|
Compatibility.setTextAppearance(mBubble.contactName, getActivity(), R.style.font9);
|
||||||
|
Compatibility.setTextAppearance(mBubble.fileTransferAction, getActivity(), R.style.font8);
|
||||||
|
mBubble.fileTransferAction.setBackgroundResource(R.drawable.resizable_assistant_button);
|
||||||
|
mBubble.contactPictureMask.setImageResource(R.drawable.avatar_chat_mask);
|
||||||
|
}
|
||||||
|
|
||||||
ChatMessage message = mRoom.findMessage(mMessageId);
|
|
||||||
Address remoteSender = message.getFromAddress();
|
Address remoteSender = message.getFromAddress();
|
||||||
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(remoteSender);
|
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(remoteSender);
|
||||||
String displayName;
|
String displayName;
|
||||||
|
@ -134,7 +143,7 @@ public class ImdnFragment extends Fragment {
|
||||||
|
|
||||||
mBubble.contactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
mBubble.contactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
||||||
if (contact.hasPhoto()) {
|
if (contact.hasPhoto()) {
|
||||||
LinphoneUtils.setThumbnailPictureFromUri(LinphoneActivity.instance(), mBubble.contactPicture, contact.getThumbnailUri());
|
LinphoneUtils.setThumbnailPictureFromUri(getActivity(), mBubble.contactPicture, contact.getThumbnailUri());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
displayName = LinphoneUtils.getAddressDisplayName(remoteSender);
|
displayName = LinphoneUtils.getAddressDisplayName(remoteSender);
|
||||||
|
@ -167,10 +176,10 @@ public class ImdnFragment extends Fragment {
|
||||||
|
|
||||||
View v = mInflater.inflate(R.layout.chat_imdn_cell, container, false);
|
View v = mInflater.inflate(R.layout.chat_imdn_cell, container, false);
|
||||||
v.findViewById(R.id.separator).setVisibility(first ? View.GONE : View.VISIBLE);
|
v.findViewById(R.id.separator).setVisibility(first ? View.GONE : View.VISIBLE);
|
||||||
((TextView)v.findViewById(R.id.time)).setText(LinphoneUtils.timestampToHumanDate(LinphoneActivity.instance(), participant.getStateChangeTime(), R.string.messages_date_format));
|
((TextView)v.findViewById(R.id.time)).setText(LinphoneUtils.timestampToHumanDate(getActivity(), participant.getStateChangeTime(), R.string.messages_date_format));
|
||||||
((TextView)v.findViewById(R.id.name)).setText(participantDisplayName);
|
((TextView)v.findViewById(R.id.name)).setText(participantDisplayName);
|
||||||
if (participantContact.hasPhoto()) {
|
if (participantContact.hasPhoto()) {
|
||||||
LinphoneUtils.setThumbnailPictureFromUri(LinphoneActivity.instance(), ((ImageView)v.findViewById(R.id.contact_picture)), participantContact.getThumbnailUri());
|
LinphoneUtils.setThumbnailPictureFromUri(getActivity(), ((ImageView)v.findViewById(R.id.contact_picture)), participantContact.getThumbnailUri());
|
||||||
} else {
|
} else {
|
||||||
((ImageView)v.findViewById(R.id.contact_picture)).setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
((ImageView)v.findViewById(R.id.contact_picture)).setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
||||||
}
|
}
|
||||||
|
@ -189,10 +198,10 @@ public class ImdnFragment extends Fragment {
|
||||||
|
|
||||||
View v = mInflater.inflate(R.layout.chat_imdn_cell, container, false);
|
View v = mInflater.inflate(R.layout.chat_imdn_cell, container, false);
|
||||||
v.findViewById(R.id.separator).setVisibility(first ? View.GONE : View.VISIBLE);
|
v.findViewById(R.id.separator).setVisibility(first ? View.GONE : View.VISIBLE);
|
||||||
((TextView)v.findViewById(R.id.time)).setText(LinphoneUtils.timestampToHumanDate(LinphoneActivity.instance(), participant.getStateChangeTime(), R.string.messages_date_format));
|
((TextView)v.findViewById(R.id.time)).setText(LinphoneUtils.timestampToHumanDate(getActivity(), participant.getStateChangeTime(), R.string.messages_date_format));
|
||||||
((TextView)v.findViewById(R.id.name)).setText(participantDisplayName);
|
((TextView)v.findViewById(R.id.name)).setText(participantDisplayName);
|
||||||
if (participantContact.hasPhoto()) {
|
if (participantContact.hasPhoto()) {
|
||||||
LinphoneUtils.setThumbnailPictureFromUri(LinphoneActivity.instance(), ((ImageView)v.findViewById(R.id.contact_picture)), participantContact.getThumbnailUri());
|
LinphoneUtils.setThumbnailPictureFromUri(getActivity(), ((ImageView)v.findViewById(R.id.contact_picture)), participantContact.getThumbnailUri());
|
||||||
} else {
|
} else {
|
||||||
((ImageView)v.findViewById(R.id.contact_picture)).setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
((ImageView)v.findViewById(R.id.contact_picture)).setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
||||||
}
|
}
|
||||||
|
@ -213,7 +222,7 @@ public class ImdnFragment extends Fragment {
|
||||||
v.findViewById(R.id.separator).setVisibility(first ? View.GONE : View.VISIBLE);
|
v.findViewById(R.id.separator).setVisibility(first ? View.GONE : View.VISIBLE);
|
||||||
((TextView)v.findViewById(R.id.name)).setText(participantDisplayName);
|
((TextView)v.findViewById(R.id.name)).setText(participantDisplayName);
|
||||||
if (participantContact.hasPhoto()) {
|
if (participantContact.hasPhoto()) {
|
||||||
LinphoneUtils.setThumbnailPictureFromUri(LinphoneActivity.instance(), ((ImageView)v.findViewById(R.id.contact_picture)), participantContact.getThumbnailUri());
|
LinphoneUtils.setThumbnailPictureFromUri(getActivity(), ((ImageView)v.findViewById(R.id.contact_picture)), participantContact.getThumbnailUri());
|
||||||
} else {
|
} else {
|
||||||
((ImageView)v.findViewById(R.id.contact_picture)).setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
((ImageView)v.findViewById(R.id.contact_picture)).setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue