Giter Site home page Giter Site logo

msoftware / android-material-color-picker-dialog Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pes8/android-material-color-picker-dialog

0.0 2.0 0.0 1.81 MB

A simple, minimalistic and beautiful dialog color picker for Android 4.1+ (Jellybean+) devices

Home Page: http://www.simonepessotto.it

License: MIT License

Java 100.00%

android-material-color-picker-dialog's Introduction

Download Donate

Android Material Color Picker Dialog

A simple, minimalistic and beautiful dialog color picker for Android 4.1+ devices. This color picker is easy-to-use and easy-to-integrate in your application to let users of your app choose color in a simple way.

Features

  • Get Hex and (A)RGB color codes
  • Set color using (A)RGB values and get HEX codes
  • Set color using HEX value
  • Separate UI for portrait and landscape devices
  • Support for pre-lollipop devices

Design inspired from Dribbble by Lucas Bonomi

Portrait

Portrait RGB Portrait ARGB

Landscape

Landscape RGB Landscape ARGB

HOW TO USE IT

Adding the library to your project

The aar artifact is available at the jcenter repository. Declare the repository and the dependency in your build.gradle.

(root)

    repositories {
        jcenter()
    }

(module)

    dependencies {
        compile 'com.pes.materialcolorpicker:library:1.1.+'
    }

Use the library

Import the class

    import com.pes.androidmaterialcolorpickerdialog.ColorPicker;

Create a color picker dialog object

    final ColorPicker cp = new ColorPicker(MainActivity.this, defaultColorR, defaultColorG, defaultColorB);

defaultColorR, defaultColorG, defaultColorB are 3 integer (value 0-255) for the initialization of the color picker with your custom color value. If you don't want to start with a color set them to 0 or use only the first argument.

The library also supports alpha values. If no color or only red, green, and blue are specified, the alpha value is set to 255 (0xFF) and no slider is shown.

Use the following constructor to specify an alternative alpha channel value (0..255). As soon as the alpha value constructor is used, a fourth slider will appear above the RGB sliders and the text input field will change from six HEX characters to eight.

    final ColorPicker cp = new ColorPicker(MainActivity.this, defaultAlphaValue, defaultColorR, defaultColorG, defaultColorB);

Then show the dialog (when and where you want) and save the selected color

    /* Show color picker dialog */
    cp.show();
    
    /* Set a new Listener called when user click "select" */
    cp.setCallback(new ColorPickerCallback() {
        @Override
        public void onColorChosen(@ColorInt int color) {
            // Do whatever you want
        }
    });

That's all :)

Transition from v1.0 to v1.1

Version 1.1 introduced some API changes---mainly a renaming of the OnColorSelected callback interface. This has been renamed to ColorPickerCallback.

The old interface is still in the library but will be removed in the next version update. It has been marked as deprecated and isn't called by the library, therefore no values will appear in your app if you still rely on the old interface.

Translations

If you would like to help localise this library please fork the project, create and verify your language files, then create a pull request.

Example

Example app that use Android Material Color Picker Dialog to let users choose the color of the Qr Code:

Qr Code Generator Play Store

Qr Code Generator Direct Download

Donation

If this project help you reduce time to develop, you can give me a cup of coffee :)

paypal

LICENSE

The MIT License (MIT)

Copyright (c) 2017 Simone Pessotto (http://www.simonepessotto.it)

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.

android-material-color-picker-dialog's People

Contributors

pes8 avatar pattafeufeu avatar captswag avatar defvs avatar javadkarbasian avatar

Watchers

Michael jentsch 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.