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

[Android][Keyboard] More consistent inequality check to compute keyboard state #5874

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void updateHeight(WindowInsetsCompat insets) {
int systemBarBottomInset = insets.getInsets(SYSTEM_BAR_TYPE_MASK).bottom;
int keyboardHeightDip = contentBottomInset - systemBarBottomInset;
int keyboardHeight = (int) PixelUtil.toDIPFromPixel(Math.max(0, keyboardHeightDip));
if (keyboardHeight == 0 && mState == KeyboardState.OPEN) {
if (keyboardHeight <= 0 && mState == KeyboardState.OPEN) {
/*
When the keyboard is being canceling, for one frame the insets show a keyboard height of 0,
causing a jump of the keyboard. We can avoid it by ignoring that frame and calling
Expand All @@ -38,15 +38,15 @@ public void onAnimationStart() {
if (mActiveTransitionCounter > 0) {
mState = mState == KeyboardState.OPENING ? KeyboardState.CLOSING : KeyboardState.OPENING;
} else {
mState = mHeight == 0 ? KeyboardState.OPENING : KeyboardState.CLOSING;
mState = mHeight <= 0 ? KeyboardState.OPENING : KeyboardState.CLOSING;
}
mActiveTransitionCounter++;
}

public void onAnimationEnd() {
mActiveTransitionCounter--;
if (mActiveTransitionCounter == 0) {
mState = mHeight == 0 ? KeyboardState.CLOSED : KeyboardState.OPEN;
mState = mHeight <= 0 ? KeyboardState.CLOSED : KeyboardState.OPEN;
}
}
}