mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-05-06 21:33:09 +00:00
Started contacts list context menu
This commit is contained in:
parent
9f943fcaa5
commit
4919347095
9 changed files with 248 additions and 0 deletions
|
|
@ -95,6 +95,15 @@ class ContactsFragment : Fragment() {
|
|||
binding.contactsList.setHasFixedSize(true)
|
||||
binding.contactsList.adapter = adapter
|
||||
|
||||
adapter.contactLongClickedEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { model ->
|
||||
val modalBottomSheet = ContactsListMenuDialogFragment(model.friend) {
|
||||
adapter.resetSelection()
|
||||
}
|
||||
modalBottomSheet.show(parentFragmentManager, ContactsListMenuDialogFragment.TAG)
|
||||
}
|
||||
}
|
||||
|
||||
val layoutManager = LinearLayoutManager(requireContext())
|
||||
binding.contactsList.layoutManager = layoutManager
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright (c) 2010-2023 Belledonne Communications SARL.
|
||||
*
|
||||
* This file is part of linphone-android
|
||||
* (see https://www.linphone.org).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.linphone.ui.contacts
|
||||
|
||||
import android.content.DialogInterface
|
||||
import android.os.Bundle
|
||||
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
|
||||
) : BottomSheetDialogFragment() {
|
||||
companion object {
|
||||
const val TAG = "ContactsListMenuDialogFragment"
|
||||
}
|
||||
|
||||
override fun onCancel(dialog: DialogInterface) {
|
||||
onDismiss?.invoke()
|
||||
super.onCancel(dialog)
|
||||
}
|
||||
|
||||
override fun onDismiss(dialog: DialogInterface) {
|
||||
onDismiss?.invoke()
|
||||
super.onDismiss(dialog)
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
val view = ContactsListLongPressMenuBinding.inflate(layoutInflater)
|
||||
|
||||
return view.root
|
||||
}
|
||||
}
|
||||
|
|
@ -4,18 +4,28 @@ import android.view.LayoutInflater
|
|||
import android.view.ViewGroup
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.ListAdapter
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import org.linphone.R
|
||||
import org.linphone.databinding.ContactListCellBinding
|
||||
import org.linphone.ui.contacts.model.ContactModel
|
||||
import org.linphone.utils.Event
|
||||
|
||||
class ContactsListAdapter(
|
||||
private val viewLifecycleOwner: LifecycleOwner
|
||||
) : ListAdapter<ContactModel, RecyclerView.ViewHolder>(ContactDiffCallback()) {
|
||||
var selectedAdapterPosition = -1
|
||||
|
||||
val contactClickedEvent: MutableLiveData<Event<ContactModel>> by lazy {
|
||||
MutableLiveData<Event<ContactModel>>()
|
||||
}
|
||||
|
||||
val contactLongClickedEvent: MutableLiveData<Event<ContactModel>> by lazy {
|
||||
MutableLiveData<Event<ContactModel>>()
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||
val binding: ContactListCellBinding = DataBindingUtil.inflate(
|
||||
LayoutInflater.from(parent.context),
|
||||
|
|
@ -63,6 +73,17 @@ class ContactsListAdapter(
|
|||
|
||||
binding.root.isSelected = bindingAdapterPosition == selectedAdapterPosition
|
||||
|
||||
binding.setOnClickListener {
|
||||
contactClickedEvent.value = Event(contactModel)
|
||||
}
|
||||
|
||||
binding.setOnLongClickListener {
|
||||
selectedAdapterPosition = bindingAdapterPosition
|
||||
binding.root.isSelected = true
|
||||
contactLongClickedEvent.value = Event(contactModel)
|
||||
true
|
||||
}
|
||||
|
||||
executePendingBindings()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
13
app/src/main/res/drawable/delete.xml
Normal file
13
app/src/main/res/drawable/delete.xml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:name="vector"
|
||||
android:width="28dp"
|
||||
android:height="28dp"
|
||||
android:viewportWidth="28"
|
||||
android:viewportHeight="28">
|
||||
<path
|
||||
android:name="path_1"
|
||||
android:pathData="M 18.667 10.5 L 18.667 22.167 L 9.333 22.167 L 9.333 10.5 L 18.667 10.5 Z M 16.917 3.5 L 11.083 3.5 L 9.917 4.667 L 5.833 4.667 L 5.833 7 L 22.167 7 L 22.167 4.667 L 18.083 4.667 L 16.917 3.5 Z M 21 8.167 L 7 8.167 L 7 22.167 C 7 23.45 8.05 24.5 9.333 24.5 L 18.667 24.5 C 19.95 24.5 21 23.45 21 22.167 L 21 8.167 Z"
|
||||
android:fillColor="#dd5f5f"
|
||||
android:strokeWidth="1"/>
|
||||
</vector>
|
||||
13
app/src/main/res/drawable/favorite.xml
Normal file
13
app/src/main/res/drawable/favorite.xml
Normal file
|
|
@ -0,0 +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">
|
||||
<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:strokeWidth="1"/>
|
||||
</vector>
|
||||
13
app/src/main/res/drawable/invite.xml
Normal file
13
app/src/main/res/drawable/invite.xml
Normal file
|
|
@ -0,0 +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">
|
||||
<path
|
||||
android:name="path"
|
||||
android:pathData="M 18 24.5 L 15.667 24.5 L 15.667 22.167 L 18 22.167 L 18 24.5 Z M 15.667 16.333 L 13.333 16.333 L 13.333 22.167 L 15.667 22.167 L 15.667 16.333 Z M 25 14 L 22.667 14 L 22.667 18.667 L 25 18.667 L 25 14 Z M 22.667 11.667 L 20.333 11.667 L 20.333 14 L 22.667 14 L 22.667 11.667 Z M 8.667 14 L 6.333 14 L 6.333 16.333 L 8.667 16.333 L 8.667 14 Z M 6.333 11.667 L 4 11.667 L 4 14 L 6.333 14 L 6.333 11.667 Z M 14.5 5.833 L 16.833 5.833 L 16.833 3.5 L 14.5 3.5 L 14.5 5.833 Z M 5.75 5.25 L 5.75 8.75 L 9.25 8.75 L 9.25 5.25 L 5.75 5.25 Z M 11 10.5 L 4 10.5 L 4 3.5 L 11 3.5 L 11 10.5 Z M 5.75 19.25 L 5.75 22.75 L 9.25 22.75 L 9.25 19.25 L 5.75 19.25 Z M 11 24.5 L 4 24.5 L 4 17.5 L 11 17.5 L 11 24.5 Z M 19.75 5.25 L 19.75 8.75 L 23.25 8.75 L 23.25 5.25 L 19.75 5.25 Z M 25 10.5 L 18 10.5 L 18 3.5 L 25 3.5 L 25 10.5 Z M 22.667 22.167 L 22.667 18.667 L 18 18.667 L 18 21 L 20.333 21 L 20.333 24.5 L 25 24.5 L 25 22.167 L 22.667 22.167 Z M 20.333 14 L 15.667 14 L 15.667 16.333 L 20.333 16.333 L 20.333 14 Z M 15.667 11.667 L 8.667 11.667 L 8.667 14 L 11 14 L 11 16.333 L 13.333 16.333 L 13.333 14 L 15.667 14 L 15.667 11.667 Z M 16.833 10.5 L 16.833 8.167 L 14.5 8.167 L 14.5 5.833 L 12.167 5.833 L 12.167 10.5 L 16.833 10.5 Z M 8.375 6.125 L 6.625 6.125 L 6.625 7.875 L 8.375 7.875 L 8.375 6.125 Z M 8.375 20.125 L 6.625 20.125 L 6.625 21.875 L 8.375 21.875 L 8.375 20.125 Z M 22.375 6.125 L 20.625 6.125 L 20.625 7.875 L 22.375 7.875 L 22.375 6.125 Z"
|
||||
android:fillColor="#6c7a87"
|
||||
android:strokeWidth="1"/>
|
||||
</vector>
|
||||
13
app/src/main/res/drawable/share.xml
Normal file
13
app/src/main/res/drawable/share.xml
Normal file
|
|
@ -0,0 +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">
|
||||
<path
|
||||
android:name="path_1"
|
||||
android:pathData="M 21.5 18.807 C 20.613 18.807 19.82 19.157 19.213 19.705 L 10.895 14.863 C 10.953 14.595 11 14.327 11 14.047 C 11 13.767 10.953 13.498 10.895 13.23 L 19.12 8.435 C 19.75 9.018 20.578 9.38 21.5 9.38 C 23.437 9.38 25 7.817 25 5.88 C 25 3.943 23.437 2.38 21.5 2.38 C 19.563 2.38 18 3.943 18 5.88 C 18 6.16 18.047 6.428 18.105 6.697 L 9.88 11.492 C 9.25 10.908 8.422 10.546 7.5 10.546 C 5.563 10.546 4 12.11 4 14.047 C 4 15.983 5.563 17.547 7.5 17.547 C 8.422 17.547 9.25 17.185 9.88 16.602 L 18.187 21.455 C 18.128 21.7 18.093 21.957 18.093 22.213 C 18.093 24.092 19.622 25.62 21.5 25.62 C 23.378 25.62 24.907 24.092 24.907 22.213 C 24.907 20.335 23.378 18.807 21.5 18.807 Z M 21.5 4.713 C 22.142 4.713 22.667 5.238 22.667 5.88 C 22.667 6.522 22.142 7.047 21.5 7.047 C 20.858 7.047 20.333 6.522 20.333 5.88 C 20.333 5.238 20.858 4.713 21.5 4.713 Z M 7.5 15.213 C 6.858 15.213 6.333 14.688 6.333 14.047 C 6.333 13.405 6.858 12.88 7.5 12.88 C 8.142 12.88 8.667 13.405 8.667 14.047 C 8.667 14.688 8.142 15.213 7.5 15.213 Z M 21.5 23.403 C 20.858 23.403 20.333 22.878 20.333 22.237 C 20.333 21.595 20.858 21.07 21.5 21.07 C 22.142 21.07 22.667 21.595 22.667 22.237 C 22.667 22.878 22.142 23.403 21.5 23.403 Z"
|
||||
android:fillColor="#6c7a87"
|
||||
android:strokeWidth="1"/>
|
||||
</vector>
|
||||
|
|
@ -15,9 +15,17 @@
|
|||
<variable
|
||||
name="show_first_letter"
|
||||
type="Boolean" />
|
||||
<variable
|
||||
name="onClickListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="onLongClickListener"
|
||||
type="View.OnLongClickListener" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:onClick="@{onClickListener}"
|
||||
android:onLongClick="@{onLongClickListener}"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
|
|
|
|||
100
app/src/main/res/layout/contacts_list_long_press_menu.xml
Normal file
100
app/src/main/res/layout/contacts_list_long_press_menu.xml
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<data>
|
||||
<import type="android.view.View" />
|
||||
<variable
|
||||
name="favoriteClickListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="shareClickListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="inviteClickListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="deleteClickListener"
|
||||
type="View.OnClickListener" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/separator">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/favorite"
|
||||
android:onClick="@{favoriteClickListener}"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Mettre en favoris"
|
||||
android:padding="20dp"
|
||||
android:textSize="17sp"
|
||||
android:textColor="@color/gray_1"
|
||||
android:gravity="center"
|
||||
android:background="@color/gray_2"
|
||||
android:layout_marginBottom="1dp"
|
||||
android:drawableLeft="@drawable/favorite"
|
||||
android:drawablePadding="8dp"
|
||||
app:layout_constraintBottom_toTopOf="@id/share"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/share"
|
||||
android:onClick="@{shareClickListener}"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Partager"
|
||||
android:padding="20dp"
|
||||
android:textSize="17sp"
|
||||
android:textColor="@color/gray_1"
|
||||
android:gravity="center"
|
||||
android:background="@color/gray_2"
|
||||
android:layout_marginBottom="1dp"
|
||||
android:drawableLeft="@drawable/share"
|
||||
android:drawablePadding="8dp"
|
||||
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"
|
||||
android:padding="20dp"
|
||||
android:textSize="17sp"
|
||||
android:textColor="@color/gray_1"
|
||||
android:gravity="center"
|
||||
android:background="@color/gray_2"
|
||||
android:layout_marginBottom="1dp"
|
||||
android:drawableLeft="@drawable/invite"
|
||||
android:drawablePadding="8dp"
|
||||
app:layout_constraintBottom_toTopOf="@id/delete"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/delete"
|
||||
android:onClick="@{deleteClickListener}"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Supprimer"
|
||||
android:padding="20dp"
|
||||
android:textSize="17sp"
|
||||
android:textColor="@color/red_danger"
|
||||
android:gravity="center"
|
||||
android:background="@color/gray_2"
|
||||
android:layout_marginBottom="1dp"
|
||||
android:drawableLeft="@drawable/delete"
|
||||
android:drawablePadding="8dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
||||
Loading…
Add table
Reference in a new issue