From d3f19bcb778a521996a5f1a89ad9d31f1561a52b Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Fri, 20 May 2022 23:11:50 +0000 Subject: [PATCH 1/2] Fix position of bubble education views on large screen in RTL In large screen or landscape, the width of the education view is not full width, so we need to position it on the edge of the screen when in RTL. It naturally does this in LTR. Bug: 233408508 Test: force user education to show for bubbles, check how it appears in RTL & LTR on: large screen portrait & landscape, and portait and landscape on phone. Change-Id: I4e9ca9ed3d59ecaab3d6522961acf190f6a54850 --- .../com/android/wm/shell/bubbles/ManageEducationView.kt | 7 ++++++- .../src/com/android/wm/shell/bubbles/StackEducationView.kt | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/ManageEducationView.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/ManageEducationView.kt index c09d1e0d189c4..2ecf388ee5142 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/ManageEducationView.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/ManageEducationView.kt @@ -108,6 +108,7 @@ class ManageEducationView constructor(context: Context, positioner: BubblePositi alpha = 0f visibility = View.VISIBLE expandedView.getManageButtonBoundsOnScreen(realManageButtonRect) + val isRTL = mContext.resources.configuration.layoutDirection == LAYOUT_DIRECTION_RTL manageView.setPadding(realManageButtonRect.left - expandedView.manageButtonMargin, manageView.paddingTop, manageView.paddingRight, manageView.paddingBottom) post { @@ -122,7 +123,11 @@ class ManageEducationView constructor(context: Context, positioner: BubblePositi val offsetViewBounds = Rect() manageButton.getDrawingRect(offsetViewBounds) manageView.offsetDescendantRectToMyCoords(manageButton, offsetViewBounds) - translationX = 0f + if (isRTL && (positioner.isLargeScreen || positioner.isLandscape)) { + translationX = (positioner.screenRect.right - width).toFloat() + } else { + translationX = 0f + } translationY = (realManageButtonRect.top - offsetViewBounds.top).toFloat() bringToFront() animate() diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/StackEducationView.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/StackEducationView.kt index 1ff4be887fb28..627273f093f33 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/StackEducationView.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/StackEducationView.kt @@ -146,6 +146,12 @@ class StackEducationView constructor( } else { setPadding(paddingLeft, paddingTop, positioner.bubbleSize + stackPadding, paddingBottom) + if (positioner.isLargeScreen || positioner.isLandscape) { + translationX = (positioner.screenRect.right - width - stackPadding) + .toFloat() + } else { + translationX = 0f + } } translationY = stackPosition.y + positioner.bubbleSize / 2 - getHeight() / 2 } From 3b272227805c44756f0857d3c5aadabe8961b239 Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Mon, 23 May 2022 19:59:57 +0000 Subject: [PATCH 2/2] Fix a padding issue for bubble user education in RTL The education view is placed on the right hand side of the screen so the padding calculation to align the manage button in the education view with the real manage button is slightly different. Bug: 230579507 Test: manual - force education for bubbles to show, set RTL language, open up stack and look at manage button education Change-Id: I282ed7eb2014d5d1a6d2b428572e495ce0d77c78 --- .../android/wm/shell/bubbles/ManageEducationView.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/ManageEducationView.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/ManageEducationView.kt index 2ecf388ee5142..e95e8e5cdaea1 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/ManageEducationView.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/ManageEducationView.kt @@ -109,8 +109,15 @@ class ManageEducationView constructor(context: Context, positioner: BubblePositi visibility = View.VISIBLE expandedView.getManageButtonBoundsOnScreen(realManageButtonRect) val isRTL = mContext.resources.configuration.layoutDirection == LAYOUT_DIRECTION_RTL - manageView.setPadding(realManageButtonRect.left - expandedView.manageButtonMargin, - manageView.paddingTop, manageView.paddingRight, manageView.paddingBottom) + if (isRTL) { + val rightPadding = positioner.screenRect.right - realManageButtonRect.right - + expandedView.manageButtonMargin + manageView.setPadding(manageView.paddingLeft, manageView.paddingTop, + rightPadding, manageView.paddingBottom) + } else { + manageView.setPadding(realManageButtonRect.left - expandedView.manageButtonMargin, + manageView.paddingTop, manageView.paddingRight, manageView.paddingBottom) + } post { manageButton .setOnClickListener {