OSDN Git Service

Fixed the contact's dialer layout.
authorNicolas Catania <niko@google.com>
Tue, 20 Oct 2009 19:36:32 +0000 (12:36 -0700)
committerNicolas Catania <niko@google.com>
Tue, 20 Oct 2009 19:36:32 +0000 (12:36 -0700)
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

res/layout-finger/dialpad.xml
res/layout-finger/twelve_key_dialer.xml
res/layout-finger/voicemail_dial_delete.xml
res/layout-long-finger/dialpad.xml
res/layout-long-finger/twelve_key_dialer.xml
res/layout-long-finger/voicemail_dial_delete.xml
src/com/android/contacts/ButtonGridLayout.java

index 82179db..1eb653d 100644 (file)
@@ -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"
index 5601574..bd2c7a8 100644 (file)
@@ -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 -->
index 1aa2ac4..910aaff 100644 (file)
@@ -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.
index af303fc..9fea6d2 100644 (file)
@@ -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"
index 1ccb70c..07771cc 100644 (file)
@@ -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 -->
index 58c482b..10e4197 100644 (file)
     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"
         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"
index b8936e3..6ce3e71 100644 (file)
@@ -35,6 +35,7 @@ import android.view.ViewGroup;
  *   - 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 @@ public class ButtonGridLayout extends ViewGroup {
     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 @@ public class ButtonGridLayout extends ViewGroup {
     @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 @@ public class ButtonGridLayout extends ViewGroup {
         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);
     }
-
 }