Skip to content

Commit

Permalink
Merge pull request #17 from side-codes/develop
Browse files Browse the repository at this point in the history
Release v0.3.0
  • Loading branch information
smelfungus authored Mar 29, 2020
2 parents 055b26d + bee64b3 commit 92ea2d5
Show file tree
Hide file tree
Showing 33 changed files with 1,641 additions and 213 deletions.
64 changes: 61 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
Gradle dependency:

```gradle
implementation "codes.side:andcolorpicker:0.2.0"
implementation "codes.side:andcolorpicker:0.3.0"
```

## :art: Picker types
Expand All @@ -30,7 +30,7 @@ implementation "codes.side:andcolorpicker:0.2.0"

- *Add color model description*

![](github/type_hsl.png)
![](github/seek_bar_hsl_pure.png)

#### Layout XML Snippet

Expand Down Expand Up @@ -121,9 +121,39 @@ pickerGroup.setColor(
hueColorPickerSeekBar.progress = 50
```

### RGB (red, green, blue)

![](github/seek_bar_rgb_pure.png)

#### Layout XML Snippet

Basic RGB components:
```xml
<codes.side.andcolorpicker.rgb.RGBColorPickerSeekBar
android:id="@+id/redRGBColorPickerSeekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:rgbMode="red" />
```

### LAB

![](github/seek_bar_lab_output.png)

#### Layout XML Snippet

Basic LAB components:
```xml
<codes.side.andcolorpicker.lab.LABColorPickerSeekBar
android:id="@+id/lLABColorPickerSeekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:labMode="l" />
```

### CMYK (cyan, magenta, yellow, key)

![](github/type_cmyk.png)
![](github/seek_bar_cmyk_pure.png)

#### Layout XML Snippet

Expand All @@ -146,6 +176,34 @@ Supported `cmykColoringMode` values:
- `pure` (default)
- `output`

### Swatches

SwatchView component:
```xml
<codes.side.andcolorpicker.view.swatch.SwatchView
android:id="@+id/swatchView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
```

#### Kotlin Snippet:
```kotlin
swatchView.setSwatchPatternTint(
Color.LTGRAY
)

swatchView.setSwatchColor(
IntegerHSLColor().also {
it.setFromColorInt(
ColorUtils.setAlphaComponent(
Color.MAGENTA,
128
)
)
}
)
```

## :rocket: Roadmap

- [ ] Add more picker types
Expand Down
4 changes: 2 additions & 2 deletions andcolorpicker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ dependencies {
publish {
def groupProjectID = "codes.side"
def artifactProjectID = "andcolorpicker"
def publishVersionID = "0.2.0"
def publishVersionID = "0.3.0"
userOrg = "side-codes"
repoName = "andColorPicker"
groupId = groupProjectID
artifactId = artifactProjectID
publishVersion = publishVersionID
desc = "Handy, flexible and lightning-fast material color picker UI component for Android"
desc = "Handy, flexible and lightning-fast material color picker view components for Android"
website = "https://github.com/side-codes/andColorPicker"
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,16 @@ abstract class AlphaColorPickerSeekBar<C : Color> @JvmOverloads constructor(
return layerList.toTypedArray()
}

override fun refreshProgressDrawable() {
super.refreshProgressDrawable()

((progressDrawable as LayerDrawable).getDrawable(1) as GradientDrawable).colors =
override fun onRefreshProgressDrawable(progressDrawable: LayerDrawable) {
(progressDrawable.getDrawable(1) as GradientDrawable).colors =
intArrayOf(
android.graphics.Color.TRANSPARENT,
colorConverter.convertToOpaqueColorInt(internalPickedColor)
)
}

override fun refreshThumb() {
super.refreshThumb()

coloringDrawables.forEach {
override fun onRefreshThumb(thumbColoringDrawables: Set<Drawable>) {
thumbColoringDrawables.forEach {
when (it) {
is GradientDrawable -> {
paintThumbStroke(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,42 +20,43 @@ class HSLAlphaColorPickerSeekBar @JvmOverloads constructor(
defStyle
) {

private var isInitialized = false

override val colorConverter: IntegerHSLColorConverter
get() = super.colorConverter as IntegerHSLColorConverter

init {
refreshProperties()
isInitialized = true
}

override fun setMax(max: Int) {
if (isInitialized && max != IntegerHSLColor.Component.A.maxValue) {
throw IllegalArgumentException("Current mode supports ${IntegerHSLColor.Component.A.maxValue} max value only, was $max")
}
super.setMax(max)
}

override fun onUpdateColorFrom(color: IntegerHSLColor, value: IntegerHSLColor) {
color.setFrom(value)
}

override fun refreshProperties() {
super.refreshProperties()
override fun onRefreshProperties() {
max = IntegerHSLColor.Component.A.maxValue
}

override fun updateInternalPickedColorFrom(value: IntegerHSLColor) {
super.updateInternalPickedColorFrom(value)
internalPickedColor.setFrom(value)
override fun onRefreshProgressFromColor(color: IntegerHSLColor): Int? {
return color.intA
}

override fun refreshInternalPickedColorFromProgress() {
super.refreshInternalPickedColorFromProgress()
val currentProgress = progress
override fun onRefreshColorFromProgress(color: IntegerHSLColor, progress: Int): Boolean {
val currentA = internalPickedColor.intA
val changed = if (currentA != currentProgress) {
return if (currentA != progress) {
internalPickedColor.intA = progress
true
} else {
false
}

if (changed) {
notifyListenersOnColorChanged()
}
}

override fun refreshProgressFromCurrentColor() {
super.refreshProgressFromCurrentColor()
progress = internalPickedColor.intA
}

interface OnColorPickListener :
Expand Down
Loading

0 comments on commit 92ea2d5

Please sign in to comment.