mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 03:18:06 +00:00
Added safe args navigation plugin + using shared element transition to maintain nav bar in place when navigating horizontally but it breaks the horizontal animation, removed them for now
This commit is contained in:
parent
137dba1bb4
commit
552459310c
15 changed files with 167 additions and 17 deletions
1
.idea/misc.xml
generated
1
.idea/misc.xml
generated
|
|
@ -1,4 +1,3 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ plugins {
|
|||
id 'org.jlleitschuh.gradle.ktlint' version '11.3.1'
|
||||
id 'org.jetbrains.kotlin.android'
|
||||
id 'com.google.gms.google-services'
|
||||
id 'androidx.navigation.safeargs.kotlin'
|
||||
}
|
||||
|
||||
static def getPackageName() {
|
||||
|
|
|
|||
|
|
@ -26,8 +26,10 @@ import android.view.ViewGroup
|
|||
import android.view.animation.Animation
|
||||
import android.view.animation.AnimationUtils
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.fragment.FragmentNavigatorExtras
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.navGraphViewModels
|
||||
import androidx.transition.AutoTransition
|
||||
import org.linphone.R
|
||||
import org.linphone.databinding.ContactsFragmentBinding
|
||||
import org.linphone.ui.contacts.viewmodel.ContactsListViewModel
|
||||
|
|
@ -52,6 +54,7 @@ class ContactsFragment : Fragment() {
|
|||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
binding = ContactsFragmentBinding.inflate(layoutInflater)
|
||||
sharedElementEnterTransition = AutoTransition()
|
||||
return binding.root
|
||||
}
|
||||
|
||||
|
|
@ -73,9 +76,11 @@ class ContactsFragment : Fragment() {
|
|||
|
||||
binding.setOnConversationsClicked {
|
||||
if (findNavController().currentDestination?.id == R.id.contactsFragment) {
|
||||
findNavController().navigate(
|
||||
R.id.action_contactsFragment_to_conversationsFragment
|
||||
val extras = FragmentNavigatorExtras(
|
||||
binding.bottomNavBar.root to "bottom_nav_bar"
|
||||
)
|
||||
val action = ContactsFragmentDirections.actionContactsFragmentToConversationsFragment()
|
||||
findNavController().navigate(action, extras)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,10 +28,12 @@ import android.view.animation.AnimationUtils
|
|||
import androidx.core.os.bundleOf
|
||||
import androidx.core.view.doOnPreDraw
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.fragment.FragmentNavigatorExtras
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.navGraphViewModels
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.transition.AutoTransition
|
||||
import org.linphone.R
|
||||
import org.linphone.databinding.ConversationsFragmentBinding
|
||||
import org.linphone.ui.conversations.adapter.ConversationsListAdapter
|
||||
|
|
@ -82,6 +84,7 @@ class ConversationsFragment : Fragment() {
|
|||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
binding = ConversationsFragmentBinding.inflate(layoutInflater)
|
||||
sharedElementEnterTransition = AutoTransition()
|
||||
return binding.root
|
||||
}
|
||||
|
||||
|
|
@ -143,9 +146,18 @@ class ConversationsFragment : Fragment() {
|
|||
|
||||
binding.setOnNewConversationClicked {
|
||||
if (findNavController().currentDestination?.id == R.id.conversationsFragment) {
|
||||
findNavController().navigate(
|
||||
R.id.action_conversationsFragment_to_newConversationFragment
|
||||
val action = ConversationsFragmentDirections.actionConversationsFragmentToNewConversationFragment()
|
||||
findNavController().navigate(action)
|
||||
}
|
||||
}
|
||||
|
||||
binding.setOnContactsClicked {
|
||||
if (findNavController().currentDestination?.id == R.id.conversationsFragment) {
|
||||
val extras = FragmentNavigatorExtras(
|
||||
binding.bottomNavBar.root to "bottom_nav_bar"
|
||||
)
|
||||
val action = ConversationsFragmentDirections.actionConversationsFragmentToContactsFragment()
|
||||
findNavController().navigate(action, extras)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
5
app/src/main/res/anim/slide_in_left.xml
Normal file
5
app/src/main/res/anim/slide_in_left.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<translate xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:fromXDelta="-100%"
|
||||
android:toXDelta="0%"
|
||||
android:duration="@android:integer/config_mediumAnimTime"/>
|
||||
5
app/src/main/res/anim/slide_out_left.xml
Normal file
5
app/src/main/res/anim/slide_out_left.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<translate xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:fromXDelta="0%"
|
||||
android:toXDelta="-100%"
|
||||
android:duration="@android:integer/config_mediumAnimTime"/>
|
||||
|
|
@ -8,6 +8,7 @@
|
|||
<import type="android.view.View" />
|
||||
</data>
|
||||
|
||||
<!-- Background color here is mandatory for transparency effect on child views -->
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@
|
|||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:transitionName="bottom_nav_bar"
|
||||
android:id="@+id/bottom_nav_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
|
|
@ -22,10 +24,10 @@
|
|||
android:layout_marginBottom="16dp"
|
||||
android:drawableTop="@drawable/contacts"
|
||||
android:drawablePadding="10dp"
|
||||
android:drawableTint="@color/primary_color"
|
||||
android:text="Contacts"
|
||||
android:textSize="11sp"
|
||||
android:textColor="@color/gray_9"
|
||||
android:drawableTint="@color/primary_color"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/calls"
|
||||
|
|
@ -44,6 +46,7 @@
|
|||
android:text="Calls"
|
||||
android:textSize="11sp"
|
||||
android:textColor="@color/gray_9"
|
||||
android:drawableTint="@color/gray_9"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/conversations"
|
||||
app:layout_constraintStart_toEndOf="@id/contacts"
|
||||
|
|
@ -62,6 +65,7 @@
|
|||
android:text="Conversations"
|
||||
android:textSize="11sp"
|
||||
android:textColor="@color/gray_9"
|
||||
android:drawableTint="@color/gray_9"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/meetings"
|
||||
app:layout_constraintStart_toEndOf="@id/calls"
|
||||
|
|
@ -79,6 +83,7 @@
|
|||
android:text="Meetings"
|
||||
android:textSize="11sp"
|
||||
android:textColor="@color/gray_9"
|
||||
android:drawableTint="@color/gray_9"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/conversations"
|
||||
93
app/src/main/res/layout/bottom_nav_bar_conversations.xml
Normal file
93
app/src/main/res/layout/bottom_nav_bar_conversations.xml
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
<?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="onContactsClicked"
|
||||
type="View.OnClickListener" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:transitionName="bottom_nav_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:onClick="@{onContactsClicked}"
|
||||
android:id="@+id/contacts"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:drawableTop="@drawable/contacts"
|
||||
android:drawablePadding="10dp"
|
||||
android:text="Contacts"
|
||||
android:textSize="11sp"
|
||||
android:textColor="@color/gray_9"
|
||||
android:drawableTint="@color/gray_9"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/calls"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/calls"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="18dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:drawableTop="@drawable/calls"
|
||||
android:drawablePadding="10dp"
|
||||
android:text="Calls"
|
||||
android:textSize="11sp"
|
||||
android:textColor="@color/gray_9"
|
||||
android:drawableTint="@color/gray_9"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/conversations"
|
||||
app:layout_constraintStart_toEndOf="@id/contacts"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/conversations"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="18dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:drawableTop="@drawable/conversations"
|
||||
android:drawablePadding="10dp"
|
||||
android:text="Conversations"
|
||||
android:textSize="11sp"
|
||||
android:textColor="@color/gray_9"
|
||||
android:drawableTint="@color/primary_color"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/meetings"
|
||||
app:layout_constraintStart_toEndOf="@id/calls"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/meetings"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="18dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:drawableTop="@drawable/meetings"
|
||||
android:drawablePadding="10dp"
|
||||
android:text="Meetings"
|
||||
android:textSize="11sp"
|
||||
android:textColor="@color/gray_9"
|
||||
android:drawableTint="@color/gray_9"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/conversations"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
||||
|
|
@ -165,7 +165,7 @@
|
|||
<include
|
||||
bind:onConversationsClicked="@{onConversationsClicked}"
|
||||
android:id="@+id/bottom_nav_bar"
|
||||
layout="@layout/bottom_nav_bar"
|
||||
layout="@layout/bottom_nav_bar_contacts"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
|
|
|||
|
|
@ -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="onNewConversationClicked"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="onContactsClicked"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="org.linphone.ui.conversations.viewmodel.ConversationsListViewModel" />
|
||||
|
|
@ -15,7 +18,8 @@
|
|||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/primary_color">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
|
|
@ -106,8 +110,9 @@
|
|||
app:layout_constraintBottom_toTopOf="@id/bottom_nav_bar" />
|
||||
|
||||
<include
|
||||
bind:onContactsClicked="@{onContactsClicked}"
|
||||
android:id="@+id/bottom_nav_bar"
|
||||
layout="@layout/bottom_nav_bar"
|
||||
layout="@layout/bottom_nav_bar_conversations"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
|
|
|||
|
|
@ -14,12 +14,19 @@
|
|||
android:id="@+id/action_conversationsFragment_to_newConversationFragment"
|
||||
app:destination="@id/newConversationFragment"
|
||||
app:enterAnim="@anim/slide_in"
|
||||
app:popExitAnim="@anim/slide_out"/>
|
||||
app:launchSingleTop="true"
|
||||
app:popExitAnim="@anim/slide_out" />
|
||||
<action
|
||||
android:id="@+id/action_conversationsFragment_to_conversationFragment"
|
||||
app:destination="@id/conversationFragment"
|
||||
app:enterAnim="@anim/slide_in_right"
|
||||
app:popExitAnim="@anim/slide_out_right" />
|
||||
<action
|
||||
android:id="@+id/action_conversationsFragment_to_contactsFragment"
|
||||
app:destination="@id/contactsFragment"
|
||||
app:launchSingleTop="true"
|
||||
app:popUpTo="@id/contactsFragment"
|
||||
app:popUpToInclusive="true" />
|
||||
</fragment>
|
||||
|
||||
<fragment
|
||||
|
|
@ -60,8 +67,9 @@
|
|||
<action
|
||||
android:id="@+id/action_contactsFragment_to_conversationsFragment"
|
||||
app:destination="@id/conversationsFragment"
|
||||
app:enterAnim="@anim/slide_in_right"
|
||||
app:popExitAnim="@anim/slide_out_right"/>
|
||||
app:launchSingleTop="true"
|
||||
app:popUpTo="@id/conversationsFragment"
|
||||
app:popUpToInclusive="true" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/newContactFragment"
|
||||
|
|
|
|||
|
|
@ -6,5 +6,6 @@
|
|||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="android:windowActivityTransitions">true</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
|
@ -6,5 +6,6 @@
|
|||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="android:windowActivityTransitions">true</item>
|
||||
</style>
|
||||
</resources>
|
||||
13
build.gradle
13
build.gradle
|
|
@ -1,7 +1,16 @@
|
|||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
}
|
||||
dependencies {
|
||||
def nav_version = "2.6.0"
|
||||
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
|
||||
}
|
||||
}
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
plugins {
|
||||
id 'com.android.application' version '8.0.2' apply false
|
||||
id 'com.android.library' version '8.0.2' apply false
|
||||
id 'com.android.application' version '8.1.0' apply false
|
||||
id 'com.android.library' version '8.1.0' apply false
|
||||
id 'org.jetbrains.kotlin.android' version '1.9.0-RC' apply false
|
||||
id 'com.google.gms.google-services' version '4.3.15' apply false
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue