Browse Source

提交人:江天明
提交内容:优化

江天明 1 year ago
parent
commit
483c244afa

+ 7 - 0
BusinessMain/src/main/java/com/develop/main/init/ui/provider/HomeBannerProvider.kt

@@ -1,10 +1,13 @@
 package com.develop.main.init.ui.provider
 
 
+import com.blankj.utilcode.util.NetworkUtils
 import com.chad.library.adapter.base.provider.BaseItemProvider
 import com.chad.library.adapter.base.viewholder.BaseViewHolder
 import com.develop.food.base.data.model.HomeBannerListModel
 import com.develop.food.base.data.model.HomeBannerModel
+import com.develop.food.base.utils.GlobalApp
+import com.develop.food.base.utils.GlobalToast
 import com.develop.main.R
 import com.develop.main.init.ui.adapter.HomeBannerAdapter
 import com.develop.main.init.ui.adapter.RecipesMainAdapter
@@ -22,6 +25,10 @@ class HomeBannerProvider : BaseItemProvider<Any>() {
        val bannerAdapter = HomeBannerAdapter(item.data)
         bannerAdapter.onBannerItemClickListener = object :HomeBannerAdapter.OnBannerItemClickListener{
             override fun onNetRecipesClick(bannerModel: HomeBannerModel) {
+                if (!NetworkUtils.isConnected()){
+                    GlobalToast.showToast(GlobalApp().getString(R.string.network_wifi_status_disconnected))
+                    return
+                }
                 onBannerItemClickListener?.onNetRecipesClick(bannerModel)
             }
         }

+ 152 - 0
BusinessSetting/src/main/java/com/develop/setting/init/ui/AboutActivity.kt

@@ -1,11 +1,16 @@
 package com.develop.setting.init.ui
 
+import android.content.ComponentName
+import android.content.Context
+import android.content.Intent
 import android.os.Build
 import android.os.Bundle
+import android.provider.Settings
 import android.util.Log
 import android.view.LayoutInflater
 import android.view.View
 import android.widget.LinearLayout
+import android.widget.Toast
 import com.alibaba.android.arouter.facade.annotation.Route
 import com.azhon.appupdate.listener.OnDownloadListener
 import com.blankj.utilcode.util.AppUtils
@@ -23,6 +28,7 @@ import com.develop.food.base.utils.isNightTheme
 import com.develop.food.base.utils.toJson
 import com.develop.food.base.widgets.CancelConfirmDialog
 import com.develop.food.base.widgets.CommonDialog
+import com.develop.food.base.widgets.PwdDialog
 import com.develop.food.base.widgets.RecipeUpdateDialog
 import com.develop.setting.R
 import com.develop.setting.databinding.ActivityAboutBinding
@@ -52,6 +58,12 @@ class AboutActivity : BaseActivity<ActivityAboutBinding>() {
     }
 
 
+    private var adbCount = 0
+
+    private var testCount = 0
+
+    private var tpCount = 0
+
     private val recipeUpdateDialog: RecipeUpdateDialog = RecipeUpdateDialog();
 
     private val weightAlignDialog: CancelConfirmDialog = CancelConfirmDialog()
@@ -200,6 +212,72 @@ class AboutActivity : BaseActivity<ActivityAboutBinding>() {
             }
 
         }
