From 983119ab22a18c743e4084dff27f35e3f490dd34 Mon Sep 17 00:00:00 2001 From: Svetoslav Ganov Date: Tue, 3 Jul 2012 21:04:10 -0700 Subject: [PATCH] AccessibilityNodeInfo bounds in screen incorrect if application scale not one. 1. If the application does not accommodate different screen density the system applies an application scale equal to the device density over the a default density. The AccessibilityNodeInfo coordinates were not reported after applying the compatibility scale, therefore the bounds in parent and screen were not as perceived by the user. bug:6764586 Change-Id: Iae2d6ea81049364194c7cb09df2240b5eda3d939 --- core/java/android/view/View.java | 4 ++++ core/java/android/widget/NumberPicker.java | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index b6f0aa2c9eeea..414bb501d33ef 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -4820,10 +4820,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { Rect bounds = mAttachInfo.mTmpInvalRect; + final float applicationScale = mAttachInfo.mApplicationScale; + getDrawingRect(bounds); + bounds.scale(applicationScale); info.setBoundsInParent(bounds); getBoundsOnScreen(bounds); + bounds.scale(applicationScale); info.setBoundsInScreen(bounds); ViewParent parent = getParentForAccessibility(); diff --git a/core/java/android/widget/NumberPicker.java b/core/java/android/widget/NumberPicker.java index a458f57d7de24..b16a6c675eb1f 100644 --- a/core/java/android/widget/NumberPicker.java +++ b/core/java/android/widget/NumberPicker.java @@ -2506,14 +2506,22 @@ public class NumberPicker extends LinearLayout { info.setParent((View) getParentForAccessibility()); info.setEnabled(NumberPicker.this.isEnabled()); info.setScrollable(true); + + final float applicationScale = + getContext().getResources().getCompatibilityInfo().applicationScale; + Rect boundsInParent = mTempRect; boundsInParent.set(left, top, right, bottom); + boundsInParent.scale(applicationScale); info.setBoundsInParent(boundsInParent); + info.setVisibleToUser(isVisibleToUser()); + Rect boundsInScreen = boundsInParent; int[] locationOnScreen = mTempArray; getLocationOnScreen(locationOnScreen); boundsInScreen.offset(locationOnScreen[0], locationOnScreen[1]); + boundsInScreen.scale(applicationScale); info.setBoundsInScreen(boundsInScreen); if (mAccessibilityFocusedView != View.NO_ID) {