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

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

VolumeDialogImpl: Respect left gravity in ringer drawer

Change-Id: I2cc18aea9bf4afb51c5faee7af6437f6c047416b
parent 6ba2fc84
Loading
Loading
Loading
Loading
+18 −10
Original line number Original line Diff line number Diff line
@@ -982,6 +982,12 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
                    mDialogView.getPaddingTop(),
                    mDialogView.getPaddingTop(),
                    mDialogView.getPaddingRight(),
                    mDialogView.getPaddingRight(),
                    mDialogView.getPaddingBottom() + getRingerDrawerOpenExtraSize());
                    mDialogView.getPaddingBottom() + getRingerDrawerOpenExtraSize());
        } else if (isWindowGravityLeft()) {
            mDialogView.setPadding(
                    mDialogView.getPaddingLeft(),
                    mDialogView.getPaddingTop(),
                    mDialogView.getPaddingRight() + getRingerDrawerOpenExtraSize(),
                    mDialogView.getPaddingBottom());
        } else {
        } else {
            mDialogView.setPadding(
            mDialogView.setPadding(
                    mDialogView.getPaddingLeft() + getRingerDrawerOpenExtraSize(),
                    mDialogView.getPaddingLeft() + getRingerDrawerOpenExtraSize(),
@@ -1052,15 +1058,16 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
    }
    }


    /**
    /**
     * Translation to apply form the origin (either top or left) to overlap the selection background
     * Translation to apply form the origin (either top or left/right) to overlap the selection
     * with the given mode in the drawer.
     * background with the given mode in the drawer.
     */
     */
    private float getTranslationInDrawerForRingerMode(int mode) {
    private float getTranslationInDrawerForRingerMode(int mode) {
        return mode == RINGER_MODE_VIBRATE
        final int distantRinger = ((isLandscape() && isWindowGravityLeft()) ? RINGER_MODE_NORMAL
                ? -mRingerDrawerItemSize * 2
                                                                            : RINGER_MODE_VIBRATE);
                : mode == RINGER_MODE_SILENT
        return (mode == distantRinger                       ? mRingerDrawerItemSize * 2
                        ? -mRingerDrawerItemSize
                               : mode == RINGER_MODE_SILENT ? mRingerDrawerItemSize
                        : 0;
                                                            : 0)
                * ((isLandscape() && isWindowGravityLeft()) ? 1 : -1);
    }
    }


    @VisibleForTesting String getSelectedRingerContainerDescription() {
    @VisibleForTesting String getSelectedRingerContainerDescription() {
@@ -1104,12 +1111,13 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
                    getTranslationInDrawerForRingerMode(mState.ringerModeInternal));
                    getTranslationInDrawerForRingerMode(mState.ringerModeInternal));
        }
        }


        // Move the drawer so that the top/rightmost ringer choice overlaps with the selected ringer
        // Move the drawer so that the top/outmost ringer choice overlaps with the selected ringer
        // icon.
        // icon.
        if (!isLandscape()) {
        if (!isLandscape()) {
            mRingerDrawerContainer.setTranslationY(mRingerDrawerItemSize * (mRingerCount - 1));
            mRingerDrawerContainer.setTranslationY(mRingerDrawerItemSize * (mRingerCount - 1));
        } else {
        } else {
            mRingerDrawerContainer.setTranslationX(mRingerDrawerItemSize * (mRingerCount - 1));
            mRingerDrawerContainer.setTranslationX(
                    (isWindowGravityLeft() ? -1 : 1) * mRingerDrawerItemSize * (mRingerCount - 1));
        }
        }
        mRingerDrawerContainer.setAlpha(0f);
        mRingerDrawerContainer.setAlpha(0f);
        mRingerDrawerContainer.setVisibility(VISIBLE);
        mRingerDrawerContainer.setVisibility(VISIBLE);
@@ -1186,7 +1194,7 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
                    .start();
                    .start();
        } else {
        } else {
            mRingerDrawerContainer.animate()
            mRingerDrawerContainer.animate()
                    .translationX(mRingerDrawerItemSize * 2)
                    .translationX((isWindowGravityLeft() ? -1 : 1) * mRingerDrawerItemSize * 2)
                    .start();
                    .start();
        }
        }