Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] #3435 - updated MapView for swallowing SecurityExceptions i…
Browse files Browse the repository at this point in the history
…f permissions are revoked by end-user
  • Loading branch information
tobrun committed Jan 7, 2016
1 parent 11d99bd commit 1caad0d
Showing 1 changed file with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,12 @@ private void initialize(Context context, AttributeSet attrs) {
, typedArray.getDimension(R.styleable.MapView_attribution_margin_bottom, DIMENSION_SEVEN_DP));

// User location
setMyLocationEnabled(typedArray.getBoolean(R.styleable.MapView_my_location_enabled, false));
try {
setMyLocationEnabled(typedArray.getBoolean(R.styleable.MapView_my_location_enabled, false));
}catch (SecurityException ignore){
// User did not accept location permissions
}

} finally {
typedArray.recycle();
}
Expand Down Expand Up @@ -918,7 +923,13 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
}
mNativeMapView.setDefaultTransitionDuration(
savedInstanceState.getLong(STATE_DEFAULT_TRANSITION_DURATION));
setMyLocationEnabled(savedInstanceState.getBoolean(STATE_MY_LOCATION_ENABLED));

// User location
try {
setMyLocationEnabled(savedInstanceState.getBoolean(STATE_MY_LOCATION_ENABLED));
}catch (SecurityException ignore){
// User did not accept location permissions
}

// Compass
setCompassEnabled(savedInstanceState.getBoolean(STATE_COMPASS_ENABLED));
Expand Down Expand Up @@ -2929,14 +2940,20 @@ private class GestureListener extends

// Must always return true otherwise all events are ignored
@Override
public boolean onDown(MotionEvent e) {
public boolean onDown(MotionEvent event) {
// Show the zoom controls
if (mZoomControlsEnabled && mZoomEnabled) {
mZoomButtonsController.setVisible(true);
}

setMyLocationTrackingMode(MyLocationTracking.TRACKING_NONE);
setMyBearingTrackingMode(MyBearingTracking.NONE);
// Disable tracking mode if a gesture occurs
try {
setMyLocationTrackingMode(MyLocationTracking.TRACKING_NONE);
setMyBearingTrackingMode(MyBearingTracking.NONE);
}catch(SecurityException ignore){
// User did not accept location permissions
}

return true;
}

Expand Down

0 comments on commit 1caad0d

Please sign in to comment.