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

Commit 51a94238 authored by Jason Monk's avatar Jason Monk
Browse files

Updates to Drawer

Support doing nothing on tvs and watches.  Also better not doing
anything with no categories existing.

Change-Id: I4a12d4d907a08e75ed3cdcd3f7c68a3a100c687d
parent a22d77e2
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
<!--
    Copyright (C) 2015 The Android Open Source Project

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/content_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
+20 −0
Original line number Diff line number Diff line
<!--
    Copyright (C) 2015 The Android Open Source Project

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/content_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
+22 −7
Original line number Diff line number Diff line
@@ -50,7 +50,9 @@ public class SettingsDrawerActivity extends Activity {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        super.setContentView(R.layout.settings_with_drawer);
        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
        // Nope.
        if (mDrawerLayout == null) {
            return;
        }
        Toolbar toolbar = (Toolbar) findViewById(R.id.action_bar);
        setActionBar(toolbar);
        mDrawerAdapter = new SettingsDrawerAdapter(this);
@@ -62,12 +64,12 @@ public class SettingsDrawerActivity extends Activity {
                onTileClicked(mDrawerAdapter.getTile(position));
            };
        });
        getActionBar().setHomeAsUpIndicator(R.drawable.ic_menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
        if (mDrawerLayout != null && item.getItemId() == android.R.id.home
                && mDrawerAdapter.getCount() != 0) {
            openDrawer();
            return true;
        }
@@ -78,16 +80,20 @@ public class SettingsDrawerActivity extends Activity {
    protected void onResume() {
        super.onResume();

        mDrawerAdapter.updateCategories();
        updateDrawer();
    }

    public void openDrawer() {
        if (mDrawerLayout != null) {
            mDrawerLayout.openDrawer(Gravity.START);
        }
    }

    public void closeDrawer() {
        if (mDrawerLayout != null) {
            mDrawerLayout.closeDrawers();
        }
    }

    @Override
    public void setContentView(@LayoutRes int layoutResID) {
@@ -106,9 +112,18 @@ public class SettingsDrawerActivity extends Activity {
    }

    public void updateDrawer() {
        if (mDrawerLayout == null) {
            return;
        }
        // TODO: Do this in the background with some loading.
        mDrawerAdapter.updateCategories();
        getActionBar().setDisplayHomeAsUpEnabled(mDrawerAdapter.getCount() != 0);
        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 List<DashboardCategory> getDashboardCategories(boolean force) {