Merge pull request #804 from ceokot/fix_control_message_date_breaks
fix: Add date breaks on control messagespull/805/head
commit
6a11c0d375
@ -0,0 +1,15 @@
|
||||
package org.thoughtcrime.securesms.conversation.v2.messages
|
||||
|
||||
import android.widget.TextView
|
||||
import androidx.core.view.isVisible
|
||||
import org.thoughtcrime.securesms.database.model.MessageRecord
|
||||
import org.thoughtcrime.securesms.util.DateUtils
|
||||
import java.util.Locale
|
||||
|
||||
private const val maxTimeBetweenBreaks = 5 * 60 * 1000L // 5 minutes
|
||||
|
||||
fun TextView.showDateBreak(message: MessageRecord, previous: MessageRecord?) {
|
||||
val showDateBreak = (previous == null || message.timestamp - previous.timestamp > maxTimeBetweenBreaks)
|
||||
isVisible = showDateBreak
|
||||
text = if (showDateBreak) DateUtils.getDisplayFormattedTimeSpanString(context, Locale.getDefault(), message.timestamp) else ""
|
||||
}
|
@ -1,28 +1,40 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:paddingVertical="@dimen/medium_spacing"
|
||||
android:paddingHorizontal="@dimen/massive_spacing"
|
||||
android:gravity="center">
|
||||
android:paddingVertical="@dimen/medium_spacing">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dateBreakTextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/text"
|
||||
android:textSize="@dimen/very_small_font_size"
|
||||
android:textStyle="bold"
|
||||
tools:text="@tools:sample/date/hhmm" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iconImageView"
|
||||
android:layout_width="12dp"
|
||||
android:layout_height="12dp"
|
||||
android:layout_marginBottom="@dimen/small_spacing"
|
||||
app:tint="@color/text" />
|
||||
app:tint="@color/text"
|
||||
tools:src="@drawable/ic_timer" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="@dimen/very_small_font_size"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/text"
|
||||
android:textSize="@dimen/very_small_font_size"
|
||||
android:textStyle="bold"
|
||||
android:gravity="center" />
|
||||
tools:text="@string/MessageRecord_you_disabled_disappearing_messages" />
|
||||
|
||||
</LinearLayout>
|
Loading…
Reference in New Issue