[680][hmi]优化硬件服务状态显示弹窗
This commit is contained in:
@@ -20,7 +20,6 @@ import android.view.ViewGroup
|
||||
import android.widget.BaseAdapter
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.widget.ListPopupWindow
|
||||
import androidx.appcompat.widget.PopupMenu
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
@@ -336,7 +335,7 @@ import kotlin.collections.component4
|
||||
import kotlin.collections.set
|
||||
import kotlin.math.abs
|
||||
import kotlin.system.exitProcess
|
||||
import com.mogo.eagle.core.function.hmi.ui.tools.ShowVersionDialog
|
||||
import com.mogo.eagle.core.function.hmi.ui.tools.ShowDevicesManagerStateDialog
|
||||
|
||||
|
||||
/**
|
||||
@@ -1339,13 +1338,7 @@ internal class DebugSettingView @JvmOverloads constructor(
|
||||
tvHardwareDeviceBindState.text =
|
||||
getBindDeviceServiceState(DevicesManager.getServiceBindState())
|
||||
tvHardwareDeviceBindState.setOnClickListener {
|
||||
var msg =
|
||||
"${getBindDeviceServiceState(DevicesManager.getServiceBindState(), false)}\n"
|
||||
msg += "客户端SDK版本:${DevicesManager.getSDKVersion() ?: "未知"}\n"
|
||||
msg += "客户端SDK AIDL版本:${DevicesManager.getSDKAIDLVersion() ?: "未知"}\n"
|
||||
msg += "硬件服务端APP版本:${DevicesManager.getServerVersion() ?: "未知"}\n"
|
||||
msg += "硬件服务端APP AIDL版本:${DevicesManager.getServerAIDLVersion() ?: "未知"}"
|
||||
ShowVersionDialog(context, "硬件服务绑定", msg).show()
|
||||
ShowDevicesManagerStateDialog(context).show()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2750,7 +2743,7 @@ internal class DebugSettingView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun getBindDeviceServiceState(state: Int, isUseTitle: Boolean = true): CharSequence {
|
||||
private fun getBindDeviceServiceState(state: Int): CharSequence {
|
||||
val msg = when (state) {
|
||||
0 -> {
|
||||
"<font color='green'>绑定成功</font>"
|
||||
@@ -2772,15 +2765,10 @@ internal class DebugSettingView @JvmOverloads constructor(
|
||||
"<font color='red'>未初始化</font>"
|
||||
}
|
||||
}
|
||||
val title = if (isUseTitle) {
|
||||
"硬件服务绑定"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
Html.fromHtml("${title}状态:${msg}", Html.FROM_HTML_MODE_LEGACY)
|
||||
Html.fromHtml("硬件服务绑定状态:${msg}", Html.FROM_HTML_MODE_LEGACY)
|
||||
} else {
|
||||
Html.fromHtml("${title}状态:${msg}")
|
||||
Html.fromHtml("硬件服务绑定状态:${msg}")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.tools
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.text.Html
|
||||
import android.widget.TextView
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.function.hmi.dialog.BaseFloatDialog
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import com.mogo.support.device.DevicesManager
|
||||
import com.mogo.support.device.IBindStateChangeListener
|
||||
|
||||
|
||||
/**
|
||||
* 硬件服务绑定状态 版本弹窗
|
||||
*/
|
||||
class ShowDevicesManagerStateDialog(context: Context) :
|
||||
BaseFloatDialog(context, TAG), IBindStateChangeListener {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "ShowDevicesManagerStateDialog"
|
||||
}
|
||||
|
||||
private var tvTitle: TextView? = null
|
||||
private var tvMsg: TextView? = null
|
||||
private var okView: TextView? = null
|
||||
|
||||
|
||||
init {
|
||||
setContentView(R.layout.dialog_show_devices_manager_state)
|
||||
setCanceledOnTouchOutside(true)
|
||||
setCancelable(true)
|
||||
initView()
|
||||
DevicesManager.addBindStateChangeListener(TAG, this)
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
tvTitle = findViewById(R.id.tv_title)
|
||||
tvMsg = findViewById(R.id.tv_msg)
|
||||
okView = findViewById(R.id.tv_ok)
|
||||
tvTitle?.text = "硬件服务绑定"
|
||||
|
||||
okView?.setOnClickListener {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun dismiss() {
|
||||
super.dismiss()
|
||||
DevicesManager.removeBindStateChangeListener(TAG)
|
||||
}
|
||||
|
||||
override fun onServiceState(state: Int) {
|
||||
UiThreadHandler.post {
|
||||
var msg =
|
||||
"${getBindDeviceServiceState(state)}\n"
|
||||
msg += "客户端SDK版本:${DevicesManager.getSDKVersion() ?: "未知"}\n"
|
||||
msg += "客户端SDK AIDL版本:${DevicesManager.getSDKAIDLVersion() ?: "未知"}\n"
|
||||
msg += "硬件服务端APP版本:${DevicesManager.getServerVersion() ?: "未知"}\n"
|
||||
msg += "硬件服务端APP AIDL版本:${DevicesManager.getServerAIDLVersion() ?: "未知"}"
|
||||
tvMsg?.text = msg
|
||||
}
|
||||
}
|
||||
|
||||
private fun getBindDeviceServiceState(state: Int): CharSequence {
|
||||
val msg = when (state) {
|
||||
0 -> {
|
||||
"<font color='green'>绑定成功</font>"
|
||||
}
|
||||
|
||||
1 -> {
|
||||
"<font color='red'>绑定失败,未安装“硬件服务”APP</font>"
|
||||
}
|
||||
|
||||
2 -> {
|
||||
"<font color='red'>绑定失败,没有绑定权限或找不到服务</font>"
|
||||
}
|
||||
|
||||
3 -> {
|
||||
"<font color='red'>绑定失败,服务被异常销毁</font>"
|
||||
}
|
||||
|
||||
else -> {
|
||||
"<font color='red'>未初始化</font>"
|
||||
}
|
||||
}
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
Html.fromHtml("状态:${msg}", Html.FROM_HTML_MODE_LEGACY)
|
||||
} else {
|
||||
Html.fromHtml("状态:${msg}")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.tools
|
||||
|
||||
import android.content.Context
|
||||
import android.widget.TextView
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.function.hmi.dialog.BaseFloatDialog
|
||||
import com.mogo.support.device.DevicesManager
|
||||
|
||||
|
||||
/**
|
||||
* 离线地图缓存
|
||||
*/
|
||||
class ShowVersionDialog(context: Context, val title: String, val msg: String) :
|
||||
BaseFloatDialog(context, TAG) {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "ShowVersionDialog"
|
||||
}
|
||||
|
||||
private var tvTitle: TextView? = null
|
||||
private var tvMsg: TextView? = null
|
||||
private var okView: TextView? = null
|
||||
|
||||
|
||||
init {
|
||||
setContentView(R.layout.dialog_show_version)
|
||||
setCanceledOnTouchOutside(true)
|
||||
setCancelable(true)
|
||||
initView()
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
tvTitle = findViewById(R.id.tv_title)
|
||||
tvMsg = findViewById(R.id.tv_msg)
|
||||
okView = findViewById(R.id.tv_ok)
|
||||
tvTitle?.text = title
|
||||
tvMsg?.text = msg
|
||||
|
||||
okView?.setOnClickListener {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun dismiss() {
|
||||
super.dismiss()
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user