CameraFragment


Source link: https://github.com/florent37/CameraFragment

CameraFragment

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

//you can configure the fragment by the configuration builder CameraFragment cameraFragment = CameraFragment.newInstance(new Configuration.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);

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

cameraFragment.toggleFlashMode();

Camera Type can be modified ( BACK / FRONT ) with

cameraFragment.switchCameraTypeFrontBack();

Camera action ( PHOTO / VIDEO ) can be modified with

cameraFragment.switchActionPhotoVideo();

And you can change the captured photo / video size with

cameraFragment.openSettingDialog();

Listeners

Result

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

cameraFragment.setResultListener(new CameraFragmentResultListener() {

  @Override

  public void onVideoRecorded(byte[] bytes, String filePath) {

  //called when the video record is finished and saved

startActivityForResult(PreviewActivity.newIntentVideo(MainActivity.this, filePath));

  
}

@Override

  public void onPhotoTaken(byte[] bytes, String filePath) {

  //called when the photo is taken and saved

startActivity(PreviewActivity.newIntentPhoto(MainActivity.this, filePath));

  
}
 
}
);

Camera Listener

cameraFragment.setStateListener(new CameraFragmentStateListener() {

//when the current displayed camera is the back
  void onCurrentCameraBack();

  //when the current displayed camera is the front
  void onCurrentCameraFront();

//when the flash is at mode auto
  void onFlashAuto();

  //when the flash is at on
  void onFlashOn();

  //when the flash is off
  void onFlashOff();

//if the camera is ready to take a photo
  void onCameraSetupForPhoto();

  //if the camera is ready to take a video
  void onCameraSetupForVideo();

//when the camera state is "ready to record a video"
  void onRecordStateVideoReadyForRecord();

  //when the camera state is "recording a video"
  void onRecordStateVideoInProgress();

  //when the camera state is "ready to take a photo"
  void onRecordStatePhoto();

//after the rotation of the screen / camera
  void shouldRotateControls(int degrees);

void onStartVideoRecord(File outputFile);

  void onStopVideoRecord();
 
}
);

Text

CameraFragment can ping you with the current record duration with CameraFragmentTextListener

Widgets

CameraFragment comes with some default views

RecordButton, MediaActionSwitchView, FlashSwitchView, CameraSwitchView, CameraSettingsView

Download

In your module

compile 'com.github.florent37:camerafragment:1.0.7'

Community

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

Credits

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

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

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. 

Resources

Java client for the Thumbor image service which allows you to build URIs in an expressive fashion using a fluent API.

Android Library Finder

An Android library that allows you to figure out the quality of the current user's internet connection. The connection gets classified into several "Connection Classes" that make it easy to develop against. The library does this by listening to the existing internet traffic done by your app and notifying you when the user's connection quality changes. Developers can then use this Connection Class information and adjust the application's behavior.

Android APT Plugin for Gradle. Makes sources generated by annotation processors visible in Android Studio.

CoolSwitch is a custom view for Android with an awesome reveal animation.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes