-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Android] Enable isInvertColorsEnabled property to AccessibilityInfo component #31070
Conversation
Hi @MSzalowski! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code analysis results:
google-java-format
found some issues. See https://github.com/google/google-java-format
@@ -11,6 +11,7 @@ | |||
import android.content.ContentResolver; | |||
import android.content.Context; | |||
import android.database.ContentObserver; | |||
import android.provider.Settings.Secure; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
google-java-format
suggested changes:
@@ -14 +13,0 @@
-import android.provider.Settings.Secure;
@@ -95,6 +99,14 @@ private boolean getIsReduceMotionEnabledValue() { | |||
return value != null && value.equals("0.0"); | |||
} | |||
|
|||
@TargetApi(Build.VERSION_CODES.LOLLIPOP) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
google-java-format
suggested changes:
@@ -105 +104,2 @@
- Settings.Secure.getString(mContentResolver, Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED);
+ Settings.Secure.getString(
+ mContentResolver, Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED);
boolean isInvertColorsEnabled = this.getIsInvertColorsEnabled(); | ||
|
||
if (mInvertColorsEnabled != isInvertColorsEnabled) { | ||
mInvertColorsEnabled = isInvertColorsEnabled; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
google-java-format
suggested changes:
@@ -162,2 +162,2 @@
- .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
- .emit(INVERT_COLORS_EVENT_NAME, mInvertColorsEnabled);
+ .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
+ .emit(INVERT_COLORS_EVENT_NAME, mInvertColorsEnabled);
ReactApplicationContext reactApplicationContext = getReactApplicationContextIfActiveOrWarn(); | ||
if (reactApplicationContext != null) { | ||
reactApplicationContext | ||
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
google-java-format
suggested changes:
@@ -167 +166,0 @@
-
Base commit: 866bf5f |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
Base commit: 118489f |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code analysis results:
google-java-format
found some issues. See https://github.com/google/google-java-format
@@ -95,6 +98,14 @@ private boolean getIsReduceMotionEnabledValue() { | |||
return value != null && value.equals("0.0"); | |||
} | |||
|
|||
@TargetApi(Build.VERSION_CODES.LOLLIPOP) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
google-java-format
suggested changes:
@@ -103,2 +103,3 @@
- String value = Settings.Secure.getString(
- mContentResolver, Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED);
+ String value =
+ Settings.Secure.getString(
+ mContentResolver, Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED);
|
||
if (mInvertColorsEnabled != isInvertColorsEnabled) { | ||
mInvertColorsEnabled = isInvertColorsEnabled; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
google-java-format
suggested changes:
@@ -161,2 +162,2 @@
- .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
- .emit(INVERT_COLORS_EVENT_NAME, mInvertColorsEnabled);
+ .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
+ .emit(INVERT_COLORS_EVENT_NAME, mInvertColorsEnabled);
Hey! Thanks so much for working on this, this is great! I'm going to tag in @blavalla to check the Android code. Please also fix the lint related changes when you can, since we'll need those fixed to merge! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Android code looks good to me. Just be sure to follow the spacing that the bot suggested to keep things consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code analysis results:
google-java-format
found some issues. See https://github.com/google/google-java-format
@@ -95,6 +98,15 @@ private boolean getIsReduceMotionEnabledValue() { | |||
return value != null && value.equals("0.0"); | |||
} | |||
|
|||
@TargetApi(Build.VERSION_CODES.LOLLIPOP) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
google-java-format
suggested changes:
@@ -103 +103 @@
- String value =
+ String value =
@kacieb has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay here, I didn't realize there was a gap here at first!
Let me know if you have any questions for how to implement this. The approach taken by reduce motion should be exactly what you need to follow here.
...roid/src/main/java/com/facebook/react/modules/accessibilityinfo/AccessibilityInfoModule.java
Show resolved
Hide resolved
Sorry, for the really late update. I don't want to make excuses, but I've had a really busy last few months and haven't had a moment to look here. @blavalla |
@@ -58,6 +58,7 @@ public void onChange(boolean selfChange) { | |||
public void onChange(boolean selfChange, Uri uri) { | |||
if (getReactApplicationContext().hasActiveCatalystInstance()) { | |||
AccessibilityInfoModule.this.updateAndSendReduceMotionChangeEvent(); | |||
AccessibilityInfoModule.this.updateAndSendInvertColorsChangeEvent(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't going to work as part of the same observer.
The way these observers work is that the URI passed into them is a reference to the specific setting changed, and this one is being trigged on Settings.Global.getUriFor(Settings.Global.TRANSITION_ANIMATION_SCALE);
(line 175 of this file), which is the URI for the animation_scale setting, not the display inversion setting.
You'll instead either need to make a second ContentObserver, or use the same observer as you have done, but add a check for the URI in the onChange method and only fire the update method associated with the URI that has triggered it. Whichever approach you opt for you'll also still need to call registerContentObserver with your new URI on line 176 like this:
mContentResolver.registerContentObserver(Settings.Secure.getUriFor(Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED), false, YOUR_CONTENT_RESOLVER_HERE);
Let me know if any of this needs any clarification!
No problem on the timing, whenever you have time to work on this, it's appreciated! I've commented with one change above. Let me know if anything needs any clarification! |
Everything is clear. Thank you for the detailed information. I'll work on this today |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code analysis results:
google-java-format
found some issues. See https://github.com/google/google-java-format
} | ||
} | ||
} | ||
|
||
@Override | ||
@TargetApi(Build.VERSION_CODES.LOLLIPOP) | ||
public void onHostResume() { | ||
mAccessibilityManager.addTouchExplorationStateChangeListener( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
google-java-format
suggested changes:
@@ -191 +191,2 @@
- Uri invertColorsUri = Settings.Secure.getUriFor(Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED);
+ Uri invertColorsUri =
+ Settings.Secure.getUriFor(Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED);
} | ||
} | ||
} | ||
|
||
@Override | ||
@TargetApi(Build.VERSION_CODES.LOLLIPOP) | ||
public void onHostResume() { | ||
mAccessibilityManager.addTouchExplorationStateChangeListener( | ||
mTouchExplorationStateChangeListener); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
google-java-format
suggested changes:
@@ -193 +194,2 @@
- mContentResolver.registerContentObserver(invertColorsUri, false, accessibilityDisplayInversionObserver);
+ mContentResolver.registerContentObserver(
+ invertColorsUri, false, accessibilityDisplayInversionObserver);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fixes, this looks great!
@kacieb has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
What about this PR. It's seems to be approved but for some reason not merged |
After years - I've run google java format on requested files 😅 |
|
|
Due to the conflicts and number of version that were released since I've sent my pr for the first time - I've closed the pr and I'll submit a new one from more recent |
Summary
This PR enables
isInvertColorsEnabled()
ofAccessibilityInfo
for Android.That setting is queried using the Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED property.
https://developer.android.com/reference/android/provider/Settings.Secure#ACCESSIBILITY_DISPLAY_INVERSION_ENABLED
Changelog
[Android] [Added] -
isInvertColorsEnabled()
ofAccessibilityInfo
Test Plan
Enable and disable color inversion setting in device/emulator accessibility settings and check if property getter updates with a new value.