diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index 663459aa50..0d156937bb 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -3,9 +3,18 @@
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
index f4d5deeca6..e082ea7475 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -4,10 +4,7 @@
-
+
-
-
-
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index bb9630b495..5121884a7f 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -4,6 +4,7 @@
package="com.mogo.launcher">
+
{
+
+ private PointF pointF1;
+ private PointF pointF2;
+
+ public BezierEvaluator(PointF point1, PointF point2) {
+ this.pointF1 = point1;
+ this.pointF2 = point2;
+ }
+
+ @Override
+ public PointF evaluate(float time, PointF startValue, PointF endValue) {
+ float timeLeft = 1.0f - time;
+
+ //结果
+ PointF point = new PointF();
+
+ PointF point0 = (PointF)startValue;//起点
+ PointF point3 = (PointF)endValue;//终点
+
+ // 贝塞尔公式
+ point.x = timeLeft * timeLeft * timeLeft * (point0.x)
+ + 3 * timeLeft * timeLeft * time * (pointF1.x)
+ + 3 * timeLeft * time * time * (pointF2.x)
+ + time * time * time * (point3.x);
+
+ point.y = timeLeft * timeLeft * timeLeft * (point0.y)
+ + 3 * timeLeft * timeLeft * time * (pointF1.y)
+ + 3 * timeLeft * time * time * (pointF2.y)
+ + time * time * time * (point3.y);
+
+ return point;
+ }
+}
\ No newline at end of file
diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/animation/BezierListener.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/animation/BezierListener.java
new file mode 100644
index 0000000000..04ab1129c2
--- /dev/null
+++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/animation/BezierListener.java
@@ -0,0 +1,24 @@
+package com.mogo.module.common.animation;
+
+import android.animation.ValueAnimator;
+import android.graphics.PointF;
+import android.view.View;
+
+public class BezierListener implements ValueAnimator.AnimatorUpdateListener {
+
+ private View target;
+
+ public BezierListener(View target) {
+ this.target = target;
+ }
+
+ @Override
+ public void onAnimationUpdate(ValueAnimator animation) {
+ //这里获取到贝塞尔曲线计算出来的的x y值 赋值给view 这样就能让爱心随着曲线走啦
+ PointF pointF = (PointF) animation.getAnimatedValue();
+ target.setX(pointF.x);
+ target.setY(pointF.y);
+ // 这里偷个懒,顺便做一个alpha动画,这样alpha渐变也完成啦
+ target.setAlpha(1 - animation.getAnimatedFraction());
+ }
+}
\ No newline at end of file
diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/constants/TrafficLightConst.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/constants/TrafficLightConst.java
new file mode 100644
index 0000000000..f543e4b242
--- /dev/null
+++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/constants/TrafficLightConst.java
@@ -0,0 +1,18 @@
+package com.mogo.module.common.constants;
+
+/**
+ * 用于内部标识红绿灯颜色
+ *
+ * @author tongchenfei
+ */
+public class TrafficLightConst {
+ public static final int TRAFFIC_LIGHT_COLOR_GRAY = 0;
+ public static final int TRAFFIC_LIGHT_COLOR_RED = 1;
+ public static final int TRAFFIC_LIGHT_COLOR_YELLOW = 2;
+ public static final int TRAFFIC_LIGHT_COLOR_GREEN = 3;
+
+ public static final int TRAFFIC_LIGHT_DIRECTION_TURN_AROUND = 0;
+ public static final int TRAFFIC_LIGHT_DIRECTION_TURN_LEFT = 1;
+ public static final int TRAFFIC_LIGHT_DIRECTION_STRAIGHT = 2;
+ public static final int TRAFFIC_LIGHT_DIRECTION_TURN_RIGHT = 3;
+}
diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MapCameraInfoView.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MapCameraInfoView.java
new file mode 100644
index 0000000000..9d88d0b644
--- /dev/null
+++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MapCameraInfoView.java
@@ -0,0 +1,67 @@
+package com.mogo.module.common.drawer.marker;
+
+import android.content.Context;
+import android.text.TextUtils;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import androidx.annotation.Nullable;
+import androidx.constraintlayout.widget.ConstraintLayout;
+
+import com.mogo.map.marker.MogoMarkerOptions;
+import com.mogo.module.common.ModuleNames;
+import com.mogo.module.common.MogoApisHandler;
+import com.mogo.module.common.R;
+import com.mogo.module.common.entity.MarkerExploreWay;
+import com.mogo.module.common.entity.MarkerShareMusic;
+import com.mogo.module.common.entity.MarkerShowEntity;
+import com.mogo.module.common.marker.PoiWrapper;
+import com.mogo.module.common.utils.CloudPoiManager;
+import com.mogo.utils.logger.Logger;
+
+/**
+ * author : donghongyu
+ * e-mail : 1358506549@qq.com
+ * date : 2020-01-0619:55
+ * desc : 地图Marker图标带文本信息
+ * version: 1.0
+ */
+public class MapCameraInfoView extends MapMarkerBaseView {
+ private String TAG = "MapCameraInfoView";
+
+ private ImageView mCameraImage;
+
+
+ public MapCameraInfoView(Context context ) {
+ super( context );
+ }
+
+ public MapCameraInfoView(Context context, @Nullable AttributeSet attrs ) {
+ super( context, attrs );
+ }
+
+ public MapCameraInfoView(Context context, @Nullable AttributeSet attrs, int defStyleAttr ) {
+ super( context, attrs, defStyleAttr );
+ }
+
+ public MapCameraInfoView(Context context, MogoMarkerOptions options ) {
+ super( context );
+ mOptions = options;
+ }
+
+ @Override
+ protected void initView( Context context ) {
+ LayoutInflater.from( context ).inflate( R.layout.modudle_camera_layout_info, this );
+ mCameraImage = findViewById( R.id.iv_camera_traffic);
+ }
+
+ @Override
+ public void updateView( MarkerShowEntity markerShowEntity ) {
+
+ }
+
+}
diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/view/RoundLayout.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/view/RoundLayout.java
index 23418c8b9e..20150f4a19 100644
--- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/view/RoundLayout.java
+++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/view/RoundLayout.java
@@ -3,6 +3,8 @@ package com.mogo.module.common.view;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.PaintFlagsDrawFilter;
import android.graphics.Path;
import android.graphics.RectF;
import android.util.AttributeSet;
@@ -19,11 +21,10 @@ import com.mogo.skin.support.helper.MogoSkinCompatBackgroundHelperDelegate;
* desc :
* version: 1.0
*/
-public class RoundLayout extends RelativeLayout implements IMogoSkinCompatSupportable {
+public class RoundLayout extends RelativeLayout {
private float roundLayoutRadius = 14f;
private Path roundPath;
private RectF rectF;
- private MogoSkinCompatBackgroundHelperDelegate mBackgroundTintHelper;
public RoundLayout(Context context) {
this(context, null);
@@ -41,9 +42,6 @@ public class RoundLayout extends RelativeLayout implements IMogoSkinCompatSuppor
typedArray.recycle();
init();
-
- mBackgroundTintHelper = new MogoSkinCompatBackgroundHelperDelegate(this);
- mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
}
@@ -75,16 +73,10 @@ public class RoundLayout extends RelativeLayout implements IMogoSkinCompatSuppor
@Override
public void draw(Canvas canvas) {
if (roundLayoutRadius > 0f) {
+ canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG));
canvas.clipPath(roundPath);
}
super.draw(canvas);
}
-
- @Override
- public void applySkin() {
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.applySkin();
- }
- }
}
diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_common_heart_animation_vr00.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_common_heart_animation_vr00.png
new file mode 100644
index 0000000000..5246d61ccc
Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_common_heart_animation_vr00.png differ
diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_common_heart_animation_vr01.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_common_heart_animation_vr01.png
new file mode 100644
index 0000000000..5246d61ccc
Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_common_heart_animation_vr01.png differ
diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_common_heart_animation_vr02.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_common_heart_animation_vr02.png
new file mode 100644
index 0000000000..5246d61ccc
Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_common_heart_animation_vr02.png differ
diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_camera_real_time_traffic.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_camera_real_time_traffic.png
new file mode 100644
index 0000000000..3f41ce4252
Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_camera_real_time_traffic.png differ
diff --git a/modules/mogo-module-common/src/main/res/layout/modudle_camera_layout_info.xml b/modules/mogo-module-common/src/main/res/layout/modudle_camera_layout_info.xml
new file mode 100644
index 0000000000..39535e2391
--- /dev/null
+++ b/modules/mogo-module-common/src/main/res/layout/modudle_camera_layout_info.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java
index 4da4fe8182..baefe740bc 100644
--- a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java
+++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java
@@ -4,15 +4,18 @@ import android.content.Intent;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Handler;
+import android.os.SystemClock;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.Button;
import android.widget.ImageButton;
import android.widget.EditText;
import android.widget.ImageView;
+import android.widget.RadioButton;
import android.widget.TextView;
import androidx.annotation.NonNull;
@@ -207,6 +210,8 @@ public class EntranceFragment extends MvpFragment {
+ if (SystemClock.elapsedRealtime() - lastDebugPanelClickTime > 1000) {
+ debugPanelClickCount = 1;
+ }else{
+ debugPanelClickCount++;
+ }
+
+ lastDebugPanelClickTime = SystemClock.elapsedRealtime();
+
+ if (debugPanelClickCount == 10) {
+ // show panel
+ debugPanelGroup.setVisibility(View.VISIBLE);
+ }
+
+ });
+
+ initDebugPanel();
+
}
+ private int debugPanelClickCount = 0;
+ private long lastDebugPanelClickTime = 0;
+
private EditText etTimes;
private Group groupFix;
private void enterVrMode(){
- tvEnterVrMode.setVisibility(View.GONE);
+// tvEnterVrMode.setVisibility(View.GONE);
mMove2CurrentLocation.setVisibility(View.GONE);
mUploadRoadCondition.setVisibility(View.GONE);
mWeatherContainer.setVisibility(View.GONE);
mMsgContainer.setVisibility(View.GONE);
groupUserHead.setVisibility(View.GONE);
- tvExitVrMode.setVisibility(View.VISIBLE);
+// tvExitVrMode.setVisibility(View.VISIBLE);
TopViewAnimHelper.getInstance().enterVrMode();
TopViewNoLinkageAnimHelper.getInstance().enterVrMode();
mNaviInfo = vrModeNavInfoView;
@@ -497,14 +524,14 @@ public class EntranceFragment extends MvpFragment debugPanelGroup.setVisibility(View.GONE));
+
+ btnOpenLog.setOnClickListener(v->{
+ Intent intent = new Intent("com.mogo.ACTION");
+ intent.putExtra("oper", 1);
+ getContext().sendBroadcast(intent);
+ debugPanelGroup.setVisibility(View.GONE);
+ });
+
+ btnCloseLog.setOnClickListener(v -> {
+ Intent intent = new Intent("com.mogo.ACTION");
+ intent.putExtra("oper", 2);
+ getContext().sendBroadcast(intent);
+ debugPanelGroup.setVisibility(View.GONE);
+ });
+
+ btnOpenV2XPanel.setOnClickListener(v -> {
+ Intent intent = new Intent("com.v2x.test_panel_control");
+ intent.putExtra("TextPanelOpenStatus", true);
+ getContext().sendBroadcast(intent);
+ debugPanelGroup.setVisibility(View.GONE);
+ });
+
+ switch (DebugConfig.getObuType()) {
+ case DebugConfig.OBU_TYPE_CIDI:
+ rbCidi.setChecked(true);
+ break;
+ case DebugConfig.OBU_TYPE_HUALI:
+ rbHuali.setChecked(true);
+ break;
+ default:
+ rbGohigh.setChecked(true);
+ break;
+ }
+
+ rbCidi.setOnClickListener(v -> exchangeObuType(DebugConfig.OBU_TYPE_CIDI));
+ rbHuali.setOnClickListener(v -> exchangeObuType(DebugConfig.OBU_TYPE_HUALI));
+ rbGohigh.setOnClickListener(v -> exchangeObuType(DebugConfig.OBU_TYPE_GOHIGH));
+
+ }
+
+ private void exchangeObuType(int obuType) {
+ SharedPrefsMgr.getInstance(getContext()).putInt("OBU_TYPE", obuType);
+ DebugConfig.setObuType(obuType);
+ Intent intent = new Intent("com.mogo.launcher.v2x.action.EXCHANGE_OBU_TYPE");
+ intent.putExtra("obuType", obuType);
+ getContext().sendBroadcast(intent);
+ }
}
diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/live/CameraLiveGSYVideoView.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/live/CameraLiveGSYVideoView.java
index 19c37173f7..2f39286ae9 100644
--- a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/live/CameraLiveGSYVideoView.java
+++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/live/CameraLiveGSYVideoView.java
@@ -113,7 +113,7 @@ public class CameraLiveGSYVideoView extends LiveRoundLayout implements IMogoSkin
private void playLiveVideo(String liveUrl) {
try {
if (mLivePlayer != null) {
- mLivePlayer.startPlay(liveUrl, TXLivePlayer.PLAY_TYPE_LIVE_RTMP);
+ mLivePlayer.startPlay(liveUrl, TXLivePlayer.PLAY_TYPE_LIVE_FLV);
mLivePlayer.setPlayListener(new ITXLivePlayListener() {
@Override
public void onPlayEvent(int event, Bundle bundle) {
diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/live/CameraWindow3DAdapter.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/live/CameraWindow3DAdapter.java
new file mode 100644
index 0000000000..d87fcb9e0f
--- /dev/null
+++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/live/CameraWindow3DAdapter.java
@@ -0,0 +1,33 @@
+package com.mogo.module.extensions.live;
+
+import android.content.Context;
+import android.view.View;
+
+import com.mogo.map.marker.IMogoInfoWindowAdapter;
+import com.mogo.map.marker.IMogoMarker;
+import com.mogo.map.marker.MogoMarkerOptions;
+import com.mogo.module.common.drawer.marker.IMarkerView;
+import com.mogo.module.common.drawer.marker.MapCameraInfoView;
+import com.mogo.module.common.drawer.marker.MapMarkerAdapter;
+import com.mogo.module.common.drawer.marker.MapMarkerView;
+import com.mogo.module.common.entity.MarkerShowEntity;
+
+/**
+ * @author lixiaopeng
+ * @since 2020/12/16
+ * 描述
+ */
+public class CameraWindow3DAdapter implements IMogoInfoWindowAdapter {
+ private Context mContext;
+ private MogoMarkerOptions mOptions;
+
+ public CameraWindow3DAdapter(Context context, MogoMarkerOptions options) {
+ this.mContext = context;
+ this.mOptions = options;
+ }
+
+ @Override
+ public View getInfoWindow(IMogoMarker marker) {
+ return new MapCameraInfoView(mContext, mOptions);
+ }
+}
diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/navi/VrModeNavInfoView.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/navi/VrModeNavInfoView.java
index f736c8b38d..43b17f467a 100644
--- a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/navi/VrModeNavInfoView.java
+++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/navi/VrModeNavInfoView.java
@@ -88,6 +88,9 @@ public class VrModeNavInfoView extends BaseNaviInfoView implements Handler.Callb
}
}
+ private int[] lightArray = new int[4];
+ private String[] surplusTimeArray = new String[4];
+
/**
* 刷新红绿灯显示状态
*
@@ -95,10 +98,22 @@ public class VrModeNavInfoView extends BaseNaviInfoView implements Handler.Callb
* @param surplusTime 固定数组长度为4的剩余时长数组,从0-3依次代表 掉头,左转,执行,右转
*/
public void refreshTrafficLightStatus(int[] laneLight, String[] surplusTime) {
+ lightArray = laneLight;
+ surplusTimeArray = surplusTime;
+
turnAroundLight.setTrafficLightStatus(laneLight[0], surplusTime[0]);
turnLeftLight.setTrafficLightStatus(laneLight[1], surplusTime[1]);
straightLight.setTrafficLightStatus(laneLight[2], surplusTime[2]);
turnRightLight.setTrafficLightStatus(laneLight[3], surplusTime[3]);
+ // todo 再根据当前所在车道,置灰不需关注的灯
+
+ }
+
+ /**
+ * 根据所在车道,控制红绿灯展示
+ */
+ public void refreshLaneStatus(){
+
}
@Override
diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/net/DelayCheckApiServices.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/net/DelayCheckApiServices.java
new file mode 100644
index 0000000000..a4089b37e3
--- /dev/null
+++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/net/DelayCheckApiServices.java
@@ -0,0 +1,26 @@
+package com.mogo.module.extensions.net;
+
+import com.mogo.commons.data.BaseData;
+
+import java.util.Map;
+
+import io.reactivex.Observable;
+import retrofit2.http.FieldMap;
+import retrofit2.http.FormUrlEncoded;
+import retrofit2.http.GET;
+import retrofit2.http.POST;
+
+/**
+ * 时延验证相关接口
+ *
+ * @author tongchenfei
+ */
+public interface DelayCheckApiServices {
+
+ @GET("/")
+ Observable emptyInterface();
+
+ @POST("/")
+ @FormUrlEncoded
+ Observable uploadDelayCheckData(@FieldMap Map params);
+}
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 0eb32beb06..b27e21bfd1 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
@@ -21,6 +21,7 @@ import com.mogo.service.connection.IMogoOnWebSocketMessageListener;
import com.mogo.service.connection.WebSocketMsgType;
import com.mogo.utils.logger.Logger;
+import org.json.JSONArray;
import org.json.JSONObject;
/**
@@ -33,9 +34,9 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
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_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 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;
@@ -53,23 +54,14 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
private VrModeNavInfoView vrModeNavInfoView;
- private Handler handler = new Handler(this);
-
- private boolean isObuLightData = false;
-
-
- private boolean lightCenter = true;
+ private final Handler handler = new Handler(this);
public void init(Context context) {
this.context = context;
- if (!lightCenter) {
- }
Logger.d(TAG, "init====");
}
public void initView(VrModeNavInfoView vrModeNavInfoView) {
- if (lightCenter) {
- }
this.vrModeNavInfoView = vrModeNavInfoView;
}
@@ -84,10 +76,9 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
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);
- }
+ // 先不监听服务端下发消息
+// MogoApisHandler.getInstance().getApis().getWebSocketManagerApi(context).registerOnWebSocketMessageListener(this);
+
}
}
@@ -96,11 +87,9 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
if (isVrMode) {
isVrMode = false;
MogoApisHandler.getInstance().getApis().getAdasControllerApi().showADAS();
- handler.removeMessages(MSG_REFRESH_CAR_STRATEGY);
MogoApisHandler.getInstance().getApis().getAdasControllerApi().removeAdasWarnMessageCallback(this);
MogoApisHandler.getInstance().getApis().getRegisterCenterApi().unregisterMogoLocationListener(TAG);
- MogoApisHandler.getInstance().getApis().getWebSocketManagerApi(context).unregisterOnWebSocketMessageListener(this);
-
+// MogoApisHandler.getInstance().getApis().getWebSocketManagerApi(context).unregisterOnWebSocketMessageListener(this);
context.unregisterReceiver(adasReceiver);
}
}
@@ -129,44 +118,15 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
return;
}
currentSpeed = (int) (location.getSpeed() * 3.6F);
- if (lightCenter) {
- }
}
@Override
public boolean handleMessage(Message msg) {
switch (msg.what) {
- case MSG_REFRESH_CAR_STRATEGY:
- // todo 暂时不采用此种渲染方式
- // 自车速度
- // todo 设置字体颜色、背景颜色、leftDrawable
- switch (lightStatus) {
- case "Y":
- // 黄灯
- break;
- case "R":
- // 红灯
- break;
- default:
- // 默认绿灯
- break;
- }
-
- if (isVrMode) {
- handler.sendEmptyMessageDelayed(MSG_REFRESH_CAR_STRATEGY, STRATEGY_DELAY);
- }
- return true;
case MSG_HIDE_LIMIT_SPEED:
limitSpeed = -1;
return true;
- case MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD:
- if (!isObuLightData && !handler.hasMessages(MSG_HIDE_TRAFFIC_LIGHT_BY_OBU)) {
- }
- return true;
case MSG_HIDE_TRAFFIC_LIGHT_BY_OBU:
- isObuLightData = false;
- if (!handler.hasMessages(MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD)) {
- }
return true;
default:
return false;
@@ -209,7 +169,17 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
String lightStatus = jsonObject.optString("lightStatus");
String surplusTime = jsonObject.optString("surplusTime");
if (!lightStatus.isEmpty() && !surplusTime.isEmpty()) {
- handleObuTrafficLightInfo(lightStatus, surplusTime);
+// String strArray = jsonObject.getString("lightArray");
+// Logger.d(TAG, "strArray: " + strArray);
+ JSONArray lightJsonArray = jsonObject.getJSONArray("lightArray");
+ JSONArray timeJsonArray = jsonObject.getJSONArray("surplusTimeArray");
+ int[] lightArray = new int[4];
+ String[] surplusTimeArray = new String[4];
+ for (int i = 0; i < 4; i++) {
+ lightArray[i] = lightJsonArray.getInt(i);
+ surplusTimeArray[i] = timeJsonArray.getString(i);
+ }
+ handleObuTrafficLightInfo(lightArray, surplusTimeArray);
} else {
Logger.d(TAG, "红绿灯必要信息都为空,不做展示");
}
@@ -224,22 +194,8 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
}
}
- private void handleObuTrafficLightInfo(String lightStatus, String surplusTime) {
- isObuLightData = true;
- }
-
- private void handleCloudTrafficLight(CloudRoadData roadData) {
- if (isObuLightData) {
- handler.removeMessages(MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD);
- return;
- }
- }
-
- private void drawTrafficLight(String lightStatus, String surplusTime) {
- this.lightStatus = lightStatus;
- this.surplusTime = surplusTime;
- if (lightCenter) {
- }
+ private void handleObuTrafficLightInfo(int[] lightArray,String[] surplusTimeArray) {
+ vrModeNavInfoView.refreshTrafficLightStatus(lightArray, surplusTimeArray);
}
@Override
@@ -254,14 +210,6 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
@Override
public void onMsgReceived(MogoSnapshotSetData obj) {
- Logger.d(TAG, "收到大而全数据: " + obj);
- CloudRoadData roadData = obj.getTrafficLight();
- 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/CameraLiveNoticeHelper.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/utils/CameraLiveNoticeHelper.java
index ea620b0f1f..d796926105 100644
--- a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/utils/CameraLiveNoticeHelper.java
+++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/utils/CameraLiveNoticeHelper.java
@@ -4,15 +4,20 @@ import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;
+import android.view.View;
+import com.mogo.commons.AbsMogoApplication;
+import com.mogo.map.marker.IMogoInfoWindowAdapter;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.IMogoMarkerClickListener;
import com.mogo.map.marker.MogoMarkerOptions;
import com.mogo.module.common.MogoApisHandler;
+import com.mogo.module.common.drawer.marker.RoadConditionInfoWindow3DAdapter;
import com.mogo.module.common.entity.CloudRoadData;
import com.mogo.module.common.entity.MogoSnapshotSetData;
import com.mogo.module.extensions.R;
import com.mogo.module.extensions.live.CameraLiveManager;
+import com.mogo.module.extensions.live.CameraWindow3DAdapter;
import com.mogo.module.extensions.live.ExtensionServiceManager;
import com.mogo.module.extensions.live.PushDataType;
import com.mogo.service.connection.IMogoOnWebSocketMessageListener;
@@ -23,28 +28,18 @@ import com.mogo.utils.logger.Logger;
/**
* vr模式下,红绿灯消息 AdasNoticeHelper
- *
*/
public class CameraLiveNoticeHelper implements IMogoOnWebSocketMessageListener {
private static final String TAG = "liyz";
private Context mContext;
private static IMogoMarker mMogoMarker;
private CloudRoadData mCloudRoadData;
-
+ private boolean isFirst;
public void init(Context context) {
Logger.d(TAG, "init ======= ");
mContext = context;
- //test
-// UiThreadHandler.postDelayed( () -> {
-// mCloudRoadData = new CloudRoadData();
-// mCloudRoadData.setRtmpUrl("rtmp://58.200.131.2:1935/livetv/hunantv");
-// mCloudRoadData.setLat(40.200353);
-// mCloudRoadData.setLon(116.745467);
-//// CameraLiveManager.getInstance().init(mCloudRoadData);
-// addCameraMarker(mCloudRoadData);
-// }, 2_000 );
}
public void enterVrMode() {
@@ -64,16 +59,35 @@ public class CameraLiveNoticeHelper implements IMogoOnWebSocketMessageListener {
+// mCloudRoadData = new CloudRoadData();
+//// mCloudRoadData.setRtmpUrl("rtmp://58.200.131.2:1935/livetv/hunantv");
+// mCloudRoadData.setRtmpUrl("http://video.zhidaozhixing.com/live/rec_12_22.flv");
+//
+// mCloudRoadData.setLat(39.969089);
+// mCloudRoadData.setLon(116.418009);
+//
+//// CameraLiveManager.getInstance().init(mCloudRoadData);
+// addCameraMarker(mCloudRoadData);
+// }, 2_000);
+// }
+
}
public void exitVrMode() {
Logger.d(TAG, "退出vr模式===");
+// removeCameraMarker();
+// isFirst = false;
MogoApisHandler.getInstance().getApis().getWebSocketManagerApi(mContext).unregisterOnWebSocketMessageListener(this);
}
/**
* PushRoadConditionDrawer
+ *
* @param roadData
*/
private void addCameraMarker(CloudRoadData roadData) {
@@ -84,12 +98,13 @@ public class CameraLiveNoticeHelper implements IMogoOnWebSocketMessageListener {
+ Logger.e(TAG, "onMsgReceived mCloudRoadData == null ");
+ UiThreadHandler.postDelayed(() -> {
removeCameraMarker();
- }, 1_000 );
+ }, 1_000);
}
} else {
Log.e(TAG, "onMsgReceived obj == null ");
diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/utils/DelayCheckUtil.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/utils/DelayCheckUtil.java
new file mode 100644
index 0000000000..d4dc6cebf2
--- /dev/null
+++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/utils/DelayCheckUtil.java
@@ -0,0 +1,121 @@
+package com.mogo.module.extensions.utils;
+
+import android.content.Context;
+import android.os.Handler;
+import android.os.Message;
+import android.os.SystemClock;
+
+import com.mogo.commons.data.BaseData;
+import com.mogo.commons.network.SubscribeImpl;
+import com.mogo.module.common.MogoApisHandler;
+import com.mogo.module.extensions.net.DelayCheckApiServices;
+import com.mogo.module.extensions.net.DztHttpConstant;
+import com.mogo.utils.NetworkUtils;
+import com.mogo.utils.network.RequestOptions;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import io.reactivex.schedulers.Schedulers;
+
+/**
+ * 延时验证工具类
+ *
+ * @author tongchenfei
+ */
+public class DelayCheckUtil implements Handler.Callback {
+
+ private final Handler handler = new Handler(this);
+
+ private static final int MSG_CHECK_NET_CONNECT_STATUS = 1001;
+ private static final long CHECK_NET_CONNECT_STATUS_DELAY = 5000L;
+
+ private static final int MSG_START_DELAY_CHECK = 1002;
+ private static final long DELAY_CHECK_DELAY = 10 * 60 * 1000;
+
+ private Context context;
+
+ public DelayCheckUtil(Context context) {
+ this.context = context;
+ }
+
+ /**
+ * 每5s检查一下网络状态,网络状态为连接状态时,开始空接口请求以及后续的参数上报
+ */
+ public void waitingForCheck() {
+ handler.sendEmptyMessageDelayed(MSG_CHECK_NET_CONNECT_STATUS, CHECK_NET_CONNECT_STATUS_DELAY);
+ }
+
+ private long requestTime, netDelay;
+
+ @Override
+ public boolean handleMessage(Message msg) {
+ switch (msg.what) {
+ case MSG_CHECK_NET_CONNECT_STATUS:
+ if (NetworkUtils.isConnected(context)) {
+ handler.sendEmptyMessage(MSG_START_DELAY_CHECK);
+ } else {
+ handler.sendEmptyMessageDelayed(MSG_CHECK_NET_CONNECT_STATUS, CHECK_NET_CONNECT_STATUS_DELAY);
+ }
+ return true;
+ case MSG_START_DELAY_CHECK:
+ // 请求空接口
+ startEmptyRequest();
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ private void startEmptyRequest() {
+ requestTime = SystemClock.elapsedRealtime();
+ MogoApisHandler.getInstance().getApis().getNetworkApi()
+ .create(DelayCheckApiServices.class, DztHttpConstant.getBaseUrl())
+ .emptyInterface().subscribeOn(Schedulers.io()).observeOn(Schedulers.io())
+ .subscribe(new SubscribeImpl(RequestOptions.create(context)) {
+ @Override
+ public void onSuccess(BaseData o) {
+ super.onSuccess(o);
+ netDelay = SystemClock.elapsedRealtime() - requestTime;
+
+ startUpload();
+
+ }
+
+ @Override
+ public void onError(Throwable e) {
+ super.onError(e);
+ }
+
+ @Override
+ public void onError(String message, int code) {
+ super.onError(message, code);
+ }
+ });
+ }
+
+ private void startUpload(){
+ Map params = new HashMap<>();
+ MogoApisHandler.getInstance().getApis().getNetworkApi()
+ .create(DelayCheckApiServices.class, DztHttpConstant.getBaseUrl())
+ .uploadDelayCheckData(params).observeOn(Schedulers.io()).subscribeOn(Schedulers.io())
+ .subscribe(new SubscribeImpl(RequestOptions.create(context)) {
+ @Override
+ public void onSuccess(BaseData o) {
+ super.onSuccess(o);
+
+ handler.sendEmptyMessageDelayed(MSG_START_DELAY_CHECK, DELAY_CHECK_DELAY);
+ }
+
+ @Override
+ public void onError(String message, int code) {
+ super.onError(message, code);
+ }
+
+ @Override
+ public void onError(Throwable e) {
+ super.onError(e);
+ }
+ });
+ }
+}
diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/view/VerticalTrafficLightView.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/view/VerticalTrafficLightView.java
index e16882fbcb..aa20aae227 100644
--- a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/view/VerticalTrafficLightView.java
+++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/view/VerticalTrafficLightView.java
@@ -13,12 +13,18 @@ import androidx.annotation.IntDef;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.Group;
+import com.mogo.module.common.constants.TrafficLightConst;
import com.mogo.module.extensions.R;
import com.mogo.utils.logger.Logger;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import static com.mogo.module.common.constants.TrafficLightConst.TRAFFIC_LIGHT_COLOR_GRAY;
+import static com.mogo.module.common.constants.TrafficLightConst.TRAFFIC_LIGHT_COLOR_GREEN;
+import static com.mogo.module.common.constants.TrafficLightConst.TRAFFIC_LIGHT_COLOR_RED;
+import static com.mogo.module.common.constants.TrafficLightConst.TRAFFIC_LIGHT_COLOR_YELLOW;
+
/**
* vr模式下的纵向显示的红绿灯封装
*
@@ -26,10 +32,6 @@ import java.lang.annotation.RetentionPolicy;
*/
public class VerticalTrafficLightView extends ConstraintLayout {
private static final String TAG = "VerticalTrafficLightView";
- public static final int TRAFFIC_LIGHT_COLOR_GRAY = 0;
- public static final int TRAFFIC_LIGHT_COLOR_RED = 1;
- public static final int TRAFFIC_LIGHT_COLOR_YELLOW = 2;
- public static final int TRAFFIC_LIGHT_COLOR_GREEN = 3;
private ImageView ivTrafficLight, ivNoLeftTime;
private TextView tvLeftTime, tvLeftTimeUnit;
@@ -90,7 +92,7 @@ public class VerticalTrafficLightView extends ConstraintLayout {
/**
* 设置红绿灯的颜色,根据颜色来展示不同的效果
*
- * @param color 红绿灯颜色{@link #TRAFFIC_LIGHT_COLOR_GRAY},{@link #TRAFFIC_LIGHT_COLOR_RED}等四个颜色
+ * @param color 红绿灯颜色{@link TrafficLightConst#TRAFFIC_LIGHT_COLOR_GRAY},{@link TrafficLightConst#TRAFFIC_LIGHT_COLOR_RED}等四个颜色
*/
private void setTrafficLightColor(@TrafficLightColor int color) {
if (iconRes == null) {
@@ -123,7 +125,7 @@ public class VerticalTrafficLightView extends ConstraintLayout {
/**
* 设置红绿灯状态,需设置颜色及时长
*
- * @param color 红绿灯颜色,使用{@link #TRAFFIC_LIGHT_COLOR_RED}等四个值
+ * @param color 红绿灯颜色,使用{@link TrafficLightConst#TRAFFIC_LIGHT_COLOR_RED}等四个值
* @param leftTime 剩余时长,null或者empty表示没有时长数据
*/
public void setTrafficLightStatus(@TrafficLightColor int color, String leftTime) {
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/icon_space.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/icon_space.png
new file mode 100644
index 0000000000..a2350b85a8
Binary files /dev/null and b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/icon_space.png differ
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-mdpi/icon_space.png b/modules/mogo-module-extensions/src/main/res/drawable-mdpi/icon_space.png
new file mode 100644
index 0000000000..a2350b85a8
Binary files /dev/null and b/modules/mogo-module-extensions/src/main/res/drawable-mdpi/icon_space.png differ
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/icon_space.png b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/icon_space.png
new file mode 100644
index 0000000000..a2350b85a8
Binary files /dev/null and b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/icon_space.png differ
diff --git a/modules/mogo-module-extensions/src/main/res/layout/include_debug_panel.xml b/modules/mogo-module-extensions/src/main/res/layout/include_debug_panel.xml
new file mode 100644
index 0000000000..4242b5b5e6
--- /dev/null
+++ b/modules/mogo-module-extensions/src/main/res/layout/include_debug_panel.xml
@@ -0,0 +1,139 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-extensions/src/main/res/layout/include_navi_in_vr.xml b/modules/mogo-module-extensions/src/main/res/layout/include_navi_in_vr.xml
index e6efac5899..1a2d4c4241 100644
--- a/modules/mogo-module-extensions/src/main/res/layout/include_navi_in_vr.xml
+++ b/modules/mogo-module-extensions/src/main/res/layout/include_navi_in_vr.xml
@@ -39,7 +39,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/module_ext_navi_in_vr_speed_margin_start"
- android:text="78"
+ android:text="--"
android:textColor="#fff"
android:textSize="@dimen/module_ext_navi_in_vr_speed_text_size"
app:layout_constraintBottom_toTopOf="@id/module_ext_id_navi_in_vr_traffic_bg"
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 b1610caf4c..a5fa25e1ed 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
@@ -219,6 +219,7 @@
android:layout_marginBottom="@dimen/module_ext_enter_vr_mode_margin_bottom"
android:background="@drawable/module_ext_dw_upload_road_condition_bkg"
android:gravity="center"
+ android:visibility="gone"
android:text="VR"
android:textColor="#fff"
android:textSize="@dimen/module_ext_enter_vr_mode_text_size"
@@ -352,4 +353,9 @@
android:visibility="gone"
app:constraint_referenced_ids="etTimes,btnFix" />
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_entrance_no_map.xml b/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_entrance_no_map.xml
index 198630bc6f..4203beedc3 100644
--- a/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_entrance_no_map.xml
+++ b/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_entrance_no_map.xml
@@ -295,4 +295,8 @@
android:visibility="gone"
app:constraint_referenced_ids="btnShowDrawableTipNoSize,btnShowDrawableTip,btnShowTextTip,btnDebugCtrlNaviView,btnDebugCtrlSubView,btnDebugCtrlTopView,btnDebugAddBottomLayerView" />
+
\ No newline at end of file
diff --git a/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_extensions.xml b/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_extensions.xml
index d2f8f84db5..5cb5722d03 100644
--- a/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_extensions.xml
+++ b/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_extensions.xml
@@ -8,15 +8,15 @@
android:id="@+id/module_ext_id_weather_container"
android:layout_width="wrap_content"
android:layout_height="@dimen/module_ext_height"
+ android:layout_marginStart="@dimen/module_ext_weather_margin_start"
android:background="@drawable/module_ext_shadow_bkg"
android:gravity="center"
android:paddingStart="@dimen/module_ext_weather_container_paddingLeft"
android:paddingEnd="@dimen/module_ext_weather_container_paddingRight"
android:visibility="invisible"
- app:layout_goneMarginLeft="@dimen/module_ext_notice_margin_start"
- app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toRightOf="@+id/module_ext_id_msg"
- android:layout_marginStart="@dimen/module_ext_weather_margin_start"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_goneMarginLeft="@dimen/module_ext_notice_margin_start"
tools:visibility="visible">
@@ -73,26 +73,35 @@
android:id="@+id/ivUserHeadBoard"
android:layout_width="@dimen/module_ext_user_avator_board_size"
android:layout_height="@dimen/module_ext_user_avator_board_size"
- android:background="@drawable/model_ext_default_user_head_board"
- android:layout_marginRight="@dimen/module_common_shadow_width_pos"
android:layout_marginTop="@dimen/module_common_shadow_width_pos"
+ android:layout_marginRight="@dimen/module_common_shadow_width_pos"
+ android:background="@drawable/model_ext_default_user_head_board"
app:layout_constraintRight_toRightOf="parent"
- app:layout_constraintTop_toTopOf="parent"/>
+ app:layout_constraintTop_toTopOf="parent" />
+ app:layout_constraintTop_toTopOf="@id/ivUserHeadBoard"
+ tools:visibility="visible" />
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-extensions/src/main/res/values/dimens.xml b/modules/mogo-module-extensions/src/main/res/values/dimens.xml
index 30d6518fb6..ea9ab4a5eb 100644
--- a/modules/mogo-module-extensions/src/main/res/values/dimens.xml
+++ b/modules/mogo-module-extensions/src/main/res/values/dimens.xml
@@ -214,8 +214,8 @@
464px
304px
- 20px
- 8px
+ 40px
+ 28px
100px
60px
48px
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 664c95a6ef..e23dc28f2f 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
@@ -34,6 +34,7 @@ import com.mogo.service.fragmentmanager.IMogoFragmentManager;
import com.mogo.service.module.IMogoModuleProvider;
import com.mogo.service.statusmanager.IMogoStatusManager;
import com.mogo.skin.support.SkinMode;
+import com.mogo.utils.NetworkUtils;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.logger.Logger;
import com.zhidao.adasconfig.api.AdasConfigApiController;
@@ -140,6 +141,8 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
super.onCreate( savedInstanceState );
ContextHolderUtil.holdContext(this);
mPresenter.postLoadModuleMsg();
+
+ NetworkUtils.listenNetStrength(this);
}
private void init() {
diff --git a/modules/mogo-module-media/src/main/java/com/mogo/module/media/utils/Utils.java b/modules/mogo-module-media/src/main/java/com/mogo/module/media/utils/Utils.java
index fdf9aaf338..6918d3fa10 100644
--- a/modules/mogo-module-media/src/main/java/com/mogo/module/media/utils/Utils.java
+++ b/modules/mogo-module-media/src/main/java/com/mogo/module/media/utils/Utils.java
@@ -26,6 +26,38 @@ import java.util.List;
public class Utils {
+ /**
+ * 将px值转换为dip或dp值,保证尺寸大小不变
+ */
+ public static int px2dip(Context context, float pxValue) {
+ final float scale = context.getResources().getDisplayMetrics().density;
+ return (int) (pxValue / scale + 0.5f);
+ }
+
+ /**
+ * 将dip或dp值转换为px值,保证尺寸大小不变
+ */
+ public static int dip2px(Context context, float dipValue) {
+ final float scale = context.getResources().getDisplayMetrics().density;
+ return (int) (dipValue * scale + 0.5f);
+ }
+
+ /**
+ * 将px值转换为sp值,保证文字大小不变
+ */
+ public static int px2sp(Context context, float pxValue) {
+ final float fontScale = context.getResources().getDisplayMetrics().scaledDensity;
+ return (int) (pxValue / fontScale + 0.5f);
+ }
+
+ /**
+ * 将sp值转换为px值,保证文字大小不变
+ */
+ public static int sp2px(Context context, float spValue) {
+ final float fontScale = context.getResources().getDisplayMetrics().scaledDensity;
+ return (int) (spValue * fontScale + 0.5f);
+ }
+
/**
* 验证手机格式
*/
diff --git a/modules/mogo-module-media/src/main/java/com/mogo/module/media/widget/CircleNumberProgress.java b/modules/mogo-module-media/src/main/java/com/mogo/module/media/widget/CircleNumberProgress.java
new file mode 100644
index 0000000000..ecd1fa5405
--- /dev/null
+++ b/modules/mogo-module-media/src/main/java/com/mogo/module/media/widget/CircleNumberProgress.java
@@ -0,0 +1,219 @@
+package com.mogo.module.media.widget;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.Path;
+import android.graphics.Rect;
+import android.graphics.RectF;
+import android.util.AttributeSet;
+import android.view.View;
+
+import com.mogo.module.media.R;
+import com.mogo.module.media.utils.Utils;
+
+/**
+ * @author lixiaopeng
+ * @description
+ * @since 2020/12/15
+ */
+public class CircleNumberProgress extends View {
+ /** 进度条画笔的宽度(dp) */
+ private int paintProgressWidth = 4;
+
+ /** 文字百分比的字体大小(sp) */
+ private int paintTextSize = 20;
+
+ /** 未完成进度条的颜色 */
+// private int paintUndoneColor = 0xffaaaaaa;
+ private int paintUndoneColor;
+
+ /** 已完成进度条的颜色 */
+// private int paintDoneColor = 0xff67aae4;
+ private int paintDoneColor;
+
+ /** 百分比文字的颜色 */
+ private int paintTextColor = 0xffff0077;
+
+ /** 设置进度条画笔的宽度(px) */
+ private int paintProgressWidthPx;
+
+ /** 文字画笔的尺寸(px) */
+ private int paintTextSizePx;
+ /** Context上下文环境 */
+ private Context context;
+
+ /** 调用者设置的进程 0 - 100 */
+ private int progress;
+
+ /** 画未完成进度圆弧的画笔 */
+ private Paint paintUndone = new Paint();
+
+ /** 画已经完成进度条的画笔 */
+ private Paint paintDone = new Paint();
+
+ /** 画文字的画笔 */
+// private Paint paintText = new Paint();
+
+ /** 包围进度条圆弧的矩形 */
+ private RectF rectF = new RectF();
+
+ /** 包围文字所在路径圆弧的矩形,比上一个矩形略小 */
+ private RectF rectF2 = new RectF();
+
+ /** 进度文字所在的路径 */
+ private Path path = new Path();
+
+ /** 文字所在路径圆弧的半径 */
+ private int radiusText;
+
+ /** 是否进行过了测量 */
+ private boolean isMeasured = false;
+
+ public CircleNumberProgress(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ this.context = context;
+ TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.PercentageRing);
+ //中间圆的背景颜色 默认为浅紫色
+ paintUndoneColor = typedArray.getColor(R.styleable.PercentageRing_circleBackground, 0xffafb4db);
+ //外圆环的颜色 默认为深紫色
+ paintDoneColor = typedArray.getColor(R.styleable.PercentageRing_ringColor, 0xff6950a1);
+
+ // 构造器中初始化数据
+ initData();
+ }
+
+ /** 初始化数据 */
+ private void initData() {
+
+ // 设置进度条画笔的宽度
+ paintProgressWidthPx = Utils.dip2px(context, paintProgressWidth);
+
+ // 设置文字画笔的尺寸(px)
+ paintTextSizePx = Utils.sp2px(context, paintTextSize);
+
+ // 未完成进度圆环的画笔的属性
+ paintUndone.setColor(paintUndoneColor);
+ paintUndone.setStrokeWidth(paintProgressWidthPx);
+ paintUndone.setAntiAlias(true);
+ paintUndone.setStyle(Paint.Style.STROKE);
+
+ // 已经完成进度条的画笔的属性
+ paintDone.setColor(paintDoneColor);
+ paintDone.setStrokeWidth(paintProgressWidthPx);
+ paintDone.setAntiAlias(true);
+ paintDone.setStyle(Paint.Style.STROKE);
+
+ // 文字的画笔的属性
+// paintText.setColor(paintTextColor);
+// paintText.setTextSize(paintTextSizePx);
+// paintText.setAntiAlias(true);
+// paintText.setStyle(Paint.Style.STROKE);
+// paintText.setTypeface(Typeface.DEFAULT_BOLD);
+
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ if (!isMeasured) {
+ getWidthAndHeight();
+ isMeasured = true;
+ }
+ }
+
+ /** 得到视图等的高度宽度尺寸数据 */
+ private void getWidthAndHeight() {
+ // 得到自定义视图的高度
+ int viewHeight;
+
+ // 得到自定义视图的宽度
+ int viewWidth;
+
+ // 得到自定义视图的X轴中心点
+ int viewCenterX;
+
+ // 得到自定义视图的Y轴中心点
+ int viewCenterY;
+
+ viewHeight = getMeasuredHeight();
+ viewWidth = getMeasuredWidth();
+ viewCenterX = viewWidth / 2;
+ viewCenterY = viewHeight / 2;
+
+ // 取本View长宽较小者的一半为整个圆环部分(包括圆环和文字)最外侧的半径
+ int minLenth = viewHeight > viewWidth ? viewWidth / 2 : viewHeight / 2;
+
+ // 比较文字高度和圆环宽度,如果文字高度较大,那么文字将突破圆环,否则,圆环会把文字包裹在内部
+ Rect rect = new Rect();
+// paintText.getTextBounds("100%", 0, "100%".length(), rect);
+ int textHeight = rect.height();
+
+ // 得到圆环的中间半径(外径和内径平均值)
+ int radiusArc = minLenth - (paintProgressWidthPx > textHeight ? paintProgressWidthPx / 2 : textHeight / 2);
+ rectF.left = viewCenterX - radiusArc;
+ rectF.top = viewCenterY - radiusArc;
+ rectF.right = viewCenterX + radiusArc;
+ rectF.bottom = viewCenterY + radiusArc;
+
+ // 文字所依赖路径圆弧的半径
+ radiusText = radiusArc - textHeight / 2;
+ rectF2.left = viewCenterX - radiusText;
+ rectF2.top = viewCenterY - radiusText;
+ rectF2.right = viewCenterX + radiusText;
+ rectF2.bottom = viewCenterY + radiusText;
+
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+
+ // 画未完成进度的圆环
+ canvas.drawArc(rectF, 0, 360, false, paintUndone);
+
+ // 画已经完成进度的圆弧 从-90度开始,即从圆环顶部开始
+ canvas.drawArc(rectF, -90, progress / 100.0f * 360, false, paintDone);
+
+ // 为文字所在路径添加一段圆弧轨迹,进度为0%-9%时应该最短,进度为10%-99%时应该边长,进度为100%时应该最长
+ // 这样才能保证文字和圆弧的进度一致,不会出现超前或者滞后的情况
+
+ // 要画的文字
+ String text = progress + "%";
+
+ // 存储字符所有字符所占宽度的数组
+ float[] widths = new float[text.length()];
+
+ // 得到所有字符所占的宽度
+// paintText.getTextWidths(text, 0, text.length(), widths);
+
+ // 所有字符所占宽度之和
+ float textWidth = 0;
+ for (float f : widths) {
+ textWidth += f;
+ }
+
+ // 根据长度得到路径对应的扫过的角度
+ // width = sweepAngle * 2 * π * R / 360 ; sweepAngle = width * 360 / 2 /
+ // π / R
+ float sweepAngle = (float) (textWidth * 360 / 2 / Math.PI / radiusText);
+
+ // 添加路径
+ path.addArc(rectF2, progress * 3.6f - 90.0f - sweepAngle / 2.0f, sweepAngle);
+
+ // 绘制进度的文字
+// canvas.drawTextOnPath(text, path, 0, 0, paintText);
+
+ // 重置路径
+ path.reset();
+ }
+
+ /**
+ * @param progress 外部传进来的当前进度,强制重绘
+ */
+ public void setProgress(int progress) {
+ this.progress = progress;
+ invalidate();
+ }
+}
diff --git a/modules/mogo-module-media/src/main/java/com/mogo/module/media/window/MediaWindow2.java b/modules/mogo-module-media/src/main/java/com/mogo/module/media/window/MediaWindow2.java
index 1959a9947e..6acb0415ac 100644
--- a/modules/mogo-module-media/src/main/java/com/mogo/module/media/window/MediaWindow2.java
+++ b/modules/mogo-module-media/src/main/java/com/mogo/module/media/window/MediaWindow2.java
@@ -26,6 +26,7 @@ import com.mogo.module.media.presenter.PresenterFactory;
import com.mogo.module.media.utils.Utils;
import com.mogo.module.media.view.IMusicView;
import com.mogo.module.media.widget.AnimCircleImageView;
+import com.mogo.module.media.widget.CircleNumberProgress;
import com.mogo.module.media.widget.PercentageRingView;
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
import com.mogo.service.statusmanager.StatusDescriptor;
@@ -66,7 +67,7 @@ public class MediaWindow2 implements IMusicView , IMogoStatusChangedListener {
private boolean mIsCallChatWindowVisible;
private ICallProviderResponse mCallProviderResponse;
- private PercentageRingView mPercentageRingView;
+ private CircleNumberProgress mPercentageRingView;
private ImageView mPauseImage;
private AnimCircleImageView mAnimCircleImageView;
@@ -312,10 +313,10 @@ public class MediaWindow2 implements IMusicView , IMogoStatusChangedListener {
GlideApp.with(mContext).asBitmap().apply(options).load(mMediaInfoData.getMediaImg()).into(new SkinAbleBitmapTarget(mAnimCircleImageView, options));
// GlideApp.with(mContext).applyDefaultRequestOptions(options).load(mMediaInfoData.getMediaImg()).into(new SkinAbleBitmapTarget(mCircleImg, options));
}else{
+ Logger.e(TAG, "mMediaInfoData == null ");
mAnimCircleImageView.setImageResource(R.drawable.module_media_default_music_img);
}
}
-
} else {
if (mScrollText != null) {
mScrollText.setText(mMediaInfoData.getMediaName());
@@ -344,7 +345,6 @@ public class MediaWindow2 implements IMusicView , IMogoStatusChangedListener {
if(mMediaInfoData!=null&&mMediaInfoData.getMediaImg()!=null&&!mMediaInfoData.getMediaImg().isEmpty()) {
int size =
mContext.getResources().getDimensionPixelSize(R.dimen.module_media_pop_window_anim_img_size);
- Logger.d(TAG, "overload: " + size);
com.bumptech.glide.request.RequestOptions options =
new com.bumptech.glide.request.RequestOptions()
.placeholder(R.drawable.module_media_default_music_img).error(R.drawable.module_media_default_music_img).override(size, size);
@@ -458,8 +458,8 @@ public class MediaWindow2 implements IMusicView , IMogoStatusChangedListener {
(int) ((current * 1.0f * 100) / (total * 1.0f));
if (mPercentageRingView != null) {
mPercentageRingView.setVisibility(View.VISIBLE);
-// Log.d(TAG, "progress vr = " + progress);
- mPercentageRingView.setTargetPercent(progress);
+ Log.d(TAG, "progress vr = " + progress);
+ mPercentageRingView.setProgress(progress);
}
} catch (Exception e) {
e.printStackTrace();
diff --git a/modules/mogo-module-media/src/main/res/layout/module_media_music_window_alert_layout_new.xml b/modules/mogo-module-media/src/main/res/layout/module_media_music_window_alert_layout_new.xml
index 8d2d4cebc0..d36414c4b7 100644
--- a/modules/mogo-module-media/src/main/res/layout/module_media_music_window_alert_layout_new.xml
+++ b/modules/mogo-module-media/src/main/res/layout/module_media_music_window_alert_layout_new.xml
@@ -5,17 +5,28 @@
android:layout_width="@dimen/module_media_pop_window_size"
android:layout_height="@dimen/module_media_pop_window_size">
-
+ app:ringColor="@color/modules_media_music_circle_color"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+
+
+
+
+
+
+
+
+
+
+
+
112px
30px
80px
- 90px
+ 101px
60px
116px
230px
diff --git a/modules/mogo-module-media/src/main/res/values/colors.xml b/modules/mogo-module-media/src/main/res/values/colors.xml
index b0944c76eb..b6ca26aca2 100644
--- a/modules/mogo-module-media/src/main/res/values/colors.xml
+++ b/modules/mogo-module-media/src/main/res/values/colors.xml
@@ -3,5 +3,5 @@
#fff
#7affffff
#444E6E
- #B63737
+ #80ffffff
diff --git a/modules/mogo-module-media/src/main/res/values/dimens.xml b/modules/mogo-module-media/src/main/res/values/dimens.xml
index 48da6e24fd..d0351297ed 100644
--- a/modules/mogo-module-media/src/main/res/values/dimens.xml
+++ b/modules/mogo-module-media/src/main/res/values/dimens.xml
@@ -70,7 +70,7 @@
60px
18px
44px
- 55px
+ 60px
60px
123px
10px
diff --git a/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/MockUtil.kt b/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/MockUtil.kt
index 68e61eb3c7..b67be3a6fe 100644
--- a/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/MockUtil.kt
+++ b/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/MockUtil.kt
@@ -45,7 +45,7 @@ class MockUtil:Handler.Callback {
if (msg.what == 1001) {
Logger.d(TAG,"准备添加调试view")
val api = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(context) as IMogoServiceApis
- api.windowManagerApi.addView(view, 1000, 600, false)
+ api.windowManagerApi.addView(view, 500, 300, false)
}
return false
}
diff --git a/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/ObuManager.kt b/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/ObuManager.kt
index b07105f7d9..fc9d239f03 100644
--- a/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/ObuManager.kt
+++ b/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/ObuManager.kt
@@ -20,18 +20,22 @@ class ObuManager {
private lateinit var obu: IObu
private lateinit var context: Context
+ private var listener:IObuCallback? = null
+
fun init(context: Context) {
- Logger.d(TAG, "init=======")
+ Logger.d(TAG, "init=======${DebugConfig.getObuType()}")
this.context = context
- obu = if (DebugConfig.getObuType() == DebugConfig.OBU_TYPE_CIDI) {
- CidiObu()
- } else {
- HualiObu()
+ obu = when (DebugConfig.getObuType()) {
+ DebugConfig.OBU_TYPE_CIDI -> CidiObu()
+ DebugConfig.OBU_TYPE_HUALI -> HualiObu()
+ else -> NetCarObu()
}
- obu.init()
+ obu.init(context)
+
}
fun registerObuDataChangedListener(listener: IObuCallback?) {
+ this.listener = listener
if (listener != null) {
obu.registerObuCallback(listener)
if(DebugConfig.isUseMockObuData() ) {
@@ -41,5 +45,9 @@ class ObuManager {
}
}
+ fun resetObuType(obuType: Int) {
+ Logger.d(TAG, "resetObuType: $obuType")
+ obu.release()
+ }
}
\ No newline at end of file
diff --git a/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/obu/BaseObu.kt b/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/obu/BaseObu.kt
index 2f8639b00c..8f451349d9 100644
--- a/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/obu/BaseObu.kt
+++ b/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/obu/BaseObu.kt
@@ -1,11 +1,16 @@
package com.zhidao.mogo.module.obu.obu
+import android.content.Context
+
abstract class BaseObu : IObu {
var callback: IObuCallback? = null
- override fun init() {
+ override fun init(context: Context) {
}
override fun registerObuCallback(callback: IObuCallback) {
this.callback = callback
}
+
+ override fun release() {
+ }
}
\ No newline at end of file
diff --git a/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/obu/CidiObu.kt b/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/obu/CidiObu.kt
index 4ad82e0df4..4b6b561093 100644
--- a/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/obu/CidiObu.kt
+++ b/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/obu/CidiObu.kt
@@ -1,5 +1,6 @@
package com.zhidao.mogo.module.obu.obu
+import android.content.Context
import android.os.Handler
import android.os.Message
import com.mogo.commons.debug.DebugConfig
@@ -26,8 +27,8 @@ class CidiObu : BaseObu(), Handler.Callback, OnMessageReceiveListener {
}
private val handler = Handler(this)
- override fun init() {
- super.init()
+ override fun init(context: Context) {
+ super.init(context)
// 初始化sdk,注册数据回调等信息
V2xController.getInstance().setMessageReceiveListener(this)
V2xController.getInstance().init()
@@ -120,4 +121,11 @@ class CidiObu : BaseObu(), Handler.Callback, OnMessageReceiveListener {
}
return false
}
+
+ override fun release() {
+ super.release()
+ handler.removeMessages(MSG_MONITOR_OBU_STATUS)
+ V2xController.getInstance().setMessageReceiveListener(null)
+ V2xController.getInstance().release()
+ }
}
\ No newline at end of file
diff --git a/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/obu/HualiObu.kt b/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/obu/HualiObu.kt
index 222ab6d9da..aa94006777 100644
--- a/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/obu/HualiObu.kt
+++ b/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/obu/HualiObu.kt
@@ -1,5 +1,6 @@
package com.zhidao.mogo.module.obu.obu
+import android.content.Context
import android.os.Handler
import android.os.SystemClock
import android.util.ArrayMap
@@ -62,8 +63,8 @@ class HualiObu : BaseObu(), IUdpSocketCallback {
private val handler = Handler()
- override fun init() {
- super.init()
+ override fun init(context: Context) {
+ super.init(context)
socketManager.connect(IP_ADDRESS, PORT)
Logger.d(TAG, "init")
}
@@ -308,4 +309,9 @@ class HualiObu : BaseObu(), IUdpSocketCallback {
private fun convertTwoUnSignInt(byteArray: ByteArray): Int =
(byteArray[0].toInt() shl 24) or (byteArray[1].toInt() and 0xFF) or (byteArray[2].toInt() shl 8) or (byteArray[3].toInt() and 0xFF)
+ override fun release() {
+ super.release()
+ socketManager.release()
+ }
+
}
\ No newline at end of file
diff --git a/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/obu/IObu.kt b/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/obu/IObu.kt
index 7e99c1c6c5..b6e20c5f8e 100644
--- a/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/obu/IObu.kt
+++ b/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/obu/IObu.kt
@@ -1,5 +1,7 @@
package com.zhidao.mogo.module.obu.obu
+import android.content.Context
+
/**
* Obu基本方法
* @author tongchenfei
@@ -8,11 +10,15 @@ interface IObu {
/**
* 初始化
*/
- fun init()
+ fun init(context: Context)
/**
* 注册数据回调
*/
fun registerObuCallback(callback: IObuCallback)
+ /**
+ * release
+ */
+ fun release()
}
\ No newline at end of file
diff --git a/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/obu/NetCarObu.kt b/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/obu/NetCarObu.kt
new file mode 100644
index 0000000000..e7678145bf
--- /dev/null
+++ b/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/obu/NetCarObu.kt
@@ -0,0 +1,236 @@
+package com.zhidao.mogo.module.obu.obu
+
+import android.content.Context
+import android.os.Handler
+import android.os.Message
+import com.mogo.utils.logger.Logger
+import com.mogo.utils.network.utils.GsonUtil
+import com.zhidao.mogo.module.obu.ObuConstant.TYPE_OPTIMAL_SPEED_ADVISORY
+import com.zhidao.mogo.module.obu.ObuConstant.TYPE_ROAD_USER_COLLISION_WARNING
+import com.zhidao.mogo.module.obu.obu.bean.MogoObuEventInfo
+import com.zhidao.mogo.module.obu.obu.bean.MogoObuTrafficLightInfo
+import com.zhidao.mogo.module.obu.socket.IUdpSocketStatusCallback
+import com.zhidao.mogo.module.obu.socket.UdpSocketManager
+import org.json.JSONObject
+
+/**
+ * 大唐高鸿obu
+ *
+ * @author tongchenfei
+ */
+class NetCarObu : BaseObu(), IUdpSocketStatusCallback, Handler.Callback {
+ companion object {
+ const val TAG = "NetCarObu"
+ const val MSG_SEND_ACTIVATION_MSG = 1001
+ const val MSG_RECONNECT = 1002
+ const val SEND_ACTIVATION_MSG_DELAY = 4 * 1000L
+ const val RECONNECT_DELAY = 10_000L
+ const val TARGET_IP = "192.168.118.104"
+ const val TARGET_PORT = 50500
+ }
+
+ private lateinit var socketManager: UdpSocketManager
+
+ private val handler = Handler(this)
+
+ override fun init(context: Context) {
+ super.init(context)
+ Logger.d(TAG, "NetCar obu init")
+ socketManager = UdpSocketManager(context = context, useDefaultAddress = true, callback = this)
+ }
+
+ override fun isReady() {
+ Logger.d(TAG, "udp is ready")
+ // 1. 向obu注册
+ sendRegisterMsg()
+ }
+
+ private var unique: String = ""
+
+ override fun onMessageReceived(msg: ByteArray) {
+ val response = String(msg)
+ val json = JSONObject(response)
+ Logger.d(TAG, "收到消息: $json")
+ when (json.optInt("tag")) {
+ 1002 -> {
+ // 查询状态成功,准备注册
+ socketManager.defaultAddress?.let {
+ socketManager.sendMsgTo(GsonUtil.jsonFromObject(Request(2001, NcsRegisteredData(it.ip, it.port))), TARGET_IP, TARGET_PORT)
+ startReconnectTiming()
+ }
+ }
+ 2002 -> {
+ // 响应注册
+ val rsp = json.optInt("rsp", -1)
+ if (rsp == 0) {
+ // 注册成功, 等待激活
+ unique = json.optString("unique", "")
+ startActivationTiming()
+ }
+ }
+ 2004 -> {
+ // 响应解除注册
+ val rsp = json.optInt("rsp", -1)
+ if (rsp == 0) {
+ // 解除注册成功
+ socketManager.release()
+ }
+ }
+ 2006 -> {
+ // 响应激活
+ val rsp = json.optInt("rsp", -1)
+ if (rsp != 0) {
+ // 激活失败,需要重新激活
+ sendActivationMsg()
+ } else {
+ // 激活成功,重新计时
+ startActivationTiming()
+ }
+ }
+ 2104 -> {
+ // 红绿灯倒数秒数上报(车速引导)
+ val dataJson = json.optJSONObject("data")
+ if (dataJson != null) {
+// val lightInfo = dataJson.optJSONObject("phase")
+ val lightInfoArray = dataJson.optJSONArray("phase")
+
+ if (lightInfoArray != null && lightInfoArray.length() > 0) {
+ Logger.d(TAG, "lightInfo: $lightInfoArray")
+ val lightInfo = lightInfoArray.getJSONObject(0)
+
+ val trafficLightInfo = MogoObuTrafficLightInfo()
+ val color = lightInfo.optInt("color")
+ if (color in 1..3) {
+ // 有效颜色数据
+ trafficLightInfo.lightStatus = when (color) {
+ 2 -> "R"
+ 3 -> "Y"
+ else -> "G"
+ }
+ trafficLightInfo.surplusTime = lightInfo.optInt("time", 0).toString()
+ callback?.onTrafficLightInfoCallback(trafficLightInfo)
+
+// val end = lightInfo.optInt("guide_speed_max", -1)
+// val start = lightInfo.optInt("guide_speed_min", -1)
+// if (start != -1 && end != -1) {
+// val eventInfo = MogoObuEventInfo()
+// eventInfo.mogoEventId = TYPE_OPTIMAL_SPEED_ADVISORY
+// eventInfo.describe = "前方路口,建议车速 $start 到 $end km/h"
+// callback?.let {
+// handler.post {
+// it.onEventInfoCallback(eventInfo)
+// }
+// }
+// }
+
+ }
+ } else {
+ Logger.e(TAG, "红绿灯数据为空")
+ }
+ } else {
+ Logger.e(TAG, "红绿灯数据为data空")
+ }
+ }
+ 2105 -> {
+ // 事件上报
+ val event = json.optJSONObject("data")
+ if (event != null) {
+ val type = event.optInt("type", 0) % 100000
+ Logger.d(TAG, "事件id,取模后: $type")
+ if (type == 4012) {
+ // 前方行人预警
+ val eventInfo = MogoObuEventInfo()
+ eventInfo.mogoEventId = TYPE_ROAD_USER_COLLISION_WARNING
+ handler.post {
+ callback?.onEventInfoCallback(eventInfo)
+ }
+ } else if (type == 3005) {
+ // 红绿灯变灯提醒
+ val eventInfo = MogoObuEventInfo()
+ eventInfo.type = "vip变灯提醒"
+ eventInfo.typeCode = "vip变灯提醒"
+ eventInfo.describe = "将为您变灯,vip车辆可优先通行"
+ handler.post {
+ callback?.onEventInfoCallback(eventInfo)
+ }
+ }
+ } else {
+ Logger.e(TAG, "事件数据为空")
+ }
+ }
+ }
+ }
+
+ private fun sendRegisterMsg() {
+ socketManager.defaultAddress?.let {
+ socketManager.sendMsgTo(GsonUtil.jsonFromObject(Request(2001, NcsRegisteredData(it.ip, it.port))), TARGET_IP, TARGET_PORT)
+ startReconnectTiming()
+ }
+ }
+
+ /**
+ * 开启激活计时
+ */
+ private fun startActivationTiming() {
+ handler.removeMessages(MSG_SEND_ACTIVATION_MSG)
+ handler.removeMessages(MSG_RECONNECT)
+ handler.sendEmptyMessageDelayed(MSG_SEND_ACTIVATION_MSG, SEND_ACTIVATION_MSG_DELAY)
+ }
+
+ private fun startReconnectTiming() {
+ handler.removeMessages(MSG_RECONNECT)
+ handler.sendEmptyMessageDelayed(MSG_RECONNECT, RECONNECT_DELAY)
+ }
+
+ /**
+ * 发送激活数据
+ */
+ private fun sendActivationMsg() {
+ Logger.d(TAG, "准备发送激活消息====")
+ socketManager.sendMsgTo(GsonUtil.jsonFromObject(NcsActivationRequest(unique = unique)), TARGET_IP, TARGET_PORT)
+ startReconnectTiming()
+ }
+
+ override fun handleMessage(msg: Message): Boolean {
+ return when (msg.what) {
+ MSG_SEND_ACTIVATION_MSG -> {
+ sendActivationMsg()
+ true
+ }
+ MSG_RECONNECT -> {
+ if (!handler.hasMessages(MSG_SEND_ACTIVATION_MSG)) {
+ // 没有等待激活,就进行重试
+ Logger.d(TAG, "准备重连===")
+ sendRegisterMsg()
+ }
+ true
+ }
+ else -> false
+ }
+ }
+
+ val firstMsg = "{\"tag\":1001}"
+
+ override fun release() {
+ super.release()
+ // 解除注册
+ socketManager.sendMsgTo(GsonUtil.jsonFromObject(NcsUnRegisteredRequest(unique = unique)), TARGET_IP, TARGET_PORT)
+ }
+
+ data class Request(val tag: Int, val data: T)
+
+ /**
+ * 注册请求data
+ */
+ data class NcsRegisteredData(val ip: String, val port: Int)
+
+ /**
+ * 解注册请求request
+ */
+ data class NcsUnRegisteredRequest(val tag: Int = 2003, val unique: String)
+
+ /**
+ * 激活请求
+ */
+ data class NcsActivationRequest(val tag: Int = 2005, val unique: String)
+}
\ No newline at end of file
diff --git a/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/obu/bean/MogoObuTrafficLightInfo.kt b/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/obu/bean/MogoObuTrafficLightInfo.kt
index 33437fedd1..0930bbedc2 100644
--- a/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/obu/bean/MogoObuTrafficLightInfo.kt
+++ b/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/obu/bean/MogoObuTrafficLightInfo.kt
@@ -1,5 +1,6 @@
package com.zhidao.mogo.module.obu.obu.bean
+import com.mogo.module.common.constants.TrafficLightConst.*
import com.zhidao.smartv2x.model.obu.TrafficLightInfo
/**
@@ -10,20 +11,72 @@ import com.zhidao.smartv2x.model.obu.TrafficLightInfo
*
* @author tongchenfei
*/
-class MogoObuTrafficLightInfo(){
- var id:String? =null
- var lightStatus:String? =null
- var surplusTime:String? =null
- var lightPriority:String? =null
- override fun toString(): String {
- return "MogoObuTrafficLightInfo(id=$id, lightStatus=$lightStatus, surplusTime=$surplusTime, lightPriority=$lightPriority)"
- }
+class MogoObuTrafficLightInfo() {
+ var id: String? = null
+ var lightStatus: String? = null
+ set(value) {
+ field = value
+ resetLightArray(value)
+ }
+ var surplusTime: String? = null
+ set(value) {
+ field = value
+ resetSurplusTimeArray(value)
+ }
+ var lightPriority: String? = null
- constructor(info:TrafficLightInfo):this(){
+ var lightArray: IntArray = IntArray(4) { 0 }
+ var surplusTimeArray: Array = Array(4) { "" }
+
+ constructor(info: TrafficLightInfo) : this() {
this.id = info.id
this.lightStatus = info.lightStatus
this.surplusTime = info.surplusTime
this.lightPriority = info.lightPriority
+
+ resetLightArray(lightStatus)
+ resetSurplusTimeArray(surplusTime)
+ }
+
+ override fun toString(): String {
+ return "MogoObuTrafficLightInfo(id=$id, lightStatus=$lightStatus, surplusTime=$surplusTime, lightPriority=$lightPriority, lightArray=${lightArray.contentToString()}, surplusTimeArray=${surplusTimeArray.contentToString()})"
+ }
+
+ private fun resetLightArray(lightStatus: String?) {
+ when (lightStatus) {
+ "R" -> {
+ lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_AROUND] = TRAFFIC_LIGHT_COLOR_GREEN
+ lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_LEFT] = TRAFFIC_LIGHT_COLOR_RED
+ lightArray[TRAFFIC_LIGHT_DIRECTION_STRAIGHT] = TRAFFIC_LIGHT_COLOR_RED
+ lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_RIGHT] = TRAFFIC_LIGHT_COLOR_GREEN
+
+ }
+ "Y" -> {
+ lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_AROUND] = TRAFFIC_LIGHT_COLOR_GREEN
+ lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_LEFT] = TRAFFIC_LIGHT_COLOR_YELLOW
+ lightArray[TRAFFIC_LIGHT_DIRECTION_STRAIGHT] = TRAFFIC_LIGHT_COLOR_YELLOW
+ lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_RIGHT] = TRAFFIC_LIGHT_COLOR_GREEN
+ }
+ "G" -> {
+ lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_AROUND] = TRAFFIC_LIGHT_COLOR_GREEN
+ lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_LEFT] = TRAFFIC_LIGHT_COLOR_GREEN
+ lightArray[TRAFFIC_LIGHT_DIRECTION_STRAIGHT] = TRAFFIC_LIGHT_COLOR_GREEN
+ lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_RIGHT] = TRAFFIC_LIGHT_COLOR_GREEN
+ }
+ else -> {
+ lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_AROUND] = TRAFFIC_LIGHT_COLOR_GRAY
+ lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_LEFT] = TRAFFIC_LIGHT_COLOR_GRAY
+ lightArray[TRAFFIC_LIGHT_DIRECTION_STRAIGHT] = TRAFFIC_LIGHT_COLOR_GRAY
+ lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_RIGHT] = TRAFFIC_LIGHT_COLOR_GRAY
+ }
+ }
+ }
+
+ private fun resetSurplusTimeArray(surplusTime: String?) {
+ surplusTimeArray[TRAFFIC_LIGHT_DIRECTION_TURN_AROUND] = ""
+ surplusTimeArray[TRAFFIC_LIGHT_DIRECTION_TURN_LEFT] = surplusTime ?: ""
+ surplusTimeArray[TRAFFIC_LIGHT_DIRECTION_STRAIGHT] = surplusTime ?: ""
+ surplusTimeArray[TRAFFIC_LIGHT_DIRECTION_TURN_RIGHT] = ""
}
}
\ No newline at end of file
diff --git a/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/socket/ISocketMsgCallback.kt b/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/socket/ISocketMsgCallback.kt
new file mode 100644
index 0000000000..946686c74d
--- /dev/null
+++ b/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/socket/ISocketMsgCallback.kt
@@ -0,0 +1,13 @@
+package com.zhidao.mogo.module.obu.socket
+
+/**
+ * udp 数据回调
+ */
+interface ISocketMsgCallback {
+ /**
+ * udp过来的字节码数据,目前已知数据类型就是ByteArray
+ *
+ * @param msg udp发过来的数据
+ */
+ fun onMessageReceived(msg: ByteArray)
+}
\ No newline at end of file
diff --git a/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/socket/IUdpSocketStatusCallback.kt b/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/socket/IUdpSocketStatusCallback.kt
new file mode 100644
index 0000000000..9f9f6e9895
--- /dev/null
+++ b/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/socket/IUdpSocketStatusCallback.kt
@@ -0,0 +1,11 @@
+package com.zhidao.mogo.module.obu.socket
+
+/**
+ * udp状态回调
+ */
+interface IUdpSocketStatusCallback:ISocketMsgCallback {
+ /**
+ * udp连接准备完毕,指的是准备好接收数据了
+ */
+ fun isReady()
+}
\ No newline at end of file
diff --git a/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/socket/SimpleSocketManager.kt b/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/socket/SimpleSocketManager.kt
index 2dc2236e6c..827d3fd68e 100644
--- a/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/socket/SimpleSocketManager.kt
+++ b/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/socket/SimpleSocketManager.kt
@@ -72,4 +72,9 @@ class SimpleSocketManager(private val callback: IUdpSocketCallback? = null) {
fun sendMessage(msg: String) {
Logger.d(TAG, "暂不支持发送消息")
}
+
+ fun release(){
+ socket?.close()
+ dataCacheHandler.looper.quitSafely()
+ }
}
\ No newline at end of file
diff --git a/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/socket/UdpSocketManager.kt b/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/socket/UdpSocketManager.kt
index c9b2ff594b..a126510637 100644
--- a/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/socket/UdpSocketManager.kt
+++ b/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/socket/UdpSocketManager.kt
@@ -1,9 +1,13 @@
package com.zhidao.mogo.module.obu.socket
+import android.content.Context
+import android.net.wifi.WifiManager
import android.os.Handler
import android.os.HandlerThread
import android.util.ArrayMap
+import com.mogo.utils.NetworkUtils
import com.mogo.utils.logger.Logger
+import java.lang.Thread.sleep
import java.net.DatagramPacket
import java.net.DatagramSocket
import java.net.InetAddress
@@ -12,9 +16,11 @@ import java.util.concurrent.Executors
/**
* udp socket 管理类,统一管理udp socket数据接收和发送
*/
-class UdpSocketManager(private val callback: IUdpSocketCallback? = null) {
+class UdpSocketManager(val context: Context? = null, useDefaultAddress: Boolean = false, private val callback: IUdpSocketStatusCallback? = null) {
companion object {
const val TAG = "Mogo-UdpSocketManager"
+ const val DEFAULT_PORT = 50501
+ const val DEFAULT_IP = "192.168.8.169"
}
private val socketMap = ArrayMap()
@@ -23,20 +29,66 @@ class UdpSocketManager(private val callback: IUdpSocketCallback? = null) {
private val dataCacheThread = HandlerThread("obu-data-cache")
private val dataCacheHandler: Handler
+ var defaultAddress:SimpleAddress? = null
+
init {
dataCacheThread.start()
dataCacheHandler = Handler(dataCacheThread.looper)
+ if (useDefaultAddress) {
+ // 获取连接的wifi的ip地址
+ if (context == null) {
+ throw IllegalArgumentException("do not find context at constructor")
+ }else{
+// defaultAddress = SimpleAddress(DEFAULT_IP, DEFAULT_PORT)
+// receiveMsgFrom(DEFAULT_IP, DEFAULT_PORT)
+ if (NetworkUtils.isConnectedWifi(context)) {
+ // 已经判定连接到了wifi
+ generateDefaultAddress()
+ }else{
+ // 还没连接到wifi,需要等待,此处采用每隔一秒检查一次,不用再注册相关监听广播
+ dataCacheHandler.post {
+ while (!NetworkUtils.isConnectedWifi(context)) {
+ sleep(1000)
+ }
+ // 已经连接到wifi
+ generateDefaultAddress()
+ }
+ }
+ }
+ }
}
@Volatile
private var isConnected = false
fun sendMsgTo(msg: String, ip: String, port: Int) {
+ Logger.d(TAG, "sendMsg: $msg to $ip:$port")
isConnected = true
val address = SimpleAddress(ip, port)
socketExecutor.execute(UdpSenderRunnable(address, msg))
}
+ /**
+ * 仅获取连接wifi后的ip地址,使用默认端口进行数据接收
+ */
+ private fun generateDefaultAddress(){
+ context?.let {
+ val wifiManager = it.getSystemService(Context.WIFI_SERVICE) as WifiManager
+ val wifiInfo = wifiManager.connectionInfo
+ val ip = intIp2StringIp(wifiInfo.ipAddress)
+ Logger.d(TAG, "获取到本机ip地址: $ip")
+ defaultAddress = SimpleAddress(ip, DEFAULT_PORT)
+ // 生成了默认地址,开始准备接受数据
+ receiveMsgFrom(ip, DEFAULT_PORT)
+ }
+ }
+
+ private fun intIp2StringIp(ip: Int):String {
+ return "${ip and 0xff}.${(ip shr 8) and 0xff}.${(ip shr 16) and 0xff}.${(ip shr 24) and 0xff}"
+ }
+
+ private var isReady = false
+
fun receiveMsgFrom(ip: String, port: Int) {
isConnected = true
val address = SimpleAddress(ip, port)
@@ -78,6 +130,10 @@ class UdpSocketManager(private val callback: IUdpSocketCallback? = null) {
if (socket.isClosed) {
break
}
+ if (!isReady) {
+ isReady = true
+ callback?.isReady()
+ }
Logger.d(TAG, "准备接受消息====$address")
socket.receive(packet)
val msg = ByteArray(buffer.size)
@@ -91,4 +147,5 @@ class UdpSocketManager(private val callback: IUdpSocketCallback? = null) {
}
+
}
\ No newline at end of file
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/location/MogoRTKLocation.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/location/MogoRTKLocation.java
index 028d73b216..a7b18542ef 100644
--- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/location/MogoRTKLocation.java
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/location/MogoRTKLocation.java
@@ -11,6 +11,7 @@ import android.location.LocationManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
+import android.util.Log;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.module.common.entity.CloudLocationInfo;
@@ -123,6 +124,8 @@ public class MogoRTKLocation {
cloudLocationInfo.setSystemTime(System.currentTimeMillis());
cloudLocationInfo.convertCoor2GCJ02();
cacheList.add(cloudLocationInfo);
+ } else {
+ Logger.e(TAG, "location == null");
}
}
diff --git a/modules/mogo-module-smp/build.gradle b/modules/mogo-module-smp/build.gradle
index e3a46f8dd8..888a054935 100644
--- a/modules/mogo-module-smp/build.gradle
+++ b/modules/mogo-module-smp/build.gradle
@@ -38,6 +38,9 @@ dependencies {
implementation rootProject.ext.dependencies.androidxappcompat
implementation rootProject.ext.dependencies.androidxconstraintlayout
implementation rootProject.ext.dependencies.arouter
+
+ implementation rootProject.ext.dependencies.amapnavi3dmap
+
annotationProcessor rootProject.ext.dependencies.aroutercompiler
if (Boolean.valueOf(RELEASE)) {
api rootProject.ext.dependencies.mogomap
diff --git a/modules/mogo-module-smp/src/main/AndroidManifest.xml b/modules/mogo-module-smp/src/main/AndroidManifest.xml
index 649a2f531a..3d0a81ab9f 100644
--- a/modules/mogo-module-smp/src/main/AndroidManifest.xml
+++ b/modules/mogo-module-smp/src/main/AndroidManifest.xml
@@ -6,6 +6,6 @@
+ />
\ No newline at end of file
diff --git a/modules/mogo-module-smp/src/main/assets/small_map_style.data b/modules/mogo-module-smp/src/main/assets/small_map_style.data
new file mode 100644
index 0000000000..75195b39a2
Binary files /dev/null and b/modules/mogo-module-smp/src/main/assets/small_map_style.data differ
diff --git a/modules/mogo-module-smp/src/main/assets/small_map_style_extra.data b/modules/mogo-module-smp/src/main/assets/small_map_style_extra.data
new file mode 100644
index 0000000000..6f65457911
Binary files /dev/null and b/modules/mogo-module-smp/src/main/assets/small_map_style_extra.data differ
diff --git a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapDirectionView.java b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapDirectionView.java
index 0e5764968c..1eaedef6d3 100644
--- a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapDirectionView.java
+++ b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapDirectionView.java
@@ -8,9 +8,21 @@ import android.widget.ImageView;
import androidx.annotation.Nullable;
+import com.amap.api.maps.AMap;
+import com.amap.api.maps.CameraUpdate;
+import com.amap.api.maps.CameraUpdateFactory;
+import com.amap.api.maps.TextureMapView;
+import com.amap.api.maps.UiSettings;
+import com.amap.api.maps.model.BitmapDescriptor;
+import com.amap.api.maps.model.BitmapDescriptorFactory;
+import com.amap.api.maps.model.CustomMapStyleOptions;
+import com.amap.api.maps.model.MyLocationStyle;
import com.mogo.module.common.view.RoundLayout;
import com.mogo.module.small.map.animation.DirectionRotateAnimation;
+import java.io.InputStream;
+import java.net.URL;
+
/**
* 小地图的方向View
*
@@ -20,6 +32,12 @@ import com.mogo.module.small.map.animation.DirectionRotateAnimation;
public class SmallMapDirectionView extends RoundLayout {
private ImageView mIvMapBorder;
+ private TextureMapView mTextureMapView;
+ private AMap mAMap;
+ private UiSettings mUiSettings;
+ private CameraUpdate mCameraUpdate;
+ private MyLocationStyle myLocationStyle;
+
private DirectionRotateAnimation mRotateAnimation;
private int lastAngle = 0;
@@ -37,9 +55,46 @@ public class SmallMapDirectionView extends RoundLayout {
}
private void initView(Context context) {
+ mRotateAnimation = new DirectionRotateAnimation(context, null);
+
LayoutInflater.from(context).inflate(R.layout.module_small_map_view, this);
mIvMapBorder = findViewById(R.id.ivMapBorder);
- mRotateAnimation = new DirectionRotateAnimation(context, null);
+ mTextureMapView = findViewById(R.id.textureMapView);
+
+ mTextureMapView.onCreate(null);
+ mAMap = mTextureMapView.getMap();
+ mAMap.setMapType(AMap.MAP_TYPE_NIGHT);//夜景地图,aMap是地图控制器对象。
+
+ URL small_map_style = getClass().getResource("/assets/small_map_style.data");
+ URL small_map_style_extra = getClass().getResource("/assets/small_map_style_extra.data");
+
+ mAMap.setCustomMapStyle(new CustomMapStyleOptions()
+ .setEnable(true)
+ .setStyleDataPath(small_map_style.getPath())
+ .setStyleExtraPath(small_map_style_extra.getPath())
+ );
+
+ myLocationStyle = new MyLocationStyle();//初始化定位蓝点样式类myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE);//连续定位、且将视角移动到地图中心点,定位点依照设备方向旋转,并且会跟随设备移动。(1秒1次定位)如果不设置myLocationType,默认也会执行此种模式。
+ myLocationStyle.interval(2000); //设置连续定位模式下的定位间隔,只在连续定位模式下生效,单次定位模式下不会生效。单位为毫秒。
+ BitmapDescriptor location = BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_my_location_logo);
+ myLocationStyle.myLocationIcon(location);
+ mAMap.setMyLocationStyle(myLocationStyle);//设置定位蓝点的Style
+ mAMap.setMyLocationEnabled(true);// 设置为true表示启动显示定位蓝点,false表示隐藏定位蓝点并不进行定位,默认是false。
+
+ //设置希望展示的地图缩放级别
+ mCameraUpdate = CameraUpdateFactory.zoomTo(12);
+ mAMap.moveCamera(mCameraUpdate);
+
+ mUiSettings = mAMap.getUiSettings();
+ mUiSettings.setZoomControlsEnabled(false);// 地图缩放级别的交换按钮
+// mUiSettings.setZoomGesturesEnabled(false);// 缩放手势
+// mUiSettings.setScrollGesturesEnabled(false);// 滑动手势
+// mUiSettings.setRotateGesturesEnabled(false);// 旋转手势
+// mUiSettings.setTiltGesturesEnabled(false);// 倾斜手势
+ mUiSettings.setAllGesturesEnabled(false);// 所有手势
+ mUiSettings.setMyLocationButtonEnabled(false); // 显示默认的定位按钮
+ mUiSettings.setLogoBottomMargin(-150); //设置Logo下边界距离屏幕底部的边距,设置为负值即可
+
}
diff --git a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapService.java b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapService.java
index de26ba6776..f50a457f25 100644
--- a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapService.java
+++ b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapService.java
@@ -32,7 +32,7 @@ public class SmallMapService extends Service {
public void onCreate() {
super.onCreate();
Logger.d(TAG, "onCreate");
- addMachineVisionMapView();
+ addSmallMapView();
}
@Nullable
@@ -46,7 +46,7 @@ public class SmallMapService extends Service {
@Override
public void onRebind(Intent intent) {
super.onRebind(intent);
- addMachineVisionMapView();
+ addSmallMapView();
Logger.d(TAG, "onRebind");
}
@@ -69,8 +69,8 @@ public class SmallMapService extends Service {
}
}
- private void addMachineVisionMapView() {
- Logger.d(TAG, "addMachineVisionMapView");
+ private void addSmallMapView() {
+ Logger.d(TAG, "addSmallMapView");
mWindowManagerView = new WindowManagerView.Builder(getApplicationContext())
.contentView(R.layout.module_small_map_direction_view)
@@ -79,8 +79,8 @@ public class SmallMapService extends Service {
WindowManager.LayoutParams.WRAP_CONTENT
)
.position(
- getResources().getDimensionPixelOffset(R.dimen.module_mvision_view_x),
- getResources().getDimensionPixelOffset(R.dimen.module_mvision_view_y)
+ getResources().getDimensionPixelOffset(R.dimen.module_small_map_view_x),
+ getResources().getDimensionPixelOffset(R.dimen.module_small_map_view_y)
)
.gravity(Gravity.TOP | Gravity.LEFT)
.showInWindowManager();
diff --git a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapView.java b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapView.java
deleted file mode 100644
index 62e75cdc07..0000000000
--- a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapView.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.mogo.module.small.map;
-
-import android.content.Context;
-import android.util.AttributeSet;
-
-import androidx.annotation.Nullable;
-
-import com.mogo.map.MogoBaseMapView;
-import com.mogo.utils.logger.Logger;
-
-/**
- * @author donghongyu
- * @date 12/10/20 1:35 PM
- */
-public class SmallMapView extends MogoBaseMapView {
-
- private static final String TAG = "SmallMapView";
-
- public SmallMapView(Context context) {
- this(context, null);
- }
-
- public SmallMapView(Context context, @Nullable AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public SmallMapView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- }
-
- @Override
- protected void addMapView(Context context) {
- Logger.d(TAG, "addMapView");
- }
-}
\ No newline at end of file
diff --git a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallVisionProvider.java b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallVisionProvider.java
index 0e3a5be274..6c18a05d75 100644
--- a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallVisionProvider.java
+++ b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallVisionProvider.java
@@ -73,15 +73,15 @@ public class SmallVisionProvider implements IMogoSmallMapProvider, IMogoStatusCh
@Override
public void showPanel() {
Log.d(TAG, "小地图模块触发展示……");
-
- mSmallMapServiceIntent = new Intent(mContext, SmallMapService.class);
- mContext.startService(mSmallMapServiceIntent);
+ if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
+ mSmallMapServiceIntent = new Intent(mContext, SmallMapService.class);
+ mContext.startService(mSmallMapServiceIntent);
+ }
}
@Override
public void hidePanel() {
Log.d(TAG, "小地图模块触发隐藏……");
-
if (mSmallMapServiceIntent != null) {
AbsMogoApplication.getApp().stopService(mSmallMapServiceIntent);
}
diff --git a/modules/mogo-module-smp/src/main/res/drawable-xhdpi/module_small_map_view_border.png b/modules/mogo-module-smp/src/main/res/drawable-xhdpi/module_small_map_view_border.png
index cc2c540c8b..1c4bf333ca 100644
Binary files a/modules/mogo-module-smp/src/main/res/drawable-xhdpi/module_small_map_view_border.png and b/modules/mogo-module-smp/src/main/res/drawable-xhdpi/module_small_map_view_border.png differ
diff --git a/modules/mogo-module-smp/src/main/res/drawable-xhdpi/module_small_map_view_my_location_logo.png b/modules/mogo-module-smp/src/main/res/drawable-xhdpi/module_small_map_view_my_location_logo.png
new file mode 100644
index 0000000000..e17d0c5eee
Binary files /dev/null and b/modules/mogo-module-smp/src/main/res/drawable-xhdpi/module_small_map_view_my_location_logo.png differ
diff --git a/modules/mogo-module-smp/src/main/res/drawable/bg_module_small_map_view_border.xml b/modules/mogo-module-smp/src/main/res/drawable/bg_module_small_map_view_border.xml
new file mode 100644
index 0000000000..46982d07c3
--- /dev/null
+++ b/modules/mogo-module-smp/src/main/res/drawable/bg_module_small_map_view_border.xml
@@ -0,0 +1,28 @@
+
+
+
+ -
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-smp/src/main/res/layout/module_small_map_view.xml b/modules/mogo-module-smp/src/main/res/layout/module_small_map_view.xml
index e5d1dbfe79..59c74ffedd 100644
--- a/modules/mogo-module-smp/src/main/res/layout/module_small_map_view.xml
+++ b/modules/mogo-module-smp/src/main/res/layout/module_small_map_view.xml
@@ -1,16 +1,36 @@
-
+
+
+
+
+
+
+
+
+
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/modules/mogo-module-smp/src/main/res/values-xhdpi/dimens.xml b/modules/mogo-module-smp/src/main/res/values-xhdpi/dimens.xml
index 9910274622..461d5da465 100644
--- a/modules/mogo-module-smp/src/main/res/values-xhdpi/dimens.xml
+++ b/modules/mogo-module-smp/src/main/res/values-xhdpi/dimens.xml
@@ -1,12 +1,18 @@
- 400px
- 400px
- 1490px
- 650px
+ 400px
+ 400px
- 0px
- 0px
- 1920px
- 1080px
+ 260px
+ 260px
+
+ 250px
+ 250px
+ 1490px
+ 650px
+
+ 0px
+ 0px
+ 1920px
+ 1080px
\ No newline at end of file
diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XObuManager.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XObuManager.java
index bdbf0ea9db..14074c55c8 100644
--- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XObuManager.java
+++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XObuManager.java
@@ -1,7 +1,9 @@
package com.mogo.module.v2x;
+import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
+import android.content.IntentFilter;
import android.os.Handler;
import android.os.Message;
import android.os.SystemClock;
@@ -30,6 +32,7 @@ import com.zhidao.mogo.module.obu.obu.bean.MogoObuEventInfo;
import com.zhidao.mogo.module.obu.obu.bean.MogoObuLocationInfo;
import com.zhidao.mogo.module.obu.obu.bean.MogoObuTrafficLightInfo;
+import org.json.JSONArray;
import org.json.JSONObject;
import java.util.Map;
@@ -66,19 +69,24 @@ public class V2XObuManager implements IObuCallback, Handler.Callback {
private static final int MSG_HIDE_TRAFFIC_LIGHT = 1001;
private static final long DEFAULT_HIDE_TRAFFIC_LIGHT_DELAY = 1500L;
- private Handler handler = new Handler(this);
+ private final Handler handler = new Handler(this);
+ private final ObuTypeExchangeReceiver obuTypeExchangeReceiver = new ObuTypeExchangeReceiver();
+ private ObuManager obuManager;
public void init(Context context) {
Logger.d(MODULE_NAME, "obuManager初始化--");
- ObuManager obuManager = new ObuManager();
+ obuManager = new ObuManager();
obuManager.init(context);
obuManager.registerObuDataChangedListener(this);
+
+ IntentFilter filter = new IntentFilter("com.mogo.launcher.v2x.action.EXCHANGE_OBU_TYPE");
+ context.registerReceiver(obuTypeExchangeReceiver, filter);
}
/**
* 用来处理30秒内不重复播报的情况
*/
- private Map intervalMap = new ArrayMap<>();
+ private final Map intervalMap = new ArrayMap<>();
private int parseObuEvent(String type) {
switch (type) {
@@ -98,7 +106,7 @@ public class V2XObuManager implements IObuCallback, Handler.Callback {
}
}
- private MogoLocation[] historyPath = new MogoLocation[2];
+ private final MogoLocation[] historyPath = new MogoLocation[2];
private float computeCarAngle(MogoLocation location) {
float angle = 0f;
@@ -142,6 +150,10 @@ public class V2XObuManager implements IObuCallback, Handler.Callback {
} else {
json.put("surplusTime", trafficLightInfo.getSurplusTime());
}
+ JSONArray lightJsonArray = new JSONArray(trafficLightInfo.getLightArray());
+ JSONArray surplusTimeJsonArray = new JSONArray(trafficLightInfo.getSurplusTimeArray());
+ json.put("lightArray", lightJsonArray);
+ json.put("surplusTimeArray", surplusTimeJsonArray);
}
String data = json.toString();
Logger.d(MODULE_NAME, "发送红绿灯广播: " + data);
@@ -172,7 +184,7 @@ public class V2XObuManager implements IObuCallback, Handler.Callback {
}
// int eventType = parseObuEvent(info.getTypeCode());
int eventType = info.getMogoEventId();
- if (eventType == ObuConstant.TYPE_OPTIMAL_SPEED_ADVISORY&& DebugConfig.getObuType() == DebugConfig.OBU_TYPE_CIDI) {
+ if (eventType == ObuConstant.TYPE_OPTIMAL_SPEED_ADVISORY && DebugConfig.getObuType() == DebugConfig.OBU_TYPE_CIDI) {
// 加一个容错机制,如果已经驶过绿波车速路口,那么再收到绿波车速obu事件,就不再上报
MogoLocation currentLocation = V2XLocationListener.getInstance().getLastCarLocation();
double eventAngle = DrivingDirectionUtils.getDegreeOfCar2Poi(
@@ -187,7 +199,7 @@ public class V2XObuManager implements IObuCallback, Handler.Callback {
return;
}
}
- if (SystemClock.elapsedRealtime() - last > DEFAULT_INTERVAL_TIME||DebugConfig.getObuType() == DebugConfig.OBU_TYPE_HUALI) {
+ if (SystemClock.elapsedRealtime() - last > DEFAULT_INTERVAL_TIME || DebugConfig.getObuType() == DebugConfig.OBU_TYPE_HUALI) {
// 距离上次记录超过三十秒,继续相关逻辑,如果不超过三十秒,忽略此次事件
// 华砺智行obu暂时去掉此判断
intervalMap.put(info.getTypeCode(), SystemClock.elapsedRealtime());
@@ -249,17 +261,17 @@ public class V2XObuManager implements IObuCallback, Handler.Callback {
default:
break;
}
- }else{
- Logger.d(TAG,"未超过时限,不展示事件");
+ } else {
+ Logger.d(TAG, "未超过时限,不展示事件");
}
}
@Override
- public void onLocationInfoCallback( MogoObuLocationInfo locationInfo) {
+ public void onLocationInfoCallback(MogoObuLocationInfo locationInfo) {
if (ObuConfig.useObuLocation) {
MogoLocation currentLocation = new MogoLocation();
- double coor[] = CoordinateUtils.transformFromWGSToGCJ( locationInfo.getLat(), locationInfo.getLon() );
+ double coor[] = CoordinateUtils.transformFromWGSToGCJ(locationInfo.getLat(), locationInfo.getLon());
currentLocation.setLatitude(coor[0]);
currentLocation.setLongitude(coor[1]);
@@ -282,4 +294,12 @@ public class V2XObuManager implements IObuCallback, Handler.Callback {
sendTrafficLightStatusToAdas(CALL_ADAS_SHOW_TRAFFIC_LIGHT, trafficLightInfo);
}
}
+
+ class ObuTypeExchangeReceiver extends BroadcastReceiver {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ int obuType = intent.getIntExtra("obuType", DebugConfig.OBU_TYPE_CIDI);
+ obuManager.resetObuType(obuType);
+ }
+ }
}
diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/manager/impl/MoGoV2XMarkerManager.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/manager/impl/MoGoV2XMarkerManager.java
index 21e184ed1f..9e3b9b2ad7 100644
--- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/manager/impl/MoGoV2XMarkerManager.java
+++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/manager/impl/MoGoV2XMarkerManager.java
@@ -4,14 +4,17 @@ import android.content.Context;
import android.graphics.Bitmap;
import com.alibaba.android.arouter.facade.annotation.Route;
+import com.mogo.commons.AbsMogoApplication;
import com.mogo.map.MogoLatLng;
import com.mogo.map.location.MogoLocation;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.IMogoMarkerClickListener;
import com.mogo.map.marker.MogoMarkerOptions;
import com.mogo.map.uicontroller.EnumMapUI;
+import com.mogo.module.common.drawer.MarkerDrawer;
import com.mogo.module.common.drawer.marker.IMarkerView;
import com.mogo.module.common.drawer.marker.MapMarkerAdapter;
+import com.mogo.module.common.drawer.marker.RoadConditionInfoWindow3DAdapter;
import com.mogo.module.common.entity.MarkerCardResult;
import com.mogo.module.common.entity.MarkerExploreWay;
import com.mogo.module.common.entity.MarkerLocation;
@@ -532,6 +535,13 @@ public class MoGoV2XMarkerManager implements IMoGoV2XMarkerManager {
.longitude(roadEventEntity.getLocation().getLon());
optionsRipple.anchor(0.5f, 0.5f);
+ MarkerShowEntity markerShowEntity = new MarkerShowEntity();
+ MarkerExploreWay markerExploreWay = roadEventEntity.getNoveltyInfo();
+ markerShowEntity.setBindObj(markerExploreWay);
+ markerShowEntity.setMarkerLocation(markerExploreWay.getLocation());
+ markerShowEntity.setMarkerType(markerExploreWay.getPoiType());
+ markerShowEntity.setTextContent(markerExploreWay.getPoiType());
+
// 由于性能问题,D车机不使用事件扩散动画
if (!CarSeries.isF8xxSeries()) {
optionsRipple.icon(V2XMarkerAdapter.getV2XRoadEventViewPng(context, roadEventEntity));
@@ -539,8 +549,13 @@ public class MoGoV2XMarkerManager implements IMoGoV2XMarkerManager {
optionsRipple.icons(V2XMarkerAdapter.getV2XRoadEventViewGif(context, roadEventEntity));
optionsRipple.period(1);
}
-
- mAlarmInfoMarker = V2XServiceManager.getMarkerManager().addMarker(V2X_EVENT_ALARM_POI, optionsRipple);
+ if (V2XServiceManager.getMoGoStatusManager().isVrMode()) {
+ mAlarmInfoMarker = MarkerDrawer.getInstance().drawMapMarkerImpl(markerShowEntity, MarkerDrawer.MARKER_Z_INDEX_HIGH, clickListener);
+ mAlarmInfoMarker.setInfoWindowAdapter(new RoadConditionInfoWindow3DAdapter(markerShowEntity, AbsMogoApplication.getApp(), mAlarmInfoMarker.getMogoMarkerOptions()));
+ mAlarmInfoMarker.showInfoWindow();
+ } else {
+ mAlarmInfoMarker = V2XServiceManager.getMarkerManager().addMarker(V2X_EVENT_ALARM_POI, optionsRipple);
+ }
// 当前Marker设置为最上面
mAlarmInfoMarker.setToTop();
// 绘制连接线
diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/animation/V2XAnimationWindow.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/animation/V2XAnimationWindow.java
index c77d966c31..0a3fe0121c 100644
--- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/animation/V2XAnimationWindow.java
+++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/animation/V2XAnimationWindow.java
@@ -106,6 +106,9 @@ public class V2XAnimationWindow extends ConstraintLayout implements IV2XWindow