[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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
|
||||
<application>
|
||||
<!-- <!–保活用–>
|
||||
|
||||
@@ -107,14 +107,14 @@ public class MainActivity extends MvpActivity<MainView, MainPresenter> implement
|
||||
// if (CallChatApi.getInstance().getApiProvider() != null) {
|
||||
// CallChatApi.getInstance().getApiProvider().initVehicleTeamContainer("init", R.id.module_main_id_message_history_fragment_container, this);
|
||||
// }
|
||||
// //申请悬浮窗权限
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
// // 检查是否有悬浮窗权限
|
||||
// if (Settings.canDrawOverlays(this)) {
|
||||
// return;
|
||||
// }
|
||||
// PermissionsDialogUtils.openAppDetails(this, "显示悬浮窗", REQUEST_CODE_DIALOG);
|
||||
// }
|
||||
//申请悬浮窗权限
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
// 检查是否有悬浮窗权限
|
||||
if (Settings.canDrawOverlays(this)) {
|
||||
return;
|
||||
}
|
||||
PermissionsDialogUtils.openAppDetails(this, "显示悬浮窗", REQUEST_CODE_DIALOG);
|
||||
}
|
||||
}
|
||||
|
||||
// 隐藏布局
|
||||
|
||||
Reference in New Issue
Block a user