完成了预警红边的迁移HMI调用方式

Signed-off-by: chenfufeng <chenfufeng@zhidaoauto.com>
This commit is contained in:
chenfufeng
2021-09-13 14:35:12 +08:00
parent cd1e2cfcf6
commit 1236316ba3
23 changed files with 388 additions and 28 deletions

1
.idea/gradle.xml generated
View File

@@ -35,6 +35,7 @@
<option value="$PROJECT_DIR$/modules/mogo-module-authorize" />
<option value="$PROJECT_DIR$/modules/mogo-module-back" />
<option value="$PROJECT_DIR$/modules/mogo-module-common" />
<option value="$PROJECT_DIR$/modules/mogo-module-data" />
<option value="$PROJECT_DIR$/modules/mogo-module-extensions" />
<option value="$PROJECT_DIR$/modules/mogo-module-hmi" />
<option value="$PROJECT_DIR$/modules/mogo-module-left-panel" />

1
modules/mogo-module-data/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

View File

@@ -0,0 +1 @@
### 这里存放数据相关的class

View File

@@ -0,0 +1,36 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion rootProject.ext.android.compileSdkVersion
// buildToolsVersion rootProject.ext.android.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.android.minSdkVersion
targetSdkVersion rootProject.ext.android.targetSdkVersion
versionCode Integer.valueOf(VERSION_CODE)
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation rootProject.ext.dependencies.kotlinstdlibjdk7
}
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()

View File

@@ -0,0 +1,3 @@
GROUP=com.mogo.module
POM_ARTIFACT_ID=module-data
VERSION_CODE=1

View File

@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mogo.mogo.module.data">
</manifest>

View File

@@ -0,0 +1,51 @@
package com.mogo.module.data.enums
/**
*@author xiaoyuzhou
*@date 2021/9/10 8:48 下午
*/
enum class WarningDirectionEnum(
var direction: Int,
var desc: String,
) {
ALERT_WARNING_NON(
0,
"关闭红色边框预警"
),
ALERT_WARNING_TOP(
1,
"正前方"
),
ALERT_WARNING_RIGHT(
2,
"正右边"
),
ALERT_WARNING_BOTTOM(
3,
"正后方"
),
ALERT_WARNING_LEFT(
4,
"正左方"
),
ALERT_WARNING_TOP_RIGHT(
5,
"正前方"
),
ALERT_WARNING_BOTTOM_RIGHT(
6,
"正前方"
),
ALERT_WARNING_BOTTOM_LEFT(
7,
"正前方"
),
ALERT_WARNING_TOP_LEFT(
8,
"正前方"
),
ALERT_WARNING_ALL(
9,
"全方位"
)
}

View File

@@ -59,6 +59,7 @@ dependencies {
api rootProject.ext.dependencies.mogoserviceapi
implementation rootProject.ext.dependencies.modulecommon
implementation rootProject.ext.dependencies.moduleservice
implementation rootProject.ext.dependencies.moduledata
} else {
api project(":libraries:mogo-map")
api project(":libraries:mogo-map-api")
@@ -67,6 +68,7 @@ dependencies {
api project(':services:mogo-service-api')
implementation project(':modules:mogo-module-common')
implementation project(':modules:mogo-module-service')
implementation project(':modules:mogo-module-data')
}
}

View File

@@ -1,6 +1,7 @@
package com.mogo.module.hmi.ui
import com.mogo.commons.mvp.IView
import com.mogo.module.data.enums.WarningDirectionEnum
/**
@@ -9,10 +10,6 @@ import com.mogo.commons.mvp.IView
*/
interface MoGoWarningContract {
/**
*
*/
interface View : IView {
/**
@@ -81,5 +78,20 @@ interface MoGoWarningContract {
* 关闭限速预警
*/
fun disableLimitingVelocity()
/**
* 展示指定方位上的红框预警
* @param direction
* @see WarningDirectionEnum
*/
fun showWarning(direction: WarningDirectionEnum)
/**
* 展示指定方位上的红框预警
* @param direction
* @see WarningDirectionEnum
* @param closeTime 倒计时
*/
fun showWarning(direction: WarningDirectionEnum, closeTime: Long)
}
}

View File

@@ -14,6 +14,7 @@ import com.mogo.module.hmi.notification.WarningFloat
import com.mogo.module.hmi.notification.anim.DefaultAnimator
import com.mogo.module.hmi.notification.enums.SidePattern
import com.mogo.module.hmi.ui.widget.V2XNotificationView
import com.mogo.module.data.enums.WarningDirectionEnum
import com.mogo.utils.logger.Logger
import kotlinx.android.synthetic.main.fragment_warning.*
@@ -95,7 +96,10 @@ class MoGoWarningFragment : MvpFragment<MoGoWarningContract.View?, WaringPresent
.show()
// 创建弹窗成功才进行TTS播报
Logger.d("MoGoWarningFragment", " mWarningFloat = " + mWarningFloat + "---ttsContent = " + ttsContent)
Logger.d(
"MoGoWarningFragment",
"mWarningFloat = $mWarningFloat---ttsContent = $ttsContent"
)
if (mWarningFloat != null && !TextUtils.isEmpty(ttsContent)) {
Logger.d("MoGoWarningFragment", "---> ttsContent = $ttsContent")
AIAssist.getInstance(activity)
@@ -171,4 +175,23 @@ class MoGoWarningFragment : MvpFragment<MoGoWarningContract.View?, WaringPresent
tvLimitingVelocity.visibility = View.GONE
tvLimitingVelocity.text = "0"
}
/**
* 展示指定方位上的红框预警
* @param direction
* @see WarningDirectionEnum
*/
override fun showWarning(direction: WarningDirectionEnum) {
flV2XWarningView.showWarning(direction)
}
/**
* 展示指定方位上的红框预警
* @param direction
* @see WarningDirectionEnum
* @param closeTime 倒计时
*/
override fun showWarning(direction: WarningDirectionEnum, closeTime: Long) {
flV2XWarningView.showWarning(direction, closeTime)
}
}

View File

@@ -10,27 +10,4 @@ class WaringPresenter(view: MoGoWarningContract.View?) :
Presenter<MoGoWarningContract.View?>(view) {
fun showWarningV2X(v2xType: Int, alertMessage: String, tag: String) {
}
fun disableWarningV2X(tag: String) {
mView?.disableWarningV2X(tag)
}
fun showWarningTrafficLight(checkLightId: Int) {
mView?.showWarningTrafficLight(checkLightId)
}
fun disableWarningTrafficLight() {
mView?.disableWarningTrafficLight()
}
fun showLimitingVelocity(limitingSpeed: Int) {
mView?.showLimitingVelocity(limitingSpeed)
}
fun disableLimitingVelocity() {
mView?.disableLimitingVelocity()
}
}

View File

@@ -0,0 +1,118 @@
package com.mogo.module.hmi.ui.widget
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.widget.RelativeLayout
import com.mogo.module.data.enums.WarningDirectionEnum
import com.mogo.module.hmi.R
import com.mogo.utils.logger.Logger
import kotlinx.android.synthetic.main.module_hmi_warning_v2x.view.*
/**
*@author xiaoyuzhou
*@date 2021/9/10 7:44 下午
*/
class V2XWarningView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : RelativeLayout(context, attrs, defStyleAttr) {
private val ALL_CLOSE_TIMER = 10000L
private val closeWarningTask: Runnable = Runnable {
showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
}
init {
LayoutInflater.from(context).inflate(R.layout.module_hmi_warning_v2x, this, true)
}
/**
* 展示指定方位上的红框预警
* @param direction
* @see WarningDirectionEnum
*/
fun showWarning(direction: WarningDirectionEnum) {
showWarning(direction, ALL_CLOSE_TIMER)
}
/**
* 展示指定方位上的红框预警
* @param direction
* @see WarningDirectionEnum
* @param closeTime 倒计时
*/
fun showWarning(direction: WarningDirectionEnum, closeTime: Long) {
Logger.d("V2XWarningView", "预警红边:预警方向->$direction 预警倒计时->$closeTime")
// 如果传入的不是关闭显示,则设置倒计时,定时关闭红框警示
if (direction != WarningDirectionEnum.ALERT_WARNING_NON) {
removeCallbacks(closeWarningTask)
postDelayed(closeWarningTask, closeTime)
}
when (direction) {
WarningDirectionEnum.ALERT_WARNING_NON -> {
hmiWarningTopImg.visibility = View.GONE
hmiWarningRightImg.visibility = View.GONE
hmiWarningBottomImg.visibility = View.GONE
hmiWarningLeftImg.visibility = View.GONE
}
WarningDirectionEnum.ALERT_WARNING_TOP -> {
hmiWarningTopImg.visibility = View.VISIBLE
hmiWarningRightImg.visibility = View.GONE
hmiWarningBottomImg.visibility = View.GONE
hmiWarningLeftImg.visibility = View.GONE
}
WarningDirectionEnum.ALERT_WARNING_RIGHT -> {
hmiWarningTopImg.visibility = View.GONE
hmiWarningRightImg.visibility = View.VISIBLE
hmiWarningBottomImg.visibility = View.GONE
hmiWarningLeftImg.visibility = View.GONE
}
WarningDirectionEnum.ALERT_WARNING_BOTTOM -> {
hmiWarningTopImg.visibility = View.GONE
hmiWarningRightImg.visibility = View.GONE
hmiWarningBottomImg.visibility = View.VISIBLE
hmiWarningLeftImg.visibility = View.GONE
}
WarningDirectionEnum.ALERT_WARNING_LEFT -> {
hmiWarningTopImg.visibility = View.GONE
hmiWarningRightImg.visibility = View.GONE
hmiWarningBottomImg.visibility = View.GONE
hmiWarningLeftImg.visibility = View.VISIBLE
}
WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT -> {
hmiWarningTopImg.visibility = View.VISIBLE
hmiWarningRightImg.visibility = View.VISIBLE
hmiWarningBottomImg.visibility = View.GONE
hmiWarningLeftImg.visibility = View.GONE
}
WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT -> {
hmiWarningTopImg.visibility = View.GONE
hmiWarningRightImg.visibility = View.VISIBLE
hmiWarningBottomImg.visibility = View.VISIBLE
hmiWarningLeftImg.visibility = View.GONE
}
WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT -> {
hmiWarningTopImg.visibility = View.GONE
hmiWarningRightImg.visibility = View.GONE
hmiWarningBottomImg.visibility = View.VISIBLE
hmiWarningLeftImg.visibility = View.VISIBLE
}
WarningDirectionEnum.ALERT_WARNING_TOP_LEFT -> {
hmiWarningTopImg.visibility = View.VISIBLE
hmiWarningRightImg.visibility = View.GONE
hmiWarningBottomImg.visibility = View.GONE
hmiWarningLeftImg.visibility = View.VISIBLE
}
WarningDirectionEnum.ALERT_WARNING_ALL -> {
hmiWarningTopImg.visibility = View.VISIBLE
hmiWarningRightImg.visibility = View.GONE
hmiWarningBottomImg.visibility = View.GONE
hmiWarningLeftImg.visibility = View.VISIBLE
}
}
}
}

