增加版本水印

增加鹰眼版本和连接工控机镜像版本的水印显示
This commit is contained in:
xuxinchao
2022-05-20 19:58:49 +08:00
parent 012eaea252
commit f45f30cdd9
3 changed files with 117 additions and 0 deletions

View File

@@ -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()
}
}

View File

@@ -171,6 +171,18 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<!--APP、MAP版本-->
<com.mogo.eagle.core.function.hmi.ui.widget.VersionNameView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="45px"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- app:layout_constraintBottom_toBottomOf="parent"-->

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/tvAppVersionName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textColor="#9EFFFFFF"
/>
<TextView
android:id="@+id/tvMapVersionName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textColor="#9EFFFFFF"
/>
</LinearLayout>