@capawesome/capacitor-android-edge-to-edge-support 8.0.6 → 8.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -14,6 +14,10 @@ Capacitor plugin to support [edge-to-edge](https://developer.android.com/develop
14
14
 
15
15
  **Attention:** Despite its name, this plugin doesn't enable edge-to-edge mode by default. Instead, it preserves the traditional app behavior by applying proper insets to the webview, preventing Android's edge-to-edge changes from affecting apps that haven't been designed to support it.
16
16
 
17
+ ## Newsletter
18
+
19
+ Stay up to date with the latest news and updates about the Capawesome, Capacitor, and Ionic ecosystem by subscribing to our [Capawesome Newsletter](https://cloud.capawesome.io/newsletter/).
20
+
17
21
  ## Compatibility
18
22
 
19
23
  | Plugin Version | Capacitor Version | Status |
@@ -23,6 +27,21 @@ Capacitor plugin to support [edge-to-edge](https://developer.android.com/develop
23
27
 
24
28
  ## Installation
25
29
 
30
+ You can use our **AI-Assisted Setup** to install the plugin.
31
+ Add the [Capawesome Skills](https://github.com/capawesome-team/skills) to your AI tool using the following command:
32
+
33
+ ```bash
34
+ npx skills add capawesome-team/skills --skill capacitor-plugins
35
+ ```
36
+
37
+ Then use the following prompt:
38
+
39
+ ```
40
+ Use the `capacitor-plugins` skill from `capawesome-team/skills` to install the `@capawesome/capacitor-android-edge-to-edge-support` plugin in my project.
41
+ ```
42
+
43
+ If you prefer **Manual Setup**, install the plugin by running the following commands and follow the platform-specific instructions below:
44
+
26
45
  ```bash
27
46
  npm install @capawesome/capacitor-android-edge-to-edge-support
28
47
  npx cap sync
@@ -77,60 +77,37 @@ public class EdgeToEdge {
77
77
 
78
78
  private void applyInsets() {
79
79
  View view = plugin.getBridge().getWebView();
80
- // Get parent view
81
- ViewGroup parent = (ViewGroup) view.getParent();
82
80
  // Set insets
83
81
  WindowInsetsCompat currentInsets = ViewCompat.getRootWindowInsets(view);
84
82
  if (currentInsets != null) {
85
- Insets systemBarsInsets = currentInsets.getInsets(
86
- WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout()
87
- );
88
- Insets imeInsets = currentInsets.getInsets(WindowInsetsCompat.Type.ime());
89
- boolean keyboardVisible = currentInsets.isVisible(WindowInsetsCompat.Type.ime());
90
- // Only use IME insets if keyboard is visible AND larger than system bars (handles external keyboard case)
91
- boolean useImeInsets = keyboardVisible && imeInsets.bottom > systemBarsInsets.bottom;
92
-
93
- ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
94
-
95
- mlp.bottomMargin = useImeInsets ? imeInsets.bottom : systemBarsInsets.bottom;
96
- mlp.topMargin = systemBarsInsets.top;
97
- mlp.leftMargin = systemBarsInsets.left;
98
- mlp.rightMargin = systemBarsInsets.right;
99
-
100
- view.setLayoutParams(mlp);
101
-
102
- // Update color overlays based on current insets
103
- updateColorOverlays(systemBarsInsets);
83
+ applyInsetsInternal(view, currentInsets);
104
84
  }
105
85
  // Set listener
106
86
  ViewCompat.setOnApplyWindowInsetsListener(view, (v, windowInsets) -> {
107
- // Retrieve system bars insets (for status/navigation bars)
108
- Insets systemBarsInsets = windowInsets.getInsets(
109
- WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout()
110
- );
111
- // Retrieve keyboard (IME) insets
112
- Insets imeInsets = windowInsets.getInsets(WindowInsetsCompat.Type.ime());
113
- boolean keyboardVisible = windowInsets.isVisible(WindowInsetsCompat.Type.ime());
114
- // Only use IME insets if keyboard is visible AND larger than system bars (handles external keyboard case)
115
- boolean useImeInsets = keyboardVisible && imeInsets.bottom > systemBarsInsets.bottom;
116
-
117
- ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
118
-
119
- // Apply the appropriate bottom inset: use keyboard inset if visible, else system bars inset
120
- mlp.bottomMargin = useImeInsets ? imeInsets.bottom : systemBarsInsets.bottom;
121
-
122
- // Set the other margins using system bars insets
123
- mlp.topMargin = systemBarsInsets.top;
124
- mlp.leftMargin = systemBarsInsets.left;
125
- mlp.rightMargin = systemBarsInsets.right;
87
+ applyInsetsInternal(v, windowInsets);
88
+ return WindowInsetsCompat.CONSUMED;
89
+ });
90
+ }
126
91
 
127
- v.setLayoutParams(mlp);
92
+ private void applyInsetsInternal(View view, WindowInsetsCompat currentInsets) {
93
+ Insets systemBarsInsets = currentInsets.getInsets(WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout());
94
+ Insets imeInsets = currentInsets.getInsets(WindowInsetsCompat.Type.ime());
95
+ boolean keyboardVisible = currentInsets.isVisible(WindowInsetsCompat.Type.ime());
96
+ // When keyboard is visible, don't apply bottom margin to avoid double-counting
97
+ // (the system already resizes the window for the keyboard)
98
+ int bottomMargin = keyboardVisible ? 0 : Math.max(imeInsets.bottom, systemBarsInsets.bottom);
128
99
 
129
- // Update color overlays based on current insets
130
- updateColorOverlays(systemBarsInsets);
100
+ ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
101
+ mlp.bottomMargin = bottomMargin;
102
+ // Only apply top margin on Android 15+ where edge-to-edge is enforced.
103
+ // On older versions, the system already positions content below the status bar.
104
+ mlp.topMargin = Build.VERSION.SDK_INT >= 35 ? systemBarsInsets.top : 0;
105
+ mlp.leftMargin = systemBarsInsets.left;
106
+ mlp.rightMargin = systemBarsInsets.right;
107
+ view.setLayoutParams(mlp);
131
108
 
132
- return WindowInsetsCompat.CONSUMED;
133
- });
109
+ // Update color overlays based on current insets
110
+ updateColorOverlays(systemBarsInsets);
134
111
  }
135
112
 
136
113
  private void removeInsets() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capawesome/capacitor-android-edge-to-edge-support",
3
- "version": "8.0.6",
3
+ "version": "8.0.7",
4
4
  "description": "Capacitor plugin to support edge-to-edge display on Android.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",