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-sample/src/main/res/layout/fragment_basic.xml b/simplecropview-sample/src/main/res/layout/fragment_basic.xml index a55d7e5..1f5f794 100644 --- a/simplecropview-sample/src/main/res/layout/fragment_basic.xml +++ b/simplecropview-sample/src/main/res/layout/fragment_basic.xml @@ -17,15 +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_frame_side_dragging_enabled = "false"/> = 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 +2430,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 { @@ -2396,6 +2487,7 @@ public static class SavedState extends BaseSavedState { boolean showGuide; boolean showHandle; int handleSize; + int handleStrokeSize; int touchPadding; float minFrameSize; float customRatioX; @@ -2404,6 +2496,7 @@ public static class SavedState extends BaseSavedState { float guideStrokeWeight; boolean isCropEnabled; int handleColor; + int handleStrokeColor; int guideColor; float initialFrameScale; float angle; @@ -2440,6 +2533,7 @@ private SavedState(Parcel in) { showGuide = (in.readInt() != 0); showHandle = (in.readInt() != 0); handleSize = in.readInt(); + handleStrokeSize = in.readInt(); touchPadding = in.readInt(); minFrameSize = in.readFloat(); customRatioX = in.readFloat(); @@ -2448,6 +2542,7 @@ private SavedState(Parcel in) { guideStrokeWeight = in.readFloat(); isCropEnabled = (in.readInt() != 0); handleColor = in.readInt(); + handleStrokeColor = in.readInt(); guideColor = in.readInt(); initialFrameScale = in.readFloat(); angle = in.readFloat(); @@ -2481,6 +2576,7 @@ private SavedState(Parcel in) { out.writeInt(showGuide ? 1 : 0); out.writeInt(showHandle ? 1 : 0); out.writeInt(handleSize); + out.writeInt(handleStrokeSize); out.writeInt(touchPadding); out.writeFloat(minFrameSize); out.writeFloat(customRatioX); @@ -2489,6 +2585,7 @@ private SavedState(Parcel in) { out.writeFloat(guideStrokeWeight); out.writeInt(isCropEnabled ? 1 : 0); out.writeInt(handleColor); + out.writeInt(handleStrokeColor); out.writeInt(guideColor); out.writeFloat(initialFrameScale); out.writeFloat(angle); diff --git a/simplecropview/src/main/res/values/attrs_crop_image_view.xml b/simplecropview/src/main/res/values/attrs_crop_image_view.xml index 93967f1..43b3cdb 100644 --- a/simplecropview/src/main/res/values/attrs_crop_image_view.xml +++ b/simplecropview/src/main/res/values/attrs_crop_image_view.xml @@ -18,6 +18,7 @@ + @@ -30,6 +31,7 @@ + @@ -39,5 +41,6 @@ + \ No newline at end of file