diff --git a/.idea/misc.xml b/.idea/misc.xml index 2db9aab721..47f1a4e1d4 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -4,7 +4,7 @@ - + diff --git a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/ic_kuwo.png b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/ic_kuwo.png new file mode 100644 index 0000000000..1198794e34 Binary files /dev/null and b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/ic_kuwo.png differ diff --git a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_auto_navi.png b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_auto_navi.png index acf89ddcf8..362fbdba37 100644 Binary files a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_auto_navi.png and b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_auto_navi.png differ 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 dd4f2dc187..1d9dc7439e 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 @@ -202,6 +202,7 @@ public class EntranceFragment extends MvpFragment { + handler.removeMessages(MSG_HIDE_LIMIT_SPEED); + + if (tvLimitSpeed.getVisibility() == View.GONE) { + tvLimitSpeed.setVisibility(View.VISIBLE); + } + tvLimitSpeed.setText(msg.value); + limitSpeed = Integer.parseInt(msg.value); + + handler.sendEmptyMessageDelayed(MSG_HIDE_LIMIT_SPEED, HIDE_LIMIT_SPEED_DELAY); + }); + } + } + } + + @Override + public void onLocationChanged(MogoLocation location) { + if (!isVrMode) { + return; + } + int speed = (int) (location.getSpeed() * 3.6F); + if (tvSelfSpeed != null) { + tvSelfSpeed.post(() -> { + if (tvSelfSpeed.getVisibility() == View.GONE) { + tvSelfSpeed.setVisibility(View.VISIBLE); + } + tvSelfSpeed.setText("" + speed); + }); + } + } + + @Override + public boolean handleMessage(Message msg) { + switch (msg.what) { + case MSG_HIDE_LIMIT_SPEED: + tvLimitSpeed.setVisibility(View.GONE); + return true; + case MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD: + if (!handler.hasMessages(MSG_HIDE_TRAFFIC_LIGHT_BY_OBU)) { + tvTrafficLight.setVisibility(View.GONE); + } + return true; + case MSG_HIDE_TRAFFIC_LIGHT_BY_OBU: + if (!handler.hasMessages(MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD)) { + tvTrafficLight.setVisibility(View.GONE); + } + return true; + default: + return false; + } } /** @@ -53,9 +154,12 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback { * * @author tongchenfei */ - private class AdasNoticeReceiver extends BroadcastReceiver{ + private class AdasNoticeReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { + if (!isVrMode) { + return; + } // todo 处理发给adas的事件, 主要处理逆向超车和obu行人碰撞 String id = intent.getStringExtra("v2x_warning_type"); if (id != null) { @@ -63,15 +167,67 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback { MogoApisHandler.getInstance().getApis().getEntranceButtonController().showLeftNoticeByType(IMogoEntranceButtonController.NOTICE_TYPE_PEOPLE_WARN, R.drawable.module_ext_people_warn, "前方注意行人"); } } + + int type = intent.getIntExtra("type", -1); + if (type == 2) { + // 红绿灯处理 + String data = intent.getStringExtra("data"); + if (data != null && !data.isEmpty()) { + try { + JSONObject jsonObject = new JSONObject(data); + String lightStatus = jsonObject.optString("lightStatus"); + String surplusTime = jsonObject.optString("surplusTime"); + if (!lightStatus.isEmpty() && !surplusTime.isEmpty()) { + handleObuTrafficLightInfo(lightStatus, surplusTime); + } else { + Logger.d(TAG, "红绿灯必要信息都为空,不做展示"); + } + } catch (Exception e) { + Logger.e(TAG, e, "解析adas数据异常"); + e.printStackTrace(); + } + } + } } } - private View generateNoticeView(int iconRes, String content) { - View view = LayoutInflater.from(context).inflate(R.layout.item_vr_left_notice, null); - ImageView icon = view.findViewById(R.id.module_ext_iv_left_notice_icon); - icon.setImageResource(iconRes); - TextView tvContent = view.findViewById(R.id.module_ext_vr_mode_left_notice_container); - tvContent.setText(content); - return view; + private void handleObuTrafficLightInfo(String lightStatus, String surplusTime) { + if (tvTrafficLight != null) { + handler.removeMessages(MSG_HIDE_TRAFFIC_LIGHT_BY_OBU); + handler.removeMessages(MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD); + drawTrafficLight(lightStatus, surplusTime); + handler.sendEmptyMessageDelayed(MSG_HIDE_TRAFFIC_LIGHT_BY_OBU, HIDE_TRAFFIC_LIGHT_DELAY); + } + } + + private void handleCloudTrafficLight(){ + if (tvTrafficLight != null && !handler.hasMessages(MSG_HIDE_TRAFFIC_LIGHT_BY_OBU)) { + handler.removeMessages(MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD); + // todo drawTrafficLight + handler.sendEmptyMessageDelayed(MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD, + HIDE_TRAFFIC_LIGHT_DELAY); + } + } + + private void drawTrafficLight(String lightStatus, String surplusTime) { + tvTrafficLight.post(() -> { + if (tvTrafficLight.getVisibility() == View.GONE) { + tvTrafficLight.setVisibility(View.VISIBLE); + } + // todo 设置字体颜色、背景颜色、leftDrawable + switch (lightStatus) { + case "Y": + // 黄灯 + break; + case "R": + // 红灯 + break; + default: + // 默认绿灯 + break; + } + tvTrafficLight.setText(surplusTime + "S"); + Logger.d(TAG, "展示红绿灯信息: " + lightStatus + " time: " + surplusTime); + }); } } diff --git a/modules/mogo-module-extensions/src/main/res/drawable/module_ext_vr_mode_speed_red_bg.xml b/modules/mogo-module-extensions/src/main/res/drawable/module_ext_vr_mode_speed_red_bg.xml new file mode 100644 index 0000000000..9b599f0e63 --- /dev/null +++ b/modules/mogo-module-extensions/src/main/res/drawable/module_ext_vr_mode_speed_red_bg.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/modules/mogo-module-extensions/src/main/res/drawable/module_ext_vr_mode_speed_white_bg.xml b/modules/mogo-module-extensions/src/main/res/drawable/module_ext_vr_mode_speed_white_bg.xml new file mode 100644 index 0000000000..84230c5a05 --- /dev/null +++ b/modules/mogo-module-extensions/src/main/res/drawable/module_ext_vr_mode_speed_white_bg.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/modules/mogo-module-extensions/src/main/res/drawable/module_ext_vr_mode_traffic_light_green_bg.xml b/modules/mogo-module-extensions/src/main/res/drawable/module_ext_vr_mode_traffic_light_green_bg.xml new file mode 100644 index 0000000000..3c907981c6 --- /dev/null +++ b/modules/mogo-module-extensions/src/main/res/drawable/module_ext_vr_mode_traffic_light_green_bg.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + \ No newline at end of file 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 a051178c81..1667f2a694 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 @@ -14,8 +14,7 @@ + android:layout_height="wrap_content" /> @@ -102,17 +101,17 @@ + android:background="@drawable/module_ext_dw_upload_road_condition_bkg" + android:gravity="center" + android:text="VR" + android:textColor="#fff" + android:textSize="@dimen/module_ext_enter_vr_mode_text_size" + app:layout_constraintBottom_toTopOf="@+id/module_entrance_id_move2_current_location" + app:layout_constraintRight_toRightOf="@+id/module_entrance_id_move2_current_location" /> + android:textSize="@dimen/module_ext_exit_vr_mode_text_size" + android:visibility="gone" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintRight_toRightOf="parent" /> + app:layout_constraintLeft_toLeftOf="parent" /> + + app:layout_constraintLeft_toRightOf="@+id/module_ext_vr_mode_left_notice_container" + app:layout_goneMarginLeft="@dimen/module_common_shadow_width_pos"> + + + + + +