Pre-fixup for nav up button
- Remove SettingsDrawerActivity.EXTRA_SHOW_MENU and force up nav button to always show. The button doesn't do anything yet. It just finishes current activity. - Remove dead code about suggestions Change-Id: I61fa9fefbaa9bced841a05969544b1c824c564ce Bug: 72337421 Test: rebuild
This commit is contained in:
@@ -82,8 +82,6 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
|
||||
// Constants for state save/restore
|
||||
private static final String SAVE_KEY_CATEGORIES = ":settings:categories";
|
||||
@VisibleForTesting
|
||||
static final String SAVE_KEY_SHOW_HOME_AS_UP = ":settings:show_home_as_up";
|
||||
|
||||
/**
|
||||
* When starting this activity, the invoking Intent can contain this extra
|
||||
@@ -146,12 +144,10 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
public static final String EXTRA_HIDE_DRAWER = ":settings:hide_drawer";
|
||||
|
||||
public static final String META_DATA_KEY_FRAGMENT_CLASS =
|
||||
"com.android.settings.FRAGMENT_CLASS";
|
||||
"com.android.settings.FRAGMENT_CLASS";
|
||||
|
||||
private static final String EXTRA_UI_OPTIONS = "settings:ui_options";
|
||||
|
||||
private static final int REQUEST_SUGGESTION = 42;
|
||||
|
||||
private String mFragmentClass;
|
||||
|
||||
private CharSequence mInitialTitle;
|
||||
@@ -183,9 +179,6 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
|
||||
private Button mNextButton;
|
||||
|
||||
@VisibleForTesting
|
||||
boolean mDisplayHomeAsUpEnabled;
|
||||
|
||||
private boolean mIsShowingDashboard;
|
||||
private boolean mIsShortcut;
|
||||
|
||||
@@ -197,7 +190,6 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
private ArrayList<DashboardCategory> mCategories = new ArrayList<>();
|
||||
|
||||
private DashboardFeatureProvider mDashboardFeatureProvider;
|
||||
private ComponentName mCurrentSuggestion;
|
||||
|
||||
public SwitchBar getSwitchBar() {
|
||||
return mSwitchBar;
|
||||
@@ -310,9 +302,6 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
mCategories.addAll(categories);
|
||||
setTitleFromBackStack();
|
||||
}
|
||||
|
||||
mDisplayHomeAsUpEnabled = savedState.getBoolean(SAVE_KEY_SHOW_HOME_AS_UP);
|
||||
|
||||
} else {
|
||||
launchSettingFragment(initialFragmentName, isSubSettings, intent);
|
||||
}
|
||||
@@ -337,8 +326,8 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
|
||||
ActionBar actionBar = getActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.setDisplayHomeAsUpEnabled(mDisplayHomeAsUpEnabled);
|
||||
actionBar.setHomeButtonEnabled(mDisplayHomeAsUpEnabled);
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
actionBar.setHomeButtonEnabled(true);
|
||||
actionBar.setDisplayShowTitleEnabled(!mIsShowingDashboard);
|
||||
}
|
||||
mSwitchBar = findViewById(R.id.switch_bar);
|
||||
@@ -353,21 +342,21 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
if (buttonBar != null) {
|
||||
buttonBar.setVisibility(View.VISIBLE);
|
||||
|
||||
Button backButton = (Button)findViewById(R.id.back_button);
|
||||
Button backButton = (Button) findViewById(R.id.back_button);
|
||||
backButton.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
setResult(RESULT_CANCELED, null);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
Button skipButton = (Button)findViewById(R.id.skip_button);
|
||||
Button skipButton = (Button) findViewById(R.id.skip_button);
|
||||
skipButton.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
setResult(RESULT_OK, null);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
mNextButton = (Button)findViewById(R.id.next_button);
|
||||
mNextButton = (Button) findViewById(R.id.next_button);
|
||||
mNextButton.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
setResult(RESULT_OK, null);
|
||||
@@ -380,8 +369,7 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
String buttonText = intent.getStringExtra(EXTRA_PREFS_SET_NEXT_TEXT);
|
||||
if (TextUtils.isEmpty(buttonText)) {
|
||||
mNextButton.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mNextButton.setText(buttonText);
|
||||
}
|
||||
}
|
||||
@@ -389,8 +377,7 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
String buttonText = intent.getStringExtra(EXTRA_PREFS_SET_BACK_TEXT);
|
||||
if (TextUtils.isEmpty(buttonText)) {
|
||||
backButton.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
backButton.setText(buttonText);
|
||||
}
|
||||
}
|
||||
@@ -408,26 +395,17 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
@VisibleForTesting
|
||||
void launchSettingFragment(String initialFragmentName, boolean isSubSettings, Intent intent) {
|
||||
if (!mIsShowingDashboard && initialFragmentName != null) {
|
||||
// UP will be shown only if it is a sub settings
|
||||
if (mIsShortcut) {
|
||||
mDisplayHomeAsUpEnabled = isSubSettings;
|
||||
} else if (isSubSettings) {
|
||||
mDisplayHomeAsUpEnabled = true;
|
||||
} else {
|
||||
mDisplayHomeAsUpEnabled = false;
|
||||
}
|
||||
setTitleFromIntent(intent);
|
||||
|
||||
Bundle initialArguments = intent.getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS);
|
||||
switchToFragment(initialFragmentName, initialArguments, true, false,
|
||||
mInitialTitleResId, mInitialTitle, false);
|
||||
mInitialTitleResId, mInitialTitle, false);
|
||||
} else {
|
||||
// Show search icon as up affordance if we are displaying the main Dashboard
|
||||
mDisplayHomeAsUpEnabled = true;
|
||||
mInitialTitleResId = R.string.dashboard_title;
|
||||
|
||||
switchToFragment(DashboardSummary.class.getName(), null /* args */, false, false,
|
||||
mInitialTitleResId, mInitialTitle, false);
|
||||
mInitialTitleResId, mInitialTitle, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -509,15 +487,6 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
if (mCategories.size() > 0) {
|
||||
outState.putParcelableArrayList(SAVE_KEY_CATEGORIES, mCategories);
|
||||
}
|
||||
|
||||
outState.putBoolean(SAVE_KEY_SHOW_HOME_AS_UP, mDisplayHomeAsUpEnabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestoreInstanceState(Bundle savedInstanceState) {
|
||||
super.onRestoreInstanceState(savedInstanceState);
|
||||
|
||||
mDisplayHomeAsUpEnabled = savedInstanceState.getBoolean(SAVE_KEY_SHOW_HOME_AS_UP);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -610,17 +579,17 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
* single-pane mode, a new activity will be launched in which to show the
|
||||
* fragment.
|
||||
*
|
||||
* @param fragmentClass Full name of the class implementing the fragment.
|
||||
* @param args Any desired arguments to supply to the fragment.
|
||||
* @param titleRes Optional resource identifier of the title of this
|
||||
* fragment.
|
||||
* @param titleText Optional text of the title of this fragment.
|
||||
* @param resultTo Optional fragment that result data should be sent to.
|
||||
* If non-null, resultTo.onActivityResult() will be called when this
|
||||
* preference panel is done. The launched panel must use
|
||||
* {@link #finishPreferencePanel(Fragment, int, Intent)} when done.
|
||||
* @param fragmentClass Full name of the class implementing the fragment.
|
||||
* @param args Any desired arguments to supply to the fragment.
|
||||
* @param titleRes Optional resource identifier of the title of this
|
||||
* fragment.
|
||||
* @param titleText Optional text of the title of this fragment.
|
||||
* @param resultTo Optional fragment that result data should be sent to.
|
||||
* If non-null, resultTo.onActivityResult() will be called when this
|
||||
* preference panel is done. The launched panel must use
|
||||
* {@link #finishPreferencePanel(Fragment, int, Intent)} when done.
|
||||
* @param resultRequestCode If resultTo is non-null, this is the caller's
|
||||
* request code to be received with the result.
|
||||
* request code to be received with the result.
|
||||
*/
|
||||
public void startPreferencePanel(Fragment caller, String fragmentClass, Bundle args,
|
||||
int titleRes, CharSequence titleText, Fragment resultTo, int resultRequestCode) {
|
||||
@@ -639,10 +608,10 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
* activity will be launched in which to show the fragment.
|
||||
*
|
||||
* @param fragmentClass Full name of the class implementing the fragment.
|
||||
* @param args Any desired arguments to supply to the fragment.
|
||||
* @param titleRes Optional resource identifier of the title of this fragment.
|
||||
* @param titleText Optional text of the title of this fragment.
|
||||
* @param userHandle The user for which the panel has to be started.
|
||||
* @param args Any desired arguments to supply to the fragment.
|
||||
* @param titleRes Optional resource identifier of the title of this fragment.
|
||||
* @param titleText Optional text of the title of this fragment.
|
||||
* @param userHandle The user for which the panel has to be started.
|
||||
*/
|
||||
public void startPreferencePanelAsUser(Fragment caller, String fragmentClass,
|
||||
Bundle args, int titleRes, CharSequence titleText, UserHandle userHandle) {
|
||||
@@ -676,11 +645,11 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
/**
|
||||
* Called by a preference panel fragment to finish itself.
|
||||
*
|
||||
* @param caller The fragment that is asking to be finished.
|
||||
* @param caller The fragment that is asking to be finished.
|
||||
* @param resultCode Optional result code to send back to the original
|
||||
* launching fragment.
|
||||
* launching fragment.
|
||||
* @param resultData Optional result data to send back to the original
|
||||
* launching fragment.
|
||||
* launching fragment.
|
||||
*/
|
||||
public void finishPreferencePanel(Fragment caller, int resultCode, Intent resultData) {
|
||||
setResult(resultCode, resultData);
|
||||
@@ -691,8 +660,8 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
* Start a new fragment.
|
||||
*
|
||||
* @param fragment The fragment to start
|
||||
* @param push If true, the current fragment will be pushed onto the back stack. If false,
|
||||
* the current fragment will be replaced.
|
||||
* @param push If true, the current fragment will be pushed onto the back stack. If false,
|
||||
* the current fragment will be replaced.
|
||||
*/
|
||||
public void startPreferenceFragment(Fragment fragment, boolean push) {
|
||||
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
||||
@@ -940,29 +909,6 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
return mNextButton;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUpRecreateTask(Intent targetIntent) {
|
||||
return super.shouldUpRecreateTask(new Intent(this, SettingsActivity.class));
|
||||
}
|
||||
|
||||
public void startSuggestion(Intent intent) {
|
||||
if (intent == null || ActivityManager.isUserAMonkey()) {
|
||||
return;
|
||||
}
|
||||
mCurrentSuggestion = intent.getComponent();
|
||||
startActivityForResult(intent, REQUEST_SUGGESTION);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == REQUEST_SUGGESTION && mCurrentSuggestion != null
|
||||
&& resultCode != RESULT_CANCELED) {
|
||||
getPackageManager().setComponentEnabledSetting(mCurrentSuggestion,
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
|
||||
}
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
Bitmap getBitmapFromXmlResource(int drawableRes) {
|
||||
Drawable drawable = getResources().getDrawable(drawableRes, getTheme());
|
||||
|
@@ -24,13 +24,12 @@ import android.content.Intent;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.os.UserHandle;
|
||||
import android.util.Log;
|
||||
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Settings.PrivacySettingsActivity;
|
||||
import com.android.settingslib.drawer.SettingsDrawerActivity;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
/**
|
||||
@@ -153,8 +152,7 @@ public class BackupSettingsHelper {
|
||||
|
||||
private Intent getIntentForDefaultBackupSettings() {
|
||||
// Extra needed by {@link SettingsDrawerActivity} to show the back button navigation.
|
||||
return new Intent(mContext, PrivacySettingsActivity.class)
|
||||
.putExtra(SettingsDrawerActivity.EXTRA_SHOW_MENU, true);
|
||||
return new Intent(mContext, PrivacySettingsActivity.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -33,21 +33,18 @@ import android.support.annotation.VisibleForTesting;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.FeatureFlagUtils;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.core.FeatureFlags;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
import com.android.settingslib.core.instrumentation.VisibilityLoggerMixin;
|
||||
import com.android.settingslib.drawer.CategoryManager;
|
||||
import com.android.settingslib.drawer.DashboardCategory;
|
||||
import com.android.settingslib.drawer.ProfileSelectDialog;
|
||||
import com.android.settingslib.drawer.SettingsDrawerActivity;
|
||||
import com.android.settingslib.drawer.Tile;
|
||||
import com.android.settingslib.drawer.TileUtils;
|
||||
import com.android.settingslib.utils.ThreadUtils;
|
||||
@@ -212,7 +209,6 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
|
||||
final Intent intent = new Intent(tile.intent)
|
||||
.putExtra(VisibilityLoggerMixin.EXTRA_SOURCE_METRICS_CATEGORY,
|
||||
MetricsEvent.DASHBOARD_SUMMARY)
|
||||
.putExtra(SettingsDrawerActivity.EXTRA_SHOW_MENU, true)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
launchIntentOrSelectProfile(activity, tile, intent, MetricsEvent.DASHBOARD_SUMMARY);
|
||||
}
|
||||
|
@@ -236,7 +236,6 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
|
||||
Intent intent = Utils.onBuildStartFragmentIntent(getActivity(),
|
||||
StorageDashboardFragment.class.getName(), args, null,
|
||||
R.string.storage_settings, null, false, getMetricsCategory());
|
||||
intent.putExtra(SettingsDrawerActivity.EXTRA_SHOW_MENU, true);
|
||||
getActivity().startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
@@ -85,7 +85,6 @@ public class UserProfileController extends AbstractPreferenceController implemen
|
||||
Intent intent = Utils.onBuildStartFragmentIntent(mContext,
|
||||
StorageProfileFragment.class.getName(), args, null, 0,
|
||||
mUser.name, false, MetricsProto.MetricsEvent.DEVICEINFO_STORAGE);
|
||||
intent.putExtra(SettingsDrawerActivity.EXTRA_SHOW_MENU, true);
|
||||
mContext.startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
|
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.android.settings;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.nullable;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
@@ -28,17 +27,14 @@ import static org.mockito.Mockito.when;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.FragmentManager;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Answers;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
@@ -48,9 +44,6 @@ import org.robolectric.annotation.Config;
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class SettingsActivityTest {
|
||||
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
private Context mContext;
|
||||
|
||||
@Mock
|
||||
private FragmentManager mFragmentManager;
|
||||
@Mock
|
||||
@@ -84,13 +77,4 @@ public class SettingsActivityTest {
|
||||
|
||||
verify(mTaskDescription).setIcon(nullable(Bitmap.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSaveState_EnabledHomeSaved() {
|
||||
mActivity.mDisplayHomeAsUpEnabled = true;
|
||||
Bundle bundle = new Bundle();
|
||||
mActivity.saveState(bundle);
|
||||
|
||||
assertThat((boolean) bundle.get(SettingsActivity.SAVE_KEY_SHOW_HOME_AS_UP)).isTrue();
|
||||
}
|
||||
}
|
||||
|
@@ -16,6 +16,14 @@
|
||||
|
||||
package com.android.settings.backup;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.anyInt;
|
||||
import static org.mockito.Mockito.anyString;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.backup.BackupManager;
|
||||
import android.app.backup.IBackupManager;
|
||||
import android.content.ComponentName;
|
||||
@@ -26,6 +34,10 @@ import android.content.res.Resources;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -36,19 +48,6 @@ import org.robolectric.annotation.Config;
|
||||
import org.robolectric.annotation.Implementation;
|
||||
import org.robolectric.annotation.Implements;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.anyInt;
|
||||
import static org.mockito.Mockito.anyString;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settingslib.drawer.SettingsDrawerActivity;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
|
||||
shadows = {BackupSettingsHelperTest.ShadowBackupManagerStub.class})
|
||||
@@ -263,8 +262,6 @@ public class BackupSettingsHelperTest {
|
||||
|
||||
assertThat(backupIntent.getComponent().getClassName()).isEqualTo(
|
||||
DEFAULT_SETTINGS_CLASSNAME);
|
||||
assertThat(backupIntent.getExtras().getBoolean(
|
||||
SettingsDrawerActivity.EXTRA_SHOW_MENU)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user