From 2b8795a9db2d494c38d34fd113a9153880a555c0 Mon Sep 17 00:00:00 2001 From: Svetoslav Date: Mon, 11 Nov 2013 18:20:25 -0800 Subject: [PATCH] PreferencesFragment showing the breadcrumb area in single pane mode. If the PreferenceActivity is running in a single pane mode we are not showing the headers and the breadcrumb area. However, when this activity is restarted and has a saved state to restore we are trying to use headers even in a single pane mode. As a result the breadcrumb area is shown and the content is shifted to the bottom with an empty space at the top. This change ignores the saved headers from the saved instance state in a single pane mode. Note that in such a case these headers are null anyway as we do not use them. bug:11242762 Change-Id: I2828bc82762695d9c93fb4ca43933598a9b12b87 --- core/java/android/preference/PreferenceActivity.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/java/android/preference/PreferenceActivity.java b/core/java/android/preference/PreferenceActivity.java index ed9264aa9203..7ddfa874155b 100644 --- a/core/java/android/preference/PreferenceActivity.java +++ b/core/java/android/preference/PreferenceActivity.java @@ -521,7 +521,9 @@ public abstract class PreferenceActivity extends ListActivity implements int initialTitle = getIntent().getIntExtra(EXTRA_SHOW_FRAGMENT_TITLE, 0); int initialShortTitle = getIntent().getIntExtra(EXTRA_SHOW_FRAGMENT_SHORT_TITLE, 0); - if (savedInstanceState != null) { + // Restore from headers only if they are supported which + // is in multi-pane mode. + if (savedInstanceState != null && !mSinglePane) { // We are restarting from a previous saved state; used that to // initialize, instead of starting fresh. ArrayList
headers = savedInstanceState.getParcelableArrayList(HEADERS_TAG); @@ -573,14 +575,12 @@ public abstract class PreferenceActivity extends ListActivity implements // Single pane, showing just a prefs fragment. findViewById(com.android.internal.R.id.headers).setVisibility(View.GONE); mPrefsContainer.setVisibility(View.VISIBLE); - CharSequence initialTitleStr = null; - CharSequence initialShortTitleStr = null; if (initialTitle != 0) { - initialTitleStr = getText(initialTitle); - initialShortTitleStr = initialShortTitle != 0 + CharSequence initialTitleStr = getText(initialTitle); + CharSequence initialShortTitleStr = initialShortTitle != 0 ? getText(initialShortTitle) : null; + showBreadCrumbs(initialTitleStr, initialShortTitleStr); } - showBreadCrumbs(initialTitleStr, initialShortTitleStr); } else if (mHeaders.size() > 0) { setListAdapter(new HeaderAdapter(this, mHeaders)); if (!mSinglePane) { -- 2.11.0