[dev_robotaxi-d_230412_2.15.0]工具箱车速设置增加手动输入模式
This commit is contained in:
@@ -70,29 +70,60 @@ 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) {
|
||||
try {
|
||||
if(inputContent.isEmpty()){
|
||||
speedLimit = 0
|
||||
}else{
|
||||
speedLimit = inputContent.toInt()
|
||||
if(speedLimit>60){
|
||||
speedLimit = 60
|
||||
ToastUtils.showShort("最大限速60")
|
||||
}
|
||||
}
|
||||
}catch (t: Exception){
|
||||
ToastUtils.showShort("最大限速60")
|
||||
speedLimit = 60
|
||||
|
||||
}
|
||||
etInputSpeed.setText(speedLimit.toString())
|
||||
etInputSpeed.setSelection(speedLimit.toString().length)
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
KeyBoardUtil.hideSystemSoftKeyboard(context, etInputSpeed)
|
||||
ivCloseIcon.setOnClickListener {
|
||||
clickListener?.onClose(it)
|
||||
}
|
||||
@@ -123,16 +154,42 @@ 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()
|
||||
}else{
|
||||
etInputSpeed.setText(speedLimit.toString())
|
||||
}else if(speedLimit in 1..4){
|
||||
speedLimit = 0
|
||||
etInputSpeed.setText(speedLimit.toString())
|
||||
} else{
|
||||
ToastUtils.showShort("车速不能再减了")
|
||||
}
|
||||
}
|
||||
@@ -140,19 +197,27 @@ internal class AutoPilotAndCheckView @JvmOverloads constructor(
|
||||
ivSpeedAdd.setOnClickListener {
|
||||
if(speedLimit<=55){
|
||||
speedLimit += 5
|
||||
tvSpeed.text = speedLimit.toString()
|
||||
}else{
|
||||
etInputSpeed.setText(speedLimit.toString())
|
||||
}else if(speedLimit in 56..59){
|
||||
speedLimit = 60
|
||||
etInputSpeed.setText(speedLimit.toString())
|
||||
} else{
|
||||
ToastUtils.showShort("车速不能再加了")
|
||||
}
|
||||
}
|
||||
|
||||
//速度确认
|
||||
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 -> {
|
||||
@@ -243,7 +308,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"
|
||||
@@ -252,8 +253,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"
|
||||
@@ -263,15 +264,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"
|
||||
/>
|
||||
|
||||
@@ -297,8 +300,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/ivSpeedAdd"
|
||||
app:layout_constraintBottom_toBottomOf="@id/ivSpeedAdd"
|
||||
app:layout_constraintLeft_toRightOf="@id/tvUnit"
|
||||
tools:visibility="visible" />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user