diff --git a/.idea/misc.xml b/.idea/misc.xml
index 2db9aab721..47f1a4e1d4 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -4,7 +4,7 @@
-
+
diff --git a/foudations/mogo-base-websocket-sdk/build.gradle b/foudations/mogo-base-websocket-sdk/build.gradle
index b5a25227ab..fd207afda9 100644
--- a/foudations/mogo-base-websocket-sdk/build.gradle
+++ b/foudations/mogo-base-websocket-sdk/build.gradle
@@ -40,6 +40,7 @@ dependencies {
implementation project(":foudations:mogo-utils")
implementation project(":foudations:mogo-commons")
implementation project(":services:mogo-service-api")
+ implementation project(':modules:mogo-module-common')
}
}
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 3da153adb3..598a4b7658 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
@@ -139,6 +139,8 @@ public class V2XMessageEntity implements Serializable {
int ALERT_ILLEGAL_PARK_WARNING = 1_008;
// 呼叫、请求直播事件
int ALERT_VOICE_CALL_FOR_LIVECAR_SHOW = 1_009;
+ // 推送VR消息展示
+ int ALERT_PUSH_VR_SHOW = 2_000;
// 自车求助
int ALERT_CAR_FOR_HELP = 8_000;
// obu事件
@@ -157,6 +159,7 @@ public class V2XMessageEntity implements Serializable {
V2XTypeEnum.ALERT_ILLEGAL_PARK_WARNING,
V2XTypeEnum.ALERT_CAR_FOR_HELP,
V2XTypeEnum.ALERT_VOICE_CALL_FOR_LIVECAR_SHOW,
+ V2XTypeEnum.ALERT_PUSH_VR_SHOW,
V2XTypeEnum.ALERT_OBU_EVENT,
})
@Target({
diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/MogoEntranceButtonControllerImpl.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/MogoEntranceButtonControllerImpl.java
index 0f046fc48f..dedc8a8994 100644
--- a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/MogoEntranceButtonControllerImpl.java
+++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/MogoEntranceButtonControllerImpl.java
@@ -9,6 +9,7 @@ import com.mogo.module.extensions.utils.EntranceViewHolder;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.entrance.ButtonIndex;
import com.mogo.service.entrance.IMogoEntranceButtonController;
+import com.mogo.service.windowview.IMogoEntranceViewListener;
/**
* @author congtaowang
@@ -59,6 +60,16 @@ public class MogoEntranceButtonControllerImpl implements IMogoEntranceButtonCont
EntranceViewHolder.getInstance().hideLeftNoticeByType(noticeType);
}
+ @Override
+ public void addEntranceViewListener(IMogoEntranceViewListener listener) {
+ EntranceViewHolder.getInstance().addEntranceViewListener(listener);
+ }
+
+ @Override
+ public void removeEntranceViewListener(IMogoEntranceViewListener listener) {
+ EntranceViewHolder.getInstance().removeEntranceViewListener(listener);
+ }
+
@Override
public void init( Context context ) {
diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/utils/AdasNoticeHelper.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/utils/AdasNoticeHelper.java
index a9d42c76c3..8372649f04 100644
--- a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/utils/AdasNoticeHelper.java
+++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/utils/AdasNoticeHelper.java
@@ -6,11 +6,13 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.os.Handler;
import android.os.Message;
+import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import com.mogo.map.location.IMogoLocationListener;
import com.mogo.map.location.MogoLocation;
+import com.mogo.map.navi.MogoTraffic;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.entity.CloudRoadData;
import com.mogo.module.common.entity.MogoSnapshotSetData;
@@ -31,54 +33,79 @@ import org.json.JSONObject;
* @author tongchenfei
*/
public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLocationListener,
- Handler.Callback , IMogoOnWebSocketMessageListener {
+ Handler.Callback, IMogoOnWebSocketMessageListener {
private static final String TAG = "AdasNoticeHelper";
private static final int MSG_HIDE_TRAFFIC_LIGHT_BY_OBU = 1001;
private static final int MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD = 1002;
private static final int MSG_HIDE_LIMIT_SPEED = 1003;
+ private static final int MSG_REFRESH_CAR_STRATEGY = 1004;
private static final long HIDE_TRAFFIC_LIGHT_DELAY = 2_000L;
private static final long HIDE_LIMIT_SPEED_DELAY = 10_000L;
+ private static final long STRATEGY_DELAY = 1000L;
private Context context;
private AdasNoticeReceiver adasReceiver = new AdasNoticeReceiver();
- private boolean isVrMode = false;
+ private volatile boolean isVrMode = false;
private TextView tvSelfSpeed, tvTrafficLight, tvLimitSpeed;
private int limitSpeed;
+ private int currentSpeed = 0;
+ private String lightStatus = "G";
+ private String surplusTime;
private Handler handler = new Handler(this);
+ private View selfCar;
+
+ private boolean lightCenter = false;
+
public void init(Context context) {
this.context = context;
+ if(!lightCenter) {
+ selfCar = LayoutInflater.from(context).inflate(R.layout.module_ext_item_self_car, null);
+ tvSelfSpeed = selfCar.findViewById(R.id.tvSelfSpeed);
+ tvTrafficLight = selfCar.findViewById(R.id.tvTrafficLight);
+ tvLimitSpeed = selfCar.findViewById(R.id.tvLimitSpeed);
+ }
+ Logger.d(TAG, "init====");
}
public void initView(View root) {
- tvSelfSpeed = root.findViewById(R.id.tvSelfSpeed);
- tvTrafficLight = root.findViewById(R.id.tvTrafficLight);
- tvLimitSpeed = root.findViewById(R.id.tvLimitSpeed);
+ if(lightCenter) {
+ tvSelfSpeed = root.findViewById(R.id.tvSelfSpeed);
+ tvTrafficLight = root.findViewById(R.id.tvTrafficLight);
+ tvLimitSpeed = root.findViewById(R.id.tvLimitSpeed);
+ }
}
public void enterVrMode() {
- isVrMode = true;
- IntentFilter filter = new IntentFilter("com.mogo.launcher.adas.app.biz");
- context.registerReceiver(adasReceiver, filter);
- MogoApisHandler.getInstance().getApis().getAdasControllerApi().addAdasWarnMessageCallback(this);
- MogoApisHandler.getInstance().getApis().getRegisterCenterApi().registerMogoLocationListener(TAG, this);
- MogoApisHandler.getInstance().getApis().getWebSocketManagerApi(context).registerOnWebSocketMessageListener(this);
-
- // debug code
- tvSelfSpeed.setVisibility(View.VISIBLE);
- tvTrafficLight.setVisibility(View.VISIBLE);
- tvLimitSpeed.setVisibility(View.VISIBLE);
+ Logger.d(TAG, "enterVrMode===" + isVrMode);
+ if (!isVrMode) {
+ isVrMode = true;
+ IntentFilter filter = new IntentFilter("com.mogo.launcher.adas.app.biz");
+ context.registerReceiver(adasReceiver, filter);
+ MogoApisHandler.getInstance().getApis().getAdasControllerApi().addAdasWarnMessageCallback(this);
+ MogoApisHandler.getInstance().getApis().getRegisterCenterApi().registerMogoLocationListener(TAG, this);
+ MogoApisHandler.getInstance().getApis().getWebSocketManagerApi(context).registerOnWebSocketMessageListener(this);
+ if(!lightCenter) {
+ handler.sendEmptyMessageDelayed(MSG_REFRESH_CAR_STRATEGY, STRATEGY_DELAY);
+ }
+ // debug code
+// tvSelfSpeed.setVisibility(View.VISIBLE);
+// tvTrafficLight.setVisibility(View.VISIBLE);
+// tvLimitSpeed.setVisibility(View.VISIBLE);
+ }
}
public void exitVrMode() {
- if(isVrMode) {
+ Logger.d(TAG, "退出vr模式===" + isVrMode);
+ if (isVrMode) {
isVrMode = false;
+ handler.removeMessages(MSG_REFRESH_CAR_STRATEGY);
tvSelfSpeed.setVisibility(View.GONE);
tvTrafficLight.setVisibility(View.GONE);
tvLimitSpeed.setVisibility(View.GONE);
@@ -91,7 +118,7 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
@Override
public void onReceiveData(ADASWarnMessage msg) {
- Logger.d(TAG, "收到adas warn message, isVrMode: "+isVrMode+" msg: " + msg);
+ Logger.d(TAG, "收到adas warn message, isVrMode: " + isVrMode + " msg: " + msg);
if (!isVrMode) {
return;
}
@@ -119,20 +146,49 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
if (!isVrMode) {
return;
}
- int speed = (int) (location.getSpeed() * 3.6F);
- if (tvSelfSpeed != null) {
- tvSelfSpeed.post(() -> {
- if (tvSelfSpeed.getVisibility() == View.GONE) {
- tvSelfSpeed.setVisibility(View.VISIBLE);
- }
- tvSelfSpeed.setText("" + speed);
- });
+ currentSpeed = (int) (location.getSpeed() * 3.6F);
+ if(lightCenter) {
+ if (tvSelfSpeed != null) {
+ tvSelfSpeed.post(() -> {
+ if (tvSelfSpeed.getVisibility() == View.GONE) {
+ tvSelfSpeed.setVisibility(View.VISIBLE);
+ }
+ tvSelfSpeed.setText("" + currentSpeed);
+ Logger.d(TAG, "onLocationChange: " + currentSpeed);
+ });
+ }
}
}
@Override
public boolean handleMessage(Message msg) {
switch (msg.what) {
+ case MSG_REFRESH_CAR_STRATEGY:
+ // 自车速度
+ tvSelfSpeed.setText("" + currentSpeed);
+ // 红绿灯
+ if (tvTrafficLight.getVisibility() == View.GONE) {
+ tvTrafficLight.setVisibility(View.VISIBLE);
+ }
+ // todo 设置字体颜色、背景颜色、leftDrawable
+ switch (lightStatus) {
+ case "Y":
+ // 黄灯
+ break;
+ case "R":
+ // 红灯
+ break;
+ default:
+ // 默认绿灯
+ break;
+ }
+ tvTrafficLight.setText(surplusTime + "S");
+
+ MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().showMyLocation(selfCar);
+ if (isVrMode) {
+ handler.sendEmptyMessageDelayed(MSG_REFRESH_CAR_STRATEGY, STRATEGY_DELAY);
+ }
+ return true;
case MSG_HIDE_LIMIT_SPEED:
tvLimitSpeed.setVisibility(View.GONE);
return true;
@@ -191,40 +247,62 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
handler.removeMessages(MSG_HIDE_TRAFFIC_LIGHT_BY_OBU);
handler.removeMessages(MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD);
drawTrafficLight(lightStatus, surplusTime);
- handler.sendEmptyMessageDelayed(MSG_HIDE_TRAFFIC_LIGHT_BY_OBU, HIDE_TRAFFIC_LIGHT_DELAY);
+ handler.sendEmptyMessageDelayed(MSG_HIDE_TRAFFIC_LIGHT_BY_OBU,
+ HIDE_TRAFFIC_LIGHT_DELAY);
}
}
- private void handleCloudTrafficLight(CloudRoadData roadData){
+ private void handleCloudTrafficLight(CloudRoadData roadData) {
if (tvTrafficLight != null && !handler.hasMessages(MSG_HIDE_TRAFFIC_LIGHT_BY_OBU)) {
handler.removeMessages(MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD);
// todo drawTrafficLight
-
+ String lightStatus;
+ switch (roadData.getLightStatus()) {
+ case 1:
+ // 红灯
+ lightStatus = "R";
+ break;
+ case 3:
+ // 黄灯
+ lightStatus = "Y";
+ break;
+ default:
+ // 默认绿灯
+ lightStatus = "G";
+ break;
+ }
+ int diff = (int) ((System.currentTimeMillis() - roadData.getSystemTime()) / 1000);
+ int leftTime = roadData.getLightLeftTime() - diff;
+ drawTrafficLight(lightStatus, "" + leftTime);
handler.sendEmptyMessageDelayed(MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD,
HIDE_TRAFFIC_LIGHT_DELAY);
}
}
private void drawTrafficLight(String lightStatus, String surplusTime) {
- tvTrafficLight.post(() -> {
- if (tvTrafficLight.getVisibility() == View.GONE) {
- tvTrafficLight.setVisibility(View.VISIBLE);
- }
- // todo 设置字体颜色、背景颜色、leftDrawable
- switch (lightStatus) {
- case "Y":
- // 黄灯
- break;
- case "R":
- // 红灯
- break;
- default:
- // 默认绿灯
- break;
- }
- tvTrafficLight.setText(surplusTime + "S");
- Logger.d(TAG, "展示红绿灯信息: " + lightStatus + " time: " + surplusTime);
- });
+ this.lightStatus = lightStatus;
+ this.surplusTime = surplusTime;
+ if(lightCenter) {
+ tvTrafficLight.post(() -> {
+ if (tvTrafficLight.getVisibility() == View.GONE) {
+ tvTrafficLight.setVisibility(View.VISIBLE);
+ }
+ // todo 设置字体颜色、背景颜色、leftDrawable
+ switch (lightStatus) {
+ case "Y":
+ // 黄灯
+ break;
+ case "R":
+ // 红灯
+ break;
+ default:
+ // 默认绿灯
+ break;
+ }
+ tvTrafficLight.setText(surplusTime + "S");
+ Logger.d(TAG, "展示红绿灯信息: " + lightStatus + " time: " + surplusTime);
+ });
+ }
}
@Override
@@ -244,6 +322,8 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
if (roadData != null) {
Logger.d(TAG, "收到红绿灯数据");
handleCloudTrafficLight(roadData);
+ } else {
+ handler.sendEmptyMessage(MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD);
}
}
}
diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/utils/EntranceViewHolder.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/utils/EntranceViewHolder.java
index bb89540f36..b8c31f56a3 100644
--- a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/utils/EntranceViewHolder.java
+++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/utils/EntranceViewHolder.java
@@ -11,6 +11,7 @@ import android.widget.TextView;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.extensions.R;
import com.mogo.module.extensions.bean.BottomLayerViewWrapper;
+import com.mogo.service.windowview.IMogoEntranceViewListener;
import com.mogo.utils.logger.Logger;
import java.util.ArrayList;
@@ -146,6 +147,9 @@ public class EntranceViewHolder {
}
public void forceHideNoticeView(){
+ for (IMogoEntranceViewListener listener : listeners) {
+ listener.onViewRemoved(currentShowNoticeType);
+ }
preAddLeftNoticeView = null;
currentShowNoticeType = 0;
if (leftNoticeContainer != null) {
@@ -156,6 +160,11 @@ public class EntranceViewHolder {
private int currentShowNoticeType = 0;
public void showLeftNoticeByType(int noticeType, int iconRes, String content){
if(MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
+ if (currentShowNoticeType != noticeType && currentShowNoticeType != 0) {
+ for (IMogoEntranceViewListener listener : listeners) {
+ listener.onViewRemoved(currentShowNoticeType);
+ }
+ }
currentShowNoticeType = noticeType;
if (leftNoticeContainer != null) {
realShowLeftNoticeView(generateNoticeViewByType(noticeType, iconRes, content));
@@ -196,6 +205,9 @@ public class EntranceViewHolder {
leftNoticeContainer.removeAllViews();
leftNoticeContainer.addView(view);
preAddLeftNoticeView = null;
+ for (IMogoEntranceViewListener listener : listeners) {
+ listener.onViewAdded(currentShowNoticeType);
+ }
}
private void realHideLeftNoticeView(View view) {
@@ -203,6 +215,16 @@ public class EntranceViewHolder {
leftNoticeContainer.setVisibility(View.GONE);
}
+ private List listeners = new ArrayList<>();
+
+ public void addEntranceViewListener(IMogoEntranceViewListener listener) {
+ listeners.add(listener);
+ }
+
+ public void removeEntranceViewListener(IMogoEntranceViewListener listener) {
+ listeners.remove(listener);
+ }
+
public void release(){
rootViewGroup = null;
}
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_self_car.png b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_self_car.png
new file mode 100644
index 0000000000..dc22ac57a1
Binary files /dev/null and b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_self_car.png differ
diff --git a/modules/mogo-module-extensions/src/main/res/layout/module_ext_item_self_car.xml b/modules/mogo-module-extensions/src/main/res/layout/module_ext_item_self_car.xml
new file mode 100644
index 0000000000..5b4e3b2c6d
--- /dev/null
+++ b/modules/mogo-module-extensions/src/main/res/layout/module_ext_item_self_car.xml
@@ -0,0 +1,64 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_entrance.xml b/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_entrance.xml
index 1e2c7d7fae..f10ce125c2 100644
--- a/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_entrance.xml
+++ b/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_entrance.xml
@@ -232,45 +232,46 @@
android:id="@+id/tvSelfSpeed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_marginEnd="@dimen/module_ext_vr_mode_self_speed_margin_end"
android:background="@drawable/module_ext_vr_mode_speed_red_bg"
+ android:gravity="center"
android:text="72"
android:textColor="@color/module_ext_vr_mode_left_traffic_light_red"
android:textSize="@dimen/module_ext_vr_mode_traffic_light_text_size"
android:visibility="gone"
- android:gravity="center"
- tools:visibility="visible"
- app:layout_constraintLeft_toLeftOf="parent"
- app:layout_constraintTop_toTopOf="parent" />
+ app:layout_constraintRight_toLeftOf="@+id/tvTrafficLight"
+ app:layout_constraintTop_toTopOf="@+id/tvTrafficLight"
+ tools:visibility="visible" />
+ app:layout_constraintRight_toLeftOf="@+id/tvLimitSpeed"
+ app:layout_constraintTop_toTopOf="@+id/tvLimitSpeed"
+ tools:visibility="visible" />
+ app:layout_constraintRight_toRightOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/ivUserHeadImg"
+ tools:visibility="visible" />