diff --git a/app/src/main/java/org/mapcomplete/MainActivity.java b/app/src/main/java/org/mapcomplete/MainActivity.java index 6d359563..738f3a4b 100644 --- a/app/src/main/java/org/mapcomplete/MainActivity.java +++ b/app/src/main/java/org/mapcomplete/MainActivity.java @@ -16,8 +16,6 @@ import com.getcapacitor.BridgeActivity; import com.getcapacitor.JSObject; import com.getcapacitor.PluginCall; -import java.util.Objects; - public class MainActivity extends BridgeActivity { private PluginCall locationRequest = null; @@ -45,11 +43,14 @@ public class MainActivity extends BridgeActivity { System.out.println("Android: Geolocation permission is: "+ permission); Databridge.sendAnswerTo(pluginCall, "" + permission); }); + Databridge.addResponder("open:login", pluginCall -> { + // We got a request - open the browser on 'app.mapcomplete.org/land' to login in the browser, then pass the token along + Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://app.mapcomplete.org/land.html")); + startActivity(browserIntent); + }); Databridge.addResponder("request:login", pluginCall -> { // We got a request - open the browser on 'app.mapcomplete.org/land' to login in the browser, then pass the token along this.authRequest = pluginCall; - Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://app.mapcomplete.org/land.html")); - startActivity(browserIntent); if (this.loginToken != null) { pluginCall.resolve(this.loginToken); } @@ -137,7 +138,7 @@ public class MainActivity extends BridgeActivity { ) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); if (requestCode == GeolocationBridge.requestCode) { - if (this.locationRequest != null) { + if (this.locationRequest != null && grantResults.length > 0) { // We've only requested "FINE_LOCATION" var granted = grantResults[0] == PackageManager.PERMISSION_GRANTED; Log.i("Geolocation", "Got fine location permission: " + granted);