mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Added missing add / go to contact action from calls list context menu + added logs
This commit is contained in:
parent
64c29d495d
commit
60965b767c
9 changed files with 129 additions and 37 deletions
|
|
@ -138,7 +138,6 @@ class CallFragment : GenericFragment() {
|
|||
popupView.contactExists = viewModel.callLogModel.value?.friendExists == true
|
||||
|
||||
popupView.setAddToContactsListener {
|
||||
// TODO: go to new contact fragment
|
||||
sharedViewModel.sipAddressToAddToNewContact = viewModel.callLogModel.value?.displayedAddress.orEmpty()
|
||||
sharedViewModel.navigateToContactsEvent.value = Event(true)
|
||||
sharedViewModel.showNewContactEvent.value = Event(true)
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import androidx.navigation.navGraphViewModels
|
|||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.R
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.CallsListFragmentBinding
|
||||
import org.linphone.databinding.CallsListPopupMenuBinding
|
||||
import org.linphone.ui.main.MainActivity
|
||||
|
|
@ -50,6 +51,9 @@ import org.linphone.utils.Event
|
|||
|
||||
@UiThread
|
||||
class CallsListFragment : GenericFragment() {
|
||||
companion object {
|
||||
const val TAG = "[Calls List Fragment]"
|
||||
}
|
||||
|
||||
private lateinit var binding: CallsListFragmentBinding
|
||||
|
||||
|
|
@ -89,17 +93,45 @@ class CallsListFragment : GenericFragment() {
|
|||
|
||||
adapter.callLogLongClickedEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { model ->
|
||||
val modalBottomSheet = CallsListMenuDialogFragment({
|
||||
// onDismiss
|
||||
adapter.resetSelection()
|
||||
}, {
|
||||
// onCopyNumberOrAddressToClipboard
|
||||
copyNumberOrAddressToClipboard(model.displayedAddress)
|
||||
}, {
|
||||
// onDeleteCallLog
|
||||
model.delete()
|
||||
adapter.deleteSelection()
|
||||
})
|
||||
val modalBottomSheet = CallsListMenuDialogFragment(
|
||||
model.friendExists,
|
||||
{ // onDismiss
|
||||
adapter.resetSelection()
|
||||
},
|
||||
{ // onAddToContact
|
||||
val addressToAdd = model.displayedAddress
|
||||
Log.i(
|
||||
"$TAG Navigating to new contact with pre-filled value [$addressToAdd]"
|
||||
)
|
||||
|
||||
sharedViewModel.sipAddressToAddToNewContact = addressToAdd
|
||||
sharedViewModel.navigateToContactsEvent.value = Event(true)
|
||||
sharedViewModel.showNewContactEvent.value = Event(true)
|
||||
},
|
||||
{ // onGoToContact
|
||||
val friendRefKey = model.friendRefKey
|
||||
if (!friendRefKey.isNullOrEmpty()) {
|
||||
Log.i("$TAG Navigating to contact with ref key [$friendRefKey]")
|
||||
|
||||
sharedViewModel.navigateToContactsEvent.value = Event(true)
|
||||
sharedViewModel.showContactEvent.value = Event(friendRefKey)
|
||||
} else {
|
||||
Log.w(
|
||||
"$TAG Can't navigate to existing friend, ref key is null or empty"
|
||||
)
|
||||
}
|
||||
},
|
||||
{ // onCopyNumberOrAddressToClipboard
|
||||
val addressToCopy = model.displayedAddress
|
||||
Log.i("$TAG Copying number [$addressToCopy] to clipboard")
|
||||
copyNumberOrAddressToClipboard(addressToCopy)
|
||||
},
|
||||
{ // onDeleteCallLog
|
||||
Log.i("$TAG Deleting call log with ref key or call ID [${model.id}]")
|
||||
model.delete()
|
||||
adapter.deleteSelection()
|
||||
}
|
||||
)
|
||||
modalBottomSheet.show(parentFragmentManager, CallsListMenuDialogFragment.TAG)
|
||||
}
|
||||
}
|
||||
|
|
@ -113,6 +145,7 @@ class CallsListFragment : GenericFragment() {
|
|||
adapter.callLogCallBackClickedEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { model ->
|
||||
coreContext.postOnCoreThread {
|
||||
Log.i("$TAG Starting call to [${model.address.asStringUriOnly()}]")
|
||||
coreContext.startCall(model.address)
|
||||
}
|
||||
}
|
||||
|
|
@ -200,6 +233,7 @@ class CallsListFragment : GenericFragment() {
|
|||
|
||||
model.confirmRemovalEvent.observe(viewLifecycleOwner) {
|
||||
it.consume {
|
||||
Log.w("$TAG Removing all call entries from database")
|
||||
listViewModel.removeAllCallLogs()
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,10 @@ import org.linphone.databinding.CallsListLongPressMenuBinding
|
|||
|
||||
@UiThread
|
||||
class CallsListMenuDialogFragment(
|
||||
private val contactExists: Boolean,
|
||||
private val onDismiss: (() -> Unit)? = null,
|
||||
private val onAddToContact: (() -> Unit)? = null,
|
||||
private val onGoToContact: (() -> Unit)? = null,
|
||||
private val onCopyNumberOrAddressToClipboard: (() -> Unit)? = null,
|
||||
private val onDeleteCallLog: (() -> Unit)? = null
|
||||
) : BottomSheetDialogFragment() {
|
||||
|
|
@ -54,6 +57,7 @@ class CallsListMenuDialogFragment(
|
|||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
val view = CallsListLongPressMenuBinding.inflate(layoutInflater)
|
||||
view.contactExists = contactExists
|
||||
|
||||
view.setCopyNumberClickListener {
|
||||
onCopyNumberOrAddressToClipboard?.invoke()
|
||||
|
|
@ -65,8 +69,13 @@ class CallsListMenuDialogFragment(
|
|||
dismiss()
|
||||
}
|
||||
|
||||
view.setNewContactClickListener {
|
||||
// TODO
|
||||
view.setAddToContactsListener {
|
||||
onAddToContact?.invoke()
|
||||
dismiss()
|
||||
}
|
||||
|
||||
view.setGoToContactClickListener {
|
||||
onGoToContact?.invoke()
|
||||
dismiss()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,6 +60,12 @@ class ContactsFragment : GenericFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
sharedViewModel.contactEditorReadyToBeDisplayedEvent.observe(viewLifecycleOwner) {
|
||||
it.consume {
|
||||
startPostponedEnterTransition()
|
||||
}
|
||||
}
|
||||
|
||||
binding.root.doOnPreDraw {
|
||||
val slidingPane = binding.slidingPaneLayout
|
||||
slidingPane.lockMode = SlidingPaneLayout.LOCK_MODE_LOCKED
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import androidx.navigation.navGraphViewModels
|
|||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.R
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.ContactsListFragmentBinding
|
||||
import org.linphone.ui.main.contacts.adapter.ContactsListAdapter
|
||||
import org.linphone.ui.main.contacts.viewmodel.ContactsListViewModel
|
||||
|
|
@ -40,6 +41,10 @@ import org.linphone.utils.Event
|
|||
|
||||
@UiThread
|
||||
class ContactsListFragment : GenericFragment() {
|
||||
companion object {
|
||||
const val TAG = "[Contacts List Fragment]"
|
||||
}
|
||||
|
||||
private lateinit var binding: ContactsListFragmentBinding
|
||||
|
||||
private val listViewModel: ContactsListViewModel by navGraphViewModels(
|
||||
|
|
@ -95,6 +100,7 @@ class ContactsListFragment : GenericFragment() {
|
|||
viewLifecycleOwner
|
||||
) {
|
||||
adapter.submitList(it)
|
||||
Log.i("$TAG Contacts list is ready with [${it.size}] items")
|
||||
|
||||
(view.parent as? ViewGroup)?.doOnPreDraw {
|
||||
startPostponedEnterTransition()
|
||||
|
|
@ -106,6 +112,7 @@ class ContactsListFragment : GenericFragment() {
|
|||
viewLifecycleOwner
|
||||
) {
|
||||
favouritesAdapter.submitList(it)
|
||||
Log.i("$TAG Favourites contacts list is ready with [${it.size}] items")
|
||||
}
|
||||
|
||||
sharedViewModel.searchFilter.observe(viewLifecycleOwner) {
|
||||
|
|
@ -122,26 +129,35 @@ class ContactsListFragment : GenericFragment() {
|
|||
private fun configureAdapter(adapter: ContactsListAdapter) {
|
||||
adapter.contactLongClickedEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { model ->
|
||||
val modalBottomSheet = ContactsListMenuDialogFragment(model.friend.starred, {
|
||||
adapter.resetSelection()
|
||||
}, {
|
||||
// onFavourite
|
||||
coreContext.postOnCoreThread {
|
||||
model.friend.edit()
|
||||
model.friend.starred = !model.friend.starred
|
||||
model.friend.done()
|
||||
coreContext.contactsManager.notifyContactsListChanged()
|
||||
val modalBottomSheet = ContactsListMenuDialogFragment(
|
||||
model.friend.starred,
|
||||
{ // ondDismiss
|
||||
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" else "removed"} from favourites"
|
||||
)
|
||||
model.friend.starred = starred
|
||||
model.friend.done()
|
||||
coreContext.contactsManager.notifyContactsListChanged()
|
||||
}
|
||||
},
|
||||
{ // onShare
|
||||
Log.i("$TAG Sharing friend [${model.name.value}]")
|
||||
// TODO
|
||||
},
|
||||
{ // onDelete
|
||||
coreContext.postOnCoreThread {
|
||||
Log.w("$TAG Removing friend [${model.name.value}]")
|
||||
model.friend.remove()
|
||||
coreContext.contactsManager.notifyContactsListChanged()
|
||||
}
|
||||
}
|
||||
}, {
|
||||
// onShare
|
||||
// TODO
|
||||
}, {
|
||||
// onDelete
|
||||
coreContext.postOnCoreThread {
|
||||
model.friend.remove()
|
||||
coreContext.contactsManager.notifyContactsListChanged()
|
||||
}
|
||||
})
|
||||
)
|
||||
modalBottomSheet.show(parentFragmentManager, ContactsListMenuDialogFragment.TAG)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,7 +101,9 @@ class NewContactFragment : GenericFragment() {
|
|||
|
||||
val addressToAdd = sharedViewModel.sipAddressToAddToNewContact
|
||||
if (addressToAdd.isNotEmpty()) {
|
||||
Log.i("$TAG Pre-filling new contact form with SIP address [$addressToAdd]")
|
||||
sharedViewModel.sipAddressToAddToNewContact = ""
|
||||
|
||||
coreContext.postOnCoreThread {
|
||||
viewModel.addSipAddress(addressToAdd)
|
||||
}
|
||||
|
|
@ -169,6 +171,8 @@ class NewContactFragment : GenericFragment() {
|
|||
removeCell(model)
|
||||
}
|
||||
}
|
||||
|
||||
sharedViewModel.contactEditorReadyToBeDisplayedEvent.value = Event(true)
|
||||
}
|
||||
|
||||
private fun addCell(model: NewOrEditNumberOrAddressModel) {
|
||||
|
|
|
|||
|
|
@ -61,6 +61,8 @@ class SharedMainViewModel @UiThread constructor() : ViewModel() {
|
|||
|
||||
val contactsListReadyToBeDisplayedEvent = MutableLiveData<Event<Boolean>>()
|
||||
|
||||
val contactEditorReadyToBeDisplayedEvent = MutableLiveData<Event<Boolean>>()
|
||||
|
||||
val showContactEvent: MutableLiveData<Event<String>> by lazy {
|
||||
MutableLiveData<Event<String>>()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:gravity="left|center_vertical"
|
||||
android:text="Ajouter aux contats"
|
||||
android:text="Ajouter aux contacts"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/gray_1"
|
||||
android:drawableStart="@drawable/add"
|
||||
|
|
|
|||
|
|
@ -5,7 +5,10 @@
|
|||
<data>
|
||||
<import type="android.view.View" />
|
||||
<variable
|
||||
name="newContactClickListener"
|
||||
name="addToContactsListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="goToContactClickListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="copyNumberClickListener"
|
||||
|
|
@ -13,6 +16,9 @@
|
|||
<variable
|
||||
name="deleteClickListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="contactExists"
|
||||
type="Boolean" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
|
@ -21,8 +27,9 @@
|
|||
android:background="@color/separator">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/favorite"
|
||||
android:onClick="@{newContactClickListener}"
|
||||
android:id="@+id/add_to_contact"
|
||||
android:onClick="@{addToContactsListener}"
|
||||
android:visibility="@{contactExists ? View.GONE : View.VISIBLE}"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Ajouter aux contacts"
|
||||
|
|
@ -30,6 +37,21 @@
|
|||
android:background="@drawable/menu_item_background"
|
||||
android:layout_marginBottom="1dp"
|
||||
android:drawableStart="@drawable/new_contact"
|
||||
app:layout_constraintBottom_toTopOf="@id/go_to_contact"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/go_to_contact"
|
||||
android:onClick="@{goToContactClickListener}"
|
||||
android:visibility="@{contactExists ? View.VISIBLE : View.GONE}"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Voir le contact"
|
||||
style="@style/context_menu_action_label_style"
|
||||
android:background="@drawable/menu_item_background"
|
||||
android:layout_marginBottom="1dp"
|
||||
android:drawableStart="@drawable/contact"
|
||||
app:layout_constraintBottom_toTopOf="@id/share"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue