diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/tools/AutoPilotAndCheckView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/tools/AutoPilotAndCheckView.kt index a41a6c77d8..c6c1ce249a 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/tools/AutoPilotAndCheckView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/tools/AutoPilotAndCheckView.kt @@ -59,15 +59,13 @@ class AutoPilotAndCheckView @JvmOverloads constructor( companion object { private var maxAcceleration: Double = 2.0 - private var speedLimit: Double = 0.0 + private var speedLimit: Int = 0 } @SuppressLint("ClickableViewAccessibility") private fun initView() { background = ColorDrawable(Color.parseColor("#F0151D41")) - if (keyBoardUtil == null) { - keyBoardUtil = KeyBoardUtil(sKeyBoardView, etInputSpeed) - } + keyBoardUtil?.setActionListener { inputContent -> inputContent.toIntOrNull()?.let { speed -> when { @@ -76,10 +74,6 @@ class AutoPilotAndCheckView @JvmOverloads constructor( ToastUtils.showShort("超过最大限速值60,设置失败") } else -> { - llSpeedPosition.background = - resources.getDrawable(R.drawable.pilot_speed_bg) - keyBoardUtil?.hideKeyboard() - etInputSpeed.clearFocus() // 设置自动驾驶速度 val isSuccess = CallerAutoPilotManager.setAutoPilotSpeed(speed) when { @@ -94,7 +88,6 @@ class AutoPilotAndCheckView @JvmOverloads constructor( } } } - KeyBoardUtil.hideSystemSoftKeyboard(context, etInputSpeed) ivCloseIcon.setOnClickListener { clickListener?.onClose(it) } @@ -113,49 +106,60 @@ class AutoPilotAndCheckView @JvmOverloads constructor( ivDebugFeedback.onClick { clickListener?.showFeedbackView() } - etInputSpeed.setOnFocusChangeListener { v, hasFocus -> - when { - hasFocus -> { - llSpeedPosition.background = - resources.getDrawable(R.drawable.pilot_speed_high_light_bg) - if (keyBoardUtil == null) { - keyBoardUtil = KeyBoardUtil(sKeyBoardView, etInputSpeed) - } - keyBoardUtil?.showKeyboard() - } - else -> llSpeedPosition.background = - resources.getDrawable(R.drawable.pilot_speed_bg) - } - } - etInputSpeed.setOnTouchListener { v, event -> - var curTime = System.currentTimeMillis() - if (curTime - lastTime < 1000) { - return@setOnTouchListener true - } - if (!connectStatus) { - ToastUtils.showShort("设置车速失败,请启动域控制器") - keyBoardUtil?.hideKeyboard() - return@setOnTouchListener true - } else { - return@setOnTouchListener false - } - } - updateSpeedSettingViews() + if (AppConfigInfo.isConnectAutopilot) { CallerAutoPilotManager.getCarConfig() } - if (maxAcceleration > 0) { - tvAcceleration.text = "加速度 $maxAcceleration m/s²" - } +// if (maxAcceleration > 0) { +// tvAcceleration.text = "加速度 $maxAcceleration m/s²" +// } + tvAcceleration.text = "每次调整车速±5km/h" if (speedLimit > 0) { - etInputSpeed.setText((speedLimit * 3.6).toInt().toString()) + tvSpeed.text = speedLimit.toString() + }else{ + tvSpeed.text = "0" + } + ivSpeedReduce.setOnClickListener { + if(speedLimit>=5){ + speedLimit -= 5 + //速度显示 + val isSuccess = CallerAutoPilotManager.setAutoPilotSpeed(speedLimit) + when { + isSuccess -> { + //速度显示 + tvSpeed.text = speedLimit.toString() + ToastUtils.showShort("车速设置成功,立即生效") + } + else -> { + ToastUtils.showShort("设置车速失败,请启动域控制器") + } + } + }else{ + ToastUtils.showShort("车速不能再减了") + } + } + ivSpeedAdd.setOnClickListener { + if(speedLimit<=55){ + speedLimit += 5 + //速度显示 + val isSuccess = CallerAutoPilotManager.setAutoPilotSpeed(speedLimit) + when { + isSuccess -> { + //速度显示 + tvSpeed.text = speedLimit.toString() + ToastUtils.showShort("车速设置成功,立即生效") + } + else -> { + ToastUtils.showShort("设置车速失败,请启动域控制器") + } + } + }else{ + ToastUtils.showShort("车速不能再加了") + } } - initOchView() -// // 比如需要设置默认速度 -// val speed = "30" -// etInputSpeed.setText(speed) -// etInputSpeed.setSelection(speed.length) + + initOchView() } private fun initOchView() { @@ -192,11 +196,6 @@ class AutoPilotAndCheckView @JvmOverloads constructor( this.clickListener = clickListener } - private fun updateSpeedSettingViews() { - tvSpeedTitle.visibility = View.VISIBLE - llSpeedPosition.visibility = View.VISIBLE - } - fun showAdUpgradeStatus(ipcUpgradeStateInfo: IPCUpgradeStateInfo) { systemVersionView?.showAdUpgradeStatus(ipcUpgradeStateInfo) } @@ -228,12 +227,15 @@ class AutoPilotAndCheckView @JvmOverloads constructor( override fun onAutopilotCarConfig(carConfigResp: MessagePad.CarConfigResp) { UiThreadHandler.post { - tvAcceleration?.let { - maxAcceleration = carConfigResp.maxAcceleration - speedLimit = carConfigResp.speedLimit - tvAcceleration.text = "加速度 ${carConfigResp.maxAcceleration} m/s²" - etInputSpeed.setText((carConfigResp.speedLimit * 3.6).toInt().toString()) - } +// tvAcceleration?.let { +// maxAcceleration = carConfigResp.maxAcceleration +// speedLimit = carConfigResp.speedLimit +//// tvAcceleration.text = "加速度 ${carConfigResp.maxAcceleration} m/s²" +// tvSpeed.text = (carConfigResp.speedLimit * 3.6).toInt().toString() +// } + maxAcceleration = carConfigResp.maxAcceleration + speedLimit = (carConfigResp.speedLimit * 3.6).toInt() + tvSpeed.text = speedLimit.toString() } } } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/icon_speed_add.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/icon_speed_add.png new file mode 100644 index 0000000000..bbd0601d27 Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/icon_speed_add.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/icon_speed_reduce.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/icon_speed_reduce.png new file mode 100644 index 0000000000..905094d461 Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/icon_speed_reduce.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_auto_pilot_check.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_auto_pilot_check.xml index ade0a7ce16..a41f32557b 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_auto_pilot_check.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_auto_pilot_check.xml @@ -43,6 +43,7 @@ android:gravity="center_vertical" android:orientation="horizontal" app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.0" app:layout_constraintStart_toStartOf="@+id/tv_check_title" app:layout_constraintTop_toBottomOf="@+id/v_second_group"> @@ -205,43 +206,51 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/sopLayout" /> - + app:layout_constraintTop_toBottomOf="@id/tvSpeedTitle" + /> - + - + - + x` + app:layout_constraintTop_toBottomOf="@id/ivSpeedReduce" />