@capgo/capacitor-updater 8.0.1 → 8.1.0
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/CapgoCapacitorUpdater.podspec +7 -5
- package/Package.swift +9 -7
- package/README.md +984 -215
- package/android/build.gradle +24 -12
- package/android/proguard-rules.pro +22 -5
- package/android/src/main/java/ee/forgr/capacitor_updater/BundleInfo.java +110 -22
- package/android/src/main/java/ee/forgr/capacitor_updater/Callback.java +2 -2
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +1310 -488
- package/android/src/main/java/ee/forgr/capacitor_updater/{CapacitorUpdater.java → CapgoUpdater.java} +640 -203
- package/android/src/main/java/ee/forgr/capacitor_updater/{CryptoCipherV2.java → CryptoCipher.java} +119 -33
- package/android/src/main/java/ee/forgr/capacitor_updater/DelayCondition.java +0 -3
- package/android/src/main/java/ee/forgr/capacitor_updater/DelayUpdateUtils.java +260 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/DeviceIdHelper.java +221 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/DownloadService.java +497 -133
- package/android/src/main/java/ee/forgr/capacitor_updater/DownloadWorkerManager.java +80 -25
- package/android/src/main/java/ee/forgr/capacitor_updater/Logger.java +338 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/ShakeDetector.java +72 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/ShakeMenu.java +169 -0
- package/dist/docs.json +873 -154
- package/dist/esm/definitions.d.ts +881 -114
- package/dist/esm/definitions.js.map +1 -1
- 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 +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/web.d.ts +12 -1
- package/dist/esm/web.js +29 -2
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +311 -2
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +311 -2
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/CapacitorUpdaterPlugin/AES.swift +69 -0
- package/ios/Sources/CapacitorUpdaterPlugin/BigInt.swift +55 -0
- package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/BundleInfo.swift +37 -10
- package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/BundleStatus.swift +1 -1
- package/ios/Sources/CapacitorUpdaterPlugin/CapacitorUpdaterPlugin.swift +1605 -0
- package/ios/{Plugin/CapacitorUpdater.swift → Sources/CapacitorUpdaterPlugin/CapgoUpdater.swift} +523 -230
- package/ios/Sources/CapacitorUpdaterPlugin/CryptoCipher.swift +267 -0
- package/ios/Sources/CapacitorUpdaterPlugin/DelayUpdateUtils.swift +220 -0
- package/ios/Sources/CapacitorUpdaterPlugin/DeviceIdHelper.swift +120 -0
- package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/InternalUtils.swift +53 -0
- package/ios/Sources/CapacitorUpdaterPlugin/Logger.swift +310 -0
- package/ios/Sources/CapacitorUpdaterPlugin/RSA.swift +274 -0
- package/ios/Sources/CapacitorUpdaterPlugin/ShakeMenu.swift +112 -0
- package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/UserDefaultsExtension.swift +0 -2
- package/package.json +21 -19
- package/ios/Plugin/CapacitorUpdaterPlugin.swift +0 -975
- package/ios/Plugin/CryptoCipherV2.swift +0 -310
- /package/{LICENCE → LICENSE} +0 -0
- /package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/DelayCondition.swift +0 -0
- /package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/DelayUntilNext.swift +0 -0
- /package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/Info.plist +0 -0
|
@@ -0,0 +1,169 @@
|
|
|
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.app.Activity;
|
|
10
|
+
import android.app.AlertDialog;
|
|
11
|
+
import android.content.DialogInterface;
|
|
12
|
+
import android.hardware.SensorManager;
|
|
13
|
+
import com.getcapacitor.Bridge;
|
|
14
|
+
import com.getcapacitor.BridgeActivity;
|
|
15
|
+
|
|
16
|
+
public class ShakeMenu implements ShakeDetector.Listener {
|
|
17
|
+
|
|
18
|
+
private CapacitorUpdaterPlugin plugin;
|
|
19
|
+
private BridgeActivity activity;
|
|
20
|
+
private ShakeDetector shakeDetector;
|
|
21
|
+
private boolean isShowing = false;
|
|
22
|
+
private Logger logger;
|
|
23
|
+
|
|
24
|
+
public ShakeMenu(CapacitorUpdaterPlugin plugin, BridgeActivity activity, Logger logger) {
|
|
25
|
+
this.plugin = plugin;
|
|
26
|
+
this.activity = activity;
|
|
27
|
+
this.logger = logger;
|
|
28
|
+
|
|
29
|
+
SensorManager sensorManager = (SensorManager) activity.getSystemService(Activity.SENSOR_SERVICE);
|
|
30
|
+
this.shakeDetector = new ShakeDetector(this);
|
|
31
|
+
this.shakeDetector.start(sensorManager);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public void stop() {
|
|
35
|
+
if (shakeDetector != null) {
|
|
36
|
+
shakeDetector.stop();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@Override
|
|
41
|
+
public void onShakeDetected() {
|
|
42
|
+
logger.info("Shake detected");
|
|
43
|
+
|
|
44
|
+
// Check if shake menu is enabled
|
|
45
|
+
if (!plugin.shakeMenuEnabled) {
|
|
46
|
+
logger.info("Shake menu is disabled");
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Prevent multiple dialogs
|
|
51
|
+
if (isShowing) {
|
|
52
|
+
logger.info("Dialog already showing");
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
isShowing = true;
|
|
57
|
+
showShakeMenu();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
private void showShakeMenu() {
|
|
61
|
+
activity.runOnUiThread(() -> {
|
|
62
|
+
try {
|
|
63
|
+
String appName = activity.getPackageManager().getApplicationLabel(activity.getApplicationInfo()).toString();
|
|
64
|
+
String title = "Preview " + appName + " Menu";
|
|
65
|
+
String message = "What would you like to do?";
|
|
66
|
+
String okButtonTitle = "Go Home";
|
|
67
|
+
String reloadButtonTitle = "Reload app";
|
|
68
|
+
String cancelButtonTitle = "Close menu";
|
|
69
|
+
|
|
70
|
+
CapgoUpdater updater = plugin.implementation;
|
|
71
|
+
Bridge bridge = activity.getBridge();
|
|
72
|
+
|
|
73
|
+
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
|
74
|
+
builder.setTitle(title);
|
|
75
|
+
builder.setMessage(message);
|
|
76
|
+
|
|
77
|
+
// Go Home button
|
|
78
|
+
builder.setPositiveButton(
|
|
79
|
+
okButtonTitle,
|
|
80
|
+
new DialogInterface.OnClickListener() {
|
|
81
|
+
public void onClick(DialogInterface dialog, int id) {
|
|
82
|
+
try {
|
|
83
|
+
BundleInfo current = updater.getCurrentBundle();
|
|
84
|
+
logger.info("Current bundle: " + current.toString());
|
|
85
|
+
|
|
86
|
+
BundleInfo next = updater.getNextBundle();
|
|
87
|
+
logger.info("Next bundle: " + (next != null ? next.toString() : "null"));
|
|
88
|
+
|
|
89
|
+
if (next != null && !next.isBuiltin()) {
|
|
90
|
+
logger.info("Setting bundle to: " + next.toString());
|
|
91
|
+
updater.set(next);
|
|
92
|
+
String path = updater.getCurrentBundlePath();
|
|
93
|
+
logger.info("Setting server path: " + path);
|
|
94
|
+
if (updater.isUsingBuiltin()) {
|
|
95
|
+
bridge.setServerAssetPath(path);
|
|
96
|
+
} else {
|
|
97
|
+
bridge.setServerBasePath(path);
|
|
98
|
+
}
|
|
99
|
+
} else {
|
|
100
|
+
logger.info("Resetting to builtin");
|
|
101
|
+
updater.reset();
|
|
102
|
+
String path = updater.getCurrentBundlePath();
|
|
103
|
+
bridge.setServerAssetPath(path);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Try to delete the current bundle
|
|
107
|
+
try {
|
|
108
|
+
updater.delete(current.getId());
|
|
109
|
+
} catch (Exception err) {
|
|
110
|
+
logger.warn("Cannot delete version " + current.getId() + ": " + err.getMessage());
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
logger.info("Reload app done");
|
|
114
|
+
} catch (Exception e) {
|
|
115
|
+
logger.error("Error in Go Home action: " + e.getMessage());
|
|
116
|
+
} finally {
|
|
117
|
+
dialog.dismiss();
|
|
118
|
+
isShowing = false;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
// Reload button
|
|
125
|
+
builder.setNeutralButton(
|
|
126
|
+
reloadButtonTitle,
|
|
127
|
+
new DialogInterface.OnClickListener() {
|
|
128
|
+
public void onClick(DialogInterface dialog, int id) {
|
|
129
|
+
try {
|
|
130
|
+
logger.info("Reloading webview");
|
|
131
|
+
String pathHot = updater.getCurrentBundlePath();
|
|
132
|
+
bridge.setServerBasePath(pathHot);
|
|
133
|
+
activity.runOnUiThread(() -> {
|
|
134
|
+
if (bridge.getWebView() != null) {
|
|
135
|
+
bridge.getWebView().reload();
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
} catch (Exception e) {
|
|
139
|
+
logger.error("Error in Reload action: " + e.getMessage());
|
|
140
|
+
} finally {
|
|
141
|
+
dialog.dismiss();
|
|
142
|
+
isShowing = false;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
// Cancel button
|
|
149
|
+
builder.setNegativeButton(
|
|
150
|
+
cancelButtonTitle,
|
|
151
|
+
new DialogInterface.OnClickListener() {
|
|
152
|
+
public void onClick(DialogInterface dialog, int id) {
|
|
153
|
+
logger.info("Shake menu cancelled");
|
|
154
|
+
dialog.dismiss();
|
|
155
|
+
isShowing = false;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
AlertDialog dialog = builder.create();
|
|
161
|
+
dialog.setOnDismissListener((dialogInterface) -> isShowing = false);
|
|
162
|
+
dialog.show();
|
|
163
|
+
} catch (Exception e) {
|
|
164
|
+
logger.error("Error showing shake menu: " + e.getMessage());
|
|
165
|
+
isShowing = false;
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|