From 5fe1caaba68f17d19385dea4ea9f297c0f6ff462 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=98=8C=E6=A0=87?= Date: Tue, 17 Aug 2021 17:02:57 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=88=AA=E5=9B=BE=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E4=BE=A7=E8=BE=B9=E6=BB=91=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- simplecropview/build.gradle | 4 +- .../simplecropview/CropImageView.java | 73 ++++++++++++++++++- 4 files changed, 75 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index 7909bc8..ad8c550 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:3.1.4' + classpath 'com.android.tools.build:gradle:3.5.3' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 5db3f70..87a842a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ 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-5.4.1-all.zip diff --git a/simplecropview/build.gradle b/simplecropview/build.gradle index 5d0ad04..e5b74d4 100644 --- a/simplecropview/build.gradle +++ b/simplecropview/build.gradle @@ -105,6 +105,4 @@ artifacts { archives sourcesJar } -task findConventions << { - println project.getConvention() -} +//t diff --git a/simplecropview/src/main/java/com/isseiaoki/simplecropview/CropImageView.java b/simplecropview/src/main/java/com/isseiaoki/simplecropview/CropImageView.java index b515aa7..8af998c 100644 --- a/simplecropview/src/main/java/com/isseiaoki/simplecropview/CropImageView.java +++ b/simplecropview/src/main/java/com/isseiaoki/simplecropview/CropImageView.java @@ -649,8 +649,22 @@ private void onMove(MotionEvent e) { case RIGHT_BOTTOM: moveHandleRB(diffX, diffY); break; + case LEFT: + moveHandleLT(diffX, 0); + break; + case TOP: + moveHandleLT(0, diffY); + break; + case RIGHT: + moveHandleRB(diffX, 0); + break; + case BOTTOM: + moveHandleRB(0, diffY); + break; case OUT_OF_BOUNDS: break; + default: + break; } invalidate(); mLastX = e.getX(); @@ -696,6 +710,35 @@ private void checkTouchArea(float x, float y) { if (mGuideShowMode == ShowMode.SHOW_ON_TOUCH) mShowGuide = true; return; } + + if(isInsideLeft(x, y)){ + mTouchArea = TouchArea.LEFT; + if (mHandleShowMode == ShowMode.SHOW_ON_TOUCH) mShowHandle = true; + if (mGuideShowMode == ShowMode.SHOW_ON_TOUCH) mShowGuide = true; + return; + } + + if(isInsideTop(x, y)){ + mTouchArea = TouchArea.TOP; + if (mHandleShowMode == ShowMode.SHOW_ON_TOUCH) mShowHandle = true; + if (mGuideShowMode == ShowMode.SHOW_ON_TOUCH) mShowGuide = true; + return; + } + + if(isInsideRight(x, y)){ + mTouchArea = TouchArea.RIGHT; + if (mHandleShowMode == ShowMode.SHOW_ON_TOUCH) mShowHandle = true; + if (mGuideShowMode == ShowMode.SHOW_ON_TOUCH) mShowGuide = true; + return; + } + + if(isInsideBottom(x, y)){ + mTouchArea = TouchArea.BOTTOM; + if (mHandleShowMode == ShowMode.SHOW_ON_TOUCH) mShowHandle = true; + if (mGuideShowMode == ShowMode.SHOW_ON_TOUCH) mShowGuide = true; + return; + } + if (isInsideFrame(x, y)) { if (mGuideShowMode == ShowMode.SHOW_ON_TOUCH) mShowGuide = true; mTouchArea = TouchArea.CENTER; @@ -742,6 +785,34 @@ private boolean isInsideCornerRightBottom(float x, float y) { return sq(mHandleSize + mTouchPadding) >= d; } + private boolean isInsideLeft(float x, float y){ + float dx = x - mFrameRect.left; + float dyT = y - mFrameRect.top - mTouchPadding - mHandleSize; + float dyB = y - mFrameRect.bottom - mTouchPadding - mHandleSize; + return Math.abs(dx) < mTouchPadding && dyT > 0 && dyB < 0; + } + + private boolean isInsideTop(float x, float y){ + float dy = y - mFrameRect.top; + float dxL = x - mFrameRect.left - mTouchPadding - mHandleSize; + float dxR = x - mFrameRect.right - mTouchPadding - mHandleSize; + return Math.abs(dy) < mTouchPadding && dxL > 0 && dxR < 0; + } + + private boolean isInsideRight(float x, float y){ + float dx = x - mFrameRect.right; + float dyT = y - mFrameRect.top - mTouchPadding - mHandleSize; + float dyB = y - mFrameRect.bottom - mTouchPadding - mHandleSize; + return Math.abs(dx) < mTouchPadding && dyT > 0 && dyB < 0; + } + + private boolean isInsideBottom(float x, float y){ + float dy = y - mFrameRect.bottom; + float dxL = x - mFrameRect.left - mTouchPadding - mHandleSize; + float dxR = x - mFrameRect.right - mTouchPadding - mHandleSize; + return Math.abs(dy) < mTouchPadding && dxL > 0 && dxR < 0; + } + // Adjust frame //////////////////////////////////////////////////////////////////////////////// private void moveFrame(float x, float y) { @@ -2339,7 +2410,7 @@ private float getFrameH() { // Enum //////////////////////////////////////////////////////////////////////////////////////// private enum TouchArea { - OUT_OF_BOUNDS, CENTER, LEFT_TOP, RIGHT_TOP, LEFT_BOTTOM, RIGHT_BOTTOM + OUT_OF_BOUNDS, CENTER, LEFT_TOP, RIGHT_TOP, LEFT_BOTTOM, RIGHT_BOTTOM,LEFT,TOP,RIGHT,BOTTOM } public enum CropMode { From 6227dd0e8e13bfde0d48070d6e3774cb4255c66e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=98=8C=E6=A0=87?= Date: Wed, 18 Aug 2021 15:05:06 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=9B=9B=E4=B8=AA=E8=A7=92=E6=8B=96?= =?UTF-8?q?=E5=8A=A8=E6=89=8B=E6=9F=84=E5=A2=9E=E5=8A=A0stroke=E8=BE=B9?= =?UTF-8?q?=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/res/layout/fragment_basic.xml | 3 ++- .../simplecropview/CropImageView.java | 23 +++++++++++++++++++ .../main/res/values/attrs_crop_image_view.xml | 2 ++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/simplecropview-sample/src/main/res/layout/fragment_basic.xml b/simplecropview-sample/src/main/res/layout/fragment_basic.xml index a55d7e5..3e85f27 100644 --- a/simplecropview-sample/src/main/res/layout/fragment_basic.xml +++ b/simplecropview-sample/src/main/res/layout/fragment_basic.xml @@ -25,7 +25,8 @@ custom:scv_min_frame_size="50dp" custom:scv_overlay_color="@color/overlay" custom:scv_touch_padding="8dp" - /> + custom:scv_handle_stroke_size = "5dp" + custom:scv_handle_stroke_color = "#fd5c02"/> + @@ -30,6 +31,7 @@ + From 6ad6b9a1aa971e212f1b55783e3c8c523dc8d386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=98=8C=E6=A0=87?= Date: Wed, 18 Aug 2021 15:59:39 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=9B=9B=E4=B8=AA=E8=A7=92=E6=8B=96?= =?UTF-8?q?=E5=8A=A8=E6=89=8B=E6=9F=84=E5=A2=9E=E5=8A=A0stroke=E8=BE=B9?= =?UTF-8?q?=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/res/layout/fragment_basic.xml | 7 +- simplecropview/build.gradle | 168 ++++++++++-------- .../simplecropview/CropImageView.java | 13 +- .../main/res/values/attrs_crop_image_view.xml | 1 + 4 files changed, 111 insertions(+), 78 deletions(-) diff --git a/simplecropview-sample/src/main/res/layout/fragment_basic.xml b/simplecropview-sample/src/main/res/layout/fragment_basic.xml index 3e85f27..1f5f794 100644 --- a/simplecropview-sample/src/main/res/layout/fragment_basic.xml +++ b/simplecropview-sample/src/main/res/layout/fragment_basic.xml @@ -17,16 +17,17 @@ custom:scv_frame_color="@color/colorAccent" custom:scv_frame_stroke_weight="1dp" custom:scv_guide_color="@color/colorAccent" - custom:scv_guide_show_mode="show_always" + custom:scv_guide_show_mode="show_on_touch" custom:scv_guide_stroke_weight="1dp" custom:scv_handle_color="@color/colorAccent" custom:scv_handle_show_mode="show_always" - custom:scv_handle_size="14dp" + custom:scv_handle_size="6dp" custom:scv_min_frame_size="50dp" custom:scv_overlay_color="@color/overlay" custom:scv_touch_padding="8dp" custom:scv_handle_stroke_size = "5dp" - custom:scv_handle_stroke_color = "#fd5c02"/> + custom:scv_handle_stroke_color = "#fd5c02" + custom:scv_frame_side_dragging_enabled = "false"/> + \ No newline at end of file