From ca5de5b11d9d12104ce32ac03ea810bc416e4dd9 Mon Sep 17 00:00:00 2001 From: xuxinchao Date: Fri, 7 Apr 2023 12:16:43 +0800 Subject: [PATCH] =?UTF-8?q?[dev=5Frobobus-d=5F230322=5F3.0.0]=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E7=AE=B1=E8=BD=A6=E9=80=9F=E8=AE=BE=E7=BD=AE=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=89=8B=E5=8A=A8=E8=BE=93=E5=85=A5=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hmi/ui/tools/AutoPilotAndCheckView.kt | 93 ++++++++++++++----- .../function/hmi/ui/utils/KeyBoardUtil.java | 8 ++ .../main/res/layout/view_auto_pilot_check.xml | 17 ++-- 3 files changed, 86 insertions(+), 32 deletions(-) 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 9b3d026e83..af151c2bc2 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 @@ -9,8 +9,8 @@ import android.os.Process import android.util.AttributeSet import android.view.LayoutInflater import android.view.View +import android.view.View.OnTouchListener import android.widget.FrameLayout -import com.mogo.commons.debug.DebugConfig import com.mogo.eagle.core.data.app.AppConfigInfo import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo import com.mogo.eagle.core.data.deva.bindingcar.IPCUpgradeStateInfo @@ -31,6 +31,7 @@ import mogo.telematics.pad.MessagePad import org.greenrobot.eventbus.EventBus import kotlin.system.exitProcess + /** * @author ChenFufeng * 设置自动驾驶速度和检测页入口 @@ -69,29 +70,44 @@ internal class AutoPilotAndCheckView @JvmOverloads constructor( @SuppressLint("ClickableViewAccessibility") private fun initView() { background = ColorDrawable(Color.parseColor("#F0151D41")) - - keyBoardUtil?.setActionListener { inputContent -> - inputContent.toIntOrNull()?.let { speed -> - when { - speed > 60 -> { - // 设置失败键盘不消失,让用户直接修改 - ToastUtils.showShort("超过最大限速值60,设置失败") - } - else -> { - // 设置自动驾驶速度 - val isSuccess = CallerAutoPilotControlManager.setAutoPilotSpeed(speed) - when { - isSuccess -> { - ToastUtils.showShort("车速设置成功,立即生效") - } - else -> { - ToastUtils.showShort("设置车速失败,请启动域控制器") + if (keyBoardUtil == null) { + keyBoardUtil = KeyBoardUtil(sKeyBoardView, etInputSpeed) + } + keyBoardUtil?.setActionListener(object: KeyBoardUtil.ActionListener{ + override fun onComplete(inputContent: String?) { + inputContent?.toIntOrNull()?.let { speed -> + when { + speed > 60 -> { + // 设置失败键盘不消失,让用户直接修改 + ToastUtils.showShort("超过最大限速值60,设置失败") + } + else -> { + keyBoardUtil?.hideKeyboard() + etInputSpeed.clearFocus() + // 设置自动驾驶速度 + val isSuccess = CallerAutoPilotControlManager.setAutoPilotSpeed(speed) + when { + isSuccess -> { + ToastUtils.showShort("车速设置成功,立即生效") + } + else -> { + ToastUtils.showShort("设置车速失败,请启动域控制器") + } } } } } } - } + + override fun onUpdate(inputContent: String?) { + if (inputContent != null) { + speedLimit = inputContent.toInt() + } + } + + }) + + KeyBoardUtil.hideSystemSoftKeyboard(context, etInputSpeed) ivCloseIcon.setOnClickListener { clickListener?.onClose(it) } @@ -123,15 +139,37 @@ internal class AutoPilotAndCheckView @JvmOverloads constructor( // } tvAcceleration.text = "每次调整车速±5km/h,点击确定生效" if (speedLimit > 0) { - tvSpeed.text = speedLimit.toString() + etInputSpeed.setText(speedLimit.toString()) }else{ - tvSpeed.text = "0" + etInputSpeed.setText("0") } + etInputSpeed.setOnTouchListener { _, _ -> + val curTime = System.currentTimeMillis() + if (curTime - lastTime < 1000) { + return@setOnTouchListener true + } + etInputSpeed.isFocusableInTouchMode = true + if (keyBoardUtil == null) { + keyBoardUtil = KeyBoardUtil(sKeyBoardView, etInputSpeed) + } + keyBoardUtil?.showKeyboard() + //滑动滚动条 + svLayout.post { + svLayout.fullScroll(View.FOCUS_DOWN) + } + if (!connectStatus) { + ToastUtils.showShort("设置车速失败,请启动域控制器") + keyBoardUtil?.hideKeyboard() + return@setOnTouchListener true + } else { + return@setOnTouchListener false + } + } ivSpeedReduce.setOnClickListener { if(speedLimit>=5){ speedLimit -= 5 - tvSpeed.text = speedLimit.toString() + etInputSpeed.setText(speedLimit.toString()) }else{ ToastUtils.showShort("车速不能再减了") } @@ -140,7 +178,7 @@ internal class AutoPilotAndCheckView @JvmOverloads constructor( ivSpeedAdd.setOnClickListener { if(speedLimit<=55){ speedLimit += 5 - tvSpeed.text = speedLimit.toString() + etInputSpeed.setText(speedLimit.toString()) }else{ ToastUtils.showShort("车速不能再加了") } @@ -148,11 +186,16 @@ internal class AutoPilotAndCheckView @JvmOverloads constructor( //速度确认 tvSureModify.setOnClickListener { + if(speedLimit>60){ + // 设置失败键盘不消失,让用户直接修改 + ToastUtils.showShort("超过最大限速值60,设置失败") + return@setOnClickListener + } val isSuccess = CallerAutoPilotControlManager.setAutoPilotSpeed(speedLimit) when { isSuccess -> { //速度显示 - tvSpeed.text = speedLimit.toString() + etInputSpeed.setText(speedLimit.toString()) ToastUtils.showShort("车速设置成功,立即生效") } else -> { @@ -230,7 +273,7 @@ internal class AutoPilotAndCheckView @JvmOverloads constructor( // } maxAcceleration = carConfigResp.maxAcceleration speedLimit = (carConfigResp.speedLimit * 3.6).toInt() - tvSpeed.text = speedLimit.toString() + etInputSpeed.setText(speedLimit.toString()) } } } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/utils/KeyBoardUtil.java b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/utils/KeyBoardUtil.java index 8b826a2255..b06500228f 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/utils/KeyBoardUtil.java +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/utils/KeyBoardUtil.java @@ -6,6 +6,7 @@ import android.inputmethodservice.KeyboardView; import android.os.Build; import android.text.Editable; import android.text.InputType; +import android.util.Log; import android.view.View; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; @@ -78,6 +79,9 @@ public class KeyBoardUtil { editable.delete(start - 1, start); } } + if(actionListener != null){ + actionListener.onUpdate(editText.getText().toString()); + } break; case Keyboard.KEYCODE_DONE: if (actionListener != null) { @@ -86,6 +90,9 @@ public class KeyBoardUtil { break; default: editable.insert(start, Character.toString((char) primaryCode)); + if(actionListener != null){ + actionListener.onUpdate(editText.getText().toString()); + } break; } } @@ -133,5 +140,6 @@ public class KeyBoardUtil { public interface ActionListener { void onComplete(String inputContent); + void onUpdate(String inputContent); } } 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 6b77eb7543..86fe2cf08a 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 @@ -6,6 +6,7 @@ android:layout_height="match_parent"> - @@ -268,8 +271,8 @@ android:textColor="@android:color/white" android:textSize="42dp" android:layout_marginLeft="50dp" - app:layout_constraintTop_toTopOf="@id/tvSpeed" - app:layout_constraintBottom_toBottomOf="@id/tvSpeed" + app:layout_constraintTop_toTopOf="@id/etInputSpeed" + app:layout_constraintBottom_toBottomOf="@id/etInputSpeed" app:layout_constraintLeft_toRightOf="@id/tvUnit" tools:visibility="visible" />