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" />
+
+