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.
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.3'
}
The library uses Android Data Binding -
make sure your build.gradle
declare that:
android {
buildFeatures {
dataBinding = true
}
}
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!
Copyright (C) 2015-present Benoit 'BoD' Lubek ([email protected])
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.