Ask user confirmation for cancelling meeting if it us the organizer, to delete it if it's only a participant

This commit is contained in:
Sylvain Berfini 2025-02-04 11:23:28 +01:00
parent 0f59e1a381
commit bfc435c350
12 changed files with 228 additions and 22 deletions

View file

@ -214,6 +214,8 @@ class ConversationsListFragment : AbstractMainFragment() {
uri
)
findNavController().navigate(action)
} else {
Log.e("$TAG Failed to navigate to meeting waiting room, wrong current destination (expected conversationsListFragment but was something else)")
}
}
}

View file

@ -198,7 +198,7 @@ class MeetingFragment : SlidingPaneChildFragment() {
viewModel.conferenceCancelledEvent.observe(viewLifecycleOwner) {
it.consume {
Log.i("$TAG Meeting has been cancelled successfully, deleting it")
Log.i("$TAG Meeting has been cancelled successfully")
(requireActivity() as GenericActivity).showGreenToast(
getString(R.string.meeting_info_cancelled_toast),
R.drawable.trash_simple
@ -222,11 +222,15 @@ class MeetingFragment : SlidingPaneChildFragment() {
true
)
val isUserOrganizer = viewModel.isEditable.value == true && viewModel.isCancelled.value == false
popupView.cancelInsteadOfDelete = isUserOrganizer
popupView.setDeleteClickListener {
if (viewModel.isEditable.value == true) {
if (isUserOrganizer) {
// In case we are organizer of the meeting, ask user confirmation before cancelling it
showCancelMeetingDialog()
} else {
viewModel.delete()
// If we're not organizer, ask user confirmation of removing itself from participants & deleting it locally
showDeleteMeetingDialog()
}
popupWindow.dismiss()
}
@ -283,8 +287,7 @@ class MeetingFragment : SlidingPaneChildFragment() {
}
private fun showCancelMeetingDialog() {
Log.i("$TAG Meeting is editable, asking whether to cancel it or not before deleting it")
Log.i("$TAG Meeting is editable, asking whether to cancel it or not")
val model = ConfirmationDialogModel()
val dialog = DialogUtils.getCancelMeetingDialog(requireContext(), model)
@ -296,7 +299,6 @@ class MeetingFragment : SlidingPaneChildFragment() {
model.cancelEvent.observe(viewLifecycleOwner) {
it.consume {
viewModel.delete()
dialog.dismiss()
}
}
@ -310,4 +312,31 @@ class MeetingFragment : SlidingPaneChildFragment() {
dialog.show()
}
private fun showDeleteMeetingDialog() {
Log.i("$TAG Meeting is not editable or already cancelled, asking whether to delete it or not")
val model = ConfirmationDialogModel()
val dialog = DialogUtils.getDeleteMeetingDialog(requireContext(), model)
model.dismissEvent.observe(viewLifecycleOwner) {
it.consume {
dialog.dismiss()
}
}
model.cancelEvent.observe(viewLifecycleOwner) {
it.consume {
dialog.dismiss()
}
}
model.confirmEvent.observe(viewLifecycleOwner) {
it.consume {
viewModel.delete()
dialog.dismiss()
}
}
dialog.show()
}
}

View file

@ -177,6 +177,7 @@ class MeetingsListFragment : AbstractMainFragment() {
meetingViewModelBeingCancelled?.delete()
meetingViewModelBeingCancelled = null
listViewModel.applyFilter()
(requireActivity() as GenericActivity).showGreenToast(
getString(R.string.meeting_info_deleted_toast),
R.drawable.trash_simple
@ -186,22 +187,25 @@ class MeetingsListFragment : AbstractMainFragment() {
adapter.meetingLongClickedEvent.observe(viewLifecycleOwner) {
it.consume { model ->
val isUserOrganizer = model.isOrganizer() && !model.isCancelled
val modalBottomSheet = MeetingsMenuDialogFragment(
isUserOrganizer,
{ // onDismiss
adapter.resetSelection()
},
{ // onDelete
if (model.isOrganizer() && !model.isCancelled) {
if (isUserOrganizer) {
showCancelMeetingDialog(model)
} else {
Log.i("$TAG Deleting meeting [${model.id}]")
showDeleteMeetingDialog(model)
/*Log.i("$TAG Deleting meeting [${model.id}]")
model.delete()
listViewModel.applyFilter()
(requireActivity() as GenericActivity).showGreenToast(
getString(R.string.meeting_info_deleted_toast),
R.drawable.trash_simple
)
)*/
}
}
)
@ -326,15 +330,7 @@ class MeetingsListFragment : AbstractMainFragment() {
model.cancelEvent.observe(viewLifecycleOwner) {
it.consume {
Log.i("$TAG Deleting meeting [${meetingModel.id}]")
meetingModel.delete()
listViewModel.applyFilter()
dialog.dismiss()
(requireActivity() as GenericActivity).showGreenToast(
getString(R.string.meeting_info_deleted_toast),
R.drawable.trash_simple
)
}
}
@ -349,4 +345,39 @@ class MeetingsListFragment : AbstractMainFragment() {
dialog.show()
}
private fun showDeleteMeetingDialog(meetingModel: MeetingModel) {
Log.i("$TAG Meeting is not editable or already cancelled, asking whether to deleting it or not")
val model = ConfirmationDialogModel()
val dialog = DialogUtils.getDeleteMeetingDialog(requireContext(), model)
model.dismissEvent.observe(viewLifecycleOwner) {
it.consume {
dialog.dismiss()
}
}
model.cancelEvent.observe(viewLifecycleOwner) {
it.consume {
dialog.dismiss()
}
}
model.confirmEvent.observe(viewLifecycleOwner) {
it.consume {
Log.i("$TAG Deleting meeting [${meetingModel.id}]")
meetingModel.delete()
listViewModel.applyFilter()
dialog.dismiss()
(requireActivity() as GenericActivity).showGreenToast(
getString(R.string.meeting_info_deleted_toast),
R.drawable.trash_simple
)
}
}
dialog.show()
}
}

View file

@ -33,6 +33,7 @@ import org.linphone.databinding.MeetingsListLongPressMenuBinding
@UiThread
class MeetingsMenuDialogFragment(
private val isUserOrganizer: Boolean,
private val onDismiss: (() -> Unit)? = null,
private val onDeleteMeeting: (() -> Unit)? = null
) : BottomSheetDialogFragment() {
@ -64,6 +65,7 @@ class MeetingsMenuDialogFragment(
savedInstanceState: Bundle?
): View {
val view = MeetingsListLongPressMenuBinding.inflate(layoutInflater)
view.cancelInsteadOfDelete = isUserOrganizer
view.setDeleteClickListener {
onDeleteMeeting?.invoke()

View file

@ -190,6 +190,14 @@ class MeetingWaitingRoomViewModel
conferenceInfoFoundEvent.postValue(Event(true))
} else {
Log.e("$TAG Conference info with SIP URI [$uri] couldn't be found!")
showRedToastEvent.postValue(
Event(
Pair(
R.string.meeting_info_not_found_toast,
R.drawable.warning_circle
)
)
)
conferenceInfoFoundEvent.postValue(Event(false))
}
} else {

View file

@ -43,6 +43,7 @@ import org.linphone.databinding.DialogConfirmTurningOnVfsBinding
import org.linphone.databinding.DialogContactConfirmTrustCallBinding
import org.linphone.databinding.DialogContactTrustProcessBinding
import org.linphone.databinding.DialogDeleteContactBinding
import org.linphone.databinding.DialogDeleteMeetingBinding
import org.linphone.databinding.DialogKickFromConferenceBinding
import org.linphone.databinding.DialogManageAccountInternationalPrefixHelpBinding
import org.linphone.databinding.DialogMergeCallsIntoConferenceBinding
@ -513,6 +514,22 @@ class DialogUtils {
return getDialog(context, binding)
}
@UiThread
fun getDeleteMeetingDialog(
context: Context,
viewModel: ConfirmationDialogModel
): Dialog {
val binding: DialogDeleteMeetingBinding = DataBindingUtil.inflate(
LayoutInflater.from(context),
R.layout.dialog_delete_meeting,
null,
false
)
binding.viewModel = viewModel
return getDialog(context, binding)
}
@UiThread
private fun getDialog(context: Context, binding: ViewDataBinding): Dialog {
val dialog = Dialog(context, R.style.Theme_LinphoneDialog)

View file

@ -68,7 +68,7 @@
android:layout_marginTop="32dp"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:text="@string/dialog_no"
android:text= "@string/dialog_no"
app:layout_constraintStart_toStartOf="@id/dialog_background"
app:layout_constraintEnd_toEndOf="@id/dialog_background"
app:layout_constraintTop_toBottomOf="@id/message"

View file

@ -0,0 +1,103 @@
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<import type="android.view.View" />
<variable
name="viewModel"
type="org.linphone.utils.ConfirmationDialogModel" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:onClick="@{() -> viewModel.dismiss()}"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/dialog_background"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="12dp"
android:layout_marginEnd="12dp"
android:layout_marginBottom="2dp"
android:src="@drawable/shape_dialog_background"
android:contentDescription="@null"
app:layout_constraintWidth_max="@dimen/dialog_max_width"
app:layout_constraintBottom_toBottomOf="@id/anchor"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/title" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/section_header_style"
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:paddingTop="@dimen/dialog_top_bottom_margin"
android:text="@string/meeting_schedule_delete_dialog_title"
app:layout_constraintVertical_chainStyle="packed"
app:layout_constraintBottom_toTopOf="@id/message"
app:layout_constraintStart_toStartOf="@id/dialog_background"
app:layout_constraintEnd_toEndOf="@id/dialog_background"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style"
android:id="@+id/message"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:layout_marginTop="10dp"
android:text="@string/meeting_schedule_delete_dialog_message"
android:textSize="14sp"
app:layout_constraintBottom_toTopOf="@id/cancel"
app:layout_constraintStart_toStartOf="@id/dialog_background"
app:layout_constraintEnd_toEndOf="@id/dialog_background"
app:layout_constraintTop_toBottomOf="@id/title" />
<androidx.appcompat.widget.AppCompatTextView
android:onClick="@{() -> viewModel.cancel()}"
style="@style/secondary_button_label_style"
android:id="@+id/cancel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:text="@string/dialog_no"
app:layout_constraintStart_toStartOf="@id/dialog_background"
app:layout_constraintEnd_toEndOf="@id/dialog_background"
app:layout_constraintTop_toBottomOf="@id/message"
app:layout_constraintBottom_toTopOf="@id/confirm"/>
<androidx.appcompat.widget.AppCompatTextView
android:onClick="@{() -> viewModel.confirm()}"
style="@style/primary_button_label_style"
android:id="@+id/confirm"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:text="@string/dialog_yes"
app:layout_constraintStart_toStartOf="@id/dialog_background"
app:layout_constraintEnd_toEndOf="@id/dialog_background"
app:layout_constraintTop_toBottomOf="@id/cancel"
app:layout_constraintBottom_toTopOf="@id/anchor"/>
<View
android:id="@+id/anchor"
android:layout_width="wrap_content"
android:layout_height="@dimen/dialog_top_bottom_margin"
app:layout_constraintTop_toBottomOf="@id/confirm"
app:layout_constraintStart_toStartOf="@id/dialog_background"
app:layout_constraintEnd_toEndOf="@id/dialog_background"
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

View file

@ -11,6 +11,9 @@
<variable
name="createCalendarEventListener"
type="View.OnClickListener" />
<variable
name="cancelInsteadOfDelete"
type="Boolean" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
@ -49,7 +52,7 @@
android:layout_marginBottom="20dp"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:text="@string/meeting_info_delete"
android:text="@{cancelInsteadOfDelete ? @string/meeting_cancel_action_label : @string/meeting_delete_action_label, default=@string/meeting_delete_action_label}"
android:textSize="14sp"
android:textColor="?attr/color_danger_500"
android:drawableStart="@drawable/trash_simple"

View file

@ -7,6 +7,9 @@
<variable
name="deleteClickListener"
type="View.OnClickListener" />
<variable
name="cancelInsteadOfDelete"
type="Boolean" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
@ -19,7 +22,7 @@
android:onClick="@{deleteClickListener}"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/menu_delete_selected_item"
android:text="@{cancelInsteadOfDelete ? @string/meeting_cancel_action_label : @string/meeting_delete_action_label, default=@string/meeting_delete_action_label}"
style="@style/context_menu_danger_action_label_style"
android:background="@drawable/menu_item_background"
android:layout_marginBottom="1dp"

View file

@ -573,13 +573,17 @@
<string name="meeting_schedule_send_invitations_title">Envoyer l\'invitation par message aux participants</string>
<string name="meeting_info_join_title">Rejoindre la réunion</string>
<string name="meeting_info_organizer_label">Organisateur</string>
<string name="meeting_info_delete">Supprimer la réunion</string>
<string name="meeting_info_export_as_calendar_event">Ajouter dans le calendrier</string>
<string name="meeting_info_deleted_toast">Réunion supprimée</string>
<string name="meeting_info_not_found_toast">Réunion introuvable !</string>
<string name="meeting_schedule_description_title">Description</string>
<string name="meeting_schedule_edit_title">Modifier la réunion</string>
<string name="meeting_schedule_cancel_dialog_title">Annuler la réunion?</string>
<string name="meeting_schedule_cancel_dialog_message">Voulez-vous annuler la réunion et envoyer une notification aux participants ?</string>
<string name="meeting_cancel_action_label">Annuler la réunion</string>
<string name="meeting_schedule_delete_dialog_title">Supprimer la réunion ?</string>
<string name="meeting_schedule_delete_dialog_message">Voulez-vous supprimer la réunion ?</string>
<string name="meeting_delete_action_label">Supprimer la réunion</string>
<string name="meeting_info_created_toast">Réunion créée</string>
<string name="meeting_info_updated_toast">Réunion mise à jour</string>
<string name="meeting_info_cancelled_toast">Réunion annulée</string>

View file

@ -613,13 +613,17 @@
<string name="meeting_schedule_send_invitations_title">Send invitation to participants</string>
<string name="meeting_info_join_title">Join the meeting now</string>
<string name="meeting_info_organizer_label">Organizer</string>
<string name="meeting_info_delete">Delete meeting</string>
<string name="meeting_info_export_as_calendar_event">Create calendar event</string>
<string name="meeting_info_deleted_toast">Meeting has been deleted</string>
<string name="meeting_info_not_found_toast">Meeting cannot be found!</string>
<string name="meeting_schedule_description_title">Description</string>
<string name="meeting_schedule_edit_title">Edit meeting</string>
<string name="meeting_schedule_cancel_dialog_title">Cancel the meeting?</string>
<string name="meeting_schedule_cancel_dialog_message">Do you want to cancel the meeting and send a notification to all participants?</string>
<string name="meeting_cancel_action_label">Cancel meeting</string>
<string name="meeting_schedule_delete_dialog_title">Delete the meeting?</string>
<string name="meeting_schedule_delete_dialog_message">Do you want to delete the meeting?</string>
<string name="meeting_delete_action_label">Delete meeting</string>
<string name="meeting_info_created_toast">Meeting has been created</string>
<string name="meeting_info_updated_toast">Meeting has been updated</string>
<string name="meeting_info_cancelled_toast">Meeting has been cancelled</string>