mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Prevent duplicated participants in list during meeting schedule + prevent scheduling a meeting without subject or participant + added icon to remove participant from list
This commit is contained in:
parent
2483b7b6d0
commit
9872f505b6
3 changed files with 56 additions and 7 deletions
|
|
@ -248,8 +248,9 @@ class ScheduleMeetingViewModel @UiThread constructor() : ViewModel() {
|
|||
val avatarModel = coreContext.contactsManager.getContactAvatarModelForAddress(
|
||||
address
|
||||
)
|
||||
val model = SelectedAddressModel(address, avatarModel) {
|
||||
val model = SelectedAddressModel(address, avatarModel) { model ->
|
||||
// onRemoveFromSelection
|
||||
removeModelFromSelection(model)
|
||||
}
|
||||
list.add(model)
|
||||
Log.i("$TAG Loaded participant [${address.asStringUriOnly()}]")
|
||||
|
|
@ -331,11 +332,20 @@ class ScheduleMeetingViewModel @UiThread constructor() : ViewModel() {
|
|||
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
|
||||
)
|
||||
val model = SelectedAddressModel(address, avatarModel) {
|
||||
val model = SelectedAddressModel(address, avatarModel) { model ->
|
||||
// onRemoveFromSelection
|
||||
removeModelFromSelection(model)
|
||||
}
|
||||
list.add(model)
|
||||
Log.i("$TAG Added participant [${address.asStringUriOnly()}]")
|
||||
|
|
@ -353,6 +363,12 @@ class ScheduleMeetingViewModel @UiThread constructor() : ViewModel() {
|
|||
|
||||
@UiThread
|
||||
fun schedule() {
|
||||
if (subject.value.orEmpty().isEmpty() || participants.value.orEmpty().isEmpty()) {
|
||||
Log.e("$TAG Either no subject was set or no participant was selected, can't schedule meeting.")
|
||||
// TODO: show red toast
|
||||
return
|
||||
}
|
||||
|
||||
coreContext.postOnCoreThread { core ->
|
||||
Log.i(
|
||||
"$TAG Scheduling ${if (isBroadcastSelected.value == true) "broadcast" else "meeting"}"
|
||||
|
|
@ -455,6 +471,15 @@ class ScheduleMeetingViewModel @UiThread constructor() : ViewModel() {
|
|||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
private fun removeModelFromSelection(model: SelectedAddressModel) {
|
||||
val newList = arrayListOf<SelectedAddressModel>()
|
||||
newList.addAll(participants.value.orEmpty())
|
||||
newList.remove(model)
|
||||
Log.i("$TAG Removed participant [${model.address.asStringUriOnly()}]")
|
||||
participants.postValue(newList)
|
||||
}
|
||||
|
||||
@AnyThread
|
||||
private fun computeDateLabels() {
|
||||
val start = TimestampUtils.toString(
|
||||
|
|
|
|||
|
|
@ -474,7 +474,6 @@
|
|||
|
||||
<LinearLayout
|
||||
android:id="@+id/participants_list"
|
||||
android:onClick="@{pickParticipantsClickListener}"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
|
|
@ -519,13 +518,22 @@
|
|||
android:layout_marginTop="20dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/meeting_schedule_send_invitations_title"
|
||||
android:textColor="@color/gray_main2_600"
|
||||
android:textSize="14sp"
|
||||
android:checked="@={viewModel.sendInvitations}"
|
||||
app:layout_constraintTop_toBottomOf="@id/separator_5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/material_switch_style"
|
||||
android:id="@+id/send_invitations_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:text="@string/meeting_schedule_send_invitations_title"
|
||||
app:layout_constraintStart_toEndOf="@id/send_invitations"
|
||||
app:layout_constraintTop_toTopOf="@id/send_invitations"
|
||||
app:layout_constraintBottom_toBottomOf="@id/send_invitations" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
|
|
|||
|
|
@ -48,11 +48,27 @@
|
|||
android:text="@{model.avatarModel.name, default=`John Doe`}"
|
||||
android:textSize="14sp"
|
||||
android:layout_marginStart="10dp"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
app:layout_constraintStart_toEndOf="@id/avatar"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/remove"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/remove"
|
||||
android:onClick="@{() -> model.removeFromSelection()}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:padding="12dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:src="@drawable/x"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:tint="@color/red_danger_500" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
||||
Loading…
Add table
Reference in a new issue