diff options
author | Ihab Awad <ihab@google.com> | 2014-03-20 23:42:00 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-03-20 23:42:00 +0000 |
commit | 6d01379857b5650b60fa1f9302afc3e519640ec4 (patch) | |
tree | f253a535349f0e3cd0285a772a26f682082e91e8 | |
parent | 1c0e52d68b3b42ef7efbad7e6f881dcc75c3f452 (diff) | |
parent | f19c50fc0fde55699f7642317bdb44af6bd429af (diff) |
am f19c50fc: am aace94af: DO NOT MERGE. Fix problem where swiping upward in overflow menu did not display the correct options menu items.
* commit 'f19c50fc0fde55699f7642317bdb44af6bd429af':
DO NOT MERGE. Fix problem where swiping upward in overflow menu did not display the correct options menu items.
-rw-r--r-- | src/com/android/dialer/DialtactsActivity.java | 28 | ||||
-rw-r--r-- | src/com/android/dialer/dialpad/DialpadFragment.java | 11 |
2 files changed, 25 insertions, 14 deletions
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index 5ec0863ac..6ea004d11 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -149,6 +149,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O private View mDialpadButton; private View mDialButton; private PopupMenu mOverflowMenu; + private PopupMenu mDialpadOverflowMenu; // Padding view used to shift the fragments up when the dialpad is shown. private View mFragmentsFrame; @@ -331,6 +332,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O @Override protected void onResume() { super.onResume(); + setupFakeActionBarItems(); if (mFirstLaunch) { displayFragment(getIntent()); } else if (!phoneIsInUse() && mInCallDialpadUp) { @@ -435,7 +437,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O switch (view.getId()) { case R.id.overflow_menu: { if (isDialpadShowing()) { - mDialpadFragment.optionsMenuInvoked(view); + mDialpadOverflowMenu.show(); } else { mOverflowMenu.show(); } @@ -529,6 +531,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O ft.commit(); mDialButton.setVisibility(shouldShowOnscreenDialButton() ? View.VISIBLE : View.GONE); mDialpadButton.setVisibility(View.GONE); + mMenuButton.setOnTouchListener(mDialpadOverflowMenu.getDragToOpenListener()); } public void hideDialpadFragment(boolean animate, boolean clearDialpad) { @@ -546,6 +549,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O ft.commit(); mDialButton.setVisibility(View.GONE); mDialpadButton.setVisibility(View.VISIBLE); + mMenuButton.setOnTouchListener(mOverflowMenu.getDragToOpenListener()); } private void prepareSearchView() { @@ -640,16 +644,17 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O }); } - - public void setupFakeActionBarItems() { + private void setupFakeActionBarItems() { mMenuButton = findViewById(R.id.overflow_menu); if (mMenuButton != null) { mMenuButton.setOnClickListener(this); - - mOverflowMenu = new OverflowPopupMenu(DialtactsActivity.this, mMenuButton); - final Menu menu = mOverflowMenu.getMenu(); - mOverflowMenu.inflate(R.menu.dialtacts_options); - mOverflowMenu.setOnMenuItemClickListener(this); + if (mOverflowMenu == null) { + mOverflowMenu = buildOptionsMenu(mMenuButton); + } + if (mDialpadOverflowMenu == null) { + mDialpadOverflowMenu = mDialpadFragment.buildOptionsMenu(mMenuButton); + } + // Initial state is with dialpad fragment not shown mMenuButton.setOnTouchListener(mOverflowMenu.getDragToOpenListener()); } @@ -668,6 +673,13 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O mDialpadButton.setOnClickListener(this); } + private PopupMenu buildOptionsMenu(View invoker) { + PopupMenu menu = new OverflowPopupMenu(this, invoker); + menu.inflate(R.menu.dialtacts_options); + menu.setOnMenuItemClickListener(this); + return menu; + } + private void fixIntent(Intent intent) { // This should be cleaned up: the call key used to send an Intent // that just said to go to the recent calls list. It now sends this diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java index a1844236d..d25ffefde 100644 --- a/src/com/android/dialer/dialpad/DialpadFragment.java +++ b/src/com/android/dialer/dialpad/DialpadFragment.java @@ -931,18 +931,17 @@ public class DialpadFragment extends Fragment } /** - * Called by the containing Activity to tell this Fragment that the gesture to display the - * "options" menu has been invoked. + * Called by the containing Activity to tell this Fragment to build an overflow options + * menu for display by the container when appropriate. * * @param invoker the View that invoked the options menu, to act as an anchor location. */ - public void optionsMenuInvoked(View invoker) { + public PopupMenu buildOptionsMenu(View invoker) { final PopupMenu popupMenu = new PopupMenu(getActivity(), invoker); - final Menu menu = popupMenu.getMenu(); popupMenu.inflate(R.menu.dialpad_options); popupMenu.setOnMenuItemClickListener(this); - setupMenuItems(menu); - popupMenu.show(); + setupMenuItems(popupMenu.getMenu()); + return popupMenu; } /** |