@Override public void send(Map<String, Object> params, final IMethodResult result) { Intent intent = makeIntent(params); Object type = params.get(HK_INTENT_TYPE); if (BROADCAST.equals(type)) { Object permissionObj = params.get(HK_PERMISSION); String permission = null; if (permissionObj != null) { if (String.class.isInstance(permissionObj)) { permission = (String) permissionObj; } else { result.setArgError("Wrong intent permission: " + permissionObj); return; } } Logger.T(TAG, "Send broadcast: " + intent); ContextFactory.getAppContext().sendBroadcast(intent, permission); } else if (START_ACTIVITY.equals(type)) { if (result.hasCallback()) { int request; synchronized (localMethodResults) { request = RhoExtManager.getInstance().getActivityResultNextRequestCode(this); final Integer finalKey = Integer.valueOf(request); Map.Entry<Integer, IMethodResult> entry = new Map.Entry<Integer, IMethodResult>() { Integer key = finalKey; IMethodResult value = result; @Override public Integer getKey() { return key; } @Override public IMethodResult getValue() { return value; } @Override public IMethodResult setValue(IMethodResult v) { return result; } }; localMethodResults.add(entry); } RhodesActivity.safeGetInstance().startActivityForResult(intent, request); Logger.T(TAG, "Start activity for result: " + intent); } else { Logger.T(TAG, "Start activity: " + intent); ContextFactory.getUiContext().startActivity(intent); } } else if (START_SERVICE.equals(type)) { Logger.T(TAG, "Start service: " + intent); ContextFactory.getContext().startService(intent); } else { result.setArgError("Wrong intent type: " + type); } }
public static void inline_signature_capture(String callback_url) { if (ourInlineSignatureView != null) { ImageCapture.takeSignature( callback_url, getSharedInstance().mProperties.imageFormat, ourInlineSignatureView.makeBitmap()); } inlineSignatureHide(RhoExtManager.getInstance()); }
@Override public void takePicture(Map<String, String> propertyMap, IMethodResult result) { Logger.T(TAG, "takePicture"); try { Map<String, String> actualPropertyMap = new HashMap<String, String>(); actualPropertyMap.putAll(getPropertiesMap()); actualPropertyMap.putAll(propertyMap); setActualPropertyMap(actualPropertyMap); String outputFormat = actualPropertyMap.get("outputFormat"); String filePath = null; if (!actualPropertyMap.containsKey("fileName")) { filePath = "/sdcard/DCIM/Camera/IMG_" + dateFormat.format(new Date(System.currentTimeMillis())) + ".jpg"; } else { filePath = actualPropertyMap.get("fileName"); } if (outputFormat.equalsIgnoreCase("image")) { filePath = actualPropertyMap.get("fileName") + ".jpg"; Logger.T(TAG, "outputFormat: " + outputFormat + ", path: " + filePath); } else if (outputFormat.equalsIgnoreCase("dataUri")) { Logger.T(TAG, "outputFormat: " + outputFormat); } else { throw new RuntimeException("Unknown 'outputFormat' value: " + outputFormat); } Intent intent = null; if (Boolean.parseBoolean(actualPropertyMap.get("useSystemViewfinder"))) { if (outputFormat.equalsIgnoreCase("image")) { values = new ContentValues(); fileUri = RhodesActivity.getContext() .getContentResolver() .insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); actualPropertyMap.put("captureUri", fileUri.toString()); propertyMap.put("dataURI", ""); // intent is null with MediaStore.EXTRA_OUTPUT so adding fileuri to map and get it with // same key // if instead of MediaStore.EXTRA_OUTPUT any other key is used then the bitmap is null // though the file is getting created intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); } else if (outputFormat.equalsIgnoreCase("dataUri")) { } } else { intent = new Intent(ContextFactory.getUiContext(), CameraActivity.class); intent.putExtra(CameraExtension.INTENT_EXTRA_PREFIX + "CAMERA_ID", getId()); } ((CameraFactory) CameraFactorySingleton.getInstance()) .getRhoListener() .setMethodResult(result); ((CameraFactory) CameraFactorySingleton.getInstance()) .getRhoListener() .setActualPropertyMap(actualPropertyMap); RhodesActivity.safeGetInstance() .startActivityForResult( intent, RhoExtManager.getInstance() .getActivityResultNextRequestCode(CameraRhoListener.getInstance())); } catch (RuntimeException e) { Logger.E(TAG, e); result.setError(e.getMessage()); } }
public static void registerSignatureCaptureExtension() { RhoExtManager.getInstance().registerExtension(SIGNATURE_EXT, getSharedInstance()); }
public static void inline_signature_clear() { inlineSignatureClear(RhoExtManager.getInstance()); }
public static void inline_signature_visible(int visible, Object params) { inlineSignatureVisible(RhoExtManager.getInstance(), (visible != 0), params); }