@capgo/capacitor-updater 7.45.10 → 7.50.2
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/Package.swift +1 -1
- package/README.md +510 -92
- package/android/src/main/java/ee/forgr/capacitor_updater/AndroidAppExitReporter.java +92 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +3192 -777
- package/android/src/main/java/ee/forgr/capacitor_updater/CapgoUpdater.java +798 -299
- package/android/src/main/java/ee/forgr/capacitor_updater/DeviceIdHelper.java +45 -30
- package/android/src/main/java/ee/forgr/capacitor_updater/DownloadService.java +46 -28
- package/android/src/main/java/ee/forgr/capacitor_updater/DownloadWorkerManager.java +2 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/ShakeDetector.java +3 -3
- package/android/src/main/java/ee/forgr/capacitor_updater/ShakeMenu.java +359 -25
- package/android/src/main/java/ee/forgr/capacitor_updater/ThreeFingerPinchDetector.java +323 -0
- package/dist/docs.json +1283 -169
- package/dist/esm/definitions.d.ts +621 -44
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +11 -1
- package/dist/esm/web.js +59 -1
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +59 -1
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +59 -1
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/CapacitorUpdaterPlugin/AES.swift +0 -1
- package/ios/Sources/CapacitorUpdaterPlugin/AppHealthTracker.swift +82 -0
- package/ios/Sources/CapacitorUpdaterPlugin/BigInt.swift +0 -16
- package/ios/Sources/CapacitorUpdaterPlugin/BundleInfo.swift +2 -2
- package/ios/Sources/CapacitorUpdaterPlugin/BundleStatus.swift +78 -2
- package/ios/Sources/CapacitorUpdaterPlugin/CapacitorUpdaterPlugin.swift +2116 -223
- package/ios/Sources/CapacitorUpdaterPlugin/CapgoUpdater.swift +997 -332
- package/ios/Sources/CapacitorUpdaterPlugin/CryptoCipher.swift +0 -1
- package/ios/Sources/CapacitorUpdaterPlugin/InternalUtils.swift +78 -1
- package/ios/Sources/CapacitorUpdaterPlugin/ShakeMenu.swift +418 -36
- package/ios/Sources/CapacitorUpdaterPlugin/WebViewStatsReporter.swift +276 -0
- package/package.json +15 -3
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
package ee.forgr.capacitor_updater;
|
|
8
|
+
|
|
9
|
+
import android.view.ActionMode;
|
|
10
|
+
import android.view.KeyEvent;
|
|
11
|
+
import android.view.KeyboardShortcutGroup;
|
|
12
|
+
import android.view.Menu;
|
|
13
|
+
import android.view.MenuItem;
|
|
14
|
+
import android.view.MotionEvent;
|
|
15
|
+
import android.view.SearchEvent;
|
|
16
|
+
import android.view.View;
|
|
17
|
+
import android.view.Window;
|
|
18
|
+
import android.view.WindowManager;
|
|
19
|
+
import android.view.accessibility.AccessibilityEvent;
|
|
20
|
+
import com.getcapacitor.BridgeActivity;
|
|
21
|
+
import java.lang.ref.WeakReference;
|
|
22
|
+
import java.util.List;
|
|
23
|
+
|
|
24
|
+
public class ThreeFingerPinchDetector {
|
|
25
|
+
|
|
26
|
+
public interface Listener {
|
|
27
|
+
void onThreeFingerPinchDetected();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private static final int REQUIRED_POINTER_COUNT = 3;
|
|
31
|
+
private static final float MIN_SCALE_DELTA = 0.12f;
|
|
32
|
+
private static final long PINCH_TIMEOUT = 1000;
|
|
33
|
+
|
|
34
|
+
private final Listener listener;
|
|
35
|
+
private final Logger logger;
|
|
36
|
+
private Window targetWindow;
|
|
37
|
+
private Window.Callback previousWindowCallback;
|
|
38
|
+
private Window.Callback windowCallback;
|
|
39
|
+
private WeakReference<ThreeFingerPinchDetector> detectorReference;
|
|
40
|
+
private float initialSpan = 0;
|
|
41
|
+
private boolean tracking = false;
|
|
42
|
+
private boolean triggered = false;
|
|
43
|
+
private long lastPinchTime = 0;
|
|
44
|
+
|
|
45
|
+
public ThreeFingerPinchDetector(Listener listener, Logger logger) {
|
|
46
|
+
this.listener = listener;
|
|
47
|
+
this.logger = logger;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public void start(BridgeActivity activity) {
|
|
51
|
+
if (targetWindow != null) {
|
|
52
|
+
stop();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
Window window = activity.getWindow();
|
|
56
|
+
if (window == null) {
|
|
57
|
+
logger.warn("Three finger pinch detector could not find a target window");
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
this.targetWindow = window;
|
|
62
|
+
this.previousWindowCallback = window.getCallback();
|
|
63
|
+
this.detectorReference = new WeakReference<>(this);
|
|
64
|
+
this.windowCallback = new PinchWindowCallback(this.previousWindowCallback, this.detectorReference);
|
|
65
|
+
window.setCallback(this.windowCallback);
|
|
66
|
+
logger.info("Three finger pinch detector installed on activity window");
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public void stop() {
|
|
70
|
+
if (targetWindow != null) {
|
|
71
|
+
if (windowCallback instanceof PinchWindowCallback) {
|
|
72
|
+
((PinchWindowCallback) windowCallback).disable();
|
|
73
|
+
}
|
|
74
|
+
if (detectorReference != null) {
|
|
75
|
+
detectorReference.clear();
|
|
76
|
+
}
|
|
77
|
+
if (targetWindow.getCallback() == windowCallback) {
|
|
78
|
+
targetWindow.setCallback(previousWindowCallback);
|
|
79
|
+
}
|
|
80
|
+
targetWindow = null;
|
|
81
|
+
previousWindowCallback = null;
|
|
82
|
+
windowCallback = null;
|
|
83
|
+
detectorReference = null;
|
|
84
|
+
}
|
|
85
|
+
reset();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
private void handleTouch(MotionEvent event) {
|
|
89
|
+
int action = event.getActionMasked();
|
|
90
|
+
if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_POINTER_UP) {
|
|
91
|
+
reset();
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (event.getPointerCount() != REQUIRED_POINTER_COUNT) {
|
|
96
|
+
if (action == MotionEvent.ACTION_POINTER_DOWN) {
|
|
97
|
+
reset();
|
|
98
|
+
}
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
float span = calculateSpan(event);
|
|
103
|
+
if (span <= 0) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (!tracking || action == MotionEvent.ACTION_POINTER_DOWN) {
|
|
108
|
+
initialSpan = span;
|
|
109
|
+
tracking = true;
|
|
110
|
+
triggered = false;
|
|
111
|
+
logger.info("Three finger pinch tracking started");
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (!triggered && Math.abs(span - initialSpan) / initialSpan >= MIN_SCALE_DELTA) {
|
|
116
|
+
long currentTime = System.currentTimeMillis();
|
|
117
|
+
if (currentTime - lastPinchTime > PINCH_TIMEOUT) {
|
|
118
|
+
triggered = true;
|
|
119
|
+
lastPinchTime = currentTime;
|
|
120
|
+
logger.info("Three finger pinch threshold reached");
|
|
121
|
+
if (listener != null) {
|
|
122
|
+
listener.onThreeFingerPinchDetected();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
private float calculateSpan(MotionEvent event) {
|
|
129
|
+
float centerX = 0;
|
|
130
|
+
float centerY = 0;
|
|
131
|
+
for (int i = 0; i < REQUIRED_POINTER_COUNT; i++) {
|
|
132
|
+
centerX += event.getX(i);
|
|
133
|
+
centerY += event.getY(i);
|
|
134
|
+
}
|
|
135
|
+
centerX /= REQUIRED_POINTER_COUNT;
|
|
136
|
+
centerY /= REQUIRED_POINTER_COUNT;
|
|
137
|
+
|
|
138
|
+
float totalDistance = 0;
|
|
139
|
+
for (int i = 0; i < REQUIRED_POINTER_COUNT; i++) {
|
|
140
|
+
float dx = event.getX(i) - centerX;
|
|
141
|
+
float dy = event.getY(i) - centerY;
|
|
142
|
+
totalDistance += Math.sqrt(dx * dx + dy * dy);
|
|
143
|
+
}
|
|
144
|
+
return totalDistance / REQUIRED_POINTER_COUNT;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
private void reset() {
|
|
148
|
+
initialSpan = 0;
|
|
149
|
+
tracking = false;
|
|
150
|
+
triggered = false;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
private static class PinchWindowCallback implements Window.Callback {
|
|
154
|
+
|
|
155
|
+
private final Window.Callback delegate;
|
|
156
|
+
private final WeakReference<ThreeFingerPinchDetector> detectorReference;
|
|
157
|
+
private boolean enabled = true;
|
|
158
|
+
|
|
159
|
+
PinchWindowCallback(Window.Callback delegate, WeakReference<ThreeFingerPinchDetector> detectorReference) {
|
|
160
|
+
this.delegate = delegate;
|
|
161
|
+
this.detectorReference = detectorReference;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
void disable() {
|
|
165
|
+
enabled = false;
|
|
166
|
+
if (detectorReference != null) {
|
|
167
|
+
detectorReference.clear();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
@Override
|
|
172
|
+
public boolean dispatchKeyEvent(KeyEvent event) {
|
|
173
|
+
return delegate != null && delegate.dispatchKeyEvent(event);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
@Override
|
|
177
|
+
public boolean dispatchKeyShortcutEvent(KeyEvent event) {
|
|
178
|
+
return delegate != null && delegate.dispatchKeyShortcutEvent(event);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
@Override
|
|
182
|
+
public boolean dispatchTouchEvent(MotionEvent event) {
|
|
183
|
+
boolean handled = delegate != null && delegate.dispatchTouchEvent(event);
|
|
184
|
+
if (enabled) {
|
|
185
|
+
ThreeFingerPinchDetector detector = detectorReference == null ? null : detectorReference.get();
|
|
186
|
+
if (detector != null) {
|
|
187
|
+
detector.handleTouch(event);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return handled;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
@Override
|
|
194
|
+
public boolean dispatchTrackballEvent(MotionEvent event) {
|
|
195
|
+
return delegate != null && delegate.dispatchTrackballEvent(event);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
@Override
|
|
199
|
+
public boolean dispatchGenericMotionEvent(MotionEvent event) {
|
|
200
|
+
return delegate != null && delegate.dispatchGenericMotionEvent(event);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
@Override
|
|
204
|
+
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
|
|
205
|
+
return delegate != null && delegate.dispatchPopulateAccessibilityEvent(event);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
@Override
|
|
209
|
+
public View onCreatePanelView(int featureId) {
|
|
210
|
+
return delegate == null ? null : delegate.onCreatePanelView(featureId);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
@Override
|
|
214
|
+
public boolean onCreatePanelMenu(int featureId, Menu menu) {
|
|
215
|
+
return delegate != null && delegate.onCreatePanelMenu(featureId, menu);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
@Override
|
|
219
|
+
public boolean onPreparePanel(int featureId, View view, Menu menu) {
|
|
220
|
+
return delegate != null && delegate.onPreparePanel(featureId, view, menu);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
@Override
|
|
224
|
+
public boolean onMenuOpened(int featureId, Menu menu) {
|
|
225
|
+
return delegate != null && delegate.onMenuOpened(featureId, menu);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
@Override
|
|
229
|
+
public boolean onMenuItemSelected(int featureId, MenuItem item) {
|
|
230
|
+
return delegate != null && delegate.onMenuItemSelected(featureId, item);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
@Override
|
|
234
|
+
public void onWindowAttributesChanged(WindowManager.LayoutParams attrs) {
|
|
235
|
+
if (delegate != null) {
|
|
236
|
+
delegate.onWindowAttributesChanged(attrs);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
@Override
|
|
241
|
+
public void onContentChanged() {
|
|
242
|
+
if (delegate != null) {
|
|
243
|
+
delegate.onContentChanged();
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
@Override
|
|
248
|
+
public void onWindowFocusChanged(boolean hasFocus) {
|
|
249
|
+
if (delegate != null) {
|
|
250
|
+
delegate.onWindowFocusChanged(hasFocus);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
@Override
|
|
255
|
+
public void onAttachedToWindow() {
|
|
256
|
+
if (delegate != null) {
|
|
257
|
+
delegate.onAttachedToWindow();
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
@Override
|
|
262
|
+
public void onDetachedFromWindow() {
|
|
263
|
+
if (delegate != null) {
|
|
264
|
+
delegate.onDetachedFromWindow();
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
@Override
|
|
269
|
+
public void onPanelClosed(int featureId, Menu menu) {
|
|
270
|
+
if (delegate != null) {
|
|
271
|
+
delegate.onPanelClosed(featureId, menu);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
@Override
|
|
276
|
+
public boolean onSearchRequested() {
|
|
277
|
+
return delegate != null && delegate.onSearchRequested();
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
@Override
|
|
281
|
+
public boolean onSearchRequested(SearchEvent searchEvent) {
|
|
282
|
+
return delegate != null && delegate.onSearchRequested(searchEvent);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
@Override
|
|
286
|
+
public ActionMode onWindowStartingActionMode(ActionMode.Callback callback) {
|
|
287
|
+
return delegate == null ? null : delegate.onWindowStartingActionMode(callback);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
@Override
|
|
291
|
+
public ActionMode onWindowStartingActionMode(ActionMode.Callback callback, int type) {
|
|
292
|
+
return delegate == null ? null : delegate.onWindowStartingActionMode(callback, type);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
@Override
|
|
296
|
+
public void onActionModeStarted(ActionMode mode) {
|
|
297
|
+
if (delegate != null) {
|
|
298
|
+
delegate.onActionModeStarted(mode);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
@Override
|
|
303
|
+
public void onActionModeFinished(ActionMode mode) {
|
|
304
|
+
if (delegate != null) {
|
|
305
|
+
delegate.onActionModeFinished(mode);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
@Override
|
|
310
|
+
public void onProvideKeyboardShortcuts(List<KeyboardShortcutGroup> data, Menu menu, int deviceId) {
|
|
311
|
+
if (delegate != null) {
|
|
312
|
+
delegate.onProvideKeyboardShortcuts(data, menu, deviceId);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
@Override
|
|
317
|
+
public void onPointerCaptureChanged(boolean hasCapture) {
|
|
318
|
+
if (delegate != null) {
|
|
319
|
+
delegate.onPointerCaptureChanged(hasCapture);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|