Updated meetings participants picker

This commit is contained in:
Sylvain Berfini 2024-04-29 17:10:46 +02:00
parent b4d25b0e6e
commit 1719a57cdc
4 changed files with 24 additions and 37 deletions

View file

@ -190,8 +190,7 @@ class EditMeetingFragment : SlidingPaneChildFragment() {
Log.i(
"$TAG Found [${list.size}] new participants to add to the meeting, let's do it"
)
// TODO FIXME: instead of adding them, replace current list with new one
viewModel.addParticipants(list)
viewModel.setParticipants(list)
}
}
}

View file

@ -77,7 +77,7 @@ class ScheduleMeetingFragment : GenericFragment() {
val participants = args.participants
if (!participants.isNullOrEmpty()) {
Log.i("$TAG Found pre-populated array of participants of size [${participants.size}]")
viewModel.addParticipants(participants.toList())
viewModel.setParticipants(participants.toList())
}
binding.setBackClickListener {
@ -191,8 +191,7 @@ class ScheduleMeetingFragment : GenericFragment() {
Log.i(
"$TAG Found [${list.size}] new participants to add to the meeting, let's do it"
)
// TODO FIXME: instead of adding them, replace current list with new one
viewModel.addParticipants(list)
viewModel.setParticipants(list)
}
}
}

View file

@ -309,24 +309,15 @@ class ScheduleMeetingViewModel @UiThread constructor() : ViewModel() {
}
@UiThread
fun addParticipants(toAdd: List<String>) {
fun setParticipants(toAdd: List<String>) {
coreContext.postOnCoreThread {
val list = arrayListOf<SelectedAddressModel>()
list.addAll(participants.value.orEmpty())
for (participant in toAdd) {
val address = Factory.instance().createAddress(participant)
if (address == null) {
Log.e("$TAG Failed to parse [$participant] as address!")
} else {
val found = list.find { it.address.weakEqual(address) }
if (found != null) {
Log.i(
"$TAG Participant [${found.address.asStringUriOnly()}] already in list, skipping"
)
continue
}
val avatarModel = coreContext.contactsManager.getContactAvatarModelForAddress(
address
)
@ -335,13 +326,11 @@ class ScheduleMeetingViewModel @UiThread constructor() : ViewModel() {
removeModelFromSelection(model)
}
list.add(model)
Log.i("$TAG Added participant [${address.asStringUriOnly()}]")
Log.i("$TAG Participant [${address.asStringUriOnly()}] added to list")
}
}
Log.i(
"$TAG [${toAdd.size}] participants added, now there are [${list.size}] participants in list"
)
Log.i("$TAG Now there are [${list.size}] participants in list")
participants.postValue(list)
}
}

View file

@ -475,22 +475,7 @@
android:src="@drawable/users"
android:visibility="@{viewModel.participants.size() > 0 ? View.VISIBLE : View.GONE, default=gone}"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/participants_list" />
<LinearLayout
android:id="@+id/participants_list"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="20dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="16dp"
android:visibility="@{viewModel.participants.size() > 0 ? View.VISIBLE : View.GONE, default=gone}"
app:layout_constraintTop_toBottomOf="@id/participants"
app:layout_constraintStart_toEndOf="@id/participants_list_icon"
app:layout_constraintEnd_toEndOf="parent"
entries="@{viewModel.participants}"
layout="@{@layout/meeting_schedule_participant_list_cell}"/>
app:layout_constraintTop_toTopOf="@id/add_more_participants" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style_300"
@ -502,9 +487,24 @@
android:layout_marginTop="10dp"
android:text="@string/meeting_schedule_add_more_participants_title"
android:visibility="@{viewModel.participants.size() > 0 ? View.VISIBLE : View.GONE, default=gone}"
app:layout_constraintTop_toBottomOf="@id/participants_list"
app:layout_constraintTop_toBottomOf="@id/participants"
app:layout_constraintStart_toEndOf="@id/participants_list_icon" />
<LinearLayout
android:id="@+id/participants_list"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="10dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="16dp"
android:visibility="@{viewModel.participants.size() > 0 ? View.VISIBLE : View.GONE, default=gone}"
app:layout_constraintTop_toBottomOf="@id/add_more_participants"
app:layout_constraintStart_toEndOf="@id/participants_list_icon"
app:layout_constraintEnd_toEndOf="parent"
entries="@{viewModel.participants}"
layout="@{@layout/meeting_schedule_participant_list_cell}"/>
<View
android:id="@+id/separator_5"
android:layout_width="0dp"
@ -512,7 +512,7 @@
android:layout_marginTop="16dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/add_more_participants"
app:layout_constraintTop_toBottomOf="@id/participants_list"
android:background="?attr/color_main2_200" />
<com.google.android.material.materialswitch.MaterialSwitch