kopia lustrzana https://github.com/ryukoposting/Signal-Android
Fix alignment issues for single line timestamps.
rodzic
31e0f3edfb
commit
0599f76ed5
|
@ -215,6 +215,10 @@ public class ConversationItemFooter extends ConstraintLayout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TextView getDateView() {
|
||||||
|
return dateView;
|
||||||
|
}
|
||||||
|
|
||||||
private void notifyTouchDelegateChanged(@NonNull Rect rect, @NonNull View touchDelegate) {
|
private void notifyTouchDelegateChanged(@NonNull Rect rect, @NonNull View touchDelegate) {
|
||||||
if (onTouchDelegateChangedListener != null) {
|
if (onTouchDelegateChangedListener != null) {
|
||||||
onTouchDelegateChangedListener.onTouchDelegateChanged(rect, touchDelegate);
|
onTouchDelegateChangedListener.onTouchDelegateChanged(rect, touchDelegate);
|
||||||
|
|
|
@ -24,6 +24,7 @@ import android.content.ActivityNotFoundException;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
import android.graphics.Paint;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.Typeface;
|
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 &&
|
if (!updatingFooter &&
|
||||||
!isCaptionlessMms(messageRecord) &&
|
!isCaptionlessMms(messageRecord) &&
|
||||||
!isViewOnceMessage(messageRecord) &&
|
!isViewOnceMessage(messageRecord) &&
|
||||||
isFooterVisible(messageRecord, nextMessageRecord, groupThread) &&
|
isFooterVisible(messageRecord, nextMessageRecord, groupThread) &&
|
||||||
bodyText.getLastLineWidth() > 0)
|
bodyText.getLastLineWidth() > 0)
|
||||||
{
|
{
|
||||||
int footerWidth = footer.getMeasuredWidth();
|
TextView dateView = footer.getDateView();
|
||||||
int availableWidth = getAvailableMessageBubbleWidth(bodyText);
|
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()) {
|
if (bodyText.isSingleLine()) {
|
||||||
int maxBubbleWidth = hasBigImageLinkPreview(messageRecord) || hasThumbnail(messageRecord) ? readDimen(R.dimen.media_bubble_max_width) : getMaxBubbleWidth();
|
int maxBubbleWidth = hasBigImageLinkPreview(messageRecord) || hasThumbnail(messageRecord) ? readDimen(R.dimen.media_bubble_max_width) : getMaxBubbleWidth();
|
||||||
int bodyMargins = ViewUtil.getLeftMargin(bodyText) + ViewUtil.getRightMargin(bodyText);
|
int bodyMargins = ViewUtil.getLeftMargin(bodyText) + ViewUtil.getRightMargin(bodyText);
|
||||||
int sizeWithMargins = bodyText.getMeasuredWidth() + ViewUtil.dpToPx(6) + footerWidth + bodyMargins;
|
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()));
|
int minSize = Math.min(maxBubbleWidth, Math.max(bodyText.getMeasuredWidth() + ViewUtil.dpToPx(6) + footerWidth + bodyMargins, bodyBubble.getMeasuredWidth()));
|
||||||
if (hasQuote(messageRecord) && sizeWithMargins < availableWidth) {
|
if (hasQuote(messageRecord) && sizeWithMargins < availableWidth) {
|
||||||
ViewUtil.setTopMargin(footer, readDimen(R.dimen.message_bubble_same_line_footer_bottom_margin));
|
ViewUtil.setTopMargin(footer, topMargin);
|
||||||
needsMeasure = true;
|
needsMeasure = true;
|
||||||
updatingFooter = true;
|
updatingFooter = true;
|
||||||
} else if (sizeWithMargins != bodyText.getMeasuredWidth() && sizeWithMargins <= minSize) {
|
} else if (sizeWithMargins != bodyText.getMeasuredWidth() && sizeWithMargins <= minSize) {
|
||||||
bodyBubble.getLayoutParams().width = minSize;
|
bodyBubble.getLayoutParams().width = minSize;
|
||||||
ViewUtil.setTopMargin(footer, readDimen(R.dimen.message_bubble_same_line_footer_bottom_margin));
|
ViewUtil.setTopMargin(footer, topMargin);
|
||||||
needsMeasure = true;
|
needsMeasure = true;
|
||||||
updatingFooter = true;
|
updatingFooter = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!updatingFooter && bodyText.getLastLineWidth() + ViewUtil.dpToPx(6) + footerWidth <= bodyText.getMeasuredWidth()) {
|
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;
|
updatingFooter = true;
|
||||||
needsMeasure = 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)) {
|
if (hasSharedContact(messageRecord)) {
|
||||||
int contactWidth = sharedContactStub.get().getMeasuredWidth();
|
int contactWidth = sharedContactStub.get().getMeasuredWidth();
|
||||||
int availableWidth = getAvailableMessageBubbleWidth(sharedContactStub.get());
|
int availableWidth = getAvailableMessageBubbleWidth(sharedContactStub.get());
|
||||||
|
|
|
@ -91,18 +91,18 @@ fun MessageRecord.hasBigImageLinkPreview(context: Context): Boolean {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun MessageRecord.isTextOnly(context: Context): Boolean {
|
fun MessageRecord.isTextOnly(context: Context): Boolean {
|
||||||
return !(
|
return !isMms ||
|
||||||
!isMms ||
|
(
|
||||||
isViewOnceMessage() ||
|
!isViewOnceMessage() &&
|
||||||
hasLinkPreview() ||
|
!hasLinkPreview() &&
|
||||||
hasQuote() ||
|
!hasQuote() &&
|
||||||
hasExtraText() ||
|
!hasExtraText() &&
|
||||||
hasDocument() ||
|
!hasDocument() &&
|
||||||
hasThumbnail() ||
|
!hasThumbnail() &&
|
||||||
hasAudio() ||
|
!hasAudio() &&
|
||||||
hasLocation() ||
|
!hasLocation() &&
|
||||||
hasSharedContact() ||
|
!hasSharedContact() &&
|
||||||
hasSticker() ||
|
!hasSticker() &&
|
||||||
isCaptionlessMms(context)
|
!isCaptionlessMms(context)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
tools:layout_width="wrap_content"
|
||||||
tools:background="@color/green"
|
tools:background="@color/green"
|
||||||
tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout">
|
tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout">
|
||||||
|
|
||||||
|
@ -54,7 +55,7 @@
|
||||||
app:layout_constraintEnd_toStartOf="@id/footer_expiration_timer"
|
app:layout_constraintEnd_toStartOf="@id/footer_expiration_timer"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
tools:text="3m" />
|
tools:text="13:14pm" />
|
||||||
|
|
||||||
<org.thoughtcrime.securesms.components.ExpirationTimerView
|
<org.thoughtcrime.securesms.components.ExpirationTimerView
|
||||||
android:id="@+id/footer_expiration_timer"
|
android:id="@+id/footer_expiration_timer"
|
||||||
|
@ -86,9 +87,9 @@
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
app:layout_constraintStart_toEndOf="@id/date_and_expiry_wrapper"
|
app:layout_constraintStart_toEndOf="@id/date_and_expiry_wrapper"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toStartOf="@id/footer_insecure_indicator"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
tools:text="Sim Op" />
|
tools:text="Sim Op"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/footer_insecure_indicator"
|
android:id="@+id/footer_insecure_indicator"
|
||||||
|
@ -113,7 +114,8 @@
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
<org.thoughtcrime.securesms.components.PlaybackSpeedToggleTextView
|
<org.thoughtcrime.securesms.components.PlaybackSpeedToggleTextView
|
||||||
android:id="@+id/footer_audio_playback_speed_toggle"
|
android:id="@+id/footer_audio_playback_speed_toggle"
|
||||||
|
|
|
@ -185,7 +185,7 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="@dimen/message_bubble_horizontal_padding"
|
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_marginEnd="@dimen/message_bubble_horizontal_padding"
|
||||||
android:layout_marginBottom="@dimen/message_bubble_bottom_padding"
|
android:layout_marginBottom="@dimen/message_bubble_bottom_padding"
|
||||||
android:layout_gravity="end"
|
android:layout_gravity="end"
|
||||||
|
@ -202,7 +202,7 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="@dimen/message_bubble_horizontal_padding"
|
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_marginBottom="@dimen/message_bubble_bottom_padding"
|
||||||
android:layout_gravity="end"
|
android:layout_gravity="end"
|
||||||
android:clipChildren="false"
|
android:clipChildren="false"
|
||||||
|
|
|
@ -115,7 +115,7 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="@dimen/message_bubble_horizontal_padding"
|
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_marginEnd="@dimen/message_bubble_horizontal_padding"
|
||||||
android:layout_marginBottom="@dimen/message_bubble_bottom_padding"
|
android:layout_marginBottom="@dimen/message_bubble_bottom_padding"
|
||||||
android:layout_gravity="end"
|
android:layout_gravity="end"
|
||||||
|
|
|
@ -153,7 +153,7 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="end"
|
android:layout_gravity="end"
|
||||||
android:layout_marginTop="-5dp"
|
android:layout_marginTop="2dp"
|
||||||
android:layout_marginBottom="@dimen/message_bubble_bottom_padding"
|
android:layout_marginBottom="@dimen/message_bubble_bottom_padding"
|
||||||
android:clipChildren="false"
|
android:clipChildren="false"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
|
|
Ładowanie…
Reference in New Issue