From 36c5413800ecd06d4d93a9e5333078fc7fbcf1d6 Mon Sep 17 00:00:00 2001 From: Yorke Lee Date: Wed, 25 Sep 2013 16:17:06 -0700 Subject: Add drag to open functionality to Dialer overflow menu Bug: 10904260 Change-Id: I18fef2f553ab2598c87972ed887b0221108957f8 --- src/com/android/dialer/DialtactsActivity.java | 29 ++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'src/com/android/dialer') diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index 05c9e2c2a..a9855901f 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -141,6 +141,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O private View mMenuButton; private View mCallHistoryButton; private View mDialpadButton; + private PopupMenu mOverflowMenu; // Padding view used to shift the fragments up when the dialpad is shown. private View mBottomPaddingView; @@ -182,6 +183,20 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O } }; + private class OverflowPopupMenu extends PopupMenu { + public OverflowPopupMenu(Context context, View anchor) { + super(context, anchor); + } + + @Override + public void show() { + final Menu menu = getMenu(); + final MenuItem clearFrequents = menu.findItem(R.id.menu_clear_frequents); + clearFrequents.setVisible(mPhoneFavoriteFragment.hasFrequents()); + super.show(); + } + } + /** * Listener used when one of phone numbers in search UI is selected. This will initiate a * phone call using the phone number. @@ -409,13 +424,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O public void onClick(View view) { switch (view.getId()) { case R.id.overflow_menu: { - final PopupMenu popupMenu = new PopupMenu(DialtactsActivity.this, view); - final Menu menu = popupMenu.getMenu(); - popupMenu.inflate(R.menu.dialtacts_options); - final MenuItem clearFrequents = menu.findItem(R.id.menu_clear_frequents); - clearFrequents.setVisible(mPhoneFavoriteFragment.hasFrequents()); - popupMenu.setOnMenuItemClickListener(this); - popupMenu.show(); + mOverflowMenu.show(); break; } case R.id.dialpad_button: @@ -591,6 +600,12 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O 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); + mMenuButton.setOnTouchListener(mOverflowMenu.getDragToOpenListener()); } mCallHistoryButton = findViewById(R.id.call_history_button); -- cgit v1.2.3