[add] 1.添加push推送数据体bean 2.添加caller调hmi UI调起流程相关java类文件

This commit is contained in:
liujing
2021-10-28 20:09:04 +08:00
parent f1be75c2f6
commit f4e5949b4e
10 changed files with 224 additions and 73 deletions

View File

@@ -9,6 +9,7 @@ import android.view.animation.OvershootInterpolator
import com.mogo.commons.mvp.MvpFragment
import com.mogo.commons.voice.AIAssist
import com.mogo.eagle.core.data.enums.WarningDirectionEnum
import com.mogo.eagle.core.data.notice.NoticePushData
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.function.hmi.notification.WarningFloat
@@ -25,7 +26,7 @@ import kotlinx.android.synthetic.main.fragment_hmi.*
* 预警图层
*/
class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>(),
MoGoWarningContract.View {
MoGoWarningContract.View {
var mWarningFloat: WarningFloat.Builder? = null
@@ -51,11 +52,11 @@ class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>
*/
@Synchronized
override fun showWarningV2X(
v2xType: Int,
alertContent: String?,
ttsContent: String?,
tag: String?,
listenerIMoGo: IMoGoWarningStatusListener?
v2xType: Int,
alertContent: String?,
ttsContent: String?,
tag: String?,
listenerIMoGo: IMoGoWarningStatusListener?
) {
activity?.let {
@@ -64,9 +65,9 @@ class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>
notificationView.setWarningIcon(EventTypeEnum.getWarningIcon(v2xType.toString()))
notificationView.setWarningContent(
alertContent ?: EventTypeEnum.getWarningContent(
v2xType.toString()
)
alertContent ?: EventTypeEnum.getWarningContent(
v2xType.toString()
)
)
if (mWarningFloat != null && mWarningFloat!!.config.floatTag != tag) {
@@ -74,47 +75,47 @@ class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>
}
mWarningFloat = WarningFloat.with(it)
.setTag(tag)
.setLayout(notificationView)
.setSidePattern(SidePattern.TOP)
.setCountDownTime(5000)
.setGravity(Gravity.CENTER_HORIZONTAL, offsetY = 110)
.setImmersionStatusBar(true)
.addWarningStatusListener(listenerIMoGo)
.addWarningStatusListener(object : IMoGoWarningStatusListener {
override fun onShow() {
// 创建弹窗成功才进行TTS播报
Logger.d(
"MoGoWarningFragment",
"mWarningFloat = $mWarningFloat---ttsContent = $ttsContent"
)
if (mWarningFloat != null && !TextUtils.isEmpty(ttsContent)) {
Logger.d("MoGoWarningFragment", "---> ttsContent = $ttsContent")
AIAssist.getInstance(activity)
.speakTTSVoice(ttsContent)
}
}
})
.setAnimator(object : DefaultAnimator() {
override fun enterAnim(
view: View,
params: WindowManager.LayoutParams,
windowManager: WindowManager,
sidePattern: SidePattern
): Animator? =
super.enterAnim(view, params, windowManager, sidePattern)?.apply {
interpolator = OvershootInterpolator()
.setTag(tag)
.setLayout(notificationView)
.setSidePattern(SidePattern.TOP)
.setCountDownTime(5000)
.setGravity(Gravity.CENTER_HORIZONTAL, offsetY = 110)
.setImmersionStatusBar(true)
.addWarningStatusListener(listenerIMoGo)
.addWarningStatusListener(object : IMoGoWarningStatusListener {
override fun onShow() {
// 创建弹窗成功才进行TTS播报
Logger.d(
"MoGoWarningFragment",
"mWarningFloat = $mWarningFloat---ttsContent = $ttsContent"
)
if (mWarningFloat != null && !TextUtils.isEmpty(ttsContent)) {
Logger.d("MoGoWarningFragment", "---> ttsContent = $ttsContent")
AIAssist.getInstance(activity)
.speakTTSVoice(ttsContent)
}
}
})
.setAnimator(object : DefaultAnimator() {
override fun enterAnim(
view: View,
params: WindowManager.LayoutParams,
windowManager: WindowManager,
sidePattern: SidePattern
): Animator? =
super.enterAnim(view, params, windowManager, sidePattern)?.apply {
interpolator = OvershootInterpolator()
}
override fun exitAnim(
view: View,
params: WindowManager.LayoutParams,
windowManager: WindowManager,
sidePattern: SidePattern
): Animator? =
super.exitAnim(view, params, windowManager, sidePattern)?.setDuration(200)
})
.show()
override fun exitAnim(
view: View,
params: WindowManager.LayoutParams,
windowManager: WindowManager,
sidePattern: SidePattern
): Animator? =
super.exitAnim(view, params, windowManager, sidePattern)?.setDuration(200)
})
.show()
}
}
@@ -205,4 +206,13 @@ class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>
override fun showWarning(direction: WarningDirectionEnum, closeTime: Long) {
flV2XWarningView.showWarning(direction, closeTime)
}
/**
* 展示云公告顶部弹窗
* @param pushData
*/
override fun showNoticeForTrafficWithData(pushData: NoticePushData) {
}
}

View File

@@ -2,6 +2,7 @@ package com.mogo.eagle.core.function.hmi.ui
import com.mogo.commons.mvp.IView
import com.mogo.eagle.core.data.enums.WarningDirectionEnum
import com.mogo.eagle.core.data.notice.NoticePushData
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
@@ -22,11 +23,11 @@ interface MoGoWarningContract {
* @param tag tag绑定弹窗的标志
*/
fun showWarningV2X(
v2xType: Int,
alertContent: String?,
ttsContent: String?,
tag: String?,
listenerIMoGo: IMoGoWarningStatusListener?
v2xType: Int,
alertContent: String?,
ttsContent: String?,
tag: String?,
listenerIMoGo: IMoGoWarningStatusListener?
)
/**
@@ -95,5 +96,11 @@ interface MoGoWarningContract {
* @param closeTime 倒计时
*/
fun showWarning(direction: WarningDirectionEnum, closeTime: Long)
/**
* 展示云公告顶部弹窗
* @param pushData
*/
fun showNoticeForTrafficWithData(pushData: NoticePushData)
}
}

View File

@@ -2,4 +2,13 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mogo.eagle.core.function.notice">
<application>
<receiver android:name=".test.TestNoticeBroadcastReceiver">
<intent-filter>
<action android:name="com.notice.test_panel_control" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
</application>
</manifest>

View File

@@ -8,7 +8,9 @@ import androidx.fragment.app.Fragment;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.eagle.core.data.constants.MogoServicePaths;
import com.mogo.eagle.core.data.notice.NoticePushData;
import com.mogo.eagle.core.function.api.notice.IMoGoNoticeProvider;
import com.mogo.eagle.core.function.call.notice.CallerNoticeManager;
import com.mogo.eagle.core.function.notice.receiver.NoticeMessageListener;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.service.cloud.socket.IMogoLifecycleListener;
@@ -51,4 +53,8 @@ public class NoticeProvider implements IMoGoNoticeProvider {
NoticeSocketManager.getInstance().registerSocketMessageListener(context);
}
@Override
public void showNoticeForTrafficWithData(NoticePushData pushData) {
}
}

View File

@@ -33,13 +33,13 @@ class NoticeSocketManager {
mContext = context;
mNoticeMessageListener = new NoticeMessageListener();
MogoApisHandler.getInstance().getApis().getSocketManagerApi(context).
registerOnMessageListener(100, mNoticeMessageListener);
registerOnMessageListener(301001, mNoticeMessageListener);
}
public void unRegisterSocketMessageListener() {
if (mNoticeMessageListener != null) {
MogoApisHandler.getInstance().getApis().getSocketManagerApi(mContext).
unregisterOnMessageListener(100, mNoticeMessageListener);
unregisterOnMessageListener(301001, mNoticeMessageListener);
}
}
}

View File

@@ -0,0 +1,42 @@
package com.mogo.eagle.core.function.notice.test;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.mogo.eagle.core.data.notice.NoticePushData;
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager;
import com.mogo.utils.logger.Logger;
/**
* @author Jing
* @description 描述
* @since: 10/28/21
*/
public class TestNoticeBroadcastReceiver extends BroadcastReceiver {
private String TAG = "notice";
private Context mContext;
@Override
public void onReceive(Context context, Intent intent) {
try {
this.mContext = context;
int sceneType = intent.getIntExtra("sceneType", 0);
Logger.d(TAG, "textPanelOpenType:" + sceneType);
// 分发场景
dispatchSceneTest(sceneType);
} catch (Exception e) {
e.printStackTrace();
}
}
private void dispatchSceneTest(int sceneType) {
if (sceneType == 301001) {
NoticePushData pushData = new NoticePushData();
pushData.setMsg("交警测试公告");
pushData.setContent("交警测试公告内容");
// CallerHmiManager.showTrafficBanner(pushData);
}
}
}

View File

@@ -0,0 +1,65 @@
package com.mogo.eagle.core.data.notice;
/**
* @author Jing
* @description 交警任务公告推送消息体
* @since: 10/28/21
*/
public class NoticePushData {
private String msg;
private String infoId;
private String imageUrl;
private String isVideo;
private String content;
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public String getInfoId() {
return infoId;
}
public void setInfoId(String infoId) {
this.infoId = infoId;
}
public String getImageUrl() {
return imageUrl;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
public String getIsVideo() {
return isVideo;
}
public void setIsVideo(String isVideo) {
this.isVideo = isVideo;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
@Override
public String toString() {
return "NoticePushData{" +
"msg='" + msg + '\'' +
", infoId='" + infoId + '\'' +
", imageUrl='" + imageUrl + '\'' +
", isVideo='" + isVideo + '\'' +
", content='" + content + '\'' +
'}';
}
}

View File

@@ -1,5 +1,6 @@
package com.mogo.eagle.core.function.api.notice;
import com.mogo.eagle.core.data.notice.NoticePushData;
import com.mogo.eagle.core.function.api.base.IMoGoFunctionProvider;
/**
@@ -9,4 +10,10 @@ import com.mogo.eagle.core.function.api.base.IMoGoFunctionProvider;
*/
public interface IMoGoNoticeProvider extends IMoGoFunctionProvider {
/**
* 呈现交警推送消息顶部弹框
*
* @param pushData 推送消息体
*/
void showNoticeForTrafficWithData(NoticePushData pushData);
}

View File

@@ -2,8 +2,10 @@ package com.mogo.eagle.core.function.call.hmi
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.data.enums.WarningDirectionEnum
import com.mogo.eagle.core.data.notice.NoticePushData
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWaringProvider
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
import com.mogo.eagle.core.function.api.notice.IMoGoNoticeProvider
import com.mogo.eagle.core.function.call.base.CallerBase
/**
@@ -16,6 +18,8 @@ object CallerHmiManager : CallerBase() {
private val waringProviderApi: IMoGoWaringProvider
get() = getApiInstance(IMoGoWaringProvider::class.java, MogoServicePaths.PATH_V2X_WARNING)
private val noticeProviderApi: IMoGoNoticeProvider
get() = getApiInstance(IMoGoNoticeProvider::class.java, MogoServicePaths.PATH_AI_NOTICE)
/**
* 展示VR下V2X预警
@@ -26,11 +30,11 @@ object CallerHmiManager : CallerBase() {
* @param tag tag绑定弹窗的标志
*/
fun showWarningV2X(
v2xType: Int,
alertContent: String?,
ttsContent: String?,
tag: String?,
listenerIMoGo: IMoGoWarningStatusListener?
v2xType: Int,
alertContent: String?,
ttsContent: String?,
tag: String?,
listenerIMoGo: IMoGoWarningStatusListener?
) {
waringProviderApi.showWarningV2X(v2xType, alertContent, ttsContent, tag, listenerIMoGo)
}
@@ -124,4 +128,13 @@ object CallerHmiManager : CallerBase() {
waringProviderApi.showWarning(direction, closeTime)
}
/**
* 呈现交通云公告弹窗(hmi)
*
* @param pushData
*/
fun showTrafficBanner(pushData: NoticePushData) {
noticeProviderApi.showNoticeForTrafficWithData(pushData)
}
}

View File

@@ -1,27 +1,19 @@
package com.mogo.eagle.core.function.call.notice;
import com.mogo.eagle.core.data.notice.NoticePushData;
import com.mogo.eagle.core.function.api.notice.IMoGoNoticeProvider;
import com.mogo.eagle.core.function.call.base.CallerBase;
import java.util.HashMap;
import static com.mogo.eagle.core.data.constants.MogoServicePaths.PATH_AI_NOTICE;
/**
* @author xiaoyuzhou
*/
public class CallerNoticeManager extends CallerBase {
private HashMap<String, IMoGoNoticeProvider> mListeners = new HashMap<>();
/**
* 添加监听者
*/
void addListener(String tag, IMoGoNoticeProvider listener) {
mListeners.put(tag, listener);
private static IMoGoNoticeProvider getNoticeProvider() {
return getApiInstance(IMoGoNoticeProvider.class, PATH_AI_NOTICE);
}
/**
* 移除监听者
*/
void removeListener(String tag) {
mListeners.remove(tag);
}
}