mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Added schedule meeting from conversation info, fixed previous participants removed when adding new participant(s) to a meeting schedule
This commit is contained in:
parent
4e602fc5e8
commit
3ea3ff288b
9 changed files with 95 additions and 8 deletions
|
|
@ -150,6 +150,16 @@ class ConversationInfoFragment : GenericFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
viewModel.goToScheduleMeetingEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { participants ->
|
||||
Log.i(
|
||||
"$TAG Forward participants list of size [${participants.size}] to schedule meeting fragment"
|
||||
)
|
||||
sharedViewModel.goToScheduleMeetingEvent.postValue(Event(participants))
|
||||
sharedViewModel.navigateToMeetingsEvent.postValue(Event(true))
|
||||
}
|
||||
}
|
||||
|
||||
sharedViewModel.listOfSelectedSipUrisEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { list ->
|
||||
Log.i("$TAG Found [${list.size}] new participants to add to the group, let's do it")
|
||||
|
|
|
|||
|
|
@ -78,6 +78,10 @@ class ConversationInfoViewModel @UiThread constructor() : ViewModel() {
|
|||
MutableLiveData<Event<Pair<View, ParticipantModel>>>()
|
||||
}
|
||||
|
||||
val goToScheduleMeetingEvent: MutableLiveData<Event<ArrayList<String>>> by lazy {
|
||||
MutableLiveData<Event<ArrayList<String>>>()
|
||||
}
|
||||
|
||||
private lateinit var chatRoom: ChatRoom
|
||||
|
||||
private val chatRoomListener = object : ChatRoomListenerStub() {
|
||||
|
|
@ -224,7 +228,43 @@ class ConversationInfoViewModel @UiThread constructor() : ViewModel() {
|
|||
|
||||
@UiThread
|
||||
fun call() {
|
||||
// TODO
|
||||
coreContext.postOnCoreThread { core ->
|
||||
if (LinphoneUtils.isChatRoomAGroup(chatRoom)) {
|
||||
// TODO
|
||||
} else {
|
||||
val firstParticipant = chatRoom.participants.firstOrNull()
|
||||
val address = firstParticipant?.address
|
||||
if (address != null) {
|
||||
val params = core.createCallParams(null)
|
||||
params?.isVideoEnabled = false
|
||||
coreContext.startCall(address, params)
|
||||
} else {
|
||||
Log.e("$TAG Failed to find participant to call!")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun scheduleMeeting() {
|
||||
coreContext.postOnCoreThread {
|
||||
if (LinphoneUtils.isChatRoomAGroup(chatRoom)) {
|
||||
val participantsList = arrayListOf<String>()
|
||||
for (participant in chatRoom.participants) {
|
||||
participantsList.add(participant.address.asStringUriOnly())
|
||||
goToScheduleMeetingEvent.postValue(Event(participantsList))
|
||||
}
|
||||
} else {
|
||||
val firstParticipant = chatRoom.participants.firstOrNull()
|
||||
val address = firstParticipant?.address
|
||||
if (address != null) {
|
||||
val participantsList = arrayListOf(address.asStringUriOnly())
|
||||
goToScheduleMeetingEvent.postValue(Event(participantsList))
|
||||
} else {
|
||||
Log.e("$TAG Failed to find participant to call!")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
|
|
|
|||
|
|
@ -176,6 +176,22 @@ class MeetingsListFragment : AbstractTopBarFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
sharedViewModel.goToScheduleMeetingEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { participants ->
|
||||
if (findNavController().currentDestination?.id == R.id.meetingsListFragment) {
|
||||
val participantsArray = participants.toTypedArray()
|
||||
Log.i(
|
||||
"$TAG Going to schedule meeting fragment with pre-populated participants array of size [${participantsArray.size}]"
|
||||
)
|
||||
val action =
|
||||
MeetingsListFragmentDirections.actionMeetingsListFragmentToScheduleMeetingFragment(
|
||||
participantsArray
|
||||
)
|
||||
findNavController().navigate(action)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TopBarFragment related
|
||||
|
||||
setViewModelAndTitle(
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import android.view.ViewGroup
|
|||
import androidx.annotation.UiThread
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.fragment.navArgs
|
||||
import com.google.android.material.datepicker.CalendarConstraints
|
||||
import com.google.android.material.datepicker.DateValidatorPointForward
|
||||
import com.google.android.material.datepicker.MaterialDatePicker
|
||||
|
|
@ -49,6 +50,8 @@ class ScheduleMeetingFragment : GenericFragment() {
|
|||
|
||||
private lateinit var viewModel: ScheduleMeetingViewModel
|
||||
|
||||
private val args: ScheduleMeetingFragmentArgs by navArgs()
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
|
|
@ -70,6 +73,12 @@ class ScheduleMeetingFragment : GenericFragment() {
|
|||
viewModel = ViewModelProvider(this)[ScheduleMeetingViewModel::class.java]
|
||||
binding.viewModel = viewModel
|
||||
|
||||
val participants = args.participants
|
||||
if (!participants.isNullOrEmpty()) {
|
||||
Log.i("$TAG Found pre-populated array of participants of size [${participants.size}]")
|
||||
viewModel.addParticipants(participants.toList())
|
||||
}
|
||||
|
||||
binding.setBackClickListener {
|
||||
goBack()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -264,9 +264,11 @@ class ScheduleMeetingViewModel @UiThread constructor() : ViewModel() {
|
|||
}
|
||||
|
||||
@UiThread
|
||||
fun addParticipants(toAdd: ArrayList<String>) {
|
||||
fun addParticipants(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) {
|
||||
|
|
@ -279,8 +281,13 @@ class ScheduleMeetingViewModel @UiThread constructor() : ViewModel() {
|
|||
// onRemoveFromSelection
|
||||
}
|
||||
list.add(model)
|
||||
Log.i("$TAG Added participant [${address.asStringUriOnly()}]")
|
||||
}
|
||||
}
|
||||
|
||||
Log.i(
|
||||
"$TAG [${toAdd.size}] participants added, now there are [${list.size}] participants in list"
|
||||
)
|
||||
participants.postValue(list)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ class FileViewerFragment : GenericFragment() {
|
|||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
isSlidingPaneChild = true
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
viewModel = ViewModelProvider(this)[FileViewModel::class.java]
|
||||
|
|
|
|||
|
|
@ -128,6 +128,10 @@ class SharedMainViewModel @UiThread constructor() : ViewModel() {
|
|||
MutableLiveData<Event<String>>()
|
||||
}
|
||||
|
||||
val goToScheduleMeetingEvent: MutableLiveData<Event<ArrayList<String>>> by lazy {
|
||||
MutableLiveData<Event<ArrayList<String>>>()
|
||||
}
|
||||
|
||||
/* Other */
|
||||
|
||||
val listOfSelectedSipUrisEvent: MutableLiveData<Event<ArrayList<String>>> by lazy {
|
||||
|
|
|
|||
|
|
@ -12,9 +12,6 @@
|
|||
<variable
|
||||
name="editSubjectClickListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="scheduleMeetingClickListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="addParticipantsClickListener"
|
||||
type="View.OnClickListener" />
|
||||
|
|
@ -222,7 +219,7 @@
|
|||
android:layout_height="56dp"
|
||||
android:layout_marginTop="40dp"
|
||||
android:background="@drawable/circle_light_blue_button_background"
|
||||
android:onClick="@{scheduleMeetingClickListener}"
|
||||
android:onClick="@{() -> viewModel.scheduleMeeting()}"
|
||||
android:padding="16dp"
|
||||
android:src="@drawable/meeting"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
|
@ -236,7 +233,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:onClick="@{scheduleMeetingClickListener}"
|
||||
android:onClick="@{() -> viewModel.scheduleMeeting()}"
|
||||
android:text="@string/meeting_schedule_meeting_label"
|
||||
android:textSize="14sp"
|
||||
app:layout_constraintEnd_toEndOf="@id/meeting"
|
||||
|
|
|
|||
|
|
@ -288,6 +288,11 @@
|
|||
app:exitAnim="@anim/slide_out_left"
|
||||
app:popEnterAnim="@anim/slide_in_left"
|
||||
app:popExitAnim="@anim/slide_out_right" />
|
||||
<argument
|
||||
android:name="participants"
|
||||
app:argType="string[]"
|
||||
app:nullable="true"
|
||||
android:defaultValue="@null" />
|
||||
</fragment>
|
||||
|
||||
<fragment
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue