Simple library for fixed portrait screen orientation camera apps(like instagram) that supports camera1 and camera2 api and allows you to display preview, reselect camera type(FRONT/BACK), take and save pictures(library determines the current position of the screen and save the image in correct orientations), enable/disable flash mode
#Install Add the following code in your gradle.build file
compile 'com.github.mistreckless:portraitcamera-support:0.1.0'
#Manifest
#Usage CameraSupport cameraSupport=CameraSupportFactory.getInstance().getCameraSupport(getActivity(),autoFitTextureView); or for some devices with api>21 that doesn't supported camera2
cameraSupport = CameraSupportFactory.getInstance()
.getCameraSupport(getActivity(), autoFitTextureView, CameraSupportController.CameraApi.OLD);
##Preview @Override public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) { cameraSupport.startPreview(surface, width, height,CameraSupportController.CameraType.BACK); }
##Take picture cameraSupport.takePhoto(new OnSupportCameraTakePictureListener() { @Override public void onPicture(byte[] bytes) { cameraSupport.savePicture(bytes, System.currentTimeMillis() + "TestPicture.jpg", Environment.getExternalStorageDirectory() + "/TestDir"); }
##Reselect camera type cameraSupport.changeCameraType(cameraSupport.getCurrentCameraType() == CameraSupportController.CameraType.BACK ? CameraSupportController.CameraType.FRONT : CameraSupportController.CameraType.BACK);
##Enable/Disable flash cameraSupport.setAutoFlashEnabled(true)//false