From a49cb0935d0c0258eb34b92c7d5da033f63c1cf3 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 23 Oct 2023 11:59:32 +0200 Subject: [PATCH] Started add participant to existing group chat room --- .../AddParticipantToConversationFragment.kt | 69 ++++++++ .../chat/fragment/ConversationInfoFragment.kt | 5 + .../ConversationAddParticipantViewModel.kt | 36 ++++ .../layout/chat_add_participant_fragment.xml | 154 ++++++++++++++++++ .../main/res/navigation/chat_nav_graph.xml | 13 ++ app/src/main/res/values/strings.xml | 1 + 6 files changed, 278 insertions(+) create mode 100644 app/src/main/java/org/linphone/ui/main/chat/fragment/AddParticipantToConversationFragment.kt create mode 100644 app/src/main/java/org/linphone/ui/main/chat/viewmodel/ConversationAddParticipantViewModel.kt create mode 100644 app/src/main/res/layout/chat_add_participant_fragment.xml diff --git a/app/src/main/java/org/linphone/ui/main/chat/fragment/AddParticipantToConversationFragment.kt b/app/src/main/java/org/linphone/ui/main/chat/fragment/AddParticipantToConversationFragment.kt new file mode 100644 index 000000000..56925cf66 --- /dev/null +++ b/app/src/main/java/org/linphone/ui/main/chat/fragment/AddParticipantToConversationFragment.kt @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2010-2023 Belledonne Communications SARL. + * + * This file is part of linphone-android + * (see https://www.linphone.org). + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.linphone.ui.main.chat.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.annotation.UiThread +import androidx.lifecycle.ViewModelProvider +import androidx.navigation.fragment.findNavController +import org.linphone.databinding.ChatAddParticipantFragmentBinding +import org.linphone.ui.main.chat.viewmodel.ConversationAddParticipantViewModel +import org.linphone.ui.main.fragment.GenericFragment + +@UiThread +class AddParticipantToConversationFragment : GenericFragment() { + + private lateinit var binding: ChatAddParticipantFragmentBinding + + private lateinit var viewModel: ConversationAddParticipantViewModel + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + binding = ChatAddParticipantFragmentBinding.inflate(layoutInflater) + return binding.root + } + + override fun goBack(): Boolean { + findNavController().popBackStack() + return true + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + // This fragment is displayed in a SlidingPane "child" area + isSlidingPaneChild = true + + super.onViewCreated(view, savedInstanceState) + + binding.lifecycleOwner = viewLifecycleOwner + + viewModel = ViewModelProvider(this)[ConversationAddParticipantViewModel::class.java] + binding.viewModel = viewModel + + binding.setBackClickListener { + goBack() + } + } +} diff --git a/app/src/main/java/org/linphone/ui/main/chat/fragment/ConversationInfoFragment.kt b/app/src/main/java/org/linphone/ui/main/chat/fragment/ConversationInfoFragment.kt index 13cceadad..66d5b8caa 100644 --- a/app/src/main/java/org/linphone/ui/main/chat/fragment/ConversationInfoFragment.kt +++ b/app/src/main/java/org/linphone/ui/main/chat/fragment/ConversationInfoFragment.kt @@ -126,6 +126,11 @@ class ConversationInfoFragment : GenericFragment() { binding.setBackClickListener { goBack() } + + binding.setAddParticipantsClickListener { + val action = ConversationInfoFragmentDirections.actionConversationInfoFragmentToAddParticipantToConversationFragment() + findNavController().navigate(action) + } } private fun showParticipantAdminPopupMenu(view: View, participantModel: ParticipantModel) { diff --git a/app/src/main/java/org/linphone/ui/main/chat/viewmodel/ConversationAddParticipantViewModel.kt b/app/src/main/java/org/linphone/ui/main/chat/viewmodel/ConversationAddParticipantViewModel.kt new file mode 100644 index 000000000..940c7cd05 --- /dev/null +++ b/app/src/main/java/org/linphone/ui/main/chat/viewmodel/ConversationAddParticipantViewModel.kt @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2010-2023 Belledonne Communications SARL. + * + * This file is part of linphone-android + * (see https://www.linphone.org). + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.linphone.ui.main.chat.viewmodel + +import androidx.annotation.UiThread +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.ViewModel +import org.linphone.ui.main.history.model.ContactOrSuggestionModel + +class ConversationAddParticipantViewModel @UiThread constructor() : ViewModel() { + val searchFilter = MutableLiveData() + + val contactsList = MutableLiveData>() + + @UiThread + fun clearFilter() { + searchFilter.value = "" + } +} diff --git a/app/src/main/res/layout/chat_add_participant_fragment.xml b/app/src/main/res/layout/chat_add_participant_fragment.xml new file mode 100644 index 000000000..a28be9745 --- /dev/null +++ b/app/src/main/res/layout/chat_add_participant_fragment.xml @@ -0,0 +1,154 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/navigation/chat_nav_graph.xml b/app/src/main/res/navigation/chat_nav_graph.xml index e24a18af3..ae1b2c3be 100644 --- a/app/src/main/res/navigation/chat_nav_graph.xml +++ b/app/src/main/res/navigation/chat_nav_graph.xml @@ -47,6 +47,19 @@ + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ed4940aaf..aaedfd5cb 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -352,6 +352,7 @@ %s is composing… %s are composing… + Add participant Group members Add participants