diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 4ff10f68a5..83405b8de1 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -91,7 +91,6 @@ diff --git a/app/src/main/java/com/mogo/launcher/MogoApplication.java b/app/src/main/java/com/mogo/launcher/MogoApplication.java index 2266035c7a..dbea2f06fd 100644 --- a/app/src/main/java/com/mogo/launcher/MogoApplication.java +++ b/app/src/main/java/com/mogo/launcher/MogoApplication.java @@ -105,6 +105,7 @@ public class MogoApplication extends AbsMogoApplication { // 小地图模块 MogoModulePaths.addModule( new MogoModule( MogoServicePaths.PATH_SMALL_MAP, "IMogoSmallMapProvider" ) ); + MogoModulePaths.addModule( new MogoModule( MogoServicePaths.PATH_V2X_FRONT_CRASH_WARNING, "IV2XManagerProvider" ) ); MogoModulePaths.addBaseModule( new MogoModule( MogoServicePaths.PATH_GLOBAL_UNWAKE, "GlobalUnwake" ) ); diff --git a/main-extensions/mogo-module-main-launcher/build.gradle b/main-extensions/mogo-module-main-launcher/build.gradle index 3de4bf61cd..efd300157a 100644 --- a/main-extensions/mogo-module-main-launcher/build.gradle +++ b/main-extensions/mogo-module-main-launcher/build.gradle @@ -43,9 +43,11 @@ dependencies { if (Boolean.valueOf(RELEASE)) { api rootProject.ext.dependencies.modulemain implementation rootProject.ext.dependencies.mogooch + implementation rootProject.ext.dependencies.moduleservice } else { api project(":modules:mogo-module-main") implementation project(":OCH:mogo-och") + implementation project(':modules:mogo-module-service') } } diff --git a/main-extensions/mogo-module-main-launcher/src/main/java/com/zhidao/mogo/module/main/launcher/MainLauncherActivity.java b/main-extensions/mogo-module-main-launcher/src/main/java/com/zhidao/mogo/module/main/launcher/MainLauncherActivity.java index 9cccae807c..77a83e18e8 100644 --- a/main-extensions/mogo-module-main-launcher/src/main/java/com/zhidao/mogo/module/main/launcher/MainLauncherActivity.java +++ b/main-extensions/mogo-module-main-launcher/src/main/java/com/zhidao/mogo/module/main/launcher/MainLauncherActivity.java @@ -4,6 +4,7 @@ import android.content.Intent; import android.os.Bundle; import android.os.Process; import android.text.TextUtils; +import android.util.Log; import android.view.View; import android.widget.FrameLayout; @@ -13,26 +14,37 @@ import com.alibaba.android.arouter.launcher.ARouter; import com.mogo.commons.debug.DebugConfig; import com.mogo.map.uicontroller.EnumMapUI; import com.mogo.module.common.MogoApisHandler; +import com.mogo.module.common.entity.V2XMessageEntity; import com.mogo.module.main.MainActivity; import com.mogo.module.main.cards.MogoModulesManager; +import com.mogo.module.service.receiver.MogoReceiver; import com.mogo.och.IMogoOCH; import com.mogo.service.intent.IMogoIntentListener; import com.mogo.service.statusmanager.IMogoStatusChangedListener; import com.mogo.service.statusmanager.StatusDescriptor; +import com.mogo.service.v2x.IV2XListener; import com.mogo.utils.logger.Logger; +import static com.mogo.module.common.entity.V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_BOTTOM; +import static com.mogo.module.common.entity.V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_LEFT; +import static com.mogo.module.common.entity.V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_RIGHT; +import static com.mogo.module.common.entity.V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_TOP; + /** * 针对作为Launcher的情况,做个性化操作 * * @author tongchenfei */ -public class MainLauncherActivity extends MainActivity implements IMogoIntentListener, IMogoStatusChangedListener { +public class MainLauncherActivity extends MainActivity implements IMogoIntentListener, IMogoStatusChangedListener, IV2XListener { private static final String TAG = "MainLauncherActivity"; protected boolean mIsHomeKeyDown = false; + @Override - protected void onCreate( @Nullable Bundle savedInstanceState ) { - super.onCreate( savedInstanceState ); - DebugConfig.setNeedRequestUserInfo( true ); + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + DebugConfig.setNeedRequestUserInfo(true); + Log.d(TAG, "onCreate"); + mServiceApis.getV2XListenerManager().registerIntentListener(MogoReceiver.ACTION_V2X_FRONT_WARNING,this); mServiceApis.getStatusManagerApi().registerStatusChangedListener(TAG, StatusDescriptor.VR_MODE, this); } @@ -43,10 +55,10 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis // 显示左边遮罩 if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) { mLeftShadowFrame.setVisibility(View.GONE); - }else { + } else { mLeftShadowFrame.setVisibility(View.VISIBLE); } - MogoModulesManager.getInstance().loadAppsListModule( com.mogo.module.main.R.id.module_main_id_apps_fragment_container ); + MogoModulesManager.getInstance().loadAppsListModule(com.mogo.module.main.R.id.module_main_id_apps_fragment_container); } @Override @@ -57,21 +69,21 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis @Override protected void hideLayout() { super.hideLayout(); - mApps.setVisibility( View.GONE ); - mLeftShadowFrame.setVisibility( View.GONE ); + mApps.setVisibility(View.GONE); + mLeftShadowFrame.setVisibility(View.GONE); } @Override protected void showLayout() { super.showLayout(); - mApps.setVisibility( View.VISIBLE ); - mLeftShadowFrame.setVisibility( View.VISIBLE ); + mApps.setVisibility(View.VISIBLE); + mLeftShadowFrame.setVisibility(View.VISIBLE); } @Override protected void onStart() { super.onStart(); - getApis().getIntentManagerApi().registerIntentListener( Intent.ACTION_CLOSE_SYSTEM_DIALOGS, this ); + getApis().getIntentManagerApi().registerIntentListener(Intent.ACTION_CLOSE_SYSTEM_DIALOGS, this); } @Override @@ -83,13 +95,13 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis @Override protected void onStop() { super.onStop(); - getApis().getIntentManagerApi().unregisterIntentListener( Intent.ACTION_CLOSE_SYSTEM_DIALOGS, this ); + getApis().getIntentManagerApi().unregisterIntentListener(Intent.ACTION_CLOSE_SYSTEM_DIALOGS, this); } @Override - public void onIntentReceived( String intentStr, Intent intent ) { - if ( TextUtils.equals( Intent.ACTION_CLOSE_SYSTEM_DIALOGS, intentStr ) ) { - mIsHomeKeyDown = intent.getBooleanExtra( "isHomeKeyDown", true ); + public void onIntentReceived(String intentStr, Intent intent) { + if (TextUtils.equals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS, intentStr)) { + mIsHomeKeyDown = intent.getBooleanExtra("isHomeKeyDown", true); } } @@ -107,10 +119,10 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis /** * 加载网约车模块 */ - private void loadOCHModule(){ - IMogoOCH och = ARouter.getInstance().navigation( IMogoOCH.class ); - if ( och != null ) { - och.init( this, R.id.module_main_id_och_fragment ); + private void loadOCHModule() { + IMogoOCH och = ARouter.getInstance().navigation(IMogoOCH.class); + if (och != null) { + och.init(this, R.id.module_main_id_och_fragment); } } @@ -119,40 +131,75 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis super.onDestroy(); mServiceApis.getStatusManagerApi().unregisterStatusChangedListener(TAG, StatusDescriptor.VR_MODE, this); + mServiceApis.getV2XListenerManager().unregisterIntentListener(TAG,this); try { // acc off 之后会出现进程还在,但是页面被杀的情况,这个直接杀掉进程,然后让整个进程重启 - Process.killProcess( Process.myPid() ); - } catch ( Exception e ) { + Process.killProcess(Process.myPid()); + } catch (Exception e) { e.printStackTrace(); } } @Override - public void onMapUiModeChanged( EnumMapUI mapUI ) { - super.onMapUiModeChanged( mapUI ); - Intent intent = new Intent( "com.mogo.style.SKIN_CHANGED" ); - intent.putExtra( "type", -1 ); - if ( mapUI == EnumMapUI.Type_Light ) { - intent.putExtra( "type", 1 ); - } else if( mapUI == EnumMapUI.Type_Night ){ - intent.putExtra( "type", 0 ); + public void onMapUiModeChanged(EnumMapUI mapUI) { + super.onMapUiModeChanged(mapUI); + Intent intent = new Intent("com.mogo.style.SKIN_CHANGED"); + intent.putExtra("type", -1); + if (mapUI == EnumMapUI.Type_Light) { + intent.putExtra("type", 1); + } else if (mapUI == EnumMapUI.Type_Night) { + intent.putExtra("type", 0); } - sendBroadcast( intent ); - Logger.d( TAG, "send msg to AI Voice" ); + sendBroadcast(intent); + Logger.d(TAG, "send msg to AI Voice"); } @Override public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) { - FrameLayout.LayoutParams entranceParams = ( ( FrameLayout.LayoutParams ) mEntrance.getLayoutParams() ); + FrameLayout.LayoutParams entranceParams = ((FrameLayout.LayoutParams) mEntrance.getLayoutParams()); if (isTrue) { - entranceParams.leftMargin = getResources().getDimensionPixelSize( R.dimen.module_main_entrance_fragment_container_marginLeft_in_vr_mode ); + entranceParams.leftMargin = getResources().getDimensionPixelSize(R.dimen.module_main_entrance_fragment_container_marginLeft_in_vr_mode); mLeftShadowFrame.setVisibility(View.GONE); mApps.setVisibility(View.GONE); - }else{ - entranceParams.leftMargin = getResources().getDimensionPixelSize( R.dimen.module_main_id_entrance_fragment_container_marginLeft ); + } else { + entranceParams.leftMargin = getResources().getDimensionPixelSize(R.dimen.module_main_id_entrance_fragment_container_marginLeft); mLeftShadowFrame.setVisibility(View.VISIBLE); mApps.setVisibility(View.VISIBLE); } - mEntrance.setLayoutParams( entranceParams ); + mEntrance.setLayoutParams(entranceParams); } + + @Override + public void warningChangedWithType(int type) { + Log.d(TAG, "显示红色预警蒙层"); + switch (type) { + case ALERT_THE_FRONT_CRASH_WARNING_TOP: + mWarningTop.setVisibility(View.VISIBLE); + mWarningLeft.setVisibility(View.GONE); + mWarningRight.setVisibility(View.GONE); + mWarningBottom.setVisibility(View.GONE); + break; + case ALERT_THE_FRONT_CRASH_WARNING_LEFT: + mWarningLeft.setVisibility(View.VISIBLE); + mWarningTop.setVisibility(View.GONE); + mWarningRight.setVisibility(View.GONE); + mWarningBottom.setVisibility(View.GONE); + break; + case ALERT_THE_FRONT_CRASH_WARNING_RIGHT: + mWarningRight.setVisibility(View.VISIBLE); + mWarningTop.setVisibility(View.GONE); + mWarningLeft.setVisibility(View.GONE); + mWarningBottom.setVisibility(View.GONE); + break; + case ALERT_THE_FRONT_CRASH_WARNING_BOTTOM: + mWarningBottom.setVisibility(View.VISIBLE); + mWarningRight.setVisibility(View.GONE); + mWarningTop.setVisibility(View.GONE); + mWarningLeft.setVisibility(View.GONE); + break; + default: + break; + } + } + } diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XMessageEntity.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XMessageEntity.java index fce034aab3..336e7d5a27 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XMessageEntity.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XMessageEntity.java @@ -145,6 +145,14 @@ public class V2XMessageEntity implements Serializable { int ALERT_RECOMMEND_ROUTE = 1_011; // 基于预判目的地违章高发停车场推荐 int ALERT_RECOMMEND_PARKING = 1_012; + // 前方碰撞预警 + int ALERT_THE_FRONT_CRASH_WARNING_TOP = 1_0013; + // 左前方碰撞预警 + int ALERT_THE_FRONT_CRASH_WARNING_LEFT = 1_0014; + // 右前方碰撞预警 + int ALERT_THE_FRONT_CRASH_WARNING_RIGHT = 1_0015; + // 后方碰撞预警 + int ALERT_THE_FRONT_CRASH_WARNING_BOTTOM = 1_0016; // 推送VR消息展示 int ALERT_PUSH_VR_SHOW = 2_000; // 自车求助 diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainActivity.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainActivity.java index 1fc72806d6..d80612b0dc 100644 --- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainActivity.java +++ b/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainActivity.java @@ -5,6 +5,7 @@ import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.FrameLayout; +import android.widget.ImageView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -29,6 +30,7 @@ import com.mogo.service.fragmentmanager.FragmentStackTransactionListener; import com.mogo.service.fragmentmanager.IMogoFragmentManager; import com.mogo.service.module.IMogoModuleProvider; import com.mogo.service.statusmanager.IMogoStatusManager; +import com.mogo.service.v2x.IV2XListener; import com.mogo.skin.support.SkinMode; import com.mogo.utils.NetworkUtils; import com.mogo.utils.logger.Logger; @@ -64,6 +66,11 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme protected FrameLayout mLeftPanelLayout; protected View mLeftShadowFrame; + protected ImageView mWarningTop; + protected ImageView mWarningLeft; + protected ImageView mWarningRight; + protected ImageView mWarningBottom; + @Override protected int getLayoutId() { if ( !DebugConfig.isMapBased() ) { @@ -103,6 +110,11 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme mLeftPanelLayout = findViewById( R.id.module_main_id_left_panel_fragment_container ); mHistoryMessagePanel = findViewById( R.id.module_main_id_message_history_fragment_container ); + mWarningTop = findViewById(R.id.warning_top); + mWarningLeft = findViewById(R.id.warning_left); + mWarningRight = findViewById(R.id.warning_right); + mWarningBottom = findViewById(R.id.warning_bottom); + // 避免事件穿透导致地图被滑动 mLeftShadowFrame.setOnClickListener( view -> { } ); diff --git a/modules/mogo-module-main/src/main/res/drawable-xhdpi/module_main_warning_bkg_bottom.xml b/modules/mogo-module-main/src/main/res/drawable-xhdpi/module_main_warning_bkg_bottom.xml new file mode 100644 index 0000000000..72aa9cfff4 --- /dev/null +++ b/modules/mogo-module-main/src/main/res/drawable-xhdpi/module_main_warning_bkg_bottom.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/modules/mogo-module-main/src/main/res/drawable-xhdpi/module_main_warning_bkg_left.xml b/modules/mogo-module-main/src/main/res/drawable-xhdpi/module_main_warning_bkg_left.xml new file mode 100644 index 0000000000..bc04920106 --- /dev/null +++ b/modules/mogo-module-main/src/main/res/drawable-xhdpi/module_main_warning_bkg_left.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/modules/mogo-module-main/src/main/res/drawable-xhdpi/module_main_warning_bkg_right.xml b/modules/mogo-module-main/src/main/res/drawable-xhdpi/module_main_warning_bkg_right.xml new file mode 100644 index 0000000000..7300bc5cf7 --- /dev/null +++ b/modules/mogo-module-main/src/main/res/drawable-xhdpi/module_main_warning_bkg_right.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/modules/mogo-module-main/src/main/res/drawable-xhdpi/module_main_warning_bkg_top.xml b/modules/mogo-module-main/src/main/res/drawable-xhdpi/module_main_warning_bkg_top.xml new file mode 100644 index 0000000000..a6317a7428 --- /dev/null +++ b/modules/mogo-module-main/src/main/res/drawable-xhdpi/module_main_warning_bkg_top.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/modules/mogo-module-main/src/main/res/layout/module_main_activity_main.xml b/modules/mogo-module-main/src/main/res/layout/module_main_activity_main.xml index 6712a3a36d..b785d02a94 100644 --- a/modules/mogo-module-main/src/main/res/layout/module_main_activity_main.xml +++ b/modules/mogo-module-main/src/main/res/layout/module_main_activity_main.xml @@ -2,8 +2,8 @@ @@ -12,6 +12,36 @@ android:layout_width="match_parent" android:layout_height="match_parent" /> + + + + + + + + 18px 18px 18px + + 1530px \ No newline at end of file diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MarkerServiceHandler.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MarkerServiceHandler.java index 367840cca3..abbc83a430 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MarkerServiceHandler.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MarkerServiceHandler.java @@ -26,6 +26,7 @@ import com.mogo.service.map.IMogoMapService; import com.mogo.service.module.IMogoActionManager; import com.mogo.service.module.IMogoRegisterCenter; import com.mogo.service.statusmanager.IMogoStatusManager; +import com.mogo.service.v2x.IV2XProvider; import com.mogo.utils.logger.Logger; import com.zhidao.carchattingprovider.CallChattingProviderConstant; import com.zhidao.carchattingprovider.ICarsChattingProvider; @@ -59,6 +60,8 @@ public class MarkerServiceHandler { private static IMogoLauncher sLauncher; private static IMogoFragmentManager sFragmentManager; private static ICarsChattingProvider sCarChatting; + private static IV2XProvider sIV2XProvider; + // private static IMogoGpsSimulatorManager sGpsSimulatorManager; public static synchronized void init( final Context context ) { @@ -86,6 +89,7 @@ public class MarkerServiceHandler { sFragmentManager = sApis.getFragmentManagerApi(); sCarChatting = ( ICarsChattingProvider ) ARouter.getInstance().build( CallChattingProviderConstant.CAR_CALL_PROVIDER ).navigation( context ); + sIV2XProvider = sApis.getV2XListenerManager(); MapMarkerManager.getInstance().init( context ); diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/receiver/MogoReceiver.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/receiver/MogoReceiver.java index 5ac444b6c0..07b2ed3cf1 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/receiver/MogoReceiver.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/receiver/MogoReceiver.java @@ -63,6 +63,9 @@ public class MogoReceiver extends BroadcastReceiver { // 同行者 查询xxx堵不堵发送的广播 public static final String ACTION_TXZ_BLOCK_SEARCH = "com.zhidao.roadcondition.roadinfo"; + //车路云—场景预警 + public static final String ACTION_V2X_FRONT_WARNING = "ACTION_V2X_FRONT_WARNING"; + private IMogoIntentManager mMogoIntentManager; public MogoReceiver(Context context) { diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/impl/V2XScenarioManager.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/impl/V2XScenarioManager.java index f46bc7a74b..285d808e28 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/impl/V2XScenarioManager.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/impl/V2XScenarioManager.java @@ -1,7 +1,6 @@ package com.mogo.module.v2x.scenario.impl; import android.content.Intent; -import android.util.Log; import androidx.localbroadcastmanager.content.LocalBroadcastManager; @@ -21,6 +20,7 @@ import com.mogo.module.v2x.scenario.scene.pushVR.V2XPushVREventScenario; import com.mogo.module.v2x.scenario.scene.road.V2XRoadEventScenario; import com.mogo.module.v2x.scenario.scene.seek.V2XSeekHelpScenario; import com.mogo.module.v2x.scenario.scene.ugc.V2XEventUgcScenario; +import com.mogo.module.v2x.scenario.scene.warning.V2XFrontWarningScenario; import com.mogo.module.v2x.utils.V2XUtils; import com.mogo.utils.TipToast; import com.mogo.utils.logger.Logger; @@ -75,8 +75,8 @@ public class V2XScenarioManager implements IV2XScenarioManager { case V2XMessageEntity.V2XTypeEnum.ALERT_SEEK_WARNING: mV2XScenario = new V2XSeekHelpScenario(); break; - case V2XMessageEntity.V2XTypeEnum.ALERT_FATIGUE_DRIVING : - case ALERT_RECOMMEND_PARKING : + case V2XMessageEntity.V2XTypeEnum.ALERT_FATIGUE_DRIVING: + case ALERT_RECOMMEND_PARKING: mV2XScenario = new V2XFatigueDrivingScenario(); break; case V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_WINDOW_WARNING: @@ -106,6 +106,12 @@ public class V2XScenarioManager implements IV2XScenarioManager { case V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_VR_SHOW: mV2XScenario = new V2XPushVREventScenario(); break; + case V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_TOP: + case V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_LEFT: + case V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_RIGHT: + case V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_BOTTOM: + mV2XScenario = new V2XFrontWarningScenario(); + break; default: mV2XScenario = null; Logger.e(MODULE_NAME, "当前V2X消息类型未定义。"); diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/test/V2XTestConsoleWindow.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/test/V2XTestConsoleWindow.java index ddac88ec6b..919831af2b 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/test/V2XTestConsoleWindow.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/test/V2XTestConsoleWindow.java @@ -51,6 +51,7 @@ public class V2XTestConsoleWindow extends ConstraintLayout { private Button mBtnTriggerRoadEvent; private Button mBtnClearRoadEvent; private Button mBtnTriggerPushEvent; + private Button mBtnTriggerWarningEvent; private Button mBtnTriggerPushLiveCarEvent; private Button mBtnTriggerAnimationEvent; private Button mBtnbtnFrontCarLiveEvent; @@ -112,6 +113,7 @@ public class V2XTestConsoleWindow extends ConstraintLayout { mBtnTriggerOpen = findViewById(R.id.btnTriggerOpen); mBtnClearRoadEvent = findViewById(R.id.btnClearRoadEvent); mBtnTriggerRoadEvent = findViewById(R.id.btnTriggerRoadEvent); + mBtnTriggerWarningEvent = findViewById(R.id.btnTriggerWarningEvent); mBtnTriggerPushEvent = findViewById(R.id.btnTriggerPushEvent); mBtnTriggerPushLiveCarEvent = findViewById(R.id.btnTriggerPushLiveCarEvent); mBtnTriggerAnimationEvent = findViewById(R.id.btnTriggerAnimationEvent); @@ -213,6 +215,16 @@ public class V2XTestConsoleWindow extends ConstraintLayout { }); + //车路云—场景预警-V1.0 碰撞预警 + mBtnTriggerWarningEvent.setOnClickListener(v->{ + V2XMessageEntity v2XMessageEntity = + TestOnLineCarUtils.getV2XScenarioPushFrontWarningEventData(); + + Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION); + intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity); + LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent); + }); + mBtnTriggerPushEvent.setOnClickListener(v -> { V2XMessageEntity v2XMessageEntity = TestOnLineCarUtils.getV2XScenarioPushEventData(); diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XFrontWarningScenario.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XFrontWarningScenario.java new file mode 100644 index 0000000000..50fee8dfac --- /dev/null +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XFrontWarningScenario.java @@ -0,0 +1,74 @@ +package com.mogo.module.v2x.scenario.scene.warning; + +import android.content.Context; +import android.content.Intent; +import android.util.Log; + +import androidx.annotation.Nullable; + +import com.alibaba.android.arouter.facade.annotation.Route; +import com.mogo.module.common.MogoApisHandler; +import com.mogo.module.common.entity.V2XMessageEntity; +import com.mogo.module.service.MarkerServiceHandler; +import com.mogo.module.service.MogoServices; +import com.mogo.module.service.receiver.MogoReceiver; +import com.mogo.module.v2x.scenario.impl.AbsV2XScenario; +import com.mogo.service.MogoServicePaths; +import com.mogo.service.impl.MogoServiceApis; +import com.mogo.service.impl.v2x.V2XManager; +import com.mogo.service.v2x.IV2XListener; +import com.mogo.service.v2x.IV2XProvider; + +/** + * @author liujing + * @description 车路云—场景预警-V1.0 前车/行人/摩托车/盲区碰撞预警 + * @since: 2021/3/24 + */ +public class V2XFrontWarningScenario extends AbsV2XScenario { + private int type; + private IV2XListener mIV2XListener; + + @Override + public void init(@Nullable V2XMessageEntity v2XMessageEntity) { + type = v2XMessageEntity.getType(); + MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithType(type, MogoReceiver.ACTION_V2X_FRONT_WARNING); + show(); + } + + @Override + public void show() { + showWindow(); + Log.d(TAG, "show"); + } + + @Override + public void showWindow() { + + } + + @Override + public void closeWindow() { + + } + + @Override + public void showButton() { + + } + + @Override + public void closeButton() { + + } + + @Override + public void drawPOI() { + + } + + @Override + public void clearPOI() { + + } + +} diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/TestOnLineCarUtils.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/TestOnLineCarUtils.java index 7757a27b51..bd0e95de1e 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/TestOnLineCarUtils.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/TestOnLineCarUtils.java @@ -156,6 +156,35 @@ public class TestOnLineCarUtils { return null; } + public static V2XMessageEntity getV2XScenarioPushFrontWarningEventData() { + try { + InputStream inputStream = V2XUtils.getApp() + .getResources() + .openRawResource(R.raw.scenario_warning_event_data); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + int len = -1; + byte[] buffer = new byte[1024]; + while ((len = inputStream.read(buffer)) != -1) { + baos.write(buffer, 0, len); + } + inputStream.close(); + + // 加载数据源 + V2XPushMessageEntity v2xRoadEventEntity = GsonUtil.objectFromJson(baos.toString(), V2XPushMessageEntity.class); + + V2XMessageEntity v2xMessageEntity = new V2XMessageEntity<>(); + // 控制类型 + v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_TOP); + // 设置数据 + v2xMessageEntity.setContent(v2xRoadEventEntity); + // 控制展示状态 + v2xMessageEntity.setShowState(true); + return v2xMessageEntity; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } /** * 模拟H5推送直播数据 diff --git a/modules/mogo-module-v2x/src/main/res/layout/window_test_console.xml b/modules/mogo-module-v2x/src/main/res/layout/window_test_console.xml index b9253925c9..0d8ba1418f 100644 --- a/modules/mogo-module-v2x/src/main/res/layout/window_test_console.xml +++ b/modules/mogo-module-v2x/src/main/res/layout/window_test_console.xml @@ -239,6 +239,20 @@ android:textSize="@dimen/dp_22" android:textStyle="bold" /> +