Skip to content

Commit

Permalink
Merge pull request #61 from side-codes/develop
Browse files Browse the repository at this point in the history
Release v0.4.0
  • Loading branch information
smelfungus authored Jun 12, 2020
2 parents 84d928f + 4e24fda commit 8fa30bd
Show file tree
Hide file tree
Showing 23 changed files with 415 additions and 189 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
Gradle dependency:

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

## :art: Picker types
Expand Down
14 changes: 7 additions & 7 deletions andcolorpicker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ android {
buildToolsVersion "29.0.3"

defaultConfig {
minSdkVersion 21
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.0"
Expand All @@ -35,19 +35,19 @@ dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

implementation "androidx.appcompat:appcompat:1.2.0-alpha03"
implementation "androidx.core:core-ktx:1.3.0-alpha02"
implementation "androidx.constraintlayout:constraintlayout:2.0.0-beta4"
implementation "androidx.appcompat:appcompat:1.3.0-alpha01"
implementation "androidx.core:core-ktx:1.4.0-alpha01"
implementation "androidx.constraintlayout:constraintlayout:2.0.0-beta6"

testImplementation "junit:junit:4.13"
androidTestImplementation "androidx.test.ext:junit:1.1.2-alpha05"
androidTestImplementation "androidx.test.espresso:espresso-core:3.3.0-alpha05"
androidTestImplementation "androidx.test.ext:junit:1.1.2-rc01"
androidTestImplementation "androidx.test.espresso:espresso-core:3.3.0-rc01"
}

publish {
def groupProjectID = "codes.side"
def artifactProjectID = "andcolorpicker"
def publishVersionID = "0.3.0"
def publishVersionID = "0.4.0"
userOrg = "side-codes"
repoName = "andColorPicker"
groupId = groupProjectID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.graphics.drawable.Drawable
import android.graphics.drawable.GradientDrawable
import android.graphics.drawable.LayerDrawable
import android.util.AttributeSet
import androidx.annotation.StringRes
import androidx.core.graphics.ColorUtils
import codes.side.andcolorpicker.R
import codes.side.andcolorpicker.converter.IntegerRGBColorConverter
Expand Down Expand Up @@ -229,7 +230,8 @@ class RGBColorPickerSeekBar @JvmOverloads constructor(
enum class Mode(
override val minProgress: Int,
override val maxProgress: Int,
val coloringModeCheckpointsMap: HashMap<ColoringMode, IntArray>
val coloringModeCheckpointsMap: HashMap<ColoringMode, IntArray>,
@StringRes val nameStringResId: Int
) : ColorSeekBar.Mode {
MODE_R(
IntegerRGBColor.Component.R.minValue,
Expand All @@ -243,7 +245,8 @@ class RGBColorPickerSeekBar @JvmOverloads constructor(
Color.RED,
Color.RED
)
)
),
R.string.title_red
),
MODE_G(
IntegerRGBColor.Component.G.minValue,
Expand All @@ -257,7 +260,8 @@ class RGBColorPickerSeekBar @JvmOverloads constructor(
Color.GREEN,
Color.GREEN
)
)
),
R.string.title_green
),
MODE_B(
IntegerRGBColor.Component.B.minValue,
Expand All @@ -271,7 +275,8 @@ class RGBColorPickerSeekBar @JvmOverloads constructor(
Color.BLUE,
Color.BLUE
)
)
),
R.string.title_blue
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package codes.side.andcolorpicker.view.picker

import android.animation.ObjectAnimator
import android.content.Context
import android.content.res.ColorStateList
import android.graphics.drawable.*
import android.os.Build
import android.util.AttributeSet
Expand Down Expand Up @@ -98,7 +97,9 @@ abstract class ColorSeekBar<C : Color> @JvmOverloads constructor(
}

init {
splitTrack = false
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
splitTrack = false
}

setOnSeekBarChangeListener(this)

