@capawesome/capacitor-android-edge-to-edge-support 8.0.6 → 8.0.8
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
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
package io.capawesome.capacitorjs.plugins.androidedgetoedgesupport;
|
|
2
2
|
|
|
3
3
|
import android.graphics.Color;
|
|
4
|
-
import android.os.Build;
|
|
5
4
|
import android.view.Gravity;
|
|
6
5
|
import android.view.View;
|
|
7
6
|
import android.view.ViewGroup;
|
|
@@ -77,60 +76,42 @@ public class EdgeToEdge {
|
|
|
77
76
|
|
|
78
77
|
private void applyInsets() {
|
|
79
78
|
View view = plugin.getBridge().getWebView();
|
|
80
|
-
// Get parent view
|
|
81
|
-
ViewGroup parent = (ViewGroup) view.getParent();
|
|
82
79
|
// Set insets
|
|
83
80
|
WindowInsetsCompat currentInsets = ViewCompat.getRootWindowInsets(view);
|
|
84
81
|
if (currentInsets != null) {
|
|
85
|
-
|
|
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);
|
|
82
|
+
applyInsetsInternal(view, currentInsets);
|
|
104
83
|
}
|
|
105
84
|
// Set listener
|
|
106
85
|
ViewCompat.setOnApplyWindowInsetsListener(view, (v, windowInsets) -> {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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;
|
|
86
|
+
applyInsetsInternal(v, windowInsets);
|
|
87
|
+
return WindowInsetsCompat.CONSUMED;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
126
90
|
|
|
127
|
-
|
|
91
|
+
private void applyInsetsInternal(View view, WindowInsetsCompat currentInsets) {
|
|
92
|
+
Insets systemBarsInsets = currentInsets.getInsets(WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout());
|
|
93
|
+
Insets imeInsets = currentInsets.getInsets(WindowInsetsCompat.Type.ime());
|
|
94
|
+
boolean keyboardVisible = currentInsets.isVisible(WindowInsetsCompat.Type.ime());
|
|
95
|
+
// When keyboard is visible, don't apply bottom margin to avoid double-counting
|
|
96
|
+
// (the system already resizes the window for the keyboard)
|
|
97
|
+
int bottomMargin = keyboardVisible ? 0 : Math.max(imeInsets.bottom, systemBarsInsets.bottom);
|
|
128
98
|
|
|
129
|
-
|
|
130
|
-
|
|
99
|
+
ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
|
|
100
|
+
mlp.bottomMargin = bottomMargin;
|
|
101
|
+
// Apply top margin when edge-to-edge is active. On Android 15+ it is always enforced.
|
|
102
|
+
// On older versions, use the system content view's top padding only as a heuristic that
|
|
103
|
+
// the top inset may already be handled elsewhere (for example by decor fitting or another
|
|
104
|
+
// insets/padding adjustment), rather than as a guaranteed signal of decorFitsSystemWindows.
|
|
105
|
+
View contentView = plugin.getActivity().findViewById(android.R.id.content);
|
|
106
|
+
boolean topInsetLikelyHandledBySystem =
|
|
107
|
+
contentView != null && contentView.getPaddingTop() >= systemBarsInsets.top && systemBarsInsets.top > 0;
|
|
108
|
+
mlp.topMargin = topInsetLikelyHandledBySystem ? 0 : systemBarsInsets.top;
|
|
109
|
+
mlp.leftMargin = systemBarsInsets.left;
|
|
110
|
+
mlp.rightMargin = systemBarsInsets.right;
|
|
111
|
+
view.setLayoutParams(mlp);
|
|
131
112
|
|
|
132
|
-
|
|
133
|
-
|
|
113
|
+
// Update color overlays based on current insets
|
|
114
|
+
updateColorOverlays(systemBarsInsets);
|
|
134
115
|
}
|
|
135
116
|
|
|
136
117
|
private void removeInsets() {
|
package/package.json
CHANGED