Android Wear Color Picker

Additional

Language
Kotlin
Version
v2.2.2 (Sep 7, 2019)
Created
Mar 15, 2015
Updated
Sep 7, 2019
Owner
Benoit Lubek (BoD)
Contributors
Benoit Lubek (BoD)
TpmKranz
2
Activity
Badge
Generate
Download
Source code

Promotion

Wear OS Color Picker

A color picker activity optimized for Wear OS (aka Android Wear). Handy for watch face settings.

The UI presents a wheel of colors with different hues and lightness.

How to use

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 file:

repositories {
    jcenter()
}

 (...)

dependencies {
    compile 'org.jraf:android-wear-color-picker:2.2.2'
}

Use the library

Start the pick color activity:

Intent intent = new ColorPickActivity.IntentBuilder()
    .oldColor(oldColor)
    .colors(myListOfColors) // <- optional, specify your own list of colors to be used instead of a "rainbow" preset
    .build(this);
startActivityForResult(intent, REQUEST_PICK_COLOR);

Get the picked color:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
        case REQUEST_PICK_COLOR:
            if (resultCode == RESULT_CANCELED) {
                // The user pressed 'Cancel'
                break;
            }

            int pickedColor = ColorPickActivity.getPickedColor(data);
            Log.d("pickedColor=" + Integer.toHexString(pickedColor));
            break;
    }
}

That's it!

License

Copyright (C) 2015-2019 Benoit 'BoD' Lubek (BoD@JRAF.org)

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.