[dev_robobus-d_230322_3.0.0]工具箱车速设置增加手动输入模式
This commit is contained in:
@@ -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())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/svLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
@@ -223,8 +224,8 @@
|
||||
app:layout_constraintTop_toBottomOf="@id/tvSpeedTitle"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvSpeed"
|
||||
<androidx.appcompat.widget.AppCompatEditText
|
||||
android:id="@+id/etInputSpeed"
|
||||
android:layout_width="189dp"
|
||||
android:layout_height="140dp"
|
||||
app:layout_constraintTop_toTopOf="@id/ivSpeedReduce"
|
||||
@@ -234,15 +235,17 @@
|
||||
android:textColor="#FFFFFFFF"
|
||||
android:textSize="80dp"
|
||||
android:gravity="center"
|
||||
tools:ignore="SpeakableTextPresentCheck"
|
||||
android:focusableInTouchMode="false"
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivSpeedAdd"
|
||||
android:layout_width="105dp"
|
||||
android:layout_height="140dp"
|
||||
app:layout_constraintTop_toTopOf="@id/tvSpeed"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tvSpeed"
|
||||
app:layout_constraintLeft_toRightOf="@id/tvSpeed"
|
||||
app:layout_constraintTop_toTopOf="@id/etInputSpeed"
|
||||
app:layout_constraintBottom_toBottomOf="@id/etInputSpeed"
|
||||
app:layout_constraintLeft_toRightOf="@id/etInputSpeed"
|
||||
android:src="@drawable/icon_speed_add"
|
||||
/>
|
||||
|
||||
@@ -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" />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user