show time underneath bubble
This commit is contained in:
parent
779e6fa61e
commit
805d0db486
|
@ -53,8 +53,8 @@ public class BindingAdapters {
|
||||||
return a.truncatedTo(ChronoUnit.DAYS).equals(b.truncatedTo(ChronoUnit.DAYS));
|
return a.truncatedTo(ChronoUnit.DAYS).equals(b.truncatedTo(ChronoUnit.DAYS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@BindingAdapter("instant")
|
@BindingAdapter("datetime")
|
||||||
public static void setInstant(final TextView textView, final Instant instant) {
|
public static void setDatetime(final TextView textView, final Instant instant) {
|
||||||
if (instant == null || instant.getEpochSecond() <= 0) {
|
if (instant == null || instant.getEpochSecond() <= 0) {
|
||||||
textView.setVisibility(View.GONE);
|
textView.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
|
@ -65,13 +65,13 @@ public class BindingAdapters {
|
||||||
textView.setText(
|
textView.setText(
|
||||||
DateUtils.formatDateTime(
|
DateUtils.formatDateTime(
|
||||||
context,
|
context,
|
||||||
instant.getEpochSecond() * 1000,
|
instant.toEpochMilli(),
|
||||||
DateUtils.FORMAT_SHOW_TIME));
|
DateUtils.FORMAT_SHOW_TIME));
|
||||||
} else if (sameYear(instant, now) || now.minus(THREE_MONTH).isBefore(instant)) {
|
} else if (sameYear(instant, now) || now.minus(THREE_MONTH).isBefore(instant)) {
|
||||||
textView.setText(
|
textView.setText(
|
||||||
DateUtils.formatDateTime(
|
DateUtils.formatDateTime(
|
||||||
context,
|
context,
|
||||||
instant.getEpochSecond() * 1000,
|
instant.toEpochMilli(),
|
||||||
DateUtils.FORMAT_SHOW_DATE
|
DateUtils.FORMAT_SHOW_DATE
|
||||||
| DateUtils.FORMAT_NO_YEAR
|
| DateUtils.FORMAT_NO_YEAR
|
||||||
| DateUtils.FORMAT_ABBREV_ALL));
|
| DateUtils.FORMAT_ABBREV_ALL));
|
||||||
|
@ -79,7 +79,7 @@ public class BindingAdapters {
|
||||||
textView.setText(
|
textView.setText(
|
||||||
DateUtils.formatDateTime(
|
DateUtils.formatDateTime(
|
||||||
context,
|
context,
|
||||||
instant.getEpochSecond() * 1000,
|
instant.toEpochMilli(),
|
||||||
DateUtils.FORMAT_SHOW_DATE
|
DateUtils.FORMAT_SHOW_DATE
|
||||||
| DateUtils.FORMAT_NO_MONTH_DAY
|
| DateUtils.FORMAT_NO_MONTH_DAY
|
||||||
| DateUtils.FORMAT_ABBREV_ALL));
|
| DateUtils.FORMAT_ABBREV_ALL));
|
||||||
|
@ -87,6 +87,22 @@ public class BindingAdapters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@BindingAdapter("time")
|
||||||
|
public static void setTime(final TextView textView, final Instant instant) {
|
||||||
|
if (instant == null || instant.getEpochSecond() <= 0) {
|
||||||
|
textView.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
final Context context = textView.getContext();
|
||||||
|
final Instant now = Instant.now();
|
||||||
|
textView.setVisibility(View.VISIBLE);
|
||||||
|
textView.setText(
|
||||||
|
DateUtils.formatDateTime(
|
||||||
|
context,
|
||||||
|
instant.toEpochMilli(),
|
||||||
|
DateUtils.FORMAT_SHOW_TIME));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@BindingAdapter("android:text")
|
@BindingAdapter("android:text")
|
||||||
public static void setSender(final TextView textView, final ChatOverviewItem.Sender sender) {
|
public static void setSender(final TextView textView, final ChatOverviewItem.Sender sender) {
|
||||||
if (sender == null) {
|
if (sender == null) {
|
||||||
|
|
|
@ -64,12 +64,7 @@ public class MessageAdapter extends PagingDataAdapter<MessageWithContentReaction
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setMessage(final MessageWithContentReactions message) {
|
protected void setMessage(final MessageWithContentReactions message) {
|
||||||
if (message == null) {
|
this.binding.setMessage(message);
|
||||||
this.binding.setMessage(null);
|
|
||||||
this.binding.text.setText("(placeholder)");
|
|
||||||
} else {
|
|
||||||
this.binding.setMessage(message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
10
app/src/main/res/drawable/ic_lock_outline_24dp.xml
Normal file
10
app/src/main/res/drawable/ic_lock_outline_24dp.xml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:tint="?attr/colorControlNormal"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M18,8h-1L17,6c0,-2.76 -2.24,-5 -5,-5S7,3.24 7,6v2L6,8c-1.1,0 -2,0.9 -2,2v10c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L20,10c0,-1.1 -0.9,-2 -2,-2zM9,6c0,-1.66 1.34,-3 3,-3s3,1.34 3,3v2L9,8L9,6zM18,20L6,20L6,10h12v10zM12,17c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2z" />
|
||||||
|
</vector>
|
|
@ -59,6 +59,7 @@
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
|
android:layout_marginHorizontal="4dp"
|
||||||
android:id="@+id/add_content"
|
android:id="@+id/add_content"
|
||||||
style="?attr/materialIconButtonStyle"
|
style="?attr/materialIconButtonStyle"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -76,7 +77,9 @@
|
||||||
android:theme="@style/ThemeOverlay.C3.TextSelection.Secondary"
|
android:theme="@style/ThemeOverlay.C3.TextSelection.Secondary"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="8dp"
|
android:layout_marginVertical="8dp"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
|
android:layout_marginStart="4dp"
|
||||||
android:minHeight="48dp"
|
android:minHeight="48dp"
|
||||||
app:boxBackgroundColor="?colorTertiaryContainer"
|
app:boxBackgroundColor="?colorTertiaryContainer"
|
||||||
app:boxCornerRadiusBottomEnd="24dp"
|
app:boxCornerRadiusBottomEnd="24dp"
|
||||||
|
|
|
@ -73,7 +73,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
android:textAppearance="?textAppearanceLabelMedium"
|
android:textAppearance="?textAppearanceLabelMedium"
|
||||||
app:instant="@{chatOverviewItem.sentAt}"
|
app:datetime="@{chatOverviewItem.sentAt}"
|
||||||
app:layout_constraintBaseline_toBaselineOf="@+id/name"
|
app:layout_constraintBaseline_toBaselineOf="@+id/name"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
tools:text="23:24" />
|
tools:text="23:24" />
|
||||||
|
|
|
@ -5,7 +5,8 @@
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingVertical="6dp">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/avatar"
|
android:id="@+id/avatar"
|
||||||
|
@ -13,42 +14,70 @@
|
||||||
android:layout_height="@dimen/avatar_chat_overview_size"
|
android:layout_height="@dimen/avatar_chat_overview_size"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:scaleType="centerCrop"
|
android:scaleType="centerCrop"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="@id/content"
|
||||||
app:layout_constraintStart_toStartOf="parent" />
|
app:layout_constraintStart_toStartOf="parent" />
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:id="@+id/content"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginHorizontal="8dp"
|
android:layout_marginHorizontal="8dp"
|
||||||
android:background="@drawable/background_message_received"
|
android:background="@drawable/background_message_received"
|
||||||
android:minHeight="40dp"
|
android:minHeight="40dp"
|
||||||
android:padding="8dp"
|
android:padding="8dp"
|
||||||
android:layout_marginTop="4dp"
|
|
||||||
app:layout_constrainedWidth="true"
|
app:layout_constrainedWidth="true"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintHorizontal_bias="0.0"
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
app:layout_constraintStart_toEndOf="@id/avatar"
|
app:layout_constraintStart_toEndOf="@id/avatar"
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/text"
|
android:id="@+id/textContent"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@{message.textContent}"
|
||||||
|
android:textAppearance="?textAppearanceBodyMedium"
|
||||||
android:textColor="?colorOnSecondaryContainer"
|
android:textColor="?colorOnSecondaryContainer"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
android:text="@{message.textContent}"
|
|
||||||
tools:text="Fusce vitae vehicula risus, nec ornare lorem. Quisque facilisis mattis velit ac porttitor. Aenean aliquet pretium varius. Quisque neque felis, mattis sit amet leo ac, tempus dapibus nibh." />
|
tools:text="Fusce vitae vehicula risus, nec ornare lorem. Quisque facilisis mattis velit ac porttitor. Aenean aliquet pretium varius. Quisque neque felis, mattis sit amet leo ac, tempus dapibus nibh." />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/time"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:layout_marginTop="2sp"
|
||||||
|
android:textAppearance="?textAppearanceLabelSmall"
|
||||||
|
android:textColor="?colorOnSurface"
|
||||||
|
app:layout_constraintStart_toStartOf="@+id/content"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/content"
|
||||||
|
app:time="@{message.sentAt}"
|
||||||
|
tools:text="11:42 PM" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/encryption"
|
||||||
|
android:layout_width="12dp"
|
||||||
|
android:layout_height="12dp"
|
||||||
|
android:layout_marginStart="4sp"
|
||||||
|
android:src="@drawable/ic_lock_outline_24dp"
|
||||||
|
android:visibility="visible"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/time"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/time"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/time"
|
||||||
|
app:tint="?colorOnSurface" />
|
||||||
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
<data>
|
<data>
|
||||||
|
|
||||||
<import type="android.view.View" />
|
<import type="android.view.View" />
|
||||||
|
|
||||||
<variable
|
<variable
|
||||||
name="message"
|
name="message"
|
||||||
type="im.conversations.android.database.model.MessageWithContentReactions" />
|
type="im.conversations.android.database.model.MessageWithContentReactions" />
|
||||||
|
|
Loading…
Reference in a new issue