[6.7.0][运营面板] 优化自动驾驶速度阈值设置逻辑
This commit is contained in:
@@ -7,7 +7,6 @@ import android.graphics.LinearGradient
|
||||
import android.graphics.Shader.TileMode.CLAMP
|
||||
import android.text.TextUtils
|
||||
import android.util.AttributeSet
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.LinearLayout
|
||||
import androidx.appcompat.widget.AppCompatTextView
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.mogo.eagle.core.function.api.hmi.view.IViewControlListener.Companion.
|
||||
import com.mogo.eagle.core.function.api.hmi.view.IViewControlListener.Companion.FUNC_MODE_RAIN
|
||||
import com.mogo.eagle.core.function.api.setting.ISopSettingListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotCarConfigListenerManager
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
|
||||
@@ -60,6 +61,7 @@ import kotlinx.coroutines.launch
|
||||
import me.jessyan.autosize.utils.AutoSizeUtils
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import kotlin.math.min
|
||||
|
||||
class OperatePanelLayout : LinearLayout {
|
||||
|
||||
@@ -965,12 +967,12 @@ class OperatePanelLayout : LinearLayout {
|
||||
return super.onCreateView(inflater, container, savedInstanceState)
|
||||
}
|
||||
|
||||
override fun updateFuncMode(tag: String, checked: Boolean) {
|
||||
super.updateFuncMode(tag, checked)
|
||||
override fun updateFuncMode(tag: String, boolean: Boolean) {
|
||||
super.updateFuncMode(tag, boolean)
|
||||
if (tag == FUNC_MODE_RAIN) {
|
||||
preferenceScreen.findPreferenceReal<SwitchPreferenceCompat>(KEY_RAIN_DAY)?.also {
|
||||
it.extras.putBoolean("is_pressed", false)
|
||||
changeValue(it, checked)
|
||||
changeValue(it, boolean)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -999,8 +1001,10 @@ class OperatePanelLayout : LinearLayout {
|
||||
override fun onAutopilotCarConfig(carConfigResp: MessagePad.CarConfigResp) {
|
||||
super.onAutopilotCarConfig(carConfigResp)
|
||||
lifecycleScope.launch {
|
||||
val max = carConfigResp.speedLimit * 3.6
|
||||
preferenceScreen.findPreferenceReal<PreferenceWithSpeedSetting>(KEY_AUTO_PILOT_SPEED_THRESHOLDS)?.update(listOf("0", "$max", "$max", "5"))
|
||||
if (carConfigResp.speedLimit > 0) {
|
||||
FunctionBuildConfig.maxSpeedLimit = min(carConfigResp.speedLimit * 3.6, 60.0)
|
||||
preferenceScreen.findPreferenceReal<PreferenceWithSpeedSetting>(KEY_AUTO_PILOT_SPEED_THRESHOLDS)?.update(listOf("0", "60.0", "${FunctionBuildConfig.maxSpeedLimit}", "5"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1049,7 +1053,7 @@ class OperatePanelLayout : LinearLayout {
|
||||
return FunctionBuildConfig.fusionMode == 5
|
||||
}
|
||||
KEY_AUTO_PILOT_SPEED_THRESHOLDS -> {
|
||||
return listOf("0.0", "${FunctionBuildConfig.maxSpeedLimit}", "${FunctionBuildConfig.maxSpeedLimit}", "5.0")
|
||||
return listOf("0.0", "60.0", "${FunctionBuildConfig.maxSpeedLimit}", "5.0")
|
||||
}
|
||||
KEY_CHANGE_LANE_SPEED_THRESHOLDS -> {
|
||||
return listOf("3.0", "7.0", "${FunctionBuildConfig.detouringSpeed}", "0.5")
|
||||
@@ -1072,7 +1076,11 @@ class OperatePanelLayout : LinearLayout {
|
||||
ToastUtils.showShort("车速设置成功,立即生效")
|
||||
}
|
||||
else -> {
|
||||
ToastUtils.showShort("设置车速失败,请启动域控制器")
|
||||
if (!CallerAutoPilotStatusListenerManager.isConnect()) {
|
||||
ToastUtils.showShort("设置车速失败,请启动域控制器")
|
||||
} else {
|
||||
ToastUtils.showShort("设置车速失败")
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
|
||||
@@ -7,7 +7,9 @@ import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceViewHolder
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.utilcode.kotlin.onClick
|
||||
import com.mogo.eagle.core.utilcode.kotlin.onClickWidthDuration
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import java.math.BigDecimal
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import kotlin.math.max
|
||||
|
||||
@@ -68,11 +70,11 @@ class PreferenceWithSpeedSetting : Preference {
|
||||
holder.itemView.isEnabled = enabled[key] ?: false
|
||||
ll.isSelected = enabled[key] ?: false
|
||||
minus.setOnClickListener(null)
|
||||
minus.onClick {
|
||||
minus.onClickWidthDuration(100) {
|
||||
val minusAfter = cur - step
|
||||
if (minusAfter < min) {
|
||||
ToastUtils.showShort("阈值最小可为${min}m/s")
|
||||
return@onClick
|
||||
ToastUtils.showShort("阈值最小可为${BigDecimal.valueOf(min).setScale(1)}km/h")
|
||||
return@onClickWidthDuration
|
||||
}
|
||||
cur = minusAfter
|
||||
btnOk.isEnabled = true
|
||||
@@ -84,11 +86,11 @@ class PreferenceWithSpeedSetting : Preference {
|
||||
}
|
||||
val add = holder.findViewById(R.id.iv_speed_add)
|
||||
add.setOnClickListener(null)
|
||||
add.onClick {
|
||||
add.onClickWidthDuration(100) {
|
||||
val addAfter = cur + step
|
||||
if (addAfter > max) {
|
||||
ToastUtils.showShort("阈值最大可为${max}m/s")
|
||||
return@onClick
|
||||
ToastUtils.showShort("阈值最大可为${BigDecimal.valueOf(max).setScale(1)}km/h")
|
||||
return@onClickWidthDuration
|
||||
}
|
||||
holder.itemView.isEnabled = false
|
||||
cur = addAfter
|
||||
|
||||
@@ -109,6 +109,16 @@ fun View.onClick(block: (View) -> Unit) {
|
||||
}
|
||||
}
|
||||
|
||||
fun View.onClickWidthDuration(duration: Int, block: (View) -> Unit) {
|
||||
this.setOnClickListener {
|
||||
if (ClickUtils.isClickTooFrequent(this, duration)) {
|
||||
return@setOnClickListener
|
||||
}
|
||||
block(it)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
val <T: Context> T.lifeCycleScope: LifecycleCoroutineScope
|
||||
get() = (this as? LifecycleOwner)?.lifecycleScope ?: ProcessLifecycleOwner.get().lifecycleScope
|
||||
|
||||
|
||||
Reference in New Issue
Block a user