@cuby-ui/ar 0.0.8 → 0.0.9
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/README.md
CHANGED
|
@@ -13,7 +13,7 @@ npx cap sync
|
|
|
13
13
|
|
|
14
14
|
<docgen-index>
|
|
15
15
|
|
|
16
|
-
* [`startAR(
|
|
16
|
+
* [`startAR()`](#startar)
|
|
17
17
|
* [`logMessage(...)`](#logmessage)
|
|
18
18
|
|
|
19
19
|
</docgen-index>
|
|
@@ -21,33 +21,29 @@ npx cap sync
|
|
|
21
21
|
<docgen-api>
|
|
22
22
|
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
23
23
|
|
|
24
|
-
### startAR(
|
|
24
|
+
### startAR()
|
|
25
25
|
|
|
26
26
|
```typescript
|
|
27
|
-
startAR(
|
|
27
|
+
startAR() => void
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
Launches the AR activity.
|
|
31
31
|
|
|
32
|
-
| Param | Type |
|
|
33
|
-
| ------------- | ---------------------------------- |
|
|
34
|
-
| **`options`** | <code>{ message?: string; }</code> |
|
|
35
|
-
|
|
36
32
|
--------------------
|
|
37
33
|
|
|
38
34
|
|
|
39
35
|
### logMessage(...)
|
|
40
36
|
|
|
41
37
|
```typescript
|
|
42
|
-
logMessage(options: { message: string; }) =>
|
|
38
|
+
logMessage(options: { message: string; duration?: number; }) => void
|
|
43
39
|
```
|
|
44
40
|
|
|
45
41
|
Sends a message to native code to be logged. Returns a small status
|
|
46
42
|
object on success.
|
|
47
43
|
|
|
48
|
-
| Param | Type
|
|
49
|
-
| ------------- |
|
|
50
|
-
| **`options`** | <code>{ message: string; }</code> |
|
|
44
|
+
| Param | Type | Description |
|
|
45
|
+
| ------------- | ---------------------------------------------------- | ------------------------------------------------------------------- |
|
|
46
|
+
| **`options`** | <code>{ message: string; duration?: number; }</code> | The message to log and optional duration in seconds (default is 5). |
|
|
51
47
|
|
|
52
48
|
--------------------
|
|
53
49
|
|
|
Binary file
|
|
@@ -23,28 +23,30 @@ import com.getcapacitor.PluginMethod;
|
|
|
23
23
|
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
24
24
|
import com.getcapacitor.JSObject;
|
|
25
25
|
|
|
26
|
-
@CapacitorPlugin(name = "NativeBridge"
|
|
26
|
+
@CapacitorPlugin(name = "NativeBridge", permissions = {
|
|
27
|
+
@Permission(strings = { Manifest.permission.CAMERA }, alias = "camera")
|
|
28
|
+
})
|
|
27
29
|
public class NativeBridge extends Plugin {
|
|
28
|
-
|
|
29
|
-
private static final int CAMERA_REQUEST_CODE = 1234;
|
|
30
|
-
private PluginCall savedCall;
|
|
31
|
-
|
|
32
30
|
private static final String LOG_TAG = "CubyARPlugin";
|
|
33
31
|
|
|
34
32
|
@PluginMethod
|
|
35
33
|
public void startAR(PluginCall call) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
ActivityCompat.requestPermissions(activity,
|
|
42
|
-
new String[] { Manifest.permission.CAMERA },
|
|
43
|
-
CAMERA_REQUEST_CODE);
|
|
44
|
-
return;
|
|
34
|
+
if (getPermissionState("camera") != PermissionState.GRANTED) {
|
|
35
|
+
requestPermissionForAlias("camera", call, "cameraPermissionCallback");
|
|
36
|
+
} else {
|
|
37
|
+
launchUnrealAR();
|
|
38
|
+
call.resolve();
|
|
45
39
|
}
|
|
40
|
+
}
|
|
46
41
|
|
|
47
|
-
|
|
42
|
+
@PermissionCallback
|
|
43
|
+
private void cameraPermissionCallback(PluginCall call) {
|
|
44
|
+
if (getPermissionState("camera") == PermissionState.GRANTED) {
|
|
45
|
+
launchUnrealAR();
|
|
46
|
+
call.resolve();
|
|
47
|
+
} else {
|
|
48
|
+
call.reject("Camera permission denied");
|
|
49
|
+
}
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
@SuppressLint("QueryPermissionsNeeded")
|
|
@@ -76,6 +78,8 @@ public class NativeBridge extends Plugin {
|
|
|
76
78
|
@PluginMethod
|
|
77
79
|
public void logMessage(PluginCall call) {
|
|
78
80
|
String message = call.getString("message");
|
|
81
|
+
float duration = call.getString("duration", "5.0") != null ? Float.parseFloat(call.getString("duration", "5.0"))
|
|
82
|
+
: 5.0f;
|
|
79
83
|
|
|
80
84
|
if (message == null) {
|
|
81
85
|
call.reject("Missing 'message' parameter");
|
|
@@ -83,7 +87,7 @@ public class NativeBridge extends Plugin {
|
|
|
83
87
|
}
|
|
84
88
|
|
|
85
89
|
try {
|
|
86
|
-
NativeLogger.logMessage(message);
|
|
90
|
+
NativeLogger.logMessage(message, duration);
|
|
87
91
|
|
|
88
92
|
JSObject ret = new JSObject();
|
|
89
93
|
ret.put("status", "logged");
|
package/dist/docs.json
CHANGED
|
@@ -7,15 +7,9 @@
|
|
|
7
7
|
"methods": [
|
|
8
8
|
{
|
|
9
9
|
"name": "startAR",
|
|
10
|
-
"signature": "(
|
|
11
|
-
"parameters": [
|
|
12
|
-
|
|
13
|
-
"name": "options",
|
|
14
|
-
"docs": "",
|
|
15
|
-
"type": "{ message?: string | undefined; } | undefined"
|
|
16
|
-
}
|
|
17
|
-
],
|
|
18
|
-
"returns": "Promise<void>",
|
|
10
|
+
"signature": "() => void",
|
|
11
|
+
"parameters": [],
|
|
12
|
+
"returns": "void",
|
|
19
13
|
"tags": [],
|
|
20
14
|
"docs": "Launches the AR activity.",
|
|
21
15
|
"complexTypes": [],
|
|
@@ -23,16 +17,21 @@
|
|
|
23
17
|
},
|
|
24
18
|
{
|
|
25
19
|
"name": "logMessage",
|
|
26
|
-
"signature": "(options: { message: string; }) =>
|
|
20
|
+
"signature": "(options: { message: string; duration?: number; }) => void",
|
|
27
21
|
"parameters": [
|
|
28
22
|
{
|
|
29
23
|
"name": "options",
|
|
30
|
-
"docs": "",
|
|
31
|
-
"type": "{ message: string; }"
|
|
24
|
+
"docs": "The message to log and optional duration in seconds (default is 5).",
|
|
25
|
+
"type": "{ message: string; duration?: number | undefined; }"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"returns": "void",
|
|
29
|
+
"tags": [
|
|
30
|
+
{
|
|
31
|
+
"name": "param",
|
|
32
|
+
"text": "options The message to log and optional duration in seconds (default is 5)."
|
|
32
33
|
}
|
|
33
34
|
],
|
|
34
|
-
"returns": "Promise<void>",
|
|
35
|
-
"tags": [],
|
|
36
35
|
"docs": "Sends a message to native code to be logged. Returns a small status\nobject on success.",
|
|
37
36
|
"complexTypes": [],
|
|
38
37
|
"slug": "logmessage"
|
|
@@ -2,14 +2,14 @@ export interface NativeBridgePlugin {
|
|
|
2
2
|
/**
|
|
3
3
|
* Launches the AR activity.
|
|
4
4
|
*/
|
|
5
|
-
startAR(
|
|
6
|
-
message?: string;
|
|
7
|
-
}): Promise<void>;
|
|
5
|
+
startAR(): void;
|
|
8
6
|
/**
|
|
9
7
|
* Sends a message to native code to be logged. Returns a small status
|
|
10
8
|
* object on success.
|
|
9
|
+
* @param options The message to log and optional duration in seconds (default is 5).
|
|
11
10
|
*/
|
|
12
11
|
logMessage(options: {
|
|
13
12
|
message: string;
|
|
14
|
-
|
|
13
|
+
duration?: number;
|
|
14
|
+
}): void;
|
|
15
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface NativeBridgePlugin {\n /**\n * Launches the AR activity.\n */\n startAR(
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface NativeBridgePlugin {\n /**\n * Launches the AR activity.\n */\n startAR(): void;\n\n /**\n * Sends a message to native code to be logged. Returns a small status\n * object on success.\n * @param options The message to log and optional duration in seconds (default is 5).\n */\n logMessage(options: { message: string; duration?: number; }): void;\n}\n"]}
|