Giter Site home page Giter Site logo

camerafragment's Introduction

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

png

//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);

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(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

png

#Download

In your module Download

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

#Community

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

#Credits

Author: Florent Champigny

Follow me on Google+ Follow me on Twitter Follow 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.

camerafragment's People

Contributors

florent37 avatar

Watchers

James Cloos avatar Lerist avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.