Fixed the contact's dialer layout.

Currently the bottom row is clipped on WVGA-800.
Changes were made to fix the emergency dialer
that needed to be applied to the contact dialer.

Now, the contact dialer uses the same ButtonGridLayout
class which aligns the button at the bottom of the view.
This way we can control the spacing between the last row and
the 'torpedo' accurately.
The rest of the white space is distributed amongst the element
using layout_weight="1".

Tested on VGA, WVGA-854, WVGA-800

Bug:2198341
diff --git a/res/layout-finger/dialpad.xml b/res/layout-finger/dialpad.xml
index 82179db..1eb653d 100644
--- a/res/layout-finger/dialpad.xml
+++ b/res/layout-finger/dialpad.xml
@@ -26,6 +26,7 @@
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_gravity="center_horizontal"
+    android:layout_weight="1"
 >
         <ImageButton android:id="@+id/one"
             android:layout_width="88dp"
diff --git a/res/layout-finger/twelve_key_dialer.xml b/res/layout-finger/twelve_key_dialer.xml
index 5601574..bd2c7a8 100644
--- a/res/layout-finger/twelve_key_dialer.xml
+++ b/res/layout-finger/twelve_key_dialer.xml
@@ -29,7 +29,6 @@
     <EditText android:id="@+id/digits"
         android:layout_width="fill_parent"
         android:layout_height="67dip"
-        android:layout_marginBottom="6dip"
         android:gravity="center"
         android:maxLines="1"
         android:scrollHorizontally="true"
@@ -40,6 +39,7 @@
         android:focusableInTouchMode="true"
         android:editable="true"
         android:cursorVisible="false"
+        android:layout_weight="0"
     />
 
     <!-- Keypad section -->
diff --git a/res/layout-finger/voicemail_dial_delete.xml b/res/layout-finger/voicemail_dial_delete.xml
index 1aa2ac4..910aaff 100644
--- a/res/layout-finger/voicemail_dial_delete.xml
+++ b/res/layout-finger/voicemail_dial_delete.xml
@@ -21,6 +21,7 @@
     android:layout_height="wrap_content"
     android:layout_gravity="center_horizontal"
     android:layout_marginTop="6dip"
+    android:layout_weight="1"
     android:orientation="horizontal">
 
     <!-- Onscreen "Voicemail" button.
diff --git a/res/layout-long-finger/dialpad.xml b/res/layout-long-finger/dialpad.xml
index af303fc..9fea6d2 100644
--- a/res/layout-long-finger/dialpad.xml
+++ b/res/layout-long-finger/dialpad.xml
@@ -27,6 +27,7 @@
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_gravity="center_horizontal"
+    android:layout_weight="1"
 >
         <ImageButton android:id="@+id/one"
             android:layout_width="88dp"
diff --git a/res/layout-long-finger/twelve_key_dialer.xml b/res/layout-long-finger/twelve_key_dialer.xml
index 1ccb70c..07771cc 100644
--- a/res/layout-long-finger/twelve_key_dialer.xml
+++ b/res/layout-long-finger/twelve_key_dialer.xml
@@ -29,7 +29,6 @@
     <EditText android:id="@+id/digits"
         android:layout_width="fill_parent"
         android:layout_height="74dip"
-        android:layout_marginBottom="20dip"
         android:gravity="center"
         android:maxLines="1"
         android:scrollHorizontally="true"
@@ -40,6 +39,7 @@
         android:focusableInTouchMode="true"
         android:editable="true"
         android:cursorVisible="false"
+        android:layout_weight="0"
     />
 
     <!-- Keypad section -->
diff --git a/res/layout-long-finger/voicemail_dial_delete.xml b/res/layout-long-finger/voicemail_dial_delete.xml
index 58c482b..10e4197 100644
--- a/res/layout-long-finger/voicemail_dial_delete.xml
+++ b/res/layout-long-finger/voicemail_dial_delete.xml
@@ -22,10 +22,14 @@
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_gravity="center_horizontal"
-    android:layout_marginTop="24dip"
+    android:layout_marginTop="6dip"
+    android:layout_weight="1"
     android:orientation="horizontal">
 
-    <!-- Onscreen "Voicemail" button -->
+    <!-- Onscreen "Voicemail" button.
+         The width is 75 (from the mocks) + 12 of padding from the
+         9patch, total is 87.
+    -->
     <ImageButton android:id="@+id/voicemailButton"
         android:layout_width="87dip"
         android:layout_height="58dip"
@@ -45,7 +49,10 @@
         android:background="@drawable/btn_dial_action"
         android:src="@drawable/ic_dial_action_call" />
 
-    <!-- Onscreen "Backspace/Delete" button -->
+    <!-- Onscreen "Backspace/Delete" button
+         The width is 75 (from the mocks) + 12 of padding from the
+         9patch, total is 87.
+    -->
     <ImageButton android:id="@+id/deleteButton"
         android:layout_width="87dip"
         android:layout_height="58dip"
diff --git a/src/com/android/contacts/ButtonGridLayout.java b/src/com/android/contacts/ButtonGridLayout.java
index b8936e3..6ce3e71 100644
--- a/src/com/android/contacts/ButtonGridLayout.java
+++ b/src/com/android/contacts/ButtonGridLayout.java
@@ -35,6 +35,7 @@
  *   - vertical = top + bottom padding.
  *
  * This class assumes that all the buttons have the same size.
+ * The buttons will be bottom aligned in their view on layout.
  *
  * Invocation: onMeasure is called first by the framework to know our
  * size. Then onLayout is invoked to layout the buttons.
@@ -53,6 +54,10 @@
     private int mWidthInc;
     private int mHeightInc;
 
+    // Height of the dialpad. Used to align it at the bottom of the
+    // view.
+    private int mHeight;
+
     public ButtonGridLayout(Context context) {
         super(context);
     }
@@ -68,7 +73,8 @@
     @Override
     protected void onLayout(boolean changed, int l, int t, int r, int b) {
         int i = 0;
-        int y = mPaddingTop;
+        // The last row is bottom aligned.
+        int y = (b - t) - mHeight + mPaddingTop;
         for (int row = 0; row < ROWS; row++) {
             int x = mPaddingLeft;
             for (int col = 0; col < COLUMNS; col++) {
@@ -99,11 +105,11 @@
         mButtonHeight = child.getMeasuredHeight();
         mWidthInc = mButtonWidth + mPaddingLeft + mPaddingRight;
         mHeightInc = mButtonHeight + mPaddingTop + mPaddingBottom;
+        mHeight = ROWS * mHeightInc;
 
         final int width = resolveSize(COLUMNS * mWidthInc, widthMeasureSpec);
-        final int height = resolveSize(ROWS * mHeightInc, heightMeasureSpec);
+        final int height = resolveSize(mHeight, heightMeasureSpec);
 
         setMeasuredDimension(width, height);
     }
-
 }