Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ public Keyboard(AppCompatActivity activity, boolean resizeOnFullScreen) {
rootView = content.getRootView();

ViewCompat.setOnApplyWindowInsetsListener(rootView, (v, insets) -> {
boolean showingKeyboard = ViewCompat.getRootWindowInsets(rootView).isVisible(WindowInsetsCompat.Type.ime());
WindowInsetsCompat rootInsets = ViewCompat.getRootWindowInsets(rootView);
if (rootInsets == null) return insets;
boolean showingKeyboard = rootInsets.isVisible(WindowInsetsCompat.Type.ime());

if (showingKeyboard && resizeOnFullScreen) {
possiblyResizeChildOfContent(true);
if (resizeOnFullScreen) {
possiblyResizeChildOfContent(showingKeyboard);
}

return insets;
Expand All @@ -85,8 +87,9 @@ public WindowInsetsAnimationCompat.BoundsCompat onStart(
@NonNull WindowInsetsAnimationCompat animation,
@NonNull WindowInsetsAnimationCompat.BoundsCompat bounds
) {
boolean showingKeyboard = ViewCompat.getRootWindowInsets(rootView).isVisible(WindowInsetsCompat.Type.ime());
WindowInsetsCompat insets = ViewCompat.getRootWindowInsets(rootView);
if (insets == null) return super.onStart(animation, bounds);
boolean showingKeyboard = insets.isVisible(WindowInsetsCompat.Type.ime());
int imeHeight = insets.getInsets(WindowInsetsCompat.Type.ime()).bottom;
DisplayMetrics dm = activity.getResources().getDisplayMetrics();
final float density = dm.density;
Expand All @@ -106,8 +109,9 @@ public WindowInsetsAnimationCompat.BoundsCompat onStart(
@Override
public void onEnd(@NonNull WindowInsetsAnimationCompat animation) {
super.onEnd(animation);
boolean showingKeyboard = ViewCompat.getRootWindowInsets(rootView).isVisible(WindowInsetsCompat.Type.ime());
WindowInsetsCompat insets = ViewCompat.getRootWindowInsets(rootView);
if (insets == null) return;
boolean showingKeyboard = insets.isVisible(WindowInsetsCompat.Type.ime());
int imeHeight = insets.getInsets(WindowInsetsCompat.Type.ime()).bottom;
DisplayMetrics dm = activity.getResources().getDisplayMetrics();
final float density = dm.density;
Expand Down