diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerMapDirectionView.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerMapDirectionView.java index 5213372938..bbd2a17c1d 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerMapDirectionView.java +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerMapDirectionView.java @@ -199,21 +199,22 @@ public class BusPassengerMapDirectionView //圈定地图显示范围 LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder(); - if (mLineStationLatLng.size() > 0){ +// if (mLineStationLatLng.size() > 0){ +// //存放经纬度 +// for (int i = 0; i < mLineStationLatLng.size(); i++) { +// boundsBuilder.include(mLineStationLatLng.get(i)); +// } +// //第二个参数为四周留空宽度 +// } + + if (mCoordinatesLatLng.size() > 0){ //存放经纬度 - for (int i = 0; i < mLineStationLatLng.size(); i++) { - boundsBuilder.include(mLineStationLatLng.get(i)); + for (int i = 0; i < mCoordinatesLatLng.size(); i++) { + boundsBuilder.include(mCoordinatesLatLng.get(i)); } //第二个参数为四周留空宽度 - } -// else { - //第二个参数为四周留空宽度 - //设置希望展示的地图缩放级别 -// CameraPosition cameraPosition = new CameraPosition.Builder() -// .target(mCarMarker.getPosition()).tilt(0).bearing(location.getBearing()).zoom(zoomLevel).build(); -// mAMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); -// } + boundsBuilder.include(currentLatLng); mAMap.moveCamera(CameraUpdateFactory.newLatLngBoundsRect(boundsBuilder.build(),100,100,100,100)); } diff --git a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/biz/PassiveBadCaseWindow.kt b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/biz/PassiveBadCaseWindow.kt index 58e49237c1..cfb42c46b6 100644 --- a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/biz/PassiveBadCaseWindow.kt +++ b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/biz/PassiveBadCaseWindow.kt @@ -37,6 +37,7 @@ import kotlinx.coroutines.launch import mogo.telematics.pad.MessagePad import com.zhidao.loglib.upload.UploadManager import me.jessyan.autosize.utils.AutoSizeUtils +import org.greenrobot.eventbus.EventBus import java.io.File import java.lang.reflect.Field @@ -139,6 +140,7 @@ class PassiveBadCaseWindow constructor(activity: Activity) : View.OnTouchListene } //删除记录 CallerMsgBoxManager.removeRecordInfo(mActivity, boxBean!!, recordKey!!) + EventBus.getDefault().post(boxBean) } tvPassiveCancel.setOnClickListener { @@ -146,6 +148,7 @@ class PassiveBadCaseWindow constructor(activity: Activity) : View.OnTouchListene clickListener?.closeWindow() //删除记录 CallerMsgBoxManager.removeRecordInfo(mActivity, boxBean!!, recordKey!!) + EventBus.getDefault().post(boxBean) } mWindowParams = WindowManager.LayoutParams() @@ -335,8 +338,6 @@ class PassiveBadCaseWindow constructor(activity: Activity) : View.OnTouchListene } override fun onCheckedChanged(buttonView: CompoundButton?, isChecked: Boolean) { - Log.i("onCheckedChanged","buttonView"+buttonView) - Log.i("onCheckedChanged","isChecked"+isChecked) buttonView?.text?.let { if(isChecked){ if(!uploadReason.contains(it)){ diff --git a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/mofang/MoFangManager.kt b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/mofang/MoFangManager.kt index 62dad7b169..e32531ee91 100644 --- a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/mofang/MoFangManager.kt +++ b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/mofang/MoFangManager.kt @@ -7,12 +7,16 @@ import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import android.content.IntentFilter -import android.util.Log -import com.mogo.commons.context.ContextHolderUtil.getContext +import com.mogo.eagle.core.data.mofang.MfConstants import com.mogo.eagle.core.function.call.hmi.CallerHmiManager.updateMfStatusView +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_F import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr +/** + * 魔方连接状态和设备管理 + */ @SuppressLint("StaticFieldLeak") class MoFangManager private constructor() { @@ -24,58 +28,61 @@ class MoFangManager private constructor() { private var mContext: Context? = null private val TAG = "MoFangManager" - private val mBluetoothAdapter: BluetoothAdapter? = null - private var deviceName = "" - //添加状态判断 - private var isMfConnect: Boolean = false + private lateinit var mBluetoothAdapter: BluetoothAdapter + private var isMfConnect: Boolean = false //添加状态判断 fun init(context: Context) { -// initBluetooth() -// mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter() -// if (!mBluetoothAdapter.isEnabled) { -// mBluetoothAdapter.enable() -// } -// mBluetoothAdapter.startDiscovery() -// showBondedDevice(mBluetoothAdapter) + mContext = context + initBluetooth(context) + mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter() + if (!mBluetoothAdapter.isEnabled) { + mBluetoothAdapter.enable() + } + mBluetoothAdapter.startDiscovery() + showBondedDevice(mBluetoothAdapter) } /** * 初始化蓝牙广播 */ - private fun initBluetooth() { + private fun initBluetooth(context: Context) { val intentFilter = IntentFilter(); // 监视蓝牙关闭和打开的状态 - intentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); + intentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED) // 监视蓝牙设备与APP连接的状态 - intentFilter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED); - intentFilter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED); + intentFilter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED) + intentFilter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED) // 注册广播 - getContext().registerReceiver(bluetoothMonitorReceiver, intentFilter); + context.registerReceiver(bluetoothMonitorReceiver, intentFilter) } /** * 查找蓝牙连接过的蓝牙设备 */ private fun showBondedDevice(bluetoothAdapter: BluetoothAdapter) { -// val deviceList = bluetoothAdapter.bondedDevices -// for (device in deviceList) { -// try { -// //使用反射调用获取设备连接状态方法 -// val isConnectedMethod = BluetoothDevice::class.java.getDeclaredMethod( -// "isConnected", -// *null as Array?>? -// ) -// isConnectedMethod.isAccessible = true -//// boolean isConnected = (boolean) isConnectedMethod.invoke(device, (Object[]) null); -// Log.d(TAG, "-- device.getName() = " + device.name) //device.getAddress() -// if (device.name == "MINI_KEYBOARD") { //并且连接 TODO -// SharedPrefsMgr.getInstance(getContext()).putString("BLUETOOTH", device.name) -// } -// } catch (e: NoSuchMethodException) { -// e.printStackTrace() -// } -// } + if (bluetoothAdapter != null) { + val deviceList = bluetoothAdapter.bondedDevices + for (device in deviceList) { + try { + //使用反射调用获取设备连接状态方 + val isConnectedMethod = BluetoothDevice::class.java.getDeclaredMethod("isConnected") + isConnectedMethod.isAccessible = true + val isConnected = isConnectedMethod.invoke(device) as Boolean + CallerLogger.d("$M_F${TAG}"," showBondedDevice name = ${device.name} ---address = ${device.address}----isMfConnect = $isMfConnect ---isConnected = $isConnected") + if (device.name == "MINI_KEYBOARD") { //并且连接 + mContext?.let { SharedPrefsMgr.getInstance(it).putString(MfConstants.BLUETOOTH_NAME, device.name) } + } + + mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean(MfConstants.BLUETOOTH_STATUS, isConnected) } + if (isConnected) { + isMfConnect = true + } + } catch (e: NoSuchMethodException) { + e.printStackTrace() + } + } + } } @@ -83,27 +90,30 @@ class MoFangManager private constructor() { override fun onReceive(context: Context, intent: Intent) { when (intent.action) { BluetoothAdapter.ACTION_STATE_CHANGED -> { //中间状态 - + CallerLogger.d("$M_F${TAG}","bluetoothMonitorReceiver ACTION_STATE_CHANGED action = ${intent.action}") } BluetoothDevice.ACTION_ACL_CONNECTED -> { //蓝牙设备已连接 if (!isMfConnect) { - updateMfStatusView("mofang", true) +// showBondedDevice(mBluetoothAdapter) + updateMfStatusView(TAG, true) isMfConnect = true + mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean(MfConstants.BLUETOOTH_STATUS, true) } } + CallerLogger.d("$M_F${TAG}","bluetoothMonitorReceiver ACTION_ACL_CONNECTED ----- isMfConnect = $isMfConnect") } - BluetoothDevice.ACTION_ACL_DISCONNECTED -> { //蓝牙设备已断开 主动更新 TODO + BluetoothDevice.ACTION_ACL_DISCONNECTED -> { //蓝牙设备已断开 主动更新 + CallerLogger.d("$M_F${TAG}","bluetoothMonitorReceiver ACTION_ACL_DISCONNECTED ----- isMfConnect = $isMfConnect ") if (isMfConnect) { - updateMfStatusView("mofang", false) + updateMfStatusView(TAG, false) isMfConnect = false + mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean(MfConstants.BLUETOOTH_STATUS, false) } } } - } } } +} - -} \ 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/MoGoHmiFragment.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt index d14a2fd150..4ea178bc6d 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt @@ -237,7 +237,7 @@ class MoGoHmiFragment : MvpFragment(), if (CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().autopilotControlParameters == null) { FunctionBuildConfig.isDemoMode = !FunctionBuildConfig.isDemoMode context?.let { - CallerHmiManager.updateStatusBarRightView( + CallerHmiManager.updateStatusBarLeftView( FunctionBuildConfig.isDemoMode, "demoMode", DemoModeView(it) @@ -455,6 +455,10 @@ class MoGoHmiFragment : MvpFragment(), statusBarView?.updateRightView(insert, tag, viewGroup) } + override fun updateStatusBarLeftView(insert: Boolean, tag: String, viewGroup: ViewGroup) { + statusBarView?.updateLeftView(insert, tag, viewGroup) + } + override fun updateStatusBarDownloadView(insert: Boolean, tag: String, progress: Int) { statusBarView?.updateProgressView(insert, tag, progress) } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/DriverMsgBoxListView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/DriverMsgBoxListView.kt index 554403778b..e12cd90b18 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/DriverMsgBoxListView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/DriverMsgBoxListView.kt @@ -22,6 +22,9 @@ import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils import com.mogo.eagle.core.utilcode.util.TimeUtils import com.mogo.eagle.core.utilcode.util.UiThreadHandler import kotlinx.android.synthetic.main.layout_driver_msg_box_list.view.* +import org.greenrobot.eventbus.EventBus +import org.greenrobot.eventbus.Subscribe +import org.greenrobot.eventbus.ThreadMode /** * @author XuXinChao @@ -186,6 +189,7 @@ class DriverMsgBoxListView @JvmOverloads constructor( super.onAttachedToWindow() if(AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)){ CallerMsgBoxListenerManager.addListener(TAG,this) + EventBus.getDefault().register(this) } } @@ -193,8 +197,16 @@ class DriverMsgBoxListView @JvmOverloads constructor( super.onDetachedFromWindow() if(AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)){ CallerMsgBoxListenerManager.removeListener(TAG) + EventBus.getDefault().unregister(this) } } + @Subscribe(threadMode = ThreadMode.MAIN) + fun notifyList(msgBoxList: MsgBoxBean){ + badCaseList?.let { + it.remove(msgBoxList) + driverMsgBoxListAdapter?.notifyItemRemoved(it.indexOf(msgBoxList)) + } + } } \ 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/msgbox/adapter/DriverMsgBoxListAdapter.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/adapter/DriverMsgBoxListAdapter.kt index 6b6cd3a740..fc5adbc9f1 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/adapter/DriverMsgBoxListAdapter.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/adapter/DriverMsgBoxListAdapter.kt @@ -2,9 +2,7 @@ package com.mogo.eagle.core.function.hmi.ui.msgbox.adapter import android.annotation.SuppressLint import android.app.Activity -import android.util.Log import android.view.LayoutInflater -import android.view.MenuItem import android.view.View import android.view.ViewGroup import android.widget.ImageView @@ -13,7 +11,6 @@ import androidx.core.view.isVisible import androidx.recyclerview.widget.RecyclerView import com.mogo.eagle.core.data.enums.EventTypeEnum import com.mogo.eagle.core.data.msgbox.* -import com.mogo.eagle.core.data.notice.NoticeNormalData import com.mogo.eagle.core.data.report.ReportEntity import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager @@ -24,7 +21,6 @@ import com.mogo.eagle.core.utilcode.mogo.glide.transform.GlideRoundedCornersTran import com.mogo.eagle.core.utilcode.util.ResourceUtils.getDrawable import com.mogo.eagle.core.utilcode.util.TimeUtils import com.mogo.eagle.core.utilcode.util.TimeUtils.getHourMinFormat -import com.mogo.eagle.core.widget.RoundConstraintLayout /** * @author XuXinChao @@ -79,7 +75,6 @@ class DriverMsgBoxListAdapter(private val activity: Activity) : RecyclerView.Ada holder.tvBagReceiveTime.text = TimeUtils.millis2String(it[position].timestamp,getHourMinFormat()) holder.tvBagRecordTime.text = "时间:${TimeUtils.millis2String(it[position].timestamp)}" val msgBoxBean = it[position] -// val recordBagMsg = (it[position].bean as RecordBagMsg) holder.tvRecordCheck.setOnClickListener { //打开被动录包弹窗 CallerDevaToolsManager.onReceiveBadCaseRecord(msgBoxBean,activity,false) diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt index 32207c1d81..2a0d1868dd 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt @@ -586,7 +586,7 @@ class DebugSettingView @JvmOverloads constructor( // 演示模式 tbIsDemoMode.setOnCheckedChangeListener { _, isChecked -> - CallerHmiManager.updateStatusBarRightView(isChecked, "demoMode", DemoModeView(context)) + CallerHmiManager.updateStatusBarLeftView(isChecked, "demoMode", DemoModeView(context)) CallerAutoPilotManager.setDemoMode(isChecked) if (!isChecked) { //关闭美化模式时,通知工控机 diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/SOPSettingView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/SOPSettingView.kt index ffb624e90f..b3f44f967d 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/SOPSettingView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/SOPSettingView.kt @@ -120,7 +120,7 @@ class SOPSettingView @JvmOverloads constructor( tbDemoMode.isChecked = FunctionBuildConfig.isDemoMode // 演示模式 tbDemoMode.setOnCheckedChangeListener { _, isChecked -> - CallerHmiManager.updateStatusBarRightView(isChecked, "demoMode", DemoModeView(context)) + CallerHmiManager.updateStatusBarLeftView(isChecked, "demoMode", DemoModeView(context)) CallerAutoPilotManager.setDemoMode(isChecked) if (!isChecked) { //关闭美化模式时,通知工控机 diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/StatusBarView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/StatusBarView.kt index d27fe7fc1a..ae89a8489b 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/StatusBarView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/StatusBarView.kt @@ -2,12 +2,15 @@ package com.mogo.eagle.core.function.hmi.ui.widget import android.content.Context import android.util.AttributeSet +import android.util.Log import android.view.* import android.widget.* +import com.mogo.eagle.core.data.mofang.MfConstants import com.mogo.eagle.core.function.api.setting.IMoGoSkinModeChangeListener import com.mogo.eagle.core.function.call.devatools.* import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager import com.mogo.eagle.core.function.hmi.R +import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr import com.mogo.eagle.core.utilcode.util.BarUtils import com.mogo.eagle.core.utilcode.util.ScreenUtils import kotlinx.android.synthetic.main.view_status_bar.view.* @@ -29,6 +32,7 @@ class StatusBarView @JvmOverloads constructor( } private val rightViewList = CopyOnWriteArrayList() + private val leftViewList = CopyOnWriteArrayList() override fun onAttachedToWindow() { super.onAttachedToWindow() @@ -39,6 +43,11 @@ class StatusBarView @JvmOverloads constructor( // 添加换肤监听 CallerSkinModeListenerManager.addListener(TAG, this) + + var isBluetoothConnect = SharedPrefsMgr.getInstance(context).getBoolean(MfConstants.BLUETOOTH_STATUS, false) + if (isBluetoothConnect) { + updateMfStatus("MoFangManager", true) + } } override fun onSkinModeChange(skinMode: Int) { @@ -70,6 +79,20 @@ class StatusBarView @JvmOverloads constructor( } } + fun updateLeftView(insert: Boolean, tag: String, viewGroup: ViewGroup) { + if (insert) { + leftViewList.add(0, tag) + viewStatusBarLeft.addView(viewGroup, 0) + } else { + leftViewList.forEachIndexed { index, s -> + if (s == tag) { + leftViewList.removeAt(index) + viewStatusBarLeft.removeViewAt(index) + } + } + } + } + fun updateProgressView(insert: Boolean, tag: String, progress: Int) { if (insert) { viewProgressTv.visibility = VISIBLE @@ -81,9 +104,9 @@ class StatusBarView @JvmOverloads constructor( fun updateMfStatus(tag: String, status: Boolean) { if (status) { -// viewMofangStatus.setImageResource(R.drawable.icon_car_red) + viewMofangStatus.setImageResource(R.drawable.icon_bluetooth_p) } else { -// viewMofangStatus.setImageResource(R.drawable.icon_car_red) + viewMofangStatus.setImageResource(R.drawable.blue_tooth) } } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainLauncherActivity.java b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainLauncherActivity.java index 24f8891050..9cd2618de3 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainLauncherActivity.java +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainLauncherActivity.java @@ -3,11 +3,9 @@ package com.mogo.eagle.core.function.main; import static com.mogo.eagle.core.data.deva.chain.ChainConstant.CHAIN_ALIAS_CODE_START_UP; import static com.mogo.eagle.core.data.deva.chain.ChainConstant.CHAIN_LINK_INIT; import static com.mogo.eagle.core.data.deva.chain.ChainConstant.CHAIN_LINK_LOG_CONNECT_STATUS; +import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_F; import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_HMI; -import android.bluetooth.BluetoothAdapter; -import android.bluetooth.BluetoothDevice; import android.content.Intent; -import android.content.IntentFilter; import android.os.Bundle; import android.os.Handler; import android.os.Process; @@ -17,11 +15,13 @@ import android.view.KeyEvent; import android.widget.FrameLayout; import androidx.annotation.Nullable; + import com.alibaba.android.arouter.launcher.ARouter; import com.mogo.commons.debug.DebugConfig; import com.mogo.commons.module.intent.IMogoIntentListener; import com.mogo.commons.module.intent.IntentManager; import com.mogo.eagle.core.data.config.FunctionBuildConfig; +import com.mogo.eagle.core.data.mofang.MfConstants; import com.mogo.eagle.core.function.api.base.IMoGoFunctionProvider; import com.mogo.eagle.core.function.api.setting.IMoGoSkinModeChangeListener; import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager; @@ -29,7 +29,6 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListener import com.mogo.eagle.core.function.call.hmi.CallerHmiManager; import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager; import com.mogo.eagle.core.function.hmi.R; -import com.mogo.eagle.core.function.main.moujie.BluetoothMonitorReceiver; import com.mogo.eagle.core.function.main.utils.MultiDisplayUtils; import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; @@ -43,9 +42,7 @@ import com.zhjt.service.chain.TracingConstants; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; -import java.lang.reflect.Method; import java.util.List; -import java.util.Set; import java.util.Timer; import java.util.TimerTask; @@ -66,8 +63,6 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis private Timer timerHorn; private Timer timerAcc; - private BluetoothMonitorReceiver mBluetoothReceiver = null; - private BluetoothAdapter mBluetoothAdapter; private boolean isShowToast = false; //toast 控制 private long startPressTime = 0; //开始按减时间 private boolean isPressEnd = false; //按键是否结束 @@ -94,14 +89,6 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis @Override protected void onResume() { super.onResume(); - - initBluetooth(); - mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); - if (!mBluetoothAdapter.isEnabled()) { - mBluetoothAdapter.enable(); - } - mBluetoothAdapter.startDiscovery(); - showBondedDevice(mBluetoothAdapter); } @Override @@ -129,7 +116,6 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis protected void onPause() { super.onPause(); mIsHomeKeyDown = false; - unregisterReceiver(this.mBluetoothReceiver); } @Override @@ -246,12 +232,10 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis */ @Override public boolean dispatchKeyEvent(KeyEvent event) { -// Log.d(TAG, "dispatchKeyEvent code = " + event.getKeyCode() + "--action = " + event.getAction() + "----" + event); - String bluetoothName = SharedPrefsMgr.getInstance(getContext()).getString("BLUETOOTH"); -// CallerHmiManager.INSTANCE.updateMfStatusView("mofang", true); - +// CallerLogger.INSTANCE.d(M_F + "MoFangManager", "dispatchKeyEvent code = " + event.getKeyCode() + "--action = " + event.getAction() + "----" + event); + String bluetoothName = SharedPrefsMgr.getInstance(getContext()).getString(MfConstants.BLUETOOTH_NAME); if (!isPressEnd) { - Log.e(TAG, "dispatchKeyEvent bluetoothName = " + bluetoothName); + CallerLogger.INSTANCE.d(M_F + "MoFangManager","dispatchKeyEvent bluetoothName = " + bluetoothName); } if (bluetoothName.equals("MINI_KEYBOARD")) { if (!isPressEnd) { @@ -262,7 +246,7 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis if (event.getKeyCode() == KeyEvent.KEYCODE_A) { //单击 -1,长按无操作,AB组合-2 if (event.getAction() == KeyEvent.ACTION_DOWN) { pressADownTime = System.currentTimeMillis(); - Log.d(TAG, "dispatchKeyEvent A down pressADownTime = " + pressADownTime + "---" + (pressADownTime - startPressTime) + "----isCombinationKey = " + isCombinationKey + "--pressBDownTime = " + pressBDownTime); + CallerLogger.INSTANCE.d(M_F + "MoFangManager", "dispatchKeyEvent A down pressADownTime = " + pressADownTime + "---" + (pressADownTime - startPressTime) + "----isCombinationKey = " + isCombinationKey + "--pressBDownTime = " + pressBDownTime); if ((pressADownTime - startPressTime) > 320 && (pressADownTime - startPressTime) < 1300 && pressBDownTime > 0) { if (isShowToast) { ToastUtils.showShort("方块 A 按AB组合 -2 "); @@ -281,7 +265,7 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis } } else if (event.getAction() == KeyEvent.ACTION_UP) { pressAUpTime = System.currentTimeMillis(); - Log.e(TAG, "dispatchKeyEvent A up pressAUpTime = " + pressAUpTime + "---" + (pressAUpTime - startPressTime) + "--pressBDownTime = " + pressBDownTime); + CallerLogger.INSTANCE.d(M_F + "MoFangManager", "dispatchKeyEvent A up pressAUpTime = " + pressAUpTime + "---" + (pressAUpTime - startPressTime) + "--pressBDownTime = " + pressBDownTime); if ((pressAUpTime - startPressTime) < 300 && isCombinationKey != 3) { isCombinationKey = 1; if (isShowToast) { @@ -298,12 +282,11 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis } }, 300); } - return true; - } else if (event.getKeyCode() == KeyEvent.KEYCODE_B) {//单击复原,长按+1,AB组合-2 + } else if (event.getKeyCode() == KeyEvent.KEYCODE_B) { //单击复原,长按+1,AB组合-2 if (event.getAction() == KeyEvent.ACTION_DOWN) { pressBDownTime = System.currentTimeMillis(); - Log.d(TAG, "dispatchKeyEvent B down pressBDownTime = " + pressBDownTime + "--差-" + (pressBDownTime - startPressTime) + "---isCombinationKey = " + isCombinationKey + "--pressADownTime = " + pressADownTime); + CallerLogger.INSTANCE.d(M_F + "MoFangManager", "dispatchKeyEvent B down pressBDownTime = " + pressBDownTime + "--差-" + (pressBDownTime - startPressTime) + "---isCombinationKey = " + isCombinationKey + "--pressADownTime = " + pressADownTime); if ((pressBDownTime - startPressTime) > 320 && (pressBDownTime - startPressTime) < 1300 && pressADownTime > 0) { if (isShowToast) { ToastUtils.showShort("方块 B 按AB组合 "); @@ -322,7 +305,7 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis } } else if (event.getAction() == KeyEvent.ACTION_UP) { pressBUpTime = System.currentTimeMillis(); - Log.e(TAG, "dispatchKeyEvent B up pressBUpTime = " + pressBUpTime + "--差-" + (pressBUpTime - startPressTime) + "--pressADownTime = " + pressADownTime); + CallerLogger.INSTANCE.d(M_F + "MoFangManager", "dispatchKeyEvent B up pressBUpTime = " + pressBUpTime + "--差-" + (pressBUpTime - startPressTime) + "--pressADownTime = " + pressADownTime); if ((pressBUpTime - startPressTime) < 300 && isCombinationKey != 3) { if (isShowToast) { ToastUtils.showShort("方块 单击B 0 "); @@ -340,12 +323,12 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis } }, 300); } - return true; } else if (event.getKeyCode() == KeyEvent.KEYCODE_C) { //单击左变道,长按无操作 if (event.getAction() == KeyEvent.ACTION_DOWN) { pressCDownTime = System.currentTimeMillis(); if ((pressCDownTime - startPressTime) > 1320) { + CallerLogger.INSTANCE.d(M_F + "MoFangManager", "dispatchKeyEvent 方块 长按C 无操作 "); if (isShowToast) { ToastUtils.showShort("方块 长按C 无操作 "); } @@ -354,6 +337,7 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis pressCUpTime = System.currentTimeMillis(); isPressEnd = false; if ((pressCUpTime - startPressTime) < 300) { + CallerLogger.INSTANCE.d(M_F + "MoFangManager", "dispatchKeyEvent 方块 单击C ← 向左变道 "); if (isShowToast) { ToastUtils.showShort("方块 单击C ← 向左变道 "); } @@ -365,6 +349,7 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis if (event.getAction() == KeyEvent.ACTION_DOWN) { pressDDownTime = System.currentTimeMillis(); if ((pressDDownTime - startPressTime) > 1320) { + CallerLogger.INSTANCE.d(M_F + "MoFangManager", "dispatchKeyEvent 方块 长按D 无操作 "); if (isShowToast) { ToastUtils.showShort("方块 长按D 无操作 "); } @@ -376,10 +361,10 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis if (isShowToast) { ToastUtils.showShort("方块 单击D → 向右变道 "); } + CallerLogger.INSTANCE.d(M_F + "MoFangManager", "dispatchKeyEvent 方块 单击D → 向右变道 "); CallerAutoPilotManager.INSTANCE.sendOperatorChangeLaneRight(); } } - return true; } else if (event.getKeyCode() == KeyEvent.KEYCODE_E) { //单击启动自驾,长按鸣笛 if (event.getAction() == KeyEvent.ACTION_DOWN) { @@ -388,6 +373,7 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis if (isShowToast) { ToastUtils.showShort("方块 长按E 鸣笛 "); } + CallerLogger.INSTANCE.d(M_F + "MoFangManager", "dispatchKeyEvent 方块 长按E 鸣笛 "); CallerAutoPilotManager.INSTANCE.sendOperatorSetHorn(1); if (timerHorn == null) { timerHorn = new Timer(); @@ -407,20 +393,18 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis if (isShowToast) { ToastUtils.showShort("方块 单击E 开启自动驾驶 "); } + CallerLogger.INSTANCE.d(M_F + "MoFangManager", "dispatchKeyEvent 方块 单击E 开启自动驾驶 "); CallerAutoPilotManager.INSTANCE.startAutoPilot(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getAutopilotControlParameters()); } } - return true; } } - return super.dispatchKeyEvent(event); } @Override public void onSkinModeChange(int skinMode) { - } private synchronized void sendAcc(boolean isSend, double acc) { @@ -444,42 +428,4 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis } } - /** - * 初始化蓝牙广播 - */ - private void initBluetooth() { - this.mBluetoothReceiver = new BluetoothMonitorReceiver(); - IntentFilter intentFilter = new IntentFilter(); - // 监视蓝牙关闭和打开的状态 - intentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); - - // 监视蓝牙设备与APP连接的状态 - intentFilter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED); - intentFilter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED); - - // 注册广播 - registerReceiver(this.mBluetoothReceiver, intentFilter); - } - - /** - * 查找蓝牙连接过的蓝牙设备 - */ - private void showBondedDevice(BluetoothAdapter bluetoothAdapter) { - Set deviceList = bluetoothAdapter.getBondedDevices(); - for (BluetoothDevice device : deviceList) { - try { - //使用反射调用获取设备连接状态方法 - Method isConnectedMethod = BluetoothDevice.class.getDeclaredMethod("isConnected", (Class[]) null); - isConnectedMethod.setAccessible(true); -// boolean isConnected = (boolean) isConnectedMethod.invoke(device, (Object[]) null); - Log.d(TAG, "-- device.getName() = " + device.getName()); //device.getAddress() - if (device.getName().equals("MINI_KEYBOARD")) { - SharedPrefsMgr.getInstance(getContext()).putString("BLUETOOTH", device.getName()); - } - } catch (NoSuchMethodException e) { - e.printStackTrace(); - } - } - } - } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable/icon_bluetooth_p.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable/icon_bluetooth_p.png new file mode 100644 index 0000000000..8220846079 Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable/icon_bluetooth_p.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_status_bar.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_status_bar.xml index 8d68848433..e2e527591e 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_status_bar.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_status_bar.xml @@ -40,8 +40,17 @@ android:id="@+id/viewMofangStatus" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/blue_tooth" android:layout_gravity="center" - android:layout_marginStart="@dimen/dp_27" /> + android:layout_marginStart="@dimen/dp_8" /> + +