From e1447acd2f5e25ea6e2d8c3f2b62e3f9f8d18a9d Mon Sep 17 00:00:00 2001 From: chenfufeng Date: Mon, 29 May 2023 19:39:52 +0800 Subject: [PATCH] =?UTF-8?q?[3.2.0][Opt]=E4=B9=98=E5=AE=A2=E5=B1=8F?= =?UTF-8?q?=E8=B0=83=E8=AF=95=E9=9D=A2=E6=9D=BF=E5=A2=9E=E5=8A=A0=E9=AB=98?= =?UTF-8?q?=E7=B2=BE=E5=9C=B0=E5=9B=BE=E7=A6=BB=E7=BA=BF=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hmi/ui/setting/DebugSettingView.kt | 78 +++++++++++++++++++ .../main/res/layout/view_debug_setting.xml | 15 ++++ .../java/com/mogo/map/AMapViewWrapper.java | 8 +- 3 files changed, 97 insertions(+), 4 deletions(-) diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt index a2fe6907a8..6bf2920d26 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt @@ -65,7 +65,9 @@ import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager import com.mogo.eagle.core.function.hmi.R import com.mogo.eagle.core.function.hmi.ui.logcatch.ILogViewListener import com.mogo.eagle.core.function.hmi.ui.logcatch.LogInfoView +import com.mogo.eagle.core.function.hmi.ui.map.OfflineMapDialog import com.mogo.eagle.core.function.hmi.ui.widget.DemoModeView +import com.mogo.eagle.core.function.hmi.ui.widget.SystemVersionView import com.mogo.eagle.core.utilcode.kotlin.* import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger @@ -76,6 +78,7 @@ import com.mogo.eagle.core.utilcode.mogo.permissions.BackgrounderPermission import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr import com.mogo.eagle.core.utilcode.mogo.toast.TipToast import com.mogo.eagle.core.utilcode.util.* +import com.mogo.map.hdcache.IHdCacheListener import com.mogo.map.uicontroller.VisualAngleMode import com.mogo.map.uicontroller.VisualAngleMode.* import kotlinx.android.synthetic.main.view_debug_setting.view.* @@ -180,6 +183,9 @@ internal class DebugSettingView @JvmOverloads constructor( private var isStarted = false + // 高精地图是否已缓存 + private var isHDCached = false + init { LayoutInflater.from(context).inflate(R.layout.view_debug_setting, this, true) initView() @@ -571,6 +577,32 @@ internal class DebugSettingView @JvmOverloads constructor( } } + btn_cache_hd_map?.onClick { + if (isHDCached) { + ToastUtils.showShort(resources.getString(R.string.offline_had_downloaded)) + } else { + if (CallerMapUIServiceManager.getCityCode().isNullOrEmpty()) {// 未拿到高德的cityCode + if (mGnssInfo == null || (mGnssInfo!!.longitude <= 0.0 && mGnssInfo!!.latitude <= 0.0)) {// 未拿到高精的经纬度 + ToastUtils.showShort(resources.getString(R.string.location_try_again)) + } else {// 拿到了高精的经纬度 + cacheHDOfflineData(false) + } + } else {// 拿到高德的cityCode + cacheHDOfflineData(true) + } + } + } + + if (AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) { + ThreadUtils.getIoPool().execute { + val isCached = CallerMapUIServiceManager.isCityDataCached() + isHDCached = isCached + UiThreadHandler.post { + btn_cache_hd_map.text = "缓存高精离线地图(${if (isCached) "已是最新版" else "待更新"}!)" + } + } + btn_cache_hd_map.visibility = View.VISIBLE + } /** * 修改自车按钮(出租车、小巴车) @@ -2123,6 +2155,52 @@ internal class DebugSettingView @JvmOverloads constructor( Process.killProcess(Process.myPid()) } + private fun cacheHDOfflineData(isGaoDe: Boolean) { + var progss = 0 + if (isGaoDe) {// 拿到了高德地图的cityCode + CallerMapUIServiceManager.cacheHDDataByCity(object : IHdCacheListener { + override fun onMapHdCacheProgress(cityId: Int, progress: Double) { + // 更新进度 + progss = progress.toInt() + if (progss == 100) { + isHDCached = true + btn_cache_hd_map.text = "缓存高精离线地图(已是最新版!)" + } else { + btn_cache_hd_map.text = "缓存高精离线地图(进度:${progss}%)" + } + } + + override fun onMapHdCacheResult(cityId: Int, state: Int) { + if (state == 0) {// 失败 + btn_cache_hd_map.text = "缓存高精离线地图(下载失败!)" + ToastUtils.showShort("下载失败,请重试!") + } + } + }) + } else {// 只拿到了高精的经纬度 + mGnssInfo?.let { loc -> + CallerMapUIServiceManager.cacheHDDataByCityByLonLat(object : IHdCacheListener { + override fun onMapHdCacheProgress(cityId: Int, progress: Double) { + progss = progress.toInt() + if (progss == 100) { + isHDCached = true + btn_cache_hd_map.text = "缓存高精离线地图(已是最新版!)" + } else { + btn_cache_hd_map.text = "缓存高精离线地图(进度:${progss}%)" + } + } + + override fun onMapHdCacheResult(cityId: Int, state: Int) { + if (state == 0) {// 失败 + btn_cache_hd_map.text = "缓存高精离线地图(下载失败!)" + ToastUtils.showShort("下载失败,请重试!") + } + } + }, loc) + } + } + } + override fun fwThreadClose() { refreshTraceInfo() } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_debug_setting.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_debug_setting.xml index 81b044daa6..2d9b5fd0d0 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_debug_setting.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_debug_setting.xml @@ -1560,6 +1560,21 @@ app:layout_constraintRight_toRightOf="@id/changesight_cross_btn" app:layout_constraintTop_toBottomOf="@id/changesight_cross_btn" /> +