Merge remote-tracking branch 'origin/demo/shunyi_vr_map' into demo/shunyi_vr_map

This commit is contained in:
董宏宇
2020-10-30 17:22:08 +08:00
10 changed files with 136 additions and 32 deletions

2
.idea/misc.xml generated
View File

@@ -4,7 +4,7 @@
<asm skipDebug="false" skipFrames="false" skipCode="false" expandFrames="false" />
<groovy codeStyle="LEGACY" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="JDK" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="SuppressionsComponent">

View File

@@ -39,6 +39,10 @@ class DialogImpl implements IWindowManagerView {
dialog.show();
}
@Override
public void update(WindowManagerView.WMViewParams params) {
}
@Override
public void hide() {
/*

View File

@@ -27,6 +27,12 @@ interface IWindowManagerView {
*/
void show();
/**
* 更新界面位置或大小
* @param params 具体参数
*/
void update(WindowManagerView.WMViewParams params);
/**
* 隐藏
*/

View File

@@ -4,6 +4,7 @@ import android.content.Context;
import android.graphics.PixelFormat;
import android.os.Build;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
/**
@@ -16,6 +17,8 @@ class WindowManagerImpl implements IWindowManagerView {
private WindowManagerView.WMViewParams mParams;
private boolean isShowing;
private View rootView;
private float mLastX, mLastY;
private int mOldOffsetX, mOldOffsetY;
@@ -23,6 +26,10 @@ class WindowManagerImpl implements IWindowManagerView {
public void init( WindowManagerView.WMViewParams params ) {
mParams = params;
mWindowManager = ( WindowManager ) mParams.mContext.getApplicationContext().getSystemService( Context.WINDOW_SERVICE );
generateLayoutParams();
}
private void generateLayoutParams(){
mLayoutParams = new WindowManager.LayoutParams();
if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ) {
mLayoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
@@ -80,10 +87,20 @@ class WindowManagerImpl implements IWindowManagerView {
public void show() {
if ( !isShowing ) {
isShowing = true;
rootView = mParams.mContentView;
mWindowManager.addView( mParams.mContentView, mLayoutParams );
}
}
@Override
public void update(WindowManagerView.WMViewParams params) {
if (isShowing) {
mParams = params;
generateLayoutParams();
mWindowManager.updateViewLayout(rootView,mLayoutParams);
}
}
@Override
public void hide() {
if ( isShowing && mParams != null ) {

View File

@@ -116,4 +116,15 @@ public class WindowManagerView {
public int mY;
public int mGravity;
}
public void exchangeSizeAndPosition(int width, int height, int x, int y) {
if (isShowing()) {
mParams.mX = x;
mParams.mY = y;
mParams.mWidth = width;
mParams.mHeight = height;
mManagerView.update(mParams);
}
}
}

View File

@@ -59,6 +59,8 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
private Handler handler = new Handler(this);
private boolean isObuLightData = false;
private View selfCar;
private boolean lightCenter = true;
@@ -95,10 +97,6 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
if(!lightCenter) {
handler.sendEmptyMessageDelayed(MSG_REFRESH_CAR_STRATEGY, STRATEGY_DELAY);
}
// debug code
// tvSelfSpeed.setVisibility(View.VISIBLE);
// tvTrafficLight.setVisibility(View.VISIBLE);
// tvLimitSpeed.setVisibility(View.VISIBLE);
}
}
@@ -209,11 +207,12 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
tvLimitSpeed.setVisibility(View.GONE);
return true;
case MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD:
if (!handler.hasMessages(MSG_HIDE_TRAFFIC_LIGHT_BY_OBU)) {
if (!isObuLightData && !handler.hasMessages(MSG_HIDE_TRAFFIC_LIGHT_BY_OBU)) {
tvTrafficLight.setVisibility(View.GONE);
}
return true;
case MSG_HIDE_TRAFFIC_LIGHT_BY_OBU:
isObuLightData = false;
if (!handler.hasMessages(MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD)) {
tvTrafficLight.setVisibility(View.GONE);
}
@@ -237,26 +236,36 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
String action = intent.getAction();
if("com.mogo.launcher.adas".equals(action)){
// 收到限速信息
limitSpeed = intent.getIntExtra("adas_speed_limit", -1);
drawLimitSpeed();
int limit = intent.getIntExtra("adas_speed_limit", -1);
if(limit>0) {
limitSpeed = limit;
drawLimitSpeed();
}
}else {
int type = intent.getIntExtra("type", -1);
if (type == 2) {
// 红绿灯处理
String data = intent.getStringExtra("data");
if (data != null && !data.isEmpty()) {
try {
JSONObject jsonObject = new JSONObject(data);
String lightStatus = jsonObject.optString("lightStatus");
String surplusTime = jsonObject.optString("surplusTime");
if (!lightStatus.isEmpty() && !surplusTime.isEmpty()) {
handleObuTrafficLightInfo(lightStatus, surplusTime);
} else {
Logger.d(TAG, "红绿灯必要信息都为空,不做展示");
String obuLightAction = intent.getStringExtra("action");
if("1".equals(obuLightAction)){
// 隐藏红绿灯
handler.removeMessages(MSG_HIDE_TRAFFIC_LIGHT_BY_OBU);
handler.sendEmptyMessage(MSG_HIDE_TRAFFIC_LIGHT_BY_OBU);
}else {
// 红绿灯处理
String data = intent.getStringExtra("data");
if (data != null && !data.isEmpty()) {
try {
JSONObject jsonObject = new JSONObject(data);
String lightStatus = jsonObject.optString("lightStatus");
String surplusTime = jsonObject.optString("surplusTime");
if (!lightStatus.isEmpty() && !surplusTime.isEmpty()) {
handleObuTrafficLightInfo(lightStatus, surplusTime);
} else {
Logger.d(TAG, "红绿灯必要信息都为空,不做展示");
}
} catch (Exception e) {
Logger.e(TAG, e, "解析adas数据异常");
e.printStackTrace();
}
} catch (Exception e) {
Logger.e(TAG, e, "解析adas数据异常");
e.printStackTrace();
}
}
}
@@ -265,6 +274,7 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
}
private void handleObuTrafficLightInfo(String lightStatus, String surplusTime) {
isObuLightData = true;
if (tvTrafficLight != null) {
handler.removeMessages(MSG_HIDE_TRAFFIC_LIGHT_BY_OBU);
handler.removeMessages(MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD);
@@ -275,6 +285,10 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
}
private void handleCloudTrafficLight(CloudRoadData roadData) {
if (isObuLightData) {
handler.removeMessages(MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD);
return;
}
if (tvTrafficLight != null && !handler.hasMessages(MSG_HIDE_TRAFFIC_LIGHT_BY_OBU)) {
handler.removeMessages(MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD);
// todo drawTrafficLight
@@ -303,6 +317,8 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
if (leftTime < 0) {
leftTime = 0;
}
Logger.d("CloudTrafficLight",
"lightStatus: " + lightStatus + " current: " + System.currentTimeMillis() + " cloudType: " + roadData.getSystemTime() + " diff: " + diff + " cloudLeftTime: " + roadData.getLightLeftTime() + " leftTime: " + leftTime);
drawTrafficLight(lightStatus, "" + leftTime);
handler.sendEmptyMessageDelayed(MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD,
HIDE_TRAFFIC_LIGHT_DELAY);

View File

@@ -51,11 +51,11 @@ class VrModeController {
}
public void onVrModeChanged( boolean isVrMode ) {
// if ( isVrMode ) {
// bindVrModeService();
// } else {
// unbindVrModeService();
// }
if ( isVrMode ) {
bindVrModeService();
} else {
unbindVrModeService();
}
}
private void bindVrModeService() {

View File

@@ -33,6 +33,8 @@ class MachineVisionMapService extends Service {
private WindowManagerView mMachineVisionMapViewManager;
private View mRootView;
private View mClickView;
private MachineVisionMapView mMapView;
@Nullable
@Override
@@ -111,6 +113,8 @@ class MachineVisionMapService extends Service {
}
}
private boolean isSmall = true;
private void addMachineVisionMapView() {
mMachineVisionMapViewManager = new WindowManagerView.Builder( getApplicationContext() )
.contentView( R.layout.module_mvision_layout_view )
@@ -125,8 +129,42 @@ class MachineVisionMapService extends Service {
.gravity( Gravity.TOP | Gravity.LEFT )
.showInWindowManager();
mRootView = mMachineVisionMapViewManager.findViewById( R.id.module_mvision_map_root );
MachineVisionMapViewHandler.getInstance().setMachineVisionMapView( mMachineVisionMapViewManager.findViewById( R.id.module_mvision_map_view ) );
mClickView = mMachineVisionMapViewManager.findViewById(R.id.module_mvision_map_click);
mMapView = mMachineVisionMapViewManager.findViewById(R.id.module_mvision_map_view);
MachineVisionMapViewHandler.getInstance().setMachineVisionMapView( mMapView );
mMachineVisionMapViewManager.show();
mClickView.setOnClickListener(v -> {
int width, height, x, y;
if (isSmall) {
// 变大
isSmall = false;
width = getResources().getDimensionPixelSize(R.dimen.module_mvision_big_view_width);
height = getResources().getDimensionPixelSize(R.dimen.module_mvision_big_view_height);
x = getResources().getDimensionPixelSize(R.dimen.module_mvision_big_view_x);
y = getResources().getDimensionPixelSize(R.dimen.module_mvision_big_view_y);
}else{
// 变小
isSmall = true;
width = getResources().getDimensionPixelSize(R.dimen.module_mvision_view_width);
height = getResources().getDimensionPixelSize(R.dimen.module_mvision_view_height);
x = getResources().getDimensionPixelSize(R.dimen.module_mvision_view_x);
y = getResources().getDimensionPixelSize(R.dimen.module_mvision_view_y);
}
mRootView.getLayoutParams().width = width;
mRootView.getLayoutParams().height = height;
mRootView.setLayoutParams(mRootView.getLayoutParams());
mClickView.getLayoutParams().width = width;
mClickView.getLayoutParams().height = height;
mClickView.setLayoutParams(mClickView.getLayoutParams());
mMapView.getLayoutParams().width = width;
mMapView.getLayoutParams().height = height;
mMapView.setLayoutParams(mMapView.getLayoutParams());
mMachineVisionMapViewManager.exchangeSizeAndPosition(width, height, x, y);
});
}
@Override
@@ -136,6 +174,8 @@ class MachineVisionMapService extends Service {
if ( mMachineVisionMapViewManager != null ) {
mMachineVisionMapViewManager.dismiss();
mRootView = null;
mClickView = null;
mMapView = null;
}
}
}

View File

@@ -8,4 +8,9 @@
android:id="@+id/module_mvision_map_view"
android:layout_width="@dimen/module_mvision_view_width"
android:layout_height="@dimen/module_mvision_view_height" />
<FrameLayout
android:layout_width="@dimen/module_mvision_view_width"
android:layout_height="@dimen/module_mvision_view_height"
android:id="@+id/module_mvision_map_click" />
</FrameLayout>

View File

@@ -1,7 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="module_mvision_view_width">960px</dimen>
<dimen name="module_mvision_view_height">540px</dimen>
<dimen name="module_mvision_view_x">300px</dimen>
<dimen name="module_mvision_view_y">100px</dimen>
<dimen name="module_mvision_view_width">460px</dimen>
<dimen name="module_mvision_view_height">460px</dimen>
<dimen name="module_mvision_view_x">204px</dimen>
<dimen name="module_mvision_view_y">368px</dimen>
<dimen name="module_mvision_big_view_x">0px</dimen>
<dimen name="module_mvision_big_view_y">0px</dimen>
<dimen name="module_mvision_big_view_width">1920px</dimen>
<dimen name="module_mvision_big_view_height">1080px</dimen>
</resources>