Skip to content

Commit 8fa30bd

Browse files
authored
Merge pull request #61 from side-codes/develop
Release v0.4.0
2 parents 84d928f + 4e24fda commit 8fa30bd

23 files changed

+415
-189
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
Gradle dependency:
2424

2525
```gradle
26-
implementation "codes.side:andcolorpicker:0.3.0"
26+
implementation "codes.side:andcolorpicker:0.4.0"
2727
```
2828

2929
## :art: Picker types

andcolorpicker/build.gradle

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ android {
1212
buildToolsVersion "29.0.3"
1313

1414
defaultConfig {
15-
minSdkVersion 21
15+
minSdkVersion 19
1616
targetSdkVersion 29
1717
versionCode 1
1818
versionName "1.0"
@@ -35,19 +35,19 @@ dependencies {
3535
implementation fileTree(dir: "libs", include: ["*.jar"])
3636
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
3737

38-
implementation "androidx.appcompat:appcompat:1.2.0-alpha03"
39-
implementation "androidx.core:core-ktx:1.3.0-alpha02"
40-
implementation "androidx.constraintlayout:constraintlayout:2.0.0-beta4"
38+
implementation "androidx.appcompat:appcompat:1.3.0-alpha01"
39+
implementation "androidx.core:core-ktx:1.4.0-alpha01"
40+
implementation "androidx.constraintlayout:constraintlayout:2.0.0-beta6"
4141

4242
testImplementation "junit:junit:4.13"
43-
androidTestImplementation "androidx.test.ext:junit:1.1.2-alpha05"
44-
androidTestImplementation "androidx.test.espresso:espresso-core:3.3.0-alpha05"
43+
androidTestImplementation "androidx.test.ext:junit:1.1.2-rc01"
44+
androidTestImplementation "androidx.test.espresso:espresso-core:3.3.0-rc01"
4545
}
4646

4747
publish {
4848
def groupProjectID = "codes.side"
4949
def artifactProjectID = "andcolorpicker"
50-
def publishVersionID = "0.3.0"
50+
def publishVersionID = "0.4.0"
5151
userOrg = "side-codes"
5252
repoName = "andColorPicker"
5353
groupId = groupProjectID

andcolorpicker/src/main/java/codes/side/andcolorpicker/rgb/RGBColorPickerSeekBar.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import android.graphics.drawable.Drawable
66
import android.graphics.drawable.GradientDrawable
77
import android.graphics.drawable.LayerDrawable
88
import android.util.AttributeSet
9+
import androidx.annotation.StringRes
910
import androidx.core.graphics.ColorUtils
1011
import codes.side.andcolorpicker.R
1112
import codes.side.andcolorpicker.converter.IntegerRGBColorConverter
@@ -229,7 +230,8 @@ class RGBColorPickerSeekBar @JvmOverloads constructor(
229230
enum class Mode(
230231
override val minProgress: Int,
231232
override val maxProgress: Int,
232-
val coloringModeCheckpointsMap: HashMap<ColoringMode, IntArray>
233+
val coloringModeCheckpointsMap: HashMap<ColoringMode, IntArray>,
234+
@StringRes val nameStringResId: Int
233235
) : ColorSeekBar.Mode {
234236
MODE_R(
235237
IntegerRGBColor.Component.R.minValue,
@@ -243,7 +245,8 @@ class RGBColorPickerSeekBar @JvmOverloads constructor(
243245
Color.RED,
244246
Color.RED
245247
)
246-
)
248+
),
249+
R.string.title_red
247250
),
248251
MODE_G(
249252
IntegerRGBColor.Component.G.minValue,
@@ -257,7 +260,8 @@ class RGBColorPickerSeekBar @JvmOverloads constructor(
257260
Color.GREEN,
258261
Color.GREEN
259262
)
260-
)
263+
),
264+
R.string.title_green
261265
),
262266
MODE_B(
263267
IntegerRGBColor.Component.B.minValue,
@@ -271,7 +275,8 @@ class RGBColorPickerSeekBar @JvmOverloads constructor(
271275
Color.BLUE,
272276
Color.BLUE
273277
)
274-
)
278+
),
279+
R.string.title_blue
275280
)
276281
}
277282
}

