Merge "Position TV volume UI based on layout orientation."

This commit is contained in:
Jacqueline Bronger
2022-12-20 13:05:21 +00:00
committed by Android (Google) Code Review
2 changed files with 21 additions and 5 deletions

View File

@@ -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>

View File

@@ -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);