diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..376f7bb --- /dev/null +++ b/.editorconfig @@ -0,0 +1,5 @@ +root = true +[*] +# Most of the standard properties are supported +indent_size=2 +max_line_length=100 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 79dcce7..885180f 100644 --- a/.gitignore +++ b/.gitignore @@ -40,6 +40,10 @@ captures/ .idea/gradle.xml .idea/dictionaries .idea/libraries +app/.idea/ + +# Mac +*.DS_Store # Keystore files *.jks @@ -53,4 +57,4 @@ google-services.json # Freeline freeline.py freeline/ -freeline_project_description.json \ No newline at end of file +freeline_project_description.json diff --git a/app/src/main/java/com/skydoves/colorpickerviewdemo/MainActivity.java b/app/src/main/java/com/skydoves/colorpickerviewdemo/MainActivity.java index 8f9a865..eb66cd4 100644 --- a/app/src/main/java/com/skydoves/colorpickerviewdemo/MainActivity.java +++ b/app/src/main/java/com/skydoves/colorpickerviewdemo/MainActivity.java @@ -58,15 +58,15 @@ public class MainActivity extends AppCompatActivity { public void onItemClick(int position, PowerMenuItem item) { switch (position) { case 0: - { - palette(); - break; - } + { + palette(); + break; + } case 1: - { - paletteFromGallery(); - break; - } + { + paletteFromGallery(); + break; + } case 2: selector(); break; @@ -82,7 +82,6 @@ public void onItemClick(int position, PowerMenuItem item) { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - Timber.plant(new Timber.DebugTree()); powerMenu = PowerMenuUtils.getPowerMenu(this, this, powerMenuItemClickListener); diff --git a/colorpickerview/src/main/java/com/skydoves/colorpickerview/preference/ColorPickerPreferenceManager.java b/colorpickerview/src/main/java/com/skydoves/colorpickerview/preference/ColorPickerPreferenceManager.java index 7817e79..e9c56a7 100644 --- a/colorpickerview/src/main/java/com/skydoves/colorpickerview/preference/ColorPickerPreferenceManager.java +++ b/colorpickerview/src/main/java/com/skydoves/colorpickerview/preference/ColorPickerPreferenceManager.java @@ -226,8 +226,7 @@ public void restoreColorPickerData(ColorPickerView colorPickerView) { String name = colorPickerView.getPreferenceName(); colorPickerView.setPureColor(getColor(name, -1)); Point defaultPoint = - new Point( - colorPickerView.getWidth() / 2, colorPickerView.getMeasuredHeight() / 2); + new Point(colorPickerView.getWidth() / 2, colorPickerView.getMeasuredHeight() / 2); colorPickerView.moveSelectorPoint( getSelectorPosition(name, defaultPoint).x, getSelectorPosition(name, defaultPoint).y, diff --git a/colorpickerview/src/main/java/com/skydoves/colorpickerview/sliders/AbstractSlider.java b/colorpickerview/src/main/java/com/skydoves/colorpickerview/sliders/AbstractSlider.java index 66107b2..8939e92 100644 --- a/colorpickerview/src/main/java/com/skydoves/colorpickerview/sliders/AbstractSlider.java +++ b/colorpickerview/src/main/java/com/skydoves/colorpickerview/sliders/AbstractSlider.java @@ -149,8 +149,7 @@ public boolean onTouchEvent(MotionEvent event) { selector.setPressed(true); if (event.getX() > getWidth() || event.getX() < 0) { return false; - } - else { + } else { onTouchReceived(event); return true; } @@ -212,8 +211,7 @@ public void setSelectorPosition(@FloatRange(from = 0.0, to = 1.0) float selector public void setSelectorByHalfSelectorPosition( @FloatRange(from = 0.0, to = 1.0) float selectorPosition) { this.selectorPosition = Math.min(selectorPosition, 1.0f); - float x = - (getWidth() * selectorPosition) - (getSelectorSize() * 0.5f) - getBorderHalfSize(); + float x = (getWidth() * selectorPosition) - (getSelectorSize() * 0.5f) - getBorderHalfSize(); selectedX = (int) getBoundaryX(x); selector.setX(selectedX); } diff --git a/colorpickerview/src/main/java/com/skydoves/colorpickerview/sliders/AlphaSlideBar.java b/colorpickerview/src/main/java/com/skydoves/colorpickerview/sliders/AlphaSlideBar.java index aaf10b1..d23e451 100644 --- a/colorpickerview/src/main/java/com/skydoves/colorpickerview/sliders/AlphaSlideBar.java +++ b/colorpickerview/src/main/java/com/skydoves/colorpickerview/sliders/AlphaSlideBar.java @@ -95,13 +95,7 @@ public void updatePaint(Paint colorPaint) { int endColor = Color.HSVToColor(255, hsv); Shader shader = new LinearGradient( - 0, - 0, - getWidth(), - getMeasuredHeight(), - startColor, - endColor, - Shader.TileMode.CLAMP); + 0, 0, getWidth(), getMeasuredHeight(), startColor, endColor, Shader.TileMode.CLAMP); colorPaint.setShader(shader); } diff --git a/colorpickerview/src/main/java/com/skydoves/colorpickerview/sliders/BrightnessSlideBar.java b/colorpickerview/src/main/java/com/skydoves/colorpickerview/sliders/BrightnessSlideBar.java index 9b5e6a3..fec08c4 100644 --- a/colorpickerview/src/main/java/com/skydoves/colorpickerview/sliders/BrightnessSlideBar.java +++ b/colorpickerview/src/main/java/com/skydoves/colorpickerview/sliders/BrightnessSlideBar.java @@ -92,18 +92,19 @@ protected void updatePaint(Paint colorPaint) { @Override public void onInflateFinished() { - selector.post(()->{ - int defaultPosition = getWidth() - selector.getWidth(); + selector.post( + () -> { + int defaultPosition = getWidth() - selector.getWidth(); - if (getPreferenceName() != null) { - updateSelectorX( + if (getPreferenceName() != null) { + updateSelectorX( ColorPickerPreferenceManager.getInstance(getContext()) .getBrightnessSliderPosition(getPreferenceName(), defaultPosition) - + getSelectorSize() / 2); - } else { - selector.setX(defaultPosition); - } - }); + + getSelectorSize() / 2); + } else { + selector.setX(defaultPosition); + } + }); } @Override diff --git a/dependencies.gradle b/dependencies.gradle index 0228e96..f41b98b 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -18,8 +18,8 @@ ext.versions = [ versionoCode : 28, versionName : '2.2.4', - gradleBuildTool : '7.1.2', - spotlessGradle : '6.3.0', + gradleBuildTool : '7.4.2', + spotlessGradle : '6.7.0', dokkaGradle : '1.4.32', mavenPublish : '0.18.0', @@ -28,6 +28,6 @@ ext.versions = [ // for demo googleMaterial : '1.5.0', - powermenu : '2.2.0', + powermenu : '2.2.2', timber : '5.0.1' ] diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180..943f0cb 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 92f06b5..e8be595 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 1b6c787..65dcd68 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,10 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' @@ -143,12 +143,16 @@ fi if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -205,6 +209,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/gradlew.bat b/gradlew.bat index ac1b06f..6689b85 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/spotless.gradle b/spotless.gradle index a37519b..8512d13 100644 --- a/spotless.gradle +++ b/spotless.gradle @@ -18,13 +18,14 @@ spotless { target "**/*.java" licenseHeaderFile "$rootDir/spotless.license.java" trimTrailingWhitespace() - removeUnusedImports() - googleJavaFormat() + googleJavaFormat('1.5') endWithNewline() } kotlin { target "**/*.kt" - ktlint().userData(['indent_size': '2', 'continuation_indent_size': '2']) + ktlint() + .setUseExperimental(true) + .editorConfigOverride(['indent_size': '2', 'continuation_indent_size': '2']) licenseHeaderFile "$rootDir/spotless.license.java" trimTrailingWhitespace() endWithNewline()