Fixed scheduled conference background color in meetings list

This commit is contained in:
Sylvain Berfini 2022-07-28 12:24:19 +02:00
parent a3f55b3baf
commit b8e65b3ac7
2 changed files with 4 additions and 9 deletions

View file

@ -28,9 +28,8 @@ import org.linphone.core.tools.Log
import org.linphone.utils.LinphoneUtils import org.linphone.utils.LinphoneUtils
import org.linphone.utils.TimestampUtils import org.linphone.utils.TimestampUtils
class ScheduledConferenceData(val conferenceInfo: ConferenceInfo) { class ScheduledConferenceData(val conferenceInfo: ConferenceInfo, private val isFinished: Boolean) {
val expanded = MutableLiveData<Boolean>() val expanded = MutableLiveData<Boolean>()
val isFinished = MutableLiveData<Boolean>()
val backgroundResId = MutableLiveData<Int>() val backgroundResId = MutableLiveData<Int>()
val address = MutableLiveData<String>() val address = MutableLiveData<String>()
@ -79,11 +78,7 @@ class ScheduledConferenceData(val conferenceInfo: ConferenceInfo) {
Log.e("[Scheduled Conference] No organizer SIP URI found for: ${conferenceInfo.uri?.asStringUriOnly()}") Log.e("[Scheduled Conference] No organizer SIP URI found for: ${conferenceInfo.uri?.asStringUriOnly()}")
} }
val now = System.currentTimeMillis() / 1000 // Linphone uses time_t in seconds
val limit = conferenceInfo.dateTime + conferenceInfo.duration
isFinished.value = limit < now
computeBackgroundResId() computeBackgroundResId()
computeParticipantsLists() computeParticipantsLists()
} }
@ -109,7 +104,7 @@ class ScheduledConferenceData(val conferenceInfo: ConferenceInfo) {
} }
private fun computeBackgroundResId() { private fun computeBackgroundResId() {
backgroundResId.value = if (isFinished.value == true) { backgroundResId.value = if (isFinished) {
if (expanded.value == true) { if (expanded.value == true) {
R.drawable.shape_round_dark_gray_background_with_orange_border R.drawable.shape_round_dark_gray_background_with_orange_border
} else { } else {

View file

@ -81,14 +81,14 @@ class ScheduledConferencesViewModel : ViewModel() {
if (conferenceInfo.duration == 0) continue // This isn't a scheduled conference, don't display it if (conferenceInfo.duration == 0) continue // This isn't a scheduled conference, don't display it
val limit = conferenceInfo.dateTime + conferenceInfo.duration val limit = conferenceInfo.dateTime + conferenceInfo.duration
if (limit >= now) continue // This isn't a terminated conference, don't display it if (limit >= now) continue // This isn't a terminated conference, don't display it
val data = ScheduledConferenceData(conferenceInfo) val data = ScheduledConferenceData(conferenceInfo, true)
conferencesList.add(0, data) // Keep terminated meetings list in reverse order to always display most recent on top conferencesList.add(0, data) // Keep terminated meetings list in reverse order to always display most recent on top
} }
} else { } else {
val oneHourAgo = now - 7200 // Show all conferences from 2 hours ago and forward val oneHourAgo = now - 7200 // Show all conferences from 2 hours ago and forward
for (conferenceInfo in coreContext.core.getConferenceInformationListAfterTime(oneHourAgo)) { for (conferenceInfo in coreContext.core.getConferenceInformationListAfterTime(oneHourAgo)) {
if (conferenceInfo.duration == 0) continue // This isn't a scheduled conference, don't display it if (conferenceInfo.duration == 0) continue // This isn't a scheduled conference, don't display it
val data = ScheduledConferenceData(conferenceInfo) val data = ScheduledConferenceData(conferenceInfo, false)
conferencesList.add(data) conferencesList.add(data)
} }
} }