Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add minimumWheelLightness #135

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 29
buildToolsVersion "29.0.0"
compileSdkVersion 30
buildToolsVersion "29.0.2"

defaultConfig {
applicationId "com.flask.colorpicker.sample"
minSdkVersion 14
targetSdkVersion 29
targetSdkVersion 30
versionCode 10
versionName "1.0.10"

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_sample2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
android:layout_height="wrap_content"
app:alphaSlider="true"
app:density="12"
app:minimumWheelLightness="0.01"
app:lightnessSlider="true"
app:wheelType="FLOWER"
app:lightnessSliderView="@+id/v_lightness_slider"
Expand Down
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
classpath 'com.android.tools.build:gradle:7.2.2'
classpath "com.github.dcendents:android-maven-gradle-plugin:2.1"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -17,5 +18,6 @@ allprojects {
repositories {
jcenter()
google()
maven { url "https://jitpack.io" }
}
}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
android.useAndroidX=true
5 changes: 2 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Thu Nov 07 22:59:21 KST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
zipStorePath=wrapper/dists
11 changes: 8 additions & 3 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
apply plugin: 'com.android.library'

group='com.github.QuadFlask'

android {
compileSdkVersion 29
buildToolsVersion "29.0.0"
compileSdkVersion 30
buildToolsVersion "29.0.2"

defaultConfig {
minSdkVersion 14
targetSdkVersion 29
targetSdkVersion 30
versionCode 17
versionName "0.0.15"
}
Expand All @@ -22,3 +24,6 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
}
repositories {
mavenCentral()
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class ColorPickerView extends View {
private Integer initialColors[] = new Integer[]{null, null, null, null, null};
private int colorSelection = 0;
private Integer initialColor;
private float minimumWheelLightness;
private Integer pickerColorEditTextColor;
private Paint colorWheelFill = PaintBuilder.newPaint().color(0).build();
private Paint selectorStroke = PaintBuilder.newPaint().color(0).build();
Expand Down Expand Up @@ -108,6 +109,7 @@ private void initWith(Context context, AttributeSet attrs) {

density = typedArray.getInt(R.styleable.ColorPickerPreference_density, 10);
initialColor = typedArray.getInt(R.styleable.ColorPickerPreference_initialColor, 0xffffffff);
minimumWheelLightness = typedArray.getFloat(R.styleable.ColorPickerPreference_minimumWheelLightness, 0.0f);

pickerColorEditTextColor = typedArray.getInt(R.styleable.ColorPickerPreference_pickerColorEditTextColor, 0xffffffff);

Expand Down Expand Up @@ -188,7 +190,7 @@ private void drawColorWheel() {
colorWheelRenderOption.cSize = cSize;
colorWheelRenderOption.strokeWidth = strokeWidth;
colorWheelRenderOption.alpha = alpha;
colorWheelRenderOption.lightness = lightness;
colorWheelRenderOption.lightness = lightness >= minimumWheelLightness ? lightness : 1.0f;
colorWheelRenderOption.targetCanvas = colorWheelCanvas;

renderer.initWith(colorWheelRenderOption);
Expand Down Expand Up @@ -228,6 +230,7 @@ public boolean onTouchEvent(MotionEvent event) {
case MotionEvent.ACTION_MOVE: {
int lastSelectedColor = getSelectedColor();
currentColorCircle = findNearestByPosition(event.getX(), event.getY());
lightness = Utils.lightnessOfColor(currentColorCircle.getColor());
int selectedColor = getSelectedColor();

callOnColorChangedListeners(lastSelectedColor, selectedColor);
Expand Down
1 change: 1 addition & 0 deletions library/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<attr name="border" format="boolean"/>
<attr name="density" format="integer"/>
<attr name="initialColor" format="integer"/>
<attr name="minimumWheelLightness" format="float"/>
<attr name="wheelType" format="enum">
<enum name="FLOWER" value="0"/>
<enum name="CIRCLE" value="1"/>
Expand Down