@capgo/capacitor-updater 7.8.2 → 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.2";
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,51 +340,52 @@ public class CapacitorUpdaterPlugin extends Plugin {
340
340
 
341
341
  private void showSplashscreen() {
342
342
  try {
343
- // Check if bridge is ready
343
+ // Show splashscreen immediately and synchronously when backgrounding
344
344
  if (getBridge() == null) {
345
- logger.warn("Bridge not ready for showing splashscreen with autoSplashscreen. Retrying in 100ms.");
346
- new android.os.Handler(android.os.Looper.getMainLooper()).postDelayed(
347
- () -> {
348
- showSplashscreen(); // Retry once
349
- },
350
- 100
351
- );
345
+ logger.warn("Bridge not ready for showing splashscreen with autoSplashscreen");
352
346
  return;
353
347
  }
354
348
 
355
- // Try to call the SplashScreen plugin directly through the bridge
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 {
356
367
  PluginHandle splashScreenPlugin = getBridge().getPlugin("SplashScreen");
357
368
  if (splashScreenPlugin != null) {
358
- try {
359
- // Create a plugin call for the show method using reflection to access private msgHandler
360
- JSObject options = new JSObject();
361
- java.lang.reflect.Field msgHandlerField = getBridge().getClass().getDeclaredField("msgHandler");
362
- msgHandlerField.setAccessible(true);
363
- Object msgHandler = msgHandlerField.get(getBridge());
364
-
365
- PluginCall call = new PluginCall(
366
- (com.getcapacitor.MessageHandler) msgHandler,
367
- "autoShowSplashscreen",
368
- PluginCall.CALLBACK_ID_DANGLING,
369
- "show",
370
- options
371
- );
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
+ );
372
381
 
373
- // Call the show method directly
374
- splashScreenPlugin.invoke("show", call);
375
- logger.info("Splashscreen shown automatically via direct plugin call");
376
- } catch (Exception e) {
377
- logger.error("Failed to call SplashScreen show method: " + e.getMessage());
378
- }
382
+ splashScreenPlugin.invoke("show", call);
383
+ logger.info("Splashscreen shown synchronously to prevent flash");
379
384
  } else {
380
- logger.warn("autoSplashscreen: SplashScreen plugin not found. Install @capacitor/splash-screen plugin.");
385
+ logger.warn("autoSplashscreen: SplashScreen plugin not found");
381
386
  }
382
387
  } catch (Exception e) {
383
- logger.error(
384
- "Error showing splashscreen with autoSplashscreen: " +
385
- e.getMessage() +
386
- ". Make sure @capacitor/splash-screen plugin is installed and configured."
387
- );
388
+ logger.error("Failed to show splashscreen synchronously: " + e.getMessage());
388
389
  }
389
390
  }
390
391
 
@@ -1531,6 +1532,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
1531
1532
  CapacitorUpdaterPlugin.this.implementation.sendStats("app_moved_to_foreground", current.getVersionName());
1532
1533
  this.delayUpdateUtils.checkCancelDelay(DelayUpdateUtils.CancelDelaySource.FOREGROUND);
1533
1534
  this.delayUpdateUtils.unsetBackgroundTimestamp();
1535
+
1534
1536
  if (
1535
1537
  CapacitorUpdaterPlugin.this._isAutoUpdateEnabled() &&
1536
1538
  (this.backgroundDownloadTask == null || !this.backgroundDownloadTask.isAlive())
@@ -1545,10 +1547,8 @@ public class CapacitorUpdaterPlugin extends Plugin {
1545
1547
 
1546
1548
  public void appMovedToBackground() {
1547
1549
  final BundleInfo current = CapacitorUpdaterPlugin.this.implementation.getCurrentBundle();
1548
- CapacitorUpdaterPlugin.this.implementation.sendStats("app_moved_to_background", current.getVersionName());
1549
- logger.info("Checking for pending update");
1550
1550
 
1551
- // 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
1552
1552
  if (this.autoSplashscreen) {
1553
1553
  boolean canShowSplashscreen = true;
1554
1554
 
@@ -1567,10 +1567,15 @@ public class CapacitorUpdaterPlugin extends Plugin {
1567
1567
  }
1568
1568
 
1569
1569
  if (canShowSplashscreen) {
1570
+ logger.info("Showing splashscreen for launcher/task switcher");
1570
1571
  this.showSplashscreen();
1571
1572
  }
1572
1573
  }
1573
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
+
1574
1579
  try {
1575
1580
  // We need to set "backgrounded time"
1576
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.2"
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.2",
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",