diff --git a/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/BusProvider.java b/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/BusProvider.java index 6b5f576a24..5d4584dd99 100644 --- a/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/BusProvider.java +++ b/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/BusProvider.java @@ -1,8 +1,6 @@ package com.mogo.och.bus; -import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS; - import android.content.Context; import androidx.fragment.app.Fragment; @@ -11,10 +9,9 @@ import androidx.fragment.app.FragmentManager; import com.alibaba.android.arouter.facade.annotation.Route; import com.mogo.eagle.core.function.api.base.IMoGoFunctionProvider; -import com.mogo.eagle.core.function.call.setting.CallerMoGoUiSettingManager; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; import com.mogo.och.bus.constant.BusConst; -import com.mogo.och.bus.fragment.BusFragment; +import com.mogo.och.bus.fragment.ShuttleFragment; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -29,7 +26,7 @@ public class BusProvider implements IMoGoFunctionProvider { private static final String TAG = "BusProvider"; - private BusFragment busFragment; + private ShuttleFragment busFragment; private int containerId; private FragmentActivity activity; @@ -41,14 +38,14 @@ public class BusProvider implements IMoGoFunctionProvider { FragmentManager supportFragmentManager = activity.getSupportFragmentManager(); if (busFragment == null) { CallerLogger.d(TAG, "准备add fragment======"); - Fragment fragmentByTag = supportFragmentManager.findFragmentByTag(BusFragment.TAG); - if (fragmentByTag instanceof BusFragment) { - busFragment = (BusFragment) fragmentByTag; + Fragment fragmentByTag = supportFragmentManager.findFragmentByTag(ShuttleFragment.TAG); + if (fragmentByTag instanceof ShuttleFragment) { + busFragment = (ShuttleFragment) fragmentByTag; } else { - busFragment = new BusFragment(); + busFragment = new ShuttleFragment(); } if(!busFragment.isAdded()) { - supportFragmentManager.beginTransaction().add(containerId, busFragment, BusFragment.TAG).commitAllowingStateLoss(); + supportFragmentManager.beginTransaction().add(containerId, busFragment, ShuttleFragment.TAG).commitAllowingStateLoss(); } return; } diff --git a/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/fragment/BaseBusTabFragment.java b/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/fragment/BaseShuttleTabFragment.java similarity index 98% rename from OCH/shuttle/driver/src/main/java/com/mogo/och/bus/fragment/BaseBusTabFragment.java rename to OCH/shuttle/driver/src/main/java/com/mogo/och/bus/fragment/BaseShuttleTabFragment.java index b6d22ccdf0..5f69222cbd 100644 --- a/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/fragment/BaseBusTabFragment.java +++ b/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/fragment/BaseShuttleTabFragment.java @@ -43,6 +43,7 @@ import com.mogo.map.listener.MogoMapListenerHandler; import com.mogo.map.uicontroller.IMogoMapUIController; import com.mogo.map.uicontroller.VisualAngleMode; import com.mogo.och.bus.R; +import com.mogo.och.bus.ui.ShuttleTrafficDataView; import com.mogo.och.bus.view.BizMapView; import com.mogo.och.data.bean.BusRoutesResult; import com.mogo.och.bus.model.OrderModel; @@ -57,7 +58,7 @@ import org.greenrobot.eventbus.EventBus; * * @author tongchenfei */ -public abstract class BaseBusTabFragment> extends MvpFragment implements IMogoMapListener { +public abstract class BaseShuttleTabFragment> extends MvpFragment implements IMogoMapListener { private static final String TAG = "BaseBusTabFragment"; @@ -72,7 +73,7 @@ public abstract class BaseBusTabFragment private FrameLayout flStationPanelContainer; private BizMapView mapBizView; private Group groupTestPanel; - private TrafficDataView mTrafficDataView; + private ShuttleTrafficDataView mTrafficDataView; // private BusTrafficLightView mTrafficLightView; //远景和中景的切换 @@ -102,7 +103,7 @@ public abstract class BaseBusTabFragment @Override protected int getLayoutId() { - return R.layout.bus_base_fragment; + return R.layout.shuttle_base_fragment; } @Override @@ -121,7 +122,7 @@ public abstract class BaseBusTabFragment // tvOperationStatus = findViewById(R.id.module_mogo_och_operation_status); tvArrived = findViewById(R.id.module_mogo_och_arrived_tv); - mTrafficDataView = (TrafficDataView) findViewById(R.id.bus_arc); + mTrafficDataView = (ShuttleTrafficDataView) findViewById(R.id.bus_arc); LayoutInflater.from(getContext()).inflate(getStationPanelViewId(), flStationPanelContainer); slidePanelView.setOnSlidePanelMoveToEndListener(onSlideToEndListener); diff --git a/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/fragment/BusFragment.java b/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/fragment/ShuttleFragment.java similarity index 99% rename from OCH/shuttle/driver/src/main/java/com/mogo/och/bus/fragment/BusFragment.java rename to OCH/shuttle/driver/src/main/java/com/mogo/och/bus/fragment/ShuttleFragment.java index 147795d085..8bd2980b4e 100644 --- a/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/fragment/BusFragment.java +++ b/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/fragment/ShuttleFragment.java @@ -60,7 +60,7 @@ import me.jessyan.autosize.utils.AutoSizeUtils; * * @author tongchenfei */ -public class BusFragment extends BaseBusTabFragment +public class ShuttleFragment extends BaseShuttleTabFragment implements SlidePanelView.OnSlidePanelMoveToEndListener, View.OnClickListener { public static final String TAG = "BusFragment"; diff --git a/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/presenter/BusPresenter.java b/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/presenter/BusPresenter.java index 155f370780..c30bb7af1e 100644 --- a/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/presenter/BusPresenter.java +++ b/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/presenter/BusPresenter.java @@ -21,7 +21,7 @@ import com.mogo.och.bus.callback.IBusADASStatusCallback; import com.mogo.och.bus.callback.IBusControllerStatusCallback; import com.mogo.och.bus.callback.IRefreshBusStationsCallback; import com.mogo.och.bus.callback.ISlidePannelHideCallback; -import com.mogo.och.bus.fragment.BusFragment; +import com.mogo.och.bus.fragment.ShuttleFragment; import com.mogo.och.bus.model.OrderModel; import com.mogo.och.bus.util.BusTrajectoryManager; import com.mogo.och.common.module.biz.bean.DriverStatusQueryRespBean; @@ -44,7 +44,7 @@ import system_master.SystemStatusInfo; * * @author tongchenfei */ -public class BusPresenter extends Presenter +public class BusPresenter extends Presenter implements IRefreshBusStationsCallback, ISlidePannelHideCallback , IMoGoAutopilotStatusListener, IBusControllerStatusCallback, ILoginCallback, IBusADASStatusCallback { @@ -53,7 +53,7 @@ public class BusPresenter extends Presenter private final List mStationList = new ArrayList<>(); private int mCurrentStation = 0; - public BusPresenter(BusFragment view) { + public BusPresenter(ShuttleFragment view) { super(view); //2021.11.1 鹰眼架构整合,由IMoGoAutopilotStatusListener逐步替代IMogoAdasOCHCallback接口 CallerAutoPilotStatusListenerManager.INSTANCE.addListener(TAG, this); diff --git a/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/ui/ShuttleTapPositionView.java b/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/ui/ShuttleTapPositionView.java new file mode 100644 index 0000000000..12ba52cda7 --- /dev/null +++ b/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/ui/ShuttleTapPositionView.java @@ -0,0 +1,87 @@ +package com.mogo.och.bus.ui; + +import android.content.Context; +import android.content.res.TypedArray; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.TextView; + +import androidx.annotation.Nullable; +import androidx.constraintlayout.widget.ConstraintLayout; + +import com.mogo.eagle.core.data.config.FunctionBuildConfig; +import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils; +import com.mogo.och.bus.R; + +import org.jetbrains.annotations.NotNull; + +import chassis.Chassis; + +/** + * @author Jing + * @description 方向盘下方的档位 + * @since: 4/7/22 + */ +public class ShuttleTapPositionView extends ConstraintLayout { + private static final String TAG = "TapPositionView"; + private TextView tabP; + private TextView tabR; + private TextView tabN; + private TextView tabD; + private TypedArray typedArray; + + public ShuttleTapPositionView(Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + LayoutInflater.from(context).inflate(R.layout.shuttle_tap_position, this); + tabP = findViewById(R.id.tap_p); + tabR = findViewById(R.id.tap_r); + tabN = findViewById(R.id.tap_n); + tabD = findViewById(R.id.tap_d); + typedArray = context.obtainStyledAttributes(attrs, R.styleable.TapPositionView); + if(AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)||AppIdentityModeUtils.isSweeper(FunctionBuildConfig.appIdentityMode)){ + tabP.setVisibility(View.GONE); + } + } + + public void updateWithGear(@NotNull Chassis.GearPosition gear) { + if (tabP != null && tabR != null && tabN != null && tabD != null) { + int defaultColor = typedArray.getColor(R.styleable.TapPositionView_defaultColor, -1); + int selectColor = typedArray.getColor(R.styleable.TapPositionView_selectColor, -1); + switch (gear) { + case GEAR_NONE: + tabP.setTextColor(defaultColor); + tabR.setTextColor(defaultColor); + tabN.setTextColor(defaultColor); + tabD.setTextColor(defaultColor); + break; + case GEAR_P: + tabP.setTextColor(selectColor); + tabR.setTextColor(defaultColor); + tabN.setTextColor(defaultColor); + tabD.setTextColor(defaultColor); + break; + case GEAR_R: + tabR.setTextColor(selectColor); + tabP.setTextColor(defaultColor); + tabN.setTextColor(defaultColor); + tabD.setTextColor(defaultColor); + break; + case GEAR_N: + tabN.setTextColor(selectColor); + tabR.setTextColor(defaultColor); + tabP.setTextColor(defaultColor); + tabD.setTextColor(defaultColor); + break; + case GEAR_D: + tabD.setTextColor(selectColor); + tabN.setTextColor(defaultColor); + tabR.setTextColor(defaultColor); + tabP.setTextColor(defaultColor); + break; + default: + break; + } + } + } +} diff --git a/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/ui/ShuttleTrafficDataView.java b/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/ui/ShuttleTrafficDataView.java new file mode 100644 index 0000000000..56c48321b4 --- /dev/null +++ b/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/ui/ShuttleTrafficDataView.java @@ -0,0 +1,170 @@ +package com.mogo.och.bus.ui; + +import static com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.os.Handler; +import android.os.Message; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.constraintlayout.widget.ConstraintLayout; + +import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotPlanningActionsListener; +import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisBrakeStateListener; +import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisGearStateListener; +import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisThrottleStateListener; +import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager; +import com.mogo.eagle.core.function.call.autopilot.CallerChassisBrakeStateListenerManager; +import com.mogo.eagle.core.function.call.autopilot.CallerChassisGearStateListenerManager; +import com.mogo.eagle.core.function.call.autopilot.CallerChassisThrottleStateListenerManager; +import com.mogo.eagle.core.function.call.autopilot.CallerPlanningActionsListenerManager; +import com.mogo.eagle.core.function.hmi.ui.widget.TapPositionView; +import com.mogo.eagle.core.utilcode.util.ThreadUtils; +import com.mogo.och.bus.R; + +import org.jetbrains.annotations.NotNull; + +import chassis.Chassis; +import mogo.telematics.pad.MessagePad; + +/** + * @author Jing + * @description 速度 加速度 档位 刹车 油门状态值 + * @since: 6/24/22 + */ +public class ShuttleTrafficDataView extends ConstraintLayout implements + IMoGoChassisGearStateListener , + IMoGoChassisBrakeStateListener, + IMoGoChassisThrottleStateListener, + IMoGoAutopilotPlanningActionsListener { + private static final String TAG = "TrafficDataView"; + private ShuttleTapPositionView tapPositionView; + private TextView speedTextView; + private TextView accTextView; + private ImageView speedImage; + private ImageView brakeStatus; + + private static final int MSG_SEND_UPDATE = 1; + private volatile double acceleration; + private volatile float mBrake; + private volatile float mThrottle; + + @SuppressLint("HandlerLeak") + private final Handler handler = new Handler() { + @Override + public void handleMessage(@NonNull Message msg) { + super.handleMessage(msg); + if (msg.what == MSG_SEND_UPDATE) { + java.text.DecimalFormat mFormat = new java.text.DecimalFormat("0.0"); + String accStr = mFormat.format(Math.abs(acceleration)); + if (acceleration > 0f) { + accTextView.setText(accStr); + } else { + accTextView.setText("- " + accStr); + } + int state = CallerAutoPilotStatusListenerManager.INSTANCE.getState(); + if (state < STATUS_AUTOPILOT_RUNNING) { + if (mBrake > 0) { + brakeStatus.setImageResource(R.drawable.traffic_data_brake); + } else if (mThrottle >= 0 && mBrake == 0) { + brakeStatus.setImageResource(R.drawable.traffic_data_accelerator); + } else { + brakeStatus.setImageResource(R.drawable.traffic_data_empty); + } + } + if (state == 2) { + brakeStatus.setImageResource(R.drawable.traffic_data_empty); + } + } + handler.sendEmptyMessageDelayed(MSG_SEND_UPDATE, 1000L); + } + }; + + public ShuttleTrafficDataView(@NonNull Context context) { + super(context); + } + + public ShuttleTrafficDataView(@NonNull Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + initView(context); + } + + public ShuttleTrafficDataView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + public ShuttleTrafficDataView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { + super(context, attrs, defStyleAttr, defStyleRes); + } + + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + handler.sendEmptyMessageDelayed(MSG_SEND_UPDATE, 1000L); + CallerChassisGearStateListenerManager.INSTANCE.addListener(TAG, this); + CallerChassisBrakeStateListenerManager.INSTANCE.addListener(TAG, this); + CallerChassisThrottleStateListenerManager.INSTANCE.addListener(TAG, this); + CallerPlanningActionsListenerManager.INSTANCE.addListener(TAG, this); + } + + private void initView(@NonNull Context context) { + LayoutInflater.from(context).inflate(R.layout.shuttle_traffic_data, this); + tapPositionView = findViewById(R.id.traffic_position); + speedImage = findViewById(R.id.speedImage); + speedTextView = findViewById(R.id.speedTextView); + accTextView = findViewById(R.id.speedAccTextView); + brakeStatus = findViewById(R.id.brakeStatus); + } + + @Override + protected void onDetachedFromWindow() { + super.onDetachedFromWindow(); + CallerChassisGearStateListenerManager.INSTANCE.removeListener(TAG); + CallerChassisBrakeStateListenerManager.INSTANCE.removeListener(TAG); + CallerChassisThrottleStateListenerManager.INSTANCE.removeListener(TAG); + CallerPlanningActionsListenerManager.INSTANCE.removeListener(TAG); + } + + @Override + public void pncActions(@NonNull MessagePad.PlanningActionMsg planningActionMsg) { + acceleration = planningActionMsg.getDestinationAcc(); + } + + /** + * 档位 + */ + @Override + public void onAutopilotGearData(@NotNull Chassis.GearPosition gear) { + ThreadUtils.runOnUiThread(() -> { + if (tapPositionView != null) { + tapPositionView.updateWithGear(gear); + } + }); + } + + @Override + public void onAutopilotBrake(float brake) { + mBrake = brake; + } + + @Override + public void onAutopilotThrottle(float throttle) { + mThrottle = throttle; + } + + /** + * value呈现 + */ + public void updateSpeedWithValue(int newSpeed) { + if (speedTextView != null) { + speedTextView.setText(String.valueOf(newSpeed)); + } + } + +} diff --git a/OCH/shuttle/driver/src/main/res/drawable-xhdpi/shuttle_traffic_data_speed.png b/OCH/shuttle/driver/src/main/res/drawable-xhdpi/shuttle_traffic_data_speed.png new file mode 100644 index 0000000000..029cf64b2a Binary files /dev/null and b/OCH/shuttle/driver/src/main/res/drawable-xhdpi/shuttle_traffic_data_speed.png differ diff --git a/OCH/shuttle/driver/src/main/res/layout/fragment_och_bus.xml b/OCH/shuttle/driver/src/main/res/layout/fragment_och_bus.xml index 5314681946..e9b705fa75 100644 --- a/OCH/shuttle/driver/src/main/res/layout/fragment_och_bus.xml +++ b/OCH/shuttle/driver/src/main/res/layout/fragment_och_bus.xml @@ -3,7 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/module_och_bus_order_status_stationInfo" - android:layout_width="@dimen/module_mogo_och_autopilot_order_bg_width" + android:layout_width="@dimen/dp_587" android:layout_height="wrap_content" android:paddingBottom="@dimen/dp_28" android:background="@drawable/bus_line_panel_bg" @@ -96,9 +96,10 @@ - @@ -163,9 +163,10 @@ @@ -211,15 +213,16 @@ app:layout_constraintLeft_toLeftOf="@id/module_mogo_och_station_panel_container" app:layout_constraintTop_toBottomOf="@id/module_mogo_och_station_panel_container" tools:visibility="visible" /> - + + + android:layout_width="@dimen/dp_585" + android:layout_height="@dimen/dp_176"/> + + + + + + + + + + + \ No newline at end of file diff --git a/OCH/shuttle/driver/src/main/res/layout/shuttle_traffic_data.xml b/OCH/shuttle/driver/src/main/res/layout/shuttle_traffic_data.xml new file mode 100644 index 0000000000..abbad9395d --- /dev/null +++ b/OCH/shuttle/driver/src/main/res/layout/shuttle_traffic_data.xml @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OCH/shuttle/driver/src/main/res/layout/shuttle_wirte_off_view.xml b/OCH/shuttle/driver/src/main/res/layout/shuttle_wirte_off_view.xml index d549ca9937..60f94aace3 100644 --- a/OCH/shuttle/driver/src/main/res/layout/shuttle_wirte_off_view.xml +++ b/OCH/shuttle/driver/src/main/res/layout/shuttle_wirte_off_view.xml @@ -12,7 +12,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/shuttle_driver_cad6ff" - android:textSize="32dp" + android:textSize="30dp" android:layout_marginStart="@dimen/dp_68" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent"