Merge "Keep rounded corners while scrolling in right pane & fix scrollbar size." into main
diff --git a/res/drawable/widget_picker_preview_pane_scroll_thumb.xml b/res/drawable/widget_picker_preview_pane_scroll_thumb.xml
new file mode 100644
index 0000000..24f90b0
--- /dev/null
+++ b/res/drawable/widget_picker_preview_pane_scroll_thumb.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ ~ Copyright (C) 2024 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<!--
+A variation of material's scrollbar_handle_material.xml that has paddings to make it smaller.
+ScrollView's "insideInsets" / "insideOverlay" styles don't consider corner radius applied to scroll
+views, so we apply matching padding to the thumb to align it.
+ -->
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+ <item
+ android:bottom="@dimen/widget_list_top_bottom_corner_radius"
+ android:top="@dimen/widget_list_top_bottom_corner_radius">
+ <shape
+ android:shape="rectangle"
+ android:tint="?android:attr/colorControlNormal">
+ <solid android:color="#84ffffff" />
+ </shape>
+ </item>
+</layer-list>
\ No newline at end of file
diff --git a/res/layout/widgets_two_pane_sheet.xml b/res/layout/widgets_two_pane_sheet.xml
index 6c4810c..bb2b7bd 100644
--- a/res/layout/widgets_two_pane_sheet.xml
+++ b/res/layout/widgets_two_pane_sheet.xml
@@ -94,42 +94,49 @@
</FrameLayout>
<FrameLayout
- android:id="@+id/right_pane_container"
android:layout_width="0dp"
android:layout_height="match_parent"
- android:layout_weight="0.67"
- android:layout_marginEnd="@dimen/widget_list_horizontal_margin_two_pane"
- android:paddingTop="@dimen/widget_list_horizontal_margin_two_pane"
- android:gravity="end"
- android:layout_gravity="end"
- android:orientation="horizontal">
- <ScrollView
- android:id="@+id/right_pane_scroll_view"
+ android:layout_weight="0.67">
+ <FrameLayout
+ android:id="@+id/right_pane_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:fillViewport="true">
- <LinearLayout
- android:orientation="vertical"
+ android:layout_marginVertical="@dimen/widget_picker_vertical_margin_right_pane"
+ android:layout_marginEnd="@dimen/widget_list_horizontal_margin_two_pane"
+ android:gravity="end"
+ android:layout_gravity="end"
+ android:orientation="horizontal">
+ <ScrollView
+ android:id="@+id/right_pane_scroll_view"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:clipToOutline="true"
- android:paddingBottom="36dp"
+ android:layout_height="match_parent"
android:background="@drawable/widgets_surface_background"
- android:importantForAccessibility="yes"
- android:id="@+id/right_pane">
- <!-- Shown when there are recommendations to display -->
+ android:scrollbarThumbVertical="@drawable/widget_picker_preview_pane_scroll_thumb"
+ android:clipToOutline="true"
+ android:fillViewport="true">
<LinearLayout
- android:id="@+id/widget_recommendations_container"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@drawable/widgets_surface_background"
android:orientation="vertical"
- android:visibility="gone">
- <include layout="@layout/widget_recommendations" />
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:clipToOutline="true"
+ android:paddingBottom="36dp"
+ android:background="@drawable/widgets_surface_background"
+ android:importantForAccessibility="yes"
+ android:id="@+id/right_pane">
+ <!-- Shown when there are recommendations to display -->
+ <LinearLayout
+ android:id="@+id/widget_recommendations_container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@drawable/widgets_surface_background"
+ android:orientation="vertical"
+ android:visibility="gone">
+ <include layout="@layout/widget_recommendations" />
+ </LinearLayout>
</LinearLayout>
- </LinearLayout>
- </ScrollView>
+ </ScrollView>
+ </FrameLayout>
</FrameLayout>
</LinearLayout>
</com.android.launcher3.views.SpringRelativeLayout>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 1e5a957..5ff9902 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -208,6 +208,7 @@
<!-- Margin applied to the recycler view with search bar & the list of widget apps below it. -->
<dimen name="widget_list_left_pane_horizontal_margin">0dp</dimen>
<dimen name="widget_list_horizontal_margin_two_pane">24dp</dimen>
+ <dimen name="widget_picker_vertical_margin_right_pane">24dp</dimen>
<dimen name="widget_preview_shadow_blur">0.5dp</dimen>
<dimen name="widget_preview_key_shadow_distance">1dp</dimen>
diff --git a/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java b/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java
index 41d5f76..2a2feed 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java
@@ -23,14 +23,12 @@
import static com.android.launcher3.UtilitiesKt.restoreAttributesOnViewTree;
import android.content.Context;
-import android.graphics.Outline;
import android.graphics.Rect;
import android.os.Process;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
-import android.view.ViewOutlineProvider;
import android.view.ViewParent;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
@@ -80,21 +78,6 @@
private int mActivePage = -1;
private PackageUserKey mSelectedHeader;
- private final ViewOutlineProvider mViewOutlineProviderRightPane = new ViewOutlineProvider() {
- @Override
- public void getOutline(View view, Outline outline) {
- outline.setRoundRect(
- 0,
- 0,
- view.getMeasuredWidth(),
- view.getMeasuredHeight() - getResources().getDimensionPixelSize(
- R.dimen.widget_list_horizontal_margin_two_pane),
- view.getResources().getDimensionPixelSize(
- R.dimen.widget_list_top_bottom_corner_radius)
- );
- }
- };
-
public WidgetsTwoPaneSheet(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@@ -138,11 +121,8 @@
mHeaderTitle = mContent.findViewById(R.id.title);
mRightPane = mContent.findViewById(R.id.right_pane);
- mRightPane.setOutlineProvider(mViewOutlineProviderRightPane);
mRightPaneScrollView = mContent.findViewById(R.id.right_pane_scroll_view);
mRightPaneScrollView.setOverScrollMode(View.OVER_SCROLL_NEVER);
- mRightPaneScrollView.setOutlineProvider(mViewOutlineProvider);
- mRightPaneScrollView.setClipToOutline(true);
mPrimaryWidgetListView = findViewById(R.id.primary_widgets_list_view);
mPrimaryWidgetListView.setOutlineProvider(mViewOutlineProvider);