From fb00cb8395f99842a41fd68980b2e87ae840c617 Mon Sep 17 00:00:00 2001 From: Ihab Awad Date: Tue, 18 Mar 2014 16:19:00 -0700 Subject: Fix problem where swiping upward in overflow menu did not display the correct options menu items. b/13441681 Change-Id: If4f6970a4dd92e20ab1c04eae5228a0475bf445c --- src/com/android/dialer/DialtactsActivity.java | 31 +++++++++++++++++---------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'src/com/android/dialer/DialtactsActivity.java') 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 -- cgit v1.2.3