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-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 66234c0fdf..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,11 +247,12 @@ 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
@@ -214,7 +271,7 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
lightStatus = "G";
break;
}
- int diff = (int) ((System.currentTimeMillis() - roadData.getSystemTime())/1000);
+ int diff = (int) ((System.currentTimeMillis() - roadData.getSystemTime()) / 1000);
int leftTime = roadData.getLightLeftTime() - diff;
drawTrafficLight(lightStatus, "" + leftTime);
handler.sendEmptyMessageDelayed(MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD,
@@ -223,25 +280,29 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
}
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
@@ -261,7 +322,7 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
if (roadData != null) {
Logger.d(TAG, "收到红绿灯数据");
handleCloudTrafficLight(roadData);
- }else{
+ } else {
handler.sendEmptyMessage(MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD);
}
}
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" />