From 4cce5648053812935bdc511748992e0e4d3647f5 Mon Sep 17 00:00:00 2001 From: Peter_Liang Date: Thu, 13 May 2021 23:59:31 +0800 Subject: [PATCH] Fix the tooltip view can't be adjusted under the change of display or font size. Solution: Should update the latest resource value before showing the tooltip Bug: 186484337 Bug: 186484718 Test: atest AccessibilityFloatingMenuViewTest Change-Id: I088cebd454d1409c71da4e80eb36eeb819bacb39 --- .../floatingmenu/BaseTooltipView.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/BaseTooltipView.java b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/BaseTooltipView.java index 1abf559d68460..308585491aef7 100644 --- a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/BaseTooltipView.java +++ b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/BaseTooltipView.java @@ -77,7 +77,6 @@ class BaseTooltipView extends FrameLayout { mAnchorView = anchorView; mCurrentLayoutParams = createDefaultLayoutParams(); - updateDimensions(); initViews(); } @@ -85,14 +84,8 @@ class BaseTooltipView extends FrameLayout { protected void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); - updateDimensions(); - updateTextView(); - mAnchorView.onConfigurationChanged(newConfig); - final Rect anchorViewLocation = mAnchorView.getWindowLocationOnScreen(); - updateArrowWith(anchorViewLocation); - updateWidthWith(anchorViewLocation); - updateLocationWith(anchorViewLocation); + updateTooltipView(); mWindowManager.updateViewLayout(this, mCurrentLayoutParams); } @@ -129,10 +122,7 @@ class BaseTooltipView extends FrameLayout { } mIsShowing = true; - final Rect anchorViewLocation = mAnchorView.getWindowLocationOnScreen(); - updateArrowWith(anchorViewLocation); - updateWidthWith(anchorViewLocation); - updateLocationWith(anchorViewLocation); + updateTooltipView(); mWindowManager.addView(this, mCurrentLayoutParams); } @@ -207,6 +197,16 @@ class BaseTooltipView extends FrameLayout { R.dimen.accessibility_floating_tooltip_text_corner_radius); } + private void updateTooltipView() { + updateDimensions(); + updateTextView(); + + final Rect anchorViewLocation = mAnchorView.getWindowLocationOnScreen(); + updateArrowWith(anchorViewLocation); + updateWidthWith(anchorViewLocation); + updateLocationWith(anchorViewLocation); + } + private void updateTextView() { mTextView.setTextSize(COMPLEX_UNIT_PX, mFontSize); mTextView.setPadding(mTextViewPadding, mTextViewPadding, mTextViewPadding,