Added filter in scheduled meetings list to show past meetings

This commit is contained in:
Sylvain Berfini 2022-06-25 10:54:21 +02:00
parent c3a4ff443b
commit e2a70c33e8
8 changed files with 112 additions and 8 deletions

View file

@ -22,6 +22,7 @@ package org.linphone.activities.main.conference.data
import androidx.lifecycle.MutableLiveData
import java.util.concurrent.TimeUnit
import org.linphone.LinphoneApplication.Companion.coreContext
import org.linphone.R
import org.linphone.core.ConferenceInfo
import org.linphone.core.tools.Log
import org.linphone.utils.LinphoneUtils
@ -29,6 +30,8 @@ import org.linphone.utils.TimestampUtils
class ScheduledConferenceData(val conferenceInfo: ConferenceInfo) {
val expanded = MutableLiveData<Boolean>()
val isFinished = MutableLiveData<Boolean>()
val backgroundResId = MutableLiveData<Int>()
val address = MutableLiveData<String>()
val subject = MutableLiveData<String>()
@ -76,6 +79,11 @@ class ScheduledConferenceData(val conferenceInfo: ConferenceInfo) {
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()
computeParticipantsLists()
}
@ -88,6 +96,23 @@ class ScheduledConferenceData(val conferenceInfo: ConferenceInfo) {
fun toggleExpand() {
expanded.value = expanded.value == false
computeBackgroundResId()
}
private fun computeBackgroundResId() {
backgroundResId.value = if (isFinished.value == true) {
if (expanded.value == true) {
R.drawable.shape_round_dark_gray_background_with_orange_border
} else {
R.drawable.shape_round_dark_gray_background
}
} else {
if (expanded.value == true) {
R.drawable.shape_round_gray_background_with_orange_border
} else {
R.drawable.shape_round_gray_background
}
}
}
private fun computeParticipantsLists() {

View file

@ -31,6 +31,8 @@ import org.linphone.core.tools.Log
class ScheduledConferencesViewModel : ViewModel() {
val conferences = MutableLiveData<ArrayList<ScheduledConferenceData>>()
val showTerminated = MutableLiveData<Boolean>()
private val listener = object : CoreListenerStub() {
override fun onConferenceInfoReceived(core: Core, conferenceInfo: ConferenceInfo) {
Log.i("[Scheduled Conferences] New conference info received")
@ -40,6 +42,9 @@ class ScheduledConferencesViewModel : ViewModel() {
init {
coreContext.core.addListener(listener)
showTerminated.value = false
computeConferenceInfoList()
}
@ -49,6 +54,10 @@ class ScheduledConferencesViewModel : ViewModel() {
super.onCleared()
}
fun applyFilter() {
computeConferenceInfoList()
}
fun deleteConferenceInfo(data: ScheduledConferenceData) {
val conferenceInfoList = arrayListOf<ScheduledConferenceData>()
@ -66,11 +75,22 @@ class ScheduledConferencesViewModel : ViewModel() {
val conferencesList = arrayListOf<ScheduledConferenceData>()
val now = System.currentTimeMillis() / 1000 // Linphone uses time_t in seconds
val oneHourAgo = now - 3600 // Show all conferences from 1 hour ago and forward
for (conferenceInfo in coreContext.core.getConferenceInformationListAfterTime(oneHourAgo)) {
if (conferenceInfo.duration == 0) continue // This isn't a scheduled conference, don't display it
val data = ScheduledConferenceData(conferenceInfo)
conferencesList.add(data)
if (showTerminated.value == true) {
for (conferenceInfo in coreContext.core.conferenceInformationList) {
if (conferenceInfo.duration == 0) continue // This isn't a scheduled conference, don't display it
val limit = conferenceInfo.dateTime + conferenceInfo.duration
if (limit >= now) continue // This isn't a terminated conference, don't display it
val data = ScheduledConferenceData(conferenceInfo)
conferencesList.add(data)
}
} else {
val oneHourAgo = now - 7200 // Show all conferences from 2 hours ago and forward
for (conferenceInfo in coreContext.core.getConferenceInformationListAfterTime(oneHourAgo)) {
if (conferenceInfo.duration == 0) continue // This isn't a scheduled conference, don't display it
val data = ScheduledConferenceData(conferenceInfo)
conferencesList.add(data)
}
}
conferences.value = conferencesList

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="7dp" />
<solid android:color="?attr/backgroundColor3"/>
</shape>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="7dp" />
<solid android:color="?attr/backgroundColor3"/>
<stroke android:width="2dp" android:color="?attr/colorPrimary"/>
</shape>

View file

@ -35,7 +35,7 @@
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="5dp"
android:background="@{data.expanded ? @drawable/shape_round_gray_background_with_orange_border : @drawable/shape_round_gray_background, default=@drawable/shape_round_gray_background}">
backgroundImage="@{data.backgroundResId, default=@drawable/shape_round_gray_background}">
<RelativeLayout
android:layout_width="match_parent"

View file

@ -60,11 +60,45 @@
</LinearLayout>
<com.google.android.material.chip.ChipGroup
android:id="@+id/chips"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/top_bar"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp">
<com.google.android.material.chip.Chip
style="@style/Widget.MaterialComponents.Chip.Choice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onCheckedChanged="@{() -> viewModel.applyFilter()}"
android:checked="@={viewModel.showTerminated, default=false}"
android:text="@string/conference_scheduled_terminated_filter" />
<com.google.android.material.chip.Chip
style="@style/Widget.MaterialComponents.Chip.Choice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onCheckedChanged="@{() -> viewModel.applyFilter()}"
android:checked="@={!viewModel.showTerminated, default=true}"
android:text="@string/conference_scheduled_future_filter" />
</com.google.android.material.chip.ChipGroup>
<View
android:id="@+id/divider"
android:layout_below="@id/chips"
android:layout_width="wrap_content"
android:layout_height="1dp"
android:background="?attr/dividerColor" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/conference_info_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/top_bar" />
android:layout_marginBottom="10dp"
android:layout_below="@id/divider" />
<TextView
style="@style/empty_list_font"
@ -73,8 +107,16 @@
android:layout_centerVertical="true"
android:gravity="center"
android:text="@string/conference_no_schedule"
android:visibility="@{viewModel.conferences.empty ? View.VISIBLE : View.GONE}" />
android:visibility="@{!viewModel.showTerminated &amp;&amp; viewModel.conferences.empty ? View.VISIBLE : View.GONE}" />
<TextView
style="@style/empty_list_font"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:gravity="center"
android:text="@string/conference_no_terminated_schedule"
android:visibility="@{viewModel.showTerminated &amp;&amp; viewModel.conferences.empty ? View.VISIBLE : View.GONE, default=gone}" />
</RelativeLayout>
</layout>

View file

@ -733,4 +733,7 @@
<string name="chat_room_context_menu_go_to_contact">Voir le contact</string>
<string name="recordings_export">Exporter l\'enregistrement avec…</string>
<string name="content_description_recording_export">Exporter l\'enregistrement</string>
<string name="conference_no_terminated_schedule">Aucune réunion terminée pour le moment.</string>
<string name="conference_scheduled_terminated_filter">Terminées</string>
<string name="conference_scheduled_future_filter">Programmées</string>
</resources>

View file

@ -283,6 +283,7 @@
<string name="conference_too_many_participants_for_mosaic_layout">There is too many participants for mosaic layout, switching to active speaker</string>
<string name="conference_participant_paused">(paused)</string>
<string name="conference_no_schedule">No scheduled meeting yet.</string>
<string name="conference_no_terminated_schedule">No terminated meeting yet.</string>
<string name="conference_schedule_organizer">Organizer:</string>
<string name="conference_go_to_chat">Meeting\'s chat room</string>
<string name="conference_creation_failed">Failed to create meeting</string>
@ -302,6 +303,8 @@
<string name="conference_start_group_call_dialog_title">Group call</string>
<string name="conference_start_group_call_dialog_message">Do you want to start a group call?\nEveryone in this group will receive a call to join the meeting.</string>
<string name="conference_start_group_call_dialog_ok_button">Start</string>
<string name="conference_scheduled_terminated_filter">Terminated</string>
<string name="conference_scheduled_future_filter">Scheduled</string>
<!-- Call -->
<string name="call_incoming_title">Incoming Call</string>