andcolorpicker/src/main/java/codes/side/andcolorpicker/view/picker/ColorSeekBar.kt

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package codes.side.andcolorpicker.view.picker
22

33
import android.animation.ObjectAnimator
44
import android.content.Context
5-
import android.content.res.ColorStateList
65
import android.graphics.drawable.*
76
import android.os.Build
87
import android.util.AttributeSet
@@ -98,7 +97,9 @@ abstract class ColorSeekBar<C : Color> @JvmOverloads constructor(
9897
}
9998

10099
init {
101-
splitTrack = false
100+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
101+
splitTrack = false
102+
}
102103

103104
setOnSeekBarChangeListener(this)
104105

@@ -116,17 +117,19 @@ abstract class ColorSeekBar<C : Color> @JvmOverloads constructor(
116117
* Setups views's background drawable. Adjusts initial thumb ripple size.
117118
*/
118119
private fun setupBackground() {
119-
background = background.mutate()
120-
.also {
121-
if (it is RippleDrawable) {
122-
// TODO: Set ripple size for pre-M too
123-
// TODO: Make ripple size configurable?
124-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
125-
val rippleSizePx = resources.getDimensionPixelOffset(R.dimen.acp_thumb_ripple_radius)
126-
it.radius = rippleSizePx
120+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
121+
background = background.mutate()
122+
.also {
123+
if (it is RippleDrawable) {
124+
// TODO: Set ripple size for pre-M too
125+
// TODO: Make ripple size configurable?
126+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
127+
val rippleSizePx = resources.getDimensionPixelOffset(R.dimen.acp_thumb_ripple_radius)
128+
it.radius = rippleSizePx
129+
}
127130
}
128131
}
129-
}
132+
}
130133
}
131134

