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

Commit 946483a6 authored by Jason Monk's avatar Jason Monk
Browse files

Only show settings drawer on top level items

Bug: 26080590
Change-Id: Id8d387492e2e1e09fc87f4123bf7c399a2c1380e
parent bba17c72
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -61,6 +61,8 @@ public class ProfileSelectDialog extends DialogFragment implements OnClickListen
    @Override
    public void onClick(DialogInterface dialog, int which) {
        UserHandle user = mSelectedTile.userHandle.get(which);
        // Show menu on top level items.
        mSelectedTile.intent.putExtra(SettingsDrawerActivity.EXTRA_SHOW_MENU, true);
        getActivity().startActivityAsUser(mSelectedTile.intent, user);
        ((SettingsDrawerActivity) getActivity()).onProfileTileOpen();
    }
+17 −3
Original line number Diff line number Diff line
@@ -48,6 +48,8 @@ public class SettingsDrawerActivity extends Activity {
    protected static final boolean DEBUG_TIMING = false;
    private static final String TAG = "SettingsDrawerActivity";

    static final String EXTRA_SHOW_MENU = "show_drawer_menu";

    private static List<DashboardCategory> sDashboardCategories;
    private static HashMap<Pair<String, String>, Tile> sTileCache;

@@ -56,6 +58,7 @@ public class SettingsDrawerActivity extends Activity {

    private SettingsDrawerAdapter mDrawerAdapter;
    private DrawerLayout mDrawerLayout;
    private boolean mShowingMenu;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -94,7 +97,7 @@ public class SettingsDrawerActivity extends Activity {

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (mDrawerLayout != null && item.getItemId() == android.R.id.home
        if (mShowingMenu && mDrawerLayout != null && item.getItemId() == android.R.id.home
                && mDrawerAdapter.getCount() != 0) {
            openDrawer();
            return true;
@@ -116,6 +119,9 @@ public class SettingsDrawerActivity extends Activity {

            new CategoriesUpdater().execute();
        }
        if (getIntent() != null && getIntent().getBooleanExtra(EXTRA_SHOW_MENU, false)) {
            showMenuIcon();
        }
    }

    @Override
@@ -171,13 +177,17 @@ public class SettingsDrawerActivity extends Activity {
        mDrawerAdapter.updateCategories();
        if (mDrawerAdapter.getCount() != 0) {
            mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
            getActionBar().setHomeAsUpIndicator(R.drawable.ic_menu);
            getActionBar().setDisplayHomeAsUpEnabled(true);
        } else {
            mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
        }
    }

    public void showMenuIcon() {
        mShowingMenu = true;
        getActionBar().setHomeAsUpIndicator(R.drawable.ic_menu);
        getActionBar().setDisplayHomeAsUpEnabled(true);
    }

    public List<DashboardCategory> getDashboardCategories() {
        if (sDashboardCategories == null) {
            sTileCache = new HashMap<>();
@@ -204,8 +214,12 @@ public class SettingsDrawerActivity extends Activity {
            ProfileSelectDialog.show(getFragmentManager(), tile);
            return false;
        } else if (numUserHandles == 1) {
            // Show menu on top level items.
            tile.intent.putExtra(EXTRA_SHOW_MENU, true);
            startActivityAsUser(tile.intent, tile.userHandle.get(0));
        } else {
            // Show menu on top level items.
            tile.intent.putExtra(EXTRA_SHOW_MENU, true);
            startActivity(tile.intent);
        }
        return true;