Merge "Fix height estimation of the widgets recommendation table" into sc-dev

This commit is contained in:
Steven Ng 2021-06-10 18:11:45 +00:00 committed by Android (Google) Code Review
commit d4bae086d3
1 changed files with 5 additions and 1 deletions

View File

@ -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;
}