Move 'no widgets found' to right pane and add rounded edges to right pane.
Previously 'no widgets found' appeared on the left pane, but in large screen landscape we want it to appear on the right pane. Additionally, we added rounded edges to the right pane that turn into sharp edges when we scroll.
Fix: 268558448
Fix: 268557435
Test: Turn on LARGE_SCREEN_WIDGET_PICKER and on tablet landscape mode go to the widget picker and search for a widget that doesn't exist, verify that 'no widgets found' appears on the right pane. Also verify that right pane has rounded corner that turn into sharp corners as we scroll
Change-Id: I6c89c63941e3b0680836828d0c7849d789cbce61
diff --git a/res/drawable/bg_widgets_content.xml b/res/drawable/bg_widgets_content.xml
index 8060430..b0b699b 100644
--- a/res/drawable/bg_widgets_content.xml
+++ b/res/drawable/bg_widgets_content.xml
@@ -18,16 +18,32 @@
<!--
L -> large radius
s -> small radius
- 0 -> no radiuls
+ 0 -> no radius
-->
+ <!-- SINGLE : L L L L -->
+ <item android:state_single="true">
+ <shape android:shape="rectangle">
+ <solid android:color="@color/surface" />
+ <corners android:radius="@dimen/widget_list_top_bottom_corner_radius"/>
+ </shape>
+ </item>
+
+ <!-- FIRST : 0 0 s s -->
+ <item android:state_first="true">
+ <shape android:shape="rectangle">
+ <solid android:color="@color/surface" />
+ <corners
+ android:bottomLeftRadius="@dimen/widget_list_content_corner_radius"
+ android:bottomRightRadius="@dimen/widget_list_content_corner_radius" />
+ </shape>
+ </item>
+
<!-- MIDDLE : 0 0 s s -->
<item android:state_middle="true">
<shape android:shape="rectangle">
<solid android:color="@color/surface" />
<corners
- android:topLeftRadius="0dp"
- android:topRightRadius="0dp"
android:bottomLeftRadius="@dimen/widget_list_content_corner_radius"
android:bottomRightRadius="@dimen/widget_list_content_corner_radius" />
</shape>
@@ -38,8 +54,6 @@
<shape android:shape="rectangle">
<solid android:color="@color/surface" />
<corners
- android:topLeftRadius="0dp"
- android:topRightRadius="0dp"
android:bottomLeftRadius="@dimen/widget_list_top_bottom_corner_radius"
android:bottomRightRadius="@dimen/widget_list_top_bottom_corner_radius" />
</shape>
diff --git a/res/layout/widgets_full_sheet_large_screen.xml b/res/layout/widgets_full_sheet_large_screen.xml
index 1c0037d..b99ac5c 100644
--- a/res/layout/widgets_full_sheet_large_screen.xml
+++ b/res/layout/widgets_full_sheet_large_screen.xml
@@ -31,23 +31,12 @@
android:id="@+id/recycler_view_container"
android:layout_width="0dp"
android:layout_height="0dp"
- app:layout_constraintEnd_toStartOf="@id/right_pane"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/title"
app:layout_constraintWidth_percent="0.33">
<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" />
-
- <TextView
android:id="@+id/fast_scroller_popup"
style="@style/FastScrollerPopup"
android:layout_marginEnd="@dimen/fastscroll_popup_margin" />
@@ -68,28 +57,42 @@
android:visibility="gone" />
</FrameLayout>
- <ScrollView
- android:id="@+id/right_pane"
+ <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"
- app:layout_constraintBottom_toBottomOf="parent"
android:paddingEnd="16dp"
android:paddingStart="8dp"
android:layout_marginTop="26dp"
- app:layout_constraintWidth_percent="0.67">
-
- <com.android.launcher3.widget.picker.WidgetsRecommendationTableLayout
- android:id="@+id/recommended_widget_table"
+ 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"
- android:layout_height="wrap_content"
- android:background="@drawable/widgets_surface_background"
- android:paddingHorizontal="@dimen/widget_list_horizontal_margin_large_screen"
- android:paddingVertical="@dimen/recommended_widgets_table_vertical_padding"
- android:visibility="gone" />
- </ScrollView>
+ 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"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingHorizontal=
+ "@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"
diff --git a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
index 77c8945..5d45602 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
@@ -46,8 +46,8 @@
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
import android.widget.Button;
+import android.widget.FrameLayout;
import android.widget.LinearLayout;
-import android.widget.ScrollView;
import android.widget.TextView;
import androidx.annotation.FloatRange;
@@ -67,6 +67,7 @@
import com.android.launcher3.model.WidgetItem;
import com.android.launcher3.model.data.PackageItemInfo;
import com.android.launcher3.pm.UserCache;
+import com.android.launcher3.recyclerview.ViewHolderBinder;
import com.android.launcher3.util.PackageUserKey;
import com.android.launcher3.views.ArrowTipView;
import com.android.launcher3.views.RecyclerViewFastScroller;
@@ -198,7 +199,7 @@
private View mSearchBarContainer;
private WidgetsSearchBar mSearchBar;
private TextView mHeaderTitle;
- private ScrollView mRightPane;
+ private FrameLayout mRightPane;
private WidgetsListTableViewHolderBinder mWidgetsListTableViewHolderBinder;
private final boolean mIsTwoPane;
@@ -389,6 +390,11 @@
private void updateRecyclerViewVisibility(AdapterHolder adapterHolder) {
// The first item is always an empty space entry. Look for any more items.
boolean isWidgetAvailable = adapterHolder.mWidgetsListAdapter.hasVisibleEntries();
+
+ if (mIsTwoPane) {
+ mRightPane.setVisibility(isWidgetAvailable ? VISIBLE : GONE);
+ }
+
adapterHolder.mWidgetsRecyclerView.setVisibility(isWidgetAvailable ? VISIBLE : GONE);
if (adapterHolder.mAdapterType == AdapterHolder.SEARCH) {
@@ -979,11 +985,13 @@
mWidgetsListTableViewHolderBinder.newViewHolder(mRightPane);
mWidgetsListTableViewHolderBinder.bindViewHolder(widgetsRowViewHolder,
contentEntry,
- 0, Collections.EMPTY_LIST);
+ ViewHolderBinder.POSITION_FIRST | ViewHolderBinder.POSITION_LAST,
+ Collections.EMPTY_LIST);
widgetsRowViewHolder.mDataCallback = data -> {
mWidgetsListTableViewHolderBinder.bindViewHolder(widgetsRowViewHolder,
contentEntry,
- 0, Collections.singletonList(data));
+ ViewHolderBinder.POSITION_FIRST | ViewHolderBinder.POSITION_LAST,
+ Collections.singletonList(data));
};
mRightPane.removeAllViews();
mRightPane.addView(widgetsRowViewHolder.itemView);
diff --git a/src/com/android/launcher3/widget/picker/WidgetsListTableViewHolderBinder.java b/src/com/android/launcher3/widget/picker/WidgetsListTableViewHolderBinder.java
index 4c1f7a9..2e8f0ab 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsListTableViewHolderBinder.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsListTableViewHolderBinder.java
@@ -15,9 +15,6 @@
*/
package com.android.launcher3.widget.picker;
-import static com.android.launcher3.widget.picker.WidgetsListDrawableState.LAST;
-import static com.android.launcher3.widget.picker.WidgetsListDrawableState.MIDDLE;
-
import android.graphics.Bitmap;
import android.util.Log;
import android.util.Pair;
@@ -84,7 +81,11 @@
Log.d(TAG, String.format("onBindViewHolder [widget#=%d, table.getChildCount=%d]",
entry.mWidgets.size(), table.getChildCount()));
}
- table.setListDrawableState(((position & POSITION_LAST) != 0) ? LAST : MIDDLE);
+ table.setListDrawableState(
+ WidgetsListDrawableState.obtain(
+ (position & POSITION_FIRST) != 0,
+ (position & POSITION_LAST) != 0));
+
List<ArrayList<WidgetItem>> widgetItemsTable =
WidgetsTableUtils.groupWidgetItemsIntoTableWithReordering(
entry.mWidgets, entry.getMaxSpanSizeInCells());