Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TIMOB-13998 add flash on in camera activity #4912

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ public void showCamera(@SuppressWarnings("rawtypes") HashMap options)
KrollFunction errorCallback = null;
boolean autohide = true;
boolean saveToPhotoGallery = false;

boolean flashMode = false;

if (options.containsKey("success")) {
successCallback = (KrollFunction) options.get("success");
}
Expand All @@ -170,6 +171,11 @@ public void showCamera(@SuppressWarnings("rawtypes") HashMap options)
if (saveToPhotoGalleryOption != null) {
saveToPhotoGallery = TiConvert.toBoolean(saveToPhotoGalleryOption);
}

Object cameraFlashModeOption = options.get("flashMode");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you create a TiC constant for 'flashmode'?

if (cameraFlashModeOption != null) {
flashMode = TiConvert.toBoolean(cameraFlashModeOption);
}

// Use our own custom camera activity when an overlay is provided.
if (options.containsKey("overlay")) {
Expand All @@ -181,6 +187,7 @@ public void showCamera(@SuppressWarnings("rawtypes") HashMap options)
TiCameraActivity.errorCallback = errorCallback;
TiCameraActivity.cancelCallback = cancelCallback;
TiCameraActivity.saveToPhotoGallery = saveToPhotoGallery;
TiCameraActivity.cameraFlashMode = flashMode;
TiCameraActivity.whichCamera = CAMERA_REAR; // default.

// This option is only applicable when running the custom
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ public class TiCameraActivity extends TiBaseActivity implements SurfaceHolder.Ca
public static boolean saveToPhotoGallery = false;
public static int whichCamera = MediaModule.CAMERA_REAR;
public static boolean autohide = true;

public static boolean cameraFlashMode = false;

private static class PreviewLayout extends FrameLayout
{
private double aspectRatio = 1;
Expand Down Expand Up @@ -195,7 +196,13 @@ protected void onResume()
openCamera();
}
}

if (camera != null) {
if (cameraFlashMode) {
Parameters p = camera.getParameters();
p.setFlashMode(Parameters.FLASH_MODE_ON);
camera.setParameters(p);
}
}
if (camera == null) {
return; // openCamera will have logged error.
}
Expand Down
5 changes: 5 additions & 0 deletions apidoc/Titanium/Media/Media.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,11 @@ properties:
overlay is not set, the default Android Camera Activity is used, which is only
capable of reporting back the results of one taken photo, making `autohide`
meaningless in that context.
- name: flashMode
summary: set camera flash on or off for custom overlays.
type: Boolean
default: false
platforms: [android]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add:
since: "3.3.0"

- name: animated
summary: Specifies if the dialog should be animated upon showing and hiding.
type: Boolean
Expand Down