@capgo/capacitor-updater 5.2.2 → 5.2.4
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.
|
@@ -78,6 +78,7 @@ public class CapacitorUpdater {
|
|
|
78
78
|
public RequestQueue requestQueue;
|
|
79
79
|
|
|
80
80
|
public File documentsDir;
|
|
81
|
+
public Boolean directUpdate = false;
|
|
81
82
|
public Activity activity;
|
|
82
83
|
public String PLUGIN_VERSION = "";
|
|
83
84
|
public String versionBuild = "";
|
|
@@ -369,7 +370,11 @@ public class CapacitorUpdater {
|
|
|
369
370
|
ret.put("bundle", next.toJSON());
|
|
370
371
|
CapacitorUpdater.this.notifyListeners("updateAvailable", ret);
|
|
371
372
|
if (setNext) {
|
|
372
|
-
this.
|
|
373
|
+
if (this.directUpdate) {
|
|
374
|
+
this.set(next);
|
|
375
|
+
} else {
|
|
376
|
+
this.setNextBundle(next.getId());
|
|
377
|
+
}
|
|
373
378
|
}
|
|
374
379
|
} catch (IOException e) {
|
|
375
380
|
e.printStackTrace();
|
|
@@ -55,7 +55,7 @@ public class CapacitorUpdaterPlugin
|
|
|
55
55
|
private static final String channelUrlDefault =
|
|
56
56
|
"https://api.capgo.app/channel_self";
|
|
57
57
|
|
|
58
|
-
private final String PLUGIN_VERSION = "5.2.
|
|
58
|
+
private final String PLUGIN_VERSION = "5.2.4";
|
|
59
59
|
private static final String DELAY_CONDITION_PREFERENCES = "";
|
|
60
60
|
|
|
61
61
|
private SharedPreferences.Editor editor;
|
|
@@ -72,7 +72,6 @@ public class CapacitorUpdaterPlugin
|
|
|
72
72
|
private Boolean resetWhenUpdate = true;
|
|
73
73
|
private Thread backgroundTask;
|
|
74
74
|
private Boolean taskRunning = false;
|
|
75
|
-
private Boolean directUpdate = false;
|
|
76
75
|
|
|
77
76
|
private Boolean isPreviousMainActivity = true;
|
|
78
77
|
|
|
@@ -113,7 +112,8 @@ public class CapacitorUpdaterPlugin
|
|
|
113
112
|
this.implementation.versionCode = Integer.toString(pInfo.versionCode);
|
|
114
113
|
this.implementation.requestQueue =
|
|
115
114
|
Volley.newRequestQueue(this.getContext());
|
|
116
|
-
this.directUpdate =
|
|
115
|
+
this.implementation.directUpdate =
|
|
116
|
+
this.getConfig().getBoolean("directUpdate", false);
|
|
117
117
|
this.currentVersionNative =
|
|
118
118
|
new Version(this.getConfig().getString("version", pInfo.versionName));
|
|
119
119
|
} catch (final PackageManager.NameNotFoundException e) {
|
|
@@ -837,6 +837,9 @@ public class CapacitorUpdaterPlugin
|
|
|
837
837
|
}
|
|
838
838
|
|
|
839
839
|
private void backgroundDownload() {
|
|
840
|
+
String messageUpdate = this.implementation.directUpdate
|
|
841
|
+
? "Update will occur now."
|
|
842
|
+
: "Update will occur next time app moves to background.";
|
|
840
843
|
new Thread(
|
|
841
844
|
new Runnable() {
|
|
842
845
|
@Override
|
|
@@ -919,9 +922,12 @@ public class CapacitorUpdaterPlugin
|
|
|
919
922
|
if (latest.isDownloaded()) {
|
|
920
923
|
Log.i(
|
|
921
924
|
CapacitorUpdater.TAG,
|
|
922
|
-
"Latest bundle already exists and download is NOT required.
|
|
925
|
+
"Latest bundle already exists and download is NOT required. " +
|
|
926
|
+
messageUpdate
|
|
923
927
|
);
|
|
924
|
-
if (
|
|
928
|
+
if (
|
|
929
|
+
CapacitorUpdaterPlugin.this.implementation.directUpdate
|
|
930
|
+
) {
|
|
925
931
|
CapacitorUpdaterPlugin.this.implementation.set(
|
|
926
932
|
latest
|
|
927
933
|
);
|
|
@@ -985,7 +991,8 @@ public class CapacitorUpdaterPlugin
|
|
|
985
991
|
latestVersionName +
|
|
986
992
|
" found. Current is: " +
|
|
987
993
|
current.getVersionName() +
|
|
988
|
-
".
|
|
994
|
+
". " +
|
|
995
|
+
messageUpdate
|
|
989
996
|
);
|
|
990
997
|
|
|
991
998
|
final String url = res.getString("url");
|
|
@@ -15,7 +15,7 @@ import Version
|
|
|
15
15
|
@objc(CapacitorUpdaterPlugin)
|
|
16
16
|
public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
17
17
|
private var implementation = CapacitorUpdater()
|
|
18
|
-
private let PLUGIN_VERSION: String = "5.2.
|
|
18
|
+
private let PLUGIN_VERSION: String = "5.2.4"
|
|
19
19
|
static let updateUrlDefault = "https://api.capgo.app/updates"
|
|
20
20
|
static let statsUrlDefault = "https://api.capgo.app/stats"
|
|
21
21
|
static let channelUrlDefault = "https://api.capgo.app/channel_self"
|
|
@@ -499,6 +499,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
|
499
499
|
}
|
|
500
500
|
|
|
501
501
|
func backgroundDownload() {
|
|
502
|
+
let messageUpdate = self.directUpdate ? "Update will occur now." : "Update will occur next time app moves to background."
|
|
502
503
|
DispatchQueue.global(qos: .background).async {
|
|
503
504
|
self.backgroundTaskID = UIApplication.shared.beginBackgroundTask(withName: "Finish Download Tasks") {
|
|
504
505
|
// End the task if time expires.
|
|
@@ -527,9 +528,8 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
|
527
528
|
}
|
|
528
529
|
let latestVersionName = res.version
|
|
529
530
|
if latestVersionName != "" && current.getVersionName() != latestVersionName {
|
|
530
|
-
let latest = self.implementation.getBundleInfoByVersionName(version: latestVersionName)
|
|
531
531
|
do {
|
|
532
|
-
print("\(self.implementation.TAG) New bundle: \(latestVersionName) found. Current is: \(current.getVersionName()).
|
|
532
|
+
print("\(self.implementation.TAG) New bundle: \(latestVersionName) found. Current is: \(current.getVersionName()). \(messageUpdate)")
|
|
533
533
|
var nextImpl = self.implementation.getBundleInfoByVersionName(version: latestVersionName)
|
|
534
534
|
if nextImpl == nil || ((nextImpl?.isDeleted()) != nil) {
|
|
535
535
|
if (nextImpl?.isDeleted()) != nil {
|
|
@@ -567,8 +567,8 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
|
567
567
|
throw ObjectSavableError.checksum
|
|
568
568
|
}
|
|
569
569
|
if self.directUpdate {
|
|
570
|
-
self.implementation.set(bundle: next)
|
|
571
|
-
self._reload()
|
|
570
|
+
_ = self.implementation.set(bundle: next)
|
|
571
|
+
_ = self._reload()
|
|
572
572
|
} else {
|
|
573
573
|
self.notifyListeners("updateAvailable", data: ["bundle": next.toJSON()])
|
|
574
574
|
_ = self.implementation.setNextBundle(next: next.getId())
|