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

Only Use WindowInsets for Keyboard Events on Android 11+ #35897

Closed
wants to merge 1 commit into from

Conversation

NickGerleman
Copy link
Contributor

Summary:
Fixes #35894

Android 11 added native support for querying whether the IME is present along with its size, as part of the WindowInsets API. D38500859 (1e48274) changed our logic for Android keyboard events to use it when available, fixing a longstanding issues where we could not reliably tell where the keyboard was open depending on softInputMode.

An androidx library WindowInsetsCompat aimed to backport some of the functionality to older versions of Android, with the same API, documenting IME queries to work down to API level 23 (Android 6). I used this, so that we would be able to remove our own logic for detecting keyboard insets once we supported 23+.

From an issue report, WindowInsetsCompat is not accurately returning whether the IME is open on at least Android 9. So this change makes it so we only use WindowInsets methods when they are provided by the OS (a tested golden path), and otherwise use the previously working heuristics on anything older.

Changelog:
[Android][Fixed] - Do not use WindowInsetsCompat for Keyboard Events

Differential Revision: D42604176

Summary:
Fixes facebook#35894

Android 11 added native support for querying whether the IME is present along with its size, as part of the WindowInsets API. D38500859 (facebook@1e48274) changed our logic for Android keyboard events to use it when available, fixing a longstanding issues where we could not reliably tell where the keyboard was open depending on softInputMode.

An androidx library WindowInsetsCompat aimed to backport some of the functionality to older versions of Android, with the same API, documenting IME queries to work down to API level 23 (Android 6). I used this, so that we would be able to remove our own logic for detecting keyboard insets once we supported 23+.

From an issue report, WindowInsetsCompat is not accurately returning whether the IME is open on at least Android 9. So this change makes it so we only use WindowInsets methods when they are provided by the OS (a tested golden path), and otherwise use the previously working heuristics on anything older.

Changelog:
[Android][Fixed] - Do not use WindowInsetsCompat for Keyboard Events

Differential Revision: D42604176

fbshipit-source-id: 123bd28f57898f186f2ca065b95f6995e67c0c1f
@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner fb-exported labels Jan 19, 2023
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D42604176

@react-native-bot react-native-bot added Bug Platform: Android Android applications. labels Jan 19, 2023
@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,465,209 -152
android hermes armeabi-v7a 7,785,737 -158
android hermes x86 8,938,325 -152
android hermes x86_64 8,796,740 -162
android jsc arm64-v8a 9,650,764 +142
android jsc armeabi-v7a 8,385,207 +133
android jsc x86 9,712,982 +130
android jsc x86_64 10,190,119 +131

Base commit: 4cdc2c4
Branch: main

@NickGerleman NickGerleman changed the title Do not use WindowInsetsCompat for Keyboard Events Only Use WindowInsets for Keyboard Events on Android 11+ Jan 19, 2023
@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Jan 19, 2023
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 32f5487.

kelset pushed a commit that referenced this pull request Jan 30, 2023
Summary:
Pull Request resolved: #35897

Fixes #35894

Android 11 added native support for querying whether the IME is present along with its size, as part of the WindowInsets API. D38500859 (1e48274) changed our logic for Android keyboard events to use it when available, fixing a longstanding issues where we could not reliably tell where the keyboard was open depending on softInputMode.

An androidx library WindowInsetsCompat aimed to backport some of the functionality to older versions of Android, with the same API, documenting IME queries to work down to API level 23 (Android 6). I used this, so that we would be able to remove our own logic for detecting keyboard insets once we supported 23+.

From an issue report, WindowInsetsCompat is not accurately returning whether the IME is open on at least Android 9. So this change makes it so we only use WindowInsets methods when they are provided by the OS (a tested golden path), and otherwise use the previously working heuristics on anything older.

Changelog:
[Android][Fixed] - Do not use WindowInsetsCompat for Keyboard Events

Reviewed By: christophpurrer

Differential Revision: D42604176

fbshipit-source-id: da6a0bbc34c36f8e6d4e4ac07bc96da048fd6aa8
OlimpiaZurek pushed a commit to OlimpiaZurek/react-native that referenced this pull request May 22, 2023
Summary:
Pull Request resolved: facebook#35897

Fixes facebook#35894

Android 11 added native support for querying whether the IME is present along with its size, as part of the WindowInsets API. D38500859 (facebook@1e48274) changed our logic for Android keyboard events to use it when available, fixing a longstanding issues where we could not reliably tell where the keyboard was open depending on softInputMode.

An androidx library WindowInsetsCompat aimed to backport some of the functionality to older versions of Android, with the same API, documenting IME queries to work down to API level 23 (Android 6). I used this, so that we would be able to remove our own logic for detecting keyboard insets once we supported 23+.

From an issue report, WindowInsetsCompat is not accurately returning whether the IME is open on at least Android 9. So this change makes it so we only use WindowInsets methods when they are provided by the OS (a tested golden path), and otherwise use the previously working heuristics on anything older.

Changelog:
[Android][Fixed] - Do not use WindowInsetsCompat for Keyboard Events

Reviewed By: christophpurrer

Differential Revision: D42604176

fbshipit-source-id: da6a0bbc34c36f8e6d4e4ac07bc96da048fd6aa8
@cipolleschi cipolleschi mentioned this pull request Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner Platform: Android Android applications.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[0.71.0] [ANDROID 9] Keyboard events do not fire on Android 9
4 participants