Started edition of messages/events in chat room view

This commit is contained in:
Sylvain Berfini 2017-11-02 17:54:39 +01:00
parent 1661d689aa
commit 975717df05
6 changed files with 135 additions and 133 deletions

View file

@ -4,6 +4,11 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/colorH" > android:background="@color/colorH" >
<RelativeLayout
android:id="@+id/top"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout <LinearLayout
android:id="@+id/top_bar" android:id="@+id/top_bar"
android:orientation="horizontal" android:orientation="horizontal"
@ -91,6 +96,8 @@
<include layout="@layout/edit_list"/> <include layout="@layout/edit_list"/>
</RelativeLayout>
<LinearLayout <LinearLayout
android:id="@+id/footer" android:id="@+id/footer"
android:background="@color/colorF" android:background="@color/colorF"
@ -177,32 +184,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_margin="10dp" android:layout_margin="10dp"
android:layout_below="@+id/top_bar"/> android:layout_below="@+id/top"/>
<EditText
android:id="@+id/search_contact_field"
android:contentDescription="@string/content_description_search"
android:textCursorDrawable="@null"
android:layout_width="match_parent"
android:layout_height="40dp"
android:visibility="gone"
android:textColor="@android:color/black"
android:background="@drawable/resizable_textfield"
android:layout_margin="5dp"
android:layout_below="@id/top_bar"
android:inputType="textPersonName"/>
<ListView
android:id="@+id/result_contacts"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@color/colorE"
android:visibility="gone"
android:layout_below="@id/search_contact_field"
android:fastScrollAlwaysVisible="true"
android:fastScrollEnabled="true"
android:dividerHeight="1dp"
android:layout_above="@+id/footer"/>
</RelativeLayout> </RelativeLayout>

View file

@ -3,11 +3,22 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<CheckBox
android:id="@+id/delete_message"
android:button="@drawable/checkbox"
android:contentDescription="@string/content_description_delete"
android:layout_marginLeft="5dp"
android:layout_width="30dp"
android:layout_height="30dp"
android:adjustViewBounds="true"
android:layout_alignParentRight="true"/>
<LinearLayout <LinearLayout
android:id="@+id/event" android:id="@+id/event"
android:orientation="horizontal" android:orientation="horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_toLeftOf="@id/delete_message"
android:gravity="center_vertical"> android:gravity="center_vertical">
<ImageView <ImageView
@ -47,26 +58,13 @@
<RelativeLayout <RelativeLayout
android:id="@+id/bubble" android:id="@+id/bubble"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:layout_toLeftOf="@id/delete_message">
<CheckBox
android:id="@+id/delete_message"
android:button="@drawable/checkbox"
android:contentDescription="@string/content_description_delete"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_width="30dp"
android:layout_height="30dp"
android:adjustViewBounds="true"
android:layout_alignParentRight="true"
android:visibility="gone"/>
<LinearLayout <LinearLayout
android:id="@+id/background" android:id="@+id/background"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_toLeftOf="@id/delete_message"
android:orientation="horizontal"> android:orientation="horizontal">
<RelativeLayout <RelativeLayout

View file

