Added reduced space between messages from same person
This commit is contained in:
parent
8f28583e9b
commit
7a33c85a1f
5 changed files with 38 additions and 9 deletions
|
@ -179,13 +179,13 @@
|
|||
android:choiceMode="multipleChoice"
|
||||
android:stackFromBottom="true"
|
||||
android:transcriptMode="normal"
|
||||
android:dividerHeight="10dp"
|
||||
android:cacheColorHint="@color/transparent"
|
||||
android:listSelector="@color/transparent"
|
||||
android:listSelector="@color/transparent"
|
||||
android:layout_above="@id/remote_composing"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_below="@+id/top"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toLeftOf="@id/delete_message"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<ImageView
|
||||
|
@ -61,10 +63,17 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_toLeftOf="@id/delete_message">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/separator"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="10dp"
|
||||
android:orientation="horizontal"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/background"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/separator"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RelativeLayout
|
||||
|
|
|
@ -38,6 +38,7 @@ public class ChatBubbleViewHolder {
|
|||
public TextView eventMessage;
|
||||
|
||||
public RelativeLayout bubbleLayout;
|
||||
public LinearLayout separatorLayout;
|
||||
public LinearLayout background;
|
||||
public ImageView contactPicture;
|
||||
public ImageView contactPictureMask;
|
||||
|
@ -67,6 +68,7 @@ public class ChatBubbleViewHolder {
|
|||
eventMessage = view.findViewById(R.id.event_text);
|
||||
|
||||
bubbleLayout = view.findViewById(R.id.bubble);
|
||||
separatorLayout = view.findViewById(R.id.separator);
|
||||
background = view.findViewById(R.id.background);
|
||||
contactPicture = view.findViewById(R.id.contact_picture);
|
||||
contactPictureMask = view.findViewById(R.id.mask);
|
||||
|
|
|
@ -56,6 +56,7 @@ import org.linphone.core.Address;
|
|||
import org.linphone.core.ChatMessage;
|
||||
import org.linphone.core.ChatMessageListenerStub;
|
||||
import org.linphone.core.Content;
|
||||
import org.linphone.core.Event;
|
||||
import org.linphone.core.EventLog;
|
||||
import org.linphone.core.LimeState;
|
||||
import org.linphone.mediastream.Log;
|
||||
|
@ -73,6 +74,9 @@ import java.util.List;
|
|||
import static android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION;
|
||||
|
||||
public class ChatEventsAdapter extends ListSelectionAdapter {
|
||||
private static int MARGIN_BETWEEN_MESSAGES = 10;
|
||||
private static int SIDE_MARGIN = 100;
|
||||
|
||||
private Context mContext;
|
||||
private List<EventLog> mHistory;
|
||||
private List<LinphoneContact> mParticipants;
|
||||
|
@ -177,6 +181,7 @@ public class ChatEventsAdapter extends ListSelectionAdapter {
|
|||
|
||||
holder.eventLayout.setVisibility(View.GONE);
|
||||
holder.bubbleLayout.setVisibility(View.GONE);
|
||||
holder.separatorLayout.setVisibility(i == 0 ? View.GONE : View.VISIBLE); // Hide separator if first item in list
|
||||
holder.delete.setVisibility(isEditionEnabled() ? View.VISIBLE : View.GONE);
|
||||
holder.messageText.setVisibility(View.GONE);
|
||||
holder.messageImage.setVisibility(View.GONE);
|
||||
|
@ -200,8 +205,21 @@ public class ChatEventsAdapter extends ListSelectionAdapter {
|
|||
EventLog event = (EventLog)getItem(i);
|
||||
if (event.getType() == EventLog.Type.ConferenceChatMessage) {
|
||||
holder.bubbleLayout.setVisibility(View.VISIBLE);
|
||||
|
||||
final ChatMessage message = event.getChatMessage();
|
||||
|
||||
if (i > 0) {
|
||||
EventLog previousEvent = (EventLog)getItem(i-1);
|
||||
if (previousEvent.getType() == EventLog.Type.ConferenceChatMessage) {
|
||||
ChatMessage previousMessage = previousEvent.getChatMessage();
|
||||
if (previousMessage.getFromAddress().weakEqual(message.getFromAddress())) {
|
||||
holder.separatorLayout.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
// No separator if previous event is not a message
|
||||
holder.separatorLayout.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
holder.messageId = message.getMessageId();
|
||||
message.setUserData(holder);
|
||||
|
||||
|
@ -253,10 +271,10 @@ public class ChatEventsAdapter extends ListSelectionAdapter {
|
|||
|
||||
if (isEditionEnabled()) {
|
||||
layoutParams.addRule(RelativeLayout.LEFT_OF, holder.delete.getId());
|
||||
layoutParams.setMargins(100, 10, 10, 10);
|
||||
layoutParams.setMargins(SIDE_MARGIN, MARGIN_BETWEEN_MESSAGES/2, 0, MARGIN_BETWEEN_MESSAGES/2);
|
||||
} else {
|
||||
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
||||
layoutParams.setMargins(100, 10, 10, 10);
|
||||
layoutParams.setMargins(SIDE_MARGIN, MARGIN_BETWEEN_MESSAGES/2, 0, MARGIN_BETWEEN_MESSAGES/2);
|
||||
}
|
||||
|
||||
holder.background.setBackgroundResource(R.drawable.resizable_chat_bubble_outgoing);
|
||||
|
@ -274,10 +292,10 @@ public class ChatEventsAdapter extends ListSelectionAdapter {
|
|||
|
||||
if (isEditionEnabled()) {
|
||||
layoutParams.addRule(RelativeLayout.LEFT_OF, holder.delete.getId());
|
||||
layoutParams.setMargins(100, 10, 10, 10);
|
||||
layoutParams.setMargins(SIDE_MARGIN, MARGIN_BETWEEN_MESSAGES/2, 0, MARGIN_BETWEEN_MESSAGES/2);
|
||||
} else {
|
||||
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
|
||||
layoutParams.setMargins(10, 10, 100, 10);
|
||||
layoutParams.setMargins(0, MARGIN_BETWEEN_MESSAGES/2, SIDE_MARGIN, MARGIN_BETWEEN_MESSAGES/2);
|
||||
}
|
||||
|
||||
holder.background.setBackgroundResource(R.drawable.resizable_chat_bubble_incoming);
|
||||
|
|
|
@ -511,7 +511,7 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
|||
|
||||
getContactsForParticipants();
|
||||
|
||||
mRemoteComposing.setVisibility(View.INVISIBLE);
|
||||
mRemoteComposing.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private void displayChatRoomHeader() {
|
||||
|
|
Loading…
Reference in a new issue