mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-24 07:08:09 +00:00
Display configured ephemeral messages duration below conversation title (next to icon)
This commit is contained in:
parent
6d959d489b
commit
27b1cf90c6
7 changed files with 64 additions and 33 deletions
|
|
@ -27,6 +27,7 @@ import org.linphone.LinphoneApplication.Companion.coreContext
|
|||
import org.linphone.R
|
||||
import org.linphone.core.EventLog
|
||||
import org.linphone.utils.AppUtils
|
||||
import org.linphone.utils.LinphoneUtils
|
||||
|
||||
class EventModel @WorkerThread constructor(private val eventLog: EventLog) {
|
||||
val text: String
|
||||
|
|
@ -77,7 +78,7 @@ class EventModel @WorkerThread constructor(private val eventLog: EventLog) {
|
|||
)
|
||||
EventLog.Type.ConferenceEphemeralMessageLifetimeChanged -> AppUtils.getFormattedString(
|
||||
R.string.conversation_event_ephemeral_messages_lifetime_changed,
|
||||
formatEphemeralExpiration(eventLog.ephemeralMessageLifetime).lowercase(
|
||||
LinphoneUtils.formatEphemeralExpiration(eventLog.ephemeralMessageLifetime).lowercase(
|
||||
Locale.getDefault()
|
||||
)
|
||||
)
|
||||
|
|
@ -126,29 +127,4 @@ class EventModel @WorkerThread constructor(private val eventLog: EventLog) {
|
|||
}
|
||||
return name
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
private fun formatEphemeralExpiration(duration: Long): String {
|
||||
return when (duration) {
|
||||
0L -> AppUtils.getString(
|
||||
R.string.conversation_ephemeral_messages_duration_disabled
|
||||
)
|
||||
60L -> AppUtils.getString(
|
||||
R.string.conversation_ephemeral_messages_duration_one_minute
|
||||
)
|
||||
3600L -> AppUtils.getString(
|
||||
R.string.conversation_ephemeral_messages_duration_one_hour
|
||||
)
|
||||
86400L -> AppUtils.getString(
|
||||
R.string.conversation_ephemeral_messages_duration_one_day
|
||||
)
|
||||
259200L -> AppUtils.getString(
|
||||
R.string.conversation_ephemeral_messages_duration_three_days
|
||||
)
|
||||
604800L -> AppUtils.getString(
|
||||
R.string.conversation_ephemeral_messages_duration_one_week
|
||||
)
|
||||
else -> "$duration s"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,6 +80,8 @@ class ConversationViewModel @UiThread constructor() : AbstractConversationViewMo
|
|||
|
||||
val ephemeralLifetime = MutableLiveData<Long>()
|
||||
|
||||
val ephemeralLifeTimeLabel = MutableLiveData<String>()
|
||||
|
||||
val composingLabel = MutableLiveData<String>()
|
||||
|
||||
val searchBarVisible = MutableLiveData<Boolean>()
|
||||
|
|
@ -247,6 +249,9 @@ class ConversationViewModel @UiThread constructor() : AbstractConversationViewMo
|
|||
ephemeralLifetime.postValue(
|
||||
if (!chatRoom.isEphemeralEnabled) 0L else chatRoom.ephemeralLifetime
|
||||
)
|
||||
ephemeralLifeTimeLabel.postValue(
|
||||
LinphoneUtils.formatEphemeralExpiration(chatRoom.ephemeralLifetime)
|
||||
)
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
|
|
@ -460,6 +465,9 @@ class ConversationViewModel @UiThread constructor() : AbstractConversationViewMo
|
|||
ephemeralLifetime.postValue(
|
||||
if (!chatRoom.isEphemeralEnabled) 0L else chatRoom.ephemeralLifetime
|
||||
)
|
||||
ephemeralLifeTimeLabel.postValue(
|
||||
LinphoneUtils.formatEphemeralExpiration(chatRoom.ephemeralLifetime)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -575,6 +583,9 @@ class ConversationViewModel @UiThread constructor() : AbstractConversationViewMo
|
|||
ephemeralLifetime.postValue(
|
||||
if (!chatRoom.isEphemeralEnabled) 0L else chatRoom.ephemeralLifetime
|
||||
)
|
||||
ephemeralLifeTimeLabel.postValue(
|
||||
LinphoneUtils.formatEphemeralExpiration(chatRoom.ephemeralLifetime)
|
||||
)
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
|
|
@ -835,7 +846,7 @@ class ConversationViewModel @UiThread constructor() : AbstractConversationViewMo
|
|||
composingFriends.add(name)
|
||||
label += "$name, "
|
||||
}
|
||||
if (composingFriends.size > 0) {
|
||||
if (composingFriends.isNotEmpty()) {
|
||||
label = label.dropLast(2)
|
||||
|
||||
val format = AppUtils.getStringWithPlural(
|
||||
|
|
|
|||
|
|
@ -316,6 +316,31 @@ class LinphoneUtils {
|
|||
}
|
||||
}
|
||||
|
||||
@AnyThread
|
||||
fun formatEphemeralExpiration(duration: Long): String {
|
||||
return when (duration) {
|
||||
0L -> AppUtils.getString(
|
||||
R.string.conversation_ephemeral_messages_duration_disabled
|
||||
)
|
||||
60L -> AppUtils.getString(
|
||||
R.string.conversation_ephemeral_messages_duration_one_minute
|
||||
)
|
||||
3600L -> AppUtils.getString(
|
||||
R.string.conversation_ephemeral_messages_duration_one_hour
|
||||
)
|
||||
86400L -> AppUtils.getString(
|
||||
R.string.conversation_ephemeral_messages_duration_one_day
|
||||
)
|
||||
259200L -> AppUtils.getString(
|
||||
R.string.conversation_ephemeral_messages_duration_three_days
|
||||
)
|
||||
604800L -> AppUtils.getString(
|
||||
R.string.conversation_ephemeral_messages_duration_one_week
|
||||
)
|
||||
else -> "$duration s"
|
||||
}
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
fun getChatRoomId(room: ChatRoom): String {
|
||||
return getChatRoomId(room.localAddress, room.peerAddress)
|
||||
|
|
|
|||
|
|
@ -260,9 +260,10 @@
|
|||
style="@style/default_text_style_300"
|
||||
android:id="@+id/countdown_clock"
|
||||
android:layout_width="@dimen/small_icon_size"
|
||||
android:layout_height="@dimen/small_icon_size"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:paddingTop="7dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:contentDescription="@null"
|
||||
android:src="@drawable/clock_countdown"
|
||||
app:tint="?attr/color_main2_600"
|
||||
|
|
@ -274,7 +275,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="2dp"
|
||||
android:textAlignment="textEnd"
|
||||
android:layout_gravity="bottom"
|
||||
android:text="@{model.ephemeralLifetime, default=`00:00`}"
|
||||
android:textSize="12sp"
|
||||
android:visibility="@{model.isEphemeral ? View.VISIBLE : View.GONE, default=gone}"/>
|
||||
|
|
|
|||
|
|
@ -208,6 +208,7 @@
|
|||
android:id="@+id/ephemeral_timer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:text="@{model.ephemeralLifetime, default=`00:00`}"
|
||||
android:textSize="12sp"
|
||||
android:visibility="@{model.isEphemeral ? View.VISIBLE : View.GONE, default=gone}"/>
|
||||
|
|
@ -216,10 +217,10 @@
|
|||
style="@style/default_text_style_300"
|
||||
android:id="@+id/countdown_clock"
|
||||
android:layout_width="@dimen/small_icon_size"
|
||||
android:layout_height="@dimen/small_icon_size"
|
||||
android:layout_gravity="center_vertical|start"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="2dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:paddingTop="7dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:contentDescription="@null"
|
||||
android:src="@drawable/clock_countdown"
|
||||
app:tint="?attr/color_main2_600"
|
||||
|
|
|
|||
|
|
@ -137,6 +137,7 @@
|
|||
android:id="@+id/ephemeral_enabled"
|
||||
android:layout_width="@dimen/small_icon_size"
|
||||
android:layout_height="@dimen/small_icon_size"
|
||||
android:layout_marginStart="@{viewModel.isMuted ? @dimen/five : @dimen/zero}"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:src="@drawable/clock_countdown"
|
||||
android:contentDescription="@string/content_description_chat_ephemeral_enabled"
|
||||
|
|
@ -146,6 +147,21 @@
|
|||
app:layout_constraintBottom_toBottomOf="@id/avatar"
|
||||
app:tint="?attr/color_main1_500"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style"
|
||||
android:id="@+id/ephemeral_duration"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:paddingBottom="2dp"
|
||||
android:text="@{viewModel.ephemeralLifeTimeLabel, default=`1 day`}"
|
||||
android:textSize="12sp"
|
||||
android:visibility="@{viewModel.ephemeralLifetime > 0L ? View.VISIBLE : View.GONE, default=gone}"
|
||||
app:layout_constraintStart_toEndOf="@id/ephemeral_enabled"
|
||||
app:layout_constraintTop_toTopOf="@id/ephemeral_enabled"
|
||||
app:layout_constraintBottom_toBottomOf="@id/ephemeral_enabled"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/show_menu"
|
||||
android:onClick="@{showMenuClickListener}"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="zero">0dp</dimen>
|
||||
<dimen name="five">5dp</dimen>
|
||||
|
||||
<dimen name="screen_bottom_margin">10dp</dimen>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue