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

Unverified Commit a34ae9da authored by Arian's avatar Arian Committed by Michael Bestas
Browse files

VolumeDialogImpl: Handle the outmost row with respect to left gravity

Change-Id: I23ffc447f512446688a20bad5639f1a1719f7660
parent fe2ddb6f
Loading
Loading
Loading
Loading
+17 −14
Original line number Original line Diff line number Diff line
@@ -1717,8 +1717,10 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
            trimObsoleteH();
            trimObsoleteH();
        }
        }


        boolean isOutmostIndexMax = isWindowGravityLeft() ? isRtl() : !isRtl();

        // Index of the last row that is actually visible.
        // Index of the last row that is actually visible.
        int rightmostVisibleRowIndex = !isRtl() ? -1 : Short.MAX_VALUE;
        int outmostVisibleRowIndex = isOutmostIndexMax ? -1 : Short.MAX_VALUE;


        // apply changes to all rows
        // apply changes to all rows
        for (final VolumeRow row : mRows) {
        for (final VolumeRow row : mRows) {
@@ -1727,14 +1729,11 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
            Util.setVisOrGone(row.view, shouldBeVisible);
            Util.setVisOrGone(row.view, shouldBeVisible);


            if (shouldBeVisible && mRingerAndDrawerContainerBackground != null) {
            if (shouldBeVisible && mRingerAndDrawerContainerBackground != null) {
                // For RTL, the rightmost row has the lowest index since child views are laid out
                // For RTL, the outmost row has the lowest index since child views are laid out
                // from right to left.
                // from right to left.
                rightmostVisibleRowIndex =
                outmostVisibleRowIndex = isOutmostIndexMax
                        !isRtl()
                        ? Math.max(outmostVisibleRowIndex, mDialogRowsView.indexOfChild(row.view))
                                ? Math.max(rightmostVisibleRowIndex,
                        : Math.min(outmostVisibleRowIndex, mDialogRowsView.indexOfChild(row.view));
                                mDialogRowsView.indexOfChild(row.view))
                                : Math.min(rightmostVisibleRowIndex,
                                        mDialogRowsView.indexOfChild(row.view));


                // Add spacing between each of the visible rows - we'll remove the spacing from the
                // Add spacing between each of the visible rows - we'll remove the spacing from the
                // last row after the loop.
                // last row after the loop.
@@ -1742,7 +1741,7 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
                if (layoutParams instanceof LinearLayout.LayoutParams) {
                if (layoutParams instanceof LinearLayout.LayoutParams) {
                    final LinearLayout.LayoutParams linearLayoutParams =
                    final LinearLayout.LayoutParams linearLayoutParams =
                            ((LinearLayout.LayoutParams) layoutParams);
                            ((LinearLayout.LayoutParams) layoutParams);
                    if (!isRtl()) {
                    if (isOutmostIndexMax) {
                        linearLayoutParams.setMarginEnd(mRingerRowsPadding);
                        linearLayoutParams.setMarginEnd(mRingerRowsPadding);
                    } else {
                    } else {
                        linearLayoutParams.setMarginStart(mRingerRowsPadding);
                        linearLayoutParams.setMarginStart(mRingerRowsPadding);
@@ -1760,8 +1759,8 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
            }
            }
        }
        }


        if (rightmostVisibleRowIndex > -1 && rightmostVisibleRowIndex < Short.MAX_VALUE) {
        if (outmostVisibleRowIndex > -1 && outmostVisibleRowIndex < Short.MAX_VALUE) {
            final View lastVisibleChild = mDialogRowsView.getChildAt(rightmostVisibleRowIndex);
            final View lastVisibleChild = mDialogRowsView.getChildAt(outmostVisibleRowIndex);
            final ViewGroup.LayoutParams layoutParams = lastVisibleChild.getLayoutParams();
            final ViewGroup.LayoutParams layoutParams = lastVisibleChild.getLayoutParams();
            // Remove the spacing on the last row, and remove its background since the container is
            // Remove the spacing on the last row, and remove its background since the container is
            // drawing a background for this row.
            // drawing a background for this row.
@@ -2314,6 +2313,9 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
        final Rect bounds = mRingerAndDrawerContainerBackground.copyBounds();
        final Rect bounds = mRingerAndDrawerContainerBackground.copyBounds();
        if (!isLandscape()) {
        if (!isLandscape()) {
            bounds.top = (int) (mRingerDrawerClosedAmount * getRingerDrawerOpenExtraSize());
            bounds.top = (int) (mRingerDrawerClosedAmount * getRingerDrawerOpenExtraSize());
        } else if (isWindowGravityLeft()) {
            bounds.right = (int) ((mDialogCornerRadius / 2) + mRingerDrawerItemSize
                    + (1f - mRingerDrawerClosedAmount) * getRingerDrawerOpenExtraSize());
        } else {
        } else {
            bounds.left = (int) (mRingerDrawerClosedAmount * getRingerDrawerOpenExtraSize());
            bounds.left = (int) (mRingerDrawerClosedAmount * getRingerDrawerOpenExtraSize());
        }
        }
@@ -2321,7 +2323,7 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
    }
    }


    /*
    /*
     * The top container is responsible for drawing the solid color background behind the rightmost
     * The top container is responsible for drawing the solid color background behind the outmost
     * (primary) volume row. This is because the volume drawer animates in from below, initially
     * (primary) volume row. This is because the volume drawer animates in from below, initially
     * overlapping the primary row. We need the drawer to draw below the row's SeekBar, since it
     * overlapping the primary row. We need the drawer to draw below the row's SeekBar, since it
     * looks strange to overlap it, but above the row's background color, since otherwise it will be
     * looks strange to overlap it, but above the row's background color, since otherwise it will be
@@ -2355,8 +2357,9 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
                        ? mDialogRowsViewContainer.getTop()
                        ? mDialogRowsViewContainer.getTop()
                        : mDialogRowsViewContainer.getTop() - mDialogCornerRadius);
                        : mDialogRowsViewContainer.getTop() - mDialogCornerRadius);


        // Set gravity to top-right, since additional rows will be added on the left.
        // Set gravity to top and opposite side where additional rows will be added.
        background.setLayerGravity(0, Gravity.TOP | Gravity.RIGHT);
        background.setLayerGravity(0,
                isWindowGravityLeft() ? Gravity.TOP | Gravity.LEFT : Gravity.TOP | Gravity.RIGHT);


        // In landscape, the ringer drawer animates out to the left (instead of down). Since the
        // In landscape, the ringer drawer animates out to the left (instead of down). Since the
        // drawer comes from the right (beyond the bounds of the dialog), we should clip it so it
        // drawer comes from the right (beyond the bounds of the dialog), we should clip it so it