@capawesome/capacitor-pixlive 0.0.1
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/CapawesomeCapacitorPixlive.podspec +30 -0
- package/Package.swift +28 -0
- package/README.md +1012 -0
- package/android/build.gradle +64 -0
- package/android/src/main/AndroidManifest.xml +8 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/Pixlive.java +704 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/PixliveHelper.java +112 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/PixlivePlugin.java +691 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/TouchInterceptorView.java +94 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/CustomException.java +20 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/CustomExceptions.java +29 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/options/ActivateContextOptions.java +29 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/options/CreateARViewOptions.java +68 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/options/EnableContextsWithTagsOptions.java +30 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/options/GetContextOptions.java +29 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/options/GetGPSPointsInBoundingBoxOptions.java +68 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/options/GetNearbyGPSPointsOptions.java +40 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/options/ResizeARViewOptions.java +68 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/options/SetARViewTouchEnabledOptions.java +26 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/options/SetARViewTouchHoleOptions.java +68 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/options/SetInterfaceLanguageOptions.java +29 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/options/SetNotificationsSupportOptions.java +26 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/options/SynchronizeOptions.java +30 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/options/SynchronizeWithToursAndContextsOptions.java +66 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/options/UpdateTagMappingOptions.java +30 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/results/GetContextResult.java +23 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/results/GetContextsResult.java +24 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/results/GetGPSPointsInBoundingBoxResult.java +24 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/results/GetNearbyBeaconsResult.java +24 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/results/GetNearbyGPSPointsResult.java +24 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/results/GetVersionResult.java +24 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/interfaces/Callback.java +5 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/interfaces/EmptyCallback.java +5 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/interfaces/NonEmptyCallback.java +7 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/interfaces/NonEmptyResultCallback.java +7 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/interfaces/Result.java +7 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +2107 -0
- package/dist/esm/definitions.d.ts +825 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +31 -0
- package/dist/esm/web.js +85 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +99 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +102 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Plugin/CapacitorARViewController.swift +17 -0
- package/ios/Plugin/Classes/Options/ActivateContextOptions.swift +16 -0
- package/ios/Plugin/Classes/Options/CreateARViewOptions.swift +47 -0
- package/ios/Plugin/Classes/Options/EnableContextsWithTagsOptions.swift +16 -0
- package/ios/Plugin/Classes/Options/GetContextOptions.swift +16 -0
- package/ios/Plugin/Classes/Options/GetGPSPointsInBoundingBoxOptions.swift +43 -0
- package/ios/Plugin/Classes/Options/GetNearbyGPSPointsOptions.swift +25 -0
- package/ios/Plugin/Classes/Options/ResizeARViewOptions.swift +47 -0
- package/ios/Plugin/Classes/Options/SetARViewTouchEnabledOptions.swift +16 -0
- package/ios/Plugin/Classes/Options/SetARViewTouchHoleOptions.swift +43 -0
- package/ios/Plugin/Classes/Options/SetInterfaceLanguageOptions.swift +16 -0
- package/ios/Plugin/Classes/Options/SetNotificationsSupportOptions.swift +16 -0
- package/ios/Plugin/Classes/Options/SynchronizeOptions.swift +16 -0
- package/ios/Plugin/Classes/Options/SynchronizeWithToursAndContextsOptions.swift +34 -0
- package/ios/Plugin/Classes/Options/UpdateTagMappingOptions.swift +16 -0
- package/ios/Plugin/Classes/Results/GetContextResult.swift +16 -0
- package/ios/Plugin/Classes/Results/GetContextsResult.swift +16 -0
- package/ios/Plugin/Classes/Results/GetGPSPointsInBoundingBoxResult.swift +16 -0
- package/ios/Plugin/Classes/Results/GetNearbyBeaconsResult.swift +16 -0
- package/ios/Plugin/Classes/Results/GetNearbyGPSPointsResult.swift +16 -0
- package/ios/Plugin/Classes/Results/GetVersionResult.swift +16 -0
- package/ios/Plugin/Enums/CustomError.swift +86 -0
- package/ios/Plugin/Info.plist +24 -0
- package/ios/Plugin/Pixlive.swift +495 -0
- package/ios/Plugin/PixliveHelper.swift +91 -0
- package/ios/Plugin/PixlivePlugin.swift +503 -0
- package/ios/Plugin/Protocols/Result.swift +6 -0
- package/ios/Plugin/TouchForwarderView.swift +24 -0
- package/package.json +93 -0
|
@@ -0,0 +1,704 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.pixlive;
|
|
2
|
+
|
|
3
|
+
import android.app.Activity;
|
|
4
|
+
import android.graphics.Color;
|
|
5
|
+
import android.view.View;
|
|
6
|
+
import android.view.ViewGroup;
|
|
7
|
+
import android.webkit.WebView;
|
|
8
|
+
import android.widget.FrameLayout;
|
|
9
|
+
import androidx.annotation.NonNull;
|
|
10
|
+
import androidx.annotation.Nullable;
|
|
11
|
+
import com.getcapacitor.JSArray;
|
|
12
|
+
import com.getcapacitor.JSObject;
|
|
13
|
+
import com.vidinoti.android.vdarsdk.VDARAnnotationView;
|
|
14
|
+
import com.vidinoti.android.vdarsdk.VDARCode;
|
|
15
|
+
import com.vidinoti.android.vdarsdk.VDARContentEventReceiver;
|
|
16
|
+
import com.vidinoti.android.vdarsdk.VDARContext;
|
|
17
|
+
import com.vidinoti.android.vdarsdk.VDARPrior;
|
|
18
|
+
import com.vidinoti.android.vdarsdk.VDARRemoteController;
|
|
19
|
+
import com.vidinoti.android.vdarsdk.VDARRemoteControllerListener;
|
|
20
|
+
import com.vidinoti.android.vdarsdk.VDARSDKController;
|
|
21
|
+
import com.vidinoti.android.vdarsdk.VDARSDKControllerEventReceiver;
|
|
22
|
+
import com.vidinoti.android.vdarsdk.VDARTagPrior;
|
|
23
|
+
import com.vidinoti.android.vdarsdk.camera.DeviceCameraImageSender;
|
|
24
|
+
import com.vidinoti.android.vdarsdk.geopoint.GeoPointManager;
|
|
25
|
+
import com.vidinoti.android.vdarsdk.geopoint.VDARGPSPoint;
|
|
26
|
+
import io.capawesome.capacitorjs.plugins.pixlive.classes.CustomExceptions;
|
|
27
|
+
import io.capawesome.capacitorjs.plugins.pixlive.classes.options.*;
|
|
28
|
+
import io.capawesome.capacitorjs.plugins.pixlive.classes.results.*;
|
|
29
|
+
import io.capawesome.capacitorjs.plugins.pixlive.interfaces.EmptyCallback;
|
|
30
|
+
import io.capawesome.capacitorjs.plugins.pixlive.interfaces.NonEmptyResultCallback;
|
|
31
|
+
import java.io.File;
|
|
32
|
+
import java.util.ArrayList;
|
|
33
|
+
import java.util.List;
|
|
34
|
+
import java.util.Observable;
|
|
35
|
+
import java.util.Observer;
|
|
36
|
+
|
|
37
|
+
public class Pixlive implements VDARSDKControllerEventReceiver, VDARContentEventReceiver, VDARRemoteControllerListener {
|
|
38
|
+
|
|
39
|
+
@NonNull
|
|
40
|
+
private final PixlivePlugin plugin;
|
|
41
|
+
|
|
42
|
+
@Nullable
|
|
43
|
+
private VDARAnnotationView annotationView;
|
|
44
|
+
|
|
45
|
+
@Nullable
|
|
46
|
+
private TouchInterceptorView touchInterceptorView;
|
|
47
|
+
|
|
48
|
+
@Nullable
|
|
49
|
+
private VDARContext currentContext;
|
|
50
|
+
|
|
51
|
+
private boolean isInitialized = false;
|
|
52
|
+
|
|
53
|
+
public Pixlive(@NonNull PixlivePlugin plugin) {
|
|
54
|
+
this.plugin = plugin;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public boolean isInitialized() {
|
|
58
|
+
return isInitialized;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public void initialize(@NonNull EmptyCallback callback) {
|
|
62
|
+
try {
|
|
63
|
+
Activity activity = plugin.getActivity();
|
|
64
|
+
String licenseKey = plugin.getConfig().getString("licenseKey", "");
|
|
65
|
+
String apiUrl = plugin.getConfig().getString("apiUrl", null);
|
|
66
|
+
String sdkUrl = plugin.getConfig().getString("sdkUrl", null);
|
|
67
|
+
|
|
68
|
+
File storageDir = new File(activity.getFilesDir(), "pixliveSDK");
|
|
69
|
+
if (!storageDir.exists()) {
|
|
70
|
+
storageDir.mkdirs();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
VDARSDKController.startSDK(activity, storageDir.getAbsolutePath(), licenseKey);
|
|
74
|
+
VDARSDKController controller = VDARSDKController.getInstance();
|
|
75
|
+
if (apiUrl != null) {
|
|
76
|
+
VDARRemoteController.getInstance().setCustomRemoteApiServerEndpoint(apiUrl);
|
|
77
|
+
}
|
|
78
|
+
if (sdkUrl != null) {
|
|
79
|
+
VDARRemoteController.getInstance().setCustomRemoteSdkApiServerEndpoint(sdkUrl);
|
|
80
|
+
}
|
|
81
|
+
controller.setEnableCodesRecognition(true);
|
|
82
|
+
controller.setActivity(activity);
|
|
83
|
+
try {
|
|
84
|
+
controller.setImageSender(new DeviceCameraImageSender());
|
|
85
|
+
} catch (Exception e) {
|
|
86
|
+
// Camera not available
|
|
87
|
+
}
|
|
88
|
+
controller.registerEventReceiver(this);
|
|
89
|
+
controller.registerContentEventReceiver(this);
|
|
90
|
+
VDARRemoteController.getInstance().addProgressListener(this);
|
|
91
|
+
isInitialized = true;
|
|
92
|
+
callback.success();
|
|
93
|
+
} catch (Exception exception) {
|
|
94
|
+
callback.error(exception);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
public void handleOnPause() {
|
|
99
|
+
if (annotationView != null && annotationView.getParent() != null && annotationView.getVisibility() == View.VISIBLE) {
|
|
100
|
+
annotationView.onPause();
|
|
101
|
+
}
|
|
102
|
+
VDARSDKController controller = VDARSDKController.getInstance();
|
|
103
|
+
if (controller != null) {
|
|
104
|
+
controller.onActivityPaused(plugin.getActivity());
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
public void handleOnResume() {
|
|
109
|
+
if (annotationView != null && annotationView.getParent() != null && annotationView.getVisibility() == View.VISIBLE) {
|
|
110
|
+
annotationView.onResume();
|
|
111
|
+
}
|
|
112
|
+
VDARSDKController controller = VDARSDKController.getInstance();
|
|
113
|
+
if (controller != null) {
|
|
114
|
+
controller.onActivityResumed(plugin.getActivity());
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
public void handleOnDestroy() {
|
|
119
|
+
VDARSDKController controller = VDARSDKController.getInstance();
|
|
120
|
+
if (controller != null) {
|
|
121
|
+
controller.unregisterEventReceiver(this);
|
|
122
|
+
controller.unregisterContentEventReceiver(this);
|
|
123
|
+
VDARRemoteController.getInstance().removeProgressListener(this);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
public void synchronize(@NonNull SynchronizeOptions options, @NonNull EmptyCallback callback) {
|
|
128
|
+
if (!isInitialized) {
|
|
129
|
+
callback.error(CustomExceptions.NOT_INITIALIZED);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
List<VDARPrior> priors = PixliveHelper.buildTagPriors(options.getTags());
|
|
134
|
+
ArrayList<VDARPrior> priorsList = new ArrayList<>(priors);
|
|
135
|
+
VDARRemoteController.getInstance()
|
|
136
|
+
.syncRemoteContextsAsynchronouslyWithPriors(
|
|
137
|
+
priorsList,
|
|
138
|
+
new Observer() {
|
|
139
|
+
@Override
|
|
140
|
+
public void update(Observable o, Object arg) {
|
|
141
|
+
VDARRemoteController.ObserverUpdateInfo info = (VDARRemoteController.ObserverUpdateInfo) arg;
|
|
142
|
+
if (!info.isCompleted()) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
if (info.getError() != null) {
|
|
146
|
+
callback.error(new Exception(info.getError()));
|
|
147
|
+
} else {
|
|
148
|
+
callback.success();
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
} catch (Exception exception) {
|
|
154
|
+
callback.error(exception);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
public void synchronizeWithToursAndContexts(@NonNull SynchronizeWithToursAndContextsOptions options, @NonNull EmptyCallback callback) {
|
|
159
|
+
if (!isInitialized) {
|
|
160
|
+
callback.error(CustomExceptions.NOT_INITIALIZED);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
try {
|
|
164
|
+
List<VDARPrior> priors = PixliveHelper.buildFullPriors(options.getTags(), options.getTourIds(), options.getContextIds());
|
|
165
|
+
ArrayList<VDARPrior> priorsList = new ArrayList<>(priors);
|
|
166
|
+
VDARRemoteController.getInstance()
|
|
167
|
+
.syncRemoteContextsAsynchronouslyWithPriors(
|
|
168
|
+
priorsList,
|
|
169
|
+
new Observer() {
|
|
170
|
+
@Override
|
|
171
|
+
public void update(Observable o, Object arg) {
|
|
172
|
+
VDARRemoteController.ObserverUpdateInfo info = (VDARRemoteController.ObserverUpdateInfo) arg;
|
|
173
|
+
if (!info.isCompleted()) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (info.getError() != null) {
|
|
177
|
+
callback.error(new Exception(info.getError()));
|
|
178
|
+
} else {
|
|
179
|
+
callback.success();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
);
|
|
184
|
+
} catch (Exception exception) {
|
|
185
|
+
callback.error(exception);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
public void updateTagMapping(@NonNull UpdateTagMappingOptions options, @NonNull EmptyCallback callback) {
|
|
190
|
+
if (!isInitialized) {
|
|
191
|
+
callback.error(CustomExceptions.NOT_INITIALIZED);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
try {
|
|
195
|
+
List<String> tags = new ArrayList<>();
|
|
196
|
+
for (int i = 0; i < options.getTags().length(); i++) {
|
|
197
|
+
tags.add(options.getTags().getString(i));
|
|
198
|
+
}
|
|
199
|
+
VDARRemoteController.getInstance()
|
|
200
|
+
.syncTagContexts(
|
|
201
|
+
tags,
|
|
202
|
+
new VDARRemoteController.Callback<Void>() {
|
|
203
|
+
@Override
|
|
204
|
+
public void onSuccess(Void result) {
|
|
205
|
+
callback.success();
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
@Override
|
|
209
|
+
public void onError(String message, Throwable throwable) {
|
|
210
|
+
callback.error(new Exception(message, throwable));
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
);
|
|
214
|
+
} catch (Exception exception) {
|
|
215
|
+
callback.error(exception);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
public void enableContextsWithTags(@NonNull EnableContextsWithTagsOptions options, @NonNull EmptyCallback callback) {
|
|
220
|
+
if (!isInitialized) {
|
|
221
|
+
callback.error(CustomExceptions.NOT_INITIALIZED);
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
try {
|
|
225
|
+
List<String> tags = new ArrayList<>();
|
|
226
|
+
for (int i = 0; i < options.getTags().length(); i++) {
|
|
227
|
+
tags.add(options.getTags().getString(i));
|
|
228
|
+
}
|
|
229
|
+
VDARSDKController.getInstance().disableContexts();
|
|
230
|
+
VDARSDKController.getInstance().enableContextsWithTags(tags);
|
|
231
|
+
callback.success();
|
|
232
|
+
} catch (Exception exception) {
|
|
233
|
+
callback.error(exception);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
public void getContexts(@NonNull NonEmptyResultCallback<GetContextsResult> callback) {
|
|
238
|
+
if (!isInitialized) {
|
|
239
|
+
callback.error(CustomExceptions.NOT_INITIALIZED);
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
try {
|
|
243
|
+
ArrayList<String> contextIds = VDARSDKController.getInstance().getAllContextIDs();
|
|
244
|
+
JSArray contextsArray = new JSArray();
|
|
245
|
+
if (contextIds != null) {
|
|
246
|
+
for (String contextId : contextIds) {
|
|
247
|
+
VDARContext context = VDARSDKController.getInstance().getContext(contextId);
|
|
248
|
+
if (context != null) {
|
|
249
|
+
contextsArray.put(PixliveHelper.contextToJSObject(context));
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
callback.success(new GetContextsResult(contextsArray));
|
|
254
|
+
} catch (Exception exception) {
|
|
255
|
+
callback.error(exception);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
public void getContext(@NonNull GetContextOptions options, @NonNull NonEmptyResultCallback<GetContextResult> callback) {
|
|
260
|
+
if (!isInitialized) {
|
|
261
|
+
callback.error(CustomExceptions.NOT_INITIALIZED);
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
try {
|
|
265
|
+
VDARContext context = VDARSDKController.getInstance().getContext(options.getContextId());
|
|
266
|
+
if (context == null) {
|
|
267
|
+
callback.error(CustomExceptions.CONTEXT_NOT_FOUND);
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
callback.success(new GetContextResult(PixliveHelper.contextToJSObject(context)));
|
|
271
|
+
} catch (Exception exception) {
|
|
272
|
+
callback.error(exception);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
public void activateContext(@NonNull ActivateContextOptions options, @NonNull EmptyCallback callback) {
|
|
277
|
+
if (!isInitialized) {
|
|
278
|
+
callback.error(CustomExceptions.NOT_INITIALIZED);
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
try {
|
|
282
|
+
VDARContext context = VDARSDKController.getInstance().getContext(options.getContextId());
|
|
283
|
+
if (context != null) {
|
|
284
|
+
context.activate();
|
|
285
|
+
}
|
|
286
|
+
callback.success();
|
|
287
|
+
} catch (Exception exception) {
|
|
288
|
+
callback.error(exception);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
public void stopContext(@NonNull EmptyCallback callback) {
|
|
293
|
+
if (!isInitialized) {
|
|
294
|
+
callback.error(CustomExceptions.NOT_INITIALIZED);
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
try {
|
|
298
|
+
if (currentContext != null) {
|
|
299
|
+
currentContext.stop();
|
|
300
|
+
}
|
|
301
|
+
callback.success();
|
|
302
|
+
} catch (Exception exception) {
|
|
303
|
+
callback.error(exception);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
public void getNearbyGPSPoints(
|
|
308
|
+
@NonNull GetNearbyGPSPointsOptions options,
|
|
309
|
+
@NonNull NonEmptyResultCallback<GetNearbyGPSPointsResult> callback
|
|
310
|
+
) {
|
|
311
|
+
if (!isInitialized) {
|
|
312
|
+
callback.error(CustomExceptions.NOT_INITIALIZED);
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
try {
|
|
316
|
+
List<VDARGPSPoint> points = GeoPointManager.getNearbyGPSPoints((float) options.getLatitude(), (float) options.getLongitude());
|
|
317
|
+
JSArray pointsArray = new JSArray();
|
|
318
|
+
if (points != null) {
|
|
319
|
+
for (VDARGPSPoint point : points) {
|
|
320
|
+
pointsArray.put(PixliveHelper.gpsPointToJSObject(point));
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
callback.success(new GetNearbyGPSPointsResult(pointsArray));
|
|
324
|
+
} catch (Exception exception) {
|
|
325
|
+
callback.error(exception);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
public void getGPSPointsInBoundingBox(
|
|
330
|
+
@NonNull GetGPSPointsInBoundingBoxOptions options,
|
|
331
|
+
@NonNull NonEmptyResultCallback<GetGPSPointsInBoundingBoxResult> callback
|
|
332
|
+
) {
|
|
333
|
+
if (!isInitialized) {
|
|
334
|
+
callback.error(CustomExceptions.NOT_INITIALIZED);
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
try {
|
|
338
|
+
List<VDARGPSPoint> points = GeoPointManager.getGPSPointsInBoundingBox(
|
|
339
|
+
(float) options.getMinLatitude(),
|
|
340
|
+
(float) options.getMinLongitude(),
|
|
341
|
+
(float) options.getMaxLatitude(),
|
|
342
|
+
(float) options.getMaxLongitude()
|
|
343
|
+
);
|
|
344
|
+
JSArray pointsArray = new JSArray();
|
|
345
|
+
if (points != null) {
|
|
346
|
+
for (VDARGPSPoint point : points) {
|
|
347
|
+
pointsArray.put(PixliveHelper.gpsPointToJSObject(point));
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
callback.success(new GetGPSPointsInBoundingBoxResult(pointsArray));
|
|
351
|
+
} catch (Exception exception) {
|
|
352
|
+
callback.error(exception);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
public void getNearbyBeacons(@NonNull NonEmptyResultCallback<GetNearbyBeaconsResult> callback) {
|
|
357
|
+
if (!isInitialized) {
|
|
358
|
+
callback.error(CustomExceptions.NOT_INITIALIZED);
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
try {
|
|
362
|
+
List<String> beaconContextIds = VDARSDKController.getInstance().getNearbyBeacons();
|
|
363
|
+
JSArray contextsArray = new JSArray();
|
|
364
|
+
if (beaconContextIds != null) {
|
|
365
|
+
for (String contextId : beaconContextIds) {
|
|
366
|
+
VDARContext context = VDARSDKController.getInstance().getContext(contextId);
|
|
367
|
+
if (context != null) {
|
|
368
|
+
contextsArray.put(PixliveHelper.contextToJSObject(context));
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
callback.success(new GetNearbyBeaconsResult(contextsArray));
|
|
373
|
+
} catch (Exception exception) {
|
|
374
|
+
callback.error(exception);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
public void startNearbyGPSDetection(@NonNull EmptyCallback callback) {
|
|
379
|
+
if (!isInitialized) {
|
|
380
|
+
callback.error(CustomExceptions.NOT_INITIALIZED);
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
try {
|
|
384
|
+
VDARSDKController.getInstance().startNearbyGPSDetection();
|
|
385
|
+
callback.success();
|
|
386
|
+
} catch (Exception exception) {
|
|
387
|
+
callback.error(exception);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
public void stopNearbyGPSDetection(@NonNull EmptyCallback callback) {
|
|
392
|
+
if (!isInitialized) {
|
|
393
|
+
callback.error(CustomExceptions.NOT_INITIALIZED);
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
try {
|
|
397
|
+
VDARSDKController.getInstance().stopNearbyGPSDetection();
|
|
398
|
+
callback.success();
|
|
399
|
+
} catch (Exception exception) {
|
|
400
|
+
callback.error(exception);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
public void startGPSNotifications(@NonNull EmptyCallback callback) {
|
|
405
|
+
if (!isInitialized) {
|
|
406
|
+
callback.error(CustomExceptions.NOT_INITIALIZED);
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
try {
|
|
410
|
+
VDARSDKController.getInstance().startGPSNotifications();
|
|
411
|
+
callback.success();
|
|
412
|
+
} catch (Exception exception) {
|
|
413
|
+
callback.error(exception);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
public void stopGPSNotifications(@NonNull EmptyCallback callback) {
|
|
418
|
+
if (!isInitialized) {
|
|
419
|
+
callback.error(CustomExceptions.NOT_INITIALIZED);
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
try {
|
|
423
|
+
VDARSDKController.getInstance().stopGPSNotifications();
|
|
424
|
+
callback.success();
|
|
425
|
+
} catch (Exception exception) {
|
|
426
|
+
callback.error(exception);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
public void setNotificationsSupport(@NonNull SetNotificationsSupportOptions options, @NonNull EmptyCallback callback) {
|
|
431
|
+
if (!isInitialized) {
|
|
432
|
+
callback.error(CustomExceptions.NOT_INITIALIZED);
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
try {
|
|
436
|
+
VDARSDKController.getInstance().setNotificationsSupport(options.isEnabled());
|
|
437
|
+
callback.success();
|
|
438
|
+
} catch (Exception exception) {
|
|
439
|
+
callback.error(exception);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
public void setInterfaceLanguage(@NonNull SetInterfaceLanguageOptions options, @NonNull EmptyCallback callback) {
|
|
444
|
+
if (!isInitialized) {
|
|
445
|
+
callback.error(CustomExceptions.NOT_INITIALIZED);
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
try {
|
|
449
|
+
VDARSDKController.getInstance().forceLanguage(options.getLanguage());
|
|
450
|
+
callback.success();
|
|
451
|
+
} catch (Exception exception) {
|
|
452
|
+
callback.error(exception);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
public void createARView(@NonNull CreateARViewOptions options, @NonNull EmptyCallback callback) {
|
|
457
|
+
if (!isInitialized) {
|
|
458
|
+
callback.error(CustomExceptions.NOT_INITIALIZED);
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
if (annotationView != null) {
|
|
462
|
+
callback.error(CustomExceptions.AR_VIEW_ALREADY_EXISTS);
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
Activity activity = plugin.getActivity();
|
|
466
|
+
activity.runOnUiThread(() -> {
|
|
467
|
+
try {
|
|
468
|
+
WebView webView = plugin.getBridge().getWebView();
|
|
469
|
+
annotationView = new VDARAnnotationView(activity);
|
|
470
|
+
float density = activity.getResources().getDisplayMetrics().density;
|
|
471
|
+
int x = (int) (options.getX() * density);
|
|
472
|
+
int y = (int) (options.getY() * density);
|
|
473
|
+
int width = (int) (options.getWidth() * density);
|
|
474
|
+
int height = (int) (options.getHeight() * density);
|
|
475
|
+
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(width, height);
|
|
476
|
+
params.leftMargin = x;
|
|
477
|
+
params.topMargin = y;
|
|
478
|
+
annotationView.setLayoutParams(params);
|
|
479
|
+
webView.setBackgroundColor(Color.TRANSPARENT);
|
|
480
|
+
|
|
481
|
+
ViewGroup parent = (ViewGroup) webView.getParent();
|
|
482
|
+
int index = parent.indexOfChild(webView);
|
|
483
|
+
ViewGroup.LayoutParams webViewParams = webView.getLayoutParams();
|
|
484
|
+
parent.removeView(webView);
|
|
485
|
+
|
|
486
|
+
TouchInterceptorView interceptor = new TouchInterceptorView(activity);
|
|
487
|
+
interceptor.setLayoutParams(webViewParams);
|
|
488
|
+
parent.addView(interceptor, index);
|
|
489
|
+
|
|
490
|
+
webView.setLayoutParams(
|
|
491
|
+
new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)
|
|
492
|
+
);
|
|
493
|
+
interceptor.addView(webView);
|
|
494
|
+
interceptor.addView(annotationView, 0);
|
|
495
|
+
interceptor.setAnnotationView(annotationView);
|
|
496
|
+
touchInterceptorView = interceptor;
|
|
497
|
+
|
|
498
|
+
VDARSDKController.getInstance().setActivity(activity);
|
|
499
|
+
annotationView.onResume();
|
|
500
|
+
callback.success();
|
|
501
|
+
} catch (Exception exception) {
|
|
502
|
+
callback.error(exception);
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
public void destroyARView(@NonNull EmptyCallback callback) {
|
|
508
|
+
if (!isInitialized) {
|
|
509
|
+
callback.error(CustomExceptions.NOT_INITIALIZED);
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
if (annotationView == null) {
|
|
513
|
+
callback.error(CustomExceptions.AR_VIEW_NOT_FOUND);
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
Activity activity = plugin.getActivity();
|
|
517
|
+
activity.runOnUiThread(() -> {
|
|
518
|
+
try {
|
|
519
|
+
WebView webView = plugin.getBridge().getWebView();
|
|
520
|
+
webView.setBackgroundColor(Color.WHITE);
|
|
521
|
+
annotationView.onPause();
|
|
522
|
+
|
|
523
|
+
if (touchInterceptorView != null) {
|
|
524
|
+
ViewGroup parent = (ViewGroup) touchInterceptorView.getParent();
|
|
525
|
+
int index = parent.indexOfChild(touchInterceptorView);
|
|
526
|
+
ViewGroup.LayoutParams interceptorParams = touchInterceptorView.getLayoutParams();
|
|
527
|
+
|
|
528
|
+
touchInterceptorView.removeView(annotationView);
|
|
529
|
+
touchInterceptorView.removeView(webView);
|
|
530
|
+
parent.removeView(touchInterceptorView);
|
|
531
|
+
|
|
532
|
+
webView.setLayoutParams(interceptorParams);
|
|
533
|
+
parent.addView(webView, index);
|
|
534
|
+
touchInterceptorView = null;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
annotationView = null;
|
|
538
|
+
callback.success();
|
|
539
|
+
} catch (Exception exception) {
|
|
540
|
+
callback.error(exception);
|
|
541
|
+
}
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
public void resizeARView(@NonNull ResizeARViewOptions options, @NonNull EmptyCallback callback) {
|
|
546
|
+
if (!isInitialized) {
|
|
547
|
+
callback.error(CustomExceptions.NOT_INITIALIZED);
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
if (annotationView == null) {
|
|
551
|
+
callback.error(CustomExceptions.AR_VIEW_NOT_FOUND);
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
Activity activity = plugin.getActivity();
|
|
555
|
+
activity.runOnUiThread(() -> {
|
|
556
|
+
try {
|
|
557
|
+
float density = activity.getResources().getDisplayMetrics().density;
|
|
558
|
+
int x = (int) (options.getX() * density);
|
|
559
|
+
int y = (int) (options.getY() * density);
|
|
560
|
+
int width = (int) (options.getWidth() * density);
|
|
561
|
+
int height = (int) (options.getHeight() * density);
|
|
562
|
+
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(width, height);
|
|
563
|
+
params.leftMargin = x;
|
|
564
|
+
params.topMargin = y;
|
|
565
|
+
annotationView.setLayoutParams(params);
|
|
566
|
+
callback.success();
|
|
567
|
+
} catch (Exception exception) {
|
|
568
|
+
callback.error(exception);
|
|
569
|
+
}
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
public void setARViewTouchEnabled(@NonNull SetARViewTouchEnabledOptions options, @NonNull EmptyCallback callback) {
|
|
574
|
+
if (!isInitialized) {
|
|
575
|
+
callback.error(CustomExceptions.NOT_INITIALIZED);
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
if (touchInterceptorView != null) {
|
|
579
|
+
plugin
|
|
580
|
+
.getActivity()
|
|
581
|
+
.runOnUiThread(() -> {
|
|
582
|
+
if (touchInterceptorView != null) {
|
|
583
|
+
touchInterceptorView.setTouchEnabled(options.isEnabled());
|
|
584
|
+
}
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
callback.success();
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
public void setARViewTouchHole(@NonNull SetARViewTouchHoleOptions options, @NonNull EmptyCallback callback) {
|
|
591
|
+
if (!isInitialized) {
|
|
592
|
+
callback.error(CustomExceptions.NOT_INITIALIZED);
|
|
593
|
+
return;
|
|
594
|
+
}
|
|
595
|
+
float density = plugin.getActivity().getResources().getDisplayMetrics().density;
|
|
596
|
+
float top = (float) (options.getTop() * density);
|
|
597
|
+
float bottom = (float) (options.getBottom() * density);
|
|
598
|
+
float left = (float) (options.getLeft() * density);
|
|
599
|
+
float right = (float) (options.getRight() * density);
|
|
600
|
+
if (touchInterceptorView != null) {
|
|
601
|
+
plugin
|
|
602
|
+
.getActivity()
|
|
603
|
+
.runOnUiThread(() -> {
|
|
604
|
+
if (touchInterceptorView != null) {
|
|
605
|
+
touchInterceptorView.setTouchHole(top, bottom, left, right);
|
|
606
|
+
}
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
callback.success();
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
public void getVersion(@NonNull NonEmptyResultCallback<GetVersionResult> callback) {
|
|
613
|
+
String version = VDARSDKController.getSDKVersion();
|
|
614
|
+
callback.success(new GetVersionResult(version));
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
// VDARSDKControllerEventReceiver
|
|
618
|
+
|
|
619
|
+
@Override
|
|
620
|
+
public void onCodesRecognized(@NonNull ArrayList<VDARCode> codes) {
|
|
621
|
+
for (VDARCode code : codes) {
|
|
622
|
+
if (code.isSpecialCode()) {
|
|
623
|
+
continue;
|
|
624
|
+
}
|
|
625
|
+
JSObject data = new JSObject();
|
|
626
|
+
data.put("code", code.getCodeData());
|
|
627
|
+
data.put("type", PixliveHelper.codeTypeToString(code.getCodeType()));
|
|
628
|
+
plugin.notifyListenersFromImplementation("codeRecognize", data);
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
@Override
|
|
633
|
+
public void onFatalError(@NonNull String error) {
|
|
634
|
+
// Not needed
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
@Override
|
|
638
|
+
public void onPresentAnnotations() {
|
|
639
|
+
plugin.notifyListenersFromImplementation("presentAnnotations", new JSObject());
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
@Override
|
|
643
|
+
public void onAnnotationsHidden() {
|
|
644
|
+
plugin.notifyListenersFromImplementation("hideAnnotations", new JSObject());
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
@Override
|
|
648
|
+
public void onTrackingStarted(int width, int height) {
|
|
649
|
+
// Not needed
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
@Override
|
|
653
|
+
public void onEnterContext(@NonNull VDARContext context) {
|
|
654
|
+
this.currentContext = context;
|
|
655
|
+
JSObject data = new JSObject();
|
|
656
|
+
data.put("contextId", context.getRemoteID());
|
|
657
|
+
plugin.notifyListenersFromImplementation("enterContext", data);
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
@Override
|
|
661
|
+
public void onExitContext(@NonNull VDARContext context) {
|
|
662
|
+
// Clear stale rendering data to prevent the previous context's last frame
|
|
663
|
+
// from briefly flashing before the new context's content is rendered.
|
|
664
|
+
VDARSDKController controller = VDARSDKController.getInstance();
|
|
665
|
+
controller.unloadAll();
|
|
666
|
+
|
|
667
|
+
this.currentContext = null;
|
|
668
|
+
JSObject data = new JSObject();
|
|
669
|
+
data.put("contextId", context.getRemoteID());
|
|
670
|
+
plugin.notifyListenersFromImplementation("exitContext", data);
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
@Override
|
|
674
|
+
public void onRequireSynchronization(@NonNull ArrayList<VDARPrior> priors) {
|
|
675
|
+
JSArray tagsArray = new JSArray();
|
|
676
|
+
for (VDARPrior prior : priors) {
|
|
677
|
+
if (prior instanceof VDARTagPrior) {
|
|
678
|
+
tagsArray.put(((VDARTagPrior) prior).getTag());
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
JSObject data = new JSObject();
|
|
682
|
+
data.put("tags", tagsArray);
|
|
683
|
+
plugin.notifyListenersFromImplementation("requireSync", data);
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
// VDARContentEventReceiver
|
|
687
|
+
|
|
688
|
+
@Override
|
|
689
|
+
public void onReceiveContentEvent(@NonNull String eventName, @NonNull String eventParams) {
|
|
690
|
+
JSObject data = new JSObject();
|
|
691
|
+
data.put("name", eventName);
|
|
692
|
+
data.put("params", eventParams);
|
|
693
|
+
plugin.notifyListenersFromImplementation("eventFromContent", data);
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
// VDARRemoteControllerListener
|
|
697
|
+
|
|
698
|
+
@Override
|
|
699
|
+
public void onSyncProgress(@NonNull VDARRemoteController controller, float progress, boolean isDone, @Nullable String error) {
|
|
700
|
+
JSObject data = new JSObject();
|
|
701
|
+
data.put("progress", progress / 100.0f);
|
|
702
|
+
plugin.notifyListenersFromImplementation("syncProgress", data);
|
|
703
|
+
}
|
|
704
|
+
}
|