opt
This commit is contained in:
@@ -11,6 +11,7 @@ import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -49,6 +50,7 @@ import com.mogo.module.extensions.ExtensionsModuleConst;
|
||||
import com.mogo.module.extensions.R;
|
||||
import com.mogo.module.extensions.navi.NaviInfoView;
|
||||
import com.mogo.module.extensions.userinfo.UserInfo;
|
||||
import com.mogo.module.extensions.utils.AdasNoticeHelper;
|
||||
import com.mogo.module.extensions.utils.EntranceViewHolder;
|
||||
import com.mogo.module.extensions.utils.NoMapTopViewShaderHelper;
|
||||
import com.mogo.module.extensions.utils.TopViewAnimHelper;
|
||||
@@ -75,13 +77,16 @@ import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.glide.GlideApp;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.storage.SharedPrefsMgr;
|
||||
import com.zhidao.manager.ts.TsThreshold;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import static com.mogo.module.common.utils.SPConst.getSPGuideRecord;
|
||||
import static com.mogo.module.common.utils.SPConst.getSpGuide;
|
||||
import static com.mogo.module.extensions.ExtensionsModuleConst.TYPE_ENTRANCE;
|
||||
import static com.mogo.module.share.constant.ShareConstants.KEY_CLICK_SHARE_BUTTON;
|
||||
import static com.mogo.module.share.constant.ShareConstants.KEY_CLICK_SHARE_TIME;
|
||||
import static com.mogo.module.share.constant.ShareConstants.KEY_SERVER_SHOW_DAY_COUNT;
|
||||
@@ -146,6 +151,11 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
private TextView mMsgCounter;
|
||||
|
||||
private ImageView mUserHeadImg;
|
||||
private View thresholdSetContainer;
|
||||
private EditText topEditC, frontLeftEditC, frontRightEditC, backLeftEditC, backRightEditC,
|
||||
bottomEditC;
|
||||
private EditText topEditS, frontLeftEditS, frontRightEditS, backLeftEditS, backRightEditS,
|
||||
bottomEditS;
|
||||
|
||||
private String[] mClickShareVoiceStrings;
|
||||
|
||||
@@ -168,6 +178,8 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
private boolean toggle = false;
|
||||
|
||||
private View mOnlineCarEntrance;
|
||||
private TextView tvEnterVrMode;
|
||||
private TextView tvExitVrMode;
|
||||
|
||||
private Runnable mLockCarRunnable = new Runnable() {
|
||||
@Override
|
||||
@@ -189,6 +201,8 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
|
||||
private TextView seekHelpNum;
|
||||
|
||||
private AdasNoticeHelper adasNoticeHelper = new AdasNoticeHelper();
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
if (DebugConfig.isMapBased()) {
|
||||
@@ -202,6 +216,9 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
protected void initViews() {
|
||||
mApis = MogoApisHandler.getInstance().getApis();
|
||||
|
||||
adasNoticeHelper.init(getContext());
|
||||
adasNoticeHelper.initView(getView());
|
||||
|
||||
mEntrancePresenter = new EntrancePresenter(getContext(), this);
|
||||
mMogoFragmentManager = mApis.getFragmentManagerApi();
|
||||
EntranceViewHolder.getInstance().initRootViewGroup(mRootView);
|
||||
@@ -267,8 +284,8 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
mMApUIController.recoverLockMode();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
} );
|
||||
mUserHeadImg = findViewById(R.id.ivUserHeadImg);
|
||||
if (DebugConfig.isDebug()) {
|
||||
mMove2CurrentLocation.setOnLongClickListener(view -> {
|
||||
mApis.getSearchManagerApi().goSettings();
|
||||
@@ -279,8 +296,19 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
mApis.getMogoMonitorApi().getMogoMonitorLog().showLogDebugDialog();
|
||||
return true;
|
||||
});
|
||||
|
||||
mUserHeadImg.setOnLongClickListener(view ->{
|
||||
if (groupFix.getVisibility() == View.VISIBLE) {
|
||||
groupFix.setVisibility(View.GONE);
|
||||
}else{
|
||||
groupFix.setVisibility(View.VISIBLE);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
groupFix = findViewById(R.id.groupFix);
|
||||
|
||||
ConstraintLayout rootView = findViewById(R.id.module_entrance_id_top_motion_layout);
|
||||
if (rootView != null) {
|
||||
TopViewAnimHelper.getInstance().init(rootView);
|
||||
@@ -359,7 +387,6 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
mWeatherIcon = findViewById(R.id.module_ext_id_weather_icon);
|
||||
mWeatherTemp = findViewById(R.id.module_ext_id_weather_temp);
|
||||
|
||||
mUserHeadImg = findViewById(R.id.ivUserHeadImg);
|
||||
groupUserHead = findViewById(R.id.groupUserHead);
|
||||
|
||||
mMsgContainer = findViewById(R.id.module_ext_id_msg);
|
||||
@@ -408,6 +435,19 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
properties.put("type", 1);
|
||||
MogoApisHandler.getInstance().getApis().getAnalyticsApi().track("APP_Find_Mogoer", properties);
|
||||
}
|
||||
} );
|
||||
tvEnterVrMode = findViewById(R.id.module_ext_enter_vr_mode);
|
||||
tvEnterVrMode.setOnClickListener((v)->{
|
||||
// 进入vr模式
|
||||
enterVrMode();
|
||||
mApis.getMapFrameControllerApi().changeToVRMode();
|
||||
});
|
||||
|
||||
tvExitVrMode = findViewById(R.id.module_ext_exit_vr_mode);
|
||||
tvExitVrMode.setOnClickListener((v)->{
|
||||
// 退出vr模式
|
||||
exitVrMode();
|
||||
mApis.getMapFrameControllerApi().changeTo2dMode();
|
||||
});
|
||||
|
||||
dealWeatherContainer();
|
||||
@@ -415,6 +455,120 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
listenSeekNumber();
|
||||
|
||||
debugTopView();
|
||||
debugCrashWarn();
|
||||
|
||||
// 检查是否在vr模式
|
||||
if (mStatusManager.isVrMode()) {
|
||||
enterVrMode();
|
||||
}
|
||||
etTimes = findViewById(R.id.etTimes);
|
||||
findViewById(R.id.btnFix).setOnClickListener((view)->{
|
||||
try {
|
||||
String times = etTimes.getText().toString().trim();
|
||||
int fixTime = Integer.parseInt(times);
|
||||
Logger.d(TAG, "修改上报时间间隔: " + times + " fixTime: " + fixTime);
|
||||
if(fixTime > 0) {
|
||||
Intent intent = new Intent("com.mogo.launcher.action.FIX_UPLOAT_DELAY");
|
||||
intent.putExtra("fixTime", fixTime);
|
||||
getContext().sendBroadcast(intent);
|
||||
TipToast.tip("已经发送修改广播");
|
||||
}else{
|
||||
TipToast.tip("fixTime为0,不发送广播");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
TipToast.tip("fixTime异常");
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private EditText etTimes;
|
||||
private Group groupFix;
|
||||
|
||||
private void enterVrMode(){
|
||||
tvEnterVrMode.setVisibility(View.GONE);
|
||||
mMove2CurrentLocation.setVisibility(View.GONE);
|
||||
mUploadRoadCondition.setVisibility(View.GONE);
|
||||
mWeatherContainer.setVisibility(View.GONE);
|
||||
mMsgContainer.setVisibility(View.GONE);
|
||||
|
||||
tvExitVrMode.setVisibility(View.VISIBLE);
|
||||
|
||||
adasNoticeHelper.enterVrMode();
|
||||
}
|
||||
|
||||
private void exitVrMode(){
|
||||
EntranceViewHolder.getInstance().forceHideNoticeView();
|
||||
tvEnterVrMode.setVisibility(View.VISIBLE);
|
||||
mMove2CurrentLocation.setVisibility(View.VISIBLE);
|
||||
mUploadRoadCondition.setVisibility(View.VISIBLE);
|
||||
// mWeatherContainer.setVisibility(View.VISIBLE);
|
||||
// mMsgContainer.setVisibility(View.VISIBLE);
|
||||
|
||||
tvExitVrMode.setVisibility(View.GONE);
|
||||
|
||||
adasNoticeHelper.exitVrMode();
|
||||
|
||||
}
|
||||
|
||||
private void debugCrashWarn(){
|
||||
thresholdSetContainer = findViewById(R.id.thresholdSetContainer);
|
||||
topEditC = findViewById(R.id.etTopC);
|
||||
frontLeftEditC = findViewById(R.id.etFrontLeftC);
|
||||
backLeftEditC = findViewById(R.id.etBackLeftC);
|
||||
frontRightEditC = findViewById(R.id.etFrontRightC);
|
||||
backRightEditC = findViewById(R.id.etBackRightC);
|
||||
bottomEditC = findViewById(R.id.etBottomC);
|
||||
|
||||
topEditS = findViewById(R.id.etTopS);
|
||||
frontLeftEditS = findViewById(R.id.etFrontLeftS);
|
||||
backLeftEditS = findViewById(R.id.etBackLeftS);
|
||||
frontRightEditS = findViewById(R.id.etFrontRightS);
|
||||
backRightEditS = findViewById(R.id.etBackRightS);
|
||||
bottomEditS = findViewById(R.id.etBottomS);
|
||||
|
||||
findViewById(R.id.btnClose).setOnClickListener(view -> {
|
||||
thresholdSetContainer.setVisibility(View.GONE);
|
||||
mApis.getAdasControllerApi().showADAS();
|
||||
});
|
||||
mUploadRoadCondition.setOnLongClickListener(v -> {
|
||||
mApis.getAdasControllerApi().closeADAS();
|
||||
thresholdSetContainer.setVisibility(View.VISIBLE);
|
||||
TsThreshold threshold = mApis.getCrashWarnProvider().getCurrentCrashThreshold();
|
||||
topEditC.setText(String.format(Locale.CHINA, "%d", threshold.getC5()));
|
||||
topEditS.setText(String.format(Locale.CHINA, "%d", threshold.getS5()));
|
||||
bottomEditC.setText(String.format(Locale.CHINA, "%d", threshold.getC6()));
|
||||
bottomEditS.setText(String.format(Locale.CHINA, "%d", threshold.getS6()));
|
||||
frontLeftEditC.setText(String.format(Locale.CHINA, "%d", threshold.getC4()));
|
||||
frontLeftEditS.setText(String.format(Locale.CHINA, "%d", threshold.getS4()));
|
||||
backLeftEditC.setText(String.format(Locale.CHINA, "%d", threshold.getC3()));
|
||||
backLeftEditS.setText(String.format(Locale.CHINA, "%d", threshold.getS3()));
|
||||
frontRightEditC.setText(String.format(Locale.CHINA, "%d", threshold.getC1()));
|
||||
frontRightEditS.setText(String.format(Locale.CHINA, "%d", threshold.getS1()));
|
||||
backRightEditC.setText(String.format(Locale.CHINA, "%d", threshold.getC2()));
|
||||
backRightEditS.setText(String.format(Locale.CHINA, "%d", threshold.getS2()));
|
||||
return true;
|
||||
});
|
||||
findViewById(R.id.btnSet).setOnClickListener(view -> {
|
||||
// 设置阈值
|
||||
TsThreshold threshold = new TsThreshold(
|
||||
Integer.parseInt(frontRightEditC.getText().toString()),
|
||||
Integer.parseInt(frontRightEditS.getText().toString()),
|
||||
Integer.parseInt(backRightEditC.getText().toString()),
|
||||
Integer.parseInt(backRightEditS.getText().toString()),
|
||||
Integer.parseInt(backLeftEditC.getText().toString()),
|
||||
Integer.parseInt(backLeftEditS.getText().toString()),
|
||||
Integer.parseInt(frontLeftEditC.getText().toString()),
|
||||
Integer.parseInt(frontLeftEditS.getText().toString()),
|
||||
Integer.parseInt(topEditC.getText().toString()),
|
||||
Integer.parseInt(topEditS.getText().toString()),
|
||||
Integer.parseInt(bottomEditC.getText().toString()),
|
||||
Integer.parseInt(bottomEditS.getText().toString())
|
||||
);
|
||||
mApis.getCrashWarnProvider().setCrashThreshold(threshold);
|
||||
thresholdSetContainer.setVisibility(View.GONE);
|
||||
mApis.getAdasControllerApi().showADAS();
|
||||
});
|
||||
|
||||
if (!DebugConfig.isMapBased()) {
|
||||
// 不基于地图的版本需要隐藏一些按钮
|
||||
@@ -622,14 +776,15 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
mMogoNavi = mService.getNavi(getContext());
|
||||
mAnalytics = mApis.getAnalyticsApi();
|
||||
|
||||
mMogoRegisterCenter.registerMogoNaviListener(ExtensionsModuleConst.TYPE_ENTRANCE, this);
|
||||
mMogoRegisterCenter.registerMogoMapListener(ExtensionsModuleConst.TYPE_ENTRANCE, this);
|
||||
mMogoRegisterCenter.registerMogoNaviListener(TYPE_ENTRANCE, this);
|
||||
mMogoRegisterCenter.registerMogoMapListener(TYPE_ENTRANCE, this);
|
||||
mMogoRegisterCenter.registerMogoAimlessModeListener(TAG, this);
|
||||
|
||||
mMogoMarkerManager = mService.getMarkerManager(getContext());
|
||||
|
||||
mStatusManager.registerStatusChangedListener(TAG, StatusDescriptor.UPLOADING, this);
|
||||
mStatusManager.registerStatusChangedListener(TAG, StatusDescriptor.DISPLAY_OVERVIEW, this);
|
||||
mStatusManager.registerStatusChangedListener(TAG, StatusDescriptor.VR_MODE, this);
|
||||
|
||||
TopViewAnimHelper.getInstance().setIMogoMapUIController(mMApUIController);
|
||||
TopViewNoLinkageAnimHelper.getInstance().setIMogoMapUIController(mMApUIController);
|
||||
@@ -808,6 +963,12 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
if (!isTrue) {
|
||||
handler.post(() -> seekHelpGroup.setVisibility(View.GONE));
|
||||
}
|
||||
} else if (descriptor == StatusDescriptor.VR_MODE) {
|
||||
if (isTrue) {
|
||||
enterVrMode();
|
||||
}else{
|
||||
exitVrMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -816,6 +977,9 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
if (!DebugConfig.isMapBased()) {
|
||||
return;
|
||||
}
|
||||
if(mApis.getStatusManagerApi().isVrMode()){
|
||||
return;
|
||||
}
|
||||
boolean hidden = false;
|
||||
if (iconId != 0) {
|
||||
mWeatherIcon.setImageResource(iconId);
|
||||
@@ -835,6 +999,9 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
if (!DebugConfig.isMapBased()) {
|
||||
return;
|
||||
}
|
||||
if (mApis.getStatusManagerApi().isVrMode()) {
|
||||
return;
|
||||
}
|
||||
mMsgContainer.setVisibility(hasMsg ? View.VISIBLE : View.GONE);
|
||||
mMsgCounter.setText(amount > MAX_DISPLAY_MSG_AMOUNT ?
|
||||
getString(R.string.module_ext_str_dots) : String.valueOf(amount));
|
||||
@@ -1025,8 +1192,8 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (mMogoRegisterCenter != null) {
|
||||
mMogoRegisterCenter.unregisterMogoNaviListener(ExtensionsModuleConst.TYPE_ENTRANCE);
|
||||
mMogoRegisterCenter.unregisterMogoMapListener(ExtensionsModuleConst.TYPE_ENTRANCE);
|
||||
mMogoRegisterCenter.unregisterMogoNaviListener(TYPE_ENTRANCE);
|
||||
mMogoRegisterCenter.unregisterMogoMapListener(TYPE_ENTRANCE);
|
||||
mMogoRegisterCenter.unregisterMogoAimlessModeListener(TAG);
|
||||
}
|
||||
if (mStatusManager != null) {
|
||||
@@ -1034,6 +1201,7 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
mStatusManager.unregisterStatusChangedListener(TAG, StatusDescriptor.DISPLAY_OVERVIEW
|
||||
, this);
|
||||
mStatusManager.unregisterStatusChangedListener(TAG, StatusDescriptor.SEEK_HELPING, this);
|
||||
mStatusManager.unregisterStatusChangedListener(TAG, StatusDescriptor.VR_MODE, this);
|
||||
}
|
||||
if (mApis != null) {
|
||||
if (mApis.getIntentManagerApi() != null) {
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.mogo.module.extensions.utils.EntranceViewHolder;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.entrance.ButtonIndex;
|
||||
import com.mogo.service.entrance.IMogoEntranceButtonController;
|
||||
import com.mogo.service.windowview.IMogoEntranceViewListener;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -39,6 +40,36 @@ public class MogoEntranceButtonControllerImpl implements IMogoEntranceButtonCont
|
||||
EntranceViewHolder.getInstance().removeBottomLayerView(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showLeftNoticeView(View view) {
|
||||
EntranceViewHolder.getInstance().showLeftNoticeView(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideLeftNoticeView(View view) {
|
||||
EntranceViewHolder.getInstance().hideLeftNoticeView(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showLeftNoticeByType(int noticeType, int iconRes, String content) {
|
||||
EntranceViewHolder.getInstance().showLeftNoticeByType(noticeType, iconRes, content);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideLeftNoticeByType(int noticeType) {
|
||||
EntranceViewHolder.getInstance().hideLeftNoticeByType(noticeType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEntranceViewListener(IMogoEntranceViewListener listener) {
|
||||
EntranceViewHolder.getInstance().addEntranceViewListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeEntranceViewListener(IMogoEntranceViewListener listener) {
|
||||
EntranceViewHolder.getInstance().removeEntranceViewListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
|
||||
|
||||
@@ -0,0 +1,394 @@
|
||||
package com.mogo.module.extensions.utils;
|
||||
|
||||
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.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.map.navi.MogoTraffic;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.entity.CloudRoadData;
|
||||
import com.mogo.module.common.entity.MogoSnapshotSetData;
|
||||
import com.mogo.module.extensions.R;
|
||||
import com.mogo.service.adas.IMogoAdasWarnMessageCallback;
|
||||
import com.mogo.service.adas.MogoADASWarnType;
|
||||
import com.mogo.service.adas.entity.ADASWarnMessage;
|
||||
import com.mogo.service.connection.IMogoOnWebSocketMessageListener;
|
||||
import com.mogo.service.connection.WebSocketMsgType;
|
||||
import com.mogo.service.entrance.IMogoEntranceButtonController;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**
|
||||
* vr模式下,adas左侧提示框帮助类
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLocationListener,
|
||||
Handler.Callback, IMogoOnWebSocketMessageListener<MogoSnapshotSetData> {
|
||||
private static final String TAG = "AdasNoticeHelper";
|
||||
|
||||
private static final int MSG_HIDE_TRAFFIC_LIGHT_BY_OBU = 1001;
|
||||
private static final int MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD = 1002;
|
||||
private static final int MSG_HIDE_LIMIT_SPEED = 1003;
|
||||
private static final int MSG_REFRESH_CAR_STRATEGY = 1004;
|
||||
|
||||
private static final long HIDE_TRAFFIC_LIGHT_DELAY = 2_000L;
|
||||
private static final long HIDE_LIMIT_SPEED_DELAY = 10_000L;
|
||||
private static final long STRATEGY_DELAY = 1000L;
|
||||
|
||||
private Context context;
|
||||
private AdasNoticeReceiver adasReceiver = new AdasNoticeReceiver();
|
||||
|
||||
private volatile boolean isVrMode = false;
|
||||
|
||||
private TextView tvSelfSpeed, tvTrafficLight, tvLimitSpeed;
|
||||
|
||||
private int limitSpeed = -1;
|
||||
private int currentSpeed = 0;
|
||||
private String lightStatus = "G";
|
||||
private String surplusTime;
|
||||
|
||||
private Handler handler = new Handler(this);
|
||||
|
||||
private boolean isObuLightData = false;
|
||||
|
||||
private View selfCar;
|
||||
|
||||
private boolean lightCenter = true;
|
||||
|
||||
public void init(Context context) {
|
||||
this.context = context;
|
||||
if(!lightCenter) {
|
||||
selfCar = LayoutInflater.from(context).inflate(R.layout.module_ext_item_self_car, null);
|
||||
tvSelfSpeed = selfCar.findViewById(R.id.tvSelfSpeed);
|
||||
tvTrafficLight = selfCar.findViewById(R.id.tvTrafficLight);
|
||||
tvLimitSpeed = selfCar.findViewById(R.id.tvLimitSpeed);
|
||||
}
|
||||
Logger.d(TAG, "init====");
|
||||
}
|
||||
|
||||
public void initView(View root) {
|
||||
if(lightCenter) {
|
||||
tvSelfSpeed = root.findViewById(R.id.tvSelfSpeed);
|
||||
tvTrafficLight = root.findViewById(R.id.tvTrafficLight);
|
||||
tvLimitSpeed = root.findViewById(R.id.tvLimitSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
public void enterVrMode() {
|
||||
Logger.d(TAG, "enterVrMode===" + isVrMode);
|
||||
if (!isVrMode) {
|
||||
isVrMode = true;
|
||||
IntentFilter filter = new IntentFilter("com.mogo.launcher.adas.app.biz");
|
||||
filter.addAction("com.mogo.launcher.adas");
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void exitVrMode() {
|
||||
Logger.d(TAG, "退出vr模式===" + isVrMode);
|
||||
if (isVrMode) {
|
||||
isVrMode = false;
|
||||
handler.removeMessages(MSG_REFRESH_CAR_STRATEGY);
|
||||
tvSelfSpeed.setVisibility(View.GONE);
|
||||
tvTrafficLight.setVisibility(View.GONE);
|
||||
tvLimitSpeed.setVisibility(View.GONE);
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().removeAdasWarnMessageCallback(this);
|
||||
MogoApisHandler.getInstance().getApis().getRegisterCenterApi().unregisterMogoLocationListener(TAG);
|
||||
MogoApisHandler.getInstance().getApis().getWebSocketManagerApi(context).unregisterOnWebSocketMessageListener(this);
|
||||
|
||||
context.unregisterReceiver(adasReceiver);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceiveData(ADASWarnMessage msg) {
|
||||
Logger.d(TAG, "收到adas warn message, isVrMode: " + isVrMode + " msg: " + msg);
|
||||
if (!isVrMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg.type == MogoADASWarnType.ADAS_WARNING_LIMIT_SPEED) {
|
||||
// 收到限速信息,更新界面
|
||||
limitSpeed = Integer.parseInt(msg.value);
|
||||
drawLimitSpeed();
|
||||
}
|
||||
}
|
||||
|
||||
private void drawLimitSpeed(){
|
||||
if (tvLimitSpeed != null) {
|
||||
tvLimitSpeed.post(() -> {
|
||||
handler.removeMessages(MSG_HIDE_LIMIT_SPEED);
|
||||
|
||||
if (tvLimitSpeed.getVisibility() == View.GONE) {
|
||||
tvLimitSpeed.setVisibility(View.VISIBLE);
|
||||
}
|
||||
tvLimitSpeed.setText(limitSpeed+"");
|
||||
handler.sendEmptyMessageDelayed(MSG_HIDE_LIMIT_SPEED, HIDE_LIMIT_SPEED_DELAY);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(MogoLocation location) {
|
||||
if (!isVrMode) {
|
||||
return;
|
||||
}
|
||||
currentSpeed = (int) (location.getSpeed() * 3.6F);
|
||||
if(lightCenter) {
|
||||
if (tvSelfSpeed != null) {
|
||||
tvSelfSpeed.post(() -> {
|
||||
if (tvSelfSpeed.getVisibility() == View.GONE) {
|
||||
tvSelfSpeed.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (limitSpeed != -1 && currentSpeed > limitSpeed) {
|
||||
// 显示红色
|
||||
tvSelfSpeed.setTextColor(context.getResources().getColor(R.color.module_ext_vr_mode_left_traffic_light_red));
|
||||
tvSelfSpeed.setBackgroundResource(R.drawable.module_ext_vr_mode_speed_red_bg);
|
||||
}else{
|
||||
// 显示白
|
||||
tvSelfSpeed.setTextColor(context.getResources().getColor(R.color.module_ext_vr_mode_left_traffic_light_white));
|
||||
tvSelfSpeed.setBackgroundResource(R.drawable.module_ext_vr_mode_speed_white_bg);
|
||||
}
|
||||
tvSelfSpeed.setText("" + currentSpeed);
|
||||
Logger.d(TAG, "onLocationChange: " + currentSpeed);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case MSG_REFRESH_CAR_STRATEGY:
|
||||
// todo 暂时不采用此种渲染方式
|
||||
// 自车速度
|
||||
tvSelfSpeed.setText("" + currentSpeed);
|
||||
// 红绿灯
|
||||
if (tvTrafficLight.getVisibility() == View.GONE) {
|
||||
tvTrafficLight.setVisibility(View.VISIBLE);
|
||||
}
|
||||
// todo 设置字体颜色、背景颜色、leftDrawable
|
||||
switch (lightStatus) {
|
||||
case "Y":
|
||||
// 黄灯
|
||||
break;
|
||||
case "R":
|
||||
// 红灯
|
||||
break;
|
||||
default:
|
||||
// 默认绿灯
|
||||
break;
|
||||
}
|
||||
tvTrafficLight.setText(surplusTime + "S");
|
||||
|
||||
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().showMyLocation(inflateRoadInfo());
|
||||
if (isVrMode) {
|
||||
handler.sendEmptyMessageDelayed(MSG_REFRESH_CAR_STRATEGY, STRATEGY_DELAY);
|
||||
}
|
||||
return true;
|
||||
case MSG_HIDE_LIMIT_SPEED:
|
||||
limitSpeed = -1;
|
||||
tvLimitSpeed.setVisibility(View.GONE);
|
||||
return true;
|
||||
case MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD:
|
||||
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);
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收智慧驾驶发给adas的展示信息,代替adas做界面展示
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
private class AdasNoticeReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (!isVrMode) {
|
||||
return;
|
||||
}
|
||||
String action = intent.getAction();
|
||||
if("com.mogo.launcher.adas".equals(action)){
|
||||
// 收到限速信息
|
||||
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 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
drawTrafficLight(lightStatus, surplusTime);
|
||||
handler.sendEmptyMessageDelayed(MSG_HIDE_TRAFFIC_LIGHT_BY_OBU,
|
||||
HIDE_TRAFFIC_LIGHT_DELAY);
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
String lightStatus = null;
|
||||
switch (roadData.getLightStatus()) {
|
||||
case 1:
|
||||
// 红灯
|
||||
lightStatus = "R";
|
||||
break;
|
||||
case 2:
|
||||
// 绿灯
|
||||
lightStatus = "G";
|
||||
break;
|
||||
case 3:
|
||||
// 黄灯
|
||||
lightStatus = "Y";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if(lightStatus == null){
|
||||
handler.sendEmptyMessage(MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD);
|
||||
}else {
|
||||
int diff = (int) ((System.currentTimeMillis() - roadData.getSystemTime()) / 1000);
|
||||
int leftTime = roadData.getLightLeftTime() - diff;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void drawTrafficLight(String lightStatus, String surplusTime) {
|
||||
this.lightStatus = lightStatus;
|
||||
this.surplusTime = surplusTime;
|
||||
if(lightCenter) {
|
||||
tvTrafficLight.post(() -> {
|
||||
if (tvTrafficLight.getVisibility() == View.GONE) {
|
||||
tvTrafficLight.setVisibility(View.VISIBLE);
|
||||
}
|
||||
// todo 设置字体颜色、背景颜色、leftDrawable
|
||||
switch (lightStatus) {
|
||||
case "Y":
|
||||
// 黄灯
|
||||
tvTrafficLight.setTextColor(context.getResources().getColor(R.color.module_ext_vr_mode_left_traffic_light_yellow));
|
||||
tvTrafficLight.setBackgroundResource(R.drawable.module_ext_vr_mode_traffic_light_yellow_bg);
|
||||
tvTrafficLight.setCompoundDrawablesWithIntrinsicBounds(R.drawable.module_ext_traffic_light_yellow, 0, 0, 0);
|
||||
break;
|
||||
case "R":
|
||||
// 红灯
|
||||
tvTrafficLight.setTextColor(context.getResources().getColor(R.color.module_ext_vr_mode_left_traffic_light_red));
|
||||
tvTrafficLight.setBackgroundResource(R.drawable.module_ext_vr_mode_traffic_light_red_bg);
|
||||
tvTrafficLight.setCompoundDrawablesWithIntrinsicBounds(R.drawable.module_ext_traffic_light_red, 0, 0, 0);
|
||||
break;
|
||||
default:
|
||||
// 默认绿灯
|
||||
tvTrafficLight.setTextColor(context.getResources().getColor(R.color.module_ext_vr_mode_left_traffic_light_green));
|
||||
tvTrafficLight.setBackgroundResource(R.drawable.module_ext_vr_mode_traffic_light_green_bg);
|
||||
tvTrafficLight.setCompoundDrawablesWithIntrinsicBounds(R.drawable.module_ext_traffic_light_green, 0, 0, 0);
|
||||
break;
|
||||
}
|
||||
tvTrafficLight.setText(surplusTime + "S");
|
||||
Logger.d(TAG, "展示红绿灯信息: " + lightStatus + " time: " + surplusTime);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebSocketMsgType getDownLinkType() {
|
||||
return WebSocketMsgType.MSG_TYPE_DOWNLINK_CAR_DATA;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<MogoSnapshotSetData> target() {
|
||||
return MogoSnapshotSetData.class;
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
||||
private View inflateRoadInfo(){
|
||||
View view = View.inflate(context, R.layout.module_ext_item_self_car, null);
|
||||
TextView _speed = view.findViewById(R.id.tvSelfSpeed);
|
||||
_speed.setText("" + currentSpeed);
|
||||
Logger.d(TAG, "showCurrentSpeed: " + currentSpeed);
|
||||
return view;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,18 +1,25 @@
|
||||
package com.mogo.module.extensions.utils;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.extensions.R;
|
||||
import com.mogo.module.extensions.bean.BottomLayerViewWrapper;
|
||||
import com.mogo.service.windowview.IMogoEntranceViewListener;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import static com.mogo.service.entrance.IMogoEntranceButtonController.NOTICE_TYPE_SEEK_HELP;
|
||||
|
||||
/**
|
||||
* 入口页view管理
|
||||
* @author tongchenfei
|
||||
@@ -21,6 +28,7 @@ public class EntranceViewHolder {
|
||||
private static final String TAG = "EntranceViewHolder";
|
||||
private List<BottomLayerViewWrapper> preAddView = new ArrayList<>();
|
||||
private List<View> leftFeaturePreAddView = new ArrayList<>();
|
||||
private View preAddLeftNoticeView = null;
|
||||
private EntranceViewHolder(){}
|
||||
private volatile static EntranceViewHolder instance = null;
|
||||
public static EntranceViewHolder getInstance(){
|
||||
@@ -35,11 +43,15 @@ public class EntranceViewHolder {
|
||||
}
|
||||
private ViewGroup rootViewGroup = null;
|
||||
private ViewGroup featureViewGroup = null;
|
||||
private ViewGroup leftNoticeContainer = null;
|
||||
|
||||
public void initRootViewGroup(View rootView) {
|
||||
Logger.i(TAG, "initRootViewGroup==");
|
||||
if(rootView instanceof ViewGroup) {
|
||||
Logger.d(TAG, "initRootViewGroup 赋值");
|
||||
rootViewGroup = (ViewGroup) rootView.getParent();
|
||||
leftNoticeContainer =
|
||||
rootView.findViewById(R.id.module_ext_vr_mode_left_notice_container);
|
||||
featureViewGroup = rootView.findViewById(R.id.module_entrance_id_buttons_container);
|
||||
if (!preAddView.isEmpty()) {
|
||||
Logger.d(TAG, "initRootViewGroup 增加底层view: " + preAddView.size());
|
||||
@@ -56,6 +68,9 @@ public class EntranceViewHolder {
|
||||
featureViewGroup.addView(view);
|
||||
}
|
||||
}
|
||||
if (preAddLeftNoticeView != null) {
|
||||
realShowLeftNoticeView(preAddLeftNoticeView);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +171,107 @@ public class EntranceViewHolder {
|
||||
}
|
||||
|
||||
|
||||
public void release(){
|
||||
public void showLeftNoticeView(View view) {
|
||||
if(MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
|
||||
if (leftNoticeContainer != null) {
|
||||
realShowLeftNoticeView(view);
|
||||
} else {
|
||||
preAddLeftNoticeView = view;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void hideLeftNoticeView(View view) {
|
||||
if(MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
|
||||
if (preAddLeftNoticeView != null && preAddLeftNoticeView == view) {
|
||||
preAddLeftNoticeView = null;
|
||||
}
|
||||
if (leftNoticeContainer != null) {
|
||||
realHideLeftNoticeView(view);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void forceHideNoticeView(){
|
||||
for (IMogoEntranceViewListener listener : listeners) {
|
||||
listener.onViewRemoved(currentShowNoticeType);
|
||||
}
|
||||
preAddLeftNoticeView = null;
|
||||
currentShowNoticeType = 0;
|
||||
if (leftNoticeContainer != null) {
|
||||
leftNoticeContainer.removeAllViews();
|
||||
}
|
||||
}
|
||||
|
||||
private int currentShowNoticeType = 0;
|
||||
public void showLeftNoticeByType(int noticeType, int iconRes, String content){
|
||||
if(MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
|
||||
if (currentShowNoticeType != noticeType && currentShowNoticeType != 0) {
|
||||
for (IMogoEntranceViewListener listener : listeners) {
|
||||
listener.onViewRemoved(currentShowNoticeType);
|
||||
}
|
||||
}
|
||||
currentShowNoticeType = noticeType;
|
||||
if (leftNoticeContainer != null) {
|
||||
realShowLeftNoticeView(generateNoticeViewByType(noticeType, iconRes, content));
|
||||
} else {
|
||||
preAddLeftNoticeView = generateNoticeViewByType(noticeType, iconRes, content);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void hideLeftNoticeByType(int noticeType) {
|
||||
if(MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
|
||||
if (currentShowNoticeType == noticeType) {
|
||||
forceHideNoticeView();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private View generateNoticeViewByType(int noticeType,int iconRes, String content) {
|
||||
View view =
|
||||
LayoutInflater.from(leftNoticeContainer.getContext()).inflate(R.layout.item_vr_left_notice, leftNoticeContainer, false);
|
||||
ImageView icon = view.findViewById(R.id.module_ext_iv_left_notice_icon);
|
||||
if (noticeType == NOTICE_TYPE_SEEK_HELP) {
|
||||
// 自车求助,是橘色的背景
|
||||
icon.setBackgroundResource(R.drawable.module_ext_left_notice_icon_orange_bg);
|
||||
}else{
|
||||
// 其他是红色背景
|
||||
icon.setBackgroundResource(R.drawable.module_ext_left_notice_icon_red_bg);
|
||||
}
|
||||
icon.setImageResource(iconRes);
|
||||
TextView tvContent = view.findViewById(R.id.module_ext_tv_left_notice_content);
|
||||
tvContent.setText(content);
|
||||
return view;
|
||||
}
|
||||
|
||||
private void realShowLeftNoticeView(View view){
|
||||
leftNoticeContainer.setVisibility(View.VISIBLE);
|
||||
leftNoticeContainer.removeAllViews();
|
||||
leftNoticeContainer.addView(view);
|
||||
preAddLeftNoticeView = null;
|
||||
for (IMogoEntranceViewListener listener : listeners) {
|
||||
listener.onViewAdded(currentShowNoticeType);
|
||||
}
|
||||
}
|
||||
|
||||
private void realHideLeftNoticeView(View view) {
|
||||
leftNoticeContainer.removeView(view);
|
||||
leftNoticeContainer.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private List<IMogoEntranceViewListener> listeners = new ArrayList<>();
|
||||
|
||||
public void addEntranceViewListener(IMogoEntranceViewListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeEntranceViewListener(IMogoEntranceViewListener listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
public void release(){
|
||||
rootViewGroup = null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user