Update two pane sheet widget picker to use RelativeLayout since ConstraintLayout was causing test failures

There are test failures when using ConstraintLayout without a known solution, see https://chat.google.com/room/AAAACwktJi8/2OogGWfbLvI. Switching back to a relativelayout to resolve those issues.

Bug: 301918659
Test: WidgetPickerImageTest
Flag: ACONFIG com.android.launcher3.enable_unfolded_two_pane_picker DEVELOPMENT
Change-Id: I004c2d77ca308d85b29217d4f1e548067126556f
This commit is contained in:
fbaron
2023-12-12 15:12:40 -08:00
parent d806c0abd1
commit b3b0215cb1
3 changed files with 32 additions and 138 deletions
@@ -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>
@@ -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
@@ -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;
@@ -116,6 +123,29 @@ public class WidgetsTwoPaneSheet extends WidgetsFullSheet {
mFastScroller.setVisibility(GONE);
}
@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();