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 ea42adc372..658e7f23a9 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 @@ -652,6 +652,50 @@ class MoGoHmiFragment : MvpFragment } + /** + * 展示工控机下载状态信息 + * @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") diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/CircularProgressView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/CircularProgressView.kt new file mode 100644 index 0000000000..66be06132d --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/CircularProgressView.kt @@ -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) + } + } + + } + +} \ 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/widget/SystemVersionView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/SystemVersionView.kt index 69f5f076af..58e9a52bc1 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/SystemVersionView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/SystemVersionView.kt @@ -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) } } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/icon_downloading.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/icon_downloading.png new file mode 100644 index 0000000000..c43939ea59 Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/icon_downloading.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/icon_upgrade_failed.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/icon_upgrade_failed.png new file mode 100644 index 0000000000..4e4966b6ce Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/icon_upgrade_failed.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/icon_upgradeable.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/icon_upgradeable.png new file mode 100644 index 0000000000..8255b8d564 Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/icon_upgradeable.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/icon_upgrading.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/icon_upgrading.png new file mode 100644 index 0000000000..61e58db5d6 Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/icon_upgrading.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_auto_pilot_check.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_auto_pilot_check.xml index b04aa31518..fe7082556b 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_auto_pilot_check.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_auto_pilot_check.xml @@ -171,6 +171,7 @@ /> + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/hmi/warning/IMoGoWaringProvider.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/hmi/warning/IMoGoWaringProvider.kt index 483f2954d6..92880a719c 100644 --- a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/hmi/warning/IMoGoWaringProvider.kt +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/hmi/warning/IMoGoWaringProvider.kt @@ -159,4 +159,18 @@ interface IMoGoWaringProvider { */ fun showBrakeLight(brakeLight: Int) + /** + * 展示工控机下载状态信息 + * @param downloadVersion 下载版本 + * @param downloadStatus 下载状态(0:下载完成;1:正在下载;2:下载失败) + * @param downloadProgress 下载进度 + */ + fun showAdDownloadStatus(downloadVersion : String,downloadStatus : Int,downloadProgress : Int) + + /** + * 展示工控机升级状态信息 + * @param upgradeStatus 升级状态(true代表升级成功、false代表升级不成功) + */ + fun showAdUpgradeStatus(upgradeStatus : Boolean) + } \ No newline at end of file diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/hmi/CallerHmiManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/hmi/CallerHmiManager.kt index b10fbffcba..367b09c856 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/hmi/CallerHmiManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/hmi/CallerHmiManager.kt @@ -226,4 +226,24 @@ object CallerHmiManager : CallerBase() { fun hideToolsView() { waringProviderApi.hideToolsView() } + + /** + * 展示工控机下载状态信息 + * @param downloadVersion 下载版本 + * @param downloadStatus 下载状态(0:下载完成;1:正在下载;2:下载失败) + * @param downloadProgress 下载进度 + */ + fun showAdDownloadStatus(downloadVersion : String,downloadStatus : Int,downloadProgress : Int){ + waringProviderApi.showAdDownloadStatus(downloadVersion,downloadStatus,downloadProgress) + } + + /** + * 展示工控机升级状态信息 + * @param upgradeStatus 升级状态(true代表升级成功、false代表升级不成功) + */ + fun showAdUpgradeStatus(upgradeStatus : Boolean){ + waringProviderApi.showAdUpgradeStatus(upgradeStatus) + } + + } \ No newline at end of file diff --git a/modules/mogo-module-adas/src/main/java/com/mogo/module/adas/OnAdasListenerAdapter.java b/modules/mogo-module-adas/src/main/java/com/mogo/module/adas/OnAdasListenerAdapter.java index 9665f90b35..729d99df65 100644 --- a/modules/mogo-module-adas/src/main/java/com/mogo/module/adas/OnAdasListenerAdapter.java +++ b/modules/mogo-module-adas/src/main/java/com/mogo/module/adas/OnAdasListenerAdapter.java @@ -25,6 +25,7 @@ import com.zhidao.support.adas.high.bean.AutopilotWayArrive; import com.zhidao.support.adas.high.bean.CarLaneInfo; import com.zhidao.support.adas.high.bean.CarStateInfo; import com.zhidao.support.adas.high.bean.IPCPowerResultInfo; +import com.zhidao.support.adas.high.bean.IPCUpgradeInfo; import com.zhidao.support.adas.high.bean.IPCUpgradePatchDownloadStatusInfo; import com.zhidao.support.adas.high.bean.IPCUpgradeStateInfo; import com.zhidao.support.adas.high.bean.LightStatueInfo; @@ -214,7 +215,21 @@ public class OnAdasListenerAdapter implements OnAdasListener { */ @Override public void onUpgradeStateInfo(IPCUpgradeStateInfo info) { - + if(info!=null){ + Logger.d(TAG,"onUpgradeStateInfo : "+info.getUpgradeStatus()); + boolean upgradeStatus=false;//工控机升级状态,true代表升级成功 false代表升级失败,默认为false + if(info.getUpgradeStatus() == IPCUpgradeStateInfo.Status.SUCCESSFUL.code){ + upgradeStatus=true;//升级成功 + //升级结束确认 + AdasManager.getInstance().sendBaseInfo(IPCUpgradeInfo.upgradeFinishAffirm()); + }else if(info.getUpgradeStatus() == IPCUpgradeStateInfo.Status.FAILED.code){ + upgradeStatus=false;//升级失败 + } + Logger.d(TAG,"onUpgradeStateInfo : "+(upgradeStatus ? "升级成功" :"升级失败")); + CallerHmiManager.INSTANCE.showAdUpgradeStatus(upgradeStatus); + }else{ + Logger.d(TAG,"onUpgradeStateInfo : upgrade status info is null"); + } } /** @@ -223,6 +238,13 @@ public class OnAdasListenerAdapter implements OnAdasListener { */ @Override public void onUpgradePatchDownloadStatus(IPCUpgradePatchDownloadStatusInfo info) { + if(info!=null){ + Logger.d(TAG,"onUpgradePatchDownloadStatus : status="+info.getDownloadStatus() + + " version="+info.getDownloadVersion()+ " progress="+info.getDownloadProgress()); + CallerHmiManager.INSTANCE.showAdDownloadStatus(info.getDownloadVersion(),info.getDownloadStatus(),info.getDownloadProgress()); + }else{ + Logger.d(TAG,"onUpgradePatchDownloadStatus : download status info is null"); + } }