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
This commit is contained in:
Federico Baron committed 2023-02-22 00:34:10 +00:00
1 parent e8217b3c1b
commit 8f6523a3d6
4 files changed
+63 -37

No files matched your search

+19 -5
View File
@@ -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>
+27 -24
View File
@@ -31,22 +31,11 @@
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"
@@ -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"
@@ -46,8 +46,8 @@ import android.view.WindowInsets;
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.UserManagerState;
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 @@ public class WidgetsFullSheet extends BaseWidgetSheet
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 @@ public class WidgetsFullSheet extends BaseWidgetSheet
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 @@ public class WidgetsFullSheet extends BaseWidgetSheet
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);
@@ -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 @@ public final class WidgetsListTableViewHolderBinder
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());