Skip to content

Commit

Permalink
Don't handle permissions other than our own #194
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyVerbruggen committed Jan 13, 2018
1 parent 93d7112 commit 107a98c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
1 change: 0 additions & 1 deletion demo/app/main-page.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
zoomLevel="3"
mapStyle="light"
hideAttribution="true"
showUserLocation="true"
hideCompass="false"
accessToken="sk.eyJ1IjoiZWRkeXZlcmJydWdnZW4iLCJhIjoia1JpRW82NCJ9.OgnvpsKzB3GJhzyofQNUBw">
</map:MapboxView>
Expand Down
11 changes: 8 additions & 3 deletions src/mapbox.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ let _polylines = [];
let _markerIconDownloadCache = [];
let _locationEngine = null;

const ACCESS_FINE_LOCATION_PERMISSION_REQUEST_CODE = 111; // irrelevant really, since we simply invoke onPermissionGranted
const ACCESS_FINE_LOCATION_PERMISSION_REQUEST_CODE = 111;


/*************** XML definition START ****************/
Expand Down Expand Up @@ -176,6 +176,7 @@ const _fineLocationPermissionGranted = () => {
hasPermission = android.content.pm.PackageManager.PERMISSION_GRANTED ===
android.support.v4.content.ContextCompat.checkSelfPermission(application.android.foregroundActivity, android.Manifest.permission.ACCESS_FINE_LOCATION);
}
console.log("******* _fineLocationPermissionGranted: " + hasPermission);
return hasPermission;
};

Expand Down Expand Up @@ -381,7 +382,7 @@ export class Mapbox extends MapboxCommon implements MapboxApi {
});
}

requestFineLocationPermission(): Promise<boolean> {
requestFineLocationPermission(): Promise<any> {
return new Promise((resolve, reject) => {
if (_fineLocationPermissionGranted()) {
resolve();
Expand All @@ -390,12 +391,16 @@ export class Mapbox extends MapboxCommon implements MapboxApi {

// grab the permission dialog result
application.android.on(application.AndroidApplication.activityRequestPermissionsEvent, (args: any) => {
if (args.requestCode !== ACCESS_FINE_LOCATION_PERMISSION_REQUEST_CODE) {
return;
}
for (let i = 0; i < args.permissions.length; i++) {
if (args.grantResults[i] === android.content.pm.PackageManager.PERMISSION_DENIED) {
reject("Permission denied");
return;
}
}
console.log("****** requestFineLocationPermission @ " + new Date().getTime());
resolve();
});

Expand Down Expand Up @@ -448,7 +453,7 @@ export class Mapbox extends MapboxCommon implements MapboxApi {
_addMarkers(settings.markers, _mapbox.mapView);

if (settings.showUserLocation) {
this.requestFineLocationPermission().then((granted: boolean) => {
this.requestFineLocationPermission().then(() => {
_showLocation(_mapbox.mapView, mbMap);
});
}
Expand Down
10 changes: 5 additions & 5 deletions src/mapbox.common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ export interface AnimateCameraOptions {
}

export interface MapboxCommonApi {
requestFineLocationPermission(): Promise<boolean>;
requestFineLocationPermission(): Promise<any>;
hasFineLocationPermission(): Promise<boolean>;
}

Expand Down Expand Up @@ -346,14 +346,14 @@ export abstract class MapboxCommon implements MapboxCommonApi {
return result;
}

requestFineLocationPermission(): Promise<boolean> {
return new Promise((resolve) => {
resolve(true);
requestFineLocationPermission(): Promise<any> {
return new Promise(resolve => {
resolve();
});
}

hasFineLocationPermission(): Promise<boolean> {
return new Promise((resolve) => {
return new Promise(resolve => {
resolve(true);
});
}
Expand Down

0 comments on commit 107a98c

Please sign in to comment.