diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/operate/OperatePanelLayout.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/operate/OperatePanelLayout.kt index 2c7eb802e3..c373b2befc 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/operate/OperatePanelLayout.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/operate/OperatePanelLayout.kt @@ -56,6 +56,8 @@ import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager import com.mogo.eagle.core.function.call.unmanned.CallerUnmannedListenerManager import com.mogo.eagle.core.function.call.vehicle.CallerSweeperModeListenerManager import com.mogo.eagle.core.function.hmi.R +import com.mogo.eagle.core.function.hmi.ui.operate.preferences.PreferenceGrayableCheckBox +import com.mogo.eagle.core.function.hmi.ui.operate.preferences.PreferenceGrayableSwitch import com.mogo.eagle.core.function.hmi.ui.operate.preferences.PreferenceWithMoFang import com.mogo.eagle.core.function.hmi.ui.operate.preferences.PreferenceWithSpeedSetting import com.mogo.eagle.core.function.hmi.ui.operate.preferences.PreferenceWithUnmanInterval @@ -1501,7 +1503,7 @@ class OperatePanelLayout : LinearLayout { // CallerAutoPilotControlManager class VehiclesPreferenceFragmentCompat : OperatePanelDetailBase(), IMoGoAutopilotCarConfigListener, ISopSettingListener, IViewControlListener, IMoGoGetParamResponseListener, IMoGoAutopilotStatusListener{ - private var v2xIsShow: Boolean = false + private var vehIsShow: Boolean = false private var operatePaneIsShow = true private var prevIpcConnectStatus = false private var customToast: Toast? = null @@ -1509,7 +1511,7 @@ class OperatePanelLayout : LinearLayout { private const val TAG = "VehiclesPreferenceFragmentCompat" private const val IS_CHECKED_DRIVING_STYLE = "is_checked_driving_style" - private const val WHAT_UPDATE_ENABLE = 0x00//更新按钮状态 + private const val WHAT_UPDATE_ENABLE = 0x01//更新按钮状态 private const val KEY_PNC_PARK_INTERSECTION_CAR = "pnc_park_intersection_car" private const val KEY_PNC_PARK_OVERTAKE_CAR = "pnc_park_overtake_car" @@ -1560,12 +1562,13 @@ class OperatePanelLayout : LinearLayout { FunctionBuildConfig.appIdentityMode ) ) { - preferenceScreen.findPreferenceReal(KEY_AIP_FUNCTION)?.isVisible= false + preferenceScreen.findPreferenceReal(KEY_AIP_FUNCTION)?.isVisible= false preferenceScreen.findPreference("header_driving_style")?.isVisible = false - preferenceScreen.findPreferenceReal(KEY_DRIVING_STYLE_NORMAL)?.isVisible= false - preferenceScreen.findPreferenceReal(KEY_DRIVING_STYLE_SAFETY)?.isVisible= false - preferenceScreen.findPreferenceReal( KEY_DRIVING_STYLE_PROFESSIONAL)?.isVisible= false + preferenceScreen.findPreferenceReal(KEY_DRIVING_STYLE_NORMAL)?.isVisible= false + preferenceScreen.findPreferenceReal(KEY_DRIVING_STYLE_SAFETY)?.isVisible= false + preferenceScreen.findPreferenceReal( KEY_DRIVING_STYLE_PROFESSIONAL)?.isVisible= false } + updateAutopilotActiveBtnDisableState() return super.onCreateView(inflater, container, savedInstanceState) } @@ -1583,7 +1586,7 @@ class OperatePanelLayout : LinearLayout { super.operatePanelDisplayStatus(isShow) operatePaneIsShow = isShow if (isShow) { - if (v2xIsShow) { + if (vehIsShow) { handler.sendEmptyMessage(WHAT_UPDATE_ENABLE) } } else { @@ -1596,7 +1599,7 @@ class OperatePanelLayout : LinearLayout { override fun onResume() { super.onResume() prevIpcConnectStatus = AppConfigInfo.isConnectAutopilot - v2xIsShow = true + vehIsShow = true if (operatePaneIsShow) { handler.sendEmptyMessage(WHAT_UPDATE_ENABLE) } @@ -1604,7 +1607,7 @@ class OperatePanelLayout : LinearLayout { override fun onPause() { super.onPause() - v2xIsShow = false + vehIsShow = false handler.removeMessages(WHAT_UPDATE_ENABLE) customToast?.cancel() customToast = null @@ -1619,6 +1622,7 @@ class OperatePanelLayout : LinearLayout { } setEnableStatus(AppConfigInfo.isConnectAutopilot) if (AppConfigInfo.isConnectAutopilot) { + updateAutopilotActiveBtnDisableState() customToast?.cancel() customToast = null } else { @@ -1653,7 +1657,7 @@ class OperatePanelLayout : LinearLayout { reason: String? ) { if (prevIpcConnectStatus != AppConfigInfo.isConnectAutopilot) { - if (operatePaneIsShow && v2xIsShow) { + if (operatePaneIsShow && vehIsShow) { handler.sendEmptyMessage(WHAT_UPDATE_ENABLE) } } @@ -1689,13 +1693,25 @@ class OperatePanelLayout : LinearLayout { //融合模式 - 纯路侧模式 preferenceScreen.findPreferenceReal(KEY_PURE_OBU_MODE)?.isEnabled = isEnable //AIP功能 - preferenceScreen.findPreferenceReal(KEY_AIP_FUNCTION)?.isEnabled = isEnable + preferenceScreen.findPreferenceReal(KEY_AIP_FUNCTION)?.let { + it.shouldDisableView = true + it.isEnabled = isEnable + } //驾驶模式 - 正常模式 - preferenceScreen.findPreferenceReal(KEY_DRIVING_STYLE_NORMAL)?.isEnabled = isEnable + preferenceScreen.findPreferenceReal(KEY_DRIVING_STYLE_NORMAL)?.let { + it.shouldDisableView = true + it.isEnabled = isEnable + } //驾驶模式 - 安全模式 - preferenceScreen.findPreferenceReal(KEY_DRIVING_STYLE_SAFETY)?.isEnabled = isEnable + preferenceScreen.findPreferenceReal(KEY_DRIVING_STYLE_SAFETY)?.let { + it.shouldDisableView = true + it.isEnabled = isEnable + } //驾驶模式 - 专业模式 - preferenceScreen.findPreferenceReal(KEY_DRIVING_STYLE_PROFESSIONAL)?.isEnabled = isEnable + preferenceScreen.findPreferenceReal(KEY_DRIVING_STYLE_PROFESSIONAL)?.let { + it.shouldDisableView = true + it.isEnabled = isEnable + } //自动驾驶速度阈值 preferenceScreen.findPreferenceReal(KEY_AUTO_PILOT_SPEED_THRESHOLDS)?.isEnabled = isEnable //变道速度阈值 @@ -1704,6 +1720,43 @@ class OperatePanelLayout : LinearLayout { preferenceScreen.findPreferenceReal(KEY_OVERTAKE_SPEED_THRESHOLDSS)?.isEnabled = isEnable } + override fun onAutopilotStatusResponse(state: Int) { + super.onAutopilotStatusResponse(state) + CallerLogger.i(TAG,"自驾状态=${state}") + ThreadUtils.runOnUiThread { + updateAutopilotActiveBtnDisableState() + } + } + + //自驾中不允许操作的按钮 + private fun updateAutopilotActiveBtnDisableState() { + if (AppConfigInfo.isConnectAutopilot) { + val isEnable = CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().state != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING + CallerLogger.i(TAG, "isEnable=$isEnable 自驾状态=${CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().state}") + //AIP功能 + preferenceScreen.findPreferenceReal(KEY_AIP_FUNCTION)?.let { + it.shouldDisableView = isEnable + it.isEnabled = isEnable + } + //驾驶模式 - 正常模式 + preferenceScreen.findPreferenceReal(KEY_DRIVING_STYLE_NORMAL)?.let { + it.shouldDisableView = isEnable + it.isEnabled = isEnable + } + //驾驶模式 - 安全模式 + preferenceScreen.findPreferenceReal(KEY_DRIVING_STYLE_SAFETY)?.let { + it.shouldDisableView = isEnable + it.isEnabled = isEnable + } + //驾驶模式 - 专业模式 + preferenceScreen.findPreferenceReal(KEY_DRIVING_STYLE_PROFESSIONAL)?.let { + it.shouldDisableView = isEnable + it.isEnabled = isEnable + } + } + + } + override fun updateFuncMode(tag: String, boolean: Boolean) { super.updateFuncMode(tag, boolean) if (tag == FUNC_MODE_RAIN) { @@ -1795,7 +1848,7 @@ class OperatePanelLayout : LinearLayout { ) if (adasParam.activateAip != -1) { ThreadUtils.runOnUiThread { - preferenceScreen.findPreferenceReal( + preferenceScreen.findPreferenceReal( KEY_AIP_FUNCTION )?.also { changeValue(it, adasParam.activateAip == 1) } } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/operate/preferences/PreferenceGrayableCheckBox.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/operate/preferences/PreferenceGrayableCheckBox.kt new file mode 100644 index 0000000000..a02ff309ef --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/operate/preferences/PreferenceGrayableCheckBox.kt @@ -0,0 +1,17 @@ +package com.mogo.eagle.core.function.hmi.ui.operate.preferences + +import android.content.Context +import android.util.AttributeSet +import androidx.preference.CheckBoxPreference +import androidx.preference.PreferenceViewHolder + +class PreferenceGrayableCheckBox(context: Context, attrs: AttributeSet) : + CheckBoxPreference(context, attrs) { + + override fun onBindViewHolder(holder: PreferenceViewHolder) { + super.onBindViewHolder(holder) + // 根据启用状态设置alpha值 + holder.findViewById(android.R.id.checkbox)?.alpha = + if (isEnabled && shouldDisableView) 1f else 0.6f + } +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/operate/preferences/PreferenceGrayableSwitch.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/operate/preferences/PreferenceGrayableSwitch.kt new file mode 100644 index 0000000000..a018e47cb4 --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/operate/preferences/PreferenceGrayableSwitch.kt @@ -0,0 +1,18 @@ +package com.mogo.eagle.core.function.hmi.ui.operate.preferences + +import android.content.Context +import android.util.AttributeSet +import androidx.preference.PreferenceViewHolder +import androidx.preference.SwitchPreferenceCompat +import com.mogo.eagle.core.function.hmi.R + +class PreferenceGrayableSwitch(context: Context, attrs: AttributeSet) : + SwitchPreferenceCompat(context, attrs) { + + override fun onBindViewHolder(holder: PreferenceViewHolder) { + super.onBindViewHolder(holder) + // 根据启用状态设置alpha值 + holder.findViewById(R.id.switchWidget)?.alpha = + if (isEnabled && shouldDisableView) 1f else 0.6f + } +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/xml/operate_panel_preference_details_vehicles.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/xml/operate_panel_preference_details_vehicles.xml index 8076b3c11d..f2fbcc89a6 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/xml/operate_panel_preference_details_vehicles.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/xml/operate_panel_preference_details_vehicles.xml @@ -78,7 +78,7 @@ android:title="纯路侧模式" android:persistent="false" android:widgetLayout="@layout/layout_operate_panel_preference_widget_checkbox_compat" /> - - - -