Ad upgrade
This commit is contained in:
@@ -652,6 +652,50 @@ class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示工控机下载状态信息
|
||||
* @param downloadVersion 下载版本
|
||||
* @param downloadStatus 下载状态(0:下载完成;1:正在下载;2:下载失败)
|
||||
* @param downloadProgress 下载进度
|
||||
*/
|
||||
override fun showAdDownloadStatus(
|
||||
downloadVersion: String,
|
||||
downloadStatus: Int,
|
||||
downloadProgress: Int
|
||||
) {
|
||||
// if (downloadProgress>0){
|
||||
// //新版工控机包处于下载中或已下载完成状态,展示工具箱提示角标
|
||||
// viewUpgradeTips.visibility = View.VISIBLE
|
||||
// }
|
||||
if(downloadStatus==0){
|
||||
//新版本工控机包下载完成,处于可升级状态,展示工具箱提示角标
|
||||
viewUpgradeTips.visibility = View.VISIBLE
|
||||
}else if(downloadStatus==1){
|
||||
//新版本工控机包正在下载中,展示工具箱提示角标
|
||||
viewUpgradeTips.visibility = View.VISIBLE
|
||||
}else if(downloadStatus==2){
|
||||
//新版本工控机包下载失败,隐藏工具箱提交角标
|
||||
viewUpgradeTips.visibility = View.GONE
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示工控机升级状态信息
|
||||
* @param upgradeStatus 升级状态(true代表升级成功、false代表升级不成功)
|
||||
*/
|
||||
override fun showAdUpgradeStatus(upgradeStatus: Boolean) {
|
||||
if(upgradeStatus){
|
||||
//工控机升级成功,隐藏工具箱提示角标
|
||||
viewUpgradeTips.visibility = View.GONE
|
||||
}else{
|
||||
//工控机升级失败,展示工具箱提示角标
|
||||
viewUpgradeTips.visibility = View.VISIBLE
|
||||
}
|
||||
//TODO 给工具箱空间传递状态
|
||||
// toolsView?.setStatus(true)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
Log.d(TAG, "onDestroy")
|
||||
|
||||
@@ -0,0 +1,191 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.widget
|
||||
|
||||
import android.animation.ValueAnimator
|
||||
import android.content.Context
|
||||
import android.content.res.TypedArray
|
||||
import android.graphics.*
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.view.animation.OvershootInterpolator
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
|
||||
/**
|
||||
* @author XuXinChao
|
||||
* @description 自定义圆形进度条
|
||||
* @since: 2022/1/14
|
||||
*/
|
||||
class CircularProgressView @JvmOverloads constructor(
|
||||
context: Context, attrs: AttributeSet?, defStyleAttr : Int)
|
||||
: View(context, attrs, defStyleAttr){
|
||||
|
||||
val typedArray : TypedArray = context.obtainStyledAttributes(attrs, R.styleable.CircularProgressView)
|
||||
// 绘制画笔
|
||||
private val mBackPaint : Paint = Paint()
|
||||
private val mProgPaint : Paint = Paint()
|
||||
// 绘制区域
|
||||
private var mRectF : RectF? = null
|
||||
// 圆环渐变色
|
||||
private var mColorArray : IntArray?=null
|
||||
// 圆环进度(0-100) 初始化进度
|
||||
private var mProgress : Int = typedArray.getInteger(R.styleable.CircularProgressView_progress, 0)
|
||||
|
||||
constructor(context : Context) : this(context,null)
|
||||
|
||||
constructor(context : Context,attrs : AttributeSet?) :this(context, attrs, 0)
|
||||
|
||||
init {
|
||||
// 初始化背景圆环画笔
|
||||
mBackPaint.style = Paint.Style.STROKE // 只描边,不填充
|
||||
mBackPaint.strokeCap = Paint.Cap.ROUND // 设置圆角
|
||||
mBackPaint.isAntiAlias = true // 设置抗锯齿
|
||||
mBackPaint.isDither = true // 设置抖动
|
||||
mBackPaint.strokeWidth = typedArray.getDimension(R.styleable.CircularProgressView_backWidth, 5.0f)
|
||||
mBackPaint.color = typedArray.getColor(R.styleable.CircularProgressView_backColor, Color.LTGRAY)
|
||||
// 初始化进度圆环画笔
|
||||
mProgPaint.style = Paint.Style.STROKE // 只描边,不填充
|
||||
mProgPaint.strokeCap = Paint.Cap.ROUND // 设置圆角
|
||||
mProgPaint.isAntiAlias = true // 设置抗锯齿
|
||||
mProgPaint.isDither = true // 设置抖动
|
||||
mProgPaint.strokeWidth = typedArray.getDimension(R.styleable.CircularProgressView_progWidth, 10.0f)
|
||||
mProgPaint.color = typedArray.getColor(R.styleable.CircularProgressView_progColor, Color.BLUE)
|
||||
// 初始化进度圆环渐变色
|
||||
val startColor = typedArray.getColor(R.styleable.CircularProgressView_progStartColor, -1)
|
||||
val firstColor = typedArray.getColor(R.styleable.CircularProgressView_progFirstColor, -1)
|
||||
if(startColor != -1 && firstColor != -1){
|
||||
mColorArray = intArrayOf(startColor,firstColor)
|
||||
}else{
|
||||
mColorArray = null
|
||||
}
|
||||
|
||||
|
||||
typedArray.recycle();
|
||||
}
|
||||
|
||||
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
|
||||
val viewWide = getMeasuredWidth() - getPaddingLeft() - getPaddingRight();
|
||||
val viewHigh = getMeasuredHeight() - getPaddingTop() - getPaddingBottom();
|
||||
val mRectLength =
|
||||
((if (viewWide > viewHigh) viewHigh else viewWide) - if (mBackPaint.strokeWidth > mProgPaint.strokeWidth) mBackPaint.strokeWidth else mProgPaint.strokeWidth).toInt()
|
||||
val mRectL = getPaddingLeft() + (viewWide - mRectLength) / 2
|
||||
val mRectT = getPaddingTop() + (viewHigh - mRectLength) / 2
|
||||
mRectF = RectF(mRectL.toFloat(), mRectT.toFloat(), (mRectL + mRectLength).toFloat(),
|
||||
(mRectT + mRectLength).toFloat())
|
||||
// 设置进度圆环渐变色
|
||||
mColorArray?.let {
|
||||
mProgPaint.shader = LinearGradient(
|
||||
0.0f, 0.0f, 0.0f,
|
||||
measuredWidth.toFloat(), it, null, Shader.TileMode.MIRROR)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onDraw(canvas: Canvas?) {
|
||||
super.onDraw(canvas)
|
||||
canvas?.let {
|
||||
mRectF?.let { it1 -> it.drawArc(it1, 0.0f, 360.0f, false, mBackPaint) }
|
||||
mRectF?.let { it1 -> it.drawArc(it1, 275.0f,
|
||||
(360 * mProgress / 100).toFloat(), false, mProgPaint) }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前进度
|
||||
* @return 当前进度(0-100)
|
||||
*/
|
||||
fun getProgress() : Int{
|
||||
return mProgress
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置当前进度
|
||||
* @param progress 当前进度(0-100)
|
||||
*/
|
||||
fun setProgress(progress : Int){
|
||||
mProgress = progress
|
||||
invalidate()
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置当前进度,并展示进度动画。如果动画时间小于等于0,则不展示动画
|
||||
* @param progress 当前进度(0-100)
|
||||
* @param animTime 动画时间(毫秒)
|
||||
*/
|
||||
fun setProgress(progress : Int, animTime : Long){
|
||||
if (animTime<=0){
|
||||
setProgress(progress)
|
||||
} else{
|
||||
val animator = ValueAnimator.ofInt(mProgress, progress)
|
||||
animator.addUpdateListener{
|
||||
mProgress = it.animatedValue as Int
|
||||
invalidate()
|
||||
}
|
||||
animator.interpolator = OvershootInterpolator()
|
||||
animator.duration = animTime
|
||||
animator.start()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置背景圆环宽度
|
||||
* @param width 背景圆环宽度
|
||||
*/
|
||||
fun setBackWidth(width : Int){
|
||||
mBackPaint.strokeWidth = width.toFloat()
|
||||
invalidate()
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置背景圆环颜色
|
||||
* @param color 背景圆环颜色
|
||||
*/
|
||||
fun setBackColor(color : Int){
|
||||
mBackPaint.color = ContextCompat.getColor(context,color)
|
||||
invalidate()
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置进度圆环宽度
|
||||
* @param width 进度圆环宽度
|
||||
*/
|
||||
fun setProgWidth(width : Int){
|
||||
mProgPaint.strokeWidth = width.toFloat()
|
||||
invalidate()
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置进度圆环颜色
|
||||
* @param color 景圆环颜色
|
||||
*/
|
||||
fun setProgColor(color : Int){
|
||||
mProgPaint.color = ContextCompat.getColor(context,color)
|
||||
mProgPaint.shader = null
|
||||
invalidate()
|
||||
}
|
||||
|
||||
fun setProgColor(startColor : Int,endColor: Int){
|
||||
mColorArray = intArrayOf(ContextCompat.getColor(context,startColor),ContextCompat.getColor(context,endColor))
|
||||
mColorArray?.let {
|
||||
mProgPaint.shader = LinearGradient(0f, 0f, 0f,
|
||||
getMeasuredWidth().toFloat(), it, null, Shader.TileMode.MIRROR)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun setProgColor(colorArray : IntArray){
|
||||
colorArray.let {
|
||||
if(it.size<2){
|
||||
return
|
||||
}
|
||||
mColorArray = it.copyOf()
|
||||
mColorArray?.let{
|
||||
mProgPaint.shader = LinearGradient(0f, 0f, 0f,
|
||||
getMeasuredWidth().toFloat(), it, null, Shader.TileMode.MIRROR)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.mogo.eagle.core.function.hmi.ui.widget
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
@@ -10,6 +11,8 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListener
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.function.hmi.ui.tools.AdUpgradeDialog
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.eagle.core.utilcode.util.AppUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import kotlinx.android.synthetic.main.view_system_version.view.*
|
||||
|
||||
/**
|
||||
@@ -25,10 +28,18 @@ class SystemVersionView @JvmOverloads constructor(
|
||||
|
||||
companion object {
|
||||
const val TAG = "SystemVersionView"
|
||||
|
||||
const val AD_LATEST_VERSION = 1 //AD最新版
|
||||
const val AD_DOWNING = 2 //AD下载中
|
||||
const val AD_DOWNLOAD_FAIL = 3 //AD下载失败
|
||||
const val AD_UPGRADEABLE = 4 //AD下载成功,可升级状态
|
||||
const val AD_UPGRADING = 5 //AD升级中
|
||||
const val AD_UPGRADE_FAIL = 6 //AD升级失败
|
||||
}
|
||||
|
||||
private var connectStatus = false
|
||||
private var adUpgradeDialog : AdUpgradeDialog? = null
|
||||
private var adStatus = AD_LATEST_VERSION //工控机默认为最新版
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_system_version, this, true)
|
||||
@@ -36,6 +47,9 @@ class SystemVersionView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
private fun initView(){
|
||||
showCurrentPadVersion()
|
||||
showCurrentAdVersion()
|
||||
|
||||
//鹰眼版本视图点击事件
|
||||
ivPadVersion.setOnClickListener {
|
||||
Logger.i(TAG,"pad version view clicked")
|
||||
@@ -43,10 +57,104 @@ class SystemVersionView @JvmOverloads constructor(
|
||||
//工控机版本视图点击事件
|
||||
ivAdVersion.setOnClickListener {
|
||||
Logger.i(TAG,"ad version view clicked")
|
||||
if(adUpgradeDialog == null){
|
||||
adUpgradeDialog = AdUpgradeDialog(context)
|
||||
when(adStatus){
|
||||
AD_LATEST_VERSION -> {
|
||||
//最新版
|
||||
|
||||
}
|
||||
AD_DOWNING -> {
|
||||
//下载中
|
||||
//TODO 需要向工控机要下载时间
|
||||
ToastUtils.showShort("新版本下载中,预计XX分钟下载完成")
|
||||
}
|
||||
AD_DOWNLOAD_FAIL -> {
|
||||
//下载失败
|
||||
|
||||
}
|
||||
AD_UPGRADEABLE -> {
|
||||
//下载成功,可升级,点击弹起升级确认弹窗
|
||||
if(adUpgradeDialog == null){
|
||||
adUpgradeDialog = AdUpgradeDialog(context)
|
||||
}
|
||||
adUpgradeDialog?.showUpgradeDialog()
|
||||
}
|
||||
AD_UPGRADING -> {
|
||||
//升级中
|
||||
ToastUtils.showShort("新版本升级中,预计5分钟升级完成")
|
||||
}
|
||||
AD_UPGRADE_FAIL -> {
|
||||
//升级失败
|
||||
ToastUtils.showShort("升级失败,请联系运维人员")
|
||||
}
|
||||
|
||||
}
|
||||
adUpgradeDialog?.showUpgradeDialog()
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示当前鹰眼版本
|
||||
*/
|
||||
private fun showCurrentPadVersion(){
|
||||
tvPadVersionContent?.let {
|
||||
it.text = AppUtils.getAppVersionName()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示当前工控机版本
|
||||
*/
|
||||
private fun showCurrentAdVersion(){
|
||||
tvAdVersionContent?.let {
|
||||
// it.text = AdasManager.getInstance().getAdasConfig().getDockVersion())
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示工控机下载状态信息
|
||||
* @param downloadVersion 下载版本
|
||||
* @param downloadStatus 下载状态(0:下载完成;1:正在下载;2:下载失败)
|
||||
* @param downloadProgress 下载进度
|
||||
*/
|
||||
fun showAdDownloadStatus(downloadVersion : String,downloadStatus : Int,downloadProgress : Int){
|
||||
if(downloadStatus==0){
|
||||
//下载完成,处于可升级状态,展示“可升级”角标,将AD背景变为蓝色,并隐藏下载进度条
|
||||
adStatus = AD_UPGRADEABLE
|
||||
ivAdStatus?.setImageResource(R.drawable.icon_upgradeable)
|
||||
ivAdVersion?.setBackgroundResource(R.drawable.version_upgradeable_background)
|
||||
adCircularProgressView?.visibility = View.GONE
|
||||
}else if(downloadStatus==1){
|
||||
//正在下载,展示“下载中”角标,展示进度条,并设置当前下载进度
|
||||
adStatus = AD_DOWNING
|
||||
ivAdStatus?.setImageResource(R.drawable.icon_downloading)
|
||||
adCircularProgressView?.let {
|
||||
it.visibility = View.VISIBLE
|
||||
it.setProgress(downloadProgress)
|
||||
}
|
||||
}else if(downloadStatus==2){
|
||||
//下载失败,目前暂时将状态设为“最新版”角标,并隐藏进度条
|
||||
adStatus = AD_DOWNLOAD_FAIL
|
||||
ivAdStatus?.setImageResource(R.drawable.icon_latest_version)
|
||||
adCircularProgressView?.visibility = View.GONE
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示工控机升级状态信息
|
||||
* @param upgradeStatus 升级状态(true代表升级成功、false代表升级不成功)
|
||||
*/
|
||||
fun showAdUpgradeStatus(upgradeStatus : Boolean){
|
||||
if(upgradeStatus){
|
||||
//AD升级成功,工控机图标展示最新版样式
|
||||
adStatus = AD_LATEST_VERSION
|
||||
ivAdStatus?.setImageResource(R.drawable.icon_latest_version)
|
||||
}else{
|
||||
//AD升级失败,工控机图标展示升级失败样式
|
||||
adStatus = AD_UPGRADE_FAIL
|
||||
ivAdStatus?.setImageResource(R.drawable.icon_upgrade_failed)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 6.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 7.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 7.3 KiB |
@@ -171,6 +171,7 @@
|
||||
/>
|
||||
|
||||
<com.mogo.eagle.core.function.hmi.ui.widget.SystemVersionView
|
||||
android:id="@+id/systemVersionView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="40px"
|
||||
|
||||
@@ -68,6 +68,21 @@
|
||||
android:background="@drawable/version_latest_background"
|
||||
/>
|
||||
|
||||
<com.mogo.eagle.core.function.hmi.ui.widget.CircularProgressView
|
||||
android:id="@+id/adCircularProgressView"
|
||||
android:layout_width="150px"
|
||||
android:layout_height="150px"
|
||||
app:layout_constraintCircle="@id/ivAdVersion"
|
||||
tools:ignore="MissingConstraints"
|
||||
app:backColor="#E63B4577"
|
||||
app:backWidth="2dp"
|
||||
app:progColor="#029DFF"
|
||||
app:progWidth="2dp"
|
||||
app:progress="0"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivAdStatus"
|
||||
android:layout_width="120px"
|
||||
|
||||
@@ -38,4 +38,15 @@
|
||||
<attr name="Title" format="string" />
|
||||
<attr name="Icon" format="string" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="CircularProgressView">
|
||||
<attr name="backWidth" format="dimension" /> <!--背景圆环宽度-->
|
||||
<attr name="progWidth" format="dimension" /> <!--进度圆环宽度-->
|
||||
<attr name="backColor" format="color" /> <!--背景圆环颜色-->
|
||||
<attr name="progColor" format="color" /> <!--进度圆环颜色-->
|
||||
<attr name="progStartColor" format="color" /> <!--进度圆环开始颜色-->
|
||||
<attr name="progFirstColor" format="color" /> <!--进度圆环结束颜色-->
|
||||
<attr name="progress" format="integer" /> <!--圆环进度-->
|
||||
</declare-styleable>
|
||||
|
||||
</resources>
|
||||
Reference in New Issue
Block a user