Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4235fc12 authored by Steven Ng's avatar Steven Ng
Browse files

Renders widget recommendations

Update the tapl test logic to scroll a smaller distance to avoid the
search bar blocking the target touch area.

Test: Open full widgets sheet and observe the widget recommendations
      shown at the top.
      Run AddConfigWidgetTest

Bug: 179797520

Change-Id: I6d53bbb46e2cb928ed7d015aaac604be17d33178
parent 4076cae8
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -18,10 +18,11 @@
    android:layout_height="wrap_content">

    <!-- The image of the widget. This view does not support padding. Any placement adjustment
         should be done using margins. -->
         should be done using margins.
          width & height are set at runtime after scaling the preview image. -->
    <com.android.launcher3.widget.WidgetImageView
        android:id="@+id/widget_preview"
        android:layout_width="wrap_content"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:importantForAccessibility="no"
@@ -38,7 +39,7 @@
        android:singleLine="true"
        android:maxLines="1"
        android:textColor="?android:attr/textColorPrimary"
        android:textSize="14sp" />
        android:textSize="@dimen/widget_cell_font_size" />

    <!-- The original dimensions of the widget (can't be the same text as above due to different
         style. -->
@@ -48,7 +49,7 @@
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:textColor="?android:attr/textColorTertiary"
        android:textSize="14sp"
        android:textSize="@dimen/widget_cell_font_size"
        android:alpha="0.8" />

    <TextView
@@ -56,7 +57,7 @@
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:textSize="14sp"
        android:textSize="@dimen/widget_cell_font_size"
        android:textColor="?android:attr/textColorTertiary"
        android:maxLines="2"
        android:ellipsize="end"
+11 −1
Original line number Diff line number Diff line
@@ -18,12 +18,15 @@
    android:id="@+id/search_and_recommendations_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="16dp"
    android:paddingHorizontal="16dp"
    android:layout_marginBottom="16dp"
    android:orientation="vertical">
    <View
        android:id="@+id/collapse_handle"
        android:layout_width="48dp"
        android:layout_height="2dp"
        android:layout_marginTop="16dp"
        android:elevation="2dp"
        android:layout_gravity="center_horizontal"
        android:background="?android:attr/textColorSecondary"/>
    <TextView
@@ -36,4 +39,11 @@
        android:textColor="?android:attr/textColorSecondary"
        android:text="@string/widget_button_text"/>
    <include layout="@layout/widgets_search_bar"/>

    <com.android.launcher3.widget.picker.WidgetsRecommendationTableLayout
        android:id="@+id/recommended_widget_table"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        android:visibility="gone" />
</LinearLayout>
+2 −1
Original line number Diff line number Diff line
@@ -6,7 +6,8 @@
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_marginTop="16dp"
    android:background="@drawable/bg_widgets_searchbox">
    android:background="@drawable/bg_widgets_searchbox"
    android:elevation="2dp">

    <com.android.launcher3.ExtendedEditText
        android:id="@+id/widgets_search_bar_edit_text"
+1 −0
Original line number Diff line number Diff line
@@ -109,6 +109,7 @@
<!-- Widget tray -->
    <dimen name="widget_cell_vertical_padding">8dp</dimen>
    <dimen name="widget_cell_horizontal_padding">16dp</dimen>
    <dimen name="widget_cell_font_size">14sp</dimen>


    <dimen name="widget_list_top_bottom_corner_radius">28dp</dimen>
+9 −2
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener {
    protected int mPreviewHeight;
    protected int mPresetPreviewSize;
    private int mCellSize;
    private float mPreviewScale = 1f;

    private WidgetImageView mWidgetImage;
    private TextView mWidgetName;
@@ -254,8 +255,8 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener {
        }
        if (drawable != null) {
            LayoutParams layoutParams = (LayoutParams) mWidgetImage.getLayoutParams();
            layoutParams.width = drawable.getIntrinsicWidth();
            layoutParams.height = drawable.getIntrinsicHeight();
            layoutParams.width = (int) (drawable.getIntrinsicWidth() * mPreviewScale);
            layoutParams.height = (int) (drawable.getIntrinsicHeight() * mPreviewScale);
            mWidgetImage.setLayoutParams(layoutParams);

            mWidgetImage.setDrawable(drawable, mWidgetPreviewLoader.getBadgeForUser(mItem.user,
@@ -305,10 +306,16 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener {

    /** Sets the widget preview image size in number of cells. */
    public void setPreviewSize(int spanX, int spanY) {
        setPreviewSize(spanX, spanY, 1f);
    }

    /** Sets the widget preview image size, in number of cells, and preview scale. */
    public void setPreviewSize(int spanX, int spanY, float previewScale) {
        int padding = 2 * getResources()
                .getDimensionPixelSize(R.dimen.widget_preview_shortcut_padding);
        mPreviewWidth = mDeviceProfile.cellWidthPx * spanX + padding;
        mPreviewHeight = mDeviceProfile.cellHeightPx * spanY + padding;
        mPreviewScale = previewScale;
    }

    @Override
Loading