From 6b8f137a1ad34170cad61980b032b4a0d9d82dc2 Mon Sep 17 00:00:00 2001
From: "rtugeek@gmail.com" <47328663>
Date: Fri, 12 Oct 2018 09:10:32 +0800
Subject: [PATCH] update build tools
---
.gitignore | 82 +++++++++++++++++++
.idea/compiler.xml | 22 -----
.idea/copyright/profiles_settings.xml | 3 -
.idea/copyright/wtfpl.xml | 6 --
.idea/gradle.xml | 3 +-
.idea/misc.xml | 20 +++--
app/build.gradle | 2 +-
.../colorseekbardemo/MainActivity.java | 9 +-
build.gradle | 2 +-
colorseekbar/build.gradle | 6 +-
.../android/colorseekbar/ColorSeekBar.java | 81 +++++++-----------
gradle/wrapper/gradle-wrapper.properties | 4 +-
12 files changed, 133 insertions(+), 107 deletions(-)
delete mode 100644 .idea/compiler.xml
delete mode 100644 .idea/copyright/profiles_settings.xml
delete mode 100644 .idea/copyright/wtfpl.xml
diff --git a/.gitignore b/.gitignore
index 71578a8..e073a52 100644
--- a/.gitignore
+++ b/.gitignore
@@ -196,3 +196,85 @@ fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md
+### JetBrains template
+# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
+# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
+
+# User-specific stuff
+.idea/**/usage.statistics.xml
+
+# Sensitive or high-churn files
+.idea/**/dbnavigator.xml
+
+# Gradle
+
+# Gradle and Maven with auto-import
+# When using Gradle or Maven with auto-import, you should exclude module files,
+# since they will be recreated, and may cause churn. Uncomment if using
+# auto-import.
+# .idea/modules.xml
+# .idea/*.iml
+# .idea/modules
+
+# CMake
+cmake-build-*/
+
+# Mongo Explorer plugin
+
+# File-based project format
+
+# IntelliJ
+
+# mpeltonen/sbt-idea plugin
+
+# JIRA plugin
+
+# Cursive Clojure plugin
+
+# Crashlytics plugin (for Android Studio and IntelliJ)
+
+# Editor-based Rest Client
+### Android template
+# Built application files
+
+# Files for the ART/Dalvik VM
+
+# Java class files
+
+# Generated files
+
+# Gradle files
+
+# Local configuration file (sdk path, etc)
+
+# Proguard folder generated by Eclipse
+
+# Log Files
+
+# Android Studio Navigation editor temp files
+
+# Android Studio captures folder
+
+# IntelliJ
+
+# Keystore files
+# Uncomment the following line if you do not want to check your keystore files in.
+#*.jks
+
+# External native build folder generated in Android Studio 2.2 and later
+
+# Google Services (e.g. APIs or Firebase)
+
+# Freeline
+
+# fastlane
+### Gradle template
+
+# Ignore Gradle GUI config
+
+# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
+
+# Cache of project
+
+# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
+# gradle/wrapper/gradle-wrapper.properties
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
deleted file mode 100644
index 96cc43e..0000000
--- a/.idea/compiler.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml
deleted file mode 100644
index e7bedf3..0000000
--- a/.idea/copyright/profiles_settings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/.idea/copyright/wtfpl.xml b/.idea/copyright/wtfpl.xml
deleted file mode 100644
index c2af1f7..0000000
--- a/.idea/copyright/wtfpl.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index ec83c78..9710da1 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -5,7 +5,7 @@
-
+
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 59f8a0c..1dc7455 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -5,29 +5,31 @@
-
+
-
-
+
+
+
+
+
-
+
+
+
-
-
-
-
-
+
+
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index 53cd95d..e8b840a 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,7 +1,7 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
- buildToolsVersion '27.0.3'
+ buildToolsVersion '28.0.2'
defaultConfig {
applicationId "com.rtugeek.android.colorseekbardemo"
minSdkVersion 14
diff --git a/app/src/main/java/com/rtugeek/android/colorseekbardemo/MainActivity.java b/app/src/main/java/com/rtugeek/android/colorseekbardemo/MainActivity.java
index 615741c..ab332a7 100644
--- a/app/src/main/java/com/rtugeek/android/colorseekbardemo/MainActivity.java
+++ b/app/src/main/java/com/rtugeek/android/colorseekbardemo/MainActivity.java
@@ -1,13 +1,9 @@
package com.rtugeek.android.colorseekbardemo;
import android.content.SharedPreferences;
-import android.graphics.Color;
-import android.os.Handler;
-import android.support.v4.graphics.ColorUtils;
-import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
import android.util.Log;
-import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.SeekBar;
@@ -15,9 +11,6 @@
import com.rtugeek.android.colorseekbar.ColorSeekBar;
-import java.util.ArrayList;
-import java.util.List;
-
public class MainActivity extends AppCompatActivity {
private ColorSeekBar mColorSeekBar;
private SharedPreferences sp;
diff --git a/build.gradle b/build.gradle
index a6dd539..44ae7f4 100644
--- a/build.gradle
+++ b/build.gradle
@@ -6,7 +6,7 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.1.1'
+ classpath 'com.android.tools.build:gradle:3.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
diff --git a/colorseekbar/build.gradle b/colorseekbar/build.gradle
index 3b7a6b9..291d547 100644
--- a/colorseekbar/build.gradle
+++ b/colorseekbar/build.gradle
@@ -2,12 +2,12 @@ apply plugin: 'com.android.library'
group='com.github.rtugeek'
android {
compileSdkVersion 27
- buildToolsVersion '27.0.3'
+ buildToolsVersion '28.0.2'
defaultConfig {
minSdkVersion 14
targetSdkVersion 27
- versionCode 6
- versionName "1.7.1"
+ versionCode 7
+ versionName "1.7.2"
}
buildTypes {
release {
diff --git a/colorseekbar/src/main/java/com/rtugeek/android/colorseekbar/ColorSeekBar.java b/colorseekbar/src/main/java/com/rtugeek/android/colorseekbar/ColorSeekBar.java
index 9c20f52..130fd78 100644
--- a/colorseekbar/src/main/java/com/rtugeek/android/colorseekbar/ColorSeekBar.java
+++ b/colorseekbar/src/main/java/com/rtugeek/android/colorseekbar/ColorSeekBar.java
@@ -22,10 +22,8 @@
public class ColorSeekBar extends View {
- private int mBackgroundColor = 0xffffffff;
private int[] mColorSeeds = new int[]{0xFF000000, 0xFF9900FF, 0xFF0000FF, 0xFF00FF00, 0xFF00FFFF, 0xFFFF0000, 0xFFFF00FF, 0xFFFF6600, 0xFFFFFF00, 0xFFFFFFFF, 0xFF000000};
- private int c0, c1, mAlpha, mRed, mGreen, mBlue;
- private float x, y;
+ private int mAlpha;
private OnColorChangeListener mOnColorChangeLister;
private Context mContext;
private boolean mIsShowAlphaBar = false;
@@ -37,24 +35,18 @@ public class ColorSeekBar extends View {
private int mThumbHeight = 20;
private float mThumbRadius;
private int mBarHeight = 2;
- private LinearGradient mColorGradient;
private Paint mColorRectPaint;
private int realLeft;
private int realRight;
- private int realTop;
- private int realBottom;
private int mBarWidth;
private int mMaxPosition;
private Rect mAlphaRect;
private int mColorBarPosition;
private int mAlphaBarPosition;
private int mBarMargin = 5;
- private int mPaddingSize;
- private int mViewWidth;
- private int mViewHeight;
private int mAlphaMinPosition = 0;
private int mAlphaMaxPosition = 255;
- private List mColors = new ArrayList<>();
+ private List mCachedColors = new ArrayList<>();
private int mColorsToInvoke = -1;
private boolean mInit = false;
private boolean mFirstDraw = true;
@@ -98,8 +90,8 @@ public void applyStyle(int resId) {
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
Logger.i("onMeasure");
- mViewWidth = widthMeasureSpec;
- mViewHeight = heightMeasureSpec;
+ int mViewWidth = widthMeasureSpec;
+ int mViewHeight = heightMeasureSpec;
int widthSpeMode = MeasureSpec.getMode(widthMeasureSpec);
int heightSpeMode = MeasureSpec.getMode(heightMeasureSpec);
@@ -137,7 +129,7 @@ protected void applyStyle(Context context, AttributeSet attrs, int defStyleAttr,
mAlphaBarPosition = a.getInteger(R.styleable.ColorSeekBar_alphaBarPosition, mAlphaMinPosition);
mIsVertical = a.getBoolean(R.styleable.ColorSeekBar_isVertical, false);
mIsShowAlphaBar = a.getBoolean(R.styleable.ColorSeekBar_showAlphaBar, false);
- mBackgroundColor = a.getColor(R.styleable.ColorSeekBar_bgColor, Color.TRANSPARENT);
+ int backgroundColor = a.getColor(R.styleable.ColorSeekBar_bgColor, Color.TRANSPARENT);
mBarHeight = (int) a.getDimension(R.styleable.ColorSeekBar_barHeight, (float) dp2px(2));
mThumbHeight = (int) a.getDimension(R.styleable.ColorSeekBar_thumbHeight, (float) dp2px(30));
mBarMargin = (int) a.getDimension(R.styleable.ColorSeekBar_barMargin, (float) dp2px(5));
@@ -147,11 +139,11 @@ protected void applyStyle(Context context, AttributeSet attrs, int defStyleAttr,
mColorSeeds = getColorsById(colorsId);
}
- setBackgroundColor(mBackgroundColor);
+ setBackgroundColor(backgroundColor);
}
/**
- * @param id color array resource
+ * @param id color array resource
* @return
*/
private int[] getColorsById(@ArrayRes int id) {
@@ -177,14 +169,13 @@ private void init() {
Logger.i("init");
//init size
mThumbRadius = mThumbHeight / 2;
- mPaddingSize = (int) mThumbRadius;
+ int mPaddingSize = (int) mThumbRadius;
int viewBottom = getHeight() - getPaddingBottom() - mPaddingSize;
int viewRight = getWidth() - getPaddingRight() - mPaddingSize;
- //init l r t b
+ //init left right top bottom
realLeft = getPaddingLeft() + mPaddingSize;
realRight = mIsVertical ? viewBottom : viewRight;
- realTop = getPaddingTop() + mPaddingSize;
- realBottom = mIsVertical ? viewRight : viewBottom;
+ int realTop = getPaddingTop() + mPaddingSize;
mBarWidth = realRight - realLeft;
@@ -192,7 +183,7 @@ private void init() {
mColorRect = new Rect(realLeft, realTop, realRight, realTop + mBarHeight);
//init paint
- mColorGradient = new LinearGradient(0, 0, mColorRect.width(), 0, mColorSeeds, null, Shader.TileMode.CLAMP);
+ LinearGradient mColorGradient = new LinearGradient(0, 0, mColorRect.width(), 0, mColorSeeds, null, Shader.TileMode.CLAMP);
mColorRectPaint = new Paint();
mColorRectPaint.setShader(mColorGradient);
mColorRectPaint.setAntiAlias(true);
@@ -223,11 +214,12 @@ private void cacheColors() {
if (mBarWidth < 1) {
return;
}
- mColors.clear();
+ mCachedColors.clear();
for (int i = 0; i <= mMaxPosition; i++) {
- mColors.add(pickColor(i));
+ mCachedColors.add(pickColor(i));
}
}
+
@Override
protected void onDraw(Canvas canvas) {
Logger.i("onDraw");
@@ -302,19 +294,14 @@ protected void onDraw(Canvas canvas) {
@Override
public boolean onTouchEvent(MotionEvent event) {
- x = mIsVertical ? event.getY() : event.getX();
- y = mIsVertical ? event.getX() : event.getY();
+ float x = mIsVertical ? event.getY() : event.getX();
+ float y = mIsVertical ? event.getX() : event.getY();
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
if (isOnBar(mColorRect, x, y)) {
mMovingColorBar = true;
float value = (x - realLeft) / mBarWidth * mMaxPosition;
- mColorBarPosition = (int) value;
- if (mColorBarPosition < 0)
- mColorBarPosition = 0;
- if (mColorBarPosition > mMaxPosition)
- mColorBarPosition = mMaxPosition;
- invalidate();
+ setColorBarPosition((int) value);
} else if (mIsShowAlphaBar) {
if (isOnBar(mAlphaRect, x, y)) {
mMovingAlphaBar = true;
@@ -325,13 +312,7 @@ public boolean onTouchEvent(MotionEvent event) {
getParent().requestDisallowInterceptTouchEvent(true);
if (mMovingColorBar) {
float value = (x - realLeft) / mBarWidth * mMaxPosition;
- mColorBarPosition = (int) value;
- if (mColorBarPosition < 0) {
- mColorBarPosition = 0;
- }
- if (mColorBarPosition > mMaxPosition) {
- mColorBarPosition = mMaxPosition;
- }
+ setColorBarPosition((int) value);
} else if (mIsShowAlphaBar) {
if (mMovingAlphaBar) {
float value = (x - realLeft) / (float) mBarWidth * (mAlphaMaxPosition - mAlphaMinPosition) + mAlphaMinPosition;
@@ -451,12 +432,12 @@ private int pickColor(float position) {
float colorPosition = unit * (mColorSeeds.length - 1);
int i = (int) colorPosition;
colorPosition -= i;
- c0 = mColorSeeds[i];
- c1 = mColorSeeds[i + 1];
+ int c0 = mColorSeeds[i];
+ int c1 = mColorSeeds[i + 1];
// mAlpha = mix(Color.alpha(c0), Color.alpha(c1), colorPosition);
- mRed = mix(Color.red(c0), Color.red(c1), colorPosition);
- mGreen = mix(Color.green(c0), Color.green(c1), colorPosition);
- mBlue = mix(Color.blue(c0), Color.blue(c1), colorPosition);
+ int mRed = mix(Color.red(c0), Color.red(c1), colorPosition);
+ int mGreen = mix(Color.green(c0), Color.green(c1), colorPosition);
+ int mBlue = mix(Color.blue(c0), Color.blue(c1), colorPosition);
return Color.rgb(mRed, mGreen, mBlue);
}
@@ -480,7 +461,7 @@ public int getColor() {
*/
public int getColor(boolean withAlpha) {
//pick mode
- if (mColorBarPosition >= mColors.size()) {
+ if (mColorBarPosition >= mCachedColors.size()) {
int color = pickColor(mColorBarPosition);
if (withAlpha) {
return color;
@@ -490,7 +471,7 @@ public int getColor(boolean withAlpha) {
}
//cache mode
- int color = mColors.get(mColorBarPosition);
+ int color = mCachedColors.get(mColorBarPosition);
if (withAlpha) {
return Color.argb(getAlphaValue(), Color.red(color), Color.green(color), Color.blue(color));
@@ -551,11 +532,11 @@ public void setColorSeeds(int[] colors) {
* @return the color's position in the bar, if not in the bar ,return -1;
*/
public int getColorIndexPosition(int color) {
- return mColors.indexOf(Color.argb(255, Color.red(color), Color.green(color), Color.blue(color)));
+ return mCachedColors.indexOf(Color.argb(255, Color.red(color), Color.green(color), Color.blue(color)));
}
public List getColors() {
- return mColors;
+ return mCachedColors;
}
public boolean isShowAlphaBar() {
@@ -666,16 +647,14 @@ public void setOnInitDoneListener(OnInitDoneListener listener) {
}
/**
- * Set color, it must correspond to the value, if not , setColorBarPosition(0);
- *
- * @paam color
+ * Set color,the mCachedColors must contains the specified color, if not ,invoke setColorBarPosition(0);
+ * @param color
*/
public void setColor(int color) {
int withoutAlphaColor = Color.rgb(Color.red(color), Color.green(color), Color.blue(color));
if (mInit) {
- int value = mColors.indexOf(withoutAlphaColor);
-// mColorsToInvoke = color;
+ int value = mCachedColors.indexOf(withoutAlphaColor);
setColorBarPosition(value);
} else {
mColorsToInvoke = color;
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 18ce96a..417ca96 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Tue Apr 17 21:00:58 CST 2018
+#Fri Oct 12 08:40:08 CST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip