diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java index dbc577319b..fb5aaf01ba 100644 --- a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java +++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java @@ -13,6 +13,7 @@ import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.Button; +import android.widget.CheckedTextView; import android.widget.EditText; import android.widget.FrameLayout; import android.widget.ImageButton; @@ -67,6 +68,8 @@ import com.mogo.module.extensions.utils.TopViewAnimHelper; import com.mogo.module.extensions.utils.TopViewNoLinkageAnimHelper; import com.mogo.module.share.manager.ServiceApisManager; import com.mogo.service.IMogoServiceApis; +import com.mogo.service.adas.IMogoAdasOCHCallback; +import com.mogo.service.adas.entity.AdasOCHData; import com.mogo.service.analytics.IMogoAnalytics; import com.mogo.service.cloud.socket.IMogoOnMessageListener; import com.mogo.service.entrance.ButtonIndex; @@ -205,6 +208,7 @@ public class EntranceFragment extends MvpFragment { + ctvAutopilotStatus.setChecked(isInAutopilot); + }); + } + + private void autopilotStatusClick() { + EntranceViewHolder.getInstance().entranceAutopilotStatusClick(); + } + private int debugPanelClickCount = 0; private long lastDebugPanelClickTime = 0; @@ -1368,4 +1399,18 @@ public class EntranceFragment extends MvpFragment sButtons = new HashMap<>(); + private static final Map< ButtonIndex, TextView > sButtons = new HashMap<>(); public static void save( ButtonIndex index, TextView btn ) { sButtons.put( index, btn ); diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/utils/EntranceViewHolder.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/utils/EntranceViewHolder.java index 4d1de4513d..eb64124d8f 100644 --- a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/utils/EntranceViewHolder.java +++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/utils/EntranceViewHolder.java @@ -1,5 +1,7 @@ package com.mogo.module.extensions.utils; +import static com.mogo.service.entrance.IMogoEntranceButtonController.NOTICE_TYPE_SEEK_HELP; + import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -10,6 +12,7 @@ import android.widget.TextView; import com.mogo.module.common.MogoApisHandler; import com.mogo.module.extensions.R; import com.mogo.module.extensions.bean.BottomLayerViewWrapper; +import com.mogo.service.entrance.IMogoEntranceAutopilotStatusClickListener; import com.mogo.service.windowview.IMogoEntranceViewListener; import com.mogo.utils.logger.Logger; @@ -17,20 +20,20 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import static com.mogo.service.entrance.IMogoEntranceButtonController.NOTICE_TYPE_SEEK_HELP; - /** * 入口页view管理 + * * @author tongchenfei */ public class EntranceViewHolder { private static final String TAG = "EntranceViewHolder"; - private List preAddView = new ArrayList<>(); - private List leftFeaturePreAddView = new ArrayList<>(); - private View preAddLeftNoticeView = null; - private EntranceViewHolder(){} + + private EntranceViewHolder() { + } + private volatile static EntranceViewHolder instance = null; - public static EntranceViewHolder getInstance(){ + + public static EntranceViewHolder getInstance() { if (instance == null) { synchronized (EntranceViewHolder.class) { if (instance == null) { @@ -40,13 +43,18 @@ public class EntranceViewHolder { } return instance; } + + private final List preAddView = new ArrayList<>(); + private final List leftFeaturePreAddView = new ArrayList<>(); + private View preAddLeftNoticeView = null; + private ViewGroup rootViewGroup = null; private ViewGroup featureViewGroup = null; private ViewGroup leftNoticeContainer = null; public void initRootViewGroup(View rootView) { Logger.i(TAG, "initRootViewGroup=="); - if(rootView instanceof ViewGroup) { + if (rootView instanceof ViewGroup) { Logger.d(TAG, "initRootViewGroup 赋值"); rootViewGroup = (ViewGroup) rootView.getParent(); leftNoticeContainer = @@ -82,12 +90,12 @@ public class EntranceViewHolder { Logger.d(TAG, "addBottomLayerView, rootViewGroup is null: " + (rootViewGroup == null) + "\n x: " + x + ", y: " + y); BottomLayerViewWrapper wrapper = new BottomLayerViewWrapper(view, x, y); - if(rootViewGroup == null) { - if(!preAddView.contains(wrapper)) { + if (rootViewGroup == null) { + if (!preAddView.contains(wrapper)) { preAddView.add(wrapper); } - }else{ - if(!containView(view)) { + } else { + if (!containView(view)) { realAddView(wrapper); } } @@ -96,7 +104,7 @@ public class EntranceViewHolder { private boolean containView(View view) { int count = rootViewGroup.getChildCount(); for (int i = 0; i < count; i++) { - if(rootViewGroup.getChildAt(i).equals(view)){ + if (rootViewGroup.getChildAt(i).equals(view)) { return true; } } @@ -106,7 +114,7 @@ public class EntranceViewHolder { private boolean containFeatureView(View view) { int count = featureViewGroup.getChildCount(); for (int i = 0; i < count; i++) { - if(featureViewGroup.getChildAt(i).equals(view)){ + if (featureViewGroup.getChildAt(i).equals(view)) { return true; } } @@ -116,7 +124,7 @@ public class EntranceViewHolder { /** * 使用的时候需要预先判断rootViewGroup是否为空,本方法默认rootViewGroup不为空 */ - private void realAddView(BottomLayerViewWrapper wrapper){ + private void realAddView(BottomLayerViewWrapper wrapper) { FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); @@ -145,10 +153,10 @@ public class EntranceViewHolder { Logger.d(TAG, "addLeftFeatureView==" + view); if (featureViewGroup == null) { // 先缓存起来,等待时机加载 - if(!leftFeaturePreAddView.contains(view)) { + if (!leftFeaturePreAddView.contains(view)) { leftFeaturePreAddView.add(view); } - }else{ + } else { // 直接加载 if (!containFeatureView(view)) { featureViewGroup.addView(view); @@ -171,7 +179,7 @@ public class EntranceViewHolder { public void showLeftNoticeView(View view) { - if(MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) { + if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) { if (leftNoticeContainer != null) { realShowLeftNoticeView(view); } else { @@ -181,7 +189,7 @@ public class EntranceViewHolder { } public void hideLeftNoticeView(View view) { - if(MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) { + if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) { if (preAddLeftNoticeView != null && preAddLeftNoticeView == view) { preAddLeftNoticeView = null; } @@ -191,7 +199,7 @@ public class EntranceViewHolder { } } - public void forceHideNoticeView(){ + public void forceHideNoticeView() { for (IMogoEntranceViewListener listener : listeners) { listener.onViewRemoved(currentShowNoticeType); } @@ -203,8 +211,9 @@ public class EntranceViewHolder { } private int currentShowNoticeType = 0; - public void showLeftNoticeByType(int noticeType, int iconRes, String content){ - if(MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) { + + public void showLeftNoticeByType(int noticeType, int iconRes, String content) { + if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) { if (currentShowNoticeType != noticeType && currentShowNoticeType != 0) { for (IMogoEntranceViewListener listener : listeners) { listener.onViewRemoved(currentShowNoticeType); @@ -221,21 +230,21 @@ public class EntranceViewHolder { } public void hideLeftNoticeByType(int noticeType) { - if(MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) { + if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) { if (currentShowNoticeType == noticeType) { forceHideNoticeView(); } } } - private View generateNoticeViewByType(int noticeType,int iconRes, String content) { + private View generateNoticeViewByType(int noticeType, int iconRes, String content) { View view = LayoutInflater.from(leftNoticeContainer.getContext()).inflate(R.layout.item_vr_left_notice, leftNoticeContainer, false); ImageView icon = view.findViewById(R.id.module_ext_iv_left_notice_icon); if (noticeType == NOTICE_TYPE_SEEK_HELP) { // 自车求助,是橘色的背景 icon.setBackgroundResource(R.drawable.module_ext_left_notice_icon_orange_bg); - }else{ + } else { // 其他是红色背景 icon.setBackgroundResource(R.drawable.module_ext_left_notice_icon_red_bg); } @@ -245,7 +254,7 @@ public class EntranceViewHolder { return view; } - private void realShowLeftNoticeView(View view){ + private void realShowLeftNoticeView(View view) { leftNoticeContainer.setVisibility(View.VISIBLE); leftNoticeContainer.removeAllViews(); leftNoticeContainer.addView(view); @@ -260,7 +269,8 @@ public class EntranceViewHolder { leftNoticeContainer.setVisibility(View.GONE); } - private List listeners = new ArrayList<>(); + private final List listeners = new ArrayList<>(); + private final List btnClickListeners = new ArrayList<>(); public void addEntranceViewListener(IMogoEntranceViewListener listener) { listeners.add(listener); @@ -270,7 +280,21 @@ public class EntranceViewHolder { listeners.remove(listener); } - public void release(){ + public void addEntranceAutopilotStatusClickListener(IMogoEntranceAutopilotStatusClickListener listener) { + btnClickListeners.add(listener); + } + + public void removeEntranceAutopilotStatusClickListener(IMogoEntranceAutopilotStatusClickListener listener) { + btnClickListeners.remove(listener); + } + + public void entranceAutopilotStatusClick() { + for (IMogoEntranceAutopilotStatusClickListener listener : btnClickListeners) { + listener.click(); + } + } + + public void release() { rootViewGroup = null; featureViewGroup = null; leftNoticeContainer = null; diff --git a/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_ic_autopilot.png b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_ic_autopilot.png new file mode 100644 index 0000000000..be978145dc Binary files /dev/null and b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_ic_autopilot.png differ diff --git a/modules/mogo-module-extensions/src/main/res/drawable/module_mogo_autopilot_status_bg.xml b/modules/mogo-module-extensions/src/main/res/drawable/module_mogo_autopilot_status_bg.xml new file mode 100644 index 0000000000..b5596fad13 --- /dev/null +++ b/modules/mogo-module-extensions/src/main/res/drawable/module_mogo_autopilot_status_bg.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_entrance.xml b/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_entrance.xml index 9e5f2ceb3e..801c96f21f 100644 --- a/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_entrance.xml +++ b/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_entrance.xml @@ -6,6 +6,26 @@ android:layout_width="match_parent" android:layout_height="match_parent"> + + 36px 50px 60px + + 460px + 140px + 40px + 530px + 92px + 44px \ No newline at end of file diff --git a/modules/mogo-module-extensions/src/main/res/values/dimens.xml b/modules/mogo-module-extensions/src/main/res/values/dimens.xml index eeb585d868..8e2ae71b16 100644 --- a/modules/mogo-module-extensions/src/main/res/values/dimens.xml +++ b/modules/mogo-module-extensions/src/main/res/values/dimens.xml @@ -251,4 +251,11 @@ 35px 38px + 460px + 140px + 40px + 530px + 92px + 44px + \ No newline at end of file diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/dispatch/DispatchAutoPilotManager.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/dispatch/DispatchAutoPilotManager.java index 3c6284abb4..b4d884d6ae 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/dispatch/DispatchAutoPilotManager.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/dispatch/DispatchAutoPilotManager.java @@ -9,6 +9,7 @@ import android.location.Location; import android.os.Handler; import android.os.Message; +import com.mogo.cloud.commons.utils.CoordinateUtils; import com.mogo.map.MogoLatLng; import com.mogo.map.location.MogoLocation; import com.mogo.map.navi.IMogoCarLocationChangedListener2; @@ -16,16 +17,21 @@ import com.mogo.module.common.MogoApisHandler; import com.mogo.module.service.dispatch.bean.DispatchAdasAutoPilotLocReceiverBean; import com.mogo.module.service.dispatch.model.DispatchServiceModel; import com.mogo.module.service.dispatch.model.IDispatch; +import com.mogo.service.IMogoServiceApis; import com.mogo.service.adas.IMogoAdasOCHCallback; import com.mogo.service.adas.RemoteControlAutoPilotParameters; import com.mogo.service.adas.entity.AdasOCHData; -import com.mogo.service.cloud.socket.IMogoOnMessageListener; +import com.mogo.service.connection.IMogoOnMessageListener; +import com.mogo.service.entrance.IMogoEntranceAutopilotStatusClickListener; import com.mogo.utils.logger.Logger; +import java.util.ArrayList; +import java.util.List; + //负责监听自动驾驶状态并进行状态上报,自动驾驶路线上报,接收调度指令展示指令弹窗 public class DispatchAutoPilotManager implements IMogoOnMessageListener , IDispatchRemindClickListener - , IMogoCarLocationChangedListener2, IMogoAdasOCHCallback { + , IMogoCarLocationChangedListener2, IMogoAdasOCHCallback, IMogoEntranceAutopilotStatusClickListener { private static final String TAG = "DispatchAutoPilotManager"; private static volatile DispatchAutoPilotManager instance; @@ -40,6 +46,10 @@ public class DispatchAutoPilotManager implements IMogoOnMessageListener wayLatLon = new ArrayList<>(); + for (MogoLatLng mogoLatLng : receiverBean.getStopsList()) { + wayLatLon.add(new RemoteControlAutoPilotParameters.AutoPilotLonLat(mogoLatLng.lat, mogoLatLng.lon)); + } + currentAutopilot.wayLatLons = wayLatLon; + currentAutopilot.startLatLon = new RemoteControlAutoPilotParameters.AutoPilotLonLat(receiverBean.getStartLat(), receiverBean.getStartLon()); + currentAutopilot.endLatLon = new RemoteControlAutoPilotParameters.AutoPilotLonLat(receiverBean.getEndLat(), receiverBean.getEndLon()); + currentAutopilot.vehicleType = 10; + Logger.d(TAG, "开启自动驾驶====" + currentAutopilot); + mApis.getAdasControllerApi().aiCloudToAdasData(currentAutopilot); + } + @Override public void cancel(boolean manualTrigger) { dispatchDialogManager.releaseDialog(); @@ -164,6 +187,40 @@ public class DispatchAutoPilotManager implements IMogoOnMessageListener()); this.receiverBean = adasAutoPilotLocReceiverBean; DispatchDialogManager.getInstance(mContext).showDialog(adasAutoPilotLocReceiverBean); } @@ -185,7 +242,7 @@ public class DispatchAutoPilotManager implements IMogoOnMessageListener()); this.receiverBean = adasAutoPilotLocReceiverBean; DispatchDialogManager.getInstance(mContext).showDialog(adasAutoPilotLocReceiverBean); } @@ -196,7 +253,7 @@ public class DispatchAutoPilotManager implements IMogoOnMessageListener()); this.receiverBean = adasAutoPilotLocReceiverBean; DispatchDialogManager.getInstance(mContext).showDialog(adasAutoPilotLocReceiverBean); } @@ -214,15 +271,4 @@ public class DispatchAutoPilotManager implements IMogoOnMessageListener stopsList; - public DispatchAdasAutoPilotLocReceiverBean(int source, int type, String poiId, double startLat, double startLon, String startLocAddress, double endLat, double endLon, String endLocAddress, String taskTime, String flightInfo, String taskInfo, long systemTime) { + public DispatchAdasAutoPilotLocReceiverBean(int source, int type, String poiId, double startLat, double startLon, String startLocAddress, double endLat, double endLon, String endLocAddress, String taskTime, String flightInfo, String taskInfo, long systemTime, List stopsList) { this.source = source; this.type = type; this.poiId = poiId; @@ -38,6 +43,7 @@ public class DispatchAdasAutoPilotLocReceiverBean { this.flightInfo = flightInfo; this.taskInfo = taskInfo; this.systemTime = systemTime; + this.stopsList = stopsList; } public int getSource() { @@ -144,6 +150,14 @@ public class DispatchAdasAutoPilotLocReceiverBean { this.systemTime = systemTime; } + public List getStopsList() { + return stopsList; + } + + public void setStopsList(List stopsList) { + this.stopsList = stopsList; + } + @Override public String toString() { return "DispatchAdasAutoPilotLocReceiverBean{" + @@ -160,6 +174,7 @@ public class DispatchAdasAutoPilotLocReceiverBean { ", flightInfo='" + flightInfo + '\'' + ", taskInfo='" + taskInfo + '\'' + ", systemTime=" + systemTime + + ", stopsList=" + stopsList + '}'; } } diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/entrance/IMogoEntranceAutopilotStatusClickListener.java b/services/mogo-service-api/src/main/java/com/mogo/service/entrance/IMogoEntranceAutopilotStatusClickListener.java new file mode 100644 index 0000000000..d42a712fdf --- /dev/null +++ b/services/mogo-service-api/src/main/java/com/mogo/service/entrance/IMogoEntranceAutopilotStatusClickListener.java @@ -0,0 +1,6 @@ +package com.mogo.service.entrance; + +public interface IMogoEntranceAutopilotStatusClickListener { + + void click(); +} diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/entrance/IMogoEntranceButtonController.java b/services/mogo-service-api/src/main/java/com/mogo/service/entrance/IMogoEntranceButtonController.java index bebd0cdd4d..eeaaf8c89e 100644 --- a/services/mogo-service-api/src/main/java/com/mogo/service/entrance/IMogoEntranceButtonController.java +++ b/services/mogo-service-api/src/main/java/com/mogo/service/entrance/IMogoEntranceButtonController.java @@ -68,10 +68,11 @@ public interface IMogoEntranceButtonController extends IProvider { * @param index * @return */ - TextView getButton( ButtonIndex index ); + TextView getButton(ButtonIndex index); /** * 添加低层级view,使用ViewGroup.addView(v,0)实现 + * * @param view 将要添加的view */ void addBottomLayerView(View view); @@ -79,65 +80,89 @@ public interface IMogoEntranceButtonController extends IProvider { /** * 添加低层级view,使用ViewGroup.addView(v,0)实现 * 可指定x,y位置 + * * @param view 将要添加的view - * @param x leftMargin - * @param y topMargin + * @param x leftMargin + * @param y topMargin */ void addBottomLayerView(View view, int x, int y); /** * 移除对应的底层view + * * @param view 待移除view */ void removeBottomLayerView(View view); /** * 添加左下角功能View,按顺序添加到最底端 + * * @param view 待添加view */ void addLeftFeatureView(View view); /** * 移除左下角功能按钮 + * * @param view 待移除view */ void removeLeftFeatureView(View view); /** * 设置vr模式下,左下角提示view + * * @param view 目前是adas提示和求助 */ void showLeftNoticeView(View view); /** * 隐藏vr模式下,左下角提示view,需要与{@link #showLeftNoticeView(View)}成对使用 + * * @param view 待隐藏view */ void hideLeftNoticeView(View view); /** * 根据noticeType添加左侧提示 + * * @param noticeType {@link #NOTICE_TYPE_SUDDENLY_BREAK}... - * @param iconRes 本地 icon res - * @param content 提示内容 + * @param iconRes 本地 icon res + * @param content 提示内容 */ void showLeftNoticeByType(int noticeType, int iconRes, String content); /** * 移除noticeType,需要与{@link #showLeftNoticeByType(int, int, String)}成对使用 + * * @param noticeType {@link #NOTICE_TYPE_SUDDENLY_BREAK}... */ void hideLeftNoticeByType(int noticeType); /** * 添加view状态回调监听 + * * @param listener 回调监听 */ void addEntranceViewListener(IMogoEntranceViewListener listener); /** * 移除view状态回调监听 + * * @param listener 回调监听 */ void removeEntranceViewListener(IMogoEntranceViewListener listener); + + /** + * 添加entrance 自动驾驶状态监听 + * + * @param listener {@link IMogoEntranceAutopilotStatusClickListener} + */ + void addEntranceAutopilotStatusClickListener(IMogoEntranceAutopilotStatusClickListener listener); + + /** + * 移除entrance 自动驾驶状态监听 + * + * @param listener {@link IMogoEntranceAutopilotStatusClickListener} + */ + void removeEntranceAutopilotStatusClickListener(IMogoEntranceAutopilotStatusClickListener listener); }