mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 03:18:06 +00:00
Added confirmation dialog before removing contact from list
This commit is contained in:
parent
9df97d7594
commit
68f2535072
7 changed files with 60 additions and 26 deletions
|
|
@ -347,7 +347,7 @@ class ContactsManager @UiThread constructor() {
|
|||
fakeFriend.name = LinphoneUtils.getDisplayName(localAccount.params.identityAddress)
|
||||
fakeFriend.photo = localAccount.params.pictureUri
|
||||
val model = ContactAvatarModel(fakeFriend)
|
||||
model.trust.postValue(SecurityLevel.EndToEndEncryptedAndVerified) // TODO CHECK: as it is ourselves, force encrypted level?
|
||||
model.trust.postValue(SecurityLevel.EndToEndEncryptedAndVerified)
|
||||
unknownContactsAvatarsMap[key] = model
|
||||
model
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class ZrtpSasConfirmationDialogModel @UiThread constructor(
|
|||
authTokenToRead
|
||||
)
|
||||
|
||||
// TODO: improve algo?
|
||||
// TODO FIXME: use SDK API when it will be available
|
||||
val rnd = Random()
|
||||
val randomLetters1 = "${ALPHABET[rnd.nextInt(ALPHABET.length)]}${ALPHABET[
|
||||
rnd.nextInt(
|
||||
|
|
|
|||
|
|
@ -224,6 +224,7 @@ class ContactFragment : SlidingPaneChildFragment() {
|
|||
Log.w(
|
||||
"$TAG Contact [${viewModel.contact.value?.name?.value}] has been deleted"
|
||||
)
|
||||
// TODO: show green toast
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,14 +38,16 @@ import androidx.navigation.fragment.findNavController
|
|||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import java.io.File
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.R
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.ContactsListFilterPopupMenuBinding
|
||||
import org.linphone.databinding.ContactsListFragmentBinding
|
||||
import org.linphone.ui.main.contacts.adapter.ContactsListAdapter
|
||||
import org.linphone.ui.main.contacts.model.ContactAvatarModel
|
||||
import org.linphone.ui.main.contacts.viewmodel.ContactsListViewModel
|
||||
import org.linphone.ui.main.fragment.AbstractMainFragment
|
||||
import org.linphone.ui.main.history.model.ConfirmationDialogModel
|
||||
import org.linphone.utils.DialogUtils
|
||||
import org.linphone.utils.Event
|
||||
|
||||
@UiThread
|
||||
|
|
@ -203,16 +205,7 @@ class ContactsListFragment : AbstractMainFragment() {
|
|||
adapter.resetSelection()
|
||||
},
|
||||
{ // onFavourite
|
||||
coreContext.postOnCoreThread {
|
||||
model.friend.edit()
|
||||
val starred = !model.friend.starred
|
||||
Log.i(
|
||||
"$TAG Friend [${model.name.value}] will be ${if (starred) "added to" else "removed from"} favourites"
|
||||
)
|
||||
model.friend.starred = starred
|
||||
model.friend.done()
|
||||
coreContext.contactsManager.notifyContactsListChanged()
|
||||
}
|
||||
listViewModel.toggleContactFavoriteFlag(model)
|
||||
},
|
||||
{ // onShare
|
||||
Log.i(
|
||||
|
|
@ -221,13 +214,7 @@ class ContactsListFragment : AbstractMainFragment() {
|
|||
listViewModel.exportContactAsVCard(model.friend)
|
||||
},
|
||||
{ // onDelete
|
||||
coreContext.postOnCoreThread {
|
||||
// TODO: confirmation dialog + confirmation toast once deleted
|
||||
Log.w("$TAG Removing friend [${model.name.value}]")
|
||||
coreContext.contactsManager.contactRemoved(model.friend)
|
||||
model.friend.remove()
|
||||
coreContext.contactsManager.notifyContactsListChanged()
|
||||
}
|
||||
showDeleteConfirmationDialog(model)
|
||||
}
|
||||
)
|
||||
modalBottomSheet.show(parentFragmentManager, ContactsListMenuDialogFragment.TAG)
|
||||
|
|
@ -320,4 +307,28 @@ class ContactsListFragment : AbstractMainFragment() {
|
|||
popupWindow.elevation = 20f
|
||||
popupWindow.showAsDropDown(view, 0, 0, Gravity.BOTTOM)
|
||||
}
|
||||
|
||||
private fun showDeleteConfirmationDialog(contactModel: ContactAvatarModel) {
|
||||
val model = ConfirmationDialogModel()
|
||||
val dialog = DialogUtils.getDeleteContactConfirmationDialog(
|
||||
requireActivity(),
|
||||
model,
|
||||
contactModel.contactName.orEmpty()
|
||||
)
|
||||
|
||||
model.dismissEvent.observe(viewLifecycleOwner) {
|
||||
it.consume {
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
model.confirmEvent.observe(viewLifecycleOwner) {
|
||||
it.consume {
|
||||
listViewModel.deleteContact(contactModel)
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
dialog.show()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -197,6 +197,31 @@ class ContactsListViewModel @UiThread constructor() : AbstractMainViewModel() {
|
|||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun toggleContactFavoriteFlag(contactModel: ContactAvatarModel) {
|
||||
coreContext.postOnCoreThread {
|
||||
contactModel.friend.edit()
|
||||
val starred = !contactModel.friend.starred
|
||||
Log.i(
|
||||
"$TAG Friend [${contactModel.name.value}] will be ${if (starred) "added to" else "removed from"} favourites"
|
||||
)
|
||||
contactModel.friend.starred = starred
|
||||
contactModel.friend.done()
|
||||
coreContext.contactsManager.notifyContactsListChanged()
|
||||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun deleteContact(contactModel: ContactAvatarModel) {
|
||||
coreContext.postOnCoreThread {
|
||||
Log.w("$TAG Removing friend [${contactModel.contactName}]")
|
||||
coreContext.contactsManager.contactRemoved(contactModel.friend)
|
||||
contactModel.friend.remove()
|
||||
coreContext.contactsManager.notifyContactsListChanged()
|
||||
// TODO: show green toast
|
||||
}
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
private fun applyFilter(
|
||||
filter: String,
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ class MediaViewModel @UiThread constructor() : ViewModel() {
|
|||
FileUtils.MimeType.Audio -> {
|
||||
Log.i("$TAG File [$file] seems to be an audio file")
|
||||
isAudio.value = true
|
||||
// TODO: handle audio files
|
||||
// TODO FIXME: handle audio files
|
||||
}
|
||||
else -> { }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ import org.linphone.ui.assistant.AssistantActivity
|
|||
import org.linphone.ui.main.MainActivity
|
||||
import org.linphone.ui.main.settings.fragment.AccountProfileFragmentDirections
|
||||
import org.linphone.ui.main.viewmodel.DrawerMenuViewModel
|
||||
import org.linphone.ui.welcome.WelcomeActivity
|
||||
|
||||
@UiThread
|
||||
class DrawerMenuFragment : GenericFragment() {
|
||||
|
|
@ -81,11 +80,9 @@ class DrawerMenuFragment : GenericFragment() {
|
|||
}
|
||||
|
||||
binding.setRecordingsClickListener {
|
||||
// TODO: recordings feature
|
||||
/*val navController = (requireActivity() as MainActivity).findNavController()
|
||||
val navController = (requireActivity() as MainActivity).findNavController()
|
||||
navController.navigate(R.id.action_global_recordingsFragment)
|
||||
(requireActivity() as MainActivity).closeDrawerMenu()*/
|
||||
startActivity(Intent(requireActivity(), WelcomeActivity::class.java))
|
||||
(requireActivity() as MainActivity).closeDrawerMenu()
|
||||
}
|
||||
|
||||
binding.setHelpClickedListener {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue