Always show options menu in Dialer dialpad.
We disable options if there are no digits in the text field. The
PopUpMenu does not reflect this visually right now though. This
also fixes bad centering of the "dial to add call" text, because
now the text field will have equal left/right margins from the
edges of the screen..
Bug: 15453278
Change-Id: I6f4a7a597ed289fb1b59c9fcac261d151144b642
diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java
index 3eedcda..134c2a7 100644
--- a/src/com/android/dialer/dialpad/DialpadFragment.java
+++ b/src/com/android/dialer/dialpad/DialpadFragment.java
@@ -174,7 +174,7 @@
/** Remembers if we need to clear digits field when the screen is completely gone. */
private boolean mClearDigitsOnStop;
- private View mOverflowMenuButton;
+ private PopupMenu mOverflowPopupMenu;
private View mDelete;
private ToneGenerator mToneGenerator;
private final Object mToneGeneratorLock = new Object();
@@ -310,10 +310,6 @@
if (isDigitsEmpty()) {
mDigitsFilledByIntent = false;
mDigits.setCursorVisible(false);
- // Set to INVISIBLE instead of GONE so that text (eg. "Type number to add") is centered.
- mOverflowMenuButton.setVisibility(View.INVISIBLE);
- } else if (mDialpadView.canDigitsBeEdited()){
- mOverflowMenuButton.setVisibility(View.VISIBLE);
}
if (mDialpadQueryListener != null) {
@@ -392,9 +388,6 @@
mDialpadChooser = (ListView) fragmentView.findViewById(R.id.dialpadChooser);
mDialpadChooser.setOnItemClickListener(this);
- mOverflowMenuButton = mDialpadView.getOverflowMenuButton();
- mOverflowMenuButton.setOnClickListener(this);
-
return fragmentView;
}
@@ -657,8 +650,10 @@
mSmsPackageComponentName = DialerUtils.getSmsComponent(activity);
- final PopupMenu overflowMenu = buildOptionsMenu(mOverflowMenuButton);
- mOverflowMenuButton.setOnTouchListener(overflowMenu.getDragToOpenListener());
+ View overflowMenuButton = mDialpadView.getOverflowMenuButton();
+ mOverflowPopupMenu = buildOptionsMenu(overflowMenuButton);
+ overflowMenuButton.setOnTouchListener(mOverflowPopupMenu.getDragToOpenListener());
+ overflowMenuButton.setOnClickListener(this);
}
@Override
@@ -851,11 +846,22 @@
* @param invoker the View that invoked the options menu, to act as an anchor location.
*/
private PopupMenu buildOptionsMenu(View invoker) {
- final PopupMenu popupMenu = new PopupMenu(getActivity(), invoker);
+ final PopupMenu popupMenu = new PopupMenu(getActivity(), invoker) {
+ @Override
+ public void show() {
+ final Menu menu = getMenu();
+ final MenuItem sendMessage = menu.findItem(R.id.menu_send_message);
+ sendMessage.setVisible(mSmsPackageComponentName != null);
+
+ boolean enable = !isDigitsEmpty();
+ for (int i = 0; i < menu.size(); i++) {
+ menu.getItem(i).setEnabled(enable);
+ }
+
+ super.show();
+ }
+ };
popupMenu.inflate(R.menu.dialpad_options);
- final Menu menu = popupMenu.getMenu();
- final MenuItem sendMessage = menu.findItem(R.id.menu_send_message);
- sendMessage.setVisible(mSmsPackageComponentName != null);
popupMenu.setOnMenuItemClickListener(this);
return popupMenu;
}
@@ -883,7 +889,7 @@
return;
}
case R.id.dialpad_overflow: {
- buildOptionsMenu(view).show();
+ mOverflowPopupMenu.show();
break;
}
default: {