summaryrefslogtreecommitdiff
path: root/src/com/android/dialer/dialpad/DialpadFragment.java
diff options
context:
space:
mode:
authorAndrew Lee <anwlee@google.com>2014-06-06 15:20:51 -0700
committerAndrew Lee <anwlee@google.com>2014-06-06 15:55:48 -0700
commitfbf7ee3329bf91214273d47d33449a064aece30d (patch)
tree6a2fb3ee575f1aa1110de15f70263ea08048fedf /src/com/android/dialer/dialpad/DialpadFragment.java
parent97c57ccec07ac91bacb71699b10dcdd24b750c3c (diff)
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
Diffstat (limited to 'src/com/android/dialer/dialpad/DialpadFragment.java')
-rw-r--r--src/com/android/dialer/dialpad/DialpadFragment.java36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java
index 3eedcdaef..134c2a7f4 100644
--- a/src/com/android/dialer/dialpad/DialpadFragment.java
+++ b/src/com/android/dialer/dialpad/DialpadFragment.java
@@ -174,7 +174,7 @@ public class DialpadFragment extends Fragment
/** 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 @@ public class DialpadFragment extends Fragment
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 @@ public class DialpadFragment extends Fragment
mDialpadChooser = (ListView) fragmentView.findViewById(R.id.dialpadChooser);
mDialpadChooser.setOnItemClickListener(this);
- mOverflowMenuButton = mDialpadView.getOverflowMenuButton();
- mOverflowMenuButton.setOnClickListener(this);
-
return fragmentView;
}
@@ -657,8 +650,10 @@ public class DialpadFragment extends Fragment
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 @@ public class DialpadFragment extends Fragment
* @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 @@ public class DialpadFragment extends Fragment
return;
}
case R.id.dialpad_overflow: {
- buildOptionsMenu(view).show();
+ mOverflowPopupMenu.show();
break;
}
default: {