@cuby-ui/ar 0.0.6 → 0.0.8

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.
@@ -21,7 +21,7 @@ android {
21
21
  namespace "com.cuby.plugins.cubyar"
22
22
  compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 35
23
23
  defaultConfig {
24
- minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
24
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 26
25
25
  targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 35
26
26
  versionCode 1
27
27
  versionName "1.0"
Binary file
@@ -1,6 +1,7 @@
1
1
  package com.cuby.plugins.cubyar;
2
2
 
3
- import static com.cuby.cubyar.NativeLogger.LogMessage;
3
+ import static com.cuby.cubyar.NativeLogger.logMessage;
4
+ import static com.cuby.cubyar.GEngineHelper.isGEngineReady;
4
5
 
5
6
  import android.Manifest;
6
7
  import android.annotation.SuppressLint;
@@ -15,6 +16,7 @@ import android.widget.Toast;
15
16
  import androidx.core.app.ActivityCompat;
16
17
  import androidx.core.content.ContextCompat;
17
18
 
19
+ import com.cuby.cubyar.NativeLogger;
18
20
  import com.getcapacitor.Plugin;
19
21
  import com.getcapacitor.PluginCall;
20
22
  import com.getcapacitor.PluginMethod;
@@ -27,6 +29,8 @@ public class NativeBridge extends Plugin {
27
29
  private static final int CAMERA_REQUEST_CODE = 1234;
28
30
  private PluginCall savedCall;
29
31
 
32
+ private static final String LOG_TAG = "CubyARPlugin";
33
+
30
34
  @PluginMethod
31
35
  public void startAR(PluginCall call) {
32
36
  Activity activity = getActivity();
@@ -40,38 +44,32 @@ public class NativeBridge extends Plugin {
40
44
  return;
41
45
  }
42
46
 
43
- launchUnrealAR(call);
47
+ launchUnrealAR();
44
48
  }
45
49
 
46
50
  @SuppressLint("QueryPermissionsNeeded")
47
- private void launchUnrealAR(PluginCall call) {
48
- Activity activity = getActivity();
49
-
50
- String message = call.getString("message");
51
+ private void launchUnrealAR() {
51
52
  try {
53
+ Activity activity = getActivity();
52
54
  Intent intent = new Intent();
53
55
  intent.setClassName(activity.getPackageName(), "com.epicgames.unreal.GameActivity");
54
56
 
55
57
  if (intent.resolveActivity(activity.getPackageManager()) != null) {
56
58
  activity.startActivity(intent);
57
- Log.i("ArLauncherPlugin", "Unreal AR activity launched successfully");
58
-
59
- // Delay calling LogMessage by 10 seconds so we don't block the UI thread
60
- // and allow the launched activity to settle first.
61
- new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
62
- @Override
63
- public void run() {
64
- LogMessage(message);
65
- Log.i("ArLauncherPlugin", message);
66
- }
67
- }, 10_000);
68
59
 
60
+ Log.i(LOG_TAG, "Unreal AR activity launched successfully");
61
+
62
+ // Wait until the Unreal Engine is fully initialized.
63
+ // This loop blocks execution to ensure no engine functions
64
+ // are called before the engine is ready
65
+ while (!isGEngineReady())
66
+ ;
69
67
  } else {
70
- Log.e("ArLauncherPlugin", "GameActivity not found in package");
68
+ Log.e(LOG_TAG, "GameActivity not found in package");
71
69
  }
72
70
 
73
71
  } catch (Exception e) {
74
- Log.e("ArLauncherPlugin", "Failed to launch AR", e);
72
+ Log.e(LOG_TAG, "Failed to launch AR", e);
75
73
  }
76
74
  }
77
75
 
@@ -85,7 +83,7 @@ public class NativeBridge extends Plugin {
85
83
  }
86
84
 
87
85
  try {
88
- LogMessage(message);
86
+ NativeLogger.logMessage(message);
89
87
 
90
88
  JSObject ret = new JSObject();
91
89
  ret.put("status", "logged");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cuby-ui/ar",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "Ar/Vr plugin",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",