Jelajahi Sumber

优化显示

詹子聪 5 tahun lalu
induk
melakukan
f8ba59dbc6

+ 3 - 3
app/src/main/java/com/miekir/ocr/bean/CommonBean.java

@@ -15,7 +15,7 @@ public class CommonBean {
      */
 
     private String text;
-    private int score;
+    private double score;
     //private List<BboxBean> bbox;
     private Object bbox;
 
@@ -27,11 +27,11 @@ public class CommonBean {
         this.text = text;
     }
 
-    public int getScore() {
+    public double getScore() {
         return score;
     }
 
-    public void setScore(int score) {
+    public void setScore(double score) {
         this.score = score;
     }
 

+ 35 - 17
app/src/main/java/com/miekir/ocr/ui/OperationActivity.java

@@ -7,6 +7,7 @@ import android.net.Uri;
 import android.os.Bundle;
 import android.text.TextUtils;
 import android.view.View;
+import android.widget.LinearLayout;
 import android.widget.TextView;
 
 import androidx.annotation.Nullable;
@@ -16,7 +17,6 @@ import com.miekir.common.utils.ViewTool;
 import com.miekir.mvp.presenter.InjectPresenter;
 import com.miekir.ocr.R;
 import com.miekir.ocr.bean.OcrResult;
-import com.miekir.ocr.constant.ConstantString;
 import com.miekir.ocr.tool.AnimateManager;
 import com.miekir.ocr.tool.SystemTool;
 import com.miekir.ocr.widget.CropView;
@@ -218,19 +218,27 @@ public class OperationActivity extends CameraActivity implements CropView.onLoca
                 }
                 if (builder.length() > 0) {
                     builder.deleteCharAt(builder.length()-1);
+                    SystemTool.copyText(OperationActivity.this, builder.toString());
+                } else {
+                    SystemTool.copyText(OperationActivity.this, " ");
                 }
-                SystemTool.copyText(OperationActivity.this, builder.toString());
             } else if (mCurrentType == CropView.SCAN_TYPE_POSTAL) {
                 if (result.postcode != null) {
                     SystemTool.copyText(OperationActivity.this, result.postcode.getText());
+                } else {
+                    SystemTool.copyText(OperationActivity.this, " ");
                 }
             } else if (mCurrentType == CropView.SCAN_TYPE_ADDRESS) {
                 if (result.address != null) {
                     SystemTool.copyText(OperationActivity.this, result.address.getText());
+                } else {
+                    SystemTool.copyText(OperationActivity.this, " ");
                 }
             } else if (mCurrentType == CropView.SCAN_TYPE_NAME) {
                 if (result.name != null) {
                     SystemTool.copyText(OperationActivity.this, result.name.getText());
+                } else {
+                    SystemTool.copyText(OperationActivity.this, " ");
                 }
             }
 
@@ -247,35 +255,45 @@ public class OperationActivity extends CameraActivity implements CropView.onLoca
         TextView tv_postal = dialog.findViewById(R.id.tv_postal);
         TextView tv_address = dialog.findViewById(R.id.tv_address);
         TextView tv_name = dialog.findViewById(R.id.tv_name);
+
+        LinearLayout ll_postal = dialog.findViewById(R.id.ll_postal);
+        LinearLayout ll_address = dialog.findViewById(R.id.ll_address);
+        LinearLayout ll_name = dialog.findViewById(R.id.ll_name);
         if (mCurrentType == CropView.SCAN_TYPE_ALL) {
-            tv_postal.setVisibility(View.VISIBLE);
-            tv_address.setVisibility(View.VISIBLE);
-            tv_name.setVisibility(View.VISIBLE);
+            ll_postal.setVisibility(View.VISIBLE);
+            ll_address.setVisibility(View.VISIBLE);
+            ll_name.setVisibility(View.VISIBLE);
         } else if (mCurrentType == CropView.SCAN_TYPE_POSTAL) {
-            tv_postal.setVisibility(View.VISIBLE);
-            tv_address.setVisibility(View.GONE);
-            tv_name.setVisibility(View.GONE);
+            ll_postal.setVisibility(View.VISIBLE);
+            ll_address.setVisibility(View.GONE);
+            ll_name.setVisibility(View.GONE);
         } else if (mCurrentType == CropView.SCAN_TYPE_ADDRESS) {
-            tv_address.setVisibility(View.VISIBLE);
-            tv_postal.setVisibility(View.GONE);
-            tv_name.setVisibility(View.GONE);
+            ll_address.setVisibility(View.VISIBLE);
+            ll_postal.setVisibility(View.GONE);
+            ll_name.setVisibility(View.GONE);
 
         } else if (mCurrentType == CropView.SCAN_TYPE_NAME) {
-            tv_name.setVisibility(View.VISIBLE);
-            tv_postal.setVisibility(View.GONE);
-            tv_address.setVisibility(View.GONE);
+            ll_name.setVisibility(View.VISIBLE);
+            ll_postal.setVisibility(View.GONE);
+            ll_address.setVisibility(View.GONE);
         }
 
         if (result.postcode != null) {
-            tv_postal.setText(String.format(ConstantString.RESULT_FORMAT, getString(R.string.postal_code), result.postcode.getText()));
+            tv_postal.setText(result.postcode.getText());
+        } else {
+            tv_postal.setText("");
         }
 
         if (result.address != null) {
-            tv_address.setText(String.format(ConstantString.RESULT_FORMAT, getString(R.string.address), result.address.getText()));
+            tv_address.setText(result.address.getText());
+        } else {
+            tv_address.setText("");
         }
 
         if (result.name != null) {
-            tv_name.setText(String.format(ConstantString.RESULT_FORMAT, getString(R.string.name), result.name.getText()));
+            tv_name.setText(result.name.getText());
+        } else {
+            tv_name.setText("");
         }
     }
 

