Skip to content
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

add getRecommendedTimeoutMillis to AccessibilityInfo #31063

Conversation

grgr-dkrk
Copy link
Contributor

Summary

resolve #30866

This PR is for using getRecommendedTimeoutMillis with React Native, which is available on Android 10 and above.
This allows the Android "Time to take action (Accessibility timeout)" setting to be reflected in the app.

Changelog

[Android] [Added] - Add getRecommendedTimeoutMillis to AccessibilityInfo

Test Plan

I couldn't find any tests at the code level, so I tested them on my Android device.


Android 10 (Pixel4a)

Settings

Set the timeout to 1 minute on the settings screen.

App

The baseline timeout is 3000 ms, but the result of `getRecommendedTimeoutMillis` returns 60000 ms.


Android 7, iOS(Simulator)

Return the original timeout.
Return the original timeout on Android 7.

Return the original timeout on iOS simulator.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 26, 2021
@analysis-bot
Copy link

analysis-bot commented Feb 26, 2021

Platform Engine Arch Size (bytes) Diff
ios - universal n/a --

Base commit: ac7ba3e

Copy link

@analysis-bot analysis-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code analysis results:

break;
default:
break;
}

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:

@@ -215 +215,2 @@
-    mRecommendedTimeout = mAccessibilityManager.getRecommendedTimeoutMillis((int)originalTimeout, flag);
+    mRecommendedTimeout =
+        mAccessibilityManager.getRecommendedTimeoutMillis((int) originalTimeout, flag);

@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,903,190 -48,577
android hermes armeabi-v7a 8,400,306 -40,286
android hermes x86 9,392,155 -53,138
android hermes x86_64 9,336,412 -51,435
android jsc arm64-v8a 10,637,144 -46,850
android jsc armeabi-v7a 10,117,360 -38,550
android jsc x86 10,687,603 -51,426
android jsc x86_64 11,272,115 -49,735

Base commit: ac7ba3e

@amarlette
Copy link

Hey, @grgr-dkrk thank you for this PR to help make React Native more accessible! I've added you to our project board. Apologies for this not getting added earlier.

*/
getRecommendedTimeoutMillis: function(
originalTimeout: number,
uiContentFlags: AccessibilityUiContentFlagsTypes,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we should bother to surface this param in the javascript API.

Under the hood it's actually not doing anything, no matter which flag you pass in, the same value comes back. Looking through the Android source, it seems like they originally intended to have two user settings for timings, one for interactive elements, and one for static elements, but at some point this was dropped in favor of a single setting that just sets both values behind the scenes. These flags seem like a vestigial remnant of that original idea, and will likely be removed in a later API version.

@kacieb, does RN generally have a standard for when we should match a platform API strictly versus going with a simpler API if both options have the same end result?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commenting again to request changes.

@facebook-github-bot
Copy link
Contributor

@nadiia has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

*/
getRecommendedTimeoutMillis: function(
originalTimeout: number,
uiContentFlags: AccessibilityUiContentFlagsTypes,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commenting again to request changes.

@blavalla
Copy link
Contributor

blavalla commented Apr 2, 2021

Sorry for the comment churn here, @nadiia is implementing the changes I requested, so no need to any more work @grgr-dkrk! Thanks again for the PR.

@facebook-github-bot
Copy link
Contributor

@nadiia merged this pull request in d29a7e7.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Apr 6, 2021
@nadiia
Copy link

nadiia commented Apr 6, 2021

@grgr-dkrk Thank you for the contribution! Would you be open to add a PR for documenting getRecommendedTimeoutMillis in here?

@amarlette
Copy link

Thank you @grgr-dkrk for this contribution! I would like to give you a shout-out on Twitter and include you in our end-of-month issues update for your contribution. Do you have a Twitter we can tag?

@grgr-dkrk
Copy link
Contributor Author

@blavalla @amarlette @nadiia Thank you for your support!

I have submitted a PR of documentation on this feature.
facebook/react-native-website#2581

My Twitter account is [@]dkrk0901, Thanks.

@nadiia nadiia removed their assignment Sep 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accessibility CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Android: Accessibility timeout setting
6 participants