├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── markdown-exported-files.xml
├── markdown-navigator.xml
├── markdown-navigator
│ └── profiles_settings.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── dingmouren
│ │ └── colorpickerpro
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── dingmouren
│ │ │ └── colorpickerpro
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ ├── header.png
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── dingmouren
│ └── colorpickerpro
│ └── ExampleUnitTest.java
├── build.gradle
├── colorpicker
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── dingmouren
│ │ └── colorpicker
│ │ ├── ColorPickerDialog.java
│ │ ├── ColorPlateView.java
│ │ └── OnColorPickerListener.java
│ └── res
│ ├── drawable-mdpi
│ ├── alpha_bottom.png
│ └── hue_list.png
│ ├── drawable
│ ├── alpha_bottom_drawable.xml
│ ├── color_arrow.xml
│ ├── cursor.xml
│ └── img_plate_cursor.xml
│ ├── layout
│ └── color_picker_dialog.xml
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── imgs
├── img.gif
└── imgbanner.png
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/markdown-exported-files.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/markdown-navigator.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/.idea/markdown-navigator/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DingMouRen/ColorPicker/4de1019e1316cc303871f0cfa72f4f2bad27285d/README.md
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 | defaultConfig {
7 | applicationId "com.dingmouren.colorpickerpro"
8 | minSdkVersion 15
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(include: ['*.jar'], dir: 'libs')
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | compile 'com.android.support:appcompat-v7:25.3.1'
28 | testCompile 'junit:junit:4.12'
29 | compile project(':colorpicker')
30 | }
31 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in F:\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/dingmouren/colorpickerpro/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.dingmouren.colorpickerpro;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.dingmouren.colorpickerpro", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/dingmouren/colorpickerpro/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.dingmouren.colorpickerpro;
2 |
3 | import android.graphics.Color;
4 | import android.os.Build;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.os.Bundle;
7 | import android.support.v7.widget.Toolbar;
8 | import android.view.View;
9 | import android.widget.Button;
10 |
11 | import com.dingmouren.colorpicker.ColorPickerDialog;
12 | import com.dingmouren.colorpicker.OnColorPickerListener;
13 |
14 | public class MainActivity extends AppCompatActivity {
15 | private Toolbar mToolbar;
16 | private Button mButton;
17 | private ColorPickerDialog mColorPickerDialog;
18 | private boolean supportAlpha;//颜色是否支持透明度
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.activity_main);
23 | mToolbar = (Toolbar) findViewById(R.id.toobar);
24 | mButton = (Button) findViewById(R.id.btn);
25 | mToolbar.setTitle("DingMouRen--ColorPicker");
26 | setSupportActionBar(mToolbar);
27 | mButton.setOnClickListener(new View.OnClickListener() {
28 | @Override
29 | public void onClick(View v) {
30 | mColorPickerDialog = new ColorPickerDialog(MainActivity.this,getResources().getColor(R.color.colorPrimary),supportAlpha,mOnColorPickerListener).show();
31 | supportAlpha = !supportAlpha;
32 | }
33 | });
34 |
35 |
36 | }
37 | private OnColorPickerListener mOnColorPickerListener = new OnColorPickerListener() {
38 | @Override
39 | public void onColorCancel(ColorPickerDialog dialog) {
40 |
41 | }
42 |
43 | @Override
44 | public void onColorChange(ColorPickerDialog dialog, int color) {
45 | if (mToolbar != null){
46 | mToolbar.setBackgroundColor(color);
47 | mColorPickerDialog.setButtonTextColor(color);
48 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
49 | getWindow().setStatusBarColor(color);
50 | }
51 | }
52 | }
53 |
54 | @Override
55 | public void onColorConfirm(ColorPickerDialog dialog, int color) {
56 | if (mButton != null){
57 | mButton.setBackgroundColor(color);
58 | }
59 | }
60 | };
61 | }
62 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
20 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DingMouRen/ColorPicker/4de1019e1316cc303871f0cfa72f4f2bad27285d/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DingMouRen/ColorPicker/4de1019e1316cc303871f0cfa72f4f2bad27285d/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/header.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DingMouRen/ColorPicker/4de1019e1316cc303871f0cfa72f4f2bad27285d/app/src/main/res/mipmap-xhdpi/header.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DingMouRen/ColorPicker/4de1019e1316cc303871f0cfa72f4f2bad27285d/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DingMouRen/ColorPicker/4de1019e1316cc303871f0cfa72f4f2bad27285d/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DingMouRen/ColorPicker/4de1019e1316cc303871f0cfa72f4f2bad27285d/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #1DE9B6
4 | #1DE9B6
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ColorPickerPro
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/test/java/com/dingmouren/colorpickerpro/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.dingmouren.colorpickerpro;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.2.2'
9 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.1'
10 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
11 | // NOTE: Do not place your application dependencies here; they belong
12 | // in the individual module build.gradle files
13 | }
14 | }
15 |
16 | allprojects {
17 | repositories {
18 | jcenter()
19 | }
20 | }
21 |
22 | task clean(type: Delete) {
23 | delete rootProject.buildDir
24 | }
25 |
--------------------------------------------------------------------------------
/colorpicker/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/colorpicker/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.github.dcendents.android-maven'
3 | apply plugin: 'com.jfrog.bintray'
4 |
5 | android {
6 | compileSdkVersion 25
7 | buildToolsVersion "25.0.2"
8 |
9 | defaultConfig {
10 | minSdkVersion 15
11 | targetSdkVersion 25
12 | versionCode 1
13 | versionName "1.0.1"
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | }
22 |
23 | dependencies {
24 | compile 'com.android.support:appcompat-v7:25.3.1'
25 | }
26 |
27 |
28 | def siteUrl = 'https://github.com/DingMouRen/ColorPicker' // #CONFIG# // project homepage
29 | def gitUrl = 'https://github.com/DingMouRen/ColorPicker.git' // #CONFIG# // project git
30 | group = "com.dingmouren.colorpicker"
31 | version = "1.0.1"
32 | install {
33 | repositories.mavenInstaller {
34 | // This generates POM.xml with proper parameters
35 | pom {
36 | project {
37 | packaging 'aar'
38 | name 'ColorPicker For Android' // #CONFIG# // project title
39 | url siteUrl
40 | // Set your license
41 | licenses {
42 | license {
43 | name 'The Apache Software License, Version 2.0'
44 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
45 | }
46 | }
47 | developers {
48 | developer {
49 | id 'dingmouren' // #CONFIG# // your user id (you can write your nickname)
50 | name 'dingmouren' // #CONFIG# // your user name
51 | email 'naildingmouren@gmail.com' // #CONFIG# // your email
52 | }
53 | }
54 | scm {
55 | connection gitUrl
56 | developerConnection gitUrl
57 | url siteUrl
58 | }
59 | }
60 | }
61 | }
62 | }
63 |
64 | task sourcesJar(type: Jar) {
65 | from android.sourceSets.main.java.srcDirs
66 | classifier = 'sources'
67 | }
68 |
69 | task javadoc(type: Javadoc) {
70 | options.encoding = "UTF-8"
71 | source = android.sourceSets.main.java.srcDirs
72 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
73 | }
74 |
75 | task javadocJar(type: Jar, dependsOn: javadoc) {
76 | classifier = 'javadoc'
77 | from javadoc.destinationDir
78 | }
79 | javadoc {
80 | options {
81 | encoding "UTF-8"
82 | charSet 'UTF-8'
83 | author true
84 | version true
85 | links "http://docs.oracle.com/javase/7/docs/api"
86 | title 'A ColorPicker For Android' // 文档标题
87 | }
88 | }
89 | artifacts {
90 | archives javadocJar
91 | archives sourcesJar
92 | }
93 | // 生成jar包
94 | task releaseJar(type: Copy) {
95 | from( 'build/intermediates/bundles/release')
96 | into( '../jar')
97 | include('classes.jar')
98 | rename('classes.jar', 'okgo-' + version + '.jar')
99 | }
100 |
101 | Properties properties = new Properties()
102 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
103 | bintray {
104 | user = properties.getProperty("bintray.user")
105 | key = properties.getProperty("bintray.apikey")
106 | configurations = ['archives']
107 | pkg {
108 | repo = "maven"
109 | name = "colorpicker" // #CONFIG# project name in jcenter
110 | userOrg = "dingmouren"
111 | websiteUrl = siteUrl
112 | vcsUrl = gitUrl
113 | licenses = ["Apache-2.0"]
114 | publish = true
115 | }
116 | }
117 |
118 |
--------------------------------------------------------------------------------
/colorpicker/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in F:\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/colorpicker/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/colorpicker/src/main/java/com/dingmouren/colorpicker/ColorPickerDialog.java:
--------------------------------------------------------------------------------
1 | package com.dingmouren.colorpicker;
2 |
3 | import android.annotation.TargetApi;
4 | import android.content.Context;
5 | import android.content.DialogInterface;
6 | import android.graphics.Color;
7 | import android.graphics.drawable.GradientDrawable;
8 | import android.os.Build;
9 | import android.support.v7.app.AlertDialog;
10 | import android.view.LayoutInflater;
11 | import android.view.MotionEvent;
12 | import android.view.View;
13 | import android.view.ViewGroup;
14 | import android.view.ViewTreeObserver;
15 | import android.widget.Button;
16 | import android.widget.ImageView;
17 | import android.widget.RelativeLayout;
18 |
19 | /**
20 | * Created by dingmouren on 2017/5/4.
21 | */
22 |
23 | public class ColorPickerDialog {
24 | private static final String TAG = ColorPickerDialog.class.getName();
25 |
26 | private AlertDialog mAlertDialog;
27 | private final boolean mIsSupportAlpha;
28 | private final OnColorPickerListener mListener;
29 | private final ViewGroup mViewContainer;
30 | private final ColorPlateView mViewPlate;
31 | private final View mViewHue;
32 | private final ImageView mViewAlphaBottom;
33 | private final View mViewAlphaOverlay;
34 | private final ImageView mPalteCursor;
35 | private final ImageView mHueCursor;
36 | private final ImageView mAlphaCursor;
37 | private final View mViewOldColor;
38 | private final View mViewNewColor;
39 | private final float[] mCurrentHSV = new float[3];
40 | private int mAlpha;
41 |
42 | /**
43 | * 创建不支持透明度的取色器
44 | * @param context
45 | * @param defauleColor 默认颜色
46 | * @param listener
47 | */
48 | public ColorPickerDialog(final Context context,int defauleColor,OnColorPickerListener listener){
49 | this(context,defauleColor,false,listener);
50 | }
51 |
52 | /**
53 | * 创建支持透明度的取色器
54 | * @param context 宿主Activity
55 | * @param defauleColor 默认的颜色
56 | * @param isSupportAlpha 颜色是否支持透明度
57 | * @param listener 取色器的监听器
58 | */
59 | public ColorPickerDialog(final Context context,int defauleColor,boolean isSupportAlpha ,OnColorPickerListener listener){
60 | this.mIsSupportAlpha = isSupportAlpha;
61 | this.mListener = listener;
62 |
63 | if (!isSupportAlpha){
64 | defauleColor = defauleColor | 0xff000000;
65 | }
66 |
67 | Color.colorToHSV(defauleColor,mCurrentHSV);
68 | mAlpha = Color.alpha(defauleColor);
69 |
70 | final View view = LayoutInflater.from(context).inflate(R.layout.color_picker_dialog,null);
71 | mViewHue = view.findViewById(R.id.img_hue);
72 | mViewPlate = (ColorPlateView) view.findViewById(R.id.color_plate);
73 | mHueCursor = (ImageView) view.findViewById(R.id.hue_cursor);
74 | mViewOldColor = view.findViewById(R.id.view_old_color);
75 | mViewNewColor = view.findViewById(R.id.view_new_color);
76 | mPalteCursor = (ImageView) view.findViewById(R.id.plate_cursor);
77 | mViewContainer = (ViewGroup) view.findViewById(R.id.container);
78 | mViewAlphaOverlay = view.findViewById(R.id.view_overlay);
79 | mAlphaCursor = (ImageView) view.findViewById(R.id.alpha_Cursor);
80 | mViewAlphaBottom = (ImageView) view.findViewById(R.id.img_alpha_bottom);
81 |
82 | {
83 | mViewAlphaBottom.setVisibility(mIsSupportAlpha ? View.VISIBLE : View.GONE);
84 | mViewAlphaOverlay.setVisibility(mIsSupportAlpha ? View.VISIBLE : View.GONE);
85 | mAlphaCursor.setVisibility(mIsSupportAlpha ? View.VISIBLE : View.GONE);
86 | }
87 |
88 | mViewPlate.setHue(getColorHue());
89 | mViewOldColor.setBackgroundColor(defauleColor);
90 | mViewNewColor.setBackgroundColor(defauleColor);
91 |
92 | initOnTouchListener();
93 | initAlerDialog(context,view);
94 | initGlobalLayoutListener(view);
95 | }
96 |
97 | /**
98 | * 触摸监听
99 | */
100 | private void initOnTouchListener() {
101 | //色彩板的触摸监听
102 | mViewHue.setOnTouchListener(new View.OnTouchListener() {
103 | @Override
104 | public boolean onTouch(View v, MotionEvent event) {
105 | int action = event.getAction();
106 | if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_MOVE || action == MotionEvent.ACTION_UP){
107 | float y = event.getY();
108 | if (y < 0.f) y = 0.f;
109 | if (y > mViewHue.getMeasuredHeight()) y = mViewHue.getMeasuredHeight() - 0.001f;
110 | float colorHue = 360.f - 360.f / mViewHue.getMeasuredHeight() * y;
111 | if (colorHue == 360.f ) colorHue = 0.f;
112 | setColorHue(colorHue);
113 | mViewPlate.setHue(colorHue);
114 |
115 | moveHueCursor();
116 | mViewNewColor.setBackgroundColor(getColor());
117 | if (mListener!=null){
118 | mListener.onColorChange(ColorPickerDialog.this,getColor());
119 | }
120 | updateAlphaView();
121 | return true;
122 | }
123 | return false;
124 | }
125 | });
126 |
127 |
128 | //支持透明度时的触摸监听
129 | if (mIsSupportAlpha) mViewAlphaBottom.setOnTouchListener(new View.OnTouchListener() {
130 | @Override
131 | public boolean onTouch(View v, MotionEvent event) {
132 | int action = event.getAction();
133 | if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_MOVE || action == MotionEvent.ACTION_UP){
134 | float y = event.getY();
135 | if (y < 0.f) y = 0.f;
136 | if (y > mViewHue.getMeasuredHeight()) y = mViewHue.getMeasuredHeight() - 0.001f;
137 | final int alpha = Math.round(255.f - (255.f / mViewAlphaBottom.getMeasuredHeight() * y));
138 | ColorPickerDialog.this.setAlpha(alpha);
139 | moveAlphaCursor();
140 | int color = ColorPickerDialog.this.getColor();
141 | int alphaColor = alpha << 24 | color & 0x00ffffff;
142 | mViewNewColor.setBackgroundColor(alphaColor);
143 | if (mListener!=null){
144 | mListener.onColorChange(ColorPickerDialog.this,getColor());
145 | }
146 | return true;
147 | }
148 | return false;
149 | }
150 | });
151 |
152 | //颜色样板的触摸监听
153 | mViewPlate.setOnTouchListener(new View.OnTouchListener() {
154 | @Override
155 | public boolean onTouch(View v, MotionEvent event) {
156 | int action = event.getAction();
157 | if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_MOVE || action == MotionEvent.ACTION_UP){
158 | float x = event.getX();
159 | float y = event.getY();
160 | if (x < 0.f) x = 0.f;
161 | if (x > mViewPlate.getMeasuredWidth()) x = mViewPlate.getMeasuredWidth();
162 | if (y < 0.f) y = 0.f;
163 | if (y > mViewPlate.getMeasuredHeight()) y = mViewPlate.getMeasuredHeight();
164 |
165 | setColorSat(1.f / mViewPlate.getMeasuredWidth() * x);//颜色深浅
166 | setColorVal(1.f - (1.f / mViewPlate.getMeasuredHeight() * y));//颜色明暗
167 | movePlateCursor();
168 | mViewNewColor.setBackgroundColor(getColor());
169 | if (mListener!=null){
170 | mListener.onColorChange(ColorPickerDialog.this,getColor());
171 | }
172 | return true;
173 | }
174 | return false;
175 | }
176 | });
177 | }
178 |
179 | /**
180 | * 初始化AlerDialog
181 | */
182 | private void initAlerDialog(Context context,View view) {
183 | mAlertDialog = new AlertDialog.Builder(context).create();
184 | mAlertDialog.setTitle(context.getResources().getString(R.string.dialog_title));
185 | mAlertDialog.setButton(DialogInterface.BUTTON_POSITIVE, context.getResources().getString(R.string.dialog_positive), new DialogInterface.OnClickListener() {
186 | @Override
187 | public void onClick(DialogInterface dialog, int which) {
188 | if (ColorPickerDialog.this.mListener != null){
189 | ColorPickerDialog.this.mListener.onColorConfirm(ColorPickerDialog.this,getColor());
190 | }
191 | }
192 | });
193 | mAlertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, context.getResources().getString(R.string.dialog_negative), new DialogInterface.OnClickListener() {
194 | @Override
195 | public void onClick(DialogInterface dialog, int which) {
196 | if (ColorPickerDialog.this.mListener != null){
197 | ColorPickerDialog.this.mListener.onColorCancel(ColorPickerDialog.this);
198 | }
199 | }
200 | });
201 | mAlertDialog.setView(view,0,0,0,0);
202 | }
203 |
204 | /**
205 | * 全局布局状态监听
206 | */
207 | private void initGlobalLayoutListener(final View view) {
208 | ViewTreeObserver vto = view.getViewTreeObserver();
209 | vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
210 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN)//api 16
211 | @Override
212 | public void onGlobalLayout() {
213 | moveHueCursor();
214 | movePlateCursor();
215 | if (ColorPickerDialog.this.mIsSupportAlpha) {
216 | moveAlphaCursor();
217 | updateAlphaView();
218 | }
219 | view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
220 |
221 | }
222 | });
223 | }
224 |
225 |
226 |
227 | /**
228 | * 移动色彩样板指针
229 | */
230 | private void moveHueCursor() {//ConstraintLayout$LayoutParams
231 | float y = mViewHue.getMeasuredHeight() - (getColorHue() * mViewHue.getMeasuredHeight() / 360.f);
232 | if (y == mViewHue.getMeasuredHeight()) y = 0.f;
233 | RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mHueCursor.getLayoutParams();
234 | layoutParams.leftMargin = (int) (mViewHue.getLeft() - Math.floor(mHueCursor.getMeasuredWidth() / 3) - mViewContainer.getPaddingLeft());
235 | layoutParams.topMargin = (int) (mViewHue.getTop() + y - Math.floor(mHueCursor.getMeasuredHeight() / 2) - mViewContainer.getPaddingTop());
236 | mHueCursor.setLayoutParams(layoutParams);
237 | }
238 |
239 | /**
240 | * 移动透明度板的指针
241 | */
242 | private void moveAlphaCursor(){
243 | final float y = mViewAlphaBottom.getMeasuredHeight() - (this.getAlpha() * mViewAlphaBottom.getMeasuredHeight() / 255.f);
244 | RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mAlphaCursor.getLayoutParams();
245 | layoutParams.leftMargin = (int) (mViewAlphaBottom.getLeft() - Math.floor(mAlphaCursor.getMeasuredWidth() /3) - mViewContainer.getPaddingLeft());
246 | layoutParams.topMargin = (int) (mViewAlphaBottom.getTop() + y - Math.floor(mAlphaCursor.getMeasuredHeight() / 2) - mViewContainer.getPaddingTop());
247 | mAlphaCursor.setLayoutParams(layoutParams);
248 | }
249 |
250 | /**
251 | * 移动最终颜色样板指针
252 | */
253 | private void movePlateCursor(){
254 | final float x = getColorSat() * mViewPlate.getMeasuredWidth();
255 | final float y = (1.f - getColorVal()) * mViewPlate.getMeasuredHeight();
256 | RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mPalteCursor.getLayoutParams();
257 | layoutParams.leftMargin = (int) (mViewPlate.getLeft() + x - Math.floor(mPalteCursor.getMeasuredWidth() / 2) - mViewContainer.getPaddingLeft());
258 | layoutParams.topMargin = (int) (mViewPlate.getTop() + y - Math.floor(mPalteCursor.getMeasuredHeight() / 2) - mViewContainer.getPaddingTop());
259 | mPalteCursor.setLayoutParams(layoutParams);
260 |
261 | }
262 |
263 | /**
264 | * 设置色彩
265 | * @param color
266 | */
267 | private void setColorHue(float color){
268 | mCurrentHSV[0] = color;
269 | }
270 |
271 | private float getColorHue(){
272 | return mCurrentHSV[0];
273 | }
274 |
275 | /**
276 | * 设置颜色深浅
277 | */
278 | private void setColorSat(float color) {
279 | this.mCurrentHSV[1] = color;
280 | }
281 |
282 | private float getColorSat(){
283 | return this.mCurrentHSV[1];
284 | }
285 |
286 | /**
287 | * 设置颜色明暗
288 | */
289 | private void setColorVal(float color){
290 | this.mCurrentHSV[2] = color;
291 | }
292 |
293 | private float getColorVal(){
294 | return mCurrentHSV[2];
295 | }
296 |
297 | /**
298 | * 获取int颜色
299 | */
300 | private int getColor(){
301 | final int argb = Color.HSVToColor(mCurrentHSV);
302 | return mAlpha << 24 | (argb & 0x00ffffff);
303 | }
304 |
305 | /**
306 | * 更新透明度UI
307 | */
308 | private void updateAlphaView(){
309 | final GradientDrawable gd = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM,new int[]{Color.HSVToColor(mCurrentHSV),0x0});
310 | mViewAlphaOverlay.setBackgroundDrawable(gd);
311 | }
312 |
313 | public void setButtonTextColor(int color){
314 | if (mAlertDialog != null) {
315 | Button btnPositive = mAlertDialog.getButton(android.app.AlertDialog.BUTTON_POSITIVE);
316 | Button btnNegative = mAlertDialog.getButton(android.app.AlertDialog.BUTTON_NEGATIVE);
317 | btnPositive.setTextColor(color);
318 | btnNegative.setTextColor(color);
319 | }
320 | }
321 |
322 | private void setAlpha(int alpha){
323 | this.mAlpha = alpha;
324 | }
325 |
326 | private int getAlpha(){
327 | return mAlpha;
328 | }
329 |
330 | public ColorPickerDialog show(){
331 | mAlertDialog.show();
332 | return ColorPickerDialog.this;
333 | }
334 |
335 | public AlertDialog getDialog(){
336 | return mAlertDialog;
337 | }
338 |
339 | }
340 |
--------------------------------------------------------------------------------
/colorpicker/src/main/java/com/dingmouren/colorpicker/ColorPlateView.java:
--------------------------------------------------------------------------------
1 | package com.dingmouren.colorpicker;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.content.Context;
5 | import android.graphics.Canvas;
6 | import android.graphics.Color;
7 | import android.graphics.ComposeShader;
8 | import android.graphics.LinearGradient;
9 | import android.graphics.Paint;
10 | import android.graphics.PorterDuff;
11 | import android.graphics.PorterDuffXfermode;
12 | import android.graphics.Shader;
13 | import android.os.Build;
14 | import android.util.AttributeSet;
15 | import android.util.Log;
16 | import android.view.View;
17 |
18 | /**
19 | * Created by dingmouren on 2017/5/4.
20 | */
21 |
22 | public class ColorPlateView extends View {
23 | private static final String TAG = ColorPlateView.class.getName();
24 | private Paint mPaint;
25 | private LinearGradient mShaderVertical;
26 | private final float[] HSV = {1.f,1.f,1.f};
27 |
28 | public ColorPlateView(Context context, AttributeSet attrs) {
29 | this(context, attrs,0);
30 | }
31 |
32 | public ColorPlateView(Context context, AttributeSet attrs, int defStyleAttr) {
33 | super(context, attrs, defStyleAttr);
34 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
35 | setLayerType(View.LAYER_TYPE_SOFTWARE, null);
36 | }
37 |
38 | }
39 | @SuppressLint("DrawAllocation")
40 | @Override
41 | protected void onDraw(Canvas canvas) {
42 | super.onDraw(canvas);
43 | if (mPaint == null){
44 | mPaint = new Paint();
45 | mShaderVertical = new LinearGradient(0.f,0.f,0.f,this.getMeasuredHeight(),0xffffffff,0xff000000, Shader.TileMode.CLAMP);//线性渐变
46 | }
47 | int rgb = Color.HSVToColor(HSV);
48 | LinearGradient shaderHorizontal = new LinearGradient(0.f,0.f,this.getMeasuredWidth(),0.f,0xffffffff,rgb,Shader.TileMode.CLAMP);
49 | ComposeShader composeShader = new ComposeShader(mShaderVertical,shaderHorizontal,PorterDuff.Mode.MULTIPLY );//混合渐变
50 | mPaint.setShader(composeShader);
51 | canvas.drawRect(0.f,0.f,this.getMeasuredWidth(),this.getMeasuredHeight(),mPaint);
52 | }
53 |
54 | /**
55 | * 设置色彩
56 | * @param hue
57 | */
58 | public void setHue(float hue){
59 | HSV[0] = hue;
60 | invalidate();
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/colorpicker/src/main/java/com/dingmouren/colorpicker/OnColorPickerListener.java:
--------------------------------------------------------------------------------
1 | package com.dingmouren.colorpicker;
2 |
3 | /**
4 | * Created by dingmouren on 2017/5/5.
5 | */
6 |
7 | public interface OnColorPickerListener {
8 | void onColorCancel(ColorPickerDialog dialog);
9 | void onColorChange(ColorPickerDialog dialog,int color);
10 | void onColorConfirm(ColorPickerDialog dialog,int color);
11 | }
12 |
--------------------------------------------------------------------------------
/colorpicker/src/main/res/drawable-mdpi/alpha_bottom.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DingMouRen/ColorPicker/4de1019e1316cc303871f0cfa72f4f2bad27285d/colorpicker/src/main/res/drawable-mdpi/alpha_bottom.png
--------------------------------------------------------------------------------
/colorpicker/src/main/res/drawable-mdpi/hue_list.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DingMouRen/ColorPicker/4de1019e1316cc303871f0cfa72f4f2bad27285d/colorpicker/src/main/res/drawable-mdpi/hue_list.png
--------------------------------------------------------------------------------
/colorpicker/src/main/res/drawable/alpha_bottom_drawable.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/colorpicker/src/main/res/drawable/color_arrow.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/colorpicker/src/main/res/drawable/cursor.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/colorpicker/src/main/res/drawable/img_plate_cursor.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/colorpicker/src/main/res/layout/color_picker_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
21 |
22 |
31 |
32 |
33 |
40 |
41 |
47 |
48 |
55 |
56 |
64 |
65 |
72 |
73 |
81 |
82 |
90 |
91 |
92 |
98 |
99 |
105 |
106 |
107 |
113 |
114 |
120 |
121 |
--------------------------------------------------------------------------------
/colorpicker/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/colorpicker/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 240dp
6 | 240dp
7 | 30dp
8 | 60dp
9 | 30dp
10 | 10dp
11 | 20dp
12 |
13 |
14 |
--------------------------------------------------------------------------------
/colorpicker/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ColorPicker
3 | Please Select Color
4 | 确定
5 | 取消
6 |
7 |
--------------------------------------------------------------------------------
/colorpicker/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DingMouRen/ColorPicker/4de1019e1316cc303871f0cfa72f4f2bad27285d/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/imgs/img.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DingMouRen/ColorPicker/4de1019e1316cc303871f0cfa72f4f2bad27285d/imgs/img.gif
--------------------------------------------------------------------------------
/imgs/imgbanner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DingMouRen/ColorPicker/4de1019e1316cc303871f0cfa72f4f2bad27285d/imgs/imgbanner.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':colorpicker'
2 |
--------------------------------------------------------------------------------