Fix bug #13813608 Launcher back button does not take you to previous...
... settings after orientation change - gasp, there were some issues in the way we were tracking if a search result fragment was opened. Simplified that code. Change-Id: I7f8efb3a5aab1a275193f7de15ac50ca33bdad16
This commit is contained in:
@@ -306,7 +306,6 @@ public class SettingsActivity extends Activity
|
||||
private SearchView mSearchView;
|
||||
private MenuItem mSearchMenuItem;
|
||||
private boolean mSearchMenuItemExpanded = false;
|
||||
private boolean mIsShowingSearchResults = false;
|
||||
private SearchResultsSummary mSearchResultsFragment;
|
||||
private String mSearchQuery;
|
||||
|
||||
@@ -1257,17 +1256,15 @@ public class SettingsActivity extends Activity
|
||||
@Override
|
||||
public boolean onMenuItemActionExpand(MenuItem item) {
|
||||
if (item.getItemId() == mSearchMenuItem.getItemId()) {
|
||||
if (mSearchResultsFragment == null) {
|
||||
switchToSearchResultsFragmentIfNeeded();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemActionCollapse(MenuItem item) {
|
||||
if (item.getItemId() == mSearchMenuItem.getItemId()) {
|
||||
if (mIsShowingSearchResults) {
|
||||
if (mSearchMenuItemExpanded) {
|
||||
revertToInitialFragment();
|
||||
}
|
||||
}
|
||||
@@ -1275,7 +1272,9 @@ public class SettingsActivity extends Activity
|
||||
}
|
||||
|
||||
private void switchToSearchResultsFragmentIfNeeded() {
|
||||
if (!mIsShowingSearchResults) {
|
||||
if (mSearchResultsFragment != null) {
|
||||
return;
|
||||
}
|
||||
Fragment current = getFragmentManager().findFragmentById(R.id.prefs);
|
||||
if (current != null && current instanceof SearchResultsSummary) {
|
||||
mSearchResultsFragment = (SearchResultsSummary) current;
|
||||
@@ -1284,8 +1283,7 @@ public class SettingsActivity extends Activity
|
||||
mSearchResultsFragment = (SearchResultsSummary) switchToFragment(
|
||||
SearchResultsSummary.class.getName(), null, false, true, title, true);
|
||||
}
|
||||
mIsShowingSearchResults = true;
|
||||
}
|
||||
mSearchMenuItemExpanded = true;
|
||||
}
|
||||
|
||||
public void needToRevertToInitialFragment() {
|
||||
@@ -1294,10 +1292,10 @@ public class SettingsActivity extends Activity
|
||||
|
||||
private void revertToInitialFragment() {
|
||||
mNeedToRevertToInitialFragment = false;
|
||||
getFragmentManager().popBackStack(SettingsActivity.BACK_STACK_PREFS,
|
||||
FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||
mSearchResultsFragment = null;
|
||||
mIsShowingSearchResults = false;
|
||||
mSearchMenuItemExpanded = false;
|
||||
getFragmentManager().popBackStackImmediate(SettingsActivity.BACK_STACK_PREFS,
|
||||
FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||
mSearchMenuItem.collapseActionView();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user