@capgo/capacitor-updater 8.47.4 → 8.47.6
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/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +314 -36
- package/android/src/main/java/ee/forgr/capacitor_updater/CapgoUpdater.java +278 -260
- package/android/src/main/java/ee/forgr/capacitor_updater/DownloadService.java +23 -26
- package/android/src/main/java/ee/forgr/capacitor_updater/ShakeMenu.java +45 -52
- package/ios/Sources/CapacitorUpdaterPlugin/CapacitorUpdaterPlugin.swift +317 -13
- package/ios/Sources/CapacitorUpdaterPlugin/ShakeMenu.swift +1 -1
- package/package.json +1 -1
|
@@ -115,15 +115,13 @@ public class DownloadService extends Worker {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
StringBuilder sanitized = new StringBuilder();
|
|
118
|
-
value
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
});
|
|
118
|
+
value.codePoints().forEach((cp) -> {
|
|
119
|
+
boolean isVisibleAscii = cp >= 0x20 && cp <= 0x7E;
|
|
120
|
+
boolean isIso88591 = cp >= 0xA0 && cp <= 0xFF;
|
|
121
|
+
if (isVisibleAscii || isIso88591) {
|
|
122
|
+
sanitized.appendCodePoint(cp);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
127
125
|
|
|
128
126
|
String result = sanitized.toString().trim();
|
|
129
127
|
return result.isEmpty() ? "unknown" : result;
|
|
@@ -255,27 +253,26 @@ public class DownloadService extends Worker {
|
|
|
255
253
|
.post(RequestBody.create(json.toString(), MediaType.get("application/json")))
|
|
256
254
|
.build();
|
|
257
255
|
|
|
258
|
-
sharedClient
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
if (logger != null) {
|
|
265
|
-
logger.error("Failed to send stats: " + e.getMessage());
|
|
266
|
-
}
|
|
256
|
+
sharedClient.newCall(request).enqueue(
|
|
257
|
+
new Callback() {
|
|
258
|
+
@Override
|
|
259
|
+
public void onFailure(@NonNull Call call, @NonNull IOException e) {
|
|
260
|
+
if (logger != null) {
|
|
261
|
+
logger.error("Failed to send stats: " + e.getMessage());
|
|
267
262
|
}
|
|
263
|
+
}
|
|
268
264
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
265
|
+
@Override
|
|
266
|
+
public void onResponse(@NonNull Call call, @NonNull Response response) {
|
|
267
|
+
try (ResponseBody body = response.body()) {
|
|
268
|
+
// nothing else to do, just closing body
|
|
269
|
+
} catch (Exception ignored) {
|
|
270
|
+
} finally {
|
|
271
|
+
response.close();
|
|
276
272
|
}
|
|
277
273
|
}
|
|
278
|
-
|
|
274
|
+
}
|
|
275
|
+
);
|
|
279
276
|
} catch (Exception e) {
|
|
280
277
|
if (logger != null) {
|
|
281
278
|
logger.error("sendStatsAsync error: " + e.getMessage());
|
|
@@ -111,49 +111,43 @@ public class ShakeMenu implements ShakeDetector.Listener {
|
|
|
111
111
|
AlertDialog dialog = builder.create();
|
|
112
112
|
dialog.setOnDismissListener((dialogInterface) -> isShowing = false);
|
|
113
113
|
dialog.show();
|
|
114
|
-
dialog
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
if (!plugin.leavePreviewSessionFromShakeMenu()) {
|
|
121
|
-
activity.runOnUiThread(() -> showError("Could not leave the test app."));
|
|
122
|
-
}
|
|
123
|
-
} catch (Exception e) {
|
|
124
|
-
logger.error("Error leaving test app: " + e.getMessage());
|
|
125
|
-
activity.runOnUiThread(() -> showError("Error leaving test app: " + e.getMessage()));
|
|
126
|
-
} finally {
|
|
127
|
-
activity.runOnUiThread(() -> {
|
|
128
|
-
dialog.dismiss();
|
|
129
|
-
isShowing = false;
|
|
130
|
-
});
|
|
114
|
+
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener((view) -> {
|
|
115
|
+
setPreviewMenuButtonsEnabled(dialog, false);
|
|
116
|
+
new Thread(() -> {
|
|
117
|
+
try {
|
|
118
|
+
if (!plugin.leavePreviewSessionFromShakeMenu()) {
|
|
119
|
+
activity.runOnUiThread(() -> showError("Could not leave the test app."));
|
|
131
120
|
}
|
|
132
|
-
})
|
|
133
|
-
.
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
activity.runOnUiThread(() ->
|
|
150
|
-
dialog.dismiss();
|
|
151
|
-
isShowing = false;
|
|
152
|
-
});
|
|
121
|
+
} catch (Exception e) {
|
|
122
|
+
logger.error("Error leaving test app: " + e.getMessage());
|
|
123
|
+
activity.runOnUiThread(() -> showError("Error leaving test app: " + e.getMessage()));
|
|
124
|
+
} finally {
|
|
125
|
+
activity.runOnUiThread(() -> {
|
|
126
|
+
dialog.dismiss();
|
|
127
|
+
isShowing = false;
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}).start();
|
|
131
|
+
});
|
|
132
|
+
dialog.getButton(AlertDialog.BUTTON_NEUTRAL).setOnClickListener((view) -> {
|
|
133
|
+
setPreviewMenuButtonsEnabled(dialog, false);
|
|
134
|
+
new Thread(() -> {
|
|
135
|
+
try {
|
|
136
|
+
logger.info("Reloading webview");
|
|
137
|
+
if (!plugin.reloadPreviewSessionFromShakeMenu()) {
|
|
138
|
+
activity.runOnUiThread(() -> showError("Could not reload the test app."));
|
|
153
139
|
}
|
|
154
|
-
})
|
|
155
|
-
.
|
|
156
|
-
|
|
140
|
+
} catch (Exception e) {
|
|
141
|
+
logger.error("Error in Reload action: " + e.getMessage());
|
|
142
|
+
activity.runOnUiThread(() -> showError("Error reloading test app: " + e.getMessage()));
|
|
143
|
+
} finally {
|
|
144
|
+
activity.runOnUiThread(() -> {
|
|
145
|
+
dialog.dismiss();
|
|
146
|
+
isShowing = false;
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}).start();
|
|
150
|
+
});
|
|
157
151
|
} catch (Exception e) {
|
|
158
152
|
logger.error("Error showing shake menu: " + e.getMessage());
|
|
159
153
|
isShowing = false;
|
|
@@ -351,8 +345,7 @@ public class ShakeMenu implements ShakeDetector.Listener {
|
|
|
351
345
|
presentChannelPicker(channels);
|
|
352
346
|
});
|
|
353
347
|
});
|
|
354
|
-
})
|
|
355
|
-
.start();
|
|
348
|
+
}).start();
|
|
356
349
|
} catch (Exception e) {
|
|
357
350
|
logger.error("Error showing channel selector: " + e.getMessage());
|
|
358
351
|
isShowing = false;
|
|
@@ -543,13 +536,14 @@ public class ShakeMenu implements ShakeDetector.Listener {
|
|
|
543
536
|
String latestKind = getString(latestRes, "kind");
|
|
544
537
|
String latestMessage = getString(latestRes, "message");
|
|
545
538
|
|
|
546
|
-
String detail =
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
539
|
+
String detail =
|
|
540
|
+
latestMessage != null && !latestMessage.isEmpty()
|
|
541
|
+
? latestMessage
|
|
542
|
+
: latestError != null && !latestError.isEmpty()
|
|
543
|
+
? latestError
|
|
544
|
+
: latestKind != null && !latestKind.isEmpty()
|
|
545
|
+
? latestKind
|
|
546
|
+
: "server did not provide a message";
|
|
553
547
|
|
|
554
548
|
// Handle update errors first (before "no new version" check)
|
|
555
549
|
if (
|
|
@@ -668,8 +662,7 @@ public class ShakeMenu implements ShakeDetector.Listener {
|
|
|
668
662
|
});
|
|
669
663
|
}
|
|
670
664
|
);
|
|
671
|
-
})
|
|
672
|
-
.start();
|
|
665
|
+
}).start();
|
|
673
666
|
} catch (Exception e) {
|
|
674
667
|
logger.error("Error selecting channel: " + e.getMessage());
|
|
675
668
|
isShowing = false;
|