Explorar el Código

face & qrcode ui tune up

billyyoyo hace 6 años
padre
commit
3c9bdae2bb

BIN
app/libs/face-sdk-release.aar


+ 1 - 1
app/src/main/AndroidManifest.xml

@@ -874,7 +874,7 @@
             android:exported="true"
             android:launchMode="singleInstance"
             android:screenOrientation="portrait"
-            android:theme="@style/AppActionTheme" />
+            android:theme="@style/AppThemeMain" />
         <activity
             android:name="com.sheep.gamegroup.view.activity.GameCertificationActivity"
             android:exported="true"

+ 9 - 0
app/src/main/java/com/sheep/gamegroup/model/entity/QRCode.java

@@ -14,6 +14,7 @@ public class QRCode {
     private String qr_url;
     private int relation_id;
     private int status;
+    private int create_count = 0;
 
 
     public int getId() {
@@ -24,6 +25,14 @@ public class QRCode {
         this.id = id;
     }
 
+    public int getCreate_count() {
+        return create_count;
+    }
+
+    public void setCreate_count(int create_count) {
+        this.create_count = create_count;
+    }
+
     public String getAction_content() {
         return action_content;
     }

+ 3 - 8
app/src/main/java/com/sheep/gamegroup/module/home/fragment/FgtMainHeader.java

@@ -3,8 +3,6 @@ package com.sheep.gamegroup.module.home.fragment;
 import android.content.Intent;
 import android.graphics.Color;
 import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentTransaction;
 import android.view.View;
 import android.widget.ImageView;
 import android.widget.TextView;
@@ -25,9 +23,7 @@ import com.sheep.gamegroup.util.LogUtil;
 import com.sheep.gamegroup.util.ViewUtil;
 import com.sheep.gamegroup.view.activity.ActMsg;
 import com.sheep.gamegroup.view.dialog.DialogNotificationOfArrival;
-import com.sheep.gamegroup.view.fragment.FgtFind;
 import com.sheep.gamegroup.view.fragment.FgtPersonalCenter;
-import com.sheep.gamegroup.view.fragment.FgtSmallSheep;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.base.BaseFragment;
@@ -132,10 +128,10 @@ public class FgtMainHeader extends BaseFragment {
 
     private void showUserProfile() {
         GlideImageLoader.setAvatar(iv_user_face, user.getAvatar(), Color.argb(128, 255, 255, 255));
-        if(iv_flag_vip!=null) {
+        if (iv_flag_vip != null) {
             if (user.isVIP()) {
                 iv_flag_vip.setImageResource(R.mipmap.level_vip);
-            } else{
+            } else {
                 iv_flag_vip.setImageResource(R.mipmap.level_vip_un);
             }
         }
@@ -176,7 +172,7 @@ public class FgtMainHeader extends BaseFragment {
     }
 
     @OnClick(R.id.iv_scan)
-    public void onScanQR(){
+    public void onScanQR() {
         if (!CameraUtil.checkCameraPermission(getActivity())) return;
         Intent intent = new Intent(getActivity(), CaptureActivity.class);
         getActivity().startActivityForResult(intent, Constant.INTENT_CAPTURE_QRCODE);
@@ -255,5 +251,4 @@ public class FgtMainHeader extends BaseFragment {
     }
 
 
-
 }

+ 1 - 0
app/src/main/java/com/sheep/gamegroup/module/qrcode/FaceWithQRActivity.java

@@ -81,6 +81,7 @@ public class FaceWithQRActivity extends BaseActivity {
             }else{
                 intent.putExtra("req", "sheep://facedetect");
             }
+            intent.putExtra("message", "检测到你的账号异常,需要人脸识别验证");
             intent.putExtra("token", token);
             intent.putExtra("extra", "");
             startActivityForResult(intent, Constant.INTENT_QRCODE_DATA);

+ 33 - 8
app/src/main/java/com/sheep/gamegroup/module/qrcode/QRCodeActivity.java

@@ -5,7 +5,9 @@ import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
 import android.os.Looper;
 import android.util.Base64;
+import android.view.View;
 import android.widget.ImageView;
+import android.widget.TextView;
 
 import com.alibaba.fastjson.JSONObject;
 import com.bumptech.glide.Glide;
@@ -14,12 +16,14 @@ import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.QRCode;
 import com.sheep.gamegroup.model.util.SheepSubscriber;
 import com.sheep.gamegroup.util.GlideImageLoader;
+import com.sheep.gamegroup.util.ViewUtil;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.utils.G;
 import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
 
 import butterknife.BindView;
+import butterknife.OnClick;
 import io.reactivex.android.schedulers.AndroidSchedulers;
 import io.reactivex.schedulers.Schedulers;
 
@@ -28,6 +32,10 @@ public class QRCodeActivity extends BaseActivity implements Runnable {
 
     @BindView(R.id.qr_iv)
     public ImageView qrCodeImageView;
+    @BindView(R.id.message_view)
+    public TextView messageView;
+    @BindView(R.id.time_view)
+    public TextView timeView;
 
     //谁
     private String token;
@@ -55,10 +63,7 @@ public class QRCodeActivity extends BaseActivity implements Runnable {
 
     @Override
     public void initView() {
-        TitleBarUtils.getInstance()
-                .setShowOrHide(this, true)
-                .setTitle(this, "扫描下面二维码")
-                .setTitleBack(this);
+        messageView.setText(getIntent().getStringExtra("message"));
     }
 
     public void createQRCodeAction(boolean withLoop) {
@@ -102,8 +107,12 @@ public class QRCodeActivity extends BaseActivity implements Runnable {
                             returnResult(qrCode.getAction_content());
                         } else {
                             if (qrCode.isExpired()) {
-                                G.showToast("二维码已过期, 自动刷新二维码");
-                                createQRCodeAction(false);
+                                if (qrCode.getCreate_count() < 5) {
+                                    G.showToast("二维码已过期, 自动刷新二维码");
+                                    createQRCodeAction(false);
+                                } else {
+                                    finish();
+                                }
                             }
                         }
                     }
@@ -123,6 +132,11 @@ public class QRCodeActivity extends BaseActivity implements Runnable {
         finish();
     }
 
+    @OnClick(R.id.close_btn)
+    public void onClose() {
+        finish();
+    }
+
     @Override
     public void onDestroy() {
         isLooping = false;
@@ -131,11 +145,22 @@ public class QRCodeActivity extends BaseActivity implements Runnable {
 
     @Override
     public void run() {
+        int i = 0;
         while (isLooping) {
             try {
-                Thread.sleep(3000);
+                Thread.sleep(1000);
+                i++;
                 if (!isLooping) break;
-                runOnUiThread(() -> fetchResult());
+                if (qrCode != null) {
+                    if (qrCode.isExpired()) {
+                        runOnUiThread(() -> ViewUtil.setText(timeView, "正在刷新二维码......"));
+                    } else {
+                        runOnUiThread(() -> ViewUtil.setText(timeView, "剩余: " + (qrCode.getExpire_time() - System.currentTimeMillis() / 1000) + "S"));
+                    }
+                }
+                if (i % 3 == 0) {
+                    runOnUiThread(() -> fetchResult());
+                }
             } catch (InterruptedException e) {
                 e.printStackTrace();
             }

+ 2 - 2
app/src/main/java/com/sheep/gamegroup/util/CertificationUtil.java

@@ -123,9 +123,9 @@ public class CertificationUtil {
                         } else if (baseMessage.getCode() == 404000023) {
                             Jump2View.getInstance().goFaceWithQR(activity, Constant.INTENT_DETECT_FACE, token);
                         } else if(baseMessage.getCode() == 404000024){
-                            G.showToast("需要绑定手机号");
+                            G.showToast("提示:请在小绵羊APP内完成当前账号绑定手机号");
                         } else if(baseMessage.getCode() == 404000025){
-                            G.showToast("需要实名认证");
+                            G.showToast("提示:请在小绵羊APP内完成当前账号实名认证");
                         } else {
                             showCertificationErrorAndExitApp(activity, "请求授权错误 " + baseMessage.getMsg(), 1000);
                         }

+ 59 - 6
app/src/main/res/layout/act_qrcode.xml

@@ -1,19 +1,72 @@
 <?xml version="1.0" encoding="utf-8"?>
 <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:background="@color/background_light_gray"
-    xmlns:app="http://schemas.android.com/apk/res-auto">
+    android:background="#333333">
+
+    <ImageView
+        android:id="@+id/close_btn"
+        android:layout_width="40dp"
+        android:layout_height="40dp"
+        android:layout_marginTop="30dp"
+        android:layout_marginRight="16dp"
+        android:src="@mipmap/ic_close_ext"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+
+    <TextView
+        android:id="@+id/message_view"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:gravity="center"
+        android:text="二维码"
+        app:layout_constraintTop_toBottomOf="@+id/close_btn"
+        android:layout_marginTop="24dp"
+        android:textColor="@android:color/white"
+        android:textSize="15sp" />
 
     <ImageView
         android:id="@+id/qr_iv"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginLeft="60dp"
+        android:layout_marginTop="50dp"
+        android:layout_marginRight="60dp"
         android:adjustViewBounds="true"
         android:scaleType="fitCenter"
+        app:layout_constraintTop_toBottomOf="@+id/message_view" />
+
+    <TextView
+        android:id="@+id/tip_view"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:layout_marginTop="50dp"
-        android:layout_marginLeft="30dp"
-        android:layout_marginRight="30dp"
-        app:layout_constraintTop_toTopOf="parent"/>
+        android:gravity="center"
+        app:layout_constraintTop_toBottomOf="@+id/qr_iv"
+        android:layout_marginTop="35dp"
+        android:text="请在手机打开小绵羊扫描二维码"
+        android:textColor="@android:color/white"
+        android:textSize="15sp" />
+
+    <TextView
+        android:id="@+id/time_view"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:gravity="center"
+        app:layout_constraintTop_toBottomOf="@+id/tip_view"
+        android:layout_marginTop="24dp"
+        android:textColor="#2EBEF2"
+        android:textSize="15sp" />
+
+    <TextView
+        android:id="@+id/warn_view"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:gravity="center"
+        app:layout_constraintBottom_toBottomOf="parent"
+        android:layout_marginBottom="60dp"
+        android:text="验证注意:验证时需要你的手机和模拟器\n处于同一个网络(IP)下"
+        android:textColor="#24A318"
+        android:textSize="13sp" />
 
 </android.support.constraint.ConstraintLayout>