Chuckytuh commented on code in PR #1817:
URL: https://github.com/apache/cordova-android/pull/1817#discussion_r2415232846


##########
framework/src/org/apache/cordova/CordovaActivity.java:
##########
@@ -184,26 +198,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);

Review Comment:
   This got answered on 
https://github.com/apache/cordova-android/pull/1847#pullrequestreview-3315768670
 



-- 
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