Show ephemeral messages icon under conversation title if they are enabled

This commit is contained in:
Sylvain Berfini 2024-02-07 16:59:06 +01:00
parent ef53eb62ae
commit 012b2419e5
3 changed files with 34 additions and 2 deletions

View file

@ -74,6 +74,8 @@ class ConversationViewModel @UiThread constructor() : ViewModel() {
val isDisabledBecauseNotSecured = MutableLiveData<Boolean>()
val ephemeralLifetime = MutableLiveData<Long>()
val composingLabel = MutableLiveData<String>()
val searchBarVisible = MutableLiveData<Boolean>()
@ -258,6 +260,10 @@ class ConversationViewModel @UiThread constructor() : ViewModel() {
list.add(EventLogModel(eventLog, avatarModel))
eventsList = list
events.postValue(eventsList)
ephemeralLifetime.postValue(
if (!chatRoom.isEphemeralEnabled) 0L else chatRoom.ephemeralLifetime
)
}
@WorkerThread
@ -602,6 +608,10 @@ class ConversationViewModel @UiThread constructor() : ViewModel() {
coreContext.contactsManager.getContactAvatarModelForAddress(address)
}
avatarModel.postValue(avatar)
ephemeralLifetime.postValue(
if (!chatRoom.isEphemeralEnabled) 0L else chatRoom.ephemeralLifetime
)
}
@WorkerThread

View file

@ -127,15 +127,36 @@
app:layout_constraintEnd_toStartOf="@id/start_call"
app:layout_constraintStart_toEndOf="@id/avatar"
app:layout_constraintTop_toTopOf="@id/avatar"
app:layout_constraintBottom_toTopOf="@id/muted"/>
app:layout_constraintBottom_toTopOf="@id/subtitle_barrier"/>
<androidx.constraintlayout.widget.Barrier
android:id="@+id/subtitle_barrier"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:barrierDirection="top"
app:constraint_referenced_ids="muted, ephemeral_enabled" />
<ImageView
android:id="@+id/muted"
android:layout_width="@dimen/small_icon_size"
android:layout_height="@dimen/small_icon_size"
android:layout_marginEnd="5dp"
android:src="@drawable/bell_simple_slash"
android:visibility="@{viewModel.isMuted ? View.VISIBLE : View.GONE, default=gone}"
app:layout_constraintStart_toStartOf="@id/title"
app:layout_constraintEnd_toStartOf="@id/ephemeral_enabled"
app:layout_constraintTop_toBottomOf="@id/title"
app:layout_constraintBottom_toBottomOf="@id/avatar"
app:tint="@color/orange_main_400"/>
<ImageView
android:id="@+id/ephemeral_enabled"
android:layout_width="@dimen/small_icon_size"
android:layout_height="@dimen/small_icon_size"
android:layout_marginEnd="5dp"
android:src="@drawable/clock_countdown"
android:visibility="@{viewModel.ephemeralLifetime > 0L ? View.VISIBLE : View.GONE, default=gone}"
app:layout_constraintStart_toEndOf="@id/muted"
app:layout_constraintTop_toBottomOf="@id/title"
app:layout_constraintBottom_toBottomOf="@id/avatar"
app:tint="@color/orange_main_400"/>

View file

@ -107,7 +107,7 @@
style="@style/default_text_style"
android:id="@+id/unmute"
android:onClick="@{unmuteClickListener}"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/popup_menu_item_top_margin"
android:text="@string/conversation_action_unmute"
@ -120,6 +120,7 @@
android:visibility="@{conversationMuted &amp;&amp; !readOnlyConversation ? View.VISIBLE : View.GONE, default=gone}"
app:drawableTint="?attr/color_main2_700"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/mute"
app:layout_constraintBottom_toTopOf="@id/ephemeral"/>