Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
34a058936a | ||
|
|
728534d8fe | ||
|
|
18ed8f7984 | ||
|
|
4473d7c7ce | ||
|
|
cfa02695cf |
@ -310,24 +310,33 @@ public class RNCameraViewHelper {
|
||||
}
|
||||
|
||||
public static void setExifData(ExifInterface exifInterface, WritableMap exifMap) {
|
||||
ReadableMapKeySetIterator iterator = exifMap.keySetIterator();
|
||||
while (iterator.hasNextKey()) {
|
||||
String key = iterator.nextKey();
|
||||
switch (exifMap.getType(key)) {
|
||||
case Null:
|
||||
exifInterface.setAttribute(key, null);
|
||||
break;
|
||||
case Boolean:
|
||||
exifInterface.setAttribute(key, Boolean.toString(exifMap.getBoolean(key)));
|
||||
break;
|
||||
case Number:
|
||||
exifInterface.setAttribute(key, Double.toString(exifMap.getDouble(key)));
|
||||
break;
|
||||
case String:
|
||||
exifInterface.setAttribute(key, exifMap.getString(key));
|
||||
break;
|
||||
for (String[] tagInfo : exifTags) {
|
||||
String name = tagInfo[1];
|
||||
if (exifMap.hasKey(name)) {
|
||||
String type = tagInfo[0];
|
||||
switch (type) {
|
||||
case "string":
|
||||
exifInterface.setAttribute(name, exifMap.getString(name));
|
||||
break;
|
||||
case "int":
|
||||
exifInterface.setAttribute(name, Integer.toString(exifMap.getInt(name)));
|
||||
exifMap.getInt(name);
|
||||
break;
|
||||
case "double":
|
||||
exifInterface.setAttribute(name, Double.toString(exifMap.getDouble(name)));
|
||||
exifMap.getDouble(name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (exifMap.hasKey(ExifInterface.TAG_GPS_LATITUDE) &&
|
||||
exifMap.hasKey(ExifInterface.TAG_GPS_LONGITUDE) &&
|
||||
exifMap.hasKey(ExifInterface.TAG_GPS_ALTITUDE)) {
|
||||
exifInterface.setLatLong(exifMap.getDouble(ExifInterface.TAG_GPS_LATITUDE),
|
||||
exifMap.getDouble(ExifInterface.TAG_GPS_LONGITUDE));
|
||||
exifInterface.setAltitude(exifMap.getDouble(ExifInterface.TAG_GPS_ALTITUDE));
|
||||
}
|
||||
}
|
||||
|
||||
public static Bitmap generateSimulatorPhoto(int width, int height) {
|
||||
|
||||
@ -15,6 +15,7 @@ import org.reactnative.camera.utils.RNFileUtils;
|
||||
import com.facebook.react.bridge.Arguments;
|
||||
import com.facebook.react.bridge.Promise;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.bridge.ReadableType;
|
||||
import com.facebook.react.bridge.WritableMap;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
@ -119,8 +120,20 @@ public class ResolveTakenPictureAsyncTask extends AsyncTask<Void, Void, Writable
|
||||
}
|
||||
|
||||
WritableMap exifData = null;
|
||||
ReadableMap exifExtraData = null;
|
||||
boolean writeExifToResponse = mOptions.hasKey("exif") && mOptions.getBoolean("exif");
|
||||
boolean writeExifToFile = mOptions.hasKey("writeExif") && mOptions.getBoolean("writeExif");
|
||||
boolean writeExifToFile = false;
|
||||
if (mOptions.hasKey("writeExif")) {
|
||||
switch (mOptions.getType("writeExif")) {
|
||||
case Boolean:
|
||||
writeExifToFile = mOptions.getBoolean("writeExif");
|
||||
break;
|
||||
case Map:
|
||||
exifExtraData = mOptions.getMap("writeExif");
|
||||
writeExifToFile = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Read Exif data if needed
|
||||
if (writeExifToResponse || writeExifToFile) {
|
||||
@ -136,6 +149,9 @@ public class ResolveTakenPictureAsyncTask extends AsyncTask<Void, Void, Writable
|
||||
if (fixOrientation) {
|
||||
fileExifData.putInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
|
||||
}
|
||||
if (exifExtraData != null) {
|
||||
fileExifData.merge(exifExtraData);
|
||||
}
|
||||
}
|
||||
|
||||
// Write Exif data to the response if requested
|
||||
|
||||
@ -29,7 +29,7 @@ interface TakePictureOptions {
|
||||
/** Android only */
|
||||
skipProcessing?: boolean;
|
||||
fixOrientation?: boolean;
|
||||
writeExif?: boolean;
|
||||
writeExif?: boolean | { [name: string]: any };
|
||||
|
||||
/** iOS only */
|
||||
forceUpOrientation?: boolean;
|
||||
|
||||
@ -82,7 +82,7 @@ const styles = StyleSheet.create({
|
||||
},
|
||||
});
|
||||
|
||||
AppRegistry.registerComponent('ExampleApp', () => ExampleApp);
|
||||
AppRegistry.registerComponent('App', () => ExampleApp);
|
||||
```
|
||||
|
||||
## FaCC (Function as Child Components)
|
||||
@ -174,7 +174,7 @@ const styles = StyleSheet.create({
|
||||
},
|
||||
});
|
||||
|
||||
AppRegistry.registerComponent('ExampleApp', () => ExampleApp);
|
||||
AppRegistry.registerComponent('App', () => ExampleApp);
|
||||
```
|
||||
|
||||
### `camera`
|
||||
|
||||
@ -697,6 +697,7 @@ static NSDictionary *defaultFaceDetectorOptions = nil;
|
||||
|
||||
if (error || captureDeviceInput == nil) {
|
||||
RCTLog(@"%s: %@", __func__, error);
|
||||
[self.session commitConfiguration];
|
||||
return;
|
||||
}
|
||||
|
||||
@ -766,6 +767,7 @@ static NSDictionary *defaultFaceDetectorOptions = nil;
|
||||
|
||||
if (error || audioDeviceInput == nil) {
|
||||
RCTLogWarn(@"%s: %@", __func__, error);
|
||||
[self.session commitConfiguration];
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "react-native-camera",
|
||||
"description": "A Camera component for React Native. Also reads barcodes.",
|
||||
"version": "2.11.1",
|
||||
"version": "2.11.2",
|
||||
"author": "Lochlan Wansbrough <lochie@live.com> (http://lwansbrough.com)",
|
||||
"collective": {
|
||||
"type": "opencollective",
|
||||
|
||||
@ -99,7 +99,7 @@ type PictureOptions = {
|
||||
base64?: boolean,
|
||||
mirrorImage?: boolean,
|
||||
exif?: boolean,
|
||||
writeExif?: boolean,
|
||||
writeExif?: boolean | { [name: string]: any },
|
||||
width?: number,
|
||||
fixOrientation?: boolean,
|
||||
forceUpOrientation?: boolean,
|
||||
|
||||
2
types/index.d.ts
vendored
2
types/index.d.ts
vendored
@ -353,7 +353,7 @@ interface TakePictureOptions {
|
||||
/** Android only */
|
||||
skipProcessing?: boolean;
|
||||
fixOrientation?: boolean;
|
||||
writeExif?: boolean;
|
||||
writeExif?: boolean | { [name: string]: any };
|
||||
|
||||
/** iOS only */
|
||||
forceUpOrientation?: boolean;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user