From f45f30cdd91420a45a540927fd4073daf9a56fa3 Mon Sep 17 00:00:00 2001 From: xuxinchao <13522809046@163.com> Date: Fri, 20 May 2022 19:58:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=89=88=E6=9C=AC=E6=B0=B4?= =?UTF-8?q?=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 增加鹰眼版本和连接工控机镜像版本的水印显示 --- .../function/hmi/ui/widget/VersionNameView.kt | 82 +++++++++++++++++++ .../src/main/res/layout/fragment_hmi.xml | 12 +++ .../src/main/res/layout/view_version_name.xml | 23 ++++++ 3 files changed, 117 insertions(+) create mode 100644 core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/VersionNameView.kt create mode 100644 core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_version_name.xml diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/VersionNameView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/VersionNameView.kt new file mode 100644 index 0000000000..8aff937915 --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/VersionNameView.kt @@ -0,0 +1,82 @@ +package com.mogo.eagle.core.function.hmi.ui.widget + +import android.annotation.SuppressLint +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import android.widget.LinearLayout +import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo +import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener +import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager +import com.mogo.eagle.core.function.hmi.R +import com.mogo.eagle.core.utilcode.util.AppUtils +import com.mogo.eagle.core.utilcode.util.UiThreadHandler +import kotlinx.android.synthetic.main.view_version_name.view.* + +/** + * @author XuXinChao + * @description APP版本号+MAP版本号水印显示 + * @since: 2022/5/20 + */ +class VersionNameView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : LinearLayout(context, attrs, defStyleAttr),IMoGoAutopilotStatusListener { + + companion object { + const val TAG = "VersionNameView" + } + + private var dockerVersion: String? = null //工控机版本 + + init{ + LayoutInflater.from(context).inflate(R.layout.view_version_name, this, true) + initView() + } + + private fun initView(){ + showCurrentPadVersion() + showCurrentMapVersion() + } + + /** + * 展示当前鹰眼版本 + */ + @SuppressLint("SetTextI18n") + private fun showCurrentPadVersion() { + tvAppVersionName?.let { + it.text = "APP:${AppUtils.getAppVersionName()}" + } + } + + /** + * 展示当前工控机版本 + */ + @SuppressLint("SetTextI18n") + private fun showCurrentMapVersion() { + UiThreadHandler.post { + tvMapVersionName?.let { + if (!dockerVersion.isNullOrEmpty()) { + it.text = "MAP:${dockerVersion}" + } + } + } + } + + override fun onAttachedToWindow() { + super.onAttachedToWindow() + CallerAutoPilotStatusListenerManager.addListener(TAG, this) + } + + override fun onDetachedFromWindow() { + super.onDetachedFromWindow() + CallerAutoPilotStatusListenerManager.removeListener(TAG) + } + + override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) { + dockerVersion = autoPilotStatusInfo.dockVersion + showCurrentMapVersion() + } + +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/fragment_hmi.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/fragment_hmi.xml index 60e2d5f838..0e2e3830cf 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/fragment_hmi.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/fragment_hmi.xml @@ -171,6 +171,18 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> + + + + + diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_version_name.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_version_name.xml new file mode 100644 index 0000000000..d281975a87 --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_version_name.xml @@ -0,0 +1,23 @@ + + + + + + + + \ No newline at end of file