[6.2.10][蘑方功能优化] 代码提交
This commit is contained in:
@@ -102,6 +102,16 @@
|
||||
app:layout_constraintTop_toBottomOf="@+id/ivCameraIcon"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<com.mogo.eagle.core.function.hmi.ui.mofang.MoFangStatusView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_71"
|
||||
app:layout_constraintEnd_toEndOf="@+id/viewLimitingVelocity"
|
||||
app:layout_goneMarginEnd="40dp"
|
||||
app:layout_goneMarginTop="@dimen/dp_236"
|
||||
android:visibility="invisible"
|
||||
app:layout_constraintTop_toBottomOf="@+id/viewLimitingVelocity"/>
|
||||
|
||||
<!--消息盒子选择入口-->
|
||||
<com.mogo.eagle.core.function.hmi.ui.msgbox.DriverMsgBoxButtonView
|
||||
android:id="@+id/viewDriverMsgBoxButton"
|
||||
|
||||
@@ -106,6 +106,16 @@
|
||||
app:layout_constraintTop_toBottomOf="@+id/ivCameraIcon"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<com.mogo.eagle.core.function.hmi.ui.mofang.MoFangStatusView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_71"
|
||||
app:layout_constraintEnd_toEndOf="@+id/viewLimitingVelocity"
|
||||
app:layout_goneMarginEnd="40dp"
|
||||
app:layout_goneMarginTop="@dimen/dp_236"
|
||||
android:visibility="invisible"
|
||||
app:layout_constraintTop_toBottomOf="@+id/viewLimitingVelocity"/>
|
||||
|
||||
<!--消息盒子选择入口-->
|
||||
<com.mogo.eagle.core.function.hmi.ui.msgbox.DriverMsgBoxButtonView
|
||||
android:id="@+id/viewDriverMsgBoxButton"
|
||||
|
||||
@@ -102,6 +102,16 @@
|
||||
app:layout_constraintTop_toBottomOf="@+id/ivCameraIcon"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<com.mogo.eagle.core.function.hmi.ui.mofang.MoFangStatusView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_71"
|
||||
app:layout_constraintEnd_toEndOf="@+id/viewLimitingVelocity"
|
||||
app:layout_goneMarginEnd="40dp"
|
||||
app:layout_goneMarginTop="@dimen/dp_236"
|
||||
android:visibility="invisible"
|
||||
app:layout_constraintTop_toBottomOf="@+id/viewLimitingVelocity"/>
|
||||
|
||||
<!--消息盒子选择入口-->
|
||||
<com.mogo.eagle.core.function.hmi.ui.msgbox.DriverMsgBoxButtonView
|
||||
android:id="@+id/viewDriverMsgBoxButton"
|
||||
|
||||
@@ -139,6 +139,16 @@
|
||||
app:layout_constraintTop_toBottomOf="@+id/ivCameraIcon"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<com.mogo.eagle.core.function.hmi.ui.mofang.MoFangStatusView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_71"
|
||||
app:layout_constraintEnd_toEndOf="@+id/viewLimitingVelocity"
|
||||
app:layout_goneMarginEnd="40dp"
|
||||
app:layout_goneMarginTop="@dimen/dp_236"
|
||||
android:visibility="invisible"
|
||||
app:layout_constraintTop_toBottomOf="@+id/viewLimitingVelocity"/>
|
||||
|
||||
<!--消息盒子选择入口-->
|
||||
<com.mogo.eagle.core.function.hmi.ui.msgbox.DriverMsgBoxButtonView
|
||||
android:id="@+id/viewDriverMsgBoxButton"
|
||||
|
||||
@@ -157,6 +157,16 @@
|
||||
app:layout_constraintTop_toBottomOf="@+id/ivCameraIcon"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<com.mogo.eagle.core.function.hmi.ui.mofang.MoFangStatusView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_71"
|
||||
app:layout_constraintEnd_toEndOf="@+id/viewLimitingVelocity"
|
||||
app:layout_goneMarginEnd="40dp"
|
||||
app:layout_goneMarginTop="@dimen/dp_236"
|
||||
android:visibility="invisible"
|
||||
app:layout_constraintTop_toBottomOf="@+id/viewLimitingVelocity"/>
|
||||
|
||||
<!--消息盒子选择入口-->
|
||||
<com.mogo.eagle.core.function.hmi.ui.msgbox.DriverMsgBoxButtonView
|
||||
android:id="@+id/viewDriverMsgBoxButton"
|
||||
|
||||
@@ -224,7 +224,7 @@ ext {
|
||||
weak_network : "com.mogo.weak:network:1.0.1",
|
||||
btrace : "com.bytedance.btrace:rhea-core:2.0.0",
|
||||
|
||||
mofang_runtime : "com.mogo.eagle.core.mofang:runtime:2.0.10",
|
||||
mofang_runtime : "com.mogo.eagle.core.mofang:runtime:2.0.11",
|
||||
log_runtime : "com.mogo.eagle.core.log.record:runtime:1.0.30",
|
||||
|
||||
// 安全证书
|
||||
|
||||
@@ -5,9 +5,14 @@ import android.util.*
|
||||
import android.view.KeyEvent
|
||||
import com.mogo.commons.utils.MogoAnalyticUtils
|
||||
import com.mogo.eagle.core.data.config.*
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnumNew
|
||||
import com.mogo.eagle.core.data.msgbox.MsgBoxBean
|
||||
import com.mogo.eagle.core.data.msgbox.MsgBoxType
|
||||
import com.mogo.eagle.core.data.msgbox.V2XMsg
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.*
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager
|
||||
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil
|
||||
import com.mogo.eagle.core.utilcode.mogo.*
|
||||
import com.zhjt.mogo.adas.data.bean.MogoReport.Code.Info.IMF
|
||||
@@ -45,6 +50,7 @@ import com.zhjt.mogo_core_function_devatools.mofang.MoFangAnalyticUtils.Companio
|
||||
import com.zhjt.mogo_core_function_devatools.mofang.MoFangAnalyticUtils.Companion.EVENT_EXECUTE_PARAMS_TYPE
|
||||
import mogo_msg.MogoReportMsg
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
|
||||
internal class MoFangCommandExecutor {
|
||||
|
||||
@@ -64,6 +70,10 @@ internal class MoFangCommandExecutor {
|
||||
@Volatile
|
||||
private var linkedLog: MoFangLinkedLog? = null
|
||||
|
||||
private val autoPilotState by lazy { AtomicInteger(CallerAutoPilotStatusListenerManager.getState()) }
|
||||
|
||||
private val ipcConnectState by lazy { AtomicBoolean(CallerAutoPilotStatusListenerManager.isConnect()) }
|
||||
|
||||
fun setLinkedLog(log: MoFangLinkedLog) {
|
||||
this.linkedLog = log
|
||||
}
|
||||
@@ -104,6 +114,36 @@ internal class MoFangCommandExecutor {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onAutopilotStatusResponse(state: Int) {
|
||||
super.onAutopilotStatusResponse(state)
|
||||
val last = autoPilotState.get()
|
||||
Log.d(TAG, "收到工控机自驾状态回调 -> state: $state, last: $last")
|
||||
if (last != state) {
|
||||
if (last == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
|
||||
// 由自驾状态改为非自驾,发送复原指令
|
||||
handleSingleClick(KeyEvent.KEYCODE_B)
|
||||
}
|
||||
autoPilotState.set(state)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotIpcConnectStatusChanged(status: Int, reason: String?) {
|
||||
super.onAutopilotIpcConnectStatusChanged(status, reason)
|
||||
Log.d(TAG, "收到工控机连接状态回调 -> status: $status, reason: $reason")
|
||||
val prev = ipcConnectState.get()
|
||||
val current = CallerAutoPilotStatusListenerManager.isConnect()
|
||||
if (!current && prev) {
|
||||
Log.d(TAG, "工控机连接断开了: -> status: $status, reason: $reason")
|
||||
CallerMsgBoxManager.saveMsgBox(MsgBoxBean(MsgBoxType.V2X, V2XMsg(
|
||||
EventTypeEnumNew.TYPE_IPC_DISCONNECT_FOR_MO_FANG.poiType,
|
||||
EventTypeEnumNew.TYPE_IPC_DISCONNECT_FOR_MO_FANG.content,
|
||||
EventTypeEnumNew.TYPE_VERIFICATION_SUCCESSFUL.tts,
|
||||
""
|
||||
)))
|
||||
}
|
||||
ipcConnectState.set(current)
|
||||
}
|
||||
}
|
||||
|
||||
private val handlerCallback = Handler.Callback { msg ->
|
||||
|
||||
@@ -0,0 +1,255 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.mofang
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.util.Log
|
||||
import android.view.KeyEvent
|
||||
import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.api.devatools.mofang.IMoGoMoFangProvider.OnMoFangStatusListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import kotlinx.android.synthetic.main.layout_mofang_status.view.tv_icon_1
|
||||
import kotlinx.android.synthetic.main.layout_mofang_status.view.tv_icon_2
|
||||
import kotlinx.android.synthetic.main.layout_mofang_status.view.tv_icon_3
|
||||
import kotlinx.android.synthetic.main.layout_mofang_status.view.tv_icon_4
|
||||
import kotlinx.android.synthetic.main.layout_mofang_status.view.tv_icon_5
|
||||
import kotlinx.android.synthetic.main.layout_mofang_status.view.v_lp_1
|
||||
import kotlinx.android.synthetic.main.layout_mofang_status.view.v_lp_2
|
||||
import kotlinx.android.synthetic.main.layout_mofang_status.view.v_lp_3
|
||||
import kotlinx.android.synthetic.main.layout_mofang_status.view.v_lp_4
|
||||
import kotlinx.android.synthetic.main.layout_mofang_status.view.v_lp_5
|
||||
import kotlinx.android.synthetic.main.layout_mofang_status.view.v_sp_1
|
||||
import kotlinx.android.synthetic.main.layout_mofang_status.view.v_sp_2
|
||||
import kotlinx.android.synthetic.main.layout_mofang_status.view.v_sp_3
|
||||
import kotlinx.android.synthetic.main.layout_mofang_status.view.v_sp_4
|
||||
import kotlinx.android.synthetic.main.layout_mofang_status.view.v_sp_5
|
||||
import me.jessyan.autosize.utils.AutoSizeUtils
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
|
||||
/**
|
||||
* 蘑方输入/执行状态反馈控件
|
||||
*/
|
||||
class MoFangStatusView : LinearLayout, OnMoFangStatusListener, IMoGoAutopilotStatusListener {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "MoFangStatusView"
|
||||
}
|
||||
|
||||
private val autoPilotState by lazy { AtomicInteger(CallerAutoPilotStatusListenerManager.getState()) }
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
|
||||
|
||||
init {
|
||||
View.inflate(context, R.layout.layout_mofang_status, this)
|
||||
orientation = VERTICAL
|
||||
background = ContextCompat.getDrawable(context, R.drawable.bg_mf_status)
|
||||
val lr = AutoSizeUtils.dp2px(context, 30f)
|
||||
val tb = AutoSizeUtils.dp2px(context, 33f)
|
||||
setPadding(lr, tb, lr, tb)
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
|
||||
visibility = if (CallerDevaToolsManager.mofang()?.isConnected() == true) {
|
||||
View.VISIBLE
|
||||
} else {
|
||||
View.INVISIBLE
|
||||
}
|
||||
CallerDevaToolsManager.mofang()?.registerMoFangStatusListener(TAG, this)
|
||||
}
|
||||
|
||||
override fun onMoFangConnected() {
|
||||
visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
override fun onMoFangDisconnected() {
|
||||
visibility = View.INVISIBLE
|
||||
}
|
||||
|
||||
override fun onAutopilotStatusResponse(state: Int) {
|
||||
super.onAutopilotStatusResponse(state)
|
||||
val last = autoPilotState.get()
|
||||
Log.d(TAG, "收到工控机自驾状态回调 -> state: $state, last: $last")
|
||||
if (last != state) {
|
||||
if (last == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
|
||||
reset()
|
||||
}
|
||||
autoPilotState.set(state)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onMoFangBatteryChanged(battery: Int) {}
|
||||
|
||||
override fun onMoFangClicked(keyCode: Int) {
|
||||
if (keyCode == KeyEvent.KEYCODE_A) {
|
||||
if (tv_icon_2?.tag != 2 && tv_icon_2?.isSelected == true) {
|
||||
tv_icon_2?.isSelected = false
|
||||
v_lp_2?.visibility = View.VISIBLE
|
||||
v_lp_2?.isSelected = false
|
||||
v_sp_2?.visibility = View.INVISIBLE
|
||||
}
|
||||
tv_icon_1?.isSelected = true
|
||||
v_lp_1?.visibility = View.INVISIBLE
|
||||
v_sp_1?.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
if (keyCode == KeyEvent.KEYCODE_B) {
|
||||
if (tv_icon_1?.isSelected == true) {
|
||||
tv_icon_1?.isSelected = false
|
||||
v_lp_1?.visibility = View.VISIBLE
|
||||
v_lp_1?.isSelected = false
|
||||
v_sp_1?.visibility = View.INVISIBLE
|
||||
}
|
||||
tv_icon_2?.isSelected = true
|
||||
tv_icon_2?.tag = 1
|
||||
v_lp_2?.visibility = View.INVISIBLE
|
||||
v_sp_2?.visibility = View.VISIBLE
|
||||
UiThreadHandler.postDelayed({
|
||||
tv_icon_2?.tag = null
|
||||
tv_icon_2?.isSelected = false
|
||||
v_lp_2?.visibility = View.VISIBLE
|
||||
v_lp_2?.isSelected = false
|
||||
v_sp_2?.visibility = View.INVISIBLE
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
if (keyCode == KeyEvent.KEYCODE_C) {
|
||||
tv_icon_3?.isSelected = true
|
||||
v_lp_3?.visibility = View.INVISIBLE
|
||||
v_sp_3?.visibility = View.VISIBLE
|
||||
UiThreadHandler.postDelayed({
|
||||
tv_icon_3?.isSelected = false
|
||||
v_lp_3?.visibility = View.VISIBLE
|
||||
v_lp_3?.isSelected = false
|
||||
v_sp_3?.visibility = View.INVISIBLE
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
if (keyCode == KeyEvent.KEYCODE_D) {
|
||||
tv_icon_4?.isSelected = true
|
||||
v_lp_4?.visibility = View.INVISIBLE
|
||||
v_sp_4?.visibility = View.VISIBLE
|
||||
UiThreadHandler.postDelayed({
|
||||
tv_icon_4?.isSelected = false
|
||||
v_lp_4?.visibility = View.VISIBLE
|
||||
v_lp_4?.isSelected = false
|
||||
v_sp_4?.visibility = View.INVISIBLE
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
if (keyCode == KeyEvent.KEYCODE_E) {
|
||||
tv_icon_5?.isSelected = true
|
||||
v_lp_5?.visibility = View.INVISIBLE
|
||||
v_sp_5?.visibility = View.VISIBLE
|
||||
UiThreadHandler.postDelayed({
|
||||
tv_icon_5?.isSelected = false
|
||||
v_lp_5?.visibility = View.VISIBLE
|
||||
v_lp_5?.isSelected = false
|
||||
v_sp_5?.visibility = View.INVISIBLE
|
||||
}, 1000)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onMoFangLongClicked(keyCode: Int) {
|
||||
if (keyCode == KeyEvent.KEYCODE_A) {
|
||||
if (tv_icon_2?.tag != 2 && tv_icon_2?.isSelected == true) {
|
||||
tv_icon_2?.isSelected = false
|
||||
v_lp_2?.visibility = View.VISIBLE
|
||||
v_lp_2?.isSelected = false
|
||||
v_sp_2?.visibility = View.INVISIBLE
|
||||
}
|
||||
tv_icon_1?.isSelected = true
|
||||
v_lp_1?.visibility = View.VISIBLE
|
||||
v_lp_1?.isSelected = true
|
||||
v_sp_1?.visibility = View.INVISIBLE
|
||||
}
|
||||
|
||||
if (keyCode == KeyEvent.KEYCODE_B) {
|
||||
tv_icon_2?.isSelected = true
|
||||
tv_icon_2?.tag = 2
|
||||
v_lp_2?.visibility = View.VISIBLE
|
||||
v_lp_2?.isSelected = true
|
||||
v_sp_2?.visibility = View.INVISIBLE
|
||||
UiThreadHandler.postDelayed({
|
||||
tv_icon_2?.tag = null
|
||||
tv_icon_2?.isSelected = false
|
||||
v_lp_2?.visibility = View.VISIBLE
|
||||
v_lp_2?.isSelected = false
|
||||
v_sp_2?.visibility = View.INVISIBLE
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
if (keyCode == KeyEvent.KEYCODE_E) {
|
||||
tv_icon_5?.isSelected = true
|
||||
v_lp_5?.visibility = View.VISIBLE
|
||||
v_lp_5?.isSelected = true
|
||||
v_sp_5?.visibility = View.INVISIBLE
|
||||
UiThreadHandler.postDelayed({
|
||||
tv_icon_5?.isSelected = false
|
||||
v_lp_5?.visibility = View.VISIBLE
|
||||
v_lp_5?.isSelected = false
|
||||
v_sp_5?.visibility = View.INVISIBLE
|
||||
}, 1000)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onMoFangCombineClicked(vararg keyCodes: Int) {
|
||||
if (keyCodes.size != 2) {
|
||||
return
|
||||
}
|
||||
val key1 = keyCodes[0]
|
||||
val key2 = keyCodes[1]
|
||||
if (key1 == KeyEvent.KEYCODE_A && key2 == KeyEvent.KEYCODE_B || (key1 == KeyEvent.KEYCODE_B && key2 == KeyEvent.KEYCODE_A)) {
|
||||
tv_icon_1?.isSelected = true
|
||||
v_lp_1?.visibility = View.INVISIBLE
|
||||
v_sp_1?.visibility = View.VISIBLE
|
||||
tv_icon_2?.isSelected = true
|
||||
v_lp_2.visibility = View.INVISIBLE
|
||||
v_sp_2.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
override fun onMoFangStatusError(msg: String) {}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
CallerDevaToolsManager.mofang()?.unRegisterMoFangStatusListener(this)
|
||||
CallerAutoPilotStatusListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
private fun reset() {
|
||||
tv_icon_1?.isSelected = false
|
||||
v_lp_1?.visibility = View.VISIBLE
|
||||
v_lp_1?.isSelected = false
|
||||
v_sp_1?.visibility = View.INVISIBLE
|
||||
|
||||
tv_icon_2?.isSelected = false
|
||||
v_lp_2?.visibility = View.VISIBLE
|
||||
v_lp_2?.isSelected = false
|
||||
v_sp_2?.visibility = View.INVISIBLE
|
||||
|
||||
|
||||
tv_icon_3?.isSelected = false
|
||||
v_lp_3?.visibility = View.VISIBLE
|
||||
v_lp_3?.isSelected = false
|
||||
v_sp_3?.visibility = View.INVISIBLE
|
||||
|
||||
tv_icon_4?.isSelected = false
|
||||
v_lp_4?.visibility = View.VISIBLE
|
||||
v_lp_4?.isSelected = false
|
||||
v_sp_4?.visibility = View.INVISIBLE
|
||||
|
||||
tv_icon_5?.isSelected = false
|
||||
v_lp_5?.visibility = View.VISIBLE
|
||||
v_lp_5?.isSelected = false
|
||||
v_sp_5?.visibility = View.INVISIBLE
|
||||
}
|
||||
}
|
||||
@@ -2,22 +2,28 @@ package com.mogo.eagle.core.function.hmi.ui.widget
|
||||
|
||||
import android.annotation.*
|
||||
import android.content.Context
|
||||
import android.graphics.*
|
||||
import android.graphics.drawable.*
|
||||
import android.os.SystemClock
|
||||
import android.util.AttributeSet
|
||||
import android.util.Log
|
||||
import android.view.*
|
||||
import android.widget.LinearLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.api.devatools.mofang.*
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.devatools.*
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.utilcode.kotlin.onClick
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import kotlinx.android.synthetic.main.view_blue_tooth.view.*
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.atomic.AtomicLong
|
||||
|
||||
/**
|
||||
* 魔戒蓝牙控件
|
||||
* 放置于StatusBar右侧位置
|
||||
*/
|
||||
open class BlueToothView: LinearLayout, IMoGoMoFangProvider.OnMoFangStatusListener {
|
||||
open class BlueToothView: LinearLayout, IMoGoMoFangProvider.OnMoFangStatusListener, IMoGoAutopilotStatusListener {
|
||||
|
||||
constructor(context: Context) : this(context, null)
|
||||
constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)
|
||||
@@ -27,25 +33,57 @@ open class BlueToothView: LinearLayout, IMoGoMoFangProvider.OnMoFangStatusListen
|
||||
LayoutInflater.from(context).inflate(R.layout.view_blue_tooth
|
||||
, this, true)
|
||||
visibility = View.GONE
|
||||
|
||||
clipChildren = false
|
||||
clipToPadding = false
|
||||
onClick {
|
||||
runCatching {
|
||||
val mofang = CallerDevaToolsManager.mofang()
|
||||
if (mofang != null && !mofang.isConnected()) {
|
||||
Log.d(TAG, "--- 点击重连 ---")
|
||||
mofang.connect()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object{
|
||||
private const val TAG = "BlueToothView"
|
||||
}
|
||||
|
||||
private val prevTime by lazy { AtomicLong(0) }
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
ivMoFangStatus?.tag = 0
|
||||
val isConnected = CallerDevaToolsManager.mofang()?.isConnected() ?: false
|
||||
visibility = if (isConnected) View.VISIBLE else View.GONE
|
||||
val isIpcConnected = CallerAutoPilotStatusListenerManager.isConnect()
|
||||
if (!isIpcConnected) {
|
||||
if (visibility == View.VISIBLE) {
|
||||
ivMoFangStatus?.tag = 1
|
||||
ivMoFangStatus?.background = (ContextCompat.getDrawable(context, R.drawable.icon_mofang_ipc_disconnected))
|
||||
}
|
||||
}
|
||||
CallerDevaToolsManager.mofang()?.registerMoFangStatusListener(TAG, this)
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
override fun onAutopilotIpcConnectStatusChanged(status: Int, reason: String?) {
|
||||
super.onAutopilotIpcConnectStatusChanged(status, reason)
|
||||
if (!CallerAutoPilotStatusListenerManager.isConnect()) {
|
||||
if (ivMoFangStatus?.tag == 0) {
|
||||
ivMoFangStatus?.tag = 1
|
||||
ivMoFangStatus?.background = (ContextCompat.getDrawable(context, R.drawable.icon_mofang_ipc_disconnected))
|
||||
}
|
||||
} else {
|
||||
ivMoFangStatus?.tag = 0
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
CallerDevaToolsManager.mofang()?.unRegisterMoFangStatusListener(this)
|
||||
CallerAutoPilotStatusListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
override fun onMoFangConnected() {
|
||||
@@ -56,28 +94,29 @@ open class BlueToothView: LinearLayout, IMoGoMoFangProvider.OnMoFangStatusListen
|
||||
visibility = View.GONE
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun onMoFangBatteryChanged(battery: Int) {
|
||||
ivMoFangBattery?.also {
|
||||
if (it.visibility != View.VISIBLE) {
|
||||
it.visibility = View.VISIBLE
|
||||
}
|
||||
val oldTextColor = it.currentTextColor
|
||||
if (CallerAutoPilotStatusListenerManager.isConnect()) {
|
||||
if (battery <= 30) {
|
||||
if (oldTextColor != Color.RED) {
|
||||
it.setTextColor(Color.RED)
|
||||
ivMoFangStatus?.drawable?.setTint(Color.RED)
|
||||
postDelayed({
|
||||
ToastUtils.showShort("蘑方处于低电状态, 请及时充电")
|
||||
}, 5000)
|
||||
post {
|
||||
runCatching {
|
||||
val prev = prevTime.get()
|
||||
val current = SystemClock.elapsedRealtime()
|
||||
if (prev == 0L || TimeUnit.MILLISECONDS.toSeconds(current - prev) >= 30) {
|
||||
ToastUtils.showShort("蘑方当前处于低电状态,请及时充电")
|
||||
prevTime.set(current)
|
||||
}
|
||||
ivMoFangStatus?.background = (ContextCompat.getDrawable(context, R.drawable.icon_mofang_low_power))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (oldTextColor != Color.WHITE) {
|
||||
it.setTextColor(Color.WHITE)
|
||||
ivMoFangStatus?.drawable?.setTint(Color.WHITE)
|
||||
post {
|
||||
runCatching {
|
||||
ivMoFangStatus?.background = (ContextCompat.getDrawable(context, R.drawable.icon_mofang_normal_power))
|
||||
}
|
||||
}
|
||||
}
|
||||
it.text = "${battery}%"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.3 KiB |
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_selected="true">
|
||||
<shape android:shape="oval">
|
||||
<size android:width="@dimen/dp_58" android:height="@dimen/dp_58"/>
|
||||
<gradient android:startColor="#029DFF" android:endColor="#ef0056FF"/>
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape android:shape="oval">
|
||||
<size android:width="@dimen/dp_58" android:height="@dimen/dp_58"/>
|
||||
<solid android:color="#8243559C"/>
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<corners android:radius="@dimen/dp_58" />
|
||||
<solid android:color="#7f000000"/>
|
||||
</shape>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_selected="true">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#7f4DFFEF" />
|
||||
<corners android:radius="@dimen/dp_200"/>
|
||||
</shape>
|
||||
</item>
|
||||
<item android:state_selected="false">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#8243559C" />
|
||||
<corners android:radius="@dimen/dp_200"/>
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
||||
<solid android:color="#7f4DFFEF" />
|
||||
<corners android:radius="@dimen/dp_10"/>
|
||||
</shape>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<corners android:radius="@dimen/dp_15" />
|
||||
<solid android:color="#30000000" />
|
||||
</shape>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,195 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:parentTag="android.widget.LinearLayout"
|
||||
tools:layout_width="wrap_content"
|
||||
tools:layout_height="wrap_content"
|
||||
tools:orientation="vertical"
|
||||
tools:background="@drawable/bg_mf_status"
|
||||
tools:paddingLeft="@dimen/dp_30"
|
||||
android:paddingRight="@dimen/dp_30"
|
||||
android:paddingTop="@dimen/dp_33"
|
||||
android:paddingBottom="@dimen/dp_33">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="@dimen/dp_254"
|
||||
android:layout_height="@dimen/dp_70"
|
||||
android:padding="@dimen/dp_5"
|
||||
android:background="@drawable/bg_mf_key_group">
|
||||
<TextView
|
||||
android:id="@+id/tv_icon_1"
|
||||
android:layout_width="@dimen/dp_58"
|
||||
android:layout_height="@dimen/dp_58"
|
||||
android:gravity="center"
|
||||
android:text="1"
|
||||
android:textSize="@dimen/dp_34"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textStyle="bold"
|
||||
android:background="@drawable/bg_mf_key"/>
|
||||
<FrameLayout
|
||||
android:layout_width="@dimen/dp_137"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dp_23"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:clipToPadding="false"
|
||||
android:clipChildren="false"
|
||||
android:layout_marginEnd="@dimen/dp_28">
|
||||
<View
|
||||
android:id="@+id/v_lp_1"
|
||||
android:layout_width="@dimen/dp_137"
|
||||
android:layout_height="@dimen/dp_8"
|
||||
android:background="@drawable/bg_mf_lp_bar"/>
|
||||
<View
|
||||
android:id="@+id/v_sp_1"
|
||||
android:visibility="gone"
|
||||
android:layout_width="@dimen/dp_49"
|
||||
android:layout_height="@dimen/dp_8"
|
||||
android:background="@drawable/bg_mf_sp_bar"/>
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="@dimen/dp_254"
|
||||
android:layout_height="@dimen/dp_70"
|
||||
android:padding="@dimen/dp_5"
|
||||
android:layout_marginTop="@dimen/dp_30"
|
||||
android:background="@drawable/bg_mf_key_group">
|
||||
<TextView
|
||||
android:id="@+id/tv_icon_2"
|
||||
android:layout_width="@dimen/dp_58"
|
||||
android:layout_height="@dimen/dp_58"
|
||||
android:gravity="center"
|
||||
android:text="2"
|
||||
android:textSize="@dimen/dp_34"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textStyle="bold"
|
||||
android:background="@drawable/bg_mf_key"/>
|
||||
<FrameLayout
|
||||
android:layout_width="@dimen/dp_137"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dp_23"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="@dimen/dp_28">
|
||||
<View
|
||||
android:id="@+id/v_lp_2"
|
||||
android:layout_width="@dimen/dp_137"
|
||||
android:layout_height="@dimen/dp_8"
|
||||
android:background="@drawable/bg_mf_lp_bar"/>
|
||||
<View
|
||||
android:id="@+id/v_sp_2"
|
||||
android:visibility="gone"
|
||||
android:layout_width="@dimen/dp_49"
|
||||
android:layout_height="@dimen/dp_8"
|
||||
android:background="@drawable/bg_mf_sp_bar"/>
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="@dimen/dp_254"
|
||||
android:layout_height="@dimen/dp_70"
|
||||
android:padding="@dimen/dp_5"
|
||||
android:layout_marginTop="@dimen/dp_30"
|
||||
android:background="@drawable/bg_mf_key_group">
|
||||
<TextView
|
||||
android:id="@+id/tv_icon_3"
|
||||
android:layout_width="@dimen/dp_58"
|
||||
android:layout_height="@dimen/dp_58"
|
||||
android:gravity="center"
|
||||
android:text="3"
|
||||
android:textSize="@dimen/dp_34"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textStyle="bold"
|
||||
android:background="@drawable/bg_mf_key"/>
|
||||
<FrameLayout
|
||||
android:layout_width="@dimen/dp_137"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dp_23"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="@dimen/dp_28">
|
||||
<View
|
||||
android:id="@+id/v_lp_3"
|
||||
android:layout_width="@dimen/dp_137"
|
||||
android:layout_height="@dimen/dp_8"
|
||||
android:background="@drawable/bg_mf_lp_bar"/>
|
||||
<View
|
||||
android:id="@+id/v_sp_3"
|
||||
android:visibility="gone"
|
||||
android:layout_width="@dimen/dp_49"
|
||||
android:layout_height="@dimen/dp_8"
|
||||
android:background="@drawable/bg_mf_sp_bar"/>
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="@dimen/dp_254"
|
||||
android:layout_height="@dimen/dp_70"
|
||||
android:padding="@dimen/dp_5"
|
||||
android:layout_marginTop="@dimen/dp_30"
|
||||
android:background="@drawable/bg_mf_key_group">
|
||||
<TextView
|
||||
android:id="@+id/tv_icon_4"
|
||||
android:layout_width="@dimen/dp_58"
|
||||
android:layout_height="@dimen/dp_58"
|
||||
android:gravity="center"
|
||||
android:text="4"
|
||||
android:textSize="@dimen/dp_34"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textStyle="bold"
|
||||
android:background="@drawable/bg_mf_key"/>
|
||||
<FrameLayout
|
||||
android:layout_width="@dimen/dp_137"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dp_23"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="@dimen/dp_28">
|
||||
<View
|
||||
android:id="@+id/v_lp_4"
|
||||
android:layout_width="@dimen/dp_137"
|
||||
android:layout_height="@dimen/dp_8"
|
||||
android:background="@drawable/bg_mf_lp_bar"/>
|
||||
<View
|
||||
android:id="@+id/v_sp_4"
|
||||
android:visibility="gone"
|
||||
android:layout_width="@dimen/dp_49"
|
||||
android:layout_height="@dimen/dp_8"
|
||||
android:background="@drawable/bg_mf_sp_bar"/>
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="@dimen/dp_254"
|
||||
android:layout_height="@dimen/dp_70"
|
||||
android:padding="@dimen/dp_5"
|
||||
android:layout_marginTop="@dimen/dp_30"
|
||||
android:background="@drawable/bg_mf_key_group">
|
||||
<TextView
|
||||
android:id="@+id/tv_icon_5"
|
||||
android:layout_width="@dimen/dp_58"
|
||||
android:layout_height="@dimen/dp_58"
|
||||
android:gravity="center"
|
||||
android:text="5"
|
||||
android:textSize="@dimen/dp_34"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textStyle="bold"
|
||||
android:background="@drawable/bg_mf_key"/>
|
||||
<FrameLayout
|
||||
android:layout_width="@dimen/dp_137"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dp_23"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="@dimen/dp_28">
|
||||
<View
|
||||
android:id="@+id/v_lp_5"
|
||||
android:layout_width="@dimen/dp_137"
|
||||
android:layout_height="@dimen/dp_8"
|
||||
android:background="@drawable/bg_mf_lp_bar"/>
|
||||
<View
|
||||
android:id="@+id/v_sp_5"
|
||||
android:visibility="gone"
|
||||
android:layout_width="@dimen/dp_49"
|
||||
android:layout_height="@dimen/dp_8"
|
||||
android:background="@drawable/bg_mf_sp_bar"/>
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
</merge>
|
||||
@@ -9,23 +9,8 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivMoFangStatus"
|
||||
android:layout_width="@dimen/dp_54"
|
||||
android:layout_height="@dimen/dp_54"
|
||||
android:layout_width="@dimen/dp_65"
|
||||
android:layout_height="@dimen/dp_65"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/blue_tooth"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/ivMoFangBattery"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="25dip"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/white"
|
||||
android:layout_gravity="bottom"
|
||||
android:visibility="gone"
|
||||
android:layout_marginStart="-8dip"
|
||||
android:layout_marginBottom="1dip"
|
||||
tools:text="18%"/>
|
||||
|
||||
</merge>
|
||||
@@ -40,7 +40,6 @@
|
||||
<com.mogo.eagle.core.function.hmi.ui.widget.BlueToothView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/blue_tooth"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginStart="@dimen/dp_8" />
|
||||
|
||||
|
||||
@@ -593,8 +593,10 @@ enum class EventTypeEnumNew(
|
||||
TYPE_VIP_IDENTIFICATION_PASS("20022", "VIP通行", "", R.drawable.icon_warning_v2x_vip_turn_light, "VIP车辆优先通行,已为您变为绿灯", "VIP车辆优先通行,已为您变为绿灯"),
|
||||
TYPE_VIP_IDENTIFICATION_EXTEND("20023", "VIP通行", "", R.drawable.icon_warning_v2x_vip_turn_light, "VIP车辆优先通行,已为您延长绿灯", "VIP车辆优先通行,已为您延长绿灯"),
|
||||
TYPE_VIP_ERROR_IDENTIFICATION("20024", "VIP通行", "", R.drawable.icon_warning_v2x_vip_turn_light, "请求失败,", "请求失败,稍后重试"),
|
||||
TYPE_OPTIMAL_ROUTE_RECOMMEND("2000", "路线推荐", "", R.drawable.icon_warning_v2x_optimal_route, "为您推荐最优路线", "已为您选择最优路线");
|
||||
TYPE_OPTIMAL_ROUTE_RECOMMEND("2000", "路线推荐", "", R.drawable.icon_warning_v2x_optimal_route, "为您推荐最优路线", "已为您选择最优路线"),
|
||||
|
||||
//蘑方指令下发时,工控机与pad断连提示
|
||||
TYPE_IPC_DISCONNECT_FOR_MO_FANG("20025", "连接异常", "", R.drawable.icon_warning_take_over, "工控机连接异常,无法执行魔方命令", "");
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
@@ -1114,6 +1116,10 @@ enum class EventTypeEnumNew(
|
||||
TYPE_USECASE_ID_LTA.poiType ->{
|
||||
TYPE_USECASE_ID_LTA.poiTypeStr
|
||||
}
|
||||
//蘑方指令下发时,工控机与pad断连提示
|
||||
TYPE_IPC_DISCONNECT_FOR_MO_FANG.poiType -> {
|
||||
TYPE_IPC_DISCONNECT_FOR_MO_FANG.poiTypeStr
|
||||
}
|
||||
else ->{
|
||||
"事件通知"
|
||||
}
|
||||
@@ -1313,7 +1319,6 @@ enum class EventTypeEnumNew(
|
||||
TYPE_USECASE_ID_LCW.poiType -> TYPE_USECASE_ID_LCW.poiTypeSrcVr
|
||||
TYPE_USECASE_ID_EVW.poiType -> TYPE_USECASE_ID_EVW.poiTypeSrcVr
|
||||
TYPE_USECASE_ID_LTA.poiType -> TYPE_USECASE_ID_LTA.poiTypeSrcVr
|
||||
|
||||
else -> {
|
||||
R.drawable.icon_default
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user