@capgo/capacitor-updater 4.17.33 → 4.17.34

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.
@@ -5,7 +5,6 @@ import android.app.ActivityManager;
5
5
  import android.app.Application;
6
6
  import android.content.Context;
7
7
  import android.content.SharedPreferences;
8
- import android.content.pm.ActivityInfo;
9
8
  import android.content.pm.PackageInfo;
10
9
  import android.content.pm.PackageManager;
11
10
  import android.os.Build;
@@ -50,7 +49,7 @@ public class CapacitorUpdaterPlugin
50
49
  private static final String channelUrlDefault =
51
50
  "https://api.capgo.app/channel_self";
52
51
 
53
- private final String PLUGIN_VERSION = "4.17.33";
52
+ private final String PLUGIN_VERSION = "4.17.34";
54
53
  private static final String DELAY_CONDITION_PREFERENCES = "";
55
54
 
56
55
  private SharedPreferences.Editor editor;
@@ -67,6 +66,8 @@ public class CapacitorUpdaterPlugin
67
66
  private Thread backgroundTask;
68
67
  private Boolean taskRunning = false;
69
68
 
69
+ private Boolean isPreviousMainActivity = true;
70
+
70
71
  private volatile Thread appReadyCheck;
71
72
 
72
73
  @Override
@@ -1217,49 +1218,33 @@ public class CapacitorUpdaterPlugin
1217
1218
  }
1218
1219
  }
1219
1220
 
1220
- @Override
1221
- public void onActivityStarted(@NonNull final Activity activity) {
1222
- this.appMovedToForeground();
1223
- }
1224
-
1225
- @Override
1226
- public void onActivityStopped(@NonNull final Activity activity) {
1221
+ private boolean isMainActivity() {
1227
1222
  Context mContext = this.getContext();
1228
1223
  ActivityManager activityManager = (ActivityManager) mContext.getSystemService(
1229
1224
  Context.ACTIVITY_SERVICE
1230
1225
  );
1231
1226
  List<ActivityManager.AppTask> runningTasks = activityManager.getAppTasks();
1232
- String runningActivity = runningTasks
1233
- .get(0)
1234
- .getTaskInfo()
1235
- .topActivity.getClassName();
1236
1227
  ActivityManager.RecentTaskInfo runningTask = runningTasks
1237
1228
  .get(0)
1238
1229
  .getTaskInfo();
1239
1230
  String className = runningTask.baseIntent.getComponent().getClassName();
1240
- ActivityInfo[] activities = null;
1241
- try {
1242
- activities =
1243
- mContext
1244
- .getPackageManager()
1245
- .getPackageInfo(
1246
- mContext.getPackageName(),
1247
- PackageManager.GET_ACTIVITIES
1248
- )
1249
- .activities;
1250
- } catch (PackageManager.NameNotFoundException e) {
1251
- e.printStackTrace();
1252
- }
1253
- boolean isThisAppActivity = false;
1254
- for (ActivityInfo activityInfo : activities) {
1255
- if (
1256
- activityInfo.name.equals(className) &&
1257
- !className.equals(runningActivity)
1258
- ) {
1259
- isThisAppActivity = true;
1260
- }
1231
+ String runningActivity = runningTask.topActivity.getClassName();
1232
+ boolean isThisAppActivity = className.equals(runningActivity);
1233
+ return isThisAppActivity;
1234
+ }
1235
+
1236
+ @Override
1237
+ public void onActivityStarted(@NonNull final Activity activity) {
1238
+ if (isPreviousMainActivity) {
1239
+ this.appMovedToForeground();
1261
1240
  }
1262
- if (!isThisAppActivity) {
1241
+ isPreviousMainActivity = true;
1242
+ }
1243
+
1244
+ @Override
1245
+ public void onActivityStopped(@NonNull final Activity activity) {
1246
+ isPreviousMainActivity = isMainActivity();
1247
+ if (isPreviousMainActivity) {
1263
1248
  this.appMovedToBackground();
1264
1249
  }
1265
1250
  }
@@ -9,7 +9,7 @@ import Version
9
9
  @objc(CapacitorUpdaterPlugin)
10
10
  public class CapacitorUpdaterPlugin: CAPPlugin {
11
11
  private var implementation = CapacitorUpdater()
12
- private let PLUGIN_VERSION: String = "4.17.33"
12
+ private let PLUGIN_VERSION: String = "4.17.34"
13
13
  static let updateUrlDefault = "https://api.capgo.app/updates"
14
14
  static let statsUrlDefault = "https://api.capgo.app/stats"
15
15
  static let channelUrlDefault = "https://api.capgo.app/channel_self"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-updater",
3
- "version": "4.17.33",
3
+ "version": "4.17.34",
4
4
  "packageManager": "pnpm@7.26.3",
5
5
  "license": "LGPL-3.0-only",
6
6
  "description": "Live update for capacitor apps",