Apply message bubble paddings to both top and bottom

Batch selecting messages now feels better. Fixes #8035.
This commit is contained in:
art1fa 2018-07-23 14:08:45 +02:00 committed by Greyson Parrelli
parent 79830049c4
commit faea8fd2ec
5 changed files with 21 additions and 16 deletions

View File

@ -9,7 +9,7 @@
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="24dp"
android:paddingBottom="16dp"
android:scrollbars="vertical"
android:cacheColorHint="?conversation_background"
android:clipChildren="false"

View File

@ -5,8 +5,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="20dp"
android:paddingBottom="21dp"
android:paddingTop="12dp"
android:paddingBottom="13dp"
android:paddingLeft="28dp"
android:paddingRight="28dp">

View File

@ -37,8 +37,8 @@
<dimen name="conversation_individual_right_gutter">16dp</dimen>
<dimen name="conversation_individual_left_gutter">16dp</dimen>
<dimen name="conversation_group_left_gutter">52dp</dimen>
<dimen name="conversation_vertical_message_spacing_default">16dp</dimen>
<dimen name="conversation_vertical_message_spacing_collapse">2dp</dimen>
<dimen name="conversation_vertical_message_spacing_default">8dp</dimen>
<dimen name="conversation_vertical_message_spacing_collapse">1dp</dimen>
<dimen name="quote_corner_radius_large">10dp</dimen>
<dimen name="quote_corner_radius_bottom">4dp</dimen>

View File

@ -215,7 +215,7 @@ public class ConversationItem extends LinearLayout
setGroupMessageStatus(messageRecord, recipient);
setAuthor(messageRecord, previousMessageRecord, nextMessageRecord, groupThread);
setQuote(messageRecord, previousMessageRecord, nextMessageRecord, groupThread);
setMessageSpacing(context, messageRecord, nextMessageRecord);
setMessageSpacing(context, messageRecord, previousMessageRecord, nextMessageRecord, groupThread);
setFooter(messageRecord, nextMessageRecord, locale, groupThread);
}
@ -771,19 +771,20 @@ public class ConversationItem extends LinearLayout
return isStartOfMessageCluster(current, previous, isGroupThread) && isEndOfMessageCluster(current, next, isGroupThread);
}
private void setMessageSpacing(@NonNull Context context, @NonNull MessageRecord current, @NonNull Optional<MessageRecord> next) {
int spacing = readDimen(context, R.dimen.conversation_vertical_message_spacing_collapse);
private void setMessageSpacing(@NonNull Context context, @NonNull MessageRecord current, @NonNull Optional<MessageRecord> previous, @NonNull Optional<MessageRecord> next, boolean isGroupThread) {
int spacingTop = readDimen(context, R.dimen.conversation_vertical_message_spacing_collapse);
int spacingBottom = spacingTop;
if (next.isPresent()) {
boolean recipientsMatch = current.getRecipient().getAddress().equals(next.get().getRecipient().getAddress());
boolean outgoingMatch = current.isOutgoing() == next.get().isOutgoing();
if (!recipientsMatch || !outgoingMatch) {
spacing = readDimen(context, R.dimen.conversation_vertical_message_spacing_default);
}
if (isStartOfMessageCluster(current, previous, isGroupThread)) {
spacingTop = readDimen(context, R.dimen.conversation_vertical_message_spacing_default);
}
ViewUtil.setPaddingBottom(this, spacing);
if (isEndOfMessageCluster(current, next, isGroupThread)) {
spacingBottom = readDimen(context, R.dimen.conversation_vertical_message_spacing_default);
}
ViewUtil.setPaddingTop(this, spacingTop);
ViewUtil.setPaddingBottom(this, spacingBottom);
}
private int readDimen(@NonNull Context context, @DimenRes int dimenId) {

View File

@ -233,6 +233,10 @@ public class ViewUtil {
view.requestLayout();
}
public static void setPaddingTop(@NonNull View view, int padding) {
view.setPadding(view.getPaddingLeft(), padding, view.getPaddingRight(), view.getPaddingBottom());
}
public static void setPaddingBottom(@NonNull View view, int padding) {
view.setPadding(view.getPaddingLeft(), view.getPaddingTop(), view.getPaddingRight(), padding);
}