PedroRF123154 opened a new issue, #1848:
URL: https://github.com/apache/cordova-android/issues/1848

   # Bug Report
   
   ## Problem
   
   ### What is expected to happen?
   When using android:windowSoftInputMode="adjustResize" and 
env(safe-area-inset-top) in a Cordova app targeting targetSdkVersion 35, the 
app should behave as before:
   
       The keyboard should resize the WebView content properly.
   
       The env(safe-area-inset-top) variable should apply correct top padding 
to accommodate notches/status bar.
   
   
   ### What does actually happen?
   
   When targeting SDK 35 (Android 15):
   
       The keyboard behavior (adjustResize) no longer works correctly without 
applying manual WindowInsets handling.
   
       The CSS variable env(safe-area-inset-top) returns 0px or is ignored in 
Android WebView, resulting in headers and content being overlapped by the 
status bar or notch.
   
   A manual workaround using ViewTreeObserver and JavaScript is required to 
restore proper layout and safe-area behavior.
   
   ## Information
   <!-- Include all relevant information that might help understand and 
reproduce the problem -->
   
   When targeting SDK 35 (Android 15):
   
       The keyboard behavior (adjustResize) no longer works correctly without 
applying manual WindowInsets handling.
   
       The CSS variable env(safe-area-inset-top) returns 0px or is ignored in 
Android WebView, resulting in headers and content being overlapped by the 
status bar or notch.
   
   A manual workaround using ViewTreeObserver and JavaScript is required to 
restore proper layout and safe-area behavior.
   
   ### Command or Code
   <!-- What command or code is needed to reproduce the problem? -->
   
   <activity
       android:name=".MainActivity"
       android:windowSoftInputMode="adjustResize"
       android:theme="@style/Theme.AppCompat.Light.NoActionBar">
   
   ### Environment, Platform, Device
   <!-- In what environment, on what platform or on which device are you 
experiencing the issue? -->
   
   Environment: Cordova + Android
   
   Platform: Android 15 (API 35)
   
   Devices: Multiple (Pixel, Samsung, Xiaomi)
   
   Emulator and physical devices tested
   
   ### Version information
   <!-- 
   What are relevant versions you are using?
   For example:
   Cordova: Cordova CLI, Cordova Platforms, Cordova Plugins 
   Other Frameworks: Ionic Framework and CLI version
   Operating System, Android Studio, Xcode etc.
   -->
   
   ### Solution
   1. Add this Java class to your project: SoftInputAssist.java
   
   This helper listens for keyboard changes and manually adjusts the layout:
   ```java
   ** Open SoftInputAssist.java **
   package mi.app.cordova;
   
   import android.app.Activity;
   import android.graphics.Rect;
   import android.view.View;
   import android.view.ViewTreeObserver;
   
   public class SoftInputAssist {
       private final View rootView;
       private final View contentView;
       private int previousHeight;
   
       public SoftInputAssist(Activity activity) {
           rootView = activity.getWindow().getDecorView();
           contentView = activity.findViewById(android.R.id.content);
   
           rootView.getViewTreeObserver().addOnGlobalLayoutListener(() -> {
               Rect r = new Rect();
               rootView.getWindowVisibleDisplayFrame(r);
               int heightDiff = rootView.getHeight() - (r.bottom - r.top);
   
               if (previousHeight != heightDiff) {
                   previousHeight = heightDiff;
                   contentView.setPadding(0, 0, 0, heightDiff);
               }
           });
       }
   }
   ** Close SoftInputAssist.java **
   
   2. Call SoftInputAssist from MainActivity.java
   
   Modify your MainActivity like this:
   ```java
   ** Open MainActivity.java **
   package mi.app.cordova;
   
   import android.os.Bundle;
   import org.apache.cordova.*;
   
   public class MainActivity extends CordovaActivity {
       private SoftInputAssist softInputAssist;
   
       @Override
       public void onCreate(Bundle savedInstanceState) {
           super.onCreate(savedInstanceState);
   
           // enable Cordova apps to be started in the background
           Bundle extras = getIntent().getExtras();
           if (extras != null && extras.getBoolean("cdvStartInBackground", 
false)) {
               moveTaskToBack(true);
           }
   
           // Carga el contenido principal de Cordova
           loadUrl(launchUrl);
   
           // Inicializa el listener para el teclado
           softInputAssist = new SoftInputAssist(this);
       }
   }
   ** Close MainActivity.java **
   ## Checklist
   <!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
   
   - [x] I searched for existing GitHub issues
   - [ x] I updated all Cordova tooling to most recent version
   - [ x] I included all the necessary information above
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to