Merge "Use availableHeightPx to calculate the max height for recommended widgets" into sc-dev am: 9ad5b60c6c

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/14234629

Change-Id: Ic6d2da3b597d6bbab6305fde9a3c1de939f39186
This commit is contained in:
Steven Ng
2021-04-20 10:56:41 +00:00
committed by Automerger Merge Worker
2 changed files with 4 additions and 5 deletions
@@ -469,8 +469,8 @@ public class WidgetsFullSheet extends BaseWidgetSheet
Log.d(TAG, "Header view height is 0 when inflating recommended widgets");
}
float maxTableHeight =
(mLauncher.getDeviceProfile().heightPx - mTabsHeight - getHeaderViewHeight())
* RECOMMENDATION_TABLE_HEIGHT_RATIO;
(mLauncher.getDeviceProfile().availableHeightPx - mTabsHeight
- getHeaderViewHeight()) * RECOMMENDATION_TABLE_HEIGHT_RATIO;
List<ArrayList<WidgetItem>> recommendedWidgetsInTable =
WidgetsTableUtils.groupWidgetItemsIntoTable(recommendedWidgets,
mMaxSpansPerRow);
@@ -42,7 +42,6 @@ public final class WidgetsRecommendationTableLayout extends TableLayout {
private static final String TAG = "WidgetsRecommendationTableLayout";
private static final float DOWN_SCALE_RATIO = 0.9f;
private static final float MAX_DOWN_SCALE_RATIO = 0.5f;
private final DeviceProfile mDeviceProfile;
private final float mWidgetCellTextViewsHeight;
private float mRecommendationTableMaxHeight = Float.MAX_VALUE;
@@ -56,7 +55,6 @@ public final class WidgetsRecommendationTableLayout extends TableLayout {
public WidgetsRecommendationTableLayout(Context context, AttributeSet attrs) {
super(context, attrs);
mDeviceProfile = Launcher.getLauncher(context).getDeviceProfile();
// There are 1 row for title, 1 row for dimension and 2 rows for description.
mWidgetCellTextViewsHeight = 4 * getResources().getDimension(R.dimen.widget_cell_font_size);
}
@@ -143,11 +141,12 @@ public final class WidgetsRecommendationTableLayout extends TableLayout {
}
// A naive estimation of the widgets recommendation table height without inflation.
float totalHeight = 0;
DeviceProfile deviceProfile = Launcher.getLauncher(getContext()).getDeviceProfile();
for (int i = 0; i < recommendedWidgetsInTable.size(); i++) {
List<WidgetItem> widgetItems = recommendedWidgetsInTable.get(i);
float rowHeight = 0;
for (int j = 0; j < widgetItems.size(); j++) {
float previewHeight = widgetItems.get(j).spanY * mDeviceProfile.allAppsCellHeightPx
float previewHeight = widgetItems.get(j).spanY * deviceProfile.allAppsCellHeightPx
* previewScale;
rowHeight = Math.max(rowHeight, previewHeight + mWidgetCellTextViewsHeight);
}