summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Baron <fbaron@google.com>2023-12-13 01:47:21 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2023-12-13 01:47:21 +0000
commit4266fa49e23641a3baa7968bcba60fd507dc80bd (patch)
treecf6aaa261101c2fccb725ec948dd26ee4e69bbd1
parent7808efbba1fe3d3ad40f682fefd92dc27c4ee4f4 (diff)
parentb3b0215cb1a810fb3df507e4a99bb6950c11b9c7 (diff)
downloadLauncher3-4266fa49e23641a3baa7968bcba60fd507dc80bd.tar.gz
Merge "Update two pane sheet widget picker to use RelativeLayout since ConstraintLayout was causing test failures" into main
-rw-r--r--res/layout/widgets_two_pane_sheet_foldable.xml131
-rw-r--r--src/com/android/launcher3/widget/picker/WidgetsFullSheet.java9
-rw-r--r--src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java30
3 files changed, 32 insertions, 138 deletions
diff --git a/res/layout/widgets_two_pane_sheet_foldable.xml b/res/layout/widgets_two_pane_sheet_foldable.xml
deleted file mode 100644
index 93c0c7053e..0000000000
--- a/res/layout/widgets_two_pane_sheet_foldable.xml
+++ /dev/null
@@ -1,131 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?><!-- Copyright (C) 2023 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.
--->
-<com.android.launcher3.widget.picker.WidgetsTwoPaneSheet
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- android:orientation="vertical"
- android:theme="?attr/widgetsTheme">
-
- <androidx.constraintlayout.widget.ConstraintLayout
- android:id="@+id/container"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:focusable="true"
- android:importantForAccessibility="no">
-
- <View
- android:id="@+id/collapse_handle"
- android:gravity="center_horizontal"
- android:layout_width="@dimen/bottom_sheet_handle_width"
- android:layout_height="@dimen/bottom_sheet_handle_height"
- android:layout_marginTop="@dimen/bottom_sheet_handle_margin"
- app:layout_constraintTop_toTopOf="parent"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintEnd_toEndOf="parent"
- android:background="@drawable/widget_picker_collapse_handle"/>
-
- <TextView
- android:id="@+id/title"
- android:gravity="center_horizontal"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="24dp"
- android:paddingHorizontal="@dimen/widget_list_horizontal_margin_two_pane"
- android:text="@string/widget_button_text"
- app:layout_constraintTop_toBottomOf="@id/collapse_handle"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintEnd_toEndOf="parent"
- android:textColor="?attr/widgetPickerTitleColor"
- android:textSize="24sp" />
-
- <FrameLayout
- android:id="@+id/recycler_view_container"
- android:layout_width="0dp"
- android:layout_height="0dp"
- app:layout_constraintTop_toBottomOf="@id/title"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintWidth_percent="0.33"
- app:layout_constraintWidth_min="254dp"
- app:layout_constraintWidth_max="395dp">
- <TextView
- android:id="@+id/fast_scroller_popup"
- style="@style/FastScrollerPopup"
- android:layout_marginEnd="@dimen/fastscroll_popup_margin" />
-
- <!-- 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" />
-
- <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_two_pane"
- android:visibility="gone" />
- </FrameLayout>
-
- <FrameLayout
- android:id="@+id/right_pane_container"
- android:layout_width="0dp"
- android:layout_height="0dp"
- android:layout_marginEnd="@dimen/widget_list_horizontal_margin_two_pane"
- android:paddingTop="@dimen/widget_list_horizontal_margin_two_pane"
- app:layout_constraintTop_toBottomOf="@id/title"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintStart_toEndOf="@id/recycler_view_container"
- app:layout_constraintEnd_toEndOf="parent">
- <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:id="@+id/right_pane_scroll_view"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:fillViewport="true">
- <LinearLayout
- android:orientation="vertical"
- 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:id="@+id/right_pane">
- <com.android.launcher3.widget.picker.WidgetsRecommendationTableLayout
- android:id="@+id/recommended_widget_table"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingHorizontal=
- "@dimen/widget_list_horizontal_margin_two_pane"
- android:visibility="gone" />
- </LinearLayout>
- </ScrollView>
- </FrameLayout>
- </androidx.constraintlayout.widget.ConstraintLayout>
-</com.android.launcher3.widget.picker.WidgetsTwoPaneSheet>
diff --git a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
index 583ef1ab20..e9a590b814 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
@@ -163,7 +163,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet
private boolean mIsInSearchMode;
private boolean mIsNoWidgetsViewNeeded;
@Px private int mMaxSpanPerRow;
- private DeviceProfile mDeviceProfile;
+ protected DeviceProfile mDeviceProfile;
protected TextView mNoWidgetsView;
protected StickyHeaderLayout mSearchScrollView;
@@ -690,12 +690,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet
// Enables two pane picker for unfolded foldables if the flag is on.
|| (activity.getDeviceProfile().isTwoPanels && enableUnfoldedTwoPanePicker());
- if (isTwoPane && activity.getDeviceProfile().isTwoPanels) {
- return R.layout.widgets_two_pane_sheet_foldable;
- } else if (isTwoPane) {
- return R.layout.widgets_two_pane_sheet;
- }
- return R.layout.widgets_full_sheet;
+ return isTwoPane ? R.layout.widgets_two_pane_sheet : R.layout.widgets_full_sheet;
}
@Override
diff --git a/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java b/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java
index d85737b28f..c3ab08c153 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java
@@ -15,6 +15,8 @@
*/
package com.android.launcher3.widget.picker;
+import static com.android.launcher3.Flags.enableUnfoldedTwoPanePicker;
+
import android.content.Context;
import android.graphics.Outline;
import android.os.Process;
@@ -23,12 +25,15 @@ import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewOutlineProvider;
+import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import androidx.annotation.NonNull;
+import androidx.annotation.Px;
import com.android.launcher3.R;
+import com.android.launcher3.Utilities;
import com.android.launcher3.model.data.PackageItemInfo;
import com.android.launcher3.recyclerview.ViewHolderBinder;
import com.android.launcher3.util.PackageUserKey;
@@ -46,6 +51,8 @@ public class WidgetsTwoPaneSheet extends WidgetsFullSheet {
private static final int PERSONAL_TAB = 0;
private static final int WORK_TAB = 1;
+ private static final int MINIMUM_WIDTH_LEFT_PANE_FOLDABLE_DP = 268;
+ private static final int MAXIMUM_WIDTH_LEFT_PANE_FOLDABLE_DP = 395;
private static final String SUGGESTIONS_PACKAGE_NAME = "widgets_list_suggestions_entry";
private LinearLayout mSuggestedWidgetsContainer;
@@ -117,6 +124,29 @@ public class WidgetsTwoPaneSheet extends WidgetsFullSheet {
}
@Override
+ protected void onLayout(boolean changed, int l, int t, int r, int b) {
+ super.onLayout(changed, l, t, r, b);
+ if (changed && mDeviceProfile.isTwoPanels && enableUnfoldedTwoPanePicker()) {
+ LinearLayout layout = mContent.findViewById(R.id.linear_layout_container);
+ FrameLayout leftPane = layout.findViewById(R.id.recycler_view_container);
+ LinearLayout.LayoutParams layoutParams = (LayoutParams) leftPane.getLayoutParams();
+ // Width is 1/3 of the sheet unless it's less than min width or max width
+ int leftPaneWidth = layout.getMeasuredWidth() / 3;
+ @Px int minLeftPaneWidthPx = Utilities.dpToPx(MINIMUM_WIDTH_LEFT_PANE_FOLDABLE_DP);
+ @Px int maxLeftPaneWidthPx = Utilities.dpToPx(MAXIMUM_WIDTH_LEFT_PANE_FOLDABLE_DP);
+ if (leftPaneWidth < minLeftPaneWidthPx) {
+ layoutParams.width = minLeftPaneWidthPx;
+ } else if (leftPaneWidth > maxLeftPaneWidthPx) {
+ layoutParams.width = maxLeftPaneWidthPx;
+ } else {
+ layoutParams.width = 0;
+ }
+ layoutParams.weight = layoutParams.width == 0 ? 0.33F : 0;
+ leftPane.setLayoutParams(layoutParams);
+ }
+ }
+
+ @Override
public void onRecommendedWidgetsBound() {
super.onRecommendedWidgetsBound();