+        binding.devSn.setOnClickListener {
+            testCount++
+            if (testCount >= 7) {
+                testCount = 0
+
+                //2023年06月29日14:16:18 处理密码弹出
+                val pwdDialog = PwdDialog()
+                pwdDialog.title = getString(com.develop.base.R.string.enter_password)
+                pwdDialog.showDialog(supportFragmentManager, "pwdDialog")
+                pwdDialog.onDialogClickListener = object : PwdDialog.OnDialogClickListener {
+
+                    override fun onConfirm(pwd: String) {
+                        if ("12345678".equals(pwd)) {
+                            // 创建启动目标活动的Intent
+                            val intent = Intent()
+                            intent.component = ComponentName(
+                                "com.zavier.androidrk3326functiontest",
+                                "com.zavier.androidrk3326functiontest.MainFunctionActivity"
+                            )
+
+                            // 启动目标活动
+                            startActivity(intent)
+                        } else {
+                            GlobalToast.showToast(getString(com.develop.base.R.string.account_password_error))
+                        }
+                    }
+
+                    override fun onCancel() {
+
+                    }
+                }
+
+
+            }
+        }
+
+        binding.tvTpVersion.setOnClickListener {
+            tpCount++
+            if (tpCount >= 7) {
+                tpCount = 0
+
+
+                val ctx = this
+                //2023年06月29日14:16:18 处理密码弹出
+                val pwdDialog = PwdDialog()
+                pwdDialog.title = getString(com.develop.base.R.string.enter_password)
+                pwdDialog.showDialog(supportFragmentManager, "pwdDialog")
+                pwdDialog.onDialogClickListener = object : PwdDialog.OnDialogClickListener {
+
+                    override fun onConfirm(pwd: String) {
+                        if ("12345678".equals(pwd)) {
+                            togglePointerLocation(ctx)
+                        } else {
+                            GlobalToast.showToast(getString(com.develop.base.R.string.account_password_error))
+                        }
+                    }
+
+                    override fun onCancel() {
+
+                    }
+                }
+
+
+            }
+        }
+
 
 
         //点击食谱更新
@@ -304,12 +382,81 @@ class AboutActivity : BaseActivity<ActivityAboutBinding>() {
             cancelConfirmDialog.showDialog(supportFragmentManager, "cancelConfirmDialog")
         }
 
+
+        binding.tvAppVersion.setOnClickListener {
+            adbCount++
+            if (adbCount >= 7) {
+                adbCount = 0
+
+                val ctx = this
+                //2023年06月29日14:16:18 处理密码弹出
+                val pwdDialog = PwdDialog()
+                pwdDialog.title = getString(com.develop.base.R.string.enter_password)
+                pwdDialog.showDialog(supportFragmentManager, "pwdDialog")
+                pwdDialog.onDialogClickListener = object : PwdDialog.OnDialogClickListener {
+
+                    override fun onConfirm(pwd: String) {
+                        if ("12345678".equals(pwd)) {
+                            if (isAdbDebuggingEnabled(ctx)) {
+                                Toast.makeText(ctx, "adb disable", Toast.LENGTH_SHORT).show()
+                                toggleAdbDebugging(ctx, false)
+                            } else {
+                                Toast.makeText(ctx, "adb enable", Toast.LENGTH_SHORT).show()
+                                toggleAdbDebugging(ctx, true)
+                            }
+                        } else {
+                            GlobalToast.showToast(getString(com.develop.base.R.string.account_password_error))
+                        }
+                    }
+
+                    override fun onCancel() {
+
+                    }
+                }
+
+
+            }
+        }
         binding.tvAppName.text = AppUtils.getAppName()
         binding.tvAppVersion.text = "v${AppUtils.getAppVersionName()}"
 
         binding.tvTpVersion.text = Build.DISPLAY
     }
 
