Pārlūkot izejas kodu

增加实名认证界面

jixionghui 4 gadi atpakaļ
vecāks
revīzija
0de74eb9df

+ 2 - 1
jixin/src/main/AndroidManifest.xml

@@ -93,7 +93,8 @@
         android:usesCleartextTraffic="true"
         tools:ignore="GoogleAppIndexingWarning"
         tools:replace="android:name, android:icon, android:roundIcon">
-        <activity android:name=".ui.me.JunYouCoinActivity"></activity>
+        <activity android:name=".ui.me.RealNameAuthActivity"></activity>
+        <activity android:name=".ui.me.JunYouCoinActivity" />
         <activity android:name=".ui.TestActivity">
 
             <!-- <intent-filter> -->

+ 104 - 0
jixin/src/main/java/com/jixin/im/ui/me/RealNameAuthActivity.java

@@ -0,0 +1,104 @@
+package com.jixin.im.ui.me;
+
+import android.os.Bundle;
+import android.text.Editable;
+import android.text.TextUtils;
+import android.text.TextWatcher;
+import android.widget.TextView;
+
+import com.jixin.im.R;
+import com.jixin.im.ui.base.BaseActivity;
+import com.jixin.im.util.RegexUtils;
+import com.jixin.im.util.ToastUtil;
+import com.jixin.im.view.ClearEditText;
+
+/**
+ * 实名认证
+ * Created by Harvey on 2020/09/24
+ */
+public class RealNameAuthActivity extends BaseActivity {
+    private ClearEditText edtRealName,edtIdNum;
+    private TextView tvFaceRecognition;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_real_name_auth);
+        initActionBar();
+        initView();
+    }
+    private void initActionBar() {
+        getSupportActionBar().hide();
+        findViewById(R.id.iv_title_left).setOnClickListener(v -> finish());
+        TextView tvTitle = (TextView) findViewById(R.id.tv_title_center);
+        tvTitle.setText(R.string.real_name_auth);
+    }
+
+    private void initView() {
+
+        edtRealName = findViewById(R.id.edt_real_name);
+        edtIdNum = findViewById(R.id.edt_input_id_num);
+        tvFaceRecognition = findViewById(R.id.tv_face_recognition);
+        setListener();
+
+    }
+
+    private void setListener(){
+        edtRealName.addTextChangedListener(new TextWatcher() {
+            @Override
+            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+
+            }
+
+            @Override
+            public void onTextChanged(CharSequence s, int start, int before, int count) {
+
+            }
+
+            @Override
+            public void afterTextChanged(Editable s) {
+                changeFaceRecognitionStatus();
+            }
+        });
+        edtIdNum.addTextChangedListener(new TextWatcher() {
+            @Override
+            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+
+            }
+
+            @Override
+            public void onTextChanged(CharSequence s, int start, int before, int count) {
+
+            }
+
+            @Override
+            public void afterTextChanged(Editable s) {
+                changeFaceRecognitionStatus();
+            }
+        });
+
+        tvFaceRecognition.setOnClickListener(v -> {
+            ToastUtil.showToast(this,"人脸识别");
+        });
+
+    }
+
+    private void changeFaceRecognitionStatus(){
+        String idNum = edtIdNum.getText().toString();
+        String realName = edtRealName.getText().toString();
+        if (!TextUtils.isEmpty(realName) &&RegexUtils.checkIdCard(idNum)){
+            setFaceRecognitionStatus(true);
+        }else {
+            setFaceRecognitionStatus(false);
+        }
+
+    }
+
+    public void setFaceRecognitionStatus(boolean isClickable){
+        tvFaceRecognition.setClickable(isClickable);
+        tvFaceRecognition.setSelected(isClickable);
+
+    }
+
+
+}

+ 4 - 1
jixin/src/main/java/com/jixin/im/util/RegexUtils.java

@@ -1,5 +1,7 @@
 package com.jixin.im.util;
 
