Improvements for All Apps on different display sizes

Bug: 262912817
Test: DeviceProfileAlternativeDisplaysDumpTest
Change-Id: I50e980183b4d5c1a46cca8f1c867b866b9eae4b5
This commit is contained in:
Thales Lima
2023-01-26 12:33:52 +00:00
parent c3cb117b01
commit e9273ea743
10 changed files with 36 additions and 14 deletions

View File

@@ -30,6 +30,4 @@
<dimen name="dynamic_grid_edge_margin">11.33dp</dimen>
<dimen name="cell_layout_padding">11.33dp</dimen>
<!-- AllApps -->
<dimen name="all_apps_bottom_sheet_horizontal_padding">52dp</dimen>
</resources>

View File

@@ -26,7 +26,6 @@
<!-- AllApps -->
<dimen name="all_apps_search_bar_content_overlap">0dp</dimen>
<dimen name="all_apps_bottom_sheet_horizontal_padding">48dp</dimen>
<!-- Fast scroll -->
<dimen name="fastscroll_popup_width">75dp</dimen>

View File

@@ -22,9 +22,6 @@
<dimen name="dynamic_grid_edge_margin">21.93dp</dimen>
<dimen name="cell_layout_padding">29.33dp</dimen>
<!-- AllApps -->
<dimen name="all_apps_bottom_sheet_horizontal_padding">32dp</dimen>
<!-- Dragging-->
<dimen name="drop_target_top_margin">0dp</dimen>
<dimen name="drop_target_bottom_margin">32dp</dimen>

View File

@@ -18,9 +18,6 @@
<!-- PagedView -->
<dimen name="min_page_snap_velocity">3400dp</dimen>
<!-- AllApps -->
<dimen name="all_apps_bottom_sheet_horizontal_padding">28dp</dimen>
<!-- Dynamic grid -->
<dimen name="dynamic_grid_edge_margin">27.59dp</dimen>
<dimen name="cell_layout_padding">36dp</dimen>

View File

@@ -151,6 +151,9 @@
<!-- Support attributes in FolderStyle -->
<attr name="folderStyle" format="reference" />
<!-- Support attributes in AllAppsStyle. Defaults to AllAppsStyleDefault -->
<attr name="allAppsStyle" format="reference" />
<!-- numAllAppsColumns defaults to numColumns, if not specified -->
<attr name="numAllAppsColumns" format="integer" />
<!-- Number of columns to use when extending the all-apps size,
@@ -418,6 +421,10 @@
<attr name="iconDrawablePadding" format="dimension" />
</declare-styleable>
<declare-styleable name="AllAppsStyle">
<attr name="horizontalPadding" format="dimension" />
</declare-styleable>
<declare-styleable name="ShadowDrawable">
<attr name="android:src" />
<attr name="android:shadowColor" />

View File

@@ -131,7 +131,6 @@
<dimen name="all_apps_content_fade_in_offset">150dp</dimen>
<dimen name="all_apps_tip_bottom_margin">8dp</dimen>
<dimen name="all_apps_height_extra">6dp</dimen>
<dimen name="all_apps_bottom_sheet_horizontal_padding">0dp</dimen>
<dimen name="all_apps_paged_view_top_padding">40dp</dimen>
<dimen name="all_apps_icon_drawable_padding">8dp</dimen>

View File

@@ -304,4 +304,8 @@
<item name="iconDrawablePadding">7dp</item>
</style>
<style name="AllAppsStyleDefault">
<item name="horizontalPadding">16dp</item>
</style>
</resources>

View File

