erisu commented on code in PR #1817: URL: https://github.com/apache/cordova-android/pull/1817#discussion_r2193989299
########## framework/src/org/apache/cordova/CordovaActivity.java: ########## @@ -180,26 +194,56 @@ protected void loadConfig() { //Suppressing warnings in AndroidStudio @SuppressWarnings({"deprecation", "ResourceType"}) protected void createViews() { - //Why are we setting a constant as the ID? This should be investigated - appView.getView().setId(100); - appView.getView().setLayoutParams(new FrameLayout.LayoutParams( + WindowCompat.setDecorFitsSystemWindows(getWindow(), false); + + // Root FrameLayout + FrameLayout rootLayout = new FrameLayout(this); + rootLayout.setLayoutParams(new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.MATCH_PARENT)); + ViewGroup.LayoutParams.MATCH_PARENT + )); - setContentView(appView.getView()); + // WebView + View webView = appView.getView(); + webView.setLayoutParams(new FrameLayout.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT + )); + + // Create StatusBar view that will overlay the top inset + View statusBarView = new View(this); + statusBarView.setTag("statusBarView"); + + // Handle Window Insets + ViewCompat.setOnApplyWindowInsetsListener(rootLayout, (v, insets) -> { + Insets bars = insets.getInsets( + WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout() + ); + + boolean isStatusBarVisible = statusBarView.getVisibility() != View.GONE; + int top = isStatusBarVisible && !canEdgeToEdge && !isFullScreen ? bars.top : 0; + int bottom = !canEdgeToEdge && !isFullScreen ? bars.bottom : 0; + + FrameLayout.LayoutParams webViewParams = (FrameLayout.LayoutParams) webView.getLayoutParams(); + webViewParams.setMargins(bars.left, top, bars.right, bottom); + webView.setLayoutParams(webViewParams); + + FrameLayout.LayoutParams statusBarParams = new FrameLayout.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, + top, + Gravity.TOP + ); + statusBarView.setLayoutParams(statusBarParams); + + return WindowInsetsCompat.CONSUMED; Review Comment: Updated this to return the `insets`. https://github.com/apache/cordova-android/pull/1817/commits/2c96c1f2a1bf5a8ad355ec25fd20c971c9760abb -- 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: issues-unsubscr...@cordova.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org