Commit 9369dc9b authored by Kyle Milka's avatar Kyle Milka Committed by Commit Bot

[SharingHub] Make share sheet scrollable

Wrap the contents of the share sheet in a ScrollView so
it can be scrolled if it doesn't all fit in the viewport.

Bug: 1127249
Change-Id: Id86b92a52f93b107842f9ddb679537afdec75306
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2410310
Commit-Queue: Kyle Milka <kmilka@chromium.org>
Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807250}
parent 489e3656
......@@ -3,44 +3,49 @@
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/min_touch_target_size"
android:orientation="vertical">
<TextView
android:id="@+id/message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="48dp"
android:paddingStart="16dp"
android:gravity="center_vertical"
android:background="@color/default_bg_color_blue"
android:textAppearance="@style/TextAppearance.TextSmall.Primary.Inverse"
android:visibility="gone"/>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/share_sheet_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/min_touch_target_size"
android:orientation="vertical">
<TextView
android:id="@+id/message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="48dp"
android:paddingStart="16dp"
android:gravity="center_vertical"
android:background="@color/default_bg_color_blue"
android:textAppearance="@style/TextAppearance.TextSmall.Primary.Inverse"
android:visibility="gone"/>
<RelativeLayout
android:id="@+id/preview_header"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="20dp"
android:paddingStart="16dp"
android:paddingTop="24dp">
<RelativeLayout
android:id="@+id/preview_header"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="20dp"
android:paddingStart="16dp"
android:paddingTop="24dp">
<org.chromium.components.browser_ui.widget.RoundedCornerImageView
android:id="@+id/image_preview"
android:layout_height="@dimen/sharing_hub_preview_monogram_size"
android:layout_width="@dimen/sharing_hub_preview_monogram_size"
android:scaleType="fitCenter"
app:cornerRadiusBottomStart="@dimen/default_rounded_corner_radius"
app:cornerRadiusBottomEnd="@dimen/default_rounded_corner_radius"
app:cornerRadiusTopStart="@dimen/default_rounded_corner_radius"
app:cornerRadiusTopEnd="@dimen/default_rounded_corner_radius"
tools:ignore="ContentDescription"/>
android:id="@+id/image_preview"
android:layout_height="@dimen/sharing_hub_preview_monogram_size"
android:layout_width="@dimen/sharing_hub_preview_monogram_size"
android:scaleType="fitCenter"
app:cornerRadiusBottomStart="@dimen/default_rounded_corner_radius"
app:cornerRadiusBottomEnd="@dimen/default_rounded_corner_radius"
app:cornerRadiusTopStart="@dimen/default_rounded_corner_radius"
app:cornerRadiusTopEnd="@dimen/default_rounded_corner_radius"
tools:ignore="ContentDescription"/>
<TextView
android:id="@+id/title_preview"
......@@ -69,38 +74,39 @@
android:paddingStart="12dp"
android:textAlignment="viewStart"
android:textAppearance="@style/TextAppearance.TextMedium.Primary"/>
</RelativeLayout>
</RelativeLayout>
<View
android:id="@+id/preview_divider"
android:background="@color/divider_line_bg_color"
android:layout_height="1dp"
android:layout_width="match_parent"/>
<View
android:id="@+id/preview_divider"
android:background="@color/divider_line_bg_color"
android:layout_height="1dp"
android:layout_width="match_parent"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/share_sheet_other_apps"
android:clipToPadding="false"
android:layout_width="wrap_content"
android:layout_height="113dp"
android:minHeight="@dimen/min_touch_target_size"
android:orientation="horizontal"
android:paddingEnd="16dp" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/share_sheet_other_apps"
android:clipToPadding="false"
android:layout_width="wrap_content"
android:layout_height="113dp"
android:minHeight="@dimen/min_touch_target_size"
android:orientation="horizontal"
android:paddingEnd="16dp" />
<View
android:id="@+id/share_sheet_divider"
android:background="@color/divider_line_bg_color"
android:layout_height="1dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_width="match_parent"
android:visibility="gone" />
<View
android:id="@+id/share_sheet_divider"
android:background="@color/divider_line_bg_color"
android:layout_height="1dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_width="match_parent"
android:visibility="gone" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/share_sheet_chrome_apps"
android:clipToPadding="false"
android:layout_width="wrap_content"
android:layout_height="113dp"
android:minHeight="@dimen/min_touch_target_size"
android:paddingEnd="16dp"
android:visibility="gone" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/share_sheet_chrome_apps"
android:clipToPadding="false"
android:layout_width="wrap_content"
android:layout_height="113dp"
android:minHeight="@dimen/min_touch_target_size"
android:paddingEnd="16dp"
android:visibility="gone" />
</LinearLayout>
</ScrollView>
......@@ -15,6 +15,7 @@ import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.TextView;
import androidx.annotation.ColorInt;
......@@ -55,6 +56,7 @@ class ShareSheetBottomSheetContent implements BottomSheetContent, OnItemClickLis
private ViewGroup mContentView;
private ShareParams mParams;
private String mUrl;
private ScrollView mContentScrollableView;
/**
* Creates a ShareSheetBottomSheetContent (custom share sheet) opened from the given activity.
......@@ -76,6 +78,7 @@ class ShareSheetBottomSheetContent implements BottomSheetContent, OnItemClickLis
private void createContentView() {
mContentView = (ViewGroup) LayoutInflater.from(mContext).inflate(
R.layout.share_sheet_content, null);
mContentScrollableView = mContentView.findViewById(R.id.share_sheet_scrollview);
}
/*
......@@ -315,6 +318,10 @@ class ShareSheetBottomSheetContent implements BottomSheetContent, OnItemClickLis
@Override
public int getVerticalScrollOffset() {
if (mContentScrollableView != null) {
return mContentScrollableView.getScrollY();
}
return 0;
}
......
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