Merge "Show hamburger menu if the activity is top level setting." into nyc-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
c353ab4a6d
@@ -32,6 +32,7 @@ import android.os.UserHandle;
|
|||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.support.v4.widget.DrawerLayout;
|
import android.support.v4.widget.DrawerLayout;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.ArraySet;
|
import android.util.ArraySet;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
@@ -58,6 +59,7 @@ public class SettingsDrawerActivity extends Activity {
|
|||||||
|
|
||||||
protected static final boolean DEBUG_TIMING = false;
|
protected static final boolean DEBUG_TIMING = false;
|
||||||
private static final String TAG = "SettingsDrawerActivity";
|
private static final String TAG = "SettingsDrawerActivity";
|
||||||
|
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||||
|
|
||||||
public static final String EXTRA_SHOW_MENU = "show_drawer_menu";
|
public static final String EXTRA_SHOW_MENU = "show_drawer_menu";
|
||||||
|
|
||||||
@@ -111,7 +113,7 @@ public class SettingsDrawerActivity extends Activity {
|
|||||||
public void onItemClick(android.widget.AdapterView<?> parent, View view, int position,
|
public void onItemClick(android.widget.AdapterView<?> parent, View view, int position,
|
||||||
long id) {
|
long id) {
|
||||||
onTileClicked(mDrawerAdapter.getTile(position));
|
onTileClicked(mDrawerAdapter.getTile(position));
|
||||||
};
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mUserManager = UserManager.get(this);
|
mUserManager = UserManager.get(this);
|
||||||
@@ -143,9 +145,17 @@ public class SettingsDrawerActivity extends Activity {
|
|||||||
|
|
||||||
new CategoriesUpdater().execute();
|
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();
|
showMenuIcon();
|
||||||
}
|
}
|
||||||
|
} else if (isTopLevelTile(intent)) {
|
||||||
|
showMenuIcon();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -157,6 +167,30 @@ public class SettingsDrawerActivity extends Activity {
|
|||||||
super.onPause();
|
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) {
|
public void addCategoryListener(CategoryListener listener) {
|
||||||
mCategoryListeners.add(listener);
|
mCategoryListeners.add(listener);
|
||||||
}
|
}
|
||||||
@@ -289,7 +323,7 @@ public class SettingsDrawerActivity extends Activity {
|
|||||||
|
|
||||||
for (int i = userHandles.size() - 1; i >= 0; i--) {
|
for (int i = userHandles.size() - 1; i >= 0; i--) {
|
||||||
if (mUserManager.getUserInfo(userHandles.get(i).getIdentifier()) == null) {
|
if (mUserManager.getUserInfo(userHandles.get(i).getIdentifier()) == null) {
|
||||||
if (DEBUG_TIMING) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "Delete the user: " + userHandles.get(i).getIdentifier());
|
Log.d(TAG, "Delete the user: " + userHandles.get(i).getIdentifier());
|
||||||
}
|
}
|
||||||
userHandles.remove(i);
|
userHandles.remove(i);
|
||||||
|
|||||||
Reference in New Issue
Block a user