[6.5.1]Bus考试UI合并到主分支

This commit is contained in:
xuxinchao
2024-07-29 17:30:00 +08:00
parent fae45e0cd4
commit 2c8e80eca8
11 changed files with 299 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
package com.mogo.eagle.core.function.hmi.ui.setting
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import androidx.constraintlayout.widget.ConstraintLayout
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.sendPlanningCmd
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.sendPlanningLineChangeCmd
import com.mogo.eagle.core.function.hmi.R
import kotlinx.android.synthetic.main.view_exam_setting.view.mOverTakeBtn
import kotlinx.android.synthetic.main.view_exam_setting.view.mStartCarBtn
import kotlinx.android.synthetic.main.view_exam_setting.view.mStopCarBtn
class ExamSettingView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : ConstraintLayout(context, attrs, defStyleAttr) {
companion object {
const val TAG = "ExamSettingView"
}
init {
LayoutInflater.from(context).inflate(R.layout.view_exam_setting, this, true)
initView()
}
private fun initView(){
initBusView()
}
private fun initBusView(){
//停车
mStopCarBtn.setOnClickListener {
sendPlanningCmd(1)
}
//出发
mStartCarBtn.setOnClickListener {
sendPlanningCmd(2)
}
//超车
mOverTakeBtn.setOnClickListener {
sendPlanningLineChangeCmd(3)
}
}
}

View File

@@ -0,0 +1,80 @@
package com.mogo.eagle.core.function.hmi.ui.setting
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import androidx.constraintlayout.widget.ConstraintLayout
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager
import com.mogo.eagle.core.function.call.setting.CallerSeatPressureManager
import com.mogo.eagle.core.function.hmi.R
import kotlinx.android.synthetic.main.view_seat_pressure_setting.view.tb_co_driver
import kotlinx.android.synthetic.main.view_seat_pressure_setting.view.tb_main_driver
import kotlinx.android.synthetic.main.view_seat_pressure_setting.view.tb_rear_row
/**
* 座椅压力设置页面(设座位是否有人)
*/
class SeatPressureSettingView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : ConstraintLayout(context, attrs, defStyleAttr) {
companion object {
const val TAG = "SeatPressureSettingView"
}
private var mainDriverStatus = false //主驾是否有人,默认没人
private var coDriverStatus = false //副驾是否有人,默认没人
private var rearRowStatus = false //后排是否有人,默认没人
init {
LayoutInflater.from(context).inflate(R.layout.view_seat_pressure_setting, this, true)
initView()
}
private fun initView(){
//主驾
tb_main_driver.isChecked = mainDriverStatus
tb_main_driver.setOnCheckedChangeListener{compoundButton, isChecked ->
if(!compoundButton.isPressed){
return@setOnCheckedChangeListener
}
mainDriverStatus = isChecked
CallerAutoPilotControlManager.sendSeatPressure(mainDriverStatus,coDriverStatus,rearRowStatus)
updateBtnBg(mainDriverStatus,coDriverStatus,rearRowStatus)
}
//副驾
tb_co_driver.isChecked = coDriverStatus
tb_co_driver.setOnCheckedChangeListener{compoundButton, isChecked ->
if(!compoundButton.isPressed){
return@setOnCheckedChangeListener
}
coDriverStatus = isChecked
CallerAutoPilotControlManager.sendSeatPressure(mainDriverStatus,coDriverStatus,rearRowStatus)
updateBtnBg(mainDriverStatus,coDriverStatus,rearRowStatus)
}
//后排
tb_rear_row.isChecked = rearRowStatus
tb_rear_row.setOnCheckedChangeListener{compoundButton, isChecked ->
if(!compoundButton.isPressed){
return@setOnCheckedChangeListener
}
rearRowStatus = isChecked
CallerAutoPilotControlManager.sendSeatPressure(mainDriverStatus,coDriverStatus,rearRowStatus)
updateBtnBg(mainDriverStatus,coDriverStatus,rearRowStatus)
}
}
//TODO 看是否有需要
private fun updateBtnBg(driver: Boolean,copilot: Boolean,backRow: Boolean){
if(driver || copilot || backRow){
//主驾、副驾、后排只要有一个位置有人则开关按钮就显示有人状态
CallerSeatPressureManager.invokeUpdateBgEvent(true)
}else{
//所有座位都没有人则显示无人状态
CallerSeatPressureManager.invokeUpdateBgEvent(false)
}
}
}

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="@dimen/dp_20" />
<gradient
android:startColor="#323C6F"
android:endColor="#323C6F"
android:angle="315"
/>
</shape>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#80FFFFFF"/>
<corners android:radius="@dimen/dp_20" />
</shape>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#029DFF"
android:endColor="#0056FF"
/>
<corners android:radius="@dimen/dp_20" />
</shape>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/seat_pressure_item_press_bg" android:state_pressed="true"/>
<item android:drawable="@drawable/seat_pressure_item_press_bg" android:state_checked="true"/>
<item android:drawable="@drawable/seat_pressure_item_normal_bg" android:state_pressed="false"/>
<item android:drawable="@drawable/seat_pressure_item_normal_bg" />
</selector>

