# ColorPicker **Repository Path**: crazychad/ColorPicker ## Basic Information - **Project Name**: ColorPicker - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: porting - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-04-21 - **Last Updated**: 2021-06-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # ColorPicker **本项目是基于开源项目 ColorPicker 进行openharmony的移植和开发的,可以通过项目标签以及github地址(https://github.com/jaredrummler/ColorPicker)追踪到原项目版本** #### 项目介绍 - 项目名称:ColorPicker - 所属系列:openharmony的第三方组件适配移植 - 功能:ColorPicker is open source color picker for openharmony. - 项目移植状态:完成 - 调用差异:openharmony没有专门封装的首选项, 因此通过自己代码来首选项部分的界面。其他打开选择颜色的Dialog的接口基本一致。 - 实现差异:目前openharmony没有setColorFilter,因此通过Text是实现了部分UI; 没有首选项, 因此demo中用代码模拟了首选项的UI。 - 开发版本:sdk5, DevEco Studio 2.1 Beta 4 Build Version: 2.1.0.303, built on April 28, 2021 Runtime version: 11.0.9+11-b944.49 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Windows 10 10.0 GC: ParNew, ConcurrentMarkSweep Memory: 1484M Cores: 8 Registry: external.system.auto.import.disabled=true - 项目作者和维护人:crazyChad - 邮箱:peidong.hou@archermind.com - 原项目Doc地址:https://github.com/jaredrummler/ColorPicker #### 项目介绍 - 编程语言:Java - Yet another open source color picker for openharmony. So, why should you use this color picker? It is highly customizable and easy to use. ![](./images/color-picker1.png) ![](./images/color-picker2.png) ![](./images/color-picker3.png) ![](./images/color-picker4.png) #### 安装教程 ##### 本地方式 1. 下载har包colorpicker-release.har包。 2. 启动 DevEco Studio,将下载的jar包,导入工程目录“entry->libs”下。 ##### 直接引用 1. 在moudle级别下的build.gradle文件中添加依赖,在dependences标签中增加对libs目录下jar包的引用。 ``` dependencies { implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) implementation 'com.jaredrummler:colorpicker:1.1.0' ...... } ``` #### 使用说明 You can use method of ```ColorPickerDialog.newBuilder()``` to customize the `ColorPickerDialog`: | method | arg type | documentation | |---------------------|-----------|---------------------------------------------------------------------------------------| | setDialogType | enum | "custom" to show the color picker, "preset" to show pre-defined colors | | setShowAlphaSlider | boolean | Show a slider for changing the alpha of a color (adding transparency) | | setColorShape | enum | "square" or "circle" for the shape of the color preview | | setPresets | int[] | An int-array of pre-defined colors to show in the dialog | | setDialogTitle | reference | The string resource id for the dialog title. By default the title is "Select a Color" | | setShowColorShades | boolean | true to show different shades of the selected color | | setAllowPresets | boolean | true to add a button to toggle to the custom color picker | | setAllowCustom | boolean | true to add a button to toggle to the presets color picker | You can use the following code to show the dialog. ```java Component c1 = (Component) view1.getComponentParent(); c1.setClickedListener(new Component.ClickedListener() { @Override public void onClick(Component component) { ColorPickerDialog dialog = ColorPickerDialog.newBuilder() .setColor(color1) .create(getContext()); dialog.setColorPickerDialogListener(new ColorPickerDialogListener() { @Override public void onColorSelected(int dialogId, int color) { color1 = color; view1.setColor(color1); } @Override public void onDialogDismissed(int dialogId) { } }); dialog.show(); } }); ``` For further doumentation about how to use the library, check the [demo](entry) app included in this project. #### 版本迭代 RELEASE: 1.1.0 原工程基线: 基于https://github.com/jaredrummler/ColorPicker/commit/eb76c92f53087cebff5521e217015ba95e49ad39 #### 版权和许可信息 ``` 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. ```