diff options
6 files changed, 72 insertions, 45 deletions
diff --git a/packages/SystemUI/res/layout-land/volume_dialog.xml b/packages/SystemUI/res/layout-land/volume_dialog.xml index b08e51372dd0..f1cda277f045 100644 --- a/packages/SystemUI/res/layout-land/volume_dialog.xml +++ b/packages/SystemUI/res/layout-land/volume_dialog.xml @@ -126,6 +126,7 @@ android:gravity="right" android:layout_gravity="right" android:clipToPadding="false" + android:clipToOutline="true" android:background="@drawable/volume_row_rounded_background"> <com.android.systemui.volume.CaptionsToggleImageButton android:id="@+id/odi_captions_icon" @@ -146,6 +147,7 @@ android:layout="@layout/volume_tool_tip_view" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_gravity="bottom | right"/> + android:layout_gravity="bottom | right" + android:layout_marginRight="@dimen/volume_tool_tip_right_margin"/> </FrameLayout>
\ No newline at end of file diff --git a/packages/SystemUI/res/layout/volume_dialog.xml b/packages/SystemUI/res/layout/volume_dialog.xml index beac05794fe9..51718d9af054 100644 --- a/packages/SystemUI/res/layout/volume_dialog.xml +++ b/packages/SystemUI/res/layout/volume_dialog.xml @@ -125,6 +125,7 @@ android:gravity="right" android:layout_gravity="right" android:clipToPadding="false" + android:clipToOutline="true" android:background="@drawable/volume_row_rounded_background"> <com.android.systemui.volume.CaptionsToggleImageButton android:id="@+id/odi_captions_icon" @@ -146,7 +147,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom | right" - android:layout_marginRight="@dimen/volume_tool_tip_right_margin" - android:layout_marginBottom="@dimen/volume_tool_tip_bottom_margin"/> + android:layout_marginRight="@dimen/volume_tool_tip_right_margin"/> </FrameLayout>
\ No newline at end of file diff --git a/packages/SystemUI/res/layout/volume_tool_tip_view.xml b/packages/SystemUI/res/layout/volume_tool_tip_view.xml index 9fe885ebefc7..ee2496948752 100644 --- a/packages/SystemUI/res/layout/volume_tool_tip_view.xml +++ b/packages/SystemUI/res/layout/volume_tool_tip_view.xml @@ -17,6 +17,7 @@ <com.android.systemui.volume.VolumeToolTipView xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:androidprv="http://schemas.android.com/apk/prv/res/android" android:id="@+id/tooltip_view" android:layout_height="wrap_content" android:layout_width="wrap_content" @@ -35,7 +36,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" - android:textColor="@android:color/white" + android:textColor="?android:attr/textColorPrimaryInverse" android:text="@string/volume_odi_captions_tip" android:textSize="14sp"/> <ImageView @@ -48,7 +49,7 @@ android:layout_marginEnd="2dp" android:alpha="0.7" android:src="@drawable/ic_remove_no_shadow" - android:tint="@android:color/white" + android:tint="?android:attr/textColorPrimaryInverse" android:background="?android:attr/selectableItemBackgroundBorderless" android:contentDescription="@string/accessibility_volume_close_odi_captions_tip"/> </LinearLayout> diff --git a/packages/SystemUI/res/values-land-television/dimens.xml b/packages/SystemUI/res/values-land-television/dimens.xml index 220ed5cce83e..a9bc9e5cd638 100644 --- a/packages/SystemUI/res/values-land-television/dimens.xml +++ b/packages/SystemUI/res/values-land-television/dimens.xml @@ -23,6 +23,7 @@ <dimen name="volume_dialog_slider_width">4dp</dimen> <dimen name="volume_dialog_slider_corner_radius">@dimen/volume_dialog_slider_width</dimen> <dimen name="volume_dialog_background_blur_radius">100dp</dimen> + <dimen name="volume_tool_tip_right_margin">136dp</dimen> <dimen name="tv_volume_dialog_bubble_size">36dp</dimen> <dimen name="tv_volume_dialog_row_padding">6dp</dimen> diff --git a/packages/SystemUI/res/values-land/dimens.xml b/packages/SystemUI/res/values-land/dimens.xml index 215698dd1884..9df9db607b9f 100644 --- a/packages/SystemUI/res/values-land/dimens.xml +++ b/packages/SystemUI/res/values-land/dimens.xml @@ -43,7 +43,6 @@ <dimen name="qs_detail_margin_top">14dp</dimen> - <dimen name="volume_tool_tip_right_margin">136dp</dimen> <dimen name="volume_tool_tip_top_margin">12dp</dimen> <dimen name="volume_row_slider_height">128dp</dimen> diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java index 50b885815e09..961822a598e7 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java +++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java @@ -337,37 +337,44 @@ public class VolumeDialogImpl implements VolumeDialog, mTouchableRegion.setEmpty(); - // Set the touchable region to the union of all child view bounds. We don't use touches on - // the volume dialog container itself, so this is fine. + // Set the touchable region to the union of all child view bounds and the live caption + // tooltip. We don't use touches on the volume dialog container itself, so this is fine. for (int i = 0; i < mDialogView.getChildCount(); i++) { - final View view = mDialogView.getChildAt(i); - final int[] locInWindow = new int[2]; - view.getLocationInWindow(locInWindow); - - float x = locInWindow[0]; - float y = locInWindow[1]; - - // The ringer and rows container has extra height at the top to fit the expanded ringer - // drawer. This area should not be touchable unless the ringer drawer is open. - if (view == mTopContainer && !mIsRingerDrawerOpen) { - if (!isLandscape()) { - y += getRingerDrawerOpenExtraSize(); - } else { - x += getRingerDrawerOpenExtraSize(); - } - } + unionViewBoundstoTouchableRegion(mDialogView.getChildAt(i)); + } - mTouchableRegion.op( - (int) x, - (int) y, - locInWindow[0] + view.getWidth(), - locInWindow[1] + view.getHeight(), - Region.Op.UNION); + if (mODICaptionsTooltipView != null && mODICaptionsTooltipView.getVisibility() == VISIBLE) { + unionViewBoundstoTouchableRegion(mODICaptionsTooltipView); } internalInsetsInfo.touchableRegion.set(mTouchableRegion); } + private void unionViewBoundstoTouchableRegion(final View view) { + final int[] locInWindow = new int[2]; + view.getLocationInWindow(locInWindow); + + float x = locInWindow[0]; + float y = locInWindow[1]; + + // The ringer and rows container has extra height at the top to fit the expanded ringer + // drawer. This area should not be touchable unless the ringer drawer is open. + if (view == mTopContainer && !mIsRingerDrawerOpen) { + if (!isLandscape()) { + y += getRingerDrawerOpenExtraSize(); + } else { + x += getRingerDrawerOpenExtraSize(); + } + } + + mTouchableRegion.op( + (int) x, + (int) y, + locInWindow[0] + view.getWidth(), + locInWindow[1] + view.getHeight(), + Region.Op.UNION); + } + private void initDialog() { mDialog = new CustomDialog(mContext); @@ -1058,21 +1065,38 @@ public class VolumeDialogImpl implements VolumeDialog, } if (mODICaptionsTooltipView != null) { - mODICaptionsTooltipView.setAlpha(0.f); - mODICaptionsTooltipView.animate() - .alpha(1.f) - .setStartDelay(mDialogShowAnimationDurationMs) - .withEndAction(() -> { - if (D.BUG) Log.d(TAG, "tool:checkODICaptionsTooltip() putBoolean true"); - Prefs.putBoolean(mContext, - Prefs.Key.HAS_SEEN_ODI_CAPTIONS_TOOLTIP, true); - mHasSeenODICaptionsTooltip = true; - if (mODICaptionsIcon != null) { - mODICaptionsIcon - .postOnAnimation(getSinglePressFor(mODICaptionsIcon)); - } - }) - .start(); + mODICaptionsTooltipView.setAlpha(0.0f); + + // We need to wait for layout and then center the caption view. Since the height of the + // dialog is now dynamic (with the variable ringer drawer height changing the height of + // the dialog), we need to do this here in code vs. in XML. + mHandler.post(() -> { + final int[] odiTooltipLocation = mODICaptionsTooltipView.getLocationOnScreen(); + final int[] odiButtonLocation = mODICaptionsIcon.getLocationOnScreen(); + + final float heightDiffForCentering = + (mODICaptionsTooltipView.getHeight() - mODICaptionsIcon.getHeight()) / 2f; + + mODICaptionsTooltipView.setTranslationY( + odiButtonLocation[1] - odiTooltipLocation[1] - heightDiffForCentering); + + mODICaptionsTooltipView.animate() + .alpha(1.0f) + .setStartDelay(mDialogShowAnimationDurationMs) + .withEndAction(() -> { + if (D.BUG) { + Log.d(TAG, "tool:checkODICaptionsTooltip() putBoolean true"); + } + Prefs.putBoolean(mContext, + Prefs.Key.HAS_SEEN_ODI_CAPTIONS_TOOLTIP, true); + mHasSeenODICaptionsTooltip = true; + if (mODICaptionsIcon != null) { + mODICaptionsIcon + .postOnAnimation(getSinglePressFor(mODICaptionsIcon)); + } + }) + .start(); + }); } } |