diff options
author | Sai Cheemalapati <saicheems@google.com> | 2014-06-03 13:54:23 -0700 |
---|---|---|
committer | Sai Cheemalapati <saicheems@google.com> | 2014-06-03 14:49:19 -0700 |
commit | 82d6da53d993bb3a5cabf7c9f5f0c0e62488c15f (patch) | |
tree | d43f4331bab66605dd59428c5077f06567675a9f | |
parent | 1e61380222440bb53a46a05907914207ce282386 (diff) |
Updated dialer animation in landscape.
Caching animations in constructor.
Dialer now flows in and out from/to the right.
Moved animation timing constants to constants file.
Change-Id: I287caa081c6576b347594d30ccce2b6d6526db1f
-rw-r--r-- | res/anim/slide_in.xml | 4 | ||||
-rw-r--r-- | res/anim/slide_in_right.xml | 21 | ||||
-rw-r--r-- | res/anim/slide_out.xml | 4 | ||||
-rw-r--r-- | res/anim/slide_out_right.xml | 21 | ||||
-rw-r--r-- | res/values/animation_constants.xml | 2 | ||||
-rw-r--r-- | src/com/android/dialer/DialtactsActivity.java | 47 |
6 files changed, 85 insertions, 14 deletions
diff --git a/res/anim/slide_in.xml b/res/anim/slide_in.xml index b0eed3713..fa0bda02a 100644 --- a/res/anim/slide_in.xml +++ b/res/anim/slide_in.xml @@ -15,6 +15,6 @@ --> <translate xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@interpolator/ease_in_interpolator" - android:duration="532" + android:duration="@integer/dialpad_slide_in_duration" android:fromYDelta="67%p" - android:toYDelta="0" />
\ No newline at end of file + android:toYDelta="0" /> diff --git a/res/anim/slide_in_right.xml b/res/anim/slide_in_right.xml new file mode 100644 index 000000000..11b764a36 --- /dev/null +++ b/res/anim/slide_in_right.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (c) 2014, The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<translate xmlns:android="http://schemas.android.com/apk/res/android" + android:fromXDelta="67%p" + android:toXDelta="0" + android:interpolator="@android:anim/decelerate_interpolator" + android:duration="@integer/dialpad_slide_in_duration"/> diff --git a/res/anim/slide_out.xml b/res/anim/slide_out.xml index 231555e88..e5d7ed4b9 100644 --- a/res/anim/slide_out.xml +++ b/res/anim/slide_out.xml @@ -15,6 +15,6 @@ --> <translate xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@interpolator/ease_out_interpolator" - android:duration="257" + android:duration="@integer/dialpad_slide_out_duration" android:fromYDelta="0" - android:toYDelta="80%p" />
\ No newline at end of file + android:toYDelta="80%p" /> diff --git a/res/anim/slide_out_right.xml b/res/anim/slide_out_right.xml new file mode 100644 index 000000000..72304a4b2 --- /dev/null +++ b/res/anim/slide_out_right.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (c) 2014, The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<translate xmlns:android="http://schemas.android.com/apk/res/android" + android:fromXDelta="0" + android:toXDelta="80%" + android:interpolator="@android:anim/decelerate_interpolator" + android:duration="@integer/dialpad_slide_out_duration"/> diff --git a/res/values/animation_constants.xml b/res/values/animation_constants.xml index 786306092..05b8e218d 100644 --- a/res/values/animation_constants.xml +++ b/res/values/animation_constants.xml @@ -16,6 +16,8 @@ --> <resources> <integer name="fade_duration">300</integer> + <integer name="dialpad_slide_in_duration">532</integer> + <integer name="dialpad_slide_out_duration">257</integer> <!-- Swipe constants --> <integer name="swipe_escape_velocity">100</integer> diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index e516a534f..f2f49c1ae 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -26,6 +26,7 @@ import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; +import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.TypedArray; import android.net.Uri; @@ -161,6 +162,31 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O private SmartDialSearchFragment mSmartDialSearchFragment; /** + * Animation that slides in. + */ + private Animation mSlideIn; + + /** + * Animation that slides out. + */ + private Animation mSlideOut; + + /** + * Listener for after slide out animation completes on dialer fragment. + */ + AnimationListenerAdapter mSlideOutListener = new AnimationListenerAdapter() { + @Override + public void onAnimationEnd(Animation animation) { + commitDialpadFragmentHide(); + } + }; + + /** + * Set to true if the device is in landscape orientation. + */ + private boolean mIsLandscape; + + /** * Fragment containing the speed dial list, recents list, and all contacts list. */ private ListsFragment mListsFragment; @@ -382,6 +408,15 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O mShowDialpadOnResume = savedInstanceState.getBoolean(KEY_IS_DIALPAD_SHOWN); mActionBarController.restoreInstanceState(savedInstanceState); } + mIsLandscape = getResources().getConfiguration().orientation == + Configuration.ORIENTATION_LANDSCAPE; + + mSlideIn = AnimationUtils.loadAnimation(this, + mIsLandscape ? R.anim.slide_in_right : R.anim.slide_in); + mSlideOut = AnimationUtils.loadAnimation(this, + mIsLandscape ? R.anim.slide_out_right : R.anim.slide_out); + + mSlideOut.setAnimationListener(mSlideOutListener); parentLayout = (RelativeLayout) findViewById(R.id.dialtacts_mainlayout); parentLayout.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING); @@ -601,8 +636,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O public void onDialpadShown() { updateFloatingActionButton(); if (mDialpadFragment.getAnimate()) { - Animation slideIn = AnimationUtils.loadAnimation(this, R.anim.slide_in); - mDialpadFragment.getView().startAnimation(slideIn); + mDialpadFragment.getView().startAnimation(mSlideIn); } else { mDialpadFragment.setYFraction(0); } @@ -631,14 +665,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O updateSearchFragmentPosition(); updateFloatingActionButton(); if (animate) { - Animation slideOut = AnimationUtils.loadAnimation(this, R.anim.slide_out); - slideOut.setAnimationListener(new AnimationListenerAdapter() { - @Override - public void onAnimationEnd(Animation animation) { - commitDialpadFragmentHide(); - } - }); - mDialpadFragment.getView().startAnimation(slideOut); + mDialpadFragment.getView().startAnimation(mSlideOut); } else { commitDialpadFragmentHide(); } |