mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Started contact details
This commit is contained in:
parent
4919347095
commit
0a978f07d9
10 changed files with 321 additions and 12 deletions
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* 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.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.fragment.navArgs
|
||||
import androidx.transition.AutoTransition
|
||||
import org.linphone.R
|
||||
import org.linphone.databinding.ContactFragmentBinding
|
||||
|
||||
class ContactFragment : Fragment() {
|
||||
private lateinit var binding: ContactFragmentBinding
|
||||
|
||||
private val args: ContactFragmentArgs by navArgs()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
sharedElementEnterTransition = AutoTransition()
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
binding = ContactFragmentBinding.inflate(layoutInflater)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
|
||||
val model = args.contact
|
||||
binding.model = model
|
||||
ViewCompat.setTransitionName(binding.avatar, "transition-avatar-${model.id}")
|
||||
ViewCompat.setTransitionName(binding.name, "transition-name-${model.id}")
|
||||
|
||||
binding.setBackClickListener {
|
||||
requireActivity().onBackPressedDispatcher.onBackPressed()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
val window = requireActivity().window
|
||||
window.statusBarColor = ContextCompat.getColor(requireActivity(), R.color.white)
|
||||
}
|
||||
}
|
||||
|
|
@ -28,7 +28,9 @@ import android.view.animation.Animation
|
|||
import android.view.animation.AnimationUtils
|
||||
import androidx.core.view.doOnPreDraw
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.navigation.fragment.FragmentNavigatorExtras
|
||||
import androidx.navigation.fragment.NavHostFragment
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.navGraphViewModels
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
|
|
@ -104,6 +106,28 @@ class ContactsFragment : Fragment() {
|
|||
}
|
||||
}
|
||||
|
||||
adapter.contactClickedEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { pair ->
|
||||
val b = pair.first
|
||||
val model = pair.second
|
||||
|
||||
if (findNavController().currentDestination?.id == R.id.contactsFragment) {
|
||||
val navHostFragment =
|
||||
childFragmentManager.findFragmentById(R.id.contacts_nav_container) as NavHostFragment
|
||||
val extras = FragmentNavigatorExtras(
|
||||
b.avatar to "transition-avatar-${model.id}",
|
||||
b.name to "transition-name-${model.id}"
|
||||
)
|
||||
val action = ContactFragmentDirections.actionGlobalContactFragment(model)
|
||||
navHostFragment.navController.navigate(action, extras)
|
||||
|
||||
if (!binding.slidingPaneLayout.isOpen) {
|
||||
binding.slidingPaneLayout.openPane()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val layoutManager = LinearLayoutManager(requireContext())
|
||||
binding.contactsList.layoutManager = layoutManager
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package org.linphone.ui.contacts.adapter
|
|||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
|
|
@ -18,8 +19,8 @@ class ContactsListAdapter(
|
|||
) : ListAdapter<ContactModel, RecyclerView.ViewHolder>(ContactDiffCallback()) {
|
||||
var selectedAdapterPosition = -1
|
||||
|
||||
val contactClickedEvent: MutableLiveData<Event<ContactModel>> by lazy {
|
||||
MutableLiveData<Event<ContactModel>>()
|
||||
val contactClickedEvent: MutableLiveData<Event<Pair<ContactListCellBinding, ContactModel>>> by lazy {
|
||||
MutableLiveData<Event<Pair<ContactListCellBinding, ContactModel>>>()
|
||||
}
|
||||
|
||||
val contactLongClickedEvent: MutableLiveData<Event<ContactModel>> by lazy {
|
||||
|
|
@ -72,9 +73,11 @@ class ContactsListAdapter(
|
|||
lifecycleOwner = viewLifecycleOwner
|
||||
|
||||
binding.root.isSelected = bindingAdapterPosition == selectedAdapterPosition
|
||||
ViewCompat.setTransitionName(binding.avatar, "transition-avatar-${contactModel.id}")
|
||||
ViewCompat.setTransitionName(binding.name, "transition-name-${contactModel.id}")
|
||||
|
||||
binding.setOnClickListener {
|
||||
contactClickedEvent.value = Event(contactModel)
|
||||
contactClickedEvent.value = Event(Pair(binding, contactModel))
|
||||
}
|
||||
|
||||
binding.setOnLongClickListener {
|
||||
|
|
@ -23,12 +23,13 @@ import android.content.ContentUris
|
|||
import android.net.Uri
|
||||
import android.provider.ContactsContract
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import java.io.Serializable
|
||||
import org.linphone.core.ConsolidatedPresence
|
||||
import org.linphone.core.Friend
|
||||
import org.linphone.core.FriendListenerStub
|
||||
import org.linphone.utils.LinphoneUtils
|
||||
|
||||
class ContactModel(val friend: Friend) {
|
||||
class ContactModel(val friend: Friend) : Serializable {
|
||||
val id = friend.refKey
|
||||
|
||||
val initials = LinphoneUtils.getInitials(friend.name.orEmpty())
|
||||
|
|
|
|||
13
app/src/main/res/drawable/edit.xml
Normal file
13
app/src/main/res/drawable/edit.xml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:name="vector"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:name="path"
|
||||
android:pathData="M 14.06 9.02 L 14.98 9.94 L 5.92 19 L 5 19 L 5 18.08 L 14.06 9.02 Z M 17.66 3 C 17.41 3 17.15 3.1 16.96 3.29 L 15.13 5.12 L 18.88 8.87 L 20.71 7.04 C 21.1 6.65 21.1 6.02 20.71 5.63 L 18.37 3.29 C 18.17 3.09 17.92 3 17.66 3 Z M 14.06 6.19 L 3 17.25 L 3 21 L 6.75 21 L 17.81 9.94 L 14.06 6.19 Z"
|
||||
android:fillColor="#fe5e00"
|
||||
android:strokeWidth="1"/>
|
||||
</vector>
|
||||
5
app/src/main/res/drawable/shape_button_round.xml
Normal file
5
app/src/main/res/drawable/shape_button_round.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
|
||||
<size android:width="44dp" android:height="44dp" />
|
||||
<solid android:color="@color/blue_outgoing_message"/>
|
||||
</shape>
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:name="vector"
|
||||
android:width="19dp"
|
||||
android:height="14dp"
|
||||
android:viewportWidth="19"
|
||||
android:viewportHeight="14">
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:name="path"
|
||||
android:pathData="M 3.089 13.23 C 2.416 13.23 1.77 12.962 1.294 12.487 C 0.818 12.011 0.55 11.366 0.55 10.693 L 0.55 3.308 C 0.55 2.635 0.818 1.99 1.294 1.514 C 1.77 1.038 2.415 0.77 3.089 0.77 L 11.396 0.77 C 12.052 0.77 12.682 1.025 13.155 1.479 C 13.627 1.934 13.906 2.554 13.933 3.209 L 16.333 2.248 C 16.73 2.09 17.175 2.095 17.569 2.264 C 17.963 2.433 18.273 2.751 18.433 3.148 C 18.509 3.339 18.549 3.543 18.549 3.748 L 18.549 10.248 C 18.549 10.513 18.484 10.773 18.36 11.006 C 18.237 11.239 18.058 11.439 17.839 11.587 C 17.62 11.735 17.368 11.827 17.106 11.855 C 16.843 11.883 16.578 11.847 16.333 11.748 L 13.933 10.789 C 13.906 11.444 13.627 12.064 13.155 12.519 C 12.682 12.973 12.052 13.228 11.396 13.229 L 3.089 13.23 Z M 1.934 3.308 L 1.934 10.693 C 1.934 10.999 2.056 11.292 2.272 11.508 C 2.489 11.725 2.782 11.846 3.089 11.847 L 11.396 11.847 C 11.701 11.846 11.995 11.725 12.211 11.508 C 12.428 11.292 12.549 10.998 12.55 10.693 L 12.55 3.308 C 12.549 3.002 12.428 2.709 12.211 2.492 C 11.995 2.276 11.702 2.154 11.396 2.154 L 3.089 2.154 C 2.782 2.154 2.489 2.276 2.272 2.492 C 2.056 2.709 1.934 3.002 1.934 3.308 Z M 16.85 10.47 C 16.884 10.483 16.922 10.488 16.96 10.484 C 16.997 10.48 17.033 10.467 17.064 10.446 C 17.095 10.425 17.121 10.396 17.138 10.363 C 17.156 10.33 17.165 10.293 17.166 10.255 L 17.166 3.756 C 17.165 3.718 17.156 3.681 17.138 3.648 C 17.121 3.614 17.095 3.586 17.064 3.565 C 17.033 3.544 16.997 3.531 16.96 3.527 C 16.922 3.523 16.884 3.528 16.85 3.542 L 13.935 4.699 L 13.935 9.3 L 16.85 10.47 Z"
|
||||
android:fillColor="#fe5e00"
|
||||
android:name="path_1"
|
||||
android:pathData="M 16 6.667 L 16 17.333 L 2.667 17.333 L 2.667 6.667 L 16 6.667 Z M 17.333 4 L 1.333 4 C 0.6 4 0 4.6 0 5.333 L 0 18.667 C 0 19.4 0.6 20 1.333 20 L 17.333 20 C 18.067 20 18.667 19.4 18.667 18.667 L 18.667 14 L 24 19.333 L 24 4.667 L 18.667 10 L 18.667 5.333 C 18.667 4.6 18.067 4 17.333 4 Z"
|
||||
android:fillColor="#6c7a87"
|
||||
android:strokeWidth="1"/>
|
||||
</vector>
|
||||
|
|
|
|||
174
app/src/main/res/layout/contact_fragment.xml
Normal file
174
app/src/main/res/layout/contact_fragment.xml
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<data>
|
||||
<import type="android.view.View" />
|
||||
<variable
|
||||
name="backClickListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="model"
|
||||
type="org.linphone.ui.contacts.model.ContactModel" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/white">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/back"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginTop="7dp"
|
||||
android:onClick="@{backClickListener}"
|
||||
android:padding="1dp"
|
||||
android:src="@drawable/back"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/edit"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginTop="7dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:padding="1dp"
|
||||
android:src="@drawable/edit"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/background"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="17dp"
|
||||
android:src="@drawable/shape_gray_background"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/edit" />
|
||||
|
||||
<io.getstream.avatarview.AvatarView
|
||||
android:id="@+id/avatar"
|
||||
android:layout_width="72dp"
|
||||
android:layout_height="72dp"
|
||||
android:layout_marginTop="38dp"
|
||||
android:adjustViewBounds="true"
|
||||
contactAvatar="@{model}"
|
||||
app:avatarViewBorderWidth="0dp"
|
||||
app:avatarViewIndicatorBorderColor="@color/white"
|
||||
app:avatarViewIndicatorBorderSizeCriteria="8"
|
||||
app:avatarViewIndicatorEnabled="true"
|
||||
app:avatarViewIndicatorPosition="bottomRight"
|
||||
app:avatarViewIndicatorSizeCriteria="7"
|
||||
app:avatarViewInitialsBackgroundColor="@color/blue_outgoing_message"
|
||||
app:avatarViewInitialsTextColor="@color/gray_9"
|
||||
app:avatarViewInitialsTextSize="21sp"
|
||||
app:avatarViewInitialsTextStyle="bold"
|
||||
app:avatarViewPlaceholder="@drawable/contact_avatar"
|
||||
app:avatarViewShape="circle"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/background" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@{model.name, default=`John Doe`}"
|
||||
android:textColor="@color/gray_8"
|
||||
android:textSize="14sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/avatar" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/status"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="En ligne"
|
||||
android:textColor="@color/green_online"
|
||||
android:textSize="14sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/name" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/call"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_marginTop="39dp"
|
||||
android:background="@drawable/shape_button_round"
|
||||
android:padding="16dp"
|
||||
android:src="@drawable/calls"
|
||||
app:tint="@color/gray_1"
|
||||
app:layout_constraintEnd_toStartOf="@id/chat"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/status" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="Call"
|
||||
android:textColor="@color/gray_9"
|
||||
android:textSize="14sp"
|
||||
app:layout_constraintTop_toBottomOf="@id/call"
|
||||
app:layout_constraintStart_toStartOf="@id/call"
|
||||
app:layout_constraintEnd_toEndOf="@id/call"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/chat"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_marginTop="39dp"
|
||||
android:background="@drawable/shape_button_round"
|
||||
android:padding="16dp"
|
||||
android:src="@drawable/chat"
|
||||
app:tint="@color/gray_1"
|
||||
app:layout_constraintEnd_toStartOf="@id/video_call"
|
||||
app:layout_constraintStart_toEndOf="@id/call"
|
||||
app:layout_constraintTop_toBottomOf="@id/status" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="Message"
|
||||
android:textColor="@color/gray_9"
|
||||
android:textSize="14sp"
|
||||
app:layout_constraintTop_toBottomOf="@id/chat"
|
||||
app:layout_constraintStart_toStartOf="@id/chat"
|
||||
app:layout_constraintEnd_toEndOf="@id/chat"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/video_call"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_marginTop="39dp"
|
||||
android:background="@drawable/shape_button_round"
|
||||
android:padding="16dp"
|
||||
android:src="@drawable/video_call"
|
||||
app:tint="@color/gray_1"
|
||||
app:layout_constraintStart_toEndOf="@id/chat"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/status" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="Video Call"
|
||||
android:textColor="@color/gray_9"
|
||||
android:textSize="14sp"
|
||||
app:layout_constraintTop_toBottomOf="@id/video_call"
|
||||
app:layout_constraintStart_toStartOf="@id/video_call"
|
||||
app:layout_constraintEnd_toEndOf="@id/video_call"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
||||
|
|
@ -61,9 +61,10 @@
|
|||
app:avatarViewInitialsTextSize="16sp"
|
||||
app:avatarViewInitialsTextStyle="bold"
|
||||
app:avatarViewShape="circle"
|
||||
app:avatarViewBorderWidth="0dp"
|
||||
app:avatarViewIndicatorEnabled="true"
|
||||
app:avatarViewIndicatorBorderColor="@color/white"
|
||||
app:avatarViewIndicatorSizeCriteria="6"
|
||||
app:avatarViewIndicatorSizeCriteria="7"
|
||||
app:avatarViewIndicatorBorderSizeCriteria="8"
|
||||
app:avatarViewIndicatorPosition="bottomRight"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
|
|
|
|||
|
|
@ -10,4 +10,18 @@
|
|||
android:name="org.linphone.ui.EmptyFragment"
|
||||
android:label="EmptyFragment"
|
||||
tools:layout="@layout/empty_fragment" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/contactFragment"
|
||||
android:name="org.linphone.ui.contacts.ContactFragment"
|
||||
android:label="ContactFragment"
|
||||
tools:layout="@layout/contact_fragment" >
|
||||
<argument
|
||||
android:name="contact"
|
||||
app:argType="org.linphone.ui.contacts.model.ContactModel" />
|
||||
</fragment>
|
||||
|
||||
<action android:id="@+id/action_global_contactFragment"
|
||||
app:destination="@id/contactFragment"/>
|
||||
|
||||
</navigation>
|
||||
Loading…
Add table
Reference in a new issue