mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-04-20 00:28:28 +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.Animation
|
||||||
import android.view.animation.AnimationUtils
|
import android.view.animation.AnimationUtils
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.navigation.fragment.findNavController
|
||||||
import androidx.navigation.navGraphViewModels
|
import androidx.navigation.navGraphViewModels
|
||||||
import org.linphone.R
|
import org.linphone.R
|
||||||
import org.linphone.databinding.ContactsFragmentBinding
|
import org.linphone.databinding.ContactsFragmentBinding
|
||||||
|
|
@ -38,9 +39,12 @@ class ContactsFragment : Fragment() {
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun onCreateAnimation(transit: Int, enter: Boolean, nextAnim: Int): Animation? {
|
override fun onCreateAnimation(transit: Int, enter: Boolean, nextAnim: Int): Animation? {
|
||||||
// Holds fragment in place while new fragment slides over it
|
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 AnimationUtils.loadAnimation(activity, R.anim.hold)
|
||||||
}
|
}
|
||||||
|
return super.onCreateAnimation(transit, enter, nextAnim)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater,
|
inflater: LayoutInflater,
|
||||||
|
|
@ -58,5 +62,25 @@ class ContactsFragment : Fragment() {
|
||||||
binding.viewModel = listViewModel
|
binding.viewModel = listViewModel
|
||||||
|
|
||||||
// postponeEnterTransition()
|
// 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,9 +61,14 @@ class ConversationsFragment : Fragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateAnimation(transit: Int, enter: Boolean, nextAnim: Int): Animation? {
|
override fun onCreateAnimation(transit: Int, enter: Boolean, nextAnim: Int): Animation? {
|
||||||
// Holds fragment in place while new fragment slides over it
|
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 AnimationUtils.loadAnimation(activity, R.anim.hold)
|
||||||
}
|
}
|
||||||
|
return super.onCreateAnimation(transit, enter, nextAnim)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
binding.conversationsList.adapter = null
|
binding.conversationsList.adapter = null
|
||||||
|
|
|
||||||
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"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
||||||
<corners android:topLeftRadius="10dp" android:topRightRadius="10dp" />
|
<corners android:topLeftRadius="30dp" android:topRightRadius="30dp" />
|
||||||
<solid android:color="@color/gray_1"/>
|
<solid android:color="@color/gray_7"/>
|
||||||
</shape>
|
</shape>
|
||||||
|
|
@ -5,6 +5,9 @@
|
||||||
|
|
||||||
<data>
|
<data>
|
||||||
<import type="android.view.View" />
|
<import type="android.view.View" />
|
||||||
|
<variable
|
||||||
|
name="onConversationsClicked"
|
||||||
|
type="View.OnClickListener" />
|
||||||
</data>
|
</data>
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
|
@ -47,6 +50,7 @@
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:onClick="@{onConversationsClicked}"
|
||||||
android:id="@+id/conversations"
|
android:id="@+id/conversations"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,16 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<layout
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:bind="http://schemas.android.com/tools">
|
||||||
|
|
||||||
<data>
|
<data>
|
||||||
<import type="android.view.View" />
|
<import type="android.view.View" />
|
||||||
<variable
|
<variable
|
||||||
name="onNewContactClicked"
|
name="onNewContactClicked"
|
||||||
type="View.OnClickListener" />
|
type="View.OnClickListener" />
|
||||||
|
<variable
|
||||||
|
name="onConversationsClicked"
|
||||||
|
type="View.OnClickListener" />
|
||||||
<variable
|
<variable
|
||||||
name="viewModel"
|
name="viewModel"
|
||||||
type="org.linphone.ui.contacts.viewmodel.ContactsListViewModel" />
|
type="org.linphone.ui.contacts.viewmodel.ContactsListViewModel" />
|
||||||
|
|
@ -160,6 +163,7 @@
|
||||||
app:layout_constraintTop_toBottomOf="@id/no_contacts_image" />
|
app:layout_constraintTop_toBottomOf="@id/no_contacts_image" />
|
||||||
|
|
||||||
<include
|
<include
|
||||||
|
bind:onConversationsClicked="@{onConversationsClicked}"
|
||||||
android:id="@+id/bottom_nav_bar"
|
android:id="@+id/bottom_nav_bar"
|
||||||
layout="@layout/bottom_nav_bar"
|
layout="@layout/bottom_nav_bar"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,6 @@
|
||||||
type="org.linphone.ui.conversations.viewmodel.ConversationsListViewModel" />
|
type="org.linphone.ui.conversations.viewmodel.ConversationsListViewModel" />
|
||||||
</data>
|
</data>
|
||||||
|
|
||||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
@ -107,9 +103,16 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/sort_by"
|
app:layout_constraintTop_toBottomOf="@id/sort_by"
|
||||||
app:layout_constraintBottom_toBottomOf="parent" />
|
app:layout_constraintBottom_toTopOf="@id/bottom_nav_bar" />
|
||||||
|
|
||||||
</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
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
android:id="@+id/new_conversation"
|
android:id="@+id/new_conversation"
|
||||||
|
|
@ -120,8 +123,10 @@
|
||||||
android:layout_margin="16dp"
|
android:layout_margin="16dp"
|
||||||
android:src="@drawable/add"
|
android:src="@drawable/add"
|
||||||
app:tint="@color/primary_color"
|
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>
|
</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:id="@+id/contactsFragment"
|
||||||
android:name="org.linphone.ui.contacts.ContactsFragment"
|
android:name="org.linphone.ui.contacts.ContactsFragment"
|
||||||
android:label="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>
|
</navigation>
|
||||||
Loading…
Add table
Reference in a new issue