+import android.text.TextUtils;
+
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -22,7 +24,8 @@ public class RegexUtils {
      * @return 验证成功返回true,验证失败返回false
      */
     public static boolean checkIdCard(String idCard) {
-        String regex = "[1-9]\\d{13,16}[a-zA-Z0-9]{1}";
+        if (TextUtils.isEmpty(idCard)) return false;
+        String regex = "[1-9]\\d{13,16}[xX0-9]";
         return Pattern.matches(regex, idCard);
     }
 

+ 25 - 0
jixin/src/main/res/drawable/selector_face_recognition.xml

@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_selected="true">
+        <shape>
+            <corners android:radius="15dp" />
+            <solid android:color="#ff2a86ff" />
+        </shape>
+    </item>
+
+    <item android:state_checkable="true">
+        <shape>
+            <corners android:radius="15dp" />
+            <solid android:color="#ff2a86ff" />
+        </shape>
+    </item>
+
+    <item>
+        <shape>
+            <corners android:radius="15dp" />
+            <solid android:color="#ffc2c2c2" />
+        </shape>
+    </item>
+
+
+</selector>

+ 94 - 0
jixin/src/main/res/layout/activity_real_name_auth.xml

@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical"
+    android:background="@color/white"
+    tools:context=".ui.me.RealNameAuthActivity">
+    <include
+        layout="@layout/a_view_actionbar"/>
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:orientation="vertical"
+        android:padding="15dp"
+        android:layout_height="match_parent">
+        <TextView
+            android:layout_width="wrap_content"
+            android:textColor="#333333"
+            android:textSize="25sp"
+            android:textStyle="bold"
+            android:layout_marginTop="20dp"
+            android:text="@string/real_name_auth"
+            android:layout_height="wrap_content"/>
+        <TextView
+            android:text="@string/real_name_auth_tips"
+            android:layout_marginTop="6dp"
+            android:layout_width="wrap_content"
+            android:textStyle="bold"
+            android:textColor="#333333"
+            android:textSize="@dimen/sp_14_text_size"
+            android:layout_height="wrap_content"/>
+        <TextView
+            android:layout_marginTop="40dp"
+            android:textColor="#333333"
+            android:textSize="@dimen/sp_15_text_size"
+            android:textStyle="bold"
+            android:text="@string/real_name"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"/>
+        <com.jixin.im.view.ClearEditText
+            android:id="@+id/edt_real_name"
+            android:layout_marginTop="26dp"
+            android:layout_width="match_parent"
+            android:background="@color/transparent"
+            android:hint="@string/real_name_input_tips"
+            android:layout_height="wrap_content"/>
+
+        <View
+            android:layout_width="match_parent"
+            android:background="#999999"
+            android:layout_marginTop="8dp"
+            android:layout_height="1px"/>
+
+        <TextView
+            android:layout_marginTop="40dp"
+            android:textColor="#333333"
+            android:textSize="@dimen/sp_15_text_size"
+            android:textStyle="bold"
+            android:text="@string/id_card_num"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"/>
+        <com.jixin.im.view.ClearEditText
+            android:id="@+id/edt_input_id_num"
+            android:layout_marginTop="26dp"
+            android:layout_width="match_parent"
+            android:digits="1234567890*"
+            android:background="@color/transparent"
+            android:hint="@string/id_card_num_input_tips"
+            android:layout_height="wrap_content"/>
+
+        <View
+            android:layout_width="match_parent"
+            android:background="#999999"
+            android:layout_marginTop="8dp"
+            android:layout_height="1px"/>
+
+        <TextView
+            android:id="@+id/tv_face_recognition"
+            android:layout_marginTop="64dp"
+            android:gravity="center"
+            android:textColor="@color/white"
+            android:text="@string/face_recognition"
+            android:layout_width="match_parent"
+            android:background="@drawable/selector_face_recognition"
+            android:layout_height="32dp"/>
+
+    </LinearLayout>
+
+
+
+
+
+</LinearLayout>

+ 7 - 3
jixin/src/main/res/values/strings.xml

@@ -2376,12 +2376,16 @@
     <string name="real_name_auth">实名认证</string>
     <string name="help">帮助</string>
     <string name="junyou_gift_pay_service">点击即表示您已同意《俊友钱包支付协议》与《俊友礼物服务条款》。</string>
-
     <string name="junyou_gift_service">《俊友礼物服务条款》</string>
-
     <string name="junyou_pay_service">《俊友钱包支付协议》</string>
 
-
+    <!-- 实名认证  -->
+    <string name="real_name_auth_tips">为有效保障您的资金安全,提升购买俊友币的速度,请填写与您身份证一致的信息,否则不face recognition会通过审核。</string>
+    <string name="real_name">真实姓名</string>
+    <string name="real_name_input_tips">请填写您本人的真实姓名</string>
+    <string name="id_card_num">身份证号码</string>
+    <string name="id_card_num_input_tips">请填写您本人的身份证号</string>
+    <string name="face_recognition">进行人脸识别</string>
 
 
     <!--  end -->