From 3c69d910c9933327c27e660c1b05543d1cadd75d Mon Sep 17 00:00:00 2001 From: wangmingjun Date: Fri, 13 May 2022 18:58:34 +0800 Subject: [PATCH] =?UTF-8?q?[taxi/bus-d=20270]=20bus/taxi=20=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E9=A9=BE=E9=A9=B6=E6=8C=89=E9=92=AE=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E7=BB=9F=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../och/bus/fragment/BaseBusTabFragment.java | 108 +++++++---------- .../com/mogo/och/bus/model/BusOrderModel.java | 4 +- .../mogo/och/bus/presenter/BusPresenter.java | 18 +-- .../src/main/res/values/strings.xml | 1 + .../mogo/och/taxi/ui/BaseTaxiTabFragment.java | 110 ++++++------------ .../main/res/layout/taxi_base_fragment.xml | 28 +---- .../src/main/res/values/strings.xml | 2 + 7 files changed, 92 insertions(+), 179 deletions(-) diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/BaseBusTabFragment.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/BaseBusTabFragment.java index 3746c54a4b..c7f2778798 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/BaseBusTabFragment.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/BaseBusTabFragment.java @@ -24,7 +24,6 @@ import com.mogo.commons.mvp.MvpFragment; import com.mogo.commons.mvp.Presenter; import com.mogo.commons.voice.AIAssist; import com.mogo.eagle.core.data.config.HmiBuildConfig; -import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotIdentifyListener; import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotRecordListener; import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener; import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager; @@ -32,6 +31,7 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotRecordListener import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager; import com.mogo.eagle.core.function.call.hmi.CallerHmiManager; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; +import com.mogo.eagle.core.utilcode.mogo.toast.TipToast; import com.mogo.eagle.core.utilcode.util.UiThreadHandler; import com.mogo.map.MogoMapUIController; import com.mogo.map.MogoMarkerManager; @@ -41,12 +41,10 @@ import com.mogo.module.common.MogoApisHandler; import com.mogo.module.common.constants.DataTypes; import com.mogo.module.common.view.OnPreventFastClickListener; import com.mogo.och.bus.R; -import com.mogo.och.bus.ui.BusTrafficLightView; import com.mogo.och.bus.util.BDRouteDataTestUtils; import com.mogo.och.bus.view.BusArcView; import com.mogo.och.bus.view.SlidePanelView; -import mogo.telematics.pad.MessagePad; import record_cache.RecordPanelOuterClass; /** @@ -159,49 +157,33 @@ public abstract class BaseBusTabFragment @Override public void onClickImpl(View v) { -// if (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE){ + if (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE){ restartAutopilot(); -// } + }else { + TipToast.shortTip(getResources().getString(R.string.bus_auto_disable_tip)); + } } }); - // debug下调用测试面板 2022.2.25修改到 长按当前站点名字 -// if (DebugConfig.isDebug()) { -// ctvAutopilotStatus.setOnLongClickListener(v -> { -// debugTestBar(); -// return true; -// }); -// } - onAutopilotStatusChanged(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState()); + setAutopilotBtnStatus(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState()); // 模拟 不可自动驾驶,目前场景是刚开机,adas还未和工控机连接 findViewById(R.id.btnAutopilotDisable).setOnClickListener(view -> -// MogoApisHandler.getInstance().getApis() -// .getAdasControllerApi() -// .mockOchStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE, "不能使用") - debugAutoPilotStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE) + debugAutoPilotStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE) ); // 模拟 可自动驾驶,工控机连接正常,且处于人工干预状态 findViewById(R.id.btnAutopilotEnable).setOnClickListener(view -> -// MogoApisHandler.getInstance().getApis() -// .getAdasControllerApi() -// .mockOchStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE, "能使用") - debugAutoPilotStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE) + debugAutoPilotStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE) ); // 模拟 自动驾驶能力,自动驾驶中,可能是停车,可能是行进,但是是机器在处理车的前进后退,不是人 findViewById(R.id.btnAutopilotRunning).setOnClickListener(view -> -// MogoApisHandler.getInstance().getApis() -// .getAdasControllerApi() -// .mockOchStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING, "Running") - debugAutoPilotStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) + debugAutoPilotStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) ); // 模拟 自动驾驶网约车回调数据 findViewById(R.id.btnAutopilotArrive).setOnClickListener(view -> -// MogoApisHandler.getInstance().getApis() -// .getAdasControllerApi().mockOchStatus(-1, "Arrived") - debugArrivedStation() + debugArrivedStation() ); findViewById(R.id.btnAutopilotRoute).setOnClickListener(view -> debugArrivedRoute()); @@ -309,66 +291,64 @@ public abstract class BaseBusTabFragment }); } - public void updateAutopilotStatus(int autopilotStatus){ + public void setAutopilotBtnStatus(int autopilotStatus) { if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE == autopilotStatus) {//0不可用 - ctvAutopilotStatusIv.setImageResource(R.drawable.bus_wrong_autopilot_icon); - ctvAutopilotStatusTv.setTextColor(getResources().getColor(R.color.bus_autopilot_text_color_normal)); - ctvAutopilotStatusTv.setText(getResources().getString(R.string.bus_loading_autopilot_failure_tv)); - ctvAutopilotStatus.setFocusableInTouchMode(false); + ctvAutopilotStatusTv.setTextColor(getResources().getColor(R.color.bus_autopilot_text_color_disable)); + ctvAutopilotStatusTv.setText(getResources().getString(R.string.bus_loading_autopilot_runnig_tv)); + ctvAutopilotStatusIv.setImageResource(R.drawable.bus_disable_autopilot_icon); ctvAutopilotStatus.setSelected(false); + ctvAutopilotStatus.setFocusableInTouchMode(true); - UiThreadHandler.postDelayed(new Runnable() { - @Override - public void run() { - ctvAutopilotStatusTv.setTextColor(getResources().getColor(R.color.bus_autopilot_text_color_disable)); - ctvAutopilotStatusTv.setText(getResources().getString(R.string.bus_loading_autopilot_runnig_tv)); - ctvAutopilotStatusIv.setImageResource(R.drawable.bus_disable_autopilot_icon); - ctvAutopilotStatus.setSelected(false); - ctvAutopilotStatus.setFocusableInTouchMode(true); -// ctvAutopilotStatus.setPressed(false); - } - }, 1000); - - } else if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE + } else if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE == autopilotStatus + || IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING == autopilotStatus) {//1可用 ctvAutopilotStatusTv.setTextColor(getResources().getColor(R.color.bus_autopilot_text_color_normal)); ctvAutopilotStatusTv.setText(getResources().getString(R.string.bus_loading_autopilot_runnig_tv)); ctvAutopilotStatusIv.setImageResource(R.drawable.bus_ic_autopilot); - ctvAutopilotStatus.setSelected(false); + ctvAutopilotStatus.setSelected(true); ctvAutopilotStatus.setFocusableInTouchMode(true); -// ctvAutopilotStatus.setPressed(true); - } else if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING + } + } + + public void updateAutopilotStatus(int autopilotStatus){ + if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING == autopilotStatus) {//2 running ctvAutopilotStatusIv.setImageResource(R.drawable.bus_right_autopilot_icon); ctvAutopilotStatusTv.setTextColor(getResources().getColor(R.color.bus_autopilot_text_color_normal)); ctvAutopilotStatusTv.setText(getResources().getString(R.string.bus_loading_autopilot_success_tv)); ctvAutopilotStatus.setSelected(false); ctvAutopilotStatus.setFocusableInTouchMode(false); - UiThreadHandler.postDelayed(new Runnable() { - @Override - public void run() { - ctvAutopilotStatusIv.setImageResource(R.drawable.bus_ic_autopilot); - ctvAutopilotStatusTv.setText(getResources().getString(R.string.bus_loading_autopilot_runnig_tv)); - ctvAutopilotStatusTv.setTextColor(getResources().getColor(R.color.bus_autopilot_text_color_normal)); - ctvAutopilotStatus.setSelected(true); - ctvAutopilotStatus.setFocusableInTouchMode(true); -// ctvAutopilotStatus.setPressed(false); - } - }, 1000); + }else { + ctvAutopilotStatusIv.setImageResource(R.drawable.bus_wrong_autopilot_icon); + ctvAutopilotStatusTv.setTextColor(getResources().getColor(R.color.bus_autopilot_text_color_normal)); + ctvAutopilotStatusTv.setText(getResources().getString(R.string.bus_loading_autopilot_failure_tv)); + ctvAutopilotStatus.setFocusableInTouchMode(false); + ctvAutopilotStatus.setSelected(false); } + UiThreadHandler.postDelayed(new Runnable() { + @Override + public void run() { + setAutopilotBtnStatus(autopilotStatus); + } + },1000); } private void changeAutopilotBtnView(int autopilotStatus, boolean isAnimateRunning) { - + CallerLogger.INSTANCE.d(M_BUS + TAG, "onStateChangeChangeAutopilotBtnView: " + + autopilotStatus + "isAnimateRunning = " + isAnimateRunning); if (isAnimateRunning && IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING != autopilotStatus) { // 主动开启自动驾驶中,不为2(为0、1)则继续loading return; } - CallerLogger.INSTANCE.d(M_BUS + TAG, "onStateChangeChangeAutopilotBtnView: " + autopilotStatus + "isAnimateRunning = " + isAnimateRunning); - stopAutopilotAnimation(); - updateAutopilotStatus(autopilotStatus); + if (isAnimateRunning){ + stopAutopilotAnimation(); + updateAutopilotStatus(autopilotStatus); + }else { + setAutopilotBtnStatus(autopilotStatus); + } + } /** diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/model/BusOrderModel.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/model/BusOrderModel.java index d95d664aab..6e157d817e 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/model/BusOrderModel.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/model/BusOrderModel.java @@ -771,9 +771,7 @@ public class BusOrderModel { */ public void restartAutopilot() { CallerLogger.INSTANCE.d( M_BUS + TAG, "重启自动驾驶===" + isGoingToNextStation ); - if ( isGoingToNextStation ) { - autoDriveToNextStation( true ); - } + autoDriveToNextStation( true ); } /** diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/BusPresenter.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/BusPresenter.java index 646d08d794..e1b6181a21 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/BusPresenter.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/BusPresenter.java @@ -1,7 +1,6 @@ package com.mogo.och.bus.presenter; import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS; -import static com.mogo.och.bus.constant.BusConst.TIMER_START_AUTOPILOT_INTERVAL; import android.location.Location; import android.os.Looper; @@ -105,8 +104,10 @@ public class BusPresenter extends Presenter } public void restartAutopilot() { - currentAutopilotStatus = -1; - BusOrderModel.getInstance().restartAutopilot(); + if (BusOrderModel.getInstance().isGoingToNextStation()){ + currentAutopilotStatus = -1; + BusOrderModel.getInstance().restartAutopilot(); + } } public void onChangeOperationStatus() { @@ -125,7 +126,7 @@ public class BusPresenter extends Presenter mStationList.clear(); mStationList.addAll(stationList); mCurrentStation = currentStation; - functionDemoModeChange(); +// functionDemoModeChange(); CallerLogger.INSTANCE.d(M_BUS + "BusOrderModel =", " mCurrentStation =" + mCurrentStation); if (mView != null) { runOnUIThread(() -> mView.refreshBusStations( @@ -221,7 +222,6 @@ public class BusPresenter extends Presenter return; } runOnUIThread(() -> { - mView.onAutopilotEnableChange(false); mView.onAutopilotStatusChanged(currentAutopilotStatus); }); } @@ -246,14 +246,8 @@ public class BusPresenter extends Presenter @Override public void startOpenAutopilot() { + //非美化模式下启动动画 runOnUIThread(() -> mView.startAutopilotAnimation()); - // TODO: 2021/8/20 无工控机环境, 手动调起自动驾驶开启返回结果,有工控机环境要删除 -// UiThreadHandler.postDelayed(new Runnable() { -// @Override -// public void run() { -// debugAutoPilotStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING); -// } -// },2300); } private void runOnUIThread(Runnable executor) { diff --git a/OCH/mogo-och-bus/src/main/res/values/strings.xml b/OCH/mogo-och-bus/src/main/res/values/strings.xml index 8ebaa40023..0e7050b014 100644 --- a/OCH/mogo-och-bus/src/main/res/values/strings.xml +++ b/OCH/mogo-och-bus/src/main/res/values/strings.xml @@ -23,4 +23,5 @@ + 自动驾驶状态为0不可用 diff --git a/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/ui/BaseTaxiTabFragment.java b/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/ui/BaseTaxiTabFragment.java index ef1f655a79..0df85304cf 100644 --- a/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/ui/BaseTaxiTabFragment.java +++ b/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/ui/BaseTaxiTabFragment.java @@ -4,7 +4,6 @@ import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAX import static com.mogo.och.taxi.constant.TaxiConst.TIMER_START_AUTOPILOT_INTERVAL; import android.animation.ObjectAnimator; -import android.content.Intent; import android.graphics.drawable.AnimationDrawable; import android.os.Handler; import android.os.Looper; @@ -27,23 +26,20 @@ import com.mogo.commons.mvp.IView; import com.mogo.commons.mvp.MvpFragment; import com.mogo.commons.mvp.Presenter; import com.mogo.commons.voice.AIAssist; -import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters; import com.mogo.eagle.core.data.config.HmiBuildConfig; import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotRecordListener; import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener; -import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager; import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager; import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotRecordListenerManager; import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager; import com.mogo.eagle.core.function.call.hmi.CallerHmiManager; import com.mogo.eagle.core.function.call.map.CallerSmpManager; -import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; +import com.mogo.eagle.core.utilcode.mogo.toast.TipToast; import com.mogo.eagle.core.utilcode.util.UiThreadHandler; import com.mogo.map.MogoMapUIController; import com.mogo.map.MogoMarkerManager; import com.mogo.map.listener.IMogoMapListener; import com.mogo.map.uicontroller.VisualAngleMode; -import com.mogo.module.common.MogoApisHandler; import com.mogo.module.common.constants.DataTypes; import com.mogo.module.common.view.OnPreventFastClickListener; import com.mogo.och.taxi.R; @@ -111,13 +107,13 @@ public abstract class BaseTaxiTabFragment { // onAutopilotStatusChanged(false); // }); - mSpeedView.setOnLongClickListener(v -> { - CallerLogger.INSTANCE.d(M_TAXI + TAG, "长按显示状态工具栏"); - Intent intent = new Intent(); - intent.putExtra("oper", 52); - MogoApisHandler.getInstance().getApis().getIntentManagerApi().invoke("com.mogo.mock", intent); - return true; - }); +// mSpeedView.setOnLongClickListener(v -> { +// CallerLogger.INSTANCE.d(M_TAXI + TAG, "长按显示状态工具栏"); +// Intent intent = new Intent(); +// intent.putExtra("oper", 52); +// MogoApisHandler.getInstance().getApis().getIntentManagerApi().invoke("com.mogo.mock", intent); +// return true; +// }); } tvOperationStatus = findViewById(R.id.module_mogo_och_operation_status); @@ -175,82 +171,44 @@ public abstract class BaseTaxiTabFragment { -// if (groupTestPanel.getVisibility() == View.VISIBLE) { - groupTestPanel.setVisibility(View.GONE); -// } else { -// groupTestPanel.setVisibility(View.VISIBLE); -// } -// return false; -// }); -// } + // debug下调用测试面板 长按速度值 + if (DebugConfig.isDebug()) { + mSpeedView.setOnLongClickListener(v -> { + if (groupTestPanel.getVisibility() == View.VISIBLE) { + groupTestPanel.setVisibility(View.GONE); + } else { + groupTestPanel.setVisibility(View.VISIBLE); + } + return false; + }); + } onAutopilotStatusChanged(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState()); // 模拟 不可自动驾驶,目前场景是刚开机,adas还未和工控机连接 -// findViewById(R.id.btnAutopilotDisable).setOnClickListener(view -> -// { -// MogoApisHandler.getInstance().getApis() -// .getAdasControllerApi() -// .mockOchStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE, "不能使用"); -//// CallerLogger.INSTANCE.d(M_TAXI + "lianglihui","模拟 不可自动驾驶"); -// } -// ); + findViewById(R.id.btnAutopilotDisable).setOnClickListener(view -> + onAutopilotStatusChanged(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE) + + ); // 模拟 可自动驾驶,工控机连接正常,且处于人工干预状态 -// findViewById(R.id.btnAutopilotEnable).setOnClickListener(view -> -// { -// MogoApisHandler.getInstance().getApis() -// .getAdasControllerApi() -// .mockOchStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE, "能使用"); -// -//// CallerLogger.INSTANCE.d(M_TAXI + "lianglihui","模拟 可自动驾驶"); -// } -// ); + findViewById(R.id.btnAutopilotEnable).setOnClickListener(view -> + onAutopilotStatusChanged(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE) + + ); // 模拟 自动驾驶能力,自动驾驶中,可能是停车,可能是行进,但是是机器在处理车的前进后退,不是人 -// findViewById(R.id.btnAutopilotRunning).setOnClickListener(view -> -// { -// MogoApisHandler.getInstance().getApis() -// .getAdasControllerApi() -// .mockOchStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING, "Running"); -//// CallerLogger.INSTANCE.d(M_TAXI + "lianglihui","模拟 自动驾驶能力"); -// } -// ); + findViewById(R.id.btnAutopilotRunning).setOnClickListener(view -> + onAutopilotStatusChanged(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) - // 模拟 自动驾驶站 -// findViewById(R.id.btnAutopilotArrive).setOnClickListener(view -> -// { -// MogoApisHandler.getInstance().getApis() -// .getAdasControllerApi().mockOchStatus(-1, "Arrived"); -// -//// CallerLogger.INSTANCE.d(M_TAXI + "lianglihui","模拟 自动驾驶站"); -// } -// ); - - // 模拟 站点下发工控 - findViewById(R.id.btnAutopilotControl).setOnClickListener(view -> - { -// CallerLogger.INSTANCE.d(M_TAXI + "lianglihui","模拟 站点下发工控"); - AutopilotControlParameters currentAutopilot = new AutopilotControlParameters(); - currentAutopilot.isSpeakVoice = true; - // 万集东门站 - currentAutopilot.startLatLon = new AutopilotControlParameters.AutoPilotLonLat(40.194795425, 116.724476409); - // 市政府前街18号 - currentAutopilot.endLatLon = new AutopilotControlParameters.AutoPilotLonLat(40.1939540844, 116.720067); - // 订单运营类型 (9出租车,10小巴) - currentAutopilot.vehicleType = 10; - CallerLogger.INSTANCE.d(M_TAXI + TAG, "模拟 订单站点下发:" + currentAutopilot); - CallerAutoPilotManager.INSTANCE.startAutoPilot(currentAutopilot); - } ); tvOperationStatus.setOnClickListener(view -> { @@ -330,7 +288,7 @@ public abstract class BaseTaxiTabFragment -