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

fix(android): incorrect keyboard height #2924

Merged
merged 3 commits into from
Jun 10, 2020

Conversation

duryno
Copy link
Contributor

@duryno duryno commented May 14, 2020

At the moment, the Keyboard plugin returns incorrect keyboard height on Android phones with cutouts. This fixes it by subtracting the size of the bottom cutout from the total screen height.

I also removed obsolete code ensuring backwards-compatibility with Android SDK versions <21 since Capacitor doesn't support these versions.

@jcesarmobile
Copy link
Member

how can I reproduce this?
I don't have any device with cutout, but if I simulate it in a real device or simulator the keyboard size doesn't change with your code

@duryno
Copy link
Contributor Author

duryno commented May 19, 2020

how can I reproduce this?
I don't have any device with cutout, but if I simulate it in a real device or simulator the keyboard size doesn't change with your code

Hey!

You can reproduce this with a simulated cutout by looking at the value of pixelHeightDiff in native code or event.keyboardHeight that you get via e.g. keyboardWillShow event in javascript.

For example, in Pixel 2 simulator with a simulated 'tall cutout' I get keyboardHeight = -48 when the keyboard is closed (I expect it to be 0 in this case) and keyboardHeight = 234 when the keyboard is open. With the fix in this PR I get 0 when closed and 282 when the keyboard is open. The behaviour is the same on my Samsung Galaxy Note 10 with a real cutout.

To further clarify, it's this value I'm referring to, not the height of the actual keyboard (which is unrelated). Hope this makes it clear but do let me know if you need more information.

Copy link
Member

@jcesarmobile jcesarmobile left a comment

Choose a reason for hiding this comment

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

just a minor comment
other than that, looks good to me

@jcesarmobile
Copy link
Member

I've committed the changes since we are doing a release today and wanted to include this fix.

@jcesarmobile jcesarmobile merged commit 035f74e into ionic-team:master Jun 10, 2020
@duryno duryno deleted the android-keyboard-fix branch June 11, 2020 05:20
tzappia added a commit to tzappia/cordova-plugin-ionic-keyboard that referenced this pull request Jun 2, 2021
molinet added a commit to molinet/cordova-plugin-ionic-keyboard that referenced this pull request Jul 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants