Add hasFlash support for Android
This commit is contained in:
parent
63cfb65e43
commit
e20902933d
|
@ -2,6 +2,7 @@ import React, {
|
|||
Component,
|
||||
NativeAppEventEmitter,
|
||||
NativeModules,
|
||||
Platform,
|
||||
PropTypes,
|
||||
StyleSheet,
|
||||
requireNativeComponent,
|
||||
|
@ -181,6 +182,12 @@ export default class Camera extends Component {
|
|||
}
|
||||
|
||||
hasFlash() {
|
||||
if (Platform.OS === 'android') {
|
||||
const props = convertStringProps(this.props);
|
||||
return CameraManager.hasFlash({
|
||||
type: props.type
|
||||
});
|
||||
}
|
||||
return CameraManager.hasFlash();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -245,7 +245,7 @@ Supported options:
|
|||
|
||||
Returns the camera's current field of view.
|
||||
|
||||
#### `iOS` `hasFlash(): Promise`
|
||||
#### `hasFlash(): Promise`
|
||||
|
||||
Returns whether or not the camera has flash capabilities.
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.Collections;
|
|||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
public class RCTCameraModule extends ReactContextBaseJavaModule {
|
||||
private static final String TAG = "RCTCameraModule";
|
||||
|
@ -234,6 +235,16 @@ public class RCTCameraModule extends ReactContextBaseJavaModule {
|
|||
// TODO: implement video capture
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void hasFlash(ReadableMap options, final Promise promise) {
|
||||
Camera camera = RCTCamera.getInstance().acquireCameraInstance(options.getInt("type"));
|
||||
if (null == camera) {
|
||||
promise.reject("No camera found.");
|
||||
}
|
||||
List<String> flashModes = camera.getParameters().getSupportedFlashModes();
|
||||
promise.resolve(null != flashModes && !flashModes.isEmpty());
|
||||
}
|
||||
|
||||
private File getOutputMediaFile(int type) {
|
||||
File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(
|
||||
Environment.DIRECTORY_PICTURES), "RCTCameraModule");
|
||||
|
|
Loading…
Reference in New Issue