diff options
author | Ihab Awad <ihab@google.com> | 2014-03-20 18:22:15 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-03-20 18:22:15 +0000 |
commit | 6cf50e98b3a1c1f46e340799b5af3ddd4780cf09 (patch) | |
tree | 167d7042a59d0c50627e04a3c03d8ece70c3a55d /src | |
parent | 732fb7627357882d87cfd7d79d02317e3f08ae65 (diff) | |
parent | fb00cb8395f99842a41fd68980b2e87ae840c617 (diff) |
Merge "Fix problem where swiping upward in overflow menu did not display the correct options menu items."
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/dialer/DialtactsActivity.java | 31 | ||||
-rw-r--r-- | src/com/android/dialer/dialpad/DialpadFragment.java | 11 |
2 files changed, 25 insertions, 17 deletions
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index 8bca7dd8b..f302f2953 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -151,6 +151,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 fragment frame up when the dialpad is shown so that // the contents of the fragment frame continue to exist in a layout of the same height @@ -337,9 +338,6 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O prepareSearchView(); - hideDialpadFragment(false, false); - setupFakeActionBarItems(); - mDialerDatabaseHelper = DatabaseHelperManager.getDatabaseHelper(this); SmartDialPrefix.initializeNanpSettings(this); } @@ -347,6 +345,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O @Override protected void onResume() { super.onResume(); + setupFakeActionBarItems(); if (mFirstLaunch) { displayFragment(getIntent()); } else if (!phoneIsInUse() && mInCallDialpadUp) { @@ -451,7 +450,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(); } @@ -545,6 +544,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) { @@ -562,6 +562,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() { @@ -664,16 +665,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()); } @@ -692,6 +694,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 7762721a1..2d3c0ee32 100644 --- a/src/com/android/dialer/dialpad/DialpadFragment.java +++ b/src/com/android/dialer/dialpad/DialpadFragment.java @@ -936,18 +936,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; } /** |