增加了红绿灯面板界面实现

This commit is contained in:
tongchenfei
2020-12-10 17:59:08 +08:00
parent 089ea76a40
commit 9f7cd7eb6b
15 changed files with 277 additions and 116 deletions

View File

@@ -57,6 +57,7 @@ import com.mogo.module.extensions.utils.EntranceViewHolder;
import com.mogo.module.extensions.utils.NoMapTopViewShaderHelper;
import com.mogo.module.extensions.utils.TopViewAnimHelper;
import com.mogo.module.extensions.utils.TopViewNoLinkageAnimHelper;
import com.mogo.module.extensions.utils.TrafficLightPanelManager;
import com.mogo.module.share.manager.ServiceApisManager;
import com.mogo.service.IMogoServiceApis;
import com.mogo.service.analytics.IMogoAnalytics;
@@ -483,6 +484,8 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
e.printStackTrace();
}
});
TrafficLightPanelManager.getInstance().initPanel(mRootView);
}
private EditText etTimes;
@@ -494,6 +497,7 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
mUploadRoadCondition.setVisibility(View.GONE);
mWeatherContainer.setVisibility(View.GONE);
mMsgContainer.setVisibility(View.GONE);
mUserHeadImg.setVisibility(View.GONE);
tvExitVrMode.setVisibility(View.VISIBLE);
TopViewAnimHelper.getInstance().enterVrMode();
@@ -501,7 +505,7 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
showVrModeNaviView();
mNaviInfo = new VrModeNavInfoView(mRootView);
adasNoticeHelper.enterVrMode();
MogoApisHandler.getInstance().getApis().getAdasControllerApi().closeADAS();
TrafficLightPanelManager.getInstance().showNavPanel();
}
private void exitVrMode(){
@@ -509,6 +513,7 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
tvEnterVrMode.setVisibility(View.VISIBLE);
mMove2CurrentLocation.setVisibility(View.VISIBLE);
mUploadRoadCondition.setVisibility(View.VISIBLE);
mUserHeadImg.setVisibility(View.VISIBLE);
// mWeatherContainer.setVisibility(View.VISIBLE);
// mMsgContainer.setVisibility(View.VISIBLE);
@@ -518,8 +523,7 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
hideVrModeNaviView();
mNaviInfo = new NaviInfoView(mRootView);
adasNoticeHelper.exitVrMode();
MogoApisHandler.getInstance().getApis().getAdasControllerApi().showADAS();
TrafficLightPanelManager.getInstance().hideNavPanel();
}
private void debugCrashWarn(){
@@ -1220,6 +1224,8 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
}
mApis.getSocketManagerApi(getContext()).unregisterOnMessageListener(SEEK_HELP_NOTICE_NUM_MSG_TYPE, seekHelpNoticeListener);
}
TrafficLightPanelManager.getInstance().release();
}
private void showVrModeNaviView(){

View File

@@ -88,6 +88,8 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
Logger.d(TAG, "enterVrMode===" + isVrMode);
if (!isVrMode) {
isVrMode = true;
MogoApisHandler.getInstance().getApis().getAdasControllerApi().closeADAS();
IntentFilter filter = new IntentFilter("com.mogo.launcher.adas.app.biz");
filter.addAction("com.mogo.launcher.adas");
context.registerReceiver(adasReceiver, filter);
@@ -104,6 +106,7 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
Logger.d(TAG, "退出vr模式===" + isVrMode);
if (isVrMode) {
isVrMode = false;
MogoApisHandler.getInstance().getApis().getAdasControllerApi().showADAS();
handler.removeMessages(MSG_REFRESH_CAR_STRATEGY);
tvSelfSpeed.setVisibility(View.GONE);
tvTrafficLight.setVisibility(View.GONE);

View File

@@ -0,0 +1,83 @@
package com.mogo.module.extensions.utils;
import android.view.View;
import android.widget.TextView;
import androidx.constraintlayout.widget.Group;
import com.mogo.module.extensions.R;
import com.mogo.module.extensions.view.VerticalTrafficLightView;
import com.mogo.utils.logger.Logger;
/**
* 红绿灯面板管理类,控制各部分显示隐藏,同时控制限速、车速、红绿灯信息展示
* <p>
* 导航信息内容通过{@link com.mogo.module.extensions.navi.VrModeNavInfoView} 在{@link com.mogo.module.extensions.entrance.EntranceFragment}进行控制
* 此处仅控制导航信息的显示与隐藏
*
* @author tongchenfei
*/
public class TrafficLightPanelManager {
private static final String TAG = "TrafficLightPanelManager";
private TrafficLightPanelManager() {
}
private final static TrafficLightPanelManager INSTANCE = new TrafficLightPanelManager();
public static TrafficLightPanelManager getInstance() {
return INSTANCE;
}
private Group speedGroup, navGroup, extraGroup;
private TextView tvLimitSpeed;
private VerticalTrafficLightView turnAroundLight, turnLeftLight, straightLight, turnRightLight;
private boolean isInit = false;
public void initPanel(View root) {
speedGroup = root.findViewById(R.id.module_ext_id_group_navi_in_vr_speed);
navGroup = root.findViewById(R.id.module_ext_id_group_navi_in_vr_nav_info);
extraGroup = root.findViewById(R.id.module_ext_id_group_traffic_light_panel_extra);
tvLimitSpeed = root.findViewById(R.id.module_ext_id_tv_limit_speed);
turnAroundLight = root.findViewById(R.id.module_ext_id_traffic_light_turn_around);
turnLeftLight = root.findViewById(R.id.module_ext_id_traffic_light_turn_left);
straightLight = root.findViewById(R.id.module_ext_id_traffic_light_straight);
turnRightLight = root.findViewById(R.id.module_ext_id_traffic_light_turn_right);
isInit = true;
}
public void showNavPanel() {
if (!isInit) {
Logger.e(TAG, "nav panel 未初始化");
return;
}
extraGroup.setVisibility(View.VISIBLE);
speedGroup.setVisibility(View.VISIBLE);
// navGroup.setVisibility(View.VISIBLE);
tvLimitSpeed.setVisibility(View.VISIBLE);
}
public void hideNavPanel() {
if (!isInit) {
Logger.e(TAG, "nav panel 未初始化");
return;
}
extraGroup.setVisibility(View.GONE);
speedGroup.setVisibility(View.GONE);
// navGroup.setVisibility(View.GONE);
tvLimitSpeed.setVisibility(View.GONE);
}
public void release() {
isInit = false;
speedGroup = null;
navGroup = null;
extraGroup = null;
tvLimitSpeed = null;
turnAroundLight = null;
turnLeftLight = null;
straightLight = null;
turnRightLight = null;
}
}

View File

@@ -54,7 +54,6 @@ public class VerticalTrafficLightView extends ConstraintLayout {
public VerticalTrafficLightView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
LayoutInflater.from(context).inflate(R.layout.merge_vertical_traffic_light_in_vr, this);
initView();
TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.VerticalTrafficLightView, 0, 0);
int lightType = typedArray.getInt(R.styleable.VerticalTrafficLightView_iconRes, 0);
typedArray.recycle();
@@ -76,6 +75,7 @@ public class VerticalTrafficLightView extends ConstraintLayout {
iconRes = TURN_AROUND_ICON_RES;
break;
}
initView();
}
private void initView() {
@@ -84,6 +84,7 @@ public class VerticalTrafficLightView extends ConstraintLayout {
tvLeftTime = findViewById(R.id.module_ext_id_traffic_light_left_time);
tvLeftTimeUnit = findViewById(R.id.module_ext_id_traffic_light_left_time_unit);
groupLeftTime = findViewById(R.id.module_ext_id_group_left_time);
ivTrafficLight.setImageResource(iconRes[0]);
}
/**

View File

@@ -8,7 +8,8 @@
<gradient
android:startColor="#9C4F77D1"
android:centerColor="#68203784"
android:endColor="#68203784" />
android:endColor="#68203784"
android:angle="270"/>
<corners android:radius="@dimen/module_ext_navi_in_vr_bg_corner" />

View File

@@ -1,77 +1,112 @@
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout">
<View
android:id="@+id/module_ext_id_navi_in_vr_bg"
android:layout_width="@dimen/module_ext_navi_in_vr_width"
android:layout_height="@dimen/module_ext_navi_in_vr_height"
android:id="@+id/module_ext_id_navi_in_vr_bg"
android:background="@drawable/module_ext_navi_in_vr_bg"/>
android:background="@drawable/module_ext_navi_in_vr_bg" />
<View
android:id="@+id/module_ext_id_navi_in_vr_speed_bg"
android:layout_width="@dimen/module_ext_navi_in_vr_speed_bg_width"
android:layout_height="@dimen/module_ext_navi_in_vr_speed_bg_height"
android:background="@drawable/module_ext_navi_in_vr_speed_bg"
app:layout_constraintLeft_toLeftOf="@id/module_ext_id_navi_in_vr_bg"
app:layout_constraintTop_toTopOf="@id/module_ext_id_navi_in_vr_bg"
app:layout_constraintBottom_toBottomOf="@id/module_ext_id_navi_in_vr_bg"
app:layout_constraintRight_toRightOf="@id/module_ext_id_navi_in_vr_bg"/>
app:layout_constraintLeft_toLeftOf="@id/module_ext_id_navi_in_vr_bg"
app:layout_constraintRight_toRightOf="@id/module_ext_id_navi_in_vr_bg"
app:layout_constraintTop_toTopOf="@id/module_ext_id_navi_in_vr_bg" />
<View
android:id="@+id/module_ext_id_navi_in_vr_traffic_bg"
android:layout_width="@dimen/module_ext_navi_in_vr_speed_bg_width"
android:layout_height="@dimen/module_ext_navi_in_vr_traffic_bg_height"
android:layout_marginBottom="@dimen/module_ext_navi_in_vr_traffic_bg_margin_bottom"
android:background="@drawable/module_ext_navi_in_vr_traffic_bg"
app:layout_constraintLeft_toLeftOf="@id/module_ext_id_navi_in_vr_bg"
app:layout_constraintRight_toRightOf="@id/module_ext_id_navi_in_vr_bg"
app:layout_constraintBottom_toBottomOf="@id/module_ext_id_navi_in_vr_bg"
android:layout_marginBottom="@dimen/module_ext_navi_in_vr_traffic_bg_margin_bottom" />
<androidx.constraintlayout.widget.Group
android:id="@+id/module_ext_id_group_navi_in_vr_speed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:constraint_referenced_ids="module_ext_id_tv_speed,module_ext_id_tv_speed_unit"/>
app:layout_constraintLeft_toLeftOf="@id/module_ext_id_navi_in_vr_bg"
app:layout_constraintRight_toRightOf="@id/module_ext_id_navi_in_vr_bg" />
<TextView
android:id="@+id/module_ext_id_tv_speed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="78"
app:layout_constraintLeft_toLeftOf="@id/module_ext_id_navi_in_vr_bg"
app:layout_constraintTop_toTopOf="@id/module_ext_id_navi_in_vr_bg"
app:layout_constraintBottom_toTopOf="@id/module_ext_id_navi_in_vr_traffic_bg"
android:layout_marginStart="@dimen/module_ext_navi_in_vr_speed_margin_start"
android:text="78"
android:textColor="#fff"
android:textSize="@dimen/module_ext_navi_in_vr_speed_text_size"
android:textColor="#fff" />
app:layout_constraintBottom_toTopOf="@id/module_ext_id_navi_in_vr_traffic_bg"
app:layout_constraintLeft_toLeftOf="@id/module_ext_id_navi_in_vr_bg"
app:layout_constraintTop_toTopOf="@id/module_ext_id_navi_in_vr_bg" />
<TextView
android:id="@+id/module_ext_id_tv_speed_unit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/module_ext_navi_in_vr_speed_unit_margin_start"
android:text="km/h"
android:textSize="@dimen/module_ext_navi_in_vr_speed_unit_size"
android:textColor="#fff"
app:layout_constraintLeft_toRightOf="@id/module_ext_id_tv_speed"
android:textSize="@dimen/module_ext_navi_in_vr_speed_unit_size"
app:layout_constraintBaseline_toBaselineOf="@id/module_ext_id_tv_speed"
android:layout_marginStart="@dimen/module_ext_navi_in_vr_speed_unit_margin_start" />
app:layout_constraintLeft_toRightOf="@id/module_ext_id_tv_speed" />
<ImageView
android:id="@+id/module_map_id_navi_next_info_road_turn_icon_in_vr_mode"
android:layout_width="@dimen/module_ext_navi_in_vr_navi_icon_size"
android:layout_height="@dimen/module_ext_navi_in_vr_navi_icon_size"
android:src="@drawable/tc_11"
app:layout_constraintBottom_toTopOf="@id/module_ext_id_navi_in_vr_traffic_bg"
app:layout_constraintLeft_toLeftOf="@id/module_ext_id_navi_in_vr_bg"
app:layout_constraintTop_toTopOf="@id/module_ext_id_navi_in_vr_bg" />
<TextView
android:id="@+id/module_map_id_navi_next_info_distance_in_vr_mode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="200"
android:textColor="#f1f1f1"
android:textSize="@dimen/module_ext_navi_in_vr_next_info_txt_size"
app:layout_constraintLeft_toRightOf="@id/module_map_id_navi_next_info_road_turn_icon_in_vr_mode"
app:layout_constraintTop_toTopOf="@id/module_map_id_navi_next_info_road_turn_icon_in_vr_mode" />
<TextView
android:id="@+id/module_map_id_navi_next_info_distance_unit_in_vr_mode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="米"
android:textColor="#f1f1f1"
android:textSize="@dimen/module_ext_navi_in_vr_next_info_unit_size"
app:layout_constraintBaseline_toBaselineOf="@id/module_map_id_navi_next_info_distance_in_vr_mode"
app:layout_constraintLeft_toRightOf="@id/module_map_id_navi_next_info_distance_in_vr_mode" />
<TextView
android:id="@+id/module_map_id_navi_next_info_road_in_vr_mode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="北三环东路辅路"
android:textColor="#f1f1f1"
android:textSize="@dimen/module_ext_navi_in_vr_next_info_road_txt_size"
app:layout_constraintLeft_toLeftOf="@id/module_map_id_navi_next_info_distance_in_vr_mode"
app:layout_constraintTop_toBottomOf="@id/module_map_id_navi_next_info_distance_in_vr_mode" />
<TextView
android:id="@+id/module_ext_id_tv_limit_speed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/module_ext_navi_in_vr_limit_speed_margin_end"
android:background="@drawable/module_ext_vr_mode_limit_speed_bg"
android:gravity="center"
android:text="80"
android:textColor="#FF9CA8D8"
android:gravity="center"
android:textSize="@dimen/module_ext_navi_in_vr_limit_speed_text_size"
app:layout_constraintRight_toRightOf="@id/module_ext_id_navi_in_vr_bg"
app:layout_constraintTop_toTopOf="@id/module_ext_id_navi_in_vr_bg"
app:layout_constraintBottom_toTopOf="@id/module_ext_id_navi_in_vr_traffic_bg"
android:layout_marginEnd="@dimen/module_ext_navi_in_vr_limit_speed_margin_end" />
app:layout_constraintRight_toRightOf="@id/module_ext_id_navi_in_vr_bg"
app:layout_constraintTop_toTopOf="@id/module_ext_id_navi_in_vr_bg" />
<com.mogo.module.extensions.view.VerticalTrafficLightView
android:id="@+id/module_ext_id_traffic_light_turn_around"
@@ -80,8 +115,8 @@
android:layout_marginTop="@dimen/module_ext_navi_in_vr_traffic_light_margin_top"
app:iconRes="turnAround"
app:layout_constraintLeft_toLeftOf="@id/module_ext_id_navi_in_vr_traffic_bg"
app:layout_constraintTop_toTopOf="@id/module_ext_id_navi_in_vr_traffic_bg"
app:layout_constraintRight_toLeftOf="@id/module_ext_id_traffic_light_turn_left"/>
app:layout_constraintRight_toLeftOf="@id/module_ext_id_traffic_light_turn_left"
app:layout_constraintTop_toTopOf="@id/module_ext_id_navi_in_vr_traffic_bg" />
<com.mogo.module.extensions.view.VerticalTrafficLightView
android:id="@+id/module_ext_id_traffic_light_turn_left"
@@ -107,10 +142,32 @@
android:layout_height="wrap_content"
app:iconRes="turnRight"
app:layout_constraintLeft_toRightOf="@id/module_ext_id_traffic_light_straight"
app:layout_constraintTop_toTopOf="@id/module_ext_id_traffic_light_straight"
app:layout_constraintRight_toRightOf="@id/module_ext_id_navi_in_vr_traffic_bg" />
app:layout_constraintRight_toRightOf="@id/module_ext_id_navi_in_vr_traffic_bg"
app:layout_constraintTop_toTopOf="@id/module_ext_id_traffic_light_straight" />
<androidx.constraintlayout.widget.Group
android:id="@+id/module_ext_id_group_navi_in_vr_speed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:constraint_referenced_ids="module_ext_id_tv_speed,module_ext_id_tv_speed_unit"
android:visibility="gone"
tools:visibility="visible" />
<androidx.constraintlayout.widget.Group
android:id="@+id/module_ext_id_group_navi_in_vr_nav_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
app:constraint_referenced_ids="module_map_id_navi_next_info_road_turn_icon_in_vr_mode,module_map_id_navi_next_info_distance_in_vr_mode,module_map_id_navi_next_info_distance_unit_in_vr_mode,module_map_id_navi_next_info_road_in_vr_mode" />
<!-- 除了上面两个group以外的其他view的group方便整体控制显示隐藏不包含limitSpeed需要单独控制它的显示隐藏 -->
<androidx.constraintlayout.widget.Group
android:id="@+id/module_ext_id_group_traffic_light_panel_extra"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
app:constraint_referenced_ids="module_ext_id_navi_in_vr_bg,module_ext_id_navi_in_vr_speed_bg,module_ext_id_navi_in_vr_traffic_bg,module_ext_id_traffic_light_turn_left,module_ext_id_traffic_light_turn_around,module_ext_id_traffic_light_straight,module_ext_id_traffic_light_turn_right"
tools:visibility="visible" />
</merge>

View File

@@ -7,6 +7,8 @@
<androidx.constraintlayout.widget.Group
android:id="@+id/module_ext_id_group_left_time"
app:constraint_referenced_ids="module_ext_id_traffic_light_left_time,module_ext_id_traffic_light_left_time_unit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
tools:visibility="visible"/>

View File

@@ -16,6 +16,11 @@
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<include
layout="@layout/include_navi_in_vr"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageButton
android:id="@+id/module_entrance_id_move2_current_location"
android:layout_width="@dimen/module_ext_operation_panel_width"

View File

@@ -214,6 +214,10 @@
<!-- 仅在vr模式下有此内容仅增加了xhdpi对应的大小 -->
<dimen name="module_ext_navi_in_vr_width">464px</dimen>
<dimen name="module_ext_navi_in_vr_height">304px</dimen>
<dimen name="module_ext_navi_in_vr_navi_icon_size">100px</dimen>
<dimen name="module_ext_navi_in_vr_next_info_txt_size">60px</dimen>
<dimen name="module_ext_navi_in_vr_next_info_unit_size">48px</dimen>
<dimen name="module_ext_navi_in_vr_next_info_road_txt_size">26px</dimen>
<dimen name="module_ext_navi_in_vr_speed_bg_width">458px</dimen>
<dimen name="module_ext_navi_in_vr_speed_bg_height">298px</dimen>
<dimen name="module_ext_navi_in_vr_traffic_bg_height">140px</dimen>
@@ -233,4 +237,5 @@
<dimen name="module_ext_navi_in_vr_traffic_light_left_time_unit_size">21px</dimen>
<dimen name="module_ext_navi_in_vr_traffic_light_no_time_margin_top">21px</dimen>
</resources>