Merge "Disable nav drawer in Settings app."
This commit is contained in:
@@ -26,6 +26,9 @@
|
||||
<!-- Whether to send a custom package name with the PSD.-->
|
||||
<bool name="config_sendPackageName">false</bool>
|
||||
|
||||
<!-- Whether to enable the left nav drawer in all Settings UI.-->
|
||||
<bool name="config_enable_nav_drawer">false</bool>
|
||||
|
||||
<!-- Name for the set of keys associating package names -->
|
||||
<string name="config_helpPackageNameKey" translatable="false"></string>
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ import android.content.pm.PackageManager;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserManager;
|
||||
import android.provider.Settings;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.util.ArraySet;
|
||||
@@ -72,7 +71,6 @@ public class SettingsDrawerActivity extends Activity {
|
||||
private FrameLayout mContentHeaderContainer;
|
||||
private DrawerLayout mDrawerLayout;
|
||||
private boolean mShowingMenu;
|
||||
private UserManager mUserManager;
|
||||
|
||||
// Remove below after new IA
|
||||
@Deprecated
|
||||
@@ -108,6 +106,9 @@ public class SettingsDrawerActivity extends Activity {
|
||||
mDrawerLayout = null;
|
||||
return;
|
||||
}
|
||||
if (!isNavDrawerEnabled()) {
|
||||
setIsDrawerPresent(false);
|
||||
}
|
||||
if (!isDashboardFeatureEnabled()) {
|
||||
getDashboardCategories();
|
||||
}
|
||||
@@ -122,7 +123,6 @@ public class SettingsDrawerActivity extends Activity {
|
||||
}
|
||||
});
|
||||
|
||||
mUserManager = UserManager.get(this);
|
||||
if (DEBUG_TIMING) Log.d(TAG, "onCreate took " + (System.currentTimeMillis() - startTime)
|
||||
+ " ms");
|
||||
}
|
||||
@@ -137,6 +137,15 @@ public class SettingsDrawerActivity extends Activity {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onNavigateUp() {
|
||||
if (!isNavDrawerEnabled()) {
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
return super.onNavigateUp();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
@@ -277,10 +286,13 @@ public class SettingsDrawerActivity extends Activity {
|
||||
}
|
||||
|
||||
public void showMenuIcon() {
|
||||
mShowingMenu = true;
|
||||
getActionBar().setHomeAsUpIndicator(R.drawable.ic_menu);
|
||||
getActionBar().setHomeActionContentDescription(R.string.content_description_menu_button);
|
||||
getActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
if (isNavDrawerEnabled()) {
|
||||
mShowingMenu = true;
|
||||
getActionBar().setHomeAsUpIndicator(R.drawable.ic_menu);
|
||||
getActionBar().setHomeActionContentDescription(
|
||||
R.string.content_description_menu_button);
|
||||
}
|
||||
}
|
||||
|
||||
public List<DashboardCategory> getDashboardCategories() {
|
||||
@@ -429,6 +441,11 @@ public class SettingsDrawerActivity extends Activity {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean isNavDrawerEnabled() {
|
||||
return !isDashboardFeatureEnabled()
|
||||
|| getResources().getBoolean(R.bool.config_enable_nav_drawer);
|
||||
}
|
||||
|
||||
private class PackageReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
||||
@@ -52,34 +52,34 @@ public class SettingsDrawerActivityTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void startActivityWithNoExtra_showNoHamburgerMenu() {
|
||||
public void startActivityWithNoExtra_showNoNavUp() {
|
||||
Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
|
||||
instrumentation.startActivitySync(new Intent(instrumentation.getTargetContext(),
|
||||
TestActivity.class));
|
||||
|
||||
onView(withContentDescription(R.string.content_description_menu_button))
|
||||
onView(withContentDescription(com.android.internal.R.string.action_bar_up_description))
|
||||
.check(doesNotExist());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void startActivityWithExtraToHideMenu_showNoHamburgerMenu() {
|
||||
public void startActivityWithExtraToHideMenu_showNavUp() {
|
||||
Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
|
||||
Intent intent = new Intent(instrumentation.getTargetContext(), TestActivity.class)
|
||||
.putExtra(TestActivity.EXTRA_SHOW_MENU, false);
|
||||
instrumentation.startActivitySync(intent);
|
||||
|
||||
onView(withContentDescription(R.string.content_description_menu_button))
|
||||
onView(withContentDescription(com.android.internal.R.string.action_bar_up_description))
|
||||
.check(doesNotExist());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void startActivityWithExtraToShowMenu_showHamburgerMenu() {
|
||||
public void startActivityWithExtraToShowMenu_showNavUp() {
|
||||
Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
|
||||
Intent intent = new Intent(instrumentation.getTargetContext(), TestActivity.class)
|
||||
.putExtra(TestActivity.EXTRA_SHOW_MENU, true);
|
||||
instrumentation.startActivitySync(intent);
|
||||
|
||||
onView(withContentDescription(R.string.content_description_menu_button))
|
||||
onView(withContentDescription(com.android.internal.R.string.action_bar_up_description))
|
||||
.check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user