Expand All @@ -116,17 +117,19 @@ abstract class ColorSeekBar<C : Color> @JvmOverloads constructor(
* Setups views's background drawable. Adjusts initial thumb ripple size.
*/
private fun setupBackground() {
background = background.mutate()
.also {
if (it is RippleDrawable) {
// TODO: Set ripple size for pre-M too
// TODO: Make ripple size configurable?
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
val rippleSizePx = resources.getDimensionPixelOffset(R.dimen.acp_thumb_ripple_radius)
it.radius = rippleSizePx
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
background = background.mutate()
.also {
if (it is RippleDrawable) {
// TODO: Set ripple size for pre-M too
// TODO: Make ripple size configurable?
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
val rippleSizePx = resources.getDimensionPixelOffset(R.dimen.acp_thumb_ripple_radius)
it.radius = rippleSizePx
}
}
}
}
}
}

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

thumbDrawable = GradientDrawable().also {
it.color = ColorStateList.valueOf(android.graphics.Color.WHITE)
it.setColor(android.graphics.Color.WHITE)
it.shape = GradientDrawable.OVAL
it.setSize(
thumbFullSizePx,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package codes.side.andcolorpicker.view.set

import android.content.Context
import android.os.Build
import android.util.AttributeSet
import android.widget.LinearLayout
import android.widget.TextView
import androidx.annotation.StringRes
import codes.side.andcolorpicker.group.PickerGroup
import codes.side.andcolorpicker.model.Color

abstract class ColorPickerSeekBarSet<C : Color> @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyle: Int = 0
) : LinearLayout(
context,
attrs,
defStyle
) {
companion object {
private const val TAG = "ColorPickerSeekBarSet"
internal const val defaultTextAppearance = android.R.style.TextAppearance_Material_Caption
}

val pickerGroup = PickerGroup<C>()

init {
orientation = VERTICAL
init(attrs)
}

private fun init(attrs: AttributeSet? = null) {
//val typedArray = context.theme.obtainStyledAttributes(
// attrs,
// R.styleable.ColorPickerSeekBarSet,
// 0,
// 0
//)

//typedArray.recycle()
}

protected fun addLabel(@StringRes titleResId: Int) {
addView(
TextView(
context
).also {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
@Suppress("DEPRECATION")
it.setTextAppearance(
context,
defaultTextAppearance
)
} else {
it.setTextAppearance(defaultTextAppearance)
}
it.setText(titleResId)
}
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package codes.side.andcolorpicker.view.set

import android.content.Context
import android.util.AttributeSet
import codes.side.andcolorpicker.model.IntegerRGBColor
import codes.side.andcolorpicker.rgb.RGBColorPickerSeekBar

class RGBColorPickerSeekBarSet @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyle: Int = 0
) : ColorPickerSeekBarSet<IntegerRGBColor>(
context,
attrs,
defStyle
) {
init {
RGBColorPickerSeekBar.Mode.values().forEach { rgbMode ->
addLabel(rgbMode.nameStringResId)
val picker =
RGBColorPickerSeekBar(
context
).also {
it.mode = rgbMode
}
pickerGroup.registerPicker(picker)
addView(picker)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import android.graphics.drawable.LayerDrawable
import android.util.AttributeSet
import android.view.View
import androidx.annotation.ColorInt
import androidx.core.content.ContextCompat
import androidx.core.graphics.drawable.DrawableCompat
import codes.side.andcolorpicker.R
import codes.side.andcolorpicker.converter.ColorConverterHub
import codes.side.andcolorpicker.model.Color
Expand All @@ -20,7 +22,12 @@ class SwatchView @JvmOverloads constructor(
defStyleAttr
) {
private val patternDrawable =
requireNotNull(context.getDrawable(R.drawable.bg_transparency_pattern))
requireNotNull(
ContextCompat.getDrawable(
context,
R.drawable.bg_transparency_pattern
)
)

init {
background = LayerDrawable(
Expand All @@ -37,6 +44,9 @@ class SwatchView @JvmOverloads constructor(
}

fun setSwatchPatternTint(@ColorInt tintColor: Int) {
patternDrawable.setTint(tintColor)
DrawableCompat.setTint(
patternDrawable,
tintColor
)
}
}
30 changes: 17 additions & 13 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ android {

defaultConfig {
applicationId "codes.side.andcolorpicker.app"
minSdkVersion 21
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.0"
Expand All @@ -38,34 +38,38 @@ android {
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

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

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "androidx.appcompat:appcompat:1.2.0-alpha03"
implementation "androidx.appcompat:appcompat:1.3.0-alpha01"

implementation "androidx.core:core-ktx:1.3.0-alpha02"
implementation "androidx.core:core-ktx:1.4.0-alpha01"

implementation "androidx.recyclerview:recyclerview:1.2.0-alpha01"
implementation "androidx.recyclerview:recyclerview:1.2.0-alpha03"
implementation "androidx.annotation:annotation:1.1.0"
implementation "androidx.fragment:fragment-ktx:1.3.0-alpha02"
implementation "androidx.constraintlayout:constraintlayout:2.0.0-beta4"
implementation "com.google.android.material:material:1.2.0-alpha05"
implementation "com.mikepenz:materialdrawer:8.0.0"
implementation "androidx.fragment:fragment-ktx:1.3.0-alpha06"
implementation "androidx.constraintlayout:constraintlayout:2.0.0-beta6"
implementation "com.google.android.material:material:1.3.0-alpha01"
implementation "com.mikepenz:materialdrawer:8.1.1"

implementation "com.mikepenz:iconics-core:5.0.1"
implementation "com.mikepenz:iconics-core:5.0.3"
implementation "com.mikepenz:material-design-icons-dx-typeface:5.0.1.0-kotlin@aar"
implementation "com.mikepenz:fontawesome-typeface:5.9.0.0-kotlin@aar"

implementation "com.mikepenz:fastadapter:5.0.0"
implementation "com.mikepenz:fastadapter-extensions-diff:5.0.0"
implementation "com.mikepenz:fastadapter:5.1.0"
implementation "com.mikepenz:fastadapter-extensions-diff:5.1.0"

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

testImplementation "junit:junit:4.13"
androidTestImplementation "androidx.test.ext:junit:1.1.2-alpha05"
androidTestImplementation "androidx.test.espresso:espresso-core:3.3.0-alpha05"
androidTestImplementation "androidx.test.ext:junit:1.1.2-rc01"
androidTestImplementation "androidx.test.espresso:espresso-core:3.3.0-rc01"
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import android.content.Intent
import android.content.res.ColorStateList
import android.content.res.Configuration
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.view.MenuItem
import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.fragment.app.Fragment
import codes.side.andcolorpicker.app.ColorizationConsumer
import codes.side.andcolorpicker.app.R
Expand Down Expand Up @@ -164,13 +166,24 @@ class MainActivity : AppCompatActivity(),
colorizeHSLColorCache.setFrom(color)
colorizeHSLColorCache.floatL = colorizeHSLColorCache.floatL.coerceAtMost(0.8f)

appBarLayout.backgroundTintList =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
appBarLayout.backgroundTintList =
ColorStateList.valueOf(colorizeHSLColorCache.toOpaqueColorInt())
} else {
appBarLayout.setBackgroundColor(colorizeHSLColorCache.toOpaqueColorInt())
}

ViewCompat.setBackgroundTintList(
appBarLayout,
ColorStateList.valueOf(colorizeHSLColorCache.toOpaqueColorInt())
)

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

window.statusBarColor = colorizeHSLColorCache.toOpaqueColorInt()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
window.statusBarColor = colorizeHSLColorCache.toOpaqueColorInt()
}

toolbar.setTitleTextColor(contrastColor)
toolbar.setSubtitleTextColor(contrastColor)
Expand Down
Loading

0 comments on commit 8fa30bd

Please sign in to comment.