diff options
author | Andrew Lee <anwlee@google.com> | 2014-06-10 17:07:43 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-06-10 17:07:43 +0000 |
commit | e69850453ec566cee019b098c60a28b61a49e090 (patch) | |
tree | 486dbbcaaa83d1404223b4dbaa7b941e8f7f1cec | |
parent | a9a75dc1956f4b6a3d3527b7b9e204acbb316b68 (diff) | |
parent | fbf7ee3329bf91214273d47d33449a064aece30d (diff) |
Merge "Always show options menu in Dialer dialpad." into lmp-preview-dev
-rw-r--r-- | src/com/android/dialer/dialpad/DialpadFragment.java | 36 |
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: { |