can open settings with support tab by default
Changes were made to the two files to allow users to provide an argument in the intent for the settings activity. This argument allows you to specify if you want the summary tab or support open on startup. Fixes: 30233920 Change-Id: I4745a0f75ea6a60a22381f5e58f2fac3836d86b9
This commit is contained in:
@@ -597,7 +597,6 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
// of starting fresh.
|
||||
mSearchMenuItemExpanded = savedState.getBoolean(SAVE_KEY_SEARCH_MENU_EXPANDED);
|
||||
mSearchQuery = savedState.getString(SAVE_KEY_SEARCH_QUERY);
|
||||
|
||||
setTitleFromIntent(intent);
|
||||
|
||||
ArrayList<DashboardCategory> categories =
|
||||
@@ -610,6 +609,7 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
|
||||
mDisplayHomeAsUpEnabled = savedState.getBoolean(SAVE_KEY_SHOW_HOME_AS_UP);
|
||||
mDisplaySearch = savedState.getBoolean(SAVE_KEY_SHOW_SEARCH);
|
||||
|
||||
} else {
|
||||
if (!mIsShowingDashboard) {
|
||||
mDisplaySearch = false;
|
||||
@@ -632,7 +632,13 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
// Show Search affordance
|
||||
mDisplaySearch = true;
|
||||
mInitialTitleResId = R.string.dashboard_title;
|
||||
switchToFragment(DashboardContainerFragment.class.getName(), null, false, false,
|
||||
|
||||
// add argument to indicate which settings tab should be initially selected
|
||||
final Bundle args = new Bundle();
|
||||
final String extraName = DashboardContainerFragment.EXTRA_SELECT_SETTINGS_TAB;
|
||||
args.putString(extraName, intent.getStringExtra(extraName));
|
||||
|
||||
switchToFragment(DashboardContainerFragment.class.getName(), args, false, false,
|
||||
mInitialTitleResId, mInitialTitle, false);
|
||||
}
|
||||
}
|
||||
@@ -1277,5 +1283,4 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
}
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -22,6 +22,7 @@ import android.app.FragmentManager;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.v13.app.FragmentPagerAdapter;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -42,6 +43,10 @@ import com.android.settingslib.drawer.SettingsDrawerActivity;
|
||||
*/
|
||||
public final class DashboardContainerFragment extends InstrumentedFragment {
|
||||
|
||||
public static final String EXTRA_SELECT_SETTINGS_TAB = ":settings:select_settings_tab";
|
||||
|
||||
private static final String ARG_SUPPORT_TAB = "SUPPORT";
|
||||
private static final String ARG_SUMMARY_TAB = "SUMMARY";
|
||||
private static final int INDEX_SUMMARY_FRAGMENT = 0;
|
||||
private static final int INDEX_SUPPORT_FRAGMENT = 1;
|
||||
|
||||
@@ -69,7 +74,16 @@ public final class DashboardContainerFragment extends InstrumentedFragment {
|
||||
mViewPager.setAdapter(mPagerAdapter);
|
||||
mViewPager.addOnPageChangeListener(
|
||||
new TabChangeListener((SettingsActivity) getActivity()));
|
||||
|
||||
// check if support tab needs to be selected
|
||||
final String selectedTab = getArguments().
|
||||
getString(EXTRA_SELECT_SETTINGS_TAB, ARG_SUMMARY_TAB);
|
||||
if (TextUtils.equals(selectedTab, ARG_SUPPORT_TAB)) {
|
||||
mViewPager.setCurrentItem(INDEX_SUPPORT_FRAGMENT);
|
||||
} else {
|
||||
mViewPager.setCurrentItem(INDEX_SUMMARY_FRAGMENT);
|
||||
}
|
||||
|
||||
mHeaderView = inflater.inflate(R.layout.dashboard_container_header, parent, false);
|
||||
((SlidingTabLayout) mHeaderView).setViewPager(mViewPager);
|
||||
return content;
|
||||
|
Reference in New Issue
Block a user