@capacitor/android 8.6.1-nightly-20261111T150738.0 → 8.6.1
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.
|
@@ -882,11 +882,24 @@ var nativeBridge = (function (exports) {
|
|
|
882
882
|
try {
|
|
883
883
|
if (typeof postToNative === 'function') {
|
|
884
884
|
let callbackId = '-1';
|
|
885
|
-
|
|
885
|
+
// native never answers removeListener nor sends `save: false` for a removed listener,
|
|
886
|
+
// so release those callbacks here, otherwise everything they capture is never freed
|
|
887
|
+
if (methodName === 'removeListener') {
|
|
888
|
+
callbacks.delete(options === null || options === void 0 ? void 0 : options.callbackId);
|
|
889
|
+
}
|
|
890
|
+
else if (methodName === 'removeAllListeners') {
|
|
891
|
+
callbacks.forEach((stored, id) => {
|
|
892
|
+
if (stored.pluginName === pluginName && stored.methodName === 'addListener') {
|
|
893
|
+
callbacks.delete(id);
|
|
894
|
+
}
|
|
895
|
+
});
|
|
896
|
+
}
|
|
897
|
+
if (methodName !== 'removeListener' &&
|
|
898
|
+
storedCallback &&
|
|
886
899
|
(typeof storedCallback.callback === 'function' || typeof storedCallback.resolve === 'function')) {
|
|
887
900
|
// store the call for later lookup
|
|
888
901
|
callbackId = String(++callbackIdCount);
|
|
889
|
-
callbacks.set(callbackId, storedCallback);
|
|
902
|
+
callbacks.set(callbackId, Object.assign(Object.assign({}, storedCallback), { pluginName, methodName }));
|
|
890
903
|
}
|
|
891
904
|
const callData = {
|
|
892
905
|
callbackId: callbackId,
|
|
@@ -7,6 +7,7 @@ import android.content.res.Resources;
|
|
|
7
7
|
import android.util.TypedValue;
|
|
8
8
|
import android.view.View;
|
|
9
9
|
import android.view.Window;
|
|
10
|
+
import android.view.WindowManager;
|
|
10
11
|
import android.webkit.WebView;
|
|
11
12
|
import androidx.core.graphics.Insets;
|
|
12
13
|
import androidx.core.view.ViewCompat;
|
|
@@ -37,8 +38,6 @@ public class SystemBars extends Plugin {
|
|
|
37
38
|
|
|
38
39
|
// https://issues.chromium.org/issues/40699457
|
|
39
40
|
private static final int WEBVIEW_VERSION_WITH_SAFE_AREA_FIX = 140;
|
|
40
|
-
// https://issues.chromium.org/issues/457682720
|
|
41
|
-
private static final int WEBVIEW_VERSION_WITH_SAFE_AREA_KEYBOARD_FIX = 144;
|
|
42
41
|
|
|
43
42
|
static final String viewportMetaJSFunction = """
|
|
44
43
|
function capacitorSystemBarsCheckMetaViewport() {
|
|
@@ -195,23 +194,28 @@ public class SystemBars extends Plugin {
|
|
|
195
194
|
|
|
196
195
|
Insets systemBarsInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout());
|
|
197
196
|
Insets imeInsets = insets.getInsets(WindowInsetsCompat.Type.ime());
|
|
198
|
-
|
|
197
|
+
// With `adjustNothing` the keyboard overlays the WebView, so it is handled as if it is not there
|
|
198
|
+
boolean keyboardOverlaysWebView =
|
|
199
|
+
(getActivity().getWindow().getAttributes().softInputMode & WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST) ==
|
|
200
|
+
WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING;
|
|
201
|
+
boolean keyboardVisible = !keyboardOverlaysWebView && insets.isVisible(WindowInsetsCompat.Type.ime());
|
|
199
202
|
|
|
200
203
|
if (shouldPassthroughInsets) {
|
|
201
204
|
// We need to correct for a possible shown IME
|
|
202
205
|
v.setPadding(0, 0, 0, keyboardVisible ? imeInsets.bottom : 0);
|
|
203
206
|
|
|
204
|
-
WindowInsetsCompat newInsets =
|
|
205
|
-
.setInsets(
|
|
207
|
+
WindowInsetsCompat newInsets = withoutOverlayingKeyboard(
|
|
208
|
+
new WindowInsetsCompat.Builder(insets).setInsets(
|
|
206
209
|
WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout(),
|
|
207
210
|
Insets.of(
|
|
208
211
|
systemBarsInsets.left,
|
|
209
212
|
systemBarsInsets.top,
|
|
210
213
|
systemBarsInsets.right,
|
|
211
|
-
getBottomInset(systemBarsInsets, keyboardVisible)
|
|
214
|
+
getBottomInset(systemBarsInsets, imeInsets, keyboardVisible)
|
|
212
215
|
)
|
|
213
|
-
)
|
|
214
|
-
|
|
216
|
+
),
|
|
217
|
+
keyboardOverlaysWebView
|
|
218
|
+
).build();
|
|
215
219
|
|
|
216
220
|
injectSafeAreaCSS(newInsets);
|
|
217
221
|
|
|
@@ -229,9 +233,13 @@ public class SystemBars extends Plugin {
|
|
|
229
233
|
// Returning `WindowInsetsCompat.CONSUMED` breaks recalculation of safe area insets
|
|
230
234
|
// So we have to explicitly set insets to `0`
|
|
231
235
|
// See: https://issues.chromium.org/issues/461332423
|
|
232
|
-
WindowInsetsCompat newInsets =
|
|
233
|
-
|
|
234
|
-
|
|
236
|
+
WindowInsetsCompat newInsets = withoutOverlayingKeyboard(
|
|
237
|
+
new WindowInsetsCompat.Builder(insets).setInsets(
|
|
238
|
+
WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout(),
|
|
239
|
+
Insets.of(0, 0, 0, 0)
|
|
240
|
+
),
|
|
241
|
+
keyboardOverlaysWebView
|
|
242
|
+
).build();
|
|
235
243
|
|
|
236
244
|
injectSafeAreaCSS(newInsets);
|
|
237
245
|
|
|
@@ -239,21 +247,31 @@ public class SystemBars extends Plugin {
|
|
|
239
247
|
});
|
|
240
248
|
}
|
|
241
249
|
|
|
250
|
+
private WindowInsetsCompat.Builder withoutOverlayingKeyboard(WindowInsetsCompat.Builder builder, boolean keyboardOverlaysWebView) {
|
|
251
|
+
if (!keyboardOverlaysWebView) {
|
|
252
|
+
return builder;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// WebView >= 139 shrinks its visual viewport for the IME insets it receives, which makes the page pannable above the keyboard.
|
|
256
|
+
// Unlike Chrome it ignores `VirtualKeyboard.overlaysContent` and `interactive-widget=overlays-content`,
|
|
257
|
+
// so not handing it the IME insets is the only way to opt out.
|
|
258
|
+
// Setting them to `0` rather than consuming them keeps the WebView's inset state up to date.
|
|
259
|
+
// See: https://developer.android.com/develop/ui/views/layout/webapps/understand-window-insets
|
|
260
|
+
return builder.setInsets(WindowInsetsCompat.Type.ime(), Insets.NONE).setVisible(WindowInsetsCompat.Type.ime(), false);
|
|
261
|
+
}
|
|
262
|
+
|
|
242
263
|
private void injectSafeAreaCSS(WindowInsetsCompat insets) {
|
|
243
264
|
if (!INSETS_HANDLING_CSS.equals(insetsHandling)) {
|
|
244
265
|
return;
|
|
245
266
|
}
|
|
246
267
|
|
|
247
268
|
Insets systemBarsInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout());
|
|
248
|
-
boolean keyboardVisible = insets.isVisible(WindowInsetsCompat.Type.ime());
|
|
249
269
|
|
|
250
270
|
// Convert pixels to density-independent pixels
|
|
251
271
|
float density = getActivity().getResources().getDisplayMetrics().density;
|
|
252
272
|
float topPx = systemBarsInsets.top / density;
|
|
253
273
|
float rightPx = systemBarsInsets.right / density;
|
|
254
|
-
|
|
255
|
-
// but for these injected values we have to handle that manually (for all WebView versions).
|
|
256
|
-
float bottomPx = (keyboardVisible ? 0 : systemBarsInsets.bottom) / density;
|
|
274
|
+
float bottomPx = systemBarsInsets.bottom / density;
|
|
257
275
|
float leftPx = systemBarsInsets.left / density;
|
|
258
276
|
|
|
259
277
|
// Execute JavaScript to inject the CSS
|
|
@@ -350,15 +368,13 @@ public class SystemBars extends Plugin {
|
|
|
350
368
|
return 0;
|
|
351
369
|
}
|
|
352
370
|
|
|
353
|
-
private int getBottomInset(Insets systemBarsInsets, boolean keyboardVisible) {
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
return 0;
|
|
361
|
-
}
|
|
371
|
+
private int getBottomInset(Insets systemBarsInsets, Insets imeInsets, boolean keyboardVisible) {
|
|
372
|
+
// Only the part of the navigation bar the IME doesn't cover is left for the page to clear:
|
|
373
|
+
// none for a docked IME, all of it for a floating one.
|
|
374
|
+
// Deliberately not gated on the WebView version: measured on 148-156, Chromium corrects
|
|
375
|
+
// this itself on API 35+ but not on API 29-34.
|
|
376
|
+
if (keyboardVisible) {
|
|
377
|
+
return Math.max(0, systemBarsInsets.bottom - imeInsets.bottom);
|
|
362
378
|
}
|
|
363
379
|
|
|
364
380
|
return systemBarsInsets.bottom;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor/android",
|
|
3
|
-
"version": "8.6.1
|
|
3
|
+
"version": "8.6.1",
|
|
4
4
|
"description": "Capacitor: Cross-platform apps with JavaScript and the web",
|
|
5
5
|
"homepage": "https://capacitorjs.com",
|
|
6
6
|
"author": "Ionic Team <hi@ionic.io> (https://ionic.io)",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"verify": "./gradlew clean lint build test -b capacitor/build.gradle"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@capacitor/core": "^8.6.0
|
|
26
|
+
"@capacitor/core": "^8.6.0"
|
|
27
27
|
},
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|