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
diff --git a/res/anim/slide_in.xml b/res/anim/slide_in.xml
index b0eed37..fa0bda0 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 0000000..11b764a
--- /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 231555e..e5d7ed4 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 0000000..72304a4
--- /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 7863060..05b8e21 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 e516a53..f2f49c1 100644
--- a/src/com/android/dialer/DialtactsActivity.java
+++ b/src/com/android/dialer/DialtactsActivity.java
@@ -26,6 +26,7 @@
 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 @@
     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 @@
             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 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 @@
         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();
         }