Merge changes I8ccf962f,I383c7540 into udc-dev
* changes:
Turn on the flag for large screen widget picker
Add test for widget picker on landscape mode for tablets
diff --git a/res/layout/widgets_full_sheet_large_screen.xml b/res/layout/widgets_full_sheet_large_screen.xml
index b99ac5c..808d3eb 100644
--- a/res/layout/widgets_full_sheet_large_screen.xml
+++ b/res/layout/widgets_full_sheet_large_screen.xml
@@ -20,68 +20,89 @@
android:orientation="vertical"
android:theme="?attr/widgetsTheme">
- <androidx.constraintlayout.widget.ConstraintLayout
+ <com.android.launcher3.views.SpringRelativeLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:importantForAccessibility="no">
- <FrameLayout
- android:id="@+id/recycler_view_container"
- android:layout_width="0dp"
- android:layout_height="0dp"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintTop_toBottomOf="@id/title"
- app:layout_constraintWidth_percent="0.33">
+ <View
+ android:id="@+id/collapse_handle"
+ android:layout_width="@dimen/bottom_sheet_handle_width"
+ android:layout_height="@dimen/bottom_sheet_handle_height"
+ android:layout_marginTop="@dimen/bottom_sheet_handle_margin"
+ android:layout_centerHorizontal="true"
+ android:background="@drawable/bg_rounded_corner_bottom_sheet_handle"/>
- <TextView
- android:id="@+id/fast_scroller_popup"
- style="@style/FastScrollerPopup"
- android:layout_marginEnd="@dimen/fastscroll_popup_margin" />
+ <TextView
+ android:id="@+id/title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="24dp"
+ android:gravity="center_horizontal"
+ android:paddingHorizontal="@dimen/widget_list_horizontal_margin_large_screen"
+ android:text="@string/widget_button_text"
+ android:textColor="?android:attr/textColorSecondary"
+ android:textSize="24sp" />
- <!-- Fast scroller popup -->
- <com.android.launcher3.views.RecyclerViewFastScroller
- android:id="@+id/fast_scroller"
- android:layout_width="@dimen/fastscroll_width"
+ <LinearLayout
+ android:id="@+id/linear_layout_container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_below="@id/title">
+
+ <FrameLayout
+ android:id="@+id/recycler_view_container"
+ android:layout_width="0dp"
android:layout_height="match_parent"
- android:layout_marginEnd="@dimen/fastscroll_end_margin" />
+ android:layout_gravity="start"
+ android:layout_weight="0.33">
+ <TextView
+ android:id="@+id/fast_scroller_popup"
+ style="@style/FastScrollerPopup"
+ android:layout_marginEnd="@dimen/fastscroll_popup_margin" />
- <com.android.launcher3.widget.picker.WidgetsRecyclerView
- android:id="@+id/search_widgets_list_view"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:clipToPadding="false"
- android:paddingHorizontal="@dimen/widget_list_horizontal_margin_large_screen"
- android:visibility="gone" />
- </FrameLayout>
+ <!-- Fast scroller popup -->
+ <com.android.launcher3.views.RecyclerViewFastScroller
+ android:id="@+id/fast_scroller"
+ android:layout_width="@dimen/fastscroll_width"
+ android:layout_height="match_parent"
+ android:layout_marginEnd="@dimen/fastscroll_end_margin" />
- <FrameLayout
- android:layout_width="0dp"
- android:layout_height="0dp"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toEndOf="@id/recycler_view_container"
- app:layout_constraintTop_toBottomOf="@id/title"
- android:paddingEnd="16dp"
- android:paddingStart="8dp"
- android:layout_marginTop="26dp"
- app:layout_constraintWidth_percent="0.67"
- app:layout_constraintBottom_toBottomOf="parent"
- android:orientation="horizontal">
- <TextView
- android:id="@+id/no_widgets_text"
- style="@style/PrimaryHeadline"
- android:layout_width="match_parent"
+ <com.android.launcher3.widget.picker.WidgetsRecyclerView
+ android:id="@+id/search_widgets_list_view"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:clipToPadding="false"
+ android:paddingHorizontal="@dimen/widget_list_horizontal_margin_large_screen"
+ android:visibility="gone" />
+ </FrameLayout>
+
+ <FrameLayout
+ android:id="@+id/right_pane_container"
+ android:layout_width="0dp"
android:layout_height="match_parent"
- android:gravity="center"
- android:textSize="18sp"
- android:visibility="gone"
- tools:text="No widgets available" />
- <ScrollView
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:id="@+id/right_pane">
+ android:layout_weight="0.67"
+ android:paddingEnd="16dp"
+ android:paddingTop="24dp"
+ android:gravity="end"
+ android:layout_gravity="end"
+ android:paddingStart="8dp"
+ android:orientation="horizontal">
+ <TextView
+ android:id="@+id/no_widgets_text"
+ style="@style/PrimaryHeadline"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center"
+ android:textSize="18sp"
+ android:visibility="gone"
+ tools:text="No widgets available" />
+ <ScrollView
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:id="@+id/right_pane">
<com.android.launcher3.widget.picker.WidgetsRecommendationTableLayout
android:id="@+id/recommended_widget_table"
android:background="@drawable/widgets_surface_background"
@@ -91,32 +112,8 @@
"@dimen/widget_list_horizontal_margin_large_screen"
android:paddingVertical="@dimen/recommended_widgets_table_vertical_padding"
android:visibility="gone" />
- </ScrollView>
- </FrameLayout>
-
- <View
- android:id="@+id/collapse_handle"
- android:layout_width="@dimen/bottom_sheet_handle_width"
- android:layout_height="@dimen/bottom_sheet_handle_height"
- android:layout_marginTop="@dimen/bottom_sheet_handle_margin"
- android:background="@drawable/bg_rounded_corner_bottom_sheet_handle"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="parent" />
-
- <TextView
- android:id="@+id/title"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@id/collapse_handle"
- android:layout_marginTop="24dp"
- android:gravity="center_horizontal"
- android:paddingHorizontal="@dimen/widget_list_horizontal_margin_large_screen"
- android:text="@string/widget_button_text"
- android:textColor="?android:attr/textColorSecondary"
- android:textSize="24sp" />
-
- </androidx.constraintlayout.widget.ConstraintLayout>
+ </ScrollView>
+ </FrameLayout>
+ </LinearLayout>
+ </com.android.launcher3.views.SpringRelativeLayout>
</com.android.launcher3.widget.picker.WidgetsFullSheet>
diff --git a/res/layout/widgets_full_sheet_paged_view_large_screen.xml b/res/layout/widgets_full_sheet_paged_view_large_screen.xml
index edee352..f729981 100644
--- a/res/layout/widgets_full_sheet_paged_view_large_screen.xml
+++ b/res/layout/widgets_full_sheet_paged_view_large_screen.xml
@@ -18,13 +18,11 @@
<FrameLayout
android:id="@+id/widgets_full_sheet_paged_view_large_screen"
- android:layout_width="0dp"
- android:layout_height="0dp"
- app:layout_constraintEnd_toStartOf="@id/scrollView"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintTop_toBottomOf="@id/title"
- app:layout_constraintWidth_percent="0.33">
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="start"
+ android:layout_gravity="start"
+ android:layout_alignParentStart="true">
<com.android.launcher3.widget.picker.WidgetPagedView
android:id="@+id/widgets_view_pager"
android:layout_width="match_parent"
diff --git a/res/layout/widgets_full_sheet_recyclerview_large_screen.xml b/res/layout/widgets_full_sheet_recyclerview_large_screen.xml
index c6a4f62..8fef303 100644
--- a/res/layout/widgets_full_sheet_recyclerview_large_screen.xml
+++ b/res/layout/widgets_full_sheet_recyclerview_large_screen.xml
@@ -18,13 +18,11 @@
<FrameLayout
android:id="@+id/widgets_full_sheet_recyclerview_large_screen"
- android:layout_width="0dp"
- android:layout_height="0dp"
- app:layout_constraintEnd_toStartOf="@id/scrollView"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintTop_toBottomOf="@id/title"
- app:layout_constraintWidth_percent="0.33">
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="start"
+ android:layout_gravity="start"
+ android:layout_alignParentStart="true">
<com.android.launcher3.widget.picker.WidgetsRecyclerView
android:id="@+id/primary_widgets_list_view"
@@ -65,4 +63,4 @@
</LinearLayout>
</com.android.launcher3.views.StickyHeaderLayout>
</FrameLayout>
-</merge>
+</merge>
\ No newline at end of file
diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java
index 38f33de..43f2329 100644
--- a/src/com/android/launcher3/config/FeatureFlags.java
+++ b/src/com/android/launcher3/config/FeatureFlags.java
@@ -351,7 +351,7 @@
"SHOW_DOT_PAGINATION", true, "Enable showing dot pagination in workspace");
public static final BooleanFlag LARGE_SCREEN_WIDGET_PICKER = getDebugFlag(270395809,
- "LARGE_SCREEN_WIDGET_PICKER", false, "Enable new widget picker that takes "
+ "LARGE_SCREEN_WIDGET_PICKER", true, "Enable new widget picker that takes "
+ "advantage of large screen format");
public static final BooleanFlag ENABLE_NEW_GESTURE_NAV_TUTORIAL = getDebugFlag(270396257,
diff --git a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
index 0b2f5a5..d3be00c 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
@@ -204,6 +204,7 @@
&& mDeviceProfile.isLandscape
&& LARGE_SCREEN_WIDGET_PICKER.get();
mHasWorkProfile = context.getSystemService(LauncherApps.class).getProfiles().size() > 1;
+ mOrientation = Launcher.getLauncher(context).getOrientation();
mAdapters.put(AdapterHolder.PRIMARY, new AdapterHolder(AdapterHolder.PRIMARY));
mAdapters.put(AdapterHolder.WORK, new AdapterHolder(AdapterHolder.WORK));
mAdapters.put(AdapterHolder.SEARCH, new AdapterHolder(AdapterHolder.SEARCH));
@@ -232,13 +233,22 @@
mContent.setClipToOutline(true);
LayoutInflater layoutInflater = LayoutInflater.from(getContext());
- int contentLayoutRes = mHasWorkProfile ? R.layout.widgets_full_sheet_paged_view
- : R.layout.widgets_full_sheet_recyclerview;
+
if (mIsTwoPane) {
- contentLayoutRes = mHasWorkProfile ? R.layout.widgets_full_sheet_paged_view_large_screen
- : R.layout.widgets_full_sheet_recyclerview_large_screen;
+ layoutInflater.inflate(
+ mHasWorkProfile
+ ? R.layout.widgets_full_sheet_paged_view_large_screen
+ : R.layout.widgets_full_sheet_recyclerview_large_screen,
+ findViewById(R.id.recycler_view_container),
+ true);
+ } else {
+ layoutInflater.inflate(
+ mHasWorkProfile
+ ? R.layout.widgets_full_sheet_paged_view
+ : R.layout.widgets_full_sheet_recyclerview,
+ mContent,
+ true);
}
- layoutInflater.inflate(contentLayoutRes, mContent, true);
mFastScroller = findViewById(R.id.fast_scroller);
if (mIsTwoPane) {
@@ -349,7 +359,8 @@
// if the current active page changes to personal or work we set suggestions
// to be the selected widget
- if (mIsTwoPane && (currentActivePage == PERSONAL_TAB || currentActivePage == WORK_TAB)) {
+ if (mIsTwoPane && mSuggestedWidgetsHeader != null
+ && (currentActivePage == PERSONAL_TAB || currentActivePage == WORK_TAB)) {
mSuggestedWidgetsHeader.callOnClick();
}
@@ -433,7 +444,9 @@
super.onAttachedToWindow();
mActivityContext.getAppWidgetHolder().addProviderChangeListener(this);
notifyWidgetProvidersChanged();
- onRecommendedWidgetsBound();
+ if (!mIsTwoPane) {
+ onRecommendedWidgetsBound();
+ }
}
@Override
@@ -696,6 +709,9 @@
recommendedWidgetsInTable, maxTableHeight);
} else {
mRecommendedWidgetsTable.setVisibility(GONE);
+ if (mSuggestedWidgetsContainer != null) {
+ mSuggestedWidgetsContainer.setVisibility(GONE);
+ }
}
}
diff --git a/tests/src/com/android/launcher3/ui/widget/AddWidgetTest.java b/tests/src/com/android/launcher3/ui/widget/AddWidgetTest.java
index 0fccf79..78a006e 100644
--- a/tests/src/com/android/launcher3/ui/widget/AddWidgetTest.java
+++ b/tests/src/com/android/launcher3/ui/widget/AddWidgetTest.java
@@ -60,11 +60,11 @@
final LauncherAppWidgetProviderInfo widgetInfo =
TestViewHelpers.findWidgetProvider(this, false /* hasConfigureScreen */);
- WidgetResizeFrame resizeFrame = mLauncher.
- getWorkspace().
- openAllWidgets().
- getWidget(widgetInfo.getLabel(mTargetContext.getPackageManager())).
- dragWidgetToWorkspace();
+ WidgetResizeFrame resizeFrame = mLauncher
+ .getWorkspace()
+ .openAllWidgets()
+ .getWidget(widgetInfo.getLabel(mTargetContext.getPackageManager()))
+ .dragWidgetToWorkspace();
assertTrue(mActivityMonitor.itemExists(
(info, view) -> info instanceof LauncherAppWidgetInfo &&
diff --git a/tests/tapl/com/android/launcher3/tapl/Widgets.java b/tests/tapl/com/android/launcher3/tapl/Widgets.java
index 96e2e3f..c1c26ec 100644
--- a/tests/tapl/com/android/launcher3/tapl/Widgets.java
+++ b/tests/tapl/com/android/launcher3/tapl/Widgets.java
@@ -77,8 +77,8 @@
mLauncher.scroll(
widgetsContainer,
Direction.UP,
- new Rect(0, 0, mLauncher.getRightGestureMarginInContainer(widgetsContainer) + 1,
- 0),
+ new Rect(0, 0, 0,
+ mLauncher.getBottomGestureMarginInContainer(widgetsContainer) + 1),
FLING_STEPS, false);
try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer("flung back")) {
verifyActiveContainer();
@@ -168,6 +168,8 @@
private UiObject2 findTestAppWidgetsTableContainer() {
final BySelector headerSelector = By.res(mLauncher.getLauncherPackageName(),
"widgets_list_header");
+ final BySelector widgetPickerSelector = By.res(mLauncher.getLauncherPackageName(),
+ "container");
final BySelector targetAppSelector = By.clazz("android.widget.TextView").text(
mLauncher.getContext().getPackageName());
final BySelector widgetsContainerSelector = By.res(mLauncher.getLauncherPackageName(),
@@ -176,17 +178,23 @@
boolean hasHeaderExpanded = false;
int scrollDistance = 0;
for (int i = 0; i < SCROLL_ATTEMPTS; i++) {
- UiObject2 fullWidgetsPicker = verifyActiveContainer();
-
- UiObject2 header = mLauncher.waitForObjectInContainer(fullWidgetsPicker,
+ UiObject2 widgetPicker = mLauncher.waitForLauncherObject(widgetPickerSelector);
+ UiObject2 widgetListView = verifyActiveContainer();
+ UiObject2 header = mLauncher.waitForObjectInContainer(widgetListView,
headerSelector);
+ // If we are in a tablet in landscape mode then we will have a two pane view and we use
+ // the right pane to display the widgets table.
+ UiObject2 rightPane = mLauncher.findObjectInContainer(
+ widgetPicker,
+ widgetsContainerSelector);
+
// If a header is barely visible in the bottom edge of the screen, its height could be
// too small for a scroll gesture. Since all header should have roughly the same height,
// let's pick the max height we have seen so far.
scrollDistance = Math.max(scrollDistance, header.getVisibleBounds().height());
// Look for a header that has the test app name.
- UiObject2 headerTitle = mLauncher.findObjectInContainer(fullWidgetsPicker,
+ UiObject2 headerTitle = mLauncher.findObjectInContainer(widgetListView,
targetAppSelector);
if (headerTitle != null) {
// If we find the header and it has not been expanded, let's click it to see the
@@ -202,7 +210,8 @@
}
// Look for a widgets list.
- UiObject2 widgetsContainer = mLauncher.findObjectInContainer(fullWidgetsPicker,
+ UiObject2 widgetsContainer = mLauncher.findObjectInContainer(
+ rightPane != null ? rightPane : widgetListView,
widgetsContainerSelector);
if (widgetsContainer != null) {
log("Widgets container found.");
@@ -210,7 +219,9 @@
}
}
log("Finding test widget package - scroll with distance: " + scrollDistance);
- mLauncher.scrollDownByDistance(fullWidgetsPicker, scrollDistance);
+ mLauncher.scrollDownByDistance(hasHeaderExpanded && rightPane != null
+ ? rightPane
+ : widgetListView, scrollDistance);
}
return null;