132135
private fun setupProgressDrawable() {
@@ -168,7 +171,7 @@ abstract class ColorSeekBar<C : Color> @JvmOverloads constructor(
168171
val thumbFullSizePx = resources.getDimensionPixelOffset(R.dimen.acp_thumb_size_full)
169172

170173
thumbDrawable = GradientDrawable().also {
171-
it.color = ColorStateList.valueOf(android.graphics.Color.WHITE)
174+
it.setColor(android.graphics.Color.WHITE)
172175
it.shape = GradientDrawable.OVAL
173176
it.setSize(
174177
thumbFullSizePx,
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package codes.side.andcolorpicker.view.set
2+
3+
import android.content.Context
4+
import android.os.Build
5+
import android.util.AttributeSet
6+
import android.widget.LinearLayout
7+
import android.widget.TextView
8+
import androidx.annotation.StringRes
9+
import codes.side.andcolorpicker.group.PickerGroup
10+
import codes.side.andcolorpicker.model.Color
11+
12+
abstract class ColorPickerSeekBarSet<C : Color> @JvmOverloads constructor(
13+
context: Context,
14+
attrs: AttributeSet? = null,
15+
defStyle: Int = 0
16+
) : LinearLayout(
17+
context,
18+
attrs,
19+
defStyle
20+
) {
21+
companion object {
22+
private const val TAG = "ColorPickerSeekBarSet"
23+
internal const val defaultTextAppearance = android.R.style.TextAppearance_Material_Caption
24+
}
25+
26+
val pickerGroup = PickerGroup<C>()
27+
28+
init {
29+
orientation = VERTICAL
30+
init(attrs)
31+
}
32+
33+
private fun init(attrs: AttributeSet? = null) {
34+
//val typedArray = context.theme.obtainStyledAttributes(
35+
// attrs,
36+
// R.styleable.ColorPickerSeekBarSet,
37+
// 0,
38+
// 0
39+
//)
40+
41+
//typedArray.recycle()
42+
}
43+
44+
protected fun addLabel(@StringRes titleResId: Int) {
45+
addView(
46+
TextView(
47+
context
48+
).also {
49+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
50+
@Suppress("DEPRECATION")
51+
it.setTextAppearance(
52+
context,
53+
defaultTextAppearance
54+
)
55+
} else {
56+
it.setTextAppearance(defaultTextAppearance)
57+
}
58+
it.setText(titleResId)
59+
}
60+
)
61+
}
62+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package codes.side.andcolorpicker.view.set
2+
3+
import android.content.Context
4+
import android.util.AttributeSet
5+
import codes.side.andcolorpicker.model.IntegerRGBColor
6+
import codes.side.andcolorpicker.rgb.RGBColorPickerSeekBar
7+
8+
class RGBColorPickerSeekBarSet @JvmOverloads constructor(
9+
context: Context,
10+
attrs: AttributeSet? = null,
11+
defStyle: Int = 0
12+
) : ColorPickerSeekBarSet<IntegerRGBColor>(
13+
context,
14+
attrs,
15+
defStyle
16+
) {
17+
init {
18+
RGBColorPickerSeekBar.Mode.values().forEach { rgbMode ->
19+
addLabel(rgbMode.nameStringResId)
20+
val picker =
21+
RGBColorPickerSeekBar(
22+
context
23+
).also {
24+
it.mode = rgbMode
25+
}
26+
pickerGroup.registerPicker(picker)
27+
addView(picker)
28+
}
29+
}
30+
}

andcolorpicker/src/main/java/codes/side/andcolorpicker/view/swatch/SwatchView.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import android.graphics.drawable.LayerDrawable
66
import android.util.AttributeSet
77
import android.view.View
88
import androidx.annotation.ColorInt
9+
import androidx.core.content.ContextCompat
10+
import androidx.core.graphics.drawable.DrawableCompat
911
import codes.side.andcolorpicker.R
1012
import codes.side.andcolorpicker.converter.ColorConverterHub
1113
import codes.side.andcolorpicker.model.Color
@@ -20,7 +22,12 @@ class SwatchView @JvmOverloads constructor(
2022
defStyleAttr
2123
) {
2224
private val patternDrawable =
23-
requireNotNull(context.getDrawable(R.drawable.bg_transparency_pattern))
25+
requireNotNull(
26+
ContextCompat.getDrawable(
27+
context,
28+
R.drawable.bg_transparency_pattern
29+
)
30+
)
2431

2532
init {
2633
background = LayerDrawable(
@@ -37,6 +44,9 @@ class SwatchView @JvmOverloads constructor(
3744
}
3845

3946
fun setSwatchPatternTint(@ColorInt tintColor: Int) {
40-
patternDrawable.setTint(tintColor)
47+
DrawableCompat.setTint(
48+
patternDrawable,
49+
tintColor
50+
)
4151
}
4252
}

app/build.gradle

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ android {
1313

1414
defaultConfig {
1515
applicationId "codes.side.andcolorpicker.app"
16-
minSdkVersion 21
16+
minSdkVersion 19
1717
targetSdkVersion 29
1818
versionCode 1
1919
versionName "1.0"
@@ -38,34 +38,38 @@ android {
3838
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
3939
}
4040
}
41+
compileOptions {
42+
sourceCompatibility JavaVersion.VERSION_1_8
43+
targetCompatibility JavaVersion.VERSION_1_8
44+
}
4145
}
4246

4347
dependencies {
4448
implementation fileTree(dir: "libs", include: ["*.jar"])
4549
implementation project(":andcolorpicker")
4650

4751
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
48-
implementation "androidx.appcompat:appcompat:1.2.0-alpha03"
52+
implementation "androidx.appcompat:appcompat:1.3.0-alpha01"
4953

50-
implementation "androidx.core:core-ktx:1.3.0-alpha02"
54+
implementation "androidx.core:core-ktx:1.4.0-alpha01"
5155

52-
implementation "androidx.recyclerview:recyclerview:1.2.0-alpha01"
56+
implementation "androidx.recyclerview:recyclerview:1.2.0-alpha03"
5357
implementation "androidx.annotation:annotation:1.1.0"
54-
implementation "androidx.fragment:fragment-ktx:1.3.0-alpha02"
55-
implementation "androidx.constraintlayout:constraintlayout:2.0.0-beta4"
56-
implementation "com.google.android.material:material:1.2.0-alpha05"
57-
implementation "com.mikepenz:materialdrawer:8.0.0"
58+
implementation "androidx.fragment:fragment-ktx:1.3.0-alpha06"
59+
implementation "androidx.constraintlayout:constraintlayout:2.0.0-beta6"
60+
implementation "com.google.android.material:material:1.3.0-alpha01"
61+
implementation "com.mikepenz:materialdrawer:8.1.1"
5862

59-
implementation "com.mikepenz:iconics-core:5.0.1"
63+
implementation "com.mikepenz:iconics-core:5.0.3"
6064
implementation "com.mikepenz:material-design-icons-dx-typeface:5.0.1.0-kotlin@aar"
6165
implementation "com.mikepenz:fontawesome-typeface:5.9.0.0-kotlin@aar"
6266

63-
implementation "com.mikepenz:fastadapter:5.0.0"
64-
implementation "com.mikepenz:fastadapter-extensions-diff:5.0.0"
67+
implementation "com.mikepenz:fastadapter:5.1.0"
68+
implementation "com.mikepenz:fastadapter-extensions-diff:5.1.0"
6569

6670
implementation "com.google.android.gms:play-services-oss-licenses:17.0.0"
6771

6872
testImplementation "junit:junit:4.13"
69-
androidTestImplementation "androidx.test.ext:junit:1.1.2-alpha05"
70-
androidTestImplementation "androidx.test.espresso:espresso-core:3.3.0-alpha05"
73+
androidTestImplementation "androidx.test.ext:junit:1.1.2-rc01"
74+
androidTestImplementation "androidx.test.espresso:espresso-core:3.3.0-rc01"
7175
}

app/src/main/java/codes/side/andcolorpicker/app/activity/MainActivity.kt

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import android.content.Intent
44
import android.content.res.ColorStateList
55
import android.content.res.Configuration
66
import android.net.Uri
7+
import android.os.Build
78
import android.os.Bundle
89
import android.view.MenuItem
910
import androidx.appcompat.app.ActionBarDrawerToggle
1011
import androidx.appcompat.app.AppCompatActivity
12+
import androidx.core.view.ViewCompat
1113
import androidx.fragment.app.Fragment
1214
import codes.side.andcolorpicker.app.ColorizationConsumer
1315
import codes.side.andcolorpicker.app.R
@@ -164,13 +166,24 @@ class MainActivity : AppCompatActivity(),
164166
colorizeHSLColorCache.setFrom(color)
165167
colorizeHSLColorCache.floatL = colorizeHSLColorCache.floatL.coerceAtMost(0.8f)
166168

167-
appBarLayout.backgroundTintList =
169+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
170+
appBarLayout.backgroundTintList =
171+
ColorStateList.valueOf(colorizeHSLColorCache.toOpaqueColorInt())
172+
} else {
173+
appBarLayout.setBackgroundColor(colorizeHSLColorCache.toOpaqueColorInt())
174+
}
175+
176+
ViewCompat.setBackgroundTintList(
177+
appBarLayout,
168178
ColorStateList.valueOf(colorizeHSLColorCache.toOpaqueColorInt())
179+
)
169180

170181
// Overwrite cache for StatusBar
171182
colorizeHSLColorCache.floatL -= 0.1f
172183

173-
window.statusBarColor = colorizeHSLColorCache.toOpaqueColorInt()
184+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
185+
window.statusBarColor = colorizeHSLColorCache.toOpaqueColorInt()
186+
}
174187

175188
toolbar.setTitleTextColor(contrastColor)
176189
toolbar.setSubtitleTextColor(contrastColor)

0 commit comments

Comments
 (0)