All Projects → hluhovskyi → Camerabutton

hluhovskyi / Camerabutton

Licence: apache-2.0
Instagram-like button for taking photos or recording videos

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Camerabutton

Materialfavoritebutton
Animated favorite/star/like button
Stars: ✭ 586 (+384.3%)
Mutual labels:  material-design, material-ui, button
Cyanea
A theme engine for Android
Stars: ✭ 1,319 (+990.08%)
Mutual labels:  material-design, material-ui
Togglebuttons
Android toggle buttons that adhere to the Material Design documentation.
Stars: ✭ 88 (-27.27%)
Mutual labels:  material-design, material-ui
Mediapicker
Easy customizable picker for all your needs in Android application
Stars: ✭ 105 (-13.22%)
Mutual labels:  material-design, material-ui
Create Mui Theme
online tool for creating material-ui themes
Stars: ✭ 80 (-33.88%)
Mutual labels:  material-design, material-ui
Wymaterialbutton
Interactive and fully animated Material Design button for iOS developers.
Stars: ✭ 80 (-33.88%)
Mutual labels:  material-design, button
Cardview
Material Design Cards ? How cool is that !
Stars: ✭ 101 (-16.53%)
Mutual labels:  material-design, material-ui
Material Message Box
A WPF Message Box implementing material design
Stars: ✭ 69 (-42.98%)
Mutual labels:  material-design, material-ui
Mui Treasury
A collection of ready-to-use components based on Material-UI
Stars: ✭ 1,821 (+1404.96%)
Mutual labels:  material-design, material-ui
Material Dashboard
Material Dashboard - Open Source Bootstrap 5 Material Design Admin
Stars: ✭ 9,987 (+8153.72%)
Mutual labels:  material-design, material-ui
Materialspinner
Implementation of a Material Spinner for Android with TextInputLayout functionalities
Stars: ✭ 107 (-11.57%)
Mutual labels:  material-design, material-ui
Materialchipview
Material Chip view. Can be used as tags for categories, contacts or creating text clouds
Stars: ✭ 1,181 (+876.03%)
Mutual labels:  material-design, material-ui
Gitexplorer Android
Find the right git commands 🔥 without digging through the web.😊😊😉
Stars: ✭ 72 (-40.5%)
Mutual labels:  material-design, material-ui
P32929.github.io
Second iteration of my portfolio - created using ReactJS, Material-UI, Overmind, etc
Stars: ✭ 84 (-30.58%)
Mutual labels:  material-design, material-ui
Material Ui Layout
Declarative layout for Material UI
Stars: ✭ 71 (-41.32%)
Mutual labels:  material-design, material-ui
Datingapp
Dating UI kit is used for online meet up with girls and boys . The screen contains more than 30 icons and most of all required elements required to design an application like this. The XML and JAVA files contains comments at each and every point for easy understanding. Everything was made with a detail oriented style and followed by today's web trends. Clean coded & Layers are well-organized, carefully named, and grouped.
Stars: ✭ 97 (-19.83%)
Mutual labels:  material-design, material-ui
Android Issue Reporter
A powerful and simple library to open issues on GitHub directly from your app.
Stars: ✭ 115 (-4.96%)
Mutual labels:  material-design, material-ui
Android Material Design In Practice
A project to demonstrate the latest material design principles with simple examples. It has additional examples on how to easily scale texts on different screen sizes without extra effort.
Stars: ✭ 67 (-44.63%)
Mutual labels:  material-design, material-ui
Mahapps.metro.iconpacks
Awesome icon packs for WPF and UWP in one library
Stars: ✭ 1,157 (+856.2%)
Mutual labels:  material-design, material-ui
Pentagonfloatingactionbutton
Android property animation - The Value Animator
Stars: ✭ 106 (-12.4%)
Mutual labels:  material-design, material-ui

CameraButton

Instagram-like button for taking photos or recording videos.

Build Status

Getting started

Add library as dependency to your build.gradle.

 compile 'com.hluhovskyi.camerabutton:camerabutton:2.0.1'
 compile 'com.hluhovskyi.camerabutton:camerabutton-rxjava2:2.0.1'
 compile 'com.hluhovskyi.camerabutton:camerabutton-rxjava2-kotlin:2.0.1'

