Bug 697121 - Keep focus on entry while typing on AwesomeBar (r=mfinkle)
When user types on AwesomeBar's entry, we always switch to 'All Pages' tab to
show the filtered results. Tab switching was causing the tab content to steal
focus from the search entry.
--- a/embedding/android/AwesomeBarTabs.java
+++ b/embedding/android/AwesomeBarTabs.java
@@ -536,19 +536,25 @@ public class AwesomeBarTabs extends TabH
if (mBookmarksAdapter != null) {
Cursor bookmarksCursor = mBookmarksAdapter.getCursor();
if (bookmarksCursor != null)
bookmarksCursor.close();
}
}
public void filter(String searchTerm) {
+ // Don't let the tab's content steal focus on tab switch
+ setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
+
// Ensure the 'All Pages' tab is selected
setCurrentTabByTag(ALL_PAGES_TAB);
+ // Restore normal focus behavior on tab host
+ setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
+
// The tabs should only be visible if there's no on-going search
int tabsVisibility = (searchTerm.length() == 0 ? View.VISIBLE : View.GONE);
getTabWidget().setVisibility(tabsVisibility);
// Perform the actual search
mAllPagesAdapter.getFilter().filter(searchTerm);
}
}