Skip to content
This repository has been archived by the owner on Sep 29, 2024. It is now read-only.

Commit

Permalink
Replace color-picker.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaobozhen committed Aug 12, 2023
1 parent 42b9e0a commit a9516da
Show file tree
Hide file tree
Showing 37 changed files with 1,950 additions and 12 deletions.
17 changes: 9 additions & 8 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ plugins {
kotlin("android")
id("com.google.devtools.ksp")
id("kotlin-parcelize")
id("sdk-editor")
id("dev.rikka.tools.materialthemebuilder")
}

val verName = "2.5.4"
val verCode = 2050400

android {
compileSdk = 33
compileSdk = 34
ndkVersion = "25.0.8775105"

defaultConfig {
Expand All @@ -39,6 +38,8 @@ android {
}

buildFeatures {
aidl = true
buildConfig = true
viewBinding = true
}

Expand Down Expand Up @@ -88,7 +89,7 @@ android {
}
}

packagingOptions {
packaging {
resources {
excludes += "META-INF/**"
excludes += "okhttp3/**"
Expand Down Expand Up @@ -117,7 +118,7 @@ repositories {
mavenCentral()
}

val optimizeReleaseRes = task("optimizeReleaseRes").doLast {
val optimizeReleaseRes: Task = task("optimizeReleaseRes").doLast {
val aapt2 = File(
androidComponents.sdkComponents.sdkDirectory.get().asFile,
"build-tools/${project.android.buildToolsVersion}/aapt2"
Expand Down Expand Up @@ -161,7 +162,7 @@ configurations.all {
dependencies {
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))

implementation(files("libs/color-picker.aar"))
implementation(project(":color-picker"))
implementation(files("libs/IceBox-SDK-1.0.6.aar"))

implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3")
Expand Down Expand Up @@ -208,10 +209,10 @@ dependencies {
ksp("com.github.bumptech.glide:compiler:4.15.1")

implementation("com.google.code.gson:gson:2.9.0")
implementation("com.google.zxing:core:3.5.1")
implementation("com.google.zxing:core:3.5.2")
implementation("com.blankj:utilcodex:1.31.1")
implementation("com.tencent:mmkv-static:1.3.0")
implementation("com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.11")
implementation("com.tencent:mmkv-static:1.3.1")
implementation("com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.14")
implementation("com.github.heruoxin.Delegated-Scopes-Manager:client:master-SNAPSHOT")
implementation("com.github.topjohnwu.libsu:core:5.2.0")
implementation("com.github.thegrizzlylabs:sardine-android:0.8")
Expand Down
Binary file removed app/libs/color-picker.aar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@
import com.flask.colorpicker.renderer.ColorWheelRenderer;
import com.flask.colorpicker.slider.AlphaSlider;
import com.flask.colorpicker.slider.LightnessSlider;
import com.iwhys.sdkeditor.domain.ReplaceClass;

@ReplaceClass("colorpicker:0.0.15")
public class ColorPickerDialogBuilder {
private final AnywhereDialogBuilder builder;
private final LinearLayout pickerContainer;
Expand Down
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ buildscript {
classpath("com.android.tools.build:gradle:8.1.0")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0")
classpath("com.google.devtools.ksp:symbol-processing-gradle-plugin:1.9.0-1.0.13")
classpath("com.github.iwhys:sdk-editor-plugin:1.1.7")
classpath("dev.rikka.tools.materialthemebuilder:gradle-plugin:1.4.0")
}
}
Expand Down
1 change: 1 addition & 0 deletions color-picker/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
24 changes: 24 additions & 0 deletions color-picker/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apply plugin: 'com.android.library'

android {
compileSdk 34

defaultConfig {
namespace "com.flask.colorpicker"
minSdkVersion 23
targetSdkVersion 33
versionCode 18
versionName "0.0.16"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.6.1'
}
17 changes: 17 additions & 0 deletions color-picker/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/flask/Documents/android-sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.flask.colorpicker;

import android.app.Application;
import android.test.ApplicationTestCase;

/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
5 changes: 5 additions & 0 deletions color-picker/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<manifest package="com.flask.colorpicker">

<application/>

</manifest>
54 changes: 54 additions & 0 deletions color-picker/src/main/java/com/flask/colorpicker/ColorCircle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.flask.colorpicker;

import android.graphics.Color;

public class ColorCircle {
private float x, y;
private float[] hsv = new float[3];
private float[] hsvClone;
private int color;

public ColorCircle(float x, float y, float[] hsv) {
set(x, y, hsv);
}

public double sqDist(float x, float y) {
double dx = this.x - x;
double dy = this.y - y;
return dx * dx + dy * dy;
}

public float getX() {
return x;
}

public float getY() {
return y;
}

public float[] getHsv() {
return hsv;
}

public float[] getHsvWithLightness(float lightness) {
if (hsvClone == null)
hsvClone = hsv.clone();
hsvClone[0] = hsv[0];
hsvClone[1] = hsv[1];
hsvClone[2] = lightness;
return hsvClone;
}

public void set(float x, float y, float[] hsv) {
this.x = x;
this.y = y;
this.hsv[0] = hsv[0];
this.hsv[1] = hsv[1];
this.hsv[2] = hsv[2];
this.color = Color.HSVToColor(this.hsv);
}

public int getColor() {
return color;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.flask.colorpicker;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.drawable.ColorDrawable;

import com.flask.colorpicker.builder.PaintBuilder;

public class ColorCircleDrawable extends ColorDrawable {
private float strokeWidth;
private Paint strokePaint = PaintBuilder.newPaint().style(Paint.Style.STROKE).stroke(strokeWidth).color(0xff9e9e9e).build();
private Paint fillPaint = PaintBuilder.newPaint().style(Paint.Style.FILL).color(0).build();
private Paint fillBackPaint = PaintBuilder.newPaint().shader(PaintBuilder.createAlphaPatternShader(26)).build();

public ColorCircleDrawable(int color) {
super(color);
}

@Override
public void draw(Canvas canvas) {
canvas.drawColor(0);

int width = canvas.getWidth();
float radius = width / 2f;
strokeWidth = radius / 8f;

this.strokePaint.setStrokeWidth(strokeWidth);
this.fillPaint.setColor(getColor());
canvas.drawCircle(radius, radius, radius - strokeWidth, fillBackPaint);
canvas.drawCircle(radius, radius, radius - strokeWidth, fillPaint);
canvas.drawCircle(radius, radius, radius - strokeWidth, strokePaint);
}

@Override
public void setColor(int color) {
super.setColor(color);
invalidateSelf();
}
}
Loading

0 comments on commit a9516da

Please sign in to comment.