Fixed call_outgoing layout + improved main_activity layout and added animations

This commit is contained in:
Sylvain Berfini 2020-10-21 13:23:56 +02:00
parent 0ed7da68a3
commit c06c90fe1a
17 changed files with 170 additions and 132 deletions

View file

@ -21,13 +21,13 @@ package org.linphone.activities.main
import android.app.Activity
import android.content.Intent
import android.content.res.Configuration
import android.net.Uri
import android.os.Bundle
import android.os.Parcelable
import android.view.Gravity
import android.view.View
import android.view.inputmethod.InputMethodManager
import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
@ -124,12 +124,7 @@ class MainActivity : GenericActivity(), SnackBarActivity, NavController.OnDestin
}
override fun showSnackBar(resourceId: Int) {
val snackBar = Snackbar.make(binding.coordinator, resourceId, Snackbar.LENGTH_LONG)
if (binding.tabsFragment.visibility == View.VISIBLE &&
resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT) {
snackBar.anchorView = binding.tabsFragment
}
snackBar.show()
Snackbar.make(findViewById(R.id.coordinator), resourceId, Snackbar.LENGTH_LONG).show()
}
override fun onPostCreate(savedInstanceState: Bundle?) {
@ -151,9 +146,11 @@ class MainActivity : GenericActivity(), SnackBarActivity, NavController.OnDestin
) {
currentFocus?.hideKeyboard()
binding.tabsFragment.visibility = when (destination.id) {
R.id.masterCallLogsFragment, R.id.masterContactsFragment, R.id.dialerFragment, R.id.masterChatRoomsFragment -> View.VISIBLE
else -> View.GONE
val motionLayout: MotionLayout = binding.content as MotionLayout
when (destination.id) {
R.id.masterCallLogsFragment, R.id.masterContactsFragment, R.id.dialerFragment, R.id.masterChatRoomsFragment ->
motionLayout.transitionToState(R.id.visible)
else -> motionLayout.transitionToState(R.id.gone)
}
}
@ -210,7 +207,10 @@ class MainActivity : GenericActivity(), SnackBarActivity, NavController.OnDestin
Log.i("[Main Activity] Starting dialer with pre-filled URI $addressToCall")
val args = Bundle()
args.putString("URI", addressToCall)
findNavController(R.id.nav_host_fragment).navigate(R.id.action_global_dialerFragment, args)
findNavController(R.id.nav_host_fragment).navigate(
R.id.action_global_dialerFragment,
args
)
}
}
else -> {
@ -237,7 +237,10 @@ class MainActivity : GenericActivity(), SnackBarActivity, NavController.OnDestin
Log.i("[Main Activity] Found dialer intent extra, go to dialer")
val args = Bundle()
args.putBoolean("Transfer", intent.getBooleanExtra("Transfer", false))
findNavController(R.id.nav_host_fragment).navigate(R.id.action_global_dialerFragment, args)
findNavController(R.id.nav_host_fragment).navigate(
R.id.action_global_dialerFragment,
args
)
}
}
}

View file

@ -1,85 +0,0 @@
<?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"
xmlns:tools="http://schemas.android.com/tools">
<data>
<import type="android.view.View" />
<variable
name="goBackToCallClickListener"
type="android.view.View.OnClickListener" />
<variable
name="viewModel"
type="org.linphone.activities.main.viewmodels.SharedMainViewModel" />
</data>
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/backgroundColor">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/status_fragment"
android:name="org.linphone.activities.main.fragments.StatusFragment"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_alignParentTop="true"
tools:layout="@layout/status_fragment" />
<androidx.drawerlayout.widget.DrawerLayout
android:id="@+id/side_menu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/status_fragment">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/tabs_fragment"
android:name="org.linphone.activities.main.fragments.TabsFragment"
android:layout_width="60dp"
android:layout_height="match_parent"
tools:layout="@layout/tabs_fragment" />
<androidx.fragment.app.FragmentContainerView
android:id="@+id/nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/status_fragment"
app:defaultNavHost="true"
app:navGraph="@navigation/main_nav_graph" />
</LinearLayout>
<!-- Side Menu -->
<RelativeLayout
android:id="@+id/side_menu_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="left">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/side_menu_fragment"
android:name="org.linphone.activities.main.sidemenu.fragments.SideMenuFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout="@layout/side_menu_fragment" />
</RelativeLayout>
</androidx.drawerlayout.widget.DrawerLayout>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>

View file

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.motion.widget.MotionLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/tabs_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
app:layoutDescription="@xml/motion_main_activity_tabs_land">
<!-- For proper snack bar placement -->
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/coordinator"
android:layout_width="0dp"
android:layout_height="match_parent"
app:layout_constraintLeft_toRightOf="@id/tabs_fragment"
app:layout_constraintRight_toRightOf="parent">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/nav_host_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="androidx.navigation.fragment.NavHostFragment"
app:defaultNavHost="true"
app:navGraph="@navigation/main_nav_graph"
tools:layout="@layout/dialer_fragment" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<androidx.fragment.app.FragmentContainerView
android:id="@+id/tabs_fragment"
android:name="org.linphone.activities.main.fragments.TabsFragment"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_width="@dimen/main_activity_tabs_fragment_size"
android:layout_height="match_parent"
tools:layout="@layout/tabs_fragment" />
</androidx.constraintlayout.motion.widget.MotionLayout>

View file

@ -150,7 +150,7 @@
android:id="@+id/selectorMotion"
android:layout_width="5dp"
android:layout_height="match_parent"
app:layoutDescription="@xml/tabs_land"
app:layoutDescription="@xml/motion_main_activity_tabs_selector_land"
app:layout_constraintRight_toRightOf="parent">
<androidx.constraintlayout.widget.Guideline

View file

@ -47,7 +47,7 @@
android:id="@+id/status_fragment"
android:name="org.linphone.activities.call.fragments.StatusFragment"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_height="@dimen/status_fragment_size"
android:layout_alignParentTop="true"
tools:layout="@layout/call_status_fragment" />
@ -68,7 +68,7 @@
android:id="@+id/side_menu_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="40dp"
android:layout_marginTop="@dimen/status_fragment_size"
android:layout_gravity="left">
<androidx.fragment.app.FragmentContainerView

View file

@ -19,7 +19,7 @@
android:id="@+id/status_fragment"
android:name="org.linphone.activities.call.fragments.StatusFragment"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_height="@dimen/status_fragment_size"
android:layout_alignParentTop="true"
tools:layout="@layout/call_status_fragment" />

View file

@ -22,7 +22,7 @@
android:id="@+id/status_fragment"
android:name="org.linphone.activities.call.fragments.StatusFragment"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_height="@dimen/status_fragment_size"
android:layout_alignParentTop="true"
tools:layout="@layout/call_status_fragment" />
@ -45,6 +45,8 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/top_bar"
android:layout_above="@id/buttons"
android:layout_centerInParent="true">
<TextView
@ -83,6 +85,7 @@
</RelativeLayout>
<LinearLayout
android:id="@+id/buttons"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentLeft="true"

View file

@ -16,7 +16,7 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_height="@dimen/status_fragment_size"
android:background="?attr/accentColor"
android:orientation="horizontal">

View file

@ -1,6 +1,5 @@
<?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"
xmlns:tools="http://schemas.android.com/tools">
<data>
@ -14,7 +13,6 @@
</data>
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent">
@ -27,7 +25,7 @@
android:id="@+id/status_fragment"
android:name="org.linphone.activities.main.fragments.StatusFragment"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_height="@dimen/status_fragment_size"
android:layout_alignParentTop="true"
tools:layout="@layout/status_fragment" />
@ -37,29 +35,7 @@
android:layout_height="match_parent"
android:layout_below="@id/status_fragment">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/tabs_fragment"
app:defaultNavHost="true"
tools:layout="@layout/dialer_fragment"
app:navGraph="@navigation/main_nav_graph" />
<androidx.fragment.app.FragmentContainerView
android:id="@+id/tabs_fragment"
android:name="org.linphone.activities.main.fragments.TabsFragment"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
tools:layout="@layout/tabs_fragment" />
</RelativeLayout>
<include android:id="@+id/content" layout="@layout/main_activity_content" />
<!-- Side Menu -->
<RelativeLayout

View file

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.motion.widget.MotionLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/tabs_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
app:layoutDescription="@xml/motion_main_activity_tabs">
<!-- For proper snack bar placement -->
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/coordinator"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/tabs_fragment">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/nav_host_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="androidx.navigation.fragment.NavHostFragment"
app:defaultNavHost="true"
app:navGraph="@navigation/main_nav_graph"
tools:layout="@layout/dialer_fragment" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<androidx.fragment.app.FragmentContainerView
android:id="@+id/tabs_fragment"
android:name="org.linphone.activities.main.fragments.TabsFragment"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_width="match_parent"
android:layout_height="@dimen/main_activity_tabs_fragment_size"
tools:layout="@layout/tabs_fragment" />
</androidx.constraintlayout.motion.widget.MotionLayout>

View file

@ -16,7 +16,7 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_height="@dimen/status_fragment_size"
android:background="?attr/accentColor"
android:orientation="horizontal">

View file

@ -143,7 +143,7 @@
android:id="@+id/selectorMotion"
android:layout_width="match_parent"
android:layout_height="5dp"
app:layoutDescription="@xml/tabs"
app:layoutDescription="@xml/motion_main_activity_tabs_selector"
app:layout_constraintBottom_toBottomOf="parent">
<androidx.constraintlayout.widget.Guideline

View file

@ -7,4 +7,6 @@
<dimen name="chat_message_bubble_image_height_small">100dp</dimen>
<dimen name="video_preview_max_size">200dp</dimen>
<dimen name="video_preview_pip_max_size">50dp</dimen>
<dimen name="main_activity_tabs_fragment_size">60dp</dimen>
<dimen name="status_fragment_size">40dp</dimen>
</resources>

View file

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:motion="http://schemas.android.com/apk/res-auto">
<Transition
motion:duration="100"
motion:constraintSetStart="@+id/visible"
motion:constraintSetEnd="@+id/gone" />
<ConstraintSet android:id="@+id/visible">
<Constraint
android:id="@id/tabs_fragment"
android:layout_width="match_parent"
android:layout_height="@dimen/main_activity_tabs_fragment_size"
motion:layout_constraintBottom_toBottomOf="parent"/>
</ConstraintSet>
<ConstraintSet android:id="@+id/gone">
<Constraint
android:id="@id/tabs_fragment"
android:layout_width="match_parent"
android:layout_height="@dimen/main_activity_tabs_fragment_size"
motion:layout_constraintTop_toBottomOf="parent"/>
</ConstraintSet>
</MotionScene>

View file

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:motion="http://schemas.android.com/apk/res-auto">
<Transition
motion:duration="100"
motion:constraintSetStart="@+id/visible"
motion:constraintSetEnd="@+id/gone" />
<ConstraintSet android:id="@+id/visible">
<Constraint
android:id="@id/tabs_fragment"
android:layout_width="@dimen/main_activity_tabs_fragment_size"
android:layout_height="match_parent"
motion:layout_constraintLeft_toLeftOf="parent"
motion:layout_constraintRight_creator="0"/>
</ConstraintSet>
<ConstraintSet android:id="@+id/gone">
<Constraint
android:id="@id/tabs_fragment"
android:layout_width="@dimen/main_activity_tabs_fragment_size"
android:layout_height="match_parent"
motion:layout_constraintRight_toLeftOf="parent"/>
</ConstraintSet>
</MotionScene>