@@ -401,6 +401,7 @@ public class DeviceProfile {
allAppsBorderSpacePx = new Point(
pxFromDp(inv.allAppsBorderSpaces[mTypeIndex].x, mMetrics),
pxFromDp(inv.allAppsBorderSpaces[mTypeIndex].y, mMetrics));
setupAllAppsStyle(context);
workspacePageIndicatorHeight = res.getDimensionPixelSize(
R.dimen.workspace_page_indicator_height);
@@ -805,9 +806,6 @@ public class DeviceProfile {
int cellLayoutHorizontalPadding =
(cellLayoutPaddingPx.left + cellLayoutPaddingPx.right) / 2;
if (isTablet) {
allAppsLeftRightPadding =
res.getDimensionPixelSize(R.dimen.all_apps_bottom_sheet_horizontal_padding);
int usedWidth = (allAppsCellWidthPx * numShownAllAppsColumns)
+ (allAppsBorderSpacePx.x * (numShownAllAppsColumns - 1))
+ allAppsLeftRightPadding * 2;
@@ -818,6 +816,20 @@ public class DeviceProfile {
}
}
private void setupAllAppsStyle(Context context) {
TypedArray allAppsStyle;
if (inv.allAppsStyle != INVALID_RESOURCE_HANDLE) {
allAppsStyle = context.obtainStyledAttributes(inv.allAppsStyle,
R.styleable.AllAppsStyle);
} else {
allAppsStyle = context.obtainStyledAttributes(R.style.AllAppsStyleDefault,
R.styleable.AllAppsStyle);
}
allAppsLeftRightPadding = allAppsStyle.getDimensionPixelSize(
R.styleable.AllAppsStyle_horizontalPadding, 0);
allAppsStyle.recycle();
}
/**
* Returns the amount of extra (or unused) vertical space.
*/
@@ -1792,7 +1804,7 @@ public class DeviceProfile {
* Set the viewScaleProvider for the builder
*
* @param viewScaleProvider The viewScaleProvider to be set for the
* DeviceProfile
* DeviceProfile
* @return This builder
*/
@NonNull

View File

@@ -175,6 +175,7 @@ public class InvariantDeviceProfile {
*/
public int numAllAppsColumns;
public int numDatabaseAllAppsColumns;
public @StyleRes int allAppsStyle;
/**
* Do not query directly. see {@link DeviceProfile#isScalableGrid}.
@@ -384,6 +385,8 @@ public class InvariantDeviceProfile {
hotseatBarBottomSpace = displayOption.hotseatBarBottomSpace;
hotseatQsbSpace = displayOption.hotseatQsbSpace;
allAppsStyle = closestProfile.allAppsStyle;
numAllAppsColumns = closestProfile.numAllAppsColumns;
numDatabaseAllAppsColumns = deviceType == TYPE_MULTI_DISPLAY
? closestProfile.numDatabaseAllAppsColumns : closestProfile.numAllAppsColumns;
@@ -789,6 +792,7 @@ public class InvariantDeviceProfile {
private final @StyleRes int folderStyle;
private final @StyleRes int cellStyle;
private final @StyleRes int allAppsStyle;
private final int numAllAppsColumns;
private final int numDatabaseAllAppsColumns;
private final int numHotseatIcons;
@@ -824,6 +828,8 @@ public class InvariantDeviceProfile {
demoModeLayoutId = a.getResourceId(
R.styleable.GridDisplayOption_demoModeLayoutId, defaultLayoutId);
allAppsStyle = a.getResourceId(R.styleable.GridDisplayOption_allAppsStyle,
R.style.AllAppsStyleDefault);
numAllAppsColumns = a.getInt(
R.styleable.GridDisplayOption_numAllAppsColumns, numColumns);
numDatabaseAllAppsColumns = a.getInt(

View File

@@ -118,6 +118,7 @@ abstract class DeviceProfileBaseTest {
horizontalMargin = FloatArray(4) { 22f }
allAppsStyle = R.style.AllAppsStyleDefault
allAppsCellSize =
listOf(
PointF(80f, 104f),
@@ -196,6 +197,7 @@ abstract class DeviceProfileBaseTest {
horizontalMargin = floatArrayOf(54f, 120f, 54f, 54f)
allAppsStyle = R.style.AllAppsStyleDefault
allAppsCellSize =
listOf(
PointF(96f, 142f),
@@ -275,6 +277,7 @@ abstract class DeviceProfileBaseTest {
horizontalMargin = floatArrayOf(21.5f, 21.5f, 22.5f, 30.5f)
allAppsStyle = R.style.AllAppsStyleDefault
allAppsCellSize =
listOf(PointF(0f, 0f), PointF(0f, 0f), PointF(68f, 104f), PointF(80f, 104f))
.toTypedArray()