Skip to content
Permalink
Browse files
Refactored Geolocation after feedback
  • Loading branch information
infil00p committed Oct 28, 2015
1 parent 40d92df commit b9426e98ac41dfe7f94b3e965e5436424c22595e
Showing 1 changed file with 2 additions and 29 deletions.
@@ -37,14 +37,7 @@ public class Geolocation extends CordovaPlugin {
String TAG = "GeolocationPlugin";
CallbackContext context;

String [] permissions;

public Geolocation()
{
permissions = new String[2];
permissions[0] = Manifest.permission.ACCESS_COARSE_LOCATION;
permissions[1] = Manifest.permission.ACCESS_FINE_LOCATION;
}
String [] permissions = { Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION };


public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
@@ -58,17 +51,13 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
return true;
}
else {
cordova.requestPermissions(this, 0);
cordova.requestPermissions(this, 0, permissions);
}
return true;
}
return false;
}

public String[] getPermissionRequest() {
return permissions;
}


public void onRequestPermissionResult(int requestCode, String[] permissions,
int[] grantResults) throws JSONException
@@ -88,21 +77,5 @@ public void onRequestPermissionResult(int requestCode, String[] permissions,
context.sendPluginResult(result);
}

public boolean hasPermisssion() {
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
{
return true;
}
for(String p : permissions)
{
if(PackageManager.PERMISSION_DENIED == cordova.getActivity().checkSelfPermission(p))
{
return false;
}
}

return true;
}


}

0 comments on commit b9426e9

Please sign in to comment.