Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aace94af authored by Ihab Awad's avatar Ihab Awad
Browse files

DO NOT MERGE. Fix problem where swiping upward in overflow menu did not display the

correct options menu items.

b/13441681

Change-Id: If4f6970a4dd92e20ab1c04eae5228a0475bf445c
parent ea8ec3cd
Loading
Loading
Loading
Loading
+20 −8
Original line number Diff line number Diff line
@@ -152,6 +152,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
@@ -353,6 +354,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
    @Override
    protected void onResume() {
        super.onResume();
        setupFakeActionBarItems();
        if (mFirstLaunch) {
            displayFragment(getIntent());
        } else if (!phoneIsInUse() && mInCallDialpadUp) {
@@ -457,7 +459,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();
                }
@@ -551,6 +553,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) {
@@ -568,6 +571,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() {
@@ -670,16 +674,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());
        }

@@ -698,6 +703,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
+5 −6
Original line number Diff line number Diff line
@@ -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;
    }

    /**