Using new API to properly know the last seen online timestamp and simply display Away when info isn't available

This commit is contained in:
Sylvain Berfini 2023-04-17 16:24:49 +02:00
parent c313e06f8f
commit 7607a5cd57
3 changed files with 32 additions and 23 deletions

View file

@ -334,30 +334,37 @@ class ChatRoomViewModel(val chatRoom: ChatRoom) : ViewModel(), ContactDataInterf
return
}
val timestamp = friend.presenceModel?.timestamp ?: -1
lastPresenceInfo.value = when {
TimestampUtils.isToday(timestamp) -> {
val time = TimestampUtils.timeToString(timestamp, timestampInSecs = true)
val text = AppUtils.getString(R.string.chat_room_presence_last_seen_online_today)
"$text $time"
}
TimestampUtils.isYesterday(timestamp) -> {
val time = TimestampUtils.timeToString(timestamp, timestampInSecs = true)
val text = AppUtils.getString(
R.string.chat_room_presence_last_seen_online_yesterday
)
"$text $time"
}
else -> {
val date = TimestampUtils.toString(
timestamp,
onlyDate = true,
shortDate = false,
hideYear = true
)
val text = AppUtils.getString(R.string.chat_room_presence_last_seen_online)
"$text $date"
val timestamp = friend.presenceModel?.latestActivityTimestamp ?: -1L
lastPresenceInfo.value = if (timestamp != -1L) {
when {
TimestampUtils.isToday(timestamp) -> {
val time = TimestampUtils.timeToString(timestamp, timestampInSecs = true)
val text =
AppUtils.getString(R.string.chat_room_presence_last_seen_online_today)
"$text $time"
}
TimestampUtils.isYesterday(timestamp) -> {
val time = TimestampUtils.timeToString(timestamp, timestampInSecs = true)
val text = AppUtils.getString(
R.string.chat_room_presence_last_seen_online_yesterday
)
"$text $time"
}
else -> {
val date = TimestampUtils.toString(
timestamp,
onlyDate = true,
shortDate = false,
hideYear = true
)
val text = AppUtils.getString(R.string.chat_room_presence_last_seen_online)
"$text $date"
}
}
} else {
AppUtils.getString(R.string.chat_room_presence_away)
}
}

View file

@ -766,6 +766,7 @@
<string name="chat_room_presence_last_seen_online_today">En ligne aujourd\'hui à</string>
<string name="chat_room_presence_last_seen_online_yesterday">En ligne hier à</string>
<string name="chat_room_presence_last_seen_online">En ligne le</string>
<string name="chat_room_presence_away">Absent</string>
<string name="chat_room_presence_do_not_disturb">Ne pas déranger</string>
<string name="account_setting_delete_dialog_title">Voulez-vous supprimer votre compte ?</string>
<string name="account_setting_delete_generic_confirmation_dialog">Votre compte sera supprimé localement.\nPour le supprimer de manière définitive, rendez-vous sur le site internet de votre fournisseur SIP.</string>

View file

@ -239,6 +239,7 @@
<string name="chat_room_presence_last_seen_online_today">Online today at</string>
<string name="chat_room_presence_last_seen_online_yesterday">Online yesterday at</string>
<string name="chat_room_presence_last_seen_online">Online on</string>
<string name="chat_room_presence_away">Away</string>
<string name="chat_room_presence_do_not_disturb">Do not disturb</string>
<!-- Recordings -->