use of com.facebook.react.bridge.ReadableMap in project react-native-image-picker by marcshilling.
the class ImageConfig method updateFromOptions.
@NonNull
public ImageConfig updateFromOptions(@NonNull final ReadableMap options) {
int maxWidth = 0;
if (options.hasKey("maxWidth")) {
maxWidth = options.getInt("maxWidth");
}
int maxHeight = 0;
if (options.hasKey("maxHeight")) {
maxHeight = options.getInt("maxHeight");
}
int quality = 100;
if (options.hasKey("quality")) {
quality = (int) (options.getDouble("quality") * 100);
}
int rotation = 0;
if (options.hasKey("rotation")) {
rotation = options.getInt("rotation");
}
boolean saveToCameraRoll = false;
if (options.hasKey("storageOptions")) {
final ReadableMap storageOptions = options.getMap("storageOptions");
if (storageOptions.hasKey("cameraRoll")) {
saveToCameraRoll = storageOptions.getBoolean("cameraRoll");
}
}
return new ImageConfig(this.original, this.resized, maxWidth, maxHeight, quality, rotation, saveToCameraRoll);
}
use of com.facebook.react.bridge.ReadableMap in project react-native-image-picker by marcshilling.
the class PermissionUtils method explainingDialog.
@Nullable
public static AlertDialog explainingDialog(@NonNull final ImagePickerModule module, @NonNull final ReadableMap options, @NonNull final OnExplainingPermissionCallback callback) {
if (module.getContext() == null) {
return null;
}
if (!options.hasKey("permissionDenied")) {
return null;
}
final ReadableMap permissionDenied = options.getMap("permissionDenied");
if (((ReadableNativeMap) permissionDenied).toHashMap().size() == 0) {
return null;
}
final String title = permissionDenied.getString("title");
final String text = permissionDenied.getString("text");
final String btnReTryTitle = permissionDenied.getString("reTryTitle");
final String btnOkTitle = permissionDenied.getString("okTitle");
final WeakReference<ImagePickerModule> reference = new WeakReference<>(module);
final Activity activity = module.getActivity();
if (activity == null) {
return null;
}
AlertDialog.Builder builder = new AlertDialog.Builder(activity, module.getDialogThemeId());
builder.setTitle(title).setMessage(text).setCancelable(false).setNegativeButton(btnOkTitle, new DialogInterface.OnClickListener() {
@Override
public void onClick(final DialogInterface dialogInterface, int i) {
callback.onCancel(reference, dialogInterface);
}
}).setPositiveButton(btnReTryTitle, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
callback.onReTry(reference, dialogInterface);
}
});
return builder.create();
}
use of com.facebook.react.bridge.ReadableMap in project react-native-camera by react-native-community.
the class MutableImage method writeLocationExifData.
private void writeLocationExifData(ReadableMap options, ExifInterface exif) {
if (!options.hasKey("metadata"))
return;
ReadableMap metadata = options.getMap("metadata");
if (!metadata.hasKey("location"))
return;
ReadableMap location = metadata.getMap("location");
if (!location.hasKey("coords"))
return;
try {
ReadableMap coords = location.getMap("coords");
double latitude = coords.getDouble("latitude");
double longitude = coords.getDouble("longitude");
GPS.writeExifData(latitude, longitude, exif);
} catch (IOException e) {
Log.e(TAG, "Couldn't write location data", e);
}
}
use of com.facebook.react.bridge.ReadableMap in project react-native-camera by react-native-community.
the class TextRecognizedEvent method rotateTextX.
private WritableMap rotateTextX(WritableMap text) {
ReadableMap faceBounds = text.getMap("bounds");
ReadableMap oldOrigin = faceBounds.getMap("origin");
WritableMap mirroredOrigin = FaceDetectorUtils.positionMirroredHorizontally(oldOrigin, mImageDimensions.getWidth(), mScaleX);
double translateX = -faceBounds.getMap("size").getDouble("width");
WritableMap translatedMirroredOrigin = FaceDetectorUtils.positionTranslatedHorizontally(mirroredOrigin, translateX);
WritableMap newBounds = Arguments.createMap();
newBounds.merge(faceBounds);
newBounds.putMap("origin", translatedMirroredOrigin);
text.putMap("bounds", newBounds);
ReadableArray oldComponents = text.getArray("components");
WritableArray newComponents = Arguments.createArray();
for (int i = 0; i < oldComponents.size(); ++i) {
WritableMap component = Arguments.createMap();
component.merge(oldComponents.getMap(i));
rotateTextX(component);
newComponents.pushMap(component);
}
text.putArray("components", newComponents);
return text;
}
use of com.facebook.react.bridge.ReadableMap in project react-native-camera by react-native-community.
the class FaceDetectorUtils method rotateFaceX.
public static WritableMap rotateFaceX(WritableMap face, int sourceWidth, double scaleX) {
ReadableMap faceBounds = face.getMap("bounds");
ReadableMap oldOrigin = faceBounds.getMap("origin");
WritableMap mirroredOrigin = positionMirroredHorizontally(oldOrigin, sourceWidth, scaleX);
double translateX = -faceBounds.getMap("size").getDouble("width");
WritableMap translatedMirroredOrigin = positionTranslatedHorizontally(mirroredOrigin, translateX);
WritableMap newBounds = Arguments.createMap();
newBounds.merge(faceBounds);
newBounds.putMap("origin", translatedMirroredOrigin);
for (String landmarkName : landmarkNames) {
ReadableMap landmark = face.hasKey(landmarkName) ? face.getMap(landmarkName) : null;
if (landmark != null) {
WritableMap mirroredPosition = positionMirroredHorizontally(landmark, sourceWidth, scaleX);
face.putMap(landmarkName, mirroredPosition);
}
}
face.putMap("bounds", newBounds);
return face;
}
Aggregations