Skip to content
This repository was archived by the owner on Feb 8, 2022. It is now read-only.

Repository files navigation

CameraFragment

Android ArsenalCircleCI

A simple easy-to-integrate Camera Fragment for Android

CameraFragment preview directly the camera view, and provides a easy API to capture or manage the device

You can setup your own layout and control the camera using CameraFragment

Android app on Google Play

CameraKit

This library works, but on some devices... errors happens, I don't have time to maintain compatibility with all device A community group was created, they created CameraKit, don't hesitate to try it !

https://github.com/CameraKit/camerakit-android

Setup

png

//you can configure the fragment by the configuration builderCameraFragmentcameraFragment = CameraFragment.newInstance(newConfiguration.Builder().build());
getSupportFragmentManager().beginTransaction()
.replace(R.id.content, cameraFragment, FRAGMENT_TAG)
.commit();

Actions

You can directly take a photo / video with

cameraFragment.takePhotoOrCaptureVideo(callback);
cameraFragment.takePhotoOrCaptureVideo(callback, directoryPath, fileName);

gif

Flash can be enable / disabled ( AUTO / OFF / ON ) with

cameraFragment.toggleFlashMode();

gif

Camera Type can be modified ( BACK / FRONT ) with

cameraFragment.switchCameraTypeFrontBack();

gif

Camera action ( PHOTO / VIDEO ) can be modified with

cameraFragment.switchActionPhotoVideo();

gif

And you can change the captured photo / video size with

cameraFragment.openSettingDialog();

gif

Listeners

Result

Get back the result of the camera record / photo in the CameraFragmentResultListener

cameraFragment.setResultListener(newCameraFragmentResultListener() {
@OverridepublicvoidonVideoRecorded(byte[] bytes, StringfilePath) {
//called when the video record is finished and savedstartActivityForResult(PreviewActivity.newIntentVideo(MainActivity.this, filePath));
}
@OverridepublicvoidonPhotoTaken(byte[] bytes, StringfilePath) {
//called when the photo is taken and savedstartActivity(PreviewActivity.newIntentPhoto(MainActivity.this, filePath));
}
});

Camera Listener

cameraFragment.setStateListener(newCameraFragmentStateListener() {
//when the current displayed camera is the backvoidonCurrentCameraBack();
//when the current displayed camera is the frontvoidonCurrentCameraFront();
//when the flash is at mode autovoidonFlashAuto();
//when the flash is at onvoidonFlashOn();
//when the flash is offvoidonFlashOff();
//if the camera is ready to take a photovoidonCameraSetupForPhoto();
//if the camera is ready to take a videovoidonCameraSetupForVideo();
//when the camera state is "ready to record a video"voidonRecordStateVideoReadyForRecord();
//when the camera state is "recording a video"voidonRecordStateVideoInProgress();
//when the camera state is "ready to take a photo"voidonRecordStatePhoto();
//after the rotation of the screen / cameravoidshouldRotateControls(intdegrees);
voidonStartVideoRecord(FileoutputFile);
voidonStopVideoRecord();
});

Text

CameraFragment can ping you with the current record duration with CameraFragmentTextListener

Widgets

CameraFragment comes with some default views

RecordButton, MediaActionSwitchView, FlashSwitchView, CameraSwitchView, CameraSettingsView

png

Download

Buy Me a Coffee at ko-fi.com

In your module Download

implementation 'com.github.florent37:camerafragment:1.0.10'

Community

Forked from https://github.com/memfis19/Annca

This library works, but on some devices... errors happens, I don't have time to maintain compatibility with all device A community group was created, they created CameraKit, don't hesitate to try it !

https://github.com/CameraKit/camerakit-android

Credits

Author: Florent Champigny http://www.florentchampigny.com/

Blog : http://www.tutos-android-france.com/

Fiches Plateau Moto : https://www.fiches-plateau-moto.fr/

Android app on Google PlayFollow me on Google+Follow me on TwitterFollow me on LinkedIn

License

Copyright 2017 florent37, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

A simple easy-to-integrate Camera Fragment for Android

Topics

Resources

Stars

2.3k stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages