Move more menu to top, and resize digits text.
- Move the overflow menu to the top in the layout.
- Remove the add contacts button from the layout.
- Change DigitsEditText to dynamically resize text to fit.
- Style Digit text area to redlines.
- Add accessor for the overflow button in the DialpadView.
Bug: 14471388
Change-Id: I9ab875a5d9ff0b43233e5d8595eb7206dc7b7dab
diff --git a/src/com/android/contacts/common/dialpad/DialpadView.java b/src/com/android/contacts/common/dialpad/DialpadView.java
index 1dade57..403663d 100644
--- a/src/com/android/contacts/common/dialpad/DialpadView.java
+++ b/src/com/android/contacts/common/dialpad/DialpadView.java
@@ -40,6 +40,7 @@
private EditText mDigits;
private ImageButton mDelete;
+ private View mOverflowMenuButton;
private boolean mCanDigitsBeEdited;
@@ -68,6 +69,7 @@
setupKeypad();
mDigits = (EditText) findViewById(R.id.digits);
mDelete = (ImageButton) findViewById(R.id.deleteButton);
+ mOverflowMenuButton = findViewById(R.id.dialpad_overflow);
}
private void setupKeypad() {
@@ -186,6 +188,10 @@
return mDelete;
}
+ public View getOverflowMenuButton() {
+ return mOverflowMenuButton;
+ }
+
private int getKeyButtonAnimationDelay(int buttonId) {
switch(buttonId) {
case R.id.one: return KEY_FRAME_DURATION * 1;
diff --git a/src/com/android/contacts/common/dialpad/DigitsEditText.java b/src/com/android/contacts/common/dialpad/DigitsEditText.java
index b7b9aff..6f99895 100644
--- a/src/com/android/contacts/common/dialpad/DigitsEditText.java
+++ b/src/com/android/contacts/common/dialpad/DigitsEditText.java
@@ -17,17 +17,24 @@
package com.android.contacts.common.dialpad;
import android.content.Context;
+import android.graphics.Paint;
import android.graphics.Rect;
import android.text.InputType;
import android.util.AttributeSet;
import android.view.MotionEvent;
+import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
+import com.android.contacts.common.R;
+
/**
* EditText which suppresses IME show up.
*/
public class DigitsEditText extends EditText {
+ // Only scale the text down to 66% smaller at most.
+ private static final float MIN_TEXT_RESIZE_RATIO = 0.66f;
+
public DigitsEditText(Context context, AttributeSet attrs) {
super(context, attrs);
setInputType(getInputType() | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
@@ -55,4 +62,31 @@
}
return ret;
}
+
+ @Override
+ protected void onTextChanged(CharSequence text, int start, int lengthBefore, int lengthAfter) {
+ super.onTextChanged(text, start, lengthBefore, lengthAfter);
+ resizeText(getWidth());
+ }
+
+ @Override
+ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
+ super.onSizeChanged(w, h, oldw, oldh);
+ resizeText(w);
+ }
+
+ private void resizeText(int width) {
+ if (width == 0) {
+ return;
+ }
+ final Paint paint = getPaint();
+ setTextScaleX(1);
+ setScaleY(1);
+
+ float ratio = width / paint.measureText(getText().toString());
+ if (ratio <= 1.0f) {
+ setTextScaleX(Math.max(MIN_TEXT_RESIZE_RATIO, ratio));
+ setScaleY(Math.max(MIN_TEXT_RESIZE_RATIO, ratio));
+ }
+ }
}