mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 07:02:51 +08:00
Got the PoC working with the Contacts plugin, going to work through all the plugins
This commit is contained in:
parent
a0747aa960
commit
5e0c9595c3
@ -493,7 +493,16 @@ public class CordovaActivity extends Activity {
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, String permissions[],
|
||||
int[] grantResults) {
|
||||
cordovaInterface.onRequestPermissionResult(requestCode, permissions, grantResults);
|
||||
try
|
||||
{
|
||||
cordovaInterface.onRequestPermissionResult(requestCode, permissions, grantResults);
|
||||
}
|
||||
catch (JSONException e)
|
||||
{
|
||||
LOG.d(TAG, "JSONException: Parameters fed into the method are not valid");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -70,6 +70,6 @@ public interface CordovaInterface {
|
||||
*/
|
||||
public ExecutorService getThreadPool();
|
||||
|
||||
public void requestPermission(CordovaPlugin plugin, String permission);
|
||||
public void requestPermissions(CordovaPlugin plugin);
|
||||
public void requestPermission(CordovaPlugin plugin, int requestCode, String permission);
|
||||
public void requestPermissions(CordovaPlugin plugin, int requestCode);
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
@ -171,7 +173,7 @@ public class CordovaInterfaceImpl implements CordovaInterface {
|
||||
* @param grantResults
|
||||
*/
|
||||
public void onRequestPermissionResult(int requestCode, String[] permissions,
|
||||
int[] grantResults) {
|
||||
int[] grantResults) throws JSONException {
|
||||
if(permissionResultCallback != null)
|
||||
{
|
||||
permissionResultCallback.onRequestPermissionResult(requestCode, permissions, grantResults);
|
||||
@ -179,19 +181,17 @@ public class CordovaInterfaceImpl implements CordovaInterface {
|
||||
}
|
||||
}
|
||||
|
||||
public void requestPermission(CordovaPlugin plugin, String permission) {
|
||||
public void requestPermission(CordovaPlugin plugin, int requestCode, String permission) {
|
||||
permissionResultCallback = plugin;
|
||||
String[] permissions = new String [1];
|
||||
permissions[0] = permission;
|
||||
int requestCode = 1;
|
||||
getActivity().requestPermissions(permissions, requestCode);
|
||||
}
|
||||
|
||||
public void requestPermissions(CordovaPlugin plugin)
|
||||
public void requestPermissions(CordovaPlugin plugin, int requestCode)
|
||||
{
|
||||
permissionResultCallback = plugin;
|
||||
String[] permissions = plugin.getPermissionRequest();
|
||||
int requestCode = 1;
|
||||
getActivity().requestPermissions(permissions, requestCode);
|
||||
}
|
||||
|
||||
|
@ -391,15 +391,8 @@ public class CordovaPlugin {
|
||||
* @param permissions
|
||||
* @param grantResults
|
||||
*/
|
||||
public boolean onRequestPermissionResult(int requestCode, String[] permissions,
|
||||
int[] grantResults) {
|
||||
public void onRequestPermissionResult(int requestCode, String[] permissions,
|
||||
int[] grantResults) throws JSONException {
|
||||
|
||||
for(int r:grantResults)
|
||||
{
|
||||
if(r == PackageManager.PERMISSION_DENIED)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ package org.apache.cordova.engine;
|
||||
import java.util.Arrays;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
@ -63,13 +64,15 @@ public class SystemWebChromeClient extends WebChromeClient {
|
||||
private View mVideoProgressView;
|
||||
|
||||
private CordovaDialogsHelper dialogsHelper;
|
||||
private Context appContext;
|
||||
|
||||
private WebChromeClient.CustomViewCallback mCustomViewCallback;
|
||||
private View mCustomView;
|
||||
|
||||
public SystemWebChromeClient(SystemWebViewEngine parentEngine) {
|
||||
this.parentEngine = parentEngine;
|
||||
dialogsHelper = new CordovaDialogsHelper(parentEngine.webView.getContext());
|
||||
appContext = parentEngine.webView.getContext();
|
||||
dialogsHelper = new CordovaDialogsHelper(appContext);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -186,7 +189,7 @@ public class SystemWebChromeClient extends WebChromeClient {
|
||||
CordovaPlugin geolocation = parentEngine.pluginManager.getPlugin("Geolocation");
|
||||
if(geolocation != null && !geolocation.hasPermisssion())
|
||||
{
|
||||
parentEngine.pluginManager.requestPermission(geolocation);
|
||||
//cordova.requestPermissions(geolocation);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user