[Feat]新增高精地图缓存功能
This commit is contained in:
@@ -0,0 +1,170 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.map
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.MainThread
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import androidx.core.view.marginTop
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.function.hmi.dialog.BaseFloatDialog
|
||||
import com.mogo.map.hdcache.IHdCacheListener
|
||||
import me.jessyan.autosize.utils.AutoSizeUtils
|
||||
|
||||
/**
|
||||
* 离线地图缓存
|
||||
*/
|
||||
class OfflineMapDialog(context: Context): BaseFloatDialog(context) {
|
||||
|
||||
private var roundRootLayout: ConstraintLayout? = null
|
||||
private var offlineTitleView: TextView? = null
|
||||
private var leftView: TextView? = null
|
||||
private var rightView: TextView? = null
|
||||
private var okView: TextView? = null
|
||||
private var vertLineView: View? = null
|
||||
private var horizontalLineView: View? = null
|
||||
private var cacheTipView: TextView? = null
|
||||
|
||||
private var progressBar: ProgressBar? = null
|
||||
private var downloadPercentView: TextView? = null
|
||||
private var downloadResultImg: ImageView? = null
|
||||
|
||||
private var isLoading = false
|
||||
private var isConfirm = true
|
||||
private var isRetry = false
|
||||
|
||||
init {
|
||||
setContentView(R.layout.dialog_offline_map)
|
||||
setCanceledOnTouchOutside(true)
|
||||
|
||||
initView()
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
roundRootLayout = findViewById(R.id.roundRootLayout)
|
||||
offlineTitleView = findViewById(R.id.tv_cache_title)
|
||||
progressBar = findViewById(R.id.progressBar)
|
||||
downloadPercentView = findViewById(R.id.tvDownloadProgress)
|
||||
leftView = findViewById(R.id.tv_cache_confirm)
|
||||
rightView = findViewById(R.id.tv_cache_cancel)
|
||||
okView = findViewById(R.id.tv_cache_ok)
|
||||
vertLineView = findViewById(R.id.view_vertical_line)
|
||||
horizontalLineView = findViewById(R.id.view_horizontal_line)
|
||||
cacheTipView = findViewById(R.id.tv_cache_tips)
|
||||
downloadResultImg = findViewById(R.id.iv_download_Status)
|
||||
|
||||
leftView?.setOnClickListener {
|
||||
when {
|
||||
isConfirm -> {
|
||||
cacheHDOfflineData()
|
||||
showNewContent(isLoading = true, false)
|
||||
}
|
||||
else -> {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rightView?.setOnClickListener {
|
||||
when {
|
||||
isRetry -> {
|
||||
cacheHDOfflineData()
|
||||
}
|
||||
else -> {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
okView?.setOnClickListener {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
private fun cacheHDOfflineData() {
|
||||
CallerMapUIServiceManager.cacheHDDataByCity(object : IHdCacheListener {
|
||||
override fun onMapHdCacheProgress(cityId: Int, progress: Double) {
|
||||
updateProgress(progress.toInt())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun updateProgress(progress: Int) {
|
||||
if (this@OfflineMapDialog.isShowing) {
|
||||
progressBar?.let {
|
||||
if (it.visibility == View.VISIBLE) {
|
||||
it.progress = if (progress in 1..5) 5 else progress
|
||||
}
|
||||
}
|
||||
downloadPercentView?.text = "$progress%"
|
||||
if (progress == 100) {
|
||||
showNewContent(isLoading = false, true)
|
||||
CallerHmiManager.updateHDDataCacheStatus(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun change2NewStyle() {
|
||||
roundRootLayout?.layoutParams?.width = AutoSizeUtils.dp2px(context, 1110f)
|
||||
roundRootLayout?.layoutParams?.height = AutoSizeUtils.dp2px(context, 668f)
|
||||
|
||||
val titleParams = offlineTitleView?.layoutParams as ConstraintLayout.LayoutParams
|
||||
titleParams.topMargin = AutoSizeUtils.dp2px(context, 51f)
|
||||
|
||||
val horizontalLineParams = horizontalLineView?.layoutParams as ConstraintLayout.LayoutParams
|
||||
horizontalLineParams.topMargin = AutoSizeUtils.dp2px(context, 374f)
|
||||
|
||||
progressBar?.visibility = View.VISIBLE
|
||||
downloadPercentView?.visibility = View.VISIBLE
|
||||
okView?.visibility = View.VISIBLE
|
||||
|
||||
vertLineView?.visibility = View.GONE
|
||||
leftView?.visibility = View.GONE
|
||||
rightView?.visibility = View.GONE
|
||||
cacheTipView?.visibility = View.INVISIBLE
|
||||
}
|
||||
|
||||
@SuppressLint("UseCompatLoadingForDrawables")
|
||||
private fun showNewContent(isLoading: Boolean, isSuccess: Boolean) {
|
||||
change2NewStyle()
|
||||
when {
|
||||
isLoading -> {
|
||||
okView?.text = context.resources.getString(R.string.cancel)
|
||||
offlineTitleView?.text = context.resources.getString(R.string.offline_downloading)
|
||||
downloadResultImg?.visibility = View.GONE
|
||||
}
|
||||
else -> {
|
||||
downloadResultImg?.visibility = View.VISIBLE
|
||||
when {
|
||||
isSuccess -> {
|
||||
okView?.visibility = View.VISIBLE
|
||||
okView?.text = context.resources.getString(R.string.ok_tip)
|
||||
offlineTitleView?.text = context.resources.getString(R.string.offline_download_success)
|
||||
progressBar?.visibility = View.GONE
|
||||
downloadPercentView?.visibility = View.GONE
|
||||
downloadResultImg?.background = ContextCompat.getDrawable(context, R.drawable.download_success_icon)
|
||||
}
|
||||
else -> {
|
||||
offlineTitleView?.text = context.resources.getString(R.string.offline_download_failure)
|
||||
okView?.visibility = View.GONE
|
||||
progressBar?.visibility = View.GONE
|
||||
downloadPercentView?.visibility = View.GONE
|
||||
leftView?.visibility = View.VISIBLE
|
||||
rightView?.visibility = View.VISIBLE
|
||||
vertLineView?.visibility = View.VISIBLE
|
||||
rightView?.text = context.resources.getString(R.string.retry)
|
||||
downloadResultImg?.background = ContextCompat.getDrawable(context, R.drawable.download_fail_icon)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -197,6 +197,10 @@ internal class AutoPilotAndCheckView @JvmOverloads constructor(
|
||||
systemVersionView?.showAdUpgradeStatus(ipcUpgradeStateInfo)
|
||||
}
|
||||
|
||||
fun updateHDDataCacheStatus(isCached: Boolean) {
|
||||
systemVersionView?.updateHDDataCacheStatus(isCached)
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
|
||||
|
||||
@@ -10,10 +10,15 @@ import com.mogo.eagle.core.data.bindingcar.AdUpgradeStateHelper
|
||||
import com.mogo.eagle.core.data.bindingcar.IPCUpgradeStateInfo
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.api.devatools.IMoGoDevaToolsListener
|
||||
import com.mogo.eagle.core.function.api.bindingcar.IMoGoBindingCarListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsListenerManager
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager
|
||||
import com.mogo.eagle.core.function.call.bindingcar.CallerBindingCarListenerManager
|
||||
import com.mogo.eagle.core.function.call.bindingcar.CallerBindingcarManager
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.function.hmi.ui.map.OfflineMapDialog
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_HMI
|
||||
import com.mogo.eagle.core.utilcode.util.AppUtils
|
||||
@@ -135,6 +140,12 @@ class SystemVersionView @JvmOverloads constructor(
|
||||
|
||||
}
|
||||
|
||||
ivHDCache.setOnClickListener {
|
||||
OfflineMapDialog(context).show()
|
||||
}
|
||||
|
||||
updateHDDataCacheStatus(CallerMapUIServiceManager.isCityDataCached())
|
||||
|
||||
if(AdUpgradeStateHelper.isConfirmUpgrade()){
|
||||
//将角标改为“下载中”
|
||||
ivAdStatus?.setImageResource(R.drawable.icon_downloading)
|
||||
@@ -239,6 +250,16 @@ class SystemVersionView @JvmOverloads constructor(
|
||||
|
||||
}
|
||||
|
||||
fun updateHDDataCacheStatus(isCached: Boolean) {
|
||||
if (isCached) {
|
||||
ivHDCacheStatus?.setImageResource(R.drawable.icon_latest_version)
|
||||
ivHDCache.isEnabled = false
|
||||
} else {
|
||||
ivHDCacheStatus?.setImageResource(R.drawable.icon_be_updated)
|
||||
ivHDCache.isEnabled = true
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示当前鹰眼版本
|
||||
*/
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 8.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 9.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 7.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.1 KiB |
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- 设置背景色 -->
|
||||
<item android:id="@android:id/background">
|
||||
<shape>
|
||||
<corners android:radius="21dp" />
|
||||
<solid android:color="@android:color/transparent" />
|
||||
<stroke android:color="#7CF6FF" android:width="2dp" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
<!-- <item android:id="@android:id/secondaryProgress"-->
|
||||
<!-- android:start="1.5dp"-->
|
||||
<!-- android:end="1.5dp"-->
|
||||
<!-- android:top="1.5dp"-->
|
||||
<!-- android:bottom="1.5dp"-->
|
||||
<!-- >-->
|
||||
<!-- <scale android:scaleWidth="100%">-->
|
||||
<!-- <shape>-->
|
||||
<!-- <corners android:radius="21dp" />-->
|
||||
<!-- <solid android:color="@android:color/holo_green_light" />-->
|
||||
<!-- </shape>-->
|
||||
<!-- </scale>-->
|
||||
<!-- </item>-->
|
||||
|
||||
<!-- 设置进度条颜色 -->
|
||||
<item android:id="@android:id/progress"
|
||||
android:start="2dp"
|
||||
android:end="2dp"
|
||||
android:top="2dp"
|
||||
android:bottom="2dp"
|
||||
>
|
||||
<scale android:scaleWidth="100%">
|
||||
<shape>
|
||||
<corners android:radius="21dp" />
|
||||
<gradient
|
||||
android:angle="0"
|
||||
android:endColor="#00E5FF"
|
||||
android:startColor="#374171" />
|
||||
</shape>
|
||||
</scale>
|
||||
</item>
|
||||
</layer-list>
|
||||
@@ -0,0 +1,135 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.mogo.eagle.core.widget.RoundConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/roundRootLayout"
|
||||
android:layout_width="840dp"
|
||||
android:layout_height="488dp"
|
||||
android:background="@color/dialog_bg_color_90_percent"
|
||||
app:roundLayoutRadius="32dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_cache_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="66dp"
|
||||
android:text="@string/offline_map_cache_tip"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="56dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_cache_tips"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="52dp"
|
||||
android:text="@string/cache_offline_map_content"
|
||||
android:textColor="#FFFFFFFF"
|
||||
android:textSize="43dp"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_cache_title" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
android:layout_width="800dp"
|
||||
android:layout_height="42dp"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_cache_title"
|
||||
android:layout_marginTop="113dp"
|
||||
android:max="100"
|
||||
android:progress="0"
|
||||
android:progressDrawable="@drawable/progressbar_corner_bg"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvDownloadProgress"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/progressBar"
|
||||
android:layout_marginTop="50dp"
|
||||
android:text="0%"
|
||||
android:textColor="#06D1ED"
|
||||
android:textSize="43dp"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_download_Status"
|
||||
android:layout_width="174dp"
|
||||
android:layout_height="174dp"
|
||||
android:layout_marginTop="96dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_cache_title"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
||||
<View
|
||||
android:id="@+id/view_horizontal_line"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="2dp"
|
||||
android:layout_marginTop="205dp"
|
||||
android:background="#66B8BFE8"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_cache_title" />
|
||||
|
||||
<View
|
||||
android:id="@+id/view_vertical_line"
|
||||
android:layout_width="2dp"
|
||||
android:layout_height="0dp"
|
||||
android:background="#66B8BFE8"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/view_horizontal_line" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_cache_confirm"
|
||||
android:layout_width="419dp"
|
||||
android:layout_height="137dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/confirm"
|
||||
android:textColor="#FFFFFFFF"
|
||||
android:textSize="46dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toLeftOf="@id/view_vertical_line"
|
||||
app:layout_constraintTop_toBottomOf="@id/view_horizontal_line" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_cache_cancel"
|
||||
android:layout_width="419dp"
|
||||
android:layout_height="137dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/cancel"
|
||||
android:textColor="#FFFFFFFF"
|
||||
android:textSize="46dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toRightOf="@id/view_vertical_line"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/view_horizontal_line" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_cache_ok"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="100dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/ok_tip"
|
||||
android:textColor="#FFFFFFFF"
|
||||
android:textSize="46dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toLeftOf="@id/view_vertical_line"
|
||||
app:layout_constraintTop_toBottomOf="@id/view_horizontal_line" />
|
||||
|
||||
</com.mogo.eagle.core.widget.RoundConstraintLayout>
|
||||
@@ -82,7 +82,6 @@
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivAdStatus"
|
||||
android:layout_width="120dp"
|
||||
@@ -120,4 +119,27 @@
|
||||
android:textSize="32dp"
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivHDCache"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="150dp"
|
||||
app:layout_constraintTop_toTopOf="@id/ivAdVersion"
|
||||
app:layout_constraintBottom_toBottomOf="@id/ivAdVersion"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:layout_marginStart="680dp"
|
||||
android:src="@drawable/icon_hd_map"
|
||||
android:padding="12dp"
|
||||
android:background="@drawable/version_latest_background"
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivHDCacheStatus"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="50dp"
|
||||
android:src="@drawable/icon_be_updated"
|
||||
app:layout_constraintCircle="@id/ivHDCache"
|
||||
app:layout_constraintCircleAngle="50"
|
||||
app:layout_constraintCircleRadius="90dp"
|
||||
tools:ignore="MissingConstraints" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -71,7 +71,5 @@
|
||||
|
||||
<color name="hmi_check_keyboard_input_field">#FF282F62</color>
|
||||
<color name="bus_autopilot_text_color_normal">#FFFFFF</color>
|
||||
|
||||
|
||||
|
||||
<color name="dialog_bg_color_90_percent">#E63B4577</color>
|
||||
</resources>
|
||||
@@ -65,4 +65,11 @@
|
||||
<string name="dispatch_cars_remind_content">车辆将开启自动驾驶,并行驶至:</string>
|
||||
<string name="dispatch_cars_affirm">确认</string>
|
||||
<string name="dispatch_cars_cancel">取消</string>
|
||||
<string name="offline_map_cache_tip">离线地图缓存提醒</string>
|
||||
<string name="cache_offline_map_content">是否缓存最新版本离线地图?</string>
|
||||
<string name="offline_downloading">离线地图下载中</string>
|
||||
<string name="offline_download_success">离线地图下载成功</string>
|
||||
<string name="offline_download_failure">离线地图下载失败</string>
|
||||
<string name="ok_tip">确定</string>
|
||||
<string name="retry">重试</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user