Bläddra i källkod

比例已调整了一下,回去参考一下IOS即可

詹子聪 5 år sedan
förälder
incheckning
eb5c8877a1
2 ändrade filer med 27 tillägg och 5 borttagningar
  1. 2 2
      app/build.gradle
  2. 25 3
      app/src/main/java/com/miekir/ocr/widget/CropView.java

+ 2 - 2
app/build.gradle

@@ -7,8 +7,8 @@ android {
         applicationId "com.miekir.ocr"
         minSdkVersion versions.minSdk
         targetSdkVersion versions.targetSdk
-        versionCode 15
-        versionName "1.0.15"
+        versionCode 16
+        versionName "1.0.16"
         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
     }
 

+ 25 - 3
app/src/main/java/com/miekir/ocr/widget/CropView.java

@@ -120,15 +120,15 @@ public class CropView extends View {
                 coverWidth = (int) (getWidth()*0.815);
                 // 最小高度不能小于图片的高度
 //                coverHeight = Math.max(minHeight, (int)(getWidth()*0.3));
-                coverHeight = SizeUtils.dp2px(50);
+                coverHeight = SizeUtils.dp2px(65);
                 sX = (getWidth()*1.0f-coverWidth)/2;
                 sY = getWidth()*0.177f;
                 mFrameRectF = new RectF(sX, sY, sX + coverWidth, sY + coverHeight);
                 break;
             case SCAN_TYPE_ADDRESS:
             case SCAN_TYPE_NAME:
-                coverWidth = (int) (getWidth()*0.815);
-                coverHeight = (int) (getWidth()*0.625);
+                coverWidth = (int) (getWidth()*0.75);
+                coverHeight = (int) (getWidth()*0.58);
                 sX = (getWidth()*1.0f-coverWidth)/2;
                 sY = (getHeight()*1.0f-coverHeight)/2;
                 mFrameRectF = new RectF(sX, sY, sX + coverWidth, sY + coverHeight);
@@ -374,6 +374,9 @@ public class CropView extends View {
     }
 
     private void onActionDown(MotionEvent event) {
+        // 按下时停止动画
+        AnimateManager.getInstance().stopAnimation();
+
         invalidate();
         mLastX = event.getX();
         mLastY = event.getY();
@@ -540,6 +543,25 @@ public class CropView extends View {
     }
 
     private void onActionUp() {
+        float handleLineLeftX = mFrameRectF.left - mHandleWidth;
+        float handleLineRightX = mFrameRectF.right + mHandleWidth;
+        float handleLineTopY = mFrameRectF.top - mHandleWidth;
+        float handleLineBottomY = mFrameRectF.bottom + mHandleWidth;
+        coverWidth = (int) (handleLineRightX - handleLineLeftX);
+        coverHeight = (int) (handleLineBottomY - handleLineTopY);
+
+        new Handler().postDelayed(new Runnable() {
+            @Override
+            public void run() {
+                if (coverWidth > coverHeight) {
+                    AnimateManager.getInstance().setWidth(coverWidth, coverHeight, (int)handleLineLeftX, (int)handleLineTopY, (int)handleLineRightX, (int)handleLineBottomY);
+                } else {
+                    AnimateManager.getInstance().setHeight(coverWidth, coverHeight, (int)handleLineLeftX, (int)handleLineTopY, (int)handleLineRightX, (int)handleLineBottomY);
+                }
+            }
+        }, 50);
+
+
         mTouchArea = TouchAreaEnum.OUT_OF_BOUNDS;
         invalidate();
     }