[6.5.0]融合红绿灯额外提示

This commit is contained in:
xuxinchao
2024-06-29 23:55:36 +08:00
parent 611c19549e
commit d646a6a256
9 changed files with 271 additions and 0 deletions

View File

@@ -153,6 +153,11 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight
convert(light.nextTwoState),light.nextTwoDuration.toInt(),
DataSourceType.TELEMATIC_UNION_V2N
)
//当前灯态倒计时小于5S时展示额外的提示框
if(light.duration < 5){
onTrafficLightPrompt(convert(light.state),light.duration.toInt())
}
//TODO 提示框的消失逻辑
}
}
}
@@ -264,6 +269,20 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight
CallerTrafficLightListenerManager.disableTrafficLight()
}
/**
* 融合V2N红绿灯额外提示框提醒
*/
@ChainLog(
linkChainLog = ChainConstant.CHAIN_TYPE_SOCKET_TRAFFIC_LIGHT,
linkCode = ChainConstant.CHAIN_SOURCE_ADAS,
nodeAliasCode = ChainConstant.CHAIN_CODE_ADAS_TRAFFIC_LIGHT,
paramIndexes = [0, 1])
override fun onTrafficLightPrompt(currentState: TrafficLightEnum, currentDuration: Int) {
super.onTrafficLightPrompt(currentState, currentDuration)
Log.i("xuxinchao","融合V2N红绿灯额外提示框提醒 Dis")
CallerTrafficLightListenerManager.onShowTrafficLightPrompt(currentState, currentDuration)
}
/**
* 融合V2N红绿灯数据带有下一下二灯态
*/

View File

@@ -0,0 +1,126 @@
package com.mogo.eagle.core.function.hmi.ui.notice.traffic
import android.content.Context
import android.util.AttributeSet
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.ContextCompat
import com.mogo.eagle.core.data.enums.TrafficLightEnum
import com.mogo.eagle.core.function.api.datacenter.union.IMoGoTrafficLightListener
import com.mogo.eagle.core.function.call.v2x.CallerTrafficLightListenerManager
import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.function.hmi.ui.widget.TypefaceTextView
import com.mogo.eagle.core.utilcode.util.ThreadUtils
/**
* 融合红绿灯变灯提示
* 鹰眼650需求
*/
class TrafficLightPromptView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : ConstraintLayout(context, attrs, defStyleAttr), IMoGoTrafficLightListener {
companion object {
private const val TAG = "TrafficLightPromptView"
}
private var user = 0 //使用方driver:0 passenger:1
private var tvPromptTitle: TextView ?= null
private var tvPromptContent: TextView ?= null
private var tvTrafficNum: TypefaceTextView ?= null
private var tvTrafficNumDecimal: TypefaceTextView ?= null
private val randomList = ArrayList<Float>()
init {
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.TrafficLightPromptView)
user = typedArray.getInt(R.styleable.TrafficLightPromptView_promptUser,0)
typedArray.recycle()
}
override fun onAttachedToWindow() {
super.onAttachedToWindow()
if(user == 0){
LayoutInflater.from(context).inflate(R.layout.view_traffic_light_prompt, this, true)
tvPromptTitle = findViewById(R.id.tvPromptTitle)
}else{
LayoutInflater.from(context).inflate(R.layout.view_traffic_light_prompt_p, this, true)
}
tvPromptContent = findViewById(R.id.tvPromptContent)
tvTrafficNum = findViewById(R.id.tvTrafficNum)
tvTrafficNumDecimal = findViewById(R.id.tvTrafficNumDecimal)
CallerTrafficLightListenerManager.addListener(TAG, this)
randomList.add(0.99f)
randomList.add(0.72f)
randomList.add(0.44f)
randomList.add(0.21f)
randomList.add(0.06f)
// tvPromptContent?.text = "请准备出发"
// tvTrafficNum?.text = "12"
// tvTrafficNumDecimal?.text = ".56"
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
CallerTrafficLightListenerManager.removeListener(TAG)
}
/**
* 红绿灯额外提示框
* @param currentState 当前灯态
* @param currentDuration 当前灯态倒计时
*/
override fun onShowTrafficLightPrompt(currentState: TrafficLightEnum, currentDuration: Int) {
super.onShowTrafficLightPrompt(currentState, currentDuration)
Log.i("xuxinchao","TrafficLightPromptView onTrafficLightPrompt")
Log.i("xuxinchao","onShowTrafficLightPrompt user="+user)
ThreadUtils.runOnUiThread {
when(currentState){
TrafficLightEnum.GREEN->{
this@TrafficLightPromptView.visibility = View.VISIBLE
if(user == 0){
tvTrafficNum?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_green))
tvTrafficNumDecimal?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_green))
}else{
Log.i("xuxinchao","user="+user)
tvTrafficNum?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_green_p))
tvTrafficNumDecimal?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_green_p))
}
}
TrafficLightEnum.RED->{
this@TrafficLightPromptView.visibility = View.VISIBLE
if(user == 0){
tvTrafficNum?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_red))
tvTrafficNumDecimal?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_red))
}else{
tvTrafficNum?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_red_p))
tvTrafficNumDecimal?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_red_p))
}
}
TrafficLightEnum.YELLOW->{
this@TrafficLightPromptView.visibility = View.VISIBLE
if(user == 0){
tvTrafficNum?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_yellow))
tvTrafficNumDecimal?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_yellow))
}else{
tvTrafficNum?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_yellow_p))
tvTrafficNumDecimal?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_yellow_p))
}
}
TrafficLightEnum.BLACK->{
this@TrafficLightPromptView.visibility = View.GONE
}
}
tvTrafficNum?.text = currentDuration.toString()
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

