Quellcode durchsuchen

Merge remote-tracking branch 'origin/master' into master-sx

# Conflicts:
#	app/build.gradle
cookbyte vor 1 Monat
Ursprung
Commit
61772eb82a

+ 2 - 5
app/build.gradle

@@ -13,8 +13,8 @@ android {
 
 
         targetSdkVersion 34
-        versionCode 10
-        versionName "1.0.1.25092315(sx)"
+        versionCode 1
+        versionName "1.0.0.2509241110"
         ndk {
             abiFilters 'armeabi-v7a'
 //            abiFilters.addAll(listOf("armeabi-v7a", "arm64-v8a"))
@@ -59,9 +59,6 @@ android {
         sourceCompatibility JavaVersion.VERSION_17
         targetCompatibility JavaVersion.VERSION_17
     }
-    kotlinOptions {
-        jvmTarget = JavaVersion.VERSION_17.toString() // or "11", or "17"
-    }
     buildFeatures {
         buildConfig = true
         viewBinding = true

+ 5 - 0
app/src/main/java/com/bskeji/face/app/AppConstant.kt

@@ -6,6 +6,11 @@ object AppConstant {
     const val collectDataDefultTime = 90
     const val adminPwd = "admin2025"
     var userPwd = "1"
+    
+    // 默认配置参数
+    const val defaultResetTimeAfterReceiveData = 15
+    const val defaultBackTimeCollect = 90
+    const val defaultBackTimeFace = 30
 }
 object TimerKey{
     const val TIMER_GPIO = "TIMER_GPIO"

+ 135 - 0
app/src/main/java/com/bskeji/face/helper/ConfigManager.kt

@@ -0,0 +1,135 @@
+package com.bskeji.face.helper
+
+import com.bskeji.face.app.AppConstant
+import com.bskeji.face.app.CacheKey
+import com.hm.library.app.Cacher
+
+/**
+ * 配置管理器
+ * 提供统一的配置参数访问接口,避免硬编码默认值
+ * 
+ * @author System
+ * @date 2024
+ */
+object ConfigManager {
+    
+    /**
+     * 获取接收数据后的重置超时时间
+     * @return 超时时间(秒)
+     */
+    fun getResetTimeAfterReceiveData(): Int {
+        return Cacher[CacheKey.cacheResetTimeAfterReceiveData, AppConstant.defaultResetTimeAfterReceiveData]
+    }
+    
+    /**
+     * 获取数据采集超时时间
+     * @return 超时时间(秒)
+     */
+    fun getBackTimeCollect(): Int {
+        return Cacher[CacheKey.cacheBackTimeCollect, AppConstant.defaultBackTimeCollect]
+    }
+    
+    /**
+     * 获取人脸识别超时时间
+     * @return 超时时间(秒)
+     */
+    fun getBackTimeFace(): Int {
+        return Cacher[CacheKey.cacheBackTimeFace, AppConstant.defaultBackTimeFace]
+    }
+    
+    /**
+     * 设置接收数据后的重置超时时间
+     * @param timeInSeconds 超时时间(秒)
+     */
+    fun setResetTimeAfterReceiveData(timeInSeconds: Int) {
+        Cacher[CacheKey.cacheResetTimeAfterReceiveData] = timeInSeconds
+    }
+    
+    /**
+     * 设置数据采集超时时间
+     * @param timeInSeconds 超时时间(秒)
+     */
+    fun setBackTimeCollect(timeInSeconds: Int) {
+        Cacher[CacheKey.cacheBackTimeCollect] = timeInSeconds
+    }
+    
+    /**
+     * 设置人脸识别超时时间
+     * @param timeInSeconds 超时时间(秒)
+     */
+    fun setBackTimeFace(timeInSeconds: Int) {
+        Cacher[CacheKey.cacheBackTimeFace] = timeInSeconds
+    }
+    
+    /**
+     * 获取IP地址配置
+     * @return IP地址
+     */
+    fun getIP(): String {
+        return Cacher[CacheKey.cacheIP, ""]
+    }
+    
+    /**
+     * 获取H5 IP地址配置
+     * @return H5 IP地址
+     */
+    fun getH5IP(): String {
+        return Cacher[CacheKey.cacheH5IP, ""]
+    }
+    
+    /**
+     * 获取用户密码
+     * @return 用户密码
+     */
+    fun getUserPassword(): String {
+        return Cacher[CacheKey.cacheUserPassword, AppConstant.userPwd]
+    }
+    
+    /**
+     * 获取百度License Key
+     * @return License Key
+     */
+    fun getBaiduLicenseKey(): String {
+        return Cacher[CacheKey.cacheBaiduLicenseKey, ""]
+    }
+    
+    /**
+     * 获取设备类型索引
+     * @return 设备类型索引 (0:体重;1:血压)
+     */
+    fun getDeviceTypeIndex(): Int {
+        return Cacher[CacheKey.cacheDeviceTypeIndex, 0]
+    }
+    
+    /**
+     * 获取设备型号索引
+     * @return 设备型号索引
+     */
+    fun getDeviceModelIndex(): Int {
+        return Cacher[CacheKey.cacheDeviceModelIndex, 0]
+    }
+    
+    /**
+     * 获取血压TTS配置
+     * @return 是否启用血压TTS
+     */
+    fun getBloodTTS(): Boolean {
+        return Cacher[CacheKey.cacheTtsBlood, true]
+    }
+    
+    /**
+     * 获取体重TTS配置
+     * @return 是否启用体重TTS
+     */
+    fun getWeightTTS(): Boolean {
+        return Cacher[CacheKey.cacheTtsWeight, true]
+    }
+    
+    /**
+     * 获取GPIO读取配置
+     * @return 是否启用GPIO读取
+     */
+    fun getReadGPIO(): Boolean {
+        return Cacher[CacheKey.cacheReadGPIO, false]
+    }
+}

+ 14 - 0
app/src/main/java/com/bskeji/face/helper/TTSUtil.kt

@@ -37,4 +37,18 @@ class TTSUtil private constructor() {
     fun speakFlush(content: String) {
         mTextToSpeech?.speak(content,TextToSpeech.QUEUE_FLUSH,null)
     }
+    
+    /**
+     * 停止当前的语音播报
+     */
+    fun stopSpeaking() {
+        mTextToSpeech?.stop()
+    }
+    
+    /**
+     * 检查是否正在播报
+     */
+    fun isSpeaking(): Boolean {
+        return mTextToSpeech?.isSpeaking ?: false
+    }
 }

+ 12 - 2
app/src/main/java/com/bskeji/face/ui/MainActivity.kt

@@ -29,6 +29,7 @@ import com.bskeji.face.expansion.appendHost
 import com.bskeji.face.expansion.format
 import com.bskeji.face.expansion.getLocalPathWithImageName
 import com.bskeji.face.expansion.inflate
+import com.bskeji.face.helper.ConfigManager
 import com.bskeji.face.helper.GsonUtils
 import com.bskeji.face.helper.SerialControlUtil
 import com.bskeji.face.helper.TTSUtil
@@ -229,7 +230,13 @@ class MainActivity : AppBaseActivity() {
         }
         binding.tvName.text = userNameId.split("_")[0]
         binding.vBack.setOnClickListener {
-            //startActivity<LogoActivity>()
+            // 停止当前的语音播报
+            try{
+                TTSUtil.get().stopSpeaking()
+                Thread.sleep(100)
+            }catch (e: Exception){}
+            
+            startActivity<LogoActivity>() //返回到开始页面
             finish()
         }
         binding.vInclude.tvTitle.text = "AI人脸识别报告"
@@ -301,10 +308,13 @@ class MainActivity : AppBaseActivity() {
 
                         } else {
                             stopTimer(timerCollectDataKey)
+                            startActivity<LogoActivity>() //返回到开始页面
+
                             finish()
                         }
                     } else {
                         stopTimer(timerCollectDataKey)
+                        startActivity<LogoActivity>() //返回到开始页面
                         finish()
                     }
 
@@ -622,7 +632,7 @@ class MainActivity : AppBaseActivity() {
                 minBlood,
                 pulse
             )
-            countDownTime = 5
+            countDownTime = ConfigManager.getResetTimeAfterReceiveData()
             if (!success) {
                 runOnUiThread {
                     TitleMsgDialog(this, "血压测量结果", ttsContent, false).show()

+ 2 - 1
app/src/main/java/com/bskeji/face/ui/SettingActivity.kt

@@ -12,6 +12,7 @@ import com.bskeji.face.app.DeviceTypeModelName
 import com.bskeji.face.base.AppBaseActivity
 import com.bskeji.face.databinding.ActivitySettingBinding
 import com.bskeji.face.expansion.inflate
+import com.bskeji.face.helper.ConfigManager
 import com.bskeji.face.http.LLogger
 import com.bskeji.face.view.dialog.DeviceTypeModelDialog
 import com.hm.library.app.Cacher
@@ -121,7 +122,7 @@ class SettingActivity(override var layoutResID: Int = R.layout.activity_setting)
             }
 
         })
-        binding.etBackTimeReceiveData.setText(Cacher[CacheKey.cacheResetTimeAfterReceiveData, 8].toString())
+        binding.etBackTimeReceiveData.setText(ConfigManager.getResetTimeAfterReceiveData().toString())
         binding.etBackTimeReceiveData.addTextChangedListener(object : TextWatcher {
             override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
             }