Added reduced space between messages from same person

This commit is contained in:
Sylvain Berfini 2018-07-18 17:10:13 +02:00 committed by Erwan Croze
parent ea8fd78d34
commit aa2cf3da4a
5 changed files with 44 additions and 18 deletions

View file

@ -188,17 +188,17 @@
<ListView
android:id="@+id/chat_message_list"
android:divider="@android:color/transparent"
android:choiceMode="multipleChoice"
android:stackFromBottom="true"
android:transcriptMode="normal"
android:cacheColorHint="@color/transparent"
android:listSelector="@color/transparent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:layout_above="@id/footer"
android:layout_below="@+id/view"
android:layout_margin="10dp"
android:cacheColorHint="@color/transparent"
android:choiceMode="multipleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="10dp"
android:listSelector="@color/transparent"
android:stackFromBottom="true"
android:transcriptMode="normal"/>
android:layout_below="@+id/view"/>
</RelativeLayout>

View file

@ -17,9 +17,10 @@
android:id="@+id/event"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/delete_message"
android:gravity="center_vertical"
android:orientation="horizontal">
android:layout_toLeftOf="@id/delete_message"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:gravity="center_vertical">
<ImageView
android:layout_width="match_parent"
@ -111,6 +112,11 @@
android:textColor="#595959"
android:textSize="13.3sp"
android:textStyle="bold"/>
<LinearLayout
android:id="@+id/separator"
android:layout_width="100dp"
android:layout_height="10dp"
android:orientation="horizontal"/>
<RelativeLayout
android:layout_width="wrap_content"

View file

@ -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;
@ -68,6 +69,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);

View file

@ -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(200, 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(200, 10, 10, 10);
layoutParams.setMargins(SIDE_MARGIN, MARGIN_BETWEEN_MESSAGES/2, 0, MARGIN_BETWEEN_MESSAGES/2);
}
holder.background.setBackgroundColor(0x26ff6600);
@ -275,10 +293,10 @@ public class ChatEventsAdapter extends ListSelectionAdapter {
if (isEditionEnabled()) {
layoutParams.addRule(RelativeLayout.LEFT_OF, holder.delete.getId());
layoutParams.setMargins(200, 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, 200, 10);
layoutParams.setMargins(0, MARGIN_BETWEEN_MESSAGES/2, SIDE_MARGIN, MARGIN_BETWEEN_MESSAGES/2);
}
holder.background.setBackgroundColor(0x19595959);

View file

@ -511,7 +511,7 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
getContactsForParticipants();
mRemoteComposing.setVisibility(View.INVISIBLE);
mRemoteComposing.setVisibility(View.GONE);
}
private void displayChatRoomHeader() {