diff --git a/.idea/misc.xml b/.idea/misc.xml index 3b62eef43d..f4d5deeca6 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -4,7 +4,7 @@ - + diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/view/VerticalTrafficLightView.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/view/VerticalTrafficLightView.java new file mode 100644 index 0000000000..417309fc64 --- /dev/null +++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/view/VerticalTrafficLightView.java @@ -0,0 +1,138 @@ +package com.mogo.module.extensions.view; + +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.Color; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.IntDef; +import androidx.constraintlayout.widget.ConstraintLayout; +import androidx.constraintlayout.widget.Group; + +import com.mogo.module.extensions.R; +import com.mogo.utils.logger.Logger; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * vr模式下的纵向显示的红绿灯封装 + * + * @author tongchenfei + */ +public class VerticalTrafficLightView extends ConstraintLayout { + private static final String TAG = "VerticalTrafficLightView"; + public static final int TRAFFIC_LIGHT_COLOR_GRAY = 0; + public static final int TRAFFIC_LIGHT_COLOR_RED = 1; + public static final int TRAFFIC_LIGHT_COLOR_YELLOW = 2; + public static final int TRAFFIC_LIGHT_COLOR_GREEN = 3; + + private ImageView ivTrafficLight, ivNoLeftTime; + private TextView tvLeftTime, tvLeftTimeUnit; + private Group groupLeftTime; + + private static final int[] TURN_AROUND_ICON_RES = new int[]{R.drawable.module_ext_dw_traffic_turn_around_gray, R.drawable.module_ext_dw_traffic_turn_around_red, R.drawable.module_ext_dw_traffic_turn_around_yellow, R.drawable.module_ext_dw_traffic_turn_around_green}; + private static final int[] TURN_LEFT_ICON_RES = new int[]{R.drawable.module_ext_dw_traffic_turn_left_gray, R.drawable.module_ext_dw_traffic_turn_left_red, R.drawable.module_ext_dw_traffic_turn_left_yellow, R.drawable.module_ext_dw_traffic_turn_left_green}; + private static final int[] STRAIGHT_ICON_RES = new int[]{R.drawable.module_ext_dw_traffic_straight_gray, R.drawable.module_ext_dw_traffic_straight_red, R.drawable.module_ext_dw_traffic_straight_yellow, R.drawable.module_ext_dw_traffic_straight_green}; + private static final int[] TURN_RIGHT_ICON_RES = new int[]{R.drawable.module_ext_dw_traffic_turn_right_gray, R.drawable.module_ext_dw_traffic_turn_right_red, R.drawable.module_ext_dw_traffic_turn_right_yellow, R.drawable.module_ext_dw_traffic_turn_right_green}; + + private final int[] iconRes; + private final int[] colorRes = new int[]{-1, Color.parseColor("#F63A35"), Color.parseColor("#F63A35"), Color.parseColor("#11FF89")}; + + public VerticalTrafficLightView(Context context) { + this(context, null); + } + + public VerticalTrafficLightView(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + 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(); + switch (lightType) { + case 1: + // turn left + iconRes = TURN_LEFT_ICON_RES; + break; + case 2: + // straight + iconRes = STRAIGHT_ICON_RES; + break; + case 3: + // turn right + iconRes = TURN_RIGHT_ICON_RES; + break; + default: + // turn around + iconRes = TURN_AROUND_ICON_RES; + break; + } + } + + private void initView() { + ivTrafficLight = findViewById(R.id.module_ext_id_traffic_light_icon); + ivNoLeftTime = findViewById(R.id.module_ext_id_traffic_light_no_left_time); + 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); + } + + /** + * 设置红绿灯的颜色,根据颜色来展示不同的效果 + * + * @param color 红绿灯颜色{@link #TRAFFIC_LIGHT_COLOR_GRAY},{@link #TRAFFIC_LIGHT_COLOR_RED}等四个颜色 + */ + private void setTrafficLightColor(@TrafficLightColor int color) { + if (iconRes == null) { + Logger.e(TAG, "红绿灯Icon数据为空,无法进行设置"); + return; + } + ivTrafficLight.setImageResource(iconRes[color]); + if (color != TRAFFIC_LIGHT_COLOR_GRAY) { + tvLeftTime.setTextColor(colorRes[color]); + tvLeftTimeUnit.setTextColor(colorRes[color]); + } + } + + /** + * 设置红绿灯剩余时长 + * + * @param leftTime 剩余时长,null或者empty表示没有时长数据 + */ + private void setTrafficLightLeftTime(String leftTime) { + if (leftTime == null || leftTime.isEmpty()) { + groupLeftTime.setVisibility(View.GONE); + ivNoLeftTime.setVisibility(View.VISIBLE); + } else { + groupLeftTime.setVisibility(View.VISIBLE); + ivNoLeftTime.setVisibility(View.GONE); + tvLeftTime.setText(leftTime); + } + } + + /** + * 设置红绿灯状态,需设置颜色及时长 + * + * @param color 红绿灯颜色,使用{@link #TRAFFIC_LIGHT_COLOR_RED}等四个值 + * @param leftTime 剩余时长,null或者empty表示没有时长数据 + */ + public void setTrafficLightStatus(@TrafficLightColor int color, String leftTime) { + setTrafficLightColor(color); + setTrafficLightLeftTime(leftTime); + } + + @IntDef({TRAFFIC_LIGHT_COLOR_GRAY, TRAFFIC_LIGHT_COLOR_GREEN, TRAFFIC_LIGHT_COLOR_RED, TRAFFIC_LIGHT_COLOR_YELLOW}) + @Retention(RetentionPolicy.SOURCE) + public @interface TrafficLightColor { + } + +} diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/module_ext_navi_in_vr_speed_bg.xml b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/module_ext_navi_in_vr_speed_bg.xml new file mode 100644 index 0000000000..fc2be5c480 --- /dev/null +++ b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/module_ext_navi_in_vr_speed_bg.xml @@ -0,0 +1,14 @@ + + + + + + + + + \ No newline at end of file diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/module_ext_navi_in_vr_traffic_bg.xml b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/module_ext_navi_in_vr_traffic_bg.xml new file mode 100644 index 0000000000..daf6c5e846 --- /dev/null +++ b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/module_ext_navi_in_vr_traffic_bg.xml @@ -0,0 +1,17 @@ + + + + + + + + + \ No newline at end of file diff --git a/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_no_time.png b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_no_time.png new file mode 100644 index 0000000000..736027225e Binary files /dev/null and b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_no_time.png differ diff --git a/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_straight_gray.png b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_straight_gray.png new file mode 100644 index 0000000000..04ae7093cc Binary files /dev/null and b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_straight_gray.png differ diff --git a/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_straight_green.png b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_straight_green.png new file mode 100644 index 0000000000..88b1c512af Binary files /dev/null and b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_straight_green.png differ diff --git a/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_straight_red.png b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_straight_red.png new file mode 100644 index 0000000000..4102f1f704 Binary files /dev/null and b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_straight_red.png differ diff --git a/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_straight_yellow.png b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_straight_yellow.png new file mode 100644 index 0000000000..478fc8bc52 Binary files /dev/null and b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_straight_yellow.png differ diff --git a/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_around_gray.png b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_around_gray.png new file mode 100644 index 0000000000..9656ca0b09 Binary files /dev/null and b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_around_gray.png differ diff --git a/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_around_green.png b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_around_green.png new file mode 100644 index 0000000000..bba7c0eec7 Binary files /dev/null and b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_around_green.png differ diff --git a/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_around_red.png b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_around_red.png new file mode 100644 index 0000000000..5f838f8634 Binary files /dev/null and b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_around_red.png differ diff --git a/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_around_yellow.png b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_around_yellow.png new file mode 100644 index 0000000000..8a4a93f136 Binary files /dev/null and b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_around_yellow.png differ diff --git a/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_left_gray.png b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_left_gray.png new file mode 100644 index 0000000000..ccc024ae2f Binary files /dev/null and b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_left_gray.png differ diff --git a/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_left_green.png b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_left_green.png new file mode 100644 index 0000000000..6e67909ef8 Binary files /dev/null and b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_left_green.png differ diff --git a/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_left_red.png b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_left_red.png new file mode 100644 index 0000000000..05f69ce9e3 Binary files /dev/null and b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_left_red.png differ diff --git a/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_left_yellow.png b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_left_yellow.png new file mode 100644 index 0000000000..eedef25bb8 Binary files /dev/null and b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_left_yellow.png differ diff --git a/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_right_gray.png b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_right_gray.png new file mode 100644 index 0000000000..0cc6a50e65 Binary files /dev/null and b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_right_gray.png differ diff --git a/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_right_green.png b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_right_green.png new file mode 100644 index 0000000000..efb4005264 Binary files /dev/null and b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_right_green.png differ diff --git a/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_right_red.png b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_right_red.png new file mode 100644 index 0000000000..b84b11449c Binary files /dev/null and b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_right_red.png differ diff --git a/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_right_yellow.png b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_right_yellow.png new file mode 100644 index 0000000000..bf3495faaf Binary files /dev/null and b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_dw_traffic_turn_right_yellow.png differ diff --git a/modules/mogo-module-extensions/src/main/res/drawable/module_ext_navi_in_vr_bg.xml b/modules/mogo-module-extensions/src/main/res/drawable/module_ext_navi_in_vr_bg.xml new file mode 100644 index 0000000000..8ebb6406a4 --- /dev/null +++ b/modules/mogo-module-extensions/src/main/res/drawable/module_ext_navi_in_vr_bg.xml @@ -0,0 +1,15 @@ + + + + + + + + + \ No newline at end of file diff --git a/modules/mogo-module-extensions/src/main/res/drawable/module_ext_vr_mode_limit_speed_bg.xml b/modules/mogo-module-extensions/src/main/res/drawable/module_ext_vr_mode_limit_speed_bg.xml new file mode 100644 index 0000000000..5b79ae5ac8 --- /dev/null +++ b/modules/mogo-module-extensions/src/main/res/drawable/module_ext_vr_mode_limit_speed_bg.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/modules/mogo-module-extensions/src/main/res/layout/include_navi_in_vr.xml b/modules/mogo-module-extensions/src/main/res/layout/include_navi_in_vr.xml new file mode 100644 index 0000000000..0bf3225ba9 --- /dev/null +++ b/modules/mogo-module-extensions/src/main/res/layout/include_navi_in_vr.xml @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/mogo-module-extensions/src/main/res/layout/merge_vertical_traffic_light_in_vr.xml b/modules/mogo-module-extensions/src/main/res/layout/merge_vertical_traffic_light_in_vr.xml new file mode 100644 index 0000000000..391cdb1d56 --- /dev/null +++ b/modules/mogo-module-extensions/src/main/res/layout/merge_vertical_traffic_light_in_vr.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/mogo-module-extensions/src/main/res/values/attrs.xml b/modules/mogo-module-extensions/src/main/res/values/attrs.xml new file mode 100644 index 0000000000..ed3912a664 --- /dev/null +++ b/modules/mogo-module-extensions/src/main/res/values/attrs.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ 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 1b4fa35128..41304c7c9d 100644 --- a/modules/mogo-module-extensions/src/main/res/values/dimens.xml +++ b/modules/mogo-module-extensions/src/main/res/values/dimens.xml @@ -209,4 +209,26 @@ 689px 86px + + 464px + 304px + 458px + 298px + 140px + 3px + 100px + 30px + 30px + 36px + 22px + 78px + 26px + 43px + 40px + 20px + 17px + 36px + 21px + 21px + \ No newline at end of file