Skip to content

Commit a4a5f2d

Browse files
committed
fix: telemetry false by default. GDRP compliant
1 parent 88ad6a8 commit a4a5f2d

File tree

3 files changed

+40
-183
lines changed

3 files changed

+40
-183
lines changed

src/mapbox.android.ts

+13-7
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import {
4040
UserLocation,
4141
UserLocationCameraMode,
4242
Viewport,
43+
telemetryProperty,
4344
} from './mapbox.common';
4445

4546
// Export the enums for devs not using TS
@@ -216,12 +217,8 @@ export class MapboxView extends MapboxViewBase {
216217
*
217218
* @todo check this.
218219
*/
219-
telemetry = false;
220220
public createNativeView(): Object {
221-
// const telemetry = com.mapbox.android.telemetry.TelemetryEnabler.updateTelemetryState;
222-
// if (telemetry != null) {
223-
// telemetry.setUserTelemetryRequestState(telemetry);
224-
// }
221+
225222
if (Trace.isEnabled()) {
226223
CLog(CLogTypes.info, 'createNativeView(): top');
227224
}
@@ -400,9 +397,13 @@ export class MapboxView extends MapboxViewBase {
400397
if (Trace.isEnabled()) {
401398
CLog(CLogTypes.info, "MapboxView:initMap(): top - accessToken is '" + this.config.accessToken + "'", this.config);
402399
}
403-
400+
404401
if (!this.nativeMapView && ((this.config && this.config.accessToken) || (this.settings && this.settings.accessToken))) {
405402
this.mapbox = new Mapbox();
403+
if (this.telemetry === false) {
404+
com.mapbox.mapboxsdk.Mapbox.getTelemetry().setUserTelemetryRequestState(false);
405+
}
406+
406407

407408
// the NativeScript contentview class extends from Observable to provide the notify method
408409
// which is the glue that joins this code with whatever callbacks are set in the Mapbox XML
@@ -428,6 +429,7 @@ export class MapboxView extends MapboxViewBase {
428429
});
429430
},
430431
onMapReady: (map) => {
432+
431433
if (Trace.isEnabled()) {
432434
CLog(CLogTypes.info, 'initMap(): onMapReady event - calling notify with the MapboxViewBase.mapReadyEvent');
433435
}
@@ -500,6 +502,10 @@ export class MapboxView extends MapboxViewBase {
500502
}
501503
}
502504
}
505+
506+
[telemetryProperty.setNative](value:boolean) {
507+
com.mapbox.mapboxsdk.Mapbox.getTelemetry().setUserTelemetryRequestState(value);
508+
}
503509
} // end of class MapboxView
504510

