summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Phil Weaver <pweaver@google.com> 2018-05-08 15:22:17 -0700
committer Phil Weaver <pweaver@google.com> 2018-05-08 15:22:17 -0700
commitd2bebd43a49d53c3298f6eebbf67bede834e9438 (patch)
tree110d808bde0f8b12bf34ce3019f4a860eebea9f1
parent331a22e39a95e335da6f401aa4caee8efb3781de (diff)
Update a11y when alpha changes
We were only updating accessibility in View#setAlpha, but View#setAlphaNoInvalidation would also change alpha, and accessibility would never find out. Bug: 78101543 Test: TalkBack now works on nightlight conditional and battery saver slider. Change-Id: I1ebb62aa7f4de700b2d7fbaae8dbbd1c84fc4ece
-rw-r--r--core/java/android/view/View.java18
1 files changed, 11 insertions, 7 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 6b16d42ac7ef..b9c500a6f79a 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -15049,8 +15049,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
public void setAlpha(@FloatRange(from=0.0, to=1.0) float alpha) {
ensureTransformationInfo();
if (mTransformationInfo.mAlpha != alpha) {
- float oldAlpha = mTransformationInfo.mAlpha;
- mTransformationInfo.mAlpha = alpha;
+ setAlphaInternal(alpha);
if (onSetAlpha((int) (alpha * 255))) {
mPrivateFlags |= PFLAG_ALPHA_SET;
// subclass is handling alpha - don't optimize rendering cache invalidation
@@ -15061,10 +15060,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
invalidateViewProperty(true, false);
mRenderNode.setAlpha(getFinalAlpha());
}
- // Report visibility changes, which can affect children, to accessibility
- if ((alpha == 0) ^ (oldAlpha == 0)) {
- notifySubtreeAccessibilityStateChangedIfNeeded();
- }
}
}
@@ -15081,7 +15076,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
boolean setAlphaNoInvalidation(float alpha) {
ensureTransformationInfo();
if (mTransformationInfo.mAlpha != alpha) {
- mTransformationInfo.mAlpha = alpha;
+ setAlphaInternal(alpha);
boolean subclassHandlesAlpha = onSetAlpha((int) (alpha * 255));
if (subclassHandlesAlpha) {
mPrivateFlags |= PFLAG_ALPHA_SET;
@@ -15094,6 +15089,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
return false;
}
+ private void setAlphaInternal(float alpha) {
+ float oldAlpha = mTransformationInfo.mAlpha;
+ mTransformationInfo.mAlpha = alpha;
+ // Report visibility changes, which can affect children, to accessibility
+ if ((alpha == 0) ^ (oldAlpha == 0)) {
+ notifySubtreeAccessibilityStateChangedIfNeeded();
+ }
+ }
+
/**
* This property is hidden and intended only for use by the Fade transition, which
* animates it to produce a visual translucency that does not side-effect (or get