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 e22e087295..3ef6b46620 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 @@ -30,6 +30,8 @@ import com.mogo.eagle.core.function.hmi.ui.notice.NoticeBannerView 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.turnlight.BrakeView +import com.mogo.eagle.core.function.hmi.ui.turnlight.TurnLightView import com.mogo.eagle.core.function.hmi.ui.widget.V2XNotificationView import com.mogo.eagle.core.utilcode.mogo.logger.Logger import com.mogo.eagle.core.utilcode.util.ThreadUtils @@ -67,6 +69,7 @@ class MoGoHmiFragment : MvpFragment // 检测、自动驾驶速度设置 private var toolsViewFloat: WarningFloat.Builder? = null + override fun vipIdentification(visible: Boolean) { ThreadUtils.runOnUiThread { Logger.d(TAG, "vipIdentification") @@ -636,17 +639,27 @@ class MoGoHmiFragment : MvpFragment } /** - * 显示转向灯效果 + * 显示转向灯效果 TODO */ override fun showTurnLight(light: Int) { + turnLightView?.visibility = View.VISIBLE + turnLightView.setTurnLight(light) } /** * 显示刹车效果 */ - override fun showBrakeLight(brakeLight: Int) { - + override fun showBrakeLight(light: Int) { + brakeView?.visibility = View.VISIBLE + brakeView.setBrakeLight(light) + +// context?.let { +// if (brakeLight == null) { +// brakeLight = BrakeView(it) +// brakeLight!!.setBrakeLight(light) +// } +// } } override fun onDestroy() { diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/turnlight/BrakeView.java b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/turnlight/BrakeView.java new file mode 100644 index 0000000000..61d607fb1d --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/turnlight/BrakeView.java @@ -0,0 +1,112 @@ +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.view.LayoutInflater; +import android.view.View; +import android.view.animation.AlphaAnimation; +import android.view.animation.DecelerateInterpolator; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.constraintlayout.widget.ConstraintLayout; + +import com.mogo.eagle.core.function.hmi.R; + +/** + * @author lixiaopeng + * @description 刹车 + * @since: 1/26/22 + */ +public class BrakeView extends ConstraintLayout { + + private LinearLayout brakeLayout; + private ImageView imageBrake; + private TextView tvBrake; + private Context mContext; + + public BrakeView(@NonNull Context context) { + super(context); + mContext = context; + LayoutInflater.from(context).inflate(R.layout.view_brake_light, this); + initView(); + } + + public BrakeView(@NonNull Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + } + + public BrakeView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + public BrakeView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { + super(context, attrs, defStyleAttr, defStyleRes); + } + + public void initView() { + brakeLayout = findViewById(R.id.layout_brake); + imageBrake = findViewById(R.id.image_brake); + tvBrake = findViewById(R.id.tv_brake); + } + + /** + * 刹车动画 + */ + public void setBrakeLight(int brakeLight) { + AlphaAnimation appearAnimation = new AlphaAnimation(0, 1f); + appearAnimation.setDuration(300); + + brakeLayout.startAnimation(appearAnimation); + imageBrake.startAnimation(appearAnimation); + tvBrake.startAnimation(appearAnimation); + brakeLayout.setVisibility(View.VISIBLE); + imageBrake.setVisibility(View.VISIBLE); + tvBrake.setVisibility(View.VISIBLE); + + if (brakeLight == 1) { //TODO 暂时还不知道数据 + + } else { //不踩刹车,就消失 + AlphaAnimation disappearAnimation = new AlphaAnimation(1, 0); + disappearAnimation.setDuration(300); + + scaleImageAndTv(); + + brakeLayout.startAnimation(disappearAnimation); + imageBrake.startAnimation(disappearAnimation); + tvBrake.startAnimation(disappearAnimation); + brakeLayout.setVisibility(View.GONE); + imageBrake.setVisibility(View.GONE); + tvBrake.setVisibility(View.GONE); + } + } + + + private void scaleImageAndTv() { + AnimatorSet animatorSuofang = new AnimatorSet();//组合动画 + ObjectAnimator scaleX = ObjectAnimator.ofFloat(imageBrake, "scaleX", 1f, 1.3f); + ObjectAnimator scaleY = ObjectAnimator.ofFloat(imageBrake, "scaleY", 1f, 1.3f); + animatorSuofang.setDuration(200); + animatorSuofang.setInterpolator(new DecelerateInterpolator()); + animatorSuofang.play(scaleX).with(scaleY); + animatorSuofang.start(); + + ObjectAnimator scaleXTv = ObjectAnimator.ofFloat(tvBrake, "scaleX", 1f, 1.3f); + ObjectAnimator scaleYTv = ObjectAnimator.ofFloat(tvBrake, "scaleY", 1f, 1.3f); + animatorSuofang.setDuration(200); + animatorSuofang.setInterpolator(new DecelerateInterpolator()); + animatorSuofang.play(scaleXTv).with(scaleYTv); + animatorSuofang.start(); + } + + private void stopAnimate() { + tvBrake.clearAnimation(); + imageBrake.clearAnimation(); + } + +} diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/turnlight/TurnLightView.java b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/turnlight/TurnLightView.java new file mode 100644 index 0000000000..7a99d78ccb --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/turnlight/TurnLightView.java @@ -0,0 +1,120 @@ +package com.mogo.eagle.core.function.hmi.ui.turnlight; + +import android.content.Context; +import android.util.AttributeSet; +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.FrameLayout; +import android.widget.ImageView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.constraintlayout.widget.ConstraintLayout; + +import com.mogo.eagle.core.function.hmi.R; + +/** + * @author lixiaopeng + * @description 顶部转向灯 + * @since: 1/26/22 + */ +public class TurnLightView extends ConstraintLayout { + + private FrameLayout mTurnLightBgLayout; + private ImageView mLeftNormalImage, mLeftSelectImage; + private ImageView mRightNormalImage, mRightSelectImage; + private Context mContext; + + public TurnLightView(@NonNull Context context) { + super(context); + mContext = context; + LayoutInflater.from(context).inflate(R.layout.view_turn_light, this); + initView(); + } + + public TurnLightView(@NonNull Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + } + + public TurnLightView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + public TurnLightView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { + super(context, attrs, defStyleAttr, defStyleRes); + } + + public void initView() { + mTurnLightBgLayout = findViewById(R.id.turn_light_layout); + mLeftNormalImage = findViewById(R.id.left_nor_image); + mLeftSelectImage = findViewById(R.id.left_select_image); + mRightNormalImage = findViewById(R.id.right_nor_image); + mRightSelectImage = findViewById(R.id.right_select_image); + } + + /** + * 转向灯动画 + */ + public void setTurnLight(int directionLight) { + //显示背景 + AlphaAnimation appearAnimation = new AlphaAnimation(0, 1f); + appearAnimation.setDuration(600); + + AlphaAnimation appearAnimationImage = new AlphaAnimation(0, 1f); + appearAnimation.setDuration(900); + + mTurnLightBgLayout.startAnimation(appearAnimation); + mLeftNormalImage.startAnimation(appearAnimationImage); + mRightNormalImage.startAnimation(appearAnimationImage); + mTurnLightBgLayout.setVisibility(View.VISIBLE); + mLeftNormalImage.setVisibility(View.VISIBLE); + mRightNormalImage.setVisibility(View.VISIBLE); + + //根据左右进行显示和隐藏,实际要判断每个来的时间和频度 TODO + if (directionLight == 1) { //左转向 + mLeftSelectImage.setVisibility(View.VISIBLE); + mRightSelectImage.setVisibility(View.GONE); + setAnimation(mLeftSelectImage); + } else if (directionLight == 2) { //右转向 + mLeftSelectImage.setVisibility(View.GONE); + mRightSelectImage.setVisibility(View.VISIBLE); + setAnimation(mRightSelectImage); + } else { //消失 + animationDisappear(); + } + } + + //消失动画,当转向等数据为空时候 + private void animationDisappear() { + mLeftSelectImage.setVisibility(View.GONE); + mRightSelectImage.setVisibility(View.GONE); + + AlphaAnimation disappearAnimationLeft = new AlphaAnimation(1, 0); + disappearAnimationLeft.setDuration(150); + AlphaAnimation disappearAnimationBg = new AlphaAnimation(1, 0); + disappearAnimationBg.setDuration(900); + + mTurnLightBgLayout.startAnimation(disappearAnimationBg); + mLeftNormalImage.startAnimation(disappearAnimationLeft); + mRightNormalImage.startAnimation(disappearAnimationLeft); + mTurnLightBgLayout.setVisibility(View.GONE); + mLeftNormalImage.setVisibility(View.GONE); + mRightNormalImage.setVisibility(View.GONE); + } + + //实现图片闪烁效果 + private void setAnimation(ImageView imageView) { + AlphaAnimation animation = new AlphaAnimation(1, 0); + + animation.setDuration(800); + animation.setInterpolator(new LinearInterpolator()); + animation.setRepeatCount(Animation.INFINITE); + animation.setRepeatMode(Animation.REVERSE); + imageView.startAnimation(animation); + } + + +} diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_arrow_left_nor.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_arrow_left_nor.png new file mode 100644 index 0000000000..335476d4c3 Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_arrow_left_nor.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_arrow_left_select_nor.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_arrow_left_select_nor.png new file mode 100644 index 0000000000..7d22f5a4c0 Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_arrow_left_select_nor.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_arrow_right_nor.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_arrow_right_nor.png new file mode 100644 index 0000000000..4f62802781 Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_arrow_right_nor.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_arrow_right_select_nor.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_arrow_right_select_nor.png new file mode 100644 index 0000000000..7ec2819571 Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_arrow_right_select_nor.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_blank_nor.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_blank_nor.png new file mode 100644 index 0000000000..3031b2ed73 Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_blank_nor.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_light_nor.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_light_nor.png new file mode 100644 index 0000000000..3822f780ed Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_light_nor.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_shadow_left_nor.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_shadow_left_nor.png new file mode 100644 index 0000000000..73be7386e4 Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_shadow_left_nor.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_shadow_right_nor.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_shadow_right_nor.png new file mode 100644 index 0000000000..19a8a96039 Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_shadow_right_nor.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_turn_light_bg.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_turn_light_bg.png new file mode 100644 index 0000000000..65a1db643d Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/module_turn_light_bg.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/fragment_hmi.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/fragment_hmi.xml index 9a9efa1cb2..f80876e857 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/fragment_hmi.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/fragment_hmi.xml @@ -127,6 +127,29 @@ app:layout_goneMarginTop="40px" tools:visibility="visible" /> + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_brake_light.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_brake_light.xml new file mode 100644 index 0000000000..ac013ebd92 --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_brake_light.xml @@ -0,0 +1,33 @@ + + + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_turn_light.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_turn_light.xml new file mode 100644 index 0000000000..9fc5c4ebf8 --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_turn_light.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + \ No newline at end of file