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

Commit 468b86b6 authored by Jorge Ruesga's avatar Jorge Ruesga Committed by Gerrit Code Review
Browse files

cmfm: Fix FC with hardware menu

JIRA: NIGHTLIES-364
https://jira.cyanogenmod.org/browse/NIGHTLIES-364


Signed-off-by: default avatarJorge Ruesga <jorge@ruesga.com>

Change-Id: I6c3f56f841f7ec69004cd4a280fdd191a47e4844
parent 878734c3
Loading
Loading
Loading
Loading
+5 −57
Original line number Diff line number Diff line
@@ -417,8 +417,6 @@ public class NavigationActivity extends Activity
    private boolean mExitFlag = false;
    private long mExitBackTimeout = -1;

    private View mOptionsAnchorView;

    private int mOrientation;

    /**
@@ -1535,7 +1533,11 @@ public class NavigationActivity extends Activity
    @Override
    public boolean onKeyUp(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_MENU) {
            showOverflowPopUp(this.mOptionsAnchorView);
            if (mDrawerLayout.isDrawerOpen(mDrawer)) {
                mDrawerLayout.closeDrawer(mDrawer);
            } else {
                mDrawerLayout.openDrawer(mDrawer);
            }
            return true;
        }
        if (keyCode == KeyEvent.KEYCODE_BACK) {
@@ -1632,10 +1634,6 @@ public class NavigationActivity extends Activity
                openSearch();
                break;

            case R.id.ab_overflow:
                showOverflowPopUp(view);
                break;

            default:
                break;
        }
@@ -1851,56 +1849,6 @@ public class NavigationActivity extends Activity
        popup.show();
    }

    /**
     * Method that shows a popup with the activity main menu.
     *
     * @param anchor The action button that was pressed
     */
    private void showOverflowPopUp(View anchor) {
        SimpleMenuListAdapter adapter =
                new HighlightedSimpleMenuListAdapter(this, R.menu.navigation);
        Menu menu = adapter.getMenu();
        int cc = this.mActionBar.getChildCount();
        for (int i = 0, j = this.mActionBar.getChildCount() - 1; i < cc; i++, j--) {
            View child = this.mActionBar.getChildAt(i);
            boolean visible = child.getVisibility() == View.VISIBLE;
            if (visible) {
                menu.removeItem(menu.getItem(j).getItemId());
            }
        }

        final ListPopupWindow popup = DialogHelper.createListPopupWindow(this, adapter, anchor);
        popup.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(
                    final AdapterView<?> parent, final View v, final int position, final long id) {

                final int itemId = (int)id;
                NavigationActivity.this.mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        popup.dismiss();
                        switch (itemId) {
                            case R.id.mnu_settings:
                                //Settings
                                openSettings();
                                break;

                            case R.id.mnu_search:
                                //Search
                                openSearch();
                                popup.dismiss();
                                break;
                            default:
                                break;
                        }
                    }
                });
            }
        });
        popup.show();
    }

    /**
     * Method that show the information of a filesystem mount point.
     *