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

Commit 4bb0e113 authored by Fan Zhang's avatar Fan Zhang Committed by android-build-merger
Browse files

Show hamburger menu if the activity is top level setting. am: f311b74b am: b785de5c

am: 108fee24

Change-Id: If1162835aab5ef068ddd40e7aeeac49da9ac4324
parents 4ea95de5 108fee24
Loading
Loading
Loading
Loading
+37 −4
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.os.UserManager;
import android.provider.Settings;
import android.support.annotation.VisibleForTesting;
import android.support.v4.widget.DrawerLayout;
import android.text.TextUtils;
import android.util.ArraySet;
import android.util.Log;
import android.util.Pair;
@@ -113,7 +114,7 @@ public class SettingsDrawerActivity extends Activity {
            public void onItemClick(android.widget.AdapterView<?> parent, View view, int position,
                    long id) {
                onTileClicked(mDrawerAdapter.getTile(position));
            };
            }
        });

        mUserManager = UserManager.get(this);
@@ -145,10 +146,18 @@ public class SettingsDrawerActivity extends Activity {

            new CategoriesUpdater().execute();
        }
        if (getIntent() != null && getIntent().getBooleanExtra(EXTRA_SHOW_MENU, false)) {
        final Intent intent = getIntent();
        if (intent != null) {
            if (intent.hasExtra(EXTRA_SHOW_MENU)) {
                if (intent.getBooleanExtra(EXTRA_SHOW_MENU, false)) {
                    // Intent explicitly set to show menu.
                    showMenuIcon();
                }
            } else if (isTopLevelTile(intent)) {
                showMenuIcon();
            }
        }
    }

    @Override
    protected void onPause() {
@@ -159,6 +168,30 @@ public class SettingsDrawerActivity extends Activity {
        super.onPause();
    }

    private boolean isTopLevelTile(Intent intent) {
        final ComponentName componentName = intent.getComponent();
        if (componentName == null) {
            return false;
        }
        // Look for a tile that has the same component as incoming intent
        final List<DashboardCategory> categories = getDashboardCategories();
        for (DashboardCategory category : categories) {
            for (Tile tile : category.tiles) {
                if (TextUtils.equals(tile.intent.getComponent().getClassName(),
                        componentName.getClassName())) {
                    if (DEBUG) {
                        Log.d(TAG, "intent is for top level tile: " + tile.title);
                    }
                    return true;
                }
            }
        }
        if (DEBUG) {
            Log.d(TAG, "Intent is not for top level settings " + intent);
        }
        return false;
    }

    public void addCategoryListener(CategoryListener listener) {
        mCategoryListeners.add(listener);
    }