修复TTS逻辑并解决合并3ee50537时产生的冲突
This commit is contained in:
@@ -4,6 +4,7 @@ import android.content.Context
|
||||
import android.view.View
|
||||
import com.mogo.module.hmi.notification.enums.SidePattern
|
||||
import com.mogo.module.hmi.notification.interfaces.OnFloatAnimator
|
||||
import com.mogo.service.warning.WarningStatusListener
|
||||
import com.mogo.utils.WindowUtils
|
||||
import com.mogo.utils.logger.Logger
|
||||
|
||||
@@ -135,6 +136,13 @@ class WarningFloat {
|
||||
fun setAnimator(floatAnimator: OnFloatAnimator?) =
|
||||
apply { config.floatAnimator = floatAnimator }
|
||||
|
||||
/**
|
||||
* 设置视图状态监听;show,dismiss
|
||||
* @param listener 设置视图状态监听
|
||||
*/
|
||||
fun setWarningStatusListener(listener: WarningStatusListener?) =
|
||||
apply { config.listener = listener }
|
||||
|
||||
/**
|
||||
* 创建浮窗,包括Activity浮窗和系统浮窗,如若系统浮窗无权限,先进行权限申请
|
||||
*/
|
||||
|
||||
@@ -119,6 +119,7 @@ internal class WarningFloatWindowHelper(
|
||||
* 入场动画
|
||||
*/
|
||||
private fun enterAnim(floatingView: View) {
|
||||
config.listener?.onShow()
|
||||
if (frameLayout == null || config.isAnim) return
|
||||
enterAnimator = AnimatorManager(frameLayout!!, params, windowManager, config)
|
||||
.enterAnim()?.apply {
|
||||
@@ -157,6 +158,7 @@ internal class WarningFloatWindowHelper(
|
||||
* 退出动画
|
||||
*/
|
||||
fun exitAnim() {
|
||||
config.listener?.onDismiss()
|
||||
if (frameLayout == null || (config.isAnim && enterAnimator == null)) return
|
||||
enterAnimator?.cancel()
|
||||
val animator: Animator? =
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.mogo.module.hmi.notification.enums.ShowPattern
|
||||
import com.mogo.module.hmi.notification.enums.SidePattern
|
||||
import com.mogo.module.hmi.notification.interfaces.OnFloatAnimator
|
||||
import com.mogo.module.hmi.notification.interfaces.OnFloatCallbacks
|
||||
import com.mogo.service.warning.WarningStatusListener
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
@@ -52,6 +53,9 @@ data class WarningNotificationConfig(
|
||||
// 出入动画
|
||||
var floatAnimator: OnFloatAnimator? = DefaultAnimator(),
|
||||
|
||||
// 设置视图状态监听;show,dismiss
|
||||
var listener: WarningStatusListener? = null,
|
||||
|
||||
// Callbacks
|
||||
var callbacks: OnFloatCallbacks? = null,
|
||||
|
||||
|
||||
@@ -86,7 +86,8 @@ class V2XWarningBroadcastReceiver : BroadcastReceiver() {
|
||||
v2xType,
|
||||
alertContent,
|
||||
ttsContent,
|
||||
tag
|
||||
tag,
|
||||
null
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.mogo.module.hmi.ui
|
||||
|
||||
import com.mogo.commons.mvp.IView
|
||||
import com.mogo.module.data.enums.WarningDirectionEnum
|
||||
import com.mogo.service.warning.WarningStatusListener
|
||||
|
||||
|
||||
/**
|
||||
@@ -22,9 +23,10 @@ interface MoGoWarningContract {
|
||||
*/
|
||||
fun showWarningV2X(
|
||||
v2xType: Int,
|
||||
alertContent: String? = null,
|
||||
ttsContent: String? = null,
|
||||
tag: String? = null
|
||||
alertContent: String?,
|
||||
ttsContent: String?,
|
||||
tag: String?,
|
||||
listener: WarningStatusListener?
|
||||
)
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.mogo.module.hmi.notification.WarningFloat
|
||||
import com.mogo.module.hmi.notification.anim.DefaultAnimator
|
||||
import com.mogo.module.hmi.notification.enums.SidePattern
|
||||
import com.mogo.module.hmi.ui.widget.V2XNotificationView
|
||||
import com.mogo.service.warning.WarningStatusListener
|
||||
import com.mogo.utils.logger.Logger
|
||||
import kotlinx.android.synthetic.main.fragment_warning.*
|
||||
|
||||
@@ -51,6 +52,7 @@ class MoGoWarningFragment : MvpFragment<MoGoWarningContract.View?, WaringPresent
|
||||
alertContent: String?,
|
||||
ttsContent: String?,
|
||||
tag: String?,
|
||||
listener: WarningStatusListener?
|
||||
) {
|
||||
|
||||
activity?.let {
|
||||
@@ -75,6 +77,7 @@ class MoGoWarningFragment : MvpFragment<MoGoWarningContract.View?, WaringPresent
|
||||
//.setCountDownTime(10000)
|
||||
.setGravity(Gravity.CENTER_HORIZONTAL, offsetY = 110)
|
||||
.setImmersionStatusBar(true)
|
||||
.setWarningStatusListener(listener)
|
||||
.setAnimator(object : DefaultAnimator() {
|
||||
override fun enterAnim(
|
||||
view: View,
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.mogo.module.hmi.ui.MoGoWarningFragment;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.module.ModuleType;
|
||||
import com.mogo.service.warning.IMoGoWaringProvider;
|
||||
import com.mogo.service.warning.WarningStatusListener;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
/**
|
||||
@@ -93,8 +94,10 @@ public class MoGoWarningProvider implements IMoGoWaringProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showWarningV2X(int v2xType, @Nullable String alertContent, @Nullable String ttsContent, @Nullable String tag) {
|
||||
mMoGoWarningFragment.showWarningV2X(v2xType, alertContent, ttsContent, tag);
|
||||
public void showWarningV2X(int v2xType, @Nullable String alertContent,
|
||||
@Nullable String ttsContent, @Nullable String tag,
|
||||
@Nullable WarningStatusListener listener) {
|
||||
mMoGoWarningFragment.showWarningV2X(v2xType, alertContent, ttsContent, tag,listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.mogo.service.IMogoServiceApis
|
||||
import com.mogo.service.MogoServicePaths
|
||||
import com.mogo.service.map.IMogoMapService
|
||||
import com.mogo.service.warning.IMoGoWaringProvider
|
||||
import com.mogo.service.warning.WarningStatusListener
|
||||
import com.mogo.utils.logger.Logger
|
||||
import com.mogo.utils.storage.SharedPrefsMgr
|
||||
import com.zhidao.support.obu.MogoObuManager
|
||||
@@ -38,6 +39,7 @@ class MogoPrivateObuManager private constructor() {
|
||||
private var mIMoGoWaringProvider: IMoGoWaringProvider? = null
|
||||
private var mIMogoMapService: IMogoMapService? = null
|
||||
private var mContext: Context? = null
|
||||
private var isStrikeTts = false
|
||||
|
||||
fun init(context: Context?) {
|
||||
Logger.d(MogoObuConst.TAG_MOGO_OBU, "obuManager初始化--")
|
||||
@@ -244,23 +246,39 @@ class MogoPrivateObuManager private constructor() {
|
||||
|
||||
when (status) {
|
||||
// 添加
|
||||
ObuConstants.STATUS.ADD -> {
|
||||
//显示警告红边
|
||||
mIMoGoWaringProvider!!.showWarning(direction)
|
||||
//显示弹框,语音提示
|
||||
mIMoGoWaringProvider!!.showWarningV2X(
|
||||
appId.toInt(),
|
||||
alertContent,
|
||||
if (level == 3) ttsContent else "",
|
||||
appId
|
||||
)
|
||||
// 更新数据
|
||||
TrafficDataConvertUtils.cvxRtiThreatIndInfo2TrafficData(info)?.let {
|
||||
TrafficMarkerDrawer.updateITrafficInfo(it)
|
||||
ObuConstants.STATUS.ADD,
|
||||
ObuConstants.STATUS.UPDATE,// 更新
|
||||
-> {
|
||||
if (level == 2 || level == 3) {
|
||||
if (!isStrikeTts) {
|
||||
//显示警告红边
|
||||
mIMoGoWaringProvider!!.showWarning(direction)
|
||||
//显示弹框,语音提示
|
||||
mIMoGoWaringProvider!!.showWarningV2X(
|
||||
appId.toInt(),
|
||||
alertContent,
|
||||
ttsContent,
|
||||
appId,
|
||||
object : WarningStatusListener {
|
||||
override fun onShow() {
|
||||
isStrikeTts = true
|
||||
}
|
||||
|
||||
override fun onDismiss() {
|
||||
isStrikeTts = false
|
||||
}
|
||||
}
|
||||
)
|
||||
// 更新数据
|
||||
TrafficDataConvertUtils.cvxRtiThreatIndInfo2TrafficData(info)?.let {
|
||||
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 删除
|
||||
ObuConstants.STATUS.DELETE -> {
|
||||
isStrikeTts = false
|
||||
// 关闭警告红边
|
||||
mIMoGoWaringProvider!!.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
|
||||
// 移除顶部弹窗
|
||||
@@ -272,15 +290,6 @@ class MogoPrivateObuManager private constructor() {
|
||||
TrafficMarkerDrawer.updateITrafficInfo(it)
|
||||
}
|
||||
}
|
||||
// 更新
|
||||
else -> {
|
||||
//显示警告红边
|
||||
mIMoGoWaringProvider!!.showWarning(direction)
|
||||
// 更新数据
|
||||
TrafficDataConvertUtils.cvxRtiThreatIndInfo2TrafficData(info)?.let {
|
||||
TrafficMarkerDrawer.updateITrafficInfo(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,7 +324,7 @@ class MogoPrivateObuManager private constructor() {
|
||||
// (2) 弱势交通参与者预警信息:CVX_PTC_THREAT_IND
|
||||
override fun onCvxPtcThreatIndInfo(info: CvxPtcThreatIndInfo?) {
|
||||
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onCvxPtcInfoIndInfo ------> $info")
|
||||
info?.let {
|
||||
if (info != null) {
|
||||
Logger.d(
|
||||
MogoObuConst.TAG_MOGO_OBU,
|
||||
"onCvxPtcInfoIndInfo ---status---> ${info.status}"
|
||||
@@ -330,25 +339,42 @@ class MogoPrivateObuManager private constructor() {
|
||||
val alertContent = EventTypeEnum.getWarningContent(v2xType)
|
||||
val direction =
|
||||
getMessageDirection(if (info.ext_info != null) info.ext_info.target_classification else -1)
|
||||
val level = info.threat_info.threat_level
|
||||
|
||||
when (info.status) {
|
||||
// 添加
|
||||
ObuConstants.STATUS.ADD -> {
|
||||
// 更新数据
|
||||
TrafficDataConvertUtils.cvxPtcThreatIndInfo2TrafficData(info)?.let {
|
||||
TrafficMarkerDrawer.updateITrafficInfo(it)
|
||||
ObuConstants.STATUS.ADD,
|
||||
ObuConstants.STATUS.UPDATE// 更新
|
||||
-> {
|
||||
if (level == 2 || level == 3) {
|
||||
if (!isStrikeTts) {
|
||||
// 更新数据
|
||||
TrafficDataConvertUtils.cvxPtcThreatIndInfo2TrafficData(info)?.let {
|
||||
TrafficMarkerDrawer.updateITrafficInfo(it)
|
||||
}
|
||||
//显示警告红边
|
||||
mIMoGoWaringProvider!!.showWarning(direction)
|
||||
mIMoGoWaringProvider!!.showWarningV2X(
|
||||
v2xType.toInt(),
|
||||
alertContent,
|
||||
ttsContent,
|
||||
v2xType,
|
||||
object : WarningStatusListener {
|
||||
override fun onShow() {
|
||||
isStrikeTts = true
|
||||
}
|
||||
|
||||
override fun onDismiss() {
|
||||
isStrikeTts = false
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
//显示警告红边
|
||||
mIMoGoWaringProvider!!.showWarning(direction)
|
||||
mIMoGoWaringProvider!!.showWarningV2X(
|
||||
v2xType.toInt(),
|
||||
alertContent,
|
||||
ttsContent,
|
||||
v2xType
|
||||
)
|
||||
}
|
||||
// 删除
|
||||
ObuConstants.STATUS.DELETE -> {
|
||||
isStrikeTts = false
|
||||
// 关闭警告红边
|
||||
mIMoGoWaringProvider!!.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
|
||||
// 更新数据
|
||||
@@ -359,35 +385,27 @@ class MogoPrivateObuManager private constructor() {
|
||||
}
|
||||
mIMoGoWaringProvider?.disableWarningV2X(ObuConstants.USE_CASE_ID.VRUCW.toString())
|
||||
}
|
||||
// 更新
|
||||
else -> {
|
||||
// 显示警告红边
|
||||
mIMoGoWaringProvider!!.showWarning(direction)
|
||||
// 更新数据
|
||||
TrafficDataConvertUtils.cvxPtcThreatIndInfo2TrafficData(info)?.let {
|
||||
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// (5) 限速预警信息:CVX_SLW_THREAT_IND
|
||||
override fun onCvxSlwThreatIndInfo(info: CvxSlwThreatIndInfo?) {
|
||||
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onCvxSlwThreatIndInfo ------> $info")
|
||||
info?.let {
|
||||
if (info != null) {
|
||||
when (info.status) {
|
||||
// 添加
|
||||
ObuConstants.STATUS.ADD -> {
|
||||
ObuConstants.STATUS.ADD,
|
||||
ObuConstants.STATUS.UPDATE,
|
||||
-> {
|
||||
mIMoGoWaringProvider?.showLimitingVelocity(info.ext_info.speed_limit_max.toInt())
|
||||
}
|
||||
// 删除
|
||||
ObuConstants.STATUS.DELETE -> {
|
||||
mIMoGoWaringProvider?.disableLimitingVelocity()
|
||||
}
|
||||
// 更新
|
||||
else -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -523,7 +541,16 @@ class MogoPrivateObuManager private constructor() {
|
||||
appId,
|
||||
alertContent,
|
||||
ttsContent,
|
||||
appId.toString()
|
||||
appId.toString(),
|
||||
object : WarningStatusListener {
|
||||
override fun onShow() {
|
||||
isStrikeTts = true
|
||||
}
|
||||
|
||||
override fun onDismiss() {
|
||||
isStrikeTts = false
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
// 绿灯
|
||||
@@ -553,7 +580,16 @@ class MogoPrivateObuManager private constructor() {
|
||||
EventTypeEnum.TYPE_USECASE_ID_IVP_GREEN.poiType.toInt(),
|
||||
alertContent,
|
||||
ttsContent,
|
||||
appId.toString()
|
||||
appId.toString(),
|
||||
object : WarningStatusListener {
|
||||
override fun onShow() {
|
||||
isStrikeTts = true
|
||||
}
|
||||
|
||||
override fun onDismiss() {
|
||||
isStrikeTts = false
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
// 黄灯
|
||||
@@ -566,6 +602,7 @@ class MogoPrivateObuManager private constructor() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 构造对应展示数据和场景 根据obu的场景,add change delete确定是否展示
|
||||
*
|
||||
@@ -682,23 +719,35 @@ class MogoPrivateObuManager private constructor() {
|
||||
MogoObuConst.TAG_MOGO_OBU,
|
||||
"appId2 = $appId --- level = $level ---ttsContent = $ttsContent --- alertContent = $alertContent --- direction = $direction"
|
||||
)
|
||||
//显示警告红边
|
||||
mIMoGoWaringProvider?.showWarning(direction)
|
||||
//显示弹框,语音提示
|
||||
mIMoGoWaringProvider?.showWarningV2X(
|
||||
appId,
|
||||
alertContent,
|
||||
ttsContent,
|
||||
appId.toString()
|
||||
)
|
||||
//更新周边车辆进行预警颜色变换,车辆实时移动和变色
|
||||
TrafficDataConvertUtils.cvxV2vThreatIndInfo2TrafficData(info)?.let {
|
||||
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
|
||||
if (!isStrikeTts) {
|
||||
//显示警告红边
|
||||
mIMoGoWaringProvider?.showWarning(direction)
|
||||
//显示弹框,语音提示
|
||||
mIMoGoWaringProvider?.showWarningV2X(
|
||||
appId,
|
||||
alertContent,
|
||||
ttsContent,
|
||||
appId.toString(),
|
||||
object : WarningStatusListener {
|
||||
override fun onShow() {
|
||||
isStrikeTts = true
|
||||
}
|
||||
|
||||
override fun onDismiss() {
|
||||
isStrikeTts = false
|
||||
}
|
||||
}
|
||||
)
|
||||
//更新周边车辆进行预警颜色变换,车辆实时移动和变色
|
||||
TrafficDataConvertUtils.cvxV2vThreatIndInfo2TrafficData(info)?.let {
|
||||
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 删除
|
||||
ObuConstants.STATUS.DELETE -> {
|
||||
isStrikeTts = false
|
||||
// 关闭警告红边
|
||||
mIMoGoWaringProvider!!.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
|
||||
// 移除顶部弹窗
|
||||
|
||||
@@ -20,7 +20,8 @@ interface IMoGoWaringProvider : IMogoModuleProvider {
|
||||
v2xType: Int,
|
||||
alertContent: String?,
|
||||
ttsContent: String?,
|
||||
tag: String?
|
||||
tag: String?,
|
||||
listener:WarningStatusListener?
|
||||
)
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.mogo.service.warning;
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
* @date 2021/9/13 4:41 下午
|
||||
*/
|
||||
public interface WarningStatusListener {
|
||||
void onShow();
|
||||
void onDismiss();
|
||||
}
|
||||
Reference in New Issue
Block a user