Allow overflow menu to overlap overflow button

Bug: 15988764
Change-Id: Ifeffb18a76f38a558e602c9fb5f62ef9d3404ecb
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java
index 4965647..f946dc1 100644
--- a/src/com/android/dialer/DialtactsActivity.java
+++ b/src/com/android/dialer/DialtactsActivity.java
@@ -42,6 +42,7 @@
 import android.text.TextWatcher;
 import android.util.Log;
 import android.view.DragEvent;
+import android.view.Gravity;
 import android.view.KeyEvent;
 import android.view.Menu;
 import android.view.MenuItem;
@@ -215,6 +216,7 @@
      */
     private String mPendingSearchViewQuery;
 
+    private PopupMenu mOverflowMenu;
     private EditText mSearchView;
     private View mVoiceSearchButton;
 
@@ -237,7 +239,7 @@
 
     private class OptionsPopupMenu extends PopupMenu {
         public OptionsPopupMenu(Context context, View anchor) {
-            super(context, anchor);
+            super(context, anchor, Gravity.END);
         }
 
         @Override
@@ -395,8 +397,8 @@
         ImageButton optionsMenuButton =
                 (ImageButton) searchEditTextLayout.findViewById(R.id.dialtacts_options_menu_button);
         optionsMenuButton.setOnClickListener(this);
-        final OptionsPopupMenu optionsMenu = buildOptionsMenu(optionsMenuButton);
-        optionsMenuButton.setOnTouchListener(optionsMenu.getDragToOpenListener());
+        mOverflowMenu = buildOptionsMenu(searchEditTextLayout);
+        optionsMenuButton.setOnTouchListener(mOverflowMenu.getDragToOpenListener());
 
         // Add the favorites fragment, and the dialpad fragment, but only if savedInstanceState
         // is null. Otherwise the fragment manager takes care of recreating these fragments.
@@ -549,7 +551,7 @@
                 }
                 break;
             case R.id.dialtacts_options_menu_button:
-                buildOptionsMenu(view).show();
+                mOverflowMenu.show();
                 break;
             default: {
                 Log.wtf(TAG, "Unexpected onClick event from " + view);