[add] 前车碰撞预警 UI + 测试数据

This commit is contained in:
liujing
2021-03-24 11:54:05 +08:00
parent 9b2944c92c
commit b60e2803d4
15 changed files with 201 additions and 38 deletions

1
.idea/gradle.xml generated
View File

@@ -91,7 +91,6 @@
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
<option name="useQualifiedModuleNames" value="true" />
</GradleProjectSettings>
</option>
</component>

View File

@@ -19,6 +19,7 @@ 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.IWarningChangeListener;
import com.mogo.utils.logger.Logger;
/**
@@ -26,13 +27,14 @@ import com.mogo.utils.logger.Logger;
*
* @author tongchenfei
*/
public class MainLauncherActivity extends MainActivity implements IMogoIntentListener, IMogoStatusChangedListener {
public class MainLauncherActivity extends MainActivity implements IMogoIntentListener, IMogoStatusChangedListener, IWarningChangeListener {
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);
mServiceApis.getStatusManagerApi().registerStatusChangedListener(TAG,
StatusDescriptor.VR_MODE, this);
}
@@ -43,10 +45,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 +59,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 +85,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 +109,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);
}
}
@@ -121,38 +123,53 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
StatusDescriptor.VR_MODE, 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(String type) {
switch (type) {
case "top":
mWarningTop.setVisibility(View.VISIBLE);
case "left":
mWarningLeft.setVisibility(View.VISIBLE);
case "right":
mWarningRight.setVisibility(View.VISIBLE);
case "bottom":
mWarningBottom.setVisibility(View.VISIBLE);
}
}
}

View File

@@ -145,6 +145,8 @@ public class V2XMessageEntity<T> implements Serializable {
int ALERT_RECOMMEND_ROUTE = 1_011;
// 基于预判目的地违章高发停车场推荐
int ALERT_RECOMMEND_PARKING = 1_012;
// 前车碰撞预警
int ALERT_THE_FRONT_CRASH_WARNING = 1_0013;
// 推送VR消息展示
int ALERT_PUSH_VR_SHOW = 2_000;
// 自车求助

View File

@@ -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;
@@ -64,6 +65,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 +109,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 -> {
} );

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="90"
android:endColor="#00F03232"
android:startColor="#A5F03232"
android:type="linear"></gradient>
</shape>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="0"
android:endColor="#00F03232"
android:startColor="#A5F03232"
android:type="linear"></gradient>
</shape>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="180"
android:endColor="#00F03232"
android:startColor="#A5F03232"
android:type="linear"></gradient>
</shape>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="270"
android:endColor="#00FF0606"
android:startColor="#8CFF0606"
android:type="linear"></gradient>
</shape>

View File

@@ -2,8 +2,8 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:background="@color/module_main_window_background_color"
android:layout_height="match_parent"
android:background="@color/module_main_window_background_color"
android:orientation="vertical">
<!-- 地图-->
@@ -12,6 +12,36 @@
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ImageView
android:id="@+id/warning_top"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_390"
android:background="@drawable/module_main_warning_bkg_top"
android:visibility="gone" />
<ImageView
android:id="@+id/warning_left"
android:layout_width="@dimen/dp_390"
android:layout_height="match_parent"
android:background="@drawable/module_main_warning_bkg_left"
android:visibility="gone" />
<ImageView
android:id="@+id/warning_right"
android:layout_width="@dimen/dp_390"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/module_main_id_warning_view_marginLeft"
android:background="@drawable/module_main_warning_bkg_right"
android:visibility="gone" />
<ImageView
android:id="@+id/warning_bottom"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_390"
android:layout_marginTop="@dimen/dp_690"
android:background="@drawable/module_main_warning_bkg_bottom"
android:visibility="gone" />
<FrameLayout
android:id="@+id/module_main_id_map_left_shadow_frame"
android:layout_width="@dimen/module_main_map_left_shadow_frame_width"

View File

@@ -32,4 +32,6 @@
<dimen name="module_main_event_panel_fragment_paddingBottom">18px</dimen>
<dimen name="module_main_event_panel_fragment_paddingLeft">18px</dimen>
<dimen name="module_main_event_panel_fragment_paddingRight">18px</dimen>
<dimen name="module_main_id_warning_view_marginLeft">1530px</dimen>
</resources>

View File

@@ -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);
@@ -211,6 +213,9 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
saveLocalStory(V2XMessageEntity.V2XTypeEnum.ALERT_ROAD_WARNING,
v2XMessageEntity.getContent().getNoveltyInfo());
});
mBtnTriggerWarningEvent.setOnClickListener(v->{
});
mBtnTriggerPushEvent.setOnClickListener(v -> {

View File

@@ -156,6 +156,35 @@ public class TestOnLineCarUtils {
return null;
}
public static V2XMessageEntity<V2XPushMessageEntity> getV2XScenarioPushWarningEventData() {
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<V2XPushMessageEntity> v2xMessageEntity = new V2XMessageEntity<>();
// 控制类型
v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING);
// 设置数据
v2xMessageEntity.setContent(v2xRoadEventEntity);
// 控制展示状态
v2xMessageEntity.setShowState(true);
return v2xMessageEntity;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 模拟H5推送直播数据

View File

@@ -239,6 +239,20 @@
android:textSize="@dimen/dp_22"
android:textStyle="bold" />
<Button
android:id="@+id/btnTriggerWarningEvent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/dp_10"
android:layout_marginBottom="@dimen/dp_10"
android:background="#1EBD85"
android:padding="@dimen/dp_10"
android:text="前车碰撞预警"
android:textColor="#FFFFFF"
android:textSize="@dimen/dp_22"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/btnTriggerPushEvent"
android:layout_width="wrap_content"

View File

@@ -0,0 +1,12 @@
{
"systemTime":1615529739389,
"satelliteTime":1615529739389,
"lon":116.411360351446,
"lat":39.9760799115428,
"alt":34.4648361206054,
"heading":359.939618623258,
"speed":11.108121,
"type":3,
"uuid":"2_1",
"direction": "0"
}

View File

@@ -0,0 +1,10 @@
package com.mogo.service.v2x;
/**
* @author liujing
* @description 描述
* @since: 2021/3/24
*/
public interface IWarningChangeListener {
void warningChangedWithType(String type);
}