diff --git a/OCH/mogo-och-bus-passenger/build.gradle b/OCH/mogo-och-bus-passenger/build.gradle index b38804a63d..fc55956e11 100644 --- a/OCH/mogo-och-bus-passenger/build.gradle +++ b/OCH/mogo-och-bus-passenger/build.gradle @@ -60,6 +60,7 @@ dependencies { implementation rootProject.ext.dependencies.mogo_core_data implementation rootProject.ext.dependencies.mogo_core_function_call implementation rootProject.ext.dependencies.mogo_core_function_v2x + implementation rootProject.ext.dependencies.mogo_core_function_hmi }else { implementation project(":core:mogo-core-utils") implementation project(":foudations:mogo-commons") @@ -67,6 +68,7 @@ dependencies { implementation project(':core:mogo-core-data') implementation project(':core:mogo-core-function-call') implementation project(':core:function-impl:mogo-core-function-v2x') + implementation project(':core:function-impl:mogo-core-function-hmi') } } diff --git a/OCH/mogo-och-bus-passenger/src/main/assets/map_style.data b/OCH/mogo-och-bus-passenger/src/main/assets/map_style.data new file mode 100644 index 0000000000..2be43925c7 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/main/assets/map_style.data differ diff --git a/OCH/mogo-och-bus-passenger/src/main/assets/map_style_extra.data b/OCH/mogo-och-bus-passenger/src/main/assets/map_style_extra.data new file mode 100644 index 0000000000..6a172a62e5 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/main/assets/map_style_extra.data differ diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/MogoOCHBusPassenger.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/MogoOCHBusPassenger.java index 2dc69f3322..c341867ff3 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/MogoOCHBusPassenger.java +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/MogoOCHBusPassenger.java @@ -11,7 +11,7 @@ import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; import com.mogo.map.MogoMapUIController; import com.mogo.module.common.MogoApisHandler; import com.mogo.och.bus.passenger.constant.BusPassengerConst; -import com.mogo.och.bus.passenger.ui.BusPassengerBaseFragment; +import com.mogo.och.bus.passenger.ui.BusPassengerRouteFragment; import com.mogo.service.statusmanager.IMogoStatusChangedListener; import com.mogo.service.statusmanager.StatusDescriptor; @@ -31,7 +31,7 @@ public class MogoOCHBusPassenger implements IMogoOCH, IMogoStatusChangedListener private FragmentActivity mActivity; private int mContainerId; - private BusPassengerBaseFragment mBusPassengerFragment; + private BusPassengerRouteFragment mPassengerFragment; @Override public void createCoverage(FragmentActivity activity, int containerId) { @@ -44,7 +44,7 @@ public class MogoOCHBusPassenger implements IMogoOCH, IMogoStatusChangedListener this.mActivity = activity; this.mContainerId = containerId; - UiThreadHandler.postDelayed(() -> stepIntoVrMode(), 5_000L); + UiThreadHandler.post(() -> stepIntoVrMode()); return null; } @@ -84,23 +84,23 @@ public class MogoOCHBusPassenger implements IMogoOCH, IMogoStatusChangedListener private void stepIntoVrMode() { CallerLogger.INSTANCE.d( M_TAXI_P + TAG, "进入vr模式" ); MogoMapUIController.getInstance() - .openVrMode( false ); + .stepInVrMode( true ); // 白天模式 } private void showFragment() { - if (mBusPassengerFragment == null) { + if (mPassengerFragment == null) { CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "准备add fragment======"); - mBusPassengerFragment = new BusPassengerBaseFragment(); - mActivity.getSupportFragmentManager().beginTransaction().add(mContainerId, mBusPassengerFragment).commitAllowingStateLoss(); + mPassengerFragment = new BusPassengerRouteFragment(); + mActivity.getSupportFragmentManager().beginTransaction().add(mContainerId, mPassengerFragment).commitAllowingStateLoss(); return; } CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "准备show fragment"); - mActivity.getSupportFragmentManager().beginTransaction().show(mBusPassengerFragment).commitAllowingStateLoss(); + mActivity.getSupportFragmentManager().beginTransaction().show(mPassengerFragment).commitAllowingStateLoss(); } private void hideFragment(){ - if (mBusPassengerFragment != null){ - mActivity.getSupportFragmentManager().beginTransaction().hide(mBusPassengerFragment).commitAllowingStateLoss(); + if (mPassengerFragment != null){ + mActivity.getSupportFragmentManager().beginTransaction().hide(mPassengerFragment).commitAllowingStateLoss(); } } } diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/adapter/BusPassengerLineStationsAdapter.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/adapter/BusPassengerLineStationsAdapter.java new file mode 100644 index 0000000000..8768a0623e --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/adapter/BusPassengerLineStationsAdapter.java @@ -0,0 +1,152 @@ +package com.mogo.och.bus.passenger.adapter; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.mogo.och.bus.passenger.R; +import com.mogo.och.bus.passenger.bean.BusPassengerStation; + +import java.util.List; + +import static com.mogo.och.bus.passenger.constant.BusPassengerConst.STATION_STATUS_STOPPED; + +/** + * @author: wangmingjun + * @date: 2022/4/6 + */ +public class BusPassengerLineStationsAdapter extends RecyclerView.Adapter { + + private Context mContext; + private List mStations; + private static final int LINE_START_STATION_ITEM = 0; + private static final int LINE_END_STATION_ITEM = 1; + private static final int LINE_MIDDLE_STATION_ITEM = 2; + + public BusPassengerLineStationsAdapter(Context context, List stations){ + this.mContext = context; + this.mStations = stations; + } + + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + if (viewType == LINE_START_STATION_ITEM){ + View view = LayoutInflater.from(mContext).inflate(R.layout.bus_p_stations_start_item,parent,false); + StartStationViewHolder viewHolder = new StartStationViewHolder(view); + return viewHolder; + }else if (viewType == LINE_END_STATION_ITEM) { + View view = LayoutInflater.from(mContext).inflate(R.layout.bus_p_stations_end_item,parent,false); + EndStationViewHolder viewHolder = new EndStationViewHolder(view); + return viewHolder; + }else { + View view = LayoutInflater.from(mContext).inflate(R.layout.bus_p_stations_middle_item,parent,false); + MiddleStationViewHolder viewHolder = new MiddleStationViewHolder(view); + return viewHolder; + } + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { + BusPassengerStation station = mStations.get(position); + if (holder instanceof StartStationViewHolder){ + StartStationViewHolder viewHolder = (StartStationViewHolder)holder; + viewHolder.startStationName.setText(station.getName()); + if (station.getDrivingStatus() == STATION_STATUS_STOPPED && !station.isLeaving()){//到站 + viewHolder.curStationBg.setVisibility(View.VISIBLE); + viewHolder.stationCircle.setVisibility(View.GONE); + viewHolder.startStationName.setTextColor(mContext.getResources().getColor(R.color.bus_p_current_station_txt_color)); + }else { + viewHolder.curStationBg.setVisibility(View.GONE); + viewHolder.stationCircle.setVisibility(View.VISIBLE); + viewHolder.startStationName.setTextColor(mContext.getResources().getColor(R.color.bus_p_station_txt_color)); + } + }else if (holder instanceof EndStationViewHolder){ + EndStationViewHolder viewHolder = (EndStationViewHolder)holder; + viewHolder.endStationName.setText(station.getName()); + BusPassengerStation preStation = mStations.get(position -1); + if ((preStation.getDrivingStatus() == STATION_STATUS_STOPPED && preStation.isLeaving()) + || (station.getDrivingStatus() == STATION_STATUS_STOPPED && !station.isLeaving())){//到站 + viewHolder.curStationBg.setVisibility(View.VISIBLE); + viewHolder.stationCircle.setVisibility(View.GONE); + viewHolder.endStationName.setTextColor(mContext.getResources().getColor(R.color.bus_p_current_station_txt_color)); + }else { + viewHolder.curStationBg.setVisibility(View.GONE); + viewHolder.stationCircle.setVisibility(View.VISIBLE); + viewHolder.endStationName.setTextColor(mContext.getResources().getColor(R.color.bus_p_station_txt_color)); + } + }else { + MiddleStationViewHolder viewHolder = (MiddleStationViewHolder)holder; + viewHolder.middleStationName.setText(station.getName()); + BusPassengerStation preStation = mStations.get(position -1); + if ((preStation.getDrivingStatus() == STATION_STATUS_STOPPED && preStation.isLeaving()) + || (station.getDrivingStatus() == STATION_STATUS_STOPPED && !station.isLeaving())) {//到站 + viewHolder.curStationBg.setVisibility(View.VISIBLE); + viewHolder.middleStationName.setTextColor(mContext.getResources().getColor(R.color.bus_p_current_station_txt_color)); + }else { + viewHolder.curStationBg.setVisibility(View.GONE); + viewHolder.middleStationName.setTextColor(mContext.getResources().getColor(R.color.bus_p_station_txt_color)); + } + } + } + + @Override + public int getItemCount() { + return mStations.size(); + } + + @Override + public int getItemViewType(int position) { + //第一个要显示时间 + if (position == 0){ + return LINE_START_STATION_ITEM; + }else if (position == mStations.size() -1){ + return LINE_END_STATION_ITEM; + }else { + return LINE_MIDDLE_STATION_ITEM; + } + } + +} + +class StartStationViewHolder extends RecyclerView.ViewHolder{ + public TextView startStationName; + public ImageView stationCircle; + public ImageView curStationBg; + public StartStationViewHolder(@NonNull View itemView) { + super(itemView); + startStationName = itemView.findViewById(R.id.bus_p_start_station); + stationCircle = itemView.findViewById(R.id.bus_p_start_circle); + curStationBg = itemView.findViewById(R.id.bus_p_cur_start_station_tag); + } +} + +class EndStationViewHolder extends RecyclerView.ViewHolder{ + + public TextView endStationName; + public ImageView stationCircle; + public ImageView curStationBg; + public EndStationViewHolder(@NonNull View itemView) { + super(itemView); + endStationName = itemView.findViewById(R.id.bus_p_end_station); + stationCircle = itemView.findViewById(R.id.bus_p_end_circle); + curStationBg = itemView.findViewById(R.id.bus_p_cur_end_station_tag); + } +} + +class MiddleStationViewHolder extends RecyclerView.ViewHolder{ + + public TextView middleStationName; + public ImageView curStationBg; + public MiddleStationViewHolder(@NonNull View itemView) { + super(itemView); + middleStationName = itemView.findViewById(R.id.bus_p_middle_station); + curStationBg = itemView.findViewById(R.id.bus_p_middle_tag); + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/bean/BusPassengerOperationStatusResponse.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/bean/BusPassengerOperationStatusResponse.java new file mode 100644 index 0000000000..1d2068e4af --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/bean/BusPassengerOperationStatusResponse.java @@ -0,0 +1,21 @@ +package com.mogo.och.bus.passenger.bean; + +import com.mogo.eagle.core.data.BaseData; + +/** + * @author congtaowang + * @since 2021/3/22 + * + * 小巴车运营状态返回参数 + */ +public class BusPassengerOperationStatusResponse extends BaseData { + + public Result data; + + public static class Result { + private String sn; //司机屏sn + public String plateNumber; //车牌号 + public int serviceStatus;//0:已收车,1:已出车 + public int businessType;// 车辆类型: taxi/bus + } +} diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/bean/BusPassengerQueryLineRequest.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/bean/BusPassengerQueryLineRequest.java new file mode 100644 index 0000000000..c4e4e428a7 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/bean/BusPassengerQueryLineRequest.java @@ -0,0 +1,18 @@ +package com.mogo.och.bus.passenger.bean; + +import com.mogo.cloud.passport.MoGoAiCloudClientConfig; + +public +/** + * @author congtaowang + * @since 2021/3/22 + * + * 根据车机行驶线路站点信息 + */ +class BusPassengerQueryLineRequest { + + private String sn; + public BusPassengerQueryLineRequest(String sn) { + this.sn = sn; + } +} diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/bean/BusPassengerRoutesResponse.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/bean/BusPassengerRoutesResponse.java new file mode 100644 index 0000000000..e8ba5d6ef2 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/bean/BusPassengerRoutesResponse.java @@ -0,0 +1,27 @@ +package com.mogo.och.bus.passenger.bean; + +import com.mogo.eagle.core.data.BaseData; + +/** + * 网约车小巴路线接口请求响应结果 返回的是对应司机屏的线路信息 + * + * @author tongchenfei + */ +public class BusPassengerRoutesResponse extends BaseData { + private BusPassengerRoutesResult data; + + public BusPassengerRoutesResult getResult() { + return data; + } + + public void setResult(BusPassengerRoutesResult data) { + this.data = data; + } + + @Override + public String toString() { + return "OchBusRoutesResponse{" + + "data=" + data + + '}'; + } +} diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/bean/BusPassengerRoutesResult.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/bean/BusPassengerRoutesResult.java new file mode 100644 index 0000000000..dbfd30bebd --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/bean/BusPassengerRoutesResult.java @@ -0,0 +1,59 @@ +package com.mogo.och.bus.passenger.bean; + +import java.util.List; + +/** + * 网约车小巴路线接口返回接口数据封装 + * + * @author tongchenfei + */ +public class BusPassengerRoutesResult { + private List sites; + private int lineId; + private String name; //线路名称 + private int lineType; //线路类型,0:环形 + private String description; + private int status; + private String runningDur; //运营时间 + + public List getSites() { + return sites; + } + + public int getLineId() { + return lineId; + } + + public String getName() { + return name; + } + + public int getLineType() { + return lineType; + } + + public String getDescription() { + return description; + } + + public int getStatus() { + return status; + } + + public String getRunningDur() { + return runningDur; + } + + @Override + public String toString() { + return "BusPassengerRoutesResult{" + + "sites=" + sites + + ", lineId=" + lineId + + ", name='" + name + '\'' + + ", lineType=" + lineType + + ", description='" + description + '\'' + + ", status=" + status + + ", runningDur='" + runningDur + '\'' + + '}'; + } +} diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/bean/BusPassengerStation.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/bean/BusPassengerStation.java new file mode 100644 index 0000000000..fa0aa2051c --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/bean/BusPassengerStation.java @@ -0,0 +1,137 @@ +package com.mogo.och.bus.passenger.bean; + +/** + * 单个网约车小巴车站信息 + * + * @author wangmingjun + */ +public class BusPassengerStation { + + private String name; + private String description; + private String cityCode; + private double lon; //高精坐标 + private double lat; //高精坐标 + private int businessType; //站点类型,9:taxi,10:bus + private int status; + private int siteId; + private int seq; + private int drivingStatus;//行驶信息,0初始值;1已经过;2当前站;3未到站 + private int ifStop = 1; // 是否需要停靠、1需要、0不需要 // TODO: 2021/10/19 原来站点里有设计是否需要停靠字段,现设计暂无,默认都需要停靠 + private boolean leaving; + + public void setName(String name) { + this.name = name; + } + + public void setDescription(String description) { + this.description = description; + } + + public void setCityCode(String cityCode) { + this.cityCode = cityCode; + } + + public void setLon(double lon) { + this.lon = lon; + } + + public void setLat(double lat) { + this.lat = lat; + } + + public void setBusinessType(int businessType) { + this.businessType = businessType; + } + + public void setStatus(int status) { + this.status = status; + } + + public void setSiteId(int siteId) { + this.siteId = siteId; + } + + public void setSeq(int seq) { + this.seq = seq; + } + + public void setDrivingStatus(int drivingStatus) { + this.drivingStatus = drivingStatus; + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } + + public String getCityCode() { + return cityCode; + } + + + public int getBusinessType() { + return businessType; + } + + public int getStatus() { + return status; + } + + public int getSiteId() { + return siteId; + } + + public int getSeq() { + return seq; + } + + public int getDrivingStatus() { + return drivingStatus; + } + + public double getLon() { + return lon; + } + + public double getLat() { + return lat; + } + + public void setIfStop(int ifStop) { + this.ifStop = ifStop; + } + + public int getIfStop() { + return ifStop; + } + + public void setLeaving(boolean leaving) { + this.leaving = leaving; + } + + public boolean isLeaving() { + return leaving; + } + + @Override + public String toString() { + return "OchBusStation{" + + "name='" + name + '\'' + + ", description='" + description + '\'' + + ", cityCode='" + cityCode + '\'' + + ", lon=" + lon + + ", lat=" + lat + + ", businessType=" + businessType + + ", status=" + status + + ", siteId=" + siteId + + ", seq=" + seq + + ", drivingStatus=" + drivingStatus + + ", ifStop=" + ifStop + + ", leaving=" + leaving + + '}'; + } +} diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/callback/IBusPassegerDriverStatusCallback.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/callback/IBusPassegerDriverStatusCallback.java new file mode 100644 index 0000000000..1dc3e00195 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/callback/IBusPassegerDriverStatusCallback.java @@ -0,0 +1,9 @@ +package com.mogo.och.bus.passenger.callback; + +/** + * @author: wangmingjun + * @date: 2021/10/22 + */ +public interface IBusPassegerDriverStatusCallback { + void changeOperationStatus(boolean changeStatus); +} diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/callback/IBusPassengerAutopilotPlanningCallback.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/callback/IBusPassengerAutopilotPlanningCallback.java index ac5b26d05c..f00d09c33c 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/callback/IBusPassengerAutopilotPlanningCallback.java +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/callback/IBusPassengerAutopilotPlanningCallback.java @@ -1,6 +1,7 @@ package com.mogo.och.bus.passenger.callback; import com.amap.api.maps.model.LatLng; +import com.mogo.eagle.core.data.map.MogoLatLng; import java.util.List; @@ -10,6 +11,6 @@ import mogo.telematics.pad.MessagePad; * Created on 2022/3/31 */ public interface IBusPassengerAutopilotPlanningCallback { - void routeResult(List models); - void routeResultByServer(List models); + void routeResult(List models); + void routePlanningToNextStationChanged(long meters, long timeInSecond); } diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/callback/IBusPassengerMapViewCallback.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/callback/IBusPassengerMapViewCallback.java new file mode 100644 index 0000000000..25f7d3bbec --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/callback/IBusPassengerMapViewCallback.java @@ -0,0 +1,9 @@ +package com.mogo.och.bus.passenger.callback; + +/** + * @author: wangmingjun + * @date: 2022/3/10 + */ +public interface IBusPassengerMapViewCallback { + void onCameraChange(float bearing); +} diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/callback/IBusPassengerRouteLineInfoCallback.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/callback/IBusPassengerRouteLineInfoCallback.java new file mode 100644 index 0000000000..c7df47ec9f --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/callback/IBusPassengerRouteLineInfoCallback.java @@ -0,0 +1,14 @@ +package com.mogo.och.bus.passenger.callback; + +import com.mogo.och.bus.passenger.bean.BusPassengerStation; + +import java.util.List; + +/** + * @author: wangmingjun + * @date: 2022/4/6 + */ +public interface IBusPassengerRouteLineInfoCallback { + void updateLineInfo(String lineName, String lineDurTime); + void updateStationsInfo(List stations,int currentStationIndex,boolean isArrived); +} diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/constant/BusPassengerConst.kt b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/constant/BusPassengerConst.kt index b3515af9ba..d947f441b2 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/constant/BusPassengerConst.kt +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/constant/BusPassengerConst.kt @@ -24,5 +24,21 @@ class BusPassengerConst { // OCH arouter 路由path const val PATH = "/och/api" + + // 轮询line + const val LOOP_LINE_2S = 2 * 1000L + const val LOOP_DELAY = 100L + + // 无状态 + const val STATION_STATUS_IDLE = 0 + // 已过站(历史站) + const val STATION_STATUS_LEAVING = 1 + // 到站(当前站) + const val STATION_STATUS_STOPPED = 2 + // 未到站(未到站) + const val STATION_STATUS_ARRIVING = 3 + + //bus平均速度 + const val BUS_AVERAGE_SPEED = 25 } } \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/model/BusPassengerModel.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/model/BusPassengerModel.java index 6364ef050e..c52d87aa10 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/model/BusPassengerModel.java +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/model/BusPassengerModel.java @@ -8,8 +8,10 @@ import android.net.ConnectivityManager; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import com.amap.api.maps.model.LatLng; import com.mogo.aicloud.services.socket.IMogoLifecycleListener; import com.mogo.aicloud.services.socket.MogoAiCloudSocketManager; +import com.mogo.cloud.commons.utils.CoordinateUtils; import com.mogo.commons.debug.DebugConfig; import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo; import com.mogo.eagle.core.data.config.FunctionBuildConfig; @@ -17,14 +19,26 @@ import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotPlanningListener import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener; import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager; import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListenerManager; +import com.mogo.eagle.core.network.utils.GsonUtil; import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; import com.mogo.eagle.core.utilcode.util.NetworkUtils; import com.mogo.map.navi.IMogoCarLocationChangedListener2; import com.mogo.module.common.MogoApisHandler; +import com.mogo.och.bus.passenger.bean.BusPassengerOperationStatusResponse; +import com.mogo.och.bus.passenger.bean.BusPassengerRoutesResponse; +import com.mogo.och.bus.passenger.bean.BusPassengerRoutesResult; +import com.mogo.och.bus.passenger.bean.BusPassengerStation; +import com.mogo.och.bus.passenger.callback.IBusPassegerDriverStatusCallback; import com.mogo.och.bus.passenger.callback.IBusPassengerADASStatusCallback; import com.mogo.och.bus.passenger.callback.IBusPassengerAutopilotPlanningCallback; import com.mogo.och.bus.passenger.callback.IBusPassengerControllerStatusCallback; +import com.mogo.och.bus.passenger.callback.IBusPassengerRouteLineInfoCallback; +import com.mogo.och.bus.passenger.constant.BusPassengerConst; +import com.mogo.och.bus.passenger.network.BusPassengerModelLoopManager; +import com.mogo.och.bus.passenger.network.BusPassengerServiceCallback; +import com.mogo.och.bus.passenger.network.BusPassengerServiceManager; +import com.mogo.och.bus.passenger.utils.BPCoordinateCalculateRouteUtil; import com.mogo.service.intent.IMogoIntentListener; import com.mogo.service.statusmanager.IMogoStatusChangedListener; import com.mogo.service.statusmanager.StatusDescriptor; @@ -40,6 +54,7 @@ import mogo.telematics.pad.MessagePad; import mogo_msg.MogoReportMsg; import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS_P; +import static com.mogo.och.bus.passenger.constant.BusPassengerConst.STATION_STATUS_STOPPED; /** * Created on 2022/3/31 @@ -47,6 +62,8 @@ import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS public class BusPassengerModel { private static final String TAG = BusPassengerModel.class.getSimpleName(); + private List mRoutePoints = new ArrayList<>(); + private static final class SingletonHolder { private static final BusPassengerModel INSTANCE = new BusPassengerModel(); } @@ -60,6 +77,9 @@ public class BusPassengerModel { private IBusPassengerAutopilotPlanningCallback mAutopilotPlanningCallback; //Model->Presenter:自动驾驶线路规划 private Map mControllerStatusCallbackMap = new ConcurrentHashMap<>(); + private IBusPassegerDriverStatusCallback mDriverStatusCallback; //出车收车状态 + private IBusPassengerRouteLineInfoCallback mRouteLineInfoCallback; // bus路线信息更新 + private double mLongitude, mLatitude; private BusPassengerModel() { @@ -69,10 +89,81 @@ public class BusPassengerModel { mContext = context.getApplicationContext(); initListeners(); // TODO: 2022/3/31 + queryDriverOperationStatus(); + } + + public void setDriverStatusCallback(IBusPassegerDriverStatusCallback callback){ + this.mDriverStatusCallback = callback; + } + + public void setRouteLineInfoCallback(IBusPassengerRouteLineInfoCallback callback){ + this.mRouteLineInfoCallback = callback; + } + + private void queryDriverOperationStatus() { + BusPassengerServiceManager.getInstance().queryDriverOperationStatus(mContext + , new BusPassengerServiceCallback() { + @Override + public void onSuccess(BusPassengerOperationStatusResponse data) { + if (data == null || data.data == null) return; + startOrStopOrderLoop(data.data.serviceStatus == 1); + if(mDriverStatusCallback != null){ + mDriverStatusCallback.changeOperationStatus(data.data.serviceStatus == 1); + } + } + + @Override + public void onFail(int code, String msg) { + queryDriverOperationStatus(); + } + }); + } + + public void queryDriverSiteByCoordinate(){ + BusPassengerServiceManager.getInstance().queryDriverSiteByCoordinate(mContext + , new BusPassengerServiceCallback() { + @Override + public void onSuccess(BusPassengerRoutesResponse data) { + if ( data == null + || data.getResult() == null + || data.getResult().getSites() == null) { + return; + } + updatePassengerRouteInfo(data.getResult()); + } + + @Override + public void onFail(int code, String msg) { + + } + }); + } + + private void updatePassengerRouteInfo(BusPassengerRoutesResult result) { + if (mRouteLineInfoCallback != null){ + mRouteLineInfoCallback.updateLineInfo(result.getName(),result.getRunningDur()); + if (result.getSites() != null){ + List stations = result.getSites(); + for (int i = 0; i< stations.size(); i++){ + BusPassengerStation station = stations.get(i); + if (station.getDrivingStatus() == STATION_STATUS_STOPPED && station.isLeaving() && i+1 < stations.size()){ + mRouteLineInfoCallback.updateStationsInfo(stations,i+1,false); + return; + }else if (station.getDrivingStatus() == STATION_STATUS_STOPPED && !station.isLeaving()){ + startOrStopCalculateRouteInfo(false); + mRouteLineInfoCallback.updateStationsInfo(stations,i,true); + return; + } + } + } + } + } public void release() { releaseListeners(); + startOrStopCalculateRouteInfo(false); + startOrStopOrderLoop(false); } public void setMoGoAutopilotPlanningListener(IBusPassengerAutopilotPlanningCallback @@ -147,7 +238,7 @@ public class BusPassengerModel { if ( ConnectivityManager.CONNECTIVITY_ACTION.equals( intentStr ) ) { if ( NetworkUtils.isConnected( mContext ) ) { if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) { - // TODO: 2022/3/31 + queryDriverOperationStatus(); } } } @@ -246,17 +337,74 @@ public class BusPassengerModel { @Override public void onAutopilotTrajectory(@NonNull List trajectoryInfos) { - } @Override public void onAutopilotRotting(@Nullable MessagePad.GlobalPathResp routeList) { - if (null != routeList && routeList.getWayPointsList().size() > 0){ - // TODO: 2022/3/31 - mAutopilotPlanningCallback.routeResult(routeList.getWayPointsList()); + CallerLogger.INSTANCE.d(M_BUS_P + TAG, "onAutopilotRotting = " + + GsonUtil.jsonFromObject(routeList)); + List mRoutePoints = routeList.getWayPointsList(); + if (null != routeList && mRoutePoints.size() > 0){ + updateRoutePoints(mRoutePoints); } } - }; + public void dynamicCalculateRouteInfo() { + List lastPoints = BPCoordinateCalculateRouteUtil + .getRemainPointListByCompare(mRoutePoints,mLongitude,mLatitude); + + float lastSumLength = 0; + if (lastPoints.size() == 1){ //只是最后一个点,计算当前位置和最后一个点的距离 + lastSumLength = CoordinateUtils.calculateLineDistance( + lastPoints.get(0).longitude, lastPoints.get(0).latitude, + mLongitude, mLatitude); + }else { + lastSumLength = BPCoordinateCalculateRouteUtil.calculateRouteSumLength(lastPoints); + } + double lastTime = lastSumLength / BusPassengerConst.BUS_AVERAGE_SPEED * 3.6 ; //秒 + + if (mAutopilotPlanningCallback != null){ + mAutopilotPlanningCallback.routePlanningToNextStationChanged((long)lastSumLength,(long) lastTime); + } + + } + + public void updateRoutePoints(List routePoints) { + if (mAutopilotPlanningCallback != null){ + mAutopilotPlanningCallback.routeResult( + BPCoordinateCalculateRouteUtil.coordinateConverterWgsToGcjListCommon(mContext + , routePoints)); + } + + //转换成高德坐标系 + mRoutePoints.clear(); + mRoutePoints.addAll(BPCoordinateCalculateRouteUtil.coordinateConverterWgsToGcjListCommon(mContext,routePoints)); + //开启实时计算剩余距离,剩余时间,预计时间 + startOrStopCalculateRouteInfo(true); + } + + /** + * 开始轮询计算剩余里程和时间 + * @param isStart + */ + public void startOrStopCalculateRouteInfo(boolean isStart) { + CallerLogger.INSTANCE.d(M_BUS_P + TAG, "startOrStopOrderLoop() " + isStart); + if (isStart) { + BusPassengerModelLoopManager.getInstance().startCalculateRouteInfoLoop(); + } else { + mRoutePoints.clear(); + BusPassengerModelLoopManager.getInstance().stopCalculateRouteInfLoop(); + } + } + + private void startOrStopOrderLoop(boolean start) { + CallerLogger.INSTANCE.d(M_BUS_P + TAG, "startOrStopOrderLoop() " + start); + if (start) { + BusPassengerModelLoopManager.getInstance().startQueryDriverLineLoop(); + } else { + BusPassengerModelLoopManager.getInstance().stopQueryDriverLineLoop(); + } + } + } diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/network/BusPassengerModelLoopManager.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/network/BusPassengerModelLoopManager.java new file mode 100644 index 0000000000..200c25be0a --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/network/BusPassengerModelLoopManager.java @@ -0,0 +1,79 @@ +package com.mogo.och.bus.passenger.network; + +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; +import com.mogo.och.bus.passenger.model.BusPassengerModel; + +import java.util.concurrent.TimeUnit; + +import io.reactivex.Observable; +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.disposables.Disposable; +import io.reactivex.schedulers.Schedulers; + +import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS_P; +import static com.mogo.och.bus.passenger.constant.BusPassengerConst.LOOP_DELAY; +import static com.mogo.och.bus.passenger.constant.BusPassengerConst.LOOP_LINE_2S; + +/** + * Created on 2021/11/22 + * + * 管理轮询逻辑(订单轮询、新单轮询、新单抢单结果轮询等等) + */ +public class BusPassengerModelLoopManager { + + private static final String TAG = BusPassengerModelLoopManager.class.getSimpleName(); + + private Disposable mCalculateRouteDisposable; //每隔2s计算一次剩余里程和时间 + + private static final class SingletonHolder { + private static final BusPassengerModelLoopManager INSTANCE = new BusPassengerModelLoopManager(); + } + + public static BusPassengerModelLoopManager getInstance() { + return SingletonHolder.INSTANCE; + } + + private Disposable mHeartbeatDisposable; //心跳轮询 + + public void startQueryDriverLineLoop() { + if (mHeartbeatDisposable != null && !mHeartbeatDisposable.isDisposed()) { + return; + } + CallerLogger.INSTANCE.i(M_BUS_P + TAG, "startQueryDriverLineLoop()"); + mHeartbeatDisposable = Observable.interval(LOOP_DELAY, + LOOP_LINE_2S, TimeUnit.MILLISECONDS) + .map((aLong -> aLong + 1)) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(aLong -> BusPassengerModel.getInstance().queryDriverSiteByCoordinate()); + } + + public void stopQueryDriverLineLoop() { + if (mHeartbeatDisposable != null) { + CallerLogger.INSTANCE.i(M_BUS_P + TAG, "stopQueryDriverLineLoop()"); + mHeartbeatDisposable.dispose(); + mHeartbeatDisposable = null; + } + } + + public void startCalculateRouteInfoLoop() { + if (mCalculateRouteDisposable != null && !mCalculateRouteDisposable.isDisposed()) { + return; + } + CallerLogger.INSTANCE.i(M_BUS_P + TAG, "startCalculateRouteInfoLoop()"); + mCalculateRouteDisposable = Observable.interval(LOOP_DELAY, + LOOP_LINE_2S, TimeUnit.MILLISECONDS) + .map((aLong -> aLong + 1)) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(aLong -> BusPassengerModel.getInstance().dynamicCalculateRouteInfo()); + } + + public void stopCalculateRouteInfLoop() { + if (mCalculateRouteDisposable != null) { + CallerLogger.INSTANCE.i(M_BUS_P + TAG, "stopCalculateRouteInfLoop()"); + mCalculateRouteDisposable.dispose(); + mCalculateRouteDisposable = null; + } + } +} diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/network/BusPassengerServiceApi.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/network/BusPassengerServiceApi.java index 8ccb8dbc0d..c9ddbd8b26 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/network/BusPassengerServiceApi.java +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/network/BusPassengerServiceApi.java @@ -1,9 +1,38 @@ package com.mogo.och.bus.passenger.network; +import com.mogo.och.bus.passenger.bean.BusPassengerOperationStatusResponse; +import com.mogo.och.bus.passenger.bean.BusPassengerQueryLineRequest; +import com.mogo.och.bus.passenger.bean.BusPassengerRoutesResponse; + +import io.reactivex.Observable; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.POST; +import retrofit2.http.Query; + /** * Created on 2022/3/31 * * Bus乘客端接口定义 */ interface BusPassengerServiceApi { + /** + * 查询bus司机端绑定路线 + * @return 接口返回数据 + */ + @Headers( {"Content-Type:application/json;charset=UTF-8"} ) + @POST( "/autopilot-car-hailing/line/v2/driver/bus/passenger/lineDataWithDriver/query" ) + Observable queryDriverSiteByCoordinate(@Header("appId") String appId, @Header("ticket") String ticket, @Body BusPassengerQueryLineRequest request); + + /** + * 查询司机端出车/收车状态 + * @param sn + * @return + */ + @Headers({"Content-type:application/json;charset=UTF-8"}) + @GET("/autopilot-car-hailing/car/v2/driver/bus/passenger/takeOrderStatus/query") + Observable queryDriverOperationStatus(@Header ("appId") String appId, @Header("ticket") String ticket, @Query("sn") String sn); + } diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/network/BusPassengerServiceManager.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/network/BusPassengerServiceManager.java index 459cbeb2d7..b155cb084c 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/network/BusPassengerServiceManager.java +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/network/BusPassengerServiceManager.java @@ -2,14 +2,21 @@ package com.mogo.och.bus.passenger.network; import android.content.Context; +import com.mogo.cloud.passport.MoGoAiCloudClientConfig; import com.mogo.eagle.core.data.BaseData; import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager; import com.mogo.eagle.core.network.MoGoRetrofitFactory; import com.mogo.eagle.core.network.RequestOptions; import com.mogo.eagle.core.network.SubscribeImpl; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; +import com.mogo.och.bus.passenger.bean.BusPassengerOperationStatusResponse; +import com.mogo.och.bus.passenger.bean.BusPassengerQueryLineRequest; +import com.mogo.och.bus.passenger.bean.BusPassengerRoutesResponse; import com.mogo.och.bus.passenger.constant.BusPassengerConst; +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.schedulers.Schedulers; + import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS_P; /** @@ -41,9 +48,39 @@ public class BusPassengerServiceManager { */ private String getDriverAppSn(){ return CallerTelematicManager.INSTANCE.getServerToken(); -// return "X2020210525EFA93B5946FA38D4"; +// return "X2020211111NG0XNFK"; } + /** + * 查询绑定行驶的小巴车路线 + * @param context + * @param callback + */ + public void queryDriverSiteByCoordinate(Context context + ,BusPassengerServiceCallback callback){ + mBusPassengerServiceApi.queryDriverSiteByCoordinate(MoGoAiCloudClientConfig.getInstance().getServiceAppId() + ,MoGoAiCloudClientConfig.getInstance().getToken() + ,new BusPassengerQueryLineRequest(getDriverAppSn())) + .subscribeOn( Schedulers.io() ) + .observeOn( AndroidSchedulers.mainThread() ) + .subscribe(getSubscribeImpl(context,callback,"queryDriverSiteByCoordinate")); + } + + /** + * 查询司机端出车收车状态,以及车牌号 + * @param context + * @param callback + */ + public void queryDriverOperationStatus(Context context, BusPassengerServiceCallback callback){ + mBusPassengerServiceApi.queryDriverOperationStatus(MoGoAiCloudClientConfig.getInstance().getServiceAppId() + ,MoGoAiCloudClientConfig.getInstance().getToken() + ,getDriverAppSn()) + .subscribeOn( Schedulers.io() ) + .observeOn( AndroidSchedulers.mainThread() ) + .subscribe(getSubscribeImpl(context,callback,"queryDriverOperationStatus")); + } + + private SubscribeImpl getSubscribeImpl( Context context, BusPassengerServiceCallback callback, String apiName) { return new SubscribeImpl(RequestOptions.create(context)) { diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/presenter/BaseBusPassengerPresenter.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/presenter/BaseBusPassengerPresenter.java index e23b3e8f1f..ca76a2a70c 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/presenter/BaseBusPassengerPresenter.java +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/presenter/BaseBusPassengerPresenter.java @@ -6,25 +6,33 @@ import android.os.Looper; import androidx.annotation.NonNull; import androidx.lifecycle.LifecycleOwner; +import com.amap.api.maps.model.LatLng; import com.mogo.commons.AbsMogoApplication; import com.mogo.commons.mvp.Presenter; +import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; import com.mogo.eagle.core.utilcode.util.UiThreadHandler; +import com.mogo.och.bus.passenger.bean.BusPassengerStation; +import com.mogo.och.bus.passenger.callback.IBusPassegerDriverStatusCallback; import com.mogo.och.bus.passenger.callback.IBusPassengerADASStatusCallback; +import com.mogo.och.bus.passenger.callback.IBusPassengerAutopilotPlanningCallback; import com.mogo.och.bus.passenger.callback.IBusPassengerControllerStatusCallback; +import com.mogo.och.bus.passenger.callback.IBusPassengerRouteLineInfoCallback; import com.mogo.och.bus.passenger.model.BusPassengerModel; -import com.mogo.och.bus.passenger.ui.BusPassengerBaseFragment; +import com.mogo.och.bus.passenger.ui.BusPassengerRouteFragment; + +import java.util.List; import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS_P; /** * Created on 2022/3/31 */ -public class BaseBusPassengerPresenter extends Presenter implements - IBusPassengerADASStatusCallback, IBusPassengerControllerStatusCallback { +public class BaseBusPassengerPresenter extends Presenter implements + IBusPassengerADASStatusCallback, IBusPassengerControllerStatusCallback, IBusPassegerDriverStatusCallback, IBusPassengerRouteLineInfoCallback, IBusPassengerAutopilotPlanningCallback { private static final String TAG = BaseBusPassengerPresenter.class.getSimpleName(); - public BaseBusPassengerPresenter(BusPassengerBaseFragment view) { + public BaseBusPassengerPresenter(BusPassengerRouteFragment view) { super(view); BusPassengerModel.getInstance().init(AbsMogoApplication.getApp()); initListeners(); @@ -47,11 +55,17 @@ public class BaseBusPassengerPresenter extends Presenter mView.onAutopilotStatusChanged( + IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE)); } @Override public void onAutopilotDisable() { - + runOnUIThread(() -> mView.onAutopilotStatusChanged( + IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE)); } @Override public void onAutopilotRunning() { - + runOnUIThread(() -> mView.onAutopilotStatusChanged( + IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING)); } @Override @@ -93,6 +110,33 @@ public class BaseBusPassengerPresenter extends Presenter mView.onCarLocationChanged(location)); + } + } + @Override + public void changeOperationStatus(boolean changeStatus) { + runOnUIThread(() -> mView.changeOperationStatus(changeStatus)); + } + + @Override + public void updateLineInfo(String lineName, String lineDurTime) { + runOnUIThread(() -> mView.updateLineInfo(lineName, lineDurTime)); + } + + @Override + public void updateStationsInfo(List stations,int currentStationIndex,boolean isArrived) { + runOnUIThread(() -> mView.updateStationsInfo(stations,currentStationIndex, isArrived)); + } + + @Override + public void routeResult(List models) { + runOnUIThread(() -> mView.routeResult(models)); + } + + @Override + public void routePlanningToNextStationChanged(long meters, long timeInSecond) { + runOnUIThread(() -> mView.updateRoutePlanningToNextStation(meters, timeInSecond)); } } diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusBorderShadowLayout.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusBorderShadowLayout.java new file mode 100644 index 0000000000..6bde93ce05 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusBorderShadowLayout.java @@ -0,0 +1,359 @@ +package com.mogo.och.bus.passenger.ui; + +import android.content.Context; +import android.content.res.Resources; +import android.content.res.TypedArray; +import android.graphics.BlurMaskFilter; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.graphics.RectF; +import android.util.AttributeSet; +import android.util.TypedValue; +import android.widget.LinearLayout; + +import com.mogo.och.bus.passenger.R; +import com.mogo.och.bus.passenger.utils.DimenUtil; + +/** + * @author: wangmingjun + * @date: 2022/1/21 + * 边框阴影 + */ +public class BusBorderShadowLayout extends LinearLayout { + + + private static final String TAG = "ShadowLayout"; + + //默认阴影半径 + public static final float SHADOW_DEFAULT_RADIUS = DimenUtil.INSTANCE.dp2px(5); + + //阴影最大偏移量 + public static final float SHADOW_MAX_OFFSET = DimenUtil.INSTANCE.dp2px(20); + + //阴影最大模糊半径 + public static final float SHADOW_MAX_BLUR = DimenUtil.INSTANCE.dp2px(20); + + + + //默认模糊半径 + public static final float SHADOW_DEFAULT_BLUR_RADIUS = DimenUtil.INSTANCE.dp2px(5); + + + //阴影颜色 + private int shadowColor = Color.parseColor("#333333"); + + //阴影类型,0:默认为单边 1:单边 2:邻边 3:四边所有 + private int shadowType; + + //阴影半径 + private float shadowRadius = 0f; + + //模糊度半径 + private float blurRadius = SHADOW_DEFAULT_BLUR_RADIUS ; + + //水平位移 + private float xOffset = DimenUtil.INSTANCE.dp2px(10); + + + //竖直方向位移 + private float yOffset = DimenUtil.INSTANCE.dp2px(0); + + //背景色 + private int bgColor = Color.WHITE; + + //是否有点击效果 + private boolean hasEffect = false ; + + + int left =0 ,right =0,top = 0,bottom = 0 ; + + //代理方式 + private IShadow shadow = new BusBorderShadowLayout.ShadowConfig(this); + + private float mWidthMode; + private float mHeightMode; + private Paint mPaint = new Paint(); + private Paint locationPaint = new Paint(); + + public BusBorderShadowLayout(Context context) { + super(context,null); + } + + public BusBorderShadowLayout(Context context, AttributeSet attrs) { + this(context, attrs,0); + } + + public BusBorderShadowLayout(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + this.setLayerType(LAYER_TYPE_SOFTWARE, null);//取消硬件加速 + TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ShadowLayout); + shadowColor = typedArray.getColor(R.styleable.ShadowLayout_shadowColor, Color.BLUE); + blurRadius = typedArray.getDimension(R.styleable.ShadowLayout_blurRadius, SHADOW_DEFAULT_BLUR_RADIUS); + shadowRadius = typedArray.getDimension(R.styleable.ShadowLayout_shadowRadius,0); + hasEffect = typedArray.getBoolean(R.styleable.ShadowLayout_hasEffect, false); + xOffset = typedArray.getDimension(R.styleable.ShadowLayout_xOffset,DimenUtil.INSTANCE.dp2px(10)); + yOffset = typedArray.getDimension(R.styleable.ShadowLayout_yOffset,DimenUtil.INSTANCE.dp2px(10)); + bgColor = typedArray.getColor(R.styleable.ShadowLayout_bgColor,Color.WHITE); + typedArray.recycle(); + + if (shadowRadius<0){ + shadowRadius = -shadowRadius; + } + if (blurRadius < 0) { + blurRadius = -blurRadius; + } + + blurRadius = Math.min(SHADOW_MAX_BLUR,blurRadius); + + if (Math.abs(xOffset)> SHADOW_MAX_OFFSET){ + xOffset = xOffset/Math.abs(xOffset) * SHADOW_MAX_OFFSET; + } + + if (Math.abs(yOffset) > SHADOW_MAX_OFFSET){ + yOffset = yOffset/Math.abs(yOffset) * SHADOW_MAX_OFFSET; + } + + init(); + } + + private void init(){ + setBackgroundColor(Color.parseColor("#00ffffff")); + if (xOffset>0){ + //水平偏移量为正数,右侧有阴影,阴影长度为blurRadius+|xOffset| + right = (int)(blurRadius + Math.abs(xOffset)); + }else if (xOffset==0){ + //水平偏移为0,水平间距为blurRadius + left = (int)blurRadius; + right = (int)blurRadius; + }else { + //水平偏移为负数,左侧有阴影,阴影长度为blurRadius+|xOffset| + left = (int)(blurRadius + Math.abs(xOffset)); + } + if (yOffset>0){ + //竖直偏移量为正数,底部有阴影,阴影长度为blurRadius+|yOffset| + bottom = (int)(blurRadius + Math.abs(yOffset)); + }else if (yOffset==0){ + //竖直偏移量为0,竖直间距为blurRadius + top = (int)blurRadius; + bottom = (int)blurRadius; + }else { + //竖直偏移量为负数,顶部有阴影,阴影长度为blurRadius+|yOffset| + top = (int)(blurRadius + Math.abs(yOffset)); + } + setPadding(left,top,right,bottom); + } + + + + + + /** + * 获取阴影设置 + * @return 返回阴影设置配置 + */ + public IShadow getShadowConfig(){ + return shadow; + } + + + @Override + protected void onLayout(boolean changed, int l, int t, int r, int b) { + super.onLayout(changed,l,t,r,b); + } + + + @Override + protected void dispatchDraw(Canvas canvas) { + super.dispatchDraw(canvas); + } + + + + @Override + protected void onDraw(Canvas canvas) { + drawBackground(canvas);//放在super前是后景,相反是前景,前景会覆盖子布局 + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + } + + + + + //绘制背景色(在子view底部) + private void drawBackground(Canvas canvas){ + + mWidthMode = getMeasuredWidth(); + mHeightMode = getMeasuredHeight(); + float startX = 0; + float startY = 0; + float endX = 0; + float endY = 0; + + if (xOffset==0){ + startX = right; + endX = mWidthMode-blurRadius; + }else { + startX = right+blurRadius; + endX = mWidthMode-left-blurRadius; + } + + if (yOffset==0){ + startY = bottom; + endY = mHeightMode-blurRadius; + }else { + startY = bottom+blurRadius; + endY = mHeightMode-top-blurRadius; + } +// mPaint.setShadowLayer(blurRadius,0,0,shadowColor); + if (blurRadius>0){ + mPaint.setMaskFilter(new BlurMaskFilter(blurRadius,BlurMaskFilter.Blur.NORMAL)); + } + mPaint.setColor(shadowColor); + mPaint.setAntiAlias(true); + + RectF shadowRect = new RectF(startX,startY,endX,endY); + + RectF locationRectF = new RectF(left,top,mWidthMode-right,mHeightMode-bottom); + if (shadowRadius==0){ + //不是圆角 + canvas.drawRect(shadowRect,mPaint); + }else { + //圆角,角度为shadowRadius + canvas.drawRoundRect(shadowRect,shadowRadius,shadowRadius,mPaint); + } + + locationPaint.setColor(bgColor); + locationPaint.setAntiAlias(true); + + if (shadowRadius==0){ + //不是圆角 + canvas.drawRect(locationRectF,locationPaint); + }else { + //圆角,角度为shadowRadius + canvas.drawRoundRect(locationRectF,shadowRadius,shadowRadius,locationPaint); + } + } + + + + /** + * 阴影配置 + */ + class ShadowConfig implements IShadow { + + //代理 + private BusBorderShadowLayout shadow; + + private ShadowConfig(BusBorderShadowLayout shadow) { + this.shadow = shadow; + } + + @Override + public IShadow setShadowRadius(float radius) { + return setShadowRadius(TypedValue.COMPLEX_UNIT_DIP,radius); + } + + @Override + public IShadow setShadowRadius(int unit, float radius) { + Context c = getContext(); + Resources r; + + if (c == null) { + r = Resources.getSystem(); + } else { + r = c.getResources(); + } + shadow.shadowRadius = Math.abs(TypedValue.applyDimension(unit,radius,r.getDisplayMetrics())); + return this; + } + + @Override + public IShadow setShadowColor(int color) { + shadow.shadowColor = color; + return this; + } + + @Override + public IShadow setShadowColorRes(int colorRes) { + shadow.shadowColor = shadow.getResources().getColor(colorRes); + return this; + } + + @Override + public IShadow setBlurRadius(float radius) { + return setBlurRadius(TypedValue.COMPLEX_UNIT_DIP,radius); + } + + @Override + public IShadow setBlurRadius(int unit, float radius) { + Context c = getContext(); + Resources r; + if (c == null) { + r = Resources.getSystem(); + } else { + r = c.getResources(); + } + shadow.blurRadius = Math.min(SHADOW_MAX_BLUR,Math.abs(TypedValue.applyDimension(unit,radius,r.getDisplayMetrics()))); + return this; + } + + @Override + public IShadow setXOffset(float offset) { + return setXOffset(TypedValue.COMPLEX_UNIT_DIP,offset); + } + + @Override + public IShadow setXOffset(int unit, float offset) { + Context c = getContext(); + Resources r; + if (c == null) { + r = Resources.getSystem(); + } else { + r = c.getResources(); + } + + float x = TypedValue.applyDimension(unit,offset,r.getDisplayMetrics()); + if (Math.abs(x)> SHADOW_MAX_OFFSET){ + x = x/Math.abs(x) * SHADOW_MAX_OFFSET; + } + shadow.xOffset = x; + return this; + } + + @Override + public IShadow setYOffset(float offset) { + return setYOffset(TypedValue.COMPLEX_UNIT_DIP,offset); + } + + @Override + public IShadow setYOffset(int unit, float offset) { + Context c = getContext(); + Resources r; + if (c == null) { + r = Resources.getSystem(); + } else { + r = c.getResources(); + } + + float y = TypedValue.applyDimension(unit,offset,r.getDisplayMetrics()); + if (Math.abs(y)> SHADOW_MAX_OFFSET){ + y = y/Math.abs(y) * SHADOW_MAX_OFFSET; + } + shadow.yOffset = y; + return this; + } + + @Override + public void commit() { + shadow.init(); + shadow.requestLayout(); + shadow.postInvalidate(); + } + } + + +} diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerBaseFragment.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerBaseFragment.java index be21df01b4..870974f144 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerBaseFragment.java +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerBaseFragment.java @@ -1,32 +1,42 @@ package com.mogo.och.bus.passenger.ui; -import android.os.Handler; -import android.os.Looper; - -import androidx.annotation.NonNull; +import android.os.Bundle; +import android.text.Html; +import android.view.LayoutInflater; +import android.widget.FrameLayout; +import android.widget.ImageView; +import android.widget.TextView; +import com.mogo.commons.mvp.IView; import com.mogo.commons.mvp.MvpFragment; -import com.mogo.och.bus.passenger.R; -import com.mogo.och.bus.passenger.presenter.BaseBusPassengerPresenter; -import org.jetbrains.annotations.NotNull; +import com.mogo.commons.mvp.Presenter; +import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener; +import com.mogo.eagle.core.function.call.map.CallerSmpManager; +import com.mogo.och.bus.passenger.R; +import com.mogo.och.bus.passenger.utils.BPDateTimeUtil; /** * Created on 2022/3/31 - * + *

* Bus乘客端基础Fragment */ -public class BusPassengerBaseFragment extends MvpFragment { +public abstract class BusPassengerBaseFragment> extends MvpFragment { private static final String TAG = BusPassengerBaseFragment.class.getSimpleName(); - private Handler mHandler = new Handler(Looper.getMainLooper()); + private TextView mCurrentArriveStation; + private TextView mCurrentArriveStationTitle; + private TextView mCurrentArriveTip; + private ImageView mAutopilotIv; + private FrameLayout flContainer; - @NonNull - @NotNull - @Override - protected BaseBusPassengerPresenter createPresenter() { - return new BaseBusPassengerPresenter(this); - } + + /** + * 改变自动驾驶状态 + * + * @param status 2 - running 1 - enable 2 - disable + */ + private int mPrevAPStatus = -1; @Override protected int getLayoutId() { @@ -38,9 +48,95 @@ public class BusPassengerBaseFragment extends MvpFragment 0){ + if (meters / 1000 < 1){ + disUnit = "米"; + dis = String.valueOf(Math.round(meters)); + }else { + disUnit = "公里"; + dis = BPDateTimeUtil.formatLong((double)meters / 1000); + } + } + String strHtml2 = "距离 " + "" + dis + "" + " "+disUnit+"" + + ""+" "+"剩余 " + "" + (int)Math.ceil((double)timeInSecond/ 60f) + "" + " 分钟"; + mCurrentArriveTip.setText(Html.fromHtml(strHtml2)); + } + + public void onAutopilotStatusChanged(int status) { + getActivity().runOnUiThread(() -> { + // 3. 其他过程直接更新 + if (mPrevAPStatus != status){ + AutopilotStatusChanged(status); + } + mPrevAPStatus = status; + }); + } + + public void AutopilotStatusChanged(int status) { + if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING == status) { + mAutopilotIv.setImageResource(R.drawable.bus_p_auto_nor); + } else if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE == status){ + mAutopilotIv.setImageResource(R.drawable.bus_p_un_auto_nor); + } else { + mAutopilotIv.setImageResource(R.drawable.bus_p_un_auto_nor); + } + + } } diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerMapDirectionView.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerMapDirectionView.java new file mode 100644 index 0000000000..7ca457caee --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerMapDirectionView.java @@ -0,0 +1,357 @@ +package com.mogo.och.bus.passenger.ui; + +import android.content.Context; +import android.graphics.Color; +import android.os.Bundle; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.widget.RelativeLayout; + +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.CoordinateConverter; +import com.amap.api.maps.TextureMapView; +import com.amap.api.maps.UiSettings; +import com.amap.api.maps.model.BitmapDescriptorFactory; +import com.amap.api.maps.model.CameraPosition; +import com.amap.api.maps.model.CustomMapStyleOptions; +import com.amap.api.maps.model.LatLng; +import com.amap.api.maps.model.LatLngBounds; +import com.amap.api.maps.model.Marker; +import com.amap.api.maps.model.MarkerOptions; +import com.amap.api.maps.model.Polyline; +import com.amap.api.maps.model.PolylineOptions; +import com.mogo.eagle.core.data.map.MogoLatLng; +import com.mogo.eagle.core.data.map.MogoLocation; +import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener; +import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager; +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; +import com.mogo.och.bus.passenger.R; +import com.mogo.och.bus.passenger.callback.IBusPassengerMapViewCallback; +import com.mogo.och.bus.passenger.utils.BusPassengerMapAssetStyleUtil; + +import java.util.ArrayList; +import java.util.List; + +import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS_P; + +/** + * 乘客屏小地图 + */ +public class BusPassengerMapDirectionView + extends RelativeLayout + implements IMoGoMapLocationListener, IBusPassengerMapDirectionView, AMap.OnCameraChangeListener { + + //小地图名称 + public static final String TAG = "TPMapDirectionView"; + + private TextureMapView mAMapNaviView; + private AMap mAMap; + private Marker mCarMarker; + private Marker mStartMarker; + private Marker mEndMarker; + + private int zoomLevel = 13; + private List mCoordinatesLatLng = new ArrayList<>(); + private List mWayPointsLatLng = new ArrayList<>(); + private Polyline mPolyline; + private CameraUpdate mCameraUpdate; + private Context mContext; + + private List colorList = new ArrayList<>(); + + private IBusPassengerMapViewCallback mIBusPassengerMapViewCallback; + + public BusPassengerMapDirectionView(Context context) { + this(context, null); + } + + public BusPassengerMapDirectionView(Context context, @Nullable AttributeSet attrs) { + this(context, attrs, 0); + } + + public BusPassengerMapDirectionView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + try { + initView(context); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void setTaxiPassengerMapViewCallback(IBusPassengerMapViewCallback iBusPassengerMapViewCallback){ + this.mIBusPassengerMapViewCallback = iBusPassengerMapViewCallback; + } + + private void initView(Context context) { + CallerLogger.INSTANCE.d(M_BUS_P + TAG, "initView"); + + mContext = context; + + View smpView = LayoutInflater.from(context).inflate(R.layout.bus_p_map_view, this); + + mAMapNaviView = (TextureMapView) smpView.findViewById(R.id.bus_p_line_amap_view); + + initAMapView(); + + // 注册定位监听 + CallerMapLocationListenerManager.INSTANCE.addListener(TAG, this); + } + + @Override + protected void onDetachedFromWindow() { + super.onDetachedFromWindow(); + // 注册定位监听 + CallerMapLocationListenerManager.INSTANCE.removeListener(TAG); + } + + private void initAMapView() { + mCameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel); + mAMap = mAMapNaviView.getMap(); + // 设置导航地图模式,aMap是地图控制器对象。 + mAMap.setMapType(AMap.MAP_TYPE_NIGHT); + + // 关闭显示实时路况图层,aMap是地图控制器对象。 + mAMap.setTrafficEnabled(false); + + // 设置 锚点 图标 + mCarMarker = mAMap.addMarker(new MarkerOptions() + .icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_car)) + .anchor(0.5f, 0.5f)); + mStartMarker = mAMap.addMarker(new MarkerOptions() + .icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_view_dir_start))); + mEndMarker = mAMap.addMarker(new MarkerOptions() + .icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_view_dir_end))); + + // 加载自定义样式 + CustomMapStyleOptions customMapStyleOptions = new CustomMapStyleOptions() + .setEnable(true) + .setStyleData(BusPassengerMapAssetStyleUtil.getAssetsStyle(getContext(),"map_style.data")) + .setStyleExtraData(BusPassengerMapAssetStyleUtil.getAssetsExtraStyle(getContext(),"map_style_extra.data")); + // 设置自定义样式 + mAMap.setCustomMapStyle(customMapStyleOptions); + + //设置希望展示的地图缩放级别 + mAMap.moveCamera(mCameraUpdate); + + // 设置地图的样式 + UiSettings uiSettings = mAMap.getUiSettings(); + uiSettings.setZoomControlsEnabled(false);// 地图缩放级别的交换按钮 + uiSettings.setAllGesturesEnabled(false);// 所有手势 + uiSettings.setMyLocationButtonEnabled(false); // 显示默认的定位按钮 + uiSettings.setLogoBottomMargin(-150); //设置Logo下边界距离屏幕底部的边距,设置为负值即可 + + mAMap.setOnMapLoadedListener(new AMap.OnMapLoadedListener() { + @Override + public void onMapLoaded() { + CallerLogger.INSTANCE.d(M_BUS_P + TAG, "smp---onMapLoaded"); + // 加载自定义样式 + CustomMapStyleOptions customMapStyleOptions = new CustomMapStyleOptions() + .setEnable(true) + .setStyleData(BusPassengerMapAssetStyleUtil.getAssetsStyle(getContext(),"map_style.data")) + .setStyleExtraData(BusPassengerMapAssetStyleUtil.getAssetsExtraStyle(getContext(),"map_style_extra.data")); + // 设置自定义样式 + mAMap.setCustomMapStyle(customMapStyleOptions); + mAMapNaviView.getMap().setPointToCenter(mAMapNaviView.getWidth() / 2, mAMapNaviView.getHeight() / 2); + } + }); + + //设置地图状态的监听接口 + mAMap.setOnCameraChangeListener(this); + } + + + @Override + public boolean onInterceptTouchEvent(MotionEvent ev) { + return true; + } + + + @Override + public void onLocationChanged(@Nullable MogoLocation location) { + CallerLogger.INSTANCE.d(M_BUS_P + TAG, "onCarLocationChanged2 :" + location.getLatitude()+":"+location.getLongitude()); + if (location == null){ + return; + } + LatLng currentLatLng = new LatLng(location.getLatitude(), location.getLongitude()); + + //更新车辆位置 + if (mCarMarker != null) { + CallerLogger.INSTANCE.d(M_BUS_P + TAG, "location.getBearing() = " + location.getBearing()); + mCarMarker.setRotateAngle(360 - location.getBearing()); + mCarMarker.setPosition(currentLatLng); + mCarMarker.setToTop(); + } + + if (mCoordinatesLatLng.size() > 1) { + //圈定地图显示范围 + LatLng endLatLng = mCoordinatesLatLng.get(mCoordinatesLatLng.size() - 1); + LatLng startLatLng = mCoordinatesLatLng.get(0); + //存放经纬度 + LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder(); + boundsBuilder.include(startLatLng); + boundsBuilder.include(endLatLng); + for (int i=0;i < mWayPointsLatLng.size();i++){ + boundsBuilder.include(mWayPointsLatLng.get(i)); + } + //第二个参数为四周留空宽度 + mAMap.animateCamera(CameraUpdateFactory.newLatLngBounds(boundsBuilder.build(), 100)); + + } else { + //设置希望展示的地图缩放级别 + CameraPosition cameraPosition = new CameraPosition.Builder() + .target(mCarMarker.getPosition()).tilt(0).bearing(location.getBearing()).zoom(zoomLevel).build(); + mAMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); + } + } + + @Override + public void drawablePolyline() { + clearPolyline(); + if (mAMap != null) { + + addRouteColorList(); + + if (mCoordinatesLatLng.size() > 2) { + // 设置开始结束Marker位置 + + LatLng startLatLng = mCoordinatesLatLng.get(0); + LatLng endLatLng = mCoordinatesLatLng.get(mCoordinatesLatLng.size() - 1); + + mStartMarker.setPosition(startLatLng); + mEndMarker.setPosition(endLatLng); + mStartMarker.setVisible(true); + mEndMarker.setVisible(true); + + //设置线段纹理 + PolylineOptions polylineOptions = new PolylineOptions(); + polylineOptions.addAll(mCoordinatesLatLng); + polylineOptions.colorValues(colorList); + polylineOptions.useGradient(true); + polylineOptions.width(10); //线段宽度 + polylineOptions.lineCapType(PolylineOptions.LineCapType.LineCapRound); + + // 绘制线 + mPolyline = mAMap.addPolyline(polylineOptions); + + } + + if (mWayPointsLatLng.size() > 0){ + for (int i =0 ;i< mWayPointsLatLng.size(); i++){ + Marker mWayPointMarker = mAMap.addMarker(new MarkerOptions() + .icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_view_dir_way_point))); + mWayPointMarker.setPosition(mWayPointsLatLng.get(i)); + mWayPointMarker.setVisible(true); + } + } + } + } + + /** + * 添加画线颜色值 + */ + private void addRouteColorList() { + for (int i = 0; i < mCoordinatesLatLng.size(); i++){ + colorList.add(Color.argb(255, 70, 147, 253));//路线颜色 + } + } + + + public LatLng CoordinateConverterFrom84(Context mContext, MogoLatLng mogoLatLng) { + CoordinateConverter mCoordinateConverter = new CoordinateConverter(mContext); + mCoordinateConverter.from(CoordinateConverter.CoordType.GPS); + mCoordinateConverter.coord(new LatLng(mogoLatLng.lat, mogoLatLng.lon)); + LatLng latLng = mCoordinateConverter.convert(); + return latLng; + } + + public List CoordinateConverterFrom84ForList(Context mContext, List mogoLatLngList) { + List list = new ArrayList<>(); + for (MogoLatLng m : mogoLatLngList) { + LatLng mogoLatLng = CoordinateConverterFrom84(mContext, m); + list.add(mogoLatLng); + } + return list; + } + + @Override + public void clearPolyline() { + if (mPolyline != null) { + mPolyline.remove(); + } + if (mStartMarker != null) { + mStartMarker.setVisible(false); + } + if (mEndMarker != null) { + mEndMarker.setVisible(false); + } + } + + public void resetPolyine() { + mCoordinatesLatLng.clear(); + if (mPolyline != null) { + mPolyline.remove(); + } + if (mStartMarker != null) { + mStartMarker.setVisible(false); + } + if (mEndMarker != null) { + mEndMarker.setVisible(false); + } + } + + public void onCreateView(Bundle savedInstanceState) { + if (mAMapNaviView != null) { + mAMapNaviView.onCreate(savedInstanceState); + } + } + + public void onResume() { + if (mAMapNaviView != null) { + mAMapNaviView.onResume(); + } + } + + public void onPause() { + if (mAMapNaviView != null) { + mAMapNaviView.onPause(); + } + } + + public void onDestroy() { + if (mAMapNaviView != null) { + mAMapNaviView.onDestroy(); + } + } + + public void convert(List coordinates) { + mCoordinatesLatLng.clear(); + List latLngs = CoordinateConverterFrom84ForList(mContext, coordinates); + mCoordinatesLatLng.addAll(latLngs); + } + + public void setCoordinatesLatLng(List latLngs){ + mCoordinatesLatLng.clear(); + mCoordinatesLatLng.addAll(latLngs); + } + + public void setWayPointMarker(List wayPointLatLngs){ + mWayPointsLatLng.clear(); + mCoordinatesLatLng.addAll(wayPointLatLngs); + } + + @Override + public void onCameraChange(CameraPosition cameraPosition) { + mIBusPassengerMapViewCallback.onCameraChange(cameraPosition.bearing); + } + + @Override + public void onCameraChangeFinish(CameraPosition cameraPosition) { + + } +} diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerRouteFragment.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerRouteFragment.java new file mode 100644 index 0000000000..52187371bc --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerRouteFragment.java @@ -0,0 +1,435 @@ +package com.mogo.och.bus.passenger.ui; + +import android.location.Location; +import android.os.Bundle; +import android.view.View; +import android.view.animation.Animation; +import android.view.animation.RotateAnimation; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.constraintlayout.widget.ConstraintLayout; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.amap.api.maps.model.LatLng; +import com.mogo.eagle.core.data.app.AppConfigInfo; +import com.mogo.eagle.core.function.call.hmi.CallerHmiManager; +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; +import com.mogo.eagle.core.utilcode.util.UiThreadHandler; +import com.mogo.och.bus.passenger.R; +import com.mogo.och.bus.passenger.adapter.BusPassengerLineStationsAdapter; +import com.mogo.och.bus.passenger.bean.BusPassengerStation; +import com.mogo.och.bus.passenger.callback.IBusPassengerMapViewCallback; +import com.mogo.och.bus.passenger.model.BusPassengerModel; +import com.mogo.och.bus.passenger.presenter.BaseBusPassengerPresenter; + +import org.jetbrains.annotations.NotNull; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; + +import mogo.telematics.pad.MessagePad; + +import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS_P; + +/** + * @author: wangmingjun + * @date: 2022/4/12 + */ +public class BusPassengerRouteFragment extends + BusPassengerBaseFragment implements IBusPassengerMapViewCallback { + + private final String TAG = "BusPassengerRouteFragment"; + + private BusPassengerTrafficLightView mTrafficLightView; + private List mStationsList = new ArrayList<>(); + private List mWayPointsList = new ArrayList<>(); + + private TextView mSpeedTv; + private ConstraintLayout mNoLineInfoView; + private TextView mCarPlateNum; + private TextView mLineName; + private TextView mOperationTime; + private ConstraintLayout mRouteInfoView; + private RecyclerView mStationsListRv; + private BusPassengerMapDirectionView mMapDirectionView; + private ImageView mMapArrowIcon; + private RotateAnimation rotateAnimation; + private float lastBearing = 0; + private BusPassengerLineStationsAdapter mAdapter; + @Override + public int getStationPanelViewId() { + return R.layout.bus_p_route_fragment; + } + + @NonNull + @Override + protected BaseBusPassengerPresenter createPresenter() { + return new BaseBusPassengerPresenter(this); + } + + @Override + protected void initViews() { + super.initViews(); + mTrafficLightView = findViewById(R.id.bus_p_traffic_light_view); + CallerHmiManager.INSTANCE.setProxyTrafficLightView(mTrafficLightView); + + mSpeedTv = findViewById(R.id.bus_p_speed_tv); + + mNoLineInfoView =findViewById(R.id.bus_p_no_order_data_view); + + mCarPlateNum = findViewById(R.id.bus_p_driver_num_plate_tv); + mLineName = findViewById(R.id.bus_p_line_name_tv); + mOperationTime = findViewById(R.id.line_operation_time_tv); + + mRouteInfoView = findViewById(R.id.bus_p_line_cl); + mStationsListRv = findViewById(R.id.bus_p_line_stations_rl); + LinearLayoutManager manager = new LinearLayoutManager(getContext()); + mStationsListRv.setLayoutManager(manager); + mAdapter = new BusPassengerLineStationsAdapter(getContext(), mStationsList); + mStationsListRv.setAdapter(mAdapter); + + mMapArrowIcon = findViewById(R.id.bus_p_arrow_nor); + + //测试 + mSpeedTv.setOnLongClickListener(new View.OnLongClickListener() { + @Override + public boolean onLongClick(View v) { + String listStr = "{\"models\":[{\n" + + "\t\t\"lat\": 40.19927810144466,\n" + + "\t\t\"lon\": 116.73527259387767\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19927836356079,\n" + + "\t\t\"lon\": 116.73513114732762\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19927759500293,\n" + + "\t\t\"lon\": 116.73497660879111\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.199264819842284,\n" + + "\t\t\"lon\": 116.73480063747202\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.1992510141554,\n" + + "\t\t\"lon\": 116.73463922037767\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.199245872804,\n" + + "\t\t\"lon\": 116.73445960685193\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19924673374912,\n" + + "\t\t\"lon\": 116.73427704009703\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19924747108264,\n" + + "\t\t\"lon\": 116.7340707102972\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19924828745573,\n" + + "\t\t\"lon\": 116.73385916927226\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19924941093133,\n" + + "\t\t\"lon\": 116.73364048294795\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19924939253381,\n" + + "\t\t\"lon\": 116.73340837408566\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19924949105934,\n" + + "\t\t\"lon\": 116.73317368725336\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19925040039033,\n" + + "\t\t\"lon\": 116.73296532811216\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.1992515355653,\n" + + "\t\t\"lon\": 116.73277787366743\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.1992512720328,\n" + + "\t\t\"lon\": 116.73263377253741\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.199205174954606,\n" + + "\t\t\"lon\": 116.73249773114644\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.1991015743076,\n" + + "\t\t\"lon\": 116.7324219601283\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.198971862686285,\n" + + "\t\t\"lon\": 116.73239393296355\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19883883071582,\n" + + "\t\t\"lon\": 116.73237676435652\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19870171355796,\n" + + "\t\t\"lon\": 116.73236052150362\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.1985491853193,\n" + + "\t\t\"lon\": 116.73234157857011\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.1983890047355,\n" + + "\t\t\"lon\": 116.73232167996464\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.1982209877466,\n" + + "\t\t\"lon\": 116.73230101645792\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.198037574138326,\n" + + "\t\t\"lon\": 116.73227735486083\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19787327856243,\n" + + "\t\t\"lon\": 116.73225676816314\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19771917207499,\n" + + "\t\t\"lon\": 116.73223814728027\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.197548305175935,\n" + + "\t\t\"lon\": 116.73221624705808\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19739568979691,\n" + + "\t\t\"lon\": 116.73219618210774\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19724703821575,\n" + + "\t\t\"lon\": 116.73217598293311\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.1970956560885,\n" + + "\t\t\"lon\": 116.73215773721505\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19697703483188,\n" + + "\t\t\"lon\": 116.73214337172284\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19687000725696,\n" + + "\t\t\"lon\": 116.73210037067965\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.196833449601726,\n" + + "\t\t\"lon\": 116.73196646708011\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19685833847804,\n" + + "\t\t\"lon\": 116.73181315361103\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.196889170203264,\n" + + "\t\t\"lon\": 116.73164355747393\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19692242860347,\n" + + "\t\t\"lon\": 116.7314555399657\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19696431701069,\n" + + "\t\t\"lon\": 116.7312261834129\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19700025925464,\n" + + "\t\t\"lon\": 116.73102774016093\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19703414798773,\n" + + "\t\t\"lon\": 116.73084270562073\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19707287604138,\n" + + "\t\t\"lon\": 116.73062835248406\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19710951629977,\n" + + "\t\t\"lon\": 116.73041744082339\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19714593807105,\n" + + "\t\t\"lon\": 116.73021414314803\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.197183297026285,\n" + + "\t\t\"lon\": 116.7300057066447\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.1972247359487,\n" + + "\t\t\"lon\": 116.7297751515664\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19726518822745,\n" + + "\t\t\"lon\": 116.72954958923812\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19730538240706,\n" + + "\t\t\"lon\": 116.72932440756041\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19734272112662,\n" + + "\t\t\"lon\": 116.72911631453036\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.197379191549075,\n" + + "\t\t\"lon\": 116.72890982812105\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.197417565369314,\n" + + "\t\t\"lon\": 116.72869447869044\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19746052080799,\n" + + "\t\t\"lon\": 116.72845641541247\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19750040582118,\n" + + "\t\t\"lon\": 116.72823569991117\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19753999704064,\n" + + "\t\t\"lon\": 116.72801998373052\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19757796882569,\n" + + "\t\t\"lon\": 116.72781280504363\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.197617062364586,\n" + + "\t\t\"lon\": 116.72759949431683\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19765391602761,\n" + + "\t\t\"lon\": 116.72739776789756\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19768973009218,\n" + + "\t\t\"lon\": 116.72719980764646\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.197726191028785,\n" + + "\t\t\"lon\": 116.72699719861669\n" + + "\t}, {\n" + + "\t\t\"lat\": 40.19776233489642,\n" + + "\t\t\"lon\": 116.72679516155276\n" + + "\t}]}\n"; + List list = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(listStr); + JSONArray jsonElements = jsonObject.getJSONArray("models"); + for (int i = 0; i < jsonElements.length(); i++){ + JSONObject s = jsonElements.getJSONObject(i); + MessagePad.Location.Builder routeModels = MessagePad.Location.newBuilder(); + routeModels.setLatitude(s.getDouble("lat")); + routeModels.setLongitude(s.getDouble("lon")); + list.add(routeModels.build()); + } + BusPassengerModel.getInstance().updateRoutePoints(list); + } catch (JSONException e) { + e.printStackTrace(); + } + return false; + } + }); + } + + @Override + protected void initViews(Bundle savedInstanceState) { + super.initViews(savedInstanceState); + mMapDirectionView = findViewById(R.id.bus_p_line_map_view); + mMapDirectionView.onCreateView(savedInstanceState); + mMapDirectionView.setTaxiPassengerMapViewCallback(this); + } + + @Override + public void onResume() { + super.onResume(); + if (mMapDirectionView != null) { + mMapDirectionView.onResume(); + } + } + + @Override + public void onPause() { + super.onPause(); + if (mMapDirectionView != null) { + mMapDirectionView.onPause(); + } + } + + @Override + public void onDestroy() { + super.onDestroy(); + if (mMapDirectionView != null) { + mMapDirectionView.onDestroy(); + } + } + + public void routeResult(List latLngList) { + CallerLogger.INSTANCE.d(M_BUS_P + TAG, "routeResult:" + latLngList.size()); + if (latLngList.size() > 0) { + drawablePolyline(latLngList); + } else { + clearPolyline(); + } + } + + /** + * 绘制 + * + * @param coordinates + */ + private void drawablePolyline(List coordinates) { + if (mMapDirectionView != null) { + mMapDirectionView.setWayPointMarker(mWayPointsList); + mMapDirectionView.setCoordinatesLatLng(coordinates); + UiThreadHandler.post(new Runnable() { + @Override + public void run() { + mMapDirectionView.drawablePolyline(); + } + }); + } + } + + private void clearPolyline() { + if (mMapDirectionView != null) { + UiThreadHandler.post(new Runnable() { + @Override + public void run() { + mMapDirectionView.clearPolyline(); + } + }); + } + } + + public void changeOperationStatus(boolean status) { + if (status) { + mNoLineInfoView.setVisibility(View.GONE); + mRouteInfoView.setVisibility(View.VISIBLE); + } else { + mNoLineInfoView.setVisibility(View.VISIBLE); + mRouteInfoView.setVisibility(View.GONE); + } + } + + public void updateLineInfo(String lineName, String lineDurTime) { + if (!mLineName.getText().toString().equals(lineName) + || !mOperationTime.getText().toString().equals(lineDurTime) + || !mCarPlateNum.getText().toString().equals(AppConfigInfo.INSTANCE.getPlateNumber())){ + mLineName.setText(lineName); + mOperationTime.setText(lineDurTime); + mCarPlateNum.setText(null == AppConfigInfo.INSTANCE.getPlateNumber() ? "-- --" : AppConfigInfo.INSTANCE.getPlateNumber()); + } + } + + public void updateStationsInfo(List stations, int currentStationIndex,boolean isArrived) { + updateArrivedStation(stations.get(currentStationIndex).getName(),currentStationIndex,isArrived); + mStationsList.clear(); + mStationsList.addAll(stations); + mAdapter.notifyDataSetChanged(); + if (stations.size() > 2){ + updateWayPointList(stations); + } + } + + private void updateWayPointList(List stations) { + mWayPointsList.clear(); + for (int i = 1; i< stations.size() -1; i++) {//去除路线的起点和终点, 只要中间途径站点 + LatLng latLng = new LatLng(stations.get(i).getLat(),stations.get(i).getLon());// lat,lon + mWayPointsList.add(latLng); + } + } + + @Override + public void onCameraChange(float bearing) { + startIvCompass(bearing); + } + + /** + * 设置指南针旋转 + * + * @param bearing + */ + private void startIvCompass(float bearing) { + bearing = 360 - bearing; + CallerLogger.INSTANCE.d(M_BUS_P + TAG, "startIvCompass: " + bearing); + rotateAnimation = new RotateAnimation(lastBearing, bearing, Animation.RELATIVE_TO_SELF + , 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); + rotateAnimation.setFillAfter(true); + + mMapArrowIcon.startAnimation(rotateAnimation); + lastBearing = bearing; + } + + public void onCarLocationChanged(Location location) { + updateSpeedView(location.getSpeed()); + } + + public void updateSpeedView(float speed){ + int speedKM = (int) (Math.abs(speed) * 3.6F); + mSpeedTv.setText(String.valueOf(speedKM)); + } +} diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerTrafficLightView.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerTrafficLightView.java new file mode 100644 index 0000000000..aea35cc715 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerTrafficLightView.java @@ -0,0 +1,166 @@ +package com.mogo.och.bus.passenger.ui; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.widget.ImageView; +import android.widget.TextView; + +import com.mogo.eagle.core.function.api.hmi.view.IViewTrafficLight; +import com.mogo.eagle.core.utilcode.util.UiThreadHandler; +import com.mogo.och.bus.passenger.R; + +import org.jetbrains.annotations.Nullable; + +/** + * bus乘客端:红绿灯view + * + * Created on 2022/3/14 + */ +public class BusPassengerTrafficLightView extends IViewTrafficLight { + + private ImageView mLightIconIV; + private TextView mLightTimeTV; + private int mCurrentLightId; + + public BusPassengerTrafficLightView(@Nullable Context context) { + this(context, null, 0); + } + + public BusPassengerTrafficLightView(@Nullable Context context, @Nullable AttributeSet attrs) { + this(context, attrs, 0); + } + + public BusPassengerTrafficLightView(@Nullable Context context, @Nullable AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + init(context); + } + + private void init(Context context) { + LayoutInflater.from(context).inflate(R.layout.bus_p_traffic_light_view, this, true); + mLightIconIV = findViewById(R.id.bus_p_traffic_light_iv); + mLightTimeTV = findViewById(R.id.bus_p_traffic_light_time_tv); + } + + /** + * 展示红绿灯预警 + * + * @param checkLightId 0-都是默认,1-红,2-黄,3-绿 + */ + @Override + public void showWarningTrafficLight(int checkLightId) { + super.showWarningTrafficLight(checkLightId); + mCurrentLightId = checkLightId; + updateTrafficLightIcon(checkLightId); + } + + /** + * 关闭红绿灯预警展示,并重制灯态 + */ + @Override + public void disableWarningTrafficLight() { + super.disableWarningTrafficLight(); + UiThreadHandler.post(() -> { + mCurrentLightId = 0; + BusPassengerTrafficLightView.this.setVisibility(GONE); + }); + } + + /** + * @param redNum 红灯倒计时 + * @param yellowNum 黄灯倒计时 + * @param greenNum 绿灯倒计时 + */ + @Override + public void changeCountdownTrafficLightNum(int redNum, int yellowNum, int greenNum) { + super.changeCountdownTrafficLightNum(redNum, yellowNum, greenNum); + switch (mCurrentLightId) { + case 1: + changeCountdownRed(redNum); + break; + case 2: + changeCountdownYellow(yellowNum); + break; + case 3: + changeCountdownGreen(greenNum); + break; + default: + UiThreadHandler.post(() -> { + mLightTimeTV.setText(""); + }); + break; + } + } + + @Override + public void changeCountdownRed(int redNum) { + super.changeCountdownRed(redNum); + UiThreadHandler.post(() -> { + if (redNum > 0) { +// mLightTimeTV.setVertrial(true); +// mLightTimeTV.setmColorList(new int[]{getResources().getColor(R.color.bus_p_traffic_light_red_color_up), +// getResources().getColor(R.color.bus_p_traffic_light_red_color_down)}); + mLightTimeTV.setText(String.valueOf(redNum)); + } else { + mLightTimeTV.setText(""); + } + }); + } + + @Override + public void changeCountdownGreen(int greenNum) { + super.changeCountdownGreen(greenNum); + UiThreadHandler.post(() -> { + if (greenNum > 0) { +// mLightTimeTV.setVertrial(true); +// mLightTimeTV.setmColorList(new int[]{getResources().getColor(R.color.bus_p_traffic_light_green_color_up), +// getResources().getColor(R.color.bus_p_traffic_light_green_color_down)}); + mLightTimeTV.setText(String.valueOf(greenNum)); + } else { + mLightTimeTV.setText(""); + } + }); + } + + @Override + public void changeCountdownYellow(int yellowNum) { + super.changeCountdownYellow(yellowNum); + UiThreadHandler.post(() -> { + if (yellowNum > 0) { +// mLightTimeTV.setVertrial(true); +// mLightTimeTV.setmColorList(new int[]{getResources().getColor(R.color.bus_p_traffic_light_yellow_color_up), +// getResources().getColor(R.color.bus_p_traffic_light_yellow_color_down)}); + mLightTimeTV.setText(String.valueOf(yellowNum)); + } else { + mLightTimeTV.setText(""); + } + }); + } + + /** + * 更新红绿灯icon + * + * @param lightId 0-都是默认,1-红,2-黄,3-绿 + */ + private void updateTrafficLightIcon(int lightId) { + UiThreadHandler.post(() -> { + switch (lightId) { + case 1: + mLightIconIV.setBackgroundResource(R.drawable.bus_p_light_red_nor); + BusPassengerTrafficLightView.this.setVisibility(VISIBLE); + break; + case 2: + mLightIconIV.setBackgroundResource(R.drawable.bus_p_light_yellow_nor); + BusPassengerTrafficLightView.this.setVisibility(VISIBLE); + break; + case 3: + mLightIconIV.setBackgroundResource(R.drawable.bus_p_light_green_nor); + BusPassengerTrafficLightView.this.setVisibility(VISIBLE); + break; + default: + BusPassengerTrafficLightView.this.setVisibility(GONE); + break; + } + }); + } +} diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/IBusPassengerMapDirectionView.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/IBusPassengerMapDirectionView.java new file mode 100644 index 0000000000..e3d42204d7 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/IBusPassengerMapDirectionView.java @@ -0,0 +1,18 @@ +package com.mogo.och.bus.passenger.ui; + +/** + * @author xiaoyuzhou + * @date 2021/6/24 11:33 上午 + */ +public interface IBusPassengerMapDirectionView { + + /** + * 绘制路径线 + */ + void drawablePolyline(); + + /** + * 清除路径线 + */ + void clearPolyline(); +} diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/IShadow.kt b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/IShadow.kt new file mode 100644 index 0000000000..ef5d8fd4eb --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/IShadow.kt @@ -0,0 +1,65 @@ +package com.mogo.och.bus.passenger.ui + +import androidx.annotation.ColorRes + +/** + * @author: wangmingjun + * @date: 2022/1/21 + */ +interface IShadow { + //设置阴影半径 + fun setShadowRadius(radius:Float):IShadow + + //添加单位设置 + fun setShadowRadius(unit:Int,radius: Float):IShadow + + //设置应用颜色 + fun setShadowColor(color:Int):IShadow + + //设置阴影颜色资源文件id + fun setShadowColorRes(@ColorRes color: Int):IShadow + /** + * 设置模糊半径 + * @param radius + */ + fun setBlurRadius(radius:Float):IShadow + + /** + * + * @param unit @{@link android.util.TypedValue#TYPE_DIMENSION} + * @param radius 模糊半径 + */ + fun setBlurRadius(unit:Int,radius:Float):IShadow + + /** + * 设置水平方向的偏移量 + * @param offset x轴偏移 + */ + fun setXOffset(offset:Float):IShadow + + + /** + * 设置x方向的偏移量,设置单位 + * @param unit @{@link android.util.TypedValue#TYPE_DIMENSION} + * @param offset x轴偏移 + */ + fun setXOffset(unit:Int,offset:Float):IShadow + + /** + * 设置竖直方向的偏移量 + * @param offset y轴偏移 + */ + fun setYOffset(offset:Float):IShadow + + /** + * 设置竖直方向的偏移量,带单位 + * @param unit @{@link android.util.TypedValue#TYPE_DIMENSION} + * @param offset y轴偏移 + */ + fun setYOffset(unit:Int,offset:Float):IShadow + + /** + * 更新绘制 + */ + fun commit(); +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/utils/BPCoordinateCalculateRouteUtil.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/utils/BPCoordinateCalculateRouteUtil.java new file mode 100644 index 0000000000..9ddb9522cf --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/utils/BPCoordinateCalculateRouteUtil.java @@ -0,0 +1,95 @@ +package com.mogo.och.bus.passenger.utils; + +import android.content.Context; + +import com.amap.api.maps.CoordinateConverter; +import com.amap.api.maps.model.LatLng; +import com.mogo.cloud.commons.utils.CoordinateUtils; +import com.mogo.eagle.core.utilcode.mogo.logger.Logger; + +import java.util.ArrayList; +import java.util.List; + +import mogo.telematics.pad.MessagePad; + +import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS_P; + +/** + * @author: wangmingjun + * @date: 2022/3/28 + */ +public class BPCoordinateCalculateRouteUtil { + + public static float calculateRouteSumLength(List points){ + if (null == points || points.size() == 0) return 0; + + float sumLength = 0; + + //计算全路径总距离 + for (int i = 0;i + 1< points.size();i++){ + double preLat = points.get(i).latitude; + double preLon = points.get(i).longitude; + double laLat = points.get(i+1).latitude; + double laLon = points.get(i+1).longitude; + + float length = CoordinateUtils.calculateLineDistance(laLon,laLat,preLon,preLat); + sumLength += length; + } + return sumLength; + } + + public static List coordinateConverterWgsToGcjListCommon(Context mContext, List models) { + //转成MogoLatLng集合 + List list = new ArrayList<>(); + for (MessagePad.Location m : models) { + LatLng mogoLatLng = coordinateConverterWgsToGcj(mContext, m); + list.add(mogoLatLng); + } + return list; + } + + public static LatLng coordinateConverterWgsToGcj(Context mContext, MessagePad.Location mogoLatLng) { + CoordinateConverter mCoordinateConverter = new CoordinateConverter(mContext); + mCoordinateConverter.from(CoordinateConverter.CoordType.GPS); + mCoordinateConverter.coord(new LatLng(mogoLatLng.getLatitude(), mogoLatLng.getLongitude())); + LatLng latLng = mCoordinateConverter.convert(); + return latLng; + } + + /** + * 简单粗暴 直接比较 todo 需要优化 + * @param mRoutePoints + * @param realLon + * @param realLat + * @return + */ + public static List getRemainPointListByCompare(List mRoutePoints,double realLon,double realLat) { + List latePoints = new ArrayList<>(); + int currentIndex = 0; //记录疑似点 + if (mRoutePoints.size() > 0){ + //基础点 + LatLng baseLatLng = mRoutePoints.get(0); + float baseDiffDis = CoordinateUtils.calculateLineDistance(realLon,realLat + ,baseLatLng.longitude,baseLatLng.latitude);// lon,lat, prelon, prelat + + for (int i= 1; i < mRoutePoints.size(); i++){ + LatLng latLng = mRoutePoints.get(i); + float diff = CoordinateUtils.calculateLineDistance(realLon,realLat + ,latLng.longitude,latLng.latitude); + if (baseDiffDis > diff){ +// Logger.d(M_TAXI + "calculateRouteSumLength", "点:"+i+"-------先记录点----- "); + baseDiffDis = diff; + currentIndex = i; + } + } + Logger.d(M_BUS_P + "calculateRouteSumLength", "点:"+currentIndex+"-------是最近的点------ "); + if (currentIndex == mRoutePoints.size()-1){ + latePoints.add(mRoutePoints.get(currentIndex)); + }else { + latePoints.addAll(mRoutePoints.subList(currentIndex,mRoutePoints.size()-1)); + } + return latePoints; + } + return latePoints; + } +} diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/utils/BPDateTimeUtil.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/utils/BPDateTimeUtil.java new file mode 100644 index 0000000000..2dc37cd2ed --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/utils/BPDateTimeUtil.java @@ -0,0 +1,109 @@ +package com.mogo.och.bus.passenger.utils; + +import com.mogo.eagle.core.utilcode.util.DateTimeUtils; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.text.SimpleDateFormat; +import java.util.Calendar; + +/** + * @author: wangmingjun + * @date: 2021/8/20 + */ +public class BPDateTimeUtil { + + public static final String TAXI_HH_mm = "HH:mm"; + public static final String TAXI_MM_dd = "MM-dd"; + public static final String TAXI_MM_dd_HH_mm = "MM-dd HH:mm"; + public static final String TAXI_yyyy_MM_dd = "yyyy-MM-dd"; + public static final String TAXI_yyyy_MM_dd_HH_mm = "yyyy-MM-dd HH:mm"; + + public static String formatCalendarToString(Calendar calendar, String format){ + if (calendar == null) return ""; + try { + SimpleDateFormat dateFormat = new SimpleDateFormat(format); + return dateFormat.format(calendar.getTime()); + }catch (Exception e){ + e.printStackTrace(); + } + return ""; + } + + public static boolean compareDateIsCurrentDay(Calendar targetCalendar){ + Calendar currentCale = DateTimeUtils.getCurrentDateTime(); + String currentDay = formatCalendarToString(currentCale, TAXI_yyyy_MM_dd); + if (currentDay.equals(formatCalendarToString(targetCalendar, TAXI_yyyy_MM_dd))){ + return true; + }else { + return false; + } + } + + public static Calendar formatLongToCalendar(long time){ + Calendar calendar = null; + try { + calendar = Calendar.getInstance(); + calendar.setTimeInMillis(time); + }catch (Exception e){ + e.printStackTrace(); + } + return calendar; + } + public static String formatLongToString(long time, String format){ + try { + SimpleDateFormat dateFormat = new SimpleDateFormat(format); + return dateFormat.format(time); + }catch (Exception e){ + e.printStackTrace(); + } + return ""; + } + public static String getYMDTime(long time){//格式为 2021.8.21 + try { + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(time); + int month = calendar.get(Calendar.MONTH) + 1; + return calendar.get(Calendar.YEAR)+"."+month+"."+ calendar.get(Calendar.DAY_OF_MONTH); + }catch (Exception e){ + e.printStackTrace(); + } + return ""; + } + + /** + * + * @param seconds 60 + * @return 1 时 + */ + public static String secondsToHourStr(long seconds){//秒数转成相应的 小时分钟数 + if (seconds >= 3600){ + int hours = (int)seconds/3600; + return String.valueOf(hours); + } + return ""; + } + /** + * + * @param seconds 60 + * @return 1 时 + */ + public static String secondsToMinuteStr(long seconds){//秒数转成相应的 小时分钟数 + int minute = (int)(seconds % 3600)/60; + return String.valueOf(minute); + } + + /** + * 有小数两位, 没有小数保留整数 + * @param d + * @return + */ + public static String formatLong(double d) { + BigDecimal bg = new BigDecimal(d).setScale(1, RoundingMode.HALF_UP); + double num = bg.doubleValue(); + if (Math.ceil(num) - num == 0) { + return String.valueOf((long) num); + } + return String.valueOf(num); + } +} diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/utils/BusPassengerMapAssetStyleUtil.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/utils/BusPassengerMapAssetStyleUtil.java new file mode 100644 index 0000000000..fb012b4143 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/utils/BusPassengerMapAssetStyleUtil.java @@ -0,0 +1,61 @@ +package com.mogo.och.bus.passenger.utils; + + +import android.content.Context; + +import java.io.IOException; +import java.io.InputStream; + +/** + * @author donghongyu + * @date 12/18/20 5:37 PM + */ +public class BusPassengerMapAssetStyleUtil { + + public static byte[] getAssetsStyle(Context context,String fileName) { + byte[] buffer1 = null; + InputStream is1 = null; + try { + is1 = context.getResources().getAssets().open(fileName); //eg. small_map_style.data + int lenght1 = is1.available(); + buffer1 = new byte[lenght1]; + is1.read(buffer1); + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + if (is1 != null) { + is1.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + return buffer1; + } + + + public static byte[] getAssetsExtraStyle(Context context, String fileName) { + byte[] buffer1 = null; + InputStream is1 = null; + try { + is1 = context.getResources().getAssets().open(fileName); //eg. small_map_style_extra.data + int lenght1 = is1.available(); + buffer1 = new byte[lenght1]; + is1.read(buffer1); + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + if (is1 != null) { + is1.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + return buffer1; + } + + +} diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/utils/DimenUtil.kt b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/utils/DimenUtil.kt new file mode 100644 index 0000000000..4ad4e9a2ba --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/utils/DimenUtil.kt @@ -0,0 +1,13 @@ +package com.mogo.och.bus.passenger.utils + +import android.content.res.Resources + +/** + * @author: wangmingjun + * @date: 2022/1/21 + */ +object DimenUtil{ + fun dp2px(value:Float):Float{ + return (0.5f + value * Resources.getSystem().displayMetrics.density) + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bg_bus_p_arrived_station.png b/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bg_bus_p_arrived_station.png new file mode 100644 index 0000000000..f47f628224 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bg_bus_p_arrived_station.png differ diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_arrow_nor.png b/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_arrow_nor.png new file mode 100644 index 0000000000..2964279c96 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_arrow_nor.png differ diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_auto_nor.png b/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_auto_nor.png new file mode 100644 index 0000000000..c9daea21c9 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_auto_nor.png differ diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_light_green_nor.png b/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_light_green_nor.png new file mode 100644 index 0000000000..76787134b6 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_light_green_nor.png differ diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_light_red_nor.png b/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_light_red_nor.png new file mode 100644 index 0000000000..4de4a75e1b Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_light_red_nor.png differ diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_light_yellow_nor.png b/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_light_yellow_nor.png new file mode 100644 index 0000000000..74dec29540 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_light_yellow_nor.png differ diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_map_car.png b/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_map_car.png new file mode 100644 index 0000000000..17beb894a6 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_map_car.png differ diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_map_view_dir_end.png b/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_map_view_dir_end.png new file mode 100644 index 0000000000..ff04c01f13 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_map_view_dir_end.png differ diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_map_view_dir_start.png b/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_map_view_dir_start.png new file mode 100644 index 0000000000..22d8f225c2 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_map_view_dir_start.png differ diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_map_view_dir_way_point.png b/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_map_view_dir_way_point.png new file mode 100644 index 0000000000..cb158ffb83 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_map_view_dir_way_point.png differ diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_mogo_nor.png b/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_mogo_nor.png new file mode 100644 index 0000000000..3f938990f6 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_mogo_nor.png differ diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_no_order_data.png b/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_no_order_data.png new file mode 100644 index 0000000000..0e61996d3f Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_no_order_data.png differ diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_un_auto_nor.png b/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_un_auto_nor.png new file mode 100644 index 0000000000..528cd4dc66 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_un_auto_nor.png differ diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bg_bus_p_arrived_station.png b/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bg_bus_p_arrived_station.png new file mode 100644 index 0000000000..f47f628224 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bg_bus_p_arrived_station.png differ diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_arrow_nor.png b/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_arrow_nor.png new file mode 100644 index 0000000000..2964279c96 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_arrow_nor.png differ diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_auto_nor.png b/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_auto_nor.png new file mode 100644 index 0000000000..c9daea21c9 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_auto_nor.png differ diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_light_green_nor.png b/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_light_green_nor.png new file mode 100644 index 0000000000..76787134b6 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_light_green_nor.png differ diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_light_red_nor.png b/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_light_red_nor.png new file mode 100644 index 0000000000..4de4a75e1b Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_light_red_nor.png differ diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_light_yellow_nor.png b/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_light_yellow_nor.png new file mode 100644 index 0000000000..74dec29540 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_light_yellow_nor.png differ diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_map_car.png b/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_map_car.png new file mode 100644 index 0000000000..17beb894a6 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_map_car.png differ diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_map_view_dir_end.png b/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_map_view_dir_end.png new file mode 100644 index 0000000000..ff04c01f13 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_map_view_dir_end.png differ diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_map_view_dir_start.png b/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_map_view_dir_start.png new file mode 100644 index 0000000000..22d8f225c2 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_map_view_dir_start.png differ diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_map_view_dir_way_point.png b/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_map_view_dir_way_point.png new file mode 100644 index 0000000000..cb158ffb83 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_map_view_dir_way_point.png differ diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_mogo_nor.png b/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_mogo_nor.png new file mode 100644 index 0000000000..3f938990f6 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_mogo_nor.png differ diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_no_order_data.png b/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_no_order_data.png new file mode 100644 index 0000000000..0e61996d3f Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_no_order_data.png differ diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_un_auto_nor.png b/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_un_auto_nor.png new file mode 100644 index 0000000000..528cd4dc66 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_un_auto_nor.png differ diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable/bg_bus_p_end_station_circle.xml b/OCH/mogo-och-bus-passenger/src/main/res/drawable/bg_bus_p_end_station_circle.xml new file mode 100644 index 0000000000..528233f84c --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/res/drawable/bg_bus_p_end_station_circle.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable/bg_bus_p_end_tag_bg.xml b/OCH/mogo-och-bus-passenger/src/main/res/drawable/bg_bus_p_end_tag_bg.xml new file mode 100644 index 0000000000..ca8ad81fe2 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/res/drawable/bg_bus_p_end_tag_bg.xml @@ -0,0 +1,14 @@ + + + + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable/bg_bus_p_start_station_circle.xml b/OCH/mogo-och-bus-passenger/src/main/res/drawable/bg_bus_p_start_station_circle.xml new file mode 100644 index 0000000000..97458b6d07 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/res/drawable/bg_bus_p_start_station_circle.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable/bg_bus_p_start_tag_bg.xml b/OCH/mogo-och-bus-passenger/src/main/res/drawable/bg_bus_p_start_tag_bg.xml new file mode 100644 index 0000000000..7a6d44a4c8 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/res/drawable/bg_bus_p_start_tag_bg.xml @@ -0,0 +1,14 @@ + + + + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable/bg_bus_p_traffic_light_background.xml b/OCH/mogo-och-bus-passenger/src/main/res/drawable/bg_bus_p_traffic_light_background.xml new file mode 100644 index 0000000000..6382b0256a --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/res/drawable/bg_bus_p_traffic_light_background.xml @@ -0,0 +1,9 @@ + + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable/bus_p_dividing_line_bg.xml b/OCH/mogo-och-bus-passenger/src/main/res/drawable/bus_p_dividing_line_bg.xml new file mode 100644 index 0000000000..d5d41809d0 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/res/drawable/bus_p_dividing_line_bg.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable/bus_p_route_bg.xml b/OCH/mogo-och-bus-passenger/src/main/res/drawable/bus_p_route_bg.xml new file mode 100644 index 0000000000..a1e022a3bc --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/res/drawable/bus_p_route_bg.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_base_fragment.xml b/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_base_fragment.xml index 77d9ef65f8..d60bc0ae92 100644 --- a/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_base_fragment.xml +++ b/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_base_fragment.xml @@ -1,6 +1,95 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_map_view.xml b/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_map_view.xml new file mode 100644 index 0000000000..d9fadd6ef5 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_map_view.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_no_data_common_view.xml b/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_no_data_common_view.xml new file mode 100644 index 0000000000..c0174fc191 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_no_data_common_view.xml @@ -0,0 +1,28 @@ + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_route_fragment.xml b/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_route_fragment.xml new file mode 100644 index 0000000000..3f4fd3015c --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_route_fragment.xml @@ -0,0 +1,176 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_stations_end_item.xml b/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_stations_end_item.xml new file mode 100644 index 0000000000..f530b3ea84 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_stations_end_item.xml @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_stations_middle_item.xml b/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_stations_middle_item.xml new file mode 100644 index 0000000000..8942ec0adf --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_stations_middle_item.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_stations_start_item.xml b/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_stations_start_item.xml new file mode 100644 index 0000000000..a1c5ee0b3e --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_stations_start_item.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_traffic_light_view.xml b/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_traffic_light_view.xml new file mode 100644 index 0000000000..0466fb6843 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_traffic_light_view.xml @@ -0,0 +1,34 @@ + + + + + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/main/res/values-sw320dp/dimens.xml b/OCH/mogo-och-bus-passenger/src/main/res/values-sw320dp/dimens.xml new file mode 100644 index 0000000000..3dc928c0b7 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/res/values-sw320dp/dimens.xml @@ -0,0 +1,54 @@ + + + 700px + 40px + 40px + 40px + 70px + 224px + 510px + 1px + + 158px + 90px + 45px + 158px + 90px + 45px + 100px + 100px + 3px + + 224px + 50px + 50px + 44px + 130px + 38px + + 36px + + 110px + 42px + + 4px + 10px + 20px + 60px + 30px + 20px + 50px + 6px + 50px + 36px + 75px + 50px + 6px + + 638px + 316px + 50px + 44px + 55px + 40px + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/main/res/values/attrs.xml b/OCH/mogo-och-bus-passenger/src/main/res/values/attrs.xml new file mode 100644 index 0000000000..c2af65cc03 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/res/values/attrs.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/main/res/values/colors.xml b/OCH/mogo-och-bus-passenger/src/main/res/values/colors.xml new file mode 100644 index 0000000000..eb3a91012c --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/res/values/colors.xml @@ -0,0 +1,28 @@ + + + #2D3E5F + #CCE9EFFC + #C7D2E1 + #2D3E5F + #0043FF + #2D3E5F + #596A8A + #D8E5F8 + #FFB327 + #2D3E5F + #0043FF + #276AFE + #0043FF + #276AFE + #FFC125 + #FF8131 + #31BFF2 + #3257E9 + #FFFFFF + #CDDBF6 + #2D3E5F + #0043FF + #2D3E5F + #E6E9EFFC + #33394C63 + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/main/res/values/dimens.xml b/OCH/mogo-och-bus-passenger/src/main/res/values/dimens.xml new file mode 100644 index 0000000000..b43711e918 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/res/values/dimens.xml @@ -0,0 +1,55 @@ + + + 700px + 40px + 40px + 40px + 40px + 70px + 224px + 510px + 1px + + 158px + 90px + 45px + 158px + 90px + 45px + 100px + 100px + 3px + + 224px + 50px + 50px + 44px + 130px + 38px + + 36px + + 110px + 42px + + 4px + 10px + 20px + 60px + 30px + 20px + 50px + 6px + 50px + 36px + 75px + 50px + 6px + + 638px + 316px + 50px + 44px + 55px + 40px + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/main/res/values/strings.xml b/OCH/mogo-och-bus-passenger/src/main/res/values/strings.xml new file mode 100644 index 0000000000..d142ef29fc --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/res/values/strings.xml @@ -0,0 +1,12 @@ + + + KM/H + 您已收车 + + + 到达站: + 下一站: + 始发站: + 请携带好随身物品下车。 + 欢迎乘坐蘑菇车联无人驾驶车。 + \ No newline at end of file diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/BusProvider.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/BusProvider.java index 43e18b13f0..02a9fc3d55 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/BusProvider.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/BusProvider.java @@ -40,7 +40,7 @@ public class BusProvider implements IMogoOCH { private void stepIntoVrMode(){ CallerLogger.INSTANCE.d( M_BUS + TAG, "进入vr模式" ); MogoMapUIController.getInstance() - .openVrMode(false); + .stepInVrMode(false); } @Override @@ -102,7 +102,7 @@ public class BusProvider implements IMogoOCH { this.containerId = integer; this.activity = fragmentActivity; - UiThreadHandler.postDelayed(this::stepIntoVrMode, 5_000L ); +// UiThreadHandler.postDelayed(this::stepIntoVrMode, 5_000L ); return null; } diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/BusFragment.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/BusFragment.java index 53efef1dc6..083cc2bab1 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/BusFragment.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/BusFragment.java @@ -174,16 +174,16 @@ public class BusFragment extends BaseBusTabFragment mStartStationFlag.setText(getResources().getString(R.string.bus_arrive_to_end_start)); setOrRemoveMapMaker(true, BusConst.BUS_START_MAP_MAKER, startStation.getLat() - , startStation.getLon()); + , startStation.getLon(),R.raw.star_marker); setOrRemoveMapMaker(true, BusConst.BUS_END_MAP_MAKER, endStation.getLat() - , endStation.getLon()); + , endStation.getLon(),R.raw.end_marker); } else if (currentStation > 0 && currentStation < stationList.size() - 1) {// 是否到达站点 isArriveAtStation = true; setOrRemoveMapMaker(false, BusConst.BUS_START_MAP_MAKER, startStation.getLat() - , startStation.getLon()); + , startStation.getLon(),R.raw.star_marker); setOrRemoveMapMaker(true, BusConst.BUS_END_MAP_MAKER, endStation.getLat() - , endStation.getLon()); + , endStation.getLon(),R.raw.end_marker); } else if (currentStation == stationList.size() - 1) {// 是否到达终点 isArriveEndStation = true; nextStationName = "--"; @@ -192,14 +192,14 @@ public class BusFragment extends BaseBusTabFragment endStationFlagVisibility = View.INVISIBLE; setOrRemoveMapMaker(false, BusConst.BUS_START_MAP_MAKER, startStation.getLat() - , startStation.getLon()); + , startStation.getLon(),R.raw.star_marker); if (isArrived) { setOrRemoveMapMaker(false, BusConst.BUS_END_MAP_MAKER, endStation.getLat() - , endStation.getLon()); + , endStation.getLon(),R.raw.end_marker); } else { setOrRemoveMapMaker(true, BusConst.BUS_END_MAP_MAKER, endStation.getLat() - , endStation.getLon()); + , endStation.getLon(),R.raw.end_marker); } } @@ -292,11 +292,11 @@ public class BusFragment extends BaseBusTabFragment //移除起点终点 if (null != startStation) { setOrRemoveMapMaker(false, BusConst.BUS_START_MAP_MAKER, startStation.getLat() - , startStation.getLon()); + , startStation.getLon(),R.raw.star_marker); } if (null != endStation) { setOrRemoveMapMaker(false, BusConst.BUS_END_MAP_MAKER, endStation.getLat() - , endStation.getLon()); + , endStation.getLon(),R.raw.end_marker); } } } @@ -318,9 +318,9 @@ public class BusFragment extends BaseBusTabFragment * @param isAdd * @param uuid */ - private void setOrRemoveMapMaker(boolean isAdd, String uuid, double lat, double longi) { + private void setOrRemoveMapMaker(boolean isAdd, String uuid, double lat, double longi,int resourceId) { if (isAdd) { - CallerLogger.INSTANCE.d("setMapMaker= ", uuid + "=latitude=" + lat + ",longitude=" + longi); + CallerLogger.INSTANCE.d(M_BUS + "setMapMaker= ", uuid + "=latitude=" + lat + ",longitude=" + longi); MogoMarkerOptions options = new MogoMarkerOptions() .owner(BusConst.TYPE_MARKER_BUS_ORDER) @@ -328,7 +328,7 @@ public class BusFragment extends BaseBusTabFragment .set3DMode(true) .gps(true) .controlAngle(true) - .icon3DRes(R.raw.start_and_end) + .icon3DRes(resourceId) .latitude(lat) .longitude(longi); IMogoMarker marker = MogoMarkerManager.getInstance(AbsMogoApplication.getApp()) .addMarker(uuid, options); @@ -337,7 +337,7 @@ public class BusFragment extends BaseBusTabFragment .getAngle() .floatValue()); }else { - CallerLogger.INSTANCE.d("RemoveMapMaker=",uuid+"=latitude="+lat+",longitude="+longi); + CallerLogger.INSTANCE.d(M_BUS + "RemoveMapMaker=",uuid+"=latitude="+lat+",longitude="+longi); MogoMarkerManager.getInstance(AbsMogoApplication.getApp()).removeMarkers(uuid); } } diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/view/BusArcView.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/view/BusArcView.java index 2fd6a41ce5..a9e7bdff5d 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/view/BusArcView.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/view/BusArcView.java @@ -24,7 +24,7 @@ import com.mogo.och.bus.R; public class BusArcView extends View { //中心的文字描述 - private String mDes = "km/h"; + private String mDes = "KM/H"; //根据数据显示的圆弧Paint private Paint mArcPaint; //圆弧颜色 diff --git a/OCH/mogo-och-bus/src/main/res/layout/bus_base_fragment.xml b/OCH/mogo-och-bus/src/main/res/layout/bus_base_fragment.xml index 6d12e21ed6..8bf210c856 100644 --- a/OCH/mogo-och-bus/src/main/res/layout/bus_base_fragment.xml +++ b/OCH/mogo-och-bus/src/main/res/layout/bus_base_fragment.xml @@ -3,7 +3,8 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="match_parent" + android:layout_marginTop="@dimen/dp_72"> stepIntoVrMode(), 5_000L); +// UiThreadHandler.postDelayed(() -> stepIntoVrMode(), 5_000L); return null; } diff --git a/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/presenter/TaxiPassengerServingOrderPresenter.java b/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/presenter/TaxiPassengerServingOrderPresenter.java index 1c50ec8c4b..c741b25165 100644 --- a/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/presenter/TaxiPassengerServingOrderPresenter.java +++ b/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/presenter/TaxiPassengerServingOrderPresenter.java @@ -2,6 +2,7 @@ package com.mogo.och.taxi.passenger.presenter; import android.location.Location; import android.os.Build; +import android.os.Looper; import androidx.annotation.NonNull; import androidx.annotation.RequiresApi; @@ -12,6 +13,7 @@ import com.mogo.commons.mvp.Presenter; import com.mogo.eagle.core.data.map.MogoLatLng; import com.mogo.eagle.core.network.utils.GsonUtil; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; +import com.mogo.eagle.core.utilcode.util.UiThreadHandler; import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrderQueryRespBean; import com.mogo.och.taxi.passenger.callback.IOCHTaxiPassengerAutopilotPlanningCallback; import com.mogo.och.taxi.passenger.callback.IOCHTaxiPassengerControllerStatusCallback; @@ -72,13 +74,13 @@ public class TaxiPassengerServingOrderPresenter extends Presenter mView.routeResult(latLngList)); } @Override public void routeResultByServer(List models) { if (models == null) return; - mView.routeResultByServer(models); + runOnUIThread(() -> mView.routeResultByServer(models)); } @Override @@ -112,12 +114,12 @@ public class TaxiPassengerServingOrderPresenter extends Presenter mView.onCurrentOrderDistToEndChanged(meters, timeInSecond)); } @Override public void onCurrentRoadName(String currentRoadName) { - mView.onCurrentRoadName(currentRoadName); + runOnUIThread(() -> mView.onCurrentRoadName(currentRoadName)); } @Override @@ -128,7 +130,7 @@ public class TaxiPassengerServingOrderPresenter extends Presenter mView.onCarLocationChanged(location)); } } @@ -143,4 +145,14 @@ public class TaxiPassengerServingOrderPresenter extends Presenter { - if (isStarting && IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING != status) { - // 1. 主动开启自动驾驶中,不为2(为0、1)则继续loading - return; - } - if (isStarting && IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING == status - && mPrevAPStatus != status) { - // 2. 主动开启自动驾驶中,为2则停止loading,并isStarting = false - startAutopilotDone(true); - return; - } +// if (isStarting && IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING != status) { +// // 1. 主动开启自动驾驶中,不为2(为0、1)则继续loading +// return; +// } +// if (isStarting && IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING == status +// && mPrevAPStatus != status) { +// // 2. 主动开启自动驾驶中,为2则停止loading,并isStarting = false +// startAutopilotDone(true); +// return; +// } // 3. 其他过程直接更新 - AutopilotStatusAnimchanged(status); - if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING == mPrevAPStatus) { - if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE == status) { - // 2->1 -// AIAssist.getInstance(getContext()).speakTTSVoice("已进入人工驾驶模式"); - } else if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE == status) { - // 2->0 -// AIAssist.getInstance(getContext()).speakTTSVoice("自动驾驶已停止,请人工接管"); - } + if (mPrevAPStatus != status){ + autopilotStatusAnimchanged(status); } +// if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING == mPrevAPStatus) { +// if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE == status) { +// // 2->1 +//// AIAssist.getInstance(getContext()).speakTTSVoice("已进入人工驾驶模式"); +// } else if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE == status) { +// // 2->0 +//// AIAssist.getInstance(getContext()).speakTTSVoice("自动驾驶已停止,请人工接管"); +// } +// } mPrevAPStatus = status; }); } - public void AutopilotStatusAnimchanged(int status) { + public void autopilotStatusAnimchanged(int status) { // mAutopilotTv.setText(isInAutopilot?"自动驾驶":"开启自动驾驶"); if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING == status) { mAutopilotImage.setImageResource(R.drawable.taxi_p_auto_nor); @@ -239,10 +245,12 @@ public class TaxiPassengerBaseFragment extends MvpFragment 57ABFF polylineOptions.useGradient(true); - polylineOptions.width(5); + polylineOptions.width(10); + polylineOptions.lineCapType(PolylineOptions.LineCapType.LineCapRound); // 绘制线 mPolyline = mAMap.addPolyline(polylineOptions); diff --git a/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/TaxiPassengerServingOrderFragment.java b/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/TaxiPassengerServingOrderFragment.java index 4761b78980..1ce87c7346 100644 --- a/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/TaxiPassengerServingOrderFragment.java +++ b/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/TaxiPassengerServingOrderFragment.java @@ -518,7 +518,7 @@ public class TaxiPassengerServingOrderFragment extends } public void onCarLocationChanged(Location location) { - runOnUIThread(() -> updateSpeedView(location.getSpeed())); + updateSpeedView(location.getSpeed()); } public void onLimitingVelocityChange(int limitingVelocity) { diff --git a/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/utils/TaxiPassengerUtils.java b/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/utils/TaxiPassengerUtils.java index 21250e6492..cc20ac563c 100644 --- a/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/utils/TaxiPassengerUtils.java +++ b/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/utils/TaxiPassengerUtils.java @@ -99,7 +99,7 @@ public class TaxiPassengerUtils { * @return */ public static String formatLong(double d) { - BigDecimal bg = new BigDecimal(d).setScale(2, RoundingMode.HALF_UP); + BigDecimal bg = new BigDecimal(d).setScale(1, RoundingMode.HALF_UP); double num = bg.doubleValue(); if (Math.round(num) - num == 0) { return String.valueOf((long) num); diff --git a/OCH/mogo-och-taxi-passenger/src/main/res/drawable/taxi_p_blue_circle_bg.xml b/OCH/mogo-och-taxi-passenger/src/main/res/drawable/taxi_p_blue_circle_bg.xml index b2d27af0ce..7a876437a8 100644 --- a/OCH/mogo-och-taxi-passenger/src/main/res/drawable/taxi_p_blue_circle_bg.xml +++ b/OCH/mogo-och-taxi-passenger/src/main/res/drawable/taxi_p_blue_circle_bg.xml @@ -1,8 +1,8 @@ - - + + diff --git a/OCH/mogo-och-taxi-passenger/src/main/res/drawable/taxi_p_yellow_circle_bg.xml b/OCH/mogo-och-taxi-passenger/src/main/res/drawable/taxi_p_yellow_circle_bg.xml index 60938a16f7..28a17cb4d0 100644 --- a/OCH/mogo-och-taxi-passenger/src/main/res/drawable/taxi_p_yellow_circle_bg.xml +++ b/OCH/mogo-och-taxi-passenger/src/main/res/drawable/taxi_p_yellow_circle_bg.xml @@ -1,8 +1,8 @@ - - + + @@ -25,23 +25,25 @@ + app:taxi_passenger_left_top_radius="@dimen/dp_48" + app:taxi_passenger_right_top_radius="@dimen/dp_48" /> @@ -49,12 +51,12 @@ android:id="@+id/taxi_p_order_status_start_station_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginLeft="68px" + android:layout_marginLeft="@dimen/dp_82" android:ellipsize="end" android:maxLines="1" android:text="--" android:textColor="#FFFFFF" - android:textSize="30px" + android:textSize="@dimen/taxi_p_order_station_size" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintTop_toTopOf="parent" /> @@ -62,7 +64,7 @@ android:id="@+id/taxi_p_blue_dot" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginRight="20px" + android:layout_marginRight="@dimen/dp_22" android:background="@drawable/taxi_p_blue_circle_bg" app:layout_constraintBottom_toBottomOf="@+id/taxi_p_order_status_start_station_tv" app:layout_constraintRight_toLeftOf="@+id/taxi_p_order_status_start_station_tv" @@ -72,12 +74,12 @@ android:id="@+id/taxi_p_order_status_end_station_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="10px" + android:layout_marginTop="@dimen/dp_12" android:ellipsize="end" android:maxLines="1" android:text="--" android:textColor="#FFFFFF" - android:textSize="30px" + android:textSize="@dimen/taxi_p_order_station_size" app:layout_constraintLeft_toLeftOf="@+id/taxi_p_order_status_start_station_tv" app:layout_constraintTop_toBottomOf="@+id/taxi_p_order_status_start_station_tv" /> @@ -85,7 +87,7 @@ android:id="@+id/taxi_p_yellow_dot" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginRight="20px" + android:layout_marginRight="@dimen/dp_22" android:background="@drawable/taxi_p_yellow_circle_bg" app:layout_constraintBottom_toBottomOf="@+id/taxi_p_order_status_end_station_tv" app:layout_constraintRight_toLeftOf="@+id/taxi_p_order_status_end_station_tv" @@ -136,8 +138,8 @@ android:layout_height="wrap_content" android:includeFontPadding="false" android:text="--" - android:textColor="#84D4FF" - android:textSize="42px" + android:textColor="@color/taxi_p_route_txt_color" + android:textSize="@dimen/taxi_p_order_route_size" android:textStyle="bold" /> + android:textSize="@dimen/taxi_p_route_txt_unit_size" /> + android:textSize="@dimen/taxi_p_route_txt_unit_size" /> @@ -189,8 +191,8 @@ android:layout_height="wrap_content" android:includeFontPadding="false" android:text="--" - android:textColor="#84D4FF" - android:textSize="42px" + android:textColor="@color/taxi_p_route_txt_color" + android:textSize="@dimen/taxi_p_order_route_size" android:textStyle="bold" /> + android:textSize="@dimen/taxi_p_route_txt_unit_size" /> + android:textSize="@dimen/taxi_p_route_txt_unit_size" /> @@ -236,8 +238,8 @@ android:layout_centerHorizontal="true" android:includeFontPadding="false" android:text="--" - android:textColor="#84D4FF" - android:textSize="42px" + android:textColor="@color/taxi_p_route_txt_color" + android:textSize="@dimen/taxi_p_order_route_size" android:textStyle="bold" /> + android:textSize="@dimen/taxi_p_route_txt_unit_size" /> @@ -273,13 +275,13 @@ @@ -308,7 +310,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="@dimen/dp_20" - android:layout_marginBottom="@dimen/dp_10" + android:layout_marginBottom="@dimen/dp_25" android:src="@drawable/taxi_p_arrow_nor" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintRight_toRightOf="parent" /> @@ -319,8 +321,8 @@ android:layout_width="@dimen/taxi_p_order_panel_width" android:layout_height="wrap_content" android:orientation="horizontal" - android:layout_marginLeft="@dimen/dp_36" - android:elevation="15dp" + android:layout_marginLeft="@dimen/dp_40" + android:elevation="@dimen/dp_30" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintTop_toTopOf="parent" android:gravity="bottom"> @@ -334,7 +336,6 @@ android:layout_height="wrap_content" android:layout_marginLeft="@dimen/dp_25" android:layout_marginTop="@dimen/dp_8" - android:includeFontPadding = "false" android:letterSpacing="-0.05" android:text="0" android:textStyle="bold" @@ -345,7 +346,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/dp_20" - android:includeFontPadding = "false" android:letterSpacing="-0.05" android:text="0" android:textStyle="bold" @@ -357,21 +357,21 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/dp_12" - android:text="KM/h" + android:text="KM/H" android:includeFontPadding="false" - android:layout_marginBottom="@dimen/dp_15" + android:layout_marginBottom="@dimen/dp_22" android:textColor="@android:color/white" - android:textSize="26px" /> + android:textSize="@dimen/taxi_p_speed_unit_size" /> + android:textSize="@dimen/taxi_p_order_status_size" /> \ No newline at end of file diff --git a/OCH/mogo-och-taxi-passenger/src/main/res/layout/taxi_p_arrived_end_panel.xml b/OCH/mogo-och-taxi-passenger/src/main/res/layout/taxi_p_arrived_end_panel.xml new file mode 100644 index 0000000000..94a263bb77 --- /dev/null +++ b/OCH/mogo-och-taxi-passenger/src/main/res/layout/taxi_p_arrived_end_panel.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-taxi-passenger/src/main/res/layout/taxi_p_base_fragment.xml b/OCH/mogo-och-taxi-passenger/src/main/res/layout/taxi_p_base_fragment.xml index 6f464fe16c..034b5d4f97 100644 --- a/OCH/mogo-och-taxi-passenger/src/main/res/layout/taxi_p_base_fragment.xml +++ b/OCH/mogo-och-taxi-passenger/src/main/res/layout/taxi_p_base_fragment.xml @@ -3,7 +3,8 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="match_parent" + android:layout_marginTop="@dimen/dp_72"> @@ -114,55 +115,4 @@ android:layout_marginTop="@dimen/taxi_p_traffic_light_layout_margin_top" android:visibility="gone"/> - - - - - - - - \ No newline at end of file diff --git a/OCH/mogo-och-taxi-passenger/src/main/res/values-sw320dp/dimens.xml b/OCH/mogo-och-taxi-passenger/src/main/res/values-sw320dp/dimens.xml index 7e4f321016..c9efef01f8 100644 --- a/OCH/mogo-och-taxi-passenger/src/main/res/values-sw320dp/dimens.xml +++ b/OCH/mogo-och-taxi-passenger/src/main/res/values-sw320dp/dimens.xml @@ -1,5 +1,7 @@ + + 496px 560px 910px 800px @@ -24,8 +26,8 @@ 420px 220px - 520px - 820px + 624px + 984px 225px 154px @@ -52,6 +54,11 @@ 82px 42px - 120px - 28px + 144px + 32px + 32px + 36px + 50px + 34px + 28px \ No newline at end of file diff --git a/OCH/mogo-och-taxi-passenger/src/main/res/values-xhdpi-2560x1440/dimens.xml b/OCH/mogo-och-taxi-passenger/src/main/res/values-xhdpi-2560x1440/dimens.xml index 4979821f90..6af3cfedd4 100644 --- a/OCH/mogo-och-taxi-passenger/src/main/res/values-xhdpi-2560x1440/dimens.xml +++ b/OCH/mogo-och-taxi-passenger/src/main/res/values-xhdpi-2560x1440/dimens.xml @@ -24,12 +24,6 @@ 120px 120px - 82px - 42px - - 120px - 28px - 83px 40px @@ -45,8 +39,6 @@ 460px 30px - 560px - 310px 15px 25px 25px @@ -71,6 +63,10 @@ 17px 31.5px + + 496px + 560px + 910px 800px 222px 1120px @@ -93,8 +89,8 @@ 420px 220px - 520px - 820px + 624px + 984px 225px 154px @@ -118,4 +114,15 @@ 20px 30px + 82px + 42px + + 144px + 32px + 32px + 36px + 50px + 34px + 28px + \ No newline at end of file diff --git a/OCH/mogo-och-taxi-passenger/src/main/res/values/colors.xml b/OCH/mogo-och-taxi-passenger/src/main/res/values/colors.xml index d9af8fd6e7..90bd4bfd1a 100644 --- a/OCH/mogo-och-taxi-passenger/src/main/res/values/colors.xml +++ b/OCH/mogo-och-taxi-passenger/src/main/res/values/colors.xml @@ -34,6 +34,7 @@ #FF6F62 #CEEEFF #A1DAFF + #84D4FF #00000000 diff --git a/OCH/mogo-och-taxi-passenger/src/main/res/values/dimens.xml b/OCH/mogo-och-taxi-passenger/src/main/res/values/dimens.xml index a95d5b27b7..f97cae2174 100644 --- a/OCH/mogo-och-taxi-passenger/src/main/res/values/dimens.xml +++ b/OCH/mogo-och-taxi-passenger/src/main/res/values/dimens.xml @@ -35,8 +35,6 @@ 460px 30px - 464px - 310px 5px 20px 20px @@ -61,6 +59,9 @@ 17px 22.5px + 496px + 560px + 910px 800px 222px 1120px @@ -83,10 +84,8 @@ 420px 220px - 520px - 820px - 520px - 432px + 624px + 984px 225px 154px @@ -110,10 +109,14 @@ 20px 30px - 82px 42px - 120px - 28px + 144px + 32px + 32px + 36px + 50px + 34px + 28px \ No newline at end of file diff --git a/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/TaxiProvider.java b/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/TaxiProvider.java index c926c94b65..3f2c014cda 100644 --- a/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/TaxiProvider.java +++ b/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/TaxiProvider.java @@ -46,7 +46,7 @@ class TaxiProvider implements IMogoOCH , IMogoStatusChangedListener { private void stepIntoVrMode() { CallerLogger.INSTANCE.d( M_TAXI + TAG, "进入vr模式" ); MogoMapUIController.getInstance() - .openVrMode( false ); + .stepInVrMode( false ); } private void showFragment() { @@ -94,7 +94,7 @@ class TaxiProvider implements IMogoOCH , IMogoStatusChangedListener { this.mActivity = fragmentActivity; this.mContainerId = integer; - UiThreadHandler.postDelayed(() -> stepIntoVrMode(), 5_000L); +// UiThreadHandler.postDelayed(() -> stepIntoVrMode(), 5_000L); return null; } diff --git a/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/ui/TaxiBeingServerdOrdersFragment.java b/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/ui/TaxiBeingServerdOrdersFragment.java index e20d397e78..28a9af53fe 100644 --- a/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/ui/TaxiBeingServerdOrdersFragment.java +++ b/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/ui/TaxiBeingServerdOrdersFragment.java @@ -384,8 +384,8 @@ public class TaxiBeingServerdOrdersFragment extends BaseTaxiUIFragment implement mTtsLessThan200Tip = 0; startNaviToStartStation(false, mOrderStartStationLat, mOrderStartStationLng); showOrHideNavi(true); - setOrRemoveMapMaker(true, TaxiConst.TAXI_START_MAP_MAKER,order.startSitePoint); - setOrRemoveMapMaker(true, TaxiConst.TAXI_END_MAP_MAKER,order.endSitePoint); + setOrRemoveMapMaker(true, TaxiConst.TAXI_START_MAP_MAKER,order.startSitePoint,R.raw.star_marker); + setOrRemoveMapMaker(true, TaxiConst.TAXI_END_MAP_MAKER,order.endSitePoint,R.raw.end_marker); break; case Cancel: mCurrentOrder = null; @@ -393,23 +393,23 @@ public class TaxiBeingServerdOrdersFragment extends BaseTaxiUIFragment implement mOrderCancel.setVisibility(View.VISIBLE); showNotice(mActivity.getString(R.string.module_och_taxi_order_cancel)); showOrHideNavi(false); - setOrRemoveMapMaker(false, TaxiConst.TAXI_START_MAP_MAKER,order.startSitePoint); - setOrRemoveMapMaker(false, TaxiConst.TAXI_END_MAP_MAKER,order.endSitePoint); + setOrRemoveMapMaker(false, TaxiConst.TAXI_START_MAP_MAKER,order.startSitePoint,R.raw.star_marker); + setOrRemoveMapMaker(false, TaxiConst.TAXI_END_MAP_MAKER,order.endSitePoint,R.raw.end_marker); break; case ArriveAtStart: mTtsLessThan200Tip = 0; mOrderCancel.setVisibility(View.VISIBLE); showNotice(mActivity.getString(R.string.module_och_taxi_order_status_ph_text)); showOrHideNavi(false); - setOrRemoveMapMaker(true, TaxiConst.TAXI_START_MAP_MAKER,order.startSitePoint); - setOrRemoveMapMaker(true, TaxiConst.TAXI_END_MAP_MAKER,order.endSitePoint); + setOrRemoveMapMaker(true, TaxiConst.TAXI_START_MAP_MAKER,order.startSitePoint,R.raw.star_marker); + setOrRemoveMapMaker(true, TaxiConst.TAXI_END_MAP_MAKER,order.endSitePoint,R.raw.end_marker); break; case OnTheWayToEnd: // showNotice("欢迎使用蘑菇智行"); mOrderCancel.setVisibility(View.VISIBLE); showOrHideNavi(false); - setOrRemoveMapMaker(false, TaxiConst.TAXI_START_MAP_MAKER,order.startSitePoint); - setOrRemoveMapMaker(true, TaxiConst.TAXI_END_MAP_MAKER,order.endSitePoint); + setOrRemoveMapMaker(false, TaxiConst.TAXI_START_MAP_MAKER,order.startSitePoint,R.raw.star_marker); + setOrRemoveMapMaker(true, TaxiConst.TAXI_END_MAP_MAKER,order.endSitePoint,R.raw.end_marker); break; case ArriveAtEnd: mCurrentOrder = null; @@ -417,8 +417,8 @@ public class TaxiBeingServerdOrdersFragment extends BaseTaxiUIFragment implement mOrderCancel.setVisibility(View.GONE); showNotice(mActivity.getString(R.string.module_och_taxi_order_auto_arrive_end_tip)); showOrHideNavi(false); - setOrRemoveMapMaker(false, TaxiConst.TAXI_START_MAP_MAKER,order.startSitePoint); - setOrRemoveMapMaker(false, TaxiConst.TAXI_END_MAP_MAKER,order.endSitePoint); + setOrRemoveMapMaker(false, TaxiConst.TAXI_START_MAP_MAKER,order.startSitePoint,R.raw.star_marker); + setOrRemoveMapMaker(false, TaxiConst.TAXI_END_MAP_MAKER,order.endSitePoint,R.raw.end_marker); break; case JourneyCompleted: mCurrentOrder = null; @@ -486,8 +486,8 @@ public class TaxiBeingServerdOrdersFragment extends BaseTaxiUIFragment implement public void onCurrentOrderCancelDone() { //去除起终点 if (mCurrentOrder != null){ - setOrRemoveMapMaker(false, TaxiConst.TAXI_START_MAP_MAKER,mCurrentOrder.startSitePoint); - setOrRemoveMapMaker(false, TaxiConst.TAXI_END_MAP_MAKER,mCurrentOrder.endSitePoint); + setOrRemoveMapMaker(false, TaxiConst.TAXI_START_MAP_MAKER,mCurrentOrder.startSitePoint,R.raw.star_marker); + setOrRemoveMapMaker(false, TaxiConst.TAXI_END_MAP_MAKER,mCurrentOrder.endSitePoint,R.raw.end_marker); } //提交取消订单后的回调 TipToast.tip("订单取消成功"); @@ -552,7 +552,7 @@ public class TaxiBeingServerdOrdersFragment extends BaseTaxiUIFragment implement * @param uuid * @param station */ - private void setOrRemoveMapMaker(boolean isAdd, String uuid, List station){ + private void setOrRemoveMapMaker(boolean isAdd, String uuid, List station,int resourceId){ if (isAdd){ CallerLogger.INSTANCE.d(M_TAXI + "setMapMaker= ",uuid+"=latitude=" +station.get(1)+",longitude="+station.get(0)); @@ -563,7 +563,7 @@ public class TaxiBeingServerdOrdersFragment extends BaseTaxiUIFragment implement .set3DMode(true) .gps(true) .controlAngle(true) - .icon3DRes(R.raw.start_and_end) + .icon3DRes(resourceId) .latitude(station.get(1)) .longitude(station.get(0)); IMogoMarker marker = MogoMarkerManager.getInstance(AbsMogoApplication.getApp()).addMarker(uuid, options); diff --git a/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/utils/TaxiDateTimeUtil.java b/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/utils/TaxiDateTimeUtil.java index da2cc3b86f..f2deca90fe 100644 --- a/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/utils/TaxiDateTimeUtil.java +++ b/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/utils/TaxiDateTimeUtil.java @@ -99,7 +99,7 @@ public class TaxiDateTimeUtil { * @return */ public static String formatLong(double d) { - BigDecimal bg = new BigDecimal(d).setScale(2, RoundingMode.HALF_UP); + BigDecimal bg = new BigDecimal(d).setScale(1, RoundingMode.HALF_UP); double num = bg.doubleValue(); if (Math.ceil(num) - num == 0) { return String.valueOf((long) num); diff --git a/OCH/mogo-och-taxi/src/main/res/layout/taxi_base_fragment.xml b/OCH/mogo-och-taxi/src/main/res/layout/taxi_base_fragment.xml index 26963bb31d..a0bb45d5dd 100644 --- a/OCH/mogo-och-taxi/src/main/res/layout/taxi_base_fragment.xml +++ b/OCH/mogo-och-taxi/src/main/res/layout/taxi_base_fragment.xml @@ -3,7 +3,8 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="match_parent" + android:layout_marginTop="@dimen/dp_72"> 车辆已停稳,请携带好随身物品,下车请注意安全 无人驾驶已启动,请您系好安全带 即将到达目的地,请拿好随身物品,准备下车 - 已达到目的地,感谢乘坐\'蘑菇车联\'无人驾驶车,期待下次相遇 + 已到达目的地,感谢乘坐\'蘑菇车联\'无人驾驶车,期待下次相遇 \ No newline at end of file diff --git a/app/src/main/java/com/mogo/launcher/MogoApplication.java b/app/src/main/java/com/mogo/launcher/MogoApplication.java index a47228a223..525609d945 100644 --- a/app/src/main/java/com/mogo/launcher/MogoApplication.java +++ b/app/src/main/java/com/mogo/launcher/MogoApplication.java @@ -67,7 +67,6 @@ public class MogoApplication extends MainMoGoApplication { DebugConfig.setProductFlavor(BuildConfig.FLAVOR_product); DebugConfig.setSocketAppId(BuildConfig.SOCKET_APP_ID); DebugConfig.setScheduleCalculateNotHomeCompanyDistanceForPush(BuildConfig.IS_SUPPORT_SCHEDULE_CALCULATE_NOT_HOME_COMPANY_DISTANCE_FOR_PUSH); - DebugConfig.setMapBased(BuildConfig.IS_MAP_BASED); DebugConfig.setNeedUploadCoordinatesInTime(BuildConfig.IS_NEED_UPLOAD_COORDINATES_IN_TIME); DebugConfig.setObuType(SharedPrefsMgr.getInstance(this).getInt("OBU_TYPE", DebugConfig.OBU_TYPE_CIDI)); diff --git a/core/function-impl/mogo-core-function-bindingcar/src/main/java/com/mogo/eagle/core/function/bindingcar/BindingcarProvider.java b/core/function-impl/mogo-core-function-bindingcar/src/main/java/com/mogo/eagle/core/function/bindingcar/BindingcarProvider.java index 90e5188004..4bf44658d8 100644 --- a/core/function-impl/mogo-core-function-bindingcar/src/main/java/com/mogo/eagle/core/function/bindingcar/BindingcarProvider.java +++ b/core/function-impl/mogo-core-function-bindingcar/src/main/java/com/mogo/eagle/core/function/bindingcar/BindingcarProvider.java @@ -10,6 +10,7 @@ import com.mogo.eagle.core.data.constants.MogoServicePaths; import com.mogo.eagle.core.function.api.bindingcar.BindingcarCallBack; import com.mogo.eagle.core.function.api.bindingcar.IMoGoBindingcarProvider; import com.mogo.eagle.core.function.bindingcar.network.BindingcarNetWorkManager; +import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils; import org.jetbrains.annotations.NotNull; @@ -66,11 +67,13 @@ public class BindingcarProvider implements IMoGoBindingcarProvider { private int getScreenType() { int screenType = -1; - if (FunctionBuildConfig.appIdentityMode == 0 || FunctionBuildConfig.appIdentityMode == 0xA0) { + if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) { screenType = 1; //司机屏 - } else if (FunctionBuildConfig.appIdentityMode == 1 || FunctionBuildConfig.appIdentityMode == 0xA1) { - screenType = 2; //乘客屏 } + +// if (AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) { +// screenType = 2; //乘客屏 +// } return screenType; } diff --git a/core/function-impl/mogo-core-function-bindingcar/src/main/java/com/mogo/eagle/core/function/bindingcar/network/BindingcarNetWorkManager.java b/core/function-impl/mogo-core-function-bindingcar/src/main/java/com/mogo/eagle/core/function/bindingcar/network/BindingcarNetWorkManager.java index 35eb82aa10..3db15f9432 100644 --- a/core/function-impl/mogo-core-function-bindingcar/src/main/java/com/mogo/eagle/core/function/bindingcar/network/BindingcarNetWorkManager.java +++ b/core/function-impl/mogo-core-function-bindingcar/src/main/java/com/mogo/eagle/core/function/bindingcar/network/BindingcarNetWorkManager.java @@ -6,6 +6,7 @@ import android.util.Log; import com.mogo.cloud.passport.MoGoAiCloudClientConfig; import com.mogo.commons.constants.SharedPrefsConstants; import com.mogo.eagle.core.data.bindingcar.BindingcarInfo; +import com.mogo.eagle.core.data.bindingcar.CarInfo; import com.mogo.eagle.core.data.bindingcar.ModifyBindingcarInfo; import com.mogo.eagle.core.function.api.bindingcar.BindingcarCallBack; import com.mogo.eagle.core.function.call.hmi.CallerHmiManager; @@ -13,6 +14,7 @@ import com.mogo.eagle.core.network.MoGoRetrofitFactory; import com.mogo.eagle.core.network.utils.GsonUtil; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr; +import com.mogo.eagle.core.utilcode.util.GsonUtils; import com.mogo.module.common.constants.HostConst; import io.reactivex.Observer; @@ -79,7 +81,7 @@ public class BindingcarNetWorkManager { CallerHmiManager.INSTANCE.showModifyBindingcarDialog(); } - SharedPrefsMgr.getInstance(context).putString(SharedPrefsConstants.CAR_MODE_TYPE, info.data.getSeries()); + SharedPrefsMgr.getInstance(context).putString(SharedPrefsConstants.CAR_INFO, GsonUtils.toJson(info.data)); } } diff --git a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/repository/net/BadCaseNetModel.kt b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/repository/net/BadCaseNetModel.kt index e643ed63ef..569eb88383 100644 --- a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/repository/net/BadCaseNetModel.kt +++ b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/repository/net/BadCaseNetModel.kt @@ -21,6 +21,7 @@ internal class BadCaseNetModel { .get(channel ?: "", pageNo) .takeIf { val body = it.body() + CallerLogger.d("$M_DEVA${BadCaseManager.TAG}", "get result: $body") it.isSuccessful && body != null && (body.code == 0 || body.code == 200) } ?.body()?.also { @@ -39,16 +40,19 @@ internal class BadCaseNetModel { } suspend fun upload(map: Map): UploadResult? = try { + CallerLogger.d("$M_DEVA${BadCaseManager.TAG}", "upload_params:$map") MoGoRetrofitFactory .getInstance(BadCaseHost.getHost()) .create(BadCaseApi::class.java) .post(map) .takeIf { val body = it.body() + CallerLogger.d("$M_DEVA${BadCaseManager.TAG}", "upload_result:$body") return@takeIf it.isSuccessful && (body != null) && (body.code == 0 || body.code == 200) } ?.body() } catch (t: Throwable) { + CallerLogger.d("$M_DEVA${BadCaseManager.TAG}", "upload_error:$t") null } } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/notification/WarningFloatWindowHelper.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/notification/WarningFloatWindowHelper.kt index 8df1a947ee..db7881ef3f 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/notification/WarningFloatWindowHelper.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/notification/WarningFloatWindowHelper.kt @@ -105,6 +105,13 @@ internal class WarningFloatWindowHelper( frameLayout?.layoutListener = object : ParentFrameLayout.OnLayoutListener { override fun onLayout() { frameLayout?.postDelayed({ + // 设置View显示模式,沉浸式的侵入到状态栏,导航栏 + frameLayout?.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY + or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION + or View.SYSTEM_UI_FLAG_LAYOUT_STABLE + or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) + setGravity(frameLayout) config.apply { enterAnim(floatingView) diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt index 70b9dd7140..c04cba92ad 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt @@ -14,6 +14,7 @@ import com.mogo.commons.mvp.MvpFragment import com.mogo.commons.voice.AIAssist import com.mogo.eagle.core.data.autopilot.AdUpgradeStateHelper import com.mogo.eagle.core.data.camera.CameraEntity +import com.mogo.eagle.core.data.config.FunctionBuildConfig import com.mogo.eagle.core.data.config.HmiBuildConfig import com.mogo.eagle.core.data.constants.MoGoFragmentPaths import com.mogo.eagle.core.data.enums.SidePattern @@ -44,6 +45,7 @@ import com.mogo.eagle.core.function.hmi.ui.notice.NoticeNormalBannerView import com.mogo.eagle.core.function.hmi.ui.setting.DebugSettingView import com.mogo.eagle.core.function.hmi.ui.tools.AutoPilotAndCheckView import com.mogo.eagle.core.function.hmi.ui.widget.V2XNotificationView +import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_HMI import com.mogo.eagle.core.utilcode.util.ThreadUtils @@ -131,6 +133,8 @@ class MoGoHmiFragment : MvpFragment(), toggleDebugView() true } + + } @OptIn(ExperimentalCoroutinesApi::class) @@ -389,11 +393,19 @@ class MoGoHmiFragment : MvpFragment(), if (mDebugSettingView == null) { mDebugSettingView = DebugSettingView(it) } + var side =SidePattern.RIGHT + var gravity = Gravity.RIGHT + //调试窗默认靠右显示,Bus的乘客端右端有视图覆盖,调试窗靠左显示 + if(AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode) && + AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)){ + side = SidePattern.LEFT + gravity = Gravity.LEFT + } mDebugSettingViewFloat = WarningFloat.with(it) .setTag("DebugSettingView") .setLayout(mDebugSettingView!!) - .setSidePattern(SidePattern.RIGHT) - .setGravity(Gravity.RIGHT, offsetY = 70) + .setSidePattern(side) + .setGravity(gravity, offsetY = 70) .setImmersionStatusBar(true) .setAnimator(object : DefaultAnimator() { override fun enterAnim( @@ -478,7 +490,7 @@ class MoGoHmiFragment : MvpFragment(), if (mWarningFloat != null && !TextUtils.isEmpty(ttsContent) && playTts) { CallerLogger.d("$M_HMI$TAG", "---> ttsContent = $ttsContent") AIAssist.getInstance(activity) - .speakTTSVoice(ttsContent) + .speakTTSVoice(ttsContent) } showWarning(WarningDirectionEnum.ALERT_WARNING_ALL) } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt index d582e9ae6e..244418a7da 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt @@ -16,7 +16,6 @@ import chassis.Chassis import com.mogo.cloud.passport.MoGoAiCloudClient import com.mogo.commons.AbsMogoApplication import com.mogo.commons.debug.DebugConfig -import com.mogo.commons.voice.AIAssist import com.mogo.eagle.core.data.app.AppConfigInfo import com.mogo.eagle.core.data.autopilot.* import com.mogo.eagle.core.data.config.FunctionBuildConfig @@ -179,6 +178,10 @@ class DebugSettingView @JvmOverloads constructor( } // 开启定时查询速度 Timer().schedule(timerTaskRefresh, Date(), 100) + if (AppConfigInfo.isConnectAutopilot && (AppConfigInfo.plateNumber.isNullOrEmpty() || AppConfigInfo.iPCMacAddress.isNullOrEmpty())) { + //查询工控机基础配置信息 + CallerAutoPilotManager.getCarConfig() + } } override fun onDetachedFromWindow() { @@ -445,7 +448,7 @@ class DebugSettingView @JvmOverloads constructor( /** * 修改自车按钮(出租车、小巴车) */ - tbChangeCurrentCarIcon.setOnCheckedChangeListener { buttonView, isChecked -> + tbChangeCurrentCarIcon.setOnCheckedChangeListener { _, isChecked -> if (!isChecked) { // 替换为出租车图标 CallerHDMapManager.changeCurrentIcon(R.raw.chuzuche) @@ -455,6 +458,14 @@ class DebugSettingView @JvmOverloads constructor( } } + + /** + * 修改地图样式按钮(白天模式、夜间模式) + */ + tbChangeCurrentMapStyle.setOnCheckedChangeListener { _, isChecked -> + CallerHDMapManager.stepInVrMode(isChecked) + } + //设置鹰眼本地参数配置监听 setEagleEyeConfigListener() //域控制器中心事件点击监听 @@ -509,7 +520,7 @@ class DebugSettingView @JvmOverloads constructor( // 演示模式,上一次勾选的数据 - tbIsDrawAutopilotTrajectoryData.setOnCheckedChangeListener { buttonView, isChecked -> + tbIsDrawAutopilotTrajectoryData.setOnCheckedChangeListener { _, isChecked -> FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = isChecked } @@ -528,7 +539,7 @@ class DebugSettingView @JvmOverloads constructor( else -> R.id.rbGpsProviderAndroid } ) - rgGpsProvider.setOnCheckedChangeListener { group, checkedId -> + rgGpsProvider.setOnCheckedChangeListener { _, checkedId -> when (checkedId) { R.id.rbGpsProviderAndroid -> { FunctionBuildConfig.gpsProvider = 0 @@ -545,13 +556,13 @@ class DebugSettingView @JvmOverloads constructor( // 初始化 ADAS感知数据是否绘制 选择情况 tbIsDrawIdentifyData.isChecked = FunctionBuildConfig.isDrawIdentifyData - tbIsDrawIdentifyData.setOnCheckedChangeListener { buttonView, isChecked -> + tbIsDrawIdentifyData.setOnCheckedChangeListener { _, isChecked -> FunctionBuildConfig.isDrawIdentifyData = isChecked } // 初始化 ADAS感知数据是否绘制 选择情况 tbIsDrawUnknownIdentifyData.isChecked = FunctionBuildConfig.isDrawUnknownIdentifyData - tbIsDrawUnknownIdentifyData.setOnCheckedChangeListener { buttonView, isChecked -> + tbIsDrawUnknownIdentifyData.setOnCheckedChangeListener { _, isChecked -> FunctionBuildConfig.isDrawUnknownIdentifyData = isChecked } @@ -562,7 +573,7 @@ class DebugSettingView @JvmOverloads constructor( // } // 模拟自动驾驶中 - tbChangeAutoPilotStatus.setOnCheckedChangeListener { buttonView, isChecked -> + tbChangeAutoPilotStatus.setOnCheckedChangeListener { _, isChecked -> CallerAutoPilotManager.setControlAutopilotCarAuto(isChecked) } when { @@ -577,6 +588,12 @@ class DebugSettingView @JvmOverloads constructor( etConnectServerIp.visibility = View.VISIBLE } } + + //初始化切换自车按钮文本(Bus版本默认显示:切换自车为出租车) + if(AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)){ + tbChangeCurrentCarIcon.isChecked = true + } + } /** @@ -591,7 +608,7 @@ class DebugSettingView @JvmOverloads constructor( //设置刹车加速度阈值信息 btnBrakeThreshold.setOnClickListener { val thresholdStr = etInputBrakeThreshold.text.toString() - if(thresholdStr.isNullOrEmpty()){ + if(thresholdStr.isEmpty()){ ToastUtils.showShort("请输入正确的判定刹车加速度阈值") }else{ try{ @@ -627,7 +644,7 @@ class DebugSettingView @JvmOverloads constructor( SharedPrefsMgr.getInstance(context) .getString(MoGoConfig.AUTOPILOT_IP, FunctionBuildConfig.adasConnectIP) - etAutopilotIP.setText("192.168.1.103:4110") + etAutopilotIP.setText("192.168.1.") etAutopilotIP.text?.let { etAutopilotIP.setSelection(it.length) } //设置工控机IP btnSetAutopilotIP.setOnClickListener { @@ -853,7 +870,7 @@ class DebugSettingView @JvmOverloads constructor( /** * 显示、隐藏迈速表 */ - tbSpeedView.setOnCheckedChangeListener { buttonView, isChecked -> + tbSpeedView.setOnCheckedChangeListener { _, isChecked -> if (!isChecked) { CallerHmiManager.setSpeedChartViewVisibility(View.VISIBLE) } else { @@ -864,7 +881,7 @@ class DebugSettingView @JvmOverloads constructor( /** * 显示、隐藏“自动驾驶控制按钮” */ - tbAutopilotStatusView.setOnCheckedChangeListener { buttonView, isChecked -> + tbAutopilotStatusView.setOnCheckedChangeListener { _, isChecked -> if (!isChecked) { CallerHmiManager.setAutopilotStatusViewVisibility(View.VISIBLE) } else { @@ -875,7 +892,7 @@ class DebugSettingView @JvmOverloads constructor( /** * 显示、隐藏视角切换按钮 */ - tbPerspectiveSwitchView.setOnCheckedChangeListener { buttonView, isChecked -> + tbPerspectiveSwitchView.setOnCheckedChangeListener { _, isChecked -> if (!isChecked) { CallerHmiManager.setPerspectiveSwitchViewVisibility(View.VISIBLE) } else { @@ -886,7 +903,7 @@ class DebugSettingView @JvmOverloads constructor( /** * 显示、隐藏工具箱 */ - tbCheckStatusView.setOnCheckedChangeListener { buttonView, isChecked -> + tbCheckStatusView.setOnCheckedChangeListener { _, isChecked -> if (!isChecked) { CallerHmiManager.setToolsViewVisibility(View.VISIBLE) } else { @@ -909,7 +926,7 @@ class DebugSettingView @JvmOverloads constructor( /** * 打开、关闭转向灯控制 */ - tbOpenLight.setOnCheckedChangeListener { buttonView, isChecked -> + tbOpenLight.setOnCheckedChangeListener { _, isChecked -> if (!isChecked) { CallerHmiManager.setTurnLightFunction(true) } else { @@ -920,7 +937,7 @@ class DebugSettingView @JvmOverloads constructor( /** * 打开、关闭刹车控制 */ - tbOpenBrakeLight.setOnCheckedChangeListener { buttonView, isChecked -> + tbOpenBrakeLight.setOnCheckedChangeListener { _, isChecked -> if (!isChecked) { CallerHmiManager.setBrakeLightFunction(true) } else { @@ -931,7 +948,7 @@ class DebugSettingView @JvmOverloads constructor( /** * sn绑定控制 */ - tbOpenSnBinding.setOnCheckedChangeListener { buttonView, isChecked -> + tbOpenSnBinding.setOnCheckedChangeListener { _, isChecked -> if (!isChecked) { CallerHmiManager.setSnBinding(true) } else { @@ -1294,7 +1311,7 @@ class DebugSettingView @JvmOverloads constructor( */ private fun dataFilter(list: ArrayList): ArrayList { val tempList = ArrayList() - list?.let { + list.let { it.iterator().forEach { entity-> if(onlineSelected && entity.name.contains("online")){ tempList.add(entity) @@ -1532,12 +1549,6 @@ class DebugSettingView @JvmOverloads constructor( override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) { mAutoPilotStatusInfo = autoPilotStatusInfo AppConfigInfo.isConnectAutopilot = autoPilotStatusInfo.connectStatus - -// if (AppConfigInfo.isConnectAutopilot && (AppConfigInfo.plateNumber.isNullOrEmpty() || AppConfigInfo.iPCMacAddress.isNullOrEmpty())) { -// //查询工控机基础配置信息 -// CallerAutoPilotManager.getCarConfig() -// } - if (autoPilotStatusInfo.connectStatus) { adasConnectStatus = true } @@ -1579,7 +1590,7 @@ class DebugSettingView @JvmOverloads constructor( * 工控机基础信息回调 */ override fun onAutopilotCarConfig(carConfigResp: MessagePad.CarConfigResp) { - carConfigResp?.let { + carConfigResp.let { AppConfigInfo.plateNumber = it.plateNumber//车牌号 AppConfigInfo.iPCMacAddress = it.macAddress//工控机MAC地址 AppConfigInfo.protocolVersionNumber = it.protocolVersion.number//工控机协议版本 diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/turnlight/BrakeViewStatus.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/turnlight/BrakeViewStatus.kt index d128c5e257..56f19763b4 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/turnlight/BrakeViewStatus.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/turnlight/BrakeViewStatus.kt @@ -10,7 +10,9 @@ import android.view.animation.AlphaAnimation import android.view.animation.Animation import android.view.animation.DecelerateInterpolator import androidx.constraintlayout.widget.ConstraintLayout +import com.mogo.eagle.core.data.config.FunctionBuildConfig import com.mogo.eagle.core.function.hmi.R +import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils import kotlinx.android.synthetic.main.view_brake_light_status.view.* import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope @@ -28,7 +30,12 @@ class BrakeViewStatus @JvmOverloads constructor( defStyleAttr: Int = 0 ) : ConstraintLayout(context, attrs, defStyleAttr) { init { - LayoutInflater.from(context).inflate(R.layout.view_brake_light_status, this, true) + //bus乘客端 + if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode) && AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) { + LayoutInflater.from(context).inflate(R.layout.view_brake_light_status_daytime, this, true) + } else { + LayoutInflater.from(context).inflate(R.layout.view_brake_light_status, this, true) + } } private var isBrake: Boolean = false diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/turnlight/TurnLightViewStatus.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/turnlight/TurnLightViewStatus.kt index de079bb6b6..50f2e8a817 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/turnlight/TurnLightViewStatus.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/turnlight/TurnLightViewStatus.kt @@ -1,19 +1,21 @@ package com.mogo.eagle.core.function.hmi.ui.turnlight +import android.animation.AnimatorSet +import android.animation.ObjectAnimator import android.content.Context import android.util.AttributeSet -import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.animation.AlphaAnimation import android.view.animation.Animation -import android.view.animation.LinearInterpolator import android.widget.ImageView import androidx.constraintlayout.widget.ConstraintLayout +import com.mogo.eagle.core.data.config.FunctionBuildConfig import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager.Scene.Default import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager.Scene.Turning import com.mogo.eagle.core.function.hmi.R +import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils import kotlinx.android.synthetic.main.view_turn_light_status.view.* import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope @@ -31,7 +33,11 @@ class TurnLightViewStatus @JvmOverloads constructor( defStyleAttr: Int = 0 ) : ConstraintLayout(context, attrs, defStyleAttr) { init { - LayoutInflater.from(context).inflate(R.layout.view_turn_light_status, this, true) + if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode) && AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) { + LayoutInflater.from(context).inflate(R.layout.view_turn_light_status_daytime, this, true) + } else { + LayoutInflater.from(context).inflate(R.layout.view_turn_light_status, this, true) + } } private var isShowNormalBg :Boolean = false @@ -169,12 +175,19 @@ class TurnLightViewStatus @JvmOverloads constructor( //实现图片闪烁效果 private fun setAnimation(imageView: ImageView) { - val animation = AlphaAnimation(1.0f, 0f) - animation.duration = 500 - animation.interpolator = LinearInterpolator() - animation.repeatCount = Animation.INFINITE - animation.repeatMode = Animation.REVERSE - imageView.startAnimation(animation) + val animationSet = AnimatorSet() + + val valueAnimator = ObjectAnimator.ofFloat(imageView, "alpha",0f, 1.0f) + val valueAnimatorDisappare = ObjectAnimator.ofFloat(imageView, "alpha",1.0f, 0f) + valueAnimator.duration = 1000 + valueAnimatorDisappare.duration = 800 + + valueAnimator.repeatCount = -1 + valueAnimatorDisappare.repeatCount = -1 + + animationSet.playTogether(valueAnimatorDisappare, valueAnimator) + animationSet.start() + } private fun stopAnimate() { diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/CircularProgressView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/CircularProgressView.kt index 66be06132d..59f51b97d1 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/CircularProgressView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/CircularProgressView.kt @@ -5,6 +5,7 @@ import android.content.Context import android.content.res.TypedArray import android.graphics.* import android.util.AttributeSet +import android.util.Log import android.view.View import android.view.animation.OvershootInterpolator import androidx.core.content.ContextCompat @@ -16,23 +17,28 @@ import com.mogo.eagle.core.function.hmi.R * @since: 2022/1/14 */ class CircularProgressView @JvmOverloads constructor( - context: Context, attrs: AttributeSet?, defStyleAttr : Int) - : View(context, attrs, defStyleAttr){ + context: Context, attrs: AttributeSet?, defStyleAttr: Int) + : View(context, attrs, defStyleAttr) { + + val typedArray: TypedArray = context.obtainStyledAttributes(attrs, R.styleable.CircularProgressView) + val TAG: String = "CircularProgressView" - val typedArray : TypedArray = context.obtainStyledAttributes(attrs, R.styleable.CircularProgressView) // 绘制画笔 - private val mBackPaint : Paint = Paint() - private val mProgPaint : Paint = Paint() + private val mBackPaint: Paint = Paint() + private val mProgPaint: Paint = Paint() + // 绘制区域 - private var mRectF : RectF? = null + private var mRectF: RectF? = null + // 圆环渐变色 - private var mColorArray : IntArray?=null + private var mColorArray: IntArray? = null + // 圆环进度(0-100) 初始化进度 - private var mProgress : Int = typedArray.getInteger(R.styleable.CircularProgressView_progress, 0) + private var mProgress: Int = typedArray.getInteger(R.styleable.CircularProgressView_progress, 0) - constructor(context : Context) : this(context,null) + constructor(context: Context) : this(context, null) - constructor(context : Context,attrs : AttributeSet?) :this(context, attrs, 0) + constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0) init { // 初始化背景圆环画笔 @@ -52,9 +58,9 @@ class CircularProgressView @JvmOverloads constructor( // 初始化进度圆环渐变色 val startColor = typedArray.getColor(R.styleable.CircularProgressView_progStartColor, -1) val firstColor = typedArray.getColor(R.styleable.CircularProgressView_progFirstColor, -1) - if(startColor != -1 && firstColor != -1){ - mColorArray = intArrayOf(startColor,firstColor) - }else{ + if (startColor != -1 && firstColor != -1) { + mColorArray = intArrayOf(startColor, firstColor) + } else { mColorArray = null } @@ -67,26 +73,32 @@ class CircularProgressView @JvmOverloads constructor( val viewWide = getMeasuredWidth() - getPaddingLeft() - getPaddingRight(); val viewHigh = getMeasuredHeight() - getPaddingTop() - getPaddingBottom(); val mRectLength = - ((if (viewWide > viewHigh) viewHigh else viewWide) - if (mBackPaint.strokeWidth > mProgPaint.strokeWidth) mBackPaint.strokeWidth else mProgPaint.strokeWidth).toInt() + ((if (viewWide > viewHigh) viewHigh else viewWide) - if (mBackPaint.strokeWidth > mProgPaint.strokeWidth) mBackPaint.strokeWidth else mProgPaint.strokeWidth).toInt() val mRectL = getPaddingLeft() + (viewWide - mRectLength) / 2 val mRectT = getPaddingTop() + (viewHigh - mRectLength) / 2 mRectF = RectF(mRectL.toFloat(), mRectT.toFloat(), (mRectL + mRectLength).toFloat(), - (mRectT + mRectLength).toFloat()) + (mRectT + mRectLength).toFloat()) // 设置进度圆环渐变色 mColorArray?.let { mProgPaint.shader = LinearGradient( - 0.0f, 0.0f, 0.0f, - measuredWidth.toFloat(), it, null, Shader.TileMode.MIRROR) + 0f, 0f, 0f, + measuredWidth.toFloat(), mColorArray!![0], mColorArray!![1], Shader.TileMode.MIRROR) } + Log.d(TAG, mRectL.toString() + "," + mRectT.toString()) + Log.d(TAG, mRectF.toString() + "," + "width:" + measuredWidth.toString() + "," + "PaddingLeft:" + getPaddingLeft().toString()) + + } override fun onDraw(canvas: Canvas?) { super.onDraw(canvas) canvas?.let { - mRectF?.let { it1 -> it.drawArc(it1, 0.0f, 360.0f, false, mBackPaint) } - mRectF?.let { it1 -> it.drawArc(it1, 275.0f, - (360 * mProgress / 100).toFloat(), false, mProgPaint) } + mRectF?.let { it1 -> it.drawArc(it1, 0.0f, 360.0f, false, mBackPaint) } + mRectF?.let { it1 -> + it.drawArc(it1, 275.0f, + (360 * mProgress / 100).toFloat(), false, mProgPaint) + } } } @@ -95,7 +107,7 @@ class CircularProgressView @JvmOverloads constructor( * 获取当前进度 * @return 当前进度(0-100) */ - fun getProgress() : Int{ + fun getProgress(): Int { return mProgress } @@ -103,7 +115,7 @@ class CircularProgressView @JvmOverloads constructor( * 设置当前进度 * @param progress 当前进度(0-100) */ - fun setProgress(progress : Int){ + fun setProgress(progress: Int) { mProgress = progress invalidate() } @@ -113,12 +125,12 @@ class CircularProgressView @JvmOverloads constructor( * @param progress 当前进度(0-100) * @param animTime 动画时间(毫秒) */ - fun setProgress(progress : Int, animTime : Long){ - if (animTime<=0){ + fun setProgress(progress: Int, animTime: Long) { + if (animTime <= 0) { setProgress(progress) - } else{ + } else { val animator = ValueAnimator.ofInt(mProgress, progress) - animator.addUpdateListener{ + animator.addUpdateListener { mProgress = it.animatedValue as Int invalidate() } @@ -132,7 +144,7 @@ class CircularProgressView @JvmOverloads constructor( * 设置背景圆环宽度 * @param width 背景圆环宽度 */ - fun setBackWidth(width : Int){ + fun setBackWidth(width: Int) { mBackPaint.strokeWidth = width.toFloat() invalidate() } @@ -141,8 +153,8 @@ class CircularProgressView @JvmOverloads constructor( * 设置背景圆环颜色 * @param color 背景圆环颜色 */ - fun setBackColor(color : Int){ - mBackPaint.color = ContextCompat.getColor(context,color) + fun setBackColor(color: Int) { + mBackPaint.color = ContextCompat.getColor(context, color) invalidate() } @@ -150,39 +162,54 @@ class CircularProgressView @JvmOverloads constructor( * 设置进度圆环宽度 * @param width 进度圆环宽度 */ - fun setProgWidth(width : Int){ + fun setProgWidth(width: Int) { mProgPaint.strokeWidth = width.toFloat() invalidate() } /** - * 设置进度圆环颜色 + * 设置进度圆环渐变色起始色 * @param color 景圆环颜色 */ - fun setProgColor(color : Int){ - mProgPaint.color = ContextCompat.getColor(context,color) + fun setProgColor(color: Int) { + mProgPaint.color = ContextCompat.getColor(context, color) mProgPaint.shader = null invalidate() } - fun setProgColor(startColor : Int,endColor: Int){ - mColorArray = intArrayOf(ContextCompat.getColor(context,startColor),ContextCompat.getColor(context,endColor)) + + /** + * 渐变色结束色 + */ + fun setProgFirstColor(color: Int) { + mProgPaint.color = ContextCompat.getColor(context, color) + mProgPaint.shader = null + invalidate() + } + + + fun setProgColor(startColor: Int, endColor: Int) { + mColorArray = intArrayOf(ContextCompat.getColor(context, startColor), ContextCompat.getColor(context, endColor)) mColorArray?.let { - mProgPaint.shader = LinearGradient(0f, 0f, 0f, - getMeasuredWidth().toFloat(), it, null, Shader.TileMode.MIRROR) + if (mRectF != null) { + mProgPaint.shader = LinearGradient(0f, 0f, 0f, + getMeasuredWidth().toFloat(), mColorArray!![0], mColorArray!![1], Shader.TileMode.MIRROR) + } } + Log.d(TAG, "setProgColor:" + getMeasuredWidth().toString()) + } - fun setProgColor(colorArray : IntArray){ + fun setProgColor(colorArray: IntArray) { colorArray.let { - if(it.size<2){ + if (it.size < 2) { return } mColorArray = it.copyOf() - mColorArray?.let{ + mColorArray?.let { mProgPaint.shader = LinearGradient(0f, 0f, 0f, - getMeasuredWidth().toFloat(), it, null, Shader.TileMode.MIRROR) + getMeasuredWidth().toFloat(), it, null, Shader.TileMode.MIRROR) } } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/SteeringWheelView.java b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/SteeringWheelView.java new file mode 100644 index 0000000000..2a4734013b --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/SteeringWheelView.java @@ -0,0 +1,224 @@ +package com.mogo.eagle.core.function.hmi.ui.widget; + +import android.content.Context; +import android.util.AttributeSet; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.animation.LinearInterpolator; +import android.view.animation.RotateAnimation; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.annotation.UiThread; +import androidx.constraintlayout.widget.ConstraintLayout; + +import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo; +import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener; +import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotVehicleStateListener; +import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager; +import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotVehicleStateListenerManager; +import com.mogo.eagle.core.function.hmi.R; +import com.mogo.eagle.core.network.utils.Util; +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; +import com.mogo.eagle.core.utilcode.util.ThreadUtils; + +import org.jetbrains.annotations.NotNull; + +import chassis.Chassis; +import mogo.telematics.pad.MessagePad; +import mogo_msg.MogoReportMsg; + +import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS_P; + +/** + * @author Jing + * @description 方向盘 + * 方向盘跟随CAN数据做旋转 + * 档位随CAN数据做切换和高亮显示 + * @since: 4/7/22 + */ +public class SteeringWheelView extends ConstraintLayout { + private static final String TAG = "SteeringWheelView"; + private ImageView autopilotIV; + private TextView steeringTVL; + private TextView steeringTVR; + private TapPositionView tapPositionView; + private CircularProgressView steeringCircularV; + private RotateAnimation rotateAnimation; + private float fromDegrees = 0;//方向盘旋转起始位置 + + public SteeringWheelView(@NonNull Context context) { + super(context); + Log.d(TAG, "1"); + } + + public SteeringWheelView(@NonNull Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + Log.d(TAG, "2"); + LayoutInflater.from(context).inflate(R.layout.hmi_steering_wheel, this); + initView(); + CallerAutoPilotStatusListenerManager.INSTANCE.addListener(TAG, mGoAutopilotStatusListener); + CallerAutopilotVehicleStateListenerManager.INSTANCE.addListener(TAG, mIMoGoAutopilotVehicleStateListener); + } + + private void initView() { + autopilotIV = (ImageView) findViewById(R.id.autopilot_iv); + steeringTVL = findViewById(R.id.steering_tv_left); + steeringTVR = findViewById(R.id.steering_tv_right); + tapPositionView = findViewById(R.id.tap_position); + steeringCircularV = findViewById(R.id.steering_circular); + steeringCircularV.setBackWidth(8); + steeringCircularV.setBackColor(R.color.hmi_light_blue_00); + steeringCircularV.setProgColor(R.color.hmi_light_blue, R.color.hmi_dark_blue); + steeringCircularV.setProgress((int) (180 * 100) / 360, 1000); + } + + public SteeringWheelView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + Log.d(TAG, "3"); + } + + public SteeringWheelView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { + super(context, attrs, defStyleAttr, defStyleRes); + Log.d(TAG, "4"); + } + + private final IMoGoAutopilotStatusListener mGoAutopilotStatusListener = new IMoGoAutopilotStatusListener() { + @Override + public void onAutopilotArriveAtStation(@org.jetbrains.annotations.Nullable MessagePad.ArrivalNotification arrivalNotification) { + + } + + @Override + public void onAutopilotGuardian(@Nullable MogoReportMsg.MogoReportMessage guardianInfo) { + + } + + @Override + public void onAutopilotStatusResponse(@NotNull AutopilotStatusInfo autopilotStatusInfo) { + ThreadUtils.runOnUiThread(new Runnable() { + @Override + public void run() { + if (autopilotStatusInfo == null) return; + int state = autopilotStatusInfo.getState(); + CallerLogger.INSTANCE.d(M_BUS_P + TAG, "state = %s", state); + if (autopilotIV != null) { + Log.d(TAG, "autopilotIV != null"); + if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) { + + autopilotIV.setImageResource(R.drawable.bg_auto); + + } else if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE) { + autopilotIV.setImageResource(R.drawable.bg_auto_nor); + + } else if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE) { + autopilotIV.setImageResource(R.drawable.bg_auto_nor); + } + } else { + Log.d(TAG, "autopilotIV=null"); + } + } + }); + + } + + @Override + public void onAutopilotSNRequest() { + + } + }; + + private final IMoGoAutopilotVehicleStateListener mIMoGoAutopilotVehicleStateListener = new IMoGoAutopilotVehicleStateListener() { + /** + * 车辆转向灯 + * @param lightSwitch + */ + @Override + public void onAutopilotLightSwitchData(@org.jetbrains.annotations.Nullable Chassis.LightSwitch lightSwitch) { + Log.d(TAG, "车辆转向灯:" + lightSwitch.toString()); + } + + /** + * 刹车灯 + * @param brakeLight + */ + @Override + public void onAutopilotBrakeLightData(boolean brakeLight) { + Log.d(TAG, "刹车灯:" + String.valueOf(brakeLight)); + } + + /** + * 方向盘转向角 + * @param steering + */ + @Override + public void onAutopilotSteeringData(float steering) { + ThreadUtils.runOnUiThread(new Runnable() { + @Override + public void run() { + Log.d(TAG, "steering" + String.valueOf(steering)); + if (steeringTVL != null && steering < 0) { + steeringTVR.setVisibility(View.INVISIBLE); + steeringTVL.setVisibility(View.VISIBLE); + steeringTVL.setText(String.valueOf((int) steering) + "°"); + } else if (steeringTVR != null && steering >= 0) { + steeringTVL.setVisibility(View.INVISIBLE); + steeringTVR.setVisibility(View.VISIBLE); + steeringTVR.setText(String.valueOf((int) steering) + "°"); + } else { + Log.d(TAG, "onAutopilotSteeringData error"); + } + animationWithSteeringData(steering); + steeringCircularV.setProgress((int) (steering * 100) / 360, 1000); + } + }); + + } + + /** + * 档位 + * @param gear + */ + @Override + public void onAutopilotGearData(@NotNull Chassis.GearPosition gear) { + ThreadUtils.runOnUiThread(new Runnable() { + @Override + public void run() { + Log.d(TAG, "档位" + gear.toString()); + if (tapPositionView != null) { + tapPositionView.updateWithGear(gear); + } + } + }); + + } + }; + + /** + * 方向盘随CAN数据做方向和角度旋转 + * 参数1从哪一个旋转角度开始 + * 参数2:转到什么角度 + * 后4个参数用于设置围绕着旋转的圆的圆心在哪里 + * 参数3:肯定x轴坐标的类型,有ABSOLUT绝对坐标、RELATIVE_TO_SELF相对于自身坐标、RELATIVE_TO_PARENT相对于父控件的坐标 + * 参数4:x轴的值,0.5f代表是以自身这个控件的一半长度为x轴 + * 参数5:肯定y轴坐标的类型 + * 参数6:y轴的值,0.5f代表是以自身这个控件的一半长度为x轴 + * + * @param steering + */ + private void animationWithSteeringData(float steering) { + Log.d(TAG, "方向盘转动" + String.valueOf(steering)); + rotateAnimation = new RotateAnimation(fromDegrees, steering, + RotateAnimation.RELATIVE_TO_SELF, 0.5f, + RotateAnimation.RELATIVE_TO_SELF, 0.5f); + rotateAnimation.setDuration(1000);//旋转时长 + rotateAnimation.setFillAfter(true);//旋转后保持原状 + autopilotIV.clearAnimation(); + autopilotIV.startAnimation(rotateAnimation); + fromDegrees = steering; + } + +} diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/TapPositionView.java b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/TapPositionView.java new file mode 100644 index 0000000000..1a655e3660 --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/TapPositionView.java @@ -0,0 +1,80 @@ +package com.mogo.eagle.core.function.hmi.ui.widget; + +import android.content.Context; +import android.graphics.Color; +import android.util.AttributeSet; +import android.util.Log; +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.function.hmi.R; + +import org.jetbrains.annotations.NotNull; + +import chassis.Chassis; + +/** + * @author Jing + * @description 方向盘下方的档位 + * @since: 4/7/22 + */ +public class TapPositionView extends ConstraintLayout { + private static final String TAG = "TapPositionView"; + private TextView tabP; + private TextView tabR; + private TextView tabN; + private TextView tabD; + + public TapPositionView(Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + Log.d(TAG, "2"); + LayoutInflater.from(context).inflate(R.layout.hmi_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); + } + + public void updateWithGear(@NotNull Chassis.GearPosition gear) { + if (tabP != null && tabR != null && tabN != null && tabD != null) { + switch (gear) { + case GEAR_NONE: + tabP.setTextColor(Color.parseColor("#6E8EC9")); + tabR.setTextColor(Color.parseColor("#6E8EC9")); + tabN.setTextColor(Color.parseColor("#6E8EC9")); + tabD.setTextColor(Color.parseColor("#6E8EC9")); + break; + case GEAR_P: + tabP.setTextColor(Color.parseColor("#0043FF")); + tabR.setTextColor(Color.parseColor("#6E8EC9")); + tabN.setTextColor(Color.parseColor("#6E8EC9")); + tabD.setTextColor(Color.parseColor("#6E8EC9")); + break; + case GEAR_R: + tabR.setTextColor(Color.parseColor("#0043FF")); + tabP.setTextColor(Color.parseColor("#6E8EC9")); + tabN.setTextColor(Color.parseColor("#6E8EC9")); + tabD.setTextColor(Color.parseColor("#6E8EC9")); + break; + case GEAR_N: + tabN.setTextColor(Color.parseColor("#0043FF")); + tabR.setTextColor(Color.parseColor("#6E8EC9")); + tabP.setTextColor(Color.parseColor("#6E8EC9")); + tabD.setTextColor(Color.parseColor("#6E8EC9")); + break; + case GEAR_D: + tabD.setTextColor(Color.parseColor("#0043FF")); + tabN.setTextColor(Color.parseColor("#6E8EC9")); + tabR.setTextColor(Color.parseColor("#6E8EC9")); + tabP.setTextColor(Color.parseColor("#6E8EC9")); + break; + default: + break; + } + } + } +} diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainActivity.java b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainActivity.java index 3354db68a0..9f78069018 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainActivity.java +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainActivity.java @@ -18,7 +18,6 @@ import androidx.fragment.app.Fragment; import com.alibaba.android.arouter.launcher.ARouter; import com.mogo.commons.context.ContextHolderUtil; -import com.mogo.commons.debug.DebugConfig; import com.mogo.commons.mvp.BaseFragment; import com.mogo.commons.mvp.MvpActivity; import com.mogo.commons.mvp.MvpFragment; @@ -44,9 +43,7 @@ import com.mogo.map.uicontroller.IMogoMapUIController; import com.mogo.module.common.MogoApisHandler; import com.mogo.service.IMogoServiceApis; import com.mogo.service.fragmentmanager.FragmentStackTransactionListener; -import com.mogo.service.statusmanager.IMogoStatusChangedListener; import com.mogo.service.statusmanager.IMogoStatusManager; -import com.mogo.service.statusmanager.StatusDescriptor; import java.util.HashMap; import java.util.Map; @@ -59,7 +56,6 @@ import java.util.Map; */ public class MainActivity extends MvpActivity implements MainView, IMogoLocationListener, - IMogoStatusChangedListener, FragmentStackTransactionListener { protected static final String TAG = "MainActivity"; @@ -122,10 +118,12 @@ public class MainActivity extends MvpActivity implement super.onCreate(savedInstanceState); calculateStartTime(); ContextHolderUtil.holdContext(this); + // 加载模块 mPresenter.postLoadModuleMsg(); + // 监听网络状态 NetworkUtils.listenNetStrength(this); + // 浓雾预警 DisplayEffectsHelper.getInstance().init(clSpecialEffect); - mServiceApis.getStatusManagerApi().registerStatusChangedListener(TAG, StatusDescriptor.VR_MODE, this); mPresenter.checkPermission(this); } @@ -185,25 +183,23 @@ public class MainActivity extends MvpActivity implement listenerRegister.registerMarkerClickListener(EventDispatchCenter.getInstance()); } - if (DebugConfig.isMapBased()) { - EventDispatchCenter.getInstance().setMapLoadedCallback(() -> { - CallerLogger.INSTANCE.d(M_HMI + TAG, "map loaded." + Thread.currentThread().getName()); - // 延时加载其他模块 - getWindow().getDecorView().postDelayed(() -> { - loadOthersModules(); - loadFunctionFragment(); + EventDispatchCenter.getInstance().setMapLoadedCallback(() -> { + CallerLogger.INSTANCE.d(M_HMI + TAG, "map loaded." + Thread.currentThread().getName()); + // 延时加载其他模块 + getWindow().getDecorView().postDelayed(() -> { + loadOthersModules(); + loadFunctionFragment(); - // TODO 这里临时兼容进入VR模式 - MogoApisHandler.getInstance().getApis().getStatusManagerApi().setVrMode(TAG, true); - MogoMapListenerHandler.getInstance().onMapModeChanged(EnumMapUI.Type_VR); - }, 1000); - CallerLogger.INSTANCE.i(M_HMI + TAG, "App launch timer cost " + (System.currentTimeMillis() - start) + "ms"); - }); - loadFunctionMapView(); - } else { - loadOthersModules(); - } + // TODO 这里临时兼容进入VR模式,标记状态机。有些业务(OCH)会根据状态判断加载 + MogoApisHandler.getInstance().getApis().getStatusManagerApi().setVrMode(TAG, true); + // 设置地图样式 + MogoMapListenerHandler.getInstance().onMapModeChanged(EnumMapUI.MAP_STYLE_DAY_VR); + }, 1000); + CallerLogger.INSTANCE.i(M_HMI + TAG, "App launch timer cost " + (System.currentTimeMillis() - start) + "ms"); + }); + // 加载地图 + loadFunctionMapView(); } @Override @@ -264,7 +260,9 @@ public class MainActivity extends MvpActivity implement */ private void loadFunctionMapView() { MvpFragment fragmentHdMap = (MvpFragment) ARouter.getInstance().build(MoGoFragmentPaths.PATH_FRAGMENT_MAP).navigation(); - addFragment(fragmentHdMap, fragmentHdMap.getTagName(), R.id.module_main_id_map_fragment_container); + if (fragmentHdMap != null) { + addFragment(fragmentHdMap, fragmentHdMap.getTagName(), R.id.module_main_id_map_fragment_container); + } } @NonNull @@ -305,10 +303,6 @@ public class MainActivity extends MvpActivity implement } - protected boolean doWhenBackPressed() { - return false; - } - @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); @@ -346,18 +340,6 @@ public class MainActivity extends MvpActivity implement ProcessUtils.killAllBackgroundProcesses(); } - @Override - public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) { - if (descriptor == StatusDescriptor.VR_MODE) { - if (isTrue) { - clSpecialEffect.setVisibility(View.VISIBLE); - } else { - clSpecialEffect.setVisibility(View.GONE); - } - - } - } - @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainLauncherActivity.java b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainLauncherActivity.java index 9f89f76a81..c4a7e2b5aa 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainLauncherActivity.java +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainLauncherActivity.java @@ -7,13 +7,16 @@ import android.os.Bundle; import android.os.Handler; import android.os.Process; import android.text.TextUtils; +import android.widget.FrameLayout; import androidx.annotation.Nullable; import com.alibaba.android.arouter.launcher.ARouter; import com.mogo.commons.debug.DebugConfig; +import com.mogo.eagle.core.data.config.FunctionBuildConfig; import com.mogo.eagle.core.function.api.base.IMoGoFunctionProvider; import com.mogo.eagle.core.function.hmi.R; +import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; import com.mogo.service.intent.IMogoIntentListener; @@ -38,6 +41,13 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis @Override protected void initViews() { super.initViews(); + // 这里在初始化完GUI后,做一些个性化的定制 + // 小巴车的乘客屏幕 + if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode) && + AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) { + FrameLayout frameLayout = findViewById(R.id.module_main_id_map_fragment_container); + frameLayout.setPadding(0, 0, 700, 0); + } } @Override diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/monitoring/VehicleMonitoring.java b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/monitoring/VehicleMonitoring.java index b841092909..bca60eed1e 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/monitoring/VehicleMonitoring.java +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/monitoring/VehicleMonitoring.java @@ -14,7 +14,7 @@ import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; /** * @author liujing - * @description 车辆监控 + * @description 车辆监控,暂时隐藏该功能 * @since: 8/16/21 */ public class VehicleMonitoring implements Handler.Callback { @@ -34,31 +34,36 @@ public class VehicleMonitoring implements Handler.Callback { } public void vehicleCheck() { - if (AutopilotStatus == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) { - CallerLogger.INSTANCE.d(M_HMI + TAG, "自动驾驶中..."); - mHandler.sendEmptyMessageDelayed(AutopilotStatus, AUTO_CHECK_STATUS_DELAY); - } else { - CallerLogger.INSTANCE.d(M_HMI + TAG, "非自动驾驶状态"); - //非自动驾驶状态只展示一次 - mHandler.sendEmptyMessageDelayed(AutopilotStatus, MANUAL_CHECK_STATUS_DELAY); - } + //暂时隐藏自检功能 + /** + * + if (AutopilotStatus == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) { + CallerLogger.INSTANCE.d(M_HMI + TAG, "自动驾驶中..."); + mHandler.sendEmptyMessageDelayed(AutopilotStatus, AUTO_CHECK_STATUS_DELAY); + } else { + CallerLogger.INSTANCE.d(M_HMI + TAG, "非自动驾驶状态"); + //非自动驾驶状态只展示一次 + mHandler.sendEmptyMessageDelayed(AutopilotStatus, MANUAL_CHECK_STATUS_DELAY); + } + + */ } @Override public boolean handleMessage(Message msg) { - AutopilotStatus = CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState(); - switch (msg.what) { - case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING: - vehicleMonitor(); - mHandler.sendEmptyMessageDelayed(AutopilotStatus, AUTO_CHECK_STATUS_DELAY); - return true; - case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE: - case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE: - vehicleMonitor(); - mHandler.sendEmptyMessageDelayed(AutopilotStatus, MANUAL_CHECK_STATUS_DELAY); - return true; - default: - } +// AutopilotStatus = CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState(); +// switch (msg.what) { +// case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING: +// vehicleMonitor(); +// mHandler.sendEmptyMessageDelayed(AutopilotStatus, AUTO_CHECK_STATUS_DELAY); +// return true; +// case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE: +// case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE: +// vehicleMonitor(); +// mHandler.sendEmptyMessageDelayed(AutopilotStatus, MANUAL_CHECK_STATUS_DELAY); +// return true; +// default: +// } return false; } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/bus_shache_nor_daytime.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/bus_shache_nor_daytime.png new file mode 100644 index 0000000000..d16d1ce141 Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/bus_shache_nor_daytime.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_arrow_left_nor_daytime.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_arrow_left_nor_daytime.png new file mode 100644 index 0000000000..f35fc125c4 Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_arrow_left_nor_daytime.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_arrow_left_select_nor_daytime.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_arrow_left_select_nor_daytime.png new file mode 100644 index 0000000000..2e4b0cd003 Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_arrow_left_select_nor_daytime.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_arrow_right_nor_daytime.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_arrow_right_nor_daytime.png new file mode 100644 index 0000000000..67f7c5b0e9 Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_arrow_right_nor_daytime.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_arrow_right_select_nor_daytime.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_arrow_right_select_nor_daytime.png new file mode 100644 index 0000000000..0837df937c Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_arrow_right_select_nor_daytime.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/bg_auto.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/bg_auto.png new file mode 100644 index 0000000000..748625a43c Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/bg_auto.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/bg_auto_nor.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/bg_auto_nor.png new file mode 100644 index 0000000000..a9965aaf1f Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/bg_auto_nor.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/bg_steering_outer.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/bg_steering_outer.xml new file mode 100644 index 0000000000..f5e1da1a55 --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/bg_steering_outer.xml @@ -0,0 +1,13 @@ + + + + + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/bg_steering_wheel.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/bg_steering_wheel.xml new file mode 100644 index 0000000000..156cc4f0e0 --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/bg_steering_wheel.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/icon_in_steering.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/icon_in_steering.png new file mode 100644 index 0000000000..4545e67555 Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/icon_in_steering.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/streeing_wheel_rotate.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/streeing_wheel_rotate.xml new file mode 100644 index 0000000000..a883260939 --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/streeing_wheel_rotate.xml @@ -0,0 +1,18 @@ + + + + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable/brakelight_background_daytime.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable/brakelight_background_daytime.xml new file mode 100644 index 0000000000..6c257d12d7 --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable/brakelight_background_daytime.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/hmi_steering_wheel.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/hmi_steering_wheel.xml new file mode 100644 index 0000000000..a9548ff937 --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/hmi_steering_wheel.xml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/hmi_tap_position.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/hmi_tap_position.xml new file mode 100644 index 0000000000..5020791857 --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/hmi_tap_position.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/module_main_activity_main.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/module_main_activity_main.xml index ca5882f47d..df6c845ce0 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/module_main_activity_main.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/module_main_activity_main.xml @@ -13,11 +13,11 @@ android:layout_width="match_parent" android:layout_height="match_parent" /> + + android:layout_height="match_parent" /> + + + + + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_debug_setting.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_debug_setting.xml index 3ce43e5217..a1ff2860b7 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_debug_setting.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_debug_setting.xml @@ -450,116 +450,6 @@ android:orientation="vertical" android:visibility="gone"> - - - - -