Bug 935604 - Part 2: Typing about:home directly does not break tab. r=sriram, a=lsblakk
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -1426,30 +1426,30 @@ abstract public class BrowserApp extends
}
private void commitEditingMode() {
if (!mBrowserToolbar.isEditing()) {
return;
}
final String url = mBrowserToolbar.commitEdit();
+ hideBrowserSearch();
// HACK: We don't know the url that will be loaded when hideHomePager is initially called
// in BrowserToolbar's onStopEditing listener so on the awesomescreen, hideHomePager will
// use the url "about:home" and return without taking any action. hideBrowserSearch is
// then called, but since hideHomePager changes both HomePager and LayerView visibility
// and exited without taking an action, no Views are displayed and graphical corruption is
// visible instead.
//
// Here we call hideHomePager for the second time with the URL to be loaded so that
// hideHomePager is called with the correct state for the upcoming page load.
//
// Expected to be fixed by bug 915825.
hideHomePager(url);
- hideBrowserSearch();
// Don't do anything if the user entered an empty URL.
if (TextUtils.isEmpty(url)) {
return;
}
// If the URL doesn't look like a search query, just load it.
if (!StringUtils.isSearchQuery(url, true)) {
@@ -1518,32 +1518,27 @@ abstract public class BrowserApp extends
private boolean dismissEditingMode() {
if (!mBrowserToolbar.isEditing()) {
return false;
}
mBrowserToolbar.cancelEdit();
- // Resetting the visibility of HomePager, which might have been hidden
- // by the filterEditingMode().
- mHomePager.setVisibility(View.VISIBLE);
hideHomePager();
hideBrowserSearch();
return true;
}
void filterEditingMode(String searchTerm, AutocompleteHandler handler) {
if (TextUtils.isEmpty(searchTerm)) {
- mHomePager.setVisibility(View.VISIBLE);
hideBrowserSearch();
} else {
showBrowserSearch();
- mHomePager.setVisibility(View.INVISIBLE);
mBrowserSearch.filter(searchTerm, handler);
}
}
/**
* Shows or hides the home pager for the given tab.
*/
private void updateHomePagerForTab(Tab tab) {
@@ -1658,16 +1653,19 @@ abstract public class BrowserApp extends
private void showBrowserSearch() {
if (mBrowserSearch.getUserVisibleHint()) {
return;
}
mBrowserSearchContainer.setVisibility(View.VISIBLE);
+ // Prevent overdraw by hiding the underlying HomePager View.
+ mHomePager.setVisibility(View.INVISIBLE);
+
final FragmentManager fm = getSupportFragmentManager();
// In certain situations, showBrowserSearch() can be called immediately after hideBrowserSearch()
// (see bug 925012). Because of an Android bug (http://code.google.com/p/android/issues/detail?id=61179),
// calling FragmentTransaction#add immediately after FragmentTransaction#remove won't add the fragment's
// view to the layout. Calling FragmentManager#executePendingTransactions before re-adding the fragment
// prevents this issue.
fm.executePendingTransactions();
@@ -1676,16 +1674,20 @@ abstract public class BrowserApp extends
mBrowserSearch.setUserVisibleHint(true);
}
private void hideBrowserSearch() {
if (!mBrowserSearch.getUserVisibleHint()) {
return;
}
+ // To prevent overdraw, the HomePager is hidden when BrowserSearch is displayed:
+ // reverse that.
+ mHomePager.setVisibility(View.VISIBLE);
+
mBrowserSearchContainer.setVisibility(View.INVISIBLE);
getSupportFragmentManager().beginTransaction()
.remove(mBrowserSearch).commitAllowingStateLoss();
mBrowserSearch.setUserVisibleHint(false);
}
private class HideTabsTouchListener implements TouchEventInterceptor {