Repository: cordova-plugin-contacts Updated Branches: refs/heads/master 07f7784ce -> 4bb747fff
CB-10148 android: Added READ_CONTACTS permission request when picking a contact Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/commit/4bb747ff Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/tree/4bb747ff Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/diff/4bb747ff Branch: refs/heads/master Commit: 4bb747fff0ad957e210408936039755b740659e5 Parents: 07f7784 Author: riknoll <richard.b.kn...@gmail.com> Authored: Mon Dec 7 12:05:51 2015 -0800 Committer: riknoll <richard.b.kn...@gmail.com> Committed: Mon Dec 7 12:05:51 2015 -0800 ---------------------------------------------------------------------- src/android/ContactManager.java | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/blob/4bb747ff/src/android/ContactManager.java ---------------------------------------------------------------------- diff --git a/src/android/ContactManager.java b/src/android/ContactManager.java index 3bdea86..a69e409 100644 --- a/src/android/ContactManager.java +++ b/src/android/ContactManager.java @@ -43,7 +43,7 @@ public class ContactManager extends CordovaPlugin { private ContactAccessor contactAccessor; private CallbackContext callbackContext; // The callback context from which we were invoked. private JSONArray executeArgs; - + private static final String LOG_TAG = "Contact Query"; public static final int UNKNOWN_ERROR = 0; @@ -62,6 +62,7 @@ public class ContactManager extends CordovaPlugin { public static final int SEARCH_REQ_CODE = 0; public static final int SAVE_REQ_CODE = 1; public static final int REMOVE_REQ_CODE = 2; + public static final int PICK_REQ_CODE = 3; public static final String READ = Manifest.permission.READ_CONTACTS; public static final String WRITE = Manifest.permission.WRITE_CONTACTS; @@ -96,10 +97,10 @@ public class ContactManager extends CordovaPlugin { * @return True if the action was valid, false otherwise. */ public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException { - + this.callbackContext = callbackContext; - this.executeArgs = args; - + this.executeArgs = args; + /** * Check to see if we are on an Android 1.X device. If we are return an error as we * do not support this as of Cordova 1.0. @@ -147,7 +148,14 @@ public class ContactManager extends CordovaPlugin { } } else if (action.equals("pickContact")) { - pickContactAsync(); + if(cordova.hasPermission(READ)) + { + pickContactAsync(); + } + else + { + getReadPermission(PICK_REQ_CODE); + } } else { return false; @@ -216,7 +224,7 @@ public class ContactManager extends CordovaPlugin { }; this.cordova.getThreadPool().execute(worker); } - + /** * Called when user picks contact. * @param requestCode The request code originally supplied to startActivityForResult(), @@ -278,6 +286,9 @@ public class ContactManager extends CordovaPlugin { case REMOVE_REQ_CODE: remove(executeArgs); break; + case PICK_REQ_CODE: + pickContactAsync(); + break; } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org For additional commands, e-mail: commits-h...@cordova.apache.org