mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Empty new contact fragment + nav from contacts to chats
This commit is contained in:
parent
f7f5a3cf50
commit
137dba1bb4
10 changed files with 309 additions and 101 deletions
|
|
@ -26,6 +26,7 @@ import android.view.ViewGroup
|
|||
import android.view.animation.Animation
|
||||
import android.view.animation.AnimationUtils
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.navGraphViewModels
|
||||
import org.linphone.R
|
||||
import org.linphone.databinding.ContactsFragmentBinding
|
||||
|
|
@ -38,8 +39,11 @@ class ContactsFragment : Fragment() {
|
|||
)
|
||||
|
||||
override fun onCreateAnimation(transit: Int, enter: Boolean, nextAnim: Int): Animation? {
|
||||
// Holds fragment in place while new fragment slides over it
|
||||
return AnimationUtils.loadAnimation(activity, R.anim.hold)
|
||||
if (findNavController().currentDestination?.id == R.id.newContactFragment) {
|
||||
// Holds fragment in place while new contact fragment slides over it
|
||||
return AnimationUtils.loadAnimation(activity, R.anim.hold)
|
||||
}
|
||||
return super.onCreateAnimation(transit, enter, nextAnim)
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
|
|
@ -58,5 +62,25 @@ class ContactsFragment : Fragment() {
|
|||
binding.viewModel = listViewModel
|
||||
|
||||
// postponeEnterTransition()
|
||||
|
||||
binding.setOnNewContactClicked {
|
||||
if (findNavController().currentDestination?.id == R.id.contactsFragment) {
|
||||
findNavController().navigate(
|
||||
R.id.action_contactsFragment_to_newContactFragment
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
binding.setOnConversationsClicked {
|
||||
if (findNavController().currentDestination?.id == R.id.contactsFragment) {
|
||||
findNavController().navigate(
|
||||
R.id.action_contactsFragment_to_conversationsFragment
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/*(view.parent as? ViewGroup)?.doOnPreDraw {
|
||||
startPostponedEnterTransition()
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* 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 android.view.animation.Animation
|
||||
import androidx.fragment.app.Fragment
|
||||
import org.linphone.databinding.NewContactFragmentBinding
|
||||
|
||||
class NewContactFragment : Fragment() {
|
||||
private lateinit var binding: NewContactFragmentBinding
|
||||
|
||||
override fun onCreateAnimation(transit: Int, enter: Boolean, nextAnim: Int): Animation? {
|
||||
/*if (findNavController().currentDestination?.id == R.id.contactFragment) {
|
||||
// Holds fragment in place while created contact fragment slides over it
|
||||
return AnimationUtils.loadAnimation(activity, R.anim.hold)
|
||||
}*/
|
||||
return super.onCreateAnimation(transit, enter, nextAnim)
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
binding = NewContactFragmentBinding.inflate(layoutInflater)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
|
||||
// postponeEnterTransition()
|
||||
|
||||
binding.setCancelClickListener {
|
||||
requireActivity().onBackPressedDispatcher.onBackPressed()
|
||||
}
|
||||
|
||||
/*(view.parent as? ViewGroup)?.doOnPreDraw {
|
||||
startPostponedEnterTransition()
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
|
@ -61,8 +61,13 @@ class ConversationsFragment : Fragment() {
|
|||
}
|
||||
|
||||
override fun onCreateAnimation(transit: Int, enter: Boolean, nextAnim: Int): Animation? {
|
||||
// Holds fragment in place while new fragment slides over it
|
||||
return AnimationUtils.loadAnimation(activity, R.anim.hold)
|
||||
if (findNavController().currentDestination?.id == R.id.newConversationFragment ||
|
||||
findNavController().currentDestination?.id == R.id.conversationFragment
|
||||
) {
|
||||
// Holds fragment in place while (new) conversation fragment slides over it
|
||||
return AnimationUtils.loadAnimation(activity, R.anim.hold)
|
||||
}
|
||||
return super.onCreateAnimation(transit, enter, nextAnim)
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
|
|
|
|||
13
app/src/main/res/drawable/check.xml
Normal file
13
app/src/main/res/drawable/check.xml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:name="vector"
|
||||
android:width="16dp"
|
||||
android:height="12dp"
|
||||
android:viewportWidth="16"
|
||||
android:viewportHeight="12">
|
||||
<path
|
||||
android:name="path"
|
||||
android:pathData="M 5.75 7.5 L 2.75 4.5 L 0.5 6.75 L 5.75 12 L 15.5 2.25 L 13.25 0 L 5.75 7.5 Z"
|
||||
android:fillColor="#ffffff"
|
||||
android:strokeWidth="1"/>
|
||||
</vector>
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
||||
<corners android:topLeftRadius="10dp" android:topRightRadius="10dp" />
|
||||
<solid android:color="@color/gray_1"/>
|
||||
<corners android:topLeftRadius="30dp" android:topRightRadius="30dp" />
|
||||
<solid android:color="@color/gray_7"/>
|
||||
</shape>
|
||||
|
|
@ -5,6 +5,9 @@
|
|||
|
||||
<data>
|
||||
<import type="android.view.View" />
|
||||
<variable
|
||||
name="onConversationsClicked"
|
||||
type="View.OnClickListener" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
|
@ -47,6 +50,7 @@
|
|||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:onClick="@{onConversationsClicked}"
|
||||
android:id="@+id/conversations"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
|||
|
|
@ -1,13 +1,16 @@
|
|||
<?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">
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:bind="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
<import type="android.view.View" />
|
||||
<variable
|
||||
name="onNewContactClicked"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="onConversationsClicked"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="org.linphone.ui.contacts.viewmodel.ContactsListViewModel" />
|
||||
|
|
@ -160,6 +163,7 @@
|
|||
app:layout_constraintTop_toBottomOf="@id/no_contacts_image" />
|
||||
|
||||
<include
|
||||
bind:onConversationsClicked="@{onConversationsClicked}"
|
||||
android:id="@+id/bottom_nav_bar"
|
||||
layout="@layout/bottom_nav_bar"
|
||||
android:layout_width="0dp"
|
||||
|
|
|
|||
|
|
@ -13,103 +13,106 @@
|
|||
type="org.linphone.ui.conversations.viewmodel.ConversationsListViewModel" />
|
||||
</data>
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Conversations"
|
||||
android:textSize="20sp"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textStyle="bold"
|
||||
android:layout_margin="20dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/menu"
|
||||
android:layout_marginStart="22dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/title"
|
||||
app:layout_constraintBottom_toBottomOf="@id/title"/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:src="@drawable/shape_white_background"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/title"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/search_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="30dp"
|
||||
android:layout_marginStart="30dp"
|
||||
android:layout_marginEnd="30dp"
|
||||
android:padding="10dp"
|
||||
android:drawableStart="@drawable/search"
|
||||
android:drawablePadding="10dp"
|
||||
android:background="@drawable/shape_search_round_background"
|
||||
android:hint="Rechercher un contact, une conversation..."
|
||||
android:textSize="14sp"
|
||||
android:inputType="textPersonName|textNoSuggestions"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/title" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Conversations"
|
||||
android:textSize="20sp"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textStyle="bold"
|
||||
android:layout_margin="20dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
<TextView
|
||||
android:id="@+id/sort_by_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="15dp"
|
||||
android:text="Trier par"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@color/gray_5"
|
||||
app:layout_constraintStart_toStartOf="@id/search_bar"
|
||||
app:layout_constraintTop_toTopOf="@id/sort_by"
|
||||
app:layout_constraintBottom_toBottomOf="@id/sort_by"/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/menu"
|
||||
android:layout_marginStart="22dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/title"
|
||||
app:layout_constraintBottom_toBottomOf="@id/title"/>
|
||||
<TextView
|
||||
android:id="@+id/sort_by"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="Récents"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/blue_filter"
|
||||
android:drawablePadding="5dp"
|
||||
app:layout_constraintStart_toEndOf="@id/sort_by_label"
|
||||
app:layout_constraintTop_toBottomOf="@id/search_bar"
|
||||
app:drawableEndCompat="@drawable/spinner" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:src="@drawable/shape_white_background"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/title"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/conversationsList"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/sort_by"
|
||||
app:layout_constraintBottom_toTopOf="@id/bottom_nav_bar" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/search_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="30dp"
|
||||
android:layout_marginStart="30dp"
|
||||
android:layout_marginEnd="30dp"
|
||||
android:padding="10dp"
|
||||
android:drawableStart="@drawable/search"
|
||||
android:drawablePadding="10dp"
|
||||
android:background="@drawable/shape_search_round_background"
|
||||
android:hint="Rechercher un contact, une conversation..."
|
||||
android:textSize="14sp"
|
||||
android:inputType="textPersonName|textNoSuggestions"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/title" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sort_by_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="15dp"
|
||||
android:text="Trier par"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@color/gray_5"
|
||||
app:layout_constraintStart_toStartOf="@id/search_bar"
|
||||
app:layout_constraintTop_toTopOf="@id/sort_by"
|
||||
app:layout_constraintBottom_toBottomOf="@id/sort_by"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sort_by"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="Récents"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/blue_filter"
|
||||
android:drawablePadding="5dp"
|
||||
app:layout_constraintStart_toEndOf="@id/sort_by_label"
|
||||
app:layout_constraintTop_toBottomOf="@id/search_bar"
|
||||
app:drawableEndCompat="@drawable/spinner" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/conversationsList"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/sort_by"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
<include
|
||||
android:id="@+id/bottom_nav_bar"
|
||||
layout="@layout/bottom_nav_bar"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/new_conversation"
|
||||
|
|
@ -120,8 +123,10 @@
|
|||
android:layout_margin="16dp"
|
||||
android:src="@drawable/add"
|
||||
app:tint="@color/primary_color"
|
||||
app:backgroundTint="@color/white" />
|
||||
app:backgroundTint="@color/white"
|
||||
app:layout_constraintBottom_toTopOf="@id/bottom_nav_bar"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
||||
72
app/src/main/res/layout/new_contact_fragment.xml
Normal file
72
app/src/main/res/layout/new_contact_fragment.xml
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
<?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="cancelClickListener"
|
||||
type="View.OnClickListener" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/primary_color">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/back"
|
||||
android:onClick="@{cancelClickListener}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp"
|
||||
android:layout_marginStart="5dp"
|
||||
android:src="@drawable/back"
|
||||
app:layout_constraintBottom_toBottomOf="@id/title"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/title"
|
||||
app:tint="@color/white" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="35dp"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:gravity="center_vertical"
|
||||
android:text="New contact"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintEnd_toStartOf="@id/save"
|
||||
app:layout_constraintStart_toEndOf="@id/back"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/save"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="6dp"
|
||||
android:layout_marginEnd="9dp"
|
||||
android:src="@drawable/check"
|
||||
app:layout_constraintBottom_toBottomOf="@id/title"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/title"
|
||||
app:tint="@color/white" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/background"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="20dp"
|
||||
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/title" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
||||
|
|
@ -51,6 +51,22 @@
|
|||
android:id="@+id/contactsFragment"
|
||||
android:name="org.linphone.ui.contacts.ContactsFragment"
|
||||
android:label="ContactsFragment"
|
||||
tools:layout="@layout/contacts_fragment" />
|
||||
tools:layout="@layout/contacts_fragment">
|
||||
<action
|
||||
android:id="@+id/action_contactsFragment_to_newContactFragment"
|
||||
app:destination="@id/newContactFragment"
|
||||
app:enterAnim="@anim/slide_in"
|
||||
app:popExitAnim="@anim/slide_out" />
|
||||
<action
|
||||
android:id="@+id/action_contactsFragment_to_conversationsFragment"
|
||||
app:destination="@id/conversationsFragment"
|
||||
app:enterAnim="@anim/slide_in_right"
|
||||
app:popExitAnim="@anim/slide_out_right"/>
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/newContactFragment"
|
||||
android:name="org.linphone.ui.contacts.NewContactFragment"
|
||||
android:label="NewContactFragment"
|
||||
tools:layout="@layout/new_contact_fragment" />
|
||||
|
||||
</navigation>
|
||||
Loading…
Add table
Reference in a new issue