将自动驾驶控制按钮移动到HMI中,还需要制定状态监听等回调

Signed-off-by: 董宏宇 <martindhy@gmail.com>
This commit is contained in:
董宏宇
2021-09-22 20:13:00 +08:00
committed by liujing
parent db01f29d68
commit c204c60894
28 changed files with 273 additions and 103 deletions

4
.idea/misc.xml generated
View File

@@ -13,8 +13,10 @@
<map>
<entry key="../../../../../../layout/custom_preview.xml" value="0.390625" />
<entry key="../../../../../layout/custom_preview.xml" value="0.19947916666666668" />
<entry key="core/function-impl/mogo-core-function-hmi/src/main/res/layout/fragment_hmi.xml" value="0.18177083333333333" />
<entry key="OCH/mogo-och/src/main/res/layout/module_mogo_och_base_fragment.xml" value="0.27239583333333334" />
<entry key="core/function-impl/mogo-core-function-hmi/src/main/res/layout/fragment_hmi.xml" value="0.25" />
<entry key="core/function-impl/mogo-core-function-hmi/src/main/res/layout/fragment_warning.xml" value="0.19895833333333332" />
<entry key="core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_autopilot_status.xml" value="1.0" />
<entry key="modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_entrance.xml" value="0.18333333333333332" />
<entry key="modules/mogo-module-hmi/src/main/res/layout/fragment_warning.xml" value="0.34427083333333336" />
<entry key="modules/mogo-module-hmi/src/main/res/layout/module_hmi_warning_v2x.xml" value="0.246875" />

View File

@@ -29,7 +29,9 @@ class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>
var mWarningFloat: WarningFloat.Builder? = null
override fun initViews() {}
override fun initViews() {
autopilotStatus.visibility = View.VISIBLE
}
override fun getLayoutId(): Int {
return R.layout.fragment_hmi

View File

@@ -0,0 +1,70 @@
package com.mogo.eagle.core.function.hmi.ui.widget
import android.content.Context
import android.content.res.TypedArray
import android.util.AttributeSet
import android.view.LayoutInflater
import androidx.constraintlayout.widget.ConstraintLayout
import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.utilcode.util.LogUtils
import kotlinx.android.synthetic.main.view_autopilot_status.view.*
/**
* @author xiaoyuzhou
* @date 2021/9/22 3:59 下午
* 自动驾驶状态按钮
*/
class AutoPilotStatusView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet
) : ConstraintLayout(context, attrs) {
private val TAG = "AutopilotStatusView"
private var mAutopilotStatus: Int = 0
init {
val typedArray: TypedArray =
context.obtainStyledAttributes(attrs, R.styleable.AutopilotStatusView)
mAutopilotStatus = typedArray.getInt(R.styleable.AutopilotStatusView_autopilotStatus, 0)
typedArray.recycle()
LogUtils.dTag(TAG, "autopilotStatus: $mAutopilotStatus")
initView(context)
}
private fun initView(context: Context) {
LayoutInflater.from(context).inflate(R.layout.view_autopilot_status, this, true)
val lp = LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)
layoutParams = lp
setAutoPilotStatus(mAutopilotStatus)
}
/**
* 设置自动驾驶状态
* 0-// 不可自动驾驶adas与工控机没有链接或工控机异常
* 1-// 可自动驾驶,目前处于人工干预状态
* 2-// 自动驾驶中
*/
fun setAutoPilotStatus(autopilotStatus: Int) {
mAutopilotStatus = autopilotStatus
when (autopilotStatus) {
0 -> {// 不可自动驾驶adas与工控机没有链接或工控机异常
clAutopilotStatus.setBackgroundResource(R.drawable.module_hmi_autopilot_status_disabled_bg)
tvStatusDes.setTextColor(resources.getColor(R.color.module_mogo_autopilot_status_disable))
}
1 -> {// 可自动驾驶,目前处于人工干预状态
clAutopilotStatus.setBackgroundResource(R.drawable.module_hmi_autopilot_status_enable_bg)
tvStatusDes.setTextColor(resources.getColor(R.color.module_mogo_autopilot_status_enable))
}
2 -> {// 自动驾驶中
clAutopilotStatus.setBackgroundResource(R.drawable.module_hmi_autopilot_status_checked_bg)
tvStatusDes.setTextColor(resources.getColor(R.color.module_mogo_autopilot_status_enable))
}
}
}
}

