@capgo/capacitor-updater 7.17.2 → 7.17.3
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/build.gradle +1 -1
- package/android/proguard-rules.pro +1 -7
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +7 -12
- package/android/src/main/java/ee/forgr/capacitor_updater/DelayCondition.java +0 -3
- package/android/src/main/java/ee/forgr/capacitor_updater/DelayUpdateUtils.java +51 -7
- package/ios/Sources/CapacitorUpdaterPlugin/CapacitorUpdaterPlugin.swift +1 -1
- package/package.json +1 -1
package/android/build.gradle
CHANGED
|
@@ -57,9 +57,9 @@ dependencies {
|
|
|
57
57
|
implementation project(':capacitor-android')
|
|
58
58
|
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
59
59
|
implementation 'io.github.g00fy2:versioncompare:1.5.0'
|
|
60
|
-
implementation 'com.google.code.gson:gson:2.13.2'
|
|
61
60
|
testImplementation "junit:junit:$junitVersion"
|
|
62
61
|
testImplementation 'org.mockito:mockito-core:5.14.2'
|
|
62
|
+
testImplementation 'org.json:json:20250517'
|
|
63
63
|
testImplementation 'org.robolectric:robolectric:4.13'
|
|
64
64
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
65
65
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
@@ -20,15 +20,12 @@
|
|
|
20
20
|
# hide the original source file name.
|
|
21
21
|
#-renamesourcefileattribute SourceFile
|
|
22
22
|
|
|
23
|
-
#
|
|
23
|
+
# Preserve annotation and signature metadata used by runtime checks
|
|
24
24
|
-keepattributes *Annotation*, Signature
|
|
25
25
|
|
|
26
26
|
# Preserve the entire Capgo plugin package
|
|
27
27
|
-keep class ee.forgr.capacitor_updater.** { *; }
|
|
28
28
|
|
|
29
|
-
# Keep all Guava reflect types (required for TypeToken)
|
|
30
|
-
-keep class com.google.common.reflect.** { *; }
|
|
31
|
-
|
|
32
29
|
# Preserve Capacitor classes and members accessed via reflection for autoSplashscreen
|
|
33
30
|
# These rules are safe even if SplashScreen plugin is not present - they only reference core Capacitor classes
|
|
34
31
|
-keep class com.getcapacitor.Bridge {
|
|
@@ -46,6 +43,3 @@
|
|
|
46
43
|
-keep class * implements com.getcapacitor.PluginHandle {
|
|
47
44
|
public void invoke(java.lang.String, com.getcapacitor.PluginCall);
|
|
48
45
|
}
|
|
49
|
-
-keepattributes Signature
|
|
50
|
-
-keep class com.google.common.reflect.TypeToken
|
|
51
|
-
-keep class com.google.common.reflect.TypeToken$TypeSet
|
|
@@ -23,11 +23,8 @@ import com.getcapacitor.PluginHandle;
|
|
|
23
23
|
import com.getcapacitor.PluginMethod;
|
|
24
24
|
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
25
25
|
import com.getcapacitor.plugin.WebView;
|
|
26
|
-
import com.google.gson.Gson;
|
|
27
|
-
import com.google.gson.reflect.TypeToken;
|
|
28
26
|
import io.github.g00fy2.versioncompare.Version;
|
|
29
27
|
import java.io.IOException;
|
|
30
|
-
import java.lang.reflect.Type;
|
|
31
28
|
import java.net.MalformedURLException;
|
|
32
29
|
import java.net.URL;
|
|
33
30
|
import java.util.ArrayList;
|
|
@@ -60,7 +57,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
60
57
|
private static final String statsUrlDefault = "https://plugin.capgo.app/stats";
|
|
61
58
|
private static final String channelUrlDefault = "https://plugin.capgo.app/channel_self";
|
|
62
59
|
|
|
63
|
-
private final String PLUGIN_VERSION = "7.17.
|
|
60
|
+
private final String PLUGIN_VERSION = "7.17.3";
|
|
64
61
|
private static final String DELAY_CONDITION_PREFERENCES = "";
|
|
65
62
|
|
|
66
63
|
private SharedPreferences.Editor editor;
|
|
@@ -1363,14 +1360,14 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
1363
1360
|
if (latest.isDownloaded()) {
|
|
1364
1361
|
logger.info("Latest bundle already exists and download is NOT required. " + messageUpdate);
|
|
1365
1362
|
if (shouldDirectUpdate) {
|
|
1366
|
-
Gson gson = new Gson();
|
|
1367
1363
|
String delayUpdatePreferences = prefs.getString(
|
|
1368
1364
|
DelayUpdateUtils.DELAY_CONDITION_PREFERENCES,
|
|
1369
1365
|
"[]"
|
|
1370
1366
|
);
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1367
|
+
ArrayList<DelayCondition> delayConditionList = delayUpdateUtils.parseDelayConditions(
|
|
1368
|
+
delayUpdatePreferences
|
|
1369
|
+
);
|
|
1370
|
+
if (!delayConditionList.isEmpty()) {
|
|
1374
1371
|
logger.info("Update delayed until delay conditions met");
|
|
1375
1372
|
CapacitorUpdaterPlugin.this.endBackGroundTaskWithNotif(
|
|
1376
1373
|
"Update delayed until delay conditions met",
|
|
@@ -1498,11 +1495,9 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
1498
1495
|
|
|
1499
1496
|
private void installNext() {
|
|
1500
1497
|
try {
|
|
1501
|
-
Gson gson = new Gson();
|
|
1502
1498
|
String delayUpdatePreferences = prefs.getString(DelayUpdateUtils.DELAY_CONDITION_PREFERENCES, "[]");
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
if (delayConditionList != null && !delayConditionList.isEmpty()) {
|
|
1499
|
+
ArrayList<DelayCondition> delayConditionList = delayUpdateUtils.parseDelayConditions(delayUpdatePreferences);
|
|
1500
|
+
if (!delayConditionList.isEmpty()) {
|
|
1506
1501
|
logger.info("Update delayed until delay conditions met");
|
|
1507
1502
|
return;
|
|
1508
1503
|
}
|
|
@@ -7,15 +7,12 @@
|
|
|
7
7
|
package ee.forgr.capacitor_updater;
|
|
8
8
|
|
|
9
9
|
import androidx.annotation.NonNull;
|
|
10
|
-
import com.google.gson.annotations.SerializedName;
|
|
11
10
|
import java.util.Objects;
|
|
12
11
|
|
|
13
12
|
public class DelayCondition {
|
|
14
13
|
|
|
15
|
-
@SerializedName("kind")
|
|
16
14
|
private DelayUntilNext kind;
|
|
17
15
|
|
|
18
|
-
@SerializedName("value")
|
|
19
16
|
private String value;
|
|
20
17
|
|
|
21
18
|
public DelayCondition(DelayUntilNext kind, String value) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
package ee.forgr.capacitor_updater;
|
|
2
2
|
|
|
3
3
|
import android.content.SharedPreferences;
|
|
4
|
-
import com.google.common.reflect.TypeToken;
|
|
5
|
-
import com.google.gson.Gson;
|
|
6
4
|
import io.github.g00fy2.versioncompare.Version;
|
|
7
|
-
import java.lang.reflect.Type;
|
|
8
5
|
import java.text.SimpleDateFormat;
|
|
9
6
|
import java.util.ArrayList;
|
|
10
7
|
import java.util.Date;
|
|
8
|
+
import org.json.JSONArray;
|
|
9
|
+
import org.json.JSONException;
|
|
10
|
+
import org.json.JSONObject;
|
|
11
11
|
|
|
12
12
|
public class DelayUpdateUtils {
|
|
13
13
|
|
|
@@ -42,10 +42,8 @@ public class DelayUpdateUtils {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
public void checkCancelDelay(CancelDelaySource source) {
|
|
45
|
-
Gson gson = new Gson();
|
|
46
45
|
String delayUpdatePreferences = prefs.getString(DELAY_CONDITION_PREFERENCES, "[]");
|
|
47
|
-
|
|
48
|
-
ArrayList<DelayCondition> delayConditionList = gson.fromJson(delayUpdatePreferences, type);
|
|
46
|
+
ArrayList<DelayCondition> delayConditionList = parseDelayConditions(delayUpdatePreferences);
|
|
49
47
|
ArrayList<DelayCondition> delayConditionListToKeep = new ArrayList<>(delayConditionList.size());
|
|
50
48
|
int index = 0;
|
|
51
49
|
|
|
@@ -163,10 +161,56 @@ public class DelayUpdateUtils {
|
|
|
163
161
|
}
|
|
164
162
|
|
|
165
163
|
if (!delayConditionListToKeep.isEmpty()) {
|
|
166
|
-
this.setMultiDelay(
|
|
164
|
+
this.setMultiDelay(convertDelayConditionsToJson(delayConditionListToKeep));
|
|
167
165
|
}
|
|
168
166
|
}
|
|
169
167
|
|
|
168
|
+
public ArrayList<DelayCondition> parseDelayConditions(String json) {
|
|
169
|
+
ArrayList<DelayCondition> conditions = new ArrayList<>();
|
|
170
|
+
if (json == null || json.isEmpty()) {
|
|
171
|
+
return conditions;
|
|
172
|
+
}
|
|
173
|
+
try {
|
|
174
|
+
JSONArray array = new JSONArray(json);
|
|
175
|
+
for (int i = 0; i < array.length(); i++) {
|
|
176
|
+
JSONObject item = array.optJSONObject(i);
|
|
177
|
+
if (item == null) {
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
String kindValue = item.optString("kind", "");
|
|
181
|
+
String value = item.optString("value", "");
|
|
182
|
+
if (kindValue.isEmpty()) {
|
|
183
|
+
logger.warn("Delay condition missing kind at index " + i);
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
try {
|
|
187
|
+
DelayUntilNext kind = DelayUntilNext.valueOf(kindValue);
|
|
188
|
+
conditions.add(new DelayCondition(kind, value));
|
|
189
|
+
} catch (IllegalArgumentException e) {
|
|
190
|
+
logger.warn("Unknown delay condition kind '" + kindValue + "' at index " + i);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
} catch (JSONException e) {
|
|
194
|
+
logger.error("Failed to parse delay conditions: " + e.getMessage());
|
|
195
|
+
}
|
|
196
|
+
return conditions;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
private String convertDelayConditionsToJson(ArrayList<DelayCondition> conditions) {
|
|
200
|
+
JSONArray array = new JSONArray();
|
|
201
|
+
for (DelayCondition condition : conditions) {
|
|
202
|
+
try {
|
|
203
|
+
JSONObject obj = new JSONObject();
|
|
204
|
+
obj.put("kind", condition.getKind().name());
|
|
205
|
+
obj.put("value", condition.getValue());
|
|
206
|
+
array.put(obj);
|
|
207
|
+
} catch (JSONException e) {
|
|
208
|
+
logger.error("Failed to serialize delay condition: " + e.getMessage());
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return array.toString();
|
|
212
|
+
}
|
|
213
|
+
|
|
170
214
|
public Boolean setMultiDelay(String delayConditions) {
|
|
171
215
|
try {
|
|
172
216
|
this.editor.putString(DELAY_CONDITION_PREFERENCES, delayConditions);
|
|
@@ -50,7 +50,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
50
50
|
CAPPluginMethod(name: "isShakeMenuEnabled", returnType: CAPPluginReturnPromise)
|
|
51
51
|
]
|
|
52
52
|
public var implementation = CapgoUpdater()
|
|
53
|
-
private let PLUGIN_VERSION: String = "7.17.
|
|
53
|
+
private let PLUGIN_VERSION: String = "7.17.3"
|
|
54
54
|
static let updateUrlDefault = "https://plugin.capgo.app/updates"
|
|
55
55
|
static let statsUrlDefault = "https://plugin.capgo.app/stats"
|
|
56
56
|
static let channelUrlDefault = "https://plugin.capgo.app/channel_self"
|