diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt index ce3bdb971d..970fe13bec 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt @@ -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 { + MoGoWarningContract.View { var mWarningFloat: WarningFloat.Builder? = null @@ -51,11 +52,11 @@ class MoGoHmiFragment : MvpFragment */ @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 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 } 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 override fun showWarning(direction: WarningDirectionEnum, closeTime: Long) { flV2XWarningView.showWarning(direction, closeTime) } + + /** + * 展示云公告顶部弹窗 + * @param pushData + */ + override fun showNoticeForTrafficWithData(pushData: NoticePushData) { + + } + } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoWarningContract.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoWarningContract.kt index 509b63bfa2..e635cd947a 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoWarningContract.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoWarningContract.kt @@ -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) } } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-notice/src/main/AndroidManifest.xml b/core/function-impl/mogo-core-function-notice/src/main/AndroidManifest.xml index d63cdb1837..810055ae58 100644 --- a/core/function-impl/mogo-core-function-notice/src/main/AndroidManifest.xml +++ b/core/function-impl/mogo-core-function-notice/src/main/AndroidManifest.xml @@ -2,4 +2,13 @@ + + + + + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-notice/src/main/java/com/mogo/eagle/core/function/notice/NoticeProvider.java b/core/function-impl/mogo-core-function-notice/src/main/java/com/mogo/eagle/core/function/notice/NoticeProvider.java index e6c66dd357..719ea6b94f 100644 --- a/core/function-impl/mogo-core-function-notice/src/main/java/com/mogo/eagle/core/function/notice/NoticeProvider.java +++ b/core/function-impl/mogo-core-function-notice/src/main/java/com/mogo/eagle/core/function/notice/NoticeProvider.java @@ -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) { + + } } diff --git a/core/function-impl/mogo-core-function-notice/src/main/java/com/mogo/eagle/core/function/notice/NoticeSocketManager.java b/core/function-impl/mogo-core-function-notice/src/main/java/com/mogo/eagle/core/function/notice/NoticeSocketManager.java index 343e92c9c1..e41325071b 100644 --- a/core/function-impl/mogo-core-function-notice/src/main/java/com/mogo/eagle/core/function/notice/NoticeSocketManager.java +++ b/core/function-impl/mogo-core-function-notice/src/main/java/com/mogo/eagle/core/function/notice/NoticeSocketManager.java @@ -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); } } } diff --git a/core/function-impl/mogo-core-function-notice/src/main/java/com/mogo/eagle/core/function/notice/test/TestNoticeBroadcastReceiver.java b/core/function-impl/mogo-core-function-notice/src/main/java/com/mogo/eagle/core/function/notice/test/TestNoticeBroadcastReceiver.java new file mode 100644 index 0000000000..204382c0ff --- /dev/null +++ b/core/function-impl/mogo-core-function-notice/src/main/java/com/mogo/eagle/core/function/notice/test/TestNoticeBroadcastReceiver.java @@ -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); + } + } + +} diff --git a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/notice/NoticePushData.java b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/notice/NoticePushData.java new file mode 100644 index 0000000000..a69215dcc5 --- /dev/null +++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/notice/NoticePushData.java @@ -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 + '\'' + + '}'; + } +} diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/notice/IMoGoNoticeProvider.java b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/notice/IMoGoNoticeProvider.java index 59ec7f1081..20d56e44f2 100644 --- a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/notice/IMoGoNoticeProvider.java +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/notice/IMoGoNoticeProvider.java @@ -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); } diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/hmi/CallerHmiManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/hmi/CallerHmiManager.kt index d2124e78b4..dde11c55d2 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/hmi/CallerHmiManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/hmi/CallerHmiManager.kt @@ -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) + } + } \ No newline at end of file diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/notice/CallerNoticeManager.java b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/notice/CallerNoticeManager.java index 03094b70e2..57566c26b9 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/notice/CallerNoticeManager.java +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/notice/CallerNoticeManager.java @@ -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 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); - } + }