Merge "Fix dialpad layout in landscape mode" into lmp-dev
diff --git a/src/com/android/phone/common/animation/AnimUtils.java b/src/com/android/phone/common/animation/AnimUtils.java
index 35ac107..3a5f679 100644
--- a/src/com/android/phone/common/animation/AnimUtils.java
+++ b/src/com/android/phone/common/animation/AnimUtils.java
@@ -18,11 +18,14 @@
 
 import android.animation.Animator;
 import android.animation.AnimatorListenerAdapter;
+import android.animation.ValueAnimator;
 import android.view.View;
 import android.view.ViewPropertyAnimator;
 import android.view.animation.Interpolator;
 import android.view.animation.PathInterpolator;
 
+import java.lang.Float;
+
 public class AnimUtils {
     public static final int DEFAULT_DURATION = -1;
     public static final Interpolator EASE_IN = new PathInterpolator(0.0f, 0.0f, 0.2f, 1.0f);
@@ -105,4 +108,31 @@
         }
         animator.start();
     }
+
+    /**
+     * Animates a view to the new specified dimensions.
+     * @param view The view to change the dimensions of.
+     * @param newWidth The new width of the view.
+     * @param newHeight The new height of the view.
+     */
+    public static void changeDimensions(final View view, final int newWidth, final int newHeight) {
+        ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f);
+
+        final int oldWidth = view.getWidth();
+        final int oldHeight = view.getHeight();
+        final int deltaWidth = newWidth - oldWidth;
+        final int deltaHeight = newHeight - oldHeight;
+
+        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+            @Override
+            public void onAnimationUpdate(ValueAnimator animator) {
+                Float value = (Float) animator.getAnimatedValue();
+
+                view.getLayoutParams().width = (int) (value * deltaWidth + oldWidth);
+                view.getLayoutParams().height = (int) (value * deltaHeight + oldHeight);
+                view.requestLayout();
+            }
+        });
+        animator.start();
+    }
 }
diff --git a/src/com/android/phone/common/dialpad/DialpadView.java b/src/com/android/phone/common/dialpad/DialpadView.java
index ef3edca..3cdc30e 100644
--- a/src/com/android/phone/common/dialpad/DialpadView.java
+++ b/src/com/android/phone/common/dialpad/DialpadView.java
@@ -131,7 +131,7 @@
             lettersView = (TextView) dialpadKey.findViewById(R.id.dialpad_key_letters);
             final String numberString = resources.getString(numberIds[i]);
             final RippleDrawable rippleBackground =
-                    (RippleDrawable) resources.getDrawable(R.drawable.btn_dialpad_key);
+                    (RippleDrawable) getContext().getDrawable(R.drawable.btn_dialpad_key);
             if (mRippleColor != null) {
                 rippleBackground.setColor(mRippleColor);
             }