Fix alignment issues for single line timestamps.

fork-5.53.8
Lucio Maciel 2021-08-16 18:56:06 -03:00 zatwierdzone przez Greyson Parrelli
rodzic 31e0f3edfb
commit 0599f76ed5
7 zmienionych plików z 43 dodań i 30 usunięć

Wyświetl plik

@ -215,6 +215,10 @@ public class ConversationItemFooter extends ConstraintLayout {
}
}
public TextView getDateView() {
return dateView;
}
private void notifyTouchDelegateChanged(@NonNull Rect rect, @NonNull View touchDelegate) {
if (onTouchDelegateChangedListener != null) {
onTouchDelegateChangedListener.onTouchDelegateChanged(rect, touchDelegate);

Wyświetl plik

@ -24,6 +24,7 @@ import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.Typeface;
@ -387,40 +388,46 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
}
}
int defaultMargin = readDimen(R.dimen.message_bubble_default_footer_bottom_margin);
if (!updatingFooter &&
!isCaptionlessMms(messageRecord) &&
!isViewOnceMessage(messageRecord) &&
isFooterVisible(messageRecord, nextMessageRecord, groupThread) &&
bodyText.getLastLineWidth() > 0)
{
int footerWidth = footer.getMeasuredWidth();
int availableWidth = getAvailableMessageBubbleWidth(bodyText);
TextView dateView = footer.getDateView();
int footerWidth = footer.getMeasuredWidth();
int availableWidth = getAvailableMessageBubbleWidth(bodyText);
int bottomDiff = (int) (bodyText.getPaint().getFontMetrics().bottom - dateView.getPaint().getFontMetrics().bottom);
int topMargin = -1 * (dateView.getMeasuredHeight() + ViewUtil.dpToPx(7) + bottomDiff) + 1;
if (bodyText.isSingleLine()) {
int maxBubbleWidth = hasBigImageLinkPreview(messageRecord) || hasThumbnail(messageRecord) ? readDimen(R.dimen.media_bubble_max_width) : getMaxBubbleWidth();
int bodyMargins = ViewUtil.getLeftMargin(bodyText) + ViewUtil.getRightMargin(bodyText);
int sizeWithMargins = bodyText.getMeasuredWidth() + ViewUtil.dpToPx(6) + footerWidth + bodyMargins;
int minSize = Math.min(maxBubbleWidth, Math.max(bodyText.getMeasuredWidth() + ViewUtil.dpToPx(6) + footerWidth + bodyMargins, bodyBubble.getMeasuredWidth()));
if (hasQuote(messageRecord) && sizeWithMargins < availableWidth) {
ViewUtil.setTopMargin(footer, readDimen(R.dimen.message_bubble_same_line_footer_bottom_margin));
ViewUtil.setTopMargin(footer, topMargin);
needsMeasure = true;
updatingFooter = true;
} else if (sizeWithMargins != bodyText.getMeasuredWidth() && sizeWithMargins <= minSize) {
bodyBubble.getLayoutParams().width = minSize;
ViewUtil.setTopMargin(footer, readDimen(R.dimen.message_bubble_same_line_footer_bottom_margin));
ViewUtil.setTopMargin(footer, topMargin);
needsMeasure = true;
updatingFooter = true;
}
}
if (!updatingFooter && bodyText.getLastLineWidth() + ViewUtil.dpToPx(6) + footerWidth <= bodyText.getMeasuredWidth()) {
ViewUtil.setTopMargin(footer, readDimen(R.dimen.message_bubble_same_line_footer_bottom_margin));
ViewUtil.setTopMargin(footer, topMargin);
updatingFooter = true;
needsMeasure = true;
} else if (!updatingFooter && ViewUtil.getTopMargin(footer) == readDimen(R.dimen.message_bubble_same_line_footer_bottom_margin)) {
ViewUtil.setTopMargin(footer, readDimen(R.dimen.message_bubble_default_footer_bottom_margin));
needsMeasure = true;
}
}
if (!updatingFooter && ViewUtil.getTopMargin(footer) != defaultMargin) {
ViewUtil.setTopMargin(footer, defaultMargin);
needsMeasure = true;
}
if (hasSharedContact(messageRecord)) {
int contactWidth = sharedContactStub.get().getMeasuredWidth();
int availableWidth = getAvailableMessageBubbleWidth(sharedContactStub.get());

Wyświetl plik

@ -91,18 +91,18 @@ fun MessageRecord.hasBigImageLinkPreview(context: Context): Boolean {
}
fun MessageRecord.isTextOnly(context: Context): Boolean {
return !(
!isMms ||
isViewOnceMessage() ||
hasLinkPreview() ||
hasQuote() ||
hasExtraText() ||
hasDocument() ||
hasThumbnail() ||
hasAudio() ||
hasLocation() ||
hasSharedContact() ||
hasSticker() ||
isCaptionlessMms(context)
)
return !isMms ||
(
!isViewOnceMessage() &&
!hasLinkPreview() &&
!hasQuote() &&
!hasExtraText() &&
!hasDocument() &&
!hasThumbnail() &&
!hasAudio() &&
!hasLocation() &&
!hasSharedContact() &&
!hasSticker() &&
!isCaptionlessMms(context)
)
}

Wyświetl plik

@ -4,6 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout_width="wrap_content"
tools:background="@color/green"
tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout">
@ -54,7 +55,7 @@
app:layout_constraintEnd_toStartOf="@id/footer_expiration_timer"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="3m" />
tools:text="13:14pm" />
<org.thoughtcrime.securesms.components.ExpirationTimerView
android:id="@+id/footer_expiration_timer"
@ -86,9 +87,9 @@
android:visibility="gone"
app:layout_constraintStart_toEndOf="@id/date_and_expiry_wrapper"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/footer_insecure_indicator"
app:layout_constraintTop_toTopOf="parent"
tools:text="Sim Op" />
tools:text="Sim Op"
tools:visibility="visible" />
<ImageView
android:id="@+id/footer_insecure_indicator"
@ -113,7 +114,8 @@
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible" />
<org.thoughtcrime.securesms.components.PlaybackSpeedToggleTextView
android:id="@+id/footer_audio_playback_speed_toggle"

Wyświetl plik

@ -185,7 +185,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/message_bubble_horizontal_padding"
android:layout_marginTop="-4dp"
android:layout_marginTop="-5dp"
android:layout_marginEnd="@dimen/message_bubble_horizontal_padding"
android:layout_marginBottom="@dimen/message_bubble_bottom_padding"
android:layout_gravity="end"
@ -202,7 +202,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/message_bubble_horizontal_padding"
android:layout_marginTop="-5dp"
android:layout_marginTop="2dp"
android:layout_marginBottom="@dimen/message_bubble_bottom_padding"
android:layout_gravity="end"
android:clipChildren="false"

Wyświetl plik

@ -115,7 +115,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/message_bubble_horizontal_padding"
android:layout_marginTop="-4dp"
android:layout_marginTop="-5dp"
android:layout_marginEnd="@dimen/message_bubble_horizontal_padding"
android:layout_marginBottom="@dimen/message_bubble_bottom_padding"
android:layout_gravity="end"

Wyświetl plik

@ -153,7 +153,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginTop="-5dp"
android:layout_marginTop="2dp"
android:layout_marginBottom="@dimen/message_bubble_bottom_padding"
android:clipChildren="false"
android:clipToPadding="false"