Also added slide to delete conference info

This commit is contained in:
Sylvain Berfini 2022-09-05 16:30:55 +02:00
parent 77331e9b94
commit 303768e2bf
2 changed files with 55 additions and 11 deletions

View file

@ -32,7 +32,7 @@ Group changes to describe their impact on the project, as follows:
- Improved how contact avatars are generated
- 3-dots menu even for basic chat rooms with more options
- Phone numbers & email addresses are now clickable links in chat messages
- Go to call activity when there is at least one active call and you click on launcher icon
- Go to call activity when you click on launcher icon if there is at least one active call
### Fixed
- Multiple file download attempt from the same chat bubble at the same time needed app restart to properly download each file
@ -46,6 +46,8 @@ Group changes to describe their impact on the project, as follows:
- Trying to keep the preferred driver (OpenSLES / AAudio) when switching device
- Issues when storing presence in native contacts + potentially duplicated SIP addresses in contact details
- Chat room scroll position lost when going into sub-view
- No longer makes requests to our LIME server (end-to-end encryption keys server) for non sip.linphone.org accounts
- Fixed incoming call/notification not ringing if Do not Disturb mode is enabled except for favorite contacts
## [4.6.13] - 2022-08-25

View file

@ -25,8 +25,11 @@ import android.content.ClipboardManager
import android.content.Context
import android.os.Bundle
import android.view.View
import androidx.core.content.ContextCompat
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import org.linphone.R
import org.linphone.activities.main.MainActivity
import org.linphone.activities.main.conference.adapters.ScheduledConferencesAdapter
@ -36,15 +39,13 @@ import org.linphone.activities.main.fragments.MasterFragment
import org.linphone.activities.main.viewmodels.DialogViewModel
import org.linphone.activities.navigateToConferenceScheduling
import org.linphone.activities.navigateToConferenceWaitingRoom
import org.linphone.core.tools.Log
import org.linphone.databinding.ConferencesScheduledFragmentBinding
import org.linphone.utils.AppUtils
import org.linphone.utils.DialogUtils
import org.linphone.utils.Event
import org.linphone.utils.RecyclerViewHeaderDecoration
import org.linphone.utils.*
class ScheduledConferencesFragment : MasterFragment<ConferencesScheduledFragmentBinding, ScheduledConferencesAdapter>() {
override val dialogConfirmationMessageBeforeRemoval = R.plurals.conference_scheduled_delete_dialog
private lateinit var viewModel: ScheduledConferencesViewModel
private lateinit var listViewModel: ScheduledConferencesViewModel
override fun getLayoutId(): Int = R.layout.conferences_scheduled_fragment
@ -55,10 +56,10 @@ class ScheduledConferencesFragment : MasterFragment<ConferencesScheduledFragment
binding.lifecycleOwner = viewLifecycleOwner
viewModel = ViewModelProvider(
listViewModel = ViewModelProvider(
this
)[ScheduledConferencesViewModel::class.java]
binding.viewModel = viewModel
binding.viewModel = listViewModel
_adapter = ScheduledConferencesAdapter(listSelectionViewModel, viewLifecycleOwner)
binding.conferenceInfoList.adapter = adapter
@ -66,11 +67,52 @@ class ScheduledConferencesFragment : MasterFragment<ConferencesScheduledFragment
val layoutManager = LinearLayoutManager(requireContext())
binding.conferenceInfoList.layoutManager = layoutManager
// Swipe action
val swipeConfiguration = RecyclerViewSwipeConfiguration()
val white = ContextCompat.getColor(requireContext(), R.color.white_color)
swipeConfiguration.rightToLeftAction = RecyclerViewSwipeConfiguration.Action(
requireContext().getString(R.string.dialog_delete),
white,
ContextCompat.getColor(requireContext(), R.color.red_color)
)
val swipeListener = object : RecyclerViewSwipeListener {
override fun onLeftToRightSwipe(viewHolder: RecyclerView.ViewHolder) {}
override fun onRightToLeftSwipe(viewHolder: RecyclerView.ViewHolder) {
val viewModel = DialogViewModel(getString(R.string.conference_scheduled_delete_one_dialog))
val dialog: Dialog = DialogUtils.getDialog(requireContext(), viewModel)
val index = viewHolder.bindingAdapterPosition
if (index < 0 || index >= adapter.currentList.size) {
Log.e("[Scheduled Conferences] Index is out of bound, can't delete conference info")
} else {
viewModel.showCancelButton {
adapter.notifyItemChanged(index)
dialog.dismiss()
}
viewModel.showDeleteButton(
{
val deletedConfInfo = adapter.currentList[index]
listViewModel.deleteConferenceInfo(deletedConfInfo)
dialog.dismiss()
},
getString(R.string.dialog_delete)
)
}
dialog.show()
}
}
RecyclerViewSwipeUtils(ItemTouchHelper.LEFT, swipeConfiguration, swipeListener)
.attachToRecyclerView(binding.conferenceInfoList)
// Displays date header
val headerItemDecoration = RecyclerViewHeaderDecoration(requireContext(), adapter)
binding.conferenceInfoList.addItemDecoration(headerItemDecoration)
viewModel.conferences.observe(
listViewModel.conferences.observe(
viewLifecycleOwner
) {
adapter.submitList(it)
@ -124,7 +166,7 @@ class ScheduledConferencesFragment : MasterFragment<ConferencesScheduledFragment
dialogViewModel.showDeleteButton(
{
viewModel.deleteConferenceInfo(data)
listViewModel.deleteConferenceInfo(data)
deleteConferenceInfoDialog?.dismiss()
(requireActivity() as MainActivity).showSnackBar(R.string.conference_info_removed)
},
@ -146,6 +188,6 @@ class ScheduledConferencesFragment : MasterFragment<ConferencesScheduledFragment
val conferenceData = adapter.currentList[index]
list.add(conferenceData)
}
viewModel.deleteConferencesInfo(list)
listViewModel.deleteConferencesInfo(list)
}
}