@capgo/cordova-updater 8.1.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.
- package/LICENSE +373 -0
- package/README.md +82 -0
- package/dist/esm/definitions.d.ts +2684 -0
- package/dist/esm/definitions.js +109 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/exec.d.ts +4 -0
- package/dist/esm/exec.js +25 -0
- package/dist/esm/exec.js.map +1 -0
- package/dist/esm/history.d.ts +1 -0
- package/dist/esm/history.js +283 -0
- package/dist/esm/history.js.map +1 -0
- package/dist/esm/index.d.ts +57 -0
- package/dist/esm/index.js +68 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/plugin.d.ts +57 -0
- package/dist/esm/plugin.js +15 -0
- package/dist/esm/plugin.js.map +1 -0
- package/dist/plugin.cjs.js +217 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +222 -0
- package/dist/plugin.js.map +1 -0
- package/package.json +96 -0
- package/plugin.xml +207 -0
- package/src/android/CordovaUpdaterPlugin.java +5662 -0
- package/src/android/UpdaterPathHandler.java +99 -0
- package/src/android/app/capgo/cordova/updater/AndroidAppExitReporter.java +92 -0
- package/src/android/app/capgo/cordova/updater/AppLifecycleObserver.java +115 -0
- package/src/android/app/capgo/cordova/updater/BundleInfo.java +246 -0
- package/src/android/app/capgo/cordova/updater/BundleStatus.java +45 -0
- package/src/android/app/capgo/cordova/updater/Callback.java +13 -0
- package/src/android/app/capgo/cordova/updater/CapgoUpdater.java +3404 -0
- package/src/android/app/capgo/cordova/updater/CordovaUpdaterConfig.java +56 -0
- package/src/android/app/capgo/cordova/updater/CryptoCipher.java +462 -0
- package/src/android/app/capgo/cordova/updater/DataManager.java +44 -0
- package/src/android/app/capgo/cordova/updater/DelayCondition.java +56 -0
- package/src/android/app/capgo/cordova/updater/DelayUntilNext.java +14 -0
- package/src/android/app/capgo/cordova/updater/DelayUpdateUtils.java +307 -0
- package/src/android/app/capgo/cordova/updater/DeviceIdHelper.java +230 -0
- package/src/android/app/capgo/cordova/updater/DownloadService.java +1219 -0
- package/src/android/app/capgo/cordova/updater/DownloadWorkerManager.java +260 -0
- package/src/android/app/capgo/cordova/updater/InternalUtils.java +54 -0
- package/src/android/app/capgo/cordova/updater/Logger.java +345 -0
- package/src/android/app/capgo/cordova/updater/ShakeDetector.java +72 -0
- package/src/android/app/capgo/cordova/updater/ShakeMenu.java +39 -0
- package/src/android/app/capgo/cordova/updater/ThreeFingerPinchDetector.java +323 -0
- package/src/android/app/capgo/cordova/updater/compat/JSArray.java +9 -0
- package/src/android/app/capgo/cordova/updater/compat/JSObject.java +83 -0
- package/src/android/app/capgo/cordova/updater/compat/PluginCall.java +165 -0
- package/src/android/capgo-cordova-updater.gradle +19 -0
- package/src/android/capgo-updater.xml +3 -0
- package/src/android/test/app/capgo/cordova/updater/CapacitorUpdaterUnitTest.java.skip +3039 -0
- package/src/android/test/app/capgo/cordova/updater/DelayUpdateUtilsTest.java +177 -0
- package/src/android/test/app/capgo/cordova/updater/NativeContractTest.java +105 -0
- package/src/ios/AES.swift +216 -0
- package/src/ios/AppHealthTracker.swift +82 -0
- package/src/ios/BundleInfo.swift +185 -0
- package/src/ios/BundleStatus.swift +127 -0
- package/src/ios/CapgoRawRsa.swift +36 -0
- package/src/ios/CapgoUpdater.swift +3544 -0
- package/src/ios/CordovaCompat.swift +11 -0
- package/src/ios/CordovaPluginCall.swift +190 -0
- package/src/ios/CordovaUpdaterCommands.swift +270 -0
- package/src/ios/CordovaUpdaterPlugin.swift +4706 -0
- package/src/ios/CryptoCipher.swift +326 -0
- package/src/ios/DelayCondition.swift +74 -0
- package/src/ios/DelayUntilNext.swift +30 -0
- package/src/ios/DelayUpdateUtils.swift +257 -0
- package/src/ios/DeviceIdHelper.swift +120 -0
- package/src/ios/Info.plist +28 -0
- package/src/ios/InternalUtils.swift +471 -0
- package/src/ios/Logger.swift +283 -0
- package/src/ios/RSA.swift +96 -0
- package/src/ios/ShakeMenu.swift +52 -0
- package/src/ios/UpdaterSchemeHandler.swift +81 -0
- package/src/ios/UserDefaultsExtension.swift +46 -0
- package/src/ios/WebViewStatsReporter.swift +303 -0
|
@@ -0,0 +1,72 @@
|
|
|
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 app.capgo.cordova.updater;
|
|
8
|
+
|
|
9
|
+
import android.hardware.Sensor;
|
|
10
|
+
import android.hardware.SensorEvent;
|
|
11
|
+
import android.hardware.SensorEventListener;
|
|
12
|
+
import android.hardware.SensorManager;
|
|
13
|
+
|
|
14
|
+
public class ShakeDetector implements SensorEventListener {
|
|
15
|
+
|
|
16
|
+
public interface Listener {
|
|
17
|
+
void onShakeDetected();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
private static final float SHAKE_THRESHOLD = 16.0f; // Acceleration threshold for shake detection
|
|
21
|
+
private static final int SHAKE_TIMEOUT = 1000; // Minimum time between shake events (ms)
|
|
22
|
+
|
|
23
|
+
private Listener listener;
|
|
24
|
+
private SensorManager sensorManager;
|
|
25
|
+
private Sensor accelerometer;
|
|
26
|
+
private long lastShakeTime = 0;
|
|
27
|
+
|
|
28
|
+
public ShakeDetector(Listener listener) {
|
|
29
|
+
this.listener = listener;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public void start(SensorManager sensorManager) {
|
|
33
|
+
this.sensorManager = sensorManager;
|
|
34
|
+
this.accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
|
|
35
|
+
|
|
36
|
+
if (accelerometer != null) {
|
|
37
|
+
sensorManager.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_UI);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public void stop() {
|
|
42
|
+
if (sensorManager != null) {
|
|
43
|
+
sensorManager.unregisterListener(this);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@Override
|
|
48
|
+
public void onSensorChanged(SensorEvent event) {
|
|
49
|
+
if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
|
|
50
|
+
float x = event.values[0];
|
|
51
|
+
float y = event.values[1];
|
|
52
|
+
float z = event.values[2];
|
|
53
|
+
|
|
54
|
+
// Calculate the acceleration magnitude (excluding gravity)
|
|
55
|
+
float acceleration = (float) Math.sqrt(x * x + y * y + z * z) - SensorManager.GRAVITY_EARTH;
|
|
56
|
+
|
|
57
|
+
// Check if acceleration exceeds threshold and enough time has passed
|
|
58
|
+
long currentTime = System.currentTimeMillis();
|
|
59
|
+
if (Math.abs(acceleration) > SHAKE_THRESHOLD && currentTime - lastShakeTime > SHAKE_TIMEOUT) {
|
|
60
|
+
lastShakeTime = currentTime;
|
|
61
|
+
if (listener != null) {
|
|
62
|
+
listener.onShakeDetected();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@Override
|
|
69
|
+
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
|
70
|
+
// Not needed for shake detection
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
package app.capgo.cordova.updater;
|
|
7
|
+
|
|
8
|
+
import android.app.Activity;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Cordova shake menu stub. Full preview/channel shake UI is planned for a follow-up release.
|
|
12
|
+
*/
|
|
13
|
+
public class ShakeMenu implements ShakeDetector.Listener, ThreeFingerPinchDetector.Listener {
|
|
14
|
+
|
|
15
|
+
private final Logger logger;
|
|
16
|
+
|
|
17
|
+
public ShakeMenu(CordovaUpdaterPlugin plugin, Activity activity, Logger logger, String gesture) {
|
|
18
|
+
this.logger = logger;
|
|
19
|
+
logger.debug("ShakeMenu: gesture " + gesture + " registered (Cordova stub)");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public boolean usesGesture(String gesture) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public void stop() {
|
|
27
|
+
// no-op
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@Override
|
|
31
|
+
public void onShakeDetected() {
|
|
32
|
+
logger.debug("ShakeMenu: shake detected (Cordova stub)");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@Override
|
|
36
|
+
public void onThreeFingerPinchDetected() {
|
|
37
|
+
logger.debug("ShakeMenu: three-finger pinch detected (Cordova stub)");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -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 app.capgo.cordova.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 android.app.Activity;
|
|
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(Activity 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
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
package app.capgo.cordova.updater.compat;
|
|
2
|
+
|
|
3
|
+
import org.json.JSONException;
|
|
4
|
+
import org.json.JSONObject;
|
|
5
|
+
|
|
6
|
+
public class JSObject extends JSONObject {
|
|
7
|
+
public JSObject() {
|
|
8
|
+
super();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public JSObject(JSONObject copy, String[] names) {
|
|
12
|
+
super();
|
|
13
|
+
for (String name : names) {
|
|
14
|
+
if (copy != null && copy.has(name)) {
|
|
15
|
+
try {
|
|
16
|
+
put(name, copy.get(name));
|
|
17
|
+
} catch (org.json.JSONException ignored) {
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public JSObject(String json) throws JSONException {
|
|
24
|
+
super(json);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@Override
|
|
28
|
+
public JSObject put(String key, boolean value) {
|
|
29
|
+
try {
|
|
30
|
+
super.put(key, value);
|
|
31
|
+
} catch (JSONException ignored) {
|
|
32
|
+
}
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@Override
|
|
37
|
+
public JSObject put(String key, int value) {
|
|
38
|
+
try {
|
|
39
|
+
super.put(key, value);
|
|
40
|
+
} catch (JSONException ignored) {
|
|
41
|
+
}
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@Override
|
|
46
|
+
public JSObject put(String key, long value) {
|
|
47
|
+
try {
|
|
48
|
+
super.put(key, value);
|
|
49
|
+
} catch (JSONException ignored) {
|
|
50
|
+
}
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@Override
|
|
55
|
+
public JSObject put(String key, double value) {
|
|
56
|
+
try {
|
|
57
|
+
super.put(key, value);
|
|
58
|
+
} catch (JSONException ignored) {
|
|
59
|
+
}
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@Override
|
|
64
|
+
public JSObject put(String key, Object value) {
|
|
65
|
+
try {
|
|
66
|
+
super.put(key, value);
|
|
67
|
+
} catch (JSONException ignored) {
|
|
68
|
+
}
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public String getString(String key) {
|
|
73
|
+
try {
|
|
74
|
+
return super.getString(key);
|
|
75
|
+
} catch (JSONException e) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
public boolean has(String key) {
|
|
81
|
+
return super.has(key);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
package app.capgo.cordova.updater.compat;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.Nullable;
|
|
4
|
+
import org.apache.cordova.CallbackContext;
|
|
5
|
+
import org.json.JSONArray;
|
|
6
|
+
import org.json.JSONObject;
|
|
7
|
+
|
|
8
|
+
public class PluginCall {
|
|
9
|
+
private final CallbackContext callbackContext;
|
|
10
|
+
private final JSONArray args;
|
|
11
|
+
private final CordovaPluginShim plugin;
|
|
12
|
+
|
|
13
|
+
public interface CordovaPluginShim {
|
|
14
|
+
void reject(PluginCall call, String message, @Nullable Exception exception);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public PluginCall(CallbackContext callbackContext, JSONArray args, CordovaPluginShim plugin) {
|
|
18
|
+
this.callbackContext = callbackContext;
|
|
19
|
+
this.args = args == null ? new JSONArray() : args;
|
|
20
|
+
this.plugin = plugin;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public CallbackContext getCallbackContext() {
|
|
24
|
+
return callbackContext;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@Nullable
|
|
28
|
+
public String getString(String key) {
|
|
29
|
+
return getString(key, null);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@Nullable
|
|
33
|
+
public String getString(String key, @Nullable String defaultValue) {
|
|
34
|
+
JSONObject obj = firstObject();
|
|
35
|
+
if (obj == null || !obj.has(key) || obj.isNull(key)) {
|
|
36
|
+
return defaultValue;
|
|
37
|
+
}
|
|
38
|
+
return obj.optString(key, defaultValue);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@Nullable
|
|
42
|
+
public Boolean getBoolean(String key) {
|
|
43
|
+
JSONObject obj = firstObject();
|
|
44
|
+
if (obj == null || !obj.has(key) || obj.isNull(key)) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return obj.optBoolean(key);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public boolean getBoolean(String key, boolean defaultValue) {
|
|
51
|
+
JSONObject obj = firstObject();
|
|
52
|
+
if (obj == null || !obj.has(key) || obj.isNull(key)) {
|
|
53
|
+
return defaultValue;
|
|
54
|
+
}
|
|
55
|
+
return obj.optBoolean(key, defaultValue);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public int getInt(String key, int defaultValue) {
|
|
59
|
+
JSONObject obj = firstObject();
|
|
60
|
+
if (obj == null || !obj.has(key) || obj.isNull(key)) {
|
|
61
|
+
return defaultValue;
|
|
62
|
+
}
|
|
63
|
+
return obj.optInt(key, defaultValue);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public double getDouble(String key, double defaultValue) {
|
|
67
|
+
JSONObject obj = firstObject();
|
|
68
|
+
if (obj == null || !obj.has(key) || obj.isNull(key)) {
|
|
69
|
+
return defaultValue;
|
|
70
|
+
}
|
|
71
|
+
return obj.optDouble(key, defaultValue);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@Nullable
|
|
75
|
+
public JSObject getObject(String key) {
|
|
76
|
+
JSONObject obj = firstObject();
|
|
77
|
+
if (obj == null || !obj.has(key) || obj.isNull(key)) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
Object value = obj.opt(key);
|
|
81
|
+
if (value instanceof JSONObject) {
|
|
82
|
+
JSObject copy = new JSObject();
|
|
83
|
+
JSONObject source = (JSONObject) value;
|
|
84
|
+
JSONArray names = source.names();
|
|
85
|
+
if (names != null) {
|
|
86
|
+
for (int i = 0; i < names.length(); i++) {
|
|
87
|
+
String name = names.optString(i);
|
|
88
|
+
copy.put(name, source.opt(name));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return copy;
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
@Nullable
|
|
97
|
+
public JSONArray getArray(String key) {
|
|
98
|
+
JSONObject obj = firstObject();
|
|
99
|
+
if (obj == null || !obj.has(key) || obj.isNull(key)) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
return obj.optJSONArray(key);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
@Nullable
|
|
106
|
+
private JSONObject firstObject() {
|
|
107
|
+
if (args.length() == 0) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
Object first = args.opt(0);
|
|
111
|
+
if (first instanceof JSONObject) {
|
|
112
|
+
return (JSONObject) first;
|
|
113
|
+
}
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
public void resolve() {
|
|
118
|
+
callbackContext.success();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
public void resolve(JSObject data) {
|
|
122
|
+
callbackContext.success(data);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
public void resolve(String data) {
|
|
126
|
+
callbackContext.success(data);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
public void reject(String message) {
|
|
130
|
+
plugin.reject(this, message, null);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
public JSObject getData() {
|
|
135
|
+
JSONObject obj = firstObject();
|
|
136
|
+
if (obj == null) {
|
|
137
|
+
return new JSObject();
|
|
138
|
+
}
|
|
139
|
+
JSObject copy = new JSObject();
|
|
140
|
+
JSONArray names = obj.names();
|
|
141
|
+
if (names != null) {
|
|
142
|
+
for (int i = 0; i < names.length(); i++) {
|
|
143
|
+
String name = names.optString(i);
|
|
144
|
+
copy.put(name, obj.opt(name));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return copy;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
public void reject(String message, String code) {
|
|
151
|
+
plugin.reject(this, message, null);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
public void reject(String message, String code, @Nullable Exception exception, JSObject data) {
|
|
155
|
+
plugin.reject(this, message, exception);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
public void reject(String message, String code, @Nullable Exception exception) {
|
|
159
|
+
plugin.reject(this, message, exception);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
public void reject(String message, @Nullable Exception exception) {
|
|
163
|
+
plugin.reject(this, message, exception);
|
|
164
|
+
}
|
|
165
|
+
}
|