+ 132 - 87
app/src/main/res/layout/dialog_result.xml

@@ -1,103 +1,148 @@
 <?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:orientation="vertical"
-    android:background="@drawable/shape_result_bg">
-
-    <TextView
-        android:layout_width="match_parent"
-        android:layout_height="56dp"
-        android:gravity="center_vertical"
-        android:textColor="@color/black_press"
-        android:text="@string/result"
-        android:textSize="@dimen/size_text_title_p"
-        android:paddingStart="@dimen/margin_default"
-        android:paddingEnd="@dimen/margin_default"/>
-
-    <View
-        android:layout_width="match_parent"
-        android:layout_height="2dp"
-        android:background="@color/divider"/>
-    <TextView
-        android:id="@+id/tv_postal"
+    android:layout_height="wrap_content">
+    <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:paddingStart="@dimen/margin_default"
-        android:paddingEnd="@dimen/margin_default"
-        android:textSize="@dimen/size_text_title"
-        android:textColor="@color/black_press"
-        android:layout_marginTop="@dimen/margin_default"
-        android:visibility="invisible"/>
+        android:orientation="vertical"
+        android:background="@drawable/shape_result_bg">
 
-    <TextView
-        android:id="@+id/tv_address"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:paddingStart="@dimen/margin_default"
-        android:paddingEnd="@dimen/margin_default"
-        android:textSize="@dimen/size_text_title"
-        android:textColor="@color/black_press"
-        android:layout_marginTop="@dimen/margin_default"
-        android:visibility="invisible"/>
+        <TextView
+            android:layout_width="match_parent"
+            android:layout_height="56dp"
+            android:gravity="center_vertical"
+            android:textColor="@color/black_press"
+            android:text="@string/result"
+            android:textSize="@dimen/size_text_title_p"
+            android:paddingStart="@dimen/margin_default"
+            android:paddingEnd="@dimen/margin_default"/>
 
-    <TextView
-        android:id="@+id/tv_name"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:paddingStart="@dimen/margin_default"
-        android:paddingEnd="@dimen/margin_default"
-        android:textSize="@dimen/size_text_title"
-        android:textColor="@color/black_press"
-        android:layout_marginTop="@dimen/margin_default"
-        android:visibility="invisible"/>
+        <View
+            android:layout_width="match_parent"
+            android:layout_height="2dp"
+            android:background="@color/divider"/>
 
-    <LinearLayout
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:orientation="horizontal"
-        android:gravity="center"
-        android:paddingStart="@dimen/margin_default"
-        android:paddingEnd="@dimen/margin_default"
-        android:layout_marginTop="64dp"
-        android:layout_marginBottom="32dp">
+        <LinearLayout
+            android:id="@+id/ll_postal"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:orientation="horizontal"
+            android:gravity="center_vertical"
+            android:paddingStart="@dimen/margin_default"
+            android:paddingEnd="@dimen/margin_default"
+            android:layout_marginTop="@dimen/margin_default">
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:textSize="@dimen/size_text_title"
+                android:textColor="@color/black_press"
+                android:text="@string/postal_code_title"/>
 
-        <TextView
-            android:id="@+id/tv_copy"
+            <TextView
+                android:id="@+id/tv_postal"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:textSize="@dimen/size_text_title"
+                android:textColor="@color/gray_text" />
+        </LinearLayout>
+
+        <LinearLayout
+            android:id="@+id/ll_address"
             android:layout_width="wrap_content"
-            android:minWidth="114dp"
             android:layout_height="wrap_content"
-            android:singleLine="true"
-            android:ellipsize="end"
-            android:gravity="center"
-            android:textSize="11.5sp"
-            android:textColor="@color/white"
-            android:paddingStart="@dimen/margin_s"
-            android:paddingEnd="@dimen/margin_s"
-            android:paddingTop="@dimen/margin_button"
-            android:paddingBottom="@dimen/margin_button"
-            android:background="@drawable/selector_copy"
-            android:text="@string/copy"/>
+            android:orientation="horizontal"
+            android:gravity="center_vertical"
+            android:paddingStart="@dimen/margin_default"
+            android:paddingEnd="@dimen/margin_default"
+            android:layout_marginTop="@dimen/margin_default">
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:textSize="@dimen/size_text_title"
+                android:textColor="@color/black_press"
+                android:text="@string/address_title"/>
 
