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 return
} }
val timestamp = friend.presenceModel?.timestamp ?: -1 val timestamp = friend.presenceModel?.latestActivityTimestamp ?: -1L
lastPresenceInfo.value = when { lastPresenceInfo.value = if (timestamp != -1L) {
TimestampUtils.isToday(timestamp) -> { when {
val time = TimestampUtils.timeToString(timestamp, timestampInSecs = true) TimestampUtils.isToday(timestamp) -> {
val text = AppUtils.getString(R.string.chat_room_presence_last_seen_online_today) val time = TimestampUtils.timeToString(timestamp, timestampInSecs = true)
"$text $time" val text =
} AppUtils.getString(R.string.chat_room_presence_last_seen_online_today)
TimestampUtils.isYesterday(timestamp) -> { "$text $time"
val time = TimestampUtils.timeToString(timestamp, timestampInSecs = true) }
val text = AppUtils.getString(
R.string.chat_room_presence_last_seen_online_yesterday TimestampUtils.isYesterday(timestamp) -> {
) val time = TimestampUtils.timeToString(timestamp, timestampInSecs = true)
"$text $time" val text = AppUtils.getString(
} R.string.chat_room_presence_last_seen_online_yesterday
else -> { )
val date = TimestampUtils.toString( "$text $time"
timestamp, }
onlyDate = true,
shortDate = false, else -> {
hideYear = true val date = TimestampUtils.toString(
) timestamp,
val text = AppUtils.getString(R.string.chat_room_presence_last_seen_online) onlyDate = true,
"$text $date" 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_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_yesterday">En ligne hier à</string>
<string name="chat_room_presence_last_seen_online">En ligne le</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="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_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> <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_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_yesterday">Online yesterday at</string>
<string name="chat_room_presence_last_seen_online">Online on</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> <string name="chat_room_presence_do_not_disturb">Do not disturb</string>
<!-- Recordings --> <!-- Recordings -->