@@ -57,6 +57,19 @@ public Keyboard(AppCompatActivity activity, boolean resizeOnFullScreen) {
5757 FrameLayout content = activity .getWindow ().getDecorView ().findViewById (android .R .id .content );
5858 rootView = content .getRootView ();
5959
60+ ViewCompat .setOnApplyWindowInsetsListener (
61+ rootView ,
62+ (v , insets ) -> {
63+ boolean showingKeyboard = ViewCompat .getRootWindowInsets (rootView ).isVisible (WindowInsetsCompat .Type .ime ());
64+
65+ if (showingKeyboard && resizeOnFullScreen ) {
66+ possiblyResizeChildOfContent (true );
67+ }
68+
69+ return insets ;
70+ }
71+ );
72+
6073 ViewCompat .setWindowInsetsAnimationCallback (
6174 rootView ,
6275 new WindowInsetsAnimationCompat .Callback (WindowInsetsAnimationCompat .Callback .DISPATCH_MODE_STOP ) {
@@ -142,38 +155,9 @@ private void possiblyResizeChildOfContent(boolean keyboardShown) {
142155 private int computeUsableHeight () {
143156 Rect r = new Rect ();
144157 mChildOfContent .getWindowVisibleDisplayFrame (r );
145- if (shouldApplyEdgeToEdgeAdjustments ()) {
146- WindowInsetsCompat insets = ViewCompat .getRootWindowInsets (rootView );
147- if (insets != null ) {
148- int systemBars = insets .getInsets (WindowInsetsCompat .Type .systemBars ()).bottom ;
149- if (systemBars > 0 ) {
150- return r .bottom + systemBars ;
151- }
152- }
153- }
154-
155158 return isOverlays () ? r .bottom : r .height ();
156159 }
157160
158- private boolean shouldApplyEdgeToEdgeAdjustments () {
159- var adjustMarginsForEdgeToEdge = this .bridge == null ? "auto" : this .bridge .getConfig ().adjustMarginsForEdgeToEdge ();
160- if (adjustMarginsForEdgeToEdge .equals ("force" )) { // Force edge-to-edge adjustments regardless of app settings
161- return true ;
162- } else if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .VANILLA_ICE_CREAM && adjustMarginsForEdgeToEdge .equals ("auto" )) { // Auto means that we need to check the app's edge-to-edge preference
163- TypedValue value = new TypedValue ();
164- boolean optOutAttributeExists = activity
165- .getTheme ()
166- .resolveAttribute (android .R .attr .windowOptOutEdgeToEdgeEnforcement , value , true );
167-
168- if (!optOutAttributeExists ) { // Default is to apply edge to edge
169- return true ;
170- } else {
171- return value .data == 0 ;
172- }
173- }
174- return false ;
175- }
176-
177161 @ SuppressWarnings ("deprecation" )
178162 private boolean isOverlays () {
179163 final Window window = activity .getWindow ();
0 commit comments