diff --git a/OCH/facade/src/main/java/com/mogo/och/facade/constant/FacadeConst.kt b/OCH/facade/src/main/java/com/mogo/och/facade/constant/FacadeConst.kt index cf5bd72fe3..e748cf5e80 100644 --- a/OCH/facade/src/main/java/com/mogo/och/facade/constant/FacadeConst.kt +++ b/OCH/facade/src/main/java/com/mogo/och/facade/constant/FacadeConst.kt @@ -8,6 +8,6 @@ class FacadeConst { // OCH arouter 路由path const val DRIVER_PATH = "/driver/api" const val PASSENGER_PATH = "/passenger/api" - + const val OCH_VIEW_PATH = "/och/view/api" } } \ No newline at end of file diff --git a/OCH/facade/src/main/java/com/mogo/och/facade/view/OchCustomViewProvider.kt b/OCH/facade/src/main/java/com/mogo/och/facade/view/OchCustomViewProvider.kt new file mode 100644 index 0000000000..e2e5950774 --- /dev/null +++ b/OCH/facade/src/main/java/com/mogo/och/facade/view/OchCustomViewProvider.kt @@ -0,0 +1,62 @@ +package com.mogo.och.facade.view + +import android.content.Context +import android.graphics.Color +import android.view.Gravity +import android.view.View +import android.widget.TextView +import com.alibaba.android.arouter.facade.annotation.Route +import com.mogo.eagle.core.function.api.och.IOchCustomViewProvider +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.och.facade.constant.FacadeConst +import kotlin.random.Random + +@Route(path = FacadeConst.OCH_VIEW_PATH) +class OchCustomViewProvider : IOchCustomViewProvider { + + companion object { + const val TAG = "OchCustomViewProvider" + } + + override fun init(context: Context?) { + CallerLogger.d(TAG, "init") + } + + /** + * 创建 Och业务层 自定义View + */ + override fun createOchBusinessView(context: Context?): View? { + return context?.let { + TextView(it).apply { + text = "业务自定义View" + gravity = Gravity.CENTER + setBackgroundColor( + Color.rgb( + Random.nextInt(256), + Random.nextInt(256), + Random.nextInt(256) + ) + ) + } + } ?: null + } + + /** + * 创建 自动自动驾驶 自定义 View + */ + override fun createStartAutopilotView(context: Context?): View? { + return context?.let { + TextView(it).apply { + text = "启动自动驾驶" + gravity = Gravity.CENTER + setBackgroundColor( + Color.rgb( + Random.nextInt(256), + Random.nextInt(256), + Random.nextInt(256) + ) + ) + } + } + } +} \ 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/bone/BoneTopStatusLayout.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/bone/BoneTopStatusLayout.kt index a252cb2960..1599629c1e 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/bone/BoneTopStatusLayout.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/bone/BoneTopStatusLayout.kt @@ -5,12 +5,16 @@ import android.util.AttributeSet import android.view.LayoutInflater import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.content.ContextCompat +import com.mogo.eagle.core.function.call.och.CallerOchCustomViewManager import com.mogo.eagle.core.function.hmi.R import com.mogo.eagle.core.function.hmi.bone.status.StartAutoPilotStatusView +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.mogo.logger.Logger import com.zhjt.mogo_core_function_devatools.status.StatusManager import com.zhjt.mogo_core_function_devatools.status.entity.SpeedStatus import com.zhjt.mogo_core_function_devatools.status.entity.Status import kotlinx.android.synthetic.main.view_bone_top_status.view.speed_custom +import kotlinx.android.synthetic.main.view_bone_top_status.view.startAutoPilotContainer import kotlinx.android.synthetic.main.view_bone_top_status.view.topStatusContainer class BoneTopStatusLayout @JvmOverloads constructor( @@ -24,6 +28,24 @@ class BoneTopStatusLayout @JvmOverloads constructor( init { LayoutInflater.from(context).inflate(R.layout.view_bone_top_status, this, true) + addStartAutoPilotView() + } + + private fun addStartAutoPilotView() { + if (context == null) { + CallerLogger.e(TAG, "addStartAutoPilotView context==null") + return + } + kotlin.runCatching { + startAutoPilotContainer?.also { container -> + container.removeAllViews() + val view = CallerOchCustomViewManager.getAutopilotView(context) + Logger.d(TAG, "$view ${Thread.currentThread().name}") + view?.also { + container.addView(it) + } + } + } } override fun onAttachedToWindow() { diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainActivity.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainActivity.kt index 718c6f6504..4b49a3b93c 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainActivity.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainActivity.kt @@ -32,6 +32,7 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListener import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager import com.mogo.eagle.core.function.call.hmi.CallerHmiManager import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager +import com.mogo.eagle.core.function.call.och.CallerOchCustomViewManager import com.mogo.eagle.core.function.call.setting.CallerRequestActivityHandleManager import com.mogo.eagle.core.function.call.startup.CallerStartUpManager.initStageTwo import com.mogo.eagle.core.function.hmi.R @@ -80,6 +81,7 @@ open class MainActivity : MvpActivity(), MainView, window.setBackgroundDrawable(null) initConnectInfoRV() CallerHmiManager.init(this) + CallerOchCustomViewManager.init(this) // 检查是否有悬浮窗权限 if (Settings.canDrawOverlays(this)) { diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_bone_top_status.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_bone_top_status.xml index 96f62d0f35..77b5a6652a 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_bone_top_status.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_bone_top_status.xml @@ -18,9 +18,18 @@ + app:layout_constraintLeft_toLeftOf="parent" /> + + \ No newline at end of file diff --git a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/constants/MogoServicePaths.java b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/constants/MogoServicePaths.java index 2fb6eb46d9..61809ce8b4 100644 --- a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/constants/MogoServicePaths.java +++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/constants/MogoServicePaths.java @@ -117,4 +117,7 @@ public class MogoServicePaths { @Keep public static final String PATH_UPGRADE_TYPE_API = "/upgrade/type/api"; + @Keep + public static final String PATH_OCH_CUSTOM_VIEW_API = "/och/view/api"; + } diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/och/IOchCustomViewProvider.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/och/IOchCustomViewProvider.kt new file mode 100644 index 0000000000..5ec0708c0b --- /dev/null +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/och/IOchCustomViewProvider.kt @@ -0,0 +1,30 @@ +package com.mogo.eagle.core.function.api.och + +import android.content.Context +import android.view.View +import com.alibaba.android.arouter.facade.template.IProvider + +/** + * @author aibingbing + * + * Och业务层自定义View Provider 接口定义 + */ +interface IOchCustomViewProvider : IProvider { + + /** + * Interface Tag + */ + val TAG: String + get() = "IOchCustomViewProvider" + + /** + * 创建 Och业务层 自定义View + */ + fun createOchBusinessView(context: Context?): View? + + /** + * 创建 自动自动驾驶 自定义 View + */ + fun createStartAutopilotView(context: Context?): View? + +} \ No newline at end of file diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/och/CallerOchCustomViewManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/och/CallerOchCustomViewManager.kt new file mode 100644 index 0000000000..98a36cb4db --- /dev/null +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/och/CallerOchCustomViewManager.kt @@ -0,0 +1,38 @@ +package com.mogo.eagle.core.function.call.och + +import android.content.Context +import android.view.View +import com.alibaba.android.arouter.launcher.ARouter +import com.mogo.eagle.core.data.constants.MogoServicePaths +import com.mogo.eagle.core.function.api.och.IOchCustomViewProvider + +/** + * @author aibingbing + * + * Och自定义View调用者管理类,用来获取 Och提供的自定义 View, 然后放入到底层框架 + */ +object CallerOchCustomViewManager { + const val TAG = "CallerOchCustomViewManager" + + private val ochCustomViewProviderApi + get() = ARouter.getInstance().build(MogoServicePaths.PATH_OCH_CUSTOM_VIEW_API) + .navigation() as? IOchCustomViewProvider + + fun init(context: Context) { + ochCustomViewProviderApi?.init(context) + } + + /** + * 创建 Och业务层 自定义View + */ + fun getOchBusinessView(context: Context?): View? { + return ochCustomViewProviderApi?.createOchBusinessView(context) + } + + /** + * 创建 自动自动驾驶 自定义 View + */ + fun getAutopilotView(context: Context?): View? { + return ochCustomViewProviderApi?.createStartAutopilotView(context) + } +} \ No newline at end of file