+    fun isAdbDebuggingEnabled(context: Context): Boolean {
+        return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
+            Settings.Secure.getInt(
+                context.contentResolver,
+                Settings.Global.ADB_ENABLED,
+                0
+            ) != 0
+        } else {
+            Settings.Secure.getInt(
+                context.contentResolver,
+                Settings.Secure.ADB_ENABLED,
+                0
+            ) != 0
+        }
+    }
+
+
+    fun toggleAdbDebugging(context: Context, enable: Boolean) {
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
+            Settings.Secure.putInt(
+                context.contentResolver,
+                Settings.Global.ADB_ENABLED,
+                if (enable) 1 else 0
+            )
+        } else {
+            Settings.Secure.putInt(
+                context.contentResolver,
+                Settings.Secure.ADB_ENABLED,
+                if (enable) 1 else 0
+            )
+        }
+    }
+
+
     override fun onResume() {
         super.onResume()
         FoodRepository.devInfo().observeStatus(onSuccess = {
@@ -322,6 +469,11 @@ class AboutActivity : BaseActivity<ActivityAboutBinding>() {
             binding.tvUpdateFirmware.visibility = View.VISIBLE
         })
     }
+    fun togglePointerLocation(context: Context) {
+        val currentSetting = Settings.System.getInt(context.contentResolver, "pointer_location", 0)
+        val newSetting = if (currentSetting == 0) 1 else 0
+        Settings.System.putInt(context.contentResolver, "pointer_location", newSetting)
+    }
 
 
     override fun onDestroy() {

+ 62 - 45
BusinessStep/src/main/java/com/develop/step/CookStepActivity2.kt

@@ -103,24 +103,28 @@ class CookStepActivity2 : CookStepToolActivity() {
         initData()
 
         binding.viewRemark.setOnClickListener {
-            Log.i("dd",CURRENT_USER_ID.toString() + recipeNumber.toString() + currentStepIndex.toString());
+            Log.i(
+                "dd",
+                CURRENT_USER_ID.toString() + recipeNumber.toString() + currentStepIndex.toString()
+            );
             var data = FoodDataProvider.getUserDatabase().userInfoDao().queryUserRecipeStepRemark(
-                CURRENT_USER_ID,recipeNumber.toString(),viewModel.stepIndex.toString());
+                CURRENT_USER_ID, recipeNumber.toString(), viewModel.stepIndex.toString()
+            );
             var dialog = NoteEditDialog();
             dialog.text = data?.remark
-            dialog.listener = object :NoteEditDialog.OnDialogClickListener{
-                override fun onComplete(remark:String) {
+            dialog.listener = object : NoteEditDialog.OnDialogClickListener {
+                override fun onComplete(remark: String) {
                     viewModel.recipe?.let {
 
 
-                        if(data == null){
-                             data = UserRecipeStepRemark(
+                        if (data == null) {
+                            data = UserRecipeStepRemark(
                                 recipeNumber = it.number.toString(),
                                 stepNumber = viewModel.stepIndex.toString(),
                                 userId = CURRENT_USER_ID,
                                 remark = remark
                             )
-                        }else{
+                        } else {
                             data!!.remark = remark;
                         }
 
@@ -141,10 +145,14 @@ class CookStepActivity2 : CookStepToolActivity() {
 
         }
 
-       ThreadUtils.runOnMainThread({
-           CofarSDK.resetLastPotStatus()
-       },1000)
+        ThreadUtils.runOnMainThread({
+            CofarSDK.resetLastPotStatus()
+        }, 1000)
+
+    }
 
+    override fun showDeviceStateDialog(): Boolean {
+        return false
     }
 
     private fun initData() {
@@ -152,17 +160,15 @@ class CookStepActivity2 : CookStepToolActivity() {
         viewModel.stepDisplay.observe(this) { it ->
 
 
-
-
             coverPath = FoodDataProvider.getImagePath(it.source.photoVideoFilePath)
             currModes = it.workMode
-            if(it.workMode == "FINISH_DESC"){
+            if (it.workMode == "FINISH_DESC") {
 
                 val stepCount = viewModel.getStepCount()
                 val stepIndex = viewModel.allSteps.indexOf(it)
                 changeDescription()
                 cookProgressDrawable.setStepState(stepIndex, stepCount)
-                binding.tvStepName.text =getText(R.string.engjoy_your_meal)
+                binding.tvStepName.text = getText(R.string.engjoy_your_meal)
                 binding.tvTitleStep.text = getText(R.string.recipe_complete)
 
                 if (stepCount == 1) {
@@ -180,7 +186,7 @@ class CookStepActivity2 : CookStepToolActivity() {
                 }
 
                 var photoPath = it.source.photoVideoFilePath;
-                if(photoPath == null || photoPath == ""){
+                if (photoPath == null || photoPath == "") {
                     photoPath = viewModel.recipe?.photoPath;
                 }
 
@@ -189,7 +195,7 @@ class CookStepActivity2 : CookStepToolActivity() {
                     .transition(DrawableTransitionOptions.withCrossFade())
                     .error(R.drawable.bg_cook_session)
                     .into(binding.ivCookBg)
-            }else{
+            } else {
                 binding.tvTitleStep.text = titleName
                 if (CofarSDK.devInfo().status == DevStatus.STOP.toInt()) {
                     CofarSDK.changeModeWithoutCfg(
@@ -223,31 +229,32 @@ class CookStepActivity2 : CookStepToolActivity() {
 //                    )
 //                )
                 cookProgressDrawable.setStepState(stepIndex, stepCount)
-                if(it.source.description == null || it.source.description == ""){
+                if (it.source.description == null || it.source.description == "") {
                     var minute = "0"
                     var second = "0"
                     var temperature = "0"
                     var rotateSpeed = "0"
                     var rotateDirection = MotorDirections.FORWARD.toString()
-                    if(it.source.minute != null){
+                    if (it.source.minute != null) {
                         minute = it.source.minute.toString();
                     }
-                    if(it.source.second != null){
+                    if (it.source.second != null) {
                         second = it.source.second.toString();
                     }
-                    if(it.source.temperature != null){
-                        temperature = CofarUtils.parseTemp(it.source.temperature!!.toShort()).toString();
+                    if (it.source.temperature != null) {
+                        temperature =
+                            CofarUtils.parseTemp(it.source.temperature!!.toShort()).toString();
                     }
-                    if(it.source.rotateSpeed != null ){
+                    if (it.source.rotateSpeed != null) {
                         rotateSpeed = it.source.rotateSpeed.toString();
                     }
-                    if(it.source.rotateDirection != null && it.source.rotateDirection != ""){
+                    if (it.source.rotateDirection != null && it.source.rotateDirection != "") {
                         rotateDirection = it.source.rotateDirection.toString();
                     }
                     //var description = "${temperature}°C/${minute}m${second}s/V${rotateSpeed}/${if(rotateDirection == MotorDirections.FORWARD.toString()) "R" else "L"}";
-                    binding.tvStepName.text =""
+                    binding.tvStepName.text = ""
 //                    binding.tvTitleStep.text = description
-                }else{
+                } else {
                     binding.tvStepName.text = it.source.description
 //                    binding.tvTitleStep.text = it.source.description
                 }
@@ -267,7 +274,7 @@ class CookStepActivity2 : CookStepToolActivity() {
                 }
 
                 var photoPath = it.source.photoVideoFilePath;
-                if(photoPath == null || photoPath == ""){
+                if (photoPath == null || photoPath == "") {
                     photoPath = viewModel.recipe?.photoPath;
                 }
 
@@ -373,7 +380,11 @@ class CookStepActivity2 : CookStepToolActivity() {
                     CofarSDK.cfgHeat(it.uiData.targetTemp.toShort(), 0)
                     CofarSDK.cfgTime(it.uiData.targetTime)
 
-                    CofarSDK.cfgMotor(it.uiData.currentSpeed.toByte(),it.uiData.direction.toByte(),1);
+                    CofarSDK.cfgMotor(
+                        it.uiData.currentSpeed.toByte(),
+                        it.uiData.direction.toByte(),
+                        1
+                    );
 
                 }
                 ThreadUtils.runOnMainThread({
@@ -488,7 +499,7 @@ class CookStepActivity2 : CookStepToolActivity() {
             initStepData();
             ThreadUtils.runOnMainThread({
                 configing = false
-            },1000);
+            }, 1000);
         } else if (tag == BUTTON_TAG_CANCEL) {
             CofarSDK.cancel()
             binding.controller.btnStart.setGone()
@@ -550,14 +561,19 @@ class CookStepActivity2 : CookStepToolActivity() {
                 mRunningInstId = devInfo.runningInstId
                 mSettingInstId = devInfo.settingInstId
                 it.uiData.runningStatus = devInfo.status
-                if(!viewModel.stepUiData.doingModify) it.uiData.targetTemp = CofarUtils.parseTemp(devInfo.targetTemp).toInt()
-                if(!viewModel.stepUiData.doingModify) it.uiData.targetTime = devInfo.targetTime.toInt()
-                if(!viewModel.stepUiData.doingModify) it.uiData.currentSpeed = devInfo.motorGear.toInt()
+                if (!viewModel.stepUiData.doingModify) it.uiData.targetTemp =
+                    CofarUtils.parseTemp(devInfo.targetTemp).toInt()
+                if (!viewModel.stepUiData.doingModify) it.uiData.targetTime =
+                    devInfo.targetTime.toInt()
+                if (!viewModel.stepUiData.doingModify) it.uiData.currentSpeed =
+                    devInfo.motorGear.toInt()
                 it.uiData.weightNum = devInfo.weight.toInt()
-                if(!viewModel.stepUiData.doingModify) it.uiData.direction = devInfo.motorDirection.toInt()
+                if (!viewModel.stepUiData.doingModify) it.uiData.direction =
+                    devInfo.motorDirection.toInt()
                 it.uiData.currentTemp = CofarUtils.parseTemp(devInfo.temp).toInt()
                 it.uiData.remainTime = devInfo.remainTime.toInt()
-                if(!viewModel.stepUiData.doingModify) it.uiData.targetTimeBuffer = devInfo.targetTimeBuffer.toInt()
+                if (!viewModel.stepUiData.doingModify) it.uiData.targetTimeBuffer =
+                    devInfo.targetTimeBuffer.toInt()
                 it.uiData.isTimeChange = devInfo.mode.isTimeChange
                 it.uiData.isTempChange = devInfo.mode.isTempChange
                 it.uiData.isMotorDirectionChange = devInfo.mode.isMotorDirectionChange
@@ -585,7 +601,7 @@ class CookStepActivity2 : CookStepToolActivity() {
             viewModel.cookingStep?.let {
                 updateUiSetting(it)
             }
-        }else{
+        } else {
             viewModel.displayStep()?.let {
                 it.uiData.currentTemp = CofarUtils.parseTemp(devInfo.temp).toInt() //回显实时温度
                 updateUiSetting(it);
@@ -657,6 +673,7 @@ class CookStepActivity2 : CookStepToolActivity() {
                 TURN_UP_KEY_CODE -> {
                     operateByPhysical(true)
                 }
+
                 TURN_DOWN_KEY_CODE -> {
                     operateByPhysical(false)
                 }
@@ -842,9 +859,9 @@ class CookStepActivity2 : CookStepToolActivity() {
         if (keyCode == PRESS_DOWN_KEY_CODE) {
             Log.d("QQQQ", "catch key down")
 
-             if(!viewModel.isCurrentOnCookingStep()){
-                  return false
-             }
+            if (!viewModel.isCurrentOnCookingStep()) {
+                return false
+            }
 
             //当前是turbo模式下
             if (viewModel.cookingStep?.isTurboMode() != true && viewModel.cookingStep?.isWeightMode() != true && viewModel.cookingStep?.isDescription() != true) {
@@ -876,12 +893,12 @@ class CookStepActivity2 : CookStepToolActivity() {
                 }
 
 
-            } else if(viewModel.cookingStep?.isTurboMode() == true){
+            } else if (viewModel.cookingStep?.isTurboMode() == true) {
                 turboUpEvent();
-            } else if(viewModel.cookingStep?.isWeightMode() == true){
+            } else if (viewModel.cookingStep?.isWeightMode() == true) {
                 clickWeightTare();
             }
-            if (currModes == "FINISH_DESC"){
+            if (currModes == "FINISH_DESC") {
                 hideCommonDialog()
             }
         }
@@ -967,8 +984,8 @@ class CookStepActivity2 : CookStepToolActivity() {
         }
 
 
-            //蒸汽模式特殊处理
-        if(viewModel.displayStep()?.workMode == ModesType.STEAM.name){
+        //蒸汽模式特殊处理
+        if (viewModel.displayStep()?.workMode == ModesType.STEAM.name) {
             binding.controller.steamFire.configNum(uiData.targetTemp);
             binding.controller.steamFireSmall.configNum(uiData.targetTemp);
         }
@@ -1056,17 +1073,17 @@ class CookStepActivity2 : CookStepToolActivity() {
             }
 
 
-            if(CommonEventTypes.CONFIRM_STOP == event.type){
+            if (CommonEventTypes.CONFIRM_STOP == event.type) {
                 clickNextStep();
             }
 
 
-            if (CommonEventTypes.MOTOR_REVERSE_CAN_NOT_RATHER_THEN_3 == event.type ) {
+            if (CommonEventTypes.MOTOR_REVERSE_CAN_NOT_RATHER_THEN_3 == event.type) {
                 CofarSDK.cfgMotorGear(3)
                 viewModel.cookingStep?.let { updateUiSetting(it, true) }
             }
 
-            if (CommonEventTypes.MOTOR_GEAR_RATHER_THEN_4_WITH_TEMP == event.type ) {
+            if (CommonEventTypes.MOTOR_GEAR_RATHER_THEN_4_WITH_TEMP == event.type) {
                 CofarSDK.cfgMotorGear(4)
                 viewModel.cookingStep?.let { updateUiSetting(it, true) }
             }

+ 3 - 1
BusinessStep/src/main/java/com/develop/step/modes/ModesDetailActivity.kt

@@ -996,6 +996,7 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
     override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
         if (keyCode == PRESS_DOWN_KEY_CODE) {
 
+            Log.d("======","down")
 
             //当前是turbo模式下
             if (modeType == ModesType.TURBO.name) {
@@ -1040,7 +1041,8 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
      * 物理键离开事件
      */
     override fun onKeyUp(keyCode: Int, event: KeyEvent): Boolean {
-
+        Log.d("======","up")
+        hideDeviceStateDialog()
         if (modeType == ModesType.TURBO.name && event.keyCode == PRESS_DOWN_KEY_CODE) {
             //当前是turbo模式下,并且是物理键按下
             turboUpEvent()

+ 20 - 13
libBase/src/main/java/com/develop/food/base/ui/BaseActivity.kt

@@ -220,7 +220,7 @@ abstract class BaseActivity<T : ViewBinding> : AppCompatActivity() {
             override fun onFinish() {
                 runOnUiThread {
                     cancelConfirmDialog.removeSelf()
-                    if (CofarSDK.devInfo().status == DevStatus.STOP.toInt()){
+                    if (CofarSDK.devInfo().status == DevStatus.STOP.toInt()) {
                         navigateTo(Screens.Setting.SCREEN_SAVER)
                     }
                 }
@@ -291,9 +291,12 @@ abstract class BaseActivity<T : ViewBinding> : AppCompatActivity() {
 
 
     var lastMsg = ""
-
+    var deviceStateDialog = CancelConfirmDialog()
     @Subscribe
     fun onCookDevMsgEvent(event: DevPromptEvent) {
+        if (!showDeviceStateDialog()) {
+            return
+        }
         if (this.localClassName != TopResumedActivityHolder.getCurrentActivity()?.localClassName) {
             return
         }
@@ -305,30 +308,30 @@ abstract class BaseActivity<T : ViewBinding> : AppCompatActivity() {
         if (lastMsg == event.msg && !event.isFocus) {
             return
         }
-        if (lastMsg == "dian_zi_cheng_tong_xin_yi_chan" && CofarSDK.devInfo().mode.mode  != "WEIGHT") {
+        if (lastMsg == "dian_zi_cheng_tong_xin_yi_chan" && CofarSDK.devInfo().mode.mode != "WEIGHT") {
             return
         }
         lastMsg = event.msg
-        var confirmCancelDialog = CancelConfirmDialog()
-        confirmCancelDialog.showCancel = event.isShowCancelBtn
-        confirmCancelDialog.showConfirm = event.isShowConfirmBtn
 
-        confirmCancelDialog.cancelStr = resources.getString(
+        deviceStateDialog.showCancel = event.isShowCancelBtn
+        deviceStateDialog.showConfirm = event.isShowConfirmBtn
+
+        deviceStateDialog.cancelStr = resources.getString(
             resources.getIdentifier(
                 event.cancelBtnText, "string", this.packageName
             )
         )
-        confirmCancelDialog.confirmStr = resources.getString(
+        deviceStateDialog.confirmStr = resources.getString(
             resources.getIdentifier(
                 event.confirmButtonText, "string", this.packageName
             )
         )
-        confirmCancelDialog.title =
+        deviceStateDialog.title =
             resources.getString(resources.getIdentifier(event.msg, "string", this.packageName))
 
-        confirmCancelDialog.showDialog(supportFragmentManager, "confirmCancelDialog")
+        deviceStateDialog.showDialog(supportFragmentManager, "confirmCancelDialog")
 
-        confirmCancelDialog.onDialogClickListener =
+        deviceStateDialog.onDialogClickListener =
             object : CancelConfirmDialog.OnDialogClickListener {
                 override fun onConfirm() {
                     if (event.confirm != null) {
@@ -351,12 +354,16 @@ abstract class BaseActivity<T : ViewBinding> : AppCompatActivity() {
     }
 
 
-    fun hideConfirmCancelDialog(){
+    fun hideDeviceStateDialog() {
         cancelConfirmDialog.removeSelf()
     }
 
+    open fun showDeviceStateDialog(): Boolean {
+        return true
+    }
+
     override fun onTouchEvent(event: MotionEvent): Boolean {
-       Log.d("kkkkkkk","触摸位置:${event.x}===${event.y}")
+        Log.d("kkkkkkk", "触摸位置:${event.x}===${event.y}")
         if (event.x == 0f && event.y == 0f) {
             return true
         }

+ 75 - 0
libBase/src/main/java/com/develop/food/base/widgets/PwdDialog.kt

@@ -0,0 +1,75 @@
+package com.develop.food.base.widgets
+
+import android.os.Bundle
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.RelativeLayout
+import com.develop.base.databinding.DialogPwdBinding
+import com.develop.food.base.ui.FullScreenTransparentDialog
+
+
+class PwdDialog(
+) : FullScreenTransparentDialog() {
+
+    lateinit var binding: DialogPwdBinding
+
+    var title = ""
+    var cancelStr = ""
+    var confirmStr = ""
+    var showConfirm = true
+    var showCancel = true
+    var onDialogClickListener: OnDialogClickListener? = null
+    override fun onCreateView(
+        inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
+    ): View {
+        binding = DialogPwdBinding.inflate(
+            inflater, container, false
+        )
+        binding.tvYes.setOnClickListener {
+            val pwd = binding.etPwd.text.toString()
+            onDialogClickListener?.onConfirm(pwd)
+            binding.etPwd.setText("")
+            removeSelf()
+        }
+        binding.tvCancel.setOnClickListener {
+            onDialogClickListener?.onCancel()
+            binding.etPwd.setText("")
+            removeSelf()
+        }
+        binding.tvTitle.text = title
+        if (cancelStr.isNotEmpty()) {
+            binding.tvCancel.text = cancelStr
+        }
+        if (confirmStr.isNotEmpty()) {
+            binding.tvYes.text = confirmStr
+        }
+
+        //只显示确认按钮
+        if (showConfirm && !showCancel) {
+            binding.tvCancel.visibility = View.GONE;
+            binding.tvYes.visibility = View.VISIBLE;
+            val layoutParams = binding.tvYes.layoutParams as RelativeLayout.LayoutParams;
+            layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL)
+            binding.tvCancel.layoutParams = layoutParams
+        }
+
+        if (!showConfirm && showCancel) {
+            binding.tvYes.visibility = View.GONE;
+            binding.tvCancel.visibility = View.VISIBLE;
+            val layoutParams = binding.tvCancel.layoutParams as RelativeLayout.LayoutParams;
+            layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL)
+            binding.tvCancel.layoutParams = layoutParams
+        }
+
+
+
+        return binding.root
+    }
+
+
+    interface OnDialogClickListener {
+        fun onConfirm(pwd: String)
+        fun onCancel()
+    }
+}

+ 7 - 0
libBase/src/main/res/drawable/bg_ee8f08_button.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <corners android:radius="@dimen/convert_100px"/>
+    <solid android:color="#EE8F08"/>
+
+</shape>

+ 8 - 0
libBase/src/main/res/drawable/bg_ee8f08_stoke.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <corners android:radius="@dimen/convert_100px"/>
+    <stroke android:color="#EE8F08"
+        android:width="@dimen/convert_2px"/>
+
+</shape>

+ 7 - 0
libBase/src/main/res/drawable/bg_white_button_round10px.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <corners android:radius="@dimen/convert_10px"/>
+    <solid android:color="#FFFFFF"/>
+
+</shape>

+ 7 - 0
libBase/src/main/res/drawable/shape_10pxf4a12e_stoke.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <corners android:radius="@dimen/convert_10px"/>
+    <stroke android:color="@color/color_F4A12E"  android:width="@dimen/convert_2px"/>
+
+</shape>

+ 76 - 0
libBase/src/main/res/layout/dialog_pwd.xml

@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="utf-8"?>
+<FrameLayout 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"
+    tools:background="#000">
+
+    <RelativeLayout
+        android:layout_width="@dimen/convert_500px"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center"
+        android:background="@drawable/bg_white_button_round10px"
+        android:paddingBottom="@dimen/convert_64px">
+
+        <TextView
+            android:id="@+id/tv_title"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="@dimen/convert_30px"
+            android:gravity="center"
+            android:text="Please input password"
+            android:textColor="#F30101"
+            android:textSize="@dimen/convert_30px" />
+
+
+        <EditText
+            android:id="@+id/et_pwd"
+            android:layout_width="match_parent"
+            android:layout_height="@dimen/convert_80px"
+            android:layout_below="@id/tv_title"
+            android:layout_marginStart="20dp"
+            android:layout_marginTop="20dp"
+            android:layout_marginEnd="20dp"
+            android:paddingStart="@dimen/convert_24px"
+            android:paddingEnd="@dimen/convert_24px"
+            android:background="@drawable/shape_10pxf4a12e_stoke"
+            android:inputType="textPassword"
+            android:singleLine="true" />
+
+
+        <TextView
+            android:id="@+id/tv_yes"
+            android:layout_width="wrap_content"
+            android:layout_height="@dimen/convert_60px"
+            android:layout_below="@id/et_pwd"
+            android:layout_marginStart="@dimen/convert_90px"
+            android:layout_marginTop="@dimen/convert_40px"
+            android:background="@drawable/bg_ee8f08_button"
+            android:gravity="center"
+            android:paddingLeft="@dimen/convert_32px"
+            android:paddingRight="@dimen/convert_32px"
+            android:text="@string/yes"
+            android:textColor="#fff"
+            android:textSize="@dimen/convert_30px" />
+
+        <TextView
+            android:id="@+id/tv_cancel"
+            android:layout_width="@dimen/convert_140px"
+            android:layout_height="@dimen/convert_60px"
+            android:layout_below="@id/et_pwd"
+            android:layout_alignParentEnd="true"
+            android:layout_marginTop="@dimen/convert_40px"
+            android:layout_marginEnd="@dimen/convert_90px"
+            android:background="@drawable/bg_ee8f08_stoke"
+            android:elevation="@dimen/convert_15px"
+            android:gravity="center"
+            android:paddingLeft="@dimen/convert_32px"
+            android:paddingRight="@dimen/convert_32px"
+            android:text="@string/no"
+            android:textColor="@color/no_color"
+            android:textSize="@dimen/convert_30px" />
+
+    </RelativeLayout>
+
+</FrameLayout>

BIN
libThirdParty/libs/cofar-cooking-device-sdk-0.0.1-SNAPSHOT.jar