No need to include all dependencies, choose just one which covers your needs.

Please, feel free to open issues you are stuck with. PRs are also welcome :)

How to use?

  1. Add CameraButton to your xml markup

     <com.hluhovskyi.camerabutton.CameraButton
         android:id="@+id/camera_button"
         android:layout_width="@dimen/cb_layout_width_default"
         android:layout_height="@dimen/cb_layout_height_default" />
    
  2. Find view and attach needed listeners

     cameraButton.setOnTapEventListener(new CameraButton.OnTapEventListener() {
         @Override public void onTap() {
             takePhoto();
         }
     });
     cameraButton.setOnHoldEventListener(new CameraButton.OnHoldEventListener() {
         @Override public void onStart() {
             startRecordVideo();
         }
         @Override public void onFinish() {
             finishRecordVideo();
         }
         @Override public void onCancel() {
             cancelRecordVideo();
         }
     });
     cameraButton.setOnStateChangeListener(new CameraButton.OnStateChangeListener() {
         @Override public void onStateChanged(@NonNull CameraButton.State state) {
             dispatchStateChange(state);
         }
     });
    
  3. Enjoy!

Check full example

Take into account that you can get ConsistencyValidationException in case some part of the button overlaps other one or crosses view's boundaries. If you don't need "pixel-perfect" checks you can disable them by calling button.shouldCheckConsistency(false) otherwise you have to set correct sizes.

RxJava and Kotlin

For now only RxJava version 2 is supported. It is implemented according to guidelines of JakeWharton/RxBinding library.

Example of usage:

 RxCameraButton.stateChanges(button)
     .filter(state -> state == CameraButton.State.START_COLLAPSING)
     .subscribe(state -> hideButtons());
     
 RxCameraButton.tapEvents(button)
     .subscribe(event -> takePhoto());

All events have componentN function so if you are using Kotlin for development there is ability to use destruction declaration and also there are few extension methods:

 button.stateChanges()
     .filter { it == CameraButton.State.START_COLLAPSING }
     .subscribe { hideButtons() }
     
 button.stateChangeEvents()
     .filter { (view, state) -> 
         view.id == R.id.alert_button && state == CameraButton.State.PRESSED
     }
     .subscribe { showAlert() }
   
 button.tapEvents()
     .subscribe { takePhoto() }

Customization

  • cb_main_circle_radius or setMainCircleRadius()

Default value - 28dp/@dimen/cb_main_circle_radius_default

  • cb_main_circle_color or setMainCircleColor()

Default value - #ffffff/@color/cb_main_circle_color_default

  • cb_stroke_width or setStrokeWidth()

Default value - 12dp/@dimen/cb_stroke_width_default

  • cb_stroke_color or setStrokeColor()

Default value - #66FFFFFF/@color/cb_stroke_color_default

  • cb_main_circle_radius_expanded or setMainCircleRadiusExpanded()

Default value - 24dp/@dimen/cb_main_circle_radius_expanded_default

  • Expanded stroke width can't be set explicitly. It is calculated by following formula:

stroke_width_expanded = min(layout_width, layout_height) - main_circle_expanded

  • cb_progress_arc_width or setProgressArcWidth()

Default value - 4dp/@dimen/cb_progress_arc_width_default

  • cb_progress_arc_colors or setProgressArcColors()

Default values - [#feda75, #fa7e1e, #d62976, #962fbf, #4f5bd5]/@array/cb_progress_arc_colors_default

To set values via xml you have to define all colors separately and merge their references into one array:

 <color name="my_color_1">#000000</color>
 <color name="my_color_2">#ffffff</color>

 <array name="my_progress_colors">
     <item>@color/my_color_1</item>
     <item>@color/my_color_2</item>
 </array>
 
 ...
 
 <com.hluhovskyi.camerabutton.CameraButton
     ...
     app:cb_progress_arc_colors="@color/my_progress_colors"/>  

To set values programmatically you have to call setProgressArcColors with array of color values:

 button.setProgressArcColors(new int[]{Color.BLACK, Color.WHITE});

License

Copyright (C) 2018 Artem Hluhovskyi

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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].