Annca


Source link: https://github.com/memfis19/Annca

Annca

Android solution to simplify work with different camera apis. Include video and photo capturing features with possibility to select quality for appropriate media action etc. In current solution were used some approaches from Grafika project and Google camera samples.

Forks

Some Annca's forks that can be useful if current functionality is not enought:

Example of using

Add Annca activities to the your app manifest file:

<activity

android:name="io.github.memfis19.annca.internal.ui.camera.Camera1Activity"

android:screenOrientation="portrait"

android:theme="@style/ThemeFullscreen" /> <activity

android:name="io.github.memfis19.annca.internal.ui.camera2.Camera2Activity"

android:screenOrientation="portrait"

android:theme="@style/ThemeFullscreen" /> <activity

android:name="io.github.memfis19.annca.internal.ui.preview.PreviewActivity"

android:screenOrientation="portrait"

android:theme="@style/ThemeFullscreen" /> 

Please note that android:screenOrientation="portrait" is mandatory. In current implementation device rotation is detecting via sensor.

Don't forget to put permissions or request them:

<uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> 

A code example of the most simple using:

 AnncaConfiguration.Builder builder = new AnncaConfiguration.Builder(activity, CAPTURE_MEDIA);
  new Annca(builder.build()).launchCamera();
 

and thats it. You can use more extended settings i.e.:

 AnncaConfiguration.Builder videoLimited = new AnncaConfiguration.Builder(activity, CAPTURE_MEDIA);
  videoLimited.setMediaAction(AnncaConfiguration.MEDIA_ACTION_VIDEO);
  videoLimited.setMediaQuality(AnncaConfiguration.MEDIA_QUALITY_AUTO);
  videoLimited.setVideoFileSize(5 * 1024 * 1024);
  videoLimited.setMinimumVideoDuration(5 * 60 * 1000);
  new Annca(videoLimited.build()).launchCamera();
 

in this example you request video capturing which is limited by file size for 5Mb and predefined minimum video duration for 5 min. To achieve this result Annca will decrease video bit rate, so use it carefully to avoid unexpected result (i.e. low quality).

How to get result?
 @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

 super.onActivityResult(requestCode, resultCode, data);

 if (requestCode == CAPTURE_MEDIA && resultCode == RESULT_OK) {

  String filePath = data.getStringExtra(AnncaConfiguration.Arguments.FILE_PATH);

 
}

 
}
 

How to add to your project?

compile 'io.github.memfis19:annca:0.3.7' 

How to customize camera?

By customizing I mean change all avaliable camera controls(not camera preview) to take photos, video recording, quality settings and more in future. To be able to customize camera view you should create activity and extend it via AnncaCameraActivity<T>, where T is camera id type (due to that in camera 1 api camera ids represent as int values and in camera 2 api as string values). You should implement all requested methods. For more details please look at BaseAnncaActivity at library project. In future I will provide more detailed instructions how to do it, but anyway it is quite easy task. In case if you gave some troubles or questions, please use GitHub Issues.

Short summary:

-Extend your activity from AnncaCameraActivity<T>;

-Declare it in the manifest only in Portrait mode.

-Override all methods;
-For method createCameraController use Camera1Controller or Camera2Controller respectively;
-If you want to rotate your views do it inside onScreenRotation(int degrees) method;
-For setting your camera contol layout use method getUserContentView();
-If you pass some parameters to your camera via bundle please use method onProcessBundle(Bundle savedInstanceState) which will be called before getUserContentView();
-In case you need to retrieve some data from camera controller or manager use in or after method onCameraControllerReady() was called.

Square camera

Sample app contains example of using square camera. Few words about it:

  1. Before appearing MediaCodec and MediaMuxer there were no ways to record video from specific surface (at least with native tools) that's why in current example I'm using view resizing to achieve square preview. Look at updateCameraPreview method within SquareCameraActivity.
  2. To make square photo I'm cropping origin, please look at onPhotoTaken method within SquareCameraActivity.
  3. To make square video I'm cropping origin with ffmpeg library, please look at onVideoRecordStop method within SquareCameraActivity. Conclusion: Becasue of some android limitations at least before API level 18 it is not possible to record square video. That's why to make solution more less generic I'm using crop outputs approach. In future I'll implement separate solution for API level 18+ to make possible apply more custom settings for camera (shaders, custom photo/preview/video sizes without cropping etc.).

Know issue

Library has not release yet, so it contains some issues.

Roadmap

-Improve determinig camera quality settings;
-Extend annca configuration settings;
-Add fragments supporting;
-Add opengl supporting.

Bugs and Feedback

For bugs, feature requests, and discussion please use GitHub Issues.

LICENSE

MIT License
Copyright (c) 2016 Rodion Surzhenko

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Resources

A simple indicator with fading animation for ViewPager in Android.

Most of the existing indicators don't provide a smooth transition, this library fades indicators in and out when pager flipped.

Android GifLoadingView.

Optionals for Java 7. This a lightweight copy of Guava's Optional interface.

This library offers easy view bindings for Android.

This library is meant to offer a wrapper around the standard Android Log.x methods in few distinct flavours. It gives you the possibility to have one logger that will use the same logging tag for the whole app and also the ability to quickly change the logging level for the whole app - you can go from debug to release by changing just one constant.

Simple drawee spannable text view based on Fresco.

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