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 SearchView mSearchView;
|
||||||
private MenuItem mSearchMenuItem;
|
private MenuItem mSearchMenuItem;
|
||||||
private boolean mSearchMenuItemExpanded = false;
|
private boolean mSearchMenuItemExpanded = false;
|
||||||
private boolean mIsShowingSearchResults = false;
|
|
||||||
private SearchResultsSummary mSearchResultsFragment;
|
private SearchResultsSummary mSearchResultsFragment;
|
||||||
private String mSearchQuery;
|
private String mSearchQuery;
|
||||||
|
|
||||||
@@ -1257,9 +1256,7 @@ public class SettingsActivity extends Activity
|
|||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemActionExpand(MenuItem item) {
|
public boolean onMenuItemActionExpand(MenuItem item) {
|
||||||
if (item.getItemId() == mSearchMenuItem.getItemId()) {
|
if (item.getItemId() == mSearchMenuItem.getItemId()) {
|
||||||
if (mSearchResultsFragment == null) {
|
switchToSearchResultsFragmentIfNeeded();
|
||||||
switchToSearchResultsFragmentIfNeeded();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1267,7 +1264,7 @@ public class SettingsActivity extends Activity
|
|||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemActionCollapse(MenuItem item) {
|
public boolean onMenuItemActionCollapse(MenuItem item) {
|
||||||
if (item.getItemId() == mSearchMenuItem.getItemId()) {
|
if (item.getItemId() == mSearchMenuItem.getItemId()) {
|
||||||
if (mIsShowingSearchResults) {
|
if (mSearchMenuItemExpanded) {
|
||||||
revertToInitialFragment();
|
revertToInitialFragment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1275,17 +1272,18 @@ public class SettingsActivity extends Activity
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void switchToSearchResultsFragmentIfNeeded() {
|
private void switchToSearchResultsFragmentIfNeeded() {
|
||||||
if (!mIsShowingSearchResults) {
|
if (mSearchResultsFragment != null) {
|
||||||
Fragment current = getFragmentManager().findFragmentById(R.id.prefs);
|
return;
|
||||||
if (current != null && current instanceof SearchResultsSummary) {
|
|
||||||
mSearchResultsFragment = (SearchResultsSummary) current;
|
|
||||||
} else {
|
|
||||||
String title = getString(R.string.search_results_title);
|
|
||||||
mSearchResultsFragment = (SearchResultsSummary) switchToFragment(
|
|
||||||
SearchResultsSummary.class.getName(), null, false, true, title, true);
|
|
||||||
}
|
|
||||||
mIsShowingSearchResults = true;
|
|
||||||
}
|
}
|
||||||
|
Fragment current = getFragmentManager().findFragmentById(R.id.prefs);
|
||||||
|
if (current != null && current instanceof SearchResultsSummary) {
|
||||||
|
mSearchResultsFragment = (SearchResultsSummary) current;
|
||||||
|
} else {
|
||||||
|
String title = getString(R.string.search_results_title);
|
||||||
|
mSearchResultsFragment = (SearchResultsSummary) switchToFragment(
|
||||||
|
SearchResultsSummary.class.getName(), null, false, true, title, true);
|
||||||
|
}
|
||||||
|
mSearchMenuItemExpanded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void needToRevertToInitialFragment() {
|
public void needToRevertToInitialFragment() {
|
||||||
@@ -1294,10 +1292,10 @@ public class SettingsActivity extends Activity
|
|||||||
|
|
||||||
private void revertToInitialFragment() {
|
private void revertToInitialFragment() {
|
||||||
mNeedToRevertToInitialFragment = false;
|
mNeedToRevertToInitialFragment = false;
|
||||||
getFragmentManager().popBackStack(SettingsActivity.BACK_STACK_PREFS,
|
|
||||||
FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
|
||||||
mSearchResultsFragment = null;
|
mSearchResultsFragment = null;
|
||||||
mIsShowingSearchResults = false;
|
mSearchMenuItemExpanded = false;
|
||||||
|
getFragmentManager().popBackStackImmediate(SettingsActivity.BACK_STACK_PREFS,
|
||||||
|
FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||||
mSearchMenuItem.collapseActionView();
|
mSearchMenuItem.collapseActionView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user