View File

@@ -0,0 +1,57 @@
<?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_800"
android:layout_height="@dimen/dp_1100"
android:background="@color/color_D4D8DC"
xmlns:app="http://schemas.android.com/apk/res-auto">
<Button
android:id="@+id/mStopCarBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/mStartCarBtn"
android:text="停车"
android:textSize="@dimen/sp_30"
android:layout_margin="@dimen/dp_20"
/>
<Button
android:id="@+id/mStartCarBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toRightOf="@id/mStopCarBtn"
app:layout_constraintRight_toLeftOf="@id/mOverTakeBtn"
android:text="出发"
android:textSize="@dimen/sp_30"
android:layout_margin="@dimen/dp_20"
/>
<Button
android:id="@+id/mOverTakeBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toRightOf="@id/mStartCarBtn"
app:layout_constraintRight_toRightOf="parent"
android:text="超车"
android:textSize="@dimen/sp_30"
android:layout_margin="@dimen/dp_20"
/>
<com.mogo.eagle.core.function.hmi.ui.setting.SeatPressureSettingView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/mStartCarBtn"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_margin="@dimen/dp_20"
/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@drawable/bg_seat_pressure_setting"
>
<ToggleButton
android:id="@+id/tb_main_driver"
android:layout_width="@dimen/dp_180"
android:layout_height="@dimen/dp_80"
android:textOff="@string/hmi_main_driver"
android:textOn="@string/hmi_main_driver"
android:textColor="@color/white"
android:textSize="@dimen/sp_30"
android:gravity="center"
android:background="@drawable/selector_seat_pressure_item"
android:layout_margin="@dimen/dp_20"
/>
<ToggleButton
android:id="@+id/tb_co_driver"
android:layout_width="@dimen/dp_180"
android:layout_height="@dimen/dp_80"
android:textOff="@string/hmi_co_driver"
android:textOn="@string/hmi_co_driver"
android:textColor="@color/white"
android:textSize="@dimen/sp_30"
android:gravity="center"
android:background="@drawable/selector_seat_pressure_item"
android:layout_margin="@dimen/dp_20"
/>
<ToggleButton
android:id="@+id/tb_rear_row"
android:layout_width="@dimen/dp_180"
android:layout_height="@dimen/dp_80"
android:textOff="@string/hmi_rear_row"
android:textOn="@string/hmi_rear_row"
android:textColor="@color/white"
android:textSize="@dimen/sp_30"
android:gravity="center"
android:background="@drawable/selector_seat_pressure_item"
android:layout_margin="@dimen/dp_20"
/>
</LinearLayout>

View File

@@ -130,4 +130,8 @@
<string name="road_cross_live_tip">蘑菇为您实时护航中,请放心驾驶!</string>
<string name="hmi_main_driver">主驾</string>
<string name="hmi_co_driver">副驾</string>
<string name="hmi_rear_row">后排</string>
</resources>

View File

@@ -0,0 +1,10 @@
package com.mogo.eagle.core.function.api.setting
/**
* 座椅压力事件监听回调接口
*/
interface ISeatPressureEventListener {
fun onUpdateBgEvent(isPress: Boolean){}
}

View File

@@ -0,0 +1,20 @@
package com.mogo.eagle.core.function.call.setting
import com.mogo.eagle.core.function.api.setting.ISeatPressureEventListener
import com.mogo.eagle.core.function.call.base.CallerBase
import java.util.concurrent.ConcurrentHashMap
/**
* 座椅压力事件监听管理
*/
object CallerSeatPressureManager: CallerBase<ISeatPressureEventListener>() {
fun invokeUpdateBgEvent(isPress: Boolean){
M_LISTENERS.forEach {
val tag = it.key
val listener = it.value
listener.onUpdateBgEvent(isPress)
}
}
}