完成红绿灯、限速标志的接口封装以及自测触发
This commit is contained in:
3
.idea/codeStyles/Project.xml
generated
3
.idea/codeStyles/Project.xml
generated
@@ -7,6 +7,9 @@
|
||||
<JetCodeStyleSettings>
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</JetCodeStyleSettings>
|
||||
<codeStyleSettings language="JAVA">
|
||||
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="XML">
|
||||
<indentOptions>
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||
|
||||
14
README.md
14
README.md
@@ -10,7 +10,19 @@ adb remount
|
||||
adb shell
|
||||
|
||||
// (新的HMI)使用命令行触发 V2X 预警场景
|
||||
adb shell am broadcast -a com.v2x.control --ei warningType 2
|
||||
// 顶部弹窗场景,控制展示
|
||||
adb shell am broadcast -a com.hmi.v2x.notification --ez v2xIsShow true --es tag "20008" --ei v2xType 20008 --es alertContent "测试外部传入数据" --es ttsContent "测试TTS"
|
||||
// 关闭顶部弹窗
|
||||
adb shell am broadcast -a com.hmi.v2x.notification --ez v2xIsShow false --es tag "20008"
|
||||
|
||||
// 控制红绿灯
|
||||
adb shell am broadcast -a com.hmi.v2x.trafficlight --ez trafficLightIsShow true --ei trafficLightCheckType 1
|
||||
adb shell am broadcast -a com.hmi.v2x.trafficlight --ez trafficLightIsShow false
|
||||
|
||||
// 控制红绿灯
|
||||
adb shell am broadcast -a com.hmi.v2x.limitingvelocity --ez limitingVelocityIsShow true --ei limitingVelocitySpeed 60
|
||||
adb shell am broadcast -a com.hmi.v2x.limitingvelocity --ez limitingVelocityIsShow false
|
||||
|
||||
|
||||
// (旧版本)使用命令行触发各种测试场景演示
|
||||
adb shell am broadcast -a com.v2x.test_panel_control --ei sceneType 1
|
||||
|
||||
@@ -24,23 +24,19 @@ interface WarningTypeEnum {
|
||||
const val warning_congestion = 20012//前方道路拥堵
|
||||
const val WARNING_TRAFFIC_SPEED_GUIDE = 20013//绿波通行车速引导
|
||||
const val WARNING_CAR_PLATE = 20014//车内标牌
|
||||
|
||||
const val WARNING_VULNERABLE_TRANSPORT_PARTICIPANT = 20015//弱势交通参与者预警
|
||||
|
||||
|
||||
const val WARNING_ROAD_HAZARDS = 20016//道路危险情况预警
|
||||
|
||||
const val WARNING_OVER_SPEED = 20017//超速预警
|
||||
const val WARNING_ROUNDABOUT = 20019//环岛
|
||||
const val WARNING_GIVE_WAY = 20020//减速让行
|
||||
const val WARNING_BAN_ASTERN = 20021//禁止倒车
|
||||
const val WARNING_TURN_LEFT_SHARP = 20022//左转急弯
|
||||
const val WARNING_TURN_RIGHT_SHARP = 20023//左转急弯
|
||||
const val WARNING_TRAMCAR = 20024//有轨电车
|
||||
const val WARNING_TEST_SECTION = 20025//考试路段
|
||||
const val WARNING_ACCIDENT_PRONE_ROAD_SECTION = 20026//事故易发路段
|
||||
const val WARNING_HUMP_BRIDGE = 20027//驼峰桥
|
||||
const val WARNING_SCHOOL = 20028// 学校
|
||||
const val WARNING_ROUNDABOUT = 20018//环岛
|
||||
const val WARNING_GIVE_WAY = 20019//减速让行
|
||||
const val WARNING_BAN_ASTERN = 20020//禁止倒车
|
||||
const val WARNING_TURN_LEFT_SHARP = 20021//左转急弯
|
||||
const val WARNING_TURN_RIGHT_SHARP = 20022//左转急弯
|
||||
const val WARNING_TRAMCAR = 20023//有轨电车
|
||||
const val WARNING_TEST_SECTION = 20024//考试路段
|
||||
const val WARNING_ACCIDENT_PRONE_ROAD_SECTION = 20025//事故易发路段
|
||||
const val WARNING_HUMP_BRIDGE = 20026//驼峰桥
|
||||
const val WARNING_SCHOOL = 20027// 学校
|
||||
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,25 @@
|
||||
|
||||
<application>
|
||||
|
||||
<receiver android:name=".receiver.WarningBroadcastReceiver">
|
||||
<receiver android:name=".receiver.V2XWarningBroadcastReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="com.hmi.v2x.control" />
|
||||
<action android:name="com.hmi.v2x.notification" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<receiver android:name=".receiver.V2XTrafficLightBroadcastReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="com.hmi.v2x.trafficlight" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<receiver android:name=".receiver.V2XLimitingVelocityBroadcastReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="com.hmi.v2x.limitingvelocity" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
|
||||
@@ -7,10 +7,28 @@ package com.mogo.module.hmi;
|
||||
public class WaringConst {
|
||||
public static String MODULE_NAME = "MODULE_LEFT_PANEL";
|
||||
|
||||
// V2X 弹窗预警
|
||||
// 是否展示:true-展示,false-关闭
|
||||
public static String BROADCAST_V2X_IS_SHOW_EXTRA_KEY = "v2xIsShow";
|
||||
// 预警类型:@WarningTypeEnum
|
||||
public static String BROADCAST_V2X_TYPE_EXTRA_KEY = "v2xType";
|
||||
// 预警弹窗文字内容
|
||||
public static String BROADCAST_V2X_ALERT_CONTENT_EXTRA_KEY = "alertContent";
|
||||
// 预警弹窗TTS播报
|
||||
public static String BROADCAST_V2X_TTS_CONTENT_EXTRA_KEY = "ttsContent";
|
||||
// 弹窗标志,一个弹窗绑定一个标志,不可重复
|
||||
public static String BROADCAST_V2X_TAG_EXTRA_KEY = "tag";
|
||||
|
||||
// 交通的灯
|
||||
// 是否展示:true-展示,false-关闭
|
||||
public static String BROADCAST_V2X_TRAFFIC_LIGHT_IS_SHOW__EXTRA_KEY = "trafficLightIsShow";
|
||||
// 选中的交通等类型,red、yellow、green
|
||||
public static String BROADCAST_V2X_TRAFFIC_LIGHT_CHECK_TYPE_EXTRA_KEY = "trafficLightCheckType";
|
||||
|
||||
// 限速标志
|
||||
// 是否展示:true-展示,false-关闭
|
||||
public static String BROADCAST_V2X_LIMITING_VELOCITY_IS_SHOW__EXTRA_KEY = "limitingVelocityIsShow";
|
||||
// 限速的速度
|
||||
public static String BROADCAST_V2X_LIMITING_VELOCITY_SPEED__EXTRA_KEY = "limitingVelocitySpeed";
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.mogo.module.hmi.receiver
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.mogo.module.hmi.WaringConst
|
||||
import com.mogo.service.IMogoServiceApis
|
||||
import com.mogo.service.MogoServicePaths
|
||||
import com.mogo.service.warning.IMoGoWaringProvider
|
||||
import com.mogo.utils.logger.Logger
|
||||
|
||||
/**
|
||||
* V2X 预警广播接收。用于跨应用,跨进程,内部也可以通过这种方式 控制限速标志
|
||||
*
|
||||
* @author donghongyu
|
||||
*/
|
||||
class V2XLimitingVelocityBroadcastReceiver : BroadcastReceiver() {
|
||||
private var mContext: Context? = null
|
||||
|
||||
companion object {
|
||||
private const val TAG = "V2XLimitingVelocityBroadcastReceiver"
|
||||
private var mMogoServiceApis: IMogoServiceApis? = null
|
||||
private var mIMoGoWaringProvider: IMoGoWaringProvider? = null
|
||||
}
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
try {
|
||||
mMogoServiceApis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS)
|
||||
.navigation(context) as IMogoServiceApis
|
||||
mIMoGoWaringProvider = mMogoServiceApis!!.waringProviderApi
|
||||
mContext = context
|
||||
|
||||
val limitingVelocityIsShow =
|
||||
intent.getBooleanExtra(
|
||||
WaringConst.BROADCAST_V2X_LIMITING_VELOCITY_IS_SHOW__EXTRA_KEY,
|
||||
false
|
||||
)
|
||||
val limitingVelocitySpeed =
|
||||
intent.getIntExtra(
|
||||
WaringConst.BROADCAST_V2X_LIMITING_VELOCITY_SPEED__EXTRA_KEY,
|
||||
0
|
||||
)
|
||||
|
||||
Logger.d(
|
||||
TAG,
|
||||
"limitingVelocityIsShow:$limitingVelocityIsShow limitingVelocitySpeed:$limitingVelocitySpeed"
|
||||
)
|
||||
if (limitingVelocityIsShow) {
|
||||
// 分发场景
|
||||
dispatchShowWaring(limitingVelocitySpeed)
|
||||
} else {
|
||||
dispatchCloseWaring()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 展示限速标志
|
||||
*
|
||||
* @param limitingVelocitySpeed 限速速度
|
||||
*/
|
||||
private fun dispatchShowWaring(limitingVelocitySpeed: Int) {
|
||||
mIMoGoWaringProvider!!.showLimitingVelocity(limitingVelocitySpeed)
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭限速标志
|
||||
*/
|
||||
private fun dispatchCloseWaring() {
|
||||
mIMoGoWaringProvider!!.disableLimitingVelocity()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.mogo.module.hmi.receiver
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.mogo.module.hmi.WaringConst
|
||||
import com.mogo.service.IMogoServiceApis
|
||||
import com.mogo.service.MogoServicePaths
|
||||
import com.mogo.service.warning.IMoGoWaringProvider
|
||||
import com.mogo.utils.logger.Logger
|
||||
|
||||
/**
|
||||
* V2X 预警广播接收。用于跨应用,跨进程,内部也可以通过这种方式 触发红绿灯场景
|
||||
*
|
||||
* @author donghongyu
|
||||
*/
|
||||
class V2XTrafficLightBroadcastReceiver : BroadcastReceiver() {
|
||||
private var mContext: Context? = null
|
||||
|
||||
companion object {
|
||||
private const val TAG = "V2XTrafficLightBroadcastReceiver"
|
||||
private var mMogoServiceApis: IMogoServiceApis? = null
|
||||
private var mIMoGoWaringProvider: IMoGoWaringProvider? = null
|
||||
}
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
try {
|
||||
mMogoServiceApis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS)
|
||||
.navigation(context) as IMogoServiceApis
|
||||
mIMoGoWaringProvider = mMogoServiceApis!!.waringProviderApi
|
||||
mContext = context
|
||||
|
||||
val trafficLightIsShow =
|
||||
intent.getBooleanExtra(
|
||||
WaringConst.BROADCAST_V2X_TRAFFIC_LIGHT_IS_SHOW__EXTRA_KEY,
|
||||
false
|
||||
)
|
||||
val trafficLightCheckType =
|
||||
intent.getIntExtra(
|
||||
WaringConst.BROADCAST_V2X_TRAFFIC_LIGHT_CHECK_TYPE_EXTRA_KEY,
|
||||
0
|
||||
)
|
||||
|
||||
Logger.d(
|
||||
TAG,
|
||||
"trafficLightIsShow:$trafficLightIsShow trafficLightCheckType:$trafficLightCheckType"
|
||||
)
|
||||
if (trafficLightIsShow) {
|
||||
// 分发场景
|
||||
dispatchShowWaring(trafficLightCheckType)
|
||||
} else {
|
||||
dispatchCloseWaring()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 展示交通灯
|
||||
*
|
||||
* @param trafficLightCheckType 选中的交通的灯 0-都是默认,1-红,2-黄,3-绿
|
||||
*/
|
||||
private fun dispatchShowWaring(trafficLightCheckType: Int) {
|
||||
mIMoGoWaringProvider!!.showWarningTrafficLight(trafficLightCheckType)
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭交通灯
|
||||
*/
|
||||
private fun dispatchCloseWaring() {
|
||||
mIMoGoWaringProvider!!.disableWarningTrafficLight()
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.mogo.module.common.enum.WarningTypeEnum
|
||||
import com.mogo.module.hmi.WaringConst
|
||||
import com.mogo.service.IMogoServiceApis
|
||||
import com.mogo.service.MogoServicePaths
|
||||
@@ -15,11 +16,11 @@ import com.mogo.utils.logger.Logger
|
||||
*
|
||||
* @author donghongyu
|
||||
*/
|
||||
class WarningBroadcastReceiver : BroadcastReceiver() {
|
||||
class V2XWarningBroadcastReceiver : BroadcastReceiver() {
|
||||
private var mContext: Context? = null
|
||||
|
||||
companion object {
|
||||
private const val TAG = "TestPanelBroadcastReceiver"
|
||||
private const val TAG = "V2XWarningBroadcastReceiver"
|
||||
private var mMogoServiceApis: IMogoServiceApis? = null
|
||||
private var mIMoGoWaringProvider: IMoGoWaringProvider? = null
|
||||
}
|
||||
@@ -78,6 +79,9 @@ class WarningBroadcastReceiver : BroadcastReceiver() {
|
||||
ttsContent: String?,
|
||||
tag: String?
|
||||
) {
|
||||
if (v2xType == WarningTypeEnum.WARNING_RED_LIGHT) {
|
||||
mIMoGoWaringProvider!!.showLimitingVelocity(1)
|
||||
}
|
||||
mIMoGoWaringProvider!!.showWarningV2X(
|
||||
v2xType,
|
||||
alertContent,
|
||||
@@ -13,6 +13,7 @@ import com.mogo.module.hmi.notification.anim.DefaultAnimator
|
||||
import com.mogo.module.hmi.notification.enums.SidePattern
|
||||
import com.mogo.module.hmi.ui.widget.ViewV2XNotification
|
||||
import com.mogo.module.hmi.utils.WarningUtils
|
||||
import kotlinx.android.synthetic.main.fragment_warning.*
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
@@ -98,19 +99,39 @@ class MoGoWarningFragment : MvpFragment<MoGoWarningContract.View?, WaringPresent
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示红绿灯预警
|
||||
*
|
||||
* @param checkLightId 0-都是默认,1-红,2-黄,3-绿
|
||||
*/
|
||||
override fun showWarningTrafficLight(checkLightId: Int) {
|
||||
|
||||
viewTrafficLightVr.showWarningTrafficLight(checkLightId)
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭红绿灯预警展示,并重制灯态
|
||||
*/
|
||||
override fun disableWarningTrafficLight() {
|
||||
|
||||
viewTrafficLightVr.disableWarningTrafficLight()
|
||||
}
|
||||
|
||||
/**
|
||||
* 控制展示限速标志及内容
|
||||
*/
|
||||
override fun showLimitingVelocity(limitingSpeed: Int) {
|
||||
|
||||
tvLimitingVelocity.visibility = View.VISIBLE
|
||||
if (limitingSpeed > 0) {
|
||||
tvLimitingVelocity.text = "$limitingSpeed"
|
||||
} else {
|
||||
tvLimitingVelocity.text = "0"
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 控制关闭限速标志及内容
|
||||
*/
|
||||
override fun disableLimitingVelocity() {
|
||||
|
||||
tvLimitingVelocity.visibility = View.GONE
|
||||
tvLimitingVelocity.text = "0"
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.mogo.module.hmi.ui.widget
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.mogo.module.hmi.R
|
||||
import kotlinx.android.synthetic.main.view_traffic_light_vr.view.*
|
||||
@@ -21,7 +22,6 @@ class ViewTrafficLight @JvmOverloads constructor(
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_traffic_light_vr, this, true)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -30,6 +30,7 @@ class ViewTrafficLight @JvmOverloads constructor(
|
||||
* @param checkLightId 0-都是默认,1-红,2-黄,3-绿
|
||||
*/
|
||||
fun showWarningTrafficLight(checkLightId: Int) {
|
||||
clTrafficLight.visibility = View.VISIBLE
|
||||
when (checkLightId) {
|
||||
0 -> {
|
||||
ctvRedTrafficLight.isChecked = false
|
||||
@@ -54,4 +55,14 @@ class ViewTrafficLight @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭红绿灯预警展示,并重制灯态
|
||||
*/
|
||||
fun disableWarningTrafficLight() {
|
||||
clTrafficLight.visibility = View.GONE
|
||||
ctvRedTrafficLight.isChecked = false
|
||||
ctvYellowTrafficLight.isChecked = false
|
||||
ctvGreenTrafficLight.isChecked = false
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
@@ -24,8 +25,10 @@
|
||||
android:text="60"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="74px"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="@+id/viewTrafficLightVr"
|
||||
app:layout_constraintTop_toBottomOf="@+id/viewTrafficLightVr" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/viewTrafficLightVr"
|
||||
tools:visibility="visible" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -9,7 +9,9 @@
|
||||
android:paddingStart="18px"
|
||||
android:paddingTop="10px"
|
||||
android:paddingEnd="18px"
|
||||
android:paddingBottom="10px">
|
||||
android:paddingBottom="10px"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<CheckedTextView
|
||||
android:id="@+id/ctvRedTrafficLight"
|
||||
|
||||
Reference in New Issue
Block a user