Commit f2cfd5c9 authored by Matthew Jones's avatar Matthew Jones Committed by Commit Bot

[Home] Allow omnibox suggestions to be scrolled up

Previously, omnibox suggestions could be scrolled down, but when
scrolling back up, the bottom sheet would intercept the scroll and
defocus the omnibox. This change adds a special case to the bottom
sheet event handler. If the suggestions are showing and scrolled
any amount, the sheet will not take the scroll event (unless it is
in the toolbar area). This allows the suggestions to be freely
scrolled and only when they reach the top can the sheet be pulled
down.

BUG=735319

Change-Id: Icaf373d573b8c2380452d2b5e272aa1ed578f4ca
Reviewed-on: https://chromium-review.googlesource.com/562667Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Matthew Jones <mdjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#487120}
parent a8825d62
...@@ -171,4 +171,14 @@ public interface LocationBar extends UrlBarDelegate { ...@@ -171,4 +171,14 @@ public interface LocationBar extends UrlBarDelegate {
* @return Whether or not the {@link UrlBar} has to be explicitly checked for its location. * @return Whether or not the {@link UrlBar} has to be explicitly checked for its location.
*/ */
boolean mustQueryUrlBarLocationForSuggestions(); boolean mustQueryUrlBarLocationForSuggestions();
/**
* @return Whether suggestions are being shown for the location bar.
*/
boolean isSuggestionsListShown();
/**
* @return Whether the suggestions list is scrolled any amount.
*/
boolean isSuggestionsListScrolled();
} }
...@@ -646,6 +646,13 @@ public class LocationBarLayout extends FrameLayout ...@@ -646,6 +646,13 @@ public class LocationBarLayout extends FrameLayout
ApiCompatibilityUtils.setLayoutDirection(childView, layoutDirection); ApiCompatibilityUtils.setLayoutDirection(childView, layoutDirection);
} }
} }
/**
* @return Whether or not the suggestions list is scrolled any amount.
*/
private boolean isScrolled() {
return computeVerticalScrollOffset() > 0;
}
} }
public LocationBarLayout(Context context, AttributeSet attrs) { public LocationBarLayout(Context context, AttributeSet attrs) {
...@@ -690,6 +697,17 @@ public class LocationBarLayout extends FrameLayout ...@@ -690,6 +697,17 @@ public class LocationBarLayout extends FrameLayout
mMicButton = (TintedImageButton) findViewById(R.id.mic_button); mMicButton = (TintedImageButton) findViewById(R.id.mic_button);
} }
@Override
public boolean isSuggestionsListShown() {
return mSuggestionsShown;
}
@Override
public boolean isSuggestionsListScrolled() {
if (!mSuggestionsShown || mSuggestionList == null) return false;
return mSuggestionList.isScrolled();
}
@Override @Override
protected void onFinishInflate() { protected void onFinishInflate() {
super.onFinishInflate(); super.onFinishInflate();
......
...@@ -771,4 +771,16 @@ public class CustomTabToolbar extends ToolbarLayout implements LocationBar, ...@@ -771,4 +771,16 @@ public class CustomTabToolbar extends ToolbarLayout implements LocationBar,
@Override @Override
protected void setMenuButtonHighlightDrawable(boolean highlighting) {} protected void setMenuButtonHighlightDrawable(boolean highlighting) {}
@Override
public boolean isSuggestionsListShown() {
// Custom tabs do not support suggestions.
return false;
}
@Override
public boolean isSuggestionsListScrolled() {
// Custom tabs do not support suggestions.
return false;
}
} }
...@@ -346,6 +346,15 @@ public class BottomSheet ...@@ -346,6 +346,15 @@ public class BottomSheet
return false; return false;
} }
// If the suggestions for the omnibox are shown, don't scroll the sheet.
// TODO(mdjones): This should probably be treated as BottomSheetContent instead of being
// a special case.
if (!isTouchEventInToolbar(e2) && mDefaultToolbarView != null
&& mDefaultToolbarView.getLocationBar().isSuggestionsListShown()
&& mDefaultToolbarView.getLocationBar().isSuggestionsListScrolled()) {
return false;
}
// If the sheet is in the max position, don't move the sheet if the scroll is upward. // If the sheet is in the max position, don't move the sheet if the scroll is upward.
// Instead, allow the sheet's content to handle it if it needs to. // Instead, allow the sheet's content to handle it if it needs to.
if (isSheetInMaxPosition && distanceY > 0) return false; if (isSheetInMaxPosition && distanceY > 0) return false;
......
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