From c2abe34d00de0eb6ee1d34253018f78e72aaacd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=91=A3=E5=AE=8F=E5=AE=87?= Date: Wed, 4 Aug 2021 18:12:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E8=B0=83=E7=94=A8=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=B0=81=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/misc.xml | 2 +- .../src/main/AndroidManifest.xml | 10 ++ .../module/warning/MoGoWarningProvider.java | 35 ++++++- .../com/mogo/module/warning/WaringConst.java | 2 +- .../mogo/module/warning/WarningTypeEnum.java | 76 ++++++++++++++++ ...r.java => WarningNotificationManager.java} | 2 +- .../receiver/TestObuBroadcastReceiver.java | 46 ---------- .../TestWarningBroadcastReceiver.java | 91 +++++++++++++++++++ .../module/warning/ui/MoGoWarningContract.kt | 54 +++++++++++ .../module/warning/ui/MoGoWarningFragment.kt | 33 ++++++- .../module/warning/ui/ViewTrafficLight.kt | 57 ++++++++++++ .../mogo/module/warning/ui/WaringPresenter.kt | 35 +++++-- .../mogo/module/warning/ui/WaringView.java | 10 -- .../src/main/res/layout/fragment_warning.xml | 11 +-- .../main/res/layout/view_traffic_light_vr.xml | 20 ++-- services/mogo-service-api/build.gradle | 18 +++- .../com/mogo/service/MogoServicePaths.java | 2 + .../service/warning/IMoGoWaringProvider.kt | 38 +++++++- 18 files changed, 447 insertions(+), 95 deletions(-) create mode 100644 modules/mogo-module-warning/src/main/java/com/mogo/module/warning/WarningTypeEnum.java rename modules/mogo-module-warning/src/main/java/com/mogo/module/warning/notification/{NotificationManager.java => WarningNotificationManager.java} (94%) delete mode 100644 modules/mogo-module-warning/src/main/java/com/mogo/module/warning/receiver/TestObuBroadcastReceiver.java create mode 100644 modules/mogo-module-warning/src/main/java/com/mogo/module/warning/receiver/TestWarningBroadcastReceiver.java create mode 100644 modules/mogo-module-warning/src/main/java/com/mogo/module/warning/ui/MoGoWarningContract.kt create mode 100644 modules/mogo-module-warning/src/main/java/com/mogo/module/warning/ui/ViewTrafficLight.kt delete mode 100644 modules/mogo-module-warning/src/main/java/com/mogo/module/warning/ui/WaringView.java diff --git a/.idea/misc.xml b/.idea/misc.xml index 76becce96e..20108f78c7 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -27,7 +27,7 @@ - + diff --git a/modules/mogo-module-warning/src/main/AndroidManifest.xml b/modules/mogo-module-warning/src/main/AndroidManifest.xml index e89b92d70a..a0f87e6503 100644 --- a/modules/mogo-module-warning/src/main/AndroidManifest.xml +++ b/modules/mogo-module-warning/src/main/AndroidManifest.xml @@ -2,4 +2,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/MoGoWarningProvider.java b/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/MoGoWarningProvider.java index ec1f124221..cfc25ed5fe 100644 --- a/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/MoGoWarningProvider.java +++ b/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/MoGoWarningProvider.java @@ -4,11 +4,13 @@ import android.content.Context; import android.os.Bundle; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import com.alibaba.android.arouter.facade.annotation.Route; import com.mogo.module.warning.ui.MoGoWarningFragment; import com.mogo.service.MogoServicePaths; +import com.mogo.service.module.ModuleType; import com.mogo.service.warning.IMoGoWaringProvider; import com.mogo.utils.logger.Logger; @@ -21,16 +23,18 @@ import com.mogo.utils.logger.Logger; public class MoGoWarningProvider implements IMoGoWaringProvider { private String TAG = "MoGoWarningProvider"; + private MoGoWarningFragment mMoGoWarningFragment; + @Override public void init(Context context) { Logger.d(TAG, "初始化蘑菇预警模块 ……"); - } @Override public Fragment createFragment(Context context, Bundle data) { Logger.d(TAG, "初始化蘑菇预警模块 Fragment……"); - return new MoGoWarningFragment(); + mMoGoWarningFragment = new MoGoWarningFragment(); + return mMoGoWarningFragment; } @NonNull @@ -41,6 +45,31 @@ public class MoGoWarningProvider implements IMoGoWaringProvider { @Override public int getType() { - return 0; + return ModuleType.TYPE_CARD_FRAGMENT; + } + + @Override + public void showWarningV2X(int v2xType, @Nullable String alertMessage) { + mMoGoWarningFragment.showWarningV2X(v2xType, alertMessage); + } + + @Override + public void showWarningTrafficLight(int checkLightId) { + mMoGoWarningFragment.showWarningTrafficLight(checkLightId); + } + + @Override + public void disableWarningTrafficLight() { + mMoGoWarningFragment.disableWarningTrafficLight(); + } + + @Override + public void showLimitingVelocity(int limitingSpeed) { + mMoGoWarningFragment.showLimitingVelocity(limitingSpeed); + } + + @Override + public void disableLimitingVelocity() { + mMoGoWarningFragment.disableLimitingVelocity(); } } diff --git a/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/WaringConst.java b/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/WaringConst.java index e0c44c00fb..7e9649e55d 100644 --- a/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/WaringConst.java +++ b/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/WaringConst.java @@ -7,6 +7,6 @@ package com.mogo.module.warning; public class WaringConst { public static String MODULE_NAME = "MODULE_LEFT_PANEL"; - public static String BROADCAST_TEST_CONTROL_TYPE_EXTRA_KEY = "waring_type"; + public static String BROADCAST_TEST_CONTROL_TYPE_EXTRA_KEY = "warningType"; } diff --git a/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/WarningTypeEnum.java b/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/WarningTypeEnum.java new file mode 100644 index 0000000000..4590b1725e --- /dev/null +++ b/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/WarningTypeEnum.java @@ -0,0 +1,76 @@ +package com.mogo.module.warning; + +/** + * author : donghongyu + * e-mail : 1358506549@qq.com + * date : 2020-01-1514:47 + * desc : 车机启动状态 + * version: 1.0 + */ +public interface WarningTypeEnum { + + /** + * 前向碰撞 + */ + int WARING_TYPE_PRIOR_COLLISION = 20001; + /** + * 交叉路口碰撞 + */ + int WARING_TYPE_INTERSECTION_COLLISION = 20002; + /** + * 左转辅助 + */ + int WARING_TYPE_LEFT_AUXILIARY = 20003; + /** + * 盲区/变道辅助 + */ + int WARING_TYPE_BLIND_AREA_COLLISION = 20004; + /** + * 逆向超车 + */ + int WARING_TYPE_REVERSE_OVERTAKING = 20005; + /** + * 紧急制动-前车急刹 + */ + int WARING_TYPE_VEHICLE_BRAKES = 20006; + /** + * 异常车辆提醒 + */ + int WARING_TYPE_ABNORMAL_VEHICLE = 20007; + /** + * 车辆失控预警 + */ + int WARING_TYPE_VEHICLE_CONTROL = 20008; + /** + * 道路危险情况预警 + */ + int WARING_TYPE_ROAD_HAZARDS = 20009; + /** + * 限速预警 + */ + int WARING_TYPE_SPEED_LIMIT = 20010; + /** + * 闯红灯预警 + */ + int WARING_TYPE_RED_LIGHT = 20011; + /** + * 弱势交通参与者预警 + */ + int WARING_TYPE_VULNERABLE_TRANSPORT_PARTICIPANT = 20012; + /** + * 绿波通行车速引导 + */ + int WARING_TYPE_TRAFFIC_SPEED_GUIDE = 20013; + /** + * 车内标牌 + */ + int WARING_TYPE_CAR_PLATE = 20014; + /** + * 前方道路拥堵 + */ + int WARING_TYPE_TRAFFIC_JAM_AHEAD = 20015; + /** + * 特种车辆通行 + */ + int WARING_TYPE_SPECIAL_VEHICLE_ACCESS = 20016; +} \ No newline at end of file diff --git a/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/notification/NotificationManager.java b/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/notification/WarningNotificationManager.java similarity index 94% rename from modules/mogo-module-warning/src/main/java/com/mogo/module/warning/notification/NotificationManager.java rename to modules/mogo-module-warning/src/main/java/com/mogo/module/warning/notification/WarningNotificationManager.java index 9b918c1dbc..fd8cfedaa4 100644 --- a/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/notification/NotificationManager.java +++ b/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/notification/WarningNotificationManager.java @@ -13,7 +13,7 @@ import com.mogo.module.warning.R; * @date 2021/8/3 5:50 下午 * 通知管理 */ -public class NotificationManager { +public class WarningNotificationManager { public static void show(Activity activity) { diff --git a/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/receiver/TestObuBroadcastReceiver.java b/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/receiver/TestObuBroadcastReceiver.java deleted file mode 100644 index 4512e128c0..0000000000 --- a/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/receiver/TestObuBroadcastReceiver.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.mogo.module.warning.receiver; - - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; - -import com.mogo.module.warning.WaringConst; -import com.mogo.utils.logger.Logger; - -/** - * V2X 测试面板广播接收,目的是可以通过广播调用起来面板 - * - * @author donghongyu - */ -public class TestObuBroadcastReceiver extends BroadcastReceiver { - private static final String TAG = "TestPanelBroadcastReceiver"; - - private Context mContext; - - @Override - public void onReceive(Context context, Intent intent) { - try { - this.mContext = context; - int waringType = intent.getIntExtra(WaringConst.BROADCAST_TEST_CONTROL_TYPE_EXTRA_KEY, 0); - Logger.d(TAG, "waringType:" + waringType); - - // 分发场景 - dispatchSceneTest(waringType); - } catch (Exception e) { - e.printStackTrace(); - } - } - - - /** - * 分发处理场景 - * - * @param sceneType 场景类型 - */ - private void dispatchSceneTest(int sceneType) { - Logger.d(TAG, "sceneType=" + sceneType); - - } - -} diff --git a/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/receiver/TestWarningBroadcastReceiver.java b/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/receiver/TestWarningBroadcastReceiver.java new file mode 100644 index 0000000000..485870f185 --- /dev/null +++ b/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/receiver/TestWarningBroadcastReceiver.java @@ -0,0 +1,91 @@ +package com.mogo.module.warning.receiver; + + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; + +import com.alibaba.android.arouter.launcher.ARouter; +import com.mogo.module.warning.WaringConst; +import com.mogo.module.warning.WarningTypeEnum; +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 + */ +public class TestWarningBroadcastReceiver extends BroadcastReceiver { + private static final String TAG = "TestPanelBroadcastReceiver"; + + private Context mContext; + private static IMogoServiceApis mMogoServiceApis; + private static IMoGoWaringProvider mIMoGoWaringProvider; + + @Override + public void onReceive(Context context, Intent intent) { + try { + mMogoServiceApis = (IMogoServiceApis) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(context); + mIMoGoWaringProvider = mMogoServiceApis.getWaringProviderApi(); + + this.mContext = context; + int warningType = intent.getIntExtra(WaringConst.BROADCAST_TEST_CONTROL_TYPE_EXTRA_KEY, 0); + Logger.d(TAG, "warningType:" + warningType); + + // 分发场景 + dispatchWaring(warningType); + } catch (Exception e) { + e.printStackTrace(); + } + } + + + /** + * 分发处理场景 + * + * @param warningType 场景类型 + */ + private void dispatchWaring(int warningType) { + + mIMoGoWaringProvider.showWarningV2X(warningType, "预警消息"); + + switch (warningType) { + case WarningTypeEnum.WARING_TYPE_PRIOR_COLLISION://前向碰撞 + break; + case WarningTypeEnum.WARING_TYPE_INTERSECTION_COLLISION://交叉路口碰撞 + break; + case WarningTypeEnum.WARING_TYPE_LEFT_AUXILIARY://左转辅助 + break; + case WarningTypeEnum.WARING_TYPE_BLIND_AREA_COLLISION://盲区/变道辅助 + break; + case WarningTypeEnum.WARING_TYPE_REVERSE_OVERTAKING://逆向超车 + break; + case WarningTypeEnum.WARING_TYPE_VEHICLE_BRAKES://紧急制动-前车急刹 + break; + case WarningTypeEnum.WARING_TYPE_ABNORMAL_VEHICLE://异常车辆提醒 + break; + case WarningTypeEnum.WARING_TYPE_VEHICLE_CONTROL://车辆失控预警 + break; + case WarningTypeEnum.WARING_TYPE_ROAD_HAZARDS://道路危险情况提示 + break; + case WarningTypeEnum.WARING_TYPE_SPEED_LIMIT://限速预警 + break; + case WarningTypeEnum.WARING_TYPE_RED_LIGHT://闯红灯预警 + break; + case WarningTypeEnum.WARING_TYPE_VULNERABLE_TRANSPORT_PARTICIPANT://弱势交通参与者 + break; + case WarningTypeEnum.WARING_TYPE_TRAFFIC_SPEED_GUIDE://绿波通行车速引导 + break; + case WarningTypeEnum.WARING_TYPE_CAR_PLATE://车内标牌 + break; + case WarningTypeEnum.WARING_TYPE_TRAFFIC_JAM_AHEAD://前方道路拥堵 + break; + case WarningTypeEnum.WARING_TYPE_SPECIAL_VEHICLE_ACCESS://紧急车辆提醒(特种车辆优先通行) + break; + } + } + +} diff --git a/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/ui/MoGoWarningContract.kt b/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/ui/MoGoWarningContract.kt new file mode 100644 index 0000000000..34f96814f4 --- /dev/null +++ b/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/ui/MoGoWarningContract.kt @@ -0,0 +1,54 @@ +package com.mogo.module.warning.ui + +import com.mogo.commons.mvp.IView + + +/** + *@author xiaoyuzhou + *@date 2021/8/4 3:38 下午 + */ +interface MoGoWarningContract { + + + /** + * + */ + interface View : IView { + /** + * 展示VR下V2X预警弹窗 + * + * @param v2xType V2X类型 + * @param alertMessage 提醒文本 + */ + fun showWarningV2X(v2xType: Int, alertMessage: String?) + + /** + * 关闭VR下V2X预警弹窗 + */ + fun disableWarningV2X() + + /** + * 展示红绿灯预警 + * + * @param checkLightId 0-都是默认,1-红,2-黄,3-绿 + */ + fun showWarningTrafficLight(checkLightId: Int) + + /** + * 关闭红绿灯预警 + */ + fun disableWarningTrafficLight() + + /** + * 展示限速预警 + * + * @param limitingSpeed 限速速度 + */ + fun showLimitingVelocity(limitingSpeed: Int) + + /** + * 关闭限速预警 + */ + fun disableLimitingVelocity() + } +} \ No newline at end of file diff --git a/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/ui/MoGoWarningFragment.kt b/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/ui/MoGoWarningFragment.kt index d1bd10ae4a..48fa14fe68 100644 --- a/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/ui/MoGoWarningFragment.kt +++ b/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/ui/MoGoWarningFragment.kt @@ -2,18 +2,47 @@ package com.mogo.module.warning.ui import com.mogo.commons.mvp.MvpFragment import com.mogo.module.warning.R +import com.mogo.module.warning.notification.WarningNotificationManager /** * @author xiaoyuzhou * @date 2021/8/3 2:40 下午 + * 预警图层 */ -class MoGoWarningFragment : MvpFragment(), WaringView { +class MoGoWarningFragment : MvpFragment(), + MoGoWarningContract.View { + + override fun initViews() {} + override fun getLayoutId(): Int { return R.layout.fragment_warning } - override fun initViews() {} override fun createPresenter(): WaringPresenter { return WaringPresenter(this) } + + override fun showWarningV2X(v2xType: Int, alertMessage: String?) { + WarningNotificationManager.show(activity) + } + + override fun disableWarningV2X() { + + } + + override fun showWarningTrafficLight(checkLightId: Int) { + + } + + override fun disableWarningTrafficLight() { + + } + + override fun showLimitingVelocity(limitingSpeed: Int) { + + } + + override fun disableLimitingVelocity() { + + } } \ No newline at end of file diff --git a/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/ui/ViewTrafficLight.kt b/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/ui/ViewTrafficLight.kt new file mode 100644 index 0000000000..6d3c4f5152 --- /dev/null +++ b/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/ui/ViewTrafficLight.kt @@ -0,0 +1,57 @@ +package com.mogo.module.warning.ui + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import androidx.constraintlayout.widget.ConstraintLayout +import com.mogo.module.warning.R +import kotlinx.android.synthetic.main.view_traffic_light_vr.view.* + +/** + * @author xiaoyuzhou + * @date 2021/8/4 3:16 下午 + * 红绿灯控件 + */ +class ViewTrafficLight @JvmOverloads constructor( + context: Context?, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : ConstraintLayout(context, attrs, defStyleAttr) { + + + init { + LayoutInflater.from(context).inflate(R.layout.view_traffic_light_vr, this, true) + + } + + /** + * 展示红绿灯预警 + * + * @param checkLightId 0-都是默认,1-红,2-黄,3-绿 + */ + fun showWarningTrafficLight(checkLightId: Int) { + when (checkLightId) { + 0 -> { + ctvRedTrafficLight.isChecked = false + ctvYellowTrafficLight.isChecked = false + ctvGreenTrafficLight.isChecked = false + } + 1 -> { + ctvRedTrafficLight.isChecked = true + ctvYellowTrafficLight.isChecked = false + ctvGreenTrafficLight.isChecked = false + } + 2 -> { + ctvRedTrafficLight.isChecked = false + ctvYellowTrafficLight.isChecked = true + ctvGreenTrafficLight.isChecked = false + } + 3 -> { + ctvRedTrafficLight.isChecked = false + ctvYellowTrafficLight.isChecked = false + ctvGreenTrafficLight.isChecked = true + } + } + } + +} \ No newline at end of file diff --git a/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/ui/WaringPresenter.kt b/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/ui/WaringPresenter.kt index 13d0bb7946..16750d69ab 100644 --- a/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/ui/WaringPresenter.kt +++ b/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/ui/WaringPresenter.kt @@ -1,13 +1,36 @@ -package com.mogo.module.warning.ui; +package com.mogo.module.warning.ui -import com.mogo.commons.mvp.Presenter; +import com.mogo.commons.mvp.Presenter /** * @author xiaoyuzhou * @date 2021/8/3 3:55 下午 */ -public class WaringPresenter extends Presenter< WaringView > { - public WaringPresenter(WaringView view) { - super(view); +class WaringPresenter(view: MoGoWarningContract.View?) : + Presenter(view) { + + + fun showWarningV2X(v2xType: Int, alertMessage: String?) { + mView?.showWarningV2X(v2xType, alertMessage) } -} + + fun disableWarningV2X() { + mView?.disableWarningV2X() + } + + fun showWarningTrafficLight(checkLightId: Int) { + mView?.showWarningTrafficLight(checkLightId) + } + + fun disableWarningTrafficLight() { + mView?.disableWarningTrafficLight() + } + + fun showLimitingVelocity(limitingSpeed: Int) { + mView?.showLimitingVelocity(limitingSpeed) + } + + fun disableLimitingVelocity() { + mView?.disableLimitingVelocity() + } +} \ No newline at end of file diff --git a/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/ui/WaringView.java b/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/ui/WaringView.java deleted file mode 100644 index dfa76a712b..0000000000 --- a/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/ui/WaringView.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.mogo.module.warning.ui; - -import com.mogo.commons.mvp.IView; - -/** - * @author xiaoyuzhou - * @date 2021/8/3 3:54 下午 - */ -public interface WaringView extends IView { -} diff --git a/modules/mogo-module-warning/src/main/res/layout/fragment_warning.xml b/modules/mogo-module-warning/src/main/res/layout/fragment_warning.xml index 585d74b261..6ad1a10710 100644 --- a/modules/mogo-module-warning/src/main/res/layout/fragment_warning.xml +++ b/modules/mogo-module-warning/src/main/res/layout/fragment_warning.xml @@ -5,9 +5,8 @@ android:layout_height="match_parent"> - + app:layout_constraintEnd_toEndOf="@+id/viewTrafficLightVr" + app:layout_constraintTop_toBottomOf="@+id/viewTrafficLightVr" /> \ No newline at end of file diff --git a/modules/mogo-module-warning/src/main/res/layout/view_traffic_light_vr.xml b/modules/mogo-module-warning/src/main/res/layout/view_traffic_light_vr.xml index 0df599ce8a..193027f234 100644 --- a/modules/mogo-module-warning/src/main/res/layout/view_traffic_light_vr.xml +++ b/modules/mogo-module-warning/src/main/res/layout/view_traffic_light_vr.xml @@ -2,7 +2,7 @@ + app:layout_constraintTop_toTopOf="parent" + tools:checked="true" + tools:text="99" />