Ver código fonte

二维码初始化

everywindchase 4 meses atrás
pai
commit
c3c8cb9a3d

+ 1 - 0
app/build.gradle

@@ -91,6 +91,7 @@ dependencies {
     implementation  libs.camera.view
     implementation  libs.camera.mlkit
     implementation  libs.camera.ext
+    implementation 'com.github.xuexiangjys:XQRCode:1.1.1'
     testImplementation 'junit:junit:4.13.2'
     androidTestImplementation 'androidx.test.ext:junit:1.1.5'
     androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

+ 25 - 10
app/src/main/java/jx/cn/escort/ui/activity/ActionTaskHandActivity.kt

@@ -6,21 +6,18 @@ import android.Manifest
 import android.Manifest.permission.*
 import android.content.Context
 import android.content.DialogInterface
-import android.content.Intent
 import android.content.SharedPreferences
 import android.content.pm.PackageManager
 import android.content.pm.PackageManager.PERMISSION_GRANTED
-import android.net.Uri
 import android.os.Build
 import android.os.Bundle
-import android.os.Handler
-import android.os.Looper
-import android.provider.Settings
+import android.os.SystemClock
 import android.util.Log
 import android.util.Size
+import android.view.Gravity
 import android.view.LayoutInflater
+import android.view.MotionEvent
 import android.view.View
-import android.widget.Toast
 import androidx.appcompat.app.AppCompatActivity
 import androidx.camera.core.*
 import androidx.camera.core.ImageAnalysis.OUTPUT_IMAGE_FORMAT_YUV_420_888
@@ -34,7 +31,9 @@ import androidx.core.content.ContextCompat
 import androidx.lifecycle.LifecycleOwner
 import androidx.lifecycle.lifecycleScope
 import com.xuexiang.xui.XUI
+import com.xuexiang.xui.widget.dialog.materialdialog.DialogAction
 import com.xuexiang.xui.widget.dialog.materialdialog.MaterialDialog
+import com.xuexiang.xui.widget.textview.supertextview.SuperTextView
 import jx.cn.escort.R
 import jx.cn.escort.databinding.ActivityActionTaskHandleBinding
 import jx.cn.escort.extension.ExtensionBinding.Companion.binding
@@ -63,6 +62,7 @@ class ActionTaskHandActivity : AppCompatActivity(), KoinComponent {
     private lateinit var camera: Camera //相机对象
     private lateinit   var imageAnalysis: ImageAnalysis
     private lateinit  var circle:CircleProgressView
+    private lateinit  var faceDialog:MaterialDialog
 
 
     override fun onCreate(savedInstanceState: Bundle?) {
@@ -131,12 +131,19 @@ class ActionTaskHandActivity : AppCompatActivity(), KoinComponent {
                         }
 
                     })
+
                 dialog.dismissListener(object:DialogInterface.OnDismissListener{
                     override fun onDismiss(dialog: DialogInterface?) {
                         if (preview != null) {
                             cameraProvider?.unbindAll()
                             preview = null;
                         }
+                        var lineCar=findViewById<SuperTextView>(R.id.line_car)
+                        lineCar.setCenterEditString("苏A000000")
+                        lineCar.setCenterTextGravity(Gravity.AXIS_X_SHIFT)
+                        var lineMember=findViewById<SuperTextView>(R.id.line_member)
+                        lineMember.setCenterEditString(defaultSharedPreferences.getString("realName","人员"))
+                        lineMember.setCenterTextGravity(Gravity.AXIS_X_SHIFT)
                     }
 
                 }).show()
@@ -205,16 +212,21 @@ class ActionTaskHandActivity : AppCompatActivity(), KoinComponent {
                 Log.d("ActionTask", "图片格式${imageProxy.format}")
 
 
-                // 定义一个Runnable,它将被重复执行
+
 
                 lifecycleScope.launch {
+                    circle.setProgress(30)
+                    delay(1000)
                     circle.setProgress(60)
-                    delay(5000)
+                    delay(1000)
                     circle.setProgress(80)
-                    delay(5000)
+                    delay(1000)
                     circle.setProgress(100)
-                }
+                    delay(1000)
+                    circle.setText("检测通过")
+                    delay(1000)
 
+}
 
 
             }
