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

Commit b0ab8163 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Tune device profiles." into ub-launcher3-edmonton-polish

parents a7d41f29 7e183c39
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -48,7 +48,7 @@
        <com.android.launcher3.pageindicators.WorkspacePageIndicator
        <com.android.launcher3.pageindicators.WorkspacePageIndicator
            android:id="@+id/page_indicator"
            android:id="@+id/page_indicator"
            android:layout_width="match_parent"
            android:layout_width="match_parent"
            android:layout_height="4dp"
            android:layout_height="@dimen/vertical_drag_handle_size"
            android:layout_gravity="bottom|center_horizontal"
            android:layout_gravity="bottom|center_horizontal"
            android:theme="@style/HomeScreenElementTheme" />
            android:theme="@style/HomeScreenElementTheme" />


+3 −0
Original line number Original line Diff line number Diff line
@@ -34,6 +34,8 @@
    <!-- Hotseat -->
    <!-- Hotseat -->
    <dimen name="dynamic_grid_hotseat_top_padding">8dp</dimen>
    <dimen name="dynamic_grid_hotseat_top_padding">8dp</dimen>
    <dimen name="dynamic_grid_hotseat_bottom_padding">2dp</dimen>
    <dimen name="dynamic_grid_hotseat_bottom_padding">2dp</dimen>
    <!-- Extra bottom padding for non-tall devices. -->
    <dimen name="dynamic_grid_hotseat_bottom_non_tall_padding">0dp</dimen>
    <dimen name="dynamic_grid_hotseat_size">80dp</dimen>
    <dimen name="dynamic_grid_hotseat_size">80dp</dimen>
    <dimen name="dynamic_grid_hotseat_side_padding">0dp</dimen>
    <dimen name="dynamic_grid_hotseat_side_padding">0dp</dimen>


@@ -42,6 +44,7 @@
    <dimen name="all_apps_scrim_margin">8dp</dimen>
    <dimen name="all_apps_scrim_margin">8dp</dimen>
    <dimen name="all_apps_scrim_blur">4dp</dimen>
    <dimen name="all_apps_scrim_blur">4dp</dimen>
    <dimen name="vertical_drag_handle_size">24dp</dimen>
    <dimen name="vertical_drag_handle_size">24dp</dimen>
    <dimen name="vertical_drag_handle_overlap_workspace">0dp</dimen>


<!-- Drop target bar -->
<!-- Drop target bar -->
    <dimen name="dynamic_grid_drop_target_size">48dp</dimen>
    <dimen name="dynamic_grid_drop_target_size">48dp</dimen>
+26 −19
Original line number Original line Diff line number Diff line
@@ -72,6 +72,7 @@ public class DeviceProfile {


    // Drag handle
    // Drag handle
    public final int verticalDragHandleSizePx;
    public final int verticalDragHandleSizePx;
    private final int verticalDragHandleOverlapWorkspace;


    // Workspace icons
    // Workspace icons
    public int iconSizePx;
    public int iconSizePx;
@@ -101,7 +102,7 @@ public class DeviceProfile {
    // In portrait: size = height, in landscape: size = width
    // In portrait: size = height, in landscape: size = width
    public int hotseatBarSizePx;
    public int hotseatBarSizePx;
    public final int hotseatBarTopPaddingPx;
    public final int hotseatBarTopPaddingPx;
    public final int hotseatBarBottomPaddingPx;
    public int hotseatBarBottomPaddingPx;
    // Start is the side next to the nav bar, end is the side next to the workspace
    // Start is the side next to the nav bar, end is the side next to the workspace
    public final int hotseatBarSidePaddingStartPx;
    public final int hotseatBarSidePaddingStartPx;
    public final int hotseatBarSidePaddingEndPx;
    public final int hotseatBarSidePaddingEndPx;
@@ -135,6 +136,17 @@ public class DeviceProfile {
        this.isLandscape = isLandscape;
        this.isLandscape = isLandscape;
        this.isMultiWindowMode = isMultiWindowMode;
        this.isMultiWindowMode = isMultiWindowMode;


        // Determine sizes.
        widthPx = width;
        heightPx = height;
        if (isLandscape) {
            availableWidthPx = maxSize.x;
            availableHeightPx = minSize.y;
        } else {
            availableWidthPx = minSize.x;
            availableHeightPx = maxSize.y;
        }

        Resources res = context.getResources();
        Resources res = context.getResources();
        DisplayMetrics dm = res.getDisplayMetrics();
        DisplayMetrics dm = res.getDisplayMetrics();


@@ -142,6 +154,8 @@ public class DeviceProfile {
        isTablet = res.getBoolean(R.bool.is_tablet);
        isTablet = res.getBoolean(R.bool.is_tablet);
        isLargeTablet = res.getBoolean(R.bool.is_large_tablet);
        isLargeTablet = res.getBoolean(R.bool.is_large_tablet);
        isPhone = !isTablet && !isLargeTablet;
        isPhone = !isTablet && !isLargeTablet;
        float aspectRatio = ((float) Math.max(widthPx, heightPx)) / Math.min(widthPx, heightPx);
        boolean isTallDevice = Float.compare(aspectRatio, TALL_DEVICE_ASPECT_RATIO_THRESHOLD) >= 0;


        // Some more constants
        // Some more constants
        transposeLayoutWithOrientation =
        transposeLayoutWithOrientation =
@@ -164,6 +178,8 @@ public class DeviceProfile {
                res.getDimensionPixelSize(R.dimen.dynamic_grid_cell_layout_bottom_padding);
                res.getDimensionPixelSize(R.dimen.dynamic_grid_cell_layout_bottom_padding);
        verticalDragHandleSizePx = res.getDimensionPixelSize(
        verticalDragHandleSizePx = res.getDimensionPixelSize(
                R.dimen.vertical_drag_handle_size);
                R.dimen.vertical_drag_handle_size);
        verticalDragHandleOverlapWorkspace =
                res.getDimensionPixelSize(R.dimen.vertical_drag_handle_overlap_workspace);
        defaultPageSpacingPx =
        defaultPageSpacingPx =
                res.getDimensionPixelSize(R.dimen.dynamic_grid_workspace_page_spacing);
                res.getDimensionPixelSize(R.dimen.dynamic_grid_workspace_page_spacing);
        topWorkspacePadding =
        topWorkspacePadding =
@@ -178,8 +194,9 @@ public class DeviceProfile {


        hotseatBarTopPaddingPx =
        hotseatBarTopPaddingPx =
                res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_top_padding);
                res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_top_padding);
        hotseatBarBottomPaddingPx =
        hotseatBarBottomPaddingPx = (isTallDevice ? 0
                res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_bottom_padding);
                : res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_bottom_non_tall_padding))
                + res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_bottom_padding);
        hotseatBarSidePaddingEndPx =
        hotseatBarSidePaddingEndPx =
                res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_side_padding);
                res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_side_padding);
        // Add a bit of space between nav bar and hotseat in multi-window vertical bar layout.
        // Add a bit of space between nav bar and hotseat in multi-window vertical bar layout.
@@ -191,30 +208,19 @@ public class DeviceProfile {
                : res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_size)
                : res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_size)
                        + hotseatBarTopPaddingPx + hotseatBarBottomPaddingPx;
                        + hotseatBarTopPaddingPx + hotseatBarBottomPaddingPx;


        // Determine sizes.
        widthPx = width;
        heightPx = height;
        if (isLandscape) {
            availableWidthPx = maxSize.x;
            availableHeightPx = minSize.y;
        } else {
            availableWidthPx = minSize.x;
            availableHeightPx = maxSize.y;
        }

        // Calculate all of the remaining variables.
        // Calculate all of the remaining variables.
        updateAvailableDimensions(dm, res);
        updateAvailableDimensions(dm, res);


        // Now that we have all of the variables calculated, we can tune certain sizes.
        // Now that we have all of the variables calculated, we can tune certain sizes.
        float aspectRatio = ((float) Math.max(widthPx, heightPx)) / Math.min(widthPx, heightPx);
        boolean isTallDevice = Float.compare(aspectRatio, TALL_DEVICE_ASPECT_RATIO_THRESHOLD) >= 0;
        if (!isVerticalBarLayout() && isPhone && isTallDevice) {
        if (!isVerticalBarLayout() && isPhone && isTallDevice) {
            // We increase the hotseat size when there is extra space.
            // We increase the hotseat size when there is extra space.
            // ie. For a display with a large aspect ratio, we can keep the icons on the workspace
            // ie. For a display with a large aspect ratio, we can keep the icons on the workspace
            // in portrait mode closer together by adding more height to the hotseat.
            // in portrait mode closer together by adding more height to the hotseat.
            // Note: This calculation was created after noticing a pattern in the design spec.
            // Note: This calculation was created after noticing a pattern in the design spec.
            int extraSpace = getCellSize().y - iconSizePx - iconDrawablePaddingPx;
            int extraSpace = getCellSize().y - iconSizePx - iconDrawablePaddingPx * 2
            hotseatBarSizePx += extraSpace - verticalDragHandleSizePx;
                    - verticalDragHandleSizePx;
            hotseatBarSizePx += extraSpace;
            hotseatBarBottomPaddingPx += extraSpace;


            // Recalculate the available dimensions using the new hotseat size.
            // Recalculate the available dimensions using the new hotseat size.
            updateAvailableDimensions(dm, res);
            updateAvailableDimensions(dm, res);
@@ -440,7 +446,8 @@ public class DeviceProfile {
                padding.right = hotseatBarSizePx;
                padding.right = hotseatBarSizePx;
            }
            }
        } else {
        } else {
            int paddingBottom = hotseatBarSizePx + verticalDragHandleSizePx;
            int paddingBottom = hotseatBarSizePx + verticalDragHandleSizePx
                    - verticalDragHandleOverlapWorkspace;
            if (isTablet) {
            if (isTablet) {
                // Pad the left and right of the workspace to ensure consistent spacing
                // Pad the left and right of the workspace to ensure consistent spacing
                // between all icons
                // between all icons