mirror of
https://github.com/SimpleMobileTools/Simple-Camera.git
synced 2025-05-20 17:04:18 +02:00
if in video mode, turning on the flash turns it into a flashlight
This commit is contained in:
parent
dff62f66d9
commit
00835946c6
@ -61,6 +61,7 @@ public class MainActivity extends AppCompatActivity implements SensorEventListen
|
|||||||
|
|
||||||
@OnClick(R.id.toggle_camera)
|
@OnClick(R.id.toggle_camera)
|
||||||
public void toggleCamera() {
|
public void toggleCamera() {
|
||||||
|
disableFlash();
|
||||||
hideTimer();
|
hideTimer();
|
||||||
if (currCamera == Camera.CameraInfo.CAMERA_FACING_BACK) {
|
if (currCamera == Camera.CameraInfo.CAMERA_FACING_BACK) {
|
||||||
currCamera = Camera.CameraInfo.CAMERA_FACING_FRONT;
|
currCamera = Camera.CameraInfo.CAMERA_FACING_FRONT;
|
||||||
@ -123,18 +124,23 @@ public class MainActivity extends AppCompatActivity implements SensorEventListen
|
|||||||
|
|
||||||
@OnClick(R.id.toggle_videocam)
|
@OnClick(R.id.toggle_videocam)
|
||||||
public void toggleVideo() {
|
public void toggleVideo() {
|
||||||
|
disableFlash();
|
||||||
hideTimer();
|
hideTimer();
|
||||||
isPhoto = !isPhoto;
|
isPhoto = !isPhoto;
|
||||||
toggleCameraBtn.setVisibility(View.VISIBLE);
|
toggleCameraBtn.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
if (isPhoto) {
|
if (isPhoto) {
|
||||||
|
initPhoto();
|
||||||
|
} else {
|
||||||
|
initVideo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initPhoto() {
|
||||||
final Resources res = getResources();
|
final Resources res = getResources();
|
||||||
togglePhotoVideoBtn.setImageDrawable(res.getDrawable(R.mipmap.videocam));
|
togglePhotoVideoBtn.setImageDrawable(res.getDrawable(R.mipmap.videocam));
|
||||||
shutterBtn.setImageDrawable(res.getDrawable(R.mipmap.camera));
|
shutterBtn.setImageDrawable(res.getDrawable(R.mipmap.camera));
|
||||||
preview.initPhotoMode();
|
preview.initPhotoMode();
|
||||||
} else {
|
|
||||||
initVideo();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initVideo() {
|
private void initVideo() {
|
||||||
|
@ -323,13 +323,19 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean enableFlash() {
|
public void enableFlash() {
|
||||||
|
if (isVideoMode) {
|
||||||
|
parameters.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
|
||||||
|
camera.setParameters(parameters);
|
||||||
|
}
|
||||||
|
|
||||||
isFlashEnabled = true;
|
isFlashEnabled = true;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disableFlash() {
|
public void disableFlash() {
|
||||||
isFlashEnabled = false;
|
isFlashEnabled = false;
|
||||||
|
parameters.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
|
||||||
|
camera.setParameters(parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initPhotoMode() {
|
public void initPhotoMode() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user