Android Material Color Picker


Source link: https://github.com/Pes8/android-material-color-picker-dialog

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

Landscape

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.2.0'
  
}

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

// Examples

Log.d("Alpha", Integer.toString(Color.alpha(color)));

Log.d("Red", Integer.toString(Color.red(color)));

Log.d("Green", Integer.toString(Color.green(color)));

Log.d("Blue", Integer.toString(Color.blue(color)));

 Log.d("Pure Hex", Integer.toHexString(color));

Log.d("#Hex no alpha", String.format("#%06X", (0xFFFFFF & color)));

Log.d("#Hex with alpha", String.format("#%08X", (0xFFFFFFFF & color)));

}

  
}
);

That's all :)

Transition from v1.1 to v1.2

The deprecated callback has been removed. See Transition from v1.0 to v1.1.

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

Available Languages

  • English
  • Italian
  • German
  • French
  • Spanish
  • Iranian
  • Persian
  • Korean
  • Turkish

If you would like to help localise this library please fork the project, create and verify your language files, add the language to the README 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 :)

Contributors

Author: Simone Pessotto

Special thanks to :

Patrick Geselbracht

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. 

Resources

SmartDeviceLink (SDL) is a standard set of protocols and messages that connect applications on a smartphone to a vehicle head unit. This messaging enables a consumer to interact with their application using common in-vehicle interfaces such as a touch screen display, embedded voice recognition, steering wheel controls and various vehicle knobs and buttons. There are three main components that make up the SDL ecosystem.

Simple custom ImageView for android giving you a simple way to enable overlapping of two images one over the other.

OkHttp-Stats is an android library built on top of OkHttp3, which is responsible for intercepting all the network calls and for calculating network stats such as the average network speed of the user.

This is more of an analytical tool which can be used to track the success and error response logs.

Can be plugged in to any app which uses okhttp in their networking stack.

Example app to use Protobuf in Android using Square's Wire library.

Espresso's consistency makes it really easy to learn.

Want to match a view with a specific id? Use withId(R.id.some_id). Need to match with a piece of text? Use withText(R.id.some_text) or withText("some text). Awesome, consistent and it's very clear what it is you are doing.

However...

After a few hours writing test code you'll find your code being a little bit too verbose. Not anymore.

Why should you need to explicitly specify that you are matching with some text if you are passing in some text as a parameter? Some for the view id, you can already see that it is a view id.

Ristretto allows you to write the same test code as you already write, but less verbose.

Complete abstraction from the Spannable API. Forget about all the boiler plate code and all the Object what nonsense that you have to deal with when working with Spannable.

  • Eliminate setSpan calls by using all the provided methods trough the StyleEZ interface.
  • Chain multiple spans with a fluent style
  • By using both the ContentEZ and StyleEZ interface it removes unnecessary methods from the autocomplete form, and thus it removes clutter.
  • Allows different ways of adding content (String, String Resource and Formatted String)
  • By default it does INCLUSIVE_INCLUSIVE to all the spans
  • After calling any of the inclusive/exclusive methods, all the next methods will be using that flag until apply is called or another flag is used
  • You can create your own locator by extending the Locator interface

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