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

Commit 3e7fa49c authored by Jacqueline Bronger's avatar Jacqueline Bronger
Browse files

Position TV volume UI based on layout orientation.

Previously, the volume UI has been positioned statically on the center
right, however since we don't generally have volume buttons on the
right side like on mobile, we will prioritise reducing content overlap
like we do with other floating windows/panels.

Bug: 246537363
Test: manual, on TV: change volume in LTR -> there should be no change,
switch to an RTL language -> volume dialog should be positioned on the
left and the animation should also have its origin on the left

Change-Id: I64970c50bc58666f99d7fad8f69e9bf6a4bf2936
parent c9f75fda
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -18,8 +18,9 @@
    <!-- The position of the volume dialog on the screen.
         See com.android.systemui.volume.VolumeDialogImpl.
         Value 81 corresponds to BOTTOM|CENTER_HORIZONTAL.
         Value 21 corresponds to RIGHT|CENTER_VERTICAL. -->
    <integer name="volume_dialog_gravity">21</integer>
         Value 21 corresponds to RIGHT|CENTER_VERTICAL.
         Value 8388629 corresponds to END|CENTER_VERTICAL -->
    <integer name="volume_dialog_gravity">8388629</integer>

    <integer name="privacy_chip_animation_millis">300</integer>
</resources>
+18 −3
Original line number Diff line number Diff line
@@ -288,6 +288,8 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,

    private boolean mSeparateNotification;

    private int mWindowGravity;

    @VisibleForTesting
    int mVolumeRingerIconDrawableId;
    @VisibleForTesting
@@ -514,7 +516,12 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
        lp.format = PixelFormat.TRANSLUCENT;
        lp.setTitle(VolumeDialogImpl.class.getSimpleName());
        lp.windowAnimations = -1;
        lp.gravity = mContext.getResources().getInteger(R.integer.volume_dialog_gravity);

        mWindowGravity = Gravity.getAbsoluteGravity(
                mContext.getResources().getInteger(R.integer.volume_dialog_gravity),
                mContext.getResources().getConfiguration().getLayoutDirection());
        lp.gravity = mWindowGravity;

        mWindow.setAttributes(lp);
        mWindow.setLayout(WRAP_CONTENT, WRAP_CONTENT);

@@ -525,7 +532,8 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
        mDialog.setOnShowListener(dialog -> {
            mDialogView.getViewTreeObserver().addOnComputeInternalInsetsListener(this);
            if (!shouldSlideInVolumeTray()) {
                mDialogView.setTranslationX(mDialogView.getWidth() / 2.0f);
                mDialogView.setTranslationX(
                        (isWindowGravityLeft() ? -1 : 1) * mDialogView.getWidth() / 2.0f);
            }
            mDialogView.setAlpha(0);
            mDialogView.animate()
@@ -696,6 +704,10 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
        initODICaptionsH();
    }

    private boolean isWindowGravityLeft() {
        return (mWindowGravity & Gravity.LEFT) == Gravity.LEFT;
    }

    private void initDimens() {
        mDialogWidth = mContext.getResources().getDimensionPixelSize(
                R.dimen.volume_dialog_panel_width);
@@ -1495,7 +1507,10 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,

                    hideRingerDrawer();
                }, 50));
        if (!shouldSlideInVolumeTray()) animator.translationX(mDialogView.getWidth() / 2.0f);
        if (!shouldSlideInVolumeTray()) {
            animator.translationX(
                    (isWindowGravityLeft() ? -1 : 1) * mDialogView.getWidth() / 2.0f);
        }
        animator.setListener(getJankListener(getDialogView(), TYPE_DISMISS,
                mDialogHideAnimationDurationMs)).start();
        checkODICaptionsTooltip(true);