@capgo/capacitor-updater 7.8.3 → 7.8.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.
@@ -59,7 +59,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
59
59
  private static final String statsUrlDefault = "https://plugin.capgo.app/stats";
60
60
  private static final String channelUrlDefault = "https://plugin.capgo.app/channel_self";
61
61
 
62
- private final String PLUGIN_VERSION = "7.8.3";
62
+ private final String PLUGIN_VERSION = "7.8.4";
63
63
  private static final String DELAY_CONDITION_PREFERENCES = "";
64
64
 
65
65
  private SharedPreferences.Editor editor;
@@ -314,8 +314,8 @@ public class CapacitorUpdaterPlugin extends Plugin {
314
314
 
315
315
  PluginCall call = new PluginCall(
316
316
  (com.getcapacitor.MessageHandler) msgHandler,
317
- "autoHideSplashscreen",
318
- PluginCall.CALLBACK_ID_DANGLING,
317
+ "SplashScreen",
318
+ "FAKE_CALLBACK_ID_HIDE",
319
319
  "hide",
320
320
  options
321
321
  );
@@ -340,39 +340,52 @@ public class CapacitorUpdaterPlugin extends Plugin {
340
340
 
341
341
  private void showSplashscreen() {
342
342
  try {
343
- // Try to call the SplashScreen plugin directly through the bridge
343
+ // Show splashscreen immediately and synchronously when backgrounding
344
+ if (getBridge() == null) {
345
+ logger.warn("Bridge not ready for showing splashscreen with autoSplashscreen");
346
+ return;
347
+ }
348
+
349
+ // Execute immediately on current thread if it's main, otherwise post to main thread
350
+ if (android.os.Looper.myLooper() == android.os.Looper.getMainLooper()) {
351
+ showSplashscreenNow();
352
+ } else {
353
+ // Use runOnUiThread for immediate execution on main thread
354
+ if (getActivity() != null) {
355
+ getActivity().runOnUiThread(() -> showSplashscreenNow());
356
+ } else {
357
+ new android.os.Handler(android.os.Looper.getMainLooper()).post(() -> showSplashscreenNow());
358
+ }
359
+ }
360
+ } catch (Exception e) {
361
+ logger.error("Error showing splashscreen when backgrounding: " + e.getMessage());
362
+ }
363
+ }
364
+
365
+ private void showSplashscreenNow() {
366
+ try {
344
367
  PluginHandle splashScreenPlugin = getBridge().getPlugin("SplashScreen");
345
368
  if (splashScreenPlugin != null) {
346
- try {
347
- // Create a plugin call for the show method using reflection to access private msgHandler
348
- JSObject options = new JSObject();
349
- java.lang.reflect.Field msgHandlerField = getBridge().getClass().getDeclaredField("msgHandler");
350
- msgHandlerField.setAccessible(true);
351
- Object msgHandler = msgHandlerField.get(getBridge());
352
-
353
- PluginCall call = new PluginCall(
354
- (com.getcapacitor.MessageHandler) msgHandler,
355
- "autoShowSplashscreen",
356
- PluginCall.CALLBACK_ID_DANGLING,
357
- "show",
358
- options
359
- );
369
+ JSObject options = new JSObject();
370
+ java.lang.reflect.Field msgHandlerField = getBridge().getClass().getDeclaredField("msgHandler");
371
+ msgHandlerField.setAccessible(true);
372
+ Object msgHandler = msgHandlerField.get(getBridge());
373
+
374
+ PluginCall call = new PluginCall(
375
+ (com.getcapacitor.MessageHandler) msgHandler,
376
+ "SplashScreen",
377
+ "FAKE_CALLBACK_ID_SHOW",
378
+ "show",
379
+ options
380
+ );
360
381
 
361
- // Call the show method directly
362
- splashScreenPlugin.invoke("show", call);
363
- logger.info("Splashscreen shown automatically via direct plugin call");
364
- } catch (Exception e) {
365
- logger.error("Failed to call SplashScreen show method: " + e.getMessage());
366
- }
382
+ splashScreenPlugin.invoke("show", call);
383
+ logger.info("Splashscreen shown synchronously to prevent flash");
367
384
  } else {
368
- logger.warn("autoSplashscreen: SplashScreen plugin not found. Install @capacitor/splash-screen plugin.");
385
+ logger.warn("autoSplashscreen: SplashScreen plugin not found");
369
386
  }
370
387
  } catch (Exception e) {
371
- logger.error(
372
- "Error showing splashscreen with autoSplashscreen: " +
373
- e.getMessage() +
374
- ". Make sure @capacitor/splash-screen plugin is installed and configured."
375
- );
388
+ logger.error("Failed to show splashscreen synchronously: " + e.getMessage());
376
389
  }
377
390
  }
378
391
 
@@ -1519,6 +1532,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
1519
1532
  CapacitorUpdaterPlugin.this.implementation.sendStats("app_moved_to_foreground", current.getVersionName());
1520
1533
  this.delayUpdateUtils.checkCancelDelay(DelayUpdateUtils.CancelDelaySource.FOREGROUND);
1521
1534
  this.delayUpdateUtils.unsetBackgroundTimestamp();
1535
+
1522
1536
  if (
1523
1537
  CapacitorUpdaterPlugin.this._isAutoUpdateEnabled() &&
1524
1538
  (this.backgroundDownloadTask == null || !this.backgroundDownloadTask.isAlive())
@@ -1533,10 +1547,8 @@ public class CapacitorUpdaterPlugin extends Plugin {
1533
1547
 
1534
1548
  public void appMovedToBackground() {
1535
1549
  final BundleInfo current = CapacitorUpdaterPlugin.this.implementation.getCurrentBundle();
1536
- CapacitorUpdaterPlugin.this.implementation.sendStats("app_moved_to_background", current.getVersionName());
1537
- logger.info("Checking for pending update");
1538
1550
 
1539
- // Show splashscreen only if autoSplashscreen is enabled AND autoUpdate is enabled AND directUpdate would be used
1551
+ // Show splashscreen FIRST, before any other background work to ensure launcher shows it
1540
1552
  if (this.autoSplashscreen) {
1541
1553
  boolean canShowSplashscreen = true;
1542
1554
 
@@ -1555,10 +1567,15 @@ public class CapacitorUpdaterPlugin extends Plugin {
1555
1567
  }
1556
1568
 
1557
1569
  if (canShowSplashscreen) {
1570
+ logger.info("Showing splashscreen for launcher/task switcher");
1558
1571
  this.showSplashscreen();
1559
1572
  }
1560
1573
  }
1561
1574
 
1575
+ // Do other background work after splashscreen is shown
1576
+ CapacitorUpdaterPlugin.this.implementation.sendStats("app_moved_to_background", current.getVersionName());
1577
+ logger.info("Checking for pending update");
1578
+
1562
1579
  try {
1563
1580
  // We need to set "backgrounded time"
1564
1581
  this.delayUpdateUtils.setBackgroundTimestamp(System.currentTimeMillis());
@@ -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.8.3"
53
+ private let PLUGIN_VERSION: String = "7.8.4"
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"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-updater",
3
- "version": "7.8.3",
3
+ "version": "7.8.4",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Live update for capacitor apps",
6
6
  "main": "dist/plugin.cjs.js",