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());
|
||||
|
Reference in New Issue
Block a user