Skip to content

Commit

Permalink
[RSearches] Add a margin under the Carousel to show the progress bar
Browse files Browse the repository at this point in the history
(cherry picked from commit 80ce0c8)

Bug: 1257889
Change-Id: Ibf7c40924d7056c06e07eebca4b9840b2725fc7c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3579346
Reviewed-by: Donn Denman <donnd@chromium.org>
Reviewed-by: Theresa Sullivan <twellington@chromium.org>
Commit-Queue: Gang Wu <gangwu@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#991316}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3585068
Auto-Submit: Gang Wu <gangwu@chromium.org>
Commit-Queue: Theresa Sullivan <twellington@chromium.org>
Commit-Queue: Donn Denman <donnd@chromium.org>
Cr-Commit-Position: refs/branch-heads/4951@{#734}
Cr-Branched-From: 27de622-refs/heads/main@{#982481}
  • Loading branch information
Gang Wu authored and Chromium LUCI CQ committed Apr 13, 2022
1 parent ec29cd8 commit b499e39
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
Expand Up @@ -4,12 +4,18 @@
found in the LICENSE file. -->

<!-- Displays Related Searches suggestions in the Bar of the Overlay Panel. -->
<org.chromium.chrome.browser.compositor.bottombar.contextualsearch.NoSystemGestureFrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/contextual_search_related_searches_view_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@macro/overlay_panel_bar_background_color"
android:visibility="invisible">
<!-- ChipView elements and their container are dynamically added here. -->
</org.chromium.chrome.browser.compositor.bottombar.contextualsearch.NoSystemGestureFrameLayout>
<org.chromium.chrome.browser.compositor.bottombar.contextualsearch.NoSystemGestureFrameLayout
android:id="@+id/contextual_search_related_searches_view_control_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@macro/overlay_panel_bar_background_color"
android:layout_marginBottom="@dimen/toolbar_progress_bar_height"
android:layout_gravity="top">
<!-- ChipView elements and their container are dynamically added here. -->
</org.chromium.chrome.browser.compositor.bottombar.contextualsearch.NoSystemGestureFrameLayout>
</FrameLayout>
Expand Up @@ -225,8 +225,11 @@ void setRelatedSearchesSuggestions(@Nullable List<String> relatedSearches,
int viewId = mIsInBarControl
? R.id.contextual_search_related_searches_view_id
: R.id.contextual_search_related_searches_in_content_view_id;
mControlView = new RelatedSearchesControlView(
mOverlayPanel, mContext, mViewContainer, mResourceLoader, layoutId, viewId);
int controlId = mIsInBarControl
? R.id.contextual_search_related_searches_view_control_id
: R.id.contextual_search_related_searches_in_content_view_id;
mControlView = new RelatedSearchesControlView(mOverlayPanel, mContext, mViewContainer,
mResourceLoader, layoutId, viewId, controlId);
}
assert mChipsSelected == 0 || hasReleatedSearchesToShow();
mRelatedSearchesSuggestions = relatedSearches;
Expand Down Expand Up @@ -406,7 +409,7 @@ private void showView(boolean fromCloseToPeek) {
if (mControlView == null) return;

float y = mPanelSectionHost.getYPositionPx();
View view = mControlView.getControlView();
View view = mControlView.getView();
if (view == null || !mIsVisible || (mIsShowingView && mViewY == y) || mHeightPx == 0.f) {
return;
}
Expand Down Expand Up @@ -438,7 +441,7 @@ private void showView(boolean fromCloseToPeek) {
private void hideView() {
if (mControlView == null) return;

View view = mControlView.getControlView();
View view = mControlView.getView();
if (view == null || !mIsVisible || !mIsShowingView) {
return;
}
Expand Down Expand Up @@ -540,6 +543,7 @@ private class RelatedSearchesControlView extends OverlayPanelInflater {
// TODO(donnd): track the offset of the carousel here, so we can use it for snapshotting
// and log that the user has scrolled it.
private float mLastOffset;
private final int mControlId;

/**
* Constructs a view that can be shown in the panel.
Expand All @@ -549,10 +553,12 @@ private class RelatedSearchesControlView extends OverlayPanelInflater {
* @param resourceLoader The resource loader that will handle the snapshot capturing.
* @param layoutId The XML Layout that declares the View.
* @param viewId The id of the root View of the Layout.
* @param controlId The id of the control View.
*/
RelatedSearchesControlView(OverlayPanel panel, Context context, ViewGroup container,
DynamicResourceLoader resourceLoader, int layoutId, int viewId) {
DynamicResourceLoader resourceLoader, int layoutId, int viewId, int controlId) {
super(panel, layoutId, viewId, context, container, resourceLoader);
mControlId = controlId;

// Setup Chips handling
mChipsCoordinator = new ChipsCoordinator(context, mChips);
Expand Down Expand Up @@ -583,6 +589,14 @@ private void scrollToPosition(int position) {

/** Returns the view for this control. */
View getControlView() {
View view = getView();
if (view == null) return null;

return view.findViewById(mControlId);
}

@Override
public View getView() {
return super.getView();
}

Expand Down

0 comments on commit b499e39

Please sign in to comment.