New dial numbers and backgrounds for the Contacts dialer.
UI overhaul for the dialer in the contacts app.
This CL changes the buttons only.
We lost the voice mail symbol on the '1' button but
the functionality is still there. A separate button
for the VM will be added at the bottom in a separate CL.
Removed the old button assets and added new ones in
the new mdpi and hdpi directories.
Fixed ButtonGridLayout to put the right amount of vertical
padding between buttons.
Also fixed a small bug in the loop to measure each child (was
measuring child 0 instead of child i.
dialpad.xml, converted px to dp units.
Adjusted the size of the buttons and padding.
Bug: 2104523
diff --git a/src/com/android/contacts/ButtonGridLayout.java b/src/com/android/contacts/ButtonGridLayout.java
index e3431b1..69eed97 100644
--- a/src/com/android/contacts/ButtonGridLayout.java
+++ b/src/com/android/contacts/ButtonGridLayout.java
@@ -25,7 +25,7 @@
public class ButtonGridLayout extends ViewGroup {
private final int mColumns = 3;
-
+
public ButtonGridLayout(Context context) {
super(context);
}
@@ -37,7 +37,7 @@
public ButtonGridLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
-
+
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
int y = mPaddingTop;
@@ -49,7 +49,7 @@
final int childHeight = child0.getMeasuredHeight();
final int xOffset = (xInc - childWidth) / 2;
final int yOffset = (yInc - childHeight) / 2;
-
+
for (int row = 0; row < rows; row++) {
int x = mPaddingLeft;
for (int col = 0; col < mColumns; col++) {
@@ -58,8 +58,8 @@
break;
}
View child = getChildAt(cell);
- child.layout(x + xOffset, y + yOffset,
- x + xOffset + childWidth,
+ child.layout(x + xOffset, y + yOffset,
+ x + xOffset + childWidth,
y + yOffset + childHeight);
x += xInc;
}
@@ -68,14 +68,14 @@
}
private int getRows() {
- return (getChildCount() + mColumns - 1) / mColumns;
+ return (getChildCount() + mColumns - 1) / mColumns;
}
-
+
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int width = mPaddingLeft + mPaddingRight;
int height = mPaddingTop + mPaddingBottom;
-
+
// Measure the first child and get it's size
View child = getChildAt(0);
child.measure(MeasureSpec.UNSPECIFIED , MeasureSpec.UNSPECIFIED);
@@ -83,15 +83,21 @@
int childHeight = child.getMeasuredHeight();
// Make sure the other children are measured as well, to initialize
for (int i = 1; i < getChildCount(); i++) {
- getChildAt(0).measure(MeasureSpec.UNSPECIFIED , MeasureSpec.UNSPECIFIED);
+ getChildAt(i).measure(MeasureSpec.UNSPECIFIED , MeasureSpec.UNSPECIFIED);
}
// All cells are going to be the size of the first child
width += mColumns * childWidth;
- height += getRows() * childHeight;
-
- width = resolveSize(width, widthMeasureSpec);
- height = resolveSize(height, heightMeasureSpec);
- setMeasuredDimension(width, height);
+ final int finalWidth = resolveSize(width, widthMeasureSpec);
+
+ // The vertical padding between button must be the same as the
+ // horizontal one. The cumulative horizontal padding is the
+ // difference between 'width' and 'finalWidth'.
+ final int padding = (finalWidth - width) / mColumns;
+
+ height += getRows() * (childHeight + padding);
+
+ final int finalHeight = resolveSize(height, heightMeasureSpec);
+ setMeasuredDimension(finalWidth, finalHeight);
}
}