505511
// ----------------------------------------------------------------------------------------------------------------
@@ -1873,7 +1879,7 @@ export class Mapbox extends MapboxCommon implements MapboxApi {
18731879
}
18741880
}
18751881
} else if (marker.iconPath) {
1876-
const iconFullPath = knownFolders.currentApp().path + '/' + marker.iconPath;
1882+
const iconFullPath =path.join(knownFolders.currentApp().path , marker.iconPath.replace('~/', ''));
18771883
// if the file doesn't exist the app will crash, so checking it
18781884
if (File.exists(iconFullPath)) {
18791885
// could set width, height, retina, see https://github.com/Telerik-Verified-Plugins/Mapbox/pull/42/files?diff=unified&short_path=1c65267, but that's what the marker.icon param is for..

src/mapbox.common.ts

+9-142
Original file line numberDiff line numberDiff line change
@@ -793,289 +793,151 @@ export abstract class MapboxViewCommonBase extends ContentView implements Mapbox
793793

794794
protected mapbox: MapboxApi;
795795

796-
abstract getNativeMapView(): any;
797-
798-
// -----------------------------------------------------------------
796+
telemetry:boolean
799797

798+
abstract getNativeMapView(): any;
800799
/**
801800
* map event
802801
*
803802
* The base NativeScript ContentView class has on() and off() methods.
804803
*/
805804

806805
public onMapEvent(eventName, id, callback): void {
807-
console.log('MapboxViewCommonBase:on(): top');
808806

809807
return this.mapbox.onMapEvent(eventName, id, callback, this.getNativeMapView());
810808
}
811-
812-
// -----------------------------------------------------------------
813-
814809
public offMapEvent(eventName, id): void {
815810
return this.mapbox.offMapEvent(eventName, id, this.getNativeMapView());
816811
}
817-
818-
// -----------------------------------------------------------------
819-
820812
addMarkers(markers: MapboxMarker[]): Promise<any> {
821813
return this.mapbox.addMarkers(markers, this.getNativeMapView());
822814
}
823-
824-
// -----------------------------------------------------------------
825-
826815
removeMarkers(options?: any): Promise<any> {
827816
return this.mapbox.removeMarkers(options, this.getNativeMapView());
828817
}
829-
830-
// -----------------------------------------------------------------
831-
832818
setOnMapClickListener(listener: (data: LatLng) => boolean): Promise<any> {
833819
return this.mapbox.setOnMapClickListener(listener, this.getNativeMapView());
834820
}
835-
836-
// -----------------------------------------------------------------
837-
838821
setOnMapLongClickListener(listener: (data: LatLng) => boolean): Promise<any> {
839822
return this.mapbox.setOnMapLongClickListener(listener, this.getNativeMapView());
840823
}
841-
842-
// -----------------------------------------------------------------
843-
844824
setOnScrollListener(listener: (data?: LatLng) => void, nativeMap?: any): Promise<void> {
845825
return this.mapbox.setOnScrollListener(listener, this.getNativeMapView());
846826
}
847-
848-
// -----------------------------------------------------------------
849-
850827
setOnMoveBeginListener(listener: (data?: LatLng) => void, nativeMap?: any): Promise<void> {
851828
return this.mapbox.setOnMoveBeginListener(listener, this.getNativeMapView());
852829
}
853-
854-
// -----------------------------------------------------------------
855-
856830
setOnFlingListener(listener: () => void, nativeMap?: any): Promise<any> {
857831
return this.mapbox.setOnFlingListener(listener, this.getNativeMapView());
858832
}
859-
860-
// -----------------------------------------------------------------
861-
862833
setOnCameraMoveListener(listener: () => void, nativeMap?: any): Promise<any> {
863834
return this.mapbox.setOnCameraMoveListener(listener, this.getNativeMapView());
864835
}
865-
866-
// -----------------------------------------------------------------
867-
868836
setOnCameraMoveCancelListener(listener: () => void, nativeMap?: any): Promise<any> {
869837
return this.mapbox.setOnCameraMoveCancelListener(listener, this.getNativeMapView());
870838
}
871-
872-
// -----------------------------------------------------------------
873-
874839
setOnCameraIdleListener(listener: () => void, nativeMap?: any): Promise<any> {
875840
return this.mapbox.setOnCameraIdleListener(listener, this.getNativeMapView());
876841
}
877-
878-
// -----------------------------------------------------------------
879-
880842
getViewport(): Promise<Viewport> {
881843
return this.mapbox.getViewport(this.getNativeMapView());
882844
}
883-
884-
// -----------------------------------------------------------------
885-
886845
setViewport(options: SetViewportOptions): Promise<any> {
887846
return this.mapbox.setViewport(options, this.getNativeMapView());
888847
}
889-
890-
// -----------------------------------------------------------------
891-
892848
setMapStyle(style: string | MapStyle): Promise<any> {
893849
return this.mapbox.setMapStyle(style, this.getNativeMapView());
894850
}
895-
896-
// -----------------------------------------------------------------
897-
898851
getCenter(): Promise<LatLng> {
899852
return this.mapbox.getCenter(this.getNativeMapView());
900853
}
901-
902-
// -----------------------------------------------------------------
903-
904854
setCenter(options: SetCenterOptions): Promise<any> {
905855
return this.mapbox.setCenter(options, this.getNativeMapView());
906856
}
907-
908-
// -----------------------------------------------------------------
909-
910857
getZoomLevel(): Promise<number> {
911858
return this.mapbox.getZoomLevel(this.getNativeMapView());
912859
}
913-
914-
// -----------------------------------------------------------------
915-
916860
setZoomLevel(options: SetZoomLevelOptions): Promise<any> {
917861
return this.mapbox.setZoomLevel(options, this.getNativeMapView());
918862
}
919-
920-
// -----------------------------------------------------------------
921-
922863
getTilt(): Promise<number> {
923864
return this.mapbox.getTilt(this.getNativeMapView());
924865
}
925-
926-
// -----------------------------------------------------------------
927-
928866
setTilt(options: SetTiltOptions): Promise<any> {
929867
return this.mapbox.setTilt(options, this.getNativeMapView());
930868
}
931-
932-
// -----------------------------------------------------------------
933-
934869
getUserLocation(): Promise<UserLocation> {
935870
return this.mapbox.getUserLocation(this.getNativeMapView());
936871
}
937-
938-
// -----------------------------------------------------------------
939-
940872
showUserLocationMarker(options): void {
941873
this.mapbox.showUserLocationMarker(options, this.getNativeMapView());
942874
}
943-
944-
// -----------------------------------------------------------------
945-
946875
hideUserLocationMarker(): void {
947876
this.mapbox.hideUserLocationMarker(this.getNativeMapView());
948877
}
949-
950-
// -----------------------------------------------------------------
951-
952878
changeUserLocationMarkerMode(renderModeString, cameraModeString: UserLocationCameraMode): void {
953879
this.mapbox.changeUserLocationMarkerMode(renderModeString, cameraModeString, this.getNativeMapView());
954880
}
955-
956-
// -----------------------------------------------------------------
957-
958881
forceUserLocationUpdate(location): void {
959882
this.mapbox.forceUserLocationUpdate(location, this.getNativeMapView());
960883
}
961-
962-
// -----------------------------------------------------------------
963-
964884
trackUser(options: TrackUserOptions): Promise<any> {
965885
return this.mapbox.trackUser(options, this.getNativeMapView());
966886
}
967-
968-
// -----------------------------------------------------------------
969-
970887
addSource(id: string, options: AddSourceOptions): Promise<any> {
971888
return this.mapbox.addSource(id, options, this.getNativeMapView());
972889
}
973-
974890
removeSource(id: string): Promise<any> {
975891
return this.mapbox.removeSource(id, this.getNativeMapView());
976892
}
977-
978-
// -----------------------------------------------------------------
979-
980893
addLayer(style): Promise<any> {
981894
return this.mapbox.addLayer(style, this.getNativeMapView());
982895
}
983-
984-
// -----------------------------------------------------------------
985-
986896
removeLayer(id: string): Promise<any> {
987897
return this.mapbox.removeLayer(id, this.getNativeMapView());
988898
}
989-
990-
// -----------------------------------------------------------------
991-
992899
addLinePoint(id: string, point): Promise<any> {
993900
return this.mapbox.addLinePoint(id, point, this.getNativeMapView());
994901
}
995-
996-
// -----------------------------------------------------------------
997-
998902
queryRenderedFeatures(options: QueryRenderedFeaturesOptions): Promise<Feature[]> {
999903
return this.mapbox.queryRenderedFeatures(options, this.getNativeMapView());
1000904
}
1001-
1002-
// -----------------------------------------------------------------
1003-
1004905
addPolygon(options: AddPolygonOptions): Promise<any> {
1005906
return this.mapbox.addPolygon(options, this.getNativeMapView());
1006907
}
1007-
1008-
// -----------------------------------------------------------------
1009-
1010908
removePolygons(ids?: any[]): Promise<any> {
1011909
return this.mapbox.removePolygons(ids, this.getNativeMapView());
1012910
}
1013-
1014-
// -----------------------------------------------------------------
1015-
1016911
addPolyline(options: AddPolylineOptions): Promise<any> {
1017912
return this.mapbox.addPolyline(options, this.getNativeMapView());
1018913
}
1019-
1020-
// -----------------------------------------------------------------
1021-
1022914
removePolylines(ids?: any[]): Promise<any> {
1023915
return this.mapbox.removePolylines(ids, this.getNativeMapView());
1024916
}
1025-
1026-
// -----------------------------------------------------------------
1027-
1028917
animateCamera(options: AnimateCameraOptions): Promise<any> {
1029918
return this.mapbox.animateCamera(options, this.getNativeMapView());
1030919
}
1031-
1032-
// -----------------------------------------------------------------
1033-
1034920
destroy(): Promise<any> {
1035921
return this.mapbox.destroy(this.getNativeMapView());
1036922
}
1037-
1038-
// -----------------------------------------------------------------
1039-
1040923
onStart(): Promise<any> {
1041924
return this.mapbox.onStart(this.getNativeMapView());
1042925
}
1043-
1044-
// -----------------------------------------------------------------
1045-
1046926
onResume(nativeMap?: any): Promise<any> {
1047-
console.log('MapboxViewCommonBase:onResume(): with nativeView:', this.getNativeMapView());
1048-
1049927
return this.mapbox.onResume(this.getNativeMapView());
1050928
}
1051-
1052-
// -----------------------------------------------------------------
1053-
1054929
onPause(nativeMap?: any): Promise<any> {
1055-
console.log('MapboxViewCommonBase:onPause(): with nativeView:', this.getNativeMapView());
1056-
1057930
return this.mapbox.onPause(this.getNativeMapView());
1058931
}
1059-
1060-
// -----------------------------------------------------------------
1061-
1062932
onStop(nativeMap?: any): Promise<any> {
1063933
return this.mapbox.onStop(this.getNativeMapView());
1064934
}
1065-
1066-
// -----------------------------------------------------------------
1067-
1068935
onLowMemory(nativeMap?: any): Promise<any> {
1069936
return this.mapbox.onLowMemory(this.getNativeMapView());
1070937
}
1071-
1072-
// -----------------------------------------------------------------
1073-
1074938
onDestroy(nativeMap?: any): Promise<any> {
1075939
return this.mapbox.onDestroy(this.getNativeMapView());
1076940
}
1077-
1078-
// onSaveInstanceState( Bundle outState)
1079941
}
1080942

1081943
// -----------------------------------------------------------------
@@ -1125,6 +987,13 @@ export const hideAttributionProperty = new Property<MapboxViewCommonBase, boolea
1125987
});
1126988
hideAttributionProperty.register(MapboxViewCommonBase);
1127989

990+
export const telemetryProperty = new Property<MapboxViewCommonBase, boolean>({
991+
name: 'telemetry',
992+
defaultValue: false,
993+
valueConverter: booleanConverter,
994+
});
995+
telemetryProperty.register(MapboxViewCommonBase);
996+
1128997
export const hideCompassProperty = new Property<MapboxViewCommonBase, boolean>({
1129998
name: 'hideCompass',
1130999
defaultValue: MapboxCommon.defaults.hideCompass,
@@ -1194,13 +1063,11 @@ export abstract class MapboxViewBase extends MapboxViewCommonBase {
11941063
}
11951064

11961065
[mapStyleProperty.setNative](value: string) {
1197-
console.log("MapboxViewBase::mapStyle.setNative(): setting value '" + value + "'");
11981066
this.config.style = value;
11991067
this.config.mapStyle = value;
12001068
}
12011069

12021070
[accessTokenProperty.setNative](value: string) {
1203-
console.log("MapboxViewBase::accessTokenProperty.setNative(): setting value '" + value + "'");
12041071
this.config.accessToken = value;
12051072
}
12061073

0 commit comments

Comments
 (0)