├── pikolo ├── .gitignore ├── src │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── com │ │ │ └── madrapps │ │ │ └── pikolo │ │ │ ├── components │ │ │ ├── hsl │ │ │ │ ├── HslMetrics.kt │ │ │ │ ├── HueComponent.kt │ │ │ │ ├── LightnessComponent.kt │ │ │ │ └── SaturationComponent.kt │ │ │ ├── rgb │ │ │ │ ├── RgbMetrics.kt │ │ │ │ ├── RedComponent.kt │ │ │ │ ├── BlueComponent.kt │ │ │ │ └── GreenComponent.kt │ │ │ ├── ColorComponent.kt │ │ │ └── ArcComponent.kt │ │ │ ├── listeners │ │ │ ├── SimpleColorSelectionListener.kt │ │ │ └── OnColorSelectionListener.kt │ │ │ ├── Metrics.kt │ │ │ ├── ColorPicker.kt │ │ │ ├── RGBColorPicker.kt │ │ │ └── HSLColorPicker.kt │ │ └── res │ │ └── values │ │ └── attrs.xml ├── proguard-rules.pro ├── build.gradle └── publish.gradle ├── sample ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── values │ │ │ ├── strings.xml │ │ │ ├── colors.xml │ │ │ └── styles.xml │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── drawable │ │ │ └── bg_circle.xml │ │ └── layout │ │ │ └── activity_main.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── madrapps │ │ └── pickcolor │ │ └── MainActivity.java ├── proguard-rules.pro └── build.gradle ├── _config.yml ├── settings.gradle ├── index.html ├── preview ├── rgb-picker.gif ├── screenshot.jpg ├── arc-selectors.gif ├── preview-full.gif └── preview-small.gif ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── .gitignore ├── .github └── workflows │ └── publish.yml ├── .travis.yml ├── README.md ├── gradlew.bat ├── gradlew └── LICENSE /pikolo/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /sample/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':sample', ':pikolo' 2 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | Pikolo 3 | 4 | -------------------------------------------------------------------------------- /pikolo/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /preview/rgb-picker.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Madrapps/Pikolo/HEAD/preview/rgb-picker.gif -------------------------------------------------------------------------------- /preview/screenshot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Madrapps/Pikolo/HEAD/preview/screenshot.jpg -------------------------------------------------------------------------------- /preview/arc-selectors.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Madrapps/Pikolo/HEAD/preview/arc-selectors.gif -------------------------------------------------------------------------------- /preview/preview-full.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Madrapps/Pikolo/HEAD/preview/preview-full.gif -------------------------------------------------------------------------------- /preview/preview-small.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Madrapps/Pikolo/HEAD/preview/preview-small.gif -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Madrapps/Pikolo/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /sample/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | PickColor 3 | 4 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | android.enableJetifier=true 2 | android.useAndroidX=true 3 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 4 | -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Madrapps/Pikolo/HEAD/sample/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Madrapps/Pikolo/HEAD/sample/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Madrapps/Pikolo/HEAD/sample/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Madrapps/Pikolo/HEAD/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Madrapps/Pikolo/HEAD/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Madrapps/Pikolo/HEAD/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Madrapps/Pikolo/HEAD/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Madrapps/Pikolo/HEAD/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Madrapps/Pikolo/HEAD/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Madrapps/Pikolo/HEAD/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable/bg_circle.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /sample/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed May 22 04:24:07 IST 2019 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-7.2-all.zip 7 | -------------------------------------------------------------------------------- /sample/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /pikolo/src/main/java/com/madrapps/pikolo/components/hsl/HslMetrics.kt: -------------------------------------------------------------------------------- 1 | package com.madrapps.pikolo.components.hsl 2 | 3 | import androidx.core.graphics.ColorUtils 4 | import com.madrapps.pikolo.Metrics 5 | 6 | internal class HslMetrics(centerX: Float = 0f, centerY: Float = 0f, color: FloatArray, density: Float) : Metrics(centerX, centerY, color, density) { 7 | 8 | override fun hue() = color[0] 9 | 10 | override fun getColor() = ColorUtils.HSLToColor(color) 11 | } -------------------------------------------------------------------------------- /pikolo/src/main/java/com/madrapps/pikolo/listeners/SimpleColorSelectionListener.kt: -------------------------------------------------------------------------------- 1 | package com.madrapps.pikolo.listeners 2 | 3 | /** 4 | * Empty implementation of [OnColorSelectionListener] so that the clients can override only the methods they care 5 | */ 6 | open class SimpleColorSelectionListener : OnColorSelectionListener { 7 | 8 | override fun onColorSelected(color: Int) {} 9 | 10 | override fun onColorSelectionStart(color: Int) {} 11 | 12 | override fun onColorSelectionEnd(color: Int) {} 13 | } -------------------------------------------------------------------------------- /pikolo/src/main/java/com/madrapps/pikolo/components/rgb/RgbMetrics.kt: -------------------------------------------------------------------------------- 1 | package com.madrapps.pikolo.components.rgb 2 | 3 | import android.graphics.Color 4 | import androidx.core.graphics.ColorUtils 5 | import com.madrapps.pikolo.Metrics 6 | 7 | internal class RgbMetrics(centerX: Float = 0f, centerY: Float = 0f, color: FloatArray, density: Float) : Metrics(centerX, centerY, color, density) { 8 | 9 | override fun hue(): Float { 10 | val hsl = FloatArray(3) 11 | ColorUtils.RGBToHSL(color[0].toInt(), color[1].toInt(), color[2].toInt(), hsl) 12 | return hsl[0] 13 | } 14 | 15 | override fun getColor() = Color.rgb(color[0].toInt(), color[1].toInt(), color[2].toInt()) 16 | } -------------------------------------------------------------------------------- /pikolo/src/main/java/com/madrapps/pikolo/listeners/OnColorSelectionListener.kt: -------------------------------------------------------------------------------- 1 | package com.madrapps.pikolo.listeners 2 | 3 | /** 4 | * Listener to listen to color change events 5 | */ 6 | interface OnColorSelectionListener { 7 | 8 | /** 9 | * Invoked every time the color changes 10 | * 11 | * @param color the selected color 12 | */ 13 | fun onColorSelected(color: Int) 14 | 15 | /** 16 | * Invoked when the color selection started 17 | * 18 | * @param color the color before the selection started 19 | */ 20 | fun onColorSelectionStart(color: Int) 21 | 22 | /** 23 | * Invoked when the color selection is over 24 | * 25 | * @param color the selected color 26 | */ 27 | fun onColorSelectionEnd(color: Int) 28 | } -------------------------------------------------------------------------------- /pikolo/src/main/java/com/madrapps/pikolo/components/rgb/RedComponent.kt: -------------------------------------------------------------------------------- 1 | package com.madrapps.pikolo.components.rgb 2 | 3 | import android.graphics.Color 4 | import com.madrapps.pikolo.Metrics 5 | import com.madrapps.pikolo.Paints 6 | import com.madrapps.pikolo.components.ArcComponent 7 | 8 | internal class RedComponent(metrics: Metrics, paints: Paints, arcLength: Float, arcStartAngle: Float) : ArcComponent(metrics, paints, arcLength, arcStartAngle) { 9 | 10 | override val componentIndex: Int = 0 11 | override val range: Float = 255f 12 | override val noOfColors = 2 13 | override val colors = IntArray(noOfColors) 14 | override val colorPosition = FloatArray(noOfColors) 15 | 16 | override fun getColorArray(color: FloatArray): IntArray { 17 | colors[0] = Color.BLACK 18 | colors[1] = Color.rgb(255, 0, 0) 19 | return colors 20 | } 21 | } -------------------------------------------------------------------------------- /pikolo/src/main/java/com/madrapps/pikolo/components/rgb/BlueComponent.kt: -------------------------------------------------------------------------------- 1 | package com.madrapps.pikolo.components.rgb 2 | 3 | import android.graphics.Color 4 | import com.madrapps.pikolo.Metrics 5 | import com.madrapps.pikolo.Paints 6 | import com.madrapps.pikolo.components.ArcComponent 7 | 8 | internal class BlueComponent(metrics: Metrics, paints: Paints, arcLength: Float, arcStartAngle: Float) : ArcComponent(metrics, paints, arcLength, arcStartAngle) { 9 | 10 | override val componentIndex: Int = 2 11 | override val range: Float = 255f 12 | override val noOfColors = 2 13 | override val colors = IntArray(noOfColors) 14 | override val colorPosition = FloatArray(noOfColors) 15 | 16 | override fun getColorArray(color: FloatArray): IntArray { 17 | colors[0] = Color.BLACK 18 | colors[1] = Color.rgb(0, 0, 255) 19 | return colors 20 | } 21 | } -------------------------------------------------------------------------------- /pikolo/src/main/java/com/madrapps/pikolo/components/rgb/GreenComponent.kt: -------------------------------------------------------------------------------- 1 | package com.madrapps.pikolo.components.rgb 2 | 3 | import android.graphics.Color 4 | import com.madrapps.pikolo.Metrics 5 | import com.madrapps.pikolo.Paints 6 | import com.madrapps.pikolo.components.ArcComponent 7 | 8 | internal class GreenComponent(metrics: Metrics, paints: Paints, arcLength: Float, arcStartAngle: Float) : ArcComponent(metrics, paints, arcLength, arcStartAngle) { 9 | 10 | override val componentIndex: Int = 1 11 | override val range: Float = 255f 12 | override val noOfColors = 2 13 | override val colors = IntArray(noOfColors) 14 | override val colorPosition = FloatArray(noOfColors) 15 | 16 | override fun getColorArray(color: FloatArray): IntArray { 17 | colors[0] = Color.BLACK 18 | colors[1] = Color.rgb(0, 255, 0) 19 | return colors 20 | } 21 | } -------------------------------------------------------------------------------- /sample/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # Intellij 36 | *.iml 37 | .idea/workspace.xml 38 | .idea/tasks.xml 39 | .idea/gradle.xml 40 | .idea/dictionaries 41 | .idea/libraries 42 | 43 | # Keystore files 44 | *.jks 45 | 46 | # External native build folder generated in Android Studio 2.2 and later 47 | .externalNativeBuild 48 | 49 | # Google Services (e.g. APIs or Firebase) 50 | google-services.json 51 | 52 | # Freeline 53 | freeline.py 54 | freeline/ 55 | freeline_project_description.json 56 | .idea 57 | -------------------------------------------------------------------------------- /pikolo/src/main/java/com/madrapps/pikolo/components/hsl/HueComponent.kt: -------------------------------------------------------------------------------- 1 | package com.madrapps.pikolo.components.hsl 2 | 3 | import androidx.core.graphics.ColorUtils 4 | import com.madrapps.pikolo.Metrics 5 | import com.madrapps.pikolo.Paints 6 | import com.madrapps.pikolo.components.ArcComponent 7 | 8 | internal class HueComponent(metrics: Metrics, paints: Paints, arcLength: Float, arcStartAngle: Float) : ArcComponent(metrics, paints, arcLength, arcStartAngle) { 9 | 10 | override val componentIndex = 0 11 | override val range: Float = 360f 12 | override val noOfColors = 360 13 | override val colors = IntArray(noOfColors) 14 | override val colorPosition = FloatArray(noOfColors) 15 | 16 | override fun getColorArray(color: FloatArray): IntArray { 17 | color[1] = 1f 18 | color[2] = 0.5f 19 | for (i in 0 until noOfColors) { 20 | color[componentIndex] = i.toFloat() 21 | colors[i] = ColorUtils.HSLToColor(color) 22 | } 23 | return colors 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /pikolo/src/main/java/com/madrapps/pikolo/components/hsl/LightnessComponent.kt: -------------------------------------------------------------------------------- 1 | package com.madrapps.pikolo.components.hsl 2 | 3 | import androidx.core.graphics.ColorUtils 4 | import com.madrapps.pikolo.Metrics 5 | import com.madrapps.pikolo.Paints 6 | import com.madrapps.pikolo.components.ArcComponent 7 | 8 | internal class LightnessComponent(metrics: Metrics, paints: Paints, arcLength: Float, arcStartAngle: Float) : ArcComponent(metrics, paints, arcLength, arcStartAngle) { 9 | 10 | override val componentIndex: Int = 2 11 | override val range: Float = 1f 12 | override val noOfColors = 11 // TODO 3 should be sufficient 13 | override val colors = IntArray(noOfColors) 14 | override val colorPosition = FloatArray(noOfColors) 15 | 16 | override fun getColorArray(color: FloatArray): IntArray { 17 | for (i in 0 until noOfColors) { 18 | color[componentIndex] = i.toFloat() / (noOfColors - 1) 19 | colors[i] = ColorUtils.HSLToColor(color) 20 | } 21 | return colors 22 | } 23 | } -------------------------------------------------------------------------------- /pikolo/src/main/java/com/madrapps/pikolo/components/hsl/SaturationComponent.kt: -------------------------------------------------------------------------------- 1 | package com.madrapps.pikolo.components.hsl 2 | 3 | import androidx.core.graphics.ColorUtils 4 | import com.madrapps.pikolo.Metrics 5 | import com.madrapps.pikolo.Paints 6 | import com.madrapps.pikolo.components.ArcComponent 7 | 8 | internal class SaturationComponent(metrics: Metrics, paints: Paints, arcLength: Float, arcStartAngle: Float) : ArcComponent(metrics, paints, arcLength, arcStartAngle) { 9 | 10 | override val componentIndex: Int = 1 11 | override val range: Float = 1f 12 | override val noOfColors = 11 // TODO 2 should be sufficient 13 | override val colors = IntArray(noOfColors) 14 | override val colorPosition = FloatArray(noOfColors) 15 | 16 | override fun getColorArray(color: FloatArray): IntArray { 17 | for (i in 0 until noOfColors) { 18 | color[componentIndex] = i.toFloat() / (noOfColors - 1) 19 | colors[i] = ColorUtils.HSLToColor(color) 20 | } 21 | return colors 22 | } 23 | } -------------------------------------------------------------------------------- /pikolo/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 /Users/tsaravana/Me/Programming/SDK/Android/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 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /sample/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 /Users/tsaravana/Me/Programming/SDK/Android/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 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish 2 | 3 | on: 4 | release: 5 | types: [created] 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Checkout 12 | uses: actions/checkout@v2 13 | 14 | - name: Setup JDK 11 15 | uses: actions/setup-java@v1 16 | with: 17 | java-version: 11 18 | 19 | - name: Check 20 | run: ./gradlew check --stacktrace 21 | 22 | - name: Build 23 | run: ./gradlew build --stacktrace 24 | 25 | - name: Publish Artifact 26 | run: ./gradlew pikolo:publishReleasePublicationToSonatypeRepository --max-workers=1 closeAndReleaseSonatypeStagingRepository --stacktrace 27 | env: 28 | OSS_USERNAME: ${{ secrets.OSS_USERNAME }} 29 | OSS_PASSWORD: ${{ secrets.OSS_PASSWORD }} 30 | OSS_STAGING_PROFILE_ID: ${{ secrets.OSS_STAGING_PROFILE_ID }} 31 | OSS_SIGNING_KEY_ID: ${{ secrets.OSS_SIGNING_KEY_ID }} 32 | OSS_SIGNING_PASSWORD: ${{ secrets.OSS_SIGNING_PASSWORD }} 33 | OSS_SIGNING_KEY: ${{ secrets.OSS_SIGNING_KEY }} 34 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | sudo: false 3 | install: true 4 | 5 | jdk: oraclejdk8 6 | android: 7 | components: 8 | - tools 9 | - platform-tools 10 | 11 | # The BuildTools version used by your project 12 | - build-tools-28.0.3 13 | 14 | # The SDK version used to compile your project 15 | - android-28 16 | 17 | env: 18 | global: 19 | # install timeout in minutes (2 minutes by default) 20 | - ADB_INSTALL_TIMEOUT=8 21 | 22 | before_install: 23 | - mkdir "$ANDROID_HOME/licenses" || true 24 | - echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license" 25 | - echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license" 26 | 27 | before_script: 28 | - android list target 29 | 30 | jobs: 31 | include: 32 | - stage: compile 33 | script: ./gradlew assemble 34 | - stage: deploy 35 | if: branch = master AND type != pull_request 36 | script: ./gradlew bintrayUpload 37 | 38 | cache: 39 | directories: 40 | - '$HOME/.m2/repository' 41 | - '$HOME/.gradle' 42 | - '.gradle' -------------------------------------------------------------------------------- /sample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 30 5 | defaultConfig { 6 | applicationId "com.madrapps.pickcolor" 7 | minSdkVersion 15 8 | targetSdkVersion 30 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled true 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | // implementation project(':pikolo') 23 | implementation 'com.github.madrapps:pikolo:2.0.2' 24 | 25 | implementation fileTree(include: ['*.jar'], dir: 'libs') 26 | implementation 'androidx.appcompat:appcompat:1.3.1' 27 | implementation 'androidx.constraintlayout:constraintlayout:2.1.0' 28 | testImplementation 'junit:junit:4.13.2' 29 | 30 | androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', { 31 | exclude group: 'com.android.support', module: 'support-annotations' 32 | }) 33 | } 34 | -------------------------------------------------------------------------------- /pikolo/src/main/java/com/madrapps/pikolo/Metrics.kt: -------------------------------------------------------------------------------- 1 | package com.madrapps.pikolo 2 | 3 | import android.graphics.Paint 4 | import java.util.* 5 | 6 | internal abstract class Metrics(var centerX: Float = 0f, var centerY: Float = 0f, var color: FloatArray, val density: Float) { 7 | override fun equals(other: Any?): Boolean { 8 | if (this === other) return true 9 | if (javaClass != other?.javaClass) return false 10 | 11 | other as Metrics 12 | 13 | if (centerX != other.centerX) return false 14 | if (centerY != other.centerY) return false 15 | if (!Arrays.equals(color, other.color)) return false 16 | if (density != other.density) return false 17 | 18 | return true 19 | } 20 | 21 | override fun hashCode(): Int { 22 | var result = centerX.hashCode() 23 | result = 31 * result + centerY.hashCode() 24 | result = 31 * result + Arrays.hashCode(color) 25 | result = 31 * result + density.hashCode() 26 | return result 27 | } 28 | 29 | abstract fun getColor(): Int 30 | 31 | abstract fun hue(): Float 32 | } 33 | 34 | data class Paints(val shaderPaint: Paint = Paint(Paint.ANTI_ALIAS_FLAG), val indicatorPaint: Paint = Paint(Paint.ANTI_ALIAS_FLAG)) -------------------------------------------------------------------------------- /pikolo/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'kotlin-android' 3 | 4 | def groupId = "com.github.madrapps" 5 | def artifactId = "pikolo" 6 | def libVersion = "2.0.2" 7 | 8 | ext { 9 | GROUP_ID = groupId 10 | ARTIFACT_ID = artifactId 11 | VERSION = libVersion 12 | } 13 | 14 | apply from: 'publish.gradle' 15 | 16 | android { 17 | compileSdkVersion 30 18 | 19 | defaultConfig { 20 | minSdkVersion 15 21 | targetSdkVersion 30 22 | version libVersion 23 | 24 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 25 | 26 | } 27 | buildTypes { 28 | release { 29 | minifyEnabled false 30 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 31 | } 32 | } 33 | } 34 | 35 | dependencies { 36 | implementation fileTree(dir: 'libs', include: ['*.jar']) 37 | implementation 'androidx.appcompat:appcompat:1.3.1' 38 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 39 | 40 | testImplementation 'junit:junit:4.13.2' 41 | 42 | androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', { 43 | exclude group: 'com.android.support', module: 'support-annotations' 44 | }) 45 | } 46 | 47 | repositories { 48 | google() 49 | mavenCentral() 50 | } 51 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Pikolo 2 | 3 | An android color picker library 4 | 5 | previewpreviewpreview 6 | 7 | Download 8 | ----- 9 | 10 | ```gradle 11 | repositories { 12 | mavenCentral() 13 | } 14 | 15 | dependencies { 16 | implementation 'com.github.madrapps:pikolo:2.0.2' 17 | } 18 | ``` 19 | 20 | Features 21 | ----- 22 | - Includes `HSLColorPicker` and `RGBColorPicker` 23 | - Full customization of the various parts of the color picker (like arc length, arc position, indicator size, color, etc...) using XML attributes 24 | 25 | Usage 26 | ----- 27 | Add the `HSLColorPicker` or `RGBColorPicker` view to your layout and use it in code as below: 28 | 29 | ```java 30 | final ColorPicker colorPicker = findViewById(R.id.colorPicker); 31 | colorPicker.setColorSelectionListener(new SimpleColorSelectionListener() { 32 | @Override 33 | public void onColorSelected(int color) { 34 | // Do whatever you want with the color 35 | imageView.getBackground().setColorFilter(color, PorterDuff.Mode.MULTIPLY); 36 | } 37 | }); 38 | ``` 39 | 40 | You can take a look at the [sample](https://github.com/Madrapps/Pikolo/tree/master/sample) app to see how 41 | the color picker can be customised. There are 3 components in both pickers. You can change their properties 42 | together or individually. For instance, `arc_length` changes the length of the arc for all 3 components, while 43 | `hue_arc_length` affects only the Hue component. Various other XML attributes are as follows:
44 | 45 | `arc_width` - width (thickness) of the components
46 | `arc_length` - length of the components
47 | `stroke_width` - width of the stroke of the components
48 | `stroke_color` - stroke color of the components
49 | `indicator_radius` - radius of the control indicator used to change color
50 | `indicator_stroke_width` - stroke width of indicator
51 | `indicator_stroke_color` - stroke color of indicator
52 | `radius_offset` - the offset of the components from the center of the picker
53 | 54 | 55 | License 56 | ----- 57 | 58 | Pikolo by [Madrapps](http://madrapps.github.io/) is licensed under a [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0). 59 | -------------------------------------------------------------------------------- /pikolo/publish.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'maven-publish' 2 | apply plugin: 'signing' 3 | 4 | task androidSourcesJar(type: Jar) { 5 | archiveClassifier.set('sources') 6 | from android.sourceSets.main.java.srcDirs 7 | from android.sourceSets.main.kotlin.srcDirs 8 | } 9 | 10 | artifacts { 11 | archives androidSourcesJar 12 | } 13 | 14 | def siteUrl = 'https://github.com/Madrapps/Pikolo' 15 | def gitUrl = 'https://github.com/Madrapps/Pikolo.git' 16 | 17 | group = GROUP_ID 18 | version = VERSION 19 | 20 | afterEvaluate { 21 | publishing { 22 | publications { 23 | release(MavenPublication) { 24 | 25 | groupId GROUP_ID 26 | artifactId ARTIFACT_ID 27 | version VERSION 28 | 29 | from components.release 30 | artifact androidSourcesJar 31 | 32 | pom { 33 | name = ARTIFACT_ID 34 | description = 'An android color picker library' 35 | url = siteUrl 36 | licenses { 37 | license { 38 | name = 'The Apache Software License, Version 2.0' 39 | url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' 40 | } 41 | } 42 | developers { 43 | developer { 44 | id = 'instrap' 45 | name = 'Madrapps' 46 | email = 'madrasappfactory@gmail.com' 47 | } 48 | developer { 49 | id = 'thsaravana' 50 | name = 'Saravana Thiyagaraj' 51 | email = 'th.saravana@gmail.com' 52 | } 53 | } 54 | 55 | scm { 56 | connection = gitUrl 57 | developerConnection = gitUrl 58 | url = siteUrl 59 | } 60 | } 61 | } 62 | } 63 | } 64 | } 65 | 66 | signing { 67 | useInMemoryPgpKeys( 68 | System.getenv("OSS_SIGNING_KEY_ID"), 69 | System.getenv("OSS_SIGNING_KEY"), 70 | System.getenv("OSS_SIGNING_PASSWORD"), 71 | ) 72 | sign publishing.publications 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 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 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 Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /sample/src/main/java/com/madrapps/pickcolor/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.madrapps.pickcolor; 2 | 3 | import android.graphics.PorterDuff; 4 | import android.graphics.drawable.ColorDrawable; 5 | import android.os.Bundle; 6 | import android.view.View; 7 | import android.widget.Button; 8 | import android.widget.ImageButton; 9 | import android.widget.ImageView; 10 | 11 | import androidx.appcompat.app.AppCompatActivity; 12 | import androidx.core.graphics.ColorUtils; 13 | 14 | import com.madrapps.pikolo.ColorPicker; 15 | import com.madrapps.pikolo.listeners.SimpleColorSelectionListener; 16 | 17 | import java.util.Random; 18 | 19 | public class MainActivity extends AppCompatActivity implements View.OnClickListener { 20 | 21 | private ColorPicker colorPicker; 22 | private ImageView imageView; 23 | private Button randomColorButton; 24 | 25 | private final Random random = new Random(); 26 | 27 | @Override 28 | protected void onCreate(Bundle savedInstanceState) { 29 | super.onCreate(savedInstanceState); 30 | setContentView(R.layout.activity_main); 31 | imageView = findViewById(R.id.imageView); 32 | 33 | colorPicker = findViewById(R.id.colorPicker); 34 | colorPicker.setColorSelectionListener(new SimpleColorSelectionListener() { 35 | @Override 36 | public void onColorSelected(int color) { 37 | // Do whatever you want with the color 38 | imageView.getBackground().setColorFilter(color, PorterDuff.Mode.MULTIPLY); 39 | } 40 | }); 41 | 42 | initializeColorButtons(); 43 | 44 | randomColorButton = findViewById(R.id.randomColorButton); 45 | randomColorButton.setOnClickListener(this); 46 | } 47 | 48 | private void initializeColorButtons() { 49 | findViewById(R.id.imageButton1).setOnClickListener(this); 50 | findViewById(R.id.imageButton2).setOnClickListener(this); 51 | findViewById(R.id.imageButton3).setOnClickListener(this); 52 | findViewById(R.id.imageButton4).setOnClickListener(this); 53 | findViewById(R.id.imageButton5).setOnClickListener(this); 54 | } 55 | 56 | @Override 57 | public void onClick(View v) { 58 | if (v.getId() == R.id.randomColorButton) { 59 | final int color = ColorUtils.HSLToColor(new float[]{random.nextInt(360), random.nextFloat(), random.nextFloat()}); 60 | final String hexColor = String.format("#%06X", (0xFFFFFF & color)); 61 | randomColorButton.setText(hexColor); 62 | randomColorButton.setBackgroundColor(color); 63 | imageView.getBackground().setColorFilter(color, PorterDuff.Mode.MULTIPLY); 64 | colorPicker.setColor(color); 65 | } 66 | if (v instanceof ImageButton) { 67 | final int color = ((ColorDrawable) ((ImageButton) v).getDrawable()).getColor(); 68 | imageView.getBackground().setColorFilter(color, PorterDuff.Mode.MULTIPLY); 69 | colorPicker.setColor(color); 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /pikolo/src/main/java/com/madrapps/pikolo/components/ColorComponent.kt: -------------------------------------------------------------------------------- 1 | package com.madrapps.pikolo.components 2 | 3 | import android.graphics.Canvas 4 | import android.graphics.PointF 5 | import android.graphics.Shader 6 | import android.view.MotionEvent 7 | import android.view.MotionEvent.* 8 | import com.madrapps.pikolo.Metrics 9 | import com.madrapps.pikolo.Paints 10 | import com.madrapps.pikolo.listeners.OnColorSelectionListener 11 | 12 | internal abstract class ColorComponent(val metrics: Metrics, val paints: Paints) { 13 | 14 | var radius: Float = 0f 15 | 16 | var fillWidth: Float = 0f 17 | var strokeWidth: Float = 0f 18 | var strokeColor: Int = 0 19 | 20 | var indicatorRadius: Float = 0f 21 | var indicatorStrokeWidth: Float = 0f 22 | var indicatorStrokeColor: Int = 0 23 | 24 | var indicatorX: Float = 0f 25 | var indicatorY: Float = 0f 26 | 27 | var angle: Double = 0.0 28 | 29 | private var isTouched = false 30 | private var colorSelectionListener: OnColorSelectionListener? = null 31 | 32 | abstract fun getShader(): Shader 33 | abstract fun drawComponent(canvas: Canvas) 34 | 35 | fun onTouchEvent(event: MotionEvent): Boolean { 36 | val x = event.x 37 | val y = event.y 38 | 39 | when (event.action) { 40 | ACTION_DOWN -> { 41 | if (PointF(x, y) in this) { 42 | colorSelectionListener?.onColorSelectionStart(metrics.getColor()) 43 | isTouched = true 44 | calculateAngle(x, y) 45 | updateComponent(angle) 46 | colorSelectionListener?.onColorSelected(metrics.getColor()) 47 | } 48 | } 49 | 50 | ACTION_MOVE -> { 51 | if (isTouched) { 52 | calculateAngle(x, y) 53 | updateComponent(angle) 54 | colorSelectionListener?.onColorSelected(metrics.getColor()) 55 | } 56 | } 57 | 58 | ACTION_UP -> { 59 | if (isTouched) colorSelectionListener?.onColorSelectionEnd(metrics.getColor()) 60 | isTouched = false 61 | } 62 | } 63 | 64 | return isTouched 65 | } 66 | 67 | operator fun contains(point: PointF): Boolean { 68 | val touchRadius = indicatorRadius + indicatorRadius * 0.2 69 | return point.x in (indicatorX - touchRadius)..(indicatorX + touchRadius) && point.y in (indicatorY - touchRadius)..(indicatorY + touchRadius) 70 | } 71 | 72 | open fun calculateAngle(x1: Float, y1: Float) { 73 | val x = x1 - metrics.centerX 74 | val y = y1 - metrics.centerY 75 | val c = Math.sqrt((x * x + y * y).toDouble()) 76 | 77 | angle = Math.toDegrees(Math.acos(x / c)) 78 | if (y < 0) { 79 | angle = 360 - angle 80 | } 81 | } 82 | 83 | abstract fun updateComponent(angle: Double) 84 | 85 | abstract fun updateAngle(component: Float) 86 | 87 | internal fun setColorSelectionListener(listener: OnColorSelectionListener) { 88 | colorSelectionListener = listener 89 | } 90 | 91 | internal fun setRadius(outerRadius: Float, offset: Float) { 92 | radius = outerRadius - (Math.max(indicatorRadius + indicatorStrokeWidth, fillWidth)) - offset 93 | } 94 | } -------------------------------------------------------------------------------- /pikolo/src/main/java/com/madrapps/pikolo/ColorPicker.kt: -------------------------------------------------------------------------------- 1 | package com.madrapps.pikolo 2 | 3 | import android.content.Context 4 | import android.graphics.Canvas 5 | import android.os.Parcel 6 | import android.os.Parcelable 7 | import android.util.AttributeSet 8 | import android.util.TypedValue 9 | import android.view.View 10 | import com.madrapps.pikolo.listeners.OnColorSelectionListener 11 | 12 | abstract class ColorPicker @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : View(context, attrs, defStyleAttr) { 13 | 14 | protected val paints = Paints() 15 | protected val config: Config 16 | 17 | internal abstract val color: Int 18 | 19 | abstract override fun onDraw(canvas: Canvas) 20 | abstract override fun onSizeChanged(width: Int, height: Int, oldW: Int, oldH: Int) 21 | abstract fun setColorSelectionListener(listener: OnColorSelectionListener) 22 | abstract fun setColor(color: Int) 23 | 24 | init { 25 | val typedArray = context.obtainStyledAttributes(attrs, R.styleable.ColorPicker, defStyleAttr, 0) 26 | 27 | val arcWidth = typedArray.getDimension(R.styleable.ColorPicker_arc_width, dp(5f)) 28 | val strokeWidth = typedArray.getDimension(R.styleable.ColorPicker_stroke_width, 0f) 29 | val indicatorRadius = typedArray.getDimension(R.styleable.ColorPicker_indicator_radius, dp(15f)) 30 | val indicatorStrokeWidth = typedArray.getDimension(R.styleable.ColorPicker_indicator_stroke_width, dp(2f)) 31 | val strokeColor = typedArray.getColor(R.styleable.ColorPicker_stroke_color, 0) 32 | val indicatorStrokeColor = typedArray.getColor(R.styleable.ColorPicker_indicator_stroke_color, 0) 33 | val arcLength = typedArray.getFloat(R.styleable.ColorPicker_arc_length, 0f) 34 | val radiusOffset = typedArray.getDimension(R.styleable.ColorPicker_radius_offset, 0f) 35 | 36 | typedArray.recycle() 37 | 38 | config = Config(arcWidth, strokeWidth, indicatorRadius, indicatorStrokeWidth, 39 | strokeColor, indicatorStrokeColor, arcLength, radiusOffset) 40 | } 41 | 42 | protected fun dp(value: Float): Float { 43 | return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, value, resources.displayMetrics) 44 | } 45 | 46 | override fun onSaveInstanceState(): Parcelable? { 47 | val bundle = super.onSaveInstanceState() 48 | if (bundle != null) { 49 | return SavedState(bundle).apply { 50 | color = this@ColorPicker.color 51 | } 52 | } 53 | return null 54 | } 55 | 56 | override fun onRestoreInstanceState(state: Parcelable?) { 57 | if (state is SavedState) { 58 | super.onRestoreInstanceState(state.superState) 59 | setColor(state.color) 60 | } else { 61 | super.onRestoreInstanceState(state) 62 | } 63 | } 64 | 65 | internal class SavedState : BaseSavedState { 66 | var color: Int = 0 67 | 68 | constructor(bundle: Parcelable) : super(bundle) 69 | 70 | private constructor(parcel: Parcel) : super(parcel) { 71 | color = parcel.readInt() 72 | } 73 | 74 | companion object { 75 | @JvmField 76 | val CREATOR: Parcelable.Creator = object : Parcelable.Creator { 77 | override fun createFromParcel(source: Parcel): SavedState = SavedState(source) 78 | override fun newArray(size: Int): Array = arrayOfNulls(size) 79 | } 80 | } 81 | 82 | override fun describeContents() = 0 83 | 84 | override fun writeToParcel(dest: Parcel, flags: Int) { 85 | super.writeToParcel(dest, flags) 86 | dest.writeInt(color) 87 | } 88 | } 89 | 90 | data class Config(val arcWidth: Float, 91 | val strokeWidth: Float, 92 | val indicatorRadius: Float, 93 | val indicatorStrokeWidth: Float, 94 | val strokeColor: Int, 95 | val indicatorStrokeColor: Int, 96 | val arcLength: Float, 97 | val radiusOffset: Float) 98 | } -------------------------------------------------------------------------------- /pikolo/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 58 | 59 | 73 | 74 | 85 | 86 | 97 | 98 | 109 | 110 | 121 | 122 | 133 | 134 |