diff --git a/OCH/shuttle/passenger_weaknet/src/main/java/b4/com/mogo/och/shuttle/weaknet/passenger/ui/line/autopilot/status/B4StatusView.kt b/OCH/shuttle/passenger_weaknet/src/main/java/b4/com/mogo/och/shuttle/weaknet/passenger/ui/line/autopilot/status/B4StatusView.kt index a3bdb96145..6643969fb1 100644 --- a/OCH/shuttle/passenger_weaknet/src/main/java/b4/com/mogo/och/shuttle/weaknet/passenger/ui/line/autopilot/status/B4StatusView.kt +++ b/OCH/shuttle/passenger_weaknet/src/main/java/b4/com/mogo/och/shuttle/weaknet/passenger/ui/line/autopilot/status/B4StatusView.kt @@ -84,25 +84,25 @@ class B4StatusView : AppCompatTextView, ICommonCallback, IReceivedMsgListener { "数据刷新来源=$sourceStr 自动驾驶状态=${autopilotState} 订单状态=${CommonModel.inOrder} 美化模式状态=${FunctionBuildConfig.isDemoMode} B2美化模式状态=${FunctionBuildConfig.isB2DemoMode} " ) if (IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING == autopilotState) { - return R.drawable.b4_status_parallel + return R.color.b4_9A2EFF } // 处理非平行驾驶状态的情况 return when { // 无订单的情况 !CommonModel.inOrder -> { - R.drawable.b4_status_basic + return R.color.b4_333333 } // 有订单,且美化状态和b2美化状态任意开着 CommonModel.inOrder && (FunctionBuildConfig.isDemoMode || FunctionBuildConfig.isB2DemoMode) -> { - R.drawable.b4_status_order_auto + R.color.b4_2EACFF } // 有订单,且美化状态和b2美化状态都关着 CommonModel.inOrder && !FunctionBuildConfig.isDemoMode && !FunctionBuildConfig.isB2DemoMode -> { - if (autopilotState == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) R.drawable.b4_status_order_auto else R.drawable.b4_status_basic + if (autopilotState == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) R.color.b4_2EACFF else R.color.b4_333333 } // 覆盖所有可能的情况 - else -> R.drawable.b4_status_basic + else -> R.color.b4_333333 } } @@ -110,7 +110,7 @@ class B4StatusView : AppCompatTextView, ICommonCallback, IReceivedMsgListener { BizLoopManager.runInMainThread { context?.let { setTextColor(ContextCompat.getColor(it, R.color.common_FFFFFF)) - background = ContextCompat.getDrawable(it, getStateIcon(source)) + setBackgroundColor(getStateIcon(source)) } } } diff --git a/OCH/shuttle/passenger_weaknet/src/main/java/b4/com/mogo/och/shuttle/weaknet/passenger/ui/map/autopilot/B4AutopilotView.kt b/OCH/shuttle/passenger_weaknet/src/main/java/b4/com/mogo/och/shuttle/weaknet/passenger/ui/map/autopilot/B4AutopilotView.kt new file mode 100644 index 0000000000..15088d1a06 --- /dev/null +++ b/OCH/shuttle/passenger_weaknet/src/main/java/b4/com/mogo/och/shuttle/weaknet/passenger/ui/map/autopilot/B4AutopilotView.kt @@ -0,0 +1,38 @@ +package com.mogo.och.shuttle.weaknet.passenger.ui.map.autopilot + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import androidx.constraintlayout.widget.ConstraintLayout +import com.mogo.och.shuttle.weaknet.passenger.R + +class B4AutopilotView : ConstraintLayout { + + private val TAG = "B4AutopilotView" + + constructor(context: Context) : super(context) + + constructor(context: Context, attributeSet: AttributeSet) : super(context, attributeSet) + + constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int) : super(context, attributeSet, defStyleAttr) + + constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attributeSet, defStyleAttr, defStyleRes) + + private fun initView() { + LayoutInflater.from(context).inflate(R.layout.b4_autopilot, this, true) + } + + override fun onVisibilityAggregated(isVisible: Boolean) { + super.onVisibilityAggregated(isVisible) + } + + init { + try { + initView() + } catch (e: Exception) { + e.printStackTrace() + } + } + + +} \ No newline at end of file diff --git a/OCH/shuttle/passenger_weaknet/src/main/java/b4/com/mogo/och/shuttle/weaknet/passenger/ui/map/autopilot/light/B4TurnLightView.kt b/OCH/shuttle/passenger_weaknet/src/main/java/b4/com/mogo/och/shuttle/weaknet/passenger/ui/map/autopilot/light/B4TurnLightView.kt new file mode 100644 index 0000000000..d9d523ea01 --- /dev/null +++ b/OCH/shuttle/passenger_weaknet/src/main/java/b4/com/mogo/och/shuttle/weaknet/passenger/ui/map/autopilot/light/B4TurnLightView.kt @@ -0,0 +1,180 @@ +package com.mogo.och.shuttle.weaknet.passenger.ui.map.autopilot.light + +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.Animation +import android.widget.ImageView +import androidx.constraintlayout.widget.ConstraintLayout +import com.mogo.eagle.core.function.api.datacenter.union.IMoGoTurnLightListener +import com.mogo.eagle.core.function.call.v2x.CallerTurnLightListenerManager +import com.mogo.eagle.core.utilcode.util.ThreadUtils +import com.mogo.och.common.module.manager.light.TurnLightManager +import com.mogo.och.shuttle.weaknet.passenger.R +import kotlinx.android.synthetic.main.shuttle_p_b4_turn_light_status.view.b4_left_select_image +import kotlinx.android.synthetic.main.shuttle_p_b4_turn_light_status.view.b4_right_nor_image +import kotlinx.android.synthetic.main.shuttle_p_b4_turn_light_status.view.b4_right_select_image + +/** + * @author: wangmingjun + * @date: 2023/2/13 + */ +class B4TurnLightView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : ConstraintLayout(context, attrs, defStyleAttr), + IMoGoTurnLightListener, TurnLightManager.TurnLightListener { + + + companion object { + private const val TAG = "B4TurnLightView" + } + + private var isLeftLight: Boolean = false + private var isRightLight: Boolean = false + private var isDisappear: Boolean = false + + init { + LayoutInflater.from(context).inflate(R.layout.shuttle_p_b4_turn_light_status, this, true) + } + + override fun onAttachedToWindow() { + super.onAttachedToWindow() + CallerTurnLightListenerManager.addListener(TAG, this) + TurnLightManager.addTurnLightStatusChangeListener(TAG, this) + } + + override fun onDetachedFromWindow() { + super.onDetachedFromWindow() + CallerTurnLightListenerManager.removeListener(TAG) + TurnLightManager.removeTurnLightStatusChangeListener(TAG) + } + + override fun hideTurnLightView() { + ThreadUtils.runOnUiThread { + if (!isDisappear) { + isDisappear = true + isLeftLight = false + isRightLight = false + animationDisappear() + } + } + } + + override fun statusChange(newStatus: TurnLightManager.TurnLightStatus) { + ThreadUtils.runOnUiThread { + setTurnLight(newStatus) + } + } + + /** + * 转向灯动画 + */ + private fun setTurnLight(directionLight: TurnLightManager.TurnLightStatus) { + if (!isAttachedToWindow) { + return + } + //根据左右进行显示和隐藏,实际要判断每个来的时间和频度 + when (directionLight) { + TurnLightManager.TurnLightStatus.TURN_LIGHT_LEFT -> { //左转向 + if (!isLeftLight) { + isLeftLight = true + isRightLight = false + isDisappear = false + showNormalAnimation() + b4_left_select_image.visibility = View.VISIBLE + b4_right_select_image.visibility = View.GONE + b4_right_select_image.clearAnimation() + setAnimation(b4_left_select_image) + } + } + + TurnLightManager.TurnLightStatus.TURN_LIGHT_RIGHT -> { //右转向 + if (!isRightLight) { + isRightLight = true + isLeftLight = false + isDisappear = false + showNormalAnimation() + b4_left_select_image.visibility = View.GONE + b4_right_select_image.visibility = View.VISIBLE + b4_left_select_image.clearAnimation() + setAnimation(b4_right_select_image) + } + } + + TurnLightManager.TurnLightStatus.TURN_LIGHT_NONE -> { //消失 + if (!isDisappear) { + isDisappear = true + isLeftLight = false + isRightLight = false + animationDisappear() + } + } + } + } + + //显示背景 + private fun showNormalAnimation() { + val appearAnimation = AlphaAnimation(0f, 1.0f) + appearAnimation.duration = 300 + val appearAnimationImage = AlphaAnimation(0f, 1.0f) + appearAnimation.duration = 500 +// turn_light_layout.startAnimation(appearAnimation) +// left_nor_image.startAnimation(appearAnimationImage) + b4_right_nor_image.startAnimation(appearAnimationImage) + +// turn_light_layout.visibility = View.VISIBLE +// left_nor_image.visibility = View.VISIBLE + b4_right_nor_image.visibility = View.VISIBLE + } + + //消失动画,当转向等数据为空时候 + private fun animationDisappear() { + b4_left_select_image.visibility = View.GONE + b4_right_select_image.visibility = View.GONE + b4_left_select_image.clearAnimation() + b4_right_select_image.clearAnimation() + + //left_nor_image.clearAnimation() + b4_right_nor_image.clearAnimation() + + val disappearAnimationLeft = AlphaAnimation(1.0f, 0f) + disappearAnimationLeft.duration = 300 + + //left_nor_image.startAnimation(disappearAnimationLeft) + b4_right_nor_image.startAnimation(disappearAnimationLeft) + + + disappearAnimationLeft.setAnimationListener(object : Animation.AnimationListener { + override fun onAnimationRepeat(p0: Animation?) { + } + + override fun onAnimationStart(p0: Animation?) { + } + + override fun onAnimationEnd(p0: Animation?) { +// left_nor_image.visibility = View.GONE +// right_nor_image.visibility = View.GONE + } + }) + } + + //实现图片闪烁效果 + private fun setAnimation(imageView: ImageView) { + val animationSet = AnimatorSet() + val valueAnimator = ObjectAnimator.ofFloat(imageView, "alpha", 0f, 1.0f) + val valueAnimatorDisappear = ObjectAnimator.ofFloat(imageView, "alpha", 1.0f, 0f) + valueAnimator.duration = 1000 + valueAnimatorDisappear.duration = 800 + valueAnimator.repeatCount = -1 + valueAnimatorDisappear.repeatCount = -1 + animationSet.playTogether(valueAnimatorDisappear, valueAnimator) + animationSet.start() + } + +} \ No newline at end of file diff --git a/OCH/shuttle/passenger_weaknet/src/main/java/b4/com/mogo/och/shuttle/weaknet/passenger/ui/map/autopilot/speed/B4SpeedView.kt b/OCH/shuttle/passenger_weaknet/src/main/java/b4/com/mogo/och/shuttle/weaknet/passenger/ui/map/autopilot/speed/B4SpeedView.kt new file mode 100644 index 0000000000..c2f53acf27 --- /dev/null +++ b/OCH/shuttle/passenger_weaknet/src/main/java/b4/com/mogo/och/shuttle/weaknet/passenger/ui/map/autopilot/speed/B4SpeedView.kt @@ -0,0 +1,64 @@ +package com.mogo.och.shuttle.weaknet.passenger.ui.map.autopilot.speed + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import androidx.constraintlayout.widget.ConstraintLayout +import com.mogo.eagle.core.data.map.MogoLocation +import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener +import com.mogo.eagle.core.function.hmi.ui.setting.ToggleDebugView +import com.mogo.och.bridge.autopilot.location.OchLocationManager +import com.mogo.och.common.module.manager.loop.BizLoopManager +import com.mogo.och.shuttle.weaknet.passenger.R +import kotlinx.android.synthetic.main.b4_speed.view.b4_tv_speed +import kotlin.math.abs + +class B4SpeedView : ConstraintLayout, IMoGoChassisLocationGCJ02Listener { + + private val TAG = "B4SpeedView" + + constructor(context: Context) : super(context) + + constructor(context: Context, attributeSet: AttributeSet) : super(context, attributeSet) + + constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int) : super(context, attributeSet, defStyleAttr) + + constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attributeSet, defStyleAttr, defStyleRes) + + private fun initView() { + LayoutInflater.from(context).inflate(R.layout.b4_speed, this, true) + + b4_tv_speed.setOnLongClickListener { + context?.let { ToggleDebugView.toggleDebugView.toggle(it) } + true + } + } + + override fun onVisibilityAggregated(isVisible: Boolean) { + super.onVisibilityAggregated(isVisible) + if (isVisible) { + OchLocationManager.addGCJ02Listener(TAG, 3, this) + } else { + OchLocationManager.removeGCJ02Listener(TAG) + } + } + + init { + try { + initView() + } catch (e: Exception) { + e.printStackTrace() + } + } + + override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) { + mogoLocation?.let { + BizLoopManager.runInMainThread { + val speedKM = (abs(it.gnssSpeed) * 3.6f).toInt() + b4_tv_speed.text = speedKM.toString() + } + } + } + + +} \ No newline at end of file diff --git a/OCH/shuttle/passenger_weaknet/src/main/java/b4/com/mogo/och/shuttle/weaknet/passenger/ui/map/autopilot/status/B4StatusView.kt b/OCH/shuttle/passenger_weaknet/src/main/java/b4/com/mogo/och/shuttle/weaknet/passenger/ui/map/autopilot/status/B4StatusView.kt new file mode 100644 index 0000000000..76d8d74377 --- /dev/null +++ b/OCH/shuttle/passenger_weaknet/src/main/java/b4/com/mogo/och/shuttle/weaknet/passenger/ui/map/autopilot/status/B4StatusView.kt @@ -0,0 +1,127 @@ +package com.mogo.och.shuttle.weaknet.passenger.ui.map.autopilot.status + +import android.content.Context +import android.util.AttributeSet +import androidx.appcompat.widget.AppCompatTextView +import androidx.core.content.ContextCompat +import com.mogo.eagle.core.data.config.FunctionBuildConfig +import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener +import com.mogo.eagle.core.function.api.telematic.IReceivedMsgListener +import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager +import com.mogo.eagle.core.function.call.telematic.CallerTelematicListenerManager +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.och.common.module.manager.loop.BizLoopManager +import com.mogo.och.shuttle.weaknet.passenger.R +import com.mogo.och.shuttle.weaknet.passenger.callback.ICommonCallback +import com.mogo.och.shuttle.weaknet.passenger.model.CommonModel + +class B4StatusView : AppCompatTextView, ICommonCallback, IReceivedMsgListener { + + private val TAG = "B4StatusView" + + constructor(context: Context) : super(context) + + constructor(context: Context, attributeSet: AttributeSet) : super(context, attributeSet) + + constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int) : super( + context, + attributeSet, + defStyleAttr + ) + + override fun onAttachedToWindow() { + super.onAttachedToWindow() + CallerTelematicListenerManager.addListener(TAG, this) + CommonModel.setRouteLineInfoCallback(TAG, this) + updateAutoIconState(0) + } + + override fun onDetachedFromWindow() { + super.onDetachedFromWindow() + CallerTelematicListenerManager.removeListener(TAG) + CommonModel.setRouteLineInfoCallback(TAG, null) + } + + private fun initView() { + + } + + + override fun onB2DemoMode(isB2DemoMode: Boolean) { + super.onB2DemoMode(isB2DemoMode) + updateAutoIconState(1) + } + + //美化模式状态变更回调 + override fun onDemoMode(isDemoMode: Boolean) { + super.onDemoMode(isDemoMode) + updateAutoIconState(2) + } + + override fun updateInOrderStatus(inOrder: Boolean) { + super.updateInOrderStatus(inOrder) + updateAutoIconState(3) + } + + //自动驾驶状态变更 + override fun updateAutoStatus(state: Int) { + updateAutoIconState(4) + } + + private fun getStateIcon(source: Int): Int { + // 平行驾驶状态下 + val sourceStr = when (source) { + 0 -> "View初始化" + 1 -> "B2美化模式状态变更" + 2 -> "美化模式状态变更" + 3 -> "订单状态变更" + 4 -> "自动驾驶状态变更" + else -> "错误" + } + val autopilotState = CallerAutoPilotStatusListenerManager.getState() + CallerLogger.i( + TAG, + "数据刷新来源=$sourceStr 自动驾驶状态=${autopilotState} 订单状态=${CommonModel.inOrder} 美化模式状态=${FunctionBuildConfig.isDemoMode} B2美化模式状态=${FunctionBuildConfig.isB2DemoMode} " + ) + if (IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING == autopilotState) { + return R.drawable.b4_status_parallel + } + + // 处理非平行驾驶状态的情况 + return when { + // 无订单的情况 + !CommonModel.inOrder -> { + R.drawable.b4_status_basic + } + // 有订单,且美化状态和b2美化状态任意开着 + CommonModel.inOrder && (FunctionBuildConfig.isDemoMode || FunctionBuildConfig.isB2DemoMode) -> { + R.drawable.b4_status_order_auto + } + // 有订单,且美化状态和b2美化状态都关着 + CommonModel.inOrder && !FunctionBuildConfig.isDemoMode && !FunctionBuildConfig.isB2DemoMode -> { + if (autopilotState == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) R.drawable.b4_status_order_auto else R.drawable.b4_status_basic + } + // 覆盖所有可能的情况 + else -> R.drawable.b4_status_basic + } + } + + private fun updateAutoIconState(source: Int) { + BizLoopManager.runInMainThread { + context?.let { + setTextColor(ContextCompat.getColor(it, R.color.common_FFFFFF)) + background = ContextCompat.getDrawable(it, getStateIcon(source)) + } + } + } + + init { + try { + initView() + } catch (e: Exception) { + e.printStackTrace() + } + } + + +} \ No newline at end of file diff --git a/OCH/shuttle/passenger_weaknet/src/main/res/b4/drawable-nodpi/shuttle_p_b4_youzhuan_open.png b/OCH/shuttle/passenger_weaknet/src/main/res/b4/drawable-nodpi/shuttle_p_b4_youzhuan_open.png index 2ac9526450..44a541d9aa 100644 Binary files a/OCH/shuttle/passenger_weaknet/src/main/res/b4/drawable-nodpi/shuttle_p_b4_youzhuan_open.png and b/OCH/shuttle/passenger_weaknet/src/main/res/b4/drawable-nodpi/shuttle_p_b4_youzhuan_open.png differ diff --git a/OCH/shuttle/passenger_weaknet/src/main/res/b4/drawable-nodpi/shuttle_p_b4_youzhuan_un_open.png b/OCH/shuttle/passenger_weaknet/src/main/res/b4/drawable-nodpi/shuttle_p_b4_youzhuan_un_open.png index 7f585ef4b6..36b7e683f9 100644 Binary files a/OCH/shuttle/passenger_weaknet/src/main/res/b4/drawable-nodpi/shuttle_p_b4_youzhuan_un_open.png and b/OCH/shuttle/passenger_weaknet/src/main/res/b4/drawable-nodpi/shuttle_p_b4_youzhuan_un_open.png differ diff --git a/OCH/shuttle/passenger_weaknet/src/main/res/b4/drawable-nodpi/shuttle_p_b4_zuozhuan_open.png b/OCH/shuttle/passenger_weaknet/src/main/res/b4/drawable-nodpi/shuttle_p_b4_zuozhuan_open.png index 2c1f8c62f4..ea66e1c43f 100644 Binary files a/OCH/shuttle/passenger_weaknet/src/main/res/b4/drawable-nodpi/shuttle_p_b4_zuozhuan_open.png and b/OCH/shuttle/passenger_weaknet/src/main/res/b4/drawable-nodpi/shuttle_p_b4_zuozhuan_open.png differ diff --git a/OCH/shuttle/passenger_weaknet/src/main/res/b4/drawable-nodpi/shuttle_p_b4_zuozhuan_un_open.png b/OCH/shuttle/passenger_weaknet/src/main/res/b4/drawable-nodpi/shuttle_p_b4_zuozhuan_un_open.png index 71643afcce..f974d63212 100644 Binary files a/OCH/shuttle/passenger_weaknet/src/main/res/b4/drawable-nodpi/shuttle_p_b4_zuozhuan_un_open.png and b/OCH/shuttle/passenger_weaknet/src/main/res/b4/drawable-nodpi/shuttle_p_b4_zuozhuan_un_open.png differ diff --git a/OCH/shuttle/passenger_weaknet/src/main/res/b4/drawable/b4_turen_light_bg.xml b/OCH/shuttle/passenger_weaknet/src/main/res/b4/drawable/b4_turen_light_bg.xml new file mode 100644 index 0000000000..b154902c07 --- /dev/null +++ b/OCH/shuttle/passenger_weaknet/src/main/res/b4/drawable/b4_turen_light_bg.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/OCH/shuttle/passenger_weaknet/src/main/res/b4/layout/b4_autopilot.xml b/OCH/shuttle/passenger_weaknet/src/main/res/b4/layout/b4_autopilot.xml index 65f60d374c..8b5b69c2b3 100644 --- a/OCH/shuttle/passenger_weaknet/src/main/res/b4/layout/b4_autopilot.xml +++ b/OCH/shuttle/passenger_weaknet/src/main/res/b4/layout/b4_autopilot.xml @@ -8,9 +8,11 @@ @@ -24,10 +26,10 @@ + android:layout_width="@dimen/dp_119" + android:layout_height="@dimen/dp_65" + android:visibility="visible"> diff --git a/OCH/shuttle/passenger_weaknet/src/main/res/b4/values/colors.xml b/OCH/shuttle/passenger_weaknet/src/main/res/b4/values/colors.xml index d37a4ce24b..8399a9297a 100644 --- a/OCH/shuttle/passenger_weaknet/src/main/res/b4/values/colors.xml +++ b/OCH/shuttle/passenger_weaknet/src/main/res/b4/values/colors.xml @@ -16,4 +16,6 @@ #555555 #333333 #7C7C7C + #2EACFF + #9A2EFF \ No newline at end of file