List of usage examples for org.apache.cordova PluginResult PluginResult
public PluginResult(Status status, List<PluginResult> multipartMessages)
From source file:cn.push.cordova.plugin.localnotification.LocalNotification.java
License:Apache License
/** * Checks wether a notification with an ID is scheduled. * * @param id// w w w.ja v a 2 s. co m * The notification ID to be check. * @param callbackContext */ public static void isScheduled(String id, CallbackContext callbackContext) { SharedPreferences settings = getSharedPreferences(); Map<String, ?> alarms = settings.getAll(); boolean isScheduled = alarms.containsKey(id); PluginResult result = new PluginResult(PluginResult.Status.OK, isScheduled); callbackContext.sendPluginResult(result); }
From source file:co.lingeng.cordova.wechat_pay.WechatPay.java
License:Apache License
public static void successCallback(String result) { PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, result); pluginResult.setKeepCallback(true);//from w ww . j av a 2 s.c om callbackContext.sendPluginResult(pluginResult); }
From source file:co.lingeng.cordova.wechat_pay.WechatPay.java
License:Apache License
public static void failedCallback(String result) { PluginResult pluginResult = new PluginResult(PluginResult.Status.ERROR, result); pluginResult.setKeepCallback(true);//from www. jav a 2s. com callbackContext.sendPluginResult(pluginResult); }
From source file:co.mwater.foregroundcameraplugin.ForegroundCameraLauncher.java
License:Apache License
void failPicture(String reason) { callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, reason)); }
From source file:co.mwater.foregroundcameraplugin.ForegroundCameraLauncher.java
License:Apache License
/** * Called when the camera view exits./*from ww w . ja va 2 s . c o m*/ * * @param requestCode * The request code originally supplied to * startActivityForResult(), allowing you to identify who this * result came from. * @param resultCode * The integer result code returned by the child activity through * its setResult(). * @param intent * An Intent, which can return result data to the caller (various * data can be attached to Intent "extras"). */ public void onActivityResult(int requestCode, int resultCode, Intent intent) { // If image available if (resultCode == Activity.RESULT_OK) { try { // Create an ExifHelper to save the exif data that is lost // during compression ExifHelper exif = new ExifHelper(); exif.createInFile( getTempDirectoryPath(this.cordova.getActivity().getApplicationContext()) + "/Pic.jpg"); exif.readExifData(); // Read in bitmap of captured image Bitmap bitmap; try { bitmap = android.provider.MediaStore.Images.Media .getBitmap(this.cordova.getActivity().getContentResolver(), imageUri); } catch (FileNotFoundException e) { Uri uri = intent.getData(); android.content.ContentResolver resolver = this.cordova.getActivity().getContentResolver(); bitmap = android.graphics.BitmapFactory.decodeStream(resolver.openInputStream(uri)); } bitmap = scaleBitmap(bitmap); // Create entry in media store for image // (Don't use insertImage() because it uses default compression // setting of 50 - no way to change it) ContentValues values = new ContentValues(); values.put(android.provider.MediaStore.Images.Media.MIME_TYPE, "image/jpeg"); Uri uri = null; try { uri = this.cordova.getActivity().getContentResolver() .insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); } catch (UnsupportedOperationException e) { LOG.d(LOG_TAG, "Can't write to external media storage."); try { uri = this.cordova.getActivity().getContentResolver() .insert(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI, values); } catch (UnsupportedOperationException ex) { LOG.d(LOG_TAG, "Can't write to internal media storage."); this.failPicture("Error capturing image - no media storage found."); return; } } // Add compressed version of captured image to returned media // store Uri OutputStream os = this.cordova.getActivity().getContentResolver().openOutputStream(uri); bitmap.compress(Bitmap.CompressFormat.JPEG, this.mQuality, os); os.close(); // Restore exif data to file exif.createOutFile(getRealPathFromURI(uri, this.cordova)); exif.writeExifData(); android.util.Log.i("CameraPlugin", "destinationType: " + this.destinationType); if (this.destinationType == 1) { //File URI // Send Uri back to JavaScript for viewing image this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, uri.toString())); } else if (this.destinationType == 0) { //DATA URL String base64Data = ForegroundCameraLauncher.encodeTobase64(bitmap, this.mQuality); this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, base64Data)); } else { this.failPicture("Unsupported destination"); } bitmap.recycle(); bitmap = null; System.gc(); checkForDuplicateImage(); } catch (IOException e) { e.printStackTrace(); this.failPicture("Error capturing image."); } } // If cancelled else if (resultCode == Activity.RESULT_CANCELED) { this.failPicture("Camera cancelled."); } // If something else else { this.failPicture("Did not complete!"); } }
From source file:com.acequare.browserlauncher.BrowserLauncher.java
License:Apache License
/** * Executes the request and returns PluginResult. * @param action The action to execute. * @param args JSONArry of arguments for the plugin. * @param callbackContext The callback context used when calling back into JavaScript. * @return A PluginResult object with a status and message. *///from w w w . j a v a 2 s . co m public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { PluginResult.Status status = PluginResult.Status.OK; String result = ""; if (action.equals("open")) { String url = args.getString(0); Context context = this.cordova.getActivity().getApplicationContext(); Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); browserIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(browserIntent); } callbackContext.sendPluginResult(new PluginResult(status, result)); return true; }
From source file:com.acuant.plugin.AcuantMobileSDK.java
@Override public boolean execute(String action, JSONArray data, CallbackContext callbackContext) throws JSONException { Action actionMethods;//from ww w. ja v a2 s . co m try { actionMethods = Action.valueOf(action); } catch (Exception ex) { ex.printStackTrace(); JSONObject obj = new JSONObject(); try { obj.put("id", "execute"); obj.put("error", String.valueOf(ex)); PluginResult result = new PluginResult(PluginResult.Status.INVALID_ACTION, obj); result.setKeepCallback(true); callbackId.sendPluginResult(result); } catch (JSONException e) { e.printStackTrace(); } return false; } JSONObject obj = new JSONObject(); switch (actionMethods) { case initAcuantMobileSDK: methodId = "initAcuantMobileSDK"; callbackId = callbackContext; if (data.getString(0) != null) { key = data.getString(0); } else { key = ""; } if (data.getString(1) != null && !data.getString(1).trim().equalsIgnoreCase("")) { cloudAddressString = data.getString(1); } else { cloudAddressString = "cssnwebservices.com"; } // load the controller instance acuantAndroidMobileSDKController = AcuantAndroidMobileSDKController.getInstance(cordova.getActivity(), cloudAddressString, key); acuantAndroidMobileSDKController.setWebServiceListener(this); acuantAndroidMobileSDKController.setCardCroppingListener(this); acuantAndroidMobileSDKController.setAcuantErrorListener(this); sdkController = acuantAndroidMobileSDKController; break; case initAcuantMobileSDKAndShowCardCaptureInterfaceInViewController: methodId = "initAcuantMobileSDKAndShowCardCaptureInterfaceInViewController"; callbackId = callbackContext; if (data.getString(0) != null) { key = data.getString(0); } else { key = ""; } if (data.getInt(1) == 1) { cardType = CardType.MEDICAL_INSURANCE; } else if (data.getInt(1) == 2) { cardType = CardType.DRIVERS_LICENSE; } else if (data.getInt(1) == 3) { cardType = CardType.PASSPORT; } if (cardType == CardType.DRIVERS_LICENSE) { cardRegion = data.getInt(2); isBarcodeSide = data.getBoolean(3); } else { cardRegion = 0; isBarcodeSide = false; } // load the controller instance acuantAndroidMobileSDKController = AcuantAndroidMobileSDKController.getInstanceAndShowCameraInterface( cordova.getActivity(), key, cordova.getActivity(), cardType, cardRegion, isBarcodeSide); break; case showManualCameraInterfaceInViewController: methodId = "showManualCameraInterfaceInViewController"; callbackId = callbackContext; if (data.getInt(0) == 1) { cardType = CardType.MEDICAL_INSURANCE; } else if (data.getInt(0) == 2) { cardType = CardType.DRIVERS_LICENSE; } else if (data.getInt(0) == 3) { cardType = CardType.PASSPORT; } if (cardType == CardType.DRIVERS_LICENSE) { cardRegion = data.getInt(1); isBarcodeSide = data.getBoolean(2); } else { cardRegion = 0; isBarcodeSide = false; } acuantAndroidMobileSDKController.showManualCameraInterface(cordova.getActivity(), cardType, cardRegion, isBarcodeSide); break; case showBarcodeCameraInterfaceInViewController: methodId = "showBarcodeCameraInterfaceInViewController"; callbackId = callbackContext; if (data.getInt(0) == 1) { cardType = CardType.MEDICAL_INSURANCE; } else if (data.getInt(0) == 2) { cardType = CardType.DRIVERS_LICENSE; } else if (data.getInt(0) == 3) { cardType = CardType.PASSPORT; } if (cardType == CardType.DRIVERS_LICENSE) { cardRegion = data.getInt(1); } else { cardRegion = 0; } acuantAndroidMobileSDKController.showCameraInterfacePDF417(cordova.getActivity(), cardType, cardRegion); break; case dismissCardCaptureInterface: callbackId = callbackContext; try { obj.put("id", "dismissCardCaptureInterface"); obj.put("error", "No " + action + " Method"); if (acuantAndroidMobileSDKController.getBarcodeCameraContext() != null) { acuantAndroidMobileSDKController.finishScanningBarcodeCamera(); } PluginResult result = new PluginResult(PluginResult.Status.INVALID_ACTION, obj); result.setKeepCallback(true); callbackId.sendPluginResult(result); } catch (JSONException e) { e.printStackTrace(); } break; case startCamera: methodId = "startCamera"; callbackId = callbackContext; try { obj.put("id", methodId); obj.put("error", "No " + action + " Method"); PluginResult result = new PluginResult(PluginResult.Status.INVALID_ACTION, obj); result.setKeepCallback(true); callbackId.sendPluginResult(result); } catch (JSONException e) { e.printStackTrace(); } break; case stopCamera: methodId = "stopCamera"; callbackId = callbackContext; try { obj.put("id", methodId); obj.put("error", "No " + action + " Method"); PluginResult result = new PluginResult(PluginResult.Status.INVALID_ACTION, obj); result.setKeepCallback(true); callbackId.sendPluginResult(result); } catch (JSONException e) { e.printStackTrace(); } break; case pauseScanningBarcodeCamera: methodId = "pauseScanningBarcodeCamera"; callbackId = callbackContext; acuantAndroidMobileSDKController.pauseScanningBarcodeCamera(); break; case resumeScanningBarcodeCamera: methodId = "resumeScanningBarcodeCamera"; callbackId = callbackContext; acuantAndroidMobileSDKController.resumeScanningBarcodeCamera(); break; case setLicenseKey: methodId = "setLicenseKey"; callbackId = callbackContext; if (data.getString(0) != null && data.getString(0).trim().length() > 0) { key = data.getString(0); } else { obj.put("id", methodId); obj.put("data", false); obj.put("errorType", ErrorType.AcuantErrorOnActiveLicenseKey); obj.put("errorMessage", "The license key cannot be empty."); PluginResult result = new PluginResult(PluginResult.Status.ERROR, obj); result.setKeepCallback(true); callbackId.sendPluginResult(result); break; } if (key.contains(" ")) { obj.put("id", methodId); obj.put("data", false); obj.put("errorType", ErrorType.AcuantErrorOnActiveLicenseKey); obj.put("errorMessage", "The license key cannot be empty."); PluginResult result = new PluginResult(PluginResult.Status.ERROR, obj); result.setKeepCallback(true); callbackId.sendPluginResult(result); break; } acuantAndroidMobileSDKController.setLicensekey(key); break; case setCloudAddress: methodId = "setCloudAddress"; callbackId = callbackContext; if (data.getString(0) != null) { cloudAddressString = data.getString(0); } else { cloudAddressString = "cssnwebservices.com"; } acuantAndroidMobileSDKController.setCloudUrl(cloudAddressString); break; case setWidth: methodId = "setWidth"; callbackId = callbackContext; int width = data.getInt(0); if (width == 0) { width = 637; } acuantAndroidMobileSDKController.setWidth(width); break; case setCanCropBarcode: methodId = "setCanCropBarcode"; callbackId = callbackContext; canCropBarcode = data.getBoolean(0); acuantAndroidMobileSDKController.setCropBarcode(canCropBarcode); break; case setCanCaptureOriginalImage: methodId = "setCanCaptureOriginalImage"; callbackId = callbackContext; canCaptureOriginalImage = data.getBoolean(0); acuantAndroidMobileSDKController.setCaptureOriginalCapture(canCaptureOriginalImage); break; case setCropBarcodeOnCancel: methodId = "setCropBarcodeOnCancel"; callbackId = callbackContext; cropBarcodeOnCancel = data.getBoolean(0); acuantAndroidMobileSDKController.setCropBarcodeOnCancel(cropBarcodeOnCancel); break; case enableLocationAuthentication: methodId = "enableLocationAuthentication"; acuantAndroidMobileSDKController.enableLocationAuthentication(cordova.getActivity()); break; case setCanShowMessage: methodId = "setCanShowMessage"; callbackId = callbackContext; canShowMessage = data.getBoolean(0); acuantAndroidMobileSDKController.setShowInitialMessage(canShowMessage); break; case setInitialMessage: methodId = "setInitialMessage"; callbackId = callbackContext; String initialMessage = data.getString(0); int initialMessageRed = data.getInt(5); int initialMessageGreen = data.getInt(6); int initialMessageBlue = data.getInt(7); int initialMessageApha = data.getInt(8); acuantAndroidMobileSDKController.setInitialMessageDescriptor(initialMessage, initialMessageRed, initialMessageGreen, initialMessageBlue, initialMessageApha); break; case setCapturingMessage: methodId = "setCapturingMessage"; callbackId = callbackContext; String capturingMessage = data.getString(0); int capturingMessageRed = data.getInt(5); int capturingMessageGreen = data.getInt(6); int capturingMessageBlue = data.getInt(7); int capturingMessageApha = data.getInt(8); acuantAndroidMobileSDKController.setFinalMessageDescriptor(capturingMessage, capturingMessageRed, capturingMessageGreen, capturingMessageBlue, capturingMessageApha); break; case processCardImage: methodId = "processCardImage"; callbackId = callbackContext; callbackIdImageProcess = callbackContext; String frontImageEcodedString = data.getString(0); byte[] frontImageDecodedString = Base64.decode(frontImageEcodedString, Base64.DEFAULT); Bitmap frontImageDecodedByte = BitmapFactory.decodeByteArray(frontImageDecodedString, 0, frontImageDecodedString.length); Drawable frontImageDrawable = new BitmapDrawable(cordova.getActivity().getResources(), frontImageDecodedByte); String backImageEcodedString = data.getString(1); byte[] backImageDecodedString = Base64.decode(backImageEcodedString, Base64.DEFAULT); Bitmap backImageDecodedByte = BitmapFactory.decodeByteArray(backImageDecodedString, 0, backImageDecodedString.length); Drawable backImageDrawable = new BitmapDrawable(cordova.getActivity().getResources(), backImageDecodedByte); String stringData = data.getString(2); if (stringData != null && stringData.equalsIgnoreCase("null")) { stringData = null; } ProcessImageRequestOptions options = ProcessImageRequestOptions.getInstance(); options.autoDetectState = data.getBoolean(3); options.stateID = data.getInt(4); options.reformatImage = data.getBoolean(5); options.reformatImageColor = data.getInt(6); options.DPI = data.getInt(7); options.cropImage = data.getBoolean(8); options.faceDetec = data.getBoolean(9); options.signDetec = data.getBoolean(10); if (cardType == CardType.DRIVERS_LICENSE) { options.iRegion = data.getInt(11); } else { options.iRegion = 0; } options.logTransaction = data.getBoolean(12); options.imageSettings = data.getInt(13); options.acuantCardType = cardType; acuantAndroidMobileSDKController.callProcessImageServices(frontImageDecodedByte, backImageDecodedByte, stringData, cordova.getActivity(), options); break; case cameraPrefersStatusBarHidden: methodId = "cameraPrefersStatusBarHidden"; callbackId = callbackContext; canShowStatusBar = data.getBoolean(0); acuantAndroidMobileSDKController.setShowStatusBar(canShowStatusBar); break; case frameForWatermarkView: callbackId = callbackContext; xWatermark = data.getInt(0); yWatermark = data.getInt(1); widthWatermark = data.getInt(2); heightWatermark = data.getInt(3); acuantAndroidMobileSDKController.setWatermarkText(watermarkText, xWatermark, yWatermark, widthWatermark, heightWatermark); break; case stringForWatermarkLabel: callbackId = callbackContext; watermarkText = data.getString(0); acuantAndroidMobileSDKController.setWatermarkText(watermarkText, xWatermark, yWatermark, widthWatermark, heightWatermark); break; case frameForHelpImageView: callbackId = callbackContext; try { obj.put("id", "frameForHelpImageView"); obj.put("error", "No " + action + " Method"); PluginResult result = new PluginResult(PluginResult.Status.INVALID_ACTION, obj); result.setKeepCallback(true); callbackId.sendPluginResult(result); } catch (JSONException e) { e.printStackTrace(); } break; case imageForHelpImageView: callbackId = callbackContext; String encodedImage = data.getString(0); if (encodedImage.contains("data:image/png;base64,")) { encodedImage = encodedImage.replaceFirst("data:image/png;base64,", ""); } byte[] decodedString = Base64.decode(encodedImage, Base64.DEFAULT); Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length); Drawable pdf417BarcodeImageDrawable = new BitmapDrawable(cordova.getActivity().getResources(), decodedByte); acuantAndroidMobileSDKController.setPdf417BarcodeImageDrawable(pdf417BarcodeImageDrawable); break; case showBackButton: callbackId = callbackContext; try { obj.put("id", "showBackButton"); obj.put("error", "No " + action + " Method"); PluginResult result = new PluginResult(PluginResult.Status.INVALID_ACTION, obj); result.setKeepCallback(true); callbackId.sendPluginResult(result); } catch (JSONException e) { e.printStackTrace(); } break; case frameForBackButton: callbackId = callbackContext; try { obj.put("id", "frameForBackButton"); obj.put("error", "No " + action + " Method"); PluginResult result = new PluginResult(PluginResult.Status.INVALID_ACTION, obj); result.setKeepCallback(true); callbackId.sendPluginResult(result); } catch (JSONException e) { e.printStackTrace(); } break; case imageForBackButton: callbackId = callbackContext; try { obj.put("id", "imageForBackButton"); obj.put("error", "No " + action + " Method"); PluginResult result = new PluginResult(PluginResult.Status.INVALID_ACTION, obj); result.setKeepCallback(true); callbackId.sendPluginResult(result); } catch (JSONException e) { e.printStackTrace(); } break; case showiPadBrackets: methodId = "showiPadBrackets"; callbackId = callbackContext; boolean showiPadBrackets = false; showiPadBrackets = data.getBoolean(0); acuantAndroidMobileSDKController.setCanShowBracketsOnTablet(showiPadBrackets); break; case showFlashlightButton: methodId = "showFlashlightButton"; callbackId = callbackContext; boolean showFlashlight = false; showFlashlight = data.getBoolean(0); acuantAndroidMobileSDKController.setFlashlight(showFlashlight); break; case frameForFlashlightButton: methodId = "frameForFlashlightButton"; callbackId = callbackContext; xFlashlight = data.getInt(0); yFlashlight = data.getInt(1); widthFlashlight = data.getInt(2); heightFlashlight = data.getInt(3); acuantAndroidMobileSDKController.setFlashlight(xFlashlight, yFlashlight, widthFlashlight, heightFlashlight); break; case imageForFlashlightButton: methodId = "imageForFlashlightButton"; callbackId = callbackContext; String encodedImageOn = data.getString(0); if (encodedImageOn.contains("data:image/png;base64,")) { encodedImageOn = encodedImageOn.replaceFirst("data:image/png;base64,", ""); } byte[] decodedStringOn = Base64.decode(encodedImageOn, Base64.DEFAULT); Bitmap decodedByteOn = BitmapFactory.decodeByteArray(decodedStringOn, 0, decodedStringOn.length); Drawable flashlightButtonImageDrawableOn = new BitmapDrawable(cordova.getActivity().getResources(), decodedByteOn); String encodedImageOff = data.getString(1); if (encodedImageOff.contains("data:image/png;base64,")) { encodedImageOff = encodedImageOff.replaceFirst("data:image/png;base64,", ""); } byte[] decodedStringOff = Base64.decode(encodedImageOff, Base64.DEFAULT); Bitmap decodedByteOff = BitmapFactory.decodeByteArray(decodedStringOff, 0, decodedStringOff.length); Drawable flashlightButtonImageDrawableOff = new BitmapDrawable(cordova.getActivity().getResources(), decodedByteOff); acuantAndroidMobileSDKController.setFlashlightImageDrawable(flashlightButtonImageDrawableOn, flashlightButtonImageDrawableOff); break; case showFacialInterface: methodId = "showFacialInterface"; callbackId = callbackContext; acuantAndroidMobileSDKController.setFacialListener(this); Paint subInstPaint = null; if (facialSubInstHexColor != null) { subInstPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG); Typeface currentTypeFace = subInstPaint.getTypeface(); Typeface bold = Typeface.create(currentTypeFace, Typeface.BOLD); subInstPaint.setColor(Color.parseColor(facialSubInstHexColor)); subInstPaint.setTextSize(30); subInstPaint.setTextAlign(Paint.Align.LEFT); subInstPaint.setTypeface(bold); } if (facialInstrunctionText != null) { Paint InstPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG); Typeface currentTypeFace = InstPaint.getTypeface(); Typeface bold = Typeface.create(currentTypeFace, Typeface.BOLD); InstPaint.setColor(Color.parseColor(facialInstructionTextFontColor)); InstPaint.setTextSize(facialInstructionTextFontSize); InstPaint.setTextAlign(Paint.Align.LEFT); InstPaint.setTypeface(bold); acuantAndroidMobileSDKController.setInstructionText(facialInstrunctionText, facialInstructionLeft, facialInstructionTop, InstPaint); } acuantAndroidMobileSDKController.setSubInstructionText(facialSubInstructionString, facialSubInstLeft, facialSubInstTop, subInstPaint); acuantAndroidMobileSDKController.showManualFacialCameraInterface(cordova.getActivity()); break; case setFacialInstructionText: methodId = "setFacialInstructionText"; callbackId = callbackContext; String facialInstruction = data.getString(0); if (facialInstruction != null) { facialInstrunctionText = facialInstruction; } break; case setFacialInstructionLocation: methodId = "setFacialInstructionLocation"; callbackId = callbackContext; facialInstructionLeft = data.getInt(0); facialInstructionTop = data.getInt(1); break; case setFacialInstructionTextStyle: methodId = "setFacialInstructionTextStyle"; callbackId = callbackContext; facialInstructionTextFontColor = data.getString(0); facialInstructionTextFontSize = data.getInt(1); break; case setFacialRecognitionTimeout: methodId = "setFacialRecognitionTimeout"; callbackId = callbackContext; facialTimeOut = data.getInt(0); acuantAndroidMobileSDKController.setFacialRecognitionTimeoutInSeconds(facialTimeOut); break; case processFacialImageValidation: methodId = "processFacialImageValidation"; callbackId = callbackContext; callbackIdFacialProcess = callbackContext; cardType = CardType.FACIAL_RECOGNITION; String selfieImageEcodedString = data.getString(0); byte[] selfieImageDecodedString = Base64.decode(selfieImageEcodedString, Base64.DEFAULT); Bitmap selfieImageDecodedByte = BitmapFactory.decodeByteArray(selfieImageDecodedString, 0, selfieImageDecodedString.length); String faceImageEcodedString = data.getString(1); byte[] faceImageDecodedString = Base64.decode(faceImageEcodedString, Base64.DEFAULT); Bitmap faceImageDecodedByte = BitmapFactory.decodeByteArray(faceImageDecodedString, 0, faceImageDecodedString.length); ProcessImageRequestOptions facialOptions = ProcessImageRequestOptions.getInstance(); facialOptions.logTransaction = data.getBoolean(2); facialOptions.acuantCardType = CardType.FACIAL_RECOGNITION; acuantAndroidMobileSDKController.callProcessImageServices(selfieImageDecodedByte, faceImageDecodedByte, null, cordova.getActivity(), facialOptions); break; case setFacialSubInstructionString: methodId = "setFacialSubInstructionString"; callbackId = callbackContext; facialSubInstructionString = data.getString(0); break; case setFacialSubInstructionColor: methodId = "setFacialSubInstructionColor"; callbackId = callbackContext; facialSubInstHexColor = data.getString(0); break; case setFacialSubInstructionLocation: methodId = "setFacialSubInstructionLocation"; callbackId = callbackContext; facialSubInstLeft = data.getInt(0); facialSubInstTop = data.getInt(1); break; case scanEChip: methodId = "scanEChip"; if (nfcAdapter == null) { nfcAdapter = NfcAdapter.getDefaultAdapter(cordova.getActivity()); } if (nfcAdapter == null) { JSONObject errorObj = new JSONObject(); errorObj.put("id", "nfcError"); errorObj.put("errorMessage", "NFC is not available for this device"); errorObj.put("errorType", ErrorType.AcuantErrorUnknown); PluginResult pluginResult = new PluginResult(PluginResult.Status.ERROR, errorObj); pluginResult.setKeepCallback(true); callbackId.sendPluginResult(pluginResult); } else if (this.nfcAdapter != null && !this.nfcAdapter.isEnabled()) { JSONObject errorObj = new JSONObject(); errorObj.put("id", "nfcError"); errorObj.put("errorType", ErrorType.AcuantErrorUnknown); errorObj.put("errorMessage", "In order to use scan eChip, the NFC sensor must be turned on."); PluginResult pluginResult = new PluginResult(PluginResult.Status.ERROR, errorObj); pluginResult.setKeepCallback(true); callbackId.sendPluginResult(pluginResult); } else { acuantAndroidMobileSDKController.listenNFC(cordova.getActivity(), nfcAdapter); JSONObject errorObj = new JSONObject(); errorObj.put("id", "nfcReady"); PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, errorObj); pluginResult.setKeepCallback(true); callbackId.sendPluginResult(pluginResult); } break; case readEChip: methodId = "readEChip"; if (nfcAdapter == null) { JSONObject errorObj = new JSONObject(); errorObj.put("id", "nfcError"); errorObj.put("errorMessage", "NFC is not available for this device"); PluginResult pluginResult = new PluginResult(PluginResult.Status.ERROR, errorObj); pluginResult.setKeepCallback(true); callbackId.sendPluginResult(pluginResult); } else if (this.nfcAdapter != null && !this.nfcAdapter.isEnabled()) { JSONObject errorObj = new JSONObject(); errorObj.put("id", "nfcError"); errorObj.put("errorMessage", "In order to use scan eChip, the NFC sensor must be turned on."); PluginResult pluginResult = new PluginResult(PluginResult.Status.ERROR, errorObj); pluginResult.setKeepCallback(true); callbackId.sendPluginResult(pluginResult); } else { nfcIntent.setAction("android.nfc.action.TECH_DISCOVERED"); Intent intent = nfcIntent; echip_docNumber = data.getString(1); echip_dateOfBirth = data.getString(2); echip_dateOfExpiry = data.getString(3); acuantAndroidMobileSDKController.setAcuantTagReadingListener(this); acuantAndroidMobileSDKController.readNFCTag(intent, echip_docNumber, echip_dateOfBirth, echip_dateOfExpiry); } break; case isSDKValidated: try { obj.put("id", "isSDKValidated"); obj.put("data", sdkValidated); PluginResult result = new PluginResult(PluginResult.Status.OK, obj); result.setKeepCallback(true); callbackId.sendPluginResult(result); } catch (JSONException e) { e.printStackTrace(); } break; default: callbackId = callbackContext; try { obj.put("id", "default"); obj.put("error", "No " + action + " Method"); PluginResult result = new PluginResult(PluginResult.Status.INVALID_ACTION, obj); result.setKeepCallback(true); callbackId.sendPluginResult(result); } catch (JSONException e) { e.printStackTrace(); } return false; } return true; }
From source file:com.acuant.plugin.AcuantMobileSDK.java
@Override public void onFacialRecognitionTimedOut(final Bitmap bitmap) { JSONObject obj = new JSONObject(); try {/* w w w .j ava 2 s . c o m*/ obj.put("id", "onFacialRecognitionTimedOut"); if (bitmap != null) { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream); byte[] byteArray = byteArrayOutputStream.toByteArray(); String encoded = Base64.encodeToString(byteArray, Base64.DEFAULT); obj.put("selfieImageData", encoded); } PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, obj); pluginResult.setKeepCallback(true); callbackId.sendPluginResult(pluginResult); } catch (JSONException e) { e.printStackTrace(); } }
From source file:com.acuant.plugin.AcuantMobileSDK.java
@Override public void onFacialRecognitionCompleted(final Bitmap bitmap) { JSONObject obj = new JSONObject(); try {/*from w ww. jav a 2s . c om*/ obj.put("id", "onFacialRecognitionCompleted"); if (bitmap != null) { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream); byte[] byteArray = byteArrayOutputStream.toByteArray(); String encoded = Base64.encodeToString(byteArray, Base64.DEFAULT); obj.put("selfieImageData", encoded); } PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, obj); pluginResult.setKeepCallback(true); callbackId.sendPluginResult(pluginResult); } catch (JSONException e) { e.printStackTrace(); } }
From source file:com.acuant.plugin.AcuantMobileSDK.java
@Override public void onFacialRecognitionCanceled() { JSONObject obj = new JSONObject(); try {/* ww w .ja va 2s . co m*/ obj.put("id", "onFacialRecognitionCanceled"); PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, obj); pluginResult.setKeepCallback(true); callbackId.sendPluginResult(pluginResult); } catch (JSONException e) { e.printStackTrace(); } }