@@ -237,6 +249,9 @@ class ActionTaskHandActivity : AppCompatActivity(), KoinComponent {
                 }
 
 
+
+
+
             } catch (e: Exception) {
                 Log.d("ActionTask","初始化相机异常${e.message}")
             }

+ 1 - 0
app/src/main/java/jx/cn/escort/ui/activity/LoginActivity.kt

@@ -94,6 +94,7 @@ import org.koin.core.component.inject
 
                 delay(1000L)
                 defaultSharedPreferences.edit().putString("isAuth", "是").apply()
+                defaultSharedPreferences.edit().putString("realName","人员").apply()
                 defaultSharedPreferences.edit().putString("account", account).apply()
                 defaultSharedPreferences.edit().putString("password", password).apply()
                 if(account.matches(accountRegex[0])){

+ 13 - 7
app/src/main/java/jx/cn/escort/ui/widget/CircleProgressView.kt

@@ -21,8 +21,10 @@ class CircleProgressView(context: Context) : View(context) {
 
     private var progress = 0 //进度
 
-    private var progressStartColor = "#b3e6fe" //进度渐变开始颜色
-    private var progressEndColor = "#04adfb" //进度渐变结束颜色
+    private var progressStartColor = "#95E4D4" //进度渐变开始颜色
+    private var progressEndColor = "#65EACD" //进度渐变结束颜色
+
+    var mtext = "未检测到人脸"
 
     fun setProgressStartColor(progressStartColor: String) {
         this.progressStartColor = progressStartColor
@@ -41,16 +43,15 @@ class CircleProgressView(context: Context) : View(context) {
     override fun onDraw(canvas: Canvas) {
         super.onDraw(canvas)
         initPaint()
-        var text = "未检测到人脸"
         var angle = progress.toFloat() * 330 / 100
         if (angle > 330) {
             angle = 330f
-        } else if (angle > 30) {
-            text = "请保持不动"
+        } else if ( angle > 30 ) {
+            mtext = "请保持不动"
         }
-        val width = mTextPaint!!.measureText(text)
+        val width = mTextPaint!!.measureText(mtext)
 
-        canvas.drawText(text, centerPoint!!.x - width / 2, InnerRectF!!.top + 100, mTextPaint!!)
+        canvas.drawText(mtext, centerPoint!!.x - width / 2, InnerRectF!!.top + 100, mTextPaint!!)
 
         canvas.drawCircle(centerPoint!!.x, centerPoint!!.y, (paintWidth * 3 / 2 + paintWidth / 2), bottomCirclePaint!!)
         canvas.drawArc(InnerRectF!!, 105f, 330f, false, mInnerPaint!!)
@@ -149,4 +150,9 @@ class CircleProgressView(context: Context) : View(context) {
         this.paintWidth = paintWidth
     }
 
+    fun setText(text: String){
+        this.mtext=text
+        postInvalidate()
+    }
+
 }

+ 95 - 2
app/src/main/res/layout/activity_action_task_handle.xml

@@ -57,8 +57,9 @@
                 android:layout_marginTop="120dp">
 
             <com.xuexiang.xui.widget.textview.supertextview.SuperTextView
+                    android:id="@+id/line_car"
                     android:layout_width="match_parent"
-                    android:layout_height="42dp"
+                    android:layout_height="57dp"
                     app:sLeftTextString="线路车辆:"
                     app:sLeftTextIsBold="true"
                     app:sLeftTextSize="21sp"
@@ -66,11 +67,14 @@
             />
 
             <com.xuexiang.xui.widget.textview.supertextview.SuperTextView
+                    android:id="@+id/line_member"
                     android:layout_width="match_parent"
-                    android:layout_height="42dp"
+                    android:layout_height="65dp"
                     app:sLeftTextString="线路人员:"
                     app:sLeftTextIsBold="true"
                     app:sLeftTextSize="21sp"
+                    app:sCenterTextSize="210sp"
+                    app:sCenterTextIsBold="true"
                     android:layout_marginTop="40dp"
                     app:sLeftIconRes="@drawable/ic_task_line_member"
             />
@@ -80,8 +84,97 @@
     </androidx.cardview.widget.CardView>
 
 
+<androidx.cardview.widget.CardView
+        android:id="@+id/escort_member"
+        android:layout_marginTop="15dp"
+        android:layout_width="match_parent"
+        android:layout_height="220dp"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toStartOf="parent"
+        app:layout_constraintTop_toBottomOf="@id/task_handle_card"
+>
+
+
+</androidx.cardview.widget.CardView>
+
+    <androidx.cardview.widget.CardView
+            android:id="@+id/go_next"
+            android:layout_marginTop="24dp"
+            android:layout_width="match_parent"
+            android:layout_height="62dp"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintEnd_toStartOf="parent"
+            app:layout_constraintBottom_toTopOf="@id/bottom_nav"
+            app:layout_constraintHorizontal_bias="0.0">
+        <com.xuexiang.xui.widget.textview.supertextview.SuperTextView
+                android:layout_width="180dp"
+                android:layout_height="match_parent"
+                android:id="@+id/top_setting_go_btn"
+                app:sCenterTextColor="@color/black"
+                app:sCenterTextString="确认验证"
+                app:sCenterTextIsBold="true"
+                app:layout_constraintTop_toTopOf="parent"
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintEnd_toStartOf="@+id/divider_setting"
+                app:sLeftIconRes="@drawable/ic_setting"
+                app:sLeftIconWidth="45sp"
+                app:sLeftIconHeight="45sp"
+                app:sLeftViewGravity="left_center"
 
+        />
+        <View
+                android:id="@+id/divider_setting"
+                android:layout_width="match_parent"
+                android:layout_height="120dp"
+                android:background="@drawable/divider_bg"
+                app:layout_constraintStart_toEndOf="@+id/top_setting_go_btn"
+
+                android:layout_gravity="center_vertical"
+        />
 
 
 
+        <com.xuexiang.xui.widget.textview.supertextview.SuperTextView
+                android:layout_width="180dp"
+                android:layout_height="match_parent"
+                android:layout_marginStart="220dp"
+                android:id="@+id/top_setting_logout_btn"
+                app:layout_constraintTop_toTopOf="parent"
+                app:layout_constraintEnd_toEndOf="parent"
+                app:sCenterTextColor="@color/black"
+                app:sCenterTextString="取消验证"
+                app:sLeftIconRes="@drawable/ic_setting_logout"
+                app:sLeftIconWidth="45sp"
+                app:sLeftIconHeight="45sp"
+                app:sCenterTextIsBold="true"
+        />
+
+
+
+
+
+    </androidx.cardview.widget.CardView>
+
+
+
+
+
+
+    <jx.cn.escort.ui.widget.CustomBottomNav
+            android:theme="@style/App.Material"
+            android:id="@+id/bottom_nav"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            app:layout_constraintEnd_toStartOf="parent"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintHorizontal_bias="0.0"
+            app:itemIconSize="20dp"
+            app:layout_constraintStart_toStartOf="parent"
+            android:background="#D7E8E8"
+            app:itemBackground="@null"
+            app:menu="@menu/layout_nav_menu"
+            style="@style/BottomNavigationView"
+
+    />
+
 </androidx.constraintlayout.widget.ConstraintLayout>

+ 2 - 2
app/src/main/res/layout/layout_task_face.xml

@@ -19,8 +19,8 @@
 
           <androidx.camera.view.PreviewView
                   android:id="@+id/mPreviewView"
-                  android:layout_width="260dp"
-                  android:layout_height="268dp"
+                  android:layout_width="290dp"
+                  android:layout_height="290dp"
                   android:layout_gravity="center"
                   android:gravity="center"
                   app:layout_constraintBottom_toBottomOf="parent"