View File

@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/dp_500"
android:layout_height="@dimen/dp_144"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@drawable/bg_light_prompt">
<TextView
android:id="@+id/tvPromptTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginTop="@dimen/dp_30"
android:layout_marginLeft="@dimen/dp_150"
android:textSize="@dimen/sp_30"
android:textColor="@color/white"
/>
<TextView
android:id="@+id/tvPromptContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/tvPromptTitle"
app:layout_constraintLeft_toLeftOf="@id/tvPromptTitle"
android:textSize="@dimen/sp_21"
android:textColor="@color/white"
/>
<com.mogo.eagle.core.function.hmi.ui.widget.TypefaceTextView
android:id="@+id/tvTrafficNumDecimal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="@id/tvPromptContent"
android:textSize="@dimen/sp_30"
/>
<com.mogo.eagle.core.function.hmi.ui.widget.TypefaceTextView
android:id="@+id/tvTrafficNum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="@id/tvTrafficNumDecimal"
app:layout_constraintRight_toLeftOf="@id/tvTrafficNumDecimal"
android:textSize="@dimen/sp_76"
/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/dp_650"
android:layout_height="@dimen/dp_200"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@drawable/bg_light">
<TextView
android:id="@+id/tvPromptContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:textSize="@dimen/sp_32"
android:textColor="@color/light_prompt_content"
android:layout_marginTop="@dimen/dp_50"
android:layout_marginStart="@dimen/dp_50"
/>
<com.mogo.eagle.core.function.hmi.ui.widget.TypefaceTextView
android:id="@+id/tvTrafficNum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="@id/tvPromptContent"
app:layout_constraintLeft_toRightOf="@id/tvPromptContent"
android:textSize="@dimen/sp_76"
/>
<com.mogo.eagle.core.function.hmi.ui.widget.TypefaceTextView
android:id="@+id/tvTrafficNumDecimal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="@id/tvTrafficNum"
app:layout_constraintLeft_toRightOf="@id/tvTrafficNum"
android:textSize="@dimen/sp_30"
/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -129,4 +129,11 @@
</attr>
</declare-styleable>
<declare-styleable name="TrafficLightPromptView">
<attr name="promptUser">
<enum name="driver" value="0"/>
<enum name="passenger" value="1"/>
</attr>
</declare-styleable>
</resources>

View File

@@ -92,4 +92,12 @@
<color name="summary_danger_num">#106FF0</color>
<color name="summary_tip">#42464F</color>
<color name="light_prompt_content">#131415 </color>
<color name="light_prompt_red">#FF3B2D</color>
<color name="light_prompt_green">#31FF56</color>
<color name="light_prompt_yellow">#FFCD3D</color>
<color name="light_prompt_red_p">#F63C12</color>
<color name="light_prompt_green_p">#36DB1C</color>
<color name="light_prompt_yellow_p">#FDB700</color>
</resources>