├── example ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── drawable-hdpi │ │ │ │ ├── ic_info_black_24dp.png │ │ │ │ ├── ic_sync_black_24dp.png │ │ │ │ └── ic_notifications_black_24dp.png │ │ │ ├── drawable-mdpi │ │ │ │ ├── ic_info_black_24dp.png │ │ │ │ ├── ic_sync_black_24dp.png │ │ │ │ └── ic_notifications_black_24dp.png │ │ │ ├── drawable-xhdpi │ │ │ │ ├── ic_info_black_24dp.png │ │ │ │ ├── ic_sync_black_24dp.png │ │ │ │ └── ic_notifications_black_24dp.png │ │ │ ├── drawable-xxhdpi │ │ │ │ ├── ic_info_black_24dp.png │ │ │ │ ├── ic_sync_black_24dp.png │ │ │ │ └── ic_notifications_black_24dp.png │ │ │ ├── drawable-xxxhdpi │ │ │ │ ├── ic_info_black_24dp.png │ │ │ │ ├── ic_sync_black_24dp.png │ │ │ │ └── ic_notifications_black_24dp.png │ │ │ ├── values │ │ │ │ ├── dimens.xml │ │ │ │ ├── styles.xml │ │ │ │ ├── strings.xml │ │ │ │ └── colors.xml │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ ├── xml │ │ │ │ ├── pref_headers.xml │ │ │ │ └── pref_general.xml │ │ │ ├── drawable-v21 │ │ │ │ ├── ic_info_black_24dp.xml │ │ │ │ ├── ic_notifications_black_24dp.xml │ │ │ │ └── ic_sync_black_24dp.xml │ │ │ └── layout │ │ │ │ └── activity_main.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── org │ │ │ └── xdty │ │ │ └── colorpicker │ │ │ ├── SettingsActivity.java │ │ │ └── MainActivity.java │ ├── test │ │ └── java │ │ │ └── org │ │ │ └── xdty │ │ │ └── colorpicker │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── org │ │ └── xdty │ │ └── colorpicker │ │ └── ApplicationTest.java ├── proguard-rules.pro └── build.gradle ├── color-picker ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── drawable-hdpi │ │ │ │ └── ic_colorpicker_swatch_selected.png │ │ │ ├── drawable-mdpi │ │ │ │ └── ic_colorpicker_swatch_selected.png │ │ │ ├── drawable-xhdpi │ │ │ │ └── ic_colorpicker_swatch_selected.png │ │ │ ├── values │ │ │ │ ├── attrs.xml │ │ │ │ ├── dimens.xml │ │ │ │ ├── arrays.xml │ │ │ │ ├── colors.xml │ │ │ │ └── strings.xml │ │ │ ├── drawable │ │ │ │ └── color_picker_swatch.xml │ │ │ ├── values-ja │ │ │ │ └── strings.xml │ │ │ ├── values-ko │ │ │ │ └── strings.xml │ │ │ ├── values-th │ │ │ │ └── strings.xml │ │ │ ├── values-zh-rHK │ │ │ │ └── strings.xml │ │ │ ├── values-zh-rTW │ │ │ │ └── strings.xml │ │ │ ├── values-am │ │ │ │ └── strings.xml │ │ │ ├── values-iw │ │ │ │ └── strings.xml │ │ │ ├── values-vi │ │ │ │ └── strings.xml │ │ │ ├── values-fa │ │ │ │ └── strings.xml │ │ │ ├── values-hi │ │ │ │ └── strings.xml │ │ │ ├── values-lo-rLA │ │ │ │ └── strings.xml │ │ │ ├── values-sv │ │ │ │ └── strings.xml │ │ │ ├── values-af │ │ │ │ └── strings.xml │ │ │ ├── values-ar │ │ │ │ └── strings.xml │ │ │ ├── values-da │ │ │ │ └── strings.xml │ │ │ ├── values-eu-rES │ │ │ │ └── strings.xml │ │ │ ├── values-fi │ │ │ │ └── strings.xml │ │ │ ├── values-hr │ │ │ │ └── strings.xml │ │ │ ├── values-in │ │ │ │ └── strings.xml │ │ │ ├── values-km-rKH │ │ │ │ └── strings.xml │ │ │ ├── values-ky-rKG │ │ │ │ └── strings.xml │ │ │ ├── values-mr-rIN │ │ │ │ └── strings.xml │ │ │ ├── values-nb │ │ │ │ └── strings.xml │ │ │ ├── values-pa-rIN │ │ │ │ └── strings.xml │ │ │ ├── values-pl │ │ │ │ └── strings.xml │ │ │ ├── values-ru │ │ │ │ └── strings.xml │ │ │ ├── values-tr │ │ │ │ └── strings.xml │ │ │ ├── values-uk │ │ │ │ └── strings.xml │ │ │ ├── values-bg │ │ │ │ └── strings.xml │ │ │ ├── values-cs │ │ │ │ └── strings.xml │ │ │ ├── values-de │ │ │ │ └── strings.xml │ │ │ ├── values-et-rEE │ │ │ │ └── strings.xml │ │ │ ├── values-gu-rIN │ │ │ │ └── strings.xml │ │ │ ├── values-hu │ │ │ │ └── strings.xml │ │ │ ├── values-is-rIS │ │ │ │ └── strings.xml │ │ │ ├── values-ka-rGE │ │ │ │ └── strings.xml │ │ │ ├── values-kk-rKZ │ │ │ │ └── strings.xml │ │ │ ├── values-mk-rMK │ │ │ │ └── strings.xml │ │ │ ├── values-ms-rMY │ │ │ │ └── strings.xml │ │ │ ├── values-pt │ │ │ │ └── strings.xml │ │ │ ├── values-sk │ │ │ │ └── strings.xml │ │ │ ├── values-sl │ │ │ │ └── strings.xml │ │ │ ├── values-sr │ │ │ │ └── strings.xml │ │ │ ├── values-sw │ │ │ │ └── strings.xml │ │ │ ├── values-uz-rUZ │ │ │ │ └── strings.xml │ │ │ ├── values-el │ │ │ │ └── strings.xml │ │ │ ├── values-en-rAU │ │ │ │ └── strings.xml │ │ │ ├── values-en-rGB │ │ │ │ └── strings.xml │ │ │ ├── values-en-rIN │ │ │ │ └── strings.xml │ │ │ ├── values-es │ │ │ │ └── strings.xml │ │ │ ├── values-hy-rAM │ │ │ │ └── strings.xml │ │ │ ├── values-lt │ │ │ │ └── strings.xml │ │ │ ├── values-lv │ │ │ │ └── strings.xml │ │ │ ├── values-mn-rMN │ │ │ │ └── strings.xml │ │ │ ├── values-pt-rPT │ │ │ │ └── strings.xml │ │ │ ├── values-si-rLK │ │ │ │ └── strings.xml │ │ │ ├── values-sq-rAL │ │ │ │ └── strings.xml │ │ │ ├── values-te-rIN │ │ │ │ └── strings.xml │ │ │ ├── values-tl │ │ │ │ └── strings.xml │ │ │ ├── values-ur-rPK │ │ │ │ └── strings.xml │ │ │ ├── values-zu │ │ │ │ └── strings.xml │ │ │ ├── values-es-rUS │ │ │ │ └── strings.xml │ │ │ ├── values-gl-rES │ │ │ │ └── strings.xml │ │ │ ├── values-it │ │ │ │ └── strings.xml │ │ │ ├── values-kn-rIN │ │ │ │ └── strings.xml │ │ │ ├── values-my-rMM │ │ │ │ └── strings.xml │ │ │ ├── values-ne-rNP │ │ │ │ └── strings.xml │ │ │ ├── values-nl │ │ │ │ └── strings.xml │ │ │ ├── values-bn-rBD │ │ │ │ └── strings.xml │ │ │ ├── values-ca │ │ │ │ └── strings.xml │ │ │ ├── values-fr │ │ │ │ └── strings.xml │ │ │ ├── values-ro │ │ │ │ └── strings.xml │ │ │ ├── values-fr-rCA │ │ │ │ └── strings.xml │ │ │ ├── values-ml-rIN │ │ │ │ └── strings.xml │ │ │ ├── layout │ │ │ │ ├── color_picker_swatch.xml │ │ │ │ └── color_picker_dialog.xml │ │ │ ├── values-ta-rIN │ │ │ │ └── strings.xml │ │ │ └── values-zh-rCN │ │ │ │ └── strings.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── org │ │ │ └── xdty │ │ │ └── preference │ │ │ ├── ColorCircleDrawable.java │ │ │ ├── colorpicker │ │ │ ├── HsvColorComparator.java │ │ │ ├── ColorStateDrawable.java │ │ │ ├── ColorPickerSwatch.java │ │ │ ├── ColorPickerPalette.java │ │ │ └── ColorPickerDialog.java │ │ │ └── ColorPreference.java │ ├── test │ │ └── java │ │ │ └── org │ │ │ └── xdty │ │ │ └── preference │ │ │ └── colorpicker │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── org │ │ └── xdty │ │ └── preference │ │ └── colorpicker │ │ └── ApplicationTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .travis.yml ├── .gitignore ├── gradle.properties ├── README.md ├── gradlew.bat ├── gradlew └── LICENSE /example/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /color-picker/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':example', ':color-picker' 2 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdtianyu/ColorPicker/master/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /example/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdtianyu/ColorPicker/master/example/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdtianyu/ColorPicker/master/example/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdtianyu/ColorPicker/master/example/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdtianyu/ColorPicker/master/example/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdtianyu/ColorPicker/master/example/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-hdpi/ic_info_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdtianyu/ColorPicker/master/example/src/main/res/drawable-hdpi/ic_info_black_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-hdpi/ic_sync_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdtianyu/ColorPicker/master/example/src/main/res/drawable-hdpi/ic_sync_black_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-mdpi/ic_info_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdtianyu/ColorPicker/master/example/src/main/res/drawable-mdpi/ic_info_black_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-mdpi/ic_sync_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdtianyu/ColorPicker/master/example/src/main/res/drawable-mdpi/ic_sync_black_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xhdpi/ic_info_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdtianyu/ColorPicker/master/example/src/main/res/drawable-xhdpi/ic_info_black_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xhdpi/ic_sync_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdtianyu/ColorPicker/master/example/src/main/res/drawable-xhdpi/ic_sync_black_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxhdpi/ic_info_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdtianyu/ColorPicker/master/example/src/main/res/drawable-xxhdpi/ic_info_black_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxhdpi/ic_sync_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdtianyu/ColorPicker/master/example/src/main/res/drawable-xxhdpi/ic_sync_black_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxxhdpi/ic_info_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdtianyu/ColorPicker/master/example/src/main/res/drawable-xxxhdpi/ic_info_black_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxxhdpi/ic_sync_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdtianyu/ColorPicker/master/example/src/main/res/drawable-xxxhdpi/ic_sync_black_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-hdpi/ic_notifications_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdtianyu/ColorPicker/master/example/src/main/res/drawable-hdpi/ic_notifications_black_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-mdpi/ic_notifications_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdtianyu/ColorPicker/master/example/src/main/res/drawable-mdpi/ic_notifications_black_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xhdpi/ic_notifications_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdtianyu/ColorPicker/master/example/src/main/res/drawable-xhdpi/ic_notifications_black_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxhdpi/ic_notifications_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdtianyu/ColorPicker/master/example/src/main/res/drawable-xxhdpi/ic_notifications_black_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxxhdpi/ic_notifications_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdtianyu/ColorPicker/master/example/src/main/res/drawable-xxxhdpi/ic_notifications_black_24dp.png -------------------------------------------------------------------------------- /color-picker/src/main/res/drawable-hdpi/ic_colorpicker_swatch_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdtianyu/ColorPicker/master/color-picker/src/main/res/drawable-hdpi/ic_colorpicker_swatch_selected.png -------------------------------------------------------------------------------- /color-picker/src/main/res/drawable-mdpi/ic_colorpicker_swatch_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdtianyu/ColorPicker/master/color-picker/src/main/res/drawable-mdpi/ic_colorpicker_swatch_selected.png -------------------------------------------------------------------------------- /color-picker/src/main/res/drawable-xhdpi/ic_colorpicker_swatch_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdtianyu/ColorPicker/master/color-picker/src/main/res/drawable-xhdpi/ic_colorpicker_swatch_selected.png -------------------------------------------------------------------------------- /example/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Mar 24 21:10:02 CST 2017 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-3.3-all.zip 7 | -------------------------------------------------------------------------------- /color-picker/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | 3 | android: 4 | components: 5 | - tools 6 | - platform-tools 7 | - android-25 8 | - build-tools-25.0.0 9 | - extra 10 | 11 | jdk: oraclejdk8 12 | 13 | notifications: 14 | email: false 15 | 16 | before_install: 17 | - touch local.properties 18 | 19 | script: 20 | - ./gradlew install 21 | -------------------------------------------------------------------------------- /example/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /example/src/test/java/org/xdty/colorpicker/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package org.xdty.colorpicker; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /example/src/main/res/xml/pref_headers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
9 | 10 | 11 | -------------------------------------------------------------------------------- /color-picker/src/test/java/org/xdty/preference/colorpicker/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package org.xdty.preference.colorpicker; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /example/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /example/src/androidTest/java/org/xdty/colorpicker/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package org.xdty.colorpicker; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /example/src/main/res/drawable-v21/ic_info_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /color-picker/src/androidTest/java/org/xdty/preference/colorpicker/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package org.xdty.preference.colorpicker; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /example/src/main/res/drawable-v21/ic_notifications_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /example/src/main/res/drawable-v21/ic_sync_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | -------------------------------------------------------------------------------- /example/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ColorPicker 3 | Settings 4 | 5 | 6 | 7 | 8 | General 9 | 10 | Enable social recommendations 11 | Recommendations for people to contact 12 | based on your message history 13 | 14 | 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # files for the dex VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # generated files 12 | bin/ 13 | gen/ 14 | 15 | # Local configuration file (sdk path, etc) 16 | local.properties 17 | 18 | # Windows thumbnail db 19 | Thumbs.db 20 | 21 | # OSX files 22 | .DS_Store 23 | 24 | # Eclipse project files 25 | .classpath 26 | .project 27 | 28 | # Android Studio 29 | *.iml 30 | .idea 31 | #.idea/workspace.xml - remove # and delete .idea if it better suit your needs. 32 | .gradle 33 | build/ 34 | 35 | #NDK 36 | obj/ 37 | 38 | /*/out 39 | /*/*/build 40 | /*/*/production 41 | *.iws 42 | *.ipr 43 | *~ 44 | *.swp -------------------------------------------------------------------------------- /example/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 /home/ty/Android/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 | -------------------------------------------------------------------------------- /color-picker/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 /home/ty/Android/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 | -------------------------------------------------------------------------------- /example/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 18 | 19 | -------------------------------------------------------------------------------- /color-picker/src/main/res/drawable/color_picker_swatch.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | -------------------------------------------------------------------------------- /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 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /example/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /example/src/main/res/xml/pref_general.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 9 | 21 | 22 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 64dip 18 | 48dip 19 | 8dip 20 | 4dip 21 | -------------------------------------------------------------------------------- /example/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion rootProject.ext.compileSdkVersion 5 | buildToolsVersion rootProject.ext.buildToolsVersion 6 | 7 | defaultConfig { 8 | applicationId "org.xdty.colorpicker" 9 | minSdkVersion rootProject.ext.minSdkVersion 10 | targetSdkVersion rootProject.ext.targetSdkVersion 11 | versionCode 1 12 | versionName "1.0" 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(dir: 'libs', include: ['*.jar']) 24 | testCompile 'junit:junit:4.12' 25 | compile "com.android.support:appcompat-v7:${rootProject.ext.supportVersion}" 26 | compile "com.android.support:support-v4:${rootProject.ext.supportVersion}" 27 | // compile 'org.xdty.preference:color-picker:0.0.4' 28 | compile project(':color-picker') 29 | } 30 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values/arrays.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | @color/tomato 5 | @color/tangerine 6 | @color/banana 7 | @color/basil 8 | @color/sage 9 | @color/peacock 10 | @color/blueberry 11 | @color/lavender 12 | @color/grape 13 | @color/flamingo 14 | @color/graphite 15 | 16 | 17 | @string/tomato 18 | @string/tangerine 19 | @string/banana 20 | @string/basil 21 | @string/sage 22 | @string/peacock 23 | @string/blueberry 24 | @string/lavender 25 | @string/grape 26 | @string/flamingo 27 | @string/graphite 28 | 29 | -------------------------------------------------------------------------------- /example/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | #FF007F 8 | #FF0000 9 | #FF7F00 10 | #FFFF00 11 | #00FF00 12 | #00FFFF 13 | #007FFF 14 | #0000FF 15 | #7F00FF 16 | #FF00FF 17 | 18 | 19 | @color/bright_pink 20 | @color/red 21 | @color/orange 22 | @color/yellow 23 | @color/green 24 | @color/cyan 25 | @color/azure 26 | @color/blue 27 | @color/violet 28 | @color/magenta 29 | 30 | 31 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #33b5e5 5 | #ff8800 6 | #ff4444 7 | 8 | #FF007F 9 | #FF0000 10 | #FF7F00 11 | #FFFF00 12 | #00FF00 13 | #00FFFF 14 | #007FFF 15 | #0000FF 16 | #7F00FF 17 | #FF00FF 18 | 19 | #d50000 20 | #f4511e 21 | #f6bf26 22 | #0b8043 23 | #33b679 24 | #039be5 25 | #3f51b5 26 | #7986cb 27 | #8e24aa 28 | #e67c73 29 | #616161 30 | -------------------------------------------------------------------------------- /example/src/main/java/org/xdty/colorpicker/SettingsActivity.java: -------------------------------------------------------------------------------- 1 | package org.xdty.colorpicker; 2 | 3 | import android.os.Bundle; 4 | import android.preference.PreferenceActivity; 5 | import android.preference.PreferenceFragment; 6 | 7 | import java.util.List; 8 | 9 | 10 | public class SettingsActivity extends PreferenceActivity { 11 | 12 | @Override 13 | protected void onCreate(Bundle savedInstanceState) { 14 | super.onCreate(savedInstanceState); 15 | } 16 | 17 | protected boolean isValidFragment(String fragmentName) { 18 | return PreferenceFragment.class.getName().equals(fragmentName) 19 | || GeneralPreferenceFragment.class.getName().equals(fragmentName); 20 | } 21 | 22 | @Override 23 | public void onBuildHeaders(List
target) { 24 | loadHeadersFromResource(R.xml.pref_headers, target); 25 | } 26 | 27 | public static class GeneralPreferenceFragment extends PreferenceFragment { 28 | @Override 29 | public void onCreate(Bundle savedInstanceState) { 30 | super.onCreate(savedInstanceState); 31 | addPreferencesFromResource(R.xml.pref_general); 32 | setHasOptionsMenu(true); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-ja/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "色の選択" 20 | "色%1$d" 21 | "色%1$dを選択しました" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-ko/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "색상 선택" 20 | "색상 %1$d" 21 | "색상 %1$d이(가) 선택됨" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-th/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "เลือกสี" 20 | "สี %1$d" 21 | "เลือกสี %1$d" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-zh-rHK/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "選取顏色" 20 | "顏色 %1$d" 21 | "已選取顏色 %1$d" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-zh-rTW/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "選取顏色" 20 | "色彩 %1$d" 21 | "已選取色彩 %1$d" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-am/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "ቀለም ምረጥ" 20 | "ቀለም %1$d" 21 | "ቀለም %1$d ተመርጧል" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-iw/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "בחר צבע" 20 | "צבע %1$d" 21 | "צבע %1$d נבחר" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-vi/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Chọn màu" 20 | "Màu %1$d" 21 | "Đã chọn màu %1$d" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-fa/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "انتخاب رنگ" 20 | "رنگ %1$d" 21 | "رنگ %1$d انتخاب شد" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-hi/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "कोई रंग चुनें:" 20 | "रंग %1$d" 21 | "रंग %1$d चयनित" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-lo-rLA/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "ເລືອກ​ສີ​" 20 | "ສີ %1$d" 21 | "​ເລືອກສີ %1$d" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-sv/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Välj en färg" 20 | "Färg %1$d" 21 | "Färg %1$d vald" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-af/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Kies \'n kleur" 20 | "Kleur %1$d" 21 | "Kleur %1$d gekies" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-ar/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "تحديد لون:" 20 | "اللون %1$d" 21 | "تم تحديد اللون %1$d" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-da/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Vælg en farve" 20 | "Farve %1$d" 21 | "Farve %1$d valgt" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-eu-rES/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Hautatu kolorea" 20 | "%1$d" 21 | "%1$d hautatu da" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-fi/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Valitse väri" 20 | "Väri %1$d" 21 | "Väri %1$d on valittu" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-hr/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Odabir boje" 20 | "Boja %1$d" 21 | "Odabrana je boja %1$d" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-in/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Pilih warna:" 20 | "Warna %1$d" 21 | "Warna %1$d dipilih" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-km-rKH/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "ជ្រើស​ពណ៌" 20 | "ពណ៌ %1$d" 21 | "បាន​ជ្រើស​ពណ៌ %1$d" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-ky-rKG/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Түс тандаңыз" 20 | "Түс %1$d" 21 | "%1$d түс тандалды" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-mr-rIN/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "एक रंग निवडा" 20 | "रंग %1$d" 21 | "%1$d रंग निवडला" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-nb/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Velg en farge" 20 | "Farge %1$d" 21 | "Farge %1$d er valgt" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-pa-rIN/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "ਇੱਕ ਰੰਗ ਚੁਣੋ" 20 | "ਰੰਗ %1$d" 21 | "ਰੰਗ %1$d ਚੁਣਿਆ ਗਿਆ" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-pl/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Wybierz kolor" 20 | "Kolor %1$d" 21 | "Wybrałeś kolor %1$d" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-ru/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Выберите цвет" 20 | "Цвет: %1$d" 21 | "Выбран цвет %1$d" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-tr/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Bir Renk Seçin" 20 | "Renk %1$d" 21 | "Renk %1$d seçildi" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-uk/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Вибрати колір" 20 | "Колір %1$d" 21 | "Вибрано колір: %1$d" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-bg/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Избиране на цвят" 20 | "Цвят %1$d" 21 | "Избрахте цвят %1$d" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-cs/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Vyberte barvu" 20 | "Barva %1$d" 21 | "Barva %1$d je vybrána" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-de/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Farbe auswählen:" 20 | "Farbe %1$d" 21 | "Farbe %1$d ausgewählt" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-et-rEE/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Valige värv" 20 | "Värv %1$d" 21 | "Valitud on värv %1$d" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-gu-rIN/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "એક રંગ પસંદ કરો" 20 | "રંગ %1$d" 21 | "રંગ %1$d પસંદ કર્યો" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-hu/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Válasszon színt" 20 | "%1$d. szín" 21 | "%1$d. szín kiválasztva" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-is-rIS/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Veldu lit" 20 | "Litur %1$d" 21 | "Liturinn %1$d valinn" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-ka-rGE/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "ფერის არჩევა" 20 | "ფერი %1$d" 21 | "არჩეულია ფერი %1$d" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-kk-rKZ/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Түсті таңдаңыз" 20 | "%1$d түсі" 21 | "%1$d түсі таңдалды" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-mk-rMK/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Изберете боја" 20 | "Боја %1$d" 21 | "Избрана е %1$d боја" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-ms-rMY/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Pilih Warna" 20 | "Warna %1$d" 21 | "Warna %1$d dipilih" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-pt/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Selecione uma cor" 20 | "Cor %1$d" 21 | "Cor %1$d selecionada" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-sk/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Vyberte farbu" 20 | "Farba %1$d" 21 | "Bola vybratá farba %1$d" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-sl/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Izberite barvo:" 20 | "Barva %1$d" 21 | "Izbrana je barva %1$d" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-sr/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Изаберите боју" 20 | "Боја %1$d" 21 | "Боја %1$d је изабрана" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-sw/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Chagua Rangi" 20 | "Rangi %1$d" 21 | "Rangi %1$d iliyochaguliwa" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-uz-rUZ/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Rang tanlash" 20 | "%1$d rangi" 21 | "%1$d rangi tanlandi" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-el/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Επιλέξτε χρώμα" 20 | "Χρώμα %1$d" 21 | "Επιλέχτηκε το χρώμα %1$d" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-en-rAU/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Select a Colour" 20 | "Colour %1$d" 21 | "Colour %1$d selected" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-en-rGB/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Select a Colour" 20 | "Colour %1$d" 21 | "Colour %1$d selected" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-en-rIN/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Select a Colour" 20 | "Colour %1$d" 21 | "Colour %1$d selected" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-es/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Selecciona un color" 20 | "Color %1$d" 21 | "Color %1$d seleccionado" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-hy-rAM/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Ընտրեք գույնը" 20 | "Գույնը %1$d" 21 | "Ընտրվել է %1$d գույնը" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-lt/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Pasirinkite spalvą" 20 | "%1$d spalva" 21 | "%1$d spalva pasirinkta" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-lv/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Krāsas atlase" 20 | "Krāsa Nr. %1$d" 21 | "Atlasīta krāsa Nr. %1$d" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-mn-rMN/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Өнгө сонгоно уу" 20 | "Өнгө %1$d" 21 | "Өнгө %1$d сонгогдсон" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-pt-rPT/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Selecionar uma Cor" 20 | "Cor %1$d" 21 | "Cor %1$d selecionada" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-si-rLK/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "වර්ණයක් තෝරන්න" 20 | "වර්ණය %1$d" 21 | "%1$d වර්ණය තෝරාගන්නා ලදී" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-sq-rAL/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Zgjidh një ngjyrë" 20 | "Ngjyra %1$d" 21 | "U zgjodh ngjyra %1$d" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-te-rIN/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "రంగును ఎంచుకోండి" 20 | "రంగు %1$d" 21 | "రంగు %1$d ఎంచుకోబడింది" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-tl/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Pumili ng Kulay" 20 | "Kulay na %1$d" 21 | "Napili ang kulay na %1$d" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-ur-rPK/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "ایک رنگ منتخب کریں" 20 | "رنگ %1$d" 21 | "رنگ %1$d منتخب کیا گیا" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-zu/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Khetha umbala" 20 | "Umbala we-%1$d" 21 | "Umbala we-%1$d ukhethiwe" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-es-rUS/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Seleccionar un color" 20 | "Color %1$d" 21 | "Color %1$d seleccionado" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-gl-rES/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Selecciona unha cor" 20 | "Cor %1$d" 21 | "Seleccionouse a cor %1$d" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-it/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Seleziona un colore" 20 | "Colore %1$d" 21 | "Colore selezionato: %1$d" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-kn-rIN/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "ಬಣ್ಣ ಆಯ್ಕೆಮಾಡಿ" 20 | "ಬಣ್ಣ %1$d" 21 | "%1$d ಬಣ್ಣವನ್ನು ಆಯ್ಕೆ ಮಾಡಲಾಗಿದೆ" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-my-rMM/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "အရောင်ကို ရွေးပါ" 20 | "အရောင် %1$d" 21 | "အရောင်ကို %1$d ရွေးပြီး" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-ne-rNP/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "एउटा रङ्ग चयन गर्नहोस्" 20 | "रङ्ग %1$d" 21 | "%1$d रङ्ग चयन गरियो" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-nl/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Een kleur selecteren" 20 | "Kleur %1$d" 21 | "Kleur %1$d geselecteerd" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-bn-rBD/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "একটি রঙ নির্বাচন করুন" 20 | "রঙ %1$d" 21 | "%1$d রঙ নির্বাচন করা হয়েছে" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-ca/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Selecciona un color" 20 | "Color %1$d" 21 | "S\'ha seleccionat el color %1$d" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-fr/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Sélectionner une couleur" 20 | "Couleur %1$d" 21 | "Couleur %1$d sélectionnée" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-ro/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Selectați o culoare" 20 | "Culoarea %1$d" 21 | "Culoarea %1$d este selectată" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-fr-rCA/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "Sélectionnez une couleur" 20 | "Couleur %1$d" 21 | "Couleur %1$d sélectionnée" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-ml-rIN/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "ഒരു വർണ്ണം തിരഞ്ഞെടുക്കുക" 20 | "വർണ്ണം %1$d" 21 | "വർണ്ണം %1$d തിരഞ്ഞെടുത്തു" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/res/layout/color_picker_swatch.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 21 | 28 | -------------------------------------------------------------------------------- /color-picker/src/main/res/values-ta-rIN/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "வண்ணத்தைத் தேர்ந்தெடுக்கவும்" 20 | "வண்ணம் %1$d" 21 | "வண்ணம் %1$d தேர்ந்தெடுக்கப்பட்டது" 22 | 23 | -------------------------------------------------------------------------------- /color-picker/src/main/java/org/xdty/preference/ColorCircleDrawable.java: -------------------------------------------------------------------------------- 1 | package org.xdty.preference; 2 | 3 | import android.graphics.Canvas; 4 | import android.graphics.ColorFilter; 5 | import android.graphics.Paint; 6 | import android.graphics.PixelFormat; 7 | import android.graphics.Rect; 8 | import android.graphics.drawable.Drawable; 9 | 10 | public class ColorCircleDrawable extends Drawable { 11 | private final Paint mPaint; 12 | private int mRadius = 0; 13 | 14 | public ColorCircleDrawable(final int color) { 15 | this.mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); 16 | this.mPaint.setColor(color); 17 | } 18 | 19 | @Override 20 | public void draw(final Canvas canvas) { 21 | final Rect bounds = getBounds(); 22 | canvas.drawCircle(bounds.centerX(), bounds.centerY(), mRadius, mPaint); 23 | } 24 | 25 | @Override 26 | protected void onBoundsChange(final Rect bounds) { 27 | super.onBoundsChange(bounds); 28 | mRadius = Math.min(bounds.width(), bounds.height()) / 2; 29 | } 30 | 31 | @Override 32 | public void setAlpha(final int alpha) { 33 | mPaint.setAlpha(alpha); 34 | } 35 | 36 | @Override 37 | public void setColorFilter(final ColorFilter cf) { 38 | mPaint.setColorFilter(cf); 39 | } 40 | 41 | @Override 42 | public int getOpacity() { 43 | return PixelFormat.TRANSLUCENT; 44 | } 45 | } -------------------------------------------------------------------------------- /color-picker/src/main/res/values-zh-rCN/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | "选择颜色" 20 | "颜色 %1$d" 21 | "已选择颜色 %1$d" 22 | 23 | 番茄红 24 | 橘红 25 | 香蕉黄 26 | 罗勒绿 27 | 鼠尾草绿 28 | 孔雀蓝 29 | 蓝莓色 30 | 薰衣草色 31 | 葡萄紫 32 | 红鹤色 33 | 石墨黑 34 | 默认颜色 35 | 36 | -------------------------------------------------------------------------------- /color-picker/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | ext { 4 | bintrayRepo = 'maven' 5 | bintrayName = 'color-picker' 6 | 7 | publishedGroupId = 'org.xdty.preference' 8 | libraryName = 'ColorPicker' 9 | artifact = 'color-picker' 10 | 11 | libraryDescription = 'An easy to use android color picker library.' 12 | 13 | siteUrl = 'https://github.com/xdtianyu/ColorPicker' 14 | gitUrl = 'https://github.com/xdtianyu/ColorPicker' 15 | 16 | libraryVersionCode = 5 17 | libraryVersion = '0.0.5' 18 | 19 | developerId = 'xdtianyu' 20 | developerName = 'xdtianyu' 21 | developerEmail = 'xdtianyu@gmail.com' 22 | 23 | licenseName = 'The Apache Software License, Version 2.0' 24 | licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' 25 | allLicenses = ["Apache-2.0"] 26 | } 27 | 28 | android { 29 | compileSdkVersion rootProject.ext.compileSdkVersion 30 | buildToolsVersion rootProject.ext.buildToolsVersion 31 | 32 | defaultConfig { 33 | minSdkVersion rootProject.ext.minSdkVersion 34 | targetSdkVersion rootProject.ext.targetSdkVersion 35 | versionCode = libraryVersionCode 36 | versionName = libraryVersion 37 | } 38 | buildTypes { 39 | release { 40 | minifyEnabled false 41 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 42 | } 43 | } 44 | } 45 | 46 | dependencies { 47 | compile fileTree(dir: 'libs', include: ['*.jar']) 48 | testCompile 'junit:junit:4.12' 49 | compile "com.android.support:appcompat-v7:${rootProject.ext.supportVersion}" 50 | } 51 | 52 | apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle' 53 | apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle' -------------------------------------------------------------------------------- /color-picker/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 18 | Select a Color 19 | 20 | Color %1$d 21 | 22 | Color %1$d selected 23 | 24 | Tomato 25 | Tangerine 26 | Banana 27 | Basil 28 | Sage 29 | Peacock 30 | Blueberry 31 | Lavender 32 | Grape 33 | Flamingo 34 | Graphite 35 | Default color 36 | -------------------------------------------------------------------------------- /color-picker/src/main/res/layout/color_picker_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 21 | 22 | 28 | 29 | 36 | 37 | 44 | 45 | -------------------------------------------------------------------------------- /example/src/main/java/org/xdty/colorpicker/MainActivity.java: -------------------------------------------------------------------------------- 1 | package org.xdty.colorpicker; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.v4.content.ContextCompat; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.widget.TextView; 8 | 9 | import org.xdty.preference.colorpicker.ColorPickerDialog; 10 | import org.xdty.preference.colorpicker.ColorPickerSwatch; 11 | 12 | public class MainActivity extends AppCompatActivity { 13 | 14 | private int mSelectedColor; 15 | 16 | TextView textView; 17 | 18 | @Override 19 | protected void onCreate(Bundle savedInstanceState) { 20 | super.onCreate(savedInstanceState); 21 | setContentView(R.layout.activity_main); 22 | 23 | mSelectedColor = ContextCompat.getColor(this, R.color.flamingo); 24 | 25 | textView = (TextView) findViewById(R.id.text); 26 | 27 | int[] mColors = getResources().getIntArray(R.array.default_rainbow); 28 | 29 | ColorPickerDialog dialog = ColorPickerDialog.newInstance(R.string.color_picker_default_title, 30 | mColors, 31 | mSelectedColor, 32 | 5, // Number of columns 33 | ColorPickerDialog.SIZE_SMALL, 34 | true // True or False to enable or disable the serpentine effect 35 | //0, // stroke width 36 | //Color.BLACK // stroke color 37 | ); 38 | 39 | dialog.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener() { 40 | 41 | @Override 42 | public void onColorSelected(int color) { 43 | mSelectedColor = color; 44 | textView.setTextColor(mSelectedColor); 45 | Intent intent = new Intent(MainActivity.this, SettingsActivity.class); 46 | startActivity(intent); 47 | } 48 | 49 | }); 50 | 51 | dialog.show(getFragmentManager(), "color_dialog_test"); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ColorPicker 2 | An easy to use android color picker library. Based on [android-colorpicker](https://github.com/woalk/android-colorpicker). 3 | 4 | [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-ColorPicker-brightgreen.svg?style=flat)](http://android-arsenal.com/details/1/3324) 5 | [![Build Status](https://travis-ci.org/xdtianyu/ColorPicker.svg?branch=master)](https://travis-ci.org/xdtianyu/ColorPicker) 6 | [![JAR](https://img.shields.io/maven-central/v/org.xdty.preference/color-picker.svg)](http://central.maven.org/maven2/org/xdty/preference/color-picker/) 7 | [ ![Download](https://api.bintray.com/packages/xdtianyu/maven/color-picker/images/download.svg) ](https://bintray.com/xdtianyu/maven/color-picker/_latestVersion) 8 | 9 | ## Download 10 | 11 | Grab via gradle 12 | 13 | ``` 14 | dependencies { 15 | compile 'org.xdty.preference:color-picker:0.0.5' 16 | } 17 | ``` 18 | 19 | or maven 20 | 21 | ``` 22 | 23 | org.xdty.preference 24 | color-picker 25 | 0.0.5 26 | aar 27 | 28 | ``` 29 | 30 | or JAR from [maven central](http://central.maven.org/maven2/org/xdty/preference/color-picker/) 31 | 32 | ## Usage 33 | 34 | For more details, see [example](https://github.com/xdtianyu/ColorPicker/tree/master/example) 35 | 36 | ``` 37 | 49 | ``` 50 | 51 | ## ScreenShot 52 | 53 | screenshot 54 | -------------------------------------------------------------------------------- /color-picker/src/main/java/org/xdty/preference/colorpicker/HsvColorComparator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.xdty.preference.colorpicker; 18 | 19 | import android.graphics.Color; 20 | 21 | import java.util.Comparator; 22 | 23 | /** 24 | * A color comparator which compares based on hue, saturation, and value. 25 | */ 26 | public class HsvColorComparator implements Comparator { 27 | 28 | @Override 29 | public int compare(Integer lhs, Integer rhs) { 30 | float[] hsv = new float[3]; 31 | Color.colorToHSV(lhs, hsv); 32 | float hue1 = hsv[0]; 33 | float sat1 = hsv[1]; 34 | float val1 = hsv[2]; 35 | 36 | float[] hsv2 = new float[3]; 37 | Color.colorToHSV(rhs, hsv2); 38 | float hue2 = hsv2[0]; 39 | float sat2 = hsv2[1]; 40 | float val2 = hsv2[2]; 41 | 42 | if (hue1 < hue2) { 43 | return 1; 44 | } else if (hue1 > hue2) { 45 | return -1; 46 | } else { 47 | if (sat1 < sat2) { 48 | return 1; 49 | } else if (sat1 > sat2) { 50 | return -1; 51 | } else { 52 | if (val1 < val2) { 53 | return 1; 54 | } else if (val1 > val2) { 55 | return -1; 56 | } 57 | } 58 | } 59 | return 0; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /color-picker/src/main/java/org/xdty/preference/colorpicker/ColorStateDrawable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.xdty.preference.colorpicker; 18 | 19 | import android.graphics.Color; 20 | import android.graphics.PorterDuff; 21 | import android.graphics.drawable.Drawable; 22 | import android.graphics.drawable.LayerDrawable; 23 | 24 | /** 25 | * A drawable which sets its color filter to a color specified by the user, and changes to a 26 | * slightly darker color when pressed or focused. 27 | */ 28 | public class ColorStateDrawable extends LayerDrawable { 29 | 30 | private static final float PRESSED_STATE_MULTIPLIER = 0.70f; 31 | 32 | private int mColor; 33 | 34 | public ColorStateDrawable(Drawable[] layers, int color) { 35 | super(layers); 36 | mColor = color; 37 | } 38 | 39 | @Override 40 | protected boolean onStateChange(int[] states) { 41 | boolean pressedOrFocused = false; 42 | for (int state : states) { 43 | if (state == android.R.attr.state_pressed || state == android.R.attr.state_focused) { 44 | pressedOrFocused = true; 45 | break; 46 | } 47 | } 48 | 49 | if (pressedOrFocused) { 50 | super.setColorFilter(getPressedColor(mColor), PorterDuff.Mode.SRC_ATOP); 51 | } else { 52 | super.setColorFilter(mColor, PorterDuff.Mode.SRC_ATOP); 53 | } 54 | 55 | return super.onStateChange(states); 56 | } 57 | 58 | /** 59 | * Given a particular color, adjusts its value by a multiplier. 60 | */ 61 | private static int getPressedColor(int color) { 62 | float[] hsv = new float[3]; 63 | Color.colorToHSV(color, hsv); 64 | hsv[2] = hsv[2] * PRESSED_STATE_MULTIPLIER; 65 | return Color.HSVToColor(hsv); 66 | } 67 | 68 | @Override 69 | public boolean isStateful() { 70 | return true; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /color-picker/src/main/java/org/xdty/preference/colorpicker/ColorPickerSwatch.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.xdty.preference.colorpicker; 18 | 19 | import android.content.Context; 20 | import android.graphics.drawable.Drawable; 21 | import android.graphics.drawable.GradientDrawable; 22 | import android.view.LayoutInflater; 23 | import android.view.View; 24 | import android.widget.FrameLayout; 25 | import android.widget.ImageView; 26 | 27 | /** 28 | * Creates a circular swatch of a specified color. Adds a checkmark if marked as checked. 29 | */ 30 | public class ColorPickerSwatch extends FrameLayout implements View.OnClickListener { 31 | private int mColor; 32 | private ImageView mSwatchImage; 33 | private ImageView mCheckMarkImage; 34 | private OnColorSelectedListener mOnColorSelectedListener; 35 | 36 | public ColorPickerSwatch(Context context, int color, boolean checked, int width, 37 | int strokeColor, OnColorSelectedListener listener) { 38 | super(context); 39 | mColor = color; 40 | mOnColorSelectedListener = listener; 41 | 42 | LayoutInflater.from(context).inflate(R.layout.color_picker_swatch, this); 43 | mSwatchImage = (ImageView) findViewById(R.id.color_picker_swatch); 44 | mCheckMarkImage = (ImageView) findViewById(R.id.color_picker_checkmark); 45 | if (width > 0) { 46 | setColor(color, width, strokeColor); 47 | } else { 48 | setColor(color); 49 | } 50 | setChecked(checked); 51 | setOnClickListener(this); 52 | } 53 | 54 | protected void setColor(int color) { 55 | Drawable[] colorDrawable = new Drawable[] 56 | { getContext().getResources().getDrawable(R.drawable.color_picker_swatch) }; 57 | mSwatchImage.setImageDrawable(new ColorStateDrawable(colorDrawable, color)); 58 | } 59 | 60 | protected void setColor(int color, int width, int strokeColor) { 61 | GradientDrawable colorDrawable; 62 | 63 | colorDrawable = new GradientDrawable(); 64 | colorDrawable.setShape(GradientDrawable.OVAL); 65 | colorDrawable.setColor(color); 66 | colorDrawable.setStroke(width, strokeColor); 67 | 68 | mSwatchImage.setImageDrawable(colorDrawable); 69 | } 70 | 71 | private void setChecked(boolean checked) { 72 | if (checked) { 73 | mCheckMarkImage.setVisibility(View.VISIBLE); 74 | } else { 75 | mCheckMarkImage.setVisibility(View.GONE); 76 | } 77 | } 78 | 79 | @Override 80 | public void onClick(View v) { 81 | if (mOnColorSelectedListener != null) { 82 | mOnColorSelectedListener.onColorSelected(mColor); 83 | } 84 | } 85 | 86 | /** 87 | * Interface for a callback when a color square is selected. 88 | */ 89 | public interface OnColorSelectedListener { 90 | 91 | /** 92 | * Called when a specific color square has been selected. 93 | */ 94 | void onColorSelected(int color); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /color-picker/src/main/java/org/xdty/preference/colorpicker/ColorPickerPalette.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.xdty.preference.colorpicker; 18 | 19 | import android.content.Context; 20 | import android.content.res.Resources; 21 | import android.util.AttributeSet; 22 | import android.view.View; 23 | import android.view.ViewGroup; 24 | import android.widget.ImageView; 25 | import android.widget.TableLayout; 26 | import android.widget.TableRow; 27 | 28 | import org.xdty.preference.colorpicker.ColorPickerSwatch.OnColorSelectedListener; 29 | 30 | /** 31 | * A color picker custom view which creates an grid of color squares. The number of squares per 32 | * row (and the padding between the squares) is determined by the user. 33 | */ 34 | public class ColorPickerPalette extends TableLayout { 35 | 36 | public OnColorSelectedListener mOnColorSelectedListener; 37 | 38 | private String mDescription; 39 | private String mDescriptionSelected; 40 | 41 | private int mSwatchLength; 42 | private int mMarginSize; 43 | private int mNumColumns; 44 | private boolean mBackwardsOrder; 45 | 46 | public ColorPickerPalette(Context context, AttributeSet attrs) { 47 | super(context, attrs); 48 | } 49 | 50 | public ColorPickerPalette(Context context) { 51 | super(context); 52 | } 53 | 54 | /** 55 | * Appends a swatch to the end of the row for even-numbered rows (starting with row 0), 56 | * to the beginning of a row for odd-numbered rows. 57 | */ 58 | private static void addSwatchToRow(TableRow row, View swatch, int rowNumber, 59 | boolean backwardsOrder) { 60 | if (backwardsOrder) { 61 | if (rowNumber % 2 == 0) { 62 | row.addView(swatch); 63 | } else { 64 | row.addView(swatch, 0); 65 | } 66 | } else { 67 | row.addView(swatch); 68 | } 69 | 70 | } 71 | 72 | /** 73 | * Initialize the size, columns, and listener. Size should be a pre-defined size (SIZE_LARGE 74 | * or SIZE_SMALL) from ColorPickerDialogFragment. 75 | */ 76 | public void init(int size, int columns, OnColorSelectedListener listener, 77 | boolean backwardsOrder) { 78 | mNumColumns = columns; 79 | mBackwardsOrder = backwardsOrder; 80 | Resources res = getResources(); 81 | if (size == ColorPickerDialog.SIZE_LARGE) { 82 | mSwatchLength = res.getDimensionPixelSize(R.dimen.color_swatch_large); 83 | mMarginSize = res.getDimensionPixelSize(R.dimen.color_swatch_margins_large); 84 | } else { 85 | mSwatchLength = res.getDimensionPixelSize(R.dimen.color_swatch_small); 86 | mMarginSize = res.getDimensionPixelSize(R.dimen.color_swatch_margins_small); 87 | } 88 | mOnColorSelectedListener = listener; 89 | 90 | mDescription = res.getString(R.string.color_swatch_description); 91 | mDescriptionSelected = res.getString(R.string.color_swatch_description_selected); 92 | } 93 | 94 | private TableRow createTableRow() { 95 | TableRow row = new TableRow(getContext()); 96 | ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, 97 | LayoutParams.WRAP_CONTENT); 98 | row.setLayoutParams(params); 99 | return row; 100 | } 101 | 102 | /** 103 | * Adds swatches to table in a serpentine format. 104 | */ 105 | public void drawPalette(int[] colors, int selectedColor, int width, int strokeColor) { 106 | drawPalette(colors, selectedColor, null, width, strokeColor); 107 | } 108 | 109 | /** 110 | * Adds swatches to table in a serpentine format. 111 | */ 112 | public void drawPalette(int[] colors, int selectedColor, String[] colorContentDescriptions, 113 | int width, int strokeColor) { 114 | if (colors == null) { 115 | return; 116 | } 117 | 118 | this.removeAllViews(); 119 | int tableElements = 0; 120 | int rowElements = 0; 121 | int rowNumber = 0; 122 | 123 | // Fills the table with swatches based on the array of colors. 124 | TableRow row = createTableRow(); 125 | for (int color : colors) { 126 | View colorSwatch = createColorSwatch(color, selectedColor, width, strokeColor); 127 | setSwatchDescription(rowNumber, tableElements, rowElements, color == selectedColor, 128 | colorSwatch, colorContentDescriptions); 129 | addSwatchToRow(row, colorSwatch, rowNumber, mBackwardsOrder); 130 | 131 | tableElements++; 132 | rowElements++; 133 | if (rowElements == mNumColumns) { 134 | addView(row); 135 | row = createTableRow(); 136 | rowElements = 0; 137 | rowNumber++; 138 | } 139 | } 140 | 141 | // Create blank views to fill the row if the last row has not been filled. 142 | if (rowElements > 0) { 143 | while (rowElements != mNumColumns) { 144 | addSwatchToRow(row, createBlankSpace(), rowNumber, mBackwardsOrder); 145 | rowElements++; 146 | } 147 | addView(row); 148 | } 149 | } 150 | 151 | /** 152 | * Add a content description to the specified swatch view. Because the colors get added in a 153 | * snaking form, every other row will need to compensate for the fact that the colors are added 154 | * in an opposite direction from their left->right/top->bottom order, which is how the system 155 | * will arrange them for accessibility purposes. 156 | */ 157 | private void setSwatchDescription(int rowNumber, int index, int rowElements, boolean selected, 158 | View swatch, String[] contentDescriptions) { 159 | String description; 160 | if (contentDescriptions != null && contentDescriptions.length > index) { 161 | description = contentDescriptions[index]; 162 | } else { 163 | int accessibilityIndex; 164 | if (mBackwardsOrder) { 165 | if (rowNumber % 2 == 0) { 166 | // We're in a regular-ordered row 167 | accessibilityIndex = index + 1; 168 | } else { 169 | // We're in a backwards-ordered row. 170 | int rowMax = ((rowNumber + 1) * mNumColumns); 171 | accessibilityIndex = rowMax - rowElements; 172 | } 173 | } else { 174 | accessibilityIndex = index + 1; 175 | } 176 | if (selected) { 177 | description = String.format(mDescriptionSelected, accessibilityIndex); 178 | } else { 179 | description = String.format(mDescription, accessibilityIndex); 180 | } 181 | } 182 | swatch.setContentDescription(description); 183 | } 184 | 185 | /** 186 | * Creates a blank space to fill the row. 187 | */ 188 | private ImageView createBlankSpace() { 189 | ImageView view = new ImageView(getContext()); 190 | TableRow.LayoutParams params = new TableRow.LayoutParams(mSwatchLength, mSwatchLength); 191 | params.setMargins(mMarginSize, mMarginSize, mMarginSize, mMarginSize); 192 | view.setLayoutParams(params); 193 | return view; 194 | } 195 | 196 | /** 197 | * Creates a color swatch. 198 | */ 199 | private ColorPickerSwatch createColorSwatch(int color, int selectedColor, int width, 200 | int strokeColor) { 201 | ColorPickerSwatch view = new ColorPickerSwatch(getContext(), color, 202 | color == selectedColor, width, strokeColor, mOnColorSelectedListener); 203 | TableRow.LayoutParams params = new TableRow.LayoutParams(mSwatchLength, mSwatchLength); 204 | params.setMargins(mMarginSize, mMarginSize, mMarginSize, mMarginSize); 205 | view.setLayoutParams(params); 206 | return view; 207 | } 208 | } 209 | -------------------------------------------------------------------------------- /color-picker/src/main/java/org/xdty/preference/colorpicker/ColorPickerDialog.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.xdty.preference.colorpicker; 18 | 19 | import android.app.Activity; 20 | import android.app.AlertDialog; 21 | import android.app.Dialog; 22 | import android.app.DialogFragment; 23 | import android.os.Bundle; 24 | import android.view.LayoutInflater; 25 | import android.view.View; 26 | import android.widget.ProgressBar; 27 | 28 | import org.xdty.preference.colorpicker.ColorPickerSwatch.OnColorSelectedListener; 29 | 30 | /** 31 | * A dialog which takes in as input an array of colors and creates a palette allowing the user to 32 | * select a specific color swatch, which invokes a listener. 33 | */ 34 | public class ColorPickerDialog extends DialogFragment implements OnColorSelectedListener { 35 | 36 | public static final int SIZE_LARGE = 1; 37 | public static final int SIZE_SMALL = 2; 38 | protected static final String KEY_TITLE_ID = "title_id"; 39 | protected static final String KEY_COLORS = "colors"; 40 | protected static final String KEY_COLOR_CONTENT_DESCRIPTIONS = "color_content_descriptions"; 41 | protected static final String KEY_SELECTED_COLOR = "selected_color"; 42 | protected static final String KEY_COLUMNS = "columns"; 43 | protected static final String KEY_SIZE = "size"; 44 | protected static final String KEY_BACKWARDS_ORDER = "backwards_order"; 45 | protected static final String KEY_STROKE_WIDTH = "stroke_width"; 46 | protected static final String KEY_STROKE_COLOR = "stroke_color"; 47 | protected AlertDialog mAlertDialog; 48 | protected int mTitleResId = R.string.color_picker_default_title; 49 | protected int[] mColors = null; 50 | protected String[] mColorContentDescriptions = null; 51 | protected int mSelectedColor; 52 | protected int mColumns; 53 | protected int mSize; 54 | protected int mStrokeWidth; 55 | protected int mStrokeColor; 56 | protected boolean mBackwardsOrder; 57 | protected OnColorSelectedListener mListener; 58 | private ColorPickerPalette mPalette; 59 | private ProgressBar mProgress; 60 | 61 | public ColorPickerDialog() { 62 | // Empty constructor required for dialog fragments. 63 | } 64 | 65 | public static ColorPickerDialog newInstance(int titleResId, int[] colors, int selectedColor, 66 | int columns, int size) { 67 | return newInstance(titleResId, colors, selectedColor, columns, size, true, 0, 0); 68 | } 69 | 70 | public static ColorPickerDialog newInstance(int titleResId, int[] colors, int selectedColor, 71 | int columns, int size, boolean backwardsOrder) { 72 | return newInstance(titleResId, colors, selectedColor, columns, size, backwardsOrder, 0, 0); 73 | } 74 | 75 | public static ColorPickerDialog newInstance(int titleResId, int[] colors, int selectedColor, 76 | int columns, int size, boolean backwardsOrder, int strokeWidth, int strokeColor) { 77 | ColorPickerDialog ret = new ColorPickerDialog(); 78 | ret.initialize(titleResId, colors, selectedColor, columns, size, backwardsOrder, 79 | strokeWidth, strokeColor); 80 | return ret; 81 | } 82 | 83 | public void initialize(int titleResId, int[] colors, int selectedColor, int columns, int size, 84 | boolean backwardsDisable, int strokeWidth, int strokeColor) { 85 | setArguments(titleResId, columns, size, backwardsDisable, strokeWidth, strokeColor); 86 | setColors(colors, selectedColor); 87 | } 88 | 89 | public void setArguments(int titleResId, int columns, int size, boolean backwardsOrder, 90 | int strokeWidth, int strokeColor) { 91 | Bundle bundle = new Bundle(); 92 | bundle.putInt(KEY_TITLE_ID, titleResId); 93 | bundle.putInt(KEY_COLUMNS, columns); 94 | bundle.putInt(KEY_SIZE, size); 95 | bundle.putBoolean(KEY_BACKWARDS_ORDER, backwardsOrder); 96 | bundle.putInt(KEY_STROKE_WIDTH, strokeWidth); 97 | bundle.putInt(KEY_STROKE_COLOR, strokeColor); 98 | setArguments(bundle); 99 | } 100 | 101 | public void setOnColorSelectedListener(OnColorSelectedListener listener) { 102 | mListener = listener; 103 | } 104 | 105 | @Override 106 | public void onCreate(Bundle savedInstanceState) { 107 | super.onCreate(savedInstanceState); 108 | 109 | if (getArguments() != null) { 110 | mTitleResId = getArguments().getInt(KEY_TITLE_ID); 111 | mColumns = getArguments().getInt(KEY_COLUMNS); 112 | mSize = getArguments().getInt(KEY_SIZE); 113 | mBackwardsOrder = getArguments().getBoolean(KEY_BACKWARDS_ORDER); 114 | mStrokeWidth = getArguments().getInt(KEY_STROKE_WIDTH); 115 | mStrokeColor = getArguments().getInt(KEY_STROKE_COLOR); 116 | } 117 | 118 | if (savedInstanceState != null) { 119 | mColors = savedInstanceState.getIntArray(KEY_COLORS); 120 | mSelectedColor = (int) savedInstanceState.getSerializable(KEY_SELECTED_COLOR); 121 | mColorContentDescriptions = savedInstanceState.getStringArray( 122 | KEY_COLOR_CONTENT_DESCRIPTIONS); 123 | mBackwardsOrder = savedInstanceState.getBoolean(KEY_BACKWARDS_ORDER); 124 | mStrokeWidth = (int) savedInstanceState.getSerializable(KEY_STROKE_WIDTH); 125 | mStrokeColor = (int) savedInstanceState.getSerializable(KEY_STROKE_COLOR); 126 | } 127 | } 128 | 129 | @Override 130 | public Dialog onCreateDialog(Bundle savedInstanceState) { 131 | final Activity activity = getActivity(); 132 | 133 | View view = LayoutInflater.from(getActivity()).inflate(R.layout.color_picker_dialog, null); 134 | mProgress = (ProgressBar) view.findViewById(android.R.id.progress); 135 | mPalette = (ColorPickerPalette) view.findViewById(R.id.color_picker); 136 | mPalette.init(mSize, mColumns, this, mBackwardsOrder); 137 | 138 | if (mColors != null) { 139 | showPaletteView(); 140 | } 141 | 142 | mAlertDialog = new AlertDialog.Builder(activity) 143 | .setTitle(mTitleResId) 144 | .setView(view) 145 | .create(); 146 | mAlertDialog.setCanceledOnTouchOutside(true); 147 | return mAlertDialog; 148 | } 149 | 150 | @Override 151 | public void onColorSelected(int color) { 152 | if (mListener != null) { 153 | mListener.onColorSelected(color); 154 | } 155 | 156 | if (getTargetFragment() instanceof OnColorSelectedListener) { 157 | final OnColorSelectedListener listener = 158 | (OnColorSelectedListener) getTargetFragment(); 159 | listener.onColorSelected(color); 160 | } 161 | 162 | if (color != mSelectedColor) { 163 | mSelectedColor = color; 164 | // Redraw palette to show checkmark on newly selected color before dismissing. 165 | mPalette.drawPalette(mColors, mSelectedColor, mStrokeWidth, mStrokeColor); 166 | } 167 | 168 | dismiss(); 169 | } 170 | 171 | public void showPaletteView() { 172 | if (mProgress != null && mPalette != null) { 173 | mProgress.setVisibility(View.GONE); 174 | refreshPalette(); 175 | mPalette.setVisibility(View.VISIBLE); 176 | } 177 | } 178 | 179 | public void showProgressBarView() { 180 | if (mProgress != null && mPalette != null) { 181 | mProgress.setVisibility(View.VISIBLE); 182 | mPalette.setVisibility(View.GONE); 183 | } 184 | } 185 | 186 | public void setColors(int[] colors, int selectedColor) { 187 | if (mColors != colors || mSelectedColor != selectedColor) { 188 | mColors = colors; 189 | mSelectedColor = selectedColor; 190 | refreshPalette(); 191 | } 192 | } 193 | 194 | public void setColorContentDescriptions(String[] colorContentDescriptions) { 195 | if (mColorContentDescriptions != colorContentDescriptions) { 196 | mColorContentDescriptions = colorContentDescriptions; 197 | refreshPalette(); 198 | } 199 | } 200 | 201 | private void refreshPalette() { 202 | if (mPalette != null && mColors != null) { 203 | mPalette.drawPalette(mColors, mSelectedColor, mColorContentDescriptions, mStrokeWidth, 204 | mStrokeColor); 205 | } 206 | } 207 | 208 | public int[] getColors() { 209 | return mColors; 210 | } 211 | 212 | public void setColors(int[] colors) { 213 | if (mColors != colors) { 214 | mColors = colors; 215 | refreshPalette(); 216 | } 217 | } 218 | 219 | public int getSelectedColor() { 220 | return mSelectedColor; 221 | } 222 | 223 | public void setSelectedColor(int color) { 224 | if (mSelectedColor != color) { 225 | mSelectedColor = color; 226 | refreshPalette(); 227 | } 228 | } 229 | 230 | public void setStrokeWidth(int width) { 231 | if (mStrokeWidth != width) { 232 | mStrokeWidth = width; 233 | refreshPalette(); 234 | } 235 | } 236 | 237 | public void setStrokeColor(int color) { 238 | if (mStrokeColor != color) { 239 | mStrokeColor = color; 240 | refreshPalette(); 241 | } 242 | } 243 | 244 | @Override 245 | public void onSaveInstanceState(Bundle outState) { 246 | super.onSaveInstanceState(outState); 247 | outState.putIntArray(KEY_COLORS, mColors); 248 | outState.putSerializable(KEY_SELECTED_COLOR, mSelectedColor); 249 | outState.putStringArray(KEY_COLOR_CONTENT_DESCRIPTIONS, mColorContentDescriptions); 250 | outState.putBoolean(KEY_BACKWARDS_ORDER, mBackwardsOrder); 251 | outState.putInt(KEY_STROKE_WIDTH, mStrokeWidth); 252 | outState.putInt(KEY_STROKE_COLOR, mStrokeColor); 253 | } 254 | } 255 | -------------------------------------------------------------------------------- /color-picker/src/main/java/org/xdty/preference/ColorPreference.java: -------------------------------------------------------------------------------- 1 | package org.xdty.preference; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.content.res.Resources; 6 | import android.content.res.TypedArray; 7 | import android.graphics.Color; 8 | import android.graphics.drawable.ShapeDrawable; 9 | import android.graphics.drawable.shapes.OvalShape; 10 | import android.os.Build; 11 | import android.os.Parcel; 12 | import android.os.Parcelable; 13 | import android.preference.Preference; 14 | import android.util.AttributeSet; 15 | import android.util.TypedValue; 16 | import android.view.View; 17 | import android.view.ViewGroup; 18 | import android.widget.TextView; 19 | 20 | import org.xdty.preference.colorpicker.ColorPickerDialog; 21 | import org.xdty.preference.colorpicker.ColorPickerSwatch; 22 | import org.xdty.preference.colorpicker.R; 23 | 24 | /** 25 | * A preference showing a {@link ColorPickerDialog} to allow the user to select a color to save as 26 | * {@link Preference}. 27 | */ 28 | public class ColorPreference extends Preference implements ColorPickerSwatch 29 | .OnColorSelectedListener { 30 | 31 | private static final int DEFAULT_VALUE = Color.BLACK; 32 | 33 | private int mTitle = R.string.color_picker_default_title; 34 | private int mCurrentValue; 35 | private int[] mColors; 36 | private int mColumns; 37 | private boolean mMaterial; 38 | private boolean mBackwardsOrder; 39 | private int mStrokeWidth; 40 | private int mStrokeColor; 41 | 42 | private View mColorView; 43 | 44 | public ColorPreference(Context context, AttributeSet attrs) { 45 | super(context, attrs); 46 | 47 | TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable 48 | .ColorPreference, 0, 0); 49 | try { 50 | int id = a.getResourceId(R.styleable.ColorPreference_colors, R.array.default_rainbow); 51 | if (id != 0) { 52 | mColors = getContext().getResources().getIntArray(id); 53 | } 54 | id = a.getResourceId(R.styleable.ColorPreference_dialogTitle, 0); 55 | if (id != 0) { 56 | mTitle = a.getResourceId(R.styleable.ColorPreference_dialogTitle, 57 | R.string.color_picker_default_title); 58 | } 59 | mColumns = a.getInt(R.styleable.ColorPreference_columns, 5); 60 | mMaterial = a.getBoolean(R.styleable.ColorPreference_material, true); 61 | mBackwardsOrder = a.getBoolean(R.styleable.ColorPreference_backwardsOrder, true); 62 | mStrokeWidth = a.getInt(R.styleable.ColorPreference_strokeWidth, 0); 63 | mStrokeColor = a.getColor(R.styleable.ColorPreference_strokeColor, 0xff000000); 64 | } finally { 65 | a.recycle(); 66 | } 67 | } 68 | 69 | @Override 70 | protected Object onGetDefaultValue(TypedArray a, int index) { 71 | return a.getInteger(index, DEFAULT_VALUE); 72 | } 73 | 74 | @Override 75 | protected View onCreateView(ViewGroup parent) { 76 | View s = super.onCreateView(parent); 77 | mColorView = new View(getContext()); 78 | int size = (int) dpToPx(32); 79 | mColorView.setLayoutParams(new ViewGroup.LayoutParams(size, size)); 80 | updateShownColor(); 81 | ViewGroup w = (ViewGroup) s.findViewById(android.R.id.widget_frame); 82 | w.setVisibility(View.VISIBLE); 83 | w.addView(mColorView); 84 | return s; 85 | } 86 | 87 | @Override 88 | protected void onBindView(View view) { 89 | super.onBindView(view); 90 | if (mMaterial) { 91 | TextView textTitle = (TextView) view.findViewById(android.R.id.title); 92 | TextView textSummary = (TextView) view.findViewById(android.R.id.summary); 93 | 94 | textTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16); 95 | textSummary.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14); 96 | textTitle.setTextColor(getColor(android.R.attr.textColorPrimary)); 97 | textSummary.setTextColor(getColor(android.R.attr.textColorSecondary)); 98 | 99 | View parent = (View) textSummary.getParent().getParent(); 100 | parent.setPadding((int) dpToPx(16), 0, (int) dpToPx(16), 0); 101 | } 102 | } 103 | 104 | @Override 105 | protected void onClick() { 106 | int[] colors = mColors.length != 0 ? mColors : new int[] { 107 | Color.BLACK, Color.WHITE, Color 108 | .RED, Color.GREEN, Color.BLUE 109 | }; 110 | ColorPickerDialog d = ColorPickerDialog.newInstance(mTitle, 111 | colors, mCurrentValue, mColumns, 112 | ColorPickerDialog.SIZE_SMALL, mBackwardsOrder, 113 | mStrokeWidth, mStrokeColor); 114 | d.setOnColorSelectedListener(this); 115 | d.show(((Activity) getContext()).getFragmentManager(), null); 116 | } 117 | 118 | @Override 119 | protected void onSetInitialValue(boolean restorePersistedValue, Object defaultValue) { 120 | if (restorePersistedValue) { 121 | // Restore existing state 122 | mCurrentValue = this.getPersistedInt(DEFAULT_VALUE); 123 | } else { 124 | // Set default state from the XML attribute 125 | mCurrentValue = (Integer) defaultValue; 126 | persistInt(mCurrentValue); 127 | } 128 | } 129 | 130 | @Override 131 | protected Parcelable onSaveInstanceState() { 132 | final Parcelable superState = super.onSaveInstanceState(); 133 | // Check whether this Preference is persistent (continually saved) 134 | if (isPersistent()) { 135 | // No need to save instance state since it's persistent, 136 | // use superclass state 137 | return superState; 138 | } 139 | 140 | // Create instance of custom BaseSavedState 141 | final SavedState myState = new SavedState(superState); 142 | // Set the state's value with the class member that holds current 143 | // setting value 144 | myState.current = mCurrentValue; 145 | myState.colors = mColors; 146 | myState.columns = mColumns; 147 | myState.material = mMaterial; 148 | myState.backwardsOrder = mBackwardsOrder; 149 | myState.strokeWidth = mStrokeWidth; 150 | myState.strokeColor = mStrokeColor; 151 | return myState; 152 | } 153 | 154 | @Override 155 | protected void onRestoreInstanceState(Parcelable state) { 156 | // Check whether we saved the state in onSaveInstanceState 157 | if (state == null || !state.getClass().equals(SavedState.class)) { 158 | // Didn't save the state, so call superclass 159 | super.onRestoreInstanceState(state); 160 | return; 161 | } 162 | 163 | // Cast state to custom BaseSavedState and pass to superclass 164 | SavedState myState = (SavedState) state; 165 | super.onRestoreInstanceState(myState.getSuperState()); 166 | 167 | // Update own values 168 | mCurrentValue = myState.current; 169 | mColors = myState.colors; 170 | mColumns = myState.columns; 171 | mMaterial = myState.material; 172 | mBackwardsOrder = myState.backwardsOrder; 173 | mStrokeWidth = myState.strokeWidth; 174 | mStrokeColor = myState.strokeColor; 175 | 176 | // Update shown color 177 | updateShownColor(); 178 | 179 | // Set this Preference's widget to reflect the restored state 180 | //mNumberPicker.setValue(myState.value); 181 | } 182 | 183 | @Override 184 | public void onColorSelected(int color) { 185 | persistInt(color); 186 | mCurrentValue = color; 187 | updateShownColor(); 188 | } 189 | 190 | private void updateShownColor() { 191 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 192 | mColorView.setBackground(new ShapeDrawable(new OvalShape())); 193 | ((ShapeDrawable) mColorView.getBackground()).getPaint().setColor(mCurrentValue); 194 | } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { 195 | mColorView.setBackground(new ColorCircleDrawable(mCurrentValue)); 196 | } else { 197 | mColorView.setBackgroundDrawable(new ColorCircleDrawable(mCurrentValue)); 198 | } 199 | mColorView.invalidate(); 200 | } 201 | 202 | /** 203 | * Convert a dp size to pixel. 204 | * Useful for specifying view sizes in code. 205 | * 206 | * @param dp The size in density-independent pixels. 207 | * @return {@code px} - The size in generic pixels (density-dependent). 208 | */ 209 | private float dpToPx(float dp) { 210 | return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, 211 | getContext().getResources().getDisplayMetrics()); 212 | } 213 | 214 | private int getColor(int attrId) { 215 | TypedValue typedValue = new TypedValue(); 216 | Resources.Theme theme = getContext().getTheme(); 217 | theme.resolveAttribute(attrId, typedValue, true); 218 | TypedArray arr = getContext().obtainStyledAttributes(typedValue.data, new int[] { attrId }); 219 | int color = arr.getColor(0, -1); 220 | arr.recycle(); 221 | return color; 222 | } 223 | 224 | private static class SavedState extends BaseSavedState { 225 | // Standard creator object using an instance of this class 226 | public static final Parcelable.Creator CREATOR = 227 | new Parcelable.Creator() { 228 | 229 | public SavedState createFromParcel(Parcel in) { 230 | return new SavedState(in); 231 | } 232 | 233 | public SavedState[] newArray(int size) { 234 | return new SavedState[size]; 235 | } 236 | }; 237 | // Member that holds the preference's values 238 | int current; 239 | int[] colors; 240 | int columns; 241 | boolean material; 242 | boolean backwardsOrder; 243 | int strokeWidth; 244 | int strokeColor; 245 | 246 | public SavedState(Parcelable superState) { 247 | super(superState); 248 | } 249 | 250 | public SavedState(Parcel source) { 251 | super(source); 252 | // Get the current preference's values 253 | current = source.readInt(); 254 | source.readIntArray(colors); 255 | columns = source.readInt(); 256 | material = source.readByte() != 0; 257 | backwardsOrder = source.readByte() != 0; 258 | strokeWidth = source.readInt(); 259 | strokeColor = source.readInt(); 260 | } 261 | 262 | @Override 263 | public void writeToParcel(Parcel dest, int flags) { 264 | super.writeToParcel(dest, flags); 265 | // Write the preference's values 266 | dest.writeInt(current); 267 | dest.writeIntArray(colors); 268 | dest.writeInt(columns); 269 | dest.writeByte((byte) (material ? 1 : 0)); 270 | dest.writeByte((byte) (backwardsOrder ? 1 : 0)); 271 | dest.writeInt(strokeWidth); 272 | dest.writeInt(strokeColor); 273 | } 274 | } 275 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | --------------------------------------------------------------------------------