Commit 0b4b79d2 authored by Hui(Andy) Wu's avatar Hui(Andy) Wu Committed by Commit Bot

[Autofill Assistant] Allow user to swipe down the assistant UI.

Avoid blocking important part of the underlying page.

Screenshots:
https://drive.google.com/file/d/1QHMmX0s2uIE1v82TNmj7KwR-3PJIipGO/view?usp=sharing
https://drive.google.com/file/d/13EipCdWx5sJDn8-BTeS9f3vb_v5poJQA/view?usp=sharing

Bug: 119282188
Change-Id: I4a5c5144f0dd4ef6803c270129d18cb716438a17
Reviewed-on: https://chromium-review.googlesource.com/c/1340940Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Reviewed-by: default avatarGanggui Tang <gogerald@chromium.org>
Commit-Queue: Hui Wu <wuandy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612344}
parent 1e501e3d
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/autofill_assistant_light_grey"/>
<corners android:radius="2dp"/>
<size android:height="4dp" android:width="36dp"/>
</shape>
...@@ -10,134 +10,154 @@ ...@@ -10,134 +10,154 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:visibility="invisible" android:visibility="invisible"
android:gravity="bottom"> android:gravity="bottom">
<org.chromium.chrome.browser.autofill_assistant.ui.TouchEventFilter
android:id="@+id/touch_event_filter"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:clickable="true"
android:visibility="visible"
android:focusable="false"
android:orientation="vertical"/>
<LinearLayout <org.chromium.chrome.browser.autofill_assistant.ui.TouchEventFilter
android:id="@+id/bottombar" android:id="@+id/touch_event_filter"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_gravity="bottom" android:gravity="center"
android:clickable="true" android:clickable="true"
android:background="@drawable/autofill_assistant_bottombar_bg" android:visibility="visible"
android:orientation="vertical"> android:focusable="false"
android:orientation="vertical"/>
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
<LinearLayout <LinearLayout
android:id="@+id/autofill_assistant_bottombar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="56dp" android:layout_height="wrap_content"
android:layout_marginTop="16dp" android:layout_gravity="bottom"
android:layout_marginStart="24dp" android:clickable="true"
android:layout_marginEnd="24dp" android:background="@drawable/autofill_assistant_bottombar_bg"
android:orientation="horizontal" android:orientation="vertical"
android:gravity="center_vertical"> app:behavior_peekHeight="34dp"
app:layout_behavior="@string/bottom_sheet_behavior">
<org.chromium.ui.widget.ChromeImageView <org.chromium.ui.widget.ChromeImageView
android:layout_width="24dp" android:id="@+id/swipe_indicator"
android:layout_height="24dp" android:layout_width="36dp"
app:srcCompat="@drawable/ic_autofill_assistant_24dp" /> android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginBottom="10dp"
android:layout_gravity="center_horizontal"
android:src="@drawable/autofill_assistant_swipe_indicator"/>
<TextView <LinearLayout
android:id="@+id/status_message" android:layout_width="match_parent"
android:layout_width="0dp" android:layout_height="wrap_content"
android:layout_height="match_parent" android:layout_marginStart="24dp"
android:gravity="center_vertical" android:layout_marginEnd="24dp"
android:paddingStart="24dp" android:orientation="horizontal"
android:paddingEnd="24dp" android:gravity="center_vertical">
android:textAppearance="@style/BlackTitle2"
android:layout_weight="1.0"
android:maxLines="2"
android:ellipsize="end"/>
<ImageButton <org.chromium.ui.widget.ChromeImageView
android:id="@+id/feedback_button" android:id="@+id/assistant_image"
android:layout_width="24dp" android:layout_width="24dp"
android:layout_height="24dp" android:layout_height="24dp"
android:layout_marginEnd="12dp" app:srcCompat="@drawable/ic_autofill_assistant_24dp" />
android:src="@drawable/ic_bug_report_24dp"
android:tint="@color/light_icon_color"
android:background="?attr/selectableItemBackground"
android:contentDescription="@string/menu_send_feedback" />
<ImageButton <TextView
android:id="@+id/close_button" android:id="@+id/status_message"
android:layout_width="24dp" android:layout_width="0dp"
android:layout_height="24dp" android:layout_height="match_parent"
android:src="@drawable/btn_delete_24dp" android:gravity="center_vertical"
android:tint="@color/light_icon_color" android:paddingStart="24dp"
android:background="?attr/selectableItemBackground" android:paddingEnd="24dp"
android:contentDescription="@string/close" /> android:textAppearance="@style/BlackTitle2"
</LinearLayout> android:layout_weight="1.0"
android:maxLines="2"
android:ellipsize="end"/>
<org.chromium.chrome.browser.widget.MaterialProgressBar <org.chromium.ui.widget.ChromeImageButton
android:id="@+id/progress_bar" android:id="@+id/feedback_button"
android:layout_width="match_parent" android:layout_width="24dp"
android:layout_height="6dp" android:layout_height="24dp"
app:colorBackground="@color/modern_grey_100" android:layout_marginEnd="12dp"
app:colorProgress="@color/modern_blue_600" /> android:src="@drawable/ic_bug_report_24dp"
android:tint="@color/light_icon_color"
android:background="?attr/selectableItemBackground"
android:contentDescription="@string/menu_send_feedback" />
<org.chromium.ui.widget.ChromeImageButton
android:id="@+id/close_button"
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@drawable/btn_delete_24dp"
android:tint="@color/light_icon_color"
android:background="?attr/selectableItemBackground"
android:contentDescription="@string/close" />
</LinearLayout>
<org.chromium.chrome.browser.widget.MaterialProgressBar
android:id="@+id/progress_bar"
android:layout_width="match_parent"
android:layout_height="6dp"
android:layout_marginTop="17dp"
app:colorBackground="@color/modern_grey_100"
app:colorProgress="@color/modern_blue_600" />
<LinearLayout
android:id="@+id/details"
android:layout_width="match_parent"
android:layout_height="64dp"
android:background="@drawable/autofill_assistant_details_bg"
android:padding="8dp"
android:visibility="gone"
android:orientation="horizontal">
<org.chromium.ui.widget.ChromeImageView
android:id="@+id/details_image"
android:layout_width="@dimen/autofill_assistant_details_image_size"
android:layout_height="@dimen/autofill_assistant_details_image_size"
android:layout_marginEnd="16dp"
android:scaleType="centerCrop"/>
<LinearLayout <LinearLayout
android:id="@+id/details"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="64dp"
android:orientation="vertical"> android:background="@drawable/autofill_assistant_details_bg"
<TextView android:padding="8dp"
android:id="@+id/details_title" android:visibility="gone"
android:layout_width="wrap_content" android:orientation="horizontal">
android:minWidth="184dp" <org.chromium.ui.widget.ChromeImageView
android:layout_height="16dp" android:id="@+id/details_image"
android:layout_marginBottom="2dp" android:layout_width="@dimen/autofill_assistant_details_image_size"
android:layout_marginTop="7dp" android:layout_height="@dimen/autofill_assistant_details_image_size"
android:gravity="bottom" android:layout_marginEnd="16dp"
android:textAppearance="@style/BlackCaptionDefault" android:scaleType="centerCrop"/>
android:textStyle="bold" <LinearLayout
android:maxLines="1"
android:ellipsize="end"/>
<TextView
android:id="@+id/details_text"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="16dp" android:layout_height="match_parent"
android:gravity="top" android:orientation="vertical">
android:textAppearance="@style/BlackCaption" <TextView
android:maxLines="1" android:id="@+id/details_title"
android:ellipsize="end"/> android:layout_width="wrap_content"
android:minWidth="184dp"
android:layout_height="16dp"
android:layout_marginBottom="2dp"
android:layout_marginTop="7dp"
android:gravity="bottom"
android:textAppearance="@style/BlackCaptionDefault"
android:textStyle="bold"
android:maxLines="1"
android:ellipsize="end"/>
<TextView
android:id="@+id/details_text"
android:layout_width="match_parent"
android:layout_height="16dp"
android:gravity="top"
android:textAppearance="@style/BlackCaption"
android:maxLines="1"
android:ellipsize="end"/>
</LinearLayout>
</LinearLayout> </LinearLayout>
</LinearLayout>
<HorizontalScrollView <HorizontalScrollView
android:id="@+id/carousel_scroll" android:id="@+id/carousel_scroll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollbars="none">
<LinearLayout
android:id="@+id/carousel"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="16dp" android:scrollbars="none">
android:paddingStart="24dp" <LinearLayout
android:paddingEnd="24dp" android:id="@+id/carousel"
android:gravity="center_vertical" android:layout_width="wrap_content"
android:orientation="horizontal" android:layout_height="wrap_content"
android:visibility="gone"> android:paddingBottom="16dp"
</LinearLayout> android:paddingStart="24dp"
</HorizontalScrollView> android:paddingEnd="24dp"
</LinearLayout> android:gravity="center_vertical"
android:orientation="horizontal"
android:visibility="gone">
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
</FrameLayout> </FrameLayout>
...@@ -10,4 +10,5 @@ ...@@ -10,4 +10,5 @@
Please see src/ui/android/java/res/values/colors.xml for the shared common colors. Please see src/ui/android/java/res/values/colors.xml for the shared common colors.
--> -->
<color name="autofill_assistant_light_blue">#e9f0fd</color> <color name="autofill_assistant_light_blue">#e9f0fd</color>
<color name="autofill_assistant_light_grey">@color/modern_grey_300</color>
</resources> </resources>
...@@ -19,6 +19,7 @@ import android.media.ThumbnailUtils; ...@@ -19,6 +19,7 @@ import android.media.ThumbnailUtils;
import android.support.annotation.ColorInt; import android.support.annotation.ColorInt;
import android.support.annotation.IntDef; import android.support.annotation.IntDef;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.design.widget.BottomSheetBehavior;
import android.support.v4.graphics.drawable.RoundedBitmapDrawable; import android.support.v4.graphics.drawable.RoundedBitmapDrawable;
import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory; import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory;
import android.support.v4.text.TextUtilsCompat; import android.support.v4.text.TextUtilsCompat;
...@@ -92,6 +93,7 @@ class AutofillAssistantUiDelegate { ...@@ -92,6 +93,7 @@ class AutofillAssistantUiDelegate {
private final View mFullContainer; private final View mFullContainer;
private final TouchEventFilter mTouchEventFilter; private final TouchEventFilter mTouchEventFilter;
private final LinearLayout mBottomBar; private final LinearLayout mBottomBar;
private final BottomSheetBehavior mBottomBarBehavior;
private final HorizontalScrollView mCarouselScroll; private final HorizontalScrollView mCarouselScroll;
private final ViewGroup mChipsViewContainer; private final ViewGroup mChipsViewContainer;
private final TextView mStatusMessageView; private final TextView mStatusMessageView;
...@@ -255,6 +257,7 @@ class AutofillAssistantUiDelegate { ...@@ -255,6 +257,7 @@ class AutofillAssistantUiDelegate {
// TODO(crbug.com/806868): Set hint text on overlay. // TODO(crbug.com/806868): Set hint text on overlay.
mTouchEventFilter = (TouchEventFilter) mFullContainer.findViewById(R.id.touch_event_filter); mTouchEventFilter = (TouchEventFilter) mFullContainer.findViewById(R.id.touch_event_filter);
mBottomBar = mFullContainer.findViewById(R.id.bottombar); mBottomBar = mFullContainer.findViewById(R.id.bottombar);
mBottomBarBehavior = BottomSheetBehavior.from(mBottomBar);
mBottomBar.findViewById(R.id.close_button) mBottomBar.findViewById(R.id.close_button)
.setOnClickListener(unusedView -> mClient.onDismiss()); .setOnClickListener(unusedView -> mClient.onDismiss());
mBottomBar.findViewById(R.id.feedback_button) mBottomBar.findViewById(R.id.feedback_button)
...@@ -423,6 +426,7 @@ class AutofillAssistantUiDelegate { ...@@ -423,6 +426,7 @@ class AutofillAssistantUiDelegate {
mTouchEventFilter.init(mClient, mActivity.getFullscreenManager(), mTouchEventFilter.init(mClient, mActivity.getFullscreenManager(),
mActivity.getActivityTab().getWebContents()); mActivity.getActivityTab().getWebContents());
mFullContainer.setVisibility(View.VISIBLE); mFullContainer.setVisibility(View.VISIBLE);
mBottomBarBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
// Announce Autofill Assistant is available for accessibility. // Announce Autofill Assistant is available for accessibility.
mBottomBar.announceForAccessibility( mBottomBar.announceForAccessibility(
......
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