View File

@@ -8,6 +8,7 @@ import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.module.data.enums.WarningDirectionEnum;
import com.mogo.module.hmi.WaringConst;
import com.mogo.module.hmi.ui.MoGoWarningFragment;
import com.mogo.service.MogoServicePaths;
@@ -101,4 +102,13 @@ public class MoGoWarningProvider implements IMoGoWaringProvider {
mMoGoWarningFragment.disableWarningV2X(tag);
}
@Override
public void showWarning(@NonNull WarningDirectionEnum direction) {
mMoGoWarningFragment.showWarning(direction);
}
@Override
public void showWarning(@NonNull WarningDirectionEnum direction, long closeTime) {
mMoGoWarningFragment.showWarning(direction, closeTime);
}
}

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="90"
android:endColor="#00F03232"
android:startColor="#66FF0808"
android:type="linear"/>
</shape>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="0"
android:endColor="#00F03232"
android:startColor="#66FF0808"
android:type="linear"/>
</shape>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="180"
android:endColor="#00F03232"
android:startColor="#66FF0808"
android:type="linear"/>
</shape>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="270"
android:endColor="#00FF0606"
android:startColor="#66FF0808"
android:type="linear"/>
</shape>

View File

@@ -5,6 +5,15 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.mogo.module.hmi.ui.widget.V2XWarningView
android:id="@+id/flV2XWarningView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.mogo.module.hmi.ui.widget.SpeedPanelView
android:id="@+id/flSpeedChartView"
android:layout_width="@dimen/module_ext_speed_width"

View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--四个方向,碰撞预警-->
<ImageView
android:id="@+id/hmiWarningTopImg"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_290"
android:background="@drawable/module_hmi_warning_bkg_top"
android:visibility="gone"
tools:visibility="visible" />
<ImageView
android:id="@+id/hmiWarningLeftImg"
android:layout_width="@dimen/dp_290"
android:layout_height="match_parent"
android:background="@drawable/module_hmi_warning_bkg_left"
android:visibility="gone"
tools:visibility="visible" />
<ImageView
android:id="@+id/hmiWarningRightImg"
android:layout_width="@dimen/dp_290"
android:layout_height="match_parent"
android:layout_gravity="end"
android:background="@drawable/module_hmi_warning_bkg_right"
android:visibility="gone"
tools:visibility="visible" />
<ImageView
android:id="@+id/hmiWarningBottomImg"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_290"
android:layout_gravity="bottom"
android:background="@drawable/module_hmi_warning_bkg_bottom"
android:visibility="gone"
tools:visibility="visible" />
</FrameLayout>

View File

@@ -56,9 +56,11 @@ dependencies {
if (Boolean.valueOf(RELEASE)) {
api rootProject.ext.dependencies.mogomapapi
api rootProject.ext.dependencies.skinsupport
implementation rootProject.ext.dependencies.moduledata
} else {
api project(":libraries:mogo-map-api")
api project(":skin:mogo-skin-support")
implementation project(':modules:mogo-module-data')
}
}

View File

@@ -1,5 +1,6 @@
package com.mogo.service.warning
import com.mogo.module.data.enums.WarningDirectionEnum
import com.mogo.service.module.IMogoModuleProvider
/**
@@ -73,4 +74,19 @@ interface IMoGoWaringProvider : IMogoModuleProvider {
* 关闭限速预警
*/
fun disableLimitingVelocity()
/**
* 展示指定方位上的红框预警
* @param direction
* @see WarningDirectionEnum
*/
fun showWarning(direction: WarningDirectionEnum)
/**
* 展示指定方位上的红框预警
* @param direction
* @see WarningDirectionEnum
* @param closeTime 倒计时
*/
fun showWarning(direction: WarningDirectionEnum, closeTime: Long)
}