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

Commit bc5099e9 authored by Steven Ng's avatar Steven Ng
Browse files

Fix height estimation of the widgets recommendation table

There are two vertical paddings
1. Table padding
2. Widget cell padding

We haven't taken account the widget cells padding

Test: Manual
Bug: 189814077
Change-Id: I9b1dc9e880d4402b9c461d0024a0748c0afc408a
parent 962b212c
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ public final class WidgetsRecommendationTableLayout extends TableLayout {
    private static final float DOWN_SCALE_RATIO = 0.9f;
    private static final float MAX_DOWN_SCALE_RATIO = 0.5f;
    private final float mWidgetsRecommendationTableVerticalPadding;
    private final float mWidgetCellVerticalPadding;
    private final float mWidgetCellTextViewsHeight;

    private float mRecommendationTableMaxHeight = Float.MAX_VALUE;
@@ -60,6 +61,8 @@ public final class WidgetsRecommendationTableLayout extends TableLayout {
        super(context, attrs);
        // There are 1 row for title, 1 row for dimension and 2 rows for description.
        mWidgetsRecommendationTableVerticalPadding = 2 * getResources()
                .getDimensionPixelSize(R.dimen.recommended_widgets_table_vertical_padding);
        mWidgetCellVerticalPadding = 2 * getResources()
                .getDimensionPixelSize(R.dimen.widget_cell_vertical_padding);
        mWidgetCellTextViewsHeight = 4 * getResources().getDimension(R.dimen.widget_cell_font_size);
    }
@@ -152,7 +155,8 @@ public final class WidgetsRecommendationTableLayout extends TableLayout {
                Size widgetSize = WidgetSizes.getWidgetSizePx(
                        deviceProfile, widgetItem.spanX, widgetItem.spanY);
                float previewHeight = widgetSize.getHeight() * previewScale;
                rowHeight = Math.max(rowHeight, previewHeight + mWidgetCellTextViewsHeight);
                rowHeight = Math.max(rowHeight,
                        previewHeight + mWidgetCellTextViewsHeight + mWidgetCellVerticalPadding);
            }
            totalHeight += rowHeight;
        }