Skip to content

Commit a6e2a05

Browse files
authored
fix: blank space above the keyboard in chat (#1547)
1 parent 2609cdf commit a6e2a05

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

cordova/cordova-plugin-ionic-keyboard/src/android/CDVIonicKeyboard.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
import android.view.DisplayCutout;
3434

3535
import androidx.core.view.WindowInsetsCompat;
36+
import androidx.core.view.OnApplyWindowInsetsListener;
37+
import androidx.core.view.ViewCompat;
3638

3739

3840

@@ -132,8 +134,9 @@ public void onGlobalLayout() {
132134

133135
if (isKeyboardVisible){
134136
float keyboardHeight = insets.getInsets(WindowInsetsCompat.Type.ime()).bottom / density;
137+
float systemBarsHeight = insets.getInsets(WindowInsetsCompat.Type.systemBars()).bottom / density;
135138

136-
pixelHeightDiff = (int) keyboardHeight;
139+
pixelHeightDiff = (int) Math.max(0, keyboardHeight - systemBarsHeight);
137140
}
138141

139142

@@ -176,6 +179,12 @@ private int computeUsableHeight() {
176179
}
177180
};
178181

182+
if (Build.VERSION.SDK_INT >= 30) {
183+
ViewCompat.setOnApplyWindowInsetsListener((View) webView.getView(), (v, insets) -> {
184+
return insets;
185+
});
186+
}
187+
179188
mChildOfContent = content.getChildAt(0);
180189
rootView.getViewTreeObserver().addOnGlobalLayoutListener(list);
181190
frameLayoutParams = (FrameLayout.LayoutParams) mChildOfContent.getLayoutParams();

0 commit comments

Comments
 (0)