Commit 8e1dc7cd authored by Ted Choc's avatar Ted Choc Committed by Commit Bot

Fix initial focus of the search widget.

UrlBar#setAllowFocus was not updating the widget if it had
not drawn a single time.  This internally was done because
tabbed mode wanted to prevent he UrlBar from gaining focus
on initial inflation, but tabbed mode never calls setAllowFocus
except when manipulating the tab switcher and thus would
never happen before drawn a single time.  This just updates
setAllowFocus to immediately take action and the lazy setting
of focus for Tabbed mode still happens in the first draw
callback (this method can just be set before that has happened,
which is OK for both SearchWidget and Custom Tabs as they both
want to set that state as early as possible).

BUG=871121

Change-Id: I74ef57890e223a10583ecbb67179705fb2f11caa
Reviewed-on: https://chromium-review.googlesource.com/1163754Reviewed-by: default avatarYusuf Ozuysal <yusufo@chromium.org>
Commit-Queue: Ted Choc <tedchoc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580968}
parent 554061ba
......@@ -298,10 +298,8 @@ public class UrlBar extends AutocompleteEditText {
*/
public void setAllowFocus(boolean allowFocus) {
mAllowFocus = allowFocus;
if (mFirstDrawComplete) {
setFocusable(allowFocus);
setFocusableInTouchMode(allowFocus);
}
setFocusable(allowFocus);
setFocusableInTouchMode(allowFocus);
}
/**
......
......@@ -32,8 +32,7 @@ class UrlBarViewBinder {
view.setCustomSelectionActionModeCallback(
model.getValue(UrlBarProperties.ACTION_MODE_CALLBACK));
} else if (UrlBarProperties.ALLOW_FOCUS.equals(propertyKey)) {
boolean allowFocus = model.getValue(UrlBarProperties.ALLOW_FOCUS);
view.setAllowFocus(allowFocus);
view.setAllowFocus(model.getValue(UrlBarProperties.ALLOW_FOCUS));
} else if (UrlBarProperties.AUTOCOMPLETE_TEXT.equals(propertyKey)) {
AutocompleteText autocomplete = model.getValue(UrlBarProperties.AUTOCOMPLETE_TEXT);
if (view.shouldAutocomplete()) {
......
......@@ -194,6 +194,9 @@ public class SearchActivity extends AsyncInitializationActivity
if (mQueuedUrl != null) loadUrl(mQueuedUrl);
AutocompleteController.nativePrefetchZeroSuggestResults();
// TODO(tedchoc): Warmup triggers the CustomTab layout to be inflated, but this widget
// will navigate to Tabbed mode. Investigate whether this can inflate
// the tabbed mode layout in the background instead of CCTs.
CustomTabsConnection.getInstance().warmup(0);
mSearchBox.onDeferredStartup(isVoiceSearchIntent());
RecordUserAction.record("SearchWidget.WidgetSelected");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment