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