@ -285,7 +285,7 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
//LinphoneActivity.instance().displayChat(contactsSelected.get(0).getAddress(), "", ""); //LinphoneActivity.instance().displayChat(contactsSelected.get(0).getAddress(), "", "");
//TODO create group chat room with only two participants ? //TODO create group chat room with only two participants ?
//TODO what subject to set ? //TODO what subject to set ?
ChatRoom chatRoom = LinphoneManager.getLc().createClientGroupChatRoom("Tata"); ChatRoom chatRoom = LinphoneManager.getLc().createClientGroupChatRoom("dummy subject");
chatRoom.setListener(new ChatRoomListenerStub() { chatRoom.setListener(new ChatRoomListenerStub() {
@Override @Override
public void onStateChanged(ChatRoom cr, ChatRoom.State newState) { public void onStateChanged(ChatRoom cr, ChatRoom.State newState) {

View file

@ -79,6 +79,7 @@ public class ChatEventsAdapter extends BaseAdapter implements ChatMessageListene
private List<LinphoneContact> mParticipants; private List<LinphoneContact> mParticipants;
private LayoutInflater mLayoutInflater; private LayoutInflater mLayoutInflater;
private Bitmap mDefaultBitmap; private Bitmap mDefaultBitmap;
private boolean mIsEditionEnabled;
public ChatEventsAdapter(Context context, GroupChatFragment fragment, LayoutInflater inflater, EventLog[] history, ArrayList<LinphoneContact> participants) { public ChatEventsAdapter(Context context, GroupChatFragment fragment, LayoutInflater inflater, EventLog[] history, ArrayList<LinphoneContact> participants) {
mContext = context; mContext = context;
@ -86,6 +87,7 @@ public class ChatEventsAdapter extends BaseAdapter implements ChatMessageListene
mLayoutInflater = inflater; mLayoutInflater = inflater;
mHistory = new ArrayList<>(Arrays.asList(history)); mHistory = new ArrayList<>(Arrays.asList(history));
mParticipants = participants; mParticipants = participants;
mIsEditionEnabled = false;
} }
public void updateHistory(EventLog[] history) { public void updateHistory(EventLog[] history) {
@ -102,6 +104,11 @@ public class ChatEventsAdapter extends BaseAdapter implements ChatMessageListene
mParticipants = participants; mParticipants = participants;
} }
public void enableEdition(boolean enable) {
mIsEditionEnabled = enable;
notifyDataSetInvalidated();
}
@Override @Override
public int getCount() { public int getCount() {
return mHistory.size(); return mHistory.size();
@ -130,7 +137,7 @@ public class ChatEventsAdapter extends BaseAdapter implements ChatMessageListene
holder.eventLayout.setVisibility(View.GONE); holder.eventLayout.setVisibility(View.GONE);
holder.bubbleLayout.setVisibility(View.GONE); holder.bubbleLayout.setVisibility(View.GONE);
holder.delete.setVisibility(View.GONE); holder.delete.setVisibility(mIsEditionEnabled ? View.VISIBLE : View.GONE);
holder.messageText.setVisibility(View.GONE); holder.messageText.setVisibility(View.GONE);
holder.messageImage.setVisibility(View.GONE); holder.messageImage.setVisibility(View.GONE);
holder.fileTransferLayout.setVisibility(View.GONE); holder.fileTransferLayout.setVisibility(View.GONE);
@ -185,8 +192,14 @@ public class ChatEventsAdapter extends BaseAdapter implements ChatMessageListene
holder.imdmLabel.setTextColor(mContext.getResources().getColor(R.color.colorI)); holder.imdmLabel.setTextColor(mContext.getResources().getColor(R.color.colorI));
} }
if (mIsEditionEnabled) {
layoutParams.addRule(RelativeLayout.LEFT_OF, holder.delete.getId());
layoutParams.setMargins(100, 10, 10, 10);
} else {
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
layoutParams.setMargins(100, 10, 10, 10); layoutParams.setMargins(100, 10, 10, 10);
}
holder.background.setBackgroundResource(R.drawable.resizable_chat_bubble_outgoing); holder.background.setBackgroundResource(R.drawable.resizable_chat_bubble_outgoing);
Compatibility.setTextAppearance(holder.contactName, mContext, R.style.font3); Compatibility.setTextAppearance(holder.contactName, mContext, R.style.font3);
Compatibility.setTextAppearance(holder.fileTransferAction, mContext, R.style.font15); Compatibility.setTextAppearance(holder.fileTransferAction, mContext, R.style.font15);
@ -216,12 +229,13 @@ public class ChatEventsAdapter extends BaseAdapter implements ChatMessageListene
holder.contactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap()); holder.contactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
} }
/*if (isEditMode) { if (mIsEditionEnabled) {
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); layoutParams.addRule(RelativeLayout.LEFT_OF, holder.delete.getId());
layoutParams.setMargins(100, 10, 10, 10); layoutParams.setMargins(100, 10, 10, 10);
}*/ } else {
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
layoutParams.setMargins(10, 10, 100, 10); layoutParams.setMargins(10, 10, 100, 10);
}
holder.background.setBackgroundResource(R.drawable.resizable_chat_bubble_incoming); holder.background.setBackgroundResource(R.drawable.resizable_chat_bubble_incoming);
Compatibility.setTextAppearance(holder.contactName, mContext, R.style.font9); Compatibility.setTextAppearance(holder.contactName, mContext, R.style.font9);

View file

@ -185,8 +185,8 @@ public class ChatFragment extends Fragment implements OnClickListener, ChatMessa
contactName = (TextView) view.findViewById(R.id.contact_name); contactName = (TextView) view.findViewById(R.id.contact_name);
messagesList = (ListView) view.findViewById(R.id.chat_message_list); messagesList = (ListView) view.findViewById(R.id.chat_message_list);
searchContactField = (EditText) view.findViewById(R.id.search_contact_field); searchContactField = null;// (EditText) view.findViewById(R.id.search_contact_field);
resultContactsSearch = (ListView) view.findViewById(R.id.result_contacts); resultContactsSearch = null;//(ListView) view.findViewById(R.id.result_contacts);
editList = (LinearLayout) view.findViewById(R.id.edit_list); editList = (LinearLayout) view.findViewById(R.id.edit_list);
topBar = (LinearLayout) view.findViewById(R.id.top_bar); topBar = (LinearLayout) view.findViewById(R.id.top_bar);

View file

@ -45,6 +45,7 @@ import android.widget.EditText;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.ListView; import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import org.linphone.LinphoneManager; import org.linphone.LinphoneManager;
@ -87,6 +88,7 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
private LayoutInflater mInflater; private LayoutInflater mInflater;
private ListView mChatEventsList; private ListView mChatEventsList;
private LinearLayout mFilesUploadLayout; private LinearLayout mFilesUploadLayout;
private LinearLayout mTopBar, mEditTopBar;
private ViewTreeObserver.OnGlobalLayoutListener mKeyboardListener; private ViewTreeObserver.OnGlobalLayoutListener mKeyboardListener;
private Uri mImageToUploadUri; private Uri mImageToUploadUri;
@ -110,6 +112,9 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
mInflater = inflater; mInflater = inflater;
View view = inflater.inflate(R.layout.chat, container, false); View view = inflater.inflate(R.layout.chat, container, false);
mTopBar = view.findViewById(R.id.top_bar);
mEditTopBar = view.findViewById(R.id.edit_list);
mBackButton = view.findViewById(R.id.back); mBackButton = view.findViewById(R.id.back);
mBackButton.setOnClickListener(new View.OnClickListener() { mBackButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -159,7 +164,9 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
mEditButton.setOnClickListener(new View.OnClickListener() { mEditButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
//TODO mEventsAdapter.enableEdition(true);
mTopBar.setVisibility(View.GONE);
mEditTopBar.setVisibility(View.VISIBLE);
} }
}); });
@ -167,7 +174,9 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
mCancelEditButton.setOnClickListener(new View.OnClickListener() { mCancelEditButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
//TODO mEventsAdapter.enableEdition(false);
mTopBar.setVisibility(View.VISIBLE);
mEditTopBar.setVisibility(View.GONE);
} }
}); });