-        <Space
-            android:layout_width="@dimen/margin_default"
-            android:layout_height="wrap_content"/>
+            <TextView
+                android:id="@+id/tv_address"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:textSize="@dimen/size_text_title"
+                android:textColor="@color/gray_text" />
+        </LinearLayout>
 
-        <TextView
-            android:id="@+id/tv_cancel"
+
+        <LinearLayout
+            android:id="@+id/ll_name"
             android:layout_width="wrap_content"
-            android:minWidth="114dp"
             android:layout_height="wrap_content"
-            android:singleLine="true"
-            android:ellipsize="end"
-            android:textColor="@color/black_press"
+            android:orientation="horizontal"
+            android:gravity="center_vertical"
+            android:paddingStart="@dimen/margin_default"
+            android:paddingEnd="@dimen/margin_default"
+            android:layout_marginTop="@dimen/margin_default">
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:textSize="@dimen/size_text_title"
+                android:textColor="@color/black_press"
+                android:text="@string/name_title"/>
+
+            <TextView
+                android:id="@+id/tv_name"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:textSize="@dimen/size_text_title"
+                android:textColor="@color/gray_text"/>
+        </LinearLayout>
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="horizontal"
             android:gravity="center"
-            android:textSize="11.8sp"
-            android:paddingStart="@dimen/margin_s"
-            android:paddingEnd="@dimen/margin_s"
-            android:paddingTop="@dimen/margin_button"
-            android:paddingBottom="@dimen/margin_button"
-            android:background="@drawable/selector_cancel"
-            android:text="@string/cancel"/>
+            android:paddingStart="@dimen/margin_default"
+            android:paddingEnd="@dimen/margin_default"
+            android:layout_marginTop="64dp"
+            android:layout_marginBottom="32dp">
+
+            <TextView
+                android:id="@+id/tv_copy"
+                android:layout_width="wrap_content"
+                android:minWidth="114dp"
+                android:layout_height="wrap_content"
+                android:singleLine="true"
+                android:ellipsize="end"
+                android:gravity="center"
+                android:textSize="11.5sp"
+                android:textColor="@color/white"
+                android:paddingStart="@dimen/margin_s"
+                android:paddingEnd="@dimen/margin_s"
+                android:paddingTop="@dimen/margin_button"
+                android:paddingBottom="@dimen/margin_button"
+                android:background="@drawable/selector_copy"
+                android:text="@string/copy"/>
+
+            <Space
+                android:layout_width="@dimen/margin_default"
+                android:layout_height="wrap_content"/>
+
+            <TextView
+                android:id="@+id/tv_cancel"
+                android:layout_width="wrap_content"
+                android:minWidth="114dp"
+                android:layout_height="wrap_content"
+                android:singleLine="true"
+                android:ellipsize="end"
+                android:textColor="@color/black_press"
+                android:gravity="center"
+                android:textSize="11.8sp"
+                android:paddingStart="@dimen/margin_s"
+                android:paddingEnd="@dimen/margin_s"
+                android:paddingTop="@dimen/margin_button"
+                android:paddingBottom="@dimen/margin_button"
+                android:background="@drawable/selector_cancel"
+                android:text="@string/cancel"/>
+        </LinearLayout>
     </LinearLayout>
-</LinearLayout>
+</ScrollView>

+ 3 - 0
app/src/main/res/values-ja-rJP/strings.xml

@@ -7,6 +7,9 @@
     <string name="postal_code">郵便番号</string>
     <string name="address">住所</string>
     <string name="name">氏名</string>
+    <string name="postal_code_title">郵便番号:&#160;</string>
+    <string name="address_title">住所:&#160;</string>
+    <string name="name_title">氏名:&#160;</string>
     <string name="full">全範囲の読取</string>
     <string name="result"># 読み取り結果</string>
     <string name="copy_success">コピー成功</string>

+ 3 - 0
app/src/main/res/values-zh-rCN/strings.xml

@@ -7,6 +7,9 @@
     <string name="postal_code">邮政编号</string>
     <string name="address">住址</string>
     <string name="name">姓名</string>
+    <string name="postal_code_title">邮政编号:&#160;</string>
+    <string name="address_title">住址:&#160;</string>
+    <string name="name_title">姓名:&#160;</string>
     <string name="full">整单识别</string>
     <string name="result"># 结果</string>
     <string name="copy_success">复制成功</string>

+ 1 - 0
app/src/main/res/values/colors.xml

@@ -9,4 +9,5 @@
     <color name="divider">#E5E5E5</color>
     <color name="blue_copy">#33A4E2</color>
     <color name="gray_stroke">#C1C1C1</color>
+    <color name="gray_text">#A9ACB3</color>
 </resources>

+ 3 - 0
app/src/main/res/values/strings.xml

@@ -7,6 +7,9 @@
     <string name="postal_code">Post Code</string>
     <string name="address">Address</string>
     <string name="name">Name</string>
+    <string name="postal_code_title">Post Code:&#160;</string>
+    <string name="address_title">Address:&#160;</string>
+    <string name="name_title">Name:&#160;</string>
     <string name="full">Full DN</string>
     <string name="result"># Result</string>
     <string name="copy_success">Copied</string>