react-native-radar 3.20.4 → 3.21.0-beta.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/Radar.podspec +22 -0
- package/android/build.gradle +77 -35
- package/android/gradle.properties +5 -1
- package/android/src/main/AndroidManifest.xml +1 -3
- package/android/src/main/java/{io/radar/react/RNRadarModule.java → com/radar/RadarModuleImpl.java} +131 -258
- package/android/src/main/java/com/radar/RadarPackage.kt +35 -0
- package/android/src/main/java/{io/radar/react/RNRadarUtils.java → com/radar/RadarUtils.java} +3 -2
- package/android/src/newarch/java/com/radar/RadarModule.kt +381 -0
- package/android/src/oldarch/java/com/radar/RadarModule.java +416 -0
- package/android/src/{main/java/io/radar/react/RNRadarReceiver.java → oldarch/java/com/radar/RadarOldArchReceiver.java} +8 -8
- package/android/src/{main/java/io/radar/react/RNRadarVerifiedReceiver.java → oldarch/java/com/radar/RadarOldArchVerifiedReceiver.java} +4 -4
- package/app.plugin.js +1 -1
- package/ios/RNRadar.h +11 -2
- package/ios/{RNRadar.m → RNRadar.mm} +77 -39
- package/lib/commonjs/@types/RadarNativeInterface.js +2 -0
- package/lib/commonjs/@types/RadarNativeInterface.js.map +1 -0
- package/lib/commonjs/@types/types.js +2 -0
- package/lib/commonjs/@types/types.js.map +1 -0
- package/lib/commonjs/NativeRadar.js +2 -0
- package/lib/commonjs/NativeRadar.js.map +1 -0
- package/lib/commonjs/helpers.js +2 -0
- package/lib/commonjs/helpers.js.map +1 -0
- package/lib/commonjs/index.js +2 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/index.native.js +2 -0
- package/lib/commonjs/index.native.js.map +1 -0
- package/lib/commonjs/index.web.js +2 -0
- package/lib/commonjs/index.web.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/plugin/types.js +2 -0
- package/lib/commonjs/plugin/types.js.map +1 -0
- package/lib/commonjs/plugin/withRadar.js +2 -0
- package/lib/commonjs/plugin/withRadar.js.map +1 -0
- package/lib/commonjs/plugin/withRadarAndroid.js +2 -0
- package/lib/commonjs/plugin/withRadarAndroid.js.map +1 -0
- package/lib/commonjs/plugin/withRadarIOS.js +2 -0
- package/lib/commonjs/plugin/withRadarIOS.js.map +1 -0
- package/lib/commonjs/ui/autocomplete.js +2 -0
- package/lib/commonjs/ui/autocomplete.js.map +1 -0
- package/lib/commonjs/ui/images.js +2 -0
- package/lib/commonjs/ui/images.js.map +1 -0
- package/lib/commonjs/ui/map.js +2 -0
- package/lib/commonjs/ui/map.js.map +1 -0
- package/lib/commonjs/ui/styles.js +2 -0
- package/lib/commonjs/ui/styles.js.map +1 -0
- package/lib/commonjs/version.js +2 -0
- package/lib/commonjs/version.js.map +1 -0
- package/{dist → lib/typescript/src}/@types/RadarNativeInterface.d.ts +18 -7
- package/lib/typescript/src/@types/RadarNativeInterface.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/@types/types.d.ts +5 -3
- package/lib/typescript/src/@types/types.d.ts.map +1 -0
- package/lib/typescript/src/NativeRadar.d.ts +87 -0
- package/lib/typescript/src/NativeRadar.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/index.native.d.ts +7 -0
- package/lib/typescript/src/index.native.d.ts.map +1 -0
- package/lib/typescript/src/plugin/types.d.ts +13 -0
- package/lib/typescript/src/plugin/types.d.ts.map +1 -0
- package/{plugin/build → lib/typescript/src/plugin}/withRadar.d.ts +2 -1
- package/lib/typescript/src/plugin/withRadar.d.ts.map +1 -0
- package/{plugin/build → lib/typescript/src/plugin}/withRadarAndroid.d.ts +1 -0
- package/lib/typescript/src/plugin/withRadarAndroid.d.ts.map +1 -0
- package/{plugin/build → lib/typescript/src/plugin}/withRadarIOS.d.ts +1 -0
- package/lib/typescript/src/plugin/withRadarIOS.d.ts.map +1 -0
- package/lib/typescript/src/version.d.ts +2 -0
- package/lib/typescript/src/version.d.ts.map +1 -0
- package/package.json +85 -34
- package/react-native.config.js +10 -0
- package/src/@types/RadarNativeInterface.ts +127 -0
- package/src/@types/types.ts +808 -0
- package/src/NativeRadar.ts +95 -0
- package/src/helpers.js +11 -0
- package/src/index.native.ts +419 -0
- package/src/index.tsx +22 -0
- package/src/index.web.js +528 -0
- package/{plugin/build/types.d.ts → src/plugin/types.ts} +1 -1
- package/src/plugin/withRadar.ts +39 -0
- package/src/plugin/withRadarAndroid.ts +147 -0
- package/src/plugin/withRadarIOS.ts +80 -0
- package/src/ui/autocomplete.jsx +324 -0
- package/src/ui/back.png +0 -0
- package/src/ui/close.png +0 -0
- package/src/ui/images.js +5 -0
- package/src/ui/map-logo.png +0 -0
- package/src/ui/map.jsx +122 -0
- package/src/ui/marker.png +0 -0
- package/src/ui/radar-logo.png +0 -0
- package/src/ui/search.png +0 -0
- package/src/ui/styles.js +125 -0
- package/src/version.ts +3 -0
- package/android/build.gradle.template +0 -49
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +0 -6
- package/android/gradlew +0 -160
- package/android/gradlew.bat +0 -90
- package/android/proguard-rules.pro +0 -4
- package/android/src/main/java/io/radar/react/RNRadarPackage.java +0 -29
- package/dist/@types/RadarNativeInterface.js +0 -2
- package/dist/@types/types.js +0 -150
- package/dist/helpers.d.ts +0 -2
- package/dist/helpers.js +0 -11
- package/dist/index.js +0 -29
- package/dist/index.native.d.ts +0 -3
- package/dist/index.native.js +0 -150
- package/dist/index.web.d.ts +0 -113
- package/dist/index.web.js +0 -516
- package/dist/ui/autocomplete.d.ts +0 -5
- package/dist/ui/autocomplete.js +0 -206
- package/dist/ui/images.d.ts +0 -5
- package/dist/ui/images.js +0 -8
- package/dist/ui/map.d.ts +0 -6
- package/dist/ui/map.js +0 -122
- package/dist/ui/styles.d.ts +0 -172
- package/dist/ui/styles.js +0 -125
- package/ios/Cartfile.private +0 -1
- package/ios/Cartfile.resolved +0 -1
- package/ios/Cartfile.resolved.template +0 -1
- package/ios/RNRadar.xcodeproj/project.pbxproj +0 -521
- package/ios/RNRadar.xcodeproj/xcshareddata/xcschemes/RNRadar.xcscheme +0 -76
- package/plugin/build/index.d.ts +0 -3
- package/plugin/build/index.js +0 -6
- package/plugin/build/types.js +0 -2
- package/plugin/build/withRadar.js +0 -26
- package/plugin/build/withRadarAndroid.js +0 -98
- package/plugin/build/withRadarIOS.js +0 -76
- package/react-native-radar.podspec +0 -19
- /package/{dist → lib/commonjs}/ui/back.png +0 -0
- /package/{dist → lib/commonjs}/ui/close.png +0 -0
- /package/{dist → lib/commonjs}/ui/map-logo.png +0 -0
- /package/{dist → lib/commonjs}/ui/marker.png +0 -0
- /package/{dist → lib/commonjs}/ui/radar-logo.png +0 -0
- /package/{dist → lib/commonjs}/ui/search.png +0 -0
package/android/src/main/java/{io/radar/react/RNRadarModule.java → com/radar/RadarModuleImpl.java}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
package
|
|
1
|
+
package com.radar;
|
|
2
2
|
|
|
3
3
|
import android.Manifest;
|
|
4
4
|
import android.app.Activity;
|
|
@@ -46,68 +46,17 @@ import org.json.JSONObject;
|
|
|
46
46
|
import java.util.EnumSet;
|
|
47
47
|
import java.util.Map;
|
|
48
48
|
|
|
49
|
-
public class
|
|
49
|
+
public class RadarModuleImpl {
|
|
50
50
|
|
|
51
51
|
private static final String TAG = "RNRadarModule";
|
|
52
|
-
private static final int PERMISSIONS_REQUEST_CODE = 20160525; // random request code (Radar's birthday!)
|
|
53
|
-
private Promise mPermissionsRequestPromise;
|
|
54
52
|
|
|
55
|
-
private RNRadarReceiver receiver;
|
|
56
|
-
private RNRadarVerifiedReceiver verifiedReceiver;
|
|
57
|
-
private int listenerCount = 0;
|
|
58
|
-
private boolean fraud = false;
|
|
59
|
-
|
|
60
|
-
public RNRadarModule(ReactApplicationContext reactContext) {
|
|
61
|
-
super(reactContext);
|
|
62
|
-
receiver = new RNRadarReceiver();
|
|
63
|
-
verifiedReceiver = new RNRadarVerifiedReceiver();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
@ReactMethod
|
|
67
|
-
public void addListener(String eventName) {
|
|
68
|
-
if (listenerCount == 0) {
|
|
69
|
-
if (fraud) {
|
|
70
|
-
verifiedReceiver.hasListeners = true;
|
|
71
|
-
}
|
|
72
|
-
receiver.hasListeners = true;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
listenerCount += 1;
|
|
76
|
-
}
|
|
77
53
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
listenerCount -= count;
|
|
81
|
-
if (listenerCount == 0) {
|
|
82
|
-
if (fraud) {
|
|
83
|
-
verifiedReceiver.hasListeners = false;
|
|
84
|
-
}
|
|
85
|
-
receiver.hasListeners = false;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
@Override
|
|
54
|
+
private boolean fraud = false;
|
|
55
|
+
|
|
90
56
|
public String getName() {
|
|
91
57
|
return "RNRadar";
|
|
92
58
|
}
|
|
93
|
-
|
|
94
|
-
@ReactMethod
|
|
95
|
-
public void initialize(String publishableKey, boolean fraud) {
|
|
96
|
-
this.fraud = fraud;
|
|
97
|
-
SharedPreferences.Editor editor = getReactApplicationContext().getSharedPreferences("RadarSDK", Context.MODE_PRIVATE).edit();
|
|
98
|
-
editor.putString("x_platform_sdk_type", "ReactNative");
|
|
99
|
-
editor.putString("x_platform_sdk_version", "3.20.4");
|
|
100
|
-
editor.apply();
|
|
101
|
-
if (fraud) {
|
|
102
|
-
Radar.initialize(getReactApplicationContext(), publishableKey, receiver, Radar.RadarLocationServicesProvider.GOOGLE, fraud);
|
|
103
|
-
Radar.setVerifiedReceiver(verifiedReceiver);
|
|
104
|
-
} else {
|
|
105
|
-
Radar.initialize(getReactApplicationContext(), publishableKey);
|
|
106
|
-
Radar.setReceiver(receiver);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
@ReactMethod
|
|
59
|
+
|
|
111
60
|
public void setLogLevel(String level) {
|
|
112
61
|
Radar.RadarLogLevel logLevel = Radar.RadarLogLevel.NONE;
|
|
113
62
|
if (level != null) {
|
|
@@ -124,12 +73,12 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
124
73
|
Radar.setLogLevel(logLevel);
|
|
125
74
|
}
|
|
126
75
|
|
|
127
|
-
|
|
76
|
+
|
|
128
77
|
public void setUserId(String userId) {
|
|
129
78
|
Radar.setUserId(userId);
|
|
130
79
|
}
|
|
131
80
|
|
|
132
|
-
|
|
81
|
+
|
|
133
82
|
public void getUserId(final Promise promise) {
|
|
134
83
|
if (promise == null) {
|
|
135
84
|
return;
|
|
@@ -138,12 +87,12 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
138
87
|
promise.resolve(Radar.getUserId());
|
|
139
88
|
}
|
|
140
89
|
|
|
141
|
-
|
|
90
|
+
|
|
142
91
|
public void setDescription(String description) {
|
|
143
92
|
Radar.setDescription(description);
|
|
144
93
|
}
|
|
145
94
|
|
|
146
|
-
|
|
95
|
+
|
|
147
96
|
public void getDescription(final Promise promise) {
|
|
148
97
|
if (promise == null) {
|
|
149
98
|
return;
|
|
@@ -152,7 +101,7 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
152
101
|
promise.resolve(Radar.getDescription());
|
|
153
102
|
}
|
|
154
103
|
|
|
155
|
-
|
|
104
|
+
|
|
156
105
|
public void nativeSdkVersion(final Promise promise) {
|
|
157
106
|
if (promise == null) {
|
|
158
107
|
return;
|
|
@@ -166,42 +115,27 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
166
115
|
}
|
|
167
116
|
}
|
|
168
117
|
|
|
169
|
-
|
|
118
|
+
|
|
170
119
|
public void setMetadata(ReadableMap metadataMap) throws JSONException {
|
|
171
|
-
Radar.setMetadata(
|
|
120
|
+
Radar.setMetadata(RadarUtils.jsonForMap(metadataMap));
|
|
172
121
|
}
|
|
173
122
|
|
|
174
|
-
|
|
123
|
+
|
|
175
124
|
public void getMetadata(final Promise promise) throws JSONException {
|
|
176
125
|
if (promise == null) {
|
|
177
126
|
return;
|
|
178
127
|
}
|
|
179
128
|
|
|
180
129
|
JSONObject metaJson = Radar.getMetadata();
|
|
181
|
-
promise.resolve(
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
@ReactMethod
|
|
185
|
-
public void setProduct(String product) throws JSONException {
|
|
186
|
-
Radar.setProduct(product);
|
|
130
|
+
promise.resolve(RadarUtils.mapForJson(metaJson));
|
|
187
131
|
}
|
|
188
132
|
|
|
189
|
-
|
|
190
|
-
public void getProduct(final Promise promise) throws JSONException {
|
|
191
|
-
if (promise == null) {
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
String product = Radar.getProduct();
|
|
196
|
-
promise.resolve(product);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
@ReactMethod
|
|
133
|
+
|
|
200
134
|
public void setAnonymousTrackingEnabled(boolean enabled) {
|
|
201
135
|
Radar.setAnonymousTrackingEnabled(enabled);
|
|
202
136
|
}
|
|
203
137
|
|
|
204
|
-
|
|
138
|
+
|
|
205
139
|
public void getHost(final Promise promise) {
|
|
206
140
|
if (promise == null) {
|
|
207
141
|
return;
|
|
@@ -210,7 +144,7 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
210
144
|
promise.resolve(Radar.getHost());
|
|
211
145
|
}
|
|
212
146
|
|
|
213
|
-
|
|
147
|
+
|
|
214
148
|
public void getPublishableKey(final Promise promise) {
|
|
215
149
|
if (promise == null) {
|
|
216
150
|
return;
|
|
@@ -218,68 +152,9 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
218
152
|
|
|
219
153
|
promise.resolve(Radar.getPublishableKey());
|
|
220
154
|
}
|
|
221
|
-
|
|
222
|
-
@ReactMethod
|
|
223
|
-
public void getPermissionsStatus(final Promise promise) {
|
|
224
|
-
if (promise == null) {
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
Activity activity = getCurrentActivity();
|
|
229
|
-
|
|
230
|
-
if (activity == null) {
|
|
231
|
-
promise.resolve("UNKNOWN");
|
|
232
|
-
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
boolean foreground = ActivityCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED ||
|
|
237
|
-
ActivityCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED;
|
|
238
|
-
boolean background = foreground;
|
|
239
|
-
boolean denied = ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.ACCESS_FINE_LOCATION);
|
|
240
|
-
|
|
241
|
-
if (Build.VERSION.SDK_INT >= 29) {
|
|
242
|
-
background = ActivityCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_BACKGROUND_LOCATION) == PackageManager.PERMISSION_GRANTED;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
if (background) {
|
|
246
|
-
promise.resolve("GRANTED_BACKGROUND");
|
|
247
|
-
} else if (foreground) {
|
|
248
|
-
promise.resolve("GRANTED_FOREGROUND");
|
|
249
|
-
} else if (denied) {
|
|
250
|
-
promise.resolve("DENIED");
|
|
251
|
-
} else {
|
|
252
|
-
promise.resolve("NOT_DETERMINED");
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
@Override
|
|
257
|
-
public boolean onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
|
258
|
-
if (requestCode == PERMISSIONS_REQUEST_CODE && mPermissionsRequestPromise != null) {
|
|
259
|
-
getPermissionsStatus(mPermissionsRequestPromise);
|
|
260
|
-
mPermissionsRequestPromise = null;
|
|
261
|
-
}
|
|
262
|
-
return true;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
@ReactMethod
|
|
267
|
-
public void requestPermissions(boolean background, final Promise promise) {
|
|
268
|
-
PermissionAwareActivity activity = (PermissionAwareActivity)getCurrentActivity();
|
|
269
|
-
mPermissionsRequestPromise = promise;
|
|
270
|
-
if (activity != null) {
|
|
271
|
-
if (Build.VERSION.SDK_INT >= 23) {
|
|
272
|
-
if (background && Build.VERSION.SDK_INT >= 29) {
|
|
273
|
-
activity.requestPermissions(new String[] { Manifest.permission.ACCESS_BACKGROUND_LOCATION }, PERMISSIONS_REQUEST_CODE, this);
|
|
274
|
-
} else {
|
|
275
|
-
activity.requestPermissions(new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, PERMISSIONS_REQUEST_CODE, this);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
@ReactMethod
|
|
155
|
+
|
|
282
156
|
public void getLocation(String desiredAccuracy, final Promise promise) {
|
|
157
|
+
|
|
283
158
|
RadarTrackingOptions.RadarTrackingOptionsDesiredAccuracy accuracyLevel = RadarTrackingOptions.RadarTrackingOptionsDesiredAccuracy.MEDIUM;
|
|
284
159
|
String accuracy = desiredAccuracy != null ? desiredAccuracy.toLowerCase() : "medium";
|
|
285
160
|
|
|
@@ -294,7 +169,7 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
294
169
|
}
|
|
295
170
|
|
|
296
171
|
Radar.getLocation(accuracyLevel, new Radar.RadarLocationCallback() {
|
|
297
|
-
|
|
172
|
+
|
|
298
173
|
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable Location location, boolean stopped) {
|
|
299
174
|
if (promise == null) {
|
|
300
175
|
return;
|
|
@@ -305,7 +180,7 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
305
180
|
WritableMap map = Arguments.createMap();
|
|
306
181
|
map.putString("status", status.toString());
|
|
307
182
|
if (location != null) {
|
|
308
|
-
map.putMap("location",
|
|
183
|
+
map.putMap("location", RadarUtils.mapForJson(Radar.jsonForLocation(location)));
|
|
309
184
|
}
|
|
310
185
|
map.putBoolean("stopped", stopped);
|
|
311
186
|
promise.resolve(map);
|
|
@@ -320,7 +195,7 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
320
195
|
});
|
|
321
196
|
}
|
|
322
197
|
|
|
323
|
-
|
|
198
|
+
|
|
324
199
|
public void trackOnce(ReadableMap optionsMap, final Promise promise) {
|
|
325
200
|
|
|
326
201
|
Location location = null;
|
|
@@ -356,7 +231,7 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
356
231
|
}
|
|
357
232
|
|
|
358
233
|
Radar.RadarTrackCallback trackCallback = new Radar.RadarTrackCallback() {
|
|
359
|
-
|
|
234
|
+
|
|
360
235
|
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable Location location, @Nullable RadarEvent[] events, @Nullable RadarUser user) {
|
|
361
236
|
if (promise == null) {
|
|
362
237
|
return;
|
|
@@ -367,13 +242,13 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
367
242
|
WritableMap map = Arguments.createMap();
|
|
368
243
|
map.putString("status", status.toString());
|
|
369
244
|
if (location != null) {
|
|
370
|
-
map.putMap("location",
|
|
245
|
+
map.putMap("location", RadarUtils.mapForJson(Radar.jsonForLocation(location)));
|
|
371
246
|
}
|
|
372
247
|
if (events != null) {
|
|
373
|
-
map.putArray("events",
|
|
248
|
+
map.putArray("events", RadarUtils.arrayForJson(RadarEvent.toJson(events)));
|
|
374
249
|
}
|
|
375
250
|
if (user != null) {
|
|
376
|
-
map.putMap("user",
|
|
251
|
+
map.putMap("user", RadarUtils.mapForJson(user.toJson()));
|
|
377
252
|
}
|
|
378
253
|
promise.resolve(map);
|
|
379
254
|
} else {
|
|
@@ -393,13 +268,11 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
393
268
|
}
|
|
394
269
|
}
|
|
395
270
|
|
|
396
|
-
|
|
271
|
+
|
|
397
272
|
public void trackVerified(ReadableMap optionsMap, final Promise promise) {
|
|
398
273
|
|
|
399
274
|
boolean beaconsTrackingOption = false;
|
|
400
275
|
RadarTrackingOptions.RadarTrackingOptionsDesiredAccuracy accuracyLevel = RadarTrackingOptions.RadarTrackingOptionsDesiredAccuracy.MEDIUM;
|
|
401
|
-
String reason = null;
|
|
402
|
-
String transactionId = null;
|
|
403
276
|
|
|
404
277
|
if (optionsMap != null) {
|
|
405
278
|
if (optionsMap.hasKey("beacons")) {
|
|
@@ -417,16 +290,10 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
417
290
|
accuracyLevel = RadarTrackingOptions.RadarTrackingOptionsDesiredAccuracy.HIGH;
|
|
418
291
|
}
|
|
419
292
|
}
|
|
420
|
-
if (optionsMap.hasKey("reason")) {
|
|
421
|
-
reason = optionsMap.getString("reason");
|
|
422
|
-
}
|
|
423
|
-
if (optionsMap.hasKey("transactionId")) {
|
|
424
|
-
transactionId = optionsMap.getString("transactionId");
|
|
425
|
-
}
|
|
426
293
|
}
|
|
427
294
|
|
|
428
295
|
Radar.RadarTrackVerifiedCallback trackCallback = new Radar.RadarTrackVerifiedCallback() {
|
|
429
|
-
|
|
296
|
+
|
|
430
297
|
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarVerifiedLocationToken token) {
|
|
431
298
|
if (promise == null) {
|
|
432
299
|
return;
|
|
@@ -437,7 +304,7 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
437
304
|
WritableMap map = Arguments.createMap();
|
|
438
305
|
map.putString("status", status.toString());
|
|
439
306
|
if (token != null) {
|
|
440
|
-
map.putMap("token",
|
|
307
|
+
map.putMap("token", RadarUtils.mapForJson(token.toJson()));
|
|
441
308
|
}
|
|
442
309
|
promise.resolve(map);
|
|
443
310
|
} else {
|
|
@@ -450,18 +317,23 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
450
317
|
}
|
|
451
318
|
};
|
|
452
319
|
|
|
453
|
-
Radar.trackVerified(beaconsTrackingOption, accuracyLevel,
|
|
320
|
+
Radar.trackVerified(beaconsTrackingOption, accuracyLevel, trackCallback);
|
|
454
321
|
}
|
|
455
322
|
|
|
456
|
-
|
|
323
|
+
|
|
457
324
|
public void isTrackingVerified(final Promise promise) {
|
|
458
325
|
promise.resolve(Radar.isTrackingVerified());
|
|
459
326
|
}
|
|
460
327
|
|
|
461
|
-
|
|
328
|
+
|
|
329
|
+
public void setProduct(String product) {
|
|
330
|
+
Radar.setProduct(product);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
|
|
462
334
|
public void getVerifiedLocationToken(final Promise promise) {
|
|
463
335
|
Radar.RadarTrackVerifiedCallback trackCallback = new Radar.RadarTrackVerifiedCallback() {
|
|
464
|
-
|
|
336
|
+
|
|
465
337
|
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarVerifiedLocationToken token) {
|
|
466
338
|
if (promise == null) {
|
|
467
339
|
return;
|
|
@@ -472,7 +344,7 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
472
344
|
WritableMap map = Arguments.createMap();
|
|
473
345
|
map.putString("status", status.toString());
|
|
474
346
|
if (token != null) {
|
|
475
|
-
map.putMap("token",
|
|
347
|
+
map.putMap("token", RadarUtils.mapForJson(token.toJson()));
|
|
476
348
|
}
|
|
477
349
|
promise.resolve(map);
|
|
478
350
|
} else {
|
|
@@ -488,30 +360,30 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
488
360
|
Radar.getVerifiedLocationToken(trackCallback);
|
|
489
361
|
}
|
|
490
362
|
|
|
491
|
-
|
|
363
|
+
|
|
492
364
|
public void clearVerifiedLocationToken() {
|
|
493
365
|
Radar.clearVerifiedLocationToken();
|
|
494
366
|
}
|
|
495
367
|
|
|
496
|
-
|
|
368
|
+
|
|
497
369
|
public void startTrackingEfficient() {
|
|
498
370
|
Radar.startTracking(RadarTrackingOptions.EFFICIENT);
|
|
499
371
|
}
|
|
500
372
|
|
|
501
|
-
|
|
373
|
+
|
|
502
374
|
public void startTrackingResponsive() {
|
|
503
375
|
Radar.startTracking(RadarTrackingOptions.RESPONSIVE);
|
|
504
376
|
}
|
|
505
377
|
|
|
506
|
-
|
|
378
|
+
|
|
507
379
|
public void startTrackingContinuous() {
|
|
508
380
|
Radar.startTracking(RadarTrackingOptions.CONTINUOUS);
|
|
509
381
|
}
|
|
510
382
|
|
|
511
|
-
|
|
383
|
+
|
|
512
384
|
public void startTrackingCustom(ReadableMap optionsMap) {
|
|
513
385
|
try {
|
|
514
|
-
JSONObject optionsObj =
|
|
386
|
+
JSONObject optionsObj = RadarUtils.jsonForMap(optionsMap);
|
|
515
387
|
RadarTrackingOptions options = RadarTrackingOptions.fromJson(optionsObj);
|
|
516
388
|
Radar.startTracking(options);
|
|
517
389
|
} catch (JSONException e) {
|
|
@@ -519,7 +391,7 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
519
391
|
}
|
|
520
392
|
}
|
|
521
393
|
|
|
522
|
-
|
|
394
|
+
|
|
523
395
|
public void startTrackingVerified(ReadableMap optionsMap) {
|
|
524
396
|
boolean beacons = false;
|
|
525
397
|
int interval = 1200;
|
|
@@ -532,7 +404,7 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
532
404
|
Radar.startTrackingVerified(interval, beacons);
|
|
533
405
|
}
|
|
534
406
|
|
|
535
|
-
|
|
407
|
+
|
|
536
408
|
public void mockTracking(ReadableMap optionsMap) {
|
|
537
409
|
ReadableMap originMap = optionsMap.getMap("origin");
|
|
538
410
|
double originLatitude = originMap.getDouble("latitude");
|
|
@@ -559,24 +431,24 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
559
431
|
int interval = optionsMap.hasKey("interval") ? optionsMap.getInt("interval") : 1;
|
|
560
432
|
|
|
561
433
|
Radar.mockTracking(origin, destination, mode, steps, interval, new Radar.RadarTrackCallback() {
|
|
562
|
-
|
|
434
|
+
|
|
563
435
|
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable Location location, @Nullable RadarEvent[] events, @Nullable RadarUser user) {
|
|
564
436
|
|
|
565
437
|
}
|
|
566
438
|
});
|
|
567
439
|
}
|
|
568
440
|
|
|
569
|
-
|
|
441
|
+
|
|
570
442
|
public void stopTracking() {
|
|
571
443
|
Radar.stopTracking();
|
|
572
444
|
}
|
|
573
445
|
|
|
574
|
-
|
|
446
|
+
|
|
575
447
|
public void stopTrackingVerified() {
|
|
576
448
|
Radar.stopTrackingVerified();
|
|
577
449
|
}
|
|
578
450
|
|
|
579
|
-
|
|
451
|
+
|
|
580
452
|
public void isTracking(final Promise promise) {
|
|
581
453
|
if (promise == null) {
|
|
582
454
|
return;
|
|
@@ -585,21 +457,21 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
585
457
|
promise.resolve(Radar.isTracking());
|
|
586
458
|
}
|
|
587
459
|
|
|
588
|
-
|
|
460
|
+
|
|
589
461
|
public void getTrackingOptions(final Promise promise) {
|
|
590
462
|
if (promise == null) {
|
|
591
463
|
return;
|
|
592
464
|
}
|
|
593
465
|
try {
|
|
594
466
|
RadarTrackingOptions options = Radar.getTrackingOptions();
|
|
595
|
-
promise.resolve(
|
|
467
|
+
promise.resolve(RadarUtils.mapForJson(options.toJson()));
|
|
596
468
|
} catch(JSONException e) {
|
|
597
469
|
Log.e(TAG, "JSONException", e);
|
|
598
470
|
promise.reject(Radar.RadarStatus.ERROR_SERVER.toString(), Radar.RadarStatus.ERROR_SERVER.toString());
|
|
599
471
|
}
|
|
600
472
|
}
|
|
601
473
|
|
|
602
|
-
|
|
474
|
+
|
|
603
475
|
public void isUsingRemoteTrackingOptions(final Promise promise) {
|
|
604
476
|
if (promise == null) {
|
|
605
477
|
return;
|
|
@@ -608,10 +480,10 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
608
480
|
promise.resolve(Radar.isUsingRemoteTrackingOptions());
|
|
609
481
|
}
|
|
610
482
|
|
|
611
|
-
|
|
483
|
+
|
|
612
484
|
public void setForegroundServiceOptions(ReadableMap optionsMap) {
|
|
613
485
|
try {
|
|
614
|
-
JSONObject optionsObj =
|
|
486
|
+
JSONObject optionsObj = RadarUtils.jsonForMap(optionsMap);
|
|
615
487
|
RadarTrackingOptionsForegroundService options = RadarTrackingOptionsForegroundService.fromJson(optionsObj);
|
|
616
488
|
Radar.setForegroundServiceOptions(options);
|
|
617
489
|
} catch (JSONException e) {
|
|
@@ -619,10 +491,10 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
619
491
|
}
|
|
620
492
|
}
|
|
621
493
|
|
|
622
|
-
|
|
494
|
+
|
|
623
495
|
public void setNotificationOptions(ReadableMap optionsMap) {
|
|
624
496
|
try {
|
|
625
|
-
JSONObject optionsObj =
|
|
497
|
+
JSONObject optionsObj = RadarUtils.jsonForMap(optionsMap);
|
|
626
498
|
RadarNotificationOptions options = RadarNotificationOptions.fromJson(optionsObj);
|
|
627
499
|
Radar.setNotificationOptions(options);
|
|
628
500
|
} catch (JSONException e) {
|
|
@@ -630,34 +502,34 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
630
502
|
}
|
|
631
503
|
}
|
|
632
504
|
|
|
633
|
-
|
|
505
|
+
|
|
634
506
|
public void acceptEvent(String eventId, String verifiedPlaceId) {
|
|
635
507
|
Radar.acceptEvent(eventId, verifiedPlaceId);
|
|
636
508
|
}
|
|
637
509
|
|
|
638
|
-
|
|
510
|
+
|
|
639
511
|
public void rejectEvent(String eventId) {
|
|
640
512
|
Radar.rejectEvent(eventId);
|
|
641
513
|
}
|
|
642
514
|
|
|
643
|
-
|
|
515
|
+
|
|
644
516
|
public void getTripOptions(final Promise promise) {
|
|
645
517
|
if (promise == null) {
|
|
646
518
|
return;
|
|
647
519
|
}
|
|
648
520
|
try {
|
|
649
521
|
RadarTripOptions options = Radar.getTripOptions();
|
|
650
|
-
promise.resolve(options != null ?
|
|
522
|
+
promise.resolve(options != null ? RadarUtils.mapForJson(options.toJson()) : null);
|
|
651
523
|
} catch(JSONException e) {
|
|
652
524
|
Log.e(TAG, "JSONException", e);
|
|
653
525
|
promise.reject(Radar.RadarStatus.ERROR_SERVER.toString(), Radar.RadarStatus.ERROR_SERVER.toString());
|
|
654
526
|
}
|
|
655
527
|
}
|
|
656
528
|
|
|
657
|
-
|
|
529
|
+
|
|
658
530
|
public void startTrip(ReadableMap optionsMap, final Promise promise) {
|
|
659
531
|
try {
|
|
660
|
-
JSONObject optionsJson =
|
|
532
|
+
JSONObject optionsJson = RadarUtils.jsonForMap(optionsMap);
|
|
661
533
|
// new format is { tripOptions, trackingOptions }
|
|
662
534
|
JSONObject tripOptionsJson = optionsJson.optJSONObject("tripOptions");
|
|
663
535
|
if (tripOptionsJson == null) {
|
|
@@ -672,7 +544,7 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
672
544
|
trackingOptions = RadarTrackingOptions.fromJson(trackingOptionsJson);
|
|
673
545
|
}
|
|
674
546
|
Radar.startTrip(options, trackingOptions, new Radar.RadarTripCallback() {
|
|
675
|
-
|
|
547
|
+
|
|
676
548
|
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarTrip trip, @Nullable RadarEvent[] events) {
|
|
677
549
|
if (promise == null) {
|
|
678
550
|
return;
|
|
@@ -682,10 +554,10 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
682
554
|
WritableMap map = Arguments.createMap();
|
|
683
555
|
map.putString("status", status.toString());
|
|
684
556
|
if (trip != null) {
|
|
685
|
-
map.putMap("trip",
|
|
557
|
+
map.putMap("trip", RadarUtils.mapForJson(trip.toJson()));
|
|
686
558
|
}
|
|
687
559
|
if (events != null) {
|
|
688
|
-
map.putArray("events",
|
|
560
|
+
map.putArray("events", RadarUtils.arrayForJson(RadarEvent.toJson(events)));
|
|
689
561
|
}
|
|
690
562
|
promise.resolve(map);
|
|
691
563
|
} else {
|
|
@@ -703,10 +575,10 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
703
575
|
}
|
|
704
576
|
}
|
|
705
577
|
|
|
706
|
-
|
|
578
|
+
|
|
707
579
|
public void completeTrip(final Promise promise) {
|
|
708
580
|
Radar.completeTrip(new Radar.RadarTripCallback() {
|
|
709
|
-
|
|
581
|
+
|
|
710
582
|
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarTrip trip, @Nullable RadarEvent[] events) {
|
|
711
583
|
if (promise == null) {
|
|
712
584
|
return;
|
|
@@ -716,10 +588,10 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
716
588
|
WritableMap map = Arguments.createMap();
|
|
717
589
|
map.putString("status", status.toString());
|
|
718
590
|
if (trip != null) {
|
|
719
|
-
map.putMap("trip",
|
|
591
|
+
map.putMap("trip", RadarUtils.mapForJson(trip.toJson()));
|
|
720
592
|
}
|
|
721
593
|
if (events != null) {
|
|
722
|
-
map.putArray("events",
|
|
594
|
+
map.putArray("events", RadarUtils.arrayForJson(RadarEvent.toJson(events)));
|
|
723
595
|
}
|
|
724
596
|
promise.resolve(map);
|
|
725
597
|
} else {
|
|
@@ -733,10 +605,10 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
733
605
|
});
|
|
734
606
|
}
|
|
735
607
|
|
|
736
|
-
|
|
608
|
+
|
|
737
609
|
public void cancelTrip(final Promise promise) {
|
|
738
610
|
Radar.cancelTrip(new Radar.RadarTripCallback() {
|
|
739
|
-
|
|
611
|
+
|
|
740
612
|
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarTrip trip, @Nullable RadarEvent[] events) {
|
|
741
613
|
if (promise == null) {
|
|
742
614
|
return;
|
|
@@ -746,10 +618,10 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
746
618
|
WritableMap map = Arguments.createMap();
|
|
747
619
|
map.putString("status", status.toString());
|
|
748
620
|
if (trip != null) {
|
|
749
|
-
map.putMap("trip",
|
|
621
|
+
map.putMap("trip", RadarUtils.mapForJson(trip.toJson()));
|
|
750
622
|
}
|
|
751
623
|
if (events != null) {
|
|
752
|
-
map.putArray("events",
|
|
624
|
+
map.putArray("events", RadarUtils.arrayForJson(RadarEvent.toJson(events)));
|
|
753
625
|
}
|
|
754
626
|
promise.resolve(map);
|
|
755
627
|
} else {
|
|
@@ -763,11 +635,11 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
763
635
|
});
|
|
764
636
|
}
|
|
765
637
|
|
|
766
|
-
|
|
638
|
+
|
|
767
639
|
public void updateTrip(ReadableMap optionsMap, final Promise promise) {
|
|
768
640
|
|
|
769
641
|
try {
|
|
770
|
-
JSONObject optionsObj =
|
|
642
|
+
JSONObject optionsObj = RadarUtils.jsonForMap(optionsMap);
|
|
771
643
|
RadarTripOptions options = RadarTripOptions.fromJson(optionsObj.getJSONObject("options"));
|
|
772
644
|
RadarTrip.RadarTripStatus status = RadarTrip.RadarTripStatus.UNKNOWN;
|
|
773
645
|
|
|
@@ -795,7 +667,7 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
795
667
|
}
|
|
796
668
|
|
|
797
669
|
Radar.updateTrip(options, status, new Radar.RadarTripCallback() {
|
|
798
|
-
|
|
670
|
+
|
|
799
671
|
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarTrip trip, @Nullable RadarEvent[] events) {
|
|
800
672
|
if (promise == null) {
|
|
801
673
|
return;
|
|
@@ -805,10 +677,10 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
805
677
|
WritableMap map = Arguments.createMap();
|
|
806
678
|
map.putString("status", status.toString());
|
|
807
679
|
if (trip != null) {
|
|
808
|
-
map.putMap("trip",
|
|
680
|
+
map.putMap("trip", RadarUtils.mapForJson(trip.toJson()));
|
|
809
681
|
}
|
|
810
682
|
if (events != null) {
|
|
811
|
-
map.putArray("events",
|
|
683
|
+
map.putArray("events", RadarUtils.arrayForJson(RadarEvent.toJson(events)));
|
|
812
684
|
}
|
|
813
685
|
promise.resolve(map);
|
|
814
686
|
} else {
|
|
@@ -826,24 +698,24 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
826
698
|
}
|
|
827
699
|
}
|
|
828
700
|
|
|
829
|
-
|
|
701
|
+
|
|
830
702
|
public void getContext(@Nullable ReadableMap locationMap, final Promise promise) {
|
|
831
703
|
if (promise == null) {
|
|
832
704
|
return;
|
|
833
705
|
}
|
|
834
706
|
|
|
835
707
|
Radar.RadarContextCallback callback = new Radar.RadarContextCallback() {
|
|
836
|
-
|
|
708
|
+
|
|
837
709
|
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable Location location, @Nullable RadarContext context) {
|
|
838
710
|
if (status == Radar.RadarStatus.SUCCESS) {
|
|
839
711
|
try {
|
|
840
712
|
WritableMap map = Arguments.createMap();
|
|
841
713
|
map.putString("status", status.toString());
|
|
842
714
|
if (location != null) {
|
|
843
|
-
map.putMap("location",
|
|
715
|
+
map.putMap("location", RadarUtils.mapForJson(Radar.jsonForLocation(location)));
|
|
844
716
|
}
|
|
845
717
|
if (context != null) {
|
|
846
|
-
map.putMap("context",
|
|
718
|
+
map.putMap("context", RadarUtils.mapForJson(context.toJson()));
|
|
847
719
|
}
|
|
848
720
|
promise.resolve(map);
|
|
849
721
|
} catch (JSONException e) {
|
|
@@ -868,7 +740,7 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
868
740
|
}
|
|
869
741
|
}
|
|
870
742
|
|
|
871
|
-
|
|
743
|
+
|
|
872
744
|
public void searchPlaces(ReadableMap optionsMap, final Promise promise) {
|
|
873
745
|
if (promise == null) {
|
|
874
746
|
return;
|
|
@@ -884,25 +756,25 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
884
756
|
near.setLongitude(longitude);
|
|
885
757
|
}
|
|
886
758
|
int radius = optionsMap.hasKey("radius") ? optionsMap.getInt("radius") : 1000;
|
|
887
|
-
String[] chains = optionsMap.hasKey("chains") ?
|
|
888
|
-
Map<String, String> chainMetadata =
|
|
889
|
-
String[] categories = optionsMap.hasKey("categories") ?
|
|
890
|
-
String[] groups = optionsMap.hasKey("groups") ?
|
|
891
|
-
String[] countryCodes = optionsMap.hasKey("countryCodes") ?
|
|
759
|
+
String[] chains = optionsMap.hasKey("chains") ? RadarUtils.stringArrayForArray(optionsMap.getArray("chains")) : null;
|
|
760
|
+
Map<String, String> chainMetadata = RadarUtils.stringStringMap(optionsMap.getMap("chainMetadata"));
|
|
761
|
+
String[] categories = optionsMap.hasKey("categories") ? RadarUtils.stringArrayForArray(optionsMap.getArray("categories")) : null;
|
|
762
|
+
String[] groups = optionsMap.hasKey("groups") ? RadarUtils.stringArrayForArray(optionsMap.getArray("groups")) : null;
|
|
763
|
+
String[] countryCodes = optionsMap.hasKey("countryCodes") ? RadarUtils.stringArrayForArray(optionsMap.getArray("countryCodes")) : null;
|
|
892
764
|
int limit = optionsMap.hasKey("limit") ? optionsMap.getInt("limit") : 10;
|
|
893
765
|
|
|
894
766
|
Radar.RadarSearchPlacesCallback callback = new Radar.RadarSearchPlacesCallback() {
|
|
895
|
-
|
|
767
|
+
|
|
896
768
|
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable Location location, @Nullable RadarPlace[] places) {
|
|
897
769
|
if (status == Radar.RadarStatus.SUCCESS) {
|
|
898
770
|
try {
|
|
899
771
|
WritableMap map = Arguments.createMap();
|
|
900
772
|
map.putString("status", status.toString());
|
|
901
773
|
if (location != null) {
|
|
902
|
-
map.putMap("location",
|
|
774
|
+
map.putMap("location", RadarUtils.mapForJson(Radar.jsonForLocation(location)));
|
|
903
775
|
}
|
|
904
776
|
if (places != null) {
|
|
905
|
-
map.putArray("places",
|
|
777
|
+
map.putArray("places", RadarUtils.arrayForJson(RadarPlace.toJson(places)));
|
|
906
778
|
}
|
|
907
779
|
promise.resolve(map);
|
|
908
780
|
} catch (JSONException e) {
|
|
@@ -922,7 +794,7 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
922
794
|
}
|
|
923
795
|
}
|
|
924
796
|
|
|
925
|
-
|
|
797
|
+
|
|
926
798
|
public void searchGeofences(ReadableMap optionsMap, final Promise promise) {
|
|
927
799
|
if (promise == null) {
|
|
928
800
|
return;
|
|
@@ -938,11 +810,11 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
938
810
|
near.setLongitude(longitude);
|
|
939
811
|
}
|
|
940
812
|
Integer radius = optionsMap.hasKey("radius") ? optionsMap.getInt("radius") : null;
|
|
941
|
-
String[] tags = optionsMap.hasKey("tags") ?
|
|
813
|
+
String[] tags = optionsMap.hasKey("tags") ? RadarUtils.stringArrayForArray(optionsMap.getArray("tags")) : null;
|
|
942
814
|
JSONObject metadata = null;
|
|
943
815
|
if (optionsMap.hasKey("metadata")) {
|
|
944
816
|
try {
|
|
945
|
-
metadata =
|
|
817
|
+
metadata = RadarUtils.jsonForMap(optionsMap.getMap("metadata"));
|
|
946
818
|
} catch (JSONException e) {
|
|
947
819
|
Log.e(TAG, "JSONException", e);
|
|
948
820
|
promise.reject(Radar.RadarStatus.ERROR_BAD_REQUEST.toString(), Radar.RadarStatus.ERROR_BAD_REQUEST.toString());
|
|
@@ -955,17 +827,17 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
955
827
|
boolean includeGeometry = optionsMap.hasKey("includeGeometry") ? optionsMap.getBoolean("includeGeometry") : false;
|
|
956
828
|
|
|
957
829
|
Radar.RadarSearchGeofencesCallback callback = new Radar.RadarSearchGeofencesCallback() {
|
|
958
|
-
|
|
830
|
+
|
|
959
831
|
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable Location location, @Nullable RadarGeofence[] geofences) {
|
|
960
832
|
if (status == Radar.RadarStatus.SUCCESS) {
|
|
961
833
|
try {
|
|
962
834
|
WritableMap map = Arguments.createMap();
|
|
963
835
|
map.putString("status", status.toString());
|
|
964
836
|
if (location != null) {
|
|
965
|
-
map.putMap("location",
|
|
837
|
+
map.putMap("location", RadarUtils.mapForJson(Radar.jsonForLocation(location)));
|
|
966
838
|
}
|
|
967
839
|
if (geofences != null) {
|
|
968
|
-
map.putArray("geofences",
|
|
840
|
+
map.putArray("geofences", RadarUtils.arrayForJson(RadarGeofence.toJson(geofences)));
|
|
969
841
|
}
|
|
970
842
|
promise.resolve(map);
|
|
971
843
|
} catch (JSONException e) {
|
|
@@ -985,7 +857,7 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
985
857
|
}
|
|
986
858
|
}
|
|
987
859
|
|
|
988
|
-
|
|
860
|
+
|
|
989
861
|
public void autocomplete(ReadableMap optionsMap, final Promise promise) {
|
|
990
862
|
if (promise == null) {
|
|
991
863
|
return;
|
|
@@ -1018,19 +890,19 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
1018
890
|
|
|
1019
891
|
int limit = optionsMap.hasKey("limit") ? optionsMap.getInt("limit") : 10;
|
|
1020
892
|
String country = optionsMap.hasKey("countryCode") ? optionsMap.getString("countryCode") : optionsMap.hasKey("country") ? optionsMap.getString("country") : null;
|
|
1021
|
-
String[] layers = optionsMap.hasKey("layers") ?
|
|
893
|
+
String[] layers = optionsMap.hasKey("layers") ? RadarUtils.stringArrayForArray(optionsMap.getArray("layers")) : null;
|
|
1022
894
|
|
|
1023
895
|
boolean mailable = optionsMap.hasKey("mailable") ? optionsMap.getBoolean("mailable") : false;
|
|
1024
896
|
|
|
1025
897
|
Radar.autocomplete(query, near, layers, limit, country, true, mailable, new Radar.RadarGeocodeCallback() {
|
|
1026
|
-
|
|
898
|
+
|
|
1027
899
|
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarAddress[] addresses) {
|
|
1028
900
|
if (status == Radar.RadarStatus.SUCCESS) {
|
|
1029
901
|
try {
|
|
1030
902
|
WritableMap map = Arguments.createMap();
|
|
1031
903
|
map.putString("status", status.toString());
|
|
1032
904
|
if (addresses != null) {
|
|
1033
|
-
map.putArray("addresses",
|
|
905
|
+
map.putArray("addresses", RadarUtils.arrayForJson(RadarAddress.toJson(addresses)));
|
|
1034
906
|
}
|
|
1035
907
|
promise.resolve(map);
|
|
1036
908
|
} catch (JSONException e) {
|
|
@@ -1044,7 +916,7 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
1044
916
|
});
|
|
1045
917
|
}
|
|
1046
918
|
|
|
1047
|
-
|
|
919
|
+
|
|
1048
920
|
public void geocode(ReadableMap optionsMap, final Promise promise) {
|
|
1049
921
|
if (promise == null) {
|
|
1050
922
|
return;
|
|
@@ -1057,18 +929,18 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
1057
929
|
}
|
|
1058
930
|
|
|
1059
931
|
String address = optionsMap.getString("address");
|
|
1060
|
-
String[] layers = optionsMap.hasKey("layers") ?
|
|
1061
|
-
String[] countries = optionsMap.hasKey("countries") ?
|
|
932
|
+
String[] layers = optionsMap.hasKey("layers") ? RadarUtils.stringArrayForArray(optionsMap.getArray("layers")) : null;
|
|
933
|
+
String[] countries = optionsMap.hasKey("countries") ? RadarUtils.stringArrayForArray(optionsMap.getArray("countries")) : null;
|
|
1062
934
|
|
|
1063
935
|
Radar.geocode(address, layers, countries, new Radar.RadarGeocodeCallback() {
|
|
1064
|
-
|
|
936
|
+
|
|
1065
937
|
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarAddress[] addresses) {
|
|
1066
938
|
if (status == Radar.RadarStatus.SUCCESS) {
|
|
1067
939
|
try {
|
|
1068
940
|
WritableMap map = Arguments.createMap();
|
|
1069
941
|
map.putString("status", status.toString());
|
|
1070
942
|
if (addresses != null) {
|
|
1071
|
-
map.putArray("addresses",
|
|
943
|
+
map.putArray("addresses", RadarUtils.arrayForJson(RadarAddress.toJson(addresses)));
|
|
1072
944
|
}
|
|
1073
945
|
promise.resolve(map);
|
|
1074
946
|
} catch (JSONException e) {
|
|
@@ -1082,7 +954,7 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
1082
954
|
});
|
|
1083
955
|
}
|
|
1084
956
|
|
|
1085
|
-
|
|
957
|
+
|
|
1086
958
|
public void reverseGeocode(ReadableMap optionsMap, final Promise promise) {
|
|
1087
959
|
if (promise == null) {
|
|
1088
960
|
return;
|
|
@@ -1093,18 +965,18 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
1093
965
|
|
|
1094
966
|
if (optionsMap != null) {
|
|
1095
967
|
locationMap = optionsMap.getMap("location");
|
|
1096
|
-
layers = optionsMap.hasKey("layers") ?
|
|
968
|
+
layers = optionsMap.hasKey("layers") ? RadarUtils.stringArrayForArray(optionsMap.getArray("layers")) : null;
|
|
1097
969
|
}
|
|
1098
970
|
|
|
1099
971
|
Radar.RadarGeocodeCallback callback = new Radar.RadarGeocodeCallback() {
|
|
1100
|
-
|
|
972
|
+
|
|
1101
973
|
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarAddress[] addresses) {
|
|
1102
974
|
if (status == Radar.RadarStatus.SUCCESS) {
|
|
1103
975
|
try {
|
|
1104
976
|
WritableMap map = Arguments.createMap();
|
|
1105
977
|
map.putString("status", status.toString());
|
|
1106
978
|
if (addresses != null) {
|
|
1107
|
-
map.putArray("addresses",
|
|
979
|
+
map.putArray("addresses", RadarUtils.arrayForJson(RadarAddress.toJson(addresses)));
|
|
1108
980
|
}
|
|
1109
981
|
promise.resolve(map);
|
|
1110
982
|
} catch (JSONException e) {
|
|
@@ -1130,21 +1002,21 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
1130
1002
|
}
|
|
1131
1003
|
}
|
|
1132
1004
|
|
|
1133
|
-
|
|
1005
|
+
|
|
1134
1006
|
public void ipGeocode(final Promise promise) {
|
|
1135
1007
|
if (promise == null) {
|
|
1136
1008
|
return;
|
|
1137
1009
|
}
|
|
1138
1010
|
|
|
1139
1011
|
Radar.ipGeocode(new Radar.RadarIpGeocodeCallback() {
|
|
1140
|
-
|
|
1012
|
+
|
|
1141
1013
|
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarAddress address, boolean proxy) {
|
|
1142
1014
|
if (status == Radar.RadarStatus.SUCCESS) {
|
|
1143
1015
|
try {
|
|
1144
1016
|
WritableMap map = Arguments.createMap();
|
|
1145
1017
|
map.putString("status", status.toString());
|
|
1146
1018
|
if (address != null) {
|
|
1147
|
-
map.putMap("address",
|
|
1019
|
+
map.putMap("address", RadarUtils.mapForJson(address.toJson()));
|
|
1148
1020
|
map.putBoolean("proxy", proxy);
|
|
1149
1021
|
}
|
|
1150
1022
|
promise.resolve(map);
|
|
@@ -1159,7 +1031,7 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
1159
1031
|
});
|
|
1160
1032
|
}
|
|
1161
1033
|
|
|
1162
|
-
|
|
1034
|
+
|
|
1163
1035
|
public void validateAddress(ReadableMap addressMap, final Promise promise) {
|
|
1164
1036
|
if (promise == null) {
|
|
1165
1037
|
return;
|
|
@@ -1167,20 +1039,20 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
1167
1039
|
|
|
1168
1040
|
RadarAddress address;
|
|
1169
1041
|
try {
|
|
1170
|
-
address = RadarAddress.fromJson(
|
|
1042
|
+
address = RadarAddress.fromJson(RadarUtils.jsonForMap(addressMap));
|
|
1171
1043
|
} catch (JSONException e) {
|
|
1172
1044
|
promise.reject(Radar.RadarStatus.ERROR_BAD_REQUEST.toString(), Radar.RadarStatus.ERROR_BAD_REQUEST.toString());
|
|
1173
1045
|
return;
|
|
1174
1046
|
}
|
|
1175
1047
|
Radar.validateAddress(address, new Radar.RadarValidateAddressCallback() {
|
|
1176
|
-
|
|
1048
|
+
|
|
1177
1049
|
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarAddress address, @Nullable Radar.RadarAddressVerificationStatus verificationStatus) {
|
|
1178
1050
|
if (status == Radar.RadarStatus.SUCCESS) {
|
|
1179
1051
|
try {
|
|
1180
1052
|
WritableMap map = Arguments.createMap();
|
|
1181
1053
|
map.putString("status", status.toString());
|
|
1182
1054
|
if (address != null) {
|
|
1183
|
-
map.putMap("address",
|
|
1055
|
+
map.putMap("address", RadarUtils.mapForJson(address.toJson()));
|
|
1184
1056
|
}
|
|
1185
1057
|
if (verificationStatus != null) {
|
|
1186
1058
|
map.putString("verificationStatus", verificationStatus.toString());
|
|
@@ -1197,7 +1069,7 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
1197
1069
|
});
|
|
1198
1070
|
}
|
|
1199
1071
|
|
|
1200
|
-
|
|
1072
|
+
|
|
1201
1073
|
public void getDistance(ReadableMap optionsMap, final Promise promise) {
|
|
1202
1074
|
if (promise == null) {
|
|
1203
1075
|
return;
|
|
@@ -1224,7 +1096,7 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
1224
1096
|
Location destination = new Location("RNRadarModule");
|
|
1225
1097
|
destination.setLatitude(latitude);
|
|
1226
1098
|
destination.setLongitude(longitude);
|
|
1227
|
-
String[] modesArr = optionsMap.hasKey("modes") ?
|
|
1099
|
+
String[] modesArr = optionsMap.hasKey("modes") ? RadarUtils.stringArrayForArray(optionsMap.getArray("modes")) : new String[]{};
|
|
1228
1100
|
EnumSet<Radar.RadarRouteMode> modes = EnumSet.noneOf(Radar.RadarRouteMode.class);
|
|
1229
1101
|
for (String modeStr : modesArr) {
|
|
1230
1102
|
if (modeStr.equals("FOOT") || modeStr.equals("foot")) {
|
|
@@ -1241,14 +1113,14 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
1241
1113
|
Radar.RadarRouteUnits units = unitsStr != null && (unitsStr.equals("METRIC") || unitsStr.equals("metric")) ? Radar.RadarRouteUnits.METRIC : Radar.RadarRouteUnits.IMPERIAL;
|
|
1242
1114
|
|
|
1243
1115
|
Radar.RadarRouteCallback callback = new Radar.RadarRouteCallback() {
|
|
1244
|
-
|
|
1116
|
+
|
|
1245
1117
|
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarRoutes routes) {
|
|
1246
1118
|
if (status == Radar.RadarStatus.SUCCESS) {
|
|
1247
1119
|
try {
|
|
1248
1120
|
WritableMap map = Arguments.createMap();
|
|
1249
1121
|
map.putString("status", status.toString());
|
|
1250
1122
|
if (routes != null) {
|
|
1251
|
-
map.putMap("routes",
|
|
1123
|
+
map.putMap("routes", RadarUtils.mapForJson(routes.toJson()));
|
|
1252
1124
|
}
|
|
1253
1125
|
promise.resolve(map);
|
|
1254
1126
|
} catch (JSONException e) {
|
|
@@ -1268,7 +1140,7 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
1268
1140
|
}
|
|
1269
1141
|
}
|
|
1270
1142
|
|
|
1271
|
-
|
|
1143
|
+
|
|
1272
1144
|
public void getMatrix(ReadableMap optionsMap, final Promise promise) {
|
|
1273
1145
|
if (promise == null) {
|
|
1274
1146
|
return;
|
|
@@ -1315,14 +1187,14 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
1315
1187
|
Radar.RadarRouteUnits units = unitsStr != null && (unitsStr.equals("METRIC") || unitsStr.equals("metric")) ? Radar.RadarRouteUnits.METRIC : Radar.RadarRouteUnits.IMPERIAL;
|
|
1316
1188
|
|
|
1317
1189
|
Radar.getMatrix(origins, destinations, mode, units, new Radar.RadarMatrixCallback() {
|
|
1318
|
-
|
|
1190
|
+
|
|
1319
1191
|
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarRouteMatrix matrix) {
|
|
1320
1192
|
if (status == Radar.RadarStatus.SUCCESS) {
|
|
1321
1193
|
try {
|
|
1322
1194
|
WritableMap map = Arguments.createMap();
|
|
1323
1195
|
map.putString("status", status.toString());
|
|
1324
1196
|
if (matrix != null) {
|
|
1325
|
-
map.putArray("matrix",
|
|
1197
|
+
map.putArray("matrix", RadarUtils.arrayForJson(matrix.toJson()));
|
|
1326
1198
|
}
|
|
1327
1199
|
promise.resolve(map);
|
|
1328
1200
|
} catch (JSONException e) {
|
|
@@ -1336,7 +1208,7 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
1336
1208
|
});
|
|
1337
1209
|
}
|
|
1338
1210
|
|
|
1339
|
-
|
|
1211
|
+
|
|
1340
1212
|
public void logConversion(ReadableMap optionsMap, final Promise promise) throws JSONException {
|
|
1341
1213
|
if (promise == null) {
|
|
1342
1214
|
return;
|
|
@@ -1352,16 +1224,16 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
1352
1224
|
Double revenue = optionsMap.hasKey("revenue") ? new Double(optionsMap.getDouble("revenue")) : null;
|
|
1353
1225
|
ReadableMap metadata = optionsMap.hasKey("metadata") ? optionsMap.getMap("metadata") : null;
|
|
1354
1226
|
|
|
1355
|
-
JSONObject metadataObj =
|
|
1227
|
+
JSONObject metadataObj = RadarUtils.jsonForMap(metadata);
|
|
1356
1228
|
Radar.RadarLogConversionCallback callback = new Radar.RadarLogConversionCallback() {
|
|
1357
|
-
|
|
1229
|
+
|
|
1358
1230
|
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarEvent event) {
|
|
1359
1231
|
try {
|
|
1360
1232
|
if (status == Radar.RadarStatus.SUCCESS) {
|
|
1361
1233
|
WritableMap map = Arguments.createMap();
|
|
1362
1234
|
map.putString("status", status.toString());
|
|
1363
1235
|
if (event != null) {
|
|
1364
|
-
map.putMap("event",
|
|
1236
|
+
map.putMap("event", RadarUtils.mapForJson(event.toJson()));
|
|
1365
1237
|
}
|
|
1366
1238
|
promise.resolve(map);
|
|
1367
1239
|
} else {
|
|
@@ -1381,3 +1253,4 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
1381
1253
|
}
|
|
1382
1254
|
}
|
|
1383
1255
|
}
|
|
1256
|
+
|