@capawesome/capacitor-android-edge-to-edge-support 8.0.2 → 8.0.4

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.
@@ -28,19 +28,27 @@ public class EdgeToEdge {
28
28
  @Nullable
29
29
  private View statusBarOverlay;
30
30
 
31
+ private int currentNavigationBarColor;
32
+
33
+ private int currentStatusBarColor;
34
+
31
35
  public EdgeToEdge(@NonNull EdgeToEdgePlugin plugin, @NonNull EdgeToEdgeConfig config) {
32
36
  this.config = config;
33
37
  this.plugin = plugin;
34
- // Create color overlays
35
- createColorOverlays();
36
- // Set colors from config
37
- setStatusBarColor(config.getStatusBarColor());
38
- setNavigationBarColor(config.getNavigationBarColor());
39
- // Apply insets to enable the edge-to-edge feature
40
- applyInsets();
38
+ // Store initial colors from config
39
+ this.currentStatusBarColor = config.getStatusBarColor();
40
+ this.currentNavigationBarColor = config.getNavigationBarColor();
41
+ // Enable edge-to-edge
42
+ enable();
41
43
  }
42
44
 
43
45
  public void enable() {
46
+ // Create color overlays if they don't exist
47
+ createColorOverlays();
48
+ // Restore previously set colors
49
+ setStatusBarColor(currentStatusBarColor);
50
+ setNavigationBarColor(currentNavigationBarColor);
51
+ // Apply insets
44
52
  applyInsets();
45
53
  }
46
54
 
@@ -79,10 +87,12 @@ public class EdgeToEdge {
79
87
  );
80
88
  Insets imeInsets = currentInsets.getInsets(WindowInsetsCompat.Type.ime());
81
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;
82
92
 
83
93
  ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
84
94
 
85
- mlp.bottomMargin = keyboardVisible ? imeInsets.bottom : systemBarsInsets.bottom;
95
+ mlp.bottomMargin = useImeInsets ? imeInsets.bottom : systemBarsInsets.bottom;
86
96
  mlp.topMargin = systemBarsInsets.top;
87
97
  mlp.leftMargin = systemBarsInsets.left;
88
98
  mlp.rightMargin = systemBarsInsets.right;
@@ -101,11 +111,13 @@ public class EdgeToEdge {
101
111
  // Retrieve keyboard (IME) insets
102
112
  Insets imeInsets = windowInsets.getInsets(WindowInsetsCompat.Type.ime());
103
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;
104
116
 
105
117
  ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
106
118
 
107
119
  // Apply the appropriate bottom inset: use keyboard inset if visible, else system bars inset
108
- mlp.bottomMargin = keyboardVisible ? imeInsets.bottom : systemBarsInsets.bottom;
120
+ mlp.bottomMargin = useImeInsets ? imeInsets.bottom : systemBarsInsets.bottom;
109
121
 
110
122
  // Set the other margins using system bars insets
111
123
  mlp.topMargin = systemBarsInsets.top;
@@ -169,12 +181,14 @@ public class EdgeToEdge {
169
181
  }
170
182
 
171
183
  private void setNavigationBarColor(int color) {
184
+ this.currentNavigationBarColor = color;
172
185
  if (navigationBarOverlay != null) {
173
186
  navigationBarOverlay.setBackgroundColor(color);
174
187
  }
175
188
  }
176
189
 
177
190
  private void setStatusBarColor(int color) {
191
+ this.currentStatusBarColor = color;
178
192
  if (statusBarOverlay != null) {
179
193
  statusBarOverlay.setBackgroundColor(color);
180
194
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capawesome/capacitor-android-edge-to-edge-support",
3
- "version": "8.0.2",
3
+ "version": "8.0.4",
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",