diff --git a/build.gradle b/build.gradle index 0ceead49a3..430d3b3bbc 100644 --- a/build.gradle +++ b/build.gradle @@ -15,7 +15,7 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:3.5.3' - classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.0' + classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.20' classpath "com.alibaba:arouter-register:1.0.2" classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:2.0.4' // classpath ("com.tencent.matrix:matrix-gradle-plugin:0.6.6") { changing = true } diff --git a/config.gradle b/config.gradle index 7ff00108c8..f826e2431c 100644 --- a/config.gradle +++ b/config.gradle @@ -1,6 +1,6 @@ ext { time = "" - kotlin_version = "1.4.10" + kotlin_version = "1.4.20" android = [ launcherApplicationId : "com.mogo.launcher", independentApplicationId : "com.mogo.launcher.app", diff --git a/modules/mogo-module-warning/build.gradle b/modules/mogo-module-warning/build.gradle index c85c05348a..d173ab6846 100644 --- a/modules/mogo-module-warning/build.gradle +++ b/modules/mogo-module-warning/build.gradle @@ -42,7 +42,8 @@ android { } dependencies { - + implementation rootProject.ext.dependencies.kotlinstdlibjdk7 + implementation rootProject.ext.dependencies.androidxccorektx implementation rootProject.ext.dependencies.androidxappcompat implementation rootProject.ext.dependencies.androidxconstraintlayout implementation rootProject.ext.dependencies.arouter diff --git a/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/MoGoWarningProvider.java b/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/MoGoWarningProvider.java index cfc25ed5fe..b25ddb3fd2 100644 --- a/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/MoGoWarningProvider.java +++ b/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/MoGoWarningProvider.java @@ -4,7 +4,6 @@ import android.content.Context; import android.os.Bundle; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import com.alibaba.android.arouter.facade.annotation.Route; @@ -24,10 +23,12 @@ public class MoGoWarningProvider implements IMoGoWaringProvider { private String TAG = "MoGoWarningProvider"; private MoGoWarningFragment mMoGoWarningFragment; + private Context mContext; @Override public void init(Context context) { Logger.d(TAG, "初始化蘑菇预警模块 ……"); + mContext = context; } @Override @@ -48,11 +49,6 @@ public class MoGoWarningProvider implements IMoGoWaringProvider { return ModuleType.TYPE_CARD_FRAGMENT; } - @Override - public void showWarningV2X(int v2xType, @Nullable String alertMessage) { - mMoGoWarningFragment.showWarningV2X(v2xType, alertMessage); - } - @Override public void showWarningTrafficLight(int checkLightId) { mMoGoWarningFragment.showWarningTrafficLight(checkLightId); @@ -72,4 +68,14 @@ public class MoGoWarningProvider implements IMoGoWaringProvider { public void disableLimitingVelocity() { mMoGoWarningFragment.disableLimitingVelocity(); } + + @Override + public void showWarningV2X(int v2xType, @NonNull String alertMessage, @NonNull String tag) { + mMoGoWarningFragment.showWarningV2X(v2xType, alertMessage, tag); + } + + @Override + public void disableWarningV2X(@NonNull String tag) { + + } } diff --git a/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/receiver/TestWarningBroadcastReceiver.kt b/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/receiver/TestWarningBroadcastReceiver.kt index 485870f185..5c958aafc8 100644 --- a/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/receiver/TestWarningBroadcastReceiver.kt +++ b/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/receiver/TestWarningBroadcastReceiver.kt @@ -1,91 +1,87 @@ -package com.mogo.module.warning.receiver; +package com.mogo.module.warning.receiver - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; - -import com.alibaba.android.arouter.launcher.ARouter; -import com.mogo.module.warning.WaringConst; -import com.mogo.module.warning.WarningTypeEnum; -import com.mogo.service.IMogoServiceApis; -import com.mogo.service.MogoServicePaths; -import com.mogo.service.warning.IMoGoWaringProvider; -import com.mogo.utils.logger.Logger; +import android.content.BroadcastReceiver +import android.content.Context +import android.content.Intent +import com.alibaba.android.arouter.launcher.ARouter +import com.mogo.module.warning.WaringConst +import com.mogo.module.warning.WarningTypeEnum +import com.mogo.service.IMogoServiceApis +import com.mogo.service.MogoServicePaths +import com.mogo.service.warning.IMoGoWaringProvider +import com.mogo.utils.logger.Logger +import kotlin.random.Random /** * V2X 测试面板广播接收,目的是可以通过广播调用起来面板 * * @author donghongyu */ -public class TestWarningBroadcastReceiver extends BroadcastReceiver { - private static final String TAG = "TestPanelBroadcastReceiver"; - - private Context mContext; - private static IMogoServiceApis mMogoServiceApis; - private static IMoGoWaringProvider mIMoGoWaringProvider; - - @Override - public void onReceive(Context context, Intent intent) { +class TestWarningBroadcastReceiver : BroadcastReceiver() { + private var mContext: Context? = null + override fun onReceive(context: Context, intent: Intent) { try { - mMogoServiceApis = (IMogoServiceApis) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(context); - mIMoGoWaringProvider = mMogoServiceApis.getWaringProviderApi(); - - this.mContext = context; - int warningType = intent.getIntExtra(WaringConst.BROADCAST_TEST_CONTROL_TYPE_EXTRA_KEY, 0); - Logger.d(TAG, "warningType:" + warningType); + mMogoServiceApis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS) + .navigation(context) as IMogoServiceApis + mIMoGoWaringProvider = mMogoServiceApis!!.waringProviderApi + mContext = context + val warningType = + intent.getIntExtra(WaringConst.BROADCAST_TEST_CONTROL_TYPE_EXTRA_KEY, 0) + Logger.d(TAG, "warningType:$warningType") // 分发场景 - dispatchWaring(warningType); - } catch (Exception e) { - e.printStackTrace(); + dispatchWaring(warningType) + } catch (e: Exception) { + e.printStackTrace() } } - /** * 分发处理场景 * * @param warningType 场景类型 */ - private void dispatchWaring(int warningType) { - - mIMoGoWaringProvider.showWarningV2X(warningType, "预警消息"); - - switch (warningType) { - case WarningTypeEnum.WARING_TYPE_PRIOR_COLLISION://前向碰撞 - break; - case WarningTypeEnum.WARING_TYPE_INTERSECTION_COLLISION://交叉路口碰撞 - break; - case WarningTypeEnum.WARING_TYPE_LEFT_AUXILIARY://左转辅助 - break; - case WarningTypeEnum.WARING_TYPE_BLIND_AREA_COLLISION://盲区/变道辅助 - break; - case WarningTypeEnum.WARING_TYPE_REVERSE_OVERTAKING://逆向超车 - break; - case WarningTypeEnum.WARING_TYPE_VEHICLE_BRAKES://紧急制动-前车急刹 - break; - case WarningTypeEnum.WARING_TYPE_ABNORMAL_VEHICLE://异常车辆提醒 - break; - case WarningTypeEnum.WARING_TYPE_VEHICLE_CONTROL://车辆失控预警 - break; - case WarningTypeEnum.WARING_TYPE_ROAD_HAZARDS://道路危险情况提示 - break; - case WarningTypeEnum.WARING_TYPE_SPEED_LIMIT://限速预警 - break; - case WarningTypeEnum.WARING_TYPE_RED_LIGHT://闯红灯预警 - break; - case WarningTypeEnum.WARING_TYPE_VULNERABLE_TRANSPORT_PARTICIPANT://弱势交通参与者 - break; - case WarningTypeEnum.WARING_TYPE_TRAFFIC_SPEED_GUIDE://绿波通行车速引导 - break; - case WarningTypeEnum.WARING_TYPE_CAR_PLATE://车内标牌 - break; - case WarningTypeEnum.WARING_TYPE_TRAFFIC_JAM_AHEAD://前方道路拥堵 - break; - case WarningTypeEnum.WARING_TYPE_SPECIAL_VEHICLE_ACCESS://紧急车辆提醒(特种车辆优先通行) - break; + private fun dispatchWaring(warningType: Int) { + mIMoGoWaringProvider!!.showWarningV2X(warningType, "预警消息", Random.nextDouble().toString()) + when (warningType) { + WarningTypeEnum.WARING_TYPE_PRIOR_COLLISION -> { + } + WarningTypeEnum.WARING_TYPE_INTERSECTION_COLLISION -> { + } + WarningTypeEnum.WARING_TYPE_LEFT_AUXILIARY -> { + } + WarningTypeEnum.WARING_TYPE_BLIND_AREA_COLLISION -> { + } + WarningTypeEnum.WARING_TYPE_REVERSE_OVERTAKING -> { + } + WarningTypeEnum.WARING_TYPE_VEHICLE_BRAKES -> { + } + WarningTypeEnum.WARING_TYPE_ABNORMAL_VEHICLE -> { + } + WarningTypeEnum.WARING_TYPE_VEHICLE_CONTROL -> { + } + WarningTypeEnum.WARING_TYPE_ROAD_HAZARDS -> { + } + WarningTypeEnum.WARING_TYPE_SPEED_LIMIT -> { + } + WarningTypeEnum.WARING_TYPE_RED_LIGHT -> { + } + WarningTypeEnum.WARING_TYPE_VULNERABLE_TRANSPORT_PARTICIPANT -> { + } + WarningTypeEnum.WARING_TYPE_TRAFFIC_SPEED_GUIDE -> { + } + WarningTypeEnum.WARING_TYPE_CAR_PLATE -> { + } + WarningTypeEnum.WARING_TYPE_TRAFFIC_JAM_AHEAD -> { + } + WarningTypeEnum.WARING_TYPE_SPECIAL_VEHICLE_ACCESS -> { + } } } -} + companion object { + private const val TAG = "TestPanelBroadcastReceiver" + private var mMogoServiceApis: IMogoServiceApis? = null + private var mIMoGoWaringProvider: IMoGoWaringProvider? = null + } +} \ No newline at end of file diff --git a/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/ui/MoGoWarningContract.kt b/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/ui/MoGoWarningContract.kt index 34f96814f4..1f322e1e45 100644 --- a/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/ui/MoGoWarningContract.kt +++ b/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/ui/MoGoWarningContract.kt @@ -14,18 +14,20 @@ interface MoGoWarningContract { * */ interface View : IView { + /** - * 展示VR下V2X预警弹窗 + * 展示VR下V2X预警 * * @param v2xType V2X类型 * @param alertMessage 提醒文本 */ - fun showWarningV2X(v2xType: Int, alertMessage: String?) + fun showWarningV2X(v2xType: Int, alertMessage: String, tag: String) /** - * 关闭VR下V2X预警弹窗 + * 关闭指定floatTag 的 VR下V2X预警弹窗 + * @param tag 弹窗标识 */ - fun disableWarningV2X() + fun disableWarningV2X(tag: String) /** * 展示红绿灯预警 diff --git a/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/ui/MoGoWarningFragment.kt b/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/ui/MoGoWarningFragment.kt index 48fa14fe68..62f06d175d 100644 --- a/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/ui/MoGoWarningFragment.kt +++ b/modules/mogo-module-warning/src/main/java/com/mogo/module/warning/ui/MoGoWarningFragment.kt @@ -22,11 +22,11 @@ class MoGoWarningFragment : MvpFragment(view) { - fun showWarningV2X(v2xType: Int, alertMessage: String?) { - mView?.showWarningV2X(v2xType, alertMessage) + fun showWarningV2X(v2xType: Int, alertMessage: String, tag: String) { + mView?.showWarningV2X(v2xType, alertMessage, tag) } - fun disableWarningV2X() { - mView?.disableWarningV2X() + fun disableWarningV2X(tag: String) { + mView?.disableWarningV2X(tag) } fun showWarningTrafficLight(checkLightId: Int) { diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/warning/IMoGoWaringProvider.kt b/services/mogo-service-api/src/main/java/com/mogo/service/warning/IMoGoWaringProvider.kt index 79813bee4b..f6fcb3ca9a 100644 --- a/services/mogo-service-api/src/main/java/com/mogo/service/warning/IMoGoWaringProvider.kt +++ b/services/mogo-service-api/src/main/java/com/mogo/service/warning/IMoGoWaringProvider.kt @@ -13,7 +13,13 @@ interface IMoGoWaringProvider : IMogoModuleProvider { * @param v2xType V2X类型 * @param alertMessage 提醒文本 */ - fun showWarningV2X(v2xType: Int, alertMessage: String?) + fun showWarningV2X(v2xType: Int, alertMessage: String, tag: String) + + /** + * 关闭指定floatTag 的 VR下V2X预警弹窗 + * @param tag 弹窗标识 + */ + fun disableWarningV2X(tag: String) /** * 展示红绿灯预警