View File

@@ -18,12 +18,24 @@
android:id="@+id/flSpeedChartView"
android:layout_width="@dimen/module_ext_speed_width"
android:layout_height="@dimen/module_ext_speed_height"
android:layout_marginLeft="@dimen/dp_40"
android:layout_marginTop="@dimen/dp_40"
android:layout_marginLeft="@dimen/module_mogo_autopilot_status_margin_left"
android:layout_marginTop="@dimen/module_ext_arcView_top"
android:elevation="@dimen/dp_10"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.mogo.eagle.core.function.hmi.ui.widget.AutoPilotStatusView
android:id="@+id/autopilotStatus"
android:layout_width="@dimen/module_mogo_autopilot_status_bg_width"
android:layout_height="@dimen/module_mogo_autopilot_status_bg_height"
android:layout_marginTop="@dimen/module_mogo_autopilot_status_margin_top"
android:elevation="@dimen/dp_10"
android:visibility="gone"
app:layout_constraintLeft_toLeftOf="@+id/flSpeedChartView"
app:layout_constraintTop_toBottomOf="@+id/flSpeedChartView"
tools:autopilotStatus="running"
tools:visibility="visible" />
<com.mogo.eagle.core.function.hmi.ui.widget.TrafficLightView
android:id="@+id/viewTrafficLightVr"
android:layout_width="wrap_content"

View File

@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/clAutopilotStatus"
android:layout_width="@dimen/module_mogo_autopilot_status_bg_width"
android:layout_height="@dimen/module_mogo_autopilot_status_bg_height"
android:background="@drawable/module_hmi_autopilot_status_bg">
<ImageView
android:id="@+id/ivStatusIcon"
android:layout_width="@dimen/module_mogo_autopilot_status_icon_width"
android:layout_height="@dimen/module_mogo_autopilot_status_icon_width"
android:layout_marginStart="@dimen/module_mogo_autopilot_status_icon_margin"
android:src="@drawable/icon_autopilot_status"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tvStatusDes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/module_mogo_autopilot_status_text_margin_start"
android:text="自动驾驶"
android:textColor="#FFFFFF"
android:textSize="@dimen/module_mogo_autopilot_status_text_size"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/ivStatusIcon"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -41,7 +41,7 @@ android {
sourceSets {
main {
res.srcDirs = [
'src/main/function-common-res',
'src/main/res',
'src/main/function-adas-res',
'src/main/function-chat-res',
'src/main/function-check-res',

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

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/module_hmi_autopilot_status_checked_bg" android:state_checked="true" />
<item android:drawable="@drawable/module_hmi_autopilot_status_enable_bg" android:state_checked="false" android:state_enabled="true" />
<item android:drawable="@drawable/module_hmi_autopilot_status_disabled_bg" android:state_checked="false" android:state_enabled="false" />
</selector>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:bottomLeftRadius="@dimen/module_hmi_autopilot_status_bg_sm_radius"
android:bottomRightRadius="@dimen/module_hmi_autopilot_status_bg_big_radius"
android:topLeftRadius="@dimen/module_hmi_autopilot_status_bg_big_radius"
android:topRightRadius="@dimen/module_hmi_autopilot_status_bg_sm_radius" />
<gradient
android:angle="315"
android:endColor="#2B6EFF"
android:startColor="#2B6EFF" />
</shape>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:bottomLeftRadius="@dimen/module_hmi_autopilot_status_bg_sm_radius"
android:bottomRightRadius="@dimen/module_hmi_autopilot_status_bg_big_radius"
android:topLeftRadius="@dimen/module_hmi_autopilot_status_bg_big_radius"
android:topRightRadius="@dimen/module_hmi_autopilot_status_bg_sm_radius" />
<gradient
android:angle="315"
android:endColor="#364071"
android:startColor="#364071" />
</shape>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:bottomLeftRadius="@dimen/module_hmi_autopilot_status_bg_sm_radius"
android:bottomRightRadius="@dimen/module_hmi_autopilot_status_bg_big_radius"
android:topLeftRadius="@dimen/module_hmi_autopilot_status_bg_big_radius"
android:topRightRadius="@dimen/module_hmi_autopilot_status_bg_sm_radius" />
<gradient
android:angle="315"
android:endColor="#3B4577"
android:startColor="#3B4577" />
</shape>

View File

@@ -5,8 +5,8 @@
android:endColor="#3B4577"
android:startColor="#3B4577" />
<corners
android:bottomLeftRadius="130px"
android:bottomRightRadius="30px"
android:topLeftRadius="30px"
android:topRightRadius="130px" />
android:bottomLeftRadius="@dimen/module_ext_speed_width_big_radius"
android:bottomRightRadius="@dimen/module_ext_speed_width_sm_radius"
android:topLeftRadius="@dimen/module_ext_speed_width_sm_radius"
android:topRightRadius="@dimen/module_ext_speed_width_big_radius" />
</shape>

View File

@@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="module_ext_speed_width">460px</dimen>
<dimen name="module_ext_speed_height">460px</dimen>
<dimen name="module_ext_arcView_width">320px</dimen>
<dimen name="module_ext_arcView_height">320px</dimen>
<dimen name="module_ext_arcView_stroke_with">20px</dimen>
<dimen name="module_ext_arcView_center_text_size">110px</dimen>
<dimen name="module_ext_arcView_des_text_size">40px</dimen>
</resources>

View File

@@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="module_ext_speed_width">300px</dimen>
<dimen name="module_ext_speed_height">300px</dimen>
<dimen name="module_ext_arcView_width">200px</dimen>
<dimen name="module_ext_arcView_height">200px</dimen>
<dimen name="module_ext_arcView_stroke_with">10px</dimen>
<dimen name="module_ext_arcView_center_text_size">80px</dimen>
<dimen name="module_ext_arcView_des_text_size">28px</dimen>
</resources>

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="module_ext_speed_width">460px</dimen>
<dimen name="module_ext_speed_height">460px</dimen>
<dimen name="module_ext_speed_width_sm_radius">30px</dimen>
<dimen name="module_ext_speed_width_big_radius">130px</dimen>
<dimen name="module_ext_arcView_top">40px</dimen>
<dimen name="module_ext_arcView_width">320px</dimen>
<dimen name="module_ext_arcView_height">320px</dimen>
<dimen name="module_ext_arcView_stroke_with">20px</dimen>
<dimen name="module_ext_arcView_center_text_size">110px</dimen>
<dimen name="module_ext_arcView_des_text_size">40px</dimen>
<dimen name="module_mogo_autopilot_status_icon_width">74px</dimen>
<dimen name="module_mogo_autopilot_status_icon_margin">92px</dimen>
<dimen name="module_mogo_autopilot_status_bg_width">460px</dimen>
<dimen name="module_mogo_autopilot_status_bg_height">140px</dimen>
<dimen name="module_mogo_autopilot_status_margin_left">40px</dimen>
<dimen name="module_mogo_autopilot_status_margin_top">30px</dimen>
<dimen name="module_mogo_autopilot_status_padding">92px</dimen>
<dimen name="module_mogo_autopilot_status_text_size">44px</dimen>
<dimen name="module_mogo_autopilot_status_text_margin_start">28px</dimen>
<dimen name="module_hmi_autopilot_status_bg_sm_radius">30px</dimen>
<dimen name="module_hmi_autopilot_status_bg_big_radius">70px</dimen>
</resources>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="module_mogo_autopilot_status_enable">#FFFFFF</color>
<color name="module_mogo_autopilot_status_disable">#4DFFFFFF</color>
</resources>

View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="module_ext_speed_width">300px</dimen>
<dimen name="module_ext_speed_height">300px</dimen>
<dimen name="module_ext_speed_width_sm_radius">20px</dimen>
<dimen name="module_ext_speed_width_big_radius">110px</dimen>
<dimen name="module_ext_arcView_top">40px</dimen>
<dimen name="module_ext_arcView_width">200px</dimen>
<dimen name="module_ext_arcView_height">200px</dimen>
<dimen name="module_ext_arcView_stroke_with">10px</dimen>
<dimen name="module_ext_arcView_center_text_size">80px</dimen>
<dimen name="module_ext_arcView_des_text_size">28px</dimen>
<dimen name="module_mogo_autopilot_status_icon_width">46px</dimen>
<dimen name="module_mogo_autopilot_status_icon_margin">60px</dimen>
<dimen name="module_mogo_autopilot_status_bg_width">300px</dimen>
<dimen name="module_mogo_autopilot_status_bg_height">100px</dimen>
<dimen name="module_mogo_autopilot_status_margin_left">40px</dimen>
<dimen name="module_mogo_autopilot_status_margin_top">30px</dimen>
<dimen name="module_mogo_autopilot_status_padding">20px</dimen>
<dimen name="module_mogo_autopilot_status_text_size">30px</dimen>
<dimen name="module_mogo_autopilot_status_text_margin_start">18px</dimen>
<dimen name="module_hmi_autopilot_status_bg_sm_radius">20px</dimen>
<dimen name="module_hmi_autopilot_status_bg_big_radius">50px</dimen>
</resources>

View File

@@ -11,4 +11,12 @@
<attr name="civ_border_overlay" format="boolean" />
<attr name="civ_fill_color" format="color" />
</declare-styleable>
<declare-styleable name="AutopilotStatusView">
<attr name="autopilotStatus">
<enum name="disable" value="0" />
<enum name="enable" value="1" />
<enum name="running" value="2" />
</attr>
</declare-styleable>
</resources>

View File

@@ -215,7 +215,7 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
private TextView tvRed;
private TextView tvGreen;
private CheckedTextView ctvAutopilotStatus;
// private CheckedTextView ctvAutopilotStatus;
/**
* 内部变量标识是否在vrMode用于方法执行过滤避免重复或异常调用
@@ -285,7 +285,7 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
mMove2CurrentLocation = findViewById(R.id.module_entrance_id_move2_current_location);
mUserHeadImg = findViewById(R.id.ivUserHeadImg);
groupFix = findViewById(R.id.groupFix);
ctvAutopilotStatus = findViewById(R.id.module_mogo_autopilot_status);
// ctvAutopilotStatus = findViewById(R.id.module_mogo_autopilot_status);
ConstraintLayout rootView = findViewById(R.id.module_entrance_id_top_motion_layout);
if (rootView != null) {
@@ -356,16 +356,16 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
});
}
onAutopilotStatusChanged(
MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus() == IMogoAdasOCHCallback.STATUS_AUTOPILOT_RUNNING);
// onAutopilotStatusChanged(
// MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus() == IMogoAdasOCHCallback.STATUS_AUTOPILOT_RUNNING);
ctvAutopilotStatus.setOnClickListener(new OnPreventFastClickListener() {
@Override
public void onClickImpl(View v) {
// 如果能自动驾驶,就自动驾驶,不能就提示
autopilotStatusClick();
}
});
// ctvAutopilotStatus.setOnClickListener(new OnPreventFastClickListener() {
// @Override
// public void onClickImpl(View v) {
// // 如果能自动驾驶,就自动驾驶,不能就提示
// autopilotStatusClick();
// }
// });
dealWeatherContainer();
@@ -414,16 +414,16 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
}
/**
* 自动驾驶状态改变
*
* @param isInAutopilot true - 在自动驾驶中 false - 不在自动驾驶中
*/
public void onAutopilotStatusChanged(boolean isInAutopilot) {
getActivity().runOnUiThread(() -> {
ctvAutopilotStatus.setChecked(isInAutopilot);
});
}
// /**
// * 自动驾驶状态改变
// *
// * @param isInAutopilot true - 在自动驾驶中 false - 不在自动驾驶中
// */
// public void onAutopilotStatusChanged(boolean isInAutopilot) {
// getActivity().runOnUiThread(() -> {
// ctvAutopilotStatus.setChecked(isInAutopilot);
// });
// }
private void autopilotStatusClick() {
EntranceViewHolder.getInstance().entranceAutopilotStatusClick();
@@ -443,7 +443,7 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
mMsgContainer.setVisibility(View.GONE);
groupUserHead.setVisibility(View.GONE);
groupUserHead.setVisibility(View.GONE);
ctvAutopilotStatus.setVisibility(View.VISIBLE);
// ctvAutopilotStatus.setVisibility(View.VISIBLE);
// tvExitVrMode.setVisibility(View.VISIBLE);
TopViewAnimHelper.getInstance().enterVrMode();
TopViewNoLinkageAnimHelper.getInstance().enterVrMode();
@@ -1438,6 +1438,6 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
@Override
public void onStateChanged(int state, String reason) {
ctvAutopilotStatus.setChecked(state == IMogoAdasOCHCallback.STATUS_AUTOPILOT_RUNNING);
// ctvAutopilotStatus.setChecked(state == IMogoAdasOCHCallback.STATUS_AUTOPILOT_RUNNING);
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

View File

@@ -1,16 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true">
<shape android:shape="rectangle">
<corners android:bottomLeftRadius="20px" android:bottomRightRadius="45px" android:topLeftRadius="45px" android:topRightRadius="20px" />
<gradient android:angle="315" android:endColor="#2B6EFF" android:startColor="#2B6EFF" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<corners android:bottomLeftRadius="20px" android:bottomRightRadius="45px" android:topLeftRadius="45px" android:topRightRadius="20px" />
<gradient android:angle="315" android:endColor="#3B4577" android:startColor="#3B4577" />
</shape>
</item>
</selector>

View File

@@ -6,27 +6,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<CheckedTextView
android:id="@+id/module_mogo_autopilot_status"
android:layout_width="@dimen/module_mogo_autopilot_status_bg_width"
android:layout_height="@dimen/module_mogo_autopilot_status_bg_height"
android:layout_marginLeft="@dimen/module_mogo_autopilot_status_margin_left"
android:layout_marginTop="@dimen/module_mogo_autopilot_status_margin_top"
android:background="@drawable/module_mogo_autopilot_status_bg"
android:drawableLeft="@drawable/module_ext_ic_autopilot"
android:drawablePadding="@dimen/dp_30"
android:elevation="@dimen/dp_10"
android:gravity="center_vertical"
android:visibility="gone"
android:paddingLeft="@dimen/module_mogo_autopilot_status_padding"
android:text="自动驾驶"
android:textColor="#FFFFFF"
android:textSize="@dimen/module_mogo_autopilot_status_text_size"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible" />
<include
layout="@layout/module_ext_layout_extensions"
android:layout_width="match_parent"

View File

@@ -9,10 +9,5 @@
<dimen name="module_switch_image">50px</dimen>
<dimen name="module_switch_image_circle">60px</dimen>
<dimen name="module_mogo_autopilot_status_bg_width">460px</dimen>
<dimen name="module_mogo_autopilot_status_bg_height">140px</dimen>
<dimen name="module_mogo_autopilot_status_margin_left">20px</dimen>
<dimen name="module_mogo_autopilot_status_margin_top">530px</dimen>
<dimen name="module_mogo_autopilot_status_padding">92px</dimen>
<dimen name="module_mogo_autopilot_status_text_size">44px</dimen>
</resources>

View File

@@ -251,11 +251,5 @@
<dimen name="module_switch_image">35px</dimen>
<dimen name="module_switch_image_circle">38px</dimen>
<dimen name="module_mogo_autopilot_status_bg_width">300px</dimen>
<dimen name="module_mogo_autopilot_status_bg_height">100px</dimen>
<dimen name="module_mogo_autopilot_status_margin_left">20px</dimen>
<dimen name="module_mogo_autopilot_status_margin_top">345px</dimen>
<dimen name="module_mogo_autopilot_status_padding">20px</dimen>
<dimen name="module_mogo_autopilot_status_text_size">30px</dimen>
</resources>