mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
More work on contacts list context menu
This commit is contained in:
parent
ab15d05ffd
commit
f13dceaa34
4 changed files with 35 additions and 33 deletions
|
|
@ -29,6 +29,7 @@ import androidx.core.view.doOnPreDraw
|
|||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.navGraphViewModels
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.R
|
||||
import org.linphone.databinding.ContactsListFragmentBinding
|
||||
import org.linphone.ui.main.contacts.adapter.ContactsListAdapter
|
||||
|
|
@ -118,9 +119,26 @@ class ContactsListFragment : GenericFragment() {
|
|||
private fun configureAdapter(adapter: ContactsListAdapter) {
|
||||
adapter.contactLongClickedEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { model ->
|
||||
val modalBottomSheet = ContactsListMenuDialogFragment(model.friend) {
|
||||
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()
|
||||
}
|
||||
}, {
|
||||
// onShare
|
||||
// TODO
|
||||
}, {
|
||||
// onDelete
|
||||
coreContext.postOnCoreThread {
|
||||
model.friend.remove()
|
||||
coreContext.contactsManager.notifyContactsListChanged()
|
||||
}
|
||||
})
|
||||
modalBottomSheet.show(parentFragmentManager, ContactsListMenuDialogFragment.TAG)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,12 +25,14 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import org.linphone.core.Friend
|
||||
import org.linphone.databinding.ContactsListLongPressMenuBinding
|
||||
|
||||
class ContactsListMenuDialogFragment(
|
||||
private val friend: Friend,
|
||||
private val onDismiss: (() -> Unit)? = null
|
||||
val isFavourite: Boolean,
|
||||
private val onDismiss: (() -> Unit)? = null,
|
||||
private val onFavourite: (() -> Unit)? = null,
|
||||
private val onShare: (() -> Unit)? = null,
|
||||
private val onDelete: (() -> Unit)? = null
|
||||
) : BottomSheetDialogFragment() {
|
||||
companion object {
|
||||
const val TAG = "ContactsListMenuDialogFragment"
|
||||
|
|
@ -52,24 +54,20 @@ class ContactsListMenuDialogFragment(
|
|||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
val view = ContactsListLongPressMenuBinding.inflate(layoutInflater)
|
||||
view.isFavourite = isFavourite
|
||||
|
||||
view.setFavoriteClickListener {
|
||||
// TODO
|
||||
onFavourite?.invoke()
|
||||
dismiss()
|
||||
}
|
||||
|
||||
view.setShareClickListener {
|
||||
// TODO
|
||||
dismiss()
|
||||
}
|
||||
|
||||
view.setInviteClickListener {
|
||||
// TODO
|
||||
onShare?.invoke()
|
||||
dismiss()
|
||||
}
|
||||
|
||||
view.setDeleteClickListener {
|
||||
// TODO
|
||||
onDelete?.invoke()
|
||||
dismiss()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:name="vector"
|
||||
android:width="29dp"
|
||||
android:height="28dp"
|
||||
android:viewportWidth="29"
|
||||
android:viewportHeight="28">
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:name="path"
|
||||
android:pathData="M 19.75 3.296 C 17.72 3.296 15.772 4.241 14.5 5.734 C 13.228 4.241 11.28 3.296 9.25 3.296 C 5.657 3.296 2.833 6.119 2.833 9.713 C 2.833 14.123 6.8 17.716 12.808 23.176 L 14.5 24.704 L 16.192 23.164 C 22.2 17.716 26.167 14.123 26.167 9.713 C 26.167 6.119 23.343 3.296 19.75 3.296 Z M 14.617 21.438 L 14.5 21.554 L 14.383 21.438 C 8.83 16.409 5.167 13.084 5.167 9.713 C 5.167 7.379 6.917 5.629 9.25 5.629 C 11.047 5.629 12.797 6.784 13.415 8.383 L 15.597 8.383 C 16.203 6.784 17.953 5.629 19.75 5.629 C 22.083 5.629 23.833 7.379 23.833 9.713 C 23.833 13.084 20.17 16.409 14.617 21.438 Z"
|
||||
android:fillColor="#6c7a87"
|
||||
android:pathData="M 16.5 2.825 C 14.76 2.825 13.09 3.635 12 4.915 C 10.91 3.635 9.24 2.825 7.5 2.825 C 4.42 2.825 2 5.245 2 8.325 C 2 12.105 5.4 15.185 10.55 19.865 L 12 21.175 L 13.45 19.855 C 18.6 15.185 22 12.105 22 8.325 C 22 5.245 19.58 2.825 16.5 2.825 Z M 12.1 18.375 L 12 18.475 L 11.9 18.375 C 7.14 14.065 4 11.215 4 8.325 C 4 6.325 5.5 4.825 7.5 4.825 C 9.04 4.825 10.54 5.815 11.07 7.185 L 12.94 7.185 C 13.46 5.815 14.96 4.825 16.5 4.825 C 18.5 4.825 20 6.325 20 8.325 C 20 11.215 16.86 14.065 12.1 18.375 Z"
|
||||
android:fillColor="#000000"
|
||||
android:strokeWidth="1"/>
|
||||
</vector>
|
||||
|
|
|
|||
|
|
@ -51,20 +51,6 @@
|
|||
android:background="@color/gray_2"
|
||||
android:layout_marginBottom="1dp"
|
||||
android:drawableStart="@drawable/share"
|
||||
app:layout_constraintBottom_toTopOf="@id/invite"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/invite"
|
||||
android:onClick="@{inviteClickListener}"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Inviter"
|
||||
style="@style/context_menu_action_label_style"
|
||||
android:background="@color/gray_2"
|
||||
android:layout_marginBottom="1dp"
|
||||
android:drawableStart="@drawable/invite"
|
||||
app:layout_constraintBottom_toTopOf="@id/delete"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue