[Fix]恢复动态请求悬浮窗权限
原因:Android11弹Toast需要悬浮窗权限
This commit is contained in:
@@ -37,6 +37,7 @@ class AutoPilotAndCheckView @JvmOverloads constructor(
|
||||
private var clickListener: ClickListener? = null
|
||||
private var keyBoardUtil: KeyBoardUtil? = null
|
||||
private var connectStatus = false
|
||||
private var lastTime = 0L
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_auto_pilot_check, this, true)
|
||||
@@ -51,10 +52,6 @@ class AutoPilotAndCheckView @JvmOverloads constructor(
|
||||
keyBoardUtil?.setActionListener { inputContent ->
|
||||
inputContent.toIntOrNull()?.let { speed ->
|
||||
when {
|
||||
!connectStatus -> {
|
||||
ToastUtils.showShort("设置车速失败,请启动域控制器")
|
||||
keyBoardUtil?.hideKeyboard()
|
||||
}
|
||||
speed > 60 -> {
|
||||
// 设置失败键盘不消失,让用户直接修改
|
||||
ToastUtils.showShort("超过最大限速值60,设置失败")
|
||||
@@ -90,22 +87,28 @@ class AutoPilotAndCheckView @JvmOverloads constructor(
|
||||
ivDebugFeedback.onClick {
|
||||
clickListener?.showFeedbackView()
|
||||
}
|
||||
etInputSpeed.setOnTouchListener { v, _ ->
|
||||
if (!connectStatus) {
|
||||
ToastUtils.showShort("设置车速失败,请启动域控制器")
|
||||
keyBoardUtil?.hideKeyboard()
|
||||
return@setOnTouchListener true
|
||||
} else {
|
||||
llSpeedPosition.background = resources.getDrawable(R.drawable.pilot_speed_high_light_bg)
|
||||
if (etInputSpeed.hasFocusable()) {
|
||||
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()
|
||||
}
|
||||
if (!etInputSpeed.hasFocus()) {
|
||||
etInputSpeed.requestFocus()
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user