diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 40c643105e..26f71788f7 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -73,6 +73,11 @@
+
+
+
+
+
diff --git a/app/build.gradle b/app/build.gradle
index 82b401e0a3..1476263a5a 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -87,6 +87,9 @@ android {
// 是否作为 launcher 运行
buildConfigField 'boolean', 'IS_LAUNCHER', 'false'
buildConfigField 'String', 'SOCKET_APP_ID', '\"com.mogo.launcher\"'
+ // 是否支持目的地导航策略
+ buildConfigField 'boolean', 'IS_SUPPORT_SCHEDULE_CALCULATE_NOT_HOME_COMPANY_DISTANCE_FOR_PUSH', 'true'
+
}
// launcher app
launcher {
@@ -96,13 +99,13 @@ android {
// 是否作为 launcher 运行
buildConfigField 'boolean', 'IS_LAUNCHER', 'true'
buildConfigField 'String', 'SOCKET_APP_ID', '\"com.mogo.launcher\"'
+ // 是否支持目的地导航策略
+ buildConfigField 'boolean', 'IS_SUPPORT_SCHEDULE_CALCULATE_NOT_HOME_COMPANY_DISTANCE_FOR_PUSH', 'false'
}
// f系列-分体机全系列,未细分
f8xx {
applicationId rootProject.ext.android.fLauncherApplicationId
dimension "product"
- // 使用思必驰语音
- buildConfigField 'int', 'AIType', '2'
buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'false'
// 车机类型,主要用于区分自研车机还是别人家的车机,自研车机类型为0
buildConfigField 'int', 'CAR_MACHINE_TYPE', '0'
@@ -110,17 +113,17 @@ android {
manifestPlaceholders = [AMAP_API_VALUE: rootProject.ext.android.fLauncherAmapApiValue]
// 是否使用高德sdk自定义导航
buildConfigField 'boolean', 'USE_CUSTOM_NAVI', 'false'
- // 是否加载引导模块
- buildConfigField 'boolean', 'LOAD_GUIDE_MODULE', 'false'
// 是否支持换肤
buildConfigField 'boolean', 'IS_SKIN_SUPPORTED', 'true'
+ // 是否支持查询导航目的地车友
+ buildConfigField 'boolean', 'IS_SUPPORTED_SEARCH_DESTINATION_ONLINE_CAR_LIST', 'true'
+ // 是否支持桌面卡片刷新
+ buildConfigField 'boolean', 'IS_SUPPORT_LAUNCHER_CARD_REFRESH_STRATEGY', 'false'
}
// f系列-分体机
f80x {
applicationId rootProject.ext.android.fLauncherApplicationId
dimension "product"
- // 使用思必驰语音
- buildConfigField 'int', 'AIType', '2'
buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'false'
// 车机类型,主要用于区分自研车机还是别人家的车机,自研车机类型为0
buildConfigField 'int', 'CAR_MACHINE_TYPE', '0'
@@ -128,17 +131,17 @@ android {
manifestPlaceholders = [AMAP_API_VALUE: rootProject.ext.android.fLauncherAmapApiValue]
// 是否使用高德sdk自定义导航
buildConfigField 'boolean', 'USE_CUSTOM_NAVI', 'false'
- // 是否加载引导模块
- buildConfigField 'boolean', 'LOAD_GUIDE_MODULE', 'false'
// 是否支持换肤
buildConfigField 'boolean', 'IS_SKIN_SUPPORTED', 'true'
+ // 是否支持查询导航目的地车友
+ buildConfigField 'boolean', 'IS_SUPPORTED_SEARCH_DESTINATION_ONLINE_CAR_LIST', 'true'
+ // 是否支持桌面卡片刷新
+ buildConfigField 'boolean', 'IS_SUPPORT_LAUNCHER_CARD_REFRESH_STRATEGY', 'false'
}
// e系列,采用Launcher方案
e8xx {
applicationId rootProject.ext.android.launcherApplicationId
dimension "product"
- // 使用思必驰语音
- buildConfigField 'int', 'AIType', '2'
buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'false'
// 车机类型,主要用于区分自研车机还是别人家的车机,自研车机类型为0
buildConfigField 'int', 'CAR_MACHINE_TYPE', '0'
@@ -146,17 +149,17 @@ android {
manifestPlaceholders = [AMAP_API_VALUE: rootProject.ext.android.commonLauncherAmapApiValue]
// 是否使用高德sdk自定义导航
buildConfigField 'boolean', 'USE_CUSTOM_NAVI', 'false'
- // 是否加载引导模块
- buildConfigField 'boolean', 'LOAD_GUIDE_MODULE', 'false'
// 是否支持换肤
buildConfigField 'boolean', 'IS_SKIN_SUPPORTED', 'true'
+ // 是否支持查询导航目的地车友
+ buildConfigField 'boolean', 'IS_SUPPORTED_SEARCH_DESTINATION_ONLINE_CAR_LIST', 'true'
+ // 是否支持桌面卡片刷新
+ buildConfigField 'boolean', 'IS_SUPPORT_LAUNCHER_CARD_REFRESH_STRATEGY', 'false'
}
// 同上
em4 {
applicationId rootProject.ext.android.launcherApplicationId
dimension "product"
- // 使用思必驰语音
- buildConfigField 'int', 'AIType', '2'
buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'false'
// 车机类型,主要用于区分自研车机还是别人家的车机,自研车机类型为0
buildConfigField 'int', 'CAR_MACHINE_TYPE', '0'
@@ -164,17 +167,17 @@ android {
manifestPlaceholders = [AMAP_API_VALUE: rootProject.ext.android.commonLauncherAmapApiValue]
// 是否使用高德sdk自定义导航
buildConfigField 'boolean', 'USE_CUSTOM_NAVI', 'false'
- // 是否加载引导模块
- buildConfigField 'boolean', 'LOAD_GUIDE_MODULE', 'false'
// 是否支持换肤
buildConfigField 'boolean', 'IS_SKIN_SUPPORTED', 'true'
+ // 是否支持查询导航目的地车友
+ buildConfigField 'boolean', 'IS_SUPPORTED_SEARCH_DESTINATION_ONLINE_CAR_LIST', 'true'
+ // 是否支持桌面卡片刷新
+ buildConfigField 'boolean', 'IS_SUPPORT_LAUNCHER_CARD_REFRESH_STRATEGY', 'false'
}
// e系列-2+32,对标D系列2+32,采用独立app的形式
em3 {
applicationId rootProject.ext.android.independentApplicationId
dimension "product"
- // 使用思必驰语音
- buildConfigField 'int', 'AIType', '2'
buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'false'
// 车机类型,主要用于区分自研车机还是别人家的车机,自研车机类型为0
buildConfigField 'int', 'CAR_MACHINE_TYPE', '0'
@@ -182,17 +185,17 @@ android {
manifestPlaceholders = [AMAP_API_VALUE: rootProject.ext.android.commonIndependentAmapApiValue]
// 是否使用高德sdk自定义导航
buildConfigField 'boolean', 'USE_CUSTOM_NAVI', 'false'
- // 是否加载引导模块
- buildConfigField 'boolean', 'LOAD_GUIDE_MODULE', 'false'
// 是否支持换肤
- buildConfigField 'boolean', 'IS_SKIN_SUPPORTED', 'false'
+ buildConfigField 'boolean', 'IS_SKIN_SUPPORTED', 'true'
+ // 是否支持查询导航目的地车友
+ buildConfigField 'boolean', 'IS_SUPPORTED_SEARCH_DESTINATION_ONLINE_CAR_LIST', 'true'
+ // 是否支持桌面卡片刷新
+ buildConfigField 'boolean', 'IS_SUPPORT_LAUNCHER_CARD_REFRESH_STRATEGY', 'true'
}
// e系列-1+16,对标D系列1+16,采用独立app形式
em1 {
applicationId rootProject.ext.android.independentApplicationId
dimension "product"
- // 使用思必驰语音
- buildConfigField 'int', 'AIType', '2'
buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'false'
// 车机类型,主要用于区分自研车机还是别人家的车机,自研车机类型为0
buildConfigField 'int', 'CAR_MACHINE_TYPE', '0'
@@ -200,17 +203,17 @@ android {
manifestPlaceholders = [AMAP_API_VALUE: rootProject.ext.android.commonIndependentAmapApiValue]
// 是否使用高德sdk自定义导航
buildConfigField 'boolean', 'USE_CUSTOM_NAVI', 'false'
- // 是否加载引导模块
- buildConfigField 'boolean', 'LOAD_GUIDE_MODULE', 'false'
// 是否支持换肤
- buildConfigField 'boolean', 'IS_SKIN_SUPPORTED', 'false'
+ buildConfigField 'boolean', 'IS_SKIN_SUPPORTED', 'true'
+ // 是否支持查询导航目的地车友
+ buildConfigField 'boolean', 'IS_SUPPORTED_SEARCH_DESTINATION_ONLINE_CAR_LIST', 'true'
+ // 是否支持桌面卡片刷新
+ buildConfigField 'boolean', 'IS_SUPPORT_LAUNCHER_CARD_REFRESH_STRATEGY', 'true'
}
// d系列
d8xx {
applicationId rootProject.ext.android.independentApplicationId
dimension "product"
- // 使用同行者语音
- buildConfigField 'int', 'AIType', '1'
buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'false'
// 车机类型,主要用于区分自研车机还是别人家的车机,自研车机类型为0
buildConfigField 'int', 'CAR_MACHINE_TYPE', '0'
@@ -218,17 +221,17 @@ android {
manifestPlaceholders = [AMAP_API_VALUE: rootProject.ext.android.commonIndependentAmapApiValue]
// 是否使用高德sdk自定义导航
buildConfigField 'boolean', 'USE_CUSTOM_NAVI', 'false'
- // 是否加载引导模块
- buildConfigField 'boolean', 'LOAD_GUIDE_MODULE', 'true'
// 是否支持换肤
- buildConfigField 'boolean', 'IS_SKIN_SUPPORTED', 'false'
+ buildConfigField 'boolean', 'IS_SKIN_SUPPORTED', 'true'
+ // 是否支持查询导航目的地车友
+ buildConfigField 'boolean', 'IS_SUPPORTED_SEARCH_DESTINATION_ONLINE_CAR_LIST', 'true'
+ // 是否支持桌面卡片刷新
+ buildConfigField 'boolean', 'IS_SUPPORT_LAUNCHER_CARD_REFRESH_STRATEGY', 'true'
}
// d系列 2 + 32
d80x {
applicationId rootProject.ext.android.independentApplicationId
dimension "product"
- // 使用同行者语音
- buildConfigField 'int', 'AIType', '1'
buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'false'
// 车机类型,主要用于区分自研车机还是别人家的车机,自研车机类型为0
buildConfigField 'int', 'CAR_MACHINE_TYPE', '0'
@@ -236,17 +239,17 @@ android {
manifestPlaceholders = [AMAP_API_VALUE: rootProject.ext.android.commonIndependentAmapApiValue]
// 是否使用高德sdk自定义导航
buildConfigField 'boolean', 'USE_CUSTOM_NAVI', 'false'
- // 是否加载引导模块
- buildConfigField 'boolean', 'LOAD_GUIDE_MODULE', 'true'
// 是否支持换肤
- buildConfigField 'boolean', 'IS_SKIN_SUPPORTED', 'false'
+ buildConfigField 'boolean', 'IS_SKIN_SUPPORTED', 'true'
+ // 是否支持查询导航目的地车友
+ buildConfigField 'boolean', 'IS_SUPPORTED_SEARCH_DESTINATION_ONLINE_CAR_LIST', 'true'
+ // 是否支持桌面卡片刷新
+ buildConfigField 'boolean', 'IS_SUPPORT_LAUNCHER_CARD_REFRESH_STRATEGY', 'true'
}
// d系列 1+16 版本
d82x {
applicationId rootProject.ext.android.independentApplicationId
dimension "product"
- // 使用同行者语音
- buildConfigField 'int', 'AIType', '1'
buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'false'
// 车机类型,主要用于区分自研车机还是别人家的车机,自研车机类型为0
buildConfigField 'int', 'CAR_MACHINE_TYPE', '0'
@@ -254,17 +257,17 @@ android {
manifestPlaceholders = [AMAP_API_VALUE: rootProject.ext.android.commonIndependentAmapApiValue]
// 是否使用高德sdk自定义导航
buildConfigField 'boolean', 'USE_CUSTOM_NAVI', 'false'
- // 是否加载引导模块
- buildConfigField 'boolean', 'LOAD_GUIDE_MODULE', 'true'
// 是否支持换肤
- buildConfigField 'boolean', 'IS_SKIN_SUPPORTED', 'false'
+ buildConfigField 'boolean', 'IS_SKIN_SUPPORTED', 'true'
+ // 是否支持查询导航目的地车友
+ buildConfigField 'boolean', 'IS_SUPPORTED_SEARCH_DESTINATION_ONLINE_CAR_LIST', 'true'
+ // 是否支持桌面卡片刷新
+ buildConfigField 'boolean', 'IS_SUPPORT_LAUNCHER_CARD_REFRESH_STRATEGY', 'true'
}
// 比亚迪
bydauto {
applicationId rootProject.ext.android.bydautoIndependentApplicationId
dimension "product"
- // 不使用语音
- buildConfigField 'int', 'AIType', '0'
buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'false'
// 车机类型,主要用于区分自研车机还是别人家的车机,其他车机,比亚迪定为1
buildConfigField 'int', 'CAR_MACHINE_TYPE', '1'
@@ -272,10 +275,12 @@ android {
manifestPlaceholders = [AMAP_API_VALUE: rootProject.ext.android.bydautoIndependentApiValue]
// 是否使用高德sdk自定义导航
buildConfigField 'boolean', 'USE_CUSTOM_NAVI', 'true'
- // 是否加载引导模块
- buildConfigField 'boolean', 'LOAD_GUIDE_MODULE', 'false'
// 是否支持换肤
buildConfigField 'boolean', 'IS_SKIN_SUPPORTED', 'false'
+ // 是否支持查询导航目的地车友
+ buildConfigField 'boolean', 'IS_SUPPORTED_SEARCH_DESTINATION_ONLINE_CAR_LIST', 'false'
+ // 是否支持桌面卡片刷新
+ buildConfigField 'boolean', 'IS_SUPPORT_LAUNCHER_CARD_REFRESH_STRATEGY', 'false'
}
// 演示地点-顺义
shunyi{
@@ -387,6 +392,7 @@ dependencies {
apply from: "./functions/skin.gradle"
apply from: "./functions/crashreport.gradle"
apply from: "./functions/widgets.gradle"
+ apply from: "./functions/tts.gradle"
}
android.applicationVariants.all { variant ->
diff --git a/app/functions/skin.gradle b/app/functions/skin.gradle
index 5945ee7e4c..e8660ab061 100644
--- a/app/functions/skin.gradle
+++ b/app/functions/skin.gradle
@@ -1,13 +1,12 @@
project.dependencies {
-
if (Boolean.valueOf(RELEASE)) {
bydautoImplementation rootProject.ext.dependencies.skinsupportnoop
- d8xxImplementation rootProject.ext.dependencies.skinsupportnoop
- d82xImplementation rootProject.ext.dependencies.skinsupportnoop
- em1Implementation rootProject.ext.dependencies.skinsupportnoop
- d80xImplementation rootProject.ext.dependencies.skinsupportnoop
- em3Implementation rootProject.ext.dependencies.skinsupportnoop
+ d82xImplementation rootProject.ext.dependencies.skinsupportimpl
+ em1Implementation rootProject.ext.dependencies.skinsupportimpl
+ em3Implementation rootProject.ext.dependencies.skinsupportimpl
+ d8xxImplementation rootProject.ext.dependencies.skinsupportimpl
+ d80xImplementation rootProject.ext.dependencies.skinsupportimpl
f8xxImplementation rootProject.ext.dependencies.skinsupportimpl
f80xImplementation rootProject.ext.dependencies.skinsupportimpl
em4Implementation rootProject.ext.dependencies.skinsupportimpl
@@ -17,19 +16,21 @@ project.dependencies {
f80xImplementation rootProject.ext.dependencies.skinsupportlight
em4Implementation rootProject.ext.dependencies.skinsupportlight
e8xxImplementation rootProject.ext.dependencies.skinsupportlight
-// d8xxImplementation rootProject.ext.dependencies.skinsupportlight
-// d82xImplementation rootProject.ext.dependencies.skinsupportlight
-// em1Implementation rootProject.ext.dependencies.skinsupportlight
-// d80xImplementation rootProject.ext.dependencies.skinsupportlight
-// em3Implementation rootProject.ext.dependencies.skinsupportlight
+ d8xxImplementation rootProject.ext.dependencies.skinsupportlight
+ d80xImplementation rootProject.ext.dependencies.skinsupportlight
+ em3Implementation rootProject.ext.dependencies.skinsupportlight
+ d82xImplementation rootProject.ext.dependencies.skinsupportlight
+ em1Implementation rootProject.ext.dependencies.skinsupportlight
} else {
- bydautoImplementation project(':skin:mogo-skin-support-noop')
- d8xxImplementation project(':skin:mogo-skin-support-noop')
- d82xImplementation project(':skin:mogo-skin-support-noop')
- em1Implementation project(':skin:mogo-skin-support-noop')
- d80xImplementation project(':skin:mogo-skin-support-noop')
- em3Implementation project(':skin:mogo-skin-support-noop')
+
+ bydautoImplementation project(':skin:mogo-skin-support-noop')
+
+ d82xImplementation project(':skin:mogo-skin-support-impl')
+ em1Implementation project(':skin:mogo-skin-support-impl')
+ em3Implementation project(':skin:mogo-skin-support-impl')
+ d8xxImplementation project(':skin:mogo-skin-support-impl')
+ d80xImplementation project(':skin:mogo-skin-support-impl')
f8xxImplementation project(':skin:mogo-skin-support-impl')
f80xImplementation project(':skin:mogo-skin-support-impl')
em4Implementation project(':skin:mogo-skin-support-impl')
@@ -39,10 +40,10 @@ project.dependencies {
f80xImplementation project(':skin:mogo-skin-light')
em4Implementation project(':skin:mogo-skin-light')
e8xxImplementation project(':skin:mogo-skin-light')
-// d8xxImplementation project(':skin:mogo-skin-light')
-// d82xImplementation project(':skin:mogo-skin-light')
-// em1Implementation project(':skin:mogo-skin-light')
-// d80xImplementation project(':skin:mogo-skin-light')
-// em3Implementation project(':skin:mogo-skin-light')
+ d8xxImplementation project(':skin:mogo-skin-light')
+ d80xImplementation project(':skin:mogo-skin-light')
+ d82xImplementation project(':skin:mogo-skin-light')
+ em1Implementation project(':skin:mogo-skin-light')
+ em3Implementation project(':skin:mogo-skin-light')
}
}
\ No newline at end of file
diff --git a/app/functions/tts.gradle b/app/functions/tts.gradle
new file mode 100644
index 0000000000..172da172b0
--- /dev/null
+++ b/app/functions/tts.gradle
@@ -0,0 +1,25 @@
+project.dependencies {
+ if (Boolean.valueOf(RELEASE)) {
+ bydautoImplementation rootProject.ext.dependencies.ttsdi
+ d82xImplementation rootProject.ext.dependencies.ttszhi
+ em1Implementation rootProject.ext.dependencies.ttszhi
+ em3Implementation rootProject.ext.dependencies.ttszhi
+ d8xxImplementation rootProject.ext.dependencies.ttszhi
+ d80xImplementation rootProject.ext.dependencies.ttszhi
+ f8xxImplementation rootProject.ext.dependencies.ttszhi
+ f80xImplementation rootProject.ext.dependencies.ttszhi
+ em4Implementation rootProject.ext.dependencies.ttszhi
+ e8xxImplementation rootProject.ext.dependencies.ttszhi
+ } else {
+ bydautoImplementation project(':tts:tts-di')
+ d82xImplementation project(':tts:tts-zhi')
+ em1Implementation project(':tts:tts-zhi')
+ em3Implementation project(':tts:tts-zhi')
+ d8xxImplementation project(':tts:tts-zhi')
+ d80xImplementation project(':tts:tts-zhi')
+ f8xxImplementation project(':tts:tts-zhi')
+ f80xImplementation project(':tts:tts-zhi')
+ em4Implementation project(':tts:tts-zhi')
+ e8xxImplementation project(':tts:tts-zhi')
+ }
+}
\ No newline at end of file
diff --git a/app/functions/widgets.gradle b/app/functions/widgets.gradle
index cc816fc4c2..7309852d9e 100644
--- a/app/functions/widgets.gradle
+++ b/app/functions/widgets.gradle
@@ -3,7 +3,9 @@
project.dependencies {
if (Boolean.valueOf(RELEASE)) {
independentImplementation rootProject.ext.dependencies.mogomodulewidgets
+ implementation rootProject.ext.dependencies.mogomodulewidgets
} else {
independentImplementation project(':modules:mogo-module-widgets')
+ implementation project(':modules:mogo-module-widgets')
}
}
\ No newline at end of file
diff --git a/app/regroup.gradle b/app/regroup.gradle
index 84cd73d13d..6302bed17f 100644
--- a/app/regroup.gradle
+++ b/app/regroup.gradle
@@ -2,8 +2,8 @@
afterEvaluate {
- def independent = ["em3", "em1", "d80x", "d82x", "bydauto"]
- def launcher = ["f80x", "em4", "e8xx"]
+ def independent = []
+ def launcher = ["f80x"]
it.getTasks().iterator().forEachRemaining {
def task = it
diff --git a/app/src/em4/AndroidManifest.xml b/app/src/em4/AndroidManifest.xml
index 39c9d3833d..d755054676 100644
--- a/app/src/em4/AndroidManifest.xml
+++ b/app/src/em4/AndroidManifest.xml
@@ -3,5 +3,4 @@
xmlns:tools="http://schemas.android.com/tools"
android:sharedUserId="android.uid.system"
package="com.mogo.launcher">
-
\ No newline at end of file
diff --git a/app/src/main/java/com/mogo/launcher/MogoApplication.java b/app/src/main/java/com/mogo/launcher/MogoApplication.java
index 666b29922e..04f44e9a90 100644
--- a/app/src/main/java/com/mogo/launcher/MogoApplication.java
+++ b/app/src/main/java/com/mogo/launcher/MogoApplication.java
@@ -14,6 +14,7 @@ import com.mogo.commons.network.Utils;
import com.mogo.module.authorize.authprovider.invoke.AuthorizeConstant;
import com.mogo.module.back.BackToLauncherConst;
import com.mogo.module.carchatting.card.CallChatConstant;
+import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.MogoModule;
import com.mogo.module.common.MogoModulePaths;
import com.mogo.module.main.service.MogoMainService;
@@ -30,7 +31,6 @@ import com.mogo.test.crashreport.ITestCrashReportProvider;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.logger.LogLevel;
import com.mogo.utils.logger.Logger;
-import com.mogo.utils.storage.SharedPrefsMgr;
import com.squareup.leakcanary.LeakCanary;
import com.zhidao.boot.persistent.lib.PersistentManager;
import com.zhidao.mogo.module.left.panel.LeftPanelConst;
@@ -64,19 +64,15 @@ public class MogoApplication extends AbsMogoApplication {
crashSystem.setDebug( BuildConfig.DEBUG );
Logger.init( BuildConfig.DEBUG ? LogLevel.DEBUG : LogLevel.OFF );
- if ( DebugConfig.isLoadGuideModule() ) {
- MogoModulePaths.addModule( new MogoModule( PATH_GUIDE_FRAGMENT, PATH_GUIDE_MODULE_NAME ) );
- }else{
- SharedPrefsMgr.getInstance(this).putBoolean(DebugConfig.getSpGuide(),true);
- }
+ MogoModulePaths.addModule( new MogoModule( PATH_GUIDE_FRAGMENT, PATH_GUIDE_MODULE_NAME ) );
MogoModulePaths.addModule( new MogoModule( MogoServicePaths.PATH_AGREEMENT, AuthorizeConstant.PATH_AGREEMENT_MODULE_NAME ) );
if ( DebugConfig.isLauncher() ) {
MogoModulePaths.addModule( new MogoModule( BackToLauncherConst.MODULE_PATH, BackToLauncherConst.MODULE_NAME ) );
MogoModulePaths.addModule( new MogoModule( MediaConstants.TAG, MediaConstants.MODULE_TYPE ) );
} else {
- MogoModulePaths.addBaseModule( new MogoModule( MogoServicePaths.PATH_WIDGETS, MogoServicePaths.PATH_WIDGETS ) );
}
+ MogoModulePaths.addBaseModule( new MogoModule( MogoServicePaths.PATH_WIDGETS, MogoServicePaths.PATH_WIDGETS ) );
if ( DebugConfig.getCarMachineType() != DebugConfig.CAR_MACHINE_TYPE_BYD ) {
MogoModulePaths.addModule( new MogoModule( CallChatConstant.PROVIDER, CallChatConstant.MODULE_NAME ) );
}
@@ -91,7 +87,6 @@ public class MogoApplication extends AbsMogoApplication {
MogoModulePaths.addBaseModule( new MogoModule( V2XConst.PATH_V2X_UI, V2XConst.MODULE_NAME ) );
MogoModulePaths.addBaseModule( new MogoModule( MogoServicePaths.PATH_STRATEGY_SHARE, "StrategyShare" ) );
MogoModulePaths.addBaseModule( new MogoModule( MogoServicePaths.PATH_MOGO_MONITOR, "MogoMonitor" ) );
- MogoModulePaths.addModule( new MogoModule( V2XConst.PATH_EVENT_PANEL, V2XConst.MODULE_NAME_EVENT_PANEL ) );
MogoModulePaths.addModule( new MogoModule( PushUIConstants.PATH, PushUIConstants.NAME ) );
// 碰撞报警模块
MogoModulePaths.addModule(new MogoModule(MogoServicePaths.PATH_CRASH_WARNING,
@@ -123,7 +118,6 @@ public class MogoApplication extends AbsMogoApplication {
}
DebugConfig.setNetMode( BuildConfig.NET_ENV );
DebugConfig.setDebug( BuildConfig.DEBUG );
- DebugConfig.setAIType( BuildConfig.AIType );
DebugConfig.setLaunchLocationService( BuildConfig.LAUNCH_LOCATION_SERVICE );
DebugConfig.setUseCustomNavi( BuildConfig.USE_CUSTOM_NAVI );
DebugConfig.setLauncher( BuildConfig.IS_LAUNCHER );
@@ -134,8 +128,10 @@ public class MogoApplication extends AbsMogoApplication {
DebugConfig.setProductFlavor( BuildConfig.FLAVOR_product );
DebugConfig.setSocketAppId( BuildConfig.SOCKET_APP_ID );
DebugConfig.setRoadEventAnimated( BuildConfig.ROAD_EVENT_ANIMATED );
- DebugConfig.setLoadGuideModule( BuildConfig.LOAD_GUIDE_MODULE );
DebugConfig.setSkinSupported( BuildConfig.IS_SKIN_SUPPORTED );
+ DebugConfig.setSupportedSearchDestinationOnlineCarList( BuildConfig.IS_SUPPORTED_SEARCH_DESTINATION_ONLINE_CAR_LIST );
+ DebugConfig.setScheduleCalculateNotHomeCompanyDistanceForPush( BuildConfig.IS_SUPPORT_SCHEDULE_CALCULATE_NOT_HOME_COMPANY_DISTANCE_FOR_PUSH );
+ DebugConfig.setSupportLauncherCardRefreshStrategy( BuildConfig.IS_SUPPORT_LAUNCHER_CARD_REFRESH_STRATEGY );
DebugConfig.setObuType(BuildConfig.OBU_TYPE);
}
@@ -147,7 +143,7 @@ public class MogoApplication extends AbsMogoApplication {
@Override
protected void init() {
super.init();
- final IMogoServiceApis apis = ARouter.getInstance().navigation( IMogoServiceApis.class );
+ final IMogoServiceApis apis = MogoApisHandler.getInstance().getApis();
prepareBaseService( apis, 2_000L );
// installSkinManager( this, apis );
}
diff --git a/config.gradle b/config.gradle
index 8dc9955bcb..91286b3b50 100644
--- a/config.gradle
+++ b/config.gradle
@@ -19,196 +19,199 @@ targetSdkVersion : 22,
]
dependencies = [
// androidx
- androidxappcompat : "androidx.appcompat:appcompat:1.1.0",
- androidxccorektx : "androidx.core:core-ktx:1.3.0",
- androidxconstraintlayout : "androidx.constraintlayout:constraintlayout:1.1.3",
- boostmultidex : "com.bytedance.boost_multidex:boost_multidex:1.0.1",
- androidxviewpager2 : "androidx.viewpager2:viewpager2:1.0.0",
- androidxrecyclerview : "androidx.recyclerview:recyclerview:1.1.0",
- androidxcardview : "androidx.cardview:cardview:1.0.0",
- localbroadcastmanager : "androidx.localbroadcastmanager:localbroadcastmanager:1.0.0",
+ androidxappcompat : "androidx.appcompat:appcompat:1.1.0",
+ androidxccorektx : "androidx.core:core-ktx:1.3.0",
+ androidxconstraintlayout : "androidx.constraintlayout:constraintlayout:1.1.3",
+ boostmultidex : "com.bytedance.boost_multidex:boost_multidex:1.0.1",
+ androidxviewpager2 : "androidx.viewpager2:viewpager2:1.0.0",
+ androidxrecyclerview : "androidx.recyclerview:recyclerview:1.1.0",
+ androidxcardview : "androidx.cardview:cardview:1.0.0",
+ localbroadcastmanager : "androidx.localbroadcastmanager:localbroadcastmanager:1.0.0",
// flexbox
- flexbox : 'com.google.android:flexbox:2.0.1',
+ flexbox : 'com.google.android:flexbox:2.0.1',
// 测试
- junit : "junit:junit:4.12",
- androidxjunit : "androidx.test.ext:junit:1.1.0",
- androidxespressocore : "androidx.test.espresso:espresso-core:3.1.1",
+ junit : "junit:junit:4.12",
+ androidxjunit : "androidx.test.ext:junit:1.1.0",
+ androidxespressocore : "androidx.test.espresso:espresso-core:3.1.1",
// 地图
- amapnavi3dmap : "com.amap.api:navi-3dmap:7.2.0_3dmap7.2.0",
- amapsearch : "com.amap.api:search:7.1.0",
- amaplocation : "com.amap.api:location:4.9.0",
+ amapnavi3dmap : "com.amap.api:navi-3dmap:7.2.0_3dmap7.2.0",
+ amapsearch : "com.amap.api:search:7.1.0",
+ amaplocation : "com.amap.api:location:4.9.0",
// json 转换
- gson : "com.google.code.gson:gson:2.8.4",
+ gson : "com.google.code.gson:gson:2.8.4",
// 内存泄漏检测
- debugleakcanary : "com.squareup.leakcanary:leakcanary-android:1.6.1",
- releaseleakcanary : "com.squareup.leakcanary:leakcanary-android-no-op:1.6.1",
- testleakcanary : "com.squareup.leakcanary:leakcanary-android-no-op:1.6.1",
+ debugleakcanary : "com.squareup.leakcanary:leakcanary-android:1.6.1",
+ releaseleakcanary : "com.squareup.leakcanary:leakcanary-android-no-op:1.6.1",
+ testleakcanary : "com.squareup.leakcanary:leakcanary-android-no-op:1.6.1",
//rxJava
- rxjava : "io.reactivex.rxjava2:rxjava:2.2.2",
- rxandroid : "io.reactivex.rxjava2:rxandroid:2.1.0",
+ rxjava : "io.reactivex.rxjava2:rxjava:2.2.2",
+ rxandroid : "io.reactivex.rxjava2:rxandroid:2.1.0",
// arouter
- arouter : "com.alibaba:arouter-api:1.5.0",
- aroutercompiler : "com.alibaba:arouter-compiler:1.2.2",
+ arouter : "com.alibaba:arouter-api:1.5.0",
+ aroutercompiler : "com.alibaba:arouter-compiler:1.2.2",
// glide
- glide : 'com.github.bumptech.glide:glide:4.8.0',
- glideokhttp3 : 'com.github.bumptech.glide:okhttp3-integration:4.8.0',
- glideanno : 'com.github.bumptech.glide:annotations:4.8.0',
- glidecompiler : 'com.github.bumptech.glide:compiler:4.8.0',
- supportannos : "com.android.support:support-annotations:28.0.0",
+ glide : 'com.github.bumptech.glide:glide:4.8.0',
+ glideokhttp3 : 'com.github.bumptech.glide:okhttp3-integration:4.8.0',
+ glideanno : 'com.github.bumptech.glide:annotations:4.8.0',
+ glidecompiler : 'com.github.bumptech.glide:compiler:4.8.0',
+ supportannos : "com.android.support:support-annotations:28.0.0",
// fresco
- fresco : 'com.facebook.fresco:fresco:1.1.0',
+ fresco : 'com.facebook.fresco:fresco:1.1.0',
// 公司服务 - 语音
- aiassist : "com.zhidaoauto.common:service:1.0.4.10",
+ aiassist : "com.zhidaoauto.common:service:1.0.8.4",
// 语音替换方案 暂时只用TTS 解决焦点问题
- aiassistReplace : "com.zhidao.mogoVoicesdk:voice:1.0.5",
+ aiassistReplace : "com.zhidao.mogoVoicesdk:voice:1.0.5",
// 公司服务 - 埋点
- analytics : "com.elegant.analytics:analytics:1.1.19",
+ analytics : "com.elegant.analytics:analytics:1.1.19",
- retrofit : "com.squareup.retrofit2:retrofit:2.6.0",
- retrofitadapter : "com.squareup.retrofit2:adapter-rxjava2:2.6.0",
- retrofitconvertergson : "com.squareup.retrofit2:converter-gson:2.6.0",
- retrofitconverterscalars : "com.squareup.retrofit2:converter-scalars:2.1.0",
+ retrofit : "com.squareup.retrofit2:retrofit:2.6.0",
+ retrofitadapter : "com.squareup.retrofit2:adapter-rxjava2:2.6.0",
+ retrofitconvertergson : "com.squareup.retrofit2:converter-gson:2.6.0",
+ retrofitconverterscalars : "com.squareup.retrofit2:converter-scalars:2.1.0",
// leakcanary
- leakcanary : 'com.squareup.leakcanary:leakcanary-android:1.5.4',
- leakcanarynoop : 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4',
+ leakcanary : 'com.squareup.leakcanary:leakcanary-android:1.5.4',
+ leakcanarynoop : 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4',
// add for room
- room : "android.arch.persistence.room:runtime:1.1.1",
- roomAnnotationProcessor : 'android.arch.persistence.room:compiler:1.1.1',
+ room : "android.arch.persistence.room:runtime:1.1.1",
+ roomAnnotationProcessor : 'android.arch.persistence.room:compiler:1.1.1',
// rxjava2 with room
- roomRxjava : "android.arch.persistence.room:rxjava2:1.1.1",
+ roomRxjava : "android.arch.persistence.room:rxjava2:1.1.1",
// material
- material : 'com.google.android.material:material:1.1.0',
+ material : 'com.google.android.material:material:1.1.0',
- indicator : 'com.github.zhpanvip:viewpagerindicator:1.0.4',
+ indicator : 'com.github.zhpanvip:viewpagerindicator:1.0.4',
// modules
- moduletanlu : "com.mogo.module:module-tanlu:${MOGO_MODULE_TANLU_VERSION}",
- moduletanluapi : "com.mogo.module:module-tanlu-api:${MOGO_TANLU_API_VERSION}",
- moduleshare : "com.mogo.module:module-share:${MOGO_MODULE_SHARE_VERSION}",
- mogocommons : "com.mogo.commons:mogo-commons:${MOGO_COMMONS_VERSION}",
- mogoutils : "com.mogo.commons:mogo-utils:${MOGO_UTILS_VERSION}",
- mapamap : "com.mogo.map:map-amap:${MAP_AMAP_VERSION}",
- mapautomap : "com.mogo.map:map-autonavi:${MAP_AUTONAVI_VERSION}",
- mogomap : "com.mogo.map:mogo-map:${MOGO_MAP_VERSION}",
- mogomapapi : "com.mogo.map:mogo-map-api:${MOGO_MAP_API_VERSION}",
- modulecommon : "com.mogo.module:module-common:${MOGO_MODULE_COMMON_VERSION}",
- modulemain : "com.mogo.module:module-main:${MOGO_MODULE_MAIN_VERSION}",
- modulemainlauncher : "com.mogo.module:module-main-launcher:${MOGO_MODULE_MAIN_LAUNCHER_VERSION}",
- modulemainindependent : "com.mogo.module:module-main-independent:${MOGO_MODULE_MAIN_INDEPENDENT_VERSION}",
- modulemap : "com.mogo.module:module-map:${MOGO_MODULE_MAP_VERSION}",
- moduleservice : "com.mogo.module:module-service:${MOGO_MODULE_SERVICE_VERSION}",
- mogoservice : "com.mogo.service:mogo-service:${MOGO_SERVICE_VERSION}",
- mogoserviceapi : "com.mogo.service:mogo-service-api:${MOGO_SERVICE_API_VERSION}",
- moduleapps : "com.mogo.module:module-apps:${MOGO_MODULE_APPS_VERSION}",
- mogoconnection : "com.mogo.connection:mogo-connection:${MOGO_CONNECTION_VERSION}",
- moduleextensions : "com.mogo.module:module-extensions:${MOGO_MODULE_EXTENSIONS_VERSION}",
- carcall : "com.mogo.module.carchatting:module-carchatting:${CARCHATTING_VERSION}",
- carcallprovider : "com.mogo.module.carchatting:module-carchatting-provider:${CARCHATTINGPROVIDER_VERSION}",
- guideshow : "com.mogo.module.guideshow:module-guideshow:${MOGO_MODULE_GUIDESHOW_VERSION}",
-// guideshowprovider : "com.mogo.module.guideshow:module-guideshow-provider:${MOGO_MODULE_GUIDESHOW_PROVIDER_VERSION}",
- // 在线车辆
- moduleonlinecar : "com.mogo.module:module-onlinecar:${MOGO_MODULE_ONLINECAR_VERSION}",
+ moduletanlu : "com.mogo.module:module-tanlu:${MOGO_MODULE_TANLU_VERSION}",
+ moduletanluapi : "com.mogo.module:module-tanlu-api:${MOGO_TANLU_API_VERSION}",
+ moduleshare : "com.mogo.module:module-share:${MOGO_MODULE_SHARE_VERSION}",
+ mogocommons : "com.mogo.commons:mogo-commons:${MOGO_COMMONS_VERSION}",
+ mogoutils : "com.mogo.commons:mogo-utils:${MOGO_UTILS_VERSION}",
+ mapamap : "com.mogo.map:map-amap:${MAP_AMAP_VERSION}",
+ mapautomap : "com.mogo.map:map-autonavi:${MAP_AUTONAVI_VERSION}",
+ mogomap : "com.mogo.map:mogo-map:${MOGO_MAP_VERSION}",
+ mogomapapi : "com.mogo.map:mogo-map-api:${MOGO_MAP_API_VERSION}",
+ modulecommon : "com.mogo.module:module-common:${MOGO_MODULE_COMMON_VERSION}",
+ modulemain : "com.mogo.module:module-main:${MOGO_MODULE_MAIN_VERSION}",
+ modulemainlauncher : "com.mogo.module:module-main-launcher:${MOGO_MODULE_MAIN_LAUNCHER_VERSION}",
+ modulemainindependent : "com.mogo.module:module-main-independent:${MOGO_MODULE_MAIN_INDEPENDENT_VERSION}",
+ modulemap : "com.mogo.module:module-map:${MOGO_MODULE_MAP_VERSION}",
+ moduleservice : "com.mogo.module:module-service:${MOGO_MODULE_SERVICE_VERSION}",
+ mogoservice : "com.mogo.service:mogo-service:${MOGO_SERVICE_VERSION}",
+ mogoserviceapi : "com.mogo.service:mogo-service-api:${MOGO_SERVICE_API_VERSION}",
+ moduleapps : "com.mogo.module:module-apps:${MOGO_MODULE_APPS_VERSION}",
+ mogoconnection : "com.mogo.connection:mogo-connection:${MOGO_CONNECTION_VERSION}",
+ moduleextensions : "com.mogo.module:module-extensions:${MOGO_MODULE_EXTENSIONS_VERSION}",
+ carcall : "com.mogo.module.carchatting:module-carchatting:${CARCHATTING_VERSION}",
+ carcallprovider : "com.mogo.module.carchatting:module-carchatting-provider:${CARCHATTINGPROVIDER_VERSION}",
+ guideshow : "com.mogo.module:module-guide:${MOGO_MODULE_GUIDESHOW_VERSION}",
// V2X
- moduleV2x : "com.mogo.module:module-v2x:${MOGO_MODULE_V2X_VERSION}",
- modulemedia : "com.mogo.module:module-media:${MOGO_MODULE_MEDIA_VERSION}",
- modulesearch : "com.mogo.module:module-search:${MOGO_MODULE_SEARCH_VERSION}",
+ moduleV2x : "com.mogo.module:module-v2x:${MOGO_MODULE_V2X_VERSION}",
+ modulemedia : "com.mogo.module:module-media:${MOGO_MODULE_MEDIA_VERSION}",
+ modulesearch : "com.mogo.module:module-search:${MOGO_MODULE_SEARCH_VERSION}",
// push
- modulepush : "com.mogo.module:module-push:${MOGO_MODULE_PUSH_VERSION}",
- modulepushbase : "com.mogo.module:module-push-base:${MOGO_MODULE_PUSH_BASE_VERSION}",
- modulepushnoop : "com.mogo.module:module-push-noop:${MOGO_MODULE_PUSH_NOOP_VERSION}",
- //运营位卡片
- moduleadcard : "com.mogo.module:module-adcard:${MOGO_MODULE_AD_CARD_VERSION}",
+ modulepush : "com.mogo.module:module-push:${MOGO_MODULE_PUSH_VERSION}",
+ modulepushbase : "com.mogo.module:module-push-base:${MOGO_MODULE_PUSH_BASE_VERSION}",
+ modulepushnoop : "com.mogo.module:module-push-noop:${MOGO_MODULE_PUSH_NOOP_VERSION}",
//统一返回键
- mogomoduleback : "com.mogo.module:module-back:${MOGO_MODULE_BACK_VERSION}",
- mogomoduleauth : "com.mogo.module:module-authorize:${MOGO_MODULE_AUTHORIZE_VERSION}",
- mogomoduleguide : "com.mogo.module:module-guide:${MOGO_MODULE_GUIDE_VERSION}",
+ mogomoduleback : "com.mogo.module:module-back:${MOGO_MODULE_BACK_VERSION}",
+ mogomoduleauth : "com.mogo.module:module-authorize:${MOGO_MODULE_AUTHORIZE_VERSION}",
+ mogomoduleguide : "com.mogo.module:module-guide:${MOGO_MODULE_GUIDE_VERSION}",
// 长链
- socketsdk : 'com.zhidao.socketsdk:socketsdk:2.1.4',
- socketsdkconnsvrprotoco : 'com.zhidao.ptech:connsvr-protoco:0.1.23',
- socketsdkprotobufjava : 'com.google.protobuf:protobuf-java:3.5.1',
+ socketsdk : 'com.zhidao.socketsdk:socketsdk:2.1.4',
+ socketsdkconnsvrprotoco : 'com.zhidao.ptech:connsvr-protoco:0.1.23',
+ socketsdkprotobufjava : 'com.google.protobuf:protobuf-java:3.5.1',
// OBU
- moduleobu : "com.mogo.module:module-obu:${MOGO_MODULE_OBU_VERSION}",
+ moduleobu : "com.mogo.module:module-obu:${MOGO_MODULE_OBU_VERSION}",
//
- jetbrainsannotationsjava5: "org.jetbrains:annotations-java5:15.0",
+ jetbrainsannotationsjava5 : "org.jetbrains:annotations-java5:15.0",
// 统一登录
- accountsdk : "com.zhidao.accountservice:account-sdk:1.0.11",
+ accountsdk : "com.zhidao.accountservice:account-sdk:1.0.14",
// crash
- crashSdk : "com.zhidaoauto.crash.log:library:1.0.5",
- kotlinstdlibjdk7 : "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${kotlin_version}",
+ crashSdk : "com.zhidaoauto.crash.log:library:1.0.5",
+ kotlinstdlibjdk7 : "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${kotlin_version}",
//探路
- videoarmv7 : "com.shuyu:gsyVideoPlayer-armv7a:7.1.2",
- videoarm64 : "com.shuyu:gsyVideoPlayer-arm64:7.1.2",
- videojava : "com.shuyu:gsyVideoPlayer-java:7.1.2",
- eventbus : "org.greenrobot:eventbus:3.1.1",
- videoprocessor : "com.zhidao.video:video-processor:1.0.2.1",
+ videoarmv7 : "com.shuyu:gsyVideoPlayer-armv7a:7.1.2",
+ videoarm64 : "com.shuyu:gsyVideoPlayer-arm64:7.1.2",
+ videojava : "com.shuyu:gsyVideoPlayer-java:7.1.2",
+ eventbus : "org.greenrobot:eventbus:3.1.1",
+ videoprocessor : "com.zhidao.video:video-processor:1.0.2.1",
- coroutinescore : "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1",
- coroutinesandroid : "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1",
+ coroutinescore : "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1",
+ coroutinesandroid : "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1",
- aspectj : "org.aspectj:aspectjrt:1.8.9",
+ aspectj : "org.aspectj:aspectjrt:1.8.9",
// gps 模拟
- gpssimulator : "com.mogo.module:module-gps-simulator:${MOGO_MODULE_GPS_SIMULATOR_VERSION}",
- gpssimulatordebug : "com.mogo.module:module-gps-simulator-debug:${MOGO_MODULE_GPS_SIMULATOR_DEBUG_VERSION}",
- gpssimulatornoop : "com.mogo.module:module-gps-simulator-noop:${MOGO_MODULE_GPS_SIMULATOR_NOOP_VERSION}",
+ gpssimulator : "com.mogo.module:module-gps-simulator:${MOGO_MODULE_GPS_SIMULATOR_VERSION}",
+ gpssimulatordebug : "com.mogo.module:module-gps-simulator-debug:${MOGO_MODULE_GPS_SIMULATOR_DEBUG_VERSION}",
+ gpssimulatornoop : "com.mogo.module:module-gps-simulator-noop:${MOGO_MODULE_GPS_SIMULATOR_NOOP_VERSION}",
- adasapi : "com.zhidao.autopilot.support:adas:1.0.1",
- adasconfigapi : "com.zhidao.adasconfig:adasconfig:1.1.5",
+ adasapi : "com.zhidao.autopilot.support:adas:1.0.3",
+ adasconfigapi : "com.zhidao.adasconfig:adasconfig:1.1.5",
// 个人中心的SDK
- personalsdk : "com.zhidaoauto.person.info:data:1.0.1",
- tanluupload : "com.mogo.module:module-tanlu-upload:${TANLULIB_VERSION}",
+ personalsdk : "com.zhidaoauto.person.info:data:1.0.1",
+ tanluupload : "com.mogo.module:module-tanlu-upload:${TANLULIB_VERSION}",
// obu sdk
obusdk : "com.zhidao.enterprise.smartv2x:smartv2x:1.0.0.3",
- //事件面板
- moduleventpanel : "com.mogo.module:module-event-panel:${MOGO_MODULE_EVENT_PANEL_VERSION}",
- // 事件面板空实现
- moduleventpanelnoop : "com.mogo.module:module-event-panel-noop:${MOGO_MODULE_EVENT_PANEL_VERSION}",
// 左侧面板
- moduleleftpanel : "com.mogo.module:module-left-panel:${MOGO_MODULE_LEFT_PANEL_VERSION}",
+ moduleleftpanel : "com.mogo.module:module-left-panel:${MOGO_MODULE_LEFT_PANEL_VERSION}",
// 左侧面板空实现
- moduleleftpanelnoop : "com.mogo.module:module-left-panel-noop:${MOGO_MODULE_LEFT_PANEL_VERSION}",
+ moduleleftpanelnoop : "com.mogo.module:module-left-panel-noop:${MOGO_MODULE_LEFT_PANEL_VERSION}",
// 闪屏页
- modulesplash : "com.mogo.module:module-splash:${MOGO_MODULE_SPLASH_VERSION}",
+ modulesplash : "com.mogo.module:module-splash:${MOGO_MODULE_SPLASH_VERSION}",
// 基础服务实现
- mogobaseservicesdk : "com.mogo.base:services-sdk:${MOGO_BASE_SERVICES_SDK_VERSION}",
- mogobaseserviceapk : "com.mogo.base:services-apk:${MOGO_BASE_SERVICES_APK_VERSION}",
+ mogobaseservicesdk : "com.mogo.base:services-sdk:${MOGO_BASE_SERVICES_SDK_VERSION}",
+ mogobaseserviceapk : "com.mogo.base:services-apk:${MOGO_BASE_SERVICES_APK_VERSION}",
// loglib
- mogologlib : "com.mogo.module:module-loglib:${LOGLIB_VERSION}",
+ mogologlib : "com.mogo.module:module-loglib:${LOGLIB_VERSION}",
// monitor
- mogomonitor : "com.mogo.module:module-monitor:${MOGO_MODULE_MONITOR_VERSION}",
+ mogomonitor : "com.mogo.module:module-monitor:${MOGO_MODULE_MONITOR_VERSION}",
// google
- googlezxing : "com.google.zxing:core:3.3.3",
- litezxing : "com.google.zxing:litezxing:1.0.29.8",
+ googlezxing : "com.google.zxing:core:3.3.3",
+ litezxing : "com.google.zxing:litezxing:1.0.29.8",
// android - room
- androidxroomruntime : "androidx.room:room-runtime:2.2.3",
- androidxroomcompiler : "androidx.room:room-compiler:2.2.3",
- androidxroomktx : "androidx.room:room-ktx:2.2.3",
+ androidxroomruntime : "androidx.room:room-runtime:2.2.3",
+ androidxroomcompiler : "androidx.room:room-compiler:2.2.3",
+ androidxroomktx : "androidx.room:room-ktx:2.2.3",
//
- mogomodulewidgets : "com.mogo.module:module-widgets:${MOGO_MODULE_WIDGETS_VERSION}",
+ mogomodulewidgets : "com.mogo.module:module-widgets:${MOGO_MODULE_WIDGETS_VERSION}",
- kotlingradleplugin : "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}",
+ kotlingradleplugin : "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}",
- skinsupport : "com.mogo.skin:skin-support:${MOGO_SKIN_SUPPORT_VERSION}",
- skinsupportimpl : "com.mogo.skin:skin-support-impl:${MOGO_SKIN_SUPPORT_IMPL_VERSION}",
- skinsupportnoop : "com.mogo.skin:skin-support-noop:${MOGO_SKIN_SUPPORT_NOOP_VERSION}",
- skinsupportlight : "com.mogo.skin:skin-light:${MOGO_SKIN_LIGHT_VERSION}",
+ skinsupport : "com.mogo.skin:skin-support:${MOGO_SKIN_SUPPORT_VERSION}",
+ skinsupportimpl : "com.mogo.skin:skin-support-impl:${MOGO_SKIN_SUPPORT_IMPL_VERSION}",
+ skinsupportnoop : "com.mogo.skin:skin-support-noop:${MOGO_SKIN_SUPPORT_NOOP_VERSION}",
+ skinsupportlight : "com.mogo.skin:skin-light:${MOGO_SKIN_LIGHT_VERSION}",
- crashreport : "com.mogo.test:crashreport:${CRASHREPORT_VERSION}",
- crashreportbugly : "com.mogo.test:crashreport-bugly:${CRASHREPORT_BUGLY_VERSION}",
- crashreportnoop : "com.mogo.test:crashreport-noop:${CRASHREPORT_NOOP_VERSION}",
+ crashreport : "com.mogo.test:crashreport:${CRASHREPORT_VERSION}",
+ crashreportbugly : "com.mogo.test:crashreport-bugly:${CRASHREPORT_BUGLY_VERSION}",
+ crashreportnoop : "com.mogo.test:crashreport-noop:${CRASHREPORT_NOOP_VERSION}",
+
+
+ skinsupportbase : "com.mogo.skin:skin-support-base:${SKIN_SUPPORT_VERSION}",
+ skinsupportappcompat : "com.mogo.skin:skin-support-appcompat:${SKIN_SUPPORT_APPCOMPAT_VERSION}",
+ skinsupportcardview : "com.mogo.skin:skin-support-cardview:${SKIN_SUPPORT_CARDVIEW_VERSION}",
+ skinsupportconstraintlayout: "com.mogo.skin:skin-support-constraint-layout:${SKIN_SUPPORT_CONSTRAINT_LAYOUT_VERSION}",
+ skinsupportdesign : "com.mogo.skin:skin-support-design:${SKIN_SUPPORT_DESIGN_VERSION}",
+
+ ttsbase : "com.mogo.tts:tts-base:${TTS_BASE_VERSION}",
+ ttsdi : "com.mogo.tts:tts-di:${TTS_DI_VERSION}",
+ ttszhi : "com.mogo.tts:tts-zhi:${TTS_ZHI_VERSION}",
+ ttsnoop : "com.mogo.tts:tts-noop:${TTS_NOOP_VERSION}",
]
}
\ No newline at end of file
diff --git a/foudations/mogo-base-services-apk/src/main/java/com/mogo/base/services/passport/PassportManager.java b/foudations/mogo-base-services-apk/src/main/java/com/mogo/base/services/passport/PassportManager.java
index a1f374e4af..624c97c390 100644
--- a/foudations/mogo-base-services-apk/src/main/java/com/mogo/base/services/passport/PassportManager.java
+++ b/foudations/mogo-base-services-apk/src/main/java/com/mogo/base/services/passport/PassportManager.java
@@ -10,6 +10,7 @@ import com.mogo.service.passport.IMogoPassportManager;
import com.mogo.service.passport.IMogoTicketCallback;
import com.mogo.utils.logger.Logger;
import com.zhidao.account.sdk.AccountClientManager;
+import com.zhidao.account.sdk.BusinessType;
import com.zhidao.account.sdk.Environment;
import com.zhidao.account.sdk.callback.TicketInfoCallback;
import com.zhidao.account.sdk.network.NetEnvironManager;
@@ -70,16 +71,12 @@ class PassportManager implements IMogoPassportManager {
}
private static void getTicket( TicketInfoCallback callback ) {
- if ( DebugConfig.isLauncher() ) {
- AccountClientManager.getTicket( callback );
- } else {
- AccountClientManager.getAppTicket( callback );
- }
+ AccountClientManager.getTicket( callback );
}
@Override
public void init( Context context ) {
- AccountClientManager.init( context.getApplicationContext(), getNetEnvironment(), NetEnvironManager.OS_2C, "os2.0-launcher" );
+ AccountClientManager.init( context.getApplicationContext(), getNetEnvironment(), BusinessType.toc_login, "os2.0-launcher" );
}
private Environment getNetEnvironment() {
diff --git a/foudations/mogo-commons/build.gradle b/foudations/mogo-commons/build.gradle
index dcb2e0b323..35c862662d 100644
--- a/foudations/mogo-commons/build.gradle
+++ b/foudations/mogo-commons/build.gradle
@@ -36,8 +36,6 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
- api rootProject.ext.dependencies.aiassist
- api rootProject.ext.dependencies.aiassistReplace
api rootProject.ext.dependencies.androidxappcompat
api rootProject.ext.dependencies.analytics
implementation rootProject.ext.dependencies.arouter
@@ -46,9 +44,11 @@ dependencies {
implementation rootProject.ext.dependencies.accountsdk
if (Boolean.valueOf(RELEASE)) {
implementation rootProject.ext.dependencies.mogoutils
+ api rootProject.ext.dependencies.ttsbase
implementation rootProject.ext.dependencies.skinsupport
} else {
implementation project(":foudations:mogo-utils")
+ api project(":tts:tts-base")
implementation project(":skin:mogo-skin-support")
}
api 'org.greenrobot:eventbus:3.1.1'
diff --git a/foudations/mogo-commons/src/main/java/com/mogo/commons/context/ContextHolderUtil.java b/foudations/mogo-commons/src/main/java/com/mogo/commons/context/ContextHolderUtil.java
new file mode 100644
index 0000000000..ee5906f96a
--- /dev/null
+++ b/foudations/mogo-commons/src/main/java/com/mogo/commons/context/ContextHolderUtil.java
@@ -0,0 +1,20 @@
+package com.mogo.commons.context;
+
+import android.content.Context;
+
+public class ContextHolderUtil {
+
+ private static Context mContext;
+
+ public static void holdContext(Context context) {
+ mContext = context;
+ }
+
+ public static void releaseContext() {
+ mContext = null;
+ }
+
+ public static Context getContext(){
+ return mContext;
+ }
+}
diff --git a/foudations/mogo-commons/src/main/java/com/mogo/commons/debug/DebugConfig.java b/foudations/mogo-commons/src/main/java/com/mogo/commons/debug/DebugConfig.java
index b000edd5f7..e4949192f2 100644
--- a/foudations/mogo-commons/src/main/java/com/mogo/commons/debug/DebugConfig.java
+++ b/foudations/mogo-commons/src/main/java/com/mogo/commons/debug/DebugConfig.java
@@ -141,23 +141,6 @@ public class DebugConfig {
DebugConfig.sUseCustomNavi = sUseCustomNavi;
}
- /**
- * 设置使用哪个语音助手
- *
- * @param aiType {@link #AI_TYPE_NOOP} {@link #AI_TYPE_TXZ} {@link #AI_TYPE_SPEECH}
- */
- public static void setAIType(int aiType) {
- Logger.d("DebugConfig", "setAiType: " + aiType);
- sAIType = aiType;
- }
-
- /**
- * 使用哪个语音助手 {@link #AI_TYPE_NOOP} {@link #AI_TYPE_TXZ} {@link #AI_TYPE_SPEECH}
- */
- public static int getAIType() {
- return sAIType;
- }
-
/**
* 设置当前车机类型
*
@@ -287,6 +270,45 @@ public class DebugConfig {
return isSkinSupported;
}
+ /**
+ * 是否支持支持查询导航目的地车友信息
+ */
+ private static boolean isSupportedSearchDestinationOnlineCarList = false;
+
+ public static void setSupportedSearchDestinationOnlineCarList( boolean isSupportedSearchDestinationOnlineCarList ) {
+ DebugConfig.isSupportedSearchDestinationOnlineCarList = isSupportedSearchDestinationOnlineCarList;
+ }
+
+ public static boolean isSupportedSearchDestinationOnlineCarList() {
+ return isSupportedSearchDestinationOnlineCarList;
+ }
+
+ /**
+ * 是否支持目的地导航推送策略
+ */
+ private static boolean isScheduleCalculateNotHomeCompanyDistanceForPush = false;
+
+ public static void setScheduleCalculateNotHomeCompanyDistanceForPush( boolean isScheduleCalculateNotHomeCompanyDistanceForPush ) {
+ DebugConfig.isScheduleCalculateNotHomeCompanyDistanceForPush = isScheduleCalculateNotHomeCompanyDistanceForPush;
+ }
+
+ public static boolean isIsScheduleCalculateNotHomeCompanyDistanceForPush() {
+ return isScheduleCalculateNotHomeCompanyDistanceForPush;
+ }
+
+ /**
+ * 是否支持刷新桌面卡片
+ */
+ private static boolean isSupportLauncherCardRefreshStrategy = false;
+
+ public static void setSupportLauncherCardRefreshStrategy( boolean isSupportLauncherCardRefreshStrategy ) {
+ DebugConfig.isSupportLauncherCardRefreshStrategy = isSupportLauncherCardRefreshStrategy;
+ }
+
+ public static boolean isIsSupportLauncherCardRefreshStrategy() {
+ return isSupportLauncherCardRefreshStrategy;
+ }
+
private static int obuType = OBU_TYPE_HUALI;
public static int getObuType() {
diff --git a/foudations/mogo-commons/src/main/java/com/mogo/commons/network/ParamsUtil.java b/foudations/mogo-commons/src/main/java/com/mogo/commons/network/ParamsUtil.java
index f3099010ef..3b3c957209 100644
--- a/foudations/mogo-commons/src/main/java/com/mogo/commons/network/ParamsUtil.java
+++ b/foudations/mogo-commons/src/main/java/com/mogo/commons/network/ParamsUtil.java
@@ -14,7 +14,6 @@ import com.mogo.utils.DeviceIdUtils;
import com.mogo.utils.WindowUtils;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.network.utils.GsonUtil;
-import com.zhidao.auto.platform.util.DeviceUtil;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
@@ -37,7 +36,7 @@ public class ParamsUtil {
params.put( ServerParam.NET_TYPE, CommonUtils.getNetworkType( AbsMogoApplication.getApp() ) );
params.put( ServerParam.CELL_ID, Utils.getCellId( AbsMogoApplication.getApp() ) );
- params.put( ServerParam.DISPLAY_ID, DeviceUtil.getSystemVersion() );
+// params.put( ServerParam.DISPLAY_ID, DeviceUtil.getSystemVersion() );
params.put( ServerParam.SN, Utils.getSn() );
params.put( ServerParam.TICKET, SpStorage.getTicket() );
diff --git a/foudations/mogo-commons/src/main/java/com/mogo/commons/storage/SpStorage.java b/foudations/mogo-commons/src/main/java/com/mogo/commons/storage/SpStorage.java
index 0fbca06a32..6971ebd8d4 100644
--- a/foudations/mogo-commons/src/main/java/com/mogo/commons/storage/SpStorage.java
+++ b/foudations/mogo-commons/src/main/java/com/mogo/commons/storage/SpStorage.java
@@ -18,4 +18,12 @@ public class SpStorage {
public static void setTicket( String ticket ) {
SharedPrefsMgr.getInstance( AbsMogoApplication.getApp() ).putString( "ticket", ticket );
}
+
+ public static String getNavigationTarget(){
+ return SharedPrefsMgr.getInstance( AbsMogoApplication.getApp() ).getString( "naviTarget" );
+ }
+
+ public static void setNavigationTarget( String naviTarget ) {
+ SharedPrefsMgr.getInstance( AbsMogoApplication.getApp() ).putString( "naviTarget", naviTarget );
+ }
}
diff --git a/foudations/mogo-commons/src/main/java/com/mogo/commons/voice/AIAssist.java b/foudations/mogo-commons/src/main/java/com/mogo/commons/voice/AIAssist.java
index e752812148..b76b8be93b 100644
--- a/foudations/mogo-commons/src/main/java/com/mogo/commons/voice/AIAssist.java
+++ b/foudations/mogo-commons/src/main/java/com/mogo/commons/voice/AIAssist.java
@@ -1,25 +1,11 @@
package com.mogo.commons.voice;
-import android.app.ActivityManager;
import android.content.Context;
-import android.content.Intent;
-import android.content.pm.ApplicationInfo;
-import android.text.TextUtils;
-import com.mogo.commons.AbsMogoApplication;
-import com.mogo.utils.logger.Logger;
-import com.zhidao.auto.platform.voice.VoiceClient;
-import com.zhidao.voicesdk.MogoVoiceManager;
-import com.zhidao.voicesdk.MogoVoiceManagerImpl;
-import com.zhidao.voicesdk.callback.OnConnStatusListener;
-import com.zhidao.voicesdk.callback.OnTtsListener;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
+import com.alibaba.android.arouter.launcher.ARouter;
+import com.mogo.tts.base.IMogoTTS;
+import com.mogo.tts.base.MogoTTSConstants;
+import com.mogo.tts.base.PreemptType;
/**
* @author congtaowang
@@ -27,14 +13,11 @@ import java.util.concurrent.ConcurrentHashMap;
*
* 语音助手通信助手
*/
-public class AIAssist implements VoiceClient.VoiceCmdCallBack, OnTtsListener {
+public class AIAssist {
- private static final String TAG = "AIAssist";
private static volatile AIAssist sInstance;
- private String mLastQAndASpeakText;
- private boolean mHasFlush = false;
- private boolean mInitReady = false;
+ private IMogoTTS mTTS;
public static AIAssist getInstance( Context context ) {
if ( sInstance == null ) {
@@ -48,61 +31,15 @@ public class AIAssist implements VoiceClient.VoiceCmdCallBack, OnTtsListener {
}
public synchronized void release() {
- Logger.d( TAG, "release" );
- if ( mCmdMap != null && !mCmdMap.isEmpty() && mVoiceClient != null ) {
- for ( String cmd : mCmdMap.keySet() ) {
- mVoiceClient.unRegisterCustomWakeupCmd( cmd );
- }
+ if ( mTTS != null ) {
+ mTTS.release();
}
- mQAndAMap.clear();
- mVoiceClient.release();
- mSpeakVoiceMap.clear();
- mCacheUnWakeupCommands.clear();
sInstance = null;
}
- private final VoiceClient mVoiceClient;
- private MogoVoiceManager mogoVoiceManager;
- // 免唤醒指令
- private Map< String, List< IMogoVoiceCmdCallBack > > mCmdMap = new HashMap<>();
- // 问答指令
- private Map< String, IMogoVoiceCmdCallBack > mQAndAMap = new HashMap<>();
- // 单独的语音播放
- private Map< String, IMogoVoiceCmdCallBack > mSpeakVoiceMap = new HashMap<>();
-
- private Map< String, String[] > mCacheUnWakeupCommands = new ConcurrentHashMap<>();
private AIAssist( Context context ) {
- // private constructor
- mVoiceClient = new VoiceClient( context.getApplicationContext() );
- mVoiceClient.setCallBack( this );
- initFlushStatus( context );
- initSpeech( context );
- Logger.w( TAG, "voice is ready = %s", mHasFlush );
- }
-
- private void initFlushStatus( Context context ) {
- if ( !mHasFlush ) {
- mHasFlush = isVoiceServiceReady( context );
- }
- }
-
- /**
- * 初始化
- */
- private void initSpeech( Context context ) {
- mogoVoiceManager = MogoVoiceManagerImpl.getInstance();
- mogoVoiceManager.init( context, new OnConnStatusListener() {
- @Override
- public void onSuccess() {
- mInitReady = true;
- }
-
- @Override
- public void onFailed() {
-
- }
- } );
+ mTTS = ( IMogoTTS ) ARouter.getInstance().build( MogoTTSConstants.API_PATH ).navigation( context.getApplicationContext() );
}
/**
@@ -111,83 +48,10 @@ public class AIAssist implements VoiceClient.VoiceCmdCallBack, OnTtsListener {
* @return
*/
public boolean hasFlush() {
- return mHasFlush;
- }
-
- @Override
- public void onCmdSelected( String cmd ) {
- if ( !mCmdMap.containsKey( cmd ) ) {
- return;
- }
- Logger.d( TAG, "received command: %s", cmd );
-
- Iterator< IMogoVoiceCmdCallBack > iterator = null;
- try {
- List< IMogoVoiceCmdCallBack > cmdCallBacks = mCmdMap.get( cmd );
- iterator = new ArrayList<>( cmdCallBacks ).iterator();
- } catch ( Exception e ) {
-
- }
- while ( iterator != null && iterator.hasNext() ) {
- IMogoVoiceCmdCallBack callBack = iterator.next();
- if ( callBack != null ) {
- callBack.onCmdSelected( cmd );
- }
- }
- }
-
- @Override
- public void onCmdAction( String speakText ) {
- if ( !TextUtils.isEmpty( mLastQAndASpeakText ) ) {
- IMogoVoiceCmdCallBack cmdCallBack = mQAndAMap.remove( mLastQAndASpeakText );
- if ( cmdCallBack != null ) {
- cmdCallBack.onCmdAction( speakText );
- }
- }
- }
-
- @Override
- public void onCmdCancel( String speakText ) {
- if ( !TextUtils.isEmpty( mLastQAndASpeakText ) ) {
- IMogoVoiceCmdCallBack cmdCallBack = mQAndAMap.remove( mLastQAndASpeakText );
- if ( cmdCallBack != null ) {
- cmdCallBack.onCmdCancel( speakText );
- }
- }
- }
-
- @Override
- public void onSpeakEnd( String speakText ) {
- if ( mQAndAMap.containsKey( speakText ) ) {
- mLastQAndASpeakText = speakText;
- IMogoVoiceCmdCallBack cmdCallBack = mQAndAMap.get( speakText );
- if ( cmdCallBack != null ) {
- cmdCallBack.onSpeakEnd( speakText );
- return;
- }
- }
- IMogoVoiceCmdCallBack callBack = mSpeakVoiceMap.remove( speakText );
- if ( callBack != null ) {
- callBack.onSpeakEnd( speakText );
- }
- }
-
- @Override
- public void onSpeakSelectTimeOut( String speakText ) {
- if ( mQAndAMap.containsKey( speakText ) ) {
- if ( TextUtils.equals( speakText, mLastQAndASpeakText ) ) {
- mLastQAndASpeakText = null;
- }
- IMogoVoiceCmdCallBack cmdCallBack = mQAndAMap.remove( speakText );
- if ( cmdCallBack != null ) {
- cmdCallBack.onSpeakSelectTimeOut( speakText );
- return;
- }
- }
- IMogoVoiceCmdCallBack callBack = mSpeakVoiceMap.remove( speakText );
- if ( callBack != null ) {
- callBack.onSpeakSelectTimeOut( speakText );
+ if ( mTTS != null ) {
+ return mTTS.hasFlush();
}
+ return false;
}
/**
@@ -196,13 +60,8 @@ public class AIAssist implements VoiceClient.VoiceCmdCallBack, OnTtsListener {
* @param text
*/
public void speakTTSVoice( String text, IMogoVoiceCmdCallBack callBack ) {
- try {
- initFlushStatus( AbsMogoApplication.getApp() );
- if ( mHasFlush ) {
- mSpeakVoiceMap.put( text, callBack );
- mVoiceClient.speakDefault( text );
- }
- } catch ( Exception e ) {
+ if ( mTTS != null ) {
+ mTTS.speakTTSVoice( text, callBack );
}
}
@@ -212,12 +71,8 @@ public class AIAssist implements VoiceClient.VoiceCmdCallBack, OnTtsListener {
* @param text
*/
public void speakTTSVoice( String text ) {
- try {
- initFlushStatus( AbsMogoApplication.getApp() );
- if ( mHasFlush ) {
- mVoiceClient.speakDefault( text );
- }
- } catch ( Exception e ) {
+ if ( mTTS != null ) {
+ mTTS.speakTTSVoice( text );
}
}
@@ -228,13 +83,25 @@ public class AIAssist implements VoiceClient.VoiceCmdCallBack, OnTtsListener {
* @param type 播报策略
*/
public void speakTTSVoice( String text, VoicePreemptType type, IMogoVoiceCmdCallBack callBack ) {
- try {
- initFlushStatus( AbsMogoApplication.getApp() );
- if ( mHasFlush ) {
- mSpeakVoiceMap.put( text, callBack );
- mVoiceClient.speakTypeText( text, type.getPreemptType() );
+ if ( mTTS != null ) {
+ PreemptType preemptType = PreemptType.PREEMPT_TYPE_NONE;
+ if ( type != null ) {
+ switch ( type ) {
+ case PREEMPT_TYPE_FLUSH:
+ preemptType = PreemptType.PREEMPT_TYPE_FLUSH;
+ break;
+ case PREEMPT_TYPE_NEXT:
+ preemptType = PreemptType.PREEMPT_TYPE_NEXT;
+ break;
+ case PREEMPT_TYPE_IMMEADIATELY:
+ preemptType = PreemptType.PREEMPT_TYPE_IMMEDIATELY;
+ break;
+ case PREEMPT_TYPE_IMMEADIATELY_WITHOUT_CANCLE:
+ preemptType = PreemptType.PREEMPT_TYPE_IMMEDIATELY_WITHOUT_CANCEL;
+ break;
+ }
}
- } catch ( Exception e ) {
+ mTTS.speakTTSVoice( text, preemptType, callBack );
}
}
@@ -244,10 +111,8 @@ public class AIAssist implements VoiceClient.VoiceCmdCallBack, OnTtsListener {
* @param tts 播报内容
*/
public void speakQAndACmd( String tts, IMogoVoiceCmdCallBack callBack ) {
- initFlushStatus( AbsMogoApplication.getApp() );
- if ( mHasFlush ) {
- mQAndAMap.put( tts, callBack );
- mVoiceClient.speakTtsAndRegistCmd( tts );
+ if ( mTTS != null ) {
+ mTTS.speakQAndACmd( tts, callBack );
}
}
@@ -259,10 +124,8 @@ public class AIAssist implements VoiceClient.VoiceCmdCallBack, OnTtsListener {
* @param cancelCmds 取消命令唤醒词
*/
public void speakQAndACmd( String tts, String[] okCmds, String[] cancelCmds, IMogoVoiceCmdCallBack callBack ) {
- initFlushStatus( AbsMogoApplication.getApp() );
- if ( mHasFlush ) {
- mQAndAMap.put( tts, callBack );
- mVoiceClient.speakTtsAndRegistCmd( tts, okCmds, cancelCmds );
+ if ( mTTS != null ) {
+ mTTS.speakQAndACmd( tts, okCmds, cancelCmds, callBack );
}
}
@@ -274,47 +137,9 @@ public class AIAssist implements VoiceClient.VoiceCmdCallBack, OnTtsListener {
* @param callBack
*/
public void registerUnWakeupCommand( String cmd, String[] cmdWords, IMogoVoiceCmdCallBack callBack ) {
- if ( !mCmdMap.containsKey( cmd ) ) {
- mCmdMap.put( cmd, new ArrayList<>() );
+ if ( mTTS != null ) {
+ mTTS.registerUnWakeupCommand( cmd, cmdWords, callBack );
}
- mCmdMap.get( cmd ).add( callBack );
-
- initFlushStatus( AbsMogoApplication.getApp() );
- if ( mHasFlush ) {
- mVoiceClient.registerCustomWakeupCmd( cmd, cmdWords );
- mCacheUnWakeupCommands.remove( cmd );
- }
- Logger.i( TAG, "cache un wakeup command2. %s", cmd );
- mCacheUnWakeupCommands.put( cmd, cmdWords );
- }
-
- /**
- * 注册免唤醒命令
- *
- * @param cmd
- * @param cmdWords
- */
- public void registerUnWakeupCommand( String cmd, String[] cmdWords ) {
- initFlushStatus( AbsMogoApplication.getApp() );
- if ( mHasFlush ) {
- mVoiceClient.registerCustomWakeupCmd( cmd, cmdWords );
- mCacheUnWakeupCommands.remove( cmd );
- }
- Logger.i( TAG, "cache un wakeup command. %s", cmd );
- mCacheUnWakeupCommands.put( cmd, cmdWords );
- }
-
- /**
- * 注册免唤醒命令回调
- *
- * @param cmd
- * @param callBack
- */
- public synchronized void registerUnWakeupCommandCallback( String cmd, IMogoVoiceCmdCallBack callBack ) {
- if ( !mCmdMap.containsKey( cmd ) ) {
- mCmdMap.put( cmd, new ArrayList<>() );
- }
- mCmdMap.get( cmd ).add( callBack );
}
/**
@@ -323,9 +148,9 @@ public class AIAssist implements VoiceClient.VoiceCmdCallBack, OnTtsListener {
* @param cmd
*/
public synchronized void unregisterUnWakeupCommand( String cmd ) {
- mCmdMap.remove( cmd );
- mVoiceClient.unRegisterCustomWakeupCmd( cmd );
- mCacheUnWakeupCommands.remove( cmd );
+ if ( mTTS != null ) {
+ mTTS.unregisterUnWakeupCommand( cmd );
+ }
}
/**
@@ -334,20 +159,12 @@ public class AIAssist implements VoiceClient.VoiceCmdCallBack, OnTtsListener {
* @param cmd
*/
public synchronized void unregisterUnWakeupCommand( String cmd, IMogoVoiceCmdCallBack callBack ) {
- if ( mCmdMap.containsKey( cmd ) ) {
- List< IMogoVoiceCmdCallBack > callBacks = mCmdMap.get( cmd );
- if ( callBacks != null ) {
- callBacks.remove( callBack );
- }
- if ( callBacks.isEmpty() ) {
- mCmdMap.remove( cmd );
- mVoiceClient.unRegisterCustomWakeupCmd( cmd );
- mCacheUnWakeupCommands.remove( cmd );
- }
+ if ( mTTS != null ) {
+ mTTS.unregisterUnWakeupCommand( cmd, callBack );
}
}
- public static void startAssistant( Context context ) {
+ public void startAssistant( Context context ) {
startAssistant( context, 1 );
}
@@ -355,160 +172,49 @@ public class AIAssist implements VoiceClient.VoiceCmdCallBack, OnTtsListener {
* @param context
* @param status window_start_cancel 0 - 结束, 1 - 显示, 2 - 未激活调试进入
*/
- public static void startAssistant( Context context, int status ) {
- final Intent intent = new Intent();
- intent.setFlags( Intent.FLAG_INCLUDE_STOPPED_PACKAGES );
- intent.setAction( "pvetec.intent.action.txz.switch" );
- intent.putExtra( "window_start_cancel", status );
- intent.putExtra( "extra_switch_type", "window_start_cancel" );
- Logger.d( TAG, "status = %d", status );
- context.sendBroadcast( intent );
+ public void startAssistant( Context context, int status ) {
+ if ( mTTS != null ) {
+ mTTS.startAIAssist( context, status );
+ }
}
public synchronized void flush() {
- if ( mCacheUnWakeupCommands.isEmpty() ) {
- return;
+ if ( mTTS != null ) {
+ mTTS.flush();
}
- mHasFlush = true;
- Logger.d( TAG, "flush cache voice command when voice service ready." );
- final Map< String, String[] > tmp = new HashMap<>( mCacheUnWakeupCommands );
- for ( String cmd : tmp.keySet() ) {
- registerUnWakeupCommand( cmd, tmp.get( cmd ) );
- }
- }
-
- private boolean isVoiceServiceReady( Context context ) {
- if ( isProcessRunning( context, getPackageUid( context, "com.zhidao.speech" ) )
- && isProcessRunning( context, getPackageUid( context, "com.zhidao.speech.adapter" ) ) ) {
- return true;
- } else if (isProcessRunning(context, getPackageUid(context, "com.txznet.txz")) && isProcessRunning(context, getPackageUid(context, "com.txznet.adapter"))) {
- Logger.d(TAG, "txz is voiceServiceReady");
- return true;
- }
- return false;
- }
-
-// private boolean isRunningTaskExist( Context context, String processName ) {
-//// ActivityManager am = ( ActivityManager ) context.getSystemService( Context.ACTIVITY_SERVICE );
-//// List< ActivityManager.RunningAppProcessInfo > processList = am.getRunningAppProcesses();
-//// for ( ActivityManager.RunningAppProcessInfo info : processList ) {
-//// if ( info.processName.equals( processName ) ) {
-//// return true;
-//// }
-//// }
-//// return false;
-//// }
-
- /**
- * 方法描述:判断某一应用是否正在运行
- * Created by cafeting on 2017/2/4.
- *
- * @param context 上下文
- * @param packageName 应用的包名
- * @return true 表示正在运行,false 表示没有运行
- */
- public static boolean isAppRunning( Context context, String packageName ) {
- ActivityManager am = ( ActivityManager ) context.getSystemService( Context.ACTIVITY_SERVICE );
- List< ActivityManager.RunningTaskInfo > list = am.getRunningTasks( 100 );
- if ( list.size() <= 0 ) {
- return false;
- }
- for ( ActivityManager.RunningTaskInfo info : list ) {
- if ( info.baseActivity.getPackageName().equals( packageName ) ) {
- return true;
- }
- }
- return false;
- }
-
-
- //获取已安装应用的 uid,-1 表示未安装此应用或程序异常
- public static int getPackageUid( Context context, String packageName ) {
- try {
- ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo( packageName, 0 );
- if ( applicationInfo != null ) {
- return applicationInfo.uid;
- }
- } catch ( Exception e ) {
- return -1;
- }
- return -1;
- }
-
- /**
- * 判断某一 uid 的程序是否有正在运行的进程,即是否存活
- * Created by cafeting on 2017/2/4.
- *
- * @param context 上下文
- * @param uid 已安装应用的 uid
- * @return true 表示正在运行,false 表示没有运行
- */
- public static boolean isProcessRunning( Context context, int uid ) {
- ActivityManager am = ( ActivityManager ) context.getSystemService( Context.ACTIVITY_SERVICE );
- List< ActivityManager.RunningServiceInfo > runningServiceInfos = am.getRunningServices( 200 );
- if ( runningServiceInfos.size() > 0 ) {
- for ( ActivityManager.RunningServiceInfo appProcess : runningServiceInfos ) {
- if ( uid == appProcess.uid ) {
- return true;
- }
- }
- }
- return false;
}
public void speakTTSAndDuck( String text ) {
- speakTTSAndDuck( text, null );
+ if ( mTTS != null ) {
+ mTTS.speakTTSAndDuck( text );
+ }
}
public void speakTTSAndDuck( String text, IMogoVoiceCmdCallBack callBack ) {
- try {
- if ( mInitReady ) {
- mSpeakVoiceMap.put( text, callBack );
- mogoVoiceManager.toSpeak( text, -3, this );
- }
- } catch ( Exception e ) {
+ if ( mTTS != null ) {
+ mTTS.speakTTSAndDuck( text, callBack );
}
}
public void shutUp( String ttsId, String text ) {
- try {
- mSpeakVoiceMap.remove( text );
- mogoVoiceManager.shutUp( ttsId );
- } catch ( Exception e ) {
+ if ( mTTS != null ) {
+ mTTS.shutUp( ttsId, text );
+ }
+ }
+ /**
+ * 打断上一条正在播报的语音内容,仅在Speech上生效,TXZ为空实现
+ * 语音SDK生效版本从1.0.8.4版本起
+ */
+ public void breakOffSpeak() {
+ if ( mTTS != null ) {
+ mTTS.breakOffSpeak();
}
}
public void clearTTSCallback( String text ) {
- try {
- mSpeakVoiceMap.remove( text );
- } catch ( Exception e ) {
- e.printStackTrace();
+ if ( mTTS != null ) {
+ mTTS.clearTTSCallback( text );
}
}
-
- @Override
- public void onTtsStart( String ttsId, String text ) {
- IMogoVoiceCmdCallBack callBack = mSpeakVoiceMap.get( text );
- if ( callBack != null ) {
- callBack.onTTSStart( ttsId, text );
- }
- }
-
- @Override
- public void onTtsFinish( String ttsId, String text ) {
- IMogoVoiceCmdCallBack callBack = mSpeakVoiceMap.remove( text );
- if ( callBack != null ) {
- callBack.onTTSEnd( ttsId, text );
- }
- }
-
- @Override
- public void onTtsError( String ttsId, String text ) {
- IMogoVoiceCmdCallBack callBack = mSpeakVoiceMap.remove( text );
- if ( callBack != null ) {
- callBack.onTTSError( ttsId, text );
- }
- }
-
}
diff --git a/foudations/mogo-commons/src/main/java/com/mogo/commons/voice/IMogoVoiceCmdCallBack.java b/foudations/mogo-commons/src/main/java/com/mogo/commons/voice/IMogoVoiceCmdCallBack.java
index eb26dc64f6..5b5dece128 100644
--- a/foudations/mogo-commons/src/main/java/com/mogo/commons/voice/IMogoVoiceCmdCallBack.java
+++ b/foudations/mogo-commons/src/main/java/com/mogo/commons/voice/IMogoVoiceCmdCallBack.java
@@ -1,66 +1,7 @@
package com.mogo.commons.voice;
-public interface IMogoVoiceCmdCallBack {
+import com.mogo.tts.base.IMogoTTSCallback;
- /**
- * 新SDK接口
- *
- * @param ttsId
- * @param tts
- */
- default void onTTSStart( String ttsId, String tts ) {
- }
+public interface IMogoVoiceCmdCallBack extends IMogoTTSCallback {
- /**
- * 新SDK接口
- *
- * @param ttsId
- * @param tts
- */
- default void onTTSEnd( String ttsId, String tts ) {
- }
-
- /**
- * 新SDK接口
- *
- * @param ttsId
- * @param tts
- */
- default void onTTSError( String ttsId, String tts ) {
- }
-
- /**
- * 免唤醒命令响应回调
- *
- * @param cmd
- */
- default void onCmdSelected( String cmd ){}
-
- /**
- * 语音播报临时免唤醒“确定”命令
- *
- * @param speakText 播报内容
- */
- default void onCmdAction( String speakText ){}
-
- /**
- * 语音播报临时免唤醒“取消”命令
- *
- * @param speakText 播报内容
- */
- default void onCmdCancel( String speakText ){}
-
- /**
- * 语音播报完毕
- *
- * @param speakText 播报内容
- */
- default void onSpeakEnd( String speakText ){}
-
- /**
- * 语音播报完临时命令选择超时
- *
- * @param speakText 播报内容
- */
- default void onSpeakSelectTimeOut( String speakText ){}
}
\ No newline at end of file
diff --git a/foudations/mogo-commons/src/main/java/com/mogo/commons/voice/VoicePreemptType.java b/foudations/mogo-commons/src/main/java/com/mogo/commons/voice/VoicePreemptType.java
index aef7e63252..dbaaa14def 100644
--- a/foudations/mogo-commons/src/main/java/com/mogo/commons/voice/VoicePreemptType.java
+++ b/foudations/mogo-commons/src/main/java/com/mogo/commons/voice/VoicePreemptType.java
@@ -1,23 +1,9 @@
package com.mogo.commons.voice;
-import com.zhidao.auto.platform.voice.VoiceClient;
-
public enum VoicePreemptType {
-
-
- PREEMPT_TYPE_NONE( VoiceClient.PreemptType.PREEMPT_TYPE_NONE ), //不打断
- PREEMPT_TYPE_IMMEADIATELY( VoiceClient.PreemptType.PREEMPT_TYPE_IMMEADIATELY ), //立即打断,取消当前的tts插队播放
- PREEMPT_TYPE_NEXT( VoiceClient.PreemptType.PREEMPT_TYPE_NEXT ), //下一个插入,不取消当前的tts,插队下一个播放
- PREEMPT_TYPE_FLUSH( VoiceClient.PreemptType.PREEMPT_TYPE_FLUSH ), //清空队列
- PREEMPT_TYPE_IMMEADIATELY_WITHOUT_CANCLE( VoiceClient.PreemptType.PREEMPT_TYPE_IMMEADIATELY_WITHOUT_CANCLE ); //立即打断,不取消当前tts
-
- public VoiceClient.PreemptType preemptType;
-
- VoicePreemptType( VoiceClient.PreemptType preemptType ) {
- this.preemptType = preemptType;
- }
-
- public VoiceClient.PreemptType getPreemptType() {
- return preemptType;
- }
+ PREEMPT_TYPE_NONE, //不打断
+ PREEMPT_TYPE_IMMEADIATELY, //立即打断,取消当前的tts插队播放
+ PREEMPT_TYPE_NEXT, //下一个插入,不取消当前的tts,插队下一个播放
+ PREEMPT_TYPE_FLUSH, //清空队列
+ PREEMPT_TYPE_IMMEADIATELY_WITHOUT_CANCLE; //立即打断,不取消当前tts
}
\ No newline at end of file
diff --git a/foudations/mogo-utils/src/main/java/com/mogo/utils/AppUtils.java b/foudations/mogo-utils/src/main/java/com/mogo/utils/AppUtils.java
index 0218167b23..acc7454a10 100644
--- a/foudations/mogo-utils/src/main/java/com/mogo/utils/AppUtils.java
+++ b/foudations/mogo-utils/src/main/java/com/mogo/utils/AppUtils.java
@@ -87,4 +87,38 @@ public class AppUtils {
}
return false;
}
+
+ //获取已安装应用的 uid,-1 表示未安装此应用或程序异常
+ public static int getPackageUid( Context context, String packageName ) {
+ try {
+ ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo( packageName, 0 );
+ if ( applicationInfo != null ) {
+ return applicationInfo.uid;
+ }
+ } catch ( Exception e ) {
+ return -1;
+ }
+ return -1;
+ }
+
+ /**
+ * 判断某一 uid 的程序是否有正在运行的进程,即是否存活
+ * Created by cafeting on 2017/2/4.
+ *
+ * @param context 上下文
+ * @param uid 已安装应用的 uid
+ * @return true 表示正在运行,false 表示没有运行
+ */
+ public static boolean isProcessRunning( Context context, int uid ) {
+ ActivityManager am = ( ActivityManager ) context.getSystemService( Context.ACTIVITY_SERVICE );
+ List< ActivityManager.RunningServiceInfo > runningServiceInfos = am.getRunningServices( 200 );
+ if ( runningServiceInfos.size() > 0 ) {
+ for ( ActivityManager.RunningServiceInfo appProcess : runningServiceInfos ) {
+ if ( uid == appProcess.uid ) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
}
diff --git a/gradle.properties b/gradle.properties
index 0a7bd019ea..7ebe5f7afc 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -29,94 +29,88 @@ PASSWORD=xintai2018
RELEASE=false
# 模块版本
## 工程内模块
-MOGO_COMMONS_VERSION=1.2.1.22
-MOGO_UTILS_VERSION=1.2.1.22
-MAP_AMAP_VERSION=1.2.1.22
-MAP_AUTONAVI_VERSION=1.2.1.22
-MOGO_MAP_VERSION=1.2.1.22
-MOGO_MAP_API_VERSION=1.2.1.22
-MOGO_SERVICE_VERSION=1.2.1.22
-MOGO_SERVICE_API_VERSION=1.2.1.22
-MOGO_CONNECTION_VERSION=1.2.1.22
-MOGO_MODULE_APPS_VERSION=1.2.1.22
-MOGO_MODULE_NAVI_VERSION=1.2.1.22
-MOGO_MODULE_SHARE_VERSION=1.2.1.22
-MOGO_MODULE_COMMON_VERSION=1.2.1.22
-MOGO_MODULE_MAIN_VERSION=1.2.1.22
-MOGO_MODULE_MAP_VERSION=1.2.1.22
-MOGO_MODULE_SERVICE_VERSION=1.2.1.22
-MOGO_MODULE_EXTENSIONS_VERSION=1.2.1.22
-MOGO_MODULE_SEARCH_VERSION=1.2.1.22
-MOGO_MODULE_BACK_VERSION=1.2.1.22
-MOGO_MODULE_GPS_SIMULATOR_VERSION=1.2.1.22
-MOGO_MODULE_GPS_SIMULATOR_DEBUG_VERSION=1.2.1.22
-MOGO_MODULE_GPS_SIMULATOR_NOOP_VERSION=1.2.1.22
-MOGO_MODULE_AUTHORIZE_VERSION=1.2.1.22
-MOGO_MODULE_GUIDE_VERSION=1.2.1.22
-MOGO_MODULE_MEDIA_VERSION=1.2.1.22
-MOGO_MODULE_MAIN_LAUNCHER_VERSION = 1.2.1.22
-MOGO_MODULE_MAIN_INDEPENDENT_VERSION = 1.2.1.22
-MOGO_MODULE_V2X_VERSION=1.2.1.22
+MOGO_COMMONS_VERSION=2.0.2
+MOGO_UTILS_VERSION=2.0.0
+MAP_AMAP_VERSION=2.0.0
+MAP_AUTONAVI_VERSION=2.0.0
+MOGO_MAP_VERSION=2.0.0
+MOGO_MAP_API_VERSION=2.0.0
+MOGO_SERVICE_VERSION=2.0.0
+MOGO_SERVICE_API_VERSION=2.0.2
+MOGO_CONNECTION_VERSION=2.0.0
+MOGO_MODULE_APPS_VERSION=2.0.0
+MOGO_MODULE_NAVI_VERSION=2.0.0
+MOGO_MODULE_SHARE_VERSION=2.0.0
+MOGO_MODULE_COMMON_VERSION=2.0.0
+MOGO_MODULE_MAIN_VERSION=2.0.0
+MOGO_MODULE_MAP_VERSION=2.0.0
+MOGO_MODULE_SERVICE_VERSION=2.0.0
+MOGO_MODULE_EXTENSIONS_VERSION=2.0.0
+MOGO_MODULE_SEARCH_VERSION=2.0.0
+MOGO_MODULE_BACK_VERSION=2.0.0
+MOGO_MODULE_GPS_SIMULATOR_VERSION=2.0.0
+MOGO_MODULE_GPS_SIMULATOR_DEBUG_VERSION=2.0.0
+MOGO_MODULE_GPS_SIMULATOR_NOOP_VERSION=2.0.0
+MOGO_MODULE_AUTHORIZE_VERSION=2.0.0
+MOGO_MODULE_GUIDE_VERSION=2.0.0
+MOGO_MODULE_MEDIA_VERSION=2.0.0
+MOGO_MODULE_MAIN_LAUNCHER_VERSION = 2.0.0
+MOGO_MODULE_MAIN_INDEPENDENT_VERSION = 2.0.0
+MOGO_MODULE_V2X_VERSION=2.0.0
# 基础服务实现:passport、socket、location
-MOGO_BASE_SERVICES_APK_VERSION = 1.2.1.22
-MOGO_BASE_SERVICES_SDK_VERSION = 1.2.1.22
-
+MOGO_BASE_SERVICES_APK_VERSION = 2.0.0
+MOGO_BASE_SERVICES_SDK_VERSION = 2.0.0
## 工程外部模块
# 探路
-MOGO_MODULE_TANLU_VERSION=1.3.1.24
-# 车聊聊
-CARCHATTING_VERSION=1.6.5
-# 车聊聊接口
-CARCHATTINGPROVIDER_VERSION=1.3.4
+MOGO_MODULE_TANLU_VERSION=2.0.0
# 视频引导
-MOGO_MODULE_GUIDESHOW_VERSION=1.0.2-SNAPSHOT
-## 视频引导接口
-
-MOGO_MODULE_GUIDESHOW_PROVIDER_VERSION=1.0.2-SNAPSHOT
-# 在线车辆F
-MOGO_MODULE_ONLINECAR_VERSION=1.0.3.2
+MOGO_MODULE_GUIDESHOW_VERSION=2.0.0
# 推送
-MOGO_MODULE_PUSH_VERSION=1.1.6.2
-MOGO_MODULE_PUSH_BASE_VERSION=1.1.5.5
-MOGO_MODULE_PUSH_NOOP_VERSION=1.1.5.6
-# 广告资源位
-MOGO_MODULE_AD_CARD_VERSION=1.0.1
+MOGO_MODULE_PUSH_VERSION=2.0.0
+MOGO_MODULE_PUSH_BASE_VERSION=2.0.0
+MOGO_MODULE_PUSH_NOOP_VERSION=2.0.0
# 探路上报和分享模块
-TANLULIB_VERSION=1.3.1.24
-MOGO_TANLU_API_VERSION = 1.0.0-SNAPSHOT
-
-MOGO_MODULE_EVENT_PANEL_VERSION = 1.0.0-SNAPSHOT
-MOGO_MODULE_EVENT_PANEL_NOOP_VERSION = 1.0.0-SNAPSHOT
+TANLULIB_VERSION=2.0.0
+MOGO_TANLU_API_VERSION=2.0.0
#左侧面板模块
-MOGO_MODULE_LEFT_PANEL_VERSION = 1.2.1.10-SNAPSHOT
-MOGO_MODULE_LEFT_PANEL_NOOP_VERSION = 1.2.1.10-SNAPSHOT
+MOGO_MODULE_LEFT_PANEL_VERSION=2.0.0
+MOGO_MODULE_LEFT_PANEL_NOOP_VERSION=2.0.0
# 小控件
-MOGO_MODULE_WIDGETS_VERSION = 1.2.1.10-SNAPSHOT
-
-# Boost分包
-BOOST_MULTIDEX_VERSION=1.0.0
-# hook ARouter分包实现
-HOOKPLUGIN_VERSION=1.0.0
-
+MOGO_MODULE_WIDGETS_VERSION=2.0.0
# obu
-MOGO_MODULE_OBU_VERSION = 1.2.1.10-SNAPSHOT
-
+MOGO_MODULE_OBU_VERSION=2.0.0
+# 皮肤
+MOGO_SKIN_SUPPORT_VERSION=2.0.0
+MOGO_SKIN_LIGHT_VERSION=2.0.0
+MOGO_SKIN_SUPPORT_IMPL_VERSION=2.0.0
+MOGO_SKIN_SUPPORT_NOOP_VERSION=2.0.0
+SKIN_SUPPORT_VERSION=2.0.0
+SKIN_SUPPORT_APPCOMPAT_VERSION=2.0.0
+SKIN_SUPPORT_CARDVIEW_VERSION=2.0.0
+SKIN_SUPPORT_CONSTRAINT_LAYOUT_VERSION=2.0.0
+SKIN_SUPPORT_DESIGN_VERSION=2.0.0
# 闪屏页
-MOGO_MODULE_SPLASH_VERSION = 1.0.0-SNAPSHOT
-MOGO_MODULE_SPLASH_NOOP_VERSION = 1.0.0-SNAPSHOT
-MOGO_SKIN_SUPPORT_VERSION=1.0.0
-MOGO_SKIN_LIGHT_VERSION=1.0.0
-MOGO_SKIN_SUPPORT_IMPL_VERSION=1.0.0
-MOGO_SKIN_SUPPORT_NOOP_VERSION=1.0.0
+MOGO_MODULE_SPLASH_VERSION=2.0.0
+MOGO_MODULE_SPLASH_NOOP_VERSION=2.0.0
+# monitor
+MOGO_MODULE_MONITOR_VERSION=2.0.0
+# bugly
+CRASHREPORT_VERSION=2.0.0
+CRASHREPORT_BUGLY_VERSION=2.0.0
+CRASHREPORT_NOOP_VERSION=2.0.0
+## tts
+TTS_BASE_VERSION=1.0.0
+TTS_DI_VERSION=1.0.0
+TTS_ZHI_VERSION=1.0.0
+TTS_NOOP_VERSION=1.0.0
+######## 外部依赖引用
+# 车聊聊
+CARCHATTING_VERSION=1.9.7.1
+# 车聊聊接口
+CARCHATTINGPROVIDER_VERSION=1.4.1
# loglib
LOGLIB_VERSION = 1.0.4
-# monitor
-MOGO_MODULE_MONITOR_VERSION = 1.0.0-SNAPSHOT
-
-CRASHREPORT_VERSION = 1.0.0
-CRASHREPORT_BUGLY_VERSION = 1.0.0
-CRASHREPORT_NOOP_VERSION = 1.0.0
## 产品库必备配置,产品库自动对versionCode和versionName版本进行升级
applicationId=com.mogo.launcer
diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapBaseMapView.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapBaseMapView.java
index 1ae99ff4d1..86c4b3e973 100644
--- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapBaseMapView.java
+++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapBaseMapView.java
@@ -34,10 +34,12 @@ public class AMapBaseMapView extends MogoBaseMapView {
@Override
protected IMogoMapView createMapView( Context context ) {
IMogoMapView mapView = AMapViewHandler.getMapView();
- if ( mapView.getMapView().getParent() != null ) {
+ if ( mapView != null
+ && mapView.getMapView()!= null
+ && mapView.getMapView().getParent() != null ) {
ViewGroup group = ( ViewGroup ) mapView.getMapView().getParent();
group.removeView( mapView.getMapView() );
}
- return AMapViewHandler.getMapView();
+ return mapView;
}
}
diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java
index 1b7e1ebc8b..f14d67a9ef 100644
--- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java
+++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java
@@ -41,6 +41,7 @@ import com.mogo.map.impl.amap.marker.AMapMarkerWrapper;
import com.mogo.map.impl.amap.message.AMapMessageListener;
import com.mogo.map.impl.amap.message.AMapMessageManager;
import com.mogo.map.impl.amap.navi.NaviClient;
+import com.mogo.map.impl.amap.uicontroller.AMapUIController;
import com.mogo.map.impl.amap.utils.MogoMapUtils;
import com.mogo.map.impl.amap.utils.ObjectUtils;
import com.mogo.map.listener.MogoMapListenerHandler;
@@ -234,6 +235,8 @@ public class AMapNaviViewWrapper implements IMogoMapView,
public void onDestroy() {
if ( mMapView != null ) {
mMapView.onDestroy();
+ AMapUIController.getInstance().release();
+ AMapWrapper.release();
Logger.d( TAG, "map onDestroy" );
}
}
diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapViewWrapper.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapViewWrapper.java
index 2c70ee3345..8ef68ba368 100644
--- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapViewWrapper.java
+++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapViewWrapper.java
@@ -39,6 +39,7 @@ import com.mogo.map.impl.amap.marker.AMapMarkerWrapper;
import com.mogo.map.impl.amap.message.AMapMessageListener;
import com.mogo.map.impl.amap.message.AMapMessageManager;
import com.mogo.map.impl.amap.navi.NaviClient;
+import com.mogo.map.impl.amap.uicontroller.AMapUIController;
import com.mogo.map.impl.amap.utils.MogoMapUtils;
import com.mogo.map.impl.amap.utils.ObjectUtils;
import com.mogo.map.listener.MogoMapListenerHandler;
@@ -48,6 +49,7 @@ import com.mogo.map.uicontroller.EnumMapUI;
import com.mogo.map.uicontroller.IMogoMapUIController;
import com.mogo.map.uicontroller.MapCameraPosition;
import com.mogo.map.uicontroller.MapControlResult;
+import com.mogo.utils.NetworkUtils;
import com.mogo.utils.WindowUtils;
import com.mogo.utils.logger.Logger;
@@ -163,7 +165,9 @@ public class AMapViewWrapper implements IMogoMapView,
// mMapView.setRouteOverlayVisible( false );
// mMapView.setCarOverlayVisible( false );
changeMapMode( EnumMapUI.CarUp_2D );
- setTrafficEnabled( true );
+ if ( NetworkUtils.isConnected( mMapView.getContext() ) ) {
+ setTrafficEnabled( true );
+ }
mMapView.getMap().moveCamera( CameraUpdateFactory.zoomTo( mDefaultZoomLevel ) );
}
@@ -202,6 +206,7 @@ public class AMapViewWrapper implements IMogoMapView,
@Override
public void onCreate( Bundle bundle ) {
+ Logger.d( TAG, Log.getStackTraceString( new Throwable( ) ) );
if ( mMapView != null ) {
mMapView.onCreate( bundle );
Logger.d( TAG, "map onCreate" );
@@ -232,6 +237,8 @@ public class AMapViewWrapper implements IMogoMapView,
public void onDestroy() {
if ( mMapView != null ) {
mMapView.onDestroy();
+ AMapUIController.getInstance().release();
+ AMapWrapper.release();
Logger.d( TAG, "map onDestroy" );
}
}
@@ -308,6 +315,7 @@ public class AMapViewWrapper implements IMogoMapView,
@Override
public void setTrafficEnabled( boolean visible ) {
if ( checkMapView() ) {
+ Logger.d( TAG, "setTrafficEnabled" );
mMapView.getMap().setTrafficEnabled( true );
}
}
@@ -552,7 +560,6 @@ public class AMapViewWrapper implements IMogoMapView,
Logger.d( TAG, Log.getStackTraceString( new Throwable() ) );
}
Logger.d( TAG, "Zoom锁定锁车比例尺 %s", var1 );
- // TODO: 2020/8/27 设置锁车比例尺
// mMapView.setLockZoom( var1 );
}
}
diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapWrapper.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapWrapper.java
index 2965606844..ceccf22eb6 100644
--- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapWrapper.java
+++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapWrapper.java
@@ -56,6 +56,10 @@ public class AMapWrapper implements IMogoMap {
return sAMap;
}
+ public static void release(){
+ sAMap = null;
+ }
+
@Override
public IMogoUiSettings getUiSettings() {
if ( !checkAMap() ) {
diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/NaviClient.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/NaviClient.java
index 0a85cd595d..4e7382f89f 100644
--- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/NaviClient.java
+++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/NaviClient.java
@@ -77,7 +77,7 @@ public class NaviClient implements IMogoNavi {
private boolean mAimlessStatus;
private NaviClient( Context context ) {
- mContext = context;
+ mContext = context.getApplicationContext();
if ( DebugConfig.isUseCustomNavi() ) {
// 按需初始化导航组件
initAMapNavi();
diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/TTSSpeaker.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/TTSSpeaker.java
index dd5c6ec2f6..dffc2067f2 100644
--- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/TTSSpeaker.java
+++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/TTSSpeaker.java
@@ -4,7 +4,6 @@ import android.text.TextUtils;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.commons.voice.AIAssist;
-import com.mogo.commons.voice.IMogoVoiceCmdCallBack;
import java.util.LinkedList;
@@ -16,7 +15,7 @@ import java.util.LinkedList;
*
* 策略:队列缓存预播报的 tts,然后上一句播完后
*/
-public class TTSSpeaker implements IMogoVoiceCmdCallBack {
+public class TTSSpeaker {
private static volatile TTSSpeaker sInstance;
@@ -48,7 +47,6 @@ public class TTSSpeaker implements IMogoVoiceCmdCallBack {
return;
}
mWaiting.add( tts );
- peekAndSpeak();
}
public synchronized void shutUp() {
@@ -60,61 +58,5 @@ public class TTSSpeaker implements IMogoVoiceCmdCallBack {
}
}
- @Override
- public void onCmdSelected( String cmd ) {
- }
-
- @Override
- public void onCmdAction( String speakText ) {
-
- }
-
- @Override
- public void onCmdCancel( String speakText ) {
-
- }
-
- @Override
- public void onSpeakEnd( String speakText ) {
-
- }
-
- @Override
- public void onSpeakSelectTimeOut( String speakText ) {
-
- }
-
- @Override
- public void onTTSStart( String ttsId, String tts ) {
- if ( TextUtils.equals( mLastTts, tts ) ) {
- mLastTtsId = ttsId;
- }
- }
-
- @Override
- public void onTTSEnd( String ttsId, String tts ) {
- mLastTtsId = null;
- peekAndSpeak();
- }
-
- @Override
- public void onTTSError( String ttsId, String tts ) {
- mLastTtsId = null;
- peekAndSpeak();
- }
-
- private synchronized void peekAndSpeak() {
- if ( mWaiting.isEmpty() ) {
- mLastTts = null;
- mLastTtsId = null;
- return;
- }
- if ( mLastTtsId != null ) {
- // 上一句还没有播完
- return;
- }
- mLastTts = mWaiting.pop();
- AIAssist.getInstance( AbsMogoApplication.getApp() ).speakTTSAndDuck( mLastTts, this );
- }
}
diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/uicontroller/AMapUIController.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/uicontroller/AMapUIController.java
index 2e874886ae..113abe60f0 100644
--- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/uicontroller/AMapUIController.java
+++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/uicontroller/AMapUIController.java
@@ -51,6 +51,7 @@ public class AMapUIController implements IMogoMapUIController {
}
public synchronized void release() {
+ mClient = null;
sInstance = null;
}
diff --git a/libraries/map-amap/src/main/res/drawable-ldpi/map_api_ic_current_location2.png b/libraries/map-amap/src/main/res/drawable-ldpi/map_api_ic_current_location2.png
index 5d2d79c7e5..5f91be07f3 100644
Binary files a/libraries/map-amap/src/main/res/drawable-ldpi/map_api_ic_current_location2.png and b/libraries/map-amap/src/main/res/drawable-ldpi/map_api_ic_current_location2.png differ
diff --git a/libraries/map-amap/src/main/res/drawable-mdpi/map_api_ic_current_location2.png b/libraries/map-amap/src/main/res/drawable-mdpi/map_api_ic_current_location2.png
index 5d2d79c7e5..5f91be07f3 100644
Binary files a/libraries/map-amap/src/main/res/drawable-mdpi/map_api_ic_current_location2.png and b/libraries/map-amap/src/main/res/drawable-mdpi/map_api_ic_current_location2.png differ
diff --git a/libraries/map-amap/src/main/res/drawable-xhdpi-1920x1000/map_api_ic_current_location2.png b/libraries/map-amap/src/main/res/drawable-xhdpi-1920x1000/map_api_ic_current_location2.png
index 06fb9a934e..c24c56f3db 100644
Binary files a/libraries/map-amap/src/main/res/drawable-xhdpi-1920x1000/map_api_ic_current_location2.png and b/libraries/map-amap/src/main/res/drawable-xhdpi-1920x1000/map_api_ic_current_location2.png differ
diff --git a/libraries/map-autonavi/src/main/java/com/mogo/map/impl/automap/navi/AutoNaviReceiver.java b/libraries/map-autonavi/src/main/java/com/mogo/map/impl/automap/navi/AutoNaviReceiver.java
index 516be8652e..c100707450 100644
--- a/libraries/map-autonavi/src/main/java/com/mogo/map/impl/automap/navi/AutoNaviReceiver.java
+++ b/libraries/map-autonavi/src/main/java/com/mogo/map/impl/automap/navi/AutoNaviReceiver.java
@@ -6,6 +6,7 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.text.TextUtils;
+import com.mogo.commons.storage.SpStorage;
import com.mogo.map.impl.amap.utils.IconTypeUtils;
import com.mogo.map.navi.MogoNaviInfo;
import com.mogo.map.navi.MogoNaviListenerHandler;
@@ -66,6 +67,11 @@ public class AutoNaviReceiver extends BroadcastReceiver {
int state = intent.getIntExtra( "EXTRA_STATE", -1 );
handleMapStatusChanged( state );
break;
+ case 10056:
+ String json = intent.getStringExtra( "EXTRA_ROAD_INFO" );
+ SpStorage.setNavigationTarget(json);
+ Logger.d( TAG, json );
+ break;
}
}
@@ -126,6 +132,7 @@ public class AutoNaviReceiver extends BroadcastReceiver {
case MapStateValue.START_NAVI:
case MapStateValue.START_EMULATOR_NAVI:
if ( MapState.getInstance().isNaving() ) {
+ Logger.w( TAG, "naving..." );
return;
}
MapState.getInstance().setNaving( true );
diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/MogoBaseMapView.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/MogoBaseMapView.java
index e51e933608..9137677d96 100644
--- a/libraries/mogo-map-api/src/main/java/com/mogo/map/MogoBaseMapView.java
+++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/MogoBaseMapView.java
@@ -86,6 +86,7 @@ public abstract class MogoBaseMapView extends FrameLayout implements ILifeCycle
if ( mMapView != null ) {
mMapView.onDestroy();
}
+ MogoMap.getInstance().clear();
}
@Override
diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/MogoMap.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/MogoMap.java
index b2c5986293..3aae71ad09 100644
--- a/libraries/mogo-map-api/src/main/java/com/mogo/map/MogoMap.java
+++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/MogoMap.java
@@ -46,4 +46,9 @@ public class MogoMap {
public IMogoMap getMogoMap() {
return mMap;
}
+
+ public void clear(){
+ mContext = null;
+ mMap = null;
+ }
}
diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/marker/MogoMarkersHandler.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/marker/MogoMarkersHandler.java
index 51425cae06..387f8f58c5 100644
--- a/libraries/mogo-map-api/src/main/java/com/mogo/map/marker/MogoMarkersHandler.java
+++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/marker/MogoMarkersHandler.java
@@ -10,6 +10,7 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
/**
* @author congtaowang
@@ -33,7 +34,7 @@ public class MogoMarkersHandler implements IMogoMarkerClickListener, IMogoMarker
return sInstance;
}
- private Map< String, List< IMogoMarker > > mServicesMarkers = new HashMap<>();
+ private Map< String, List< IMogoMarker > > mServicesMarkers = new ConcurrentHashMap<>();
private MogoMarkersHandler() {
}
diff --git a/libraries/mogo-map-api/src/main/res/drawable-ldpi/map_api_ic_current_location2.png b/libraries/mogo-map-api/src/main/res/drawable-ldpi/map_api_ic_current_location2.png
index 5d2d79c7e5..5f91be07f3 100644
Binary files a/libraries/mogo-map-api/src/main/res/drawable-ldpi/map_api_ic_current_location2.png and b/libraries/mogo-map-api/src/main/res/drawable-ldpi/map_api_ic_current_location2.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-mdpi/map_api_ic_current_location2.png b/libraries/mogo-map-api/src/main/res/drawable-mdpi/map_api_ic_current_location2.png
index 5d2d79c7e5..5f91be07f3 100644
Binary files a/libraries/mogo-map-api/src/main/res/drawable-mdpi/map_api_ic_current_location2.png and b/libraries/mogo-map-api/src/main/res/drawable-mdpi/map_api_ic_current_location2.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xhdpi-1920x1000/map_api_ic_current_location2.png b/libraries/mogo-map-api/src/main/res/drawable-xhdpi-1920x1000/map_api_ic_current_location2.png
index 06fb9a934e..c24c56f3db 100644
Binary files a/libraries/mogo-map-api/src/main/res/drawable-xhdpi-1920x1000/map_api_ic_current_location2.png and b/libraries/mogo-map-api/src/main/res/drawable-xhdpi-1920x1000/map_api_ic_current_location2.png differ
diff --git a/libraries/mogo-tanlu-api/src/main/java/com/zhidao/mogo/tanlu/api/MogoTanluApiProvider.java b/libraries/mogo-tanlu-api/src/main/java/com/zhidao/mogo/tanlu/api/MogoTanluApiProvider.java
index 3cf0f80644..b5aa2b650d 100644
--- a/libraries/mogo-tanlu-api/src/main/java/com/zhidao/mogo/tanlu/api/MogoTanluApiProvider.java
+++ b/libraries/mogo-tanlu-api/src/main/java/com/zhidao/mogo/tanlu/api/MogoTanluApiProvider.java
@@ -3,15 +3,10 @@ package com.zhidao.mogo.tanlu.api;
import android.content.Context;
import android.util.ArrayMap;
-import androidx.annotation.NonNull;
-
import com.alibaba.android.arouter.facade.annotation.Route;
-import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.commons.analytics.AnalyticsUtils;
-import com.mogo.service.IMogoServiceApis;
-import com.mogo.service.MogoServicePaths;
-import com.mogo.service.tanlu.IMogoTanluProvider;
-import com.mogo.service.tanlu.TanluUploadParams;
+import com.mogo.service.share.IMogoTanluProvider;
+import com.mogo.service.share.TanluUploadParams;
import com.mogo.utils.logger.Logger;
import com.zhidao.roadcondition.service.MainService;
import com.zhidao.roadcondition.service.UploadParams;
diff --git a/libraries/tanlulib/build.gradle b/libraries/tanlulib/build.gradle
index de83c92c42..1dd83ed55b 100644
--- a/libraries/tanlulib/build.gradle
+++ b/libraries/tanlulib/build.gradle
@@ -46,12 +46,11 @@ dependencies {
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.6.0'
implementation 'com.zhidaoauto.controller:api:1.0.8'
- implementation 'com.zhidao.cosupload:cosuploadsdk:1.1.6'
+ implementation 'com.zhidao.cosupload:cosuploadsdk:1.1.6', {
+ exclude group: 'com.zhidao.utils', module: 'utils'
+ }
implementation 'com.zhidao.video:video-processor:1.0.2.1'
implementation 'com.foundation.utils:common-utils:1.0.7'
-
- implementation rootProject.ext.dependencies.eventbus
- compileOnly rootProject.ext.dependencies.mogocommons
implementation rootProject.ext.dependencies.eventbus
implementation rootProject.ext.dependencies.coroutinescore
implementation rootProject.ext.dependencies.coroutinesandroid
@@ -60,9 +59,16 @@ dependencies {
implementation rootProject.ext.dependencies.gson
implementation rootProject.ext.dependencies.rxjava
implementation rootProject.ext.dependencies.rxandroid
- compileOnly rootProject.ext.dependencies.mogomap
implementation rootProject.ext.dependencies.aspectj
implementation rootProject.ext.dependencies.analytics
+
+ if (Boolean.valueOf(RELEASE)) {
+ compileOnly rootProject.ext.dependencies.mogocommons
+ compileOnly rootProject.ext.dependencies.mogomap
+ } else {
+ implementation project(':modules:mogo-module-common')
+ implementation project(':libraries:mogo-map')
+ }
}
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
diff --git a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CosStatusController.kt b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CosStatusController.kt
index b46e500568..62b9193271 100644
--- a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CosStatusController.kt
+++ b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CosStatusController.kt
@@ -92,9 +92,9 @@ class CosStatusController : CosStatusCallback {
) {
// VoiceController.speakVoice("cos上报失败")
Log.d(TAG, "uploadCosFailed mType = $mType")
- if (entity?.isCustom && mFromType != UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO) {
- sendGetInfoFailedReceiver("100")
- }
+// if (entity?.isCustom && mFromType != UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO) {
+// sendGetInfoFailedReceiver("100")
+// }
}
if (!isRetry) {
@@ -227,9 +227,9 @@ class CosStatusController : CosStatusCallback {
}
}
} else {
- if (type == INFO_TYPE_VIDEO) {
- TipToast.shortTip("分享失败,请检查网络")
- }
+// if (type == INFO_TYPE_VIDEO) {
+// TipToast.shortTip("分享失败,请检查网络")
+// }
}
}
diff --git a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/MainService.kt b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/MainService.kt
index bdd3f12d19..7909e83a62 100644
--- a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/MainService.kt
+++ b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/MainService.kt
@@ -11,10 +11,14 @@ import android.os.IBinder
import android.util.Log
import com.elegant.analytics.Analytics
import com.mogo.commons.AbsMogoApplication
-import com.mogo.commons.debug.DebugConfig
+import com.mogo.utils.logger.Logger
+import com.mogo.utils.storage.SharedPrefsMgr
import com.zhidao.cosupload.manager.CosUploadManagerImpl
import com.zhidao.roadcondition.BuildConfig
-import com.zhidao.roadcondition.constant.*
+import com.zhidao.roadcondition.constant.DEFAULT_VIDEO_DURATION
+import com.zhidao.roadcondition.constant.TANLU_ROAD_CURRENT
+import com.zhidao.roadcondition.constant.UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO
+import com.zhidao.roadcondition.constant.UPLOAD_FROM_STRATEGY_BLOCK_AUTO
import com.zhidao.roadcondition.event.GetImageSuccessEvent
import com.zhidao.roadcondition.event.LatLngStickyEventBus
import com.zhidao.roadcondition.util.*
@@ -200,18 +204,18 @@ class MainService : Service() {
}
private fun sendMarkerInfoReceiver(lat: Double, lon: Double, imageUrl: String?, type: String?) {
- Log.e("MainService", "sendMarkerInfoReceiver ------> type = $type ")
- Log.e("MainService", "sendMarkerInfoReceiver ------> fromType = $fromType ")
- Log.e("MainService", "sendMarkerInfoReceiver ------> isCustom = $isCustom ")
- var intent = Intent()
- intent.action = "com.zhidao.roadcondition.marker.info"
- intent.putExtra("type", type)
- intent.putExtra("imageUrl", imageUrl)
- intent.putExtra("lat", lat)
- intent.putExtra("lon", lon)
- intent.putExtra("custom", isCustom)
- intent.putExtra("fromType", fromType)
- sendBroadcast(intent)
+// Log.e("MainService", "sendMarkerInfoReceiver ------> type = $type ")
+// Log.e("MainService", "sendMarkerInfoReceiver ------> fromType = $fromType ")
+// Log.e("MainService", "sendMarkerInfoReceiver ------> isCustom = $isCustom ")
+// var intent = Intent()
+// intent.action = "com.zhidao.roadcondition.marker.info"
+// intent.putExtra("type", type)
+// intent.putExtra("imageUrl", imageUrl)
+// intent.putExtra("lat", lat)
+// intent.putExtra("lon", lon)
+// intent.putExtra("custom", isCustom)
+// intent.putExtra("fromType", fromType)
+// sendBroadcast(intent)
}
/**
@@ -221,12 +225,16 @@ class MainService : Service() {
//开始开始监听速度,只要超过一次5公里每小时则即开始获取策略进行本地上报 只有release才加此判断,qa环境方便测试
LocationUtil.getInstance().setonSpeedlistenner(object : LocationUtil.SpeedListener {
override fun onSpeedGet(speed: Float) {
- if (speed > (5 / 3.6f) && !isGetStrategies) {
- mainServiceHttpModel.initStrategies {
- handleReportStrategy()
+ var isOpen = SharedPrefsMgr.getInstance(AbsMogoApplication.getApp().applicationContext).getBoolean("KEY_SERVER_REPORTSTRATEGY_SWITCH", false)
+ Logger.d("EntrancePresenter", " -------- isOpen = $isOpen")
+ if (isOpen) {
+ if (speed > (5 / 3.6f) && !isGetStrategies) {
+ mainServiceHttpModel.initStrategies {
+ handleReportStrategy()
+ }
+ Log.d("MainService", "initLocationListener more than 5 start upload speed = $speed")
+ isGetStrategies = true
}
- Log.d("MainService", "initLocationListener more than 5 start upload speed = $speed")
- isGetStrategies = true
}
}
})
diff --git a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/MainServiceController.kt b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/MainServiceController.kt
index 64eb300bb4..19e07a22be 100644
--- a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/MainServiceController.kt
+++ b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/MainServiceController.kt
@@ -264,20 +264,23 @@ class MainServiceController {
longitude: Double,
latitude: Double
) {
- Log.d(TAG, " geoLocation -- poiType = $poiType");
+ Log.d(TAG, " geoLocation -- poiType = $poiType")
LocationUtil.getInstance()
.geoCodeLocation(locationInfo.toLatLngPoint(), { locInfo: LocationInfo ->
+ Log.d(TAG, "geoLocation -------start -->")
postInformationMessage(
getInformationBody(type, url, locationInfo, isCustom, trafficInfoType, isShare, poiType,mainInfoId,longitude,latitude),
customSend
)
}, {
//转换失败的情况下再重试一次
+ Log.d(TAG, "geoLocation -------true-->")
geoRetryed = if (!geoRetryed) {
geoLocation(type, url, locationInfo, isCustom, trafficInfoType, isShare, customSend, poiType,mainInfoId,longitude,latitude)
true
} else {
//如果两次都失败,直接上报服务端
+ Log.d(TAG, "geoLocation ---- postInformationMessage ---false-->")
postInformationMessage(
getInformationBody(type, url, locationInfo, isCustom, trafficInfoType, isShare, poiType,mainInfoId,longitude,latitude),
customSend
diff --git a/main-extensions/mogo-module-main-independent/src/main/java/com/zhidao/mogo/module/main/independent/MainIndependentActivity.java b/main-extensions/mogo-module-main-independent/src/main/java/com/zhidao/mogo/module/main/independent/MainIndependentActivity.java
index f3ae390679..53b3136c4a 100644
--- a/main-extensions/mogo-module-main-independent/src/main/java/com/zhidao/mogo/module/main/independent/MainIndependentActivity.java
+++ b/main-extensions/mogo-module-main-independent/src/main/java/com/zhidao/mogo/module/main/independent/MainIndependentActivity.java
@@ -39,7 +39,12 @@ public class MainIndependentActivity extends MainActivity {
eventPanelParams.leftMargin = getResources().getDimensionPixelSize( R.dimen.module_main_entrance_fragment_container_marginLeft );
mEntrance.setLayoutParams( eventPanelParams );
- mLeftShadowFrame.setVisibility(View.VISIBLE);
+ // 事件面板
+ FrameLayout.LayoutParams historyMessagePanelParams = ( ( FrameLayout.LayoutParams ) mEventPanel.getLayoutParams() );
+ historyMessagePanelParams.leftMargin = getResources().getDimensionPixelSize( R.dimen.module_main_entrance_fragment_container_marginLeft );
+ mHistoryMessagePanel.setLayoutParams( historyMessagePanelParams );
+
+ mLeftShadowFrame.setVisibility(View.INVISIBLE);
mApps.setVisibility( View.GONE );
}
@@ -58,7 +63,6 @@ public class MainIndependentActivity extends MainActivity {
}
}
-
@Override
protected void onPause() {
super.onPause();
diff --git a/main-extensions/mogo-module-main-independent/src/main/res/values-ldpi/dimens.xml b/main-extensions/mogo-module-main-independent/src/main/res/values-ldpi/dimens.xml
new file mode 100644
index 0000000000..d25f1c125d
--- /dev/null
+++ b/main-extensions/mogo-module-main-independent/src/main/res/values-ldpi/dimens.xml
@@ -0,0 +1,5 @@
+
+
+ 358px
+ 366px
+
\ No newline at end of file
diff --git a/main-extensions/mogo-module-main-independent/src/main/res/values-mdpi/dimens.xml b/main-extensions/mogo-module-main-independent/src/main/res/values-mdpi/dimens.xml
new file mode 100644
index 0000000000..d25f1c125d
--- /dev/null
+++ b/main-extensions/mogo-module-main-independent/src/main/res/values-mdpi/dimens.xml
@@ -0,0 +1,5 @@
+
+
+ 358px
+ 366px
+
\ No newline at end of file
diff --git a/main-extensions/mogo-module-main-independent/src/main/res/values/dimens.xml b/main-extensions/mogo-module-main-independent/src/main/res/values/dimens.xml
index 7c6006c413..d25f1c125d 100644
--- a/main-extensions/mogo-module-main-independent/src/main/res/values/dimens.xml
+++ b/main-extensions/mogo-module-main-independent/src/main/res/values/dimens.xml
@@ -1,5 +1,5 @@
- 350px
+ 358px
366px
\ No newline at end of file
diff --git a/main-extensions/mogo-module-main-launcher/src/main/java/com/zhidao/mogo/module/main/launcher/MainLauncherActivity.java b/main-extensions/mogo-module-main-launcher/src/main/java/com/zhidao/mogo/module/main/launcher/MainLauncherActivity.java
index 48c9b4c52f..872b5f804f 100644
--- a/main-extensions/mogo-module-main-launcher/src/main/java/com/zhidao/mogo/module/main/launcher/MainLauncherActivity.java
+++ b/main-extensions/mogo-module-main-launcher/src/main/java/com/zhidao/mogo/module/main/launcher/MainLauncherActivity.java
@@ -2,15 +2,18 @@ package com.zhidao.mogo.module.main.launcher;
import android.content.Intent;
import android.os.Bundle;
+import android.os.Process;
import android.text.TextUtils;
import android.view.View;
import androidx.annotation.Nullable;
+import com.mogo.map.uicontroller.EnumMapUI;
import com.mogo.module.extensions.utils.ExtensionsConfig;
import com.mogo.module.main.MainActivity;
import com.mogo.module.main.cards.MogoModulesManager;
import com.mogo.service.intent.IMogoIntentListener;
+import com.mogo.utils.logger.Logger;
/**
* 针对作为Launcher的情况,做个性化操作
@@ -82,4 +85,29 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
protected boolean shouldCloseADASPanelWhenPause() {
return !mIsHomeKeyDown;
}
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ try {
+ // acc off 之后会出现进程还在,但是页面被杀的情况,这个直接杀掉进程,然后让整个进程重启
+ Process.killProcess( Process.myPid() );
+ } catch ( Exception e ) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onMapUiModeChanged( EnumMapUI mapUI ) {
+ super.onMapUiModeChanged( mapUI );
+ Intent intent = new Intent( "com.mogo.style.SKIN_CHANGED" );
+ intent.putExtra( "type", -1 );
+ if ( mapUI == EnumMapUI.Type_Light ) {
+ intent.putExtra( "type", 1 );
+ } else if( mapUI == EnumMapUI.Type_Night ){
+ intent.putExtra( "type", 0 );
+ }
+ sendBroadcast( intent );
+ Logger.d( TAG, "send msg to AI Voice" );
+ }
}
diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppServiceHandler.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppServiceHandler.java
index 4df55c25b6..faa3baec81 100644
--- a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppServiceHandler.java
+++ b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppServiceHandler.java
@@ -1,9 +1,7 @@
package com.mogo.module.apps;
-import com.alibaba.android.arouter.launcher.ARouter;
-import com.mogo.commons.AbsMogoApplication;
+import com.mogo.module.common.MogoApisHandler;
import com.mogo.service.IMogoServiceApis;
-import com.mogo.service.MogoServicePaths;
/**
* author : zyz
@@ -20,7 +18,7 @@ public class AppServiceHandler {
public static IMogoServiceApis getApis() {
if ( mApis == null ) {
- mApis = ( IMogoServiceApis ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICE_APIS ).navigation( AbsMogoApplication.getApp() );
+ mApis = MogoApisHandler.getInstance().getApis();
}
return mApis;
}
diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsPresenter.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsPresenter.java
index ed8d6d9ca8..6d31751c17 100644
--- a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsPresenter.java
+++ b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsPresenter.java
@@ -6,14 +6,12 @@ import androidx.lifecycle.LifecycleOwner;
import com.mogo.commons.mvp.Presenter;
import com.mogo.module.apps.applaunch.AppLaunchFilter;
import com.mogo.module.apps.applaunch.AppLauncher;
-import com.mogo.module.apps.applaunch.CardAppLauncher;
import com.mogo.module.apps.applaunch.GuideShowLauncher;
import com.mogo.module.apps.applaunch.InternalFunctionLauncher;
import com.mogo.module.apps.model.AppInfo;
import com.mogo.module.apps.model.AppsModel;
import com.mogo.module.apps.model.UnScannedApps;
import com.mogo.service.analytics.IMogoAnalytics;
-import com.mogo.service.cardmanager.IMogoCardManager;
import com.mogo.utils.ThreadPoolService;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.logger.Logger;
@@ -38,16 +36,11 @@ public class AppsPresenter extends Presenter< AppsView > {
private IMogoAnalytics mAnalytics;
private AppLaunchFilter mLauncher;
- private IMogoCardManager mCardManager;
-
public AppsPresenter( AppsView view ) {
super( view );
- mCardManager = AppServiceHandler.getApis().getCardManagerApi();
InternalFunctionLauncher internalFunctionLauncher = new InternalFunctionLauncher( getContext() );
- CardAppLauncher cardAppLauncher = new CardAppLauncher( this, mCardManager );
GuideShowLauncher guideShowLauncher = new GuideShowLauncher( AppServiceHandler.getApis().getMapServiceApi().getNavi( getContext() ) );
- internalFunctionLauncher.setNext( cardAppLauncher );
- cardAppLauncher.setNext( guideShowLauncher );
+ internalFunctionLauncher.setNext( guideShowLauncher );
guideShowLauncher.setNext( new AppLauncher() );
mLauncher = internalFunctionLauncher;
}
@@ -217,7 +210,6 @@ public class AppsPresenter extends Presenter< AppsView > {
mView = null;
mLauncher.destroy();
mAnalytics = null;
- mCardManager = null;
if ( mLauncher != null ) {
mLauncher.destroy();
}
diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/applaunch/CardAppLauncher.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/applaunch/CardAppLauncher.java
deleted file mode 100644
index 117dd06cb8..0000000000
--- a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/applaunch/CardAppLauncher.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package com.mogo.module.apps.applaunch;
-
-import android.content.Context;
-
-import com.mogo.module.apps.AppsPresenter;
-import com.mogo.module.apps.model.AppInfo;
-import com.mogo.service.cardmanager.IMogoCardManager;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author congtaowang
- * @since 2020-02-09
- *
- * 描述
- */
-public class CardAppLauncher extends BaseAppLauncher {
-
- private static Map< String, String > sCardApps = new HashMap<>();
-
- static {
- sCardApps.put( "com.zhidao.roadcondition.split", "CARD_TYPE_ROAD_CONDITION" );
- sCardApps.put( "com.zhidao.roadcondition", "CARD_TYPE_ROAD_CONDITION" );
- sCardApps.put( "com.zhidao.imdemo", "CARD_TYPE_CARS_CHATTING" );
- }
-
- private AppsPresenter mAppsPresenter;
- private IMogoCardManager mCardManager;
-
- public CardAppLauncher( AppsPresenter mAppsPresenter, IMogoCardManager mCardManager ) {
- this.mAppsPresenter = mAppsPresenter;
- this.mCardManager = mCardManager;
- }
-
- @Override
- public void launch( Context context, AppInfo appInfo ) {
- if ( getNext() != null ) {
- getNext().launch( context, appInfo );
- }
- }
-
- @Override
- public void destroy() {
- mAppsPresenter = null;
- mCardManager = null;
- if ( getNext() != null ) {
- getNext().destroy();
- setNext( null );
- }
- }
-}
diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/model/AppsModel.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/model/AppsModel.java
index ca43439031..9652cd810b 100644
--- a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/model/AppsModel.java
+++ b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/model/AppsModel.java
@@ -156,7 +156,8 @@ public class AppsModel {
if ( totalPages == 0 ) {
return 0;
} else {
- if ( mPagedApps.get( totalPages - 1 ).size() == AppsConst.TOTAL_SIZE_EACH_PAGE ) {
+ if ( mPagedApps.get( totalPages - 1 ) == null
+ || mPagedApps.get( totalPages - 1 ).size() == AppsConst.TOTAL_SIZE_EACH_PAGE ) {
return totalPages;
} else {
return totalPages - 1;
diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/view/OnAiAssistClickListener.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/view/OnAiAssistClickListener.java
index 032ea2ad8e..5fc98232c2 100644
--- a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/view/OnAiAssistClickListener.java
+++ b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/view/OnAiAssistClickListener.java
@@ -27,10 +27,10 @@ class OnAiAssistClickListener implements View.OnClickListener {
@Override
public void onClick( View v ) {
if ( Devices.isBind() || !DebugConfig.isActiveAIAssistFlag() ) {
- AIAssist.startAssistant( v.getContext() );
+ AIAssist.getInstance( v.getContext() ).startAssistant( v.getContext() );
} else {
if ( mDebugModeOpen ) {
- AIAssist.startAssistant( v.getContext(), 1 );
+ AIAssist.getInstance( v.getContext() ).startAssistant( v.getContext(), 1 );
return;
}
if ( mClickCounter == 0 ) {
@@ -38,7 +38,7 @@ class OnAiAssistClickListener implements View.OnClickListener {
mClickCounter++;
} else {
if ( mClickCounter == TOTAL_CLICK_AMOUNT ) {
- AIAssist.startAssistant( v.getContext(), 2 );
+ AIAssist.getInstance( v.getContext() ).startAssistant( v.getContext(), 2 );
TipToast.shortTip( "开启语音调试" );
mClickCounter = 0;
mLastClickTime = 0L;
diff --git a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/authprovider/biz/MogoAuthorizeProvider.kt b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/authprovider/biz/MogoAuthorizeProvider.kt
index 00261fe76b..dd4df21e58 100644
--- a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/authprovider/biz/MogoAuthorizeProvider.kt
+++ b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/authprovider/biz/MogoAuthorizeProvider.kt
@@ -11,6 +11,7 @@ import com.mogo.map.marker.IMogoMarkerClickListener
import com.mogo.map.navi.IMogoNaviListener
import com.mogo.module.authorize.authprovider.invoke.AuthorizeConstant.Companion.PATH_AGREEMENT_MODULE_NAME
import com.mogo.module.authorize.authprovider.invoke.AuthorizeInvokerConstant.Companion.AUTHORIZE_TYPE_LAUNCHER_MAIN
+import com.mogo.module.authorize.authprovider.launcher.MogoMainAuthorize
import com.mogo.module.authorize.authprovider.launcher.MogoMainAuthorize.Companion.mogoAuthShow
import com.mogo.module.authorize.util.SharedPreferenceUtil.hasGuide
import com.mogo.service.MogoServicePaths
@@ -91,4 +92,8 @@ class MogoAuthorizeProvider : IMogoAuthManager {
return null
}
+ override fun onDestroy() {
+ mContext = null
+ mogoAuthShow.release()
+ }
}
\ No newline at end of file
diff --git a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/authprovider/launcher/MogoMainAuthorize.kt b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/authprovider/launcher/MogoMainAuthorize.kt
index 681ffbd91e..4b527dc993 100644
--- a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/authprovider/launcher/MogoMainAuthorize.kt
+++ b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/authprovider/launcher/MogoMainAuthorize.kt
@@ -2,6 +2,7 @@ package com.mogo.module.authorize.authprovider.launcher
import android.content.Context
import android.os.Looper
+import com.mogo.commons.context.ContextHolderUtil
import com.mogo.module.authorize.authprovider.biz.MogoAuthorizeManagerImpl
import com.mogo.module.authorize.authprovider.biz.MogoAuthorizeRegisterHandler
import com.mogo.module.authorize.authprovider.invoke.AuthorizeInvokerConstant.Companion.AUTHORIZE_TYPE_LAUNCHER_MAIN
@@ -82,7 +83,7 @@ class MogoMainAuthorize private constructor() : MogoAuthorizeManagerImpl(), IMog
return
}
if (authorizeDialog == null) {
- authorizeDialog = AuthorizeDialog(tag, mContext!!)
+ authorizeDialog = AuthorizeDialog(tag, ContextHolderUtil.getContext() ?: mContext!!)
authorizeDialog!!.setOnDismissListener {
authorizeDialog = null
}
@@ -96,4 +97,8 @@ class MogoMainAuthorize private constructor() : MogoAuthorizeManagerImpl(), IMog
}
}
+ fun release(){
+ mContext = null
+ }
+
}
\ No newline at end of file
diff --git a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/authprovider/module/MogoModuleAuthorize.kt b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/authprovider/module/MogoModuleAuthorize.kt
index c6061c6e64..33361ceba2 100644
--- a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/authprovider/module/MogoModuleAuthorize.kt
+++ b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/authprovider/module/MogoModuleAuthorize.kt
@@ -6,7 +6,6 @@ import com.mogo.module.authorize.authprovider.biz.MogoAuthorizeManagerImpl
import com.mogo.module.authorize.authprovider.biz.MogoAuthorizeRegisterHandler
import com.mogo.module.authorize.authprovider.launcher.MogoMainAuthorize.Companion.mogoAuthShow
import com.mogo.module.authorize.util.SharedPreferenceUtil
-import com.mogo.module.authorize.util.isDeviceOfD
import com.mogo.service.module.IMogoModuleProvider
class MogoModuleAuthorize private constructor() : MogoAuthorizeManagerImpl(), IMogoAuthorizeModuleProvider {
@@ -22,7 +21,7 @@ class MogoModuleAuthorize private constructor() : MogoAuthorizeManagerImpl(), IM
}
override fun invokeAuthorization(tag: String) {
- if(isDeviceOfD() && !SharedPreferenceUtil.hasGuide()){
+ if(!SharedPreferenceUtil.hasGuide()){
val guideService = ARouter.getInstance().build("/guide/showFragment").navigation()
if(guideService is IMogoModuleProvider){
guideService.init(AbsMogoApplication.getApp().applicationContext)
diff --git a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/layout/AuthorizeDialog.kt b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/layout/AuthorizeDialog.kt
index abe1cd043a..5a428731f6 100644
--- a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/layout/AuthorizeDialog.kt
+++ b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/layout/AuthorizeDialog.kt
@@ -1,7 +1,6 @@
package com.mogo.module.authorize.layout
import android.content.Context
-import android.graphics.drawable.ColorDrawable
import android.text.Html
import android.view.View
import android.widget.Button
@@ -207,4 +206,9 @@ class AuthorizeDialog : BaseFloatDialog, View.OnClickListener, IVoiceCommandList
showAuthorizationError()
})
}
+
+ override fun dismiss() {
+ super.dismiss()
+ mContext = null
+ }
}
\ No newline at end of file
diff --git a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/util/DeviceUtil.kt b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/util/DeviceUtil.kt
deleted file mode 100644
index 8884512894..0000000000
--- a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/util/DeviceUtil.kt
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.mogo.module.authorize.util
-
-import com.mogo.module.common.utils.CarSeries.*
-
-fun isDeviceOfD(): Boolean {
- return when (getSeries()) {
- CAR_SERIES_D80X, CAR_SERIES_D81X, CAR_SERIES_D82X, CAR_SERIES_D84X -> true
- else -> false
- }
-}
\ No newline at end of file
diff --git a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/util/SharedPreferenceUtil.kt b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/util/SharedPreferenceUtil.kt
index 6418cae142..9262e0184b 100644
--- a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/util/SharedPreferenceUtil.kt
+++ b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/util/SharedPreferenceUtil.kt
@@ -1,7 +1,7 @@
package com.mogo.module.authorize.util
import com.mogo.commons.AbsMogoApplication
-import com.mogo.commons.debug.DebugConfig.getSpGuide
+import com.mogo.module.common.utils.SPConst.getSpGuide
import com.mogo.utils.storage.SharedPrefsMgr
object SharedPreferenceUtil {
diff --git a/modules/mogo-module-back/src/main/java/com/mogo/module/back/BackToLauncherModuleProvider.java b/modules/mogo-module-back/src/main/java/com/mogo/module/back/BackToLauncherModuleProvider.java
index c03d6944b3..2b5bce827c 100644
--- a/modules/mogo-module-back/src/main/java/com/mogo/module/back/BackToLauncherModuleProvider.java
+++ b/modules/mogo-module-back/src/main/java/com/mogo/module/back/BackToLauncherModuleProvider.java
@@ -8,15 +8,10 @@ import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import com.alibaba.android.arouter.facade.annotation.Route;
-import com.alibaba.android.arouter.launcher.ARouter;
-import com.mogo.map.listener.IMogoMapListener;
-import com.mogo.map.location.IMogoLocationListener;
-import com.mogo.map.marker.IMogoMarkerClickListener;
-import com.mogo.map.navi.IMogoNaviListener;
+import com.mogo.commons.debug.DebugConfig;
+import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.utils.CarSeries;
import com.mogo.service.IMogoServiceApis;
-import com.mogo.service.MogoServicePaths;
-import com.mogo.service.module.IMogoModuleLifecycle;
import com.mogo.service.module.IMogoModuleProvider;
import com.mogo.service.module.ModuleType;
@@ -56,10 +51,21 @@ public class BackToLauncherModuleProvider implements IMogoModuleProvider {
@Override
public void init( Context context ) {
- if ( CarSeries.getSeries() == CarSeries.CAR_SERIES_F80X ) {
- BackToMainHomeManager.addMainHomeView();
+ final String product = DebugConfig.getProductFlavor();
+ if ( product != null ) {
+ switch ( product ) {
+ case "f80x":
+ case "f8xx":
+ BackToMainHomeManager.addMainHomeView();
+ break;
+ case "changanauto":
+ if ( DebugConfig.isDebug() ) {
+ BackToMainHomeManager.addMainHomeView();
+ }
+ break;
+ }
}
- mServiceApis = ( IMogoServiceApis ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICE_APIS ).navigation();
+ mServiceApis = MogoApisHandler.getInstance().getApis();
BackToMainHomeManager.init( mServiceApis );
}
}
diff --git a/modules/mogo-module-back/src/main/java/com/mogo/module/back/BackToMainHomeManager.java b/modules/mogo-module-back/src/main/java/com/mogo/module/back/BackToMainHomeManager.java
index ea748c53fe..26dbe1f40e 100644
--- a/modules/mogo-module-back/src/main/java/com/mogo/module/back/BackToMainHomeManager.java
+++ b/modules/mogo-module-back/src/main/java/com/mogo/module/back/BackToMainHomeManager.java
@@ -63,7 +63,7 @@ public class BackToMainHomeManager {
.size( WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT )
.gravity( Gravity.LEFT | Gravity.TOP )
.showInWindowManager();
- mWindowManagerView.attachTouchEvent( view -> {
+ mWindowManagerView.attachTouchEvent( (view, xPos, yPos) -> {
backToLauncher();
} );
}
diff --git a/modules/mogo-module-common/build.gradle b/modules/mogo-module-common/build.gradle
index c3f39b9c50..bf000cacf7 100644
--- a/modules/mogo-module-common/build.gradle
+++ b/modules/mogo-module-common/build.gradle
@@ -32,6 +32,8 @@ dependencies {
implementation rootProject.ext.dependencies.androidxappcompat
implementation rootProject.ext.dependencies.androidxrecyclerview
implementation rootProject.ext.dependencies.androidxconstraintlayout
+ implementation rootProject.ext.dependencies.arouter
+ implementation rootProject.ext.dependencies.carcallprovider
if (Boolean.valueOf(RELEASE)) {
api rootProject.ext.dependencies.mogomap
api rootProject.ext.dependencies.mogomapapi
diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/MogoApisHandler.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/MogoApisHandler.java
new file mode 100644
index 0000000000..1fc4db92be
--- /dev/null
+++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/MogoApisHandler.java
@@ -0,0 +1,52 @@
+package com.mogo.module.common;
+
+import com.alibaba.android.arouter.launcher.ARouter;
+import com.mogo.service.IMogoServiceApis;
+
+/**
+ * @author congtaowang
+ * @since 2020/9/21
+ *
+ * 描述
+ */
+public final class MogoApisHandler {
+
+ private IMogoServiceApis sApis;
+
+ private static volatile MogoApisHandler sInstance;
+
+ private MogoApisHandler() {
+ sApis = ARouter.getInstance().navigation( IMogoServiceApis.class );
+ }
+
+ public static MogoApisHandler getInstance() {
+ if ( sInstance == null ) {
+ synchronized ( MogoApisHandler.class ) {
+ if ( sInstance == null ) {
+ sInstance = new MogoApisHandler();
+ }
+ }
+ }
+ return sInstance;
+ }
+
+ public synchronized void release() {
+ sInstance = null;
+ }
+
+ private Object readResolve() {
+ // 阻止反序列化,必须实现 Serializable 接口
+ return sInstance;
+ }
+
+ public IMogoServiceApis getApis() {
+ if ( sApis == null ) {
+ synchronized ( this ) {
+ if ( sApis != null ) {
+ sApis = ARouter.getInstance().navigation( IMogoServiceApis.class );
+ }
+ }
+ }
+ return sApis;
+ }
+}
diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/animation/Animation.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/animation/Animation.java
similarity index 58%
rename from modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/animation/Animation.java
rename to modules/mogo-module-common/src/main/java/com/mogo/module/common/animation/Animation.java
index a91503d370..3c0981fe05 100644
--- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/animation/Animation.java
+++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/animation/Animation.java
@@ -1,4 +1,4 @@
-package com.mogo.module.v2x.utils.animation;
+package com.mogo.module.common.animation;
interface Animation {
diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/animation/V2XAnimationManager.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/animation/AnimationManager.java
similarity index 93%
rename from modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/animation/V2XAnimationManager.java
rename to modules/mogo-module-common/src/main/java/com/mogo/module/common/animation/AnimationManager.java
index 94a760dd65..b0732a7d97 100644
--- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/animation/V2XAnimationManager.java
+++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/animation/AnimationManager.java
@@ -1,13 +1,12 @@
-package com.mogo.module.v2x.utils.animation;
+package com.mogo.module.common.animation;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.view.View;
-import android.widget.ImageView;
import android.widget.ProgressBar;
-public class V2XAnimationManager implements Animation {
+public class AnimationManager implements Animation {
private static final String TAG = "V2XAnimationManager";
private ProgressBar targetImageView;
diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/animation/AnimationResources.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/animation/AnimationResources.java
similarity index 94%
rename from modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/animation/AnimationResources.java
rename to modules/mogo-module-common/src/main/java/com/mogo/module/common/animation/AnimationResources.java
index fc6970f275..8919d777e6 100644
--- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/animation/AnimationResources.java
+++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/animation/AnimationResources.java
@@ -1,7 +1,7 @@
-package com.mogo.module.v2x.utils.animation;
+package com.mogo.module.common.animation;
-import com.mogo.module.v2x.R;
+import com.mogo.module.common.R;
public class AnimationResources {
public static final int loadingRes[] = {
diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/animation/DelegateDrawable.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/animation/DelegateDrawable.java
similarity index 91%
rename from modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/animation/DelegateDrawable.java
rename to modules/mogo-module-common/src/main/java/com/mogo/module/common/animation/DelegateDrawable.java
index 0959e58281..b9ed974cf5 100644
--- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/animation/DelegateDrawable.java
+++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/animation/DelegateDrawable.java
@@ -1,4 +1,4 @@
-package com.mogo.module.v2x.utils.animation;
+package com.mogo.module.common.animation;
import android.graphics.drawable.AnimationDrawable;
diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/api/CallChatApi.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/api/CallChatApi.java
new file mode 100644
index 0000000000..c8fdd220bc
--- /dev/null
+++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/api/CallChatApi.java
@@ -0,0 +1,81 @@
+package com.mogo.module.common.api;
+
+import android.content.Context;
+
+import com.alibaba.android.arouter.launcher.ARouter;
+import com.mogo.module.carchattingprovider.ICarsChattingProvider;
+import com.mogo.module.common.entity.MarkerOnlineCar;
+import com.mogo.utils.logger.Logger;
+import com.zhidao.carchattingprovider.MogoDriverInfo;
+
+public
+/**
+ * @author congtaowang
+ * @since 2020/9/24
+ *
+ * 车聊聊接口
+ */
+class CallChatApi {
+
+ private static final String TAG = "CallChatApi";
+
+ private static volatile CallChatApi sInstance;
+
+ private CallChatApi() {
+ mApiProvider = ARouter.getInstance().navigation( ICarsChattingProvider.class );
+ }
+
+ public static CallChatApi getInstance() {
+ if ( sInstance == null ) {
+ synchronized ( CallChatApi.class ) {
+ if ( sInstance == null ) {
+ sInstance = new CallChatApi();
+ }
+ }
+ }
+ return sInstance;
+ }
+
+ public synchronized void release() {
+ sInstance = null;
+ }
+
+ private Object readResolve() {
+ // 阻止反序列化,必须实现 Serializable 接口
+ return sInstance;
+ }
+
+ public ICarsChattingProvider getApiProvider() {
+ return mApiProvider;
+ }
+
+ private ICarsChattingProvider mApiProvider;
+
+ public void showUserWindow( Context context, MarkerOnlineCar onlineCar ) throws Exception {
+ if ( mApiProvider == null ) {
+ Logger.e( TAG, "no call chat api instance." );
+ return;
+ }
+ MogoDriverInfo driverInfo = new MogoDriverInfo();
+ driverInfo.setAge( onlineCar.getUserInfo().getAgeNumber() );
+ driverInfo.setCarTypeName( onlineCar.getCarInfo().getCarTypeName() );
+ driverInfo.setGender( onlineCar.getUserInfo().getGender() );
+ driverInfo.setLat( onlineCar.getLocation().getLat() );
+ driverInfo.setLon( onlineCar.getLocation().getLon() );
+ driverInfo.setLocationInfo( onlineCar.getLocation().getAddress() );
+ driverInfo.setSn( onlineCar.getUserInfo().getSn() );
+ driverInfo.setUserHead( onlineCar.getUserInfo().getUserHead() );
+ driverInfo.setUserName( onlineCar.getUserInfo().getUserName() );
+ mApiProvider.showUserWindow( TAG, driverInfo, context );
+ }
+
+ public void hideUserWindow( Context context ) {
+ if ( mApiProvider != null ) {
+ if ( mApiProvider == null ) {
+ Logger.e( TAG, "no call chat api instance." );
+ return;
+ }
+ }
+ mApiProvider.hideUserWindow( TAG, context, null );
+ }
+}
diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XMessageEntity.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XMessageEntity.java
index 40ee54edc5..3da153adb3 100644
--- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XMessageEntity.java
+++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XMessageEntity.java
@@ -33,6 +33,19 @@ public class V2XMessageEntity implements Serializable {
*/
boolean showState;
+ /**
+ * 是否需要判断重复事件
+ * true-判断,false-不判断
+ * 默认需要判断
+ */
+ boolean isNeedCompareSameScenario = true;
+
+ //是否播报tts
+ private boolean onlyShow = false;
+
+ //本机与事件是否连线
+ private boolean needAddLine = true;
+
/**
* 场景具体的数据内容
*/
@@ -54,6 +67,14 @@ public class V2XMessageEntity implements Serializable {
this.showState = showState;
}
+ public boolean isNeedCompareSameScenario() {
+ return isNeedCompareSameScenario;
+ }
+
+ public void setNeedCompareSameScenario(boolean needCompareSameScenario) {
+ isNeedCompareSameScenario = needCompareSameScenario;
+ }
+
public T getContent() {
return content;
}
@@ -76,6 +97,22 @@ public class V2XMessageEntity implements Serializable {
return Objects.hash(type, content);
}
+ public boolean isOnlyShow() {
+ return onlyShow;
+ }
+
+ public void setOnlyShow(boolean onlyShow) {
+ this.onlyShow = onlyShow;
+ }
+
+ public boolean isNeedAddLine() {
+ return needAddLine;
+ }
+
+ public void setNeedAddLine(boolean needAddLine) {
+ this.needAddLine = needAddLine;
+ }
+
/**
* V2X 场景类型
*/
diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XRoadEventEntity.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XRoadEventEntity.java
index 2546f5bebf..80039b4244 100644
--- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XRoadEventEntity.java
+++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XRoadEventEntity.java
@@ -24,6 +24,7 @@ public class V2XRoadEventEntity implements Serializable {
private MarkerExploreWay noveltyInfo;
// tts 提示
private String tts;
+
// ADAS 展示文案
private String alarmContent;
// 距离当前车辆的距离
diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/map/MapCenterPointStrategy.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/map/MapCenterPointStrategy.java
index 1d4cdb1e0b..c117f81214 100644
--- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/map/MapCenterPointStrategy.java
+++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/map/MapCenterPointStrategy.java
@@ -1,7 +1,7 @@
package com.mogo.module.common.map;
+import com.mogo.commons.debug.DebugConfig;
import com.mogo.map.uicontroller.IMogoMapUIController;
-import com.mogo.module.common.utils.CarSeries;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.logger.Logger;
@@ -18,112 +18,102 @@ public class MapCenterPointStrategy {
private static final String TAG = "MapCenterPointStrategy";
- private static Map< Integer, Map< Integer, MapCenterPoint > > sStrategies = new HashMap<>();
+ private static Map< Integer, Map< String, MapCenterPoint > > sStrategies = new HashMap<>();
public static final MapCenterPoint DEFAULT = new MapCenterPoint( 0.677734D, 0.5733333D );
- private static MapCenterPoint sLastPoint = DEFAULT;
-
public static void init() {
{
// 选点场景,定位中心点
- Map< Integer, MapCenterPoint > choosePoint = new HashMap<>();
- choosePoint.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.5D, 0.5D ) );
- choosePoint.put( CarSeries.CAR_SERIES_E84X, new MapCenterPoint( 0.5D, 0.5D ) );
- choosePoint.put( CarSeries.CAR_SERIES_E84XCD, new MapCenterPoint( 0.5D, 0.5D ) );
- choosePoint.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.5D, 0.5D ) );
+ Map< String, MapCenterPoint > choosePoint = new HashMap<>();
+ choosePoint.put( "d80x", new MapCenterPoint( 0.5D, 0.5D ) );
+ choosePoint.put( "em4", new MapCenterPoint( 0.5D, 0.5D ) );
+ choosePoint.put( "e8xx", new MapCenterPoint( 0.5D, 0.5D ) );
+ choosePoint.put( "f80x", new MapCenterPoint( 0.5D, 0.5D ) );
+ choosePoint.put( "f8xx", new MapCenterPoint( 0.5D, 0.5D ) );
sStrategies.put( Scene.CHOOSE_POINT, choosePoint );
}
{
// 导航场景,定位视图右下角偏下
- Map< Integer, MapCenterPoint > navi = new HashMap<>();
- navi.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.669444444444444, 0.573333333333D ) );
- navi.put( CarSeries.CAR_SERIES_E84X, new MapCenterPoint( 0.734375D, 0.573333333333D ) );
- navi.put( CarSeries.CAR_SERIES_E84XCD, new MapCenterPoint( 0.734375D, 0.573333333333D ) );
- navi.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.705208333D, 0.575D ) );
+ Map< String, MapCenterPoint > navi = new HashMap<>();
+ navi.put( "d80x", new MapCenterPoint( 0.669444444444444, 0.573333333333D ) );
+ navi.put( "em4", new MapCenterPoint( 0.734375D, 0.573333333333D ) );
+ navi.put( "e8xx", new MapCenterPoint( 0.734375D, 0.573333333333D ) );
+ navi.put( "f80x", new MapCenterPoint( 0.705208333D, 0.575D ) );
+ navi.put( "f8xx", new MapCenterPoint( 0.705208333D, 0.575D ) );
sStrategies.put( Scene.NAVI, navi );
}
{
// 导航场景 vs 道路事件展示场景,定位视图右下角偏下
- Map< Integer, MapCenterPoint > naviWithRoadEvent = new HashMap<>();
- naviWithRoadEvent.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.669444444444444, 0.73936170212766D ) );
- naviWithRoadEvent.put( CarSeries.CAR_SERIES_E84X, new MapCenterPoint( 0.734375D, 0.73936170212766D ) );
- naviWithRoadEvent.put( CarSeries.CAR_SERIES_E84XCD, new MapCenterPoint( 0.734375D, 0.73936170212766D ) );
- naviWithRoadEvent.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.705208333D, 0.683333333333D ) );
+ Map< String, MapCenterPoint > naviWithRoadEvent = new HashMap<>();
+ naviWithRoadEvent.put( "d80x", new MapCenterPoint( 0.669444444444444, 0.73936170212766D ) );
+ naviWithRoadEvent.put( "em4", new MapCenterPoint( 0.734375D, 0.73936170212766D ) );
+ naviWithRoadEvent.put( "e8xx", new MapCenterPoint( 0.734375D, 0.73936170212766D ) );
+ naviWithRoadEvent.put( "f80x", new MapCenterPoint( 0.705208333D, 0.683333333333D ) );
+ naviWithRoadEvent.put( "f8xx", new MapCenterPoint( 0.705208333D, 0.683333333333D ) );
sStrategies.put( Scene.NAVI_WITH_ROAD_EVENT, naviWithRoadEvent );
}
{
// 巡航场景
- Map< Integer, MapCenterPoint > aimless = new HashMap<>();
- aimless.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.669444444444444, 0.5D ) );
- aimless.put( CarSeries.CAR_SERIES_E84X, new MapCenterPoint( 0.734375D, 0.5D ) );
- aimless.put( CarSeries.CAR_SERIES_E84XCD, new MapCenterPoint( 0.734375D, 0.5D ) );
- aimless.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.705208333D, 0.5D ) );
+ Map< String, MapCenterPoint > aimless = new HashMap<>();
+ aimless.put( "d80x", new MapCenterPoint( 0.669444444444444, 0.5D ) );
+ aimless.put( "em4", new MapCenterPoint( 0.734375D, 0.5D ) );
+ aimless.put( "e8xx", new MapCenterPoint( 0.734375D, 0.5D ) );
+ aimless.put( "f80x", new MapCenterPoint( 0.705208333D, 0.5D ) );
+ aimless.put( "f8xx", new MapCenterPoint( 0.705208333D, 0.5D ) );
sStrategies.put( Scene.AIMLESS, aimless );
}
{
// 巡航场景 vs 道路事件展示场景
- Map< Integer, MapCenterPoint > aimlessWithRoadEvent = new HashMap<>();
- aimlessWithRoadEvent.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.669444444444444, 0.68617 ) );
- aimlessWithRoadEvent.put( CarSeries.CAR_SERIES_E84X, new MapCenterPoint( 0.734375D, 0.68617 ) );
- aimlessWithRoadEvent.put( CarSeries.CAR_SERIES_E84XCD, new MapCenterPoint( 0.734375D, 0.68617 ) );
- aimlessWithRoadEvent.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.705208333D, 0.599074074D ) );
+ Map< String, MapCenterPoint > aimlessWithRoadEvent = new HashMap<>();
+ aimlessWithRoadEvent.put( "d80x", new MapCenterPoint( 0.669444444444444, 0.68617 ) );
+ aimlessWithRoadEvent.put( "em4", new MapCenterPoint( 0.734375D, 0.68617 ) );
+ aimlessWithRoadEvent.put( "e8xx", new MapCenterPoint( 0.734375D, 0.68617 ) );
+ aimlessWithRoadEvent.put( "f80x", new MapCenterPoint( 0.705208333D, 0.599074074D ) );
+ aimlessWithRoadEvent.put( "f8xx", new MapCenterPoint( 0.705208333D, 0.599074074D ) );
sStrategies.put( Scene.AIMLESS_WITH_ROAD_EVENT, aimlessWithRoadEvent );
}
{
// 规划路线,定位视图右边
- Map< Integer, MapCenterPoint > calculatePath = new HashMap<>();
- calculatePath.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.733398D, 0.610833D ) );
- calculatePath.put( CarSeries.CAR_SERIES_E84X, new MapCenterPoint( 0.733398D, 0.610833D ) );
- calculatePath.put( CarSeries.CAR_SERIES_E84XCD, new MapCenterPoint( 0.733398D, 0.610833D ) );
- calculatePath.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.703125D, 0.6083333D ) );
+ Map< String, MapCenterPoint > calculatePath = new HashMap<>();
+ calculatePath.put( "d80x", new MapCenterPoint( 0.733398D, 0.610833D ) );
+ calculatePath.put( "em4", new MapCenterPoint( 0.733398D, 0.610833D ) );
+ calculatePath.put( "e8xx", new MapCenterPoint( 0.733398D, 0.610833D ) );
+ calculatePath.put( "f80x", new MapCenterPoint( 0.703125D, 0.6083333D ) );
+ calculatePath.put( "f8xx", new MapCenterPoint( 0.703125D, 0.6083333D ) );
sStrategies.put( Scene.CALCULATE_PATH, calculatePath );
}
{
// 分类搜索,定位视图右边
- Map< Integer, MapCenterPoint > categorySearch = new HashMap<>();
- categorySearch.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.733398D, 0.5D ) );
- categorySearch.put( CarSeries.CAR_SERIES_E84X, new MapCenterPoint( 0.733398D, 0.5D ) );
- categorySearch.put( CarSeries.CAR_SERIES_E84XCD, new MapCenterPoint( 0.733398D, 0.5D ) );
- categorySearch.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.733594D, 0.5D ) );
+ Map< String, MapCenterPoint > categorySearch = new HashMap<>();
+ categorySearch.put( "d80x", new MapCenterPoint( 0.733398D, 0.5D ) );
+ categorySearch.put( "em4", new MapCenterPoint( 0.733398D, 0.5D ) );
+ categorySearch.put( "e8xx", new MapCenterPoint( 0.733398D, 0.5D ) );
+ categorySearch.put( "f80x", new MapCenterPoint( 0.733594D, 0.5D ) );
+ categorySearch.put( "f8xx", new MapCenterPoint( 0.733594D, 0.5D ) );
sStrategies.put( Scene.CATEGORY_SEARCH, categorySearch );
}
{
// V2X,场景视图右边
- Map< Integer, MapCenterPoint > categoryV2XEvent = new HashMap<>();
- categoryV2XEvent.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.669444444444444, 0.7D ) );
- categoryV2XEvent.put( CarSeries.CAR_SERIES_E84X, new MapCenterPoint( 0.677734375D, 0.7D ) );
- categoryV2XEvent.put( CarSeries.CAR_SERIES_E84XCD, new MapCenterPoint( 0.677734375D, 0.7D ) );
- categoryV2XEvent.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.6963541D, 0.65D ) );
+ Map< String, MapCenterPoint > categoryV2XEvent = new HashMap<>();
+ categoryV2XEvent.put( "d80x", new MapCenterPoint( 0.669444444444444, 0.7D ) );
+ categoryV2XEvent.put( "em4", new MapCenterPoint( 0.677734375D, 0.7D ) );
+ categoryV2XEvent.put( "e8xx", new MapCenterPoint( 0.677734375D, 0.7D ) );
+ categoryV2XEvent.put( "f80x", new MapCenterPoint( 0.6963541D, 0.65D ) );
+ categoryV2XEvent.put( "f8xx", new MapCenterPoint( 0.6963541D, 0.65D ) );
sStrategies.put( Scene.CATEGORY_V2X_EVENT, categoryV2XEvent );
}
-
- try {
- sLastPoint = sStrategies.get( Scene.AIMLESS ).get( CarSeries.getSeries() );
- } catch ( Exception e ) {
- sLastPoint = DEFAULT;
- }
}
- public static void restoreLastScene( IMogoMapUIController controller ) {
- if ( sLastPoint == null ) {
- return;
- }
- if ( controller == null ) {
- return;
- }
- controller.setPointToCenter( sLastPoint.x, sLastPoint.y );
- }
-
- public static void addScene( int scene, Map< Integer, MapCenterPoint > config ) {
+ public static void addScene( int scene, Map< String, MapCenterPoint > config ) {
if ( sStrategies.containsKey( scene ) ) {
Logger.w( TAG, "scene has already defined, append config..." );
}
@@ -147,25 +137,21 @@ public class MapCenterPointStrategy {
if ( !sStrategies.containsKey( scene ) ) {
Logger.w( TAG, "no strategy for scene: %s, use DEFAULT", scene );
controller.setPointToCenter( DEFAULT.x, DEFAULT.y );
- sLastPoint = DEFAULT;
return;
}
- Map< Integer, MapCenterPoint > points = sStrategies.get( scene );
- int car = CarSeries.getSeries();
+ Map< String, MapCenterPoint > points = sStrategies.get( scene );
+ String car = DebugConfig.getProductFlavor();
if ( !points.containsKey( car ) ) {
Logger.w( TAG, "no strategy for series: %s, use DEFAULT", scene );
controller.setPointToCenter( DEFAULT.x, DEFAULT.y );
- sLastPoint = DEFAULT;
return;
}
MapCenterPoint point = points.get( car );
if ( point == null ) {
Logger.w( TAG, "no strategy config for series: %s, use DEFAULT", scene );
controller.setPointToCenter( DEFAULT.x, DEFAULT.y );
- sLastPoint = DEFAULT;
return;
}
- sLastPoint = point;
controller.setPointToCenter( point.x, point.y );
}
diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/utils/Const.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/utils/Const.java
new file mode 100644
index 0000000000..ff10114899
--- /dev/null
+++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/utils/Const.java
@@ -0,0 +1,10 @@
+package com.mogo.module.common.utils;
+
+public class Const {
+ /**
+ * V2X 场景广播 Action
+ */
+ public static final String BROADCAST_SCENE_HANDLER_ACTION = "com.v2x.scene_handler_broadcast";
+ public static final String BROADCAST_SCENE_EXTRA_KEY = "V2XMessageEntity";
+
+}
diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/utils/SPConst.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/utils/SPConst.java
new file mode 100644
index 0000000000..36ed5551d0
--- /dev/null
+++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/utils/SPConst.java
@@ -0,0 +1,22 @@
+package com.mogo.module.common.utils;
+
+/**
+ * 多模块之间SP状态公共类
+ */
+public class SPConst {
+
+ private static String SP_GUIDE = "SP_GUIDE_2020_09_09";
+
+ //用于多模块之间引导状态判断
+ public static String getSpGuide() {
+ return SP_GUIDE;
+ }
+
+ private static String SP_GUIDE_FIRST_TIME_RECORD = "SP_GUIDE_FIRST_TIME_RECORD";
+
+ //用于多模块之间首次引导时间记录
+ public static String getSPGuideRecord(){
+ return SP_GUIDE_FIRST_TIME_RECORD;
+ }
+
+}
diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/view/CustomRatingBar.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/view/CustomRatingBar.java
new file mode 100644
index 0000000000..f896e216c6
--- /dev/null
+++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/view/CustomRatingBar.java
@@ -0,0 +1,298 @@
+package com.mogo.module.common.view;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.drawable.Drawable;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+
+import androidx.annotation.Nullable;
+import androidx.core.content.ContextCompat;
+
+import com.mogo.module.common.R;
+
+import java.math.BigDecimal;
+
+public class CustomRatingBar extends LinearLayout {
+ private Context mContext;
+ /*
+ 是否可点击
+ * */
+ private boolean mClickable;
+ /*
+ * 单元总数(心形/星星)
+ * */
+ private int elementCount;
+ /*
+ * 单元点击事件
+ * */
+ private OnRatingChangeListener mOnRatingBarChangeListener;
+ /*
+ * 每个单元的大小
+ * */
+ private float elementWidth;
+
+ private float elementHeight;
+
+ public float getElementWidth() {
+ return elementWidth;
+ }
+
+ public void setElementWidth(float elementWidth) {
+ this.elementWidth = elementWidth;
+ }
+
+ public float getElementHeight() {
+ return elementHeight;
+ }
+
+ public void setElementHeight(float elementHeight) {
+ this.elementHeight = elementHeight;
+ }
+
+ /*
+ * 每个单元间的距离
+ * */
+ private float elementPadding;
+ /*
+ *单元的显示数量,支持小数点
+ * */
+ private float elementStep;
+ /*
+ * 空白的默认单元图片
+ * */
+ private Drawable elementEmptyDrawable;
+ /*
+ * 选中后的单元图片
+ * */
+ private Drawable elementFillDrawable;
+ /*
+ * 半颗单元图片
+ * */
+ private Drawable elementHarfDrawable;
+ /*
+ * 每次点击单元所增加的量是半个还是整个
+ * */
+ private StepSize stepSize;
+
+ @Override
+ public boolean isClickable() {
+ return mClickable;
+ }
+
+ @Override
+ public void setClickable(boolean clickable) {
+ mClickable = clickable;
+ }
+
+ public int getElementCount() {
+ return elementCount;
+ }
+
+ public void setElementCount(int elementCount) {
+ this.elementCount = elementCount;
+ }
+
+ public OnRatingChangeListener getOnRatingBarChangeListener() {
+ return mOnRatingBarChangeListener;
+ }
+
+ public void setOnRatingChangeListener(OnRatingChangeListener onRatingBarChangeListener) {
+ mOnRatingBarChangeListener = onRatingBarChangeListener;
+ }
+
+ public float getElementPadding() {
+ return elementPadding;
+ }
+
+ public void setElementPadding(float elementPadding) {
+ this.elementPadding = elementPadding;
+ }
+
+ public float getElementStep() {
+ return elementStep;
+ }
+
+ public void setElementStep(float elementStep) {
+ this.elementStep = elementStep;
+ }
+
+ public Drawable getElementEmptyDrawable() {
+ return elementEmptyDrawable;
+ }
+
+ public void setElementEmptyDrawable(Drawable elementEmptyDrawable) {
+ this.elementEmptyDrawable = elementEmptyDrawable;
+ }
+
+ public Drawable getElementFillDrawable() {
+ return elementFillDrawable;
+ }
+
+ public void setElementFillDrawable(Drawable elementFillDrawable) {
+ this.elementFillDrawable = elementFillDrawable;
+ }
+
+ public Drawable getElementHarfDrawable() {
+ return elementHarfDrawable;
+ }
+
+ public void setElementHarfDrawable(Drawable elementHarfDrawable) {
+ this.elementHarfDrawable = elementHarfDrawable;
+ }
+
+
+ public void setStepSize(StepSize stepSize) {
+ this.stepSize = stepSize;
+ }
+
+ public CustomRatingBar(Context context, @Nullable AttributeSet attrs) {
+ super(context, attrs);
+ mContext = context;
+ setOrientation(LinearLayout.HORIZONTAL);
+ TypedArray mTypedArray = context.obtainStyledAttributes(attrs, R.styleable.CustomRatingBar);
+ elementWidth = mTypedArray.getDimension(R.styleable.CustomRatingBar_elenmentWidth,
+ context.getResources().getDimension(R.dimen.heart_ratingbar_width));
+ elementHeight = mTypedArray.getDimension(R.styleable.CustomRatingBar_elenmentHeight,
+ context.getResources().getDimension(R.dimen.heart_ratingbar_height));
+ elementPadding = mTypedArray.getDimension(R.styleable.CustomRatingBar_elenmentPadding, 10);
+
+ elementStep = mTypedArray.getFloat(R.styleable.CustomRatingBar_elenmentStep, 1.0f);
+ stepSize = StepSize.fromStep(mTypedArray.getInt(R.styleable.CustomRatingBar_stepSize, 1));
+ elementCount = mTypedArray.getInteger(R.styleable.CustomRatingBar_elenmentCount, 5);
+ stepSize = StepSize.Half;
+
+ Drawable drawable_empty_default = ContextCompat.getDrawable(context, R.drawable.icon_heart_unchoose);
+ Drawable drawable_harf_default = ContextCompat.getDrawable(context, R.drawable.icon_heart_second);
+ Drawable drawable_fill_default = ContextCompat.getDrawable(context, R.drawable.icon_heart_choose);
+
+ Drawable drawable_empty = mTypedArray.getDrawable(R.styleable.CustomRatingBar_elenmentEmpty);
+ Drawable drawable_harf = mTypedArray.getDrawable(R.styleable.CustomRatingBar_elenmentHarf);
+ Drawable drawable_fill = mTypedArray.getDrawable(R.styleable.CustomRatingBar_elenmentFill);
+
+ elementEmptyDrawable = drawable_empty != null ? drawable_empty : drawable_empty_default;
+ elementFillDrawable = drawable_harf != null ? drawable_harf : drawable_fill_default;
+ elementHarfDrawable = drawable_fill != null ? drawable_fill : drawable_harf_default;
+ mClickable = mTypedArray.getBoolean(R.styleable.CustomRatingBar_clickable, false);
+ mTypedArray.recycle();
+ for (int i = 0; i < elementCount; ++i) {
+ final ImageView imageView = getElenmentImageView();
+ imageView.setImageDrawable(elementEmptyDrawable);
+ imageView.setOnClickListener(
+ new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (mClickable) {
+ //浮点数的整数部分
+ int fint = (int) elementStep;
+ BigDecimal b1 = new BigDecimal(Float.toString(elementStep));
+ BigDecimal b2 = new BigDecimal(Integer.toString(fint));
+ //浮点数的小数部分
+ float fPoint = b1.subtract(b2).floatValue();
+ if (fPoint == 0) {
+ fint -= 1;
+ }
+
+ if (indexOfChild(v) > fint) {
+ setRating(indexOfChild(v) + 1);
+ } else if (indexOfChild(v) == fint) {
+ if (stepSize == StepSize.Full) {//如果是满星 就不考虑半颗星了
+ return;
+ }
+ //点击之后默认每次先增加一颗星,再次点击变为半颗星
+ if (imageView.getDrawable().getCurrent().getConstantState().
+ equals(elementHarfDrawable.getConstantState())) {
+ setRating(indexOfChild(v) + 1);
+ } else {
+ setRating(indexOfChild(v) + 0.5f);
+ }
+ } else {
+ setRating(indexOfChild(v) + 1f);
+ }
+
+ }
+ }
+ }
+ );
+ addView(imageView);
+ }
+ setRating(elementStep);
+ }
+
+ private ImageView getElenmentImageView() {
+ ImageView imageView = new ImageView(getContext());
+ LayoutParams layout = new LayoutParams(
+ Math.round(mContext.getResources().getDimension(R.dimen.heart_ratingbar_width)),
+ Math.round(mContext.getResources().getDimension(R.dimen.heart_ratingbar_width)));//设置每个单元格在线性布局的大小
+ layout.setMargins(0, 0, Math.round(elementPadding), 0);//设置每颗星星在线性布局的间距
+ imageView.setLayoutParams(layout);
+ imageView.setAdjustViewBounds(true);
+ imageView.setScaleType(ImageView.ScaleType.FIT_XY);
+ imageView.setImageDrawable(elementEmptyDrawable);
+ imageView.setMinimumWidth((int) elementWidth);
+ imageView.setMaxWidth((int) elementWidth);
+ imageView.setMinimumHeight((int) elementHeight);
+ imageView.setMaxHeight((int) elementHeight);
+ return imageView;
+ }
+
+ public void setRating(float rating) {
+ if (rating > elementCount)
+ rating = elementCount;
+
+ if (mOnRatingBarChangeListener != null) {
+ mOnRatingBarChangeListener.onRatingChange(rating);
+ }
+ this.elementStep = rating;
+ //浮点数的整数部分
+ int fint = (int) rating;
+ BigDecimal b1 = new BigDecimal(Float.toString(rating));
+ BigDecimal b2 = new BigDecimal(Integer.toString(fint));
+ //浮点数的小数部分
+ float fPoint = b1.subtract(b2).floatValue();
+
+ //设置选中的单元
+ for (int i = 0; i < fint; ++i) {
+ ((ImageView) getChildAt(i)).setImageDrawable(elementFillDrawable);
+ }
+ //设置没有选中的单元
+ for (int i = fint; i < elementCount; i++) {
+ ((ImageView) getChildAt(i)).setImageDrawable(elementEmptyDrawable);
+ }
+ //小数点默认增加半个
+ if (fPoint > 0) {
+ ((ImageView) getChildAt(fint)).setImageDrawable(elementHarfDrawable);
+ }
+
+
+ }
+
+ public interface OnRatingChangeListener {
+ void onRatingChange(float ratingCount);
+ }
+
+ /**
+ * 每次增加的方式整颗还是半颗,枚举类型
+ * 类似于View.GONE
+ */
+ public enum StepSize {
+ Half(0), Full(1);
+ int step;
+
+ StepSize(int step) {
+ this.step = step;
+ }
+
+ public static StepSize fromStep(int step) {
+ for (StepSize f : values()) {
+ if (f.step == step) {
+ return f;
+ }
+ }
+ throw new IllegalArgumentException();
+ }
+ }
+
+}
diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/V2XNetworkLoadingView.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/view/NetworkLoadingView.java
similarity index 62%
rename from modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/V2XNetworkLoadingView.java
rename to modules/mogo-module-common/src/main/java/com/mogo/module/common/view/NetworkLoadingView.java
index 99a6cbbad7..7a8fad2cf0 100644
--- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/V2XNetworkLoadingView.java
+++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/view/NetworkLoadingView.java
@@ -1,37 +1,36 @@
-package com.mogo.module.v2x.view;
+package com.mogo.module.common.view;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
-import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.Nullable;
-import com.mogo.module.v2x.R;
-import com.mogo.module.v2x.utils.animation.AnimationResources;
-import com.mogo.module.v2x.utils.animation.V2XAnimationManager;
+import com.mogo.module.common.R;
+import com.mogo.module.common.animation.AnimationResources;
+import com.mogo.module.common.animation.AnimationManager;
-public class V2XNetworkLoadingView extends RelativeLayout {
+public class NetworkLoadingView extends RelativeLayout {
private ProgressBar loadView;
private TextView textView;
- private V2XAnimationManager v2XAnimationManager;
+ private AnimationManager mAnimationManager;
public Button refresButton;
private String loadingText = "正在获取信息…";
- public V2XNetworkLoadingView(Context context) {
+ public NetworkLoadingView(Context context) {
super(context);
}
- public V2XNetworkLoadingView(Context context, @Nullable AttributeSet attrs) {
+ public NetworkLoadingView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
- LayoutInflater.from(context).inflate(R.layout.v2x_network_loading_item, this);
+ LayoutInflater.from(context).inflate(R.layout.network_loading_item, this);
initView();
/*
添加动画图片资源
@@ -39,12 +38,12 @@ public class V2XNetworkLoadingView extends RelativeLayout {
setLoadingImage(AnimationResources.loadingRes);
}
- public V2XNetworkLoadingView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
+ public NetworkLoadingView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public void initView() {
- v2XAnimationManager = new V2XAnimationManager();
+ mAnimationManager = new AnimationManager();
loadView = findViewById(R.id.loading_imageview);
textView = findViewById(R.id.loading_text);
refresButton = findViewById(R.id.refresh_button);
@@ -57,12 +56,12 @@ public class V2XNetworkLoadingView extends RelativeLayout {
}
public void setLoadingImage(int[] resources) {
- v2XAnimationManager.animationWithTarget(loadView, resources, 100);
+ mAnimationManager.animationWithTarget(loadView, resources, 100);
}
public void start() {
- if (v2XAnimationManager != null) {
- v2XAnimationManager.start();
+ if (mAnimationManager != null) {
+ mAnimationManager.start();
this.setVisibility(View.VISIBLE);
}
if (refresButton != null) {
@@ -74,15 +73,15 @@ public class V2XNetworkLoadingView extends RelativeLayout {
}
public void stop() {
- if (v2XAnimationManager != null) {
- v2XAnimationManager.stop();
+ if (mAnimationManager != null) {
+ mAnimationManager.stop();
this.setVisibility(GONE);
}
}
public void stopWithError(String errormsg, int showRefreshButton) {
- if (v2XAnimationManager != null) {
- v2XAnimationManager.soptWithError();
+ if (mAnimationManager != null) {
+ mAnimationManager.soptWithError();
}
if (textView != null) {
textView.setText(errormsg);
diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/view/OnPreventFastClickListener.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/view/OnPreventFastClickListener.java
new file mode 100644
index 0000000000..cc87f416d7
--- /dev/null
+++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/view/OnPreventFastClickListener.java
@@ -0,0 +1,39 @@
+package com.mogo.module.common.view;
+
+import android.view.View;
+
+public
+/**
+ * @author congtaowang
+ * @since 2020/9/25
+ *
+ * 防止短时间内多次点击
+ */
+abstract class OnPreventFastClickListener implements View.OnClickListener {
+
+ public static final long INTERVAL = 1_000L;
+
+ private long mInterval;
+ private long mLastClickTime = 0L;
+
+ public OnPreventFastClickListener() {
+ this( INTERVAL );
+ }
+
+ public OnPreventFastClickListener( long interval ) {
+ if ( interval < 0L ) {
+ interval = INTERVAL;
+ }
+ this.mInterval = interval;
+ }
+
+ @Override
+ public final void onClick( View v ) {
+ if ( System.currentTimeMillis() - mLastClickTime > mInterval ) {
+ onClickImpl( v );
+ mLastClickTime = System.currentTimeMillis();
+ }
+ }
+
+ public abstract void onClickImpl( View v );
+}
diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/widget/CustomCircleImageView.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/widget/CustomCircleImageView.java
new file mode 100644
index 0000000000..c743b08a24
--- /dev/null
+++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/widget/CustomCircleImageView.java
@@ -0,0 +1,337 @@
+package com.mogo.module.common.widget;
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.Bitmap;
+import android.graphics.BitmapShader;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.ColorFilter;
+import android.graphics.Matrix;
+import android.graphics.Paint;
+import android.graphics.RectF;
+import android.graphics.Shader;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.ColorDrawable;
+import android.graphics.drawable.Drawable;
+import android.net.Uri;
+import android.util.AttributeSet;
+import android.widget.ImageView;
+
+import androidx.annotation.ColorInt;
+import androidx.annotation.ColorRes;
+import androidx.annotation.DrawableRes;
+
+import com.mogo.module.common.R;
+
+@SuppressLint("AppCompatCustomView")
+public class CustomCircleImageView extends ImageView {
+
+ private static final ScaleType SCALE_TYPE = ScaleType.CENTER_CROP;
+
+ private static final Bitmap.Config BITMAP_CONFIG = Bitmap.Config.ARGB_8888;
+ private static final int COLORDRAWABLE_DIMENSION = 2;
+
+ private static final int DEFAULT_BORDER_WIDTH = 0;
+ private static final int DEFAULT_BORDER_COLOR = Color.BLACK;
+ private static final int DEFAULT_FILL_COLOR = Color.TRANSPARENT;
+ private static final boolean DEFAULT_BORDER_OVERLAY = false;
+
+ private final RectF mDrawableRect = new RectF();
+ private final RectF mBorderRect = new RectF();
+
+ private final Matrix mShaderMatrix = new Matrix();
+ private final Paint mBitmapPaint = new Paint();
+ private final Paint mBorderPaint = new Paint();
+ private final Paint mFillPaint = new Paint();
+
+ private int mBorderColor = DEFAULT_BORDER_COLOR;
+ private int mBorderWidth = DEFAULT_BORDER_WIDTH;
+ private int mFillColor = DEFAULT_FILL_COLOR;
+
+ private Bitmap mBitmap;
+ private BitmapShader mBitmapShader;
+ private int mBitmapWidth;
+ private int mBitmapHeight;
+
+ private float mDrawableRadius;
+ private float mBorderRadius;
+
+ private ColorFilter mColorFilter;
+
+ private boolean mReady;
+ private boolean mSetupPending;
+ private boolean mBorderOverlay;
+
+ public CustomCircleImageView( Context context) {
+ super(context);
+
+ init();
+ }
+
+ public CustomCircleImageView( Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public CustomCircleImageView( Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+
+ TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CustomCircleImageView, defStyle, 0);
+
+ mBorderWidth = a.getDimensionPixelSize(R.styleable.CustomCircleImageView_civ_border_width, DEFAULT_BORDER_WIDTH);
+ mBorderColor = a.getColor(R.styleable.CustomCircleImageView_civ_border_color, DEFAULT_BORDER_COLOR);
+ mBorderOverlay = a.getBoolean(R.styleable.CustomCircleImageView_civ_border_overlay, DEFAULT_BORDER_OVERLAY);
+ mFillColor = a.getColor(R.styleable.CustomCircleImageView_civ_fill_color, DEFAULT_FILL_COLOR);
+
+ a.recycle();
+
+ init();
+ }
+
+ private void init() {
+ super.setScaleType(SCALE_TYPE);
+ mReady = true;
+
+ if (mSetupPending) {
+ setup();
+ mSetupPending = false;
+ }
+ }
+
+ @Override
+ public ScaleType getScaleType() {
+ return SCALE_TYPE;
+ }
+
+ @Override
+ public void setScaleType(ScaleType scaleType) {
+ if (scaleType != SCALE_TYPE) {
+ throw new IllegalArgumentException(String.format("ScaleType %s not supported.", scaleType));
+ }
+ }
+
+ @Override
+ public void setAdjustViewBounds(boolean adjustViewBounds) {
+ if (adjustViewBounds) {
+ throw new IllegalArgumentException("adjustViewBounds not supported.");
+ }
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ if (mBitmap == null) {
+ return;
+ }
+
+ if (mFillColor != Color.TRANSPARENT) {
+ canvas.drawCircle(getWidth() / 2.0f, getHeight() / 2.0f, mDrawableRadius, mFillPaint);
+ }
+ canvas.drawCircle(getWidth() / 2.0f, getHeight() / 2.0f, mDrawableRadius, mBitmapPaint);
+ if (mBorderWidth != 0) {
+ canvas.drawCircle(getWidth() / 2.0f, getHeight() / 2.0f, mBorderRadius, mBorderPaint);
+ }
+ }
+
+ @Override
+ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
+ super.onSizeChanged(w, h, oldw, oldh);
+ setup();
+ }
+
+ public int getBorderColor() {
+ return mBorderColor;
+ }
+
+ public void setBorderColor(@ColorInt int borderColor) {
+ if (borderColor == mBorderColor) {
+ return;
+ }
+
+ mBorderColor = borderColor;
+ mBorderPaint.setColor(mBorderColor);
+ invalidate();
+ }
+
+ public void setBorderColorResource(@ColorRes int borderColorRes) {
+ setBorderColor(getContext().getResources().getColor(borderColorRes));
+ }
+
+ public int getFillColor() {
+ return mFillColor;
+ }
+
+ public void setFillColor(@ColorInt int fillColor) {
+ if (fillColor == mFillColor) {
+ return;
+ }
+
+ mFillColor = fillColor;
+ mFillPaint.setColor(fillColor);
+ invalidate();
+ }
+
+ public void setFillColorResource(@ColorRes int fillColorRes) {
+ setFillColor(getContext().getResources().getColor(fillColorRes));
+ }
+
+ public int getBorderWidth() {
+ return mBorderWidth;
+ }
+
+ public void setBorderWidth(int borderWidth) {
+ if (borderWidth == mBorderWidth) {
+ return;
+ }
+
+ mBorderWidth = borderWidth;
+ setup();
+ }
+
+ public boolean isBorderOverlay() {
+ return mBorderOverlay;
+ }
+
+ public void setBorderOverlay(boolean borderOverlay) {
+ if (borderOverlay == mBorderOverlay) {
+ return;
+ }
+
+ mBorderOverlay = borderOverlay;
+ setup();
+ }
+
+ @Override
+ public void setImageBitmap(Bitmap bm) {
+ super.setImageBitmap(bm);
+ mBitmap = bm;
+ setup();
+ }
+
+ @Override
+ public void setImageDrawable(Drawable drawable) {
+ super.setImageDrawable(drawable);
+ mBitmap = getBitmapFromDrawable(drawable);
+ setup();
+ }
+
+ @Override
+ public void setImageResource(@DrawableRes int resId) {
+ super.setImageResource(resId);
+ mBitmap = getBitmapFromDrawable(getDrawable());
+ setup();
+ }
+
+ @Override
+ public void setImageURI(Uri uri) {
+ super.setImageURI(uri);
+ mBitmap = uri != null ? getBitmapFromDrawable(getDrawable()) : null;
+ setup();
+ }
+
+ @Override
+ public void setColorFilter(ColorFilter cf) {
+ if (cf == mColorFilter) {
+ return;
+ }
+
+ mColorFilter = cf;
+ mBitmapPaint.setColorFilter(mColorFilter);
+ invalidate();
+ }
+
+ private Bitmap getBitmapFromDrawable(Drawable drawable) {
+ if (drawable == null) {
+ return null;
+ }
+
+ if (drawable instanceof BitmapDrawable) {
+ return ((BitmapDrawable) drawable).getBitmap();
+ }
+
+ try {
+ Bitmap bitmap;
+
+ if (drawable instanceof ColorDrawable) {
+ bitmap = Bitmap.createBitmap(COLORDRAWABLE_DIMENSION, COLORDRAWABLE_DIMENSION, BITMAP_CONFIG);
+ } else {
+ bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), BITMAP_CONFIG);
+ }
+
+ Canvas canvas = new Canvas(bitmap);
+ drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
+ drawable.draw(canvas);
+ return bitmap;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ private void setup() {
+ if (!mReady) {
+ mSetupPending = true;
+ return;
+ }
+
+ if (getWidth() == 0 && getHeight() == 0) {
+ return;
+ }
+
+ if (mBitmap == null) {
+ invalidate();
+ return;
+ }
+
+ mBitmapShader = new BitmapShader(mBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
+
+ mBitmapPaint.setAntiAlias(true);
+ mBitmapPaint.setShader(mBitmapShader);
+
+ mBorderPaint.setStyle(Paint.Style.STROKE);
+ mBorderPaint.setAntiAlias(true);
+ mBorderPaint.setColor(mBorderColor);
+ mBorderPaint.setStrokeWidth(mBorderWidth);
+
+ mFillPaint.setStyle(Paint.Style.FILL);
+ mFillPaint.setAntiAlias(true);
+ mFillPaint.setColor(mFillColor);
+
+ mBitmapHeight = mBitmap.getHeight();
+ mBitmapWidth = mBitmap.getWidth();
+
+ mBorderRect.set(0, 0, getWidth(), getHeight());
+ mBorderRadius = Math.min((mBorderRect.height() - mBorderWidth) / 2.0f, (mBorderRect.width() - mBorderWidth) / 2.0f);
+
+ mDrawableRect.set(mBorderRect);
+ if (!mBorderOverlay) {
+ mDrawableRect.inset(mBorderWidth, mBorderWidth);
+ }
+ mDrawableRadius = Math.min(mDrawableRect.height() / 2.0f, mDrawableRect.width() / 2.0f);
+
+ updateShaderMatrix();
+ invalidate();
+ }
+
+ private void updateShaderMatrix() {
+ float scale;
+ float dx = 0;
+ float dy = 0;
+
+ mShaderMatrix.set(null);
+
+ if (mBitmapWidth * mDrawableRect.height() > mDrawableRect.width() * mBitmapHeight) {
+ scale = mDrawableRect.height() / (float) mBitmapHeight;
+ dx = (mDrawableRect.width() - mBitmapWidth * scale) * 0.5f;
+ } else {
+ scale = mDrawableRect.width() / (float) mBitmapWidth;
+ dy = (mDrawableRect.height() - mBitmapHeight * scale) * 0.5f;
+ }
+
+ mShaderMatrix.setScale(scale, scale);
+ mShaderMatrix.postTranslate((int) (dx + 0.5f) + mDrawableRect.left, (int) (dy + 0.5f) + mDrawableRect.top);
+
+ mBitmapShader.setLocalMatrix(mShaderMatrix);
+ }
+
+}
diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/wm/IWindowManagerView.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/wm/IWindowManagerView.java
index 14891ed7d6..cab1b77605 100644
--- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/wm/IWindowManagerView.java
+++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/wm/IWindowManagerView.java
@@ -33,6 +33,6 @@ interface IWindowManagerView {
void hide();
interface OnViewClickListener {
- void onClick( View view );
+ void onClick( View view, float xPos, float yPos );
}
}
diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/wm/WindowManagerImpl.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/wm/WindowManagerImpl.java
index d4314d4106..d810e6033f 100644
--- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/wm/WindowManagerImpl.java
+++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/wm/WindowManagerImpl.java
@@ -64,7 +64,10 @@ class WindowManagerImpl implements IWindowManagerView {
// 只要按钮一动位置不是很大,就认为是点击事件
if ( Math.abs( mOldOffsetX - newOffsetX ) <= 20
&& Math.abs( mOldOffsetY - newOffsetY ) <= 20 ) {
- listener.onClick( mParams.mContentView );
+ if ( listener != null ) {
+ listener.onClick( mParams.mContentView, x, y );
+ }
+ return false;
}
mOldOffsetX = newOffsetX;
mOldOffsetY = newOffsetY;
diff --git a/modules/mogo-module-common/src/main/res/drawable-ldpi/icon_heart_choose.png b/modules/mogo-module-common/src/main/res/drawable-ldpi/icon_heart_choose.png
new file mode 100644
index 0000000000..7fc320c21f
Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-ldpi/icon_heart_choose.png differ
diff --git a/modules/mogo-module-common/src/main/res/drawable-ldpi/icon_heart_second.png b/modules/mogo-module-common/src/main/res/drawable-ldpi/icon_heart_second.png
new file mode 100644
index 0000000000..71f17bcc7e
Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-ldpi/icon_heart_second.png differ
diff --git a/modules/mogo-module-common/src/main/res/drawable-ldpi/icon_heart_unchoose.png b/modules/mogo-module-common/src/main/res/drawable-ldpi/icon_heart_unchoose.png
new file mode 100644
index 0000000000..c7ee647c81
Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-ldpi/icon_heart_unchoose.png differ
diff --git a/modules/mogo-module-common/src/main/res/drawable-ldpi/module_common_default_user_head.png b/modules/mogo-module-common/src/main/res/drawable-ldpi/module_common_default_user_head.png
new file mode 100644
index 0000000000..726124020a
Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-ldpi/module_common_default_user_head.png differ
diff --git a/modules/mogo-module-common/src/main/res/drawable-mdpi/icon_heart_choose.png b/modules/mogo-module-common/src/main/res/drawable-mdpi/icon_heart_choose.png
new file mode 100644
index 0000000000..7fc320c21f
Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-mdpi/icon_heart_choose.png differ
diff --git a/modules/mogo-module-common/src/main/res/drawable-mdpi/icon_heart_second.png b/modules/mogo-module-common/src/main/res/drawable-mdpi/icon_heart_second.png
new file mode 100644
index 0000000000..71f17bcc7e
Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-mdpi/icon_heart_second.png differ
diff --git a/modules/mogo-module-common/src/main/res/drawable-mdpi/icon_heart_unchoose.png b/modules/mogo-module-common/src/main/res/drawable-mdpi/icon_heart_unchoose.png
new file mode 100644
index 0000000000..c7ee647c81
Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-mdpi/icon_heart_unchoose.png differ
diff --git a/modules/mogo-module-common/src/main/res/drawable-mdpi/module_common_default_user_head.png b/modules/mogo-module-common/src/main/res/drawable-mdpi/module_common_default_user_head.png
new file mode 100644
index 0000000000..726124020a
Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-mdpi/module_common_default_user_head.png differ
diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_heart_choose.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_heart_choose.png
new file mode 100644
index 0000000000..d6c0f59110
Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_heart_choose.png differ
diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_heart_second.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_heart_second.png
new file mode 100644
index 0000000000..bb5cf70654
Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_heart_second.png differ
diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_heart_unchoose.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_heart_unchoose.png
new file mode 100644
index 0000000000..3a74a64a43
Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_heart_unchoose.png differ
diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_common_default_user_head.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_common_default_user_head.png
new file mode 100644
index 0000000000..baa717be4d
Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_common_default_user_head.png differ
diff --git a/modules/mogo-module-common/src/main/res/drawable/module_common_default_user_head.png b/modules/mogo-module-common/src/main/res/drawable/module_common_default_user_head.png
new file mode 100644
index 0000000000..726124020a
Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable/module_common_default_user_head.png differ
diff --git a/modules/mogo-module-v2x/src/main/res/drawable/share_rating_bar.xml b/modules/mogo-module-common/src/main/res/drawable/module_commons_heart_ratingbar_drawable.xml
similarity index 63%
rename from modules/mogo-module-v2x/src/main/res/drawable/share_rating_bar.xml
rename to modules/mogo-module-common/src/main/res/drawable/module_commons_heart_ratingbar_drawable.xml
index afded5aacb..ee83cb56c4 100644
--- a/modules/mogo-module-v2x/src/main/res/drawable/share_rating_bar.xml
+++ b/modules/mogo-module-common/src/main/res/drawable/module_commons_heart_ratingbar_drawable.xml
@@ -2,15 +2,15 @@
-
+ android:drawable="@drawable/icon_heart_unchoose">
-
+ android:drawable="@drawable/icon_heart_second">
-
+ android:drawable="@drawable/icon_heart_choose">
\ No newline at end of file
diff --git a/modules/mogo-module-v2x/src/main/res/drawable/v2xt_dw_common_corner_bkg_light.xml b/modules/mogo-module-common/src/main/res/drawable/module_dw_common_corner_bkg_light.xml
similarity index 100%
rename from modules/mogo-module-v2x/src/main/res/drawable/v2xt_dw_common_corner_bkg_light.xml
rename to modules/mogo-module-common/src/main/res/drawable/module_dw_common_corner_bkg_light.xml
diff --git a/modules/mogo-module-common/src/main/res/layout/modeules_commons_layout_custom_ratingbar.xml b/modules/mogo-module-common/src/main/res/layout/modeules_commons_layout_custom_ratingbar.xml
new file mode 100644
index 0000000000..ac3fb54105
--- /dev/null
+++ b/modules/mogo-module-common/src/main/res/layout/modeules_commons_layout_custom_ratingbar.xml
@@ -0,0 +1,7 @@
+
+
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-v2x/src/main/res/layout/v2x_network_loading_item.xml b/modules/mogo-module-common/src/main/res/layout/network_loading_item.xml
similarity index 97%
rename from modules/mogo-module-v2x/src/main/res/layout/v2x_network_loading_item.xml
rename to modules/mogo-module-common/src/main/res/layout/network_loading_item.xml
index 063ab8f34e..e16c269062 100644
--- a/modules/mogo-module-v2x/src/main/res/layout/v2x_network_loading_item.xml
+++ b/modules/mogo-module-common/src/main/res/layout/network_loading_item.xml
@@ -45,7 +45,7 @@
android:layout_centerHorizontal="true"
android:layout_gravity="top|center"
android:layout_marginTop="@dimen/dp_40"
- android:background="@drawable/v2xt_dw_common_corner_bkg_light"
+ android:background="@drawable/module_dw_common_corner_bkg_light"
android:gravity="center"
android:text="刷新"
android:textColor="#FFFFFF"
diff --git a/modules/mogo-module-common/src/main/res/values-mdpi/dimens.xml b/modules/mogo-module-common/src/main/res/values-mdpi/dimens.xml
new file mode 100644
index 0000000000..73cc314845
--- /dev/null
+++ b/modules/mogo-module-common/src/main/res/values-mdpi/dimens.xml
@@ -0,0 +1,10 @@
+
+
+ 20px
+ 16px
+ 120px
+ 150px
+ 48px
+ 17.5000px
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-common/src/main/res/values-xhdpi/dimens.xml b/modules/mogo-module-common/src/main/res/values-xhdpi/dimens.xml
index ca1346e002..9692e54e2a 100644
--- a/modules/mogo-module-common/src/main/res/values-xhdpi/dimens.xml
+++ b/modules/mogo-module-common/src/main/res/values-xhdpi/dimens.xml
@@ -1054,5 +1054,12 @@
48px
-10px
10px
+ 40px
+ 43px
+ 300px
+ 281px
+ 90px
+ 32px
+ 28px
diff --git a/modules/mogo-module-common/src/main/res/values/attr.xml b/modules/mogo-module-common/src/main/res/values/attr.xml
index 7310089318..c18d5a5d09 100644
--- a/modules/mogo-module-common/src/main/res/values/attr.xml
+++ b/modules/mogo-module-common/src/main/res/values/attr.xml
@@ -6,4 +6,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-common/src/main/res/values/colors.xml b/modules/mogo-module-common/src/main/res/values/colors.xml
index 993e412000..d73639033d 100644
--- a/modules/mogo-module-common/src/main/res/values/colors.xml
+++ b/modules/mogo-module-common/src/main/res/values/colors.xml
@@ -2,4 +2,5 @@
#7f000000
#FFFFFF
+ #FFFFFF
\ No newline at end of file
diff --git a/modules/mogo-module-common/src/main/res/values/dimens.xml b/modules/mogo-module-common/src/main/res/values/dimens.xml
index 170c5a430d..bd36dac4cb 100644
--- a/modules/mogo-module-common/src/main/res/values/dimens.xml
+++ b/modules/mogo-module-common/src/main/res/values/dimens.xml
@@ -1045,4 +1045,12 @@
26.2500px
-8px
8px
+ 20px
+ 16px
+ 120px
+ 150px
+ 48px
+ 17.5000px
+ 15.3125px
+
diff --git a/modules/mogo-module-common/src/main/res/values/styles.xml b/modules/mogo-module-common/src/main/res/values/styles.xml
index 10ca997feb..e12e13d325 100644
--- a/modules/mogo-module-common/src/main/res/values/styles.xml
+++ b/modules/mogo-module-common/src/main/res/values/styles.xml
@@ -14,4 +14,19 @@
- @android:color/transparent
- @android:color/transparent
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/ExtensionsFragment.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/ExtensionsFragment.java
deleted file mode 100644
index 81b7c02eb5..0000000000
--- a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/ExtensionsFragment.java
+++ /dev/null
@@ -1,132 +0,0 @@
-package com.mogo.module.extensions;
-
-import android.os.Bundle;
-import android.text.TextUtils;
-import android.view.View;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import com.alibaba.android.arouter.launcher.ARouter;
-import com.mogo.commons.debug.DebugConfig;
-import com.mogo.commons.mvp.MvpFragment;
-import com.mogo.module.extensions.userinfo.UserInfo;
-import com.mogo.module.share.manager.ServiceApisManager;
-import com.mogo.utils.LaunchUtils;
-import com.mogo.utils.glide.GlideApp;
-import com.mogo.utils.logger.Logger;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * 天气,消息,个人头像
- *
- * @author congtaowang
- * @since 2020-01-05
- *
- * 描述
- */
-public class ExtensionsFragment extends MvpFragment< ExtensionsView, ExtensionsPresenter > implements ExtensionsView {
-
- private static final String TAG = "ExtensionsFragment";
-
- public static final int MAX_DISPLAY_MSG_AMOUNT = 99;
-
- private View mWeatherContainer;
- private ImageView mWeatherIcon;
- private TextView mWeatherTemp;
-
- private View mMsgContainer;
- private TextView mMsgCounter;
-
- private ImageView mUserHeadImg;
-
- @Override
- protected int getLayoutId() {
- return R.layout.module_ext_layout_extensions;
- }
-
- @Override
- protected void initViews() {
-
- mWeatherContainer = findViewById( R.id.module_ext_id_weather_container );
- mWeatherIcon = findViewById( R.id.module_ext_id_weather_icon );
- mWeatherTemp = findViewById( R.id.module_ext_id_weather_temp );
-
- mUserHeadImg = findViewById(R.id.ivUserHeadImg);
-
- mMsgContainer = findViewById( R.id.module_ext_id_msg );
-
- mMsgContainer.setOnClickListener( view -> {
- ARouter.getInstance().build( "/push/ui/message" ).navigation( getContext() );
- } );
- mMsgCounter = findViewById( R.id.module_ext_id_msg_counter );
- mUserHeadImg.setOnClickListener(view ->{
- try {
- LaunchUtils.launchByPkg(getContext(), "com.zhidao.auto.personal");
- // 埋点
- final Map properties = new HashMap<>();
- properties.put("type", 3);
- ServiceApisManager.serviceApis.getAnalyticsApi().track( "Launcher_APP_Icon", properties );
- } catch (Exception e) {
- Logger.e(TAG, e, "打开个人中心Exception");
- }
- });
-
- mUserHeadImg.setVisibility(DebugConfig.isLauncher()?View.VISIBLE:View.GONE);
- }
-
- @NonNull
- @Override
- protected ExtensionsPresenter createPresenter() {
- return new ExtensionsPresenter( this );
- }
-
- @Override
- public void onActivityCreated( @Nullable Bundle savedInstanceState ) {
- super.onActivityCreated( savedInstanceState );
- }
-
- @Override
- public void onResume() {
- super.onResume();
- }
-
- @Override
- public void onStop() {
- super.onStop();
- }
-
- @Override
- public void renderWeatherInfo( String temp, String desc, int iconId ) {
- boolean hidden = false;
- if ( iconId != 0 ) {
- mWeatherIcon.setImageResource( iconId );
- mWeatherIcon.setVisibility( View.VISIBLE );
- } else {
- mWeatherIcon.setVisibility( View.GONE );
- hidden |= true;
- }
- hidden |= TextUtils.isEmpty( temp );
- hidden |= TextUtils.isEmpty( desc );
- mWeatherTemp.setText( temp );
- mWeatherContainer.setVisibility( hidden ? View.GONE : View.VISIBLE );
- }
-
- @Override
- public void renderMsgInfo( boolean hasMsg, int amount ) {
- mMsgContainer.setVisibility( hasMsg ? View.VISIBLE : View.GONE );
- mMsgCounter.setText( amount > MAX_DISPLAY_MSG_AMOUNT ? getString( R.string.module_ext_str_dots ) : String.valueOf( amount ) );
- }
-
- @Override
- public void renderUserInfo(UserInfo userInfo) {
- if(userInfo != null){
- Logger.d(TAG, "renderUserInfo: " + userInfo);
- GlideApp.with(getContext()).load(userInfo.getHeadImgurl()).placeholder(R.drawable.model_ext_default_user_head).circleCrop().into(mUserHeadImg);
- }
- }
-}
diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/ExtensionsModuleConst.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/ExtensionsModuleConst.java
index 4c5a0fe623..9a563f521d 100644
--- a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/ExtensionsModuleConst.java
+++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/ExtensionsModuleConst.java
@@ -8,11 +8,6 @@ package com.mogo.module.extensions;
*/
public class ExtensionsModuleConst {
- /**
- * 顶部UI
- */
- public static final String PATH_EXTENSION = "/extension/ui";
-
/**
* 快捷操作入口:定位、
*/
diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/ExtensionsModuleProvider.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/ExtensionsModuleProvider.java
deleted file mode 100644
index 2484719833..0000000000
--- a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/ExtensionsModuleProvider.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package com.mogo.module.extensions;
-
-import android.content.Context;
-import android.os.Bundle;
-import android.view.View;
-
-import androidx.annotation.NonNull;
-import androidx.fragment.app.Fragment;
-
-import com.alibaba.android.arouter.facade.annotation.Route;
-import com.mogo.map.listener.IMogoMapListener;
-import com.mogo.map.location.IMogoLocationListener;
-import com.mogo.map.marker.IMogoMarkerClickListener;
-import com.mogo.map.navi.IMogoNaviListener;
-import com.mogo.service.module.IMogoModuleLifecycle;
-import com.mogo.service.module.IMogoModuleProvider;
-import com.mogo.service.module.ModuleType;
-
-/**
- * @author congtaowang
- * @since 2020-01-05
- *
- * 描述
- */
-@Route( path = ExtensionsModuleConst.PATH_EXTENSION )
-public class ExtensionsModuleProvider implements IMogoModuleProvider {
-
- @Override
- public Fragment createFragment( Context context, Bundle data ) {
- ExtensionsFragment fragment = new ExtensionsFragment();
- fragment.setArguments( data );
- return fragment;
- }
-
- @Override
- public View createView( Context context ) {
- return null;
- }
-
- @NonNull
- @Override
- public String getModuleName() {
- return ExtensionsModuleConst.TYPE;
- }
-
- @Override
- public IMogoModuleLifecycle getCardLifecycle() {
- return null;
- }
-
- @Override
- public IMogoMapListener getMapListener() {
- return null;
- }
-
- @Override
- public int getType() {
- return ModuleType.TYPE_EXTENSION;
- }
-
- @Override
- public IMogoNaviListener getNaviListener() {
- return null;
- }
-
- @Override
- public IMogoLocationListener getLocationListener() {
- return null;
- }
-
- @Override
- public void init( Context context ) {
-
- }
-
- @Override
- public IMogoMarkerClickListener getMarkerClickListener() {
- return null;
- }
-
- @Override
- public String getAppPackage() {
- return null;
- }
-
- @Override
- public String getAppName() {
- return null;
- }
-}
diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/ExtensionsPresenter.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/ExtensionsPresenter.java
deleted file mode 100644
index 11aa6dee90..0000000000
--- a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/ExtensionsPresenter.java
+++ /dev/null
@@ -1,161 +0,0 @@
-package com.mogo.module.extensions;
-
-import android.util.ArrayMap;
-
-import androidx.annotation.NonNull;
-import androidx.lifecycle.LifecycleOwner;
-
-import com.alibaba.android.arouter.launcher.ARouter;
-import com.mogo.commons.mvp.Presenter;
-import com.mogo.commons.network.Utils;
-import com.mogo.module.extensions.net.UserInfoNetApiServices;
-import com.mogo.module.extensions.userinfo.UserInfo;
-import com.mogo.module.extensions.userinfo.UserInfoConstant;
-import com.mogo.module.extensions.userinfo.UserInfoResponse;
-import com.mogo.module.extensions.utils.ExtensionsConfig;
-import com.mogo.module.extensions.weather.Phenomena;
-import com.mogo.module.extensions.weather.WeatherCallback;
-import com.mogo.module.extensions.weather.WeatherInfo;
-import com.mogo.module.extensions.weather.WeatherModel;
-import com.mogo.service.IMogoServiceApis;
-import com.mogo.service.MogoServicePaths;
-import com.mogo.service.network.IMogoNetwork;
-import com.mogo.service.statusmanager.IMogoMsgCenter;
-import com.mogo.service.statusmanager.IMogoMsgCenterListener;
-import com.mogo.utils.digest.DigestUtils;
-import com.mogo.utils.logger.Logger;
-
-import java.util.Map;
-
-import io.reactivex.SingleObserver;
-import io.reactivex.android.schedulers.AndroidSchedulers;
-import io.reactivex.disposables.Disposable;
-import io.reactivex.schedulers.Schedulers;
-
-
-/**
- * @author congtaowang
- * @since 2020-01-05
- *
- * 描述
- */
-public class ExtensionsPresenter extends Presenter< ExtensionsView > implements WeatherCallback,
- IMogoMsgCenterListener {
-
- private static final String TAG = "ExtensionsPresenter";
-
- private WeatherModel mWeatherModel;
-
- private IMogoMsgCenter mMsgCenter;
-
- private IMogoNetwork mNetWork;
-
- public ExtensionsPresenter( ExtensionsView view ) {
- super( view );
- mWeatherModel = new WeatherModel( getContext() );
- mNetWork =
- ((IMogoServiceApis) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(view.getContext())).getNetworkApi();
- }
-
- @Override
- public void onCreate( @NonNull LifecycleOwner owner ) {
- super.onCreate( owner );
- mWeatherModel.init( this );
- mWeatherModel.queryWeatherInformation();
- mMsgCenter = ( IMogoMsgCenter ) ARouter.getInstance().build( MogoServicePaths.PATH_MSG_CENTER ).navigation();
- mMsgCenter.registerMsgCenterListener( this );
- }
-
- @Override
- public void onWeatherLoaded( WeatherInfo weatherInfo ) {
- if ( weatherInfo == null ) {
- return;
- }
- String temp = getContext().getResources().getString( R.string.module_ext_str_weather_temp_format, weatherInfo.getTemperature() );
- Phenomena phenomena = Phenomena.getById( weatherInfo.getPhenomena() );
- String desc = phenomena == null ? "" : phenomena.nameCn;
- int resId = phenomena.resId;
- mView.renderWeatherInfo( temp, desc, resId );
- }
-
- @Override
- public void onMsgChanged( boolean hasMsg, int amount ) {
- if ( mView != null ) {
- mView.renderMsgInfo( hasMsg, amount );
- }
- }
-
- @Override
- public void onResume( @NonNull LifecycleOwner owner ) {
- super.onResume( owner );
- if(ExtensionsConfig.needRequestUserInfo()){
- // 相当于每次onResume都会请求一下个人信息,目的是能够相对及时的同步手机端的个人信息修改
- requestUserInfo();
- }
- }
-
- @Override
- public void onPause( @NonNull LifecycleOwner owner ) {
- super.onPause( owner );
- }
-
- @Override
- public void onDestroy( @NonNull LifecycleOwner owner ) {
- super.onDestroy( owner );
- if ( mWeatherModel != null ) {
- mWeatherModel.destroy();
- }
- if ( mMsgCenter != null ) {
- mMsgCenter.unregisterMsgCenterListener( this );
- }
- }
-
- private UserInfo userInfo;
- public void requestUserInfo() {
- Map params = new ArrayMap<>();
- params.put("sn", Utils.getSn());
- params.put("source", "2");
- String sign = createSign(params, "JGqZw9");
- params.put("sig", sign);
- mNetWork.create(UserInfoNetApiServices.class, UserInfoConstant.getUserInfoBaseUrl()).requestUserInfo(params).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new SingleObserver() {
- @Override
- public void onSubscribe(Disposable d) {
- }
-
- @Override
- public void onSuccess(UserInfoResponse userInfoBaseResponse) {
- userInfo = userInfoBaseResponse.getResult();
- if(userInfo!=null) {
- Logger.d(TAG, "获取个人信息成功: " + userInfo);
- mView.renderUserInfo(userInfo);
- }else{
- Logger.e(TAG,"获取个人信息失败");
- }
- }
-
- @Override
- public void onError(Throwable e) {
- e.printStackTrace();
- Logger.e(TAG, e, "获取个人信息失败==");
- }
- });
- }
-
- private String createSign(Map map, String salt) {
- try {
- StringBuilder queryString = new StringBuilder();
- for (Map.Entry entry : map.entrySet()) {
- queryString.append(entry.getKey())
- .append("=")
- .append(entry.getValue())
- .append("&");
- }
- queryString.append("key=").append(DigestUtils.shaHex(salt));
- return DigestUtils.shaHex(queryString.toString()).toUpperCase();
- } catch (Exception e) {
- e.printStackTrace();
- Logger.e(TAG, e, "createSign()");
- return "";
- }
- }
-}
diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/bean/CommonConfig.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/bean/CommonConfig.java
new file mode 100644
index 0000000000..36e5ca7a48
--- /dev/null
+++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/bean/CommonConfig.java
@@ -0,0 +1,59 @@
+package com.mogo.module.extensions.bean;
+
+import com.mogo.commons.data.BaseData;
+
+/**
+ * @author lixiaopeng
+ * @description
+ * @since 2020/9/22
+ */
+public class CommonConfig {
+
+ public Active active;//活动配置
+ public Auth auth; //授权配置
+ public Speech speech; //语音播报次数
+ public ReportStrategy reportStrategy; //被动上报策略开关
+
+ public CommonConfig(Active active, Auth auth, Speech speech, ReportStrategy reportStrategy) {
+ this.active = active;
+ this.auth = auth;
+ this.speech = speech;
+ this.reportStrategy = reportStrategy;
+ }
+
+ public class Active{
+ public String imageUrl;
+ public String webUrl;
+ public int status;
+
+ Active(String imageUrl, String webUrl, int status) {
+ this.imageUrl = imageUrl;
+ this.webUrl = webUrl;
+ this.status = status;
+ }
+ }
+
+
+ public class Speech{
+ public int count;
+
+ Speech(int count) {
+ this.count = count;
+ }
+ }
+
+ public class Auth{
+ int isNeedAuth;
+
+ Auth(int isNeedAuth) {
+ this.isNeedAuth = isNeedAuth;
+ }
+ }
+
+ public class ReportStrategy {
+ public boolean open;
+ ReportStrategy(boolean open) {
+ this.open = open;
+ }
+ }
+}
diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/bean/CommonConfigResponse.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/bean/CommonConfigResponse.java
new file mode 100644
index 0000000000..e4e640d788
--- /dev/null
+++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/bean/CommonConfigResponse.java
@@ -0,0 +1,13 @@
+package com.mogo.module.extensions.bean;
+
+import com.mogo.commons.data.BaseData;
+
+/**
+ * @author lixiaopeng
+ * @description
+ * @since 2020/9/22
+ */
+public class CommonConfigResponse extends BaseData {
+
+ public CommonConfig result;
+}
diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java
index e4877e12b8..7ec1345d38 100644
--- a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java
+++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java
@@ -6,6 +6,7 @@ import android.os.Bundle;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.LayoutInflater;
+import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
@@ -22,6 +23,8 @@ import com.bumptech.glide.request.RequestOptions;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.commons.mvp.MvpFragment;
+import com.mogo.commons.voice.AIAssist;
+import com.mogo.map.MogoLatLng;
import com.mogo.map.listener.IMogoMapListener;
import com.mogo.map.location.IMogoLocationClient;
import com.mogo.map.location.MogoLocation;
@@ -33,11 +36,13 @@ import com.mogo.map.navi.MogoNaviInfo;
import com.mogo.map.navi.MogoTraffic;
import com.mogo.map.uicontroller.EnumMapUI;
import com.mogo.map.uicontroller.IMogoMapUIController;
+import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.dialog.WMDialog;
import com.mogo.module.common.glide.SkinAbleBitmapTarget;
import com.mogo.module.common.map.CustomNaviInterrupter;
import com.mogo.module.common.map.MapCenterPointStrategy;
import com.mogo.module.common.map.Scene;
+import com.mogo.module.common.view.OnPreventFastClickListener;
import com.mogo.module.extensions.ExtensionsModuleConst;
import com.mogo.module.extensions.R;
import com.mogo.module.extensions.navi.NaviInfoView;
@@ -46,7 +51,6 @@ import com.mogo.module.extensions.utils.EntranceViewHolder;
import com.mogo.module.extensions.utils.TopViewAnimHelper;
import com.mogo.module.share.manager.ServiceApisManager;
import com.mogo.service.IMogoServiceApis;
-import com.mogo.service.MogoServicePaths;
import com.mogo.service.analytics.IMogoAnalytics;
import com.mogo.service.entrance.ButtonIndex;
import com.mogo.service.fragmentmanager.IFragmentProvider;
@@ -65,6 +69,7 @@ import com.mogo.utils.TipToast;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.glide.GlideApp;
import com.mogo.utils.logger.Logger;
+import com.mogo.utils.storage.SharedPrefsMgr;
import com.zhidao.manager.ts.TsThreshold;
import java.util.HashMap;
@@ -72,6 +77,19 @@ import java.util.Locale;
import java.util.Map;
import java.util.Random;
+import static com.mogo.module.common.utils.SPConst.getSPGuideRecord;
+import static com.mogo.module.common.utils.SPConst.getSpGuide;
+import static com.mogo.module.share.constant.ShareConstants.KEY_CLICK_SHARE_BUTTON;
+import static com.mogo.module.share.constant.ShareConstants.KEY_CLICK_SHARE_TIME;
+import static com.mogo.module.share.constant.ShareConstants.KEY_SERVER_SHOW_DAY_COUNT;
+import static com.mogo.module.share.constant.ShareConstants.KEY_SHARE_INNER_GUIDE;
+import static com.mogo.module.share.constant.ShareConstants.KEY_SHARE_INNER_GUIDE_TIME;
+import static com.mogo.module.share.constant.ShareConstants.KEY_SHARE_OUTER_GUIDE;
+import static com.mogo.module.share.constant.ShareConstants.KEY_SHARE_OUTER_GUIDE_TIME;
+import static com.mogo.module.share.constant.ShareConstants.ONE_DAY_TIME;
+import static com.mogo.module.share.constant.ShareConstants.SEVEN_DAY_TIME;
+import static com.mogo.module.share.constant.ShareConstants.VOICE_ALERT_COUNT;
+
/**
* @author congtaowang
* @since 2020-01-07
@@ -131,6 +149,14 @@ public class EntranceFragment extends MvpFragment {
- showShareDialog();
- });
+ mUploadRoadCondition.setOnClickListener( new OnPreventFastClickListener() {
+ @Override
+ public void onClickImpl( View v ) {
+ showShareDialog();
+ playShareGuideVoice();
+ }
+ } );
mDisplayOverview = findViewById(R.id.module_ext_id_display_overview);
mDisplayOverviewText = findViewById(R.id.module_ext_id_display_overview_text);
mDisplayOverviewIcon = findViewById(R.id.module_ext_id_display_overview_icon);
- mDisplayOverview.setOnClickListener(view -> {
- if (getContext() != null) {
- // 加此判断是解决下面setDisplayOverview后,本Fragment回调中出现not attached to a context问题
- if (!mStatusManager.isDisplayOverview()) {
- mMApUIController.displayOverview(mDisplayOverviewBounds);
- UiThreadHandler.removeCallbacks(mLockCarRunnable);
- UiThreadHandler.postDelayed(mLockCarRunnable, 20_000);
- } else {
- mMApUIController.recoverLockMode();
- UiThreadHandler.removeCallbacks(mLockCarRunnable);
+ mDisplayOverview.setOnClickListener( new OnPreventFastClickListener() {
+ @Override
+ public void onClickImpl( View v ) {
+ if (getContext() != null) {
+ // 加此判断是解决下面setDisplayOverview后,本Fragment回调中出现not attached to a context问题
+ if (!mStatusManager.isDisplayOverview()) {
+ mMApUIController.displayOverview(mDisplayOverviewBounds);
+ UiThreadHandler.removeCallbacks(mLockCarRunnable);
+ UiThreadHandler.postDelayed(mLockCarRunnable, 20_000);
+ } else {
+ mMApUIController.recoverLockMode();
+ UiThreadHandler.removeCallbacks(mLockCarRunnable);
+ }
+ mStatusManager.setDisplayOverview(TAG, !mStatusManager.isDisplayOverview());
}
- mStatusManager.setDisplayOverview(TAG, !mStatusManager.isDisplayOverview());
}
- });
+ } );
mMove2CurrentLocation = findViewById(R.id.module_entrance_id_move2_current_location);
- mMove2CurrentLocation.setOnClickListener(view -> {
- final MogoLocation location = mMogoLocationClient.getLastKnowLocation();
- if (location != null) {
- if (mStatusManager.isDisplayOverview()) {
- mStatusManager.setDisplayOverview(TAG, false);
- UiThreadHandler.removeCallbacks(mLockCarRunnable);
+ mMove2CurrentLocation.setOnClickListener( new OnPreventFastClickListener() {
+ @Override
+ public void onClickImpl( View v ) {
+ final MogoLocation location = mMogoLocationClient.getLastKnowLocation();
+ if (location != null) {
+ if (mStatusManager.isDisplayOverview()) {
+ mStatusManager.setDisplayOverview(TAG, false);
+ UiThreadHandler.removeCallbacks(mLockCarRunnable);
+ }
+ mStatusManager.setUserInteractionStatus(TAG, true, false);
+ mMApUIController.recoverLockMode();
}
- mStatusManager.setUserInteractionStatus(TAG, true, false);
- mMApUIController.recoverLockMode();
}
- });
+ } );
if (DebugConfig.isDebug()) {
mMove2CurrentLocation.setOnLongClickListener(view -> {
@@ -227,46 +267,47 @@ public class EntranceFragment extends MvpFragment {
- if (mMogoNavi != null) {
- if (mIsLock) {
- new WMDialog.Builder(getContext())
- .setOkButton(R.string.module_commons_button_ok, (dlg, which) -> {
- dlg.dismiss();
- mMogoNavi.stopNavi();
- })
- .setCancelButton(R.string.module_commons_button_cancel,
- (dlg, which) -> {
- dlg.dismiss();
- })
- .setContent(R.string.module_commons_exit_navi_content)
- .build()
- .show();
- } else {
- MapCenterPointStrategy.setMapCenterPointByScene(mMApUIController, Scene.NAVI);
- mMApUIController.recoverLockMode();
+ mExitNavi.setOnClickListener( new OnPreventFastClickListener() {
+ @Override
+ public void onClickImpl( View v ) {
+ if (mMogoNavi != null) {
+ if (mIsLock) {
+ new WMDialog.Builder(getContext())
+ .setOkButton(R.string.module_commons_button_ok, (dlg, which) -> {
+ dlg.dismiss();
+ mMogoNavi.stopNavi();
+ })
+ .setCancelButton(R.string.module_commons_button_cancel,
+ (dlg, which) -> {
+ dlg.dismiss();
+ })
+ .setContent(R.string.module_commons_exit_navi_content)
+ .build()
+ .show();
+ } else {
+ MapCenterPointStrategy.setMapCenterPointByScene(mMApUIController, Scene.NAVI);
+ mMApUIController.recoverLockMode();
+ }
}
}
- });
+ } );
mCameraMode = findViewById(R.id.module_ext_id_north);
- mCameraMode.setOnClickListener(view -> {
- if (mCameraMode.isSelected()) {
- mMApUIController.changeMapMode(EnumMapUI.CarUp_2D);
- } else {
- mMApUIController.changeMapMode(EnumMapUI.NorthUP_2D);
+ mCameraMode.setOnClickListener( new OnPreventFastClickListener() {
+ @Override
+ public void onClickImpl( View v ) {
+ if (mCameraMode.isSelected()) {
+ mMApUIController.changeMapMode(EnumMapUI.CarUp_2D);
+ } else {
+ mMApUIController.changeMapMode(EnumMapUI.NorthUP_2D);
+ }
}
-// mCameraMode.setSelected(!mCameraMode.isSelected());
-// mCameraMode.setText(getString(mCameraMode.isSelected() ? R.string.mode_car_up :
-// R.string.mode_north_up));
- });
+ } );
mApis.getIntentManagerApi().registerIntentListener(AUTONAVI_STANDARD_BROADCAST_RECV, this);
- MogoEntranceButtons.save(ButtonIndex.BUTTON1,
- findViewById(R.id.module_entrance_id_button1));
- MogoEntranceButtons.save(ButtonIndex.BUTTON2,
- findViewById(R.id.module_entrance_id_button2));
+ MogoEntranceButtons.save(ButtonIndex.BUTTON1, findViewById(R.id.module_entrance_id_button1));
+ MogoEntranceButtons.save(ButtonIndex.BUTTON2, findViewById(R.id.module_entrance_id_button2));
mDisplayOverviewBounds = new Rect(
ResourcesHelper.getDimensionPixelSize(getContext(),
@@ -282,13 +323,16 @@ public class EntranceFragment extends MvpFragment {
- try {
- LaunchUtils.launchByPkg(getContext(), "com.autonavi.amapauto");
- } catch (Exception e) {
- e.printStackTrace();
+ findViewById(R.id.module_map_id_navi_bg).setOnClickListener( new OnPreventFastClickListener() {
+ @Override
+ public void onClickImpl( View v ) {
+ try {
+ LaunchUtils.launchByPkg(getContext(), "com.autonavi.amapauto");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
- });
+ } );
mWeatherContainer = findViewById(R.id.module_ext_id_weather_container);
mWeatherIcon = findViewById(R.id.module_ext_id_weather_icon);
@@ -298,33 +342,52 @@ public class EntranceFragment extends MvpFragment {
- try {
- IFragmentProvider provider = (IFragmentProvider)ARouter.getInstance().build("/push/ui/message").navigation(getContext());
- provider.createFragment( getActivity(), mMogoFragmentManager.getMessageHistoryContainerId(), null );
- } catch( Exception e ){
+ mMsgContainer.setOnClickListener( new OnPreventFastClickListener() {
+ @Override
+ public void onClickImpl( View v ) {
+ try {
+ if ( mMessageHistoryPanelProvider == null ) {
+ mMessageHistoryPanelProvider = (IFragmentProvider)ARouter.getInstance().build("/push/ui/message").navigation(getContext());
+ }
+ mMessageHistoryPanelProvider.createFragment( getActivity(), mMogoFragmentManager.getMessageHistoryContainerId(), null );
+ } catch( Exception e ){
+ }
}
- });
+ } );
mMsgCounter = findViewById(R.id.module_ext_id_msg_counter);
- mUserHeadImg.setOnClickListener(view -> {
- try {
- LaunchUtils.launchByPkg(getContext(), "com.zhidao.auto.personal");
- // 埋点
- final Map properties = new HashMap<>();
- properties.put("type", 3);
- ServiceApisManager.serviceApis.getAnalyticsApi().track("Launcher_APP_Icon",
- properties);
- } catch (Exception e) {
- Logger.e(TAG, e, "打开个人中心Exception");
+ mUserHeadImg.setOnClickListener( new OnPreventFastClickListener() {
+ @Override
+ public void onClickImpl( View v ) {
+ try {
+ LaunchUtils.launchByPkg(getContext(), "com.zhidao.auto.personal");
+ // 埋点
+ final Map properties = new HashMap<>();
+ properties.put("type", 3);
+ ServiceApisManager.serviceApis.getAnalyticsApi().track("Launcher_APP_Icon",
+ properties);
+ } catch (Exception e) {
+ Logger.e(TAG, e, "打开个人中心Exception");
+ }
}
- });
+ } );
mUserHeadImg.setVisibility(DebugConfig.isLauncher() ? View.VISIBLE : View.GONE);
mUploadButtonAnimatorController = new UploadButtonAnimatorController(mUploading, mUpload,
mStatusManager);
+ mOnlineCarEntrance = findViewById( R.id.module_ext_id_destination_online_car );
+ mOnlineCarEntrance.setOnClickListener( new OnPreventFastClickListener() {
+ @Override
+ public void onClickImpl( View v ) {
+ MogoApisHandler.getInstance().getApis().getOnlineCarPanelApi().showPanel();
+ Map properties = new HashMap<>();
+ properties.put( "type", 1 );
+ MogoApisHandler.getInstance().getApis().getAnalyticsApi().track( "APP_Find_Mogoer", properties );
+ }
+ } );
+
dealWeatherContainer();
debugTopView();
@@ -389,6 +452,161 @@ public class EntranceFragment extends MvpFragment {
+ playShareOuterGuideVoice();
+ }, 5_000L
+ );
+ }
+ }
+
+
+ private boolean isGreaterThanOneDay() {
+ boolean isGreaterThanOneDay;
+ long guideRecordTime = SharedPrefsMgr.getInstance(AbsMogoApplication.getApp()).getLong(getSPGuideRecord(), 0);
+ Logger.d(TAG, " isGreaterThanOneDay interval = " + (System.currentTimeMillis() - guideRecordTime) + "---currentTime = " + System.currentTimeMillis() + "---guideRecordTime =" + guideRecordTime);
+ if ((System.currentTimeMillis() - guideRecordTime) > ONE_DAY_TIME) {
+ isGreaterThanOneDay = true;
+ } else {
+ isGreaterThanOneDay = false;
+ }
+
+ return isGreaterThanOneDay;
+ }
+
+ Random random = new Random();
+
+ /**
+ * 外部触发引导
+ */
+ private void playShareOuterGuideVoice() {
+ long intervalTime = SharedPrefsMgr.getInstance(getContext()).getLong(KEY_SHARE_OUTER_GUIDE_TIME, 0);
+ int shareItemSum = SharedPrefsMgr.getInstance(getContext()).getInt(KEY_SHARE_OUTER_GUIDE, 0);
+ int serverIssueCount = SharedPrefsMgr.getInstance(getContext()).getInt(KEY_SERVER_SHOW_DAY_COUNT, 6);
+
+ if (shareItemSum < serverIssueCount) {
+ long time = System.currentTimeMillis();
+ Logger.d(TAG, " playShareOuterGuideVoice shareItemSum = " + shareItemSum + "---- intervalTime = " + intervalTime + "----serverIssueCount = " + serverIssueCount + "---time = " + time);
+ if (intervalTime == 0) {
+ SharedPrefsMgr.getInstance(getContext()).putLong(KEY_SHARE_OUTER_GUIDE_TIME, time);
+ SharedPrefsMgr.getInstance(getContext()).putInt(KEY_SHARE_OUTER_GUIDE, ++shareItemSum);
+// AIAssist.getInstance(getContext()).speakTTSVoice(mOuterGuideVoiceStrings[random.nextInt(3)]);
+ AIAssist.getInstance(getContext()).speakTTSVoice(mOuterGuideVoiceStrings[0]);
+ } else {
+ Logger.d(TAG, " playShareOuterGuideVoice else interval = " + (time - intervalTime));
+ if ((time - intervalTime) > SEVEN_DAY_TIME) {
+ if (shareItemSum == 1) {
+ AIAssist.getInstance(getContext()).speakTTSVoice(mOuterGuideVoiceStrings[1]);
+ } else if (shareItemSum == 2) {
+ AIAssist.getInstance(getContext()).speakTTSVoice(mOuterGuideVoiceStrings[2]);
+ } else if (shareItemSum == 3) {
+ AIAssist.getInstance(getContext()).speakTTSVoice(mOuterGuideVoiceStrings[0]);
+ } else if (shareItemSum == 4) {
+ AIAssist.getInstance(getContext()).speakTTSVoice(mOuterGuideVoiceStrings[1]);
+ } else if (shareItemSum == 5) {
+ AIAssist.getInstance(getContext()).speakTTSVoice(mOuterGuideVoiceStrings[2]);
+ }
+ SharedPrefsMgr.getInstance(getContext()).putLong(KEY_SHARE_OUTER_GUIDE_TIME, time);
+ SharedPrefsMgr.getInstance(getContext()).putInt(KEY_SHARE_OUTER_GUIDE, ++shareItemSum);
+ } else {
+ Logger.e(TAG, " playShareOuterGuideVoice else < ONE_DAY_TIME ");
+ }
+ }
+ }
+ }
+
+
+ private void playShareGuideVoice() {
+ long intervalTime = SharedPrefsMgr.getInstance(getContext()).getLong(KEY_CLICK_SHARE_TIME, 0);
+ int shareItemSum = SharedPrefsMgr.getInstance(getContext()).getInt(KEY_CLICK_SHARE_BUTTON, 0);
+ if (shareItemSum < VOICE_ALERT_COUNT) {
+ long time = System.currentTimeMillis();
+ Logger.d(TAG, " playShareGuideVoice shareItemSum = " + shareItemSum + "---- intervalTime = " + intervalTime + ">>> time = " + time);
+ if (intervalTime == 0) {
+ SharedPrefsMgr.getInstance(getContext()).putLong(KEY_CLICK_SHARE_TIME, time);
+ SharedPrefsMgr.getInstance(getContext()).putInt(KEY_CLICK_SHARE_BUTTON, ++shareItemSum);
+ AIAssist.getInstance(getContext()).speakTTSVoice(mClickShareVoiceStrings[0]);
+ } else {
+ Logger.d(TAG, " playShareGuideVoice else interval = " + (time - intervalTime));
+ if ((time - intervalTime) > ONE_DAY_TIME) {
+ if (shareItemSum == 1) {
+ AIAssist.getInstance(getContext()).speakTTSVoice(mClickShareVoiceStrings[1]);
+ } else {
+ AIAssist.getInstance(getContext()).speakTTSVoice(mClickShareVoiceStrings[0]);
+ }
+
+ SharedPrefsMgr.getInstance(getContext()).putLong(KEY_CLICK_SHARE_TIME, time);
+ SharedPrefsMgr.getInstance(getContext()).putInt(KEY_CLICK_SHARE_BUTTON, ++shareItemSum);
+ } else {
+ Logger.e(TAG, " playShareGuideVoice else < ONE_DAY_TIME ");
+ }
+ }
+ }
+ }
+
+ /**
+ * 地图移动和缩放回调
+ * @param latLng 中点的经纬度
+ * @param zoom 缩放大小
+ * @param tilt 倾斜度
+ * @param bearing 旋转角度
+ */
+ @Override
+ public void onMapChanged(MogoLatLng latLng, float zoom, float tilt, float bearing) {
+
+ }
+
+ private void showSlideMapVoiceGuide() {
+ long intervalTime = SharedPrefsMgr.getInstance(getContext()).getLong(KEY_SHARE_INNER_GUIDE_TIME, 0);
+ int shareItemSum = SharedPrefsMgr.getInstance(getContext()).getInt(KEY_SHARE_INNER_GUIDE, 0);
+ if (shareItemSum < VOICE_ALERT_COUNT) {
+ long time = System.currentTimeMillis();
+ Logger.d(TAG, " showSlideMapVoiceGuide shareItemSum = " + shareItemSum + "---- intervalTime = " + intervalTime + "---time = " + time);
+ if (intervalTime == 0) {
+ SharedPrefsMgr.getInstance(getContext()).putLong(KEY_SHARE_INNER_GUIDE_TIME, time);
+ SharedPrefsMgr.getInstance(getContext()).putInt(KEY_SHARE_INNER_GUIDE, ++shareItemSum);
+ AIAssist.getInstance(getContext()).speakTTSVoice(mInnerGuideVoiceStrings[0]);
+ } else {
+ Logger.d(TAG, " showSlideMapVoiceGuide else interval = " + (time - intervalTime));
+ if ((time - intervalTime) > ONE_DAY_TIME) {
+ if (shareItemSum == 1) {
+ AIAssist.getInstance(getContext()).speakTTSVoice(mInnerGuideVoiceStrings[1]);
+ } else {
+ AIAssist.getInstance(getContext()).speakTTSVoice(mInnerGuideVoiceStrings[2]);
+ }
+ SharedPrefsMgr.getInstance(getContext()).putLong(KEY_SHARE_INNER_GUIDE_TIME, time);
+ SharedPrefsMgr.getInstance(getContext()).putInt(KEY_SHARE_INNER_GUIDE, ++shareItemSum);
+
+ } else {
+ Logger.e(TAG, " showSlideMapVoiceGuide else < ONE_DAY_TIME ");
+ }
+ }
+ }
+ }
+
+ @Override
+ public void onTouch(MotionEvent motionEvent) {
+ switch (motionEvent.getAction()) {
+ case MotionEvent.ACTION_DOWN:
+
+ break;
+
+ case MotionEvent.ACTION_UP:
+ if (isShowGuide && isGreaterThanOneDay()) {
+ if (motionEvent.getX() > 200) {
+ showSlideMapVoiceGuide();
+ }
+ }
+
+ break;
+
+ case MotionEvent.ACTION_MOVE:
+
+ break;
+ }
}
/**
@@ -409,6 +627,7 @@ public class EntranceFragment extends MvpFragment 10021" );
+ }
}
}
@@ -498,6 +732,11 @@ public class EntranceFragment extends MvpFragment());
+ if ( DebugConfig.isSupportedSearchDestinationOnlineCarList() ) {
+ mOnlineCarEntrance.setVisibility( View.VISIBLE );
+ } else {
+ mOnlineCarEntrance.setVisibility( View.GONE );
+ }
}
@Override
@@ -507,6 +746,7 @@ public class EntranceFragment extends MvpFragment implements Weathe
public EntrancePresenter(Context context, EntranceView view) {
super(view);
mWeatherModel = new WeatherModel( getContext() );
- mNetWork =
- ((IMogoServiceApis) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(view.getContext())).getNetworkApi();
+ mNetWork = MogoApisHandler.getInstance().getApis().getNetworkApi();
}
@Override
@@ -101,6 +107,7 @@ public class EntrancePresenter extends Presenter implements Weathe
// 相当于每次onResume都会请求一下个人信息,目的是能够相对及时的同步手机端的个人信息修改
requestUserInfo();
}
+ getCommonConfig();
}
@Override
@@ -120,6 +127,51 @@ public class EntrancePresenter extends Presenter implements Weathe
}
}
+ public void getCommonConfig() {
+ Map params = new ArrayMap<>();
+ params.put("sn", Utils.getSn());
+ mNetWork.create(GetConfigApiServices.class, UserInfoConstant.getUserInfoBaseUrl())
+ .getConfig(params)
+ .subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe(new SingleObserver() {
+ @Override
+ public void onSubscribe(Disposable d) {
+ }
+
+ @Override
+ public void onSuccess(CommonConfigResponse config) {
+ Logger.d(TAG, "getCommonConfig onSuccess -----> ");
+ if (config != null && config.result != null) {
+ CommonConfig.Speech speech = config.result.speech;
+ CommonConfig.ReportStrategy strategy = config.result.reportStrategy;
+ if (speech != null) {
+ Logger.d(TAG, "getCommonConfig onSuccess speech.count = " + speech.count);
+ SharedPrefsMgr.getInstance(getContext()).putInt(KEY_SERVER_SHOW_DAY_COUNT, speech.count);
+ } else {
+ Logger.e(TAG, "getCommonConfig onSuccess speech == null ");
+ }
+
+ if (strategy != null) {
+ Logger.d(TAG, "getCommonConfig onSuccess strategy.open = " + strategy.open);
+ SharedPrefsMgr.getInstance(getContext()).putBoolean("KEY_SERVER_REPORTSTRATEGY_SWITCH", strategy.open);
+ } else {
+ Logger.e(TAG, "getCommonConfig onSuccess strategy == null ");
+ }
+ } else {
+ Logger.e(TAG, "getCommonConfig onSuccess config == null");
+ }
+ }
+
+ @Override
+ public void onError(Throwable e) {
+ e.printStackTrace();
+ Logger.e(TAG,"getCommonConfig onError ---> e = " + e);
+ }
+ });
+ }
+
+
private UserInfo userInfo;
public void requestUserInfo() {
Map params = new ArrayMap<>();
diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/net/GetConfigApiServices.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/net/GetConfigApiServices.java
new file mode 100644
index 0000000000..ab3b78a18b
--- /dev/null
+++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/net/GetConfigApiServices.java
@@ -0,0 +1,20 @@
+package com.mogo.module.extensions.net;
+
+import com.mogo.module.extensions.bean.CommonConfigResponse;
+
+import java.util.Map;
+
+import io.reactivex.Single;
+import retrofit2.http.GET;
+import retrofit2.http.QueryMap;
+
+/**
+ * 获取配置信息
+ */
+public interface GetConfigApiServices {
+
+ @GET("dataService/car/customConfig/no/getAll/v1")
+ Single getConfig(@QueryMap Map parameters);
+
+
+}
diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/utils/EntranceViewHolder.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/utils/EntranceViewHolder.java
index a9f64ad4a7..7e8670189e 100644
--- a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/utils/EntranceViewHolder.java
+++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/utils/EntranceViewHolder.java
@@ -105,4 +105,8 @@ public class EntranceViewHolder {
}
}
+ public void release(){
+ rootViewGroup = null;
+ }
+
}
diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/utils/TopViewAnimHelper.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/utils/TopViewAnimHelper.java
index 70177fc753..34481dc884 100644
--- a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/utils/TopViewAnimHelper.java
+++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/utils/TopViewAnimHelper.java
@@ -49,8 +49,8 @@ public class TopViewAnimHelper {
private TextView tvTurnInfo;
private TopView topContainer;
- private ConstraintSet constraintSet = new ConstraintSet();
- private Transition transition = new AutoTransition();
+ private ConstraintSet constraintSet;
+ private Transition transition;
private TextView cameraMode;
private float topHeight = 0f;
@@ -84,6 +84,10 @@ public class TopViewAnimHelper {
}
public void init(ConstraintLayout rootView, OnTopViewAnimSimpleListener listener) {
+
+ constraintSet = new ConstraintSet();
+ transition = new AutoTransition();
+
topMotionLayout = rootView;
naviBg = rootView.findViewById(R.id.module_map_id_navi_bg);
remainTimeGroup = rootView.findViewById(R.id.remainTimeGroup);
@@ -680,4 +684,20 @@ public class TopViewAnimHelper {
hideNaviView();
MapCenterPointStrategy.setMapCenterPointByScene(mogoMapUIController, Scene.AIMLESS);
}
+
+ public void clear(){
+ topMotionLayout = null;
+ remainTimeGroup = null;
+ remainDistanceGroup = null;
+ arriveTimeGroup = null;
+ naviBg = null;
+ ivTurnIcon = null;
+ tvNextDistance = null;
+ tvNextRoad = null;
+ tvNextDistanceUnit = null;
+ tvTurnInfo = null;
+ topContainer = null;
+ cameraMode = null;
+ transition = null;
+ }
}
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/module_ext_destination_online_car_dw.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/module_ext_destination_online_car_dw.png
new file mode 100644
index 0000000000..36a731a814
Binary files /dev/null and b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/module_ext_destination_online_car_dw.png differ
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-mdpi/module_ext_destination_online_car_dw.png b/modules/mogo-module-extensions/src/main/res/drawable-mdpi/module_ext_destination_online_car_dw.png
new file mode 100644
index 0000000000..36a731a814
Binary files /dev/null and b/modules/mogo-module-extensions/src/main/res/drawable-mdpi/module_ext_destination_online_car_dw.png differ
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-xhdpi-1920x1000/module_ext_destination_online_car_dw.png b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi-1920x1000/module_ext_destination_online_car_dw.png
new file mode 100644
index 0000000000..fcfe56f4f4
Binary files /dev/null and b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi-1920x1000/module_ext_destination_online_car_dw.png differ
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_destination_online_car_dw.png b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_destination_online_car_dw.png
new file mode 100644
index 0000000000..fcfe56f4f4
Binary files /dev/null and b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_ext_destination_online_car_dw.png differ
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_map_ic_move2_current_location.png b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_map_ic_move2_current_location.png
index 8c8ce20e1d..401802a43f 100644
Binary files a/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_map_ic_move2_current_location.png and b/modules/mogo-module-extensions/src/main/res/drawable-xhdpi/module_map_ic_move2_current_location.png differ
diff --git a/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_entrance.xml b/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_entrance.xml
index 50b4577f6e..27ee95577c 100644
--- a/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_entrance.xml
+++ b/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_entrance.xml
@@ -36,6 +36,29 @@
app:layout_goneMarginTop="@dimen/module_ext_north_goneMarginTop"
tools:visibility="visible" />
+
+
+
+ tools:visibility="gone">
10px
2px
2px
+ 4px
+ 14px
+ 14px
8px
\ No newline at end of file
diff --git a/modules/mogo-module-extensions/src/main/res/values-xhdpi-1920x1000/dimens.xml b/modules/mogo-module-extensions/src/main/res/values-xhdpi-1920x1000/dimens.xml
index d34d1a739a..75f2f2b1fa 100644
--- a/modules/mogo-module-extensions/src/main/res/values-xhdpi-1920x1000/dimens.xml
+++ b/modules/mogo-module-extensions/src/main/res/values-xhdpi-1920x1000/dimens.xml
@@ -131,7 +131,7 @@
30px
120px
120px
- 30px
+ 10px
22px
28px
28px
@@ -150,4 +150,7 @@
30px
20px
20px
+ 8px
+ 21px
+ 31px
\ No newline at end of file
diff --git a/modules/mogo-module-extensions/src/main/res/values-xhdpi/dimens.xml b/modules/mogo-module-extensions/src/main/res/values-xhdpi/dimens.xml
index ba03ec1b90..125e839721 100644
--- a/modules/mogo-module-extensions/src/main/res/values-xhdpi/dimens.xml
+++ b/modules/mogo-module-extensions/src/main/res/values-xhdpi/dimens.xml
@@ -131,7 +131,7 @@
30px
120px
120px
- 30px
+ 10px
22px
28px
28px
@@ -152,6 +152,9 @@
30px
20px
20px
+ 8px
+ 21px
+ 31px
10px
\ No newline at end of file
diff --git a/modules/mogo-module-extensions/src/main/res/values/dimens.xml b/modules/mogo-module-extensions/src/main/res/values/dimens.xml
index 696e7cb80e..bc7e325604 100644
--- a/modules/mogo-module-extensions/src/main/res/values/dimens.xml
+++ b/modules/mogo-module-extensions/src/main/res/values/dimens.xml
@@ -137,7 +137,7 @@
142px
66px
66px
- 16px
+ 10px
12px
14px
14px
@@ -146,7 +146,7 @@
58px
3dp
10px
- 4px
+ 6px
6px
10px
@@ -157,6 +157,9 @@
10px
2px
2px
+ 4px
+ 14px
+ 14px
8px
\ No newline at end of file
diff --git a/modules/mogo-module-extensions/src/main/res/values/strings.xml b/modules/mogo-module-extensions/src/main/res/values/strings.xml
index def8fbcd0e..65e4b58ae8 100644
--- a/modules/mogo-module-extensions/src/main/res/values/strings.xml
+++ b/modules/mogo-module-extensions/src/main/res/values/strings.xml
@@ -22,6 +22,7 @@
退出全览
车头
正北
+ 目的地车友
- 你好小智,播放音乐
@@ -47,4 +48,25 @@
- 你好小智,打开全部应用
- 你好小智,返回桌面
+
+
+
+ - 查询路况,唤醒小智说“天安门附近路况怎么样”
+ - 想知道出行路况,唤醒小智说“中关村堵车吗”
+ - 出行路况早知道,唤醒小智说“长安街路况怎么样”
+
+
+
+
+ - 您可以将当前的路况分享给其他车友,帮助他们获得最新的路况信息,试试对我说“上报路况”
+ - 您的分享信息将会帮助更多车友,当您发现以下交通事件,可以直接对我说上报路况
+
+
+
+
+ - 查路况您可以直接唤醒小智说“天安门附近堵不堵”
+ - 出行路况早知道,试试唤醒小智说,“附近路况怎么样”
+ - 提前看看出行路况,试试唤醒小智说,“中关村路况怎么样”
+
+
diff --git a/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/GuideBizManager.kt b/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/GuideBizManager.kt
index ce741dde37..e92db55b72 100644
--- a/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/GuideBizManager.kt
+++ b/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/GuideBizManager.kt
@@ -11,6 +11,7 @@ import com.mogo.module.guide.GuideConstant.Companion.PATH_GUIDE_MODULE_NAME
import com.mogo.module.guide.fragment.GuideFragment
import com.mogo.module.guide.util.SharedPreferenceUtil.hasGuide
import com.mogo.module.guide.util.SharedPreferenceUtil.setGuideFinish
+import com.mogo.module.guide.util.SharedPreferenceUtil.setGuideRecord
import com.mogo.service.IMogoServiceApis
import com.mogo.service.MogoServicePaths
import com.mogo.service.fragmentmanager.FragmentDescriptor
@@ -48,6 +49,7 @@ object GuideBizManager {
fun removeGuideFragmentToStack() {
Logger.d("GuideBizManager", "removeGuideFragmentToStack")
setGuideFinish()
+ setGuideRecord()
serviceApi?.let {
it.fragmentManagerApi.pop()
}
diff --git a/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/MogoGuideProvider.kt b/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/MogoGuideProvider.kt
index 85262296c0..d1a00f893e 100644
--- a/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/MogoGuideProvider.kt
+++ b/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/MogoGuideProvider.kt
@@ -5,17 +5,14 @@ import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
import com.alibaba.android.arouter.facade.annotation.Route
-import com.mogo.commons.debug.DebugConfig
import com.mogo.map.listener.IMogoMapListener
import com.mogo.map.location.IMogoLocationListener
import com.mogo.map.marker.IMogoMarkerClickListener
import com.mogo.map.navi.IMogoNaviListener
import com.mogo.module.guide.GuideConstant.Companion.PATH_GUIDE_FRAGMENT
import com.mogo.module.guide.GuideConstant.Companion.PATH_GUIDE_MODULE_NAME
-import com.mogo.module.guide.util.isDeviceOfD
import com.mogo.service.module.IMogoModuleProvider
import com.mogo.service.module.ModuleType
-import com.mogo.utils.UiThreadHandler
import com.mogo.utils.logger.Logger
@Route(path = PATH_GUIDE_FRAGMENT)
@@ -58,12 +55,7 @@ class MogoGuideProvider : IMogoModuleProvider {
override fun init(context: Context?) {
Logger.d("MogoGuideProvider", "init====")
-// if (DebugConfig.isLoadGuideModule()) {
GuideBizManager.init()
-// } else {
-// Logger.d("MogoGuideProvider", "device type is not D")
-// }
-
}
override fun getAppPackage(): String? {
diff --git a/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/fragment/GuideFragment.kt b/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/fragment/GuideFragment.kt
index 5d4054afdc..77779ede91 100644
--- a/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/fragment/GuideFragment.kt
+++ b/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/fragment/GuideFragment.kt
@@ -10,6 +10,7 @@ import com.mogo.module.guide.util.AnalyticsUtil
import com.mogo.module.guide.util.AnalyticsUtil.INVOKE_TRACK_PASS_TIME
import com.mogo.module.guide.util.AnalyticsUtil.INVOKE_TRACK_PLAY_PASS_ID
import com.mogo.module.guide.util.AnalyticsUtil.INVOKE_TRACK_PLAY_TIME
+import com.mogo.module.guide.util.breakOffSpeak
import com.mogo.module.guide.util.speak
import com.mogo.utils.logger.Logger
import com.zhpan.indicator.enums.IndicatorSlideMode
@@ -104,11 +105,6 @@ class GuideFragment : MvpFragment(), GuideC
}
private fun destroy() {
- speak(context!!, context!!.resources.getString(R.string.module_guide_voice_page_end), object : IMogoVoiceCmdCallBack {
- override fun onTTSEnd(ttsId: String?, tts: String?) {
-
- }
- })
GuideBizManager.removeGuideFragmentToStack()
}
@@ -124,6 +120,12 @@ class GuideFragment : MvpFragment(), GuideC
override fun onDestroy() {
super.onDestroy()
track()
+ breakOffSpeak(context!!)
+ speak(context!!, context!!.resources.getString(R.string.module_guide_voice_page_end), object : IMogoVoiceCmdCallBack {
+ override fun onTTSEnd(ttsId: String?, tts: String?) {
+
+ }
+ })
invokeAuthorize()
}
}
\ No newline at end of file
diff --git a/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/guide/GuideStageFiveFragment.kt b/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/guide/GuideStageFiveFragment.kt
index 814a846509..341bbda15d 100644
--- a/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/guide/GuideStageFiveFragment.kt
+++ b/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/guide/GuideStageFiveFragment.kt
@@ -1,12 +1,16 @@
package com.mogo.module.guide.guide
+import com.mogo.commons.debug.DebugConfig
import com.mogo.commons.mvp.IView
import com.mogo.commons.mvp.MvpFragment
import com.mogo.commons.mvp.Presenter
import com.mogo.commons.voice.IMogoVoiceCmdCallBack
import com.mogo.module.guide.R
import com.mogo.module.guide.fragment.GuideFragment
+import com.mogo.module.guide.util.breakOffSpeak
import com.mogo.module.guide.util.speak
+import kotlinx.android.synthetic.main.module_guide_item_stage_five.*
+import kotlinx.android.synthetic.main.module_guide_item_stage_four.*
class GuideStageFiveFragment : MvpFragment> {
@@ -25,12 +29,15 @@ class GuideStageFiveFragment : MvpFragment> {
}
override fun initViews() {
-
+ if(!DebugConfig.isLauncher()){
+ moduleGuidePageFive.background = context!!.resources!!.getDrawable(R.mipmap.module_guide_item_stage_five)
+ }
}
override fun onResume() {
super.onResume()
containerFragment?.invisibleRight()
+ breakOffSpeak(context!!)
speak(context!!, context!!.resources.getString(R.string.module_guide_voice_page_five), object : IMogoVoiceCmdCallBack {
override fun onSpeakEnd(speakText: String?) {
if(!isVisible){
diff --git a/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/guide/GuideStageFourFragment.kt b/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/guide/GuideStageFourFragment.kt
index 5770e9a986..434bb09496 100644
--- a/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/guide/GuideStageFourFragment.kt
+++ b/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/guide/GuideStageFourFragment.kt
@@ -1,12 +1,16 @@
package com.mogo.module.guide.guide
+import com.mogo.commons.debug.DebugConfig
import com.mogo.commons.mvp.IView
import com.mogo.commons.mvp.MvpFragment
import com.mogo.commons.mvp.Presenter
import com.mogo.commons.voice.IMogoVoiceCmdCallBack
import com.mogo.module.guide.R
import com.mogo.module.guide.fragment.GuideFragment
+import com.mogo.module.guide.util.breakOffSpeak
import com.mogo.module.guide.util.speak
+import kotlinx.android.synthetic.main.module_guide_item_stage_four.*
+import kotlinx.android.synthetic.main.module_guide_item_stage_three.*
class GuideStageFourFragment : MvpFragment> {
@@ -25,13 +29,16 @@ class GuideStageFourFragment : MvpFragment> {
}
override fun initViews() {
-
+ if(!DebugConfig.isLauncher()){
+ moduleGuidePageFour.background = context!!.resources!!.getDrawable(R.mipmap.module_guide_item_stage_four)
+ }
}
override fun onResume() {
super.onResume()
containerFragment?.visibleLeft()
containerFragment?.visibleRight()
+ breakOffSpeak(context!!)
speak(context!!, context!!.resources.getString(R.string.module_guide_voice_page_four), object : IMogoVoiceCmdCallBack {
override fun onSpeakEnd(speakText: String?) {
if(!isVisible){
diff --git a/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/guide/GuideStageOneFragment.kt b/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/guide/GuideStageOneFragment.kt
index 93a9f606c4..b609a9b0b0 100644
--- a/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/guide/GuideStageOneFragment.kt
+++ b/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/guide/GuideStageOneFragment.kt
@@ -1,12 +1,15 @@
package com.mogo.module.guide.guide
+import com.mogo.commons.debug.DebugConfig
import com.mogo.commons.mvp.IView
import com.mogo.commons.mvp.MvpFragment
import com.mogo.commons.mvp.Presenter
import com.mogo.commons.voice.IMogoVoiceCmdCallBack
import com.mogo.module.guide.R
import com.mogo.module.guide.fragment.GuideFragment
+import com.mogo.module.guide.util.breakOffSpeak
import com.mogo.module.guide.util.speak
+import kotlinx.android.synthetic.main.module_guide_item_stage_one.*
class GuideStageOneFragment : MvpFragment> {
@@ -27,11 +30,15 @@ class GuideStageOneFragment : MvpFragment> {
override fun initViews() {
containerFragment?.visibleRight()
+ if(!DebugConfig.isLauncher()){
+ moduleGuidePageOne.background = context!!.resources!!.getDrawable(R.mipmap.module_guide_item_stage_one)
+ }
}
override fun onResume() {
super.onResume()
containerFragment?.invisibleLeft()
+ breakOffSpeak(context!!)
speak(context!!, context!!.resources.getString(R.string.module_guide_voice_page_one), object : IMogoVoiceCmdCallBack {
override fun onSpeakEnd(speakText: String?) {
if (!isVisible) {
diff --git a/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/guide/GuideStageThreeFragment.kt b/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/guide/GuideStageThreeFragment.kt
index f8cb5fdcc3..1d8e35d73a 100644
--- a/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/guide/GuideStageThreeFragment.kt
+++ b/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/guide/GuideStageThreeFragment.kt
@@ -1,12 +1,16 @@
package com.mogo.module.guide.guide
+import com.mogo.commons.debug.DebugConfig
import com.mogo.commons.mvp.IView
import com.mogo.commons.mvp.MvpFragment
import com.mogo.commons.mvp.Presenter
import com.mogo.commons.voice.IMogoVoiceCmdCallBack
import com.mogo.module.guide.R
import com.mogo.module.guide.fragment.GuideFragment
+import com.mogo.module.guide.util.breakOffSpeak
import com.mogo.module.guide.util.speak
+import kotlinx.android.synthetic.main.module_guide_item_stage_three.*
+import kotlinx.android.synthetic.main.module_guide_item_stage_two.*
class GuideStageThreeFragment : MvpFragment> {
@@ -25,13 +29,16 @@ class GuideStageThreeFragment : MvpFragment> {
}
override fun initViews() {
-
+ if(!DebugConfig.isLauncher()){
+ moduleGuidePageThree.background = context!!.resources!!.getDrawable(R.mipmap.module_guide_item_stage_three)
+ }
}
override fun onResume() {
super.onResume()
containerFragment?.visibleLeft()
containerFragment?.visibleRight()
+ breakOffSpeak(context!!)
speak(context!!, context!!.resources.getString(R.string.module_guide_voice_page_three), object : IMogoVoiceCmdCallBack {
override fun onSpeakEnd(speakText: String?) {
if(!isVisible){
diff --git a/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/guide/GuideStageTwoFragment.kt b/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/guide/GuideStageTwoFragment.kt
index 862148061c..1986051ca3 100644
--- a/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/guide/GuideStageTwoFragment.kt
+++ b/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/guide/GuideStageTwoFragment.kt
@@ -1,12 +1,16 @@
package com.mogo.module.guide.guide
+import com.mogo.commons.debug.DebugConfig
import com.mogo.commons.mvp.IView
import com.mogo.commons.mvp.MvpFragment
import com.mogo.commons.mvp.Presenter
import com.mogo.commons.voice.IMogoVoiceCmdCallBack
import com.mogo.module.guide.R
import com.mogo.module.guide.fragment.GuideFragment
+import com.mogo.module.guide.util.breakOffSpeak
import com.mogo.module.guide.util.speak
+import kotlinx.android.synthetic.main.module_guide_item_stage_one.*
+import kotlinx.android.synthetic.main.module_guide_item_stage_two.*
class GuideStageTwoFragment : MvpFragment> {
@@ -25,13 +29,16 @@ class GuideStageTwoFragment : MvpFragment> {
}
override fun initViews() {
-
+ if(!DebugConfig.isLauncher()){
+ moduleGuidePageTwo.background = context!!.resources!!.getDrawable(R.mipmap.module_guide_item_stage_two)
+ }
}
override fun onResume() {
super.onResume()
containerFragment?.visibleLeft()
containerFragment?.visibleRight()
+ breakOffSpeak(context!!)
speak(context!!, context!!.resources.getString(R.string.module_guide_voice_page_two), object : IMogoVoiceCmdCallBack {
override fun onSpeakEnd(speakText: String?) {
if(!isVisible){
diff --git a/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/util/DeviceUtil.kt b/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/util/DeviceUtil.kt
deleted file mode 100644
index 970611850e..0000000000
--- a/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/util/DeviceUtil.kt
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.mogo.module.guide.util
-
-import com.mogo.module.common.utils.CarSeries.*
-
-fun isDeviceOfD(): Boolean {
- return when (getSeries()) {
- CAR_SERIES_D80X, CAR_SERIES_D81X, CAR_SERIES_D82X, CAR_SERIES_D84X -> true
- else -> false
- }
-}
\ No newline at end of file
diff --git a/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/util/SharedPreferenceUtil.kt b/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/util/SharedPreferenceUtil.kt
index e34e5b0bbf..ee0b39edb3 100644
--- a/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/util/SharedPreferenceUtil.kt
+++ b/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/util/SharedPreferenceUtil.kt
@@ -1,17 +1,22 @@
package com.mogo.module.guide.util
import com.mogo.commons.AbsMogoApplication
-import com.mogo.commons.debug.DebugConfig
+import com.mogo.module.common.utils.SPConst.getSPGuideRecord
+import com.mogo.module.common.utils.SPConst.getSpGuide
import com.mogo.utils.storage.SharedPrefsMgr
object SharedPreferenceUtil {
fun hasGuide(): Boolean {
- return SharedPrefsMgr.getInstance(AbsMogoApplication.getApp()).getBoolean(DebugConfig.getSpGuide(), false)
+ return SharedPrefsMgr.getInstance(AbsMogoApplication.getApp()).getBoolean(getSpGuide(), false)
}
fun setGuideFinish() {
- SharedPrefsMgr.getInstance(AbsMogoApplication.getApp()).putBoolean(DebugConfig.getSpGuide(), true)
+ SharedPrefsMgr.getInstance(AbsMogoApplication.getApp()).putBoolean(getSpGuide(), true)
+ }
+
+ fun setGuideRecord() {
+ SharedPrefsMgr.getInstance(AbsMogoApplication.getApp()).putLong(getSPGuideRecord(), System.currentTimeMillis())
}
}
\ No newline at end of file
diff --git a/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/util/VoiceUtil.kt b/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/util/VoiceUtil.kt
index c0184db527..b4d728f82e 100644
--- a/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/util/VoiceUtil.kt
+++ b/modules/mogo-module-guide/src/main/java/com/mogo/module/guide/util/VoiceUtil.kt
@@ -7,4 +7,8 @@ import com.mogo.commons.voice.VoicePreemptType
fun speak(context: Context, text: String, callBack: IMogoVoiceCmdCallBack?) {
AIAssist.getInstance(context).speakTTSVoice(text, VoicePreemptType.PREEMPT_TYPE_IMMEADIATELY, callBack)
+}
+
+fun breakOffSpeak(context: Context){
+ AIAssist.getInstance(context).breakOffSpeak()
}
\ No newline at end of file
diff --git a/modules/mogo-module-guide/src/main/res/layout/module_guide_item_adapter.xml b/modules/mogo-module-guide/src/main/res/layout/module_guide_item_adapter.xml
deleted file mode 100644
index 3509b84116..0000000000
--- a/modules/mogo-module-guide/src/main/res/layout/module_guide_item_adapter.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/modules/mogo-module-guide/src/main/res/layout/module_guide_item_stage_five.xml b/modules/mogo-module-guide/src/main/res/layout/module_guide_item_stage_five.xml
index 586f730d9b..a7842257a8 100644
--- a/modules/mogo-module-guide/src/main/res/layout/module_guide_item_stage_five.xml
+++ b/modules/mogo-module-guide/src/main/res/layout/module_guide_item_stage_five.xml
@@ -1,7 +1,8 @@
+ android:background="@mipmap/module_guide_item_stage_five_launcher">
\ No newline at end of file
diff --git a/modules/mogo-module-guide/src/main/res/layout/module_guide_item_stage_four.xml b/modules/mogo-module-guide/src/main/res/layout/module_guide_item_stage_four.xml
index 69c79b5c8c..a0a61c5541 100644
--- a/modules/mogo-module-guide/src/main/res/layout/module_guide_item_stage_four.xml
+++ b/modules/mogo-module-guide/src/main/res/layout/module_guide_item_stage_four.xml
@@ -1,6 +1,7 @@
+ android:background="@mipmap/module_guide_item_stage_four_launcher">
\ No newline at end of file
diff --git a/modules/mogo-module-guide/src/main/res/layout/module_guide_item_stage_one.xml b/modules/mogo-module-guide/src/main/res/layout/module_guide_item_stage_one.xml
index b1115882b3..217f6c1c9c 100644
--- a/modules/mogo-module-guide/src/main/res/layout/module_guide_item_stage_one.xml
+++ b/modules/mogo-module-guide/src/main/res/layout/module_guide_item_stage_one.xml
@@ -1,8 +1,9 @@
+ android:background="@mipmap/module_guide_item_stage_one_launcher">
\ No newline at end of file
diff --git a/modules/mogo-module-guide/src/main/res/layout/module_guide_item_stage_three.xml b/modules/mogo-module-guide/src/main/res/layout/module_guide_item_stage_three.xml
index 52de1ceff2..7721a4fde7 100644
--- a/modules/mogo-module-guide/src/main/res/layout/module_guide_item_stage_three.xml
+++ b/modules/mogo-module-guide/src/main/res/layout/module_guide_item_stage_three.xml
@@ -1,6 +1,7 @@
+ android:background="@mipmap/module_guide_item_stage_three_launcher">
\ No newline at end of file
diff --git a/modules/mogo-module-guide/src/main/res/layout/module_guide_item_stage_two.xml b/modules/mogo-module-guide/src/main/res/layout/module_guide_item_stage_two.xml
index 4e402f8994..4c79d09447 100644
--- a/modules/mogo-module-guide/src/main/res/layout/module_guide_item_stage_two.xml
+++ b/modules/mogo-module-guide/src/main/res/layout/module_guide_item_stage_two.xml
@@ -1,6 +1,7 @@
+ android:background="@mipmap/module_guide_item_stage_two_launcher">
\ No newline at end of file
diff --git a/modules/mogo-module-guide/src/main/res/mipmap/module_guide_item_stage_five.png b/modules/mogo-module-guide/src/main/res/mipmap-ldpi/module_guide_item_stage_five.png
similarity index 100%
rename from modules/mogo-module-guide/src/main/res/mipmap/module_guide_item_stage_five.png
rename to modules/mogo-module-guide/src/main/res/mipmap-ldpi/module_guide_item_stage_five.png
diff --git a/modules/mogo-module-guide/src/main/res/mipmap/module_guide_item_stage_four.png b/modules/mogo-module-guide/src/main/res/mipmap-ldpi/module_guide_item_stage_four.png
similarity index 100%
rename from modules/mogo-module-guide/src/main/res/mipmap/module_guide_item_stage_four.png
rename to modules/mogo-module-guide/src/main/res/mipmap-ldpi/module_guide_item_stage_four.png
diff --git a/modules/mogo-module-guide/src/main/res/mipmap/module_guide_item_stage_one.png b/modules/mogo-module-guide/src/main/res/mipmap-ldpi/module_guide_item_stage_one.png
similarity index 100%
rename from modules/mogo-module-guide/src/main/res/mipmap/module_guide_item_stage_one.png
rename to modules/mogo-module-guide/src/main/res/mipmap-ldpi/module_guide_item_stage_one.png
diff --git a/modules/mogo-module-guide/src/main/res/mipmap/module_guide_item_stage_three.png b/modules/mogo-module-guide/src/main/res/mipmap-ldpi/module_guide_item_stage_three.png
similarity index 100%
rename from modules/mogo-module-guide/src/main/res/mipmap/module_guide_item_stage_three.png
rename to modules/mogo-module-guide/src/main/res/mipmap-ldpi/module_guide_item_stage_three.png
diff --git a/modules/mogo-module-guide/src/main/res/mipmap/module_guide_item_stage_two.png b/modules/mogo-module-guide/src/main/res/mipmap-ldpi/module_guide_item_stage_two.png
similarity index 100%
rename from modules/mogo-module-guide/src/main/res/mipmap/module_guide_item_stage_two.png
rename to modules/mogo-module-guide/src/main/res/mipmap-ldpi/module_guide_item_stage_two.png
diff --git a/modules/mogo-module-guide/src/main/res/mipmap/module_guide_left_page.png b/modules/mogo-module-guide/src/main/res/mipmap-ldpi/module_guide_left_page.png
similarity index 100%
rename from modules/mogo-module-guide/src/main/res/mipmap/module_guide_left_page.png
rename to modules/mogo-module-guide/src/main/res/mipmap-ldpi/module_guide_left_page.png
diff --git a/modules/mogo-module-guide/src/main/res/mipmap/module_guide_right_page.png b/modules/mogo-module-guide/src/main/res/mipmap-ldpi/module_guide_right_page.png
similarity index 100%
rename from modules/mogo-module-guide/src/main/res/mipmap/module_guide_right_page.png
rename to modules/mogo-module-guide/src/main/res/mipmap-ldpi/module_guide_right_page.png
diff --git a/modules/mogo-module-guide/src/main/res/mipmap-mdpi/module_guide_item_stage_five_launcher.png b/modules/mogo-module-guide/src/main/res/mipmap-mdpi/module_guide_item_stage_five_launcher.png
new file mode 100644
index 0000000000..6d997bb1fd
Binary files /dev/null and b/modules/mogo-module-guide/src/main/res/mipmap-mdpi/module_guide_item_stage_five_launcher.png differ
diff --git a/modules/mogo-module-guide/src/main/res/mipmap-mdpi/module_guide_item_stage_four_launcher.png b/modules/mogo-module-guide/src/main/res/mipmap-mdpi/module_guide_item_stage_four_launcher.png
new file mode 100644
index 0000000000..b985bd68a1
Binary files /dev/null and b/modules/mogo-module-guide/src/main/res/mipmap-mdpi/module_guide_item_stage_four_launcher.png differ
diff --git a/modules/mogo-module-guide/src/main/res/mipmap-mdpi/module_guide_item_stage_one_launcher.png b/modules/mogo-module-guide/src/main/res/mipmap-mdpi/module_guide_item_stage_one_launcher.png
new file mode 100644
index 0000000000..68fa96ea17
Binary files /dev/null and b/modules/mogo-module-guide/src/main/res/mipmap-mdpi/module_guide_item_stage_one_launcher.png differ
diff --git a/modules/mogo-module-guide/src/main/res/mipmap-mdpi/module_guide_item_stage_three_launcher.png b/modules/mogo-module-guide/src/main/res/mipmap-mdpi/module_guide_item_stage_three_launcher.png
new file mode 100644
index 0000000000..67d93590b3
Binary files /dev/null and b/modules/mogo-module-guide/src/main/res/mipmap-mdpi/module_guide_item_stage_three_launcher.png differ
diff --git a/modules/mogo-module-guide/src/main/res/mipmap-mdpi/module_guide_item_stage_two_launcher.png b/modules/mogo-module-guide/src/main/res/mipmap-mdpi/module_guide_item_stage_two_launcher.png
new file mode 100644
index 0000000000..d20271f8c3
Binary files /dev/null and b/modules/mogo-module-guide/src/main/res/mipmap-mdpi/module_guide_item_stage_two_launcher.png differ
diff --git a/modules/mogo-module-guide/src/main/res/mipmap-mdpi/module_guide_left_page.png b/modules/mogo-module-guide/src/main/res/mipmap-mdpi/module_guide_left_page.png
new file mode 100644
index 0000000000..a79e3d796c
Binary files /dev/null and b/modules/mogo-module-guide/src/main/res/mipmap-mdpi/module_guide_left_page.png differ
diff --git a/modules/mogo-module-guide/src/main/res/mipmap-mdpi/module_guide_right_page.png b/modules/mogo-module-guide/src/main/res/mipmap-mdpi/module_guide_right_page.png
new file mode 100644
index 0000000000..07fed27927
Binary files /dev/null and b/modules/mogo-module-guide/src/main/res/mipmap-mdpi/module_guide_right_page.png differ
diff --git a/modules/mogo-module-guide/src/main/res/mipmap-xhdpi/module_guide_item_stage_five_launcher.png b/modules/mogo-module-guide/src/main/res/mipmap-xhdpi/module_guide_item_stage_five_launcher.png
new file mode 100644
index 0000000000..a537e7443a
Binary files /dev/null and b/modules/mogo-module-guide/src/main/res/mipmap-xhdpi/module_guide_item_stage_five_launcher.png differ
diff --git a/modules/mogo-module-guide/src/main/res/mipmap-xhdpi/module_guide_item_stage_four_launcher.png b/modules/mogo-module-guide/src/main/res/mipmap-xhdpi/module_guide_item_stage_four_launcher.png
new file mode 100644
index 0000000000..c1b4136c1c
Binary files /dev/null and b/modules/mogo-module-guide/src/main/res/mipmap-xhdpi/module_guide_item_stage_four_launcher.png differ
diff --git a/modules/mogo-module-guide/src/main/res/mipmap-xhdpi/module_guide_item_stage_one_launcher.png b/modules/mogo-module-guide/src/main/res/mipmap-xhdpi/module_guide_item_stage_one_launcher.png
new file mode 100644
index 0000000000..56fa123526
Binary files /dev/null and b/modules/mogo-module-guide/src/main/res/mipmap-xhdpi/module_guide_item_stage_one_launcher.png differ
diff --git a/modules/mogo-module-guide/src/main/res/mipmap-xhdpi/module_guide_item_stage_three_launcher.png b/modules/mogo-module-guide/src/main/res/mipmap-xhdpi/module_guide_item_stage_three_launcher.png
new file mode 100644
index 0000000000..fc75a9732e
Binary files /dev/null and b/modules/mogo-module-guide/src/main/res/mipmap-xhdpi/module_guide_item_stage_three_launcher.png differ
diff --git a/modules/mogo-module-guide/src/main/res/mipmap-xhdpi/module_guide_item_stage_two_launcher.png b/modules/mogo-module-guide/src/main/res/mipmap-xhdpi/module_guide_item_stage_two_launcher.png
new file mode 100644
index 0000000000..a9f74d11ab
Binary files /dev/null and b/modules/mogo-module-guide/src/main/res/mipmap-xhdpi/module_guide_item_stage_two_launcher.png differ
diff --git a/modules/mogo-module-guide/src/main/res/mipmap-xhdpi/module_guide_left_page.png b/modules/mogo-module-guide/src/main/res/mipmap-xhdpi/module_guide_left_page.png
new file mode 100644
index 0000000000..98ca2cb6df
Binary files /dev/null and b/modules/mogo-module-guide/src/main/res/mipmap-xhdpi/module_guide_left_page.png differ
diff --git a/modules/mogo-module-guide/src/main/res/mipmap-xhdpi/module_guide_right_page.png b/modules/mogo-module-guide/src/main/res/mipmap-xhdpi/module_guide_right_page.png
new file mode 100644
index 0000000000..f476cfc2dc
Binary files /dev/null and b/modules/mogo-module-guide/src/main/res/mipmap-xhdpi/module_guide_right_page.png differ
diff --git a/modules/mogo-module-left-panel/src/main/java/com/zhidao/mogo/module/left/panel/fragment/SimpleSpeedFragment.kt b/modules/mogo-module-left-panel/src/main/java/com/zhidao/mogo/module/left/panel/fragment/SimpleSpeedFragment.kt
index be2d724a0e..6867534ea4 100644
--- a/modules/mogo-module-left-panel/src/main/java/com/zhidao/mogo/module/left/panel/fragment/SimpleSpeedFragment.kt
+++ b/modules/mogo-module-left-panel/src/main/java/com/zhidao/mogo/module/left/panel/fragment/SimpleSpeedFragment.kt
@@ -34,4 +34,10 @@ class SimpleSpeedFragment: MvpFragment(view) {
+class SimpleSpeedPresenter(view: SimpleSpeedFragment) : Presenter(view), IDestroyable {
+
+ companion object {
+ @JvmField
+ val TAG: String = "SimpleSpeedPresenter.kt"
+ }
+
private val handler = Handler()
- private var mogoApis: IMogoServiceApis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(view.context) as IMogoServiceApis
init {
// 注册相关回调,监测速度变化
- mogoApis.registerCenterApi.registerMogoLocationListener(MODULE_NAME) {
+ MogoApisHandler.getInstance()?.apis?.registerCenterApi?.registerMogoLocationListener(MODULE_NAME) {
handler.post {
mView.refreshSpeed((it.speed * 3.6).toInt())
}
@@ -38,4 +46,9 @@ class SimpleSpeedPresenter(view: SimpleSpeedFragment) : Presenter impleme
mLeftShadowFrame.setOnClickListener( view -> {
} );
FloatingViewHandler.init( mFloatingLayout );
+
+ mServiceApis.getOnlineCarPanelApi().initContainer( R.id.module_main_id_message_history_fragment_container, this );
}
// 隐藏布局
@@ -130,15 +134,17 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
@Override
protected void onCreate( @Nullable Bundle savedInstanceState ) {
super.onCreate( savedInstanceState );
+ ContextHolderUtil.holdContext(this);
mPresenter.postLoadModuleMsg();
}
private void init() {
if ( mServiceApis == null ) {
- mServiceApis = ( IMogoServiceApis ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICE_APIS ).navigation();
+ mServiceApis = MogoApisHandler.getInstance().getApis();
}
mServiceApis.getShareManager().resetContext( this );
mServiceApis.getAuthManagerApi().showAuth( this );
+
mMogoStatusManager = mServiceApis.getStatusManagerApi();
mMogoStatusManager.setMainPageLaunchedStatus( TAG, true );
AutopilotServiceManage.getInstance().init( getContext() );
@@ -148,7 +154,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
public void loadModules() {
final long start = System.currentTimeMillis();
- MogoModulesManager.getInstance().init( this, getApis() );
+ MogoModulesManager.getInstance().init( this );
loadSplash();
mMogoMapService = mServiceApis.getMapServiceApi();
if ( mMogoMapService != null ) {
@@ -327,7 +333,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
@Override
public IMogoServiceApis getApis() {
if ( mServiceApis == null ) {
- mServiceApis = ( IMogoServiceApis ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICE_APIS ).navigation();
+ mServiceApis = MogoApisHandler.getInstance().getApis();
}
return mServiceApis;
}
@@ -335,9 +341,14 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
@Override
protected void onDestroy() {
super.onDestroy();
+ mMogoMapService.getHostListenerRegister().unregisterMarkerClickListener();
+ mMogoMapService.getHostListenerRegister().unregisterHostAimlessModeListener();
+ mMogoMapService.getHostListenerRegister().unregisterHostNaviListener();
+ mMogoMapService.getHostListenerRegister().unregisterHostMapListener();
mMogoStatusManager.setMainPageLaunchedStatus( TAG, false );
mMogoMapService = null;
mMogoMapUIController = null;
+ mMogoFragmentManager.unregisterMainFragmentStackTransactionListener();
mMogoFragmentManager = null;
mServiceApis.getMapServiceApi().getMapViewInstanceHandler().destroy();
AdasConfigApiController.getInstance().release();
@@ -345,5 +356,11 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
Logger.d( TAG, "destroy." );
mServiceApis.getRefreshStrategyControllerApi().clearAllData();
AIAssist.getInstance( this ).release();
+ mServiceApis.getOnlineCarPanelApi().clear();
+ ContextHolderUtil.releaseContext();
+ MogoModulesManager.getInstance().onDestroy();
+ SchemeIntent.getInstance().clear();
+ FloatingViewHandler.clear();
+ mServiceApis.getShareManager().releaseContext();
}
}
diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/MogoCardManager.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/MogoCardManager.java
index 69b8c1bdd9..59f7d5a63c 100644
--- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/MogoCardManager.java
+++ b/modules/mogo-module-main/src/main/java/com/mogo/module/main/MogoCardManager.java
@@ -3,15 +3,10 @@ package com.mogo.module.main;
import android.content.Context;
import com.alibaba.android.arouter.facade.annotation.Route;
-import com.mogo.module.main.livedata.CardInfo;
-import com.mogo.module.main.livedata.CardSwitchLiveData;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.cardmanager.IMogoCardChangedListener;
import com.mogo.service.cardmanager.IMogoCardManager;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
+import com.mogo.utils.logger.Logger;
/**
* @author congtaowang
@@ -19,42 +14,35 @@ import java.util.Map;
*
* 卡片控制
*/
+@Deprecated
@Route( path = MogoServicePaths.PATH_CARD_MANAGER )
public class MogoCardManager implements IMogoCardManager {
- private static final Map< String, IMogoCardChangedListener > sListeners = new HashMap<>();
+ private static final String TAG = "MogoCardManager";
@Override
public void switch2( String cardType ) {
- CardSwitchLiveData.getInstance().postValue( new CardInfo( cardType, false ) );
+ Logger.w( TAG, "Useless, do not invoke anymore." );
}
@Override
public void registerCardChangedListener( String tag, IMogoCardChangedListener listener ) {
- sListeners.put( tag, listener );
+ Logger.w( TAG, "Useless, do not invoke anymore." );
}
@Override
public void unregisterCardChangedListener( String tag ) {
- sListeners.remove( tag );
+ Logger.w( TAG, "Useless, do not invoke anymore." );
}
@Override
public void invoke( int position, String moduleName ) {
- if ( sListeners != null && !sListeners.isEmpty() ) {
- Iterator< IMogoCardChangedListener > iterator = sListeners.values().iterator();
- while ( iterator.hasNext() ) {
- IMogoCardChangedListener listener = iterator.next();
- if ( listener != null ) {
- listener.onSwitched( position, moduleName );
- }
- }
- }
+ Logger.w( TAG, "Useless, do not invoke anymore." );
}
@Override
public void switch2( String cardType, boolean lockCar ) {
- CardSwitchLiveData.getInstance().postValue( new CardInfo( cardType, lockCar ) );
+ Logger.w( TAG, "Useless, do not invoke anymore." );
}
@Override
diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/SchemeIntent.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/SchemeIntent.java
index d8e6e15f60..81d435746f 100644
--- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/SchemeIntent.java
+++ b/modules/mogo-module-main/src/main/java/com/mogo/module/main/SchemeIntent.java
@@ -6,15 +6,9 @@ import android.net.Uri;
import android.text.TextUtils;
import com.mogo.map.MogoLatLng;
-import com.mogo.module.common.ModuleNames;
-import com.mogo.module.main.livedata.CardInfo;
-import com.mogo.module.main.livedata.CardSwitchLiveData;
import com.mogo.service.IMogoServiceApis;
-import com.mogo.service.intent.IMogoIntentListener;
-import com.mogo.service.intent.IMogoIntentManager;
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
import com.mogo.service.statusmanager.StatusDescriptor;
-import com.mogo.utils.AppUtils;
import com.mogo.utils.CommonUtils;
import com.mogo.utils.TipToast;
import com.mogo.utils.UiThreadHandler;
@@ -41,21 +35,41 @@ public class SchemeIntent implements IMogoStatusChangedListener {
public static final String TYPE_LAUNCH = "launch";
+ public static final String TYPE_SHOW_ONLINE_CAR_PANEL = "showOnlineCarPanel";
+
private IMogoServiceApis mApis;
private Context mContext;
- private Intent mNextIntent;
+ private IntentWrapper mNextIntent;
- private SchemeIntent() {
- // private constructor
+ private static class IntentWrapper {
+ public Intent mIntent;
+ public long mDelay = 0L;
+
+ public IntentWrapper( Intent intent, long delay ) {
+ this.mIntent = intent;
+ this.mDelay = delay;
+ }
}
- private static final class InstanceHolder {
- private static final SchemeIntent INSTANCE = new SchemeIntent();
+ private static volatile SchemeIntent sInstance;
+
+ private SchemeIntent() {
}
public static SchemeIntent getInstance() {
- return InstanceHolder.INSTANCE;
+ if ( sInstance == null ) {
+ synchronized ( SchemeIntent.class ) {
+ if ( sInstance == null ) {
+ sInstance = new SchemeIntent();
+ }
+ }
+ }
+ return sInstance;
+ }
+
+ public synchronized void release() {
+ sInstance = null;
}
public void init( Context context, IMogoServiceApis apis ) {
@@ -64,9 +78,11 @@ public class SchemeIntent implements IMogoStatusChangedListener {
mApis.getStatusManagerApi().registerStatusChangedListener( TAG, StatusDescriptor.MAIN_PAGE_RESUME, this );
}
- private Object readResolve() {
- // 阻止反序列化,必须实现 Serializable 接口
- return InstanceHolder.INSTANCE;
+ public void clear() {
+ mApis.getStatusManagerApi().unregisterStatusChangedListener( TAG, StatusDescriptor.MAIN_PAGE_RESUME, this );
+ mContext = null;
+ mApis = null;
+
}
public void handle( Intent intent ) {
@@ -80,7 +96,11 @@ public class SchemeIntent implements IMogoStatusChangedListener {
}
if ( !mApis.getStatusManagerApi().isMainPageOnResume() ) {
- mNextIntent = intent;
+ long delay = 0L;
+ if ( isNaviIntent( intent ) ) {
+ delay = 2_000L;
+ }
+ mNextIntent = new IntentWrapper( intent, delay );
mApis.getLauncherApi().backToLauncher( mContext );
return;
}
@@ -104,20 +124,21 @@ public class SchemeIntent implements IMogoStatusChangedListener {
mNextIntent = null;
}
+ private boolean isNaviIntent( Intent intent ) {
+ if ( intent == null || intent.getData() == null ) {
+ return false;
+ }
+ Uri target = intent.getData();
+ String type = target.getQueryParameter( "type" );
+ return TextUtils.equals( TYPE_NAVI, type );
+ }
+
private void handleSwitch2Action( Uri target ) {
String type = target.getQueryParameter( "type" );
if ( TextUtils.isEmpty( type ) ) {
return;
}
switch ( type ) {
- case ModuleNames.CARD_TYPE_BUSINESS_OPERATION:
- case ModuleNames.CARD_TYPE_CARS_CHATTING:
- case ModuleNames.CARD_TYPE_NOVELTY:
- case ModuleNames.CARD_TYPE_ROAD_CONDITION:
- case ModuleNames.CARD_TYPE_SHARE_MUSIC:
- case ModuleNames.CARD_TYPE_USER_DATA:
- handleSwitchCardIntent( type );
- break;
case TYPE_NAVI:
handleNaviIntent( target );
break;
@@ -125,25 +146,23 @@ public class SchemeIntent implements IMogoStatusChangedListener {
handleLaunchIntent( target );
break;
case TYPE_SEARCH_ROAD_CONDITION:
- handleSearchRoadCondition(target);
+ handleSearchRoadCondition( target );
break;
+ case TYPE_SHOW_ONLINE_CAR_PANEL:
+ handleShowOnlineCarPanel( target );
default:
break;
}
}
- private void handleSearchRoadCondition(Uri target) {
- if (mApis == null) {
+ private void handleSearchRoadCondition( Uri target ) {
+ if ( mApis == null ) {
return;
}
- mApis.getTanluUiApi().searchRoadCondition(target.getQueryParameter("intentStr"),
- target.getQueryParameter("data"), target.getQueryParameter("city"),
- target.getQueryParameter("keywords"));
- }
-
- private void handleSwitchCardIntent( String type ) {
- CardSwitchLiveData.getInstance().postValue( new CardInfo( type, true ) );
+ mApis.getTanluUiApi().searchRoadCondition( target.getQueryParameter( "intentStr" ),
+ target.getQueryParameter( "data" ), target.getQueryParameter( "city" ),
+ target.getQueryParameter( "keywords" ) );
}
private void handleNaviIntent( Uri naviUri ) {
@@ -153,8 +172,6 @@ public class SchemeIntent implements IMogoStatusChangedListener {
String lon = naviUri.getQueryParameter( "lon" );
String lat = naviUri.getQueryParameter( "lat" );
- // TODO: 2020-04-20 补充场景
-
try {
double dlon = Double.valueOf( lon );
double dlat = Double.valueOf( lat );
@@ -178,14 +195,24 @@ public class SchemeIntent implements IMogoStatusChangedListener {
mApis.getAnalyticsApi().track( "appenterfront", properties );
}
+ private void handleShowOnlineCarPanel( Uri uri ) {
+ mApis.getOnlineCarPanelApi().showPanel();
+ }
+
@Override
public void onStatusChanged( StatusDescriptor descriptor, boolean isTrue ) {
if ( descriptor == StatusDescriptor.MAIN_PAGE_RESUME ) {
+ if ( mNextIntent == null ) {
+ return;
+ }
if ( isTrue ) {
// 保证回到桌面后在开始该规划路线。
UiThreadHandler.postDelayed( () -> {
- handle( mNextIntent );
- }, 2_000L );
+ if ( mNextIntent == null ) {
+ return;
+ }
+ handle( mNextIntent.mIntent );
+ }, mNextIntent.mDelay );
}
}
}
diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/CardIntroduceConfig.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/CardIntroduceConfig.java
deleted file mode 100644
index ef3b24ed50..0000000000
--- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/CardIntroduceConfig.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.mogo.module.main.cards;
-
-/**
- * @author congtaowang
- * @since 2020-03-27
- *
- * 卡片播报配置
- */
-public class CardIntroduceConfig {
-
- public String cardType;
- public String broadcastWords;
- public int broadcastAmount;
-
- public CardIntroduceConfig( String cardType, String broadcastWords, int broadcastAmount ) {
- this.cardType = cardType;
- this.broadcastWords = broadcastWords;
- this.broadcastAmount = broadcastAmount;
- }
-
- public CardIntroduceConfig() {
- }
-}
diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/CardIntroduceConfigs.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/CardIntroduceConfigs.java
deleted file mode 100644
index 6689415a06..0000000000
--- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/CardIntroduceConfigs.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package com.mogo.module.main.cards;
-
-import android.content.Context;
-
-import com.mogo.commons.voice.AIAssist;
-import com.mogo.commons.voice.VoicePreemptType;
-import com.mogo.map.navi.IMogoNavi;
-import com.mogo.module.common.ModuleNames;
-import com.mogo.service.IMogoServiceApis;
-import com.mogo.service.statusmanager.IMogoStatusManager;
-import com.mogo.utils.CommonUtils;
-import com.mogo.utils.WorkThreadHandler;
-import com.mogo.utils.logger.Logger;
-import com.mogo.utils.network.utils.GsonUtil;
-import com.mogo.utils.storage.SharedPrefsMgr;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author congtaowang
- * @since 2020-03-27
- *
- * 卡片播报配置
- */
-public class CardIntroduceConfigs {
-
- private static final String TAG = "CardIntroduceConfigs";
-
- public static final String KEY_VOICE_BROADCAST_CONFIG = "voice_broadcast_";
- public static String sBroadcastConfigKey;
-
- public static Map< String, CardIntroduceConfig > sConfigs = new HashMap<>();
- private static IMogoStatusManager sStatusManager;
- private static IMogoNavi sNaiv;
-
- static {
- sConfigs.put( ModuleNames.CARD_TYPE_BUSINESS_OPERATION, new CardIntroduceConfig( ModuleNames.CARD_TYPE_BUSINESS_OPERATION, "", 3 ) );
- sConfigs.put( ModuleNames.CARD_TYPE_SHARE_MUSIC, new CardIntroduceConfig( ModuleNames.CARD_TYPE_SHARE_MUSIC, "音乐新闻听书,海量资源随你选", 0 ) );
- sConfigs.put( ModuleNames.CARD_TYPE_CARS_CHATTING, new CardIntroduceConfig( ModuleNames.CARD_TYPE_CARS_CHATTING, "开车无聊,就用车聊聊", 0 ) );
- sConfigs.put( ModuleNames.CARD_TYPE_ROAD_CONDITION, new CardIntroduceConfig( ModuleNames.CARD_TYPE_ROAD_CONDITION, "随时查看路况,可以对我说某某地点堵不堵", 0 ) );
- sConfigs.put( ModuleNames.CARD_TYPE_USER_DATA, new CardIntroduceConfig( ModuleNames.CARD_TYPE_USER_DATA, "在线车辆,邀你在地图上发现万千有趣的车友", 0 ) );
- sConfigs.put( ModuleNames.CARD_TYPE_NOVELTY, new CardIntroduceConfig( ModuleNames.CARD_TYPE_NOVELTY, "新鲜事,邀你给同城车友分享沿途封路、拥堵消息", 0 ) );
- }
-
- public static void init( Context context, IMogoServiceApis apis ) {
- sStatusManager = apis.getStatusManagerApi();
- sNaiv = apis.getMapServiceApi().getNavi( context );
- WorkThreadHandler.getInstance().post( () -> {
- sBroadcastConfigKey = KEY_VOICE_BROADCAST_CONFIG + CommonUtils.getVersionCode( context );
- String configsStr = SharedPrefsMgr.getInstance( context ).getString( sBroadcastConfigKey );
- List< CardIntroduceConfig > configs = GsonUtil.arrayFromJson( configsStr, CardIntroduceConfig.class );
- if ( configs == null ) {
- return;
- }
- for ( CardIntroduceConfig config : configs ) {
- if ( config == null ) {
- return;
- }
- sConfigs.put( config.cardType, config );
- }
- } );
- }
-
- public static void broadcastCardIntroduce( Context context, String type ) {
- if ( sConfigs.get( type ) == null ) {
- Logger.d( TAG, "un support %s", type );
- return;
- }
-
- if ( sConfigs.get( type ).broadcastAmount >= 3 ) {
- Logger.d( TAG, "do not broadcastCardIntroduce %s cast amount = %s", type, type );
- return;
- }
-
- if ( sStatusManager != null ) {
- if ( !sStatusManager.isAIAssistReady() ) {
- Logger.w( TAG, "ai assist not ready: %s", type );
- return;
- }
- }
-
- if ( sNaiv.isNaviing() ) {
- Logger.d( TAG, "do not broadcastCardIntroduce cause naving" );
- return;
- }
-
- CardIntroduceConfig config = sConfigs.get( type );
- config.broadcastAmount++;
-
- Logger.d( TAG, "speak card introduce: %s", config.broadcastWords );
- AIAssist.getInstance( context ).speakTTSVoice( config.broadcastWords, VoicePreemptType.PREEMPT_TYPE_IMMEADIATELY, null );
- }
-
- public static void flush( Context context ) {
- if ( sBroadcastConfigKey == null || sConfigs.isEmpty() ) {
- return;
- }
- WorkThreadHandler.getInstance().post( () -> {
- synchronized ( sConfigs ) {
- ArrayList configs = new ArrayList( sConfigs.entrySet() );
- SharedPrefsMgr.getInstance( context ).putString( sBroadcastConfigKey, GsonUtil.jsonFromObject( configs ) );
- }
- } );
- }
-}
diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/CardModulesAdapter.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/CardModulesAdapter.java
deleted file mode 100644
index c86fb39297..0000000000
--- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/CardModulesAdapter.java
+++ /dev/null
@@ -1,87 +0,0 @@
-package com.mogo.module.main.cards;
-
-import android.os.Bundle;
-import android.text.TextUtils;
-import android.view.ViewGroup;
-
-import androidx.annotation.NonNull;
-import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentStatePagerAdapter;
-
-import com.mogo.module.main.MainActivity;
-import com.mogo.service.module.IMogoModuleProvider;
-import com.mogo.utils.logger.Logger;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author congtaowang
- * @since 2019-12-30
- *
- * 描述
- */
-public class CardModulesAdapter extends FragmentStatePagerAdapter {
-
- private static final String TAG = "CardModulesAdapter";
-
- private final MainActivity mActivity;
- private List< IMogoModuleProvider > mProviders;
-
- public CardModulesAdapter( @NonNull MainActivity fragmentActivity, List< IMogoModuleProvider > providers ) {
- super( fragmentActivity.getSupportFragmentManager() );
- mActivity = fragmentActivity;
- this.mProviders = new ArrayList<>( providers );
- }
-
- @NonNull
- @Override
- public Fragment getItem( int position ) {
- Logger.i( TAG, "current position: %d", position );
- int factPosition = getFactPosition( position );
- Bundle bundle = new Bundle();
- bundle.putInt( "position", factPosition );
- final Fragment f = mProviders.get( factPosition ).createFragment( mActivity, bundle );
- return f;
- }
-
- @Override
- public int getCount() {
- return mProviders.size();
-// return Integer.MAX_VALUE;
- }
-
- public IMogoModuleProvider getProvider( int position ) {
- return mProviders.get( getFactPosition( position ) );
- }
-
- public int getFactPosition( int position ) {
- return position % mProviders.size();
- }
-
- @Override
- public int getItemPosition( Object object ) {
- return POSITION_NONE;
- }
-
- /**
- * 获取对应卡片类型在列表中的位置
- *
- * @param tag 卡片类型
- * @return 列表中的位置
- */
- public int getProviderPosition( String tag ) {
- if ( mProviders != null ) {
- for ( int i = 0; i < mProviders.size(); i++ ) {
- IMogoModuleProvider provider = mProviders.get( i );
- if ( provider != null ) {
- if ( TextUtils.equals( provider.getModuleName(), tag ) ) {
- return i;
- }
- }
- }
- }
- return -1;
- }
-
-}
diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/HorizentalBaseTransformer.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/HorizentalBaseTransformer.java
deleted file mode 100644
index 3983ef6b56..0000000000
--- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/HorizentalBaseTransformer.java
+++ /dev/null
@@ -1,110 +0,0 @@
-
-package com.mogo.module.main.cards;
-
-import android.view.View;
-import androidx.viewpager.widget.ViewPager;
-
-/**
- * Created by Nate on 2016/7/22.
- */
-public abstract class HorizentalBaseTransformer implements ViewPager.PageTransformer {
- /**
- * Called each {@link #transformPage(View, float)}.
- *
- * @param page Apply the transformation to this page
- * @param position Position of page relative to the current front-and-center position of the pager. 0 is front and
- * center. 1 is one full page position to the right, and -1 is one page position to the left.
- */
- protected abstract void onTransform(View page, float position);
-
- /**
- * Apply a property transformation to the given page. For most use cases, this method should not be overridden.
- * Instead use {@link #transformPage(View, float)} to perform typical transformations.
- *
- * @param page Apply the transformation to this page
- * @param position Position of page relative to the current front-and-center position of the pager. 0 is front and
- * center. 1 is one full page position to the right, and -1 is one page position to the left.
- */
- @Override
- public void transformPage(View page, float position) {
- onPreTransform(page, position);
- onTransform(page, position);
- onPostTransform(page, position);
- }
-
- /**
- * If the position offset of a fragment is less than negative one or greater than one, returning true will set the
- * fragment alpha to 0f. Otherwise fragment alpha is always defaulted to 1f.
- *
- * @return
- */
- protected boolean hideOffscreenPages() {
- return true;
- }
-
- /**
- * Indicates if the default animations of the view pager should be used.
- *
- * @return
- */
- protected boolean isPagingEnabled() {
- return false;
- }
-
- /**
- * Called each {@link #transformPage(View, float)} before {{@link #onTransform(View, float)}.
- *
- * The default implementation attempts to reset all view properties. This is useful when toggling transforms that do
- * not modify the same page properties. For instance changing from a transformation that applies rotation to a
- * transformation that fades can inadvertently leave a fragment stuck with a rotation or with some degree of applied
- * alpha.
- *
- * @param page Apply the transformation to this page
- * @param position Position of page relative to the current front-and-center position of the pager. 0 is front and
- * center. 1 is one full page position to the right, and -1 is one page position to the left.
- */
- protected void onPreTransform(View page, float position) {
- final float width = page.getWidth();
- //final float height = page.getHeight();
-
- page.setRotationX(0);
- page.setRotationY(0);
- page.setRotation(0);
- page.setScaleX(1);
- page.setScaleY(1);
- page.setPivotX(0);
- page.setPivotY(0);
- page.setTranslationY(0);
- page.setTranslationX(isPagingEnabled() ? 0f : -width * position);
-
- if (hideOffscreenPages()) {
- page.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
- } else {
- page.setAlpha(1f);
- }
-
- /*final float normalizedposition = Math.abs(Math.abs(position) - 1);
- page.setAlpha(normalizedposition);*/
- }
-
- /**
- * Called each {@link #transformPage(View, float)} after {@link #onTransform(View, float)}.
- *
- * @param page Apply the transformation to this page
- * @param position Position of page relative to the current front-and-center position of the pager. 0 is front and
- * center. 1 is one full page position to the right, and -1 is one page position to the left.
- */
- protected void onPostTransform(View page, float position) {
- }
-
- /**
- * Same as {@link Math#min(double, double)} without double casting, zero closest to infinity handling, or NaN support.
- *
- * @param val
- * @param min
- * @return
- */
- protected static final float min(float val, float min) {
- return val < min ? min : val;
- }
-}
\ No newline at end of file
diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/HorizentalStackTransformer.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/HorizentalStackTransformer.java
deleted file mode 100644
index bec1449b7c..0000000000
--- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/HorizentalStackTransformer.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package com.mogo.module.main.cards;
-
-import android.content.Context;
-import android.view.View;
-import com.mogo.module.main.R;
-import com.mogo.utils.logger.Logger;
-
-public class HorizentalStackTransformer extends HorizentalBaseTransformer {
-
- private Context context;
- private int spaceBetweenFirAndSecWith;//第一张卡片和第二张卡片宽度差
- private int spaceBetweenFirAndSecHeight;//第一张卡片和第二张卡片高度差
- private float offsetScroll = 0.0f;//ViewPager滑动时变化幅度
-
- public HorizentalStackTransformer( Context context ) {
- this.context = context;
- spaceBetweenFirAndSecHeight = 0;
- spaceBetweenFirAndSecWith = context.getResources().getDimensionPixelSize( R.dimen.module_main_card_card_shadow_width_div );
- }
-
- public HorizentalStackTransformer( Context context, int spaceBetweenFirAndSecWith, int spaceBetweenFirAndSecHeight ) {
- this.context = context;
- this.spaceBetweenFirAndSecWith = spaceBetweenFirAndSecWith;
- this.spaceBetweenFirAndSecHeight = spaceBetweenFirAndSecHeight;
- }
-
- public void offsetScrollChanged(float offset){
- if(offset ==0){
- return;
- }
- offsetScroll = offset;
- }
-
- public void resetOffsetScroll(){
- offsetScroll = 0.0f;
- }
-
- @Override
- protected void onTransform( View page, float position ) {
- if ( position == 0.0f ) {
- page.setAlpha( 1.0f );
- page.setTranslationX( 0f );
- //控制停止滑动切换的时候,只有最上面的一张卡片可以点击
- page.setClickable( true );
- } else if(position>0){
- float scale = ( float ) ( page.getWidth() - spaceBetweenFirAndSecWith * position ) / ( float ) ( page.getWidth() );
- Logger.d("VerticalStackTransformer","scale :" + scale);
- //控制下面卡片的可见度
- page.setAlpha( 1.0f );
- //控制停止滑动切换的时候,只有最上面的一张卡片可以点击
- page.setClickable( false );
- page.setPivotX( page.getWidth() / 2f );
- page.setPivotY( page.getHeight() / 2f );
- page.setScaleX( scale );
- page.setScaleY( scale );
- page.setTranslationX( -page.getHeight() * position + ( page.getHeight() * 0.5f ) * ( 1 - scale ) + spaceBetweenFirAndSecHeight * position );
- }else{
- float currentPage;
- if(offsetScroll > 0.1f){
- currentPage = 0.1f;
- }else{
- currentPage = offsetScroll;
- }
- page.setAlpha( 1 );
- page.setScaleX(1-currentPage);
- page.setScaleY(1-currentPage);
- page.setPivotX( page.getWidth() / 2f );
- page.setPivotY( page.getHeight() / 2f );
- page.setTranslationX( 0f );
- page.setClickable( false );
- }
- }
-}
\ No newline at end of file
diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/MogoModulesHandler.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/MogoModulesHandler.java
index c07373d5d7..442e314597 100644
--- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/MogoModulesHandler.java
+++ b/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/MogoModulesHandler.java
@@ -38,13 +38,6 @@ public interface MogoModulesHandler {
*/
void loadAppsListModule( int containerId );
- /**
- * 加载头部信息
- *
- * @param containerId
- */
- void loadExtensionsModule( int containerId );
-
/**
* 加载快捷操作
*
@@ -77,4 +70,9 @@ public interface MogoModulesHandler {
* @param containerId
*/
void loadSplashModule(int containerId);
+
+ /**
+ * 释放各个模块资源
+ */
+ void onDestroy();
}
diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/MogoModulesManager.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/MogoModulesManager.java
index 355c6324b5..7d548c7b94 100644
--- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/MogoModulesManager.java
+++ b/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/MogoModulesManager.java
@@ -1,10 +1,12 @@
package com.mogo.module.main.cards;
+import android.app.Application;
import android.content.Context;
import androidx.fragment.app.Fragment;
import com.alibaba.android.arouter.launcher.ARouter;
+import com.alibaba.idst.nls.internal.utils.L;
import com.mogo.module.common.MogoModule;
import com.mogo.module.common.MogoModulePaths;
import com.mogo.module.extensions.ExtensionsModuleConst;
@@ -16,6 +18,7 @@ import com.mogo.utils.ResourcesHelper;
import com.mogo.utils.logger.Logger;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -31,6 +34,7 @@ public class MogoModulesManager implements MogoModulesHandler {
private static final String TAG = "MogoModulesManager";
private MainActivity mActivity;
+ private Application mApp;
private Map< MogoModule, IMogoModuleProvider > mModuleProviders = new HashMap<>();
// 空间换效率
@@ -56,19 +60,20 @@ public class MogoModulesManager implements MogoModulesHandler {
sInstance = null;
}
- public void init( MainActivity activity, IMogoServiceApis apis ) {
+ public void init( MainActivity activity ) {
if ( activity == null ) {
throw new NullPointerException( "activity can't be null." );
}
this.mActivity = activity;
+ mApp = mActivity.getApplication();
}
private Context getContext() {
- return mActivity;
+ return getApplicationContext();
}
private Context getApplicationContext() {
- return mActivity.getApplicationContext();
+ return mApp;
}
@Override
@@ -100,6 +105,7 @@ public class MogoModulesManager implements MogoModulesHandler {
@Override
public void loadMapModule( int containerId ) {
+ Logger.d( TAG, "loadMapModule" );
IMogoModuleProvider provider = ( IMogoModuleProvider ) ARouter.getInstance()
.build( MogoModulePaths.PATH_MODULE_MAP )
.navigation( getContext() );
@@ -114,14 +120,6 @@ public class MogoModulesManager implements MogoModulesHandler {
addFragment( provider, containerId );
}
- @Override
- public void loadExtensionsModule( int containerId ) {
- IMogoModuleProvider provider = ( IMogoModuleProvider ) ARouter.getInstance()
- .build( ExtensionsModuleConst.PATH_EXTENSION )
- .navigation( getContext() );
- addFragment( provider, containerId );
- }
-
@Override
public void loadEntrancesModule( int containerId ) {
IMogoModuleProvider provider = ( IMogoModuleProvider ) ARouter.getInstance()
@@ -131,25 +129,25 @@ public class MogoModulesManager implements MogoModulesHandler {
}
@Override
- public void loadEventPanelModule(int containerId) {
+ public void loadEventPanelModule( int containerId ) {
IMogoModuleProvider provider = ( IMogoModuleProvider ) ARouter.getInstance()
- .build(MogoServicePaths.PATH_EVENT_PANEL)
+ .build( MogoServicePaths.PATH_EVENT_PANEL )
.navigation( getContext() );
addFragment( provider, containerId );
}
@Override
- public void loadLeftPanelModule(int containerId) {
+ public void loadLeftPanelModule( int containerId ) {
IMogoModuleProvider provider = ( IMogoModuleProvider ) ARouter.getInstance()
- .build(MogoServicePaths.PATH_LEFT_PANEL)
+ .build( MogoServicePaths.PATH_LEFT_PANEL )
.navigation( getContext() );
addFragment( provider, containerId );
}
@Override
- public void loadSplashModule(int containerId) {
+ public void loadSplashModule( int containerId ) {
IMogoModuleProvider provider = ( IMogoModuleProvider ) ARouter.getInstance()
- .build(MogoServicePaths.PATH_SPLASH)
+ .build( MogoServicePaths.PATH_SPLASH )
.navigation( getContext() );
addFragment( provider, containerId );
}
@@ -179,7 +177,11 @@ public class MogoModulesManager implements MogoModulesHandler {
Logger.e( TAG, "add fragment fail cause provider == null, container is %s", ResourcesHelper.getResNameById( getApplicationContext(), containerId ) );
return;
}
- final Fragment fragment = provider.createFragment( getContext(), null );
+ Fragment fragment = null;
+ fragment = mActivity.getSupportFragmentManager().findFragmentByTag( provider.getModuleName() );
+ if ( fragment == null ) {
+ fragment = provider.createFragment( getContext(), null );
+ }
if ( fragment == null ) {
Logger.e( TAG, "add fragment fail cause fragment == null, container is %s", ResourcesHelper.getResNameById( getApplicationContext(), containerId ) );
return;
@@ -188,4 +190,26 @@ public class MogoModulesManager implements MogoModulesHandler {
.replace( containerId, fragment, provider.getModuleName() )
.commitAllowingStateLoss();
}
+
+ @Override
+ public void onDestroy() {
+ if ( mModuleNameProviders != null ) {
+ Collection< IMogoModuleProvider > modules = mModuleNameProviders.values();
+ if ( modules != null ) {
+ for ( IMogoModuleProvider module : modules ) {
+ try {
+ Logger.d( TAG, "destroy module: " + module.getModuleName() );
+ module.onDestroy();
+ } catch ( Exception e ) {
+ Logger.e( TAG, e, "onDestroy" );
+ }
+ }
+ }
+ mModuleNameProviders.clear();
+ }
+ if ( mModuleProviders != null ) {
+ mModuleProviders.clear();
+ }
+ mActivity = null;
+ }
}
diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/OnPageChangeListenerAdapter.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/OnPageChangeListenerAdapter.java
deleted file mode 100644
index f43f436c6e..0000000000
--- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/OnPageChangeListenerAdapter.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.mogo.module.main.cards;
-
-import androidx.viewpager.widget.ViewPager;
-
-/**
- * @author congtaowang
- * @since 2020-01-06
- *
- * 描述
- */
-public class OnPageChangeListenerAdapter implements ViewPager.OnPageChangeListener {
-
- @Override
- public void onPageScrolled( int position, float positionOffset, int positionOffsetPixels ) {
-
- }
-
- @Override
- public void onPageSelected( int position ) {
-
- }
-
- @Override
- public void onPageScrollStateChanged( int state ) {
-
- }
-}
diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/OrientedViewPager.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/OrientedViewPager.java
deleted file mode 100644
index 35680f3336..0000000000
--- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/OrientedViewPager.java
+++ /dev/null
@@ -1,3390 +0,0 @@
-package com.mogo.module.main.cards;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.content.res.TypedArray;
-import android.database.DataSetObserver;
-import android.graphics.Canvas;
-import android.graphics.Rect;
-import android.graphics.drawable.Drawable;
-import android.os.Build;
-import android.os.Bundle;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.os.SystemClock;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.view.FocusFinder;
-import android.view.Gravity;
-import android.view.KeyEvent;
-import android.view.MotionEvent;
-import android.view.SoundEffectConstants;
-import android.view.VelocityTracker;
-import android.view.View;
-import android.view.ViewConfiguration;
-import android.view.ViewGroup;
-import android.view.ViewParent;
-import android.view.accessibility.AccessibilityEvent;
-import android.view.animation.Interpolator;
-import android.widget.Scroller;
-
-import androidx.core.view.AccessibilityDelegateCompat;
-import androidx.core.view.MotionEventCompat;
-import androidx.core.view.VelocityTrackerCompat;
-import androidx.core.view.ViewCompat;
-import androidx.core.view.ViewConfigurationCompat;
-import androidx.core.view.accessibility.AccessibilityEventCompat;
-import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
-import androidx.core.view.accessibility.AccessibilityRecordCompat;
-import androidx.core.widget.EdgeEffectCompat;
-import androidx.viewpager.widget.PagerAdapter;
-import androidx.viewpager.widget.ViewPager;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-
-/**
- * Created by Bartosz Lipinski
- * Based on castorflex's VerticalViewPager (https://github.com/castorflex/VerticalViewPager)
- *
- * 03.05.15
- */
-public class OrientedViewPager extends ViewGroup {
-
- public enum Orientation {
- VERTICAL, HORIZONTAL
- }
-
- private static final String TAG = "ViewPager";
- private static final boolean DEBUG = false;
-
- private static final boolean USE_CACHE = false;
-
- private static final int DEFAULT_OFFSCREEN_PAGES = 1;
- private static final int MAX_SETTLE_DURATION = 600; // ms
- private static final int MIN_DISTANCE_FOR_FLING = 25; // dips
-
- private static final int DEFAULT_GUTTER_SIZE = 16; // dips
-
- private static final int MIN_FLING_VELOCITY = 400; // dips
-
- private static final int[] LAYOUT_ATTRS = new int[] {
- android.R.attr.layout_gravity
- };
-
- /**
- * Used to track what the expected number of items in the adapter should be.
- * If the app changes this when we don't expect it, we'll throw a big obnoxious exception.
- */
- private int mExpectedAdapterCount;
-
- private static class ItemInfo {
- Object object;
- int position;
- boolean scrolling;
- float sizeFactor;
- float offset;
- }
-
- private static final Comparator COMPARATOR = new Comparator() {
- @Override
- public int compare(ItemInfo lhs, ItemInfo rhs) {
- return lhs.position - rhs.position;
- }
- };
-
- private static final Interpolator sInterpolator = new Interpolator() {
- public float getInterpolation(float t) {
- t -= 1.0f;
- return t * t * t * t * t + 1.0f;
- }
- };
-
- private final ArrayList mItems = new ArrayList();
- private final ItemInfo mTempItem = new ItemInfo();
-
- private final Rect mTempRect = new Rect();
-
- private Orientation mOrientation = Orientation.HORIZONTAL;
-
- private PagerAdapter mAdapter;
- private int mCurItem; // Index of currently displayed page.
- private int mRestoredCurItem = -1;
- private Parcelable mRestoredAdapterState = null;
- private ClassLoader mRestoredClassLoader = null;
- private Scroller mScroller;
- private PagerObserver mObserver;
-
- private int mPageMargin;
- private Drawable mMarginDrawable;
- private int mTopLeftPageBounds;
- private int mBottomRightPageBounds;
-
- // Offsets of the first and last items, if known.
- // Set during population, used to determine if we are at the beginning
- // or end of the pager data set during touch scrolling.
- private float mFirstOffset = -Float.MAX_VALUE;
- private float mLastOffset = Float.MAX_VALUE;
-
- private int mChildWidthMeasureSpec;
- private int mChildHeightMeasureSpec;
- private boolean mInLayout;
-
- private boolean mScrollingCacheEnabled;
-
- private boolean mPopulatePending;
- private int mOffscreenPageLimit = DEFAULT_OFFSCREEN_PAGES;
-
- private boolean mIsBeingDragged;
- private boolean mIsUnableToDrag;
- private boolean mIgnoreGutter;
- private int mDefaultGutterSize;
- private int mGutterSize;
- private int mTouchSlop;
- /**
- * Position of the last motion event.
- */
- private float mLastMotionX;
- private float mLastMotionY;
- private float mInitialMotionX;
- private float mInitialMotionY;
- /**
- * ID of the active pointer. This is used to retain consistency during
- * drags/flings if multiple pointers are used.
- */
- private int mActivePointerId = INVALID_POINTER;
- /**
- * Sentinel value for no current active pointer.
- * Used by {@link #mActivePointerId}.
- */
- private static final int INVALID_POINTER = -1;
-
- /**
- * Determines speed during touch scrolling
- */
- private VelocityTracker mVelocityTracker;
- private int mMinimumVelocity;
- private int mMaximumVelocity;
- private int mFlingDistance;
- private int mCloseEnough;
-
- // If the pager is at least this close to its final position, complete the scroll
- // on touch down and let the user interact with the content inside instead of
- // "catching" the flinging pager.
- private static final int CLOSE_ENOUGH = 2; // dp
-
- private boolean mFakeDragging;
- private long mFakeDragBeginTime;
-
- private EdgeEffectCompat mTopLeftEdge;
- private EdgeEffectCompat mRightBottomEdge;
-
- private boolean mFirstLayout = true;
- private boolean mNeedCalculatePageOffsets = false;
- private boolean mCalledSuper;
- private int mDecorChildCount;
-
- private ViewPager.OnPageChangeListener mOnPageChangeListener;
- private ViewPager.OnPageChangeListener mInternalPageChangeListener;
- private OnAdapterChangeListener mAdapterChangeListener;
- private ViewPager.PageTransformer mPageTransformer;
- private Method mSetChildrenDrawingOrderEnabled;
-
- private static final int DRAW_ORDER_DEFAULT = 0;
- private static final int DRAW_ORDER_FORWARD = 1;
- private static final int DRAW_ORDER_REVERSE = 2;
- private int mDrawingOrder;
- private ArrayList mDrawingOrderedChildren;
- private static final ViewPositionComparator sPositionComparator = new ViewPositionComparator();
-
- /**
- * Indicates that the pager is in an idle, settled state. The current page
- * is fully in view and no animation is in progress.
- */
- public static final int SCROLL_STATE_IDLE = 0;
-
- /**
- * Indicates that the pager is currently being dragged by the user.
- */
- public static final int SCROLL_STATE_DRAGGING = 1;
-
- /**
- * Indicates that the pager is in the process of settling to a final position.
- */
- public static final int SCROLL_STATE_SETTLING = 2;
-
- private final Runnable mEndScrollRunnable = new Runnable() {
- public void run() {
- setScrollState(SCROLL_STATE_IDLE);
- populate();
- }
- };
-
- private int mScrollState = SCROLL_STATE_IDLE;
-
- /**
- * Used internally to monitor when adapters are switched.
- */
- interface OnAdapterChangeListener {
- public void onAdapterChanged(PagerAdapter oldAdapter, PagerAdapter newAdapter);
- }
-
- /**
- * Used internally to mTag special types of child views that should be added as
- * pager decorations by default.
- */
- interface Decor {
- }
-
- public OrientedViewPager(Context context) {
- super(context);
- initViewPager();
- }
-
- public OrientedViewPager(Context context, AttributeSet attrs) {
- super(context, attrs);
- initViewPager();
- }
-
- void initViewPager() {
- setWillNotDraw(false);
- setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
- setFocusable(true);
- final Context context = getContext();
- mScroller = new Scroller(context, sInterpolator);
- final ViewConfiguration configuration = ViewConfiguration.get(context);
- final float density = context.getResources().getDisplayMetrics().density;
-
- mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
- mMinimumVelocity = (int) (MIN_FLING_VELOCITY * density);
- mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
- mTopLeftEdge = new EdgeEffectCompat(context);
- mRightBottomEdge = new EdgeEffectCompat(context);
-
- mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
- mCloseEnough = (int) (CLOSE_ENOUGH * density);
- mDefaultGutterSize = (int) (DEFAULT_GUTTER_SIZE * density);
-
- ViewCompat.setAccessibilityDelegate(this, new MyAccessibilityDelegate());
-
- if (ViewCompat.getImportantForAccessibility(this)
- == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
- ViewCompat.setImportantForAccessibility(this,
- ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
- }
- }
-
- public void setOrientation(Orientation orientation) {
- mOrientation = orientation;
- }
-
- @Override
- protected void onDetachedFromWindow() {
- removeCallbacks(mEndScrollRunnable);
- super.onDetachedFromWindow();
- }
-
- private void setScrollState(int newState) {
- if (mScrollState == newState) {
- return;
- }
-
- mScrollState = newState;
- if (mPageTransformer != null) {
- // PageTransformers can do complex things that benefit from hardware layers.
- enableLayers(newState != SCROLL_STATE_IDLE);
- }
- if (mOnPageChangeListener != null) {
- mOnPageChangeListener.onPageScrollStateChanged(newState);
- }
- }
-
- /**
- * Set a PagerAdapter that will supply views for this pager as needed.
- *
- * @param adapter Adapter to use
- */
- public void setAdapter(PagerAdapter adapter) {
- if (mAdapter != null) {
- mAdapter.unregisterDataSetObserver(mObserver);
- mAdapter.startUpdate(this);
- for (int i = 0; i < mItems.size(); i++) {
- final ItemInfo ii = mItems.get(i);
- mAdapter.destroyItem(this, ii.position, ii.object);
- }
- mAdapter.finishUpdate(this);
- mItems.clear();
- removeNonDecorViews();
- mCurItem = 0;
- scrollTo(0, 0);
- }
-
- final PagerAdapter oldAdapter = mAdapter;
- mAdapter = adapter;
- mExpectedAdapterCount = 0;
-
- if (mAdapter != null) {
- if (mObserver == null) {
- mObserver = new PagerObserver();
- }
- mAdapter.registerDataSetObserver(mObserver);
- mPopulatePending = false;
- final boolean wasFirstLayout = mFirstLayout;
- mFirstLayout = true;
- mExpectedAdapterCount = mAdapter.getCount();
- if (mRestoredCurItem >= 0) {
- mAdapter.restoreState(mRestoredAdapterState, mRestoredClassLoader);
- setCurrentItemInternal(mRestoredCurItem, false, true);
- mRestoredCurItem = -1;
- mRestoredAdapterState = null;
- mRestoredClassLoader = null;
- } else if (!wasFirstLayout) {
- populate();
- } else {
- requestLayout();
- }
- }
-
- if (mAdapterChangeListener != null && oldAdapter != adapter) {
- mAdapterChangeListener.onAdapterChanged(oldAdapter, adapter);
- }
- }
-
- private void removeNonDecorViews() {
- for (int i = 0; i < getChildCount(); i++) {
- final View child = getChildAt(i);
- final LayoutParams lp = (LayoutParams) child.getLayoutParams();
- if (!lp.isDecor) {
- removeViewAt(i);
- i--;
- }
- }
- }
-
- /**
- * Retrieve the current adapter supplying pages.
- *
- * @return The currently registered PagerAdapter
- */
- public PagerAdapter getAdapter() {
- return mAdapter;
- }
-
- void setOnAdapterChangeListener(OnAdapterChangeListener listener) {
- mAdapterChangeListener = listener;
- }
-
- private int getClientSize() {
- return (mOrientation == Orientation.VERTICAL) ?
- getMeasuredHeight() - getPaddingTop() - getPaddingBottom() :
- getMeasuredWidth() - getPaddingLeft() - getPaddingRight();
- }
-
- /**
- * Set the currently selected page. If the ViewPager has already been through its first
- * layout with its current adapter there will be a smooth animated transition between
- * the current item and the specified item.
- *
- * @param item Item index to select
- */
- public void setCurrentItem(int item) {
- mPopulatePending = false;
- setCurrentItemInternal(item, !mFirstLayout, false);
- }
-
- /**
- * Set the currently selected page.
- *
- * @param item Item index to select
- * @param smoothScroll True to smoothly scroll to the new item, false to transition immediately
- */
- public void setCurrentItem(int item, boolean smoothScroll) {
- mPopulatePending = false;
- setCurrentItemInternal(item, smoothScroll, false);
- }
-
- public int getCurrentItem() {
- return mCurItem;
- }
-
- void setCurrentItemInternal(int item, boolean smoothScroll, boolean always) {
- setCurrentItemInternal(item, smoothScroll, always, 0);
- }
-
- void setCurrentItemInternal(int item, boolean smoothScroll, boolean always, int velocity) {
- if (mAdapter == null || mAdapter.getCount() <= 0) {
- setScrollingCacheEnabled(false);
- return;
- }
- if (!always && mCurItem == item && mItems.size() != 0) {
- setScrollingCacheEnabled(false);
- return;
- }
-
- if (item < 0) {
- item = 0;
- } else if (item >= mAdapter.getCount()) {
- item = mAdapter.getCount() - 1;
- }
- final int pageLimit = mOffscreenPageLimit;
- if (item > (mCurItem + pageLimit) || item < (mCurItem - pageLimit)) {
- // We are doing a jump by more than one page. To avoid
- // glitches, we want to keep all current pages in the view
- // until the scroll ends.
- for (int i = 0; i < mItems.size(); i++) {
- mItems.get(i).scrolling = true;
- }
- }
- final boolean dispatchSelected = mCurItem != item;
-
- if (mFirstLayout) {
- // We don't have any idea how big we are yet and shouldn't have any pages either.
- // Just set things up and let the pending layout handle things.
- mCurItem = item;
- if (dispatchSelected && mOnPageChangeListener != null) {
- mOnPageChangeListener.onPageSelected(item);
- }
- if (dispatchSelected && mInternalPageChangeListener != null) {
- mInternalPageChangeListener.onPageSelected(item);
- }
- requestLayout();
- } else {
- populate(item);
- scrollToItem(item, smoothScroll, velocity, dispatchSelected);
- }
- }
-
- private void scrollToItem(int item, boolean smoothScroll, int velocity,
- boolean dispatchSelected) {
- final ItemInfo curInfo = infoForPosition(item);
- int dest = 0;
- if (curInfo != null) {
- final int size = getClientSize();
- dest = (int) (size * Math.max(mFirstOffset,
- Math.min(curInfo.offset, mLastOffset)));
- }
- if (smoothScroll) {
- if (mOrientation == Orientation.VERTICAL) {
- smoothScrollTo(0, dest, velocity);
- } else {
- smoothScrollTo(dest, 0, velocity);
- }
- if (dispatchSelected && mOnPageChangeListener != null) {
- mOnPageChangeListener.onPageSelected(item);
- }
- if (dispatchSelected && mInternalPageChangeListener != null) {
- mInternalPageChangeListener.onPageSelected(item);
- }
- } else {
- if (dispatchSelected && mOnPageChangeListener != null) {
- mOnPageChangeListener.onPageSelected(item);
- }
- if (dispatchSelected && mInternalPageChangeListener != null) {
- mInternalPageChangeListener.onPageSelected(item);
- }
- completeScroll(false);
- if (mOrientation == Orientation.VERTICAL) {
- scrollTo(0, dest);
- } else {
- scrollTo(dest, 0);
- }
- pageScrolled(dest);
- }
- }
-
- /**
- * Set a listener that will be invoked whenever the page changes or is incrementally
- * scrolled. See {@link androidx.viewpager.widget.ViewPager.OnPageChangeListener}.
- *
- * @param listener Listener to set
- */
- public void setOnPageChangeListener(ViewPager.OnPageChangeListener listener) {
- mOnPageChangeListener = listener;
- }
-
- /**
- * Set a {@link androidx.viewpager.widget.ViewPager.PageTransformer} that will be called for each
- * attached page whenever
- * the scroll position is changed. This allows the application to apply custom property
- * transformations to each page, overriding the default sliding look and feel.
- *
- * Note: Prior to Android 3.0 the property animation APIs did not exist.
- * As a result, setting a PageTransformer prior to Android 3.0 (API 11) will have no effect.
- *
- * @param reverseDrawingOrder true if the supplied PageTransformer requires page views
- * to be drawn from last to first instead of first to last.
- * @param transformer PageTransformer that will modify each page's animation properties
- */
- public void setPageTransformer(boolean reverseDrawingOrder,
- ViewPager.PageTransformer transformer) {
- if (Build.VERSION.SDK_INT >= 11) {
- final boolean hasTransformer = transformer != null;
- final boolean needsPopulate = hasTransformer != (mPageTransformer != null);
- mPageTransformer = transformer;
- setChildrenDrawingOrderEnabledCompat(hasTransformer);
- if (hasTransformer) {
- mDrawingOrder = reverseDrawingOrder ? DRAW_ORDER_REVERSE : DRAW_ORDER_FORWARD;
- } else {
- mDrawingOrder = DRAW_ORDER_DEFAULT;
- }
- if (needsPopulate) populate();
- }
- }
-
- void setChildrenDrawingOrderEnabledCompat(boolean enable) {
- if (Build.VERSION.SDK_INT >= 7) {
- if (mSetChildrenDrawingOrderEnabled == null) {
- try {
- mSetChildrenDrawingOrderEnabled = ViewGroup.class.getDeclaredMethod(
- "setChildrenDrawingOrderEnabled", new Class[] { Boolean.TYPE });
- } catch (NoSuchMethodException e) {
- Log.e(TAG, "Can't find setChildrenDrawingOrderEnabled", e);
- }
- }
- try {
- mSetChildrenDrawingOrderEnabled.invoke(this, enable);
- } catch (Exception e) {
- Log.e(TAG, "Error changing children drawing order", e);
- }
- }
- }
-
- @Override
- protected int getChildDrawingOrder(int childCount, int i) {
- final int index = mDrawingOrder == DRAW_ORDER_REVERSE ? childCount - 1 - i : i;
- final int result =
- ((LayoutParams) mDrawingOrderedChildren.get(index).getLayoutParams()).childIndex;
- return result;
- }
-
- /**
- * Set a separate OnPageChangeListener for internal use by the support library.
- *
- * @param listener Listener to set
- * @return The old listener that was set, if any.
- */
- ViewPager.OnPageChangeListener setInternalPageChangeListener(
- ViewPager.OnPageChangeListener listener) {
- ViewPager.OnPageChangeListener oldListener = mInternalPageChangeListener;
- mInternalPageChangeListener = listener;
- return oldListener;
- }
-
- /**
- * Returns the number of pages that will be retained to either side of the
- * current page in the view hierarchy in an idle state. Defaults to 1.
- *
- * @return How many pages will be kept offscreen on either side
- * @see #setOffscreenPageLimit(int)
- */
- public int getOffscreenPageLimit() {
- return mOffscreenPageLimit;
- }
-
- /**
- * Set the number of pages that should be retained to either side of the
- * current page in the view hierarchy in an idle state. Pages beyond this
- * limit will be recreated from the adapter when needed.
- *
- * This is offered as an optimization. If you know in advance the number
- * of pages you will need to support or have lazy-loading mechanisms in place
- * on your pages, tweaking this setting can have benefits in perceived smoothness
- * of paging animations and interaction. If you have a small number of pages (3-4)
- * that you can keep active all at once, less time will be spent in layout for
- * newly created view subtrees as the user pages back and forth.
- *
- * You should keep this limit low, especially if your pages have complex layouts.
- * This setting defaults to 1.
- *
- * @param limit How many pages will be kept offscreen in an idle state.
- */
- public void setOffscreenPageLimit(int limit) {
- if (limit < DEFAULT_OFFSCREEN_PAGES) {
- Log.w(TAG, "Requested offscreen page limit " + limit + " too small; defaulting to " +
- DEFAULT_OFFSCREEN_PAGES);
- limit = DEFAULT_OFFSCREEN_PAGES;
- }
- if (limit != mOffscreenPageLimit) {
- mOffscreenPageLimit = limit;
- populate();
- }
- }
-
- /**
- * Set the margin between pages.
- *
- * @param marginPixels Distance between adjacent pages in pixels
- * @see #getPageMargin()
- * @see #setPageMarginDrawable(Drawable)
- * @see #setPageMarginDrawable(int)
- */
- public void setPageMargin(int marginPixels) {
- final int oldMargin = mPageMargin;
- mPageMargin = marginPixels;
-
- final int size = (mOrientation == Orientation.VERTICAL) ? getHeight() : getWidth();
- recomputeScrollPosition(size, size, marginPixels, oldMargin);
-
- requestLayout();
- }
-
- /**
- * Return the margin between pages.
- *
- * @return The size of the margin in pixels
- */
- public int getPageMargin() {
- return mPageMargin;
- }
-
- /**
- * Set a drawable that will be used to fill the margin between pages.
- *
- * @param d Drawable to display between pages
- */
- public void setPageMarginDrawable(Drawable d) {
- mMarginDrawable = d;
- if (d != null) refreshDrawableState();
- setWillNotDraw(d == null);
- invalidate();
- }
-
- /**
- * Set a drawable that will be used to fill the margin between pages.
- *
- * @param resId Resource ID of a drawable to display between pages
- */
- public void setPageMarginDrawable(int resId) {
- setPageMarginDrawable(getContext().getResources().getDrawable(resId));
- }
-
- @Override
- protected boolean verifyDrawable(Drawable who) {
- return super.verifyDrawable(who) || who == mMarginDrawable;
- }
-
- @Override
- protected void drawableStateChanged() {
- super.drawableStateChanged();
- final Drawable d = mMarginDrawable;
- if (d != null && d.isStateful()) {
- d.setState(getDrawableState());
- }
- }
-
- // We want the duration of the page snap animation to be influenced by the distance that
- // the screen has to travel, however, we don't want this duration to be effected in a
- // purely linear fashion. Instead, we use this method to moderate the effect that the distance
- // of travel has on the overall snap duration.
- float distanceInfluenceForSnapDuration(float f) {
- f -= 0.5f; // center the values about 0.
- f *= 0.3f * Math.PI / 2.0f;
- return (float) Math.sin(f);
- }
-
- /**
- * Like {@link View#scrollBy}, but scroll smoothly instead of immediately.
- *
- * @param x the number of pixels to scroll by on the X axis
- * @param y the number of pixels to scroll by on the Y axis
- */
- void smoothScrollTo(int x, int y) {
- smoothScrollTo(x, y, 0);
- }
-
- /**
- * Like {@link View#scrollBy}, but scroll smoothly instead of immediately.
- *
- * @param x the number of pixels to scroll by on the X axis
- * @param y the number of pixels to scroll by on the Y axis
- * @param velocity the velocity associated with a fling, if applicable. (0 otherwise)
- */
- void smoothScrollTo(int x, int y, int velocity) {
- if (getChildCount() == 0) {
- // Nothing to do.
- setScrollingCacheEnabled(false);
- return;
- }
- int sx = getScrollX();
- int sy = getScrollY();
- int dx = x - sx;
- int dy = y - sy;
- if (dx == 0 && dy == 0) {
- completeScroll(false);
- populate();
- setScrollState(SCROLL_STATE_IDLE);
- return;
- }
-
- setScrollingCacheEnabled(true);
- setScrollState(SCROLL_STATE_SETTLING);
-
- final int size = getClientSize();
- final int halfSize = size / 2;
- final float distanceRatio = Math.min(1f, 1.0f * Math.abs(dx) / size);
- final float distance = halfSize + halfSize *
- distanceInfluenceForSnapDuration(distanceRatio);
-
- int duration = 0;
- velocity = Math.abs(velocity);
- if (velocity > 0) {
- duration = 4 * Math.round(1000 * Math.abs(distance / velocity));
- } else {
- final float pageSize = size * mAdapter.getPageWidth(mCurItem);
- final float pageDelta = (float) Math.abs(dx) / (pageSize + mPageMargin);
- duration = (int) ((pageDelta + 1) * 100);
- }
- duration = Math.min(duration, MAX_SETTLE_DURATION);
-
- mScroller.startScroll(sx, sy, dx, dy, duration);
- ViewCompat.postInvalidateOnAnimation(this);
- }
-
- ItemInfo addNewItem(int position, int index) {
- ItemInfo ii = new ItemInfo();
- ii.position = position;
- ii.object = mAdapter.instantiateItem(this, position);
- ii.sizeFactor = mAdapter.getPageWidth(position);
- if (index < 0 || index >= mItems.size()) {
- mItems.add(ii);
- } else {
- mItems.add(index, ii);
- }
- return ii;
- }
-
- void dataSetChanged() {
- // This method only gets called if our observer is attached, so mAdapter is non-null.
-
- final int adapterCount = mAdapter.getCount();
- mExpectedAdapterCount = adapterCount;
- boolean needPopulate = mItems.size() < mOffscreenPageLimit * 2 + 1 &&
- mItems.size() < adapterCount;
- int newCurrItem = mCurItem;
-
- boolean isUpdating = false;
- for (int i = 0; i < mItems.size(); i++) {
- final ItemInfo ii = mItems.get(i);
- final int newPos = mAdapter.getItemPosition(ii.object);
-
- if (newPos == PagerAdapter.POSITION_UNCHANGED) {
- continue;
- }
-
- if (newPos == PagerAdapter.POSITION_NONE) {
- mItems.remove(i);
- i--;
-
- if (!isUpdating) {
- mAdapter.startUpdate(this);
- isUpdating = true;
- }
-
- mAdapter.destroyItem(this, ii.position, ii.object);
- needPopulate = true;
-
- if (mCurItem == ii.position) {
- // Keep the current item in the valid range
- newCurrItem = Math.max(0, Math.min(mCurItem, adapterCount - 1));
- needPopulate = true;
- }
- continue;
- }
-
- if (ii.position != newPos) {
- if (ii.position == mCurItem) {
- // Our current item changed position. Follow it.
- newCurrItem = newPos;
- }
-
- ii.position = newPos;
- needPopulate = true;
- }
- }
-
- if (isUpdating) {
- mAdapter.finishUpdate(this);
- }
-
- Collections.sort(mItems, COMPARATOR);
-
- if (needPopulate) {
- // Reset our known page widths; populate will recompute them.
- final int childCount = getChildCount();
- for (int i = 0; i < childCount; i++) {
- final View child = getChildAt(i);
- final LayoutParams lp = (LayoutParams) child.getLayoutParams();
- if (!lp.isDecor) {
- lp.heightFactor = 0.f;
- }
- }
-
- setCurrentItemInternal(newCurrItem, false, true);
- requestLayout();
- }
- }
-
- void populate() {
- populate(mCurItem);
- }
-
- void populate(int newCurrentItem) {
- ItemInfo oldCurInfo = null;
- int focusDirection = View.FOCUS_FORWARD;
- if (mCurItem != newCurrentItem) {
- focusDirection = mCurItem < newCurrentItem ? View.FOCUS_DOWN : View.FOCUS_UP;
- oldCurInfo = infoForPosition(mCurItem);
- mCurItem = newCurrentItem;
- }
-
- if (mAdapter == null) {
- sortChildDrawingOrder();
- return;
- }
-
- // Bail now if we are waiting to populate. This is to hold off
- // on creating views from the time the user releases their finger to
- // fling to a new position until we have finished the scroll to
- // that position, avoiding glitches from happening at that point.
- if (mPopulatePending) {
- if (DEBUG) Log.i(TAG, "populate is pending, skipping for now...");
- sortChildDrawingOrder();
- return;
- }
-
- // Also, don't populate until we are attached to a window. This is to
- // avoid trying to populate before we have restored our view hierarchy
- // state and conflicting with what is restored.
- if (getWindowToken() == null) {
- return;
- }
-
- mAdapter.startUpdate(this);
-
- final int pageLimit = mOffscreenPageLimit;
- final int startPos = Math.max(0, mCurItem - pageLimit);
- final int N = mAdapter.getCount();
- final int endPos = Math.min(N - 1, mCurItem + pageLimit);
-
- if (N != mExpectedAdapterCount) {
- String resName;
- try {
- resName = getResources().getResourceName(getId());
- } catch (Resources.NotFoundException e) {
- resName = Integer.toHexString(getId());
- }
- throw new IllegalStateException("The application's PagerAdapter changed the adapter's" +
- " contents without calling PagerAdapter#notifyDataSetChanged!" +
- " Expected adapter item count: " + mExpectedAdapterCount + ", found: " + N +
- " Pager id: " + resName +
- " Pager class: " + getClass() +
- " Problematic adapter: " + mAdapter.getClass());
- }
-
- // Locate the currently focused item or add it if needed.
- int curIndex = -1;
- ItemInfo curItem = null;
- for (curIndex = 0; curIndex < mItems.size(); curIndex++) {
- final ItemInfo ii = mItems.get(curIndex);
- if (ii.position >= mCurItem) {
- if (ii.position == mCurItem) curItem = ii;
- break;
- }
- }
-
- if (curItem == null && N > 0) {
- curItem = addNewItem(mCurItem, curIndex);
- }
-
- // Fill 3x the available width or up to the number of offscreen
- // pages requested to either side, whichever is larger.
- // If we have no current item we have no work to do.
- if (curItem != null) {
- float extraSizeTopLeft = 0.f;
- int itemIndex = curIndex - 1;
- ItemInfo ii = itemIndex >= 0 ? mItems.get(itemIndex) : null;
- final int clientSize = getClientSize();
- final float topLeftSizeNeeded = clientSize <= 0 ? 0 :
- 2.f - curItem.sizeFactor + (float) getPaddingLeft() / (float) clientSize;
- for (int pos = mCurItem - 1; pos >= 0; pos--) {
- if (extraSizeTopLeft >= topLeftSizeNeeded && pos < startPos) {
- if (ii == null) {
- break;
- }
- if (pos == ii.position && !ii.scrolling) {
- mItems.remove(itemIndex);
- mAdapter.destroyItem(this, pos, ii.object);
- if (DEBUG) {
- Log.i(TAG, "populate() - destroyItem() with pos: " + pos +
- " view: " + ((View) ii.object));
- }
- itemIndex--;
- curIndex--;
- ii = itemIndex >= 0 ? mItems.get(itemIndex) : null;
- }
- } else if (ii != null && pos == ii.position) {
- extraSizeTopLeft += ii.sizeFactor;
- itemIndex--;
- ii = itemIndex >= 0 ? mItems.get(itemIndex) : null;
- } else {
- ii = addNewItem(pos, itemIndex + 1);
- extraSizeTopLeft += ii.sizeFactor;
- curIndex++;
- ii = itemIndex >= 0 ? mItems.get(itemIndex) : null;
- }
- }
-
- float extraSizeBottomRight = curItem.sizeFactor;
- itemIndex = curIndex + 1;
- if (extraSizeBottomRight < 2.f) {
- ii = itemIndex < mItems.size() ? mItems.get(itemIndex) : null;
- final float bottomRightSizeNeeded = clientSize <= 0 ? 0 :
- (float) getPaddingRight() / (float) clientSize + 2.f;
- for (int pos = mCurItem + 1; pos < N; pos++) {
- if (extraSizeBottomRight >= bottomRightSizeNeeded && pos > endPos) {
- if (ii == null) {
- break;
- }
- if (pos == ii.position && !ii.scrolling) {
- mItems.remove(itemIndex);
- mAdapter.destroyItem(this, pos, ii.object);
- if (DEBUG) {
- Log.i(TAG, "populate() - destroyItem() with pos: " + pos +
- " view: " + ((View) ii.object));
- }
- ii = itemIndex < mItems.size() ? mItems.get(itemIndex) : null;
- }
- } else if (ii != null && pos == ii.position) {
- extraSizeBottomRight += ii.sizeFactor;
- itemIndex++;
- ii = itemIndex < mItems.size() ? mItems.get(itemIndex) : null;
- } else {
- ii = addNewItem(pos, itemIndex);
- itemIndex++;
- extraSizeBottomRight += ii.sizeFactor;
- ii = itemIndex < mItems.size() ? mItems.get(itemIndex) : null;
- }
- }
- }
-
- calculatePageOffsets(curItem, curIndex, oldCurInfo);
- }
-
- if (DEBUG) {
- Log.i(TAG, "Current page list:");
- for (int i = 0; i < mItems.size(); i++) {
- Log.i(TAG, "#" + i + ": page " + mItems.get(i).position);
- }
- }
-
- mAdapter.setPrimaryItem(this, mCurItem, curItem != null ? curItem.object : null);
-
- mAdapter.finishUpdate(this);
-
- // Check width measurement of current pages and drawing sort order.
- // Update LayoutParams as needed.
- final int childCount = getChildCount();
- if (mOrientation == Orientation.VERTICAL) {
- for (int i = 0; i < childCount; i++) {
- final View child = getChildAt(i);
- final LayoutParams lp = (LayoutParams) child.getLayoutParams();
- lp.childIndex = i;
- if (!lp.isDecor && lp.heightFactor == 0.f) {
- // 0 means requery the adapter for this, it doesn't have a valid width
- // .
- final ItemInfo ii = infoForChild(child);
- if (ii != null) {
- lp.heightFactor = ii.sizeFactor;
- lp.position = ii.position;
- }
- }
- }
- } else {
- for (int i = 0; i < childCount; i++) {
- final View child = getChildAt(i);
- final LayoutParams lp = (LayoutParams) child.getLayoutParams();
- lp.childIndex = i;
- if (!lp.isDecor && lp.widthFactor == 0.f) {
- // 0 means requery the adapter for this, it doesn't have a valid width.
- final ItemInfo ii = infoForChild(child);
- if (ii != null) {
- lp.widthFactor = ii.sizeFactor;
- lp.position = ii.position;
- }
- }
- }
- }
- sortChildDrawingOrder();
-
- if (hasFocus()) {
- View currentFocused = findFocus();
- ItemInfo ii = currentFocused != null ? infoForAnyChild(currentFocused) : null;
- if (ii == null || ii.position != mCurItem) {
- for (int i = 0; i < getChildCount(); i++) {
- View child = getChildAt(i);
- ii = infoForChild(child);
- if (ii != null && ii.position == mCurItem) {
- if (child.requestFocus(focusDirection)) {
- break;
- }
- }
- }
- }
- }
- }
-
- private void sortChildDrawingOrder() {
- if (mDrawingOrder != DRAW_ORDER_DEFAULT) {
- if (mDrawingOrderedChildren == null) {
- mDrawingOrderedChildren = new ArrayList();
- } else {
- mDrawingOrderedChildren.clear();
- }
- final int childCount = getChildCount();
- for (int i = 0; i < childCount; i++) {
- final View child = getChildAt(i);
- mDrawingOrderedChildren.add(child);
- }
- Collections.sort(mDrawingOrderedChildren, sPositionComparator);
- }
- }
-
- private void calculatePageOffsets(ItemInfo curItem, int curIndex, ItemInfo oldCurInfo) {
- final int N = mAdapter.getCount();
- final int size = getClientSize();
- final float marginOffset = size > 0 ? (float) mPageMargin / size : 0;
- // Fix up offsets for later layout.
- if (oldCurInfo != null) {
- final int oldCurPosition = oldCurInfo.position;
- // Base offsets off of oldCurInfo.
- if (oldCurPosition < curItem.position) {
- int itemIndex = 0;
- ItemInfo ii = null;
- float offset = oldCurInfo.offset + oldCurInfo.sizeFactor + marginOffset;
- for (int pos = oldCurPosition + 1;
- pos <= curItem.position && itemIndex < mItems.size(); pos++) {
- ii = mItems.get(itemIndex);
- while (pos > ii.position && itemIndex < mItems.size() - 1) {
- itemIndex++;
- ii = mItems.get(itemIndex);
- }
- while (pos < ii.position) {
- // We don't have an item populated for this,
- // ask the adapter for an offset.
- offset += mAdapter.getPageWidth(pos) + marginOffset;
- pos++;
- }
- ii.offset = offset;
- offset += ii.sizeFactor + marginOffset;
- }
- } else if (oldCurPosition > curItem.position) {
- int itemIndex = mItems.size() - 1;
- ItemInfo ii = null;
- float offset = oldCurInfo.offset;
- for (int pos = oldCurPosition - 1;
- pos >= curItem.position && itemIndex >= 0; pos--) {
- ii = mItems.get(itemIndex);
- while (pos < ii.position && itemIndex > 0) {
- itemIndex--;
- ii = mItems.get(itemIndex);
- }
- while (pos > ii.position) {
- // We don't have an item populated for this,
- // ask the adapter for an offset.
- offset -= mAdapter.getPageWidth(pos) + marginOffset;
- pos--;
- }
- offset -= ii.sizeFactor + marginOffset;
- ii.offset = offset;
- }
- }
- }
-
- // Base all offsets off of curItem.
- final int itemCount = mItems.size();
- float offset = curItem.offset;
- int pos = curItem.position - 1;
- mFirstOffset = curItem.position == 0 ? curItem.offset : -Float.MAX_VALUE;
- mLastOffset = curItem.position == N - 1 ?
- curItem.offset + curItem.sizeFactor - 1 : Float.MAX_VALUE;
- // Previous pages
- for (int i = curIndex - 1; i >= 0; i--, pos--) {
- final ItemInfo ii = mItems.get(i);
- while (pos > ii.position) {
- offset -= mAdapter.getPageWidth(pos--) + marginOffset;
- }
- offset -= ii.sizeFactor + marginOffset;
- ii.offset = offset;
- if (ii.position == 0) mFirstOffset = offset;
- }
- offset = curItem.offset + curItem.sizeFactor + marginOffset;
- pos = curItem.position + 1;
- // Next pages
- for (int i = curIndex + 1; i < itemCount; i++, pos++) {
- final ItemInfo ii = mItems.get(i);
- while (pos < ii.position) {
- offset += mAdapter.getPageWidth(pos++) + marginOffset;
- }
- if (ii.position == N - 1) {
- mLastOffset = offset + ii.sizeFactor - 1;
- }
- ii.offset = offset;
- offset += ii.sizeFactor + marginOffset;
- }
-
- mNeedCalculatePageOffsets = false;
- }
-
- /**
- * This is the persistent state that is saved by ViewPager. Only needed
- * if you are creating a sublass of ViewPager that must save its own
- * state, in which case it should implement a subclass of this which
- * contains that state.
- */
- public static class ViewPagerSavedState extends BaseSavedState {
- int position;
- Parcelable adapterState;
- ClassLoader loader;
-
- public ViewPagerSavedState(Parcelable superState) {
- super(superState);
- }
-
- @Override
- public void writeToParcel(Parcel out, int flags) {
- super.writeToParcel(out, flags);
- out.writeInt(position);
- out.writeParcelable(adapterState, flags);
- }
-
- @Override
- public String toString() {
- return "FragmentPager.SavedState{"
- + Integer.toHexString(System.identityHashCode(this))
- + " position=" + position + "}";
- }
-
- public static final Parcelable.Creator CREATOR
- = ParcelableCompat.newCreator(new ParcelableCompatCreatorCallbacks() {
- @Override
- public ViewPagerSavedState createFromParcel(Parcel in, ClassLoader loader) {
- return new ViewPagerSavedState(in, loader);
- }
-
- @Override
- public ViewPagerSavedState[] newArray(int size) {
- return new ViewPagerSavedState[size];
- }
- });
-
- ViewPagerSavedState(Parcel in, ClassLoader loader) {
- super(in);
- if (loader == null) {
- loader = getClass().getClassLoader();
- }
- position = in.readInt();
- adapterState = in.readParcelable(loader);
- this.loader = loader;
- }
- }
-
- @Override
- public Parcelable onSaveInstanceState() {
- Parcelable superState = super.onSaveInstanceState();
- ViewPagerSavedState ss = new ViewPagerSavedState(superState);
- ss.position = mCurItem;
- if (mAdapter != null) {
- ss.adapterState = mAdapter.saveState();
- }
- return ss;
- }
-
- @Override
- public void onRestoreInstanceState(Parcelable state) {
- if (!(state instanceof ViewPagerSavedState)) {
- super.onRestoreInstanceState(state);
- return;
- }
-
- ViewPagerSavedState ss = (ViewPagerSavedState) state;
- super.onRestoreInstanceState(ss.getSuperState());
-
- if (mAdapter != null) {
- mAdapter.restoreState(ss.adapterState, ss.loader);
- setCurrentItemInternal(ss.position, false, true);
- } else {
- mRestoredCurItem = ss.position;
- mRestoredAdapterState = ss.adapterState;
- mRestoredClassLoader = ss.loader;
- }
- }
-
- @Override
- public void addView(View child, int index, ViewGroup.LayoutParams params) {
- if (!checkLayoutParams(params)) {
- params = generateLayoutParams(params);
- }
- final LayoutParams lp = (LayoutParams) params;
- lp.isDecor |= child instanceof Decor;
- if (mInLayout) {
- if (lp != null && lp.isDecor) {
- throw new IllegalStateException("Cannot add pager decor view during layout");
- }
- lp.needsMeasure = true;
- addViewInLayout(child, index, params);
- } else {
- super.addView(child, index, params);
- }
-
- if (USE_CACHE) {
- if (child.getVisibility() != GONE) {
- child.setDrawingCacheEnabled(mScrollingCacheEnabled);
- } else {
- child.setDrawingCacheEnabled(false);
- }
- }
- }
-
- @Override
- public void removeView(View view) {
- if (mInLayout) {
- removeViewInLayout(view);
- } else {
- super.removeView(view);
- }
- }
-
- ItemInfo infoForChild(View child) {
- for (int i = 0; i < mItems.size(); i++) {
- ItemInfo ii = mItems.get(i);
- if (mAdapter.isViewFromObject(child, ii.object)) {
- return ii;
- }
- }
- return null;
- }
-
- ItemInfo infoForAnyChild(View child) {
- ViewParent parent;
- while ((parent = child.getParent()) != this) {
- if (parent == null || !(parent instanceof View)) {
- return null;
- }
- child = (View) parent;
- }
- return infoForChild(child);
- }
-
- ItemInfo infoForPosition(int position) {
- for (int i = 0; i < mItems.size(); i++) {
- ItemInfo ii = mItems.get(i);
- if (ii.position == position) {
- return ii;
- }
- }
- return null;
- }
-
- @Override
- protected void onAttachedToWindow() {
- super.onAttachedToWindow();
- mFirstLayout = true;
- }
-
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- // For simple implementation, our internal size is always 0.
- // We depend on the container to specify the layout size of
- // our view. We can't really know what it is since we will be
- // adding and removing different arbitrary views and do not
- // want the layout to change as this happens.
- setMeasuredDimension(getDefaultSize(0, widthMeasureSpec),
- getDefaultSize(0, heightMeasureSpec));
-
- final int measuredSize =
- (mOrientation == Orientation.VERTICAL) ? getMeasuredHeight() : getMeasuredWidth();
- final int maxGutterSize = measuredSize / 10;
- mGutterSize = Math.min(maxGutterSize, mDefaultGutterSize);
-
- // Children are just made to fill our space.
- int childWidthSize;
- int childHeightSize;
-
- if (mOrientation == Orientation.VERTICAL) {
- childWidthSize = getMeasuredWidth() - getPaddingLeft() - getPaddingRight();
- childHeightSize = measuredSize - getPaddingTop() - getPaddingBottom();
- } else {
- childWidthSize = measuredSize - getPaddingLeft() - getPaddingRight();
- childHeightSize = getMeasuredHeight() - getPaddingTop() - getPaddingBottom();
- }
-
- /*
- * Make sure all children have been properly measured. Decor views first.
- * Right now we cheat and make this less complicated by assuming decor
- * views won't intersect. We will pin to edges based on gravity.
- */
- int size = getChildCount();
- for (int i = 0; i < size; ++i) {
- final View child = getChildAt(i);
- if (child.getVisibility() != GONE) {
- final LayoutParams lp = (LayoutParams) child.getLayoutParams();
- if (lp != null && lp.isDecor) {
- final int hgrav = lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK;
- final int vgrav = lp.gravity & Gravity.VERTICAL_GRAVITY_MASK;
- int widthMode = MeasureSpec.AT_MOST;
- int heightMode = MeasureSpec.AT_MOST;
- boolean consumeVertical = vgrav == Gravity.TOP || vgrav == Gravity.BOTTOM;
- boolean consumeHorizontal = hgrav == Gravity.LEFT || hgrav == Gravity.RIGHT;
-
- if (consumeVertical) {
- widthMode = MeasureSpec.EXACTLY;
- } else if (consumeHorizontal) {
- heightMode = MeasureSpec.EXACTLY;
- }
-
- int widthSize = childWidthSize;
- int heightSize = childHeightSize;
- if (lp.width != LayoutParams.WRAP_CONTENT) {
- widthMode = MeasureSpec.EXACTLY;
- if (lp.width != LayoutParams.FILL_PARENT) {
- widthSize = lp.width;
- }
- }
- if (lp.height != LayoutParams.WRAP_CONTENT) {
- heightMode = MeasureSpec.EXACTLY;
- if (lp.height != LayoutParams.FILL_PARENT) {
- heightSize = lp.height;
- }
- }
- final int widthSpec = MeasureSpec.makeMeasureSpec(widthSize, widthMode);
- final int heightSpec = MeasureSpec.makeMeasureSpec(heightSize, heightMode);
- child.measure(widthSpec, heightSpec);
-
- if (consumeVertical) {
- childHeightSize -= child.getMeasuredHeight();
- } else if (consumeHorizontal) {
- childWidthSize -= child.getMeasuredWidth();
- }
- }
- }
- }
-
- mChildWidthMeasureSpec = MeasureSpec.makeMeasureSpec(childWidthSize, MeasureSpec.EXACTLY);
- mChildHeightMeasureSpec = MeasureSpec.makeMeasureSpec(childHeightSize, MeasureSpec.EXACTLY);
-
- // Make sure we have created all fragments that we need to have shown.
- mInLayout = true;
- populate();
- mInLayout = false;
-
- // Page views next.
- size = getChildCount();
- for (int i = 0; i < size; ++i) {
- final View child = getChildAt(i);
- if (child.getVisibility() != GONE) {
- if (DEBUG) {
- Log.v(TAG, "Measuring #" + i + " " + child
- + ": " + mChildWidthMeasureSpec);
- }
-
- final LayoutParams lp = (LayoutParams) child.getLayoutParams();
- if (lp == null || !lp.isDecor) {
- if (mOrientation == Orientation.VERTICAL) {
- final int heightSpec = MeasureSpec.makeMeasureSpec(
- (int) (childHeightSize * lp.heightFactor), MeasureSpec.EXACTLY);
- child.measure(mChildWidthMeasureSpec, heightSpec);
- } else {
-
- final int widthSpec = MeasureSpec.makeMeasureSpec(
- (int) (childWidthSize * lp.widthFactor), MeasureSpec.EXACTLY);
- child.measure(widthSpec, mChildHeightMeasureSpec);
- }
- }
- }
- }
- }
-
- @Override
- protected void onSizeChanged(int w, int h, int oldw, int oldh) {
- super.onSizeChanged(w, h, oldw, oldh);
-
- // Make sure scroll position is set correctly.
- if (mOrientation == Orientation.VERTICAL) {
- if (h != oldh) {
- recomputeScrollPosition(h, oldh, mPageMargin, mPageMargin);
- }
- } else {
- if (w != oldw) {
- recomputeScrollPosition(w, oldw, mPageMargin, mPageMargin);
- }
- }
- }
-
- private void recomputeScrollPosition(int size, int oldSize, int margin, int oldMargin) {
- if (mOrientation == Orientation.VERTICAL) {
- if (oldSize > 0 && !mItems.isEmpty()) {
- final int heightWithMargin = size - getPaddingTop() - getPaddingBottom() + margin;
- final int oldHeightWithMargin = oldSize - getPaddingTop() - getPaddingBottom()
- + oldMargin;
- final int ypos = getScrollY();
- final float pageOffset = (float) ypos / oldHeightWithMargin;
- final int newOffsetPixels = (int) (pageOffset * heightWithMargin);
-
- scrollTo(getScrollX(), newOffsetPixels);
- if (!mScroller.isFinished()) {
- // We now return to your regularly scheduled scroll, already in progress.
- final int newDuration = mScroller.getDuration() - mScroller.timePassed();
- ItemInfo targetInfo = infoForPosition(mCurItem);
- mScroller.startScroll(0, newOffsetPixels,
- 0, (int) (targetInfo.offset * size), newDuration);
- }
- } else {
- final ItemInfo ii = infoForPosition(mCurItem);
- final float scrollOffset = ii != null ? Math.min(ii.offset, mLastOffset) : 0;
- final int scrollPos = (int) (scrollOffset *
- (size - getPaddingTop() - getPaddingBottom()));
- if (scrollPos != getScrollY()) {
- completeScroll(false);
- scrollTo(getScrollX(), scrollPos);
- }
- }
- } else {
- if (oldSize > 0 && !mItems.isEmpty()) {
- final int widthWithMargin = size - getPaddingLeft() - getPaddingRight() + margin;
- final int oldWidthWithMargin = oldSize - getPaddingLeft() - getPaddingRight()
- + oldMargin;
- final int xpos = getScrollX();
- final float pageOffset = (float) xpos / oldWidthWithMargin;
- final int newOffsetPixels = (int) (pageOffset * widthWithMargin);
-
- scrollTo(newOffsetPixels, getScrollY());
- if (!mScroller.isFinished()) {
- // We now return to your regularly scheduled scroll, already in progress.
- final int newDuration = mScroller.getDuration() - mScroller.timePassed();
- ItemInfo targetInfo = infoForPosition(mCurItem);
- mScroller.startScroll(newOffsetPixels, 0,
- (int) (targetInfo.offset * size), 0, newDuration);
- }
- } else {
- final ItemInfo ii = infoForPosition(mCurItem);
- final float scrollOffset = ii != null ? Math.min(ii.offset, mLastOffset) : 0;
- final int scrollPos = (int) (scrollOffset *
- (size - getPaddingLeft() - getPaddingRight()));
- if (scrollPos != getScrollX()) {
- completeScroll(false);
- scrollTo(scrollPos, getScrollY());
- }
- }
- }
- }
-
- @Override
- protected void onLayout(boolean changed, int l, int t, int r, int b) {
- final int count = getChildCount();
- int width = r - l;
- int height = b - t;
- int paddingLeft = getPaddingLeft();
- int paddingTop = getPaddingTop();
- int paddingRight = getPaddingRight();
- int paddingBottom = getPaddingBottom();
- final int scroll = (mOrientation == Orientation.VERTICAL) ? getScrollY() : getScrollX();
-
- int decorCount = 0;
-
- // First pass - decor views. We need to do this in two passes so that
- // we have the proper offsets for non-decor views later.
- for (int i = 0; i < count; i++) {
- final View child = getChildAt(i);
- if (child.getVisibility() != GONE) {
- final LayoutParams lp = (LayoutParams) child.getLayoutParams();
- int childLeft = 0;
- int childTop = 0;
- if (lp.isDecor) {
- final int hgrav = lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK;
- final int vgrav = lp.gravity & Gravity.VERTICAL_GRAVITY_MASK;
- switch (hgrav) {
- default:
- childLeft = paddingLeft;
- break;
- case Gravity.LEFT:
- childLeft = paddingLeft;
- paddingLeft += child.getMeasuredWidth();
- break;
- case Gravity.CENTER_HORIZONTAL:
- childLeft = Math.max((width - child.getMeasuredWidth()) / 2,
- paddingLeft);
- break;
- case Gravity.RIGHT:
- childLeft = width - paddingRight - child.getMeasuredWidth();
- paddingRight += child.getMeasuredWidth();
- break;
- }
- switch (vgrav) {
- default:
- childTop = paddingTop;
- break;
- case Gravity.TOP:
- childTop = paddingTop;
- paddingTop += child.getMeasuredHeight();
- break;
- case Gravity.CENTER_VERTICAL:
- childTop = Math.max((height - child.getMeasuredHeight()) / 2,
- paddingTop);
- break;
- case Gravity.BOTTOM:
- childTop = height - paddingBottom - child.getMeasuredHeight();
- paddingBottom += child.getMeasuredHeight();
- break;
- }
- if (mOrientation == Orientation.VERTICAL) {
- childTop += scroll;
- } else {
- childLeft += scroll;
- }
- child.layout(childLeft, childTop,
- childLeft + child.getMeasuredWidth(),
- childTop + child.getMeasuredHeight());
- decorCount++;
- }
- }
- }
-
- final int childSize =
- (mOrientation == Orientation.VERTICAL) ? height - paddingTop - paddingBottom
- : width - paddingLeft - paddingRight;
- // Page views. Do this once we have the right padding offsets from above.
- for (int i = 0; i < count; i++) {
- final View child = getChildAt(i);
- if (child.getVisibility() != GONE) {
- final LayoutParams lp = (LayoutParams) child.getLayoutParams();
- ItemInfo ii;
- if (!lp.isDecor && (ii = infoForChild(child)) != null) {
- int topLeftoff = (int) (childSize * ii.offset);
- int childLeft;
- int childTop;
- if (mOrientation == Orientation.VERTICAL) {
- childLeft = paddingLeft;
- childTop = paddingTop + topLeftoff;
- if (lp.needsMeasure) {
- // This was added during layout and needs measurement.
- // Do it now that we know what we're working with.
- lp.needsMeasure = false;
- final int widthSpec = MeasureSpec.makeMeasureSpec(
- (int) (width - paddingLeft - paddingRight),
- MeasureSpec.EXACTLY);
- final int heightSpec = MeasureSpec.makeMeasureSpec(
- (int) (childSize * lp.heightFactor),
- MeasureSpec.EXACTLY);
- child.measure(widthSpec, heightSpec);
- }
- } else {
- childLeft = paddingLeft + topLeftoff;
- childTop = paddingTop;
- if (lp.needsMeasure) {
- // This was added during layout and needs measurement.
- // Do it now that we know what we're working with.
- lp.needsMeasure = false;
- final int widthSpec = MeasureSpec.makeMeasureSpec(
- (int) (childSize * lp.widthFactor),
- MeasureSpec.EXACTLY);
- final int heightSpec = MeasureSpec.makeMeasureSpec(
- (int) (height - paddingTop - paddingBottom),
- MeasureSpec.EXACTLY);
- child.measure(widthSpec, heightSpec);
- }
- }
- if (DEBUG) {
- Log.v(TAG, "Positioning #" + i + " " + child + " f=" + ii.object
- + ":" + childLeft + "," + childTop + " " + child.getMeasuredWidth()
- + "x" + child.getMeasuredHeight());
- }
- child.layout(childLeft, childTop,
- childLeft + child.getMeasuredWidth(),
- childTop + child.getMeasuredHeight());
- }
- }
- }
- mTopLeftPageBounds = (mOrientation == Orientation.VERTICAL) ? paddingLeft : paddingTop;
- mBottomRightPageBounds =
- (mOrientation == Orientation.VERTICAL) ? width - paddingRight : height - paddingBottom;
- mDecorChildCount = decorCount;
-
- if (mFirstLayout) {
- scrollToItem(mCurItem, false, 0, false);
- }
- mFirstLayout = false;
- }
-
- @Override
- public void computeScroll() {
- if (!mScroller.isFinished() && mScroller.computeScrollOffset()) {
- int oldX = getScrollX();
- int oldY = getScrollY();
- int x = mScroller.getCurrX();
- int y = mScroller.getCurrY();
-
- if (oldX != x || oldY != y) {
- scrollTo(x, y);
- if (mOrientation == Orientation.VERTICAL) {
- if (!pageScrolled(y)) {
- mScroller.abortAnimation();
- scrollTo(x, 0);
- }
- } else {
- if (!pageScrolled(x)) {
- mScroller.abortAnimation();
- scrollTo(0, y);
- }
- }
- }
-
- // Keep on drawing until the animation has finished.
- ViewCompat.postInvalidateOnAnimation(this);
- return;
- }
-
- // Done with scroll, clean up state.
- completeScroll(true);
- }
-
- private boolean pageScrolled(int pos) {
- if (mItems.size() == 0) {
- mCalledSuper = false;
- onPageScrolled(0, 0, 0);
- if (!mCalledSuper) {
- throw new IllegalStateException(
- "onPageScrolled did not call superclass implementation");
- }
- return false;
- }
- final ItemInfo ii = infoForCurrentScrollPosition();
- final int size = getClientSize();
- final int sizeWithMargin = size + mPageMargin;
- final float marginOffset = (float) mPageMargin / size;
- final int currentPage = ii.position;
- final float pageOffset = (((float) pos / size) - ii.offset) / (ii.sizeFactor + marginOffset);
- final int offsetPixels = (int) (pageOffset * sizeWithMargin);
-
- mCalledSuper = false;
- onPageScrolled(currentPage, pageOffset, offsetPixels);
- if (!mCalledSuper) {
- throw new IllegalStateException(
- "onPageScrolled did not call superclass implementation");
- }
- return true;
- }
-
- /**
- * This method will be invoked when the current page is scrolled, either as part
- * of a programmatically initiated smooth scroll or a user initiated touch scroll.
- * If you override this method you must call through to the superclass implementation
- * (e.g. super.onPageScrolled(position, offset, offsetPixels)) before onPageScrolled
- * returns.
- *
- * @param position Position index of the first page currently being displayed.
- * Page position+1 will be visible if positionOffset is nonzero.
- * @param offset Value from [0, 1) indicating the offset from the page at position.
- * @param offsetPixels Value in pixels indicating the offset from position.
- */
- protected void onPageScrolled(int position, float offset, int offsetPixels) {
- // Offset any decor views if needed - keep them on-screen at all times.
- if (mDecorChildCount > 0) {
- if (mOrientation == Orientation.VERTICAL) {
- final int scrollY = getScrollY();
- int paddingTop = getPaddingTop();
- int paddingBottom = getPaddingBottom();
- final int height = getHeight();
- final int childCount = getChildCount();
- for (int i = 0; i < childCount; i++) {
- final View child = getChildAt(i);
- final LayoutParams lp = (LayoutParams) child.getLayoutParams();
- if (!lp.isDecor) continue;
-
- final int vgrav = lp.gravity & Gravity.VERTICAL_GRAVITY_MASK;
- int childTop = 0;
- switch (vgrav) {
- default:
- childTop = paddingTop;
- break;
- case Gravity.TOP:
- childTop = paddingTop;
- paddingTop += child.getHeight();
- break;
- case Gravity.CENTER_VERTICAL:
- childTop = Math.max((height - child.getMeasuredHeight()) / 2,
- paddingTop);
- break;
- case Gravity.BOTTOM:
- childTop = height - paddingBottom - child.getMeasuredHeight();
- paddingBottom += child.getMeasuredHeight();
- break;
- }
- childTop += scrollY;
-
- final int childOffset = childTop - child.getTop();
- if (childOffset != 0) {
- child.offsetTopAndBottom(childOffset);
- }
- }
- } else {
- final int scrollX = getScrollX();
- int paddingLeft = getPaddingLeft();
- int paddingRight = getPaddingRight();
- final int width = getWidth();
- final int childCount = getChildCount();
- for (int i = 0; i < childCount; i++) {
- final View child = getChildAt(i);
- final LayoutParams lp = (LayoutParams) child.getLayoutParams();
- if (!lp.isDecor) continue;
-
- final int hgrav = lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK;
- int childLeft = 0;
- switch (hgrav) {
- default:
- childLeft = paddingLeft;
- break;
- case Gravity.LEFT:
- childLeft = paddingLeft;
- paddingLeft += child.getWidth();
- break;
- case Gravity.CENTER_HORIZONTAL:
- childLeft = Math.max((width - child.getMeasuredWidth()) / 2,
- paddingLeft);
- break;
- case Gravity.RIGHT:
- childLeft = width - paddingRight - child.getMeasuredWidth();
- paddingRight += child.getMeasuredWidth();
- break;
- }
- childLeft += scrollX;
-
- final int childOffset = childLeft - child.getLeft();
- if (childOffset != 0) {
- child.offsetLeftAndRight(childOffset);
- }
- }
- }
- }
-
- if (mOnPageChangeListener != null) {
- mOnPageChangeListener.onPageScrolled(position, offset, offsetPixels);
- }
- if (mInternalPageChangeListener != null) {
- mInternalPageChangeListener.onPageScrolled(position, offset, offsetPixels);
- }
-
- if (mPageTransformer != null) {
- final int scroll = (mOrientation == Orientation.VERTICAL) ? getScrollY() : getScrollX();
- final int childCount = getChildCount();
- for (int i = 0; i < childCount; i++) {
- final View child = getChildAt(i);
- final LayoutParams lp = (LayoutParams) child.getLayoutParams();
-
- if (lp.isDecor) continue;
-
- final float transformPos =
- (float) (((mOrientation == Orientation.VERTICAL) ? child.getTop() : child.getLeft())
- - scroll) / getClientSize();
- mPageTransformer.transformPage(child, transformPos);
- }
- }
-
- mCalledSuper = true;
- }
-
- private void completeScroll(boolean postEvents) {
- boolean needPopulate = mScrollState == SCROLL_STATE_SETTLING;
- if (needPopulate) {
- // Done with scroll, no longer want to cache view drawing.
- setScrollingCacheEnabled(false);
- mScroller.abortAnimation();
- int oldX = getScrollX();
- int oldY = getScrollY();
- int x = mScroller.getCurrX();
- int y = mScroller.getCurrY();
- if (oldX != x || oldY != y) {
- scrollTo(x, y);
- }
- }
- mPopulatePending = false;
- for (int i = 0; i < mItems.size(); i++) {
- ItemInfo ii = mItems.get(i);
- if (ii.scrolling) {
- needPopulate = true;
- ii.scrolling = false;
- }
- }
- if (needPopulate) {
- if (postEvents) {
- ViewCompat.postOnAnimation(this, mEndScrollRunnable);
- } else {
- mEndScrollRunnable.run();
- }
- }
- }
-
- private boolean isGutterDrag(float axis, float dAxis) {
- return (axis < mGutterSize && dAxis > 0) || (axis
- > (mOrientation == Orientation.VERTICAL ? getHeight() : getWidth()) - mGutterSize
- && dAxis < 0);
- }
-
- private void enableLayers(boolean enable) {
- final int childCount = getChildCount();
- for (int i = 0; i < childCount; i++) {
- final int layerType = enable ?
- ViewCompat.LAYER_TYPE_HARDWARE : ViewCompat.LAYER_TYPE_NONE;
- ViewCompat.setLayerType(getChildAt(i), layerType, null);
- }
- }
-
- @Override
- public boolean onInterceptTouchEvent(MotionEvent ev) {
- /*
- * This method JUST determines whether we want to intercept the motion.
- * If we return true, onMotionEvent will be called and we do the actual
- * scrolling there.
- */
-
- final int action = ev.getAction() & MotionEventCompat.ACTION_MASK;
-
- // Always take care of the touch gesture being complete.
- if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) {
- // Release the drag.
- if (DEBUG) Log.v(TAG, "Intercept done!");
- mIsBeingDragged = false;
- mIsUnableToDrag = false;
- mActivePointerId = INVALID_POINTER;
- if (mVelocityTracker != null) {
- mVelocityTracker.recycle();
- mVelocityTracker = null;
- }
- return false;
- }
-
- // Nothing more to do here if we have decided whether or not we
- // are dragging.
- if (action != MotionEvent.ACTION_DOWN) {
- if (mIsBeingDragged) {
- if (DEBUG) Log.v(TAG, "Intercept returning true!");
- return true;
- }
- if (mIsUnableToDrag) {
- if (DEBUG) Log.v(TAG, "Intercept returning false!");
- return false;
- }
- }
-
- switch (action) {
- case MotionEvent.ACTION_MOVE: {
- /*
- * mIsBeingDragged == false, otherwise the shortcut would have caught it. Check
- * whether the user has moved far enough from his original down touch.
- */
-
- /*
- * Locally do absolute value. mLastMotionY is set to the y value
- * of the down event.
- */
- final int activePointerId = mActivePointerId;
- if (activePointerId == INVALID_POINTER) {
- // If we don't have a valid id, the touch down wasn't on content.
- break;
- }
-
- final int pointerIndex = MotionEventCompat.findPointerIndex(ev, activePointerId);
- if (mOrientation == Orientation.VERTICAL) {
- final float y = MotionEventCompat.getY(ev, pointerIndex);
- final float dy = y - mLastMotionY;
- final float yDiff = Math.abs(dy);
- final float x = MotionEventCompat.getX(ev, pointerIndex);
- final float xDiff = Math.abs(x - mInitialMotionX);
- if (DEBUG) {
- Log.v(TAG, "Moved x to " + x + "," + y + " diff=" + xDiff + "," + yDiff);
- }
-
- if (dy != 0 && !isGutterDrag(mLastMotionY, dy) &&
- canScroll(this, false, (int) dy, (int) x, (int) y)) {
- // Nested view has scrollable area under this point. Let it be handled there.
- mLastMotionX = x;
- mLastMotionY = y;
- mIsUnableToDrag = true;
- return false;
- }
- if (yDiff > mTouchSlop && yDiff * 0.5f > xDiff) {
- if (DEBUG) Log.v(TAG, "Starting drag!");
- mIsBeingDragged = true;
- requestParentDisallowInterceptTouchEvent(true);
- setScrollState(SCROLL_STATE_DRAGGING);
- mLastMotionY = dy > 0 ? mInitialMotionY + mTouchSlop :
- mInitialMotionY - mTouchSlop;
- mLastMotionX = x;
- setScrollingCacheEnabled(true);
- } else if (xDiff > mTouchSlop) {
- // The finger has moved enough in the vertical
- // direction to be counted as a drag... abort
- // any attempt to drag horizontally, to work correctly
- // with children that have scrolling containers.
- if (DEBUG) Log.v(TAG, "Starting unable to drag!");
- mIsUnableToDrag = true;
- }
- if (mIsBeingDragged) {
- // Scroll to follow the motion event
- if (performDrag(y)) {
- ViewCompat.postInvalidateOnAnimation(this);
- }
- }
- } else {
- final float x = MotionEventCompat.getX(ev, pointerIndex);
- final float dx = x - mLastMotionX;
- final float xDiff = Math.abs(dx);
- final float y = MotionEventCompat.getY(ev, pointerIndex);
- final float yDiff = Math.abs(y - mInitialMotionY);
- if (DEBUG) {
- Log.v(TAG, "Moved x to " + x + "," + y + " diff=" + xDiff + "," + yDiff);
- }
-
- //if (dx != 0 && !isGutterDrag(mLastMotionX, dx) &&
- // canScroll(this, false, (int) dx, (int) x, (int) y)) {
- // // Nested view has scrollable area under this point. Let it be handled there.
- // mLastMotionX = x;
- // mLastMotionY = y;
- // mIsUnableToDrag = true;
- // return false;
- //}
- if (xDiff > mTouchSlop && xDiff * 0.5f > yDiff) {
- if (DEBUG) Log.v(TAG, "Starting drag!");
- mIsBeingDragged = true;
- requestParentDisallowInterceptTouchEvent(true);
- setScrollState(SCROLL_STATE_DRAGGING);
- mLastMotionX = dx > 0 ? mInitialMotionX + mTouchSlop :
- mInitialMotionX - mTouchSlop;
- mLastMotionY = y;
- setScrollingCacheEnabled(true);
- } else if (yDiff > mTouchSlop) {
- // The finger has moved enough in the vertical
- // direction to be counted as a drag... abort
- // any attempt to drag horizontally, to work correctly
- // with children that have scrolling containers.
- if (DEBUG) Log.v(TAG, "Starting unable to drag!");
- mIsUnableToDrag = true;
- }
- if (mIsBeingDragged) {
- // Scroll to follow the motion event
- if (performDrag(x)) {
- ViewCompat.postInvalidateOnAnimation(this);
- }
- }
- }
- break;
- }
-
- case MotionEvent.ACTION_DOWN: {
- /*
- * Remember location of down touch.
- * ACTION_DOWN always refers to pointer index 0.
- */
- mLastMotionX = mInitialMotionX = ev.getX();
- mLastMotionY = mInitialMotionY = ev.getY();
- mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
- mIsUnableToDrag = false;
-
- mScroller.computeScrollOffset();
- if (mOrientation == Orientation.VERTICAL) {
- if (mScrollState == SCROLL_STATE_SETTLING &&
- Math.abs(mScroller.getFinalY() - mScroller.getCurrY()) > mCloseEnough) {
- // Let the user 'catch' the pager as it animates.
- mScroller.abortAnimation();
- mPopulatePending = false;
- populate();
- mIsBeingDragged = true;
- requestParentDisallowInterceptTouchEvent(true);
- setScrollState(SCROLL_STATE_DRAGGING);
- } else {
- completeScroll(false);
- mIsBeingDragged = false;
- }
- } else {
- if (mScrollState == SCROLL_STATE_SETTLING &&
- Math.abs(mScroller.getFinalX() - mScroller.getCurrX()) > mCloseEnough) {
- // Let the user 'catch' the pager as it animates.
- mScroller.abortAnimation();
- mPopulatePending = false;
- populate();
- mIsBeingDragged = true;
- requestParentDisallowInterceptTouchEvent(true);
- setScrollState(SCROLL_STATE_DRAGGING);
- } else {
- completeScroll(false);
- mIsBeingDragged = false;
- }
- }
-
- if (DEBUG) {
- Log.v(TAG, "Down at " + mLastMotionX + "," + mLastMotionY
- + " mIsBeingDragged=" + mIsBeingDragged
- + "mIsUnableToDrag=" + mIsUnableToDrag);
- }
- break;
- }
-
- case MotionEventCompat.ACTION_POINTER_UP:
- onSecondaryPointerUp(ev);
- break;
- }
-
- if (mVelocityTracker == null) {
- mVelocityTracker = VelocityTracker.obtain();
- }
- mVelocityTracker.addMovement(ev);
-
- /*
- * The only time we want to intercept motion events is if we are in the
- * drag mode.
- */
- return mIsBeingDragged;
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent ev) {
- if (mFakeDragging) {
- // A fake drag is in progress already, ignore this real one
- // but still eat the touch events.
- // (It is likely that the user is multi-touching the screen.)
- return true;
- }
-
- if (ev.getAction() == MotionEvent.ACTION_DOWN && ev.getEdgeFlags() != 0) {
- // Don't handle edge touches immediately -- they may actually belong to one of our
- // descendants.
- return false;
- }
-
- if (mAdapter == null || mAdapter.getCount() == 0) {
- // Nothing to present or scroll; nothing to touch.
- return false;
- }
-
- if (mVelocityTracker == null) {
- mVelocityTracker = VelocityTracker.obtain();
- }
- mVelocityTracker.addMovement(ev);
-
- final int action = ev.getAction();
- boolean needsInvalidate = false;
-
- switch (action & MotionEventCompat.ACTION_MASK) {
- case MotionEvent.ACTION_DOWN: {
- mScroller.abortAnimation();
- mPopulatePending = false;
- populate();
-
- // Remember where the motion event started
- mLastMotionX = mInitialMotionX = ev.getX();
- mLastMotionY = mInitialMotionY = ev.getY();
- mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
- break;
- }
- case MotionEvent.ACTION_MOVE:
- if (!mIsBeingDragged) {
- final int pointerIndex = MotionEventCompat.findPointerIndex(ev, mActivePointerId);
- final float y = MotionEventCompat.getY(ev, pointerIndex);
- final float yDiff = Math.abs(y - mLastMotionY);
- final float x = MotionEventCompat.getX(ev, pointerIndex);
- final float xDiff = Math.abs(x - mLastMotionX);
- if (DEBUG) {
- Log.v(TAG, "Moved x to " + x + "," + y + " diff=" + xDiff + "," + yDiff);
- }
- if (mOrientation == Orientation.VERTICAL) {
- if (yDiff > mTouchSlop && yDiff > xDiff) {
- if (DEBUG) Log.v(TAG, "Starting drag!");
- mIsBeingDragged = true;
- requestParentDisallowInterceptTouchEvent(true);
- mLastMotionY = y - mInitialMotionY > 0 ? mInitialMotionY + mTouchSlop :
- mInitialMotionY - mTouchSlop;
- mLastMotionX = x;
- setScrollState(SCROLL_STATE_DRAGGING);
- setScrollingCacheEnabled(true);
-
- // Disallow Parent Intercept, just in case
- ViewParent parent = getParent();
- if (parent != null) {
- parent.requestDisallowInterceptTouchEvent(true);
- }
- }
- } else {
- if (xDiff > mTouchSlop && xDiff > yDiff) {
- if (DEBUG) Log.v(TAG, "Starting drag!");
- mIsBeingDragged = true;
- requestParentDisallowInterceptTouchEvent(true);
- mLastMotionX = x - mInitialMotionX > 0 ? mInitialMotionX + mTouchSlop :
- mInitialMotionX - mTouchSlop;
- mLastMotionY = y;
- setScrollState(SCROLL_STATE_DRAGGING);
- setScrollingCacheEnabled(true);
-
- // Disallow Parent Intercept, just in case
- ViewParent parent = getParent();
- if (parent != null) {
- parent.requestDisallowInterceptTouchEvent(true);
- }
- }
- }
- }
- // Not else! Note that mIsBeingDragged can be set above.
- if (mIsBeingDragged) {
- // Scroll to follow the motion event
- final int activePointerIndex = MotionEventCompat.findPointerIndex(
- ev, mActivePointerId);
- if (mOrientation == Orientation.VERTICAL) {
- final float y = MotionEventCompat.getY(ev, activePointerIndex);
- needsInvalidate |= performDrag(y);
- } else {
- final float x = MotionEventCompat.getX(ev, activePointerIndex);
- needsInvalidate |= performDrag(x);
- }
- }
- break;
- case MotionEvent.ACTION_UP:
- if (mIsBeingDragged) {
- int currentPage;
- int initialVelocity;
- int totalDelta;
- float pageOffset;
- if (mOrientation == Orientation.VERTICAL) {
- final VelocityTracker velocityTracker = mVelocityTracker;
- velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
- initialVelocity = (int) VelocityTrackerCompat.getYVelocity(
- velocityTracker, mActivePointerId);
- mPopulatePending = true;
- final int height = getClientSize();
- final int scrollY = getScrollY();
- final ItemInfo ii = infoForCurrentScrollPosition();
- currentPage = ii.position;
- pageOffset = (((float) scrollY / height) - ii.offset) / ii.sizeFactor;
- final int activePointerIndex =
- MotionEventCompat.findPointerIndex(ev, mActivePointerId);
- final float y = MotionEventCompat.getY(ev, activePointerIndex);
- totalDelta = (int) (y - mInitialMotionY);
- } else {
- final VelocityTracker velocityTracker = mVelocityTracker;
- velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
- initialVelocity = (int) VelocityTrackerCompat.getXVelocity(
- velocityTracker, mActivePointerId);
- mPopulatePending = true;
- final int width = getClientSize();
- final int scrollX = getScrollX();
- final ItemInfo ii = infoForCurrentScrollPosition();
- currentPage = ii.position;
- pageOffset = (((float) scrollX / width) - ii.offset) / ii.sizeFactor;
- final int activePointerIndex =
- MotionEventCompat.findPointerIndex(ev, mActivePointerId);
- final float x = MotionEventCompat.getX(ev, activePointerIndex);
- totalDelta = (int) (x - mInitialMotionX);
- }
- int nextPage = determineTargetPage(currentPage, pageOffset, initialVelocity,
- totalDelta);
- setCurrentItemInternal(nextPage, true, true, initialVelocity);
-
- mActivePointerId = INVALID_POINTER;
- endDrag();
- needsInvalidate = mTopLeftEdge.onRelease() | mRightBottomEdge.onRelease();
- }
- break;
- case MotionEvent.ACTION_CANCEL:
- if (mIsBeingDragged) {
- scrollToItem(mCurItem, true, 0, false);
- mActivePointerId = INVALID_POINTER;
- endDrag();
- needsInvalidate = mTopLeftEdge.onRelease() | mRightBottomEdge.onRelease();
- }
- break;
- case MotionEventCompat.ACTION_POINTER_DOWN: {
- int index;
- if (mOrientation == Orientation.VERTICAL) {
- index = MotionEventCompat.getActionIndex(ev);
- final float y = MotionEventCompat.getY(ev, index);
- mLastMotionY = y;
- } else {
- index = MotionEventCompat.getActionIndex(ev);
- final float x = MotionEventCompat.getX(ev, index);
- mLastMotionX = x;
- }
- mActivePointerId = MotionEventCompat.getPointerId(ev, index);
- break;
- }
- case MotionEventCompat.ACTION_POINTER_UP:
- onSecondaryPointerUp(ev);
- if (mOrientation == Orientation.VERTICAL) {
- mLastMotionY = MotionEventCompat.getY(ev,
- MotionEventCompat.findPointerIndex(ev, mActivePointerId));
- } else {
- mLastMotionX = MotionEventCompat.getX(ev,
- MotionEventCompat.findPointerIndex(ev, mActivePointerId));
- }
- break;
- }
- if (needsInvalidate) {
- ViewCompat.postInvalidateOnAnimation(this);
- }
- return true;
- }
-
- private void requestParentDisallowInterceptTouchEvent(boolean disallowIntercept) {
- final ViewParent parent = getParent();
- if (parent != null) {
- parent.requestDisallowInterceptTouchEvent(disallowIntercept);
- }
- }
-
- private boolean performDrag(float dimen) {
- boolean needsInvalidate = false;
-
- if (mOrientation == Orientation.VERTICAL) {
- float y = dimen;
- final float deltaY = mLastMotionY - y;
- mLastMotionY = y;
-
- float oldScrollY = getScrollY();
- float scrollY = oldScrollY + deltaY;
- final int height = getClientSize();
-
- float topBound = height * mFirstOffset;
- float bottomBound = height * mLastOffset;
- boolean topAbsolute = true;
- boolean bottomAbsolute = true;
-
- final ItemInfo firstItem = mItems.get(0);
- final ItemInfo lastItem = mItems.get(mItems.size() - 1);
- if (firstItem.position != 0) {
- topAbsolute = false;
- topBound = firstItem.offset * height;
- }
- if (lastItem.position != mAdapter.getCount() - 1) {
- bottomAbsolute = false;
- bottomBound = lastItem.offset * height;
- }
-
- if (scrollY < topBound) {
- if (topAbsolute) {
- float over = topBound - scrollY;
- needsInvalidate = mTopLeftEdge.onPull(Math.abs(over) / height);
- }
- scrollY = topBound;
- } else if (scrollY > bottomBound) {
- if (bottomAbsolute) {
- float over = scrollY - bottomBound;
- needsInvalidate = mRightBottomEdge.onPull(Math.abs(over) / height);
- }
- scrollY = bottomBound;
- }
- // Don't lose the rounded component
- mLastMotionX += scrollY - (int) scrollY;
- scrollTo(getScrollX(), (int) scrollY);
- pageScrolled((int) scrollY);
- } else {
- float x = dimen;
-
- final float deltaX = mLastMotionX - x;
- mLastMotionX = x;
-
- float oldScrollX = getScrollX();
- float scrollX = oldScrollX + deltaX;
- final int width = getClientSize();
-
- float leftBound = width * mFirstOffset;
- float rightBound = width * mLastOffset;
- boolean leftAbsolute = true;
- boolean rightAbsolute = true;
-
- final ItemInfo firstItem = mItems.get(0);
- final ItemInfo lastItem = mItems.get(mItems.size() - 1);
- if (firstItem.position != 0) {
- leftAbsolute = false;
- leftBound = firstItem.offset * width;
- }
- if (lastItem.position != mAdapter.getCount() - 1) {
- rightAbsolute = false;
- rightBound = lastItem.offset * width;
- }
-
- if (scrollX < leftBound) {
- if (leftAbsolute) {
- float over = leftBound - scrollX;
- needsInvalidate = mTopLeftEdge.onPull(Math.abs(over) / width);
- }
- scrollX = leftBound;
- } else if (scrollX > rightBound) {
- if (rightAbsolute) {
- float over = scrollX - rightBound;
- needsInvalidate = mRightBottomEdge.onPull(Math.abs(over) / width);
- }
- scrollX = rightBound;
- }
- // Don't lose the rounded component
- mLastMotionX += scrollX - (int) scrollX;
- scrollTo((int) scrollX, getScrollY());
- pageScrolled((int) scrollX);
- }
-
- return needsInvalidate;
- }
-
- /**
- * @return Info about the page at the current scroll position.
- * This can be synthetic for a missing middle page; the 'object' field can be null.
- */
- private ItemInfo infoForCurrentScrollPosition() {
- final int size = getClientSize();
- final float scrollOffset =
- size > 0 ? (float) ((mOrientation == Orientation.VERTICAL) ? getScrollY() : getScrollX())
- / size : 0;
- final float marginOffset = size > 0 ? (float) mPageMargin / size : 0;
- int lastPos = -1;
- float lastOffset = 0.f;
- float lastSize = 0.f;
- boolean first = true;
-
- ItemInfo lastItem = null;
- for (int i = 0; i < mItems.size(); i++) {
- ItemInfo ii = mItems.get(i);
- float offset;
- if (!first && ii.position != lastPos + 1) {
- // Create a synthetic item for a missing page.
- ii = mTempItem;
- ii.offset = lastOffset + lastSize + marginOffset;
- ii.position = lastPos + 1;
- ii.sizeFactor = mAdapter.getPageWidth(ii.position);
- i--;
- }
- offset = ii.offset;
-
- final float topLeftBound = offset;
- final float bottomRightBound = offset + ii.sizeFactor + marginOffset;
- if (first || scrollOffset >= topLeftBound) {
- if (scrollOffset < bottomRightBound || i == mItems.size() - 1) {
- return ii;
- }
- } else {
- return lastItem;
- }
- first = false;
- lastPos = ii.position;
- lastOffset = offset;
- lastSize = ii.sizeFactor;
- lastItem = ii;
- }
-
- return lastItem;
- }
-
- private int determineTargetPage(int currentPage, float pageOffset, int velocity, int deltaDimen) {
- int targetPage;
- if (Math.abs(deltaDimen) > mFlingDistance && Math.abs(velocity) > mMinimumVelocity) {
- targetPage = velocity > 0 ? currentPage : currentPage + 1;
- } else {
- final float truncator = currentPage >= mCurItem ? 0.4f : 0.6f;
- targetPage = (int) (currentPage + pageOffset + truncator);
- }
-
- if (mItems.size() > 0) {
- final ItemInfo firstItem = mItems.get(0);
- final ItemInfo lastItem = mItems.get(mItems.size() - 1);
-
- // Only let the user target pages we have items for
- targetPage = Math.max(firstItem.position, Math.min(targetPage, lastItem.position));
- }
-
- return targetPage;
- }
-
- @Override
- public void draw(Canvas canvas) {
- super.draw(canvas);
- boolean needsInvalidate = false;
-
- final int overScrollMode = ViewCompat.getOverScrollMode(this);
- if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS ||
- (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS &&
- mAdapter != null && mAdapter.getCount() > 1)) {
- if (mOrientation == Orientation.VERTICAL) {
- if (!mTopLeftEdge.isFinished()) {
- final int restoreCount = canvas.save();
- final int height = getHeight();
- final int width = getWidth() - getPaddingLeft() - getPaddingRight();
-
- canvas.translate(getPaddingLeft(), mFirstOffset * height);
- mTopLeftEdge.setSize(width, height);
- needsInvalidate |= mTopLeftEdge.draw(canvas);
- canvas.restoreToCount(restoreCount);
- }
- if (!mRightBottomEdge.isFinished()) {
- final int restoreCount = canvas.save();
- final int height = getHeight();
- final int width = getWidth() - getPaddingLeft() - getPaddingRight();
-
- canvas.rotate(180);
- canvas.translate(-width - getPaddingLeft(), -(mLastOffset + 1) * height);
- mRightBottomEdge.setSize(width, height);
- needsInvalidate |= mRightBottomEdge.draw(canvas);
- canvas.restoreToCount(restoreCount);
- }
- } else {
- if (!mTopLeftEdge.isFinished()) {
- final int restoreCount = canvas.save();
- final int height = getHeight() - getPaddingTop() - getPaddingBottom();
- final int width = getWidth();
-
- canvas.rotate(270);
- canvas.translate(-height + getPaddingTop(), mFirstOffset * width);
- mTopLeftEdge.setSize(height, width);
- needsInvalidate |= mTopLeftEdge.draw(canvas);
- canvas.restoreToCount(restoreCount);
- }
- if (!mRightBottomEdge.isFinished()) {
- final int restoreCount = canvas.save();
- final int width = getWidth();
- final int height = getHeight() - getPaddingTop() - getPaddingBottom();
-
- canvas.rotate(90);
- canvas.translate(-getPaddingTop(), -(mLastOffset + 1) * width);
- mRightBottomEdge.setSize(height, width);
- needsInvalidate |= mRightBottomEdge.draw(canvas);
- canvas.restoreToCount(restoreCount);
- }
- }
- } else {
- mTopLeftEdge.finish();
- mRightBottomEdge.finish();
- }
-
- if (needsInvalidate) {
- // Keep animating
- ViewCompat.postInvalidateOnAnimation(this);
- }
- }
-
- @Override
- protected void onDraw(Canvas canvas) {
- super.onDraw(canvas);
-
- // Draw the margin drawable between pages if needed.
- if (mPageMargin > 0 && mMarginDrawable != null && mItems.size() > 0 && mAdapter != null) {
- if (mOrientation == Orientation.VERTICAL) {
- final int scrollY = getScrollY();
- final int height = getHeight();
-
- final float marginOffset = (float) mPageMargin / height;
- int itemIndex = 0;
- ItemInfo ii = mItems.get(0);
- float offset = ii.offset;
- final int itemCount = mItems.size();
- final int firstPos = ii.position;
- final int lastPos = mItems.get(itemCount - 1).position;
- for (int pos = firstPos; pos < lastPos; pos++) {
- while (pos > ii.position && itemIndex < itemCount) {
- ii = mItems.get(++itemIndex);
- }
-
- float drawAt;
- if (pos == ii.position) {
- drawAt = (ii.offset + ii.sizeFactor) * height;
- offset = ii.offset + ii.sizeFactor + marginOffset;
- } else {
- float heightFactor = mAdapter.getPageWidth(pos);
- drawAt = (offset + heightFactor) * height;
- offset += heightFactor + marginOffset;
- }
-
- if (drawAt + mPageMargin > scrollY) {
- mMarginDrawable.setBounds(mTopLeftPageBounds, (int) drawAt,
- mBottomRightPageBounds, (int) (drawAt + mPageMargin + 0.5f));
- mMarginDrawable.draw(canvas);
- }
-
- if (drawAt > scrollY + height) {
- break; // No more visible, no sense in continuing
- }
- }
- } else {
- final int scrollX = getScrollX();
- final int width = getWidth();
-
- final float marginOffset = (float) mPageMargin / width;
- int itemIndex = 0;
- ItemInfo ii = mItems.get(0);
- float offset = ii.offset;
- final int itemCount = mItems.size();
- final int firstPos = ii.position;
- final int lastPos = mItems.get(itemCount - 1).position;
- for (int pos = firstPos; pos < lastPos; pos++) {
- while (pos > ii.position && itemIndex < itemCount) {
- ii = mItems.get(++itemIndex);
- }
-
- float drawAt;
- if (pos == ii.position) {
- drawAt = (ii.offset + ii.sizeFactor) * width;
- offset = ii.offset + ii.sizeFactor + marginOffset;
- } else {
- float widthFactor = mAdapter.getPageWidth(pos);
- drawAt = (offset + widthFactor) * width;
- offset += widthFactor + marginOffset;
- }
-
- if (drawAt + mPageMargin > scrollX) {
- mMarginDrawable.setBounds((int) drawAt, mTopLeftPageBounds,
- (int) (drawAt + mPageMargin + 0.5f), mBottomRightPageBounds);
- mMarginDrawable.draw(canvas);
- }
-
- if (drawAt > scrollX + width) {
- break; // No more visible, no sense in continuing
- }
- }
- }
- }
- }
-
- /**
- * Start a fake drag of the pager.
- *
- * A fake drag can be useful if you want to synchronize the motion of the ViewPager
- * with the touch scrolling of another view, while still letting the ViewPager
- * control the snapping motion and fling behavior. (e.g. parallax-scrolling tabs.)
- * Call {@link #fakeDragBy(float)} to simulate the actual drag motion. Call
- * {@link #endFakeDrag()} to complete the fake drag and fling as necessary.
- *
- * During a fake drag the ViewPager will ignore all touch events. If a real drag
- * is already in progress, this method will return false.
- *
- * @return true if the fake drag began successfully, false if it could not be started.
- * @see #fakeDragBy(float)
- * @see #endFakeDrag()
- */
- public boolean beginFakeDrag() {
- if (mIsBeingDragged) {
- return false;
- }
- mFakeDragging = true;
- setScrollState(SCROLL_STATE_DRAGGING);
- if (mOrientation == Orientation.VERTICAL) {
- mInitialMotionY = mLastMotionY = 0;
- } else {
- mInitialMotionX = mLastMotionX = 0;
- }
- if (mVelocityTracker == null) {
- mVelocityTracker = VelocityTracker.obtain();
- } else {
- mVelocityTracker.clear();
- }
- final long time = SystemClock.uptimeMillis();
- final MotionEvent ev = MotionEvent.obtain(time, time, MotionEvent.ACTION_DOWN, 0, 0, 0);
- mVelocityTracker.addMovement(ev);
- ev.recycle();
- mFakeDragBeginTime = time;
- return true;
- }
-
- /**
- * End a fake drag of the pager.
- *
- * @see #beginFakeDrag()
- * @see #fakeDragBy(float)
- */
- public void endFakeDrag() {
- if (!mFakeDragging) {
- throw new IllegalStateException("No fake drag in progress. Call beginFakeDrag first.");
- }
-
- final VelocityTracker velocityTracker = mVelocityTracker;
- velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
- if (mOrientation == Orientation.VERTICAL) {
- int initialVelocity = (int) VelocityTrackerCompat.getYVelocity(
- velocityTracker, mActivePointerId);
- mPopulatePending = true;
- final int size = getClientSize();
- final int scrollY = getScrollY();
- final ItemInfo ii = infoForCurrentScrollPosition();
- final int currentPage = ii.position;
- final float pageOffset = (((float) scrollY / size) - ii.offset) / ii.sizeFactor;
- final int totalDelta = (int) (mLastMotionY - mInitialMotionY);
-
- int nextPage = determineTargetPage(currentPage, pageOffset, initialVelocity,
- totalDelta);
- setCurrentItemInternal(nextPage, true, true, initialVelocity);
- } else {
- int initialVelocity = (int) VelocityTrackerCompat.getXVelocity(
- velocityTracker, mActivePointerId);
- mPopulatePending = true;
- final int size = getClientSize();
- final int scrollX = getScrollX();
- final ItemInfo ii = infoForCurrentScrollPosition();
- final int currentPage = ii.position;
- final float pageOffset = (((float) scrollX / size) - ii.offset) / ii.sizeFactor;
- final int totalDelta = (int) (mLastMotionX - mInitialMotionX);
- int nextPage = determineTargetPage(currentPage, pageOffset, initialVelocity,
- totalDelta);
- setCurrentItemInternal(nextPage, true, true, initialVelocity);
- }
- endDrag();
-
- mFakeDragging = false;
- }
-
- /**
- * Fake drag by an offset in pixels. You must have called {@link #beginFakeDrag()} first.
- *
- * @param offset Offset in pixels to drag by.
- * @see #beginFakeDrag()
- * @see #endFakeDrag()
- */
- public void fakeDragBy(float offset) {
- if (!mFakeDragging) {
- throw new IllegalStateException("No fake drag in progress. Call beginFakeDrag first.");
- }
-
- if (mOrientation == Orientation.VERTICAL) {
- mLastMotionY += offset;
-
- float oldScrollY = getScrollY();
- float scrollY = oldScrollY - offset;
- final int height = getClientSize();
-
- float topBound = height * mFirstOffset;
- float bottomBound = height * mLastOffset;
-
- final ItemInfo firstItem = mItems.get(0);
- final ItemInfo lastItem = mItems.get(mItems.size() - 1);
- if (firstItem.position != 0) {
- topBound = firstItem.offset * height;
- }
- if (lastItem.position != mAdapter.getCount() - 1) {
- bottomBound = lastItem.offset * height;
- }
-
- if (scrollY < topBound) {
- scrollY = topBound;
- } else if (scrollY > bottomBound) {
- scrollY = bottomBound;
- }
- // Don't lose the rounded component
- mLastMotionY += scrollY - (int) scrollY;
- scrollTo(getScrollX(), (int) scrollY);
- pageScrolled((int) scrollY);
-
- // Synthesize an event for the VelocityTracker.
- final long time = SystemClock.uptimeMillis();
- final MotionEvent ev = MotionEvent.obtain(mFakeDragBeginTime, time, MotionEvent.ACTION_MOVE,
- 0, mLastMotionY, 0);
- mVelocityTracker.addMovement(ev);
- ev.recycle();
- } else {
- mLastMotionX += offset;
-
- float oldScrollX = getScrollX();
- float scrollX = oldScrollX - offset;
- final int width = getClientSize();
-
- float leftBound = width * mFirstOffset;
- float rightBound = width * mLastOffset;
-
- final ItemInfo firstItem = mItems.get(0);
- final ItemInfo lastItem = mItems.get(mItems.size() - 1);
- if (firstItem.position != 0) {
- leftBound = firstItem.offset * width;
- }
- if (lastItem.position != mAdapter.getCount() - 1) {
- rightBound = lastItem.offset * width;
- }
-
- if (scrollX < leftBound) {
- scrollX = leftBound;
- } else if (scrollX > rightBound) {
- scrollX = rightBound;
- }
- // Don't lose the rounded component
- mLastMotionX += scrollX - (int) scrollX;
- scrollTo((int) scrollX, getScrollY());
- pageScrolled((int) scrollX);
-
- // Synthesize an event for the VelocityTracker.
- final long time = SystemClock.uptimeMillis();
- final MotionEvent ev = MotionEvent.obtain(mFakeDragBeginTime, time, MotionEvent.ACTION_MOVE,
- mLastMotionX, 0, 0);
- mVelocityTracker.addMovement(ev);
- ev.recycle();
- }
- }
-
- /**
- * Returns true if a fake drag is in progress.
- *
- * @return true if currently in a fake drag, false otherwise.
- * @see #beginFakeDrag()
- * @see #fakeDragBy(float)
- * @see #endFakeDrag()
- */
- public boolean isFakeDragging() {
- return mFakeDragging;
- }
-
- private void onSecondaryPointerUp(MotionEvent ev) {
- final int pointerIndex = MotionEventCompat.getActionIndex(ev);
- final int pointerId = MotionEventCompat.getPointerId(ev, pointerIndex);
- if (pointerId == mActivePointerId) {
- // This was our active pointer going up. Choose a new
- // active pointer and adjust accordingly.
- final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
- if (mOrientation == Orientation.VERTICAL) {
- mLastMotionY = MotionEventCompat.getY(ev, newPointerIndex);
- } else {
- mLastMotionX = MotionEventCompat.getX(ev, newPointerIndex);
- }
- mActivePointerId = MotionEventCompat.getPointerId(ev, newPointerIndex);
- if (mVelocityTracker != null) {
- mVelocityTracker.clear();
- }
- }
- }
-
- private void endDrag() {
- mIsBeingDragged = false;
- mIsUnableToDrag = false;
-
- if (mVelocityTracker != null) {
- mVelocityTracker.recycle();
- mVelocityTracker = null;
- }
- }
-
- private void setScrollingCacheEnabled(boolean enabled) {
- if (mScrollingCacheEnabled != enabled) {
- mScrollingCacheEnabled = enabled;
- if (USE_CACHE) {
- final int size = getChildCount();
- for (int i = 0; i < size; ++i) {
- final View child = getChildAt(i);
- if (child.getVisibility() != GONE) {
- child.setDrawingCacheEnabled(enabled);
- }
- }
- }
- }
- }
-
- public boolean internalCanScrollVertically(int direction) {
- if (mAdapter == null) {
- return false;
- }
-
- final int size = getClientSize();
- final int scroll = (mOrientation == Orientation.VERTICAL) ? getScrollY() : getScrollX();
- if (direction < 0) {
- return (scroll > (int) (size * mFirstOffset));
- } else if (direction > 0) {
- return (scroll < (int) (size * mLastOffset));
- } else {
- return false;
- }
- }
-
- /**
- * Tests scrollability within child views of v given a delta of dx.
- *
- * @param v View to test for horizontal scrollability
- * @param checkV Whether the view v passed should itself be checked for scrollability (true),
- * or just its children (false).
- * @param delta Delta scrolled in pixels
- * @param x X coordinate of the active touch point
- * @param y Y coordinate of the active touch point
- * @return true if child views of v can be scrolled by delta of dx.
- */
- protected boolean canScroll(View v, boolean checkV, int delta, int x, int y) {
- if (v instanceof ViewGroup) {
- final ViewGroup group = (ViewGroup) v;
- final int scrollX = v.getScrollX();
- final int scrollY = v.getScrollY();
- final int count = group.getChildCount();
- // Count backwards - let topmost views consume scroll distance first.
- for (int i = count - 1; i >= 0; i--) {
- // TODO: Add versioned support here for transformed views.
- // This will not work for transformed views in Honeycomb+
- final View child = group.getChildAt(i);
- if (mOrientation == Orientation.VERTICAL) {
- if (y + scrollY >= child.getTop() && y + scrollY < child.getBottom() &&
- x + scrollX >= child.getLeft() && x + scrollX < child.getRight() &&
- canScroll(child, true, delta, x + scrollX - child.getLeft(),
- y + scrollY - child.getTop())) {
- return true;
- }
- } else {
- if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() &&
- y + scrollY >= child.getTop() && y + scrollY < child.getBottom() &&
- canScroll(child, true, delta, x + scrollX - child.getLeft(),
- y + scrollY - child.getTop())) {
- return true;
- }
- }
- }
- }
-
- return checkV && ViewCompat.canScrollVertically(v, -delta);
- }
-
- @Override
- public boolean dispatchKeyEvent(KeyEvent event) {
- // Let the focused view and/or our descendants get the key first
- return super.dispatchKeyEvent(event) || executeKeyEvent(event);
- }
-
- /**
- * You can call this function yourself to have the scroll view perform
- * scrolling from a key event, just as if the event had been dispatched to
- * it by the view hierarchy.
- *
- * @param event The key event to execute.
- * @return Return true if the event was handled, else false.
- */
- public boolean executeKeyEvent(KeyEvent event) {
- boolean handled = false;
- if (event.getAction() == KeyEvent.ACTION_DOWN) {
- switch (event.getKeyCode()) {
- case KeyEvent.KEYCODE_DPAD_LEFT:
- handled = arrowScroll(FOCUS_LEFT);
- break;
- case KeyEvent.KEYCODE_DPAD_RIGHT:
- handled = arrowScroll(FOCUS_RIGHT);
- break;
- case KeyEvent.KEYCODE_TAB:
- if (Build.VERSION.SDK_INT >= 11) {
- // The focus finder had a bug handling FOCUS_FORWARD and FOCUS_BACKWARD
- // before Android 3.0. Ignore the tab key on those devices.
- if (event.hasNoModifiers()) {
- handled = arrowScroll(FOCUS_FORWARD);
- } else if (event.hasModifiers(KeyEvent.META_SHIFT_ON)) {
- handled = arrowScroll(FOCUS_BACKWARD);
- }
- }
- break;
- }
- }
- return handled;
- }
-
- public boolean arrowScroll(int direction) {
- View currentFocused = findFocus();
- if (currentFocused == this) {
- currentFocused = null;
- } else if (currentFocused != null) {
- boolean isChild = false;
- for (ViewParent parent = currentFocused.getParent(); parent instanceof ViewGroup;
- parent = parent.getParent()) {
- if (parent == this) {
- isChild = true;
- break;
- }
- }
- if (!isChild) {
- // This would cause the focus search down below to fail in fun ways.
- final StringBuilder sb = new StringBuilder();
- sb.append(currentFocused.getClass().getSimpleName());
- for (ViewParent parent = currentFocused.getParent(); parent instanceof ViewGroup;
- parent = parent.getParent()) {
- sb.append(" => ").append(parent.getClass().getSimpleName());
- }
- Log.e(TAG, "arrowScroll tried to find focus based on non-child " +
- "current focused view " + sb.toString());
- currentFocused = null;
- }
- }
-
- boolean handled = false;
-
- View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused,
- direction);
- if (nextFocused != null && nextFocused != currentFocused) {
- if (direction == View.FOCUS_UP) {
- // If there is nothing to the left, or this is causing us to
- // jump to the right, then what we really want to do is page left.
- if (mOrientation == Orientation.VERTICAL) {
- final int nextTop = getChildRectInPagerCoordinates(mTempRect, nextFocused).top;
- final int currTop = getChildRectInPagerCoordinates(mTempRect, currentFocused).top;
- if (currentFocused != null && nextTop >= currTop) {
- handled = pageBack();
- } else {
- handled = nextFocused.requestFocus();
- }
- } else {
- final int nextLeft = getChildRectInPagerCoordinates(mTempRect, nextFocused).left;
- final int currLeft = getChildRectInPagerCoordinates(mTempRect, currentFocused).left;
- if (currentFocused != null && nextLeft >= currLeft) {
- handled = pageBack();
- } else {
- handled = nextFocused.requestFocus();
- }
- }
- } else if (direction == View.FOCUS_DOWN) {
- // If there is nothing to the right, or this is causing us to
- // jump to the left, then what we really want to do is page right.
- if (mOrientation == Orientation.VERTICAL) {
- final int nextDown = getChildRectInPagerCoordinates(mTempRect, nextFocused).bottom;
- final int currDown = getChildRectInPagerCoordinates(mTempRect, currentFocused).bottom;
- if (currentFocused != null && nextDown <= currDown) {
- handled = pageForward();
- } else {
- handled = nextFocused.requestFocus();
- }
- } else {
- final int nextLeft = getChildRectInPagerCoordinates(mTempRect, nextFocused).left;
- final int currLeft = getChildRectInPagerCoordinates(mTempRect, currentFocused).left;
- if (currentFocused != null && nextLeft <= currLeft) {
- handled = pageForward();
- } else {
- handled = nextFocused.requestFocus();
- }
- }
- }
- } else if (direction == FOCUS_UP || direction == FOCUS_BACKWARD) {
- // Trying to move left and nothing there; try to page.
- handled = pageBack();
- } else if (direction == FOCUS_DOWN || direction == FOCUS_FORWARD) {
- // Trying to move right and nothing there; try to page.
- handled = pageForward();
- }
- if (handled) {
- playSoundEffect(SoundEffectConstants.getContantForFocusDirection(direction));
- }
- return handled;
- }
-
- private Rect getChildRectInPagerCoordinates(Rect outRect, View child) {
- if (outRect == null) {
- outRect = new Rect();
- }
- if (child == null) {
- outRect.set(0, 0, 0, 0);
- return outRect;
- }
- outRect.left = child.getLeft();
- outRect.right = child.getRight();
- outRect.top = child.getTop();
- outRect.bottom = child.getBottom();
-
- ViewParent parent = child.getParent();
- while (parent instanceof ViewGroup && parent != this) {
- final ViewGroup group = (ViewGroup) parent;
- outRect.left += group.getLeft();
- outRect.right += group.getRight();
- outRect.top += group.getTop();
- outRect.bottom += group.getBottom();
-
- parent = group.getParent();
- }
- return outRect;
- }
-
- boolean pageBack() {
- if (mCurItem > 0) {
- setCurrentItem(mCurItem - 1, true);
- return true;
- }
- return false;
- }
-
- boolean pageForward() {
- if (mAdapter != null && mCurItem < (mAdapter.getCount() - 1)) {
- setCurrentItem(mCurItem + 1, true);
- return true;
- }
- return false;
- }
-
- /**
- * We only want the current page that is being shown to be focusable.
- */
- @Override
- public void addFocusables(ArrayList views, int direction, int focusableMode) {
- final int focusableCount = views.size();
-
- final int descendantFocusability = getDescendantFocusability();
-
- if (descendantFocusability != FOCUS_BLOCK_DESCENDANTS) {
- for (int i = 0; i < getChildCount(); i++) {
- final View child = getChildAt(i);
- if (child.getVisibility() == VISIBLE) {
- ItemInfo ii = infoForChild(child);
- if (ii != null && ii.position == mCurItem) {
- child.addFocusables(views, direction, focusableMode);
- }
- }
- }
- }
-
- // we add ourselves (if focusable) in all cases except for when we are
- // FOCUS_AFTER_DESCENDANTS and there are some descendants focusable. this is
- // to avoid the focus search finding layouts when a more precise search
- // among the focusable children would be more interesting.
- if (
- descendantFocusability != FOCUS_AFTER_DESCENDANTS ||
- // No focusable descendants
- (focusableCount == views.size())) {
- // Note that we can't call the superclass here, because it will
- // add all views in. So we need to do the same thing View does.
- if (!isFocusable()) {
- return;
- }
- if ((focusableMode & FOCUSABLES_TOUCH_MODE) == FOCUSABLES_TOUCH_MODE &&
- isInTouchMode() && !isFocusableInTouchMode()) {
- return;
- }
- if (views != null) {
- views.add(this);
- }
- }
- }
-
- /**
- * We only want the current page that is being shown to be touchable.
- */
- @Override
- public void addTouchables(ArrayList views) {
- // Note that we don't call super.addTouchables(), which means that
- // we don't call View.addTouchables(). This is okay because a ViewPager
- // is itself not touchable.
- for (int i = 0; i < getChildCount(); i++) {
- final View child = getChildAt(i);
- if (child.getVisibility() == VISIBLE) {
- ItemInfo ii = infoForChild(child);
- if (ii != null && ii.position == mCurItem) {
- child.addTouchables(views);
- }
- }
- }
- }
-
- /**
- * We only want the current page that is being shown to be focusable.
- */
- @Override
- protected boolean onRequestFocusInDescendants(int direction,
- Rect previouslyFocusedRect) {
- int index;
- int increment;
- int end;
- int count = getChildCount();
- if ((direction & FOCUS_FORWARD) != 0) {
- index = 0;
- increment = 1;
- end = count;
- } else {
- index = count - 1;
- increment = -1;
- end = -1;
- }
- for (int i = index; i != end; i += increment) {
- View child = getChildAt(i);
- if (child.getVisibility() == VISIBLE) {
- ItemInfo ii = infoForChild(child);
- if (ii != null && ii.position == mCurItem) {
- if (child.requestFocus(direction, previouslyFocusedRect)) {
- return true;
- }
- }
- }
- }
- return false;
- }
-
- @Override
- public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
- // Dispatch scroll events from this ViewPager.
- if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED) {
- return super.dispatchPopulateAccessibilityEvent(event);
- }
-
- // Dispatch all other accessibility events from the current page.
- final int childCount = getChildCount();
- for (int i = 0; i < childCount; i++) {
- final View child = getChildAt(i);
- if (child.getVisibility() == VISIBLE) {
- final ItemInfo ii = infoForChild(child);
- if (ii != null && ii.position == mCurItem &&
- child.dispatchPopulateAccessibilityEvent(event)) {
- return true;
- }
- }
- }
-
- return false;
- }
-
- @Override
- protected ViewGroup.LayoutParams generateDefaultLayoutParams() {
- return new LayoutParams();
- }
-
- @Override
- protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) {
- return generateDefaultLayoutParams();
- }
-
- @Override
- protected boolean checkLayoutParams(ViewGroup.LayoutParams p) {
- return p instanceof LayoutParams && super.checkLayoutParams(p);
- }
-
- @Override
- public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs) {
- return new LayoutParams(getContext(), attrs);
- }
-
- class MyAccessibilityDelegate extends AccessibilityDelegateCompat {
-
- @Override
- public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
- super.onInitializeAccessibilityEvent(host, event);
- event.setClassName(ViewPager.class.getName());
- final AccessibilityRecordCompat recordCompat = AccessibilityRecordCompat.obtain();
- recordCompat.setScrollable(canScroll());
- if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED
- && mAdapter != null) {
- recordCompat.setItemCount(mAdapter.getCount());
- recordCompat.setFromIndex(mCurItem);
- recordCompat.setToIndex(mCurItem);
- }
- }
-
- @Override
- public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
- super.onInitializeAccessibilityNodeInfo(host, info);
- info.setClassName(ViewPager.class.getName());
- info.setScrollable(canScroll());
- if (mOrientation == Orientation.VERTICAL) {
- if (internalCanScrollVertically(1)) {
- info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD);
- }
- if (internalCanScrollVertically(-1)) {
- info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD);
- }
- } else {
- if (canScrollHorizontally(1)) {
- info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD);
- }
- if (canScrollHorizontally(-1)) {
- info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD);
- }
- }
- }
-
- @Override
- public boolean performAccessibilityAction(View host, int action, Bundle args) {
- if (super.performAccessibilityAction(host, action, args)) {
- return true;
- }
- switch (action) {
- case AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD: {
- if ((mOrientation == Orientation.VERTICAL && internalCanScrollVertically(1))
- || (mOrientation == Orientation.HORIZONTAL && canScrollHorizontally(1))) {
- setCurrentItem(mCurItem + 1);
- return true;
- }
- }
- return false;
- case AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD: {
- if ((mOrientation == Orientation.VERTICAL && internalCanScrollVertically(-1))
- || (mOrientation == Orientation.HORIZONTAL && canScrollHorizontally(-1))) {
- setCurrentItem(mCurItem - 1);
- return true;
- }
- }
- return false;
- }
- return false;
- }
-
- private boolean canScroll() {
- return (mAdapter != null) && (mAdapter.getCount() > 1);
- }
- }
-
- private class PagerObserver extends DataSetObserver {
- @Override
- public void onChanged() {
- dataSetChanged();
- }
-
- @Override
- public void onInvalidated() {
- dataSetChanged();
- }
- }
-
- /**
- * Layout parameters that should be supplied for views added to a
- * ViewPager.
- */
- public static class LayoutParams extends ViewGroup.LayoutParams {
- /**
- * true if this view is a decoration on the pager itself and not
- * a view supplied by the adapter.
- */
- public boolean isDecor;
-
- /**
- * Gravity setting for use on decor views only:
- * Where to position the view page within the overall ViewPager
- * container; constants are defined in {@link android.view.Gravity}.
- */
- public int gravity;
-
- /**
- * Width as a 0-1 multiplier of the measured pager height
- */
- float heightFactor = 0.f;
-
- /**
- * Width as a 0-1 multiplier of the measured pager width
- */
- float widthFactor = 0.f;
-
- /**
- * true if this view was added during layout and needs to be measured
- * before being positioned.
- */
- boolean needsMeasure;
-
- /**
- * Adapter position this view is for if !isDecor
- */
- int position;
-
- /**
- * Current child index within the ViewPager that this view occupies
- */
- int childIndex;
-
- public LayoutParams() {
- super(FILL_PARENT, FILL_PARENT);
- }
-
- public LayoutParams(Context context, AttributeSet attrs) {
- super(context, attrs);
-
- final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
- gravity = a.getInteger(0, Gravity.TOP);
- a.recycle();
- }
- }
-
- static class ViewPositionComparator implements Comparator {
- @Override
- public int compare(View lhs, View rhs) {
- final LayoutParams llp = (LayoutParams) lhs.getLayoutParams();
- final LayoutParams rlp = (LayoutParams) rhs.getLayoutParams();
- if (llp.isDecor != rlp.isDecor) {
- return llp.isDecor ? 1 : -1;
- }
- return llp.position - rlp.position;
- }
- }
-
- // Following classes and the interface are needed for the Maven Central upload script to work properly.
- // They are being introduced here, sort of temporarily (until I find a better solution for this issue).
-
- /**
- * Callbacks a {@link Parcelable} creator should implement.
- */
- public interface ParcelableCompatCreatorCallbacks {
-
- /**
- * Create a new instance of the Parcelable class, instantiating it
- * from the given Parcel whose data had previously been written by
- * {@link Parcelable#writeToParcel Parcelable.writeToParcel()} and
- * using the given ClassLoader.
- *
- * @param in The Parcel to read the object's data from.
- * @param loader The ClassLoader that this object is being created in.
- * @return Returns a new instance of the Parcelable class.
- */
- public T createFromParcel(Parcel in, ClassLoader loader);
-
- /**
- * Create a new array of the Parcelable class.
- *
- * @param size Size of the array.
- * @return Returns an array of the Parcelable class, with every entry
- * initialized to null.
- */
- public T[] newArray(int size);
- }
-
- /**
- * Helper for accessing features in {@link android.os.Parcelable}
- * introduced after API level 4 in a backwards compatible fashion.
- */
- public static class ParcelableCompat {
-
- /**
- * Factory method for {@link Parcelable.Creator}.
- *
- * @param callbacks Creator callbacks implementation.
- * @return New creator.
- */
- public static Parcelable.Creator newCreator(
- OrientedViewPager.ParcelableCompatCreatorCallbacks callbacks) {
- if (android.os.Build.VERSION.SDK_INT >= 13) {
- return ParcelableCompatCreatorHoneycombMR2Stub.instantiate(callbacks);
- }
- return new CompatCreator(callbacks);
- }
-
- public static class CompatCreator implements Parcelable.Creator {
- final OrientedViewPager.ParcelableCompatCreatorCallbacks mCallbacks;
-
- public CompatCreator(OrientedViewPager.ParcelableCompatCreatorCallbacks callbacks) {
- mCallbacks = callbacks;
- }
-
- @Override
- public T createFromParcel(Parcel source) {
- return mCallbacks.createFromParcel(source, null);
- }
-
- @Override
- public T[] newArray(int size) {
- return mCallbacks.newArray(size);
- }
- }
- }
-
- static class ParcelableCompatCreatorHoneycombMR2Stub {
- public static Parcelable.Creator instantiate(
- OrientedViewPager.ParcelableCompatCreatorCallbacks callbacks) {
- return new ParcelableCompatCreatorHoneycombMR2(callbacks);
- }
- }
-
- static class ParcelableCompatCreatorHoneycombMR2 implements Parcelable.ClassLoaderCreator {
- private final OrientedViewPager.ParcelableCompatCreatorCallbacks mCallbacks;
-
- public ParcelableCompatCreatorHoneycombMR2(
- OrientedViewPager.ParcelableCompatCreatorCallbacks callbacks) {
- mCallbacks = callbacks;
- }
-
- public T createFromParcel(Parcel in) {
- return mCallbacks.createFromParcel(in, null);
- }
-
- public T createFromParcel(Parcel in, ClassLoader loader) {
- return mCallbacks.createFromParcel(in, loader);
- }
-
- public T[] newArray(int size) {
- return mCallbacks.newArray(size);
- }
- }
-}
\ No newline at end of file
diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/VerticalBaseTransformer.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/VerticalBaseTransformer.java
deleted file mode 100644
index 329d66a2b4..0000000000
--- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/VerticalBaseTransformer.java
+++ /dev/null
@@ -1,112 +0,0 @@
-
-package com.mogo.module.main.cards;
-
-import android.view.View;
-
-import androidx.viewpager.widget.ViewPager;
-
-
-/**
- * Created by Nate on 2016/7/22.
- */
-public abstract class VerticalBaseTransformer implements ViewPager.PageTransformer {
- /**
- * Called each {@link #transformPage(View, float)}.
- *
- * @param page Apply the transformation to this page
- * @param position Position of page relative to the current front-and-center position of the pager. 0 is front and
- * center. 1 is one full page position to the right, and -1 is one page position to the left.
- */
- protected abstract void onTransform(View page, float position);
-
- /**
- * Apply a property transformation to the given page. For most use cases, this method should not be overridden.
- * Instead use {@link #transformPage(View, float)} to perform typical transformations.
- *
- * @param page Apply the transformation to this page
- * @param position Position of page relative to the current front-and-center position of the pager. 0 is front and
- * center. 1 is one full page position to the right, and -1 is one page position to the left.
- */
- @Override
- public void transformPage(View page, float position) {
- onPreTransform(page, position);
- onTransform(page, position);
- onPostTransform(page, position);
- }
-
- /**
- * If the position offset of a fragment is less than negative one or greater than one, returning true will set the
- * fragment alpha to 0f. Otherwise fragment alpha is always defaulted to 1f.
- *
- * @return
- */
- protected boolean hideOffscreenPages() {
- return true;
- }
-
- /**
- * Indicates if the default animations of the view pager should be used.
- *
- * @return
- */
- protected boolean isPagingEnabled() {
- return false;
- }
-
- /**
- * Called each {@link #transformPage(View, float)} before {{@link #onTransform(View, float)}.
- *
- * The default implementation attempts to reset all view properties. This is useful when toggling transforms that do
- * not modify the same page properties. For instance changing from a transformation that applies rotation to a
- * transformation that fades can inadvertently leave a fragment stuck with a rotation or with some degree of applied
- * alpha.
- *
- * @param page Apply the transformation to this page
- * @param position Position of page relative to the current front-and-center position of the pager. 0 is front and
- * center. 1 is one full page position to the right, and -1 is one page position to the left.
- */
- protected void onPreTransform(View page, float position) {
- final float width = page.getWidth();
- final float height = page.getHeight();
-
- page.setRotationX(0);
- page.setRotationY(0);
- page.setRotation(0);
- page.setScaleX(1);
- page.setScaleY(1);
- page.setPivotX(0);
- page.setPivotY(0);
- page.setTranslationX(0);
- page.setTranslationY(isPagingEnabled() ? 0f : -height * position);
-
- if (hideOffscreenPages()) {
- page.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
- } else {
- page.setAlpha(1f);
- }
-
- /*final float normalizedposition = Math.abs(Math.abs(position) - 1);
- page.setAlpha(normalizedposition);*/
- }
-
- /**
- * Called each {@link #transformPage(View, float)} after {@link #onTransform(View, float)}.
- *
- * @param page Apply the transformation to this page
- * @param position Position of page relative to the current front-and-center position of the pager. 0 is front and
- * center. 1 is one full page position to the right, and -1 is one page position to the left.
- */
- protected void onPostTransform(View page, float position) {
- }
-
- /**
- * Same as {@link Math#min(double, double)} without double casting, zero closest to infinity handling, or NaN support.
- *
- * @param val
- * @param min
- * @return
- */
- protected static final float min(float val, float min) {
- return val < min ? min : val;
- }
-}
\ No newline at end of file
diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/VerticalStackTransformer.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/VerticalStackTransformer.java
deleted file mode 100644
index f7433ad2dc..0000000000
--- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/VerticalStackTransformer.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package com.mogo.module.main.cards;
-
-import android.content.Context;
-import android.util.Log;
-import android.view.View;
-
-import com.mogo.module.main.R;
-import com.mogo.utils.WindowUtils;
-import com.mogo.utils.logger.Logger;
-
-public class VerticalStackTransformer extends VerticalBaseTransformer {
-
- private Context context;
- private int spaceBetweenFirAndSecWith;//第一张卡片和第二张卡片宽度差
- private int spaceBetweenFirAndSecHeight;//第一张卡片和第二张卡片高度差
- private float offsetScroll = 0.0f;//ViewPager滑动时变化幅度
-
- public VerticalStackTransformer( Context context ) {
- this.context = context;
- spaceBetweenFirAndSecHeight = 0;
- spaceBetweenFirAndSecWith = context.getResources().getDimensionPixelSize( R.dimen.module_main_card_card_shadow_width_div );
- }
-
- public VerticalStackTransformer( Context context, int spaceBetweenFirAndSecWith, int spaceBetweenFirAndSecHeight ) {
- this.context = context;
- this.spaceBetweenFirAndSecWith = spaceBetweenFirAndSecWith;
- this.spaceBetweenFirAndSecHeight = spaceBetweenFirAndSecHeight;
- }
-
- public void offsetScrollChanged(float offset){
- if(offset ==0){
- return;
- }
- offsetScroll = offset;
- }
-
- public void resetOffsetScroll(){
- offsetScroll = 0.0f;
- }
-
- @Override
- protected void onTransform( View page, float position ) {
- if ( position == 0.0f ) {
- page.setAlpha( 1.0f );
- page.setTranslationY( 0f );
- //控制停止滑动切换的时候,只有最上面的一张卡片可以点击
- page.setClickable( true );
- } else if(position>0){
- float scale = ( float ) ( page.getWidth() - spaceBetweenFirAndSecWith * position ) / ( float ) ( page.getWidth() );
- Logger.d("VerticalStackTransformer","scale :" + scale);
- //控制下面卡片的可见度
- page.setAlpha( 1.0f );
- //控制停止滑动切换的时候,只有最上面的一张卡片可以点击
- page.setClickable( false );
- page.setPivotX( page.getWidth() / 2f );
- page.setPivotY( page.getHeight() / 2f );
- page.setScaleX( scale );
- page.setScaleY( scale );
- page.setTranslationY( -page.getHeight() * position + ( page.getHeight() * 0.5f ) * ( 1 - scale ) + spaceBetweenFirAndSecHeight * position );
- }else{
- float currentPage;
- if(offsetScroll > 0.2f){
- currentPage = 0.2f;
- }else{
- currentPage = offsetScroll;
- }
- page.setAlpha( 1 );
- page.setScaleX(1-currentPage);
- page.setScaleY(1-currentPage);
- page.setPivotX( page.getWidth() / 2f );
- page.setPivotY( page.getHeight() / 2f );
- page.setTranslationY( 0f );
- page.setClickable( false );
- }
- }
-}
\ No newline at end of file
diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/constants/VoiceConstants.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/constants/VoiceConstants.java
deleted file mode 100644
index d14b06381d..0000000000
--- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/constants/VoiceConstants.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.mogo.module.main.constants;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author zyz
- * 2020-03-02.
- */
-public class VoiceConstants {
- /**
- * 切换上一张卡片
- */
- public static final String COMMAND_ZHIDAO_SWITCHCARD_PREVIOUS = "com.zhidao.desk.switchCard.previous";
- /**
- * 切换下一张卡片
- */
- public static final String COMMAND_ZHIDAO_SWITCHCARD_NEXT = "com.zhidao.desk.switchCard.next";
- /**
- * 查看多媒体卡片、探路卡片
- */
- public static final String COMMAND_ZHIDAO_SWITCHCARD = "com.zhidao.desk.switchCard";
-
-
-
- public static ArrayList sCmds=new ArrayList<>();
-
- static {
- sCmds.add(COMMAND_ZHIDAO_SWITCHCARD_PREVIOUS);
- sCmds.add(COMMAND_ZHIDAO_SWITCHCARD_NEXT);
- sCmds.add(COMMAND_ZHIDAO_SWITCHCARD);
- }
-}
diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/livedata/CardInfo.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/livedata/CardInfo.java
deleted file mode 100644
index 08cee036af..0000000000
--- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/livedata/CardInfo.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package com.mogo.module.main.livedata;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-
-/**
- * @author congtaowang
- * @since 2020-03-09
- *
- * 描述
- */
-public class CardInfo implements Parcelable {
-
- public String mCardName;
- public boolean mLockCar;
-
- public CardInfo( String cardName, boolean lockCar ) {
- this.mCardName = cardName;
- this.mLockCar = lockCar;
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel( Parcel dest, int flags ) {
- dest.writeString( this.mCardName );
- dest.writeByte( this.mLockCar ? ( byte ) 1 : ( byte ) 0 );
- }
-
- protected CardInfo( Parcel in ) {
- this.mCardName = in.readString();
- this.mLockCar = in.readByte() != 0;
- }
-
- public static final Parcelable.Creator< CardInfo > CREATOR = new Parcelable.Creator< CardInfo >() {
- @Override
- public CardInfo createFromParcel( Parcel source ) {
- return new CardInfo( source );
- }
-
- @Override
- public CardInfo[] newArray( int size ) {
- return new CardInfo[size];
- }
- };
-}
diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/livedata/CardSwitchLiveData.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/livedata/CardSwitchLiveData.java
deleted file mode 100644
index 0f078ce718..0000000000
--- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/livedata/CardSwitchLiveData.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.mogo.module.main.livedata;
-
-import androidx.lifecycle.MutableLiveData;
-
-/**
- * @author congtaowang
- * @since 2020-01-06
- *
- * 切换卡片
- */
-public class CardSwitchLiveData extends MutableLiveData< CardInfo > {
-
- private CardSwitchLiveData() {
- // private constructor
- }
-
- private static final class InstanceHolder {
- private static final CardSwitchLiveData INSTANCE = new CardSwitchLiveData();
- }
-
- public static CardSwitchLiveData getInstance() {
- return InstanceHolder.INSTANCE;
- }
-}
diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/registercenter/MogoRegisterCenterHandler.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/registercenter/MogoRegisterCenterHandler.java
index d4a009fa7d..56c9e0eb01 100644
--- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/registercenter/MogoRegisterCenterHandler.java
+++ b/modules/mogo-module-main/src/main/java/com/mogo/module/main/registercenter/MogoRegisterCenterHandler.java
@@ -15,6 +15,7 @@ import com.mogo.service.module.IMogoRegisterCenter;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
/**
* @author congtaowang
@@ -28,7 +29,7 @@ public class MogoRegisterCenterHandler implements IMogoRegisterCenter {
private Map< String, IMogoModuleLifecycle > mLifecycle = new HashMap<>();
private Map< String, IMogoMapListener > mMap = new HashMap<>();
- private Map< String, IMogoNaviListener > mNavi = new HashMap<>();
+ private Map< String, IMogoNaviListener > mNavi = new ConcurrentHashMap<>();
private Map< String, IMogoLocationListener > mLocation = new HashMap<>();
private Map< String, IMogoMarkerClickListener > mMarker = new HashMap<>();
private Map< String, IMogoAimlessModeListener > mAimless = new HashMap<>();
diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/service/MogoMainService.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/service/MogoMainService.java
index b7c220f00b..149ffad5e7 100644
--- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/service/MogoMainService.java
+++ b/modules/mogo-module-main/src/main/java/com/mogo/module/main/service/MogoMainService.java
@@ -7,15 +7,14 @@ import android.os.IBinder;
import androidx.annotation.Nullable;
import com.alibaba.android.arouter.facade.annotation.Route;
-import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.map.location.IMogoLocationClient;
import com.mogo.map.location.IMogoLocationListener;
import com.mogo.map.location.MogoLocation;
+import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.main.EventDispatchCenter;
import com.mogo.module.main.cards.MogoModulesManager;
import com.mogo.service.IMogoServiceApis;
-import com.mogo.service.MogoServicePaths;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.logger.Logger;
@@ -26,7 +25,7 @@ public
*
* 描述
*/
-@Route(path = "/service/base/info")
+@Route( path = "/service/base/info" )
class MogoMainService extends Service implements IMogoLocationListener {
private static final String TAG = "MogoMainService";
@@ -39,10 +38,10 @@ class MogoMainService extends Service implements IMogoLocationListener {
@Override
public void onCreate() {
- Logger.d(TAG, "基本服务启动");
- mServiceApis = (IMogoServiceApis) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation();
+ Logger.d( TAG, "基本服务启动" );
+ mServiceApis = MogoApisHandler.getInstance().getApis();
initAndStartLocation();
- UiThreadHandler.postDelayed(() -> {
+ UiThreadHandler.postDelayed( () -> {
loadBaseModules();
startTanluService();
initADAS();
@@ -53,53 +52,53 @@ class MogoMainService extends Service implements IMogoLocationListener {
@Nullable
@Override
- public IBinder onBind(Intent intent) {
+ public IBinder onBind( Intent intent ) {
return null;
}
@Override
- public int onStartCommand(Intent intent, int flags, int startId) {
+ public int onStartCommand( Intent intent, int flags, int startId ) {
return START_STICKY;
}
private void initAndStartLocation() {
- Logger.d(TAG, "开始定位");
- mLocationClient = mServiceApis.getMapServiceApi().getSingletonLocationClient(AbsMogoApplication.getApp());
- mLocationClient.addLocationListener(this);
- mLocationClient.start(2_000L);
+ Logger.d( TAG, "开始定位" );
+ mLocationClient = mServiceApis.getMapServiceApi().getSingletonLocationClient( AbsMogoApplication.getApp() );
+ mLocationClient.addLocationListener( this );
+ mLocationClient.start( 2_000L );
}
private void initGpsSimulatorListener() {
- mServiceApis.getMapServiceApi().getNavi(this).registerCarLocationChangedListener(EventDispatchCenter.getInstance());
+ mServiceApis.getMapServiceApi().getNavi( this ).registerCarLocationChangedListener( EventDispatchCenter.getInstance() );
}
private void loadBaseModules() {
- Logger.d(TAG, "加载基本模块");
+ Logger.d( TAG, "加载基本模块" );
MogoModulesManager.getInstance().loadBaseModule();
}
private void startTanluService() {
- UiThreadHandler.postDelayed(() -> {
- Logger.d(TAG, "startTanluService ---------- ");
+ UiThreadHandler.postDelayed( () -> {
+ Logger.d( TAG, "startTanluService ---------- " );
mServiceApis.getTanluApi().startTanluService();
}, 2_000L
);
}
private void initADAS() {
- mServiceApis.getAdasControllerApi().init(AbsMogoApplication.getApp());
+ mServiceApis.getAdasControllerApi().init( AbsMogoApplication.getApp() );
}
@Override
- public void onLocationChanged(MogoLocation location) {
- EventDispatchCenter.getInstance().onLocationChanged(location);
+ public void onLocationChanged( MogoLocation location ) {
+ EventDispatchCenter.getInstance().onLocationChanged( location );
}
@Override
public void onDestroy() {
super.onDestroy();
- if (mLocationClient != null) {
- mLocationClient.removeLocationListener(this);
+ if ( mLocationClient != null ) {
+ mLocationClient.removeLocationListener( this );
mLocationClient.stop();
mLocationClient.destroy();
mLocationClient = null;
diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/windowview/FloatingViewHandler.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/windowview/FloatingViewHandler.java
index 5485f4778d..a1c8afd276 100644
--- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/windowview/FloatingViewHandler.java
+++ b/modules/mogo-module-main/src/main/java/com/mogo/module/main/windowview/FloatingViewHandler.java
@@ -41,6 +41,10 @@ public class FloatingViewHandler {
sFloatingLayout = frameLayout;
}
+ public static void clear(){
+ sFloatingLayout = null;
+ }
+
/**
* 添加任意view到布局,不考虑优先级
*
diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/windowview/TopViewHolder.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/windowview/TopViewHolder.java
deleted file mode 100644
index 12bc772e07..0000000000
--- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/windowview/TopViewHolder.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.mogo.module.main.windowview;
-
-import android.view.View;
-
-/**
- * 用来处理主屏上方1/2屏的view
- */
-public class TopViewHolder {
- public void init(){
-
- }
- public void addView(View view) {
-
- }
-}
diff --git a/modules/mogo-module-main/src/main/res/values-mdpi/dimens.xml b/modules/mogo-module-main/src/main/res/values-mdpi/dimens.xml
index d27dfc19e4..707ac832c0 100644
--- a/modules/mogo-module-main/src/main/res/values-mdpi/dimens.xml
+++ b/modules/mogo-module-main/src/main/res/values-mdpi/dimens.xml
@@ -17,7 +17,7 @@
319px
110px
- 10px
+ 6px
15px
460px
444px
diff --git a/modules/mogo-module-main/src/main/res/values/dimens.xml b/modules/mogo-module-main/src/main/res/values/dimens.xml
index 3cf1f1ee39..707ac832c0 100644
--- a/modules/mogo-module-main/src/main/res/values/dimens.xml
+++ b/modules/mogo-module-main/src/main/res/values/dimens.xml
@@ -17,7 +17,7 @@
319px
110px
- 10px
+ 6px
15px
460px
444px
@@ -26,6 +26,6 @@
16px
658px
8px
- 10px
+ 2px
\ No newline at end of file
diff --git a/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapBroadCastHelper.java b/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapBroadCastHelper.java
index 8eef0ad064..21475de044 100644
--- a/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapBroadCastHelper.java
+++ b/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapBroadCastHelper.java
@@ -4,11 +4,10 @@ import android.content.Context;
import android.content.Intent;
import android.util.Log;
-import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.map.navi.MogoNaviInfo;
+import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.map.CustomNaviInterrupter;
import com.mogo.service.IMogoServiceApis;
-import com.mogo.service.MogoServicePaths;
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
import com.mogo.service.statusmanager.StatusDescriptor;
import com.mogo.utils.AppUtils;
@@ -31,8 +30,7 @@ public class MapBroadCastHelper implements IMogoStatusChangedListener {
private MapBroadCastHelper( Context context ) {
this.mContext = context;
- IMogoServiceApis api = ( IMogoServiceApis ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICE_APIS ).navigation( context );
- api.getStatusManagerApi().registerStatusChangedListener( TAG, StatusDescriptor.AI_ASSIST_READY, this );
+ MogoApisHandler.getInstance().getApis().getStatusManagerApi().registerStatusChangedListener( TAG, StatusDescriptor.AI_ASSIST_READY, this );
}
public static MapBroadCastHelper getInstance( Context context ) {
@@ -101,4 +99,10 @@ public class MapBroadCastHelper implements IMogoStatusChangedListener {
}
}
}
+
+ public void release(){
+ MogoApisHandler.getInstance().getApis().getStatusManagerApi().unregisterStatusChangedListener( TAG, StatusDescriptor.AI_ASSIST_READY, this );
+ mContext = null;
+ sInstance = null;
+ }
}
diff --git a/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapFragment.java b/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapFragment.java
index 353af2b392..0ad88b5e6e 100644
--- a/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapFragment.java
+++ b/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapFragment.java
@@ -16,6 +16,7 @@ import com.mogo.service.MogoServicePaths;
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
import com.mogo.service.statusmanager.IMogoStatusManager;
import com.mogo.service.statusmanager.StatusDescriptor;
+import com.mogo.utils.logger.Logger;
/**
* @author congtaowang
@@ -60,6 +61,7 @@ public class MapFragment extends MvpFragment< MapView, MapPresenter > implements
@Override
public void onActivityCreated( @Nullable Bundle savedInstanceState ) {
super.onActivityCreated( savedInstanceState );
+ Logger.d( TAG, "onActivityCreated" );
initMapView();
}
@@ -143,5 +145,6 @@ public class MapFragment extends MvpFragment< MapView, MapPresenter > implements
if ( mMogoMapView != null ) {
mMogoMapView.onDestroy();
}
+ MapBroadCastHelper.getInstance( getContext() ).release();
}
}
diff --git a/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapPresenter.java b/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapPresenter.java
index f0316ac8e9..f96ca3c162 100644
--- a/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapPresenter.java
+++ b/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapPresenter.java
@@ -9,7 +9,6 @@ import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.lifecycle.LifecycleOwner;
-import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.commons.mvp.Presenter;
import com.mogo.commons.voice.AIAssist;
import com.mogo.commons.voice.IMogoVoiceCmdCallBack;
@@ -21,9 +20,9 @@ import com.mogo.map.navi.MogoNaviConfig;
import com.mogo.map.navi.MogoNaviInfo;
import com.mogo.map.uicontroller.EnumMapUI;
import com.mogo.map.uicontroller.MapControlResult;
+import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.map.CustomNaviInterrupter;
import com.mogo.service.IMogoServiceApis;
-import com.mogo.service.MogoServicePaths;
import com.mogo.service.adas.IMogoADASControlStatusChangedListener;
import com.mogo.service.intent.IMogoIntentListener;
import com.mogo.service.intent.IMogoIntentManager;
@@ -248,7 +247,7 @@ public class MapPresenter extends Presenter< MapView > implements
public void onCreate( @NonNull LifecycleOwner owner ) {
super.onCreate( owner );
- mApis = ( IMogoServiceApis ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICE_APIS ).navigation( getContext() );
+ mApis = MogoApisHandler.getInstance().getApis();
mMogoMapService = mApis.getMapServiceApi();
mMogoIntentManager = mApis.getIntentManagerApi();
mSearchManager = mApis.getSearchManagerApi();
diff --git a/modules/mogo-module-media/build.gradle b/modules/mogo-module-media/build.gradle
index 0ddfae0634..dff1c08f76 100644
--- a/modules/mogo-module-media/build.gradle
+++ b/modules/mogo-module-media/build.gradle
@@ -47,6 +47,8 @@ dependencies {
implementation "com.mogo.tencent.wecarflow:mogo-wecarflow:+@aar"
implementation "com.mogo.kwmusic:mogo-kwmusic:+"
+ implementation rootProject.ext.dependencies.carcallprovider
+
if (Boolean.valueOf(RELEASE)) {
implementation rootProject.ext.dependencies.mogomap
implementation rootProject.ext.dependencies.mogoutils
diff --git a/modules/mogo-module-media/src/main/java/com/mogo/module/media/MediaCardViewProvider.java b/modules/mogo-module-media/src/main/java/com/mogo/module/media/MediaCardViewProvider.java
index 059a886869..c4fdd84162 100644
--- a/modules/mogo-module-media/src/main/java/com/mogo/module/media/MediaCardViewProvider.java
+++ b/modules/mogo-module-media/src/main/java/com/mogo/module/media/MediaCardViewProvider.java
@@ -20,7 +20,7 @@ import com.mogo.service.module.ModuleType;
public class MediaCardViewProvider implements IMogoModuleProvider {
private static final String TAG = "MediaCardViewProvider";
-
+ private MediaWindow2 mediaWindow2;
@Override
public Fragment createFragment( Context context, Bundle data ) {
@@ -33,7 +33,7 @@ public class MediaCardViewProvider implements IMogoModuleProvider {
@Override
public void init( Context context ) {
ServiceMediaHandler.init( context );
- MediaWindow2 mediaWindow2 = new MediaWindow2();
+ mediaWindow2 = new MediaWindow2();
mediaWindow2.initMedia(context);
}
@@ -88,4 +88,12 @@ public class MediaCardViewProvider implements IMogoModuleProvider {
public String getAppName() {
return "";
}
+
+ @Override
+ public void onDestroy() {
+ if ( mediaWindow2 != null ) {
+ mediaWindow2.onDestroy();
+ }
+ mediaWindow2 = null;
+ }
}
diff --git a/modules/mogo-module-media/src/main/java/com/mogo/module/media/ServiceMediaHandler.java b/modules/mogo-module-media/src/main/java/com/mogo/module/media/ServiceMediaHandler.java
index 17a0a08c47..db9b78b43d 100644
--- a/modules/mogo-module-media/src/main/java/com/mogo/module/media/ServiceMediaHandler.java
+++ b/modules/mogo-module-media/src/main/java/com/mogo/module/media/ServiceMediaHandler.java
@@ -11,6 +11,7 @@ import com.mogo.map.navi.IMogoNavi;
import com.mogo.map.uicontroller.IMogoMapUIController;
import com.mogo.module.authorize.authprovider.invoke.AuthorizeConstant;
import com.mogo.module.authorize.authprovider.module.IMogoAuthorizeModuleManager;
+import com.mogo.module.carchattingprovider.ICarsChattingProvider;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.adas.IMogoADASController;
import com.mogo.service.analytics.IMogoAnalytics;
@@ -53,6 +54,8 @@ public class ServiceMediaHandler {
private static IMogoAuthorizeModuleManager mMogoAuthorizeModuleManager;
private static IMogoMarkerService sMarkerService;
+ private static ICarsChattingProvider sCarsChattingProvider;
+
public static void init(Context context) {
mApis = (MogoServiceApis) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(context);
mMapService = mApis.getMapServiceApi();
@@ -73,6 +76,8 @@ public class ServiceMediaHandler {
mMogoADASController = mApis.getAdasControllerApi();
mMogoAuthorizeModuleManager = (IMogoAuthorizeModuleManager) ARouter.getInstance().build(AuthorizeConstant.PROVIDER_MODULE).navigation(context);
sMarkerService = mApis.getMarkerService();
+
+ sCarsChattingProvider = ARouter.getInstance().navigation( ICarsChattingProvider.class );
}
public static IMogoADASController getMogoADASController(){
@@ -157,6 +162,10 @@ public class ServiceMediaHandler {
return mMogoDataManager;
}
+ public static MogoServiceApis getApis() {
+ return mApis;
+ }
+
/**
* 这个注册的第一个参数是模块名称,目的是只给当前显示的卡片分发事件
* @return
@@ -183,6 +192,11 @@ public class ServiceMediaHandler {
return sMarkerService;
}
+ public static ICarsChattingProvider getCarsChattingApis() {
+ isApisNull( sCarsChattingProvider );
+ return sCarsChattingProvider;
+ }
+
public static void isApisNull( Object object){
if (isObjStaticNull(object)){
init(AbsMogoApplication.getApp());
diff --git a/modules/mogo-module-media/src/main/java/com/mogo/module/media/listener/CallProviderResponseAdapter.java b/modules/mogo-module-media/src/main/java/com/mogo/module/media/listener/CallProviderResponseAdapter.java
new file mode 100644
index 0000000000..6fa008de0e
--- /dev/null
+++ b/modules/mogo-module-media/src/main/java/com/mogo/module/media/listener/CallProviderResponseAdapter.java
@@ -0,0 +1,106 @@
+package com.mogo.module.media.listener;
+
+import com.mogo.module.carchattingprovider.ICallProviderResponse;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+public
+/**
+ * @author congtaowang
+ * @since 2020/9/24
+ *
+ * 描述
+ */
+abstract class CallProviderResponseAdapter implements ICallProviderResponse {
+
+ @Override
+ public void addFriend( boolean b ) {
+
+ }
+
+ @Override
+ public void callInvokeError( @NotNull String s ) {
+
+ }
+
+ @Override
+ public void callStatus( int i ) {
+
+ }
+
+ @Override
+ public void canCall( boolean b ) {
+
+ }
+
+ @Override
+ public void hideUserWindowError( @NotNull String s ) {
+
+ }
+
+ @Override
+ public void invisibleUser( boolean b ) {
+
+ }
+
+ @Override
+ public void isFriend( boolean b ) {
+
+ }
+
+ @Override
+ public void isOnLine( boolean b, @Nullable String s ) {
+
+ }
+
+ @Override
+ public void userInfoCallBack( @Nullable String s, @Nullable String s1 ) {
+
+ }
+
+ @Override
+ public void userWindowStatus( boolean b ) {
+
+ }
+
+ @Override
+ public void call( @NotNull String s ) {
+
+ }
+
+ @Override
+ public void cancelMatch( boolean b ) {
+
+ }
+
+ @Override
+ public void error( @NotNull String s ) {
+
+ }
+
+ @Override
+ public void hangUp( boolean b ) {
+
+ }
+
+ @Override
+ public void invokeCallData( @NotNull String s ) {
+
+ }
+
+ @Override
+ public void match( @NotNull String s ) {
+
+ }
+
+ @Override
+ public void matchInvokeResult( boolean b, @NotNull String s ) {
+
+ }
+
+ @Override
+ public void mute( boolean b ) {
+
+ }
+}
diff --git a/modules/mogo-module-media/src/main/java/com/mogo/module/media/presenter/KwPresenter.java b/modules/mogo-module-media/src/main/java/com/mogo/module/media/presenter/KwPresenter.java
index 60810062c4..6d40bafb55 100644
--- a/modules/mogo-module-media/src/main/java/com/mogo/module/media/presenter/KwPresenter.java
+++ b/modules/mogo-module-media/src/main/java/com/mogo/module/media/presenter/KwPresenter.java
@@ -5,13 +5,12 @@ import android.os.Handler;
import android.os.Message;
import android.util.Log;
-import com.alibaba.android.arouter.launcher.ARouter;
+import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.media.MediaConstants;
import com.mogo.module.media.constants.MusicConstant;
import com.mogo.module.media.model.MediaInfoData;
import com.mogo.module.media.view.IMusicView;
import com.mogo.service.IMogoServiceApis;
-import com.mogo.service.MogoServicePaths;
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
import com.mogo.service.statusmanager.StatusDescriptor;
@@ -108,8 +107,7 @@ public class KwPresenter extends BaseMediaPresenter {
}
});
- IMogoServiceApis serviceApis =
- (IMogoServiceApis) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(context);
+ IMogoServiceApis serviceApis = MogoApisHandler.getInstance().getApis();
serviceApis.getStatusManagerApi().registerStatusChangedListener(MediaConstants.MODULE_TYPE, StatusDescriptor.MAIN_PAGE_RESUME, new IMogoStatusChangedListener() {
@Override
diff --git a/modules/mogo-module-media/src/main/java/com/mogo/module/media/presenter/WeCarFlowPresenter.java b/modules/mogo-module-media/src/main/java/com/mogo/module/media/presenter/WeCarFlowPresenter.java
index 4aa6dd259c..570964a4b2 100644
--- a/modules/mogo-module-media/src/main/java/com/mogo/module/media/presenter/WeCarFlowPresenter.java
+++ b/modules/mogo-module-media/src/main/java/com/mogo/module/media/presenter/WeCarFlowPresenter.java
@@ -2,16 +2,12 @@ package com.mogo.module.media.presenter;
import android.content.Context;
-import androidx.annotation.NonNull;
-import androidx.lifecycle.LifecycleOwner;
-
-import com.alibaba.android.arouter.launcher.ARouter;
+import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.media.MediaConstants;
import com.mogo.module.media.constants.MusicConstant;
import com.mogo.module.media.model.MediaInfoData;
import com.mogo.module.media.view.IMusicView;
import com.mogo.service.IMogoServiceApis;
-import com.mogo.service.MogoServicePaths;
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
import com.mogo.service.statusmanager.StatusDescriptor;
import com.mogo.utils.logger.Logger;
@@ -77,8 +73,7 @@ public class WeCarFlowPresenter extends BaseMediaPresenter {
this.context = context;
currentMedia = new MediaInfoData();
- serviceApis =
- (IMogoServiceApis) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(context);
+ serviceApis = MogoApisHandler.getInstance().getApis();
serviceApis.getStatusManagerApi().registerStatusChangedListener(MediaConstants.MODULE_TYPE, StatusDescriptor.MAIN_PAGE_RESUME, new IMogoStatusChangedListener() {
@Override
diff --git a/modules/mogo-module-media/src/main/java/com/mogo/module/media/window/MediaWindow2.java b/modules/mogo-module-media/src/main/java/com/mogo/module/media/window/MediaWindow2.java
index b8edafa4bd..6cc81d0938 100644
--- a/modules/mogo-module-media/src/main/java/com/mogo/module/media/window/MediaWindow2.java
+++ b/modules/mogo-module-media/src/main/java/com/mogo/module/media/window/MediaWindow2.java
@@ -12,11 +12,13 @@ import android.widget.TextView;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.commons.voice.AIAssist;
import com.mogo.commons.voice.IMogoVoiceCmdCallBack;
+import com.mogo.module.carchattingprovider.ICallProviderResponse;
import com.mogo.module.common.glide.SkinAbleBitmapTarget;
import com.mogo.module.media.MediaConstants;
import com.mogo.module.media.R;
import com.mogo.module.media.ServiceMediaHandler;
import com.mogo.module.media.constants.MusicConstant;
+import com.mogo.module.media.listener.CallProviderResponseAdapter;
import com.mogo.module.media.listener.NoDoubleClickListener;
import com.mogo.module.media.model.MediaInfoData;
import com.mogo.module.media.presenter.BaseMediaPresenter;
@@ -25,6 +27,7 @@ import com.mogo.module.media.presenter.PresenterFactory;
import com.mogo.module.media.utils.Utils;
import com.mogo.module.media.view.IMusicView;
import com.mogo.module.media.widget.AnimCircleImageView;
+import com.mogo.service.statusmanager.IMogoStatusChangedListener;
import com.mogo.service.statusmanager.StatusDescriptor;
import com.mogo.utils.WindowUtils;
import com.mogo.utils.glide.GlideApp;
@@ -38,7 +41,7 @@ import com.tencent.wecarflow.flowoutside.sdk.FlowPlayControl;
*
* @author tongchenfei
*/
-public class MediaWindow2 implements IMusicView {
+public class MediaWindow2 implements IMusicView , IMogoStatusChangedListener {
public static final String TAG = MediaWindow2.class.getName();
private Context mContext;
@@ -58,6 +61,9 @@ public class MediaWindow2 implements IMusicView {
private boolean mHasAddWindow = false;
private boolean mTwoChange = false;
private boolean isFirstPlay = false;
+ private boolean mIsCallChatWindowVisible;
+
+ private ICallProviderResponse mCallProviderResponse;
public void initMedia(Context context) {
mContext = context;
@@ -76,14 +82,34 @@ public class MediaWindow2 implements IMusicView {
});
}
- ServiceMediaHandler.getIMogoStatusManager().registerStatusChangedListener(MediaConstants.MODULE_TYPE, StatusDescriptor.ACC_STATUS, (descriptor, isTrue) -> {
- if (descriptor == StatusDescriptor.ACC_STATUS&&!isTrue) {
- ServiceMediaHandler.getMogoWindowManager().removeView(mWindowView);
- mHasAddWindow = false;
- }
- });
+ ServiceMediaHandler.getIMogoStatusManager().registerStatusChangedListener(MediaConstants.MODULE_TYPE, StatusDescriptor.ACC_STATUS, this);
- isFirstPlay = true;
+ // 车聊聊才是王
+ mCallProviderResponse = new CallProviderResponseAdapter(){
+ @Override
+ public void callWindowStatus( boolean b ) {
+ Logger.d( TAG, "callWindowStatus: "+ b);
+ mIsCallChatWindowVisible = b;
+ if ( !mHasAddWindow || mWindowView == null ) {
+ return;
+ }
+ if ( mIsCallChatWindowVisible ) {
+ mWindowView.setVisibility(View.GONE );
+ } else {
+ mWindowView.setVisibility(View.VISIBLE);
+ }
+ }
+ };
+ ServiceMediaHandler.getCarsChattingApis().registerCallWindowStatusListener( MediaConstants.MODULE_TYPE, mContext, mCallProviderResponse);
+ isFirstPlay = true;
+ }
+
+ @Override
+ public void onStatusChanged( StatusDescriptor descriptor, boolean isTrue ) {
+ if (descriptor == StatusDescriptor.ACC_STATUS&&!isTrue) {
+ ServiceMediaHandler.getMogoWindowManager().removeView(mWindowView);
+ mHasAddWindow = false;
+ }
}
private void addWindowView() {
@@ -93,16 +119,10 @@ public class MediaWindow2 implements IMusicView {
return;
}
-// if(!ServiceMediaHandler.getIMogoStatusManager().isMainPageOnResume()){
-// Log.d(TAG, "not in front");
-// return;
-// }
-
if (!mHasAddWindow) {
mHasAddWindow = true;
mWindowView =
LayoutInflater.from(mContext).inflate(R.layout.module_media_music_window_alert_layout, null);
- mWindowView.setVisibility(View.VISIBLE);
mCircleImg = mWindowView.findViewById(R.id.window_circle_img);
mScrollText = mWindowView.findViewById(R.id.window_scroll_txt);
mWindowPlayPause = mWindowView.findViewById(R.id.window_play_pause);
@@ -158,6 +178,13 @@ public class MediaWindow2 implements IMusicView {
}
}
});
+
+ if ( mIsCallChatWindowVisible ) {
+ Logger.d( TAG, "mWindowView.setVisibility: status = " + mIsCallChatWindowVisible );
+ mWindowView.setVisibility(View.GONE);
+ } else {
+ mWindowView.setVisibility(View.VISIBLE);
+ }
}
}
@@ -173,7 +200,11 @@ public class MediaWindow2 implements IMusicView {
if (mMediaInfoData.getType() == MusicConstant.PLAY_STATE_ERROR||isFirstPlay) {
mWindowView.setVisibility(View.GONE);
} else {
- mWindowView.setVisibility(View.VISIBLE);
+ if ( mIsCallChatWindowVisible ) {
+ mWindowView.setVisibility(View.GONE );
+ } else {
+ mWindowView.setVisibility(View.VISIBLE);
+ }
}
} else {
mWindowView.setVisibility(View.GONE);
@@ -305,4 +336,10 @@ public class MediaWindow2 implements IMusicView {
mWindowView.setVisibility(View.GONE);
}
}
+
+ public void onDestroy(){
+ Logger.d(TAG, "onDestroy");
+ ServiceMediaHandler.getCarsChattingApis().unRegisterCallWindowStatusListener( MediaConstants.MODULE_TYPE, mContext);
+ ServiceMediaHandler.getIMogoStatusManager().unregisterStatusChangedListener(MediaConstants.MODULE_TYPE, StatusDescriptor.ACC_STATUS,this);
+ }
}
diff --git a/modules/mogo-module-monitor/src/main/java/com/zhidao/mogo/module/monitor/MogoMonitorProvider.java b/modules/mogo-module-monitor/src/main/java/com/zhidao/mogo/module/monitor/MogoMonitorProvider.java
index 133fd25bd5..4f1c08f5aa 100644
--- a/modules/mogo-module-monitor/src/main/java/com/zhidao/mogo/module/monitor/MogoMonitorProvider.java
+++ b/modules/mogo-module-monitor/src/main/java/com/zhidao/mogo/module/monitor/MogoMonitorProvider.java
@@ -8,10 +8,9 @@ import android.os.Message;
import android.widget.Toast;
import com.alibaba.android.arouter.facade.annotation.Route;
-import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.commons.debug.DebugConfig;
+import com.mogo.module.common.MogoApisHandler;
import com.mogo.service.IMogoServiceApis;
-import com.mogo.service.MogoServicePaths;
import com.mogo.service.connection.IMogoOnMessageListener;
import com.mogo.service.monitor.IMogoMonitorProvider;
import com.mogo.utils.logger.LogLevel;
@@ -49,8 +48,7 @@ public class MogoMonitorProvider implements IMogoMonitorProvider,
@Override
public void init(Context context) {
this.context = context;
- IMogoServiceApis apis =
- (IMogoServiceApis) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(context);
+ IMogoServiceApis apis = MogoApisHandler.getInstance().getApis();
apis.getSocketManagerApi(context).registerOnMessageListener(MogoMonitorConst.LOG_PUSH_TYPE, this);
startRemoteCtrl();
}
diff --git a/modules/mogo-module-push/src/main/java/com/mogo/module/push/PushHistoryUiProvider.java b/modules/mogo-module-push/src/main/java/com/mogo/module/push/PushHistoryUiProvider.java
index dd389a6bdb..0b5b84d790 100644
--- a/modules/mogo-module-push/src/main/java/com/mogo/module/push/PushHistoryUiProvider.java
+++ b/modules/mogo-module-push/src/main/java/com/mogo/module/push/PushHistoryUiProvider.java
@@ -26,7 +26,7 @@ class PushHistoryUiProvider implements IFragmentProvider {
Fragment fragment = new MessageHistoryFragment();
activity.getSupportFragmentManager()
.beginTransaction()
- .add( containerId, fragment, PushUIConstants.Push_MESSAGE_ACTIVITY_PATH )
+ .replace( containerId, fragment, PushUIConstants.Push_MESSAGE_ACTIVITY_PATH )
.show( fragment )
.commitNowAllowingStateLoss();
return fragment;
@@ -36,4 +36,10 @@ class PushHistoryUiProvider implements IFragmentProvider {
public void init( Context context ) {
}
+
+
+ @Override
+ public void onDestroy() {
+
+ }
}
diff --git a/modules/mogo-module-push/src/main/java/com/mogo/module/push/fragment/MessageHistoryFragment.java b/modules/mogo-module-push/src/main/java/com/mogo/module/push/fragment/MessageHistoryFragment.java
index 17f97556a5..cea74ae303 100644
--- a/modules/mogo-module-push/src/main/java/com/mogo/module/push/fragment/MessageHistoryFragment.java
+++ b/modules/mogo-module-push/src/main/java/com/mogo/module/push/fragment/MessageHistoryFragment.java
@@ -10,6 +10,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.commons.analytics.AnalyticsUtils;
import com.mogo.commons.mvp.MvpFragment;
+import com.mogo.module.common.view.OnPreventFastClickListener;
import com.mogo.module.push.Config;
import com.mogo.module.push.R;
import com.mogo.module.push.adapter.PushMessageAdapter;
@@ -64,20 +65,26 @@ class MessageHistoryFragment extends MvpFragment< MessageHistoryView, MessageHis
mClose = findViewById( R.id.module_push_id_close );
AnalyticsUtils.track( Config.NEWS_HISTORY_OPEN, null );
- mClose.setOnClickListener( view -> {
- exitSelf();
+ mClose.setOnClickListener( new OnPreventFastClickListener() {
+ @Override
+ public void onClickImpl( View v ) {
+ exitSelf();
+ }
} );
- mClear.setOnClickListener( view -> {
- AnalyticsUtils.track( Config.NEWS_HISTORY_ALL_CLEAR, null );
- if ( !mClearing ) {
- mClearing = true;
- AnimatorUtilsKt.startClearAnimator(
- mHistoryList,
- () -> {
- mViewModel.deleteAll();
- mClearing = false;
- }
- );
+ mClear.setOnClickListener( new OnPreventFastClickListener() {
+ @Override
+ public void onClickImpl( View v ) {
+ AnalyticsUtils.track( Config.NEWS_HISTORY_ALL_CLEAR, null );
+ if ( !mClearing ) {
+ mClearing = true;
+ AnimatorUtilsKt.startClearAnimator(
+ mHistoryList,
+ () -> {
+ mViewModel.deleteAll();
+ mClearing = false;
+ }
+ );
+ }
}
} );
mAdapter.deletePushBean = new PushMessageAdapter.PushAdapterListener() {
diff --git a/modules/mogo-module-push/src/main/res/drawable-ldpi/module_push_item_background_p.9.png b/modules/mogo-module-push/src/main/res/drawable-ldpi/module_push_item_background_p.9.png
new file mode 100644
index 0000000000..a5dedc9ca3
Binary files /dev/null and b/modules/mogo-module-push/src/main/res/drawable-ldpi/module_push_item_background_p.9.png differ
diff --git a/modules/mogo-module-push/src/main/res/drawable-mdpi/module_push_item_background_p.9.png b/modules/mogo-module-push/src/main/res/drawable-mdpi/module_push_item_background_p.9.png
new file mode 100644
index 0000000000..5b43f7451d
Binary files /dev/null and b/modules/mogo-module-push/src/main/res/drawable-mdpi/module_push_item_background_p.9.png differ
diff --git a/modules/mogo-module-push/src/main/res/drawable-xhdpi/module_push_item_background_p.9.png b/modules/mogo-module-push/src/main/res/drawable-xhdpi/module_push_item_background_p.9.png
new file mode 100644
index 0000000000..87a3f9179d
Binary files /dev/null and b/modules/mogo-module-push/src/main/res/drawable-xhdpi/module_push_item_background_p.9.png differ
diff --git a/modules/mogo-module-push/src/main/res/layout/module_push_item.xml b/modules/mogo-module-push/src/main/res/layout/module_push_item.xml
index 1b970735f8..f43312ef3f 100644
--- a/modules/mogo-module-push/src/main/res/layout/module_push_item.xml
+++ b/modules/mogo-module-push/src/main/res/layout/module_push_item.xml
@@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="@dimen/module_push_ui_height"
- android:background="@drawable/module_push_item_background">
+ android:background="@drawable/module_push_item_background_p">
() {
+ private RefreshCallback mAutoRefreshCallback = new RefreshCallback< MarkerResponse >() {
@Override
public void onSuccess( MarkerResponse o ) {
MapMarkerManager.getInstance().onSyncMarkerResponse( o );
@@ -390,11 +410,12 @@ public class MogoServices implements IMogoMapListener,
mIntentManager.registerIntentListener( MogoReceiver.ACTION_AUTO_NAVI_RECEIVER, this );
mIntentManager.registerIntentListener( MogoReceiver.ACTION_AUTO_NAVI_SEND, this );
mIntentManager.registerIntentListener( MogoReceiver.ACTION_MOGO, this );
+ mIntentManager.registerIntentListener( ServiceConst.COMMAND_ONLINE_CAR_PANEL, this );
+ mIntentManager.registerIntentListener( ConnectivityManager.CONNECTIVITY_ACTION, this );
mADASController = MarkerServiceHandler.getADASController();
mLauncher = MarkerServiceHandler.getLauncher();
mFragmentManager = MarkerServiceHandler.getFragmentManager();
- mCardManager = MarkerServiceHandler.getMogoCardManager();
mFragmentManager.addMainFragmentStackTransactionListener( this );
@@ -403,6 +424,8 @@ public class MogoServices implements IMogoMapListener,
if ( DebugConfig.isLaunchLocationService() ) {
initLocationServiceProcess( context );
}
+
+ AutoPilotRemoteController.getInstance().start();
}
private void initLocationServiceProcess( Context context ) {
@@ -484,7 +507,8 @@ public class MogoServices implements IMogoMapListener,
filter.addAction( MogoReceiver.ACTION_AUTO_NAVI_RECEIVER );
filter.addAction( MogoReceiver.ACTION_AUTO_NAVI_SEND );
filter.addAction( MogoReceiver.ACTION_MOGO );
- filter.addAction(MogoReceiver.ACTION_TXZ_BLOCK_SEARCH);
+ filter.addAction( MogoReceiver.ACTION_TXZ_BLOCK_SEARCH );
+ filter.addAction( ConnectivityManager.CONNECTIVITY_ACTION );
try {
context.getApplicationContext().registerReceiver( mAIAssistReceiver, filter );
Logger.i( TAG, "register voice receiver." );
@@ -752,7 +776,7 @@ public class MogoServices implements IMogoMapListener,
return;
}
Logger.d( TAG, mAutoRefreshCallback == callback ? "触发自动刷新" : "触发手动刷新" );
- int amount = 10;
+ int amount = 20;
Message msg = Message.obtain();
msg.what = ServiceConst.MSG_REQUEST_DATA;
@@ -847,6 +871,10 @@ public class MogoServices implements IMogoMapListener,
} else if ( ServiceConst.COMMAND_PREVIOUS.equals( command ) ) {
onActionDone( MogoAction.Prev );
} else {
+ if ( TextUtils.equals( command, ConnectivityManager.CONNECTIVITY_ACTION )
+ && NetworkUtils.isConnected( mContext ) ) {
+ mIntentManager.unregisterIntentListener( ConnectivityManager.CONNECTIVITY_ACTION, this );
+ }
IntentHandlerFactory.getInstance().handle( mContext, command, intent );
}
}
@@ -925,4 +953,90 @@ public class MogoServices implements IMogoMapListener,
AIAssist.getInstance( mContext ).registerUnWakeupCommand( ServiceConst.CMD_BACK, ServiceConst.CMD_BACK_WORDS, this );
}
}
+
+ @Override
+ public void onStartNavi() {
+ if ( DebugConfig.isIsScheduleCalculateNotHomeCompanyDistanceForPush() ) {
+ Logger.d( TAG, "onStartNavi: scheduleCalculationNotHomeCompanyDistanceForPush" );
+ scheduleCalculationNotHomeCompanyDistanceForPush( 1, ServiceConst.INTERVAL_SCHEDULE_CALCULATE_NOT_HOME_COMPANY_DISTANCE_FOR_PUSH );
+ } else {
+ Logger.d( TAG, "onStartNavi: scheduleCalculationNotHomeCompanyDistanceForPush un support" );
+ }
+ }
+
+ @Override
+ public void onStopNavi() {
+ SpStorage.setNavigationTarget( "" );
+ Logger.d( TAG, "onStopNavi: remove MSG_SCHEDULE_CALCULATE_NOT_HOME_COMPANY_DISTANCE_FOR_PUSH msg" );
+ mHandler.removeMessages( ServiceConst.MSG_SCHEDULE_CALCULATE_NOT_HOME_COMPANY_DISTANCE_FOR_PUSH );
+ }
+
+ /**
+ * 延时一分钟发起计算导航目的地推送策略
+ */
+ private void scheduleCalculationNotHomeCompanyDistanceForPush( int time, long delay ) {
+ Message msg = Message.obtain();
+ msg.what = ServiceConst.MSG_SCHEDULE_CALCULATE_NOT_HOME_COMPANY_DISTANCE_FOR_PUSH;
+ msg.arg1 = time;
+ mHandler.sendMessageDelayed( msg, delay );
+ }
+
+ /**
+ * 发起计算导航目的地推送策略
+ *
+ * @param time 第x次重试
+ */
+ private void handleCalculationNotHomeCompanyDistanceForPush( final int time ) {
+ if ( time > 3 ) {
+ return;
+ }
+ String json = SpStorage.getNavigationTarget();
+ if ( !TextUtils.isEmpty( json ) ) {
+ try {
+ NavigationTargetInfo info = GsonUtil.objectFromJson( json, NavigationTargetInfo.class );
+
+ Logger.d( TAG, "info = %s", info );
+
+ HomeCompanyDistanceForPushData data = new HomeCompanyDistanceForPushData();
+ data.lat = Double.valueOf( info.getToPoiLatitude() );
+ data.lon = Double.valueOf( info.getToPoiLongitude() );
+
+ final Map< String, Object > query = new ParamsProvider.Builder( mContext ).build();
+ query.put( "data", GsonUtil.jsonFromObject( data ) );
+ mRefreshModel.getRefreshApiService().calculationNotHomeCompanyDistanceForPush( query )
+ .subscribeOn( Schedulers.io() )
+ .observeOn( AndroidSchedulers.mainThread() )
+ .subscribe( new SubscribeImpl< HomeCompanyDistanceForPushResponse >( RequestOptions.create( mContext ) ) {
+ @Override
+ public void onSuccess( HomeCompanyDistanceForPushResponse o ) {
+ super.onSuccess( o );
+ if ( o != null && o.result != null ) {
+ Logger.d( TAG, "calculationNotHomeCompanyDistanceForPush result %s", o.result.pushFlag );
+ }
+ }
+
+ @Override
+ public void onError( Throwable e ) {
+ super.onError( e );
+ Logger.d( TAG, "re scheduleCalculationNotHomeCompanyDistanceForPush after 30s" );
+ // 延时30s重试
+ scheduleCalculationNotHomeCompanyDistanceForPush( time + 1, 30_000L );
+ }
+
+ @Override
+ public void onError( String message, int code ) {
+ super.onError( message, code );
+ }
+ } );
+ } catch ( Exception e ) {
+ Logger.e( TAG, e, "handleCalculationNotHomeCompanyDistanceForPush" );
+ }
+
+ }
+ }
+
+ @Override
+ public void destroy() {
+ Logger.d( TAG, "MogoServices do nothings." );
+ }
}
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/ServiceConst.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/ServiceConst.java
index b07aad4f99..1fb0c5cdf2 100644
--- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/ServiceConst.java
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/ServiceConst.java
@@ -108,7 +108,6 @@ public class ServiceConst {
public static final int MSG_REQUEST_DATA = 0x201;
/**
- *
* 锁车消息
*/
public static final int MSG_LOCK_CAR = 0x202;
@@ -159,7 +158,7 @@ public class ServiceConst {
};
public static final String CMD_BACK = "back";
- public static final String[] CMD_BACK_WORDS = new String[]{"关闭", "返回"};
+ public static final String[] CMD_BACK_WORDS = new String[]{"关闭", "返回"};
/**
@@ -203,4 +202,20 @@ public class ServiceConst {
public static final int ONLINE_SEARCH_LIMIT = 20;
public static final int ONLINE_SEARCH_RADIUS = 2_000;
+
+ /**
+ * 查找目的地车友
+ */
+ public static final String COMMAND_ONLINE_CAR_PANEL = "com.zhidao.search.riders";
+
+ /**
+ * 导航开始后,延时1分钟开启推送策略
+ */
+ public static final int MSG_SCHEDULE_CALCULATE_NOT_HOME_COMPANY_DISTANCE_FOR_PUSH = 0x301;
+
+ /**
+ * 延时1分钟开启推送策略
+ */
+ public static final long INTERVAL_SCHEDULE_CALCULATE_NOT_HOME_COMPANY_DISTANCE_FOR_PUSH = 60 * 1_000L;
+
}
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/autopilot/AutoPilotParameters.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/autopilot/AutoPilotParameters.java
new file mode 100644
index 0000000000..9e40ca6454
--- /dev/null
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/autopilot/AutoPilotParameters.java
@@ -0,0 +1,23 @@
+package com.mogo.module.service.autopilot;
+
+import java.util.List;
+
+public
+/**
+ * @author congtaowang
+ * @since 2020/10/16
+ *
+ * 自动驾驶参数
+ */
+class AutoPilotParameters {
+
+ public AutoPilotLonLat startLatLon;
+ public List< AutoPilotLonLat > wayLatLons;
+ public AutoPilotLonLat endLatLon;
+ public float speedLimit;
+
+ public static class AutoPilotLonLat {
+ public double lat;
+ public double lon;
+ }
+}
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/autopilot/AutoPilotRemoteController.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/autopilot/AutoPilotRemoteController.java
new file mode 100644
index 0000000000..c0ce944161
--- /dev/null
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/autopilot/AutoPilotRemoteController.java
@@ -0,0 +1,81 @@
+package com.mogo.module.service.autopilot;
+
+import com.mogo.commons.AbsMogoApplication;
+import com.mogo.module.common.MogoApisHandler;
+import com.mogo.service.connection.IMogoOnMessageListener;
+import com.mogo.service.connection.IMogoSocketManager;
+import com.mogo.utils.logger.Logger;
+import com.mogo.utils.network.utils.GsonUtil;
+
+public
+/**
+ * @author congtaowang
+ * @since 2020/10/16
+ *
+ * 远端控制自动驾驶
+ */
+class AutoPilotRemoteController {
+
+ private static final String TAG = "AutoPilotRemoteController";
+
+ private static volatile AutoPilotRemoteController sInstance;
+
+ private IMogoSocketManager mMogoSocketManager;
+
+ private IMogoOnMessageListener< AutoPilotParameters > mParametersListener = new IMogoOnMessageListener< AutoPilotParameters >() {
+ @Override
+ public Class< AutoPilotParameters > target() {
+ return AutoPilotParameters.class;
+ }
+
+ @Override
+ public void onMsgReceived( AutoPilotParameters obj ) {
+ if ( obj == null ) {
+ Logger.e( TAG, "远端控制参数为null", new NullPointerException() );
+ return;
+ }
+ String json = GsonUtil.jsonFromObject( obj );
+ Logger.d( TAG, json );
+ MogoApisHandler.getInstance().getApis().getAdasControllerApi().notifyAdas( json );
+ }
+ };
+
+ /**
+ * 远端控制自动驾驶的消息类型
+ */
+ public static final int MSG_TYPE_REMOTE_CONTROL_AUTOPILOT = 401014;
+
+ private AutoPilotRemoteController() {
+ mMogoSocketManager = MogoApisHandler.getInstance().getApis().getSocketManagerApi( AbsMogoApplication.getApp() );
+ }
+
+ public static AutoPilotRemoteController getInstance() {
+ if ( sInstance == null ) {
+ synchronized ( AutoPilotRemoteController.class ) {
+ if ( sInstance == null ) {
+ sInstance = new AutoPilotRemoteController();
+ }
+ }
+ }
+ return sInstance;
+ }
+
+ public void start() {
+ mMogoSocketManager.registerOnMessageListener( MSG_TYPE_REMOTE_CONTROL_AUTOPILOT, mParametersListener );
+ }
+
+ public synchronized void release() {
+ sInstance = null;
+ if ( mMogoSocketManager != null ) {
+ mMogoSocketManager.unregisterOnMessageListener( MSG_TYPE_REMOTE_CONTROL_AUTOPILOT, mParametersListener );
+ }
+ mMogoSocketManager = null;
+ mParametersListener = null;
+ }
+
+ private Object readResolve() {
+ // 阻止反序列化,必须实现 Serializable 接口
+ return sInstance;
+ }
+
+}
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/IntentHandlerFactory.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/IntentHandlerFactory.java
index 1f9939807f..2b440d9efe 100644
--- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/IntentHandlerFactory.java
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/IntentHandlerFactory.java
@@ -2,6 +2,7 @@ package com.mogo.module.service.intent;
import android.content.Context;
import android.content.Intent;
+import android.net.ConnectivityManager;
import com.mogo.module.service.ServiceConst;
import com.mogo.module.service.receiver.AccStatusReceiver;
@@ -21,7 +22,6 @@ public class IntentHandlerFactory {
private IntentHandlerFactory() {
// private constructor
mHandlers.put( MogoReceiver.ACTION_MOCK, new MockIntentHandler() );
- mHandlers.put( ServiceConst.COMMAND_SWITCH_CARD, new SwitchCardIntentHandler() );
mHandlers.put( ServiceConst.COMMAND_OPERATION, new AppOperationIntentHandler() );
mHandlers.put( ServiceConst.COMMAND_MY_LOCATION, new MyLocationHandler() );
mHandlers.put( ServiceConst.COMMAND_ZHIDAO_NEARBY_CAR_ONLINE, OnlineCarSearchIntentHandler.getInstance() );
@@ -38,6 +38,8 @@ public class IntentHandlerFactory {
mHandlers.put( MogoReceiver.ACTION_VOICE_READY, new AIAssistIntentHandler() );
mHandlers.put( ServiceConst.COMMAND_BACK, WholeVoiceCommandIntentHandler.getInstance() );
mHandlers.put( MogoReceiver.ACTION_MOGO, new MogoControllerIntentHandler() );
+ mHandlers.put( ServiceConst.COMMAND_ONLINE_CAR_PANEL, new OnlineCarPanelIntentHandler() );
+ mHandlers.put( ConnectivityManager.CONNECTIVITY_ACTION, new NetworkChangedIntentHandler() );
}
private static final class InstanceHolder {
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/MockIntentHandler.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/MockIntentHandler.java
index 6339b4f7f8..a7a19b4131 100644
--- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/MockIntentHandler.java
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/MockIntentHandler.java
@@ -12,6 +12,7 @@ import android.widget.TextView;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.commons.debug.DebugConfig;
+import com.mogo.commons.voice.AIAssist;
import com.mogo.map.MogoLatLng;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.MogoMarkerOptions;
@@ -338,6 +339,19 @@ public class MockIntentHandler implements IntentHandler {
case 30:
MarkerServiceHandler.getMapService().getMapUIController().forceRender();
break;
+ case 31:
+ Intent intent3 = new Intent();
+ intent3.setAction( "AUTONAVI_STANDARD_BROADCAST_RECV" );
+ intent3.putExtra( "KEY_TYPE", 12404 );
+ intent3.putExtra( "EXTRA_REQUEST_AUTO_STATE", 0 );
+ context.sendBroadcast( intent3 );
+ break;
+ case 32:
+ MarkerServiceHandler.getMapService().getMapUIController().setTrafficEnabled( true );
+ break;
+ case 33:
+ AIAssist.getInstance( context ).speakTTSVoice( "庞帆说这个是一个 hard coding." );
+ break;
}
}
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/NetworkChangedIntentHandler.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/NetworkChangedIntentHandler.java
new file mode 100644
index 0000000000..c61ff760eb
--- /dev/null
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/NetworkChangedIntentHandler.java
@@ -0,0 +1,38 @@
+package com.mogo.module.service.intent;
+
+import android.content.Context;
+import android.content.Intent;
+
+import com.mogo.module.common.MogoApisHandler;
+import com.mogo.utils.NetworkUtils;
+import com.mogo.utils.logger.LogLevel;
+import com.mogo.utils.logger.Logger;
+import com.mogo.utils.network.NetConfig;
+
+public
+/**
+ * @author congtaowang
+ * @since 2020/8/17
+ *
+ * 描述
+ */
+class NetworkChangedIntentHandler implements IntentHandler {
+
+ private static final String TAG = "NetworkChangedIntentHandler";
+
+ @Override
+ public void handle( Context context, Intent intent ) {
+ if ( NetworkUtils.isConnected( context ) ) {
+ try {
+ Logger.d( TAG, "setTrafficEnabled" );
+ MogoApisHandler.getInstance()
+ .getApis()
+ .getMapServiceApi()
+ .getMapUIController()
+ .setTrafficEnabled( true );
+ } catch ( Exception e ) {
+ e.printStackTrace();
+ }
+ }
+ }
+}
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/OnlineCarPanelIntentHandler.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/OnlineCarPanelIntentHandler.java
new file mode 100644
index 0000000000..0fc9085e6d
--- /dev/null
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/OnlineCarPanelIntentHandler.java
@@ -0,0 +1,38 @@
+package com.mogo.module.service.intent;
+
+import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+import android.text.TextUtils;
+
+import com.mogo.commons.storage.SpStorage;
+import com.mogo.commons.voice.AIAssist;
+import com.mogo.module.service.MarkerServiceHandler;
+
+public
+/**
+ * @author congtaowang
+ * @since 2020/9/21
+ *
+ * 描述
+ */
+class OnlineCarPanelIntentHandler implements IntentHandler {
+
+ @Override
+ public void handle( Context context, Intent intent ) {
+ String json = SpStorage.getNavigationTarget();
+ if ( TextUtils.isEmpty( json ) ) {
+ AIAssist.getInstance( context ).speakTTSVoice( "没有导航目的地" );
+ return;
+ }
+ AIAssist.getInstance( context ).speakTTSVoice( "正在查询" );
+ if ( MarkerServiceHandler.getMogoStatusManager().isMainPageOnResume() ) {
+ MarkerServiceHandler.getApis().getOnlineCarPanelApi().showPanel();
+ } else {
+ Intent start = new Intent( Intent.ACTION_VIEW );
+ start.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK );
+ start.setData( Uri.parse( "mogo://launcher/main/switch2?type=showOnlineCarPanel" ) );
+ context.startActivity( start );
+ }
+ }
+}
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/SwitchCardIntentHandler.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/SwitchCardIntentHandler.java
deleted file mode 100644
index 1c3e56567a..0000000000
--- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/SwitchCardIntentHandler.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package com.mogo.module.service.intent;
-
-import android.content.Context;
-import android.content.Intent;
-import android.text.TextUtils;
-
-import com.mogo.module.service.MarkerServiceHandler;
-import com.mogo.module.service.ServiceConst;
-import com.mogo.utils.AppUtils;
-import com.mogo.utils.UiThreadHandler;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-/**
- * @author congtaowang
- * @since 2020-04-17
- *
- * 描述
- */
-public class SwitchCardIntentHandler implements IntentHandler {
-
- @Override
- public void handle( Context context, Intent intent ) {
- String data = intent.getStringExtra( "data" );
- try {
- JSONObject jsonObject = new JSONObject( data );
- String card = jsonObject.getString( "card" );
- if ( TextUtils.equals( "多媒体卡片", card )
- || TextUtils.equals( "媒体中心卡片", card )
- || TextUtils.equals( "音乐卡片", card ) ) {
- switchCard2( context, ServiceConst.CARD_TYPE_SHARE_MUSIC );
- } else if ( TextUtils.equals( "探路卡片", card ) ) {
- switchCard2( context, ServiceConst.CARD_TYPE_ROAD_CONDITION );
- } else if ( TextUtils.equals( "在线车辆卡片", card ) ) {
- switchCard2( context, ServiceConst.CARD_TYPE_USER_DATA );
- } else if ( TextUtils.equals( "新鲜事卡片", card ) ) {
- switchCard2( context, ServiceConst.CARD_TYPE_NOVELTY );
- }
- } catch ( JSONException e ) {
- e.printStackTrace();
- }
- }
-
- /**
- * 切换卡片
- */
- public static void switchCard2( Context context, String card ) {
- if ( AppUtils.isApplicationBroughtToBackground( context ) ) {
- MarkerServiceHandler.getLauncher().backToLauncher( context );
- UiThreadHandler.postDelayed( () -> {
- if ( MarkerServiceHandler.getMogoStatusManager().isADASShow() ) {
- MarkerServiceHandler.getADASController().closeADAS();
- }
- MarkerServiceHandler.getMogoCardManager().switch2( card, true );
- }, 2000L );
- } else {
- MarkerServiceHandler.getFragmentManager().clearAll();
- if ( MarkerServiceHandler.getMogoStatusManager().isADASShow() ) {
- MarkerServiceHandler.getADASController().closeADAS();
- }
- MarkerServiceHandler.getMogoCardManager().switch2( card, true );
- }
- }
-}
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/launchercard/LauncherCardRefresher.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/launchercard/LauncherCardRefresher.java
index 73fe2a4801..42614860ee 100644
--- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/launchercard/LauncherCardRefresher.java
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/launchercard/LauncherCardRefresher.java
@@ -76,6 +76,11 @@ class LauncherCardRefresher {
*/
private int mDefaultConfigCounter = 0;
+ /**
+ * 事件/车友播报次数
+ */
+ private int mMsgExplorerWayOrOnlineCarDataCounter = 0;
+
/**
* 因为缓存ticket失效导致失败的情况,需要重新请求ticket然后再次获取数据,这里重试3次
*/
@@ -151,18 +156,18 @@ class LauncherCardRefresher {
private ZhidaoRefreshModel mZhidaoRefreshModel;
private LauncherCardRefreshStrategy mExplorerWayOrOnlineCarDataStrategy = new LauncherCardRefreshStrategy(
- 20 * ONE_MINUTE,null, MSG_EXPLORER_WAY_OR_ONLINE_CAR_DATA
+ 40 * ONE_MINUTE, null, MSG_EXPLORER_WAY_OR_ONLINE_CAR_DATA
);
private LauncherCardRefreshStrategy mInduceStrategy = new LauncherCardRefreshStrategy(
- 3 * ONE_MINUTE,mExplorerWayOrOnlineCarDataStrategy, MSG_INDUCE
+ 3 * ONE_MINUTE, mExplorerWayOrOnlineCarDataStrategy, MSG_INDUCE
);
private LauncherCardRefreshStrategy mLauncherCardConfigStrategy = new LauncherCardRefreshStrategy(
- 2 * ONE_MINUTE,mInduceStrategy, MSG_REFRESH_DEFAULT_CARD
+ 2 * ONE_MINUTE, mInduceStrategy, MSG_REFRESH_DEFAULT_CARD
);
private LauncherCardRefreshStrategy mRefreshStrategy = mLauncherCardConfigStrategy;
public void start() {
- if ( DebugConfig.isLauncher() || DebugConfig.getCarMachineType() == DebugConfig.CAR_MACHINE_TYPE_BYD ) {
+ if ( !DebugConfig.isIsSupportLauncherCardRefreshStrategy() ) {
return;
}
if ( mStart ) {
@@ -172,6 +177,7 @@ class LauncherCardRefresher {
mLaunchTTSText = mContext.getString( R.string.module_service_open_app_tip );
mDefaultConfigCounter = 0;
mRefreshTicketCounter = 0;
+ mMsgExplorerWayOrOnlineCarDataCounter = 0;
mRefreshStrategy = mLauncherCardConfigStrategy;
// 延时加载数据,已保证accOn之后网络恢复正常
long delay = ONE_MINUTE;
@@ -238,12 +244,16 @@ class LauncherCardRefresher {
restart();
return;
}
+ mMsgExplorerWayOrOnlineCarDataCounter++;
+ if ( mMsgExplorerWayOrOnlineCarDataCounter > 2 ) {
+ return;
+ }
MogoLatLng latLng = new MogoLatLng( location.getLatitude(), location.getLongitude() );
handleRefreshExplorerWayOrOnlineCarData( latLng, mRefreshStrategy.getType() );
}
private void handleRefreshExplorerWayOrOnlineCarData( MogoLatLng latLng, LauncherCardRefreshType type ) {
- mRefreshModel.refreshDataSync( latLng,
+ mRefreshModel.refreshLauncherCardDataSync( latLng,
mRefreshStrategy.getRadius(),
mRefreshStrategy.getLimit(),
new RefreshCallback< MarkerResponse >() {
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/CallProviderResponseImpl.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/CallProviderResponseImpl.java
new file mode 100644
index 0000000000..069b90560d
--- /dev/null
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/CallProviderResponseImpl.java
@@ -0,0 +1,111 @@
+package com.mogo.module.service.marker;
+
+import com.mogo.module.carchattingprovider.ICallProviderResponse;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+public
+/**
+ * @author congtaowang
+ * @since 2020/9/28
+ *
+ * 描述
+ */
+abstract class CallProviderResponseImpl implements ICallProviderResponse {
+
+ @Override
+ public void addFriend( boolean b ) {
+
+ }
+
+ @Override
+ public void callInvokeError( @NotNull String s ) {
+
+ }
+
+ @Override
+ public void callStatus( int i ) {
+
+ }
+
+ @Override
+ public void callWindowStatus( boolean b ) {
+
+ }
+
+ @Override
+ public void canCall( boolean b ) {
+
+ }
+
+ @Override
+ public void hideUserWindowError( @NotNull String s ) {
+
+ }
+
+ @Override
+ public void invisibleUser( boolean b ) {
+
+ }
+
+ @Override
+ public void isFriend( boolean b ) {
+
+ }
+
+ @Override
+ public void isOnLine( boolean b, @Nullable String s ) {
+
+ }
+
+ @Override
+ public void userInfoCallBack( @Nullable String s, @Nullable String s1 ) {
+
+ }
+
+ @Override
+ public void userWindowStatus( boolean b ) {
+
+ }
+
+ @Override
+ public void call( @NotNull String s ) {
+
+ }
+
+ @Override
+ public void cancelMatch( boolean b ) {
+
+ }
+
+ @Override
+ public void error( @NotNull String s ) {
+
+ }
+
+ @Override
+ public void hangUp( boolean b ) {
+
+ }
+
+ @Override
+ public void invokeCallData( @NotNull String s ) {
+
+ }
+
+ @Override
+ public void match( @NotNull String s ) {
+
+ }
+
+ @Override
+ public void matchInvokeResult( boolean b, @NotNull String s ) {
+
+ }
+
+ @Override
+ public void mute( boolean b ) {
+
+ }
+}
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerManager.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerManager.java
index 3130142004..39a8bb11aa 100644
--- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerManager.java
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerManager.java
@@ -3,7 +3,6 @@ package com.mogo.module.service.marker;
import android.content.Context;
import android.graphics.Rect;
import android.text.TextUtils;
-import android.view.animation.AccelerateInterpolator;
import android.view.animation.LinearInterpolator;
import com.mogo.commons.AbsMogoApplication;
@@ -16,6 +15,7 @@ import com.mogo.map.marker.MogoMarkerOptions;
import com.mogo.map.marker.anim.OnMarkerAnimationListener;
import com.mogo.map.uicontroller.EnumMapUI;
import com.mogo.module.common.ModuleNames;
+import com.mogo.module.common.api.CallChatApi;
import com.mogo.module.common.entity.MarkerCarPois;
import com.mogo.module.common.entity.MarkerCardResult;
import com.mogo.module.common.entity.MarkerExploreWay;
@@ -25,7 +25,6 @@ import com.mogo.module.common.entity.MarkerOnlineCar;
import com.mogo.module.common.entity.MarkerResponse;
import com.mogo.module.common.entity.MarkerShareMusic;
import com.mogo.module.common.entity.MarkerShowEntity;
-import com.mogo.module.common.utils.CarSeries;
import com.mogo.module.service.MarkerServiceHandler;
import com.mogo.module.service.R;
import com.mogo.module.service.ServiceConst;
@@ -109,16 +108,27 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
mContext = context.getApplicationContext();
mRefreshModel = new RefreshModel( mContext );
- // 长连接 - 长链变短链
-// MarkerServiceHandler.getMogoSocketManager().registerOnMessageListener( 401001, this );
MarkerServiceHandler.getActionManager().registerBizActionDoneListener( this );
MarkerServiceHandler.getApis().getRegisterCenterApi().registerADASControlStatusChangedListener( TAG, this );
- }
- // ACC ON 的时候重置为true,ACC OFF 设置为 false
- // 保留 - 外部模块调用
- public void setCheckOn( boolean checkOnLineData ) {
- Logger.e( TAG, "do not invoke anymore." );
+ CallChatApi.getInstance().getApiProvider().registerUserWindowStatusListener( TAG, mContext, new CallProviderResponseImpl() {
+
+ @Override
+ public void userWindowStatus( boolean show ) {
+ try {
+ if ( mLastCheckMarker == null ) {
+ return;
+ }
+ if ( TextUtils.equals( mLastCheckMarker.getOwner(), ModuleNames.CARD_TYPE_USER_DATA )
+ && !show ) {
+ closeMarker( mLastCheckMarker );
+ }
+ } catch ( Exception e ) {
+ e.printStackTrace();
+ }
+ }
+
+ } );
}
/**
@@ -130,6 +140,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
try {
boolean result = switchMarkerOpenStatus( marker );
if ( !result ) {
+ updateCarUserInfoWindow( marker );
return false;
}
@@ -186,11 +197,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
mLastCheckMarker = mogoMarker;
// 在线车辆点击使用infoWindow
if ( TextUtils.equals( mogoMarker.getOwner(), ModuleNames.CARD_TYPE_USER_DATA ) ) {
- if ( !mogoMarker.isDestroyed() ) {
- mogoMarker.setInfoWindowAdapter( UserDataMarkerInfoWindowAdapter.getInstance( mContext ) );
- mogoMarker.showInfoWindow();
- Logger.d( TAG, "打开info window" );
- }
+ updateCarUserInfoWindow( mogoMarker );
} else {
Object object = mogoMarker.getObject();
if ( object != null ) {
@@ -210,7 +217,22 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
}
}
MarkerServiceHandler.getMogoStatusManager().setUserInteractionStatus( TAG, true, false );
- MarkerServiceHandler.getMapUIController().moveToCenter( mogoMarker.getPosition(), CarSeries.getSeries() == CarSeries.CAR_SERIES_F80X );
+ MarkerServiceHandler.getMapUIController().moveToCenter( mogoMarker.getPosition(), DebugConfig.isRoadEventAnimated() );
+ }
+
+ private void updateCarUserInfoWindow( IMogoMarker marker ) {
+ if ( marker != null && !marker.isDestroyed() ) {
+ try {
+ if ( !TextUtils.equals( marker.getOwner(), ModuleNames.CARD_TYPE_USER_DATA ) ) {
+ return;
+ }
+ marker.setIcon( OnlineCarMarkerView.getInstance().getSelectedBitmap( getCarVehicleType( marker ) ) );
+ MarkerOnlineCar onlineCar = ( MarkerOnlineCar ) ( ( MarkerShowEntity ) marker.getObject() ).getBindObj();
+ CallChatApi.getInstance().showUserWindow( mContext, onlineCar );
+ } catch ( Exception e ) {
+ Logger.e( TAG, e, "openMarker" );
+ }
+ }
}
// 折叠气泡
@@ -220,8 +242,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
}
// 在线车辆点击使用infoWindow
if ( TextUtils.equals( mogoMarker.getOwner(), ModuleNames.CARD_TYPE_USER_DATA ) ) {
- mogoMarker.hideInfoWindow();
- Logger.d( TAG, "关闭info window" );
+ mogoMarker.setIcon( OnlineCarMarkerView.getInstance().getBitmap( getCarVehicleType( mogoMarker ) ) );
} else {
Object object = mogoMarker.getObject();
if ( object != null ) {
@@ -241,6 +262,17 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
}
}
+ private int getCarVehicleType( IMogoMarker marker ) {
+ try {
+ return ( ( MarkerOnlineCar )
+ ( ( MarkerShowEntity ) marker.getObject() ).getBindObj() )
+ .getCarInfo()
+ .getVehicleType();
+ } catch ( Exception e ) {
+ return 0;
+ }
+ }
+
// 绘制Marker
public synchronized void drawMapMarker( MarkerResponse response ) {
@@ -809,7 +841,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
}
Logger.d( TAG, "内部 - 请求开始" );
- mRefreshModel.queryOnLineCarWithRoute( latLng, onlyFocus, onlySameCity, radius, limit, new RefreshCallback() {
+ mRefreshModel.queryOnLineCarWithRoute( latLng, onlyFocus, onlySameCity, radius, limit, false, new RefreshCallback() {
@Override
public void onSuccess( Object o ) {
MarkerResponse data = ( MarkerResponse ) o;
@@ -994,7 +1026,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
return;
}
if ( mLastDataResult != null ) {
- runOnTargetThread( ()->{
+ runOnTargetThread( () -> {
MarkerServiceHandler.getMarkerManager().removeMarkers( ModuleNames.CARD_TYPE_ROAD_CONDITION );
drawMarkerByCurrentType( mLastDataResult );
mLastCheckMarker = null;
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/OnlineCarMarkerView.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/OnlineCarMarkerView.java
index a277c94308..33c9aea200 100644
--- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/OnlineCarMarkerView.java
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/OnlineCarMarkerView.java
@@ -22,6 +22,7 @@ import java.util.Map;
public class OnlineCarMarkerView implements IMarkerView {
private static Map< Integer, SoftReference< Bitmap > > sRef = new HashMap<>();
+ private static Map< Integer, SoftReference< Bitmap > > sTypedRef = new HashMap<>();
private OnlineCarMarkerView() {
// private constructor
@@ -72,6 +73,20 @@ public class OnlineCarMarkerView implements IMarkerView {
return sRef.get( vehicleType ).get();
}
+ public Bitmap getSelectedBitmap( int vehicleType ) {
+ if ( sTypedRef.get( vehicleType ) == null || sTypedRef.get( vehicleType ).get() == null
+ || sTypedRef.get( vehicleType ).get().isRecycled() ) {
+ switch ( vehicleType ) {
+ case 2:
+ sTypedRef.put( vehicleType, new SoftReference<>( BitmapFactory.decodeResource( AbsMogoApplication.getApp().getResources(), R.drawable.icon_map_marker_car_type2 ) ) );
+ break;
+ default:
+ sTypedRef.put( vehicleType, new SoftReference<>( BitmapFactory.decodeResource( AbsMogoApplication.getApp().getResources(), R.drawable.icon_map_marker_car_gray_selected ) ) );
+ }
+ }
+ return sTypedRef.get( vehicleType ).get();
+ }
+
@Override
public void setMarker( IMogoMarker marker ) {
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/RefreshApiService.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/RefreshApiService.java
index 8f58de2d68..3076af4be6 100644
--- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/RefreshApiService.java
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/RefreshApiService.java
@@ -3,6 +3,7 @@ package com.mogo.module.service.network;
import com.mogo.commons.data.BaseData;
import com.mogo.module.common.entity.MarkerResponse;
import com.mogo.module.service.network.bean.DemoUserInfoEntity;
+import com.mogo.module.service.network.bean.HomeCompanyDistanceForPushResponse;
import java.util.Map;
@@ -37,4 +38,8 @@ public interface RefreshApiService {
*/
@GET( "/yycp-launcherSnapshot/mock/getMockUserInfos" )
Observable< DemoUserInfoEntity > getMockUsers();
+
+ @FormUrlEncoded
+ @POST("/yycp-travel-condition/trajectoryPrediction/calculationNotHomeCompanyDistanceForPush")
+ Observable< HomeCompanyDistanceForPushResponse > calculationNotHomeCompanyDistanceForPush( @FieldMap Map< String, Object > parameters);
}
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/RefreshBody.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/RefreshBody.java
index d1a5384490..853b8280d2 100644
--- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/RefreshBody.java
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/RefreshBody.java
@@ -20,6 +20,7 @@ public class RefreshBody {
public boolean onlyFocus; // 是否仅查询已关注的好友
public boolean onlySameCity; // 是否仅查询注册城市相同的同城用户
public boolean viewPush; // 是否走V2X通道 ,true-401011,false -401001
+ public boolean onlyRealUser;
public static class LatLon {
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/RefreshModel.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/RefreshModel.java
index c368ec6956..a5e0c91888 100644
--- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/RefreshModel.java
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/RefreshModel.java
@@ -65,51 +65,6 @@ public class RefreshModel {
}
}
- public void refreshData( MogoLatLng latLng, int radius, int limit, final RefreshCallback callback ) {
- if ( mRefreshApiService != null ) {
- final Map< String, Object > query = new ParamsProvider.Builder( mContext ).build();
- final RefreshBody refreshBody = new RefreshBody();
- refreshBody.limit = limit;
- refreshBody.location = new RefreshBody.LatLon( latLng.lat, latLng.lng );
- refreshBody.radius = radius;
- refreshBody.dataType.add( ServiceConst.CARD_TYPE_ROAD_CONDITION );
-
- String data = GsonUtil.jsonFromObject( refreshBody );
- query.put( "data", data );
- Logger.d( TAG, data );
-
-
- mRefreshApiService.refreshData( query )
- .subscribeOn( Schedulers.io() )
- .observeOn( AndroidSchedulers.mainThread() )
- .subscribe( new SubscribeImpl< BaseData >( RequestOptions.create( mContext ) ) {
- @Override
- public void onSuccess( BaseData o ) {
- super.onSuccess( o );
- if ( callback != null ) {
- callback.onSuccess( o );
- }
- }
-
- @Override
- public void onError( Throwable e ) {
- super.onError( e );
- if ( callback != null ) {
- callback.onFail();
- }
- }
-
- @Override
- public void onError( String message, int code ) {
- super.onError( message, code );
- if ( callback != null ) {
- callback.onFail();
- }
- }
- } );
- }
- }
-
public void refreshExplorerWayData( MogoLatLng latLng, int radius, int limit, final RefreshCallback callback ) {
if ( mRefreshApiService != null ) {
final Map< String, Object > query = new ParamsProvider.Builder( mContext ).build();
@@ -117,6 +72,7 @@ public class RefreshModel {
refreshBody.limit = limit;
refreshBody.location = new RefreshBody.LatLon( latLng.lat, latLng.lng );
refreshBody.radius = radius;
+ refreshBody.viewPush = true;
refreshBody.dataType.add( ServiceConst.CARD_TYPE_ROAD_CONDITION );
String data = GsonUtil.jsonFromObject( refreshBody );
@@ -155,7 +111,7 @@ public class RefreshModel {
}
}
- public void refreshDataSync( MogoLatLng latLng, int radius, int limit, final RefreshCallback callback ) {
+ public void refreshLauncherCardDataSync( MogoLatLng latLng, int radius, int limit, final RefreshCallback callback ) {
if ( mRefreshApiService != null ) {
final Map< String, Object > query = new ParamsProvider.Builder( mContext ).build();
final RefreshBody refreshBody = new RefreshBody();
@@ -169,7 +125,6 @@ public class RefreshModel {
query.put( "data", data );
Logger.d( TAG, data );
-
mRefreshApiService.refreshDataSync( query )
.subscribeOn( Schedulers.io() )
.observeOn( AndroidSchedulers.mainThread() )
@@ -208,12 +163,14 @@ public class RefreshModel {
* @param onlyFocus 是否仅查询已关注的好友
* @param onlySameCity 是否仅查询注册城市相同的同城用户
* @param callback
+ * @param onlyRealUser 是否只查询真实用户
*/
public void queryOnLineCarWithRoute( MogoLatLng latLng,
boolean onlyFocus,
boolean onlySameCity,
int radius,
int limit,
+ boolean onlyRealUser,
final RefreshCallback callback ) {
if ( mRefreshApiService != null ) {
final Map< String, Object > query = new ParamsProvider.Builder( mContext ).build();
@@ -226,6 +183,7 @@ public class RefreshModel {
refreshBody.location = new RefreshBody.LatLon( latLng.lat, latLng.lng );
refreshBody.onlyFocus = onlyFocus;
refreshBody.onlySameCity = onlySameCity;
+ refreshBody.onlyRealUser = onlyRealUser;
refreshBody.dataType.add( ServiceConst.CARD_TYPE_USER_DATA );
query.put( "data", GsonUtil.jsonFromObject( refreshBody ) );
@@ -241,6 +199,14 @@ public class RefreshModel {
}
}
+ @Override
+ public void onError( Throwable e ) {
+ super.onError( e );
+ if ( callback != null ) {
+ callback.onFail();
+ }
+ }
+
@Override
public void onError( String message, int code ) {
super.onError( message, code );
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/bean/HomeCompanyDistanceForPushData.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/bean/HomeCompanyDistanceForPushData.java
new file mode 100644
index 0000000000..574627da0b
--- /dev/null
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/bean/HomeCompanyDistanceForPushData.java
@@ -0,0 +1,14 @@
+package com.mogo.module.service.network.bean;
+
+public
+/**
+ * @author congtaowang
+ * @since 2020/9/22
+ *
+ * 描述
+ */
+class HomeCompanyDistanceForPushData {
+
+ public double lon;
+ public double lat;
+}
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/bean/HomeCompanyDistanceForPushResponse.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/bean/HomeCompanyDistanceForPushResponse.java
new file mode 100644
index 0000000000..c825712ef7
--- /dev/null
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/bean/HomeCompanyDistanceForPushResponse.java
@@ -0,0 +1,19 @@
+package com.mogo.module.service.network.bean;
+
+import com.mogo.commons.data.BaseData;
+
+public
+/**
+ * @author congtaowang
+ * @since 2020/9/22
+ *
+ * 描述
+ */
+class HomeCompanyDistanceForPushResponse extends BaseData {
+
+ public HomeCompanyDistanceForPushResult result;
+
+ public static class HomeCompanyDistanceForPushResult {
+ public boolean pushFlag;
+ }
+}
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/onlinecar/panel/ContainerHandler.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/onlinecar/panel/ContainerHandler.java
new file mode 100644
index 0000000000..b09def3289
--- /dev/null
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/onlinecar/panel/ContainerHandler.java
@@ -0,0 +1,15 @@
+package com.mogo.module.service.onlinecar.panel;
+
+import androidx.fragment.app.FragmentActivity;
+
+/**
+ * @author congtaowang
+ * @since 2020/9/21
+ *
+ * 描述
+ */
+class ContainerHandler {
+
+ public static int sContainerId = 0;
+ public static FragmentActivity sAttachContext;
+}
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/onlinecar/panel/IOnlineCarPanelView.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/onlinecar/panel/IOnlineCarPanelView.java
new file mode 100644
index 0000000000..9f361462b4
--- /dev/null
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/onlinecar/panel/IOnlineCarPanelView.java
@@ -0,0 +1,27 @@
+package com.mogo.module.service.onlinecar.panel;
+
+import com.mogo.commons.mvp.IView;
+import com.mogo.module.common.entity.MarkerOnlineCar;
+
+import java.util.List;
+
+/**
+ * @author congtaowang
+ * @since 2020/9/21
+ *
+ * 描述
+ */
+interface IOnlineCarPanelView extends IView {
+
+ void showLoading(boolean visible);
+
+ void renderOnlineCarList( List< MarkerOnlineCar > onlineCars, double lon, double lat );
+
+ void renderEmptyUi( OnlineCarStrategy strategy );
+
+ void renderNoNavigationInfoUi();
+
+ void renderErrorUi();
+
+ void removeSelf();
+}
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/onlinecar/panel/NavigationTargetInfo.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/onlinecar/panel/NavigationTargetInfo.java
new file mode 100644
index 0000000000..a8c5635cd9
--- /dev/null
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/onlinecar/panel/NavigationTargetInfo.java
@@ -0,0 +1,85 @@
+package com.mogo.module.service.onlinecar.panel;
+
+public
+/**
+ * @author congtaowang
+ * @since 2020/9/21
+ *
+ * 描述
+ */
+class NavigationTargetInfo {
+
+
+ /**
+ * FromPoiName : 东城区小黄庄北街2号
+ * FromPoiAddr : 在中国银行(北京安贞桥支行)附近
+ * FromPoiLongitude : 116.41082763671875
+ * FromPoiLatitude : 39.96831130981445
+ * ToPoiName : 北京市北京市北小营镇宏大工业开发中心A座7号
+ * ToPoiLongitude : 116.74490356445312
+ * ToPoiLatitude : 40.19820785522461
+ */
+ private String FromPoiName;
+ private String FromPoiAddr;
+ private String FromPoiLongitude;
+ private String FromPoiLatitude;
+ private String ToPoiName;
+ private String ToPoiLongitude;
+ private String ToPoiLatitude;
+
+ public String getFromPoiName() {
+ return FromPoiName;
+ }
+
+ public void setFromPoiName( String FromPoiName ) {
+ this.FromPoiName = FromPoiName;
+ }
+
+ public String getFromPoiAddr() {
+ return FromPoiAddr;
+ }
+
+ public void setFromPoiAddr( String FromPoiAddr ) {
+ this.FromPoiAddr = FromPoiAddr;
+ }
+
+ public String getFromPoiLongitude() {
+ return FromPoiLongitude;
+ }
+
+ public void setFromPoiLongitude( String FromPoiLongitude ) {
+ this.FromPoiLongitude = FromPoiLongitude;
+ }
+
+ public String getFromPoiLatitude() {
+ return FromPoiLatitude;
+ }
+
+ public void setFromPoiLatitude( String FromPoiLatitude ) {
+ this.FromPoiLatitude = FromPoiLatitude;
+ }
+
+ public String getToPoiName() {
+ return ToPoiName;
+ }
+
+ public void setToPoiName( String ToPoiName ) {
+ this.ToPoiName = ToPoiName;
+ }
+
+ public String getToPoiLongitude() {
+ return ToPoiLongitude;
+ }
+
+ public void setToPoiLongitude( String ToPoiLongitude ) {
+ this.ToPoiLongitude = ToPoiLongitude;
+ }
+
+ public String getToPoiLatitude() {
+ return ToPoiLatitude;
+ }
+
+ public void setToPoiLatitude( String ToPoiLatitude ) {
+ this.ToPoiLatitude = ToPoiLatitude;
+ }
+}
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/onlinecar/panel/OnlineCarListPanelProvider.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/onlinecar/panel/OnlineCarListPanelProvider.java
new file mode 100644
index 0000000000..36402ac240
--- /dev/null
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/onlinecar/panel/OnlineCarListPanelProvider.java
@@ -0,0 +1,71 @@
+package com.mogo.module.service.onlinecar.panel;
+
+import android.content.Context;
+
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentActivity;
+
+import com.alibaba.android.arouter.facade.annotation.Route;
+import com.mogo.service.MogoServicePaths;
+import com.mogo.service.strategy.IMogoOnlineCarListPanelProvider;
+import com.mogo.utils.logger.Logger;
+
+public
+/**
+ * @author congtaowang
+ * @since 2020/9/21
+ *
+ * 描述
+ */
+@Route( path = MogoServicePaths.PATH_ONLINE_CAR_PANEL )
+class OnlineCarListPanelProvider implements IMogoOnlineCarListPanelProvider {
+
+ private static final String TAG = "OnlineCarListPanelProvider";
+
+ @Override
+ public void initContainer( int containerId, FragmentActivity activity ) {
+ ContainerHandler.sContainerId = containerId;
+ ContainerHandler.sAttachContext = activity;
+ }
+
+ @Override
+ public void showPanel() {
+ if ( ContainerHandler.sAttachContext == null ) {
+ return;
+ }
+ Fragment fragment = new OnlineCarPanelFragment();
+ Logger.d( TAG, "showPanel" );
+ ContainerHandler.sAttachContext
+ .getSupportFragmentManager()
+ .beginTransaction()
+ .replace( ContainerHandler.sContainerId, fragment, TAG )
+ .commitNowAllowingStateLoss();
+ }
+
+ @Override
+ public void hidePanel() {
+ if ( ContainerHandler.sAttachContext == null ) {
+ return;
+ }
+ Logger.d( TAG, "hidePanel" );
+ Fragment fragment = ContainerHandler.sAttachContext.getSupportFragmentManager().findFragmentByTag( TAG );
+ if ( fragment != null ) {
+ ContainerHandler.sAttachContext
+ .getSupportFragmentManager()
+ .beginTransaction()
+ .remove( fragment )
+ .commitNowAllowingStateLoss();
+ }
+ }
+
+ @Override
+ public void clear() {
+ ContainerHandler.sContainerId = 0;
+ ContainerHandler.sAttachContext = null;
+ }
+
+ @Override
+ public void init( Context context ) {
+
+ }
+}
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/onlinecar/panel/OnlineCarPanelAdapter.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/onlinecar/panel/OnlineCarPanelAdapter.java
new file mode 100644
index 0000000000..55da33b57a
--- /dev/null
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/onlinecar/panel/OnlineCarPanelAdapter.java
@@ -0,0 +1,118 @@
+package com.mogo.module.service.onlinecar.panel;
+
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.bumptech.glide.request.RequestOptions;
+import com.mogo.map.location.MogoLocation;
+import com.mogo.module.common.MogoApisHandler;
+import com.mogo.module.common.api.CallChatApi;
+import com.mogo.module.common.entity.MarkerLocation;
+import com.mogo.module.common.entity.MarkerOnlineCar;
+import com.mogo.module.common.glide.SkinAbleBitmapTarget;
+import com.mogo.module.service.MarkerServiceHandler;
+import com.mogo.module.service.R;
+import com.mogo.module.service.Utils;
+import com.mogo.utils.ResourcesHelper;
+import com.mogo.utils.WindowUtils;
+import com.mogo.utils.glide.GlideApp;
+import com.mogo.utils.logger.Logger;
+
+import java.util.List;
+
+/**
+ * @author congtaowang
+ * @since 2020/9/21
+ *
+ * 描述
+ */
+class OnlineCarPanelAdapter extends RecyclerView.Adapter< OnlineCarPanelAdapter.VH > {
+
+ private static final String TAG = "OnlineCarPanelAdapter";
+
+ private List< MarkerOnlineCar > mDatums;
+ private double mToLon;
+ private double mToLat;
+
+ public OnlineCarPanelAdapter( List< MarkerOnlineCar > mDatums, double mToLon, double mToLat ) {
+ this.mDatums = mDatums;
+ this.mToLon = mToLon;
+ this.mToLat = mToLat;
+ }
+
+ public void setDatums( List< MarkerOnlineCar > mDatums ) {
+ this.mDatums = mDatums;
+ notifyDataSetChanged();
+ }
+
+ @NonNull
+ @Override
+ public OnlineCarPanelAdapter.VH onCreateViewHolder( @NonNull ViewGroup parent, int viewType ) {
+ return new VH( LayoutInflater.from( parent.getContext() ).inflate( R.layout.module_services_online_car_panel_item, null ) );
+ }
+
+ @Override
+ public void onBindViewHolder( @NonNull OnlineCarPanelAdapter.VH holder, int position ) {
+ holder.bind( mDatums.get( position ), mToLon, mToLat );
+ }
+
+ @Override
+ public int getItemCount() {
+ return mDatums == null ? 0 : mDatums.size();
+ }
+
+ public static class VH extends RecyclerView.ViewHolder {
+
+ private ImageView avatar;
+ private TextView nickname;
+ private TextView distance;
+ private TextView detail;
+
+ public VH( @NonNull View itemView ) {
+ super( itemView );
+ RecyclerView.LayoutParams params = new RecyclerView.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT );
+ params.bottomMargin = ResourcesHelper.getDimensionPixelSize( itemView.getContext(), R.dimen.module_services_panel_item_marginBottom );
+ itemView.setLayoutParams( params );
+ avatar = itemView.findViewById( R.id.module_services_id_panel_item_avatar );
+ nickname = itemView.findViewById( R.id.module_services_id_panel_item_nickname );
+ distance = itemView.findViewById( R.id.module_services_id_panel_item_distance );
+ detail = itemView.findViewById( R.id.module_services_id_panel_item_detail );
+ }
+
+ public void bind( MarkerOnlineCar car, double lon, double lat ) {
+ RequestOptions options = new RequestOptions().circleCrop().placeholder( R.drawable.module_common_default_user_head ).error( R.drawable.module_common_default_user_head );
+ GlideApp.with( itemView.getContext() ).asBitmap().apply( options ).load( car.getUserInfo().getUserHead() ).into( new SkinAbleBitmapTarget( avatar, options ) );
+ nickname.setText( car.getUserInfo().getUserName() );
+ String content = getDistanceStr( car.getLocation(), lon, lat );
+ distance.setText( content );
+ detail.setOnClickListener( view -> {
+ MogoApisHandler.getInstance().getApis().getAnalyticsApi().track( "Mogoer_List_click", null );
+ try {
+ CallChatApi.getInstance().showUserWindow( itemView.getContext(), car );
+ } catch ( Exception e ) {
+ Logger.e( TAG, e, "detail.OnClick" );
+ }
+ } );
+ }
+
+ private String getDistanceStr( MarkerLocation location, double lon, double lat ) {
+ if ( location == null ) {
+ return "未知";
+ }
+ float distance = Utils.calculateLineDistance( location.getLon(), location.getLat(), lon, lat );
+ if ( distance >= 1000 ) {
+ return String.format( "%.1fKM", distance / 1000 );
+ } else {
+ return String.format( "%.1fM", distance );
+ }
+ }
+ }
+
+
+}
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/onlinecar/panel/OnlineCarPanelFragment.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/onlinecar/panel/OnlineCarPanelFragment.java
new file mode 100644
index 0000000000..4fbe490aaf
--- /dev/null
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/onlinecar/panel/OnlineCarPanelFragment.java
@@ -0,0 +1,183 @@
+package com.mogo.module.service.onlinecar.panel;
+
+import android.view.View;
+import android.widget.ProgressBar;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.mogo.commons.mvp.MvpFragment;
+import com.mogo.commons.voice.AIAssist;
+import com.mogo.module.common.MogoApisHandler;
+import com.mogo.module.common.entity.MarkerOnlineCar;
+import com.mogo.module.common.view.OnPreventFastClickListener;
+import com.mogo.module.service.MarkerServiceHandler;
+import com.mogo.module.service.R;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author congtaowang
+ * @since 2020/9/21
+ *
+ * 描述
+ */
+public class OnlineCarPanelFragment extends MvpFragment< IOnlineCarPanelView, OnlineCarPanelPresenter > implements IOnlineCarPanelView {
+
+ private RecyclerView mList;
+ private View mErrorPanel;
+
+ private View mRefreshPanel;
+ private TextView mEmptyTip;
+ private View m20KMStrategy;
+ private View m40KMStrategy;
+
+ private ProgressBar mLoading;
+
+ private OnlineCarPanelAdapter mOnlineCarPanelAdapter;
+
+ @Override
+ protected int getLayoutId() {
+ return R.layout.module_services_fragment_online_car_panel;
+ }
+
+ @Override
+ protected void initViews() {
+ findViewById( R.id.module_services_id_close ).setOnClickListener( new OnPreventFastClickListener() {
+ @Override
+ public void onClickImpl( View v ) {
+ removeSelf();
+ }
+ } );
+ mList = findViewById( R.id.module_services_id_recycler_view );
+ mRefreshPanel = findViewById( R.id.module_services_id_load_strategy_container );
+ mErrorPanel = findViewById( R.id.module_services_id_error_container );
+ m20KMStrategy = findViewById( R.id.module_services_id_20Km_radius );
+ m40KMStrategy = findViewById( R.id.module_services_id_40Km_radius );
+ mEmptyTip = findViewById( R.id.module_services_empty_tip );
+ mLoading = findViewById( R.id.module_services_id_loading );
+
+ mList.setLayoutManager( new LinearLayoutManager( getContext(), LinearLayoutManager.VERTICAL, false ) );
+
+ m20KMStrategy.setOnClickListener( new OnPreventFastClickListener() {
+ @Override
+ public void onClickImpl( View v ) {
+ mPresenter.next20KMStrategy();
+ }
+ } );
+ m40KMStrategy.setOnClickListener( new OnPreventFastClickListener() {
+ @Override
+ public void onClickImpl( View v ) {
+ mPresenter.next40KMStrategy();
+ }
+ } );
+ mErrorPanel.setOnClickListener( new OnPreventFastClickListener() {
+ @Override
+ public void onClickImpl( View v ) {
+ mPresenter.loadOnlineCar();
+ }
+ } );
+
+ mRootView.setOnClickListener( view -> {
+ } );
+ }
+
+ public void refreshPanel() {
+ mPresenter.refreshPanel();
+ }
+
+ @Override
+ public void showLoading( boolean visible ) {
+ if ( visible ) {
+ mRefreshPanel.setVisibility( View.GONE );
+ mList.setVisibility( View.GONE );
+ mErrorPanel.setVisibility( View.GONE );
+ mLoading.setVisibility( View.VISIBLE );
+ } else {
+ mLoading.setVisibility( View.GONE );
+ }
+ }
+
+ @NonNull
+ @Override
+ protected OnlineCarPanelPresenter createPresenter() {
+ return new OnlineCarPanelPresenter( this );
+ }
+
+ @Override
+ public void renderOnlineCarList( List< MarkerOnlineCar > onlineCars, double lon, double lat ) {
+ mRefreshPanel.setVisibility( View.GONE );
+ mErrorPanel.setVisibility( View.GONE );
+ mList.setVisibility( View.VISIBLE );
+ mLoading.setVisibility( View.GONE );
+ if ( mOnlineCarPanelAdapter == null ) {
+ mOnlineCarPanelAdapter = new OnlineCarPanelAdapter( onlineCars, lon, lat );
+ mList.setAdapter( mOnlineCarPanelAdapter );
+ } else {
+ mOnlineCarPanelAdapter.setDatums( onlineCars );
+ }
+ AIAssist.getInstance( getContext() ).speakTTSVoice( String.format( "为您找到%s个车友", onlineCars.size() ) );
+ Map< String, Object > properties = new HashMap<>();
+ properties.put( "number", onlineCars.size() );
+ MogoApisHandler.getInstance().getApis().getAnalyticsApi().track( "Mogoer_List_number", properties );
+ }
+
+ @Override
+ public void renderEmptyUi( OnlineCarStrategy strategy ) {
+ mErrorPanel.setVisibility( View.GONE );
+ mList.setVisibility( View.GONE );
+ mRefreshPanel.setVisibility( View.VISIBLE );
+ mLoading.setVisibility( View.GONE );
+
+ AIAssist.getInstance( getContext() ).speakTTSVoice( "未找到车友" );
+ if ( strategy == null ) {
+ m20KMStrategy.setVisibility( View.GONE );
+ m40KMStrategy.setVisibility( View.GONE );
+ mEmptyTip.setText( getString( R.string.module_services_online_car_panel_empty_tmpl, OnlineCarStrategy.Strategy3.getRadiusKM() ) );
+ } else {
+ switch ( strategy ) {
+ case Strategy3:
+ m20KMStrategy.setVisibility( View.GONE );
+ m40KMStrategy.setVisibility( View.GONE );
+ case Strategy2:
+ m20KMStrategy.setVisibility( View.GONE );
+ case Default:
+ break;
+ }
+ mEmptyTip.setText( getString( R.string.module_services_online_car_panel_empty_tmpl, strategy.getRadiusKM() ) );
+ }
+ }
+
+ @Override
+ public void renderNoNavigationInfoUi() {
+ mList.setVisibility( View.GONE );
+ mRefreshPanel.setVisibility( View.GONE );
+ mErrorPanel.setVisibility( View.VISIBLE );
+ mLoading.setVisibility( View.GONE );
+ }
+
+ @Override
+ public void renderErrorUi() {
+ mList.setVisibility( View.GONE );
+ mRefreshPanel.setVisibility( View.GONE );
+ mLoading.setVisibility( View.GONE );
+ mErrorPanel.setVisibility( View.VISIBLE );
+ }
+
+ @Override
+ public void removeSelf() {
+ MarkerServiceHandler.getApis().getOnlineCarPanelApi().hidePanel();
+ }
+
+ @Override
+ public void onDestroyView() {
+ if ( mPresenter != null ) {
+ mPresenter.destroy();
+ }
+ super.onDestroyView();
+ }
+}
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/onlinecar/panel/OnlineCarPanelPresenter.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/onlinecar/panel/OnlineCarPanelPresenter.java
new file mode 100644
index 0000000000..54049dbccf
--- /dev/null
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/onlinecar/panel/OnlineCarPanelPresenter.java
@@ -0,0 +1,122 @@
+package com.mogo.module.service.onlinecar.panel;
+
+import android.text.TextUtils;
+
+import androidx.annotation.NonNull;
+import androidx.lifecycle.LifecycleOwner;
+
+import com.mogo.commons.mvp.Presenter;
+import com.mogo.commons.storage.SpStorage;
+import com.mogo.map.IDestroyable;
+import com.mogo.map.MogoLatLng;
+import com.mogo.map.navi.IMogoNaviListener2;
+import com.mogo.module.common.MogoApisHandler;
+import com.mogo.module.common.entity.MarkerResponse;
+import com.mogo.module.service.network.RefreshCallback;
+import com.mogo.module.service.network.RefreshModel;
+import com.mogo.utils.logger.Logger;
+import com.mogo.utils.network.utils.GsonUtil;
+
+/**
+ * @author congtaowang
+ * @since 2020/9/21
+ *
+ * 描述
+ */
+class OnlineCarPanelPresenter extends Presenter< IOnlineCarPanelView > implements
+ RefreshCallback< MarkerResponse >,
+ IMogoNaviListener2,
+ IDestroyable {
+
+ private static final String TAG = "OnlineCarPanelPresenter";
+
+ public static final int LIMIT = 20;
+ private RefreshModel mRefreshModel;
+ private OnlineCarStrategy mStrategy;
+ private NavigationTargetInfo mNavigationTargetInfo;
+ private Double mToLat;
+ private Double mToLon;
+
+ public OnlineCarPanelPresenter( IOnlineCarPanelView view ) {
+ super( view );
+ mRefreshModel = new RefreshModel( getContext() );
+ MogoApisHandler.getInstance().getApis().getRegisterCenterApi().registerMogoNaviListener( TAG, this );
+ }
+
+ @Override
+ public void onStopNavi() {
+ mView.removeSelf();
+ }
+
+ @Override
+ public void onCreate( @NonNull LifecycleOwner owner ) {
+ super.onCreate( owner );
+ refreshPanel();
+ }
+
+ public void next20KMStrategy() {
+ mStrategy = OnlineCarStrategy.Strategy2;
+ loadOnlineCar();
+ }
+
+ public void next40KMStrategy() {
+ mStrategy = OnlineCarStrategy.Strategy3;
+ loadOnlineCar();
+ }
+
+ public void refreshPanel() {
+ mStrategy = OnlineCarStrategy.Default;
+ String json = SpStorage.getNavigationTarget();
+ if ( TextUtils.isEmpty( json ) ) {
+ mView.renderNoNavigationInfoUi();
+ return;
+ }
+ Logger.d( TAG, json );
+ mNavigationTargetInfo = GsonUtil.objectFromJson( json, NavigationTargetInfo.class );
+ loadOnlineCar();
+ }
+
+ public void loadOnlineCar() {
+ if ( mNavigationTargetInfo == null ) {
+ mView.renderNoNavigationInfoUi();
+ return;
+ }
+ mView.showLoading( true );
+ try {
+ mToLat = Double.valueOf( mNavigationTargetInfo.getToPoiLatitude() );
+ mToLon = Double.valueOf( mNavigationTargetInfo.getToPoiLongitude() );
+ mRefreshModel.queryOnLineCarWithRoute( new MogoLatLng( mToLat, mToLon ),
+ false,
+ false,
+ mStrategy.getRadius(),
+ LIMIT,
+ true,
+ this
+ );
+ } catch ( Exception e ) {
+ mView.renderNoNavigationInfoUi();
+ }
+ }
+
+ @Override
+ public void onSuccess( MarkerResponse o ) {
+ if ( o == null
+ || o.getResult() == null
+ || o.getResult().getOnlineCar() == null
+ || o.getResult().getOnlineCar().isEmpty() ) {
+ mView.renderEmptyUi( mStrategy );
+ } else {
+ mView.renderOnlineCarList( o.getResult().getOnlineCar(), mToLon, mToLat );
+ }
+ }
+
+ @Override
+ public void onFail() {
+ mView.renderErrorUi();
+ }
+
+ @Override
+ public void destroy() {
+ MogoApisHandler.getInstance().getApis().getRegisterCenterApi().unregisterMogoNaviListener( TAG );
+ }
+}
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/onlinecar/panel/OnlineCarStrategy.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/onlinecar/panel/OnlineCarStrategy.java
new file mode 100644
index 0000000000..ffad8fc82a
--- /dev/null
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/onlinecar/panel/OnlineCarStrategy.java
@@ -0,0 +1,35 @@
+package com.mogo.module.service.onlinecar.panel;
+
+/**
+ * @author congtaowang
+ * @since 2020/9/21
+ *
+ * 描述
+ */
+enum OnlineCarStrategy {
+
+ Strategy3( 40_000, null ),
+ Strategy2( 20_000, Strategy3 ),
+ Default( 10_000, Strategy2 ),
+ ;
+
+ private int radius;
+ private OnlineCarStrategy next;
+
+ OnlineCarStrategy( int radius, OnlineCarStrategy next ) {
+ this.radius = radius;
+ this.next = next;
+ }
+
+ public int getRadius() {
+ return radius;
+ }
+
+ public int getRadiusKM() {
+ return radius / 1000;
+ }
+
+ public OnlineCarStrategy getNext() {
+ return next;
+ }
+}
diff --git a/modules/mogo-module-service/src/main/res/drawable-ldpi/icon_map_marker_car_gray_selected.png b/modules/mogo-module-service/src/main/res/drawable-ldpi/icon_map_marker_car_gray_selected.png
new file mode 100644
index 0000000000..b701a8aae2
Binary files /dev/null and b/modules/mogo-module-service/src/main/res/drawable-ldpi/icon_map_marker_car_gray_selected.png differ
diff --git a/modules/mogo-module-service/src/main/res/drawable-ldpi/map_api_ic_current_location2_cursor.png b/modules/mogo-module-service/src/main/res/drawable-ldpi/map_api_ic_current_location2_cursor.png
index 55dbd72260..5f91be07f3 100644
Binary files a/modules/mogo-module-service/src/main/res/drawable-ldpi/map_api_ic_current_location2_cursor.png and b/modules/mogo-module-service/src/main/res/drawable-ldpi/map_api_ic_current_location2_cursor.png differ
diff --git a/modules/mogo-module-service/src/main/res/drawable-ldpi/module_services_close.png b/modules/mogo-module-service/src/main/res/drawable-ldpi/module_services_close.png
new file mode 100755
index 0000000000..c1381dc44c
Binary files /dev/null and b/modules/mogo-module-service/src/main/res/drawable-ldpi/module_services_close.png differ
diff --git a/modules/mogo-module-service/src/main/res/drawable-ldpi/module_services_online_car_panel_background.9.png b/modules/mogo-module-service/src/main/res/drawable-ldpi/module_services_online_car_panel_background.9.png
new file mode 100644
index 0000000000..80ab4b841f
Binary files /dev/null and b/modules/mogo-module-service/src/main/res/drawable-ldpi/module_services_online_car_panel_background.9.png differ
diff --git a/modules/mogo-module-service/src/main/res/drawable-ldpi/module_services_online_car_panel_empty_icon.png b/modules/mogo-module-service/src/main/res/drawable-ldpi/module_services_online_car_panel_empty_icon.png
new file mode 100644
index 0000000000..0befdbd823
Binary files /dev/null and b/modules/mogo-module-service/src/main/res/drawable-ldpi/module_services_online_car_panel_empty_icon.png differ
diff --git a/modules/mogo-module-service/src/main/res/drawable-mdpi/icon_map_marker_car_gray_selected.png b/modules/mogo-module-service/src/main/res/drawable-mdpi/icon_map_marker_car_gray_selected.png
new file mode 100644
index 0000000000..b701a8aae2
Binary files /dev/null and b/modules/mogo-module-service/src/main/res/drawable-mdpi/icon_map_marker_car_gray_selected.png differ
diff --git a/modules/mogo-module-service/src/main/res/drawable-mdpi/map_api_ic_current_location2_cursor.png b/modules/mogo-module-service/src/main/res/drawable-mdpi/map_api_ic_current_location2_cursor.png
index 55dbd72260..5f91be07f3 100644
Binary files a/modules/mogo-module-service/src/main/res/drawable-mdpi/map_api_ic_current_location2_cursor.png and b/modules/mogo-module-service/src/main/res/drawable-mdpi/map_api_ic_current_location2_cursor.png differ
diff --git a/modules/mogo-module-service/src/main/res/drawable-mdpi/module_services_close.png b/modules/mogo-module-service/src/main/res/drawable-mdpi/module_services_close.png
new file mode 100755
index 0000000000..c1381dc44c
Binary files /dev/null and b/modules/mogo-module-service/src/main/res/drawable-mdpi/module_services_close.png differ
diff --git a/modules/mogo-module-service/src/main/res/drawable-mdpi/module_services_online_car_panel_background.9.png b/modules/mogo-module-service/src/main/res/drawable-mdpi/module_services_online_car_panel_background.9.png
new file mode 100644
index 0000000000..80ab4b841f
Binary files /dev/null and b/modules/mogo-module-service/src/main/res/drawable-mdpi/module_services_online_car_panel_background.9.png differ
diff --git a/modules/mogo-module-service/src/main/res/drawable-mdpi/module_services_online_car_panel_empty_icon.png b/modules/mogo-module-service/src/main/res/drawable-mdpi/module_services_online_car_panel_empty_icon.png
new file mode 100644
index 0000000000..0befdbd823
Binary files /dev/null and b/modules/mogo-module-service/src/main/res/drawable-mdpi/module_services_online_car_panel_empty_icon.png differ
diff --git a/modules/mogo-module-service/src/main/res/drawable-xhdpi/icon_map_marker_car_gray_selected.png b/modules/mogo-module-service/src/main/res/drawable-xhdpi/icon_map_marker_car_gray_selected.png
new file mode 100644
index 0000000000..725a560b4f
Binary files /dev/null and b/modules/mogo-module-service/src/main/res/drawable-xhdpi/icon_map_marker_car_gray_selected.png differ
diff --git a/modules/mogo-module-service/src/main/res/drawable-xhdpi/module_services_close.png b/modules/mogo-module-service/src/main/res/drawable-xhdpi/module_services_close.png
new file mode 100755
index 0000000000..bb3e2b1195
Binary files /dev/null and b/modules/mogo-module-service/src/main/res/drawable-xhdpi/module_services_close.png differ
diff --git a/modules/mogo-module-service/src/main/res/drawable-xhdpi/module_services_online_car_panel_background.9.png b/modules/mogo-module-service/src/main/res/drawable-xhdpi/module_services_online_car_panel_background.9.png
new file mode 100644
index 0000000000..b3149721b1
Binary files /dev/null and b/modules/mogo-module-service/src/main/res/drawable-xhdpi/module_services_online_car_panel_background.9.png differ
diff --git a/modules/mogo-module-service/src/main/res/drawable-xhdpi/module_services_online_car_panel_empty_icon.png b/modules/mogo-module-service/src/main/res/drawable-xhdpi/module_services_online_car_panel_empty_icon.png
new file mode 100644
index 0000000000..e225da807b
Binary files /dev/null and b/modules/mogo-module-service/src/main/res/drawable-xhdpi/module_services_online_car_panel_empty_icon.png differ
diff --git a/modules/mogo-module-service/src/main/res/drawable/module_services_close.png b/modules/mogo-module-service/src/main/res/drawable/module_services_close.png
new file mode 100755
index 0000000000..c1381dc44c
Binary files /dev/null and b/modules/mogo-module-service/src/main/res/drawable/module_services_close.png differ
diff --git a/modules/mogo-module-service/src/main/res/drawable/module_services_online_car_panel_background.9.png b/modules/mogo-module-service/src/main/res/drawable/module_services_online_car_panel_background.9.png
new file mode 100644
index 0000000000..f19ee05db1
Binary files /dev/null and b/modules/mogo-module-service/src/main/res/drawable/module_services_online_car_panel_background.9.png differ
diff --git a/modules/mogo-module-service/src/main/res/drawable/module_services_panel_item_bkg.xml b/modules/mogo-module-service/src/main/res/drawable/module_services_panel_item_bkg.xml
new file mode 100644
index 0000000000..08e5f85a0a
--- /dev/null
+++ b/modules/mogo-module-service/src/main/res/drawable/module_services_panel_item_bkg.xml
@@ -0,0 +1,9 @@
+
+
+ -
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-service/src/main/res/drawable/module_services_panel_item_detail_bkg.xml b/modules/mogo-module-service/src/main/res/drawable/module_services_panel_item_detail_bkg.xml
new file mode 100644
index 0000000000..9a503568e3
--- /dev/null
+++ b/modules/mogo-module-service/src/main/res/drawable/module_services_panel_item_detail_bkg.xml
@@ -0,0 +1,9 @@
+
+
+ -
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-service/src/main/res/drawable/module_services_panel_strategy_button_bkg.xml b/modules/mogo-module-service/src/main/res/drawable/module_services_panel_strategy_button_bkg.xml
new file mode 100644
index 0000000000..265d98a08c
--- /dev/null
+++ b/modules/mogo-module-service/src/main/res/drawable/module_services_panel_strategy_button_bkg.xml
@@ -0,0 +1,9 @@
+
+
+ -
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-service/src/main/res/layout/module_services_fragment_online_car_panel.xml b/modules/mogo-module-service/src/main/res/layout/module_services_fragment_online_car_panel.xml
new file mode 100644
index 0000000000..04abbaae72
--- /dev/null
+++ b/modules/mogo-module-service/src/main/res/layout/module_services_fragment_online_car_panel.xml
@@ -0,0 +1,133 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-service/src/main/res/layout/module_services_online_car_panel_item.xml b/modules/mogo-module-service/src/main/res/layout/module_services_online_car_panel_item.xml
new file mode 100644
index 0000000000..ca3b363f83
--- /dev/null
+++ b/modules/mogo-module-service/src/main/res/layout/module_services_online_car_panel_item.xml
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-service/src/main/res/values-ldpi/dimens.xml b/modules/mogo-module-service/src/main/res/values-ldpi/dimens.xml
index fd1066746d..0c1ef99605 100644
--- a/modules/mogo-module-service/src/main/res/values-ldpi/dimens.xml
+++ b/modules/mogo-module-service/src/main/res/values-ldpi/dimens.xml
@@ -22,4 +22,35 @@
64px
6.5px
10px
+
+ 2px
+ 2px
+ 0px
+ 28px
+ 16px
+
+ 20px
+ 28px
+ 20px
+ 84px
+ 18px
+ 58px
+ 14px
+ 16px
+ 18px
+ 5px
+ 20px
+ 13px
+ 42px
+ 8.89px
+ 13px
+ 16px
+ 25px
+ 13px
+ 26px
+ 20px
+ 18px
+ 17px
+ 60px
+ 12.5px
\ No newline at end of file
diff --git a/modules/mogo-module-service/src/main/res/values-mdpi/dimens.xml b/modules/mogo-module-service/src/main/res/values-mdpi/dimens.xml
index fd1066746d..9a63e6ddca 100644
--- a/modules/mogo-module-service/src/main/res/values-mdpi/dimens.xml
+++ b/modules/mogo-module-service/src/main/res/values-mdpi/dimens.xml
@@ -22,4 +22,35 @@
64px
6.5px
10px
+
+ 2px
+ 2px
+ 6px
+ 28px
+ 16px
+
+ 20px
+ 28px
+ 20px
+ 84px
+ 18px
+ 58px
+ 14px
+ 16px
+ 18px
+ 5px
+ 20px
+ 13px
+ 42px
+ 8.89px
+ 13px
+ 16px
+ 25px
+ 13px
+ 26px
+ 40px
+ 18px
+ 28px
+ 108px
+ 12.5px
\ No newline at end of file
diff --git a/modules/mogo-module-service/src/main/res/values-xhdpi-1920x1000/dimens.xml b/modules/mogo-module-service/src/main/res/values-xhdpi-1920x1000/dimens.xml
index 341706179d..6e500351ca 100644
--- a/modules/mogo-module-service/src/main/res/values-xhdpi-1920x1000/dimens.xml
+++ b/modules/mogo-module-service/src/main/res/values-xhdpi-1920x1000/dimens.xml
@@ -22,4 +22,35 @@
20px
120px
20px
+
+ 20px
+ 20px
+ 20px
+ 50px
+ 28px
+
+ 36px
+ 50px
+ 36px
+ 151px
+ 33px
+ 102px
+ 26px
+ 30px
+ 34px
+ 9px
+ 40px
+ 20px
+ 70px
+ 16px
+ 21px
+ 28px
+ 45px
+ 22px
+ 42px
+ 40px
+ 34px
+ 17px
+ 108px
+ 22.5px
\ No newline at end of file
diff --git a/modules/mogo-module-service/src/main/res/values-xhdpi/dimens.xml b/modules/mogo-module-service/src/main/res/values-xhdpi/dimens.xml
index 341706179d..717e486bf5 100644
--- a/modules/mogo-module-service/src/main/res/values-xhdpi/dimens.xml
+++ b/modules/mogo-module-service/src/main/res/values-xhdpi/dimens.xml
@@ -22,4 +22,35 @@
20px
120px
20px
+
+ 20px
+ 20px
+ 20px
+ 50px
+ 28px
+
+ 36px
+ 50px
+ 36px
+ 151px
+ 33px
+ 102px
+ 26px
+ 30px
+ 34px
+ 9px
+ 40px
+ 20px
+ 70px
+ 16px
+ 21px
+ 28px
+ 45px
+ 22px
+ 42px
+ 20px
+ 34px
+ 28px
+ 60px
+ 22.5px
\ No newline at end of file
diff --git a/modules/mogo-module-service/src/main/res/values/colors.xml b/modules/mogo-module-service/src/main/res/values/colors.xml
index e5cc33f8fa..aa88d40e7f 100644
--- a/modules/mogo-module-service/src/main/res/values/colors.xml
+++ b/modules/mogo-module-service/src/main/res/values/colors.xml
@@ -1,4 +1,12 @@
#ffffff
+ #FFFFFFFF
+ #FFFFFF
+ #FFFFFF
+ #7FFFFFFF
+ #FFFFFF
+ #3081A4DC
+ #B2FFFFFF
+ #FFFFFF
\ No newline at end of file
diff --git a/modules/mogo-module-service/src/main/res/values/dimens.xml b/modules/mogo-module-service/src/main/res/values/dimens.xml
index 341706179d..066fdbc538 100644
--- a/modules/mogo-module-service/src/main/res/values/dimens.xml
+++ b/modules/mogo-module-service/src/main/res/values/dimens.xml
@@ -22,4 +22,35 @@
20px
120px
20px
+
+ 2px
+ 2px
+ 0px
+ 28px
+ 16px
+
+ 20px
+ 28px
+ 20px
+ 84px
+ 18px
+ 58px
+ 14px
+ 16px
+ 18px
+ 5px
+ 20px
+ 13px
+ 42px
+ 8.89px
+ 13px
+ 16px
+ 25px
+ 13px
+ 26px
+ 20px
+ 18px
+ 17px
+ 60px
+ 12.5px
\ No newline at end of file
diff --git a/modules/mogo-module-service/src/main/res/values/strings.xml b/modules/mogo-module-service/src/main/res/values/strings.xml
index 78e8c3f560..13b65ec18f 100644
--- a/modules/mogo-module-service/src/main/res/values/strings.xml
+++ b/modules/mogo-module-service/src/main/res/values/strings.xml
@@ -4,4 +4,11 @@
你的周围有%d个%s,请点击查看,你也可以对我说打开蘑菇出行
周围有%d个%s
建议开启蘑菇出行,守护你的每一段行程,你可以直接对我说,打开蘑菇出行
+ 扩大到20KM半径
+ 扩大到40KM半径
+ 距离导航目的地
+ 查看车友信息
+ 很抱歉,目的地%dKM内未找到车友
+ 目的地车友
+ 加载失败,请点击重试
diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/ShareControl.java b/modules/mogo-module-share/src/main/java/com/mogo/module/share/ShareControl.java
index be7bb6d82a..a05c8b67e9 100644
--- a/modules/mogo-module-share/src/main/java/com/mogo/module/share/ShareControl.java
+++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/ShareControl.java
@@ -10,6 +10,7 @@ import android.util.ArrayMap;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.commons.debug.DebugConfig;
+import com.mogo.commons.network.ParamsProvider;
import com.mogo.commons.network.SubscribeImpl;
import com.mogo.commons.network.Utils;
import com.mogo.commons.voice.AIAssist;
@@ -37,8 +38,8 @@ import com.mogo.service.intent.IMogoIntentManager;
import com.mogo.service.share.IMogoShareManager;
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
import com.mogo.service.statusmanager.StatusDescriptor;
-import com.mogo.service.tanlu.IMogoTanluProvider;
-import com.mogo.service.tanlu.TanluUploadParams;
+import com.mogo.service.share.IMogoTanluProvider;
+import com.mogo.service.share.TanluUploadParams;
import com.mogo.utils.NetworkUtils;
import com.mogo.utils.TipToast;
import com.mogo.utils.logger.Logger;
@@ -50,6 +51,7 @@ import org.jetbrains.annotations.NotNull;
import org.json.JSONObject;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -77,15 +79,15 @@ import static com.mogo.module.share.constant.ShareConstants.VOICE_CMD_NO_REPLY_S
import static com.mogo.module.share.constant.ShareConstants.VOICE_CMD_PUB_ROAD_CONDITION;
import static com.mogo.module.share.constant.ShareConstants.VOICE_CMD_PUB_TROUBLE_HELP;
import static com.mogo.module.share.constant.ShareConstants.VOICE_CMD_SHARE_DIALOG_CLOSE;
-import static com.mogo.service.tanlu.IMogoTanluProvider.TYPE_ACCIDENT;
-import static com.mogo.service.tanlu.IMogoTanluProvider.TYPE_BLOCK;
-import static com.mogo.service.tanlu.IMogoTanluProvider.TYPE_CLOSURE;
-import static com.mogo.service.tanlu.IMogoTanluProvider.TYPE_DENSE_FOG;
-import static com.mogo.service.tanlu.IMogoTanluProvider.TYPE_REAL_TIME_TRAFFIC;
-import static com.mogo.service.tanlu.IMogoTanluProvider.TYPE_ROAD_CONSTRUCTION;
-import static com.mogo.service.tanlu.IMogoTanluProvider.TYPE_ROAD_ICY;
-import static com.mogo.service.tanlu.IMogoTanluProvider.TYPE_STAGNANT_WATER;
-import static com.mogo.service.tanlu.IMogoTanluProvider.TYPE_TRAFFIC_CHECK;
+import static com.mogo.service.share.IMogoTanluProvider.TYPE_ACCIDENT;
+import static com.mogo.service.share.IMogoTanluProvider.TYPE_BLOCK;
+import static com.mogo.service.share.IMogoTanluProvider.TYPE_CLOSURE;
+import static com.mogo.service.share.IMogoTanluProvider.TYPE_DENSE_FOG;
+import static com.mogo.service.share.IMogoTanluProvider.TYPE_REAL_TIME_TRAFFIC;
+import static com.mogo.service.share.IMogoTanluProvider.TYPE_ROAD_CONSTRUCTION;
+import static com.mogo.service.share.IMogoTanluProvider.TYPE_ROAD_ICY;
+import static com.mogo.service.share.IMogoTanluProvider.TYPE_STAGNANT_WATER;
+import static com.mogo.service.share.IMogoTanluProvider.TYPE_TRAFFIC_CHECK;
/**
* 分享框的逻辑都放到这里吧
@@ -129,14 +131,19 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener,
mContext = context;
}
+ @Override
+ public void releaseContext() {
+ mContext = mContext.getApplicationContext();
+ }
+
private void realShowDialog() {
if (mShareDialog == null) {
Logger.d(TAG, "realShowDialog context : " + mContext);
- if(DebugConfig.isLauncher()){
- mShareDialog = new LaucherShareDialog(mContext);
- }else {
- mShareDialog = new GridFixableShareDialog(mContext);
- }
+// if(DebugConfig.isLauncher()){
+// mShareDialog = new LaucherShareDialog(mContext);
+// }else {
+ mShareDialog = new GridFixableShareDialog(mContext);
+// }
mShareDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
@@ -202,32 +209,34 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener,
AIAssist.getInstance(mContext).registerUnWakeupCommand(UNWAKE_UPLOAD_REAL_TIME_TRAFFIC,
UPLOAD_REAL_TIME_TRAFFIC, ShareControl.this);
- if (!DebugConfig.isLauncher()) {
- ServiceApisManager.serviceApis.getStatusManagerApi().registerStatusChangedListener(TAG, StatusDescriptor.MAIN_PAGE_RESUME, new IMogoStatusChangedListener() {
- @Override
- public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) {
- if (!isTrue) {
- dismissShareDialog();
- }
+// if (!DebugConfig.isLauncher()) {
+ ServiceApisManager.serviceApis.getStatusManagerApi().registerStatusChangedListener(TAG,
+ StatusDescriptor.MAIN_PAGE_RESUME, new IMogoStatusChangedListener() {
+ @Override
+ public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) {
+ if (!isTrue) {
+ dismissShareDialog();
}
- });
- }
+ }
+ });
+// }
- if (!DebugConfig.isLauncher()) {
- ServiceApisManager.serviceApis.getStatusManagerApi().registerStatusChangedListener(TAG, StatusDescriptor.ACC_STATUS, new IMogoStatusChangedListener() {
- @Override
- public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) {
- if (isTrue) {
- queryShareConfigRetryTime = 0;
- queryShareButtonConfig();
+// if (!DebugConfig.isLauncher()) {
+ ServiceApisManager.serviceApis.getStatusManagerApi().registerStatusChangedListener(TAG,
+ StatusDescriptor.ACC_STATUS, new IMogoStatusChangedListener() {
+ @Override
+ public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) {
+ if (isTrue) {
+ queryShareConfigRetryTime = 0;
+ queryShareButtonConfig();
+ }
}
- }
- });
+ });
- // 获取分享框配置信息
- queryShareConfigRetryTime = 0;
- queryShareButtonConfig();
- }
+ // 获取分享框配置信息
+ queryShareConfigRetryTime = 0;
+ queryShareButtonConfig();
+// }
Logger.d(TAG, "init over====");
}
diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/StrategyShareProvider.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/StrategyShareProvider.kt
index a09b3a53c0..f7c667d3fa 100644
--- a/modules/mogo-module-share/src/main/java/com/mogo/module/share/StrategyShareProvider.kt
+++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/StrategyShareProvider.kt
@@ -27,12 +27,12 @@ class StrategyShareProvider : IProvider {
blockStrategy = BlockStrategy(context, apis)
// 注册事故
apis.getSocketManagerApi(context).registerOnMessageListener(ACCIDENT_STRATEGY_SHARE_PUSH_TYPE, AccidentStrategyReceiver(apis))
- if(!DebugConfig.isLauncher()) {
- apis.registerCenterApi.registerMogoLocationListener(MogoServicePaths.PATH_STRATEGY_SHARE) {
+// if(!DebugConfig.isLauncher()) {
+ apis.registerCenterApi.registerMogoLocationListener(MogoServicePaths.PATH_STRATEGY_SHARE) {
// Logger.d(S_TAG,"定位发生变化,准备记录速度: ${it.speed}")
- blockStrategy.recordSpeed(it.speed * 3.6F)
- }
+ blockStrategy.recordSpeed(it.speed * 3.6F)
}
+// }
}
}
\ No newline at end of file
diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/FixableButton.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/FixableButton.kt
index 17ec692ef6..f80afbfa52 100644
--- a/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/FixableButton.kt
+++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/FixableButton.kt
@@ -2,7 +2,7 @@ package com.mogo.module.share.bean
import com.mogo.commons.data.BaseData
import com.mogo.module.share.R
-import com.mogo.service.tanlu.IMogoTanluProvider.*
+import com.mogo.service.share.IMogoTanluProvider.*
/**
* 可配置按钮封装
diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/constant/ShareConstants.java b/modules/mogo-module-share/src/main/java/com/mogo/module/share/constant/ShareConstants.java
index e55fcb61c9..28ed0f468e 100644
--- a/modules/mogo-module-share/src/main/java/com/mogo/module/share/constant/ShareConstants.java
+++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/constant/ShareConstants.java
@@ -86,4 +86,40 @@ public class ShareConstants {
* 分享框配置本地缓存的key
*/
public static final String KEY_SHARE_CONFIG = "SHARE_BUTTON_CONFIG";
+
+ /**
+ * 外部触发
+ */
+ public static final String KEY_SHARE_OUTER_GUIDE = "KEY_SHARE_OUTER_GUIDE";
+ public static final String KEY_SHARE_OUTER_GUIDE_TIME = "KEY_SHARE_OUTER_GUIDE_TIME";
+ public static final String KEY_SERVER_SHOW_DAY_COUNT = "KEY_SERVER_SHOW_DAY_COUNT";
+
+ /**
+ * 内部触发
+ */
+ public static final String KEY_SHARE_INNER_GUIDE = "KEY_SHARE_INNER_GUIDE";
+ public static final String KEY_SHARE_INNER_GUIDE_TIME = "KEY_SHARE_INNER_GUIDE_TIME";
+
+ /**
+ * 点击分享
+ */
+ public static final String KEY_CLICK_SHARE_BUTTON = "KEY_CLICK_SHARE_BUTTON";
+ public static final String KEY_CLICK_SHARE_TIME = "KEY_CLICK_SHARE_TIME";
+
+ /**
+ * 点击具体分享类别
+ */
+ public static final String KEY_CLICK_SHARE_ITEM_BUTTON = "KEY_CLICK_SHARE_ITEM_BUTTON";
+ public static final String KEY_CLICK_SHARE_ITEM_TIME = "KEY_CLICK_SHARE_ITEM_TIME";
+
+ public static final int VOICE_ALERT_COUNT = 3;
+
+ //1天的毫秒 TODO
+ public static final long ONE_DAY_TIME = 86400000;
+// public static final long ONE_DAY_TIME = 60000;
+
+ //7天的毫秒
+ public static final long SEVEN_DAY_TIME = 604800000;
+// public static final long SEVEN_DAY_TIME = 60000;
+
}
diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/dialog/GridFixableShareDialog.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/dialog/GridFixableShareDialog.kt
index 8b8eaa14ee..c3d16fe965 100644
--- a/modules/mogo-module-share/src/main/java/com/mogo/module/share/dialog/GridFixableShareDialog.kt
+++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/dialog/GridFixableShareDialog.kt
@@ -17,8 +17,8 @@ import com.mogo.service.IMogoServiceApis
import com.mogo.service.MogoServicePaths
import com.mogo.service.analytics.IMogoAnalytics
import com.mogo.service.statusmanager.IMogoStatusManager
-import com.mogo.service.tanlu.IMogoTanluProvider
-import com.mogo.service.tanlu.TanluUploadParams
+import com.mogo.service.share.IMogoTanluProvider
+import com.mogo.service.share.TanluUploadParams
import com.mogo.utils.logger.Logger
import kotlin.random.Random
diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/dialog/LaucherShareDialog.java b/modules/mogo-module-share/src/main/java/com/mogo/module/share/dialog/LaucherShareDialog.java
index 238667d7fb..bf5bcf8365 100644
--- a/modules/mogo-module-share/src/main/java/com/mogo/module/share/dialog/LaucherShareDialog.java
+++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/dialog/LaucherShareDialog.java
@@ -18,8 +18,8 @@ import com.mogo.service.IMogoServiceApis;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.analytics.IMogoAnalytics;
import com.mogo.service.statusmanager.IMogoStatusManager;
-import com.mogo.service.tanlu.IMogoTanluProvider;
-import com.mogo.service.tanlu.TanluUploadParams;
+import com.mogo.service.share.IMogoTanluProvider;
+import com.mogo.service.share.TanluUploadParams;
import com.mogo.utils.logger.Logger;
diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/manager/GridBtnManager.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/manager/GridBtnManager.kt
index 7dd041a33e..07d436adba 100644
--- a/modules/mogo-module-share/src/main/java/com/mogo/module/share/manager/GridBtnManager.kt
+++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/manager/GridBtnManager.kt
@@ -9,7 +9,7 @@ import android.widget.TextView
import com.mogo.module.share.R
import com.mogo.module.share.bean.FixableButton
import com.mogo.module.share.constant.ShareConstants
-import com.mogo.service.tanlu.IMogoTanluProvider
+import com.mogo.service.share.IMogoTanluProvider
import com.mogo.utils.glide.GlideApp
import com.mogo.utils.logger.Logger
import com.mogo.utils.network.utils.GsonUtil
diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/manager/SeekHelpManager.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/manager/SeekHelpManager.kt
index 83282b97f4..e55988e46c 100644
--- a/modules/mogo-module-share/src/main/java/com/mogo/module/share/manager/SeekHelpManager.kt
+++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/manager/SeekHelpManager.kt
@@ -82,7 +82,7 @@ object SeekHelpManager {
if(!isSeeking) {
isSeeking = true
if (this.context == null) {
- this.context = context
+ this.context = context.applicationContext
}
aiAssist = AIAssist.getInstance(context)
diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/manager/UploadHelper.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/manager/UploadHelper.kt
index 62cc8b2584..a4b734bd8b 100644
--- a/modules/mogo-module-share/src/main/java/com/mogo/module/share/manager/UploadHelper.kt
+++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/manager/UploadHelper.kt
@@ -1,64 +1,109 @@
package com.mogo.module.share.manager
import android.content.Context
-import android.content.Intent
-import com.mogo.commons.debug.DebugConfig
+import android.util.Log
import com.mogo.commons.voice.AIAssist
import com.mogo.map.MogoLatLng
-import com.mogo.map.location.MogoLocation
+import com.mogo.module.common.entity.MarkerPoiTypeEnum
import com.mogo.module.share.R
-import com.mogo.module.share.ShareControl
-import com.mogo.module.share.dialog.LaucherShareDialog
-import com.mogo.service.tanlu.TanluUploadParams
+import com.mogo.module.share.constant.ShareConstants.*
+import com.mogo.service.share.TanluUploadParams
import com.mogo.utils.NetworkUtils
import com.mogo.utils.TipDrawable
import com.mogo.utils.TipToast
import com.mogo.utils.logger.Logger
+import com.mogo.utils.storage.SharedPrefsMgr
/**
* 上报工具类
*/
object UploadHelper {
fun upload(context: Context, type: TanluUploadParams, forcePlayVoice: Boolean = false) {
- if (DebugConfig.isLauncher()) {
- if (ServiceApisManager.serviceApis.statusManagerApi.isUploading) {
- // 上报即成功,当前还有正在上报的事件,仅做界面展示,不做具体操作
- Logger.d("UploadHelper", "正在上报===")
- TipToast.tip("正在上报,请稍后重试")
- } else {
+// if (DebugConfig.isLauncher()) { //TODO launcher和独立应用
+// if (ServiceApisManager.serviceApis.statusManagerApi.isUploading) {
+// // 上报即成功,当前还有正在上报的事件,仅做界面展示,不做具体操作
+// Logger.d("UploadHelper", "正在上报===")
+// TipToast.tip("正在上报,请稍后重试")
+// } else {
+// ServiceApisManager.serviceApis.statusManagerApi.setUploadingStatus("CARD_TYPE_ROAD_CONDITION", true)
+// if (DebugConfig.getAIType() == DebugConfig.AI_TYPE_TXZ || forcePlayVoice) {
+// // 因为思必驰语音分享时,语音助手会自己播报一段文字
+//// AIAssist.getInstance(context).speakTTSVoice("感谢分享,正在上传")
+
+// val location = ServiceApisManager.serviceApis.mapServiceApi.getSingletonLocationClient(context).lastKnowLocation
+// val latLon = MogoLatLng(location.latitude, location.longitude)
+// type.location = latLon
+// Logger.d("UploadHelper", "upload ----> $type")
+// ServiceApisManager.serviceApis.tanluApi.uploadRoadCondition(type)
+// }
+// } else {
+ if (ServiceApisManager.serviceApis.statusManagerApi.isUploading) {
+ // 上报即成功,当前还有正在上报的事件,仅做界面展示,不做具体操作
+ ServiceApisManager.serviceApis.tanluUiApi.shareSuccess(type.eventType, type.location)
+ } else {
+ // 判断当前网络状态
+ if (NetworkUtils.isConnected(context)) {
+ // 有网就正常上报
ServiceApisManager.serviceApis.statusManagerApi.setUploadingStatus("CARD_TYPE_ROAD_CONDITION", true)
- if (DebugConfig.getAIType() == DebugConfig.AI_TYPE_TXZ || forcePlayVoice) {
- // 因为思必驰语音分享时,语音助手会自己播报一段文字
- AIAssist.getInstance(context).speakTTSVoice("感谢分享,正在上传")
- }
+ // 上报即成功
+ ServiceApisManager.serviceApis.tanluUiApi.shareSuccess(type.eventType, type.location)
val location = ServiceApisManager.serviceApis.mapServiceApi.getSingletonLocationClient(context).lastKnowLocation
val latLon = MogoLatLng(location.latitude, location.longitude)
type.location = latLon
Logger.d("UploadHelper", "upload ----> $type")
ServiceApisManager.serviceApis.tanluApi.uploadRoadCondition(type)
- }
- } else {
- if (ServiceApisManager.serviceApis.statusManagerApi.isUploading) {
- // 上报即成功,当前还有正在上报的事件,仅做界面展示,不做具体操作
- ServiceApisManager.serviceApis.tanluUiApi.shareSuccess(type.eventType, type.location)
+ //语音播报
+ showVoiceTip(context, type.eventType)
+
} else {
- // 判断当前网络状态
- if (NetworkUtils.isConnected(context)) {
- // 有网就正常上报
- ServiceApisManager.serviceApis.statusManagerApi.setUploadingStatus("CARD_TYPE_ROAD_CONDITION", true)
- // 上报即成功
- ServiceApisManager.serviceApis.tanluUiApi.shareSuccess(type.eventType, type.location)
- val location = ServiceApisManager.serviceApis.mapServiceApi.getSingletonLocationClient(context).lastKnowLocation
- val latLon = MogoLatLng(location.latitude, location.longitude)
- type.location = latLon
- Logger.d("UploadHelper", "upload ----> $type")
- ServiceApisManager.serviceApis.tanluApi.uploadRoadCondition(type)
+ // 没网就直接提示失败
+ AIAssist.getInstance(context).speakTTSVoice("分享失败,请检查网络")
+ TipToast.tip("分享失败,请检查网络", TipDrawable(context.resources.getDrawable(R.drawable.module_share_upload_fail)))
+ }
+ }
+// }
+ }
+
+ private fun showVoiceTip(context: Context, type: String) {
+ var shareItemSum = SharedPrefsMgr.getInstance(context).getInt(KEY_CLICK_SHARE_ITEM_BUTTON, 0)
+ var intervalTime = SharedPrefsMgr.getInstance(context).getLong(KEY_CLICK_SHARE_ITEM_TIME, 0)
+ if (shareItemSum < VOICE_ALERT_COUNT) {
+ Log.d("UploadHelper", "shareItemSum = $shareItemSum --- intervalTime = $intervalTime --type = ${type}")
+ var time = System.currentTimeMillis()
+ Log.d("UploadHelper", "time = $time ")
+ if (intervalTime == 0.toLong()) {
+ SharedPrefsMgr.getInstance(context).putLong(KEY_CLICK_SHARE_ITEM_TIME, time)
+ SharedPrefsMgr.getInstance(context).putInt(KEY_CLICK_SHARE_ITEM_BUTTON, ++shareItemSum)
+ AIAssist.getInstance(context).speakTTSVoice("下次可以直接对我说 上报" + getTypeName(type))
+ } else {
+ Log.d("UploadHelper", " else interval = " + (time - intervalTime))
+ if ((time - intervalTime) > ONE_DAY_TIME) {
+ SharedPrefsMgr.getInstance(context).putLong(KEY_CLICK_SHARE_ITEM_TIME, time)
+ SharedPrefsMgr.getInstance(context).putInt(KEY_CLICK_SHARE_ITEM_BUTTON, ++shareItemSum)
+ AIAssist.getInstance(context).speakTTSVoice("下次可以直接对我说 上报" + getTypeName(type))
} else {
- // 没网就直接提示失败
- AIAssist.getInstance(context).speakTTSVoice("分享失败,请检查网络")
- TipToast.tip("分享失败,请检查网络", TipDrawable(context.resources.getDrawable(R.drawable.module_share_upload_fail)))
+ Log.e("UploadHelper", " else < ONE_DAY_TIME ")
}
}
}
}
+
+
+ private fun getTypeName(type: String): String? {
+ var typeName = ""
+ typeName = when (type) {
+ MarkerPoiTypeEnum.TRAFFIC_CHECK -> "交通检查"
+ MarkerPoiTypeEnum.ROAD_CLOSED -> "封路"
+ MarkerPoiTypeEnum.FOURS_ROAD_WORK -> "施工"
+ MarkerPoiTypeEnum.FOURS_BLOCK_UP -> "拥堵"
+ MarkerPoiTypeEnum.FOURS_PONDING -> "道路积水"
+ MarkerPoiTypeEnum.FOURS_ICE -> "道路结冰"
+ MarkerPoiTypeEnum.FOURS_FOG -> "浓雾"
+ MarkerPoiTypeEnum.FOURS_ACCIDENT -> "交通事故"
+ MarkerPoiTypeEnum.FOURS_LIVING -> "实时路况"
+ else -> "实时路况"
+ }
+ return typeName
+ }
+
}
\ No newline at end of file
diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/net/ShareApiService.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/net/ShareApiService.kt
index fb427784f0..7921527e17 100644
--- a/modules/mogo-module-share/src/main/java/com/mogo/module/share/net/ShareApiService.kt
+++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/net/ShareApiService.kt
@@ -4,7 +4,6 @@ import com.mogo.commons.data.BaseData
import com.mogo.module.share.bean.AverateSpeedResponse
import com.mogo.module.share.bean.ShareButtonConfigResponse
import io.reactivex.Observable
-import io.reactivex.Single
import okhttp3.RequestBody
import retrofit2.http.*
@@ -32,4 +31,5 @@ interface ShareApiService {
@FormUrlEncoded
@POST("/deva/car/poiType/no/poiTypeList")
fun queryShareButtonConfig(@FieldMap param: Map):Observable
+
}
\ No newline at end of file
diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/strategyreceiver/AccidentStrategyReceiver.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/strategyreceiver/AccidentStrategyReceiver.kt
index 242faf2381..987454e88b 100644
--- a/modules/mogo-module-share/src/main/java/com/mogo/module/share/strategyreceiver/AccidentStrategyReceiver.kt
+++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/strategyreceiver/AccidentStrategyReceiver.kt
@@ -6,8 +6,8 @@ import com.mogo.module.share.strategyreceiver.AccidentStrategyPushWrapper.Compan
import com.mogo.module.share.strategyreceiver.AccidentStrategyPushWrapper.Companion.TYPE_BLOCK
import com.mogo.service.IMogoServiceApis
import com.mogo.service.connection.IMogoOnMessageListener
-import com.mogo.service.tanlu.IMogoTanluProvider
-import com.mogo.service.tanlu.TanluUploadParams
+import com.mogo.service.share.IMogoTanluProvider
+import com.mogo.service.share.TanluUploadParams
import com.mogo.utils.logger.Logger
/**
diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/strategyreceiver/BlockStrategy.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/strategyreceiver/BlockStrategy.kt
index 1cc241dddc..b8ba3c7cc8 100644
--- a/modules/mogo-module-share/src/main/java/com/mogo/module/share/strategyreceiver/BlockStrategy.kt
+++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/strategyreceiver/BlockStrategy.kt
@@ -11,9 +11,8 @@ import com.mogo.module.share.constant.HttpConstant
import com.mogo.module.share.manager.ServiceApisManager
import com.mogo.module.share.net.ShareApiService
import com.mogo.service.IMogoServiceApis
-import com.mogo.service.tanlu.IMogoTanluProvider
-import com.mogo.service.tanlu.TanluUploadParams
-import com.mogo.utils.DeviceIdUtils
+import com.mogo.service.share.IMogoTanluProvider
+import com.mogo.service.share.TanluUploadParams
import com.mogo.utils.logger.Logger
import com.mogo.utils.network.RequestOptions
import com.mogo.utils.network.utils.GsonUtil
diff --git a/modules/mogo-module-share/src/main/res/values/strings.xml b/modules/mogo-module-share/src/main/res/values/strings.xml
index 94c5463011..4c1ef21f86 100644
--- a/modules/mogo-module-share/src/main/res/values/strings.xml
+++ b/modules/mogo-module-share/src/main/res/values/strings.xml
@@ -1,3 +1,4 @@
share
+
diff --git a/modules/mogo-module-tanlu/build.gradle b/modules/mogo-module-tanlu/build.gradle
index c1b444cdc9..478e05d53f 100644
--- a/modules/mogo-module-tanlu/build.gradle
+++ b/modules/mogo-module-tanlu/build.gradle
@@ -51,6 +51,8 @@ dependencies {
implementation rootProject.ext.dependencies.androidxconstraintlayout
implementation rootProject.ext.dependencies.rxjava
implementation rootProject.ext.dependencies.rxandroid
+ implementation rootProject.ext.dependencies.localbroadcastmanager
+
if (Boolean.valueOf(RELEASE)) {
compileOnly rootProject.ext.dependencies.mogomap
compileOnly rootProject.ext.dependencies.mogoutils
@@ -73,6 +75,7 @@ dependencies {
implementation rootProject.ext.dependencies.videojava
implementation rootProject.ext.dependencies.eventbus
+
// if( Boolean.valueOf(RELEASE)){
// implementation rootProject.ext.dependencies.moduletanlulib
// } else {
diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/callback/UploadShareCallback.java b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/callback/UploadShareCallback.java
index c0ae07ea7a..550b674874 100644
--- a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/callback/UploadShareCallback.java
+++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/callback/UploadShareCallback.java
@@ -5,7 +5,7 @@ import com.mogo.commons.data.BaseData;
/**
* @author lixiaopeng
- * @description 上报分享
+ * @description 上报分享 废弃
* @since 2020-01-09
*/
public interface UploadShareCallback {
diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/constant/TanluConstants.java b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/constant/TanluConstants.java
index 9f3d7c34ae..f47228a344 100644
--- a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/constant/TanluConstants.java
+++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/constant/TanluConstants.java
@@ -110,6 +110,4 @@ public class TanluConstants {
//视频播放
public static final String CARNET_USER_VIDEO_PLAY = "CarNet_user_video_play";
- public static final String LAUNCHER_MARKER_ICON_CLICK = "Launcher_Icon_Click";
-
}
diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluCardViewFragment.java b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluCardViewFragment.java
deleted file mode 100644
index 7766ac1280..0000000000
--- a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluCardViewFragment.java
+++ /dev/null
@@ -1,1713 +0,0 @@
-package com.mogo.module.tanlu.fragment;
-
-import android.content.Intent;
-import android.graphics.Bitmap;
-import android.graphics.Rect;
-import android.os.Bundle;
-import android.os.CountDownTimer;
-import android.os.Handler;
-import android.text.TextUtils;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.animation.Interpolator;
-import android.view.animation.LinearInterpolator;
-import android.widget.RelativeLayout;
-import android.widget.TextView;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.recyclerview.widget.GridLayoutManager;
-import androidx.recyclerview.widget.RecyclerView;
-
-import com.alibaba.android.arouter.launcher.ARouter;
-import com.mogo.commons.data.BaseData;
-import com.mogo.commons.mvp.IView;
-import com.mogo.commons.mvp.MvpFragment;
-import com.mogo.commons.mvp.Presenter;
-import com.mogo.commons.voice.AIAssist;
-import com.mogo.commons.voice.IMogoVoiceCmdCallBack;
-import com.mogo.map.MogoLatLng;
-import com.mogo.map.listener.IMogoMapListener;
-import com.mogo.map.location.IMogoLocationListener;
-import com.mogo.map.location.MogoLocation;
-import com.mogo.map.marker.IMogoMarker;
-import com.mogo.map.marker.IMogoMarkerClickListener;
-import com.mogo.map.marker.IMogoMarkerManager;
-import com.mogo.map.marker.MogoMarkerOptions;
-import com.mogo.map.marker.anim.OnMarkerAnimationListener;
-import com.mogo.map.model.MogoPoi;
-import com.mogo.map.navi.IMogoNaviListener;
-import com.mogo.map.navi.MogoNaviInfo;
-import com.mogo.map.navi.MogoTraffic;
-import com.mogo.map.search.geo.IMogoGeoSearch;
-import com.mogo.map.search.geo.IMogoGeoSearchListener;
-import com.mogo.map.search.geo.MogoGeocodeAddress;
-import com.mogo.map.search.geo.MogoGeocodeResult;
-import com.mogo.map.search.geo.MogoPoiItem;
-import com.mogo.map.search.geo.MogoRegeocodeResult;
-import com.mogo.map.search.geo.query.MogoGeocodeQuery;
-import com.mogo.map.search.poisearch.IMogoPoiSearch;
-import com.mogo.map.search.poisearch.IMogoPoiSearchListener;
-import com.mogo.map.search.poisearch.MogoPoiResult;
-import com.mogo.map.search.poisearch.query.MogoPoiSearchQuery;
-import com.mogo.map.uicontroller.EnumMapUI;
-import com.mogo.map.uicontroller.IMogoMapUIController;
-import com.mogo.module.common.entity.MarkerExploreWay;
-import com.mogo.module.common.entity.MarkerExploreWayItem;
-import com.mogo.module.common.entity.MarkerLocation;
-import com.mogo.module.common.entity.MarkerShowEntity;
-import com.mogo.module.common.entity.MarkerUserInfo;
-import com.mogo.module.tanlu.R;
-import com.mogo.module.tanlu.callback.DataSetChangedAdapter;
-import com.mogo.module.tanlu.callback.NaviCallback;
-import com.mogo.module.tanlu.callback.RoadLineCallback;
-import com.mogo.module.tanlu.callback.UploadShareCallback;
-import com.mogo.module.tanlu.callback.VoiceSearchCallback;
-import com.mogo.module.tanlu.constant.TanluConstants;
-import com.mogo.module.tanlu.model.Center;
-import com.mogo.module.tanlu.model.Information;
-import com.mogo.module.tanlu.model.Items;
-import com.mogo.module.tanlu.model.NaviResult;
-import com.mogo.module.tanlu.model.PathLineResult;
-import com.mogo.module.tanlu.model.TanluModelData;
-import com.mogo.module.tanlu.model.VoiceSearchResult;
-import com.mogo.module.tanlu.model.event.ControlClickUpInfo;
-import com.mogo.module.tanlu.model.event.DataErrorInfo;
-import com.mogo.module.tanlu.model.event.GetInfoError;
-import com.mogo.module.tanlu.model.event.MarkerInfo;
-import com.mogo.module.tanlu.model.event.PushTypeInfo;
-import com.mogo.module.tanlu.model.event.SharedialogEvent;
-import com.mogo.module.tanlu.model.event.StartPlayInfo;
-import com.mogo.module.tanlu.model.event.VoiceControlUpInfo;
-import com.mogo.module.tanlu.util.LocationUtils;
-import com.mogo.module.tanlu.util.Utils;
-import com.mogo.module.tanlu.view.NetErrorDialog;
-import com.mogo.module.tanlu.view.UploadFailedDialog;
-import com.mogo.service.IMogoServiceApis;
-import com.mogo.service.MogoServicePaths;
-import com.mogo.service.adas.IMogoADASController;
-import com.mogo.service.analytics.IMogoAnalytics;
-import com.mogo.service.cardmanager.IMogoCardManager;
-import com.mogo.service.datamanager.IMogoDataChangedListener;
-import com.mogo.service.fragmentmanager.IMogoFragmentManager;
-import com.mogo.service.imageloader.IMogoImageloader;
-import com.mogo.service.intent.IMogoIntentListener;
-import com.mogo.service.intent.IMogoIntentManager;
-import com.mogo.service.map.IMogoMapService;
-import com.mogo.service.module.IMogoActionListener;
-import com.mogo.service.module.IMogoActionManager;
-import com.mogo.service.module.IMogoModuleLifecycle;
-import com.mogo.service.module.IMogoRegisterCenter;
-import com.mogo.service.module.MogoAction;
-import com.mogo.service.statusmanager.IMogoStatusManager;
-import com.mogo.utils.TipToast;
-import com.mogo.utils.logger.Logger;
-import com.shuyu.gsyvideoplayer.GSYVideoManager;
-
-import org.greenrobot.eventbus.EventBus;
-import org.greenrobot.eventbus.Subscribe;
-import org.greenrobot.eventbus.ThreadMode;
-import org.json.JSONObject;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-
-import static android.view.View.OVER_SCROLL_NEVER;
-import static com.mogo.module.tanlu.video.VideoInitKt.initVideo;
-
-/**
- * @author lixiaopeng
- * @description 探路卡片
- * @since 2020-01-02
- */
-public class TanluCardViewFragment extends MvpFragment>
- implements IView,
- IMogoMarkerClickListener,
- IMogoModuleLifecycle,
- IMogoMapListener,
- IMogoPoiSearchListener,
- IMogoLocationListener,
- View.OnClickListener,
- IMogoDataChangedListener,
- IMogoGeoSearchListener {
-
- private static final String TAG = "TanluCardViewFragment";
- //map
- private IMogoMarkerManager mMarkerManager;
- private IMogoMapService mMogoMapService;
- private IMogoCardManager iMogoCardManager;
- private IMogoStatusManager mMogoStatusManager;
- private IMogoIntentManager mogoIntentManager;
- private IMogoMapUIController mMApUIController;
- private IMogoAnalytics mAnalytics;
- private IMogoGeoSearch mIMogoGeoSearch;
- private IMogoFragmentManager mIMogoFragmentManager;
- private IMogoImageloader mogoImageloader;
- private IMogoADASController mADASController;
-
- //语音上一条,下一条
- private IMogoServiceApis mIMogoServiceApis;
- private IMogoActionManager mActionManager;
-
- //声音控制文字
- private String voiceGetInfoMationTts;
- // private String[] searchingVoiceStrings;
- private String[] searchfaileVoiceStrings;
- private String voiceShareSuccessTts;
-
- private List markerExploreWayList = new ArrayList<>();
- private int mCurrentPosition = 0; //卡片媒体当前位置
- private Bitmap mMarkerIcon;
- private Bitmap multiMarkerIcon;
- private TanluModelData mTanluModelData;
- private List passedByPoints;
- private IMogoRegisterCenter mMogoRegisterCenter;
- private String mKeywords;
- private boolean isCurrentPage;
- //新修改
- private RecyclerView mLoopRecyclerView;
-// private TanluSlideAdapter mTanluSlideAdapter;
- private RelativeLayout mEmptyLayout;
- private TextView mEmptyTv;
-
-
- @Override
- protected int getLayoutId() {
- return R.layout.tanlu_main_media_recycler;
- }
-
- @Override
- protected void initViews() {
- initVideo();
- initInterface();
-
- mLoopRecyclerView = findViewById(R.id.tanlu_rloop_recycleview);
- mEmptyLayout = findViewById(R.id.layout_empty_data_show);
- mEmptyTv = findViewById(R.id.tv_main_empty);
- mEmptyTv.setOnClickListener(this);
- mEmptyLayout.setVisibility(View.VISIBLE);
- mLoopRecyclerView.setVisibility(View.GONE);
-
- mLoopRecyclerView.setHasFixedSize(true);
- mLoopRecyclerView.setOverScrollMode(OVER_SCROLL_NEVER);
- GridLayoutManager layoutManage = new GridLayoutManager(getContext(), 1);
- mLoopRecyclerView.setLayoutManager(layoutManage);
-
-// mTanluSlideAdapter = new TanluSlideAdapter(getContext(), mAnalytics);
-// mLoopRecyclerView.setAdapter(mTanluSlideAdapter);
-
- //保证滑动单页显示
-// PagerSnapHelper snapHelper = new PagerSnapHelper();
-// snapHelper.attachToRecyclerView(mLoopRecyclerView);
-
- //滑动监听
- mLoopRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
- @Override
- public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
-// super.onScrollStateChanged(recyclerView, newState);
- if (recyclerView != null && recyclerView.getChildCount() > 0) {
- try {
- int currentPositionPage = ((RecyclerView.LayoutParams) recyclerView.getChildAt(0).getLayoutParams()).getViewAdapterPosition();
- Logger.e(TAG, "fragment currentPositionPage = " + currentPositionPage + " >>> size = " + markerExploreWayList.size() + " >>mCurrentPosition = " + mCurrentPosition);
- if (currentPositionPage >= markerExploreWayList.size()) {
- return;
- }
-
- if (mCurrentPosition != currentPositionPage) {
- mCurrentPosition = currentPositionPage;
- Logger.d(TAG, "fragment-------mCurrentPosition = " + mCurrentPosition);
- moveMapLocation(mCurrentPosition);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
-
- @Override
- public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
-// super.onScrolled(recyclerView, dx, dy);
- }
- });
- }
-
- /**
- * 移动地图位置
- */
- private void moveMapLocation(int currentPositionPage) {
- Logger.d(TAG, "fragment moveMapLocation size() =" + markerExploreWayList.size() + " >>>currentPositionPage = " + currentPositionPage);
- if (markerExploreWayList.size() > currentPositionPage) {
- MarkerExploreWay exploreWay = markerExploreWayList.get(currentPositionPage);
- mActionManager.bizInvoke(TanluConstants.MODEL_NAME, currentPositionPage, markerExploreWayList.get(currentPositionPage));
- moveMapToInfoFragement(exploreWay);
- } else {
- Logger.e(TAG, "Fragment error markerExploreWayList.size() <= currentPositionPage ");
- }
- }
-
- /**
- * 移动地图到某个位置
- *
- * @param exploreWay
- */
- private void moveMapToInfoFragement(MarkerExploreWay exploreWay) {
- //经度
- Double longit = TanluServiceManager.getLocationClient().getLastKnowLocation().getLongitude();
- //纬度
- Double lat = TanluServiceManager.getLocationClient().getLastKnowLocation().getLatitude();
-
- if (exploreWay.getLocation() == null) {
- return;
- }
- double distance = LocationUtils.getDistance(lat, longit, exploreWay.getLocation().getLat(), exploreWay.getLocation().getLon());
- Logger.e(TAG, " fragment moveMapToInfoFragement distance =" + distance);
- if (distance >= 20000) {
- moveToMarcker(exploreWay.getLocation().getLat(), exploreWay.getLocation().getLon());
- } else {
- Rect rect = new Rect(
- (int) getContext().getResources().getDimension(R.dimen.tanlu_module_map_left),
- (int) getContext().getResources().getDimension(R.dimen.tanlu_module_map_top),
- (int) getContext().getResources().getDimension(R.dimen.tanlu_module_map_right),
- (int) getContext().getResources().getDimension(R.dimen.tanlu_module_map_bottom));
- Logger.d(TAG, " Fragment moveMapToInfoFragement size() = " + getList(exploreWay).size());
- moveNotFresh();
- //第一个参数:调用者,第二个参数:当前自车的位置,第三个参数:需要显示在范围内的点(不包含自车的位置)
- //第四个参数:显示范围的UI边界,第五个参数:是否锁定自车位置(看业务需要)
- mMApUIController.showBounds(TanluConstants.MODEL_NAME, new MogoLatLng(lat, longit),
- getList(exploreWay), rect, true);
- }
- }
-
- private void moveNotFresh() {
- mMogoStatusManager.setUserInteractionStatus(TAG, true, false);
- }
-
-
- /**
- * 构造经纬度列表
- *
- * @param markerExploreWay
- * @return
- */
- private List getList(MarkerExploreWay markerExploreWay) {
- List list = new ArrayList<>();
- if (markerExploreWay != null) {
- MarkerLocation location = markerExploreWay.getLocation();
- if (location != null) {
- Logger.d(TAG, "getList location.getLon() =" + location.getLon() + " >>>location.getLat()=" + location.getLat());
- MogoLatLng mogoLatLng = new MogoLatLng(location.getLat(), location.getLon());
- //经度
- Double longit = TanluServiceManager.getLocationClient().getLastKnowLocation().getLongitude();
- //维度
- Double lat = TanluServiceManager.getLocationClient().getLastKnowLocation().getLatitude();
-
- list.add(mogoLatLng);
- } else {
- Logger.e(TAG, "getList() location == null");
- }
- } else {
- Logger.e(TAG, "getList() markerExploreWay == null");
- }
- return list;
- }
-
-
- private void initInterface() {
- mIMogoServiceApis = (IMogoServiceApis) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation();
- mActionManager = mIMogoServiceApis.getActionManagerApi();
- mADASController = mIMogoServiceApis.getAdasControllerApi();
-
- //地图marker,地图操作
- mMogoMapService = (IMogoMapService) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICES_MAP).navigation(getActivity());
- mMarkerManager = mMogoMapService.getMarkerManager(getContext());
- mMApUIController = mMogoMapService.getMapUIController();
- //地图逆序
- mIMogoGeoSearch = mMogoMapService.getGeoSearch(getContext());
- mogoImageloader = (IMogoImageloader) ARouter.getInstance().build(MogoServicePaths.PATH_UTILS_IMAGE_LOADER).navigation();
- //切换卡片操作
- iMogoCardManager = (IMogoCardManager) ARouter.getInstance().build(MogoServicePaths.PATH_CARD_MANAGER).navigation(getActivity());
- mMogoRegisterCenter = (IMogoRegisterCenter) ARouter.getInstance().build(MogoServicePaths.PATH_REGISTER_CENTER).navigation(getContext());
- mMogoRegisterCenter.registerMogoModuleLifecycle(TanluConstants.MODEL_NAME, this);
- //唤醒
- mogoIntentManager = (IMogoIntentManager) ARouter.getInstance().build(MogoServicePaths.PATH_INTENT_MANAGER).navigation(getContext());
-
- mMogoStatusManager = (IMogoStatusManager) ARouter.getInstance().build(MogoServicePaths.PATH_STATUS_MANAGER).navigation(getContext());
- mAnalytics = (IMogoAnalytics) ARouter.getInstance().build(MogoServicePaths.PATH_UTILS_ANALYTICS).navigation(getContext());
-
- mIMogoFragmentManager = (IMogoFragmentManager) ARouter.getInstance().build(MogoServicePaths.PATH_FRAGMENT_MANAGER).navigation(getContext());
-
- mIMogoGeoSearch.setGeoSearchListener(this);
- DataSetChangedAdapter.getInstance().setDelegate(this);
- }
-
- @Override
- public void onActivityCreated(@Nullable Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
- getViewLifecycleOwner().getLifecycle().addObserver(mPresenter);
- EventBus.getDefault().register(this);
- initModelData();
- initMap();
- initStrings();
- initListener();
- Logger.d(TAG, "onActivityCreated ------>");
- // 数据先到,卡片后创建
- initData(DataSetChangedAdapter.getInstance().getData());
- sendShareReceiver("0");
- }
-
- private void initModelData() {
- if (mTanluModelData == null) {
- mTanluModelData = new TanluModelData(getContext());
- }
- }
-
- @Override
- public void onResume() {
- super.onResume();
- }
-
- @Override
- public void onRegeocodeSearched(MogoRegeocodeResult regeocodeResult) {
- Logger.d(TAG, "onRegeocodeSearched -----> ");
- }
-
- @Override
- public void onGeocodeSearched(MogoGeocodeResult geocodeResult) {
- Logger.d(TAG, "onGeocodeSearched ------mKeywords =" + mKeywords);
- if (geocodeResult != null) {
- if (geocodeResult.getAddresses() != null && geocodeResult.getAddresses().size() > 0) {
- Logger.d(TAG, "geocodeResult.getAddresses().size() = " + geocodeResult.getAddresses().size());
- MogoGeocodeAddress geocodeAddress = geocodeResult.getAddresses().get(0);
- MogoLatLng latLon = geocodeAddress.getLatlng();
- Double longit; //经度
- Double lat; //维度
- if (mKeywords.equals("附近")) {
- Logger.d(TAG, "附近 ----1---");
- longit = TanluServiceManager.getLocationClient().getLastKnowLocation().getLongitude();
- lat = TanluServiceManager.getLocationClient().getLastKnowLocation().getLatitude();
- } else {
- Logger.d(TAG, "其他 ---1----");
- longit = latLon.lng;
- lat = latLon.lat;
- }
- Logger.d(TAG, "geoSearch keywords =" + mKeywords + ">>longitude= " + longit + "--latitude= " + lat);
- getVoiceControlRoadData(mKeywords, lat, longit);
- } else {
- Logger.d(TAG, "onGeocodeSearched ------mKeywords =" + mKeywords);
- handlePoi(mKeywords);
- }
- } else {
- Logger.e(TAG, "geocodeResult.getAddresses() == null");
- speakFailVoice(searchfaileVoiceStrings[2]);
- }
- }
-
-
- /**
- * 初始化导航
- */
- private void initMap() {
- mMogoRegisterCenter.registerMogoNaviListener(TanluConstants.MODEL_NAME, new IMogoNaviListener() {
- @Override
- public void onInitNaviFailure() {
- }
-
- @Override
- public void onInitNaviSuccess() {
- }
-
- @Override
- public void onNaviInfoUpdate(MogoNaviInfo naviinfo) {
- }
-
- @Override
- public void onStartNavi() { //开始导航
- Logger.d(TAG, "onStartNavi ------> ");
- initModelData();
- getNavigationData();
- }
-
- @Override
- public void onStopNavi() {
- }
-
- @Override
- public void onCalculateSuccess() {
- }
-
- @Override
- public void onoCalculateFailed() {
- }
-
- @Override
- public void onUpdateTraffic(MogoTraffic traffic) {
- }
- });
-
- //监听marker点击
- mMogoRegisterCenter.registerMogoMarkerClickListener(TanluConstants.MODEL_NAME, new IMogoMarkerClickListener() {
- @Override
- public boolean onMarkerClicked(IMogoMarker marker) {
- //marker 点击
- Map properties = new HashMap<>();
- properties.put("type", "2");
- mAnalytics.track(TanluConstants.LAUNCHER_ICON_CLICK, properties);
-
- MarkerExploreWay exploreWay = extractFromMarker(marker);
- if (exploreWay == null) { // 自己打点数据
- double lat = marker.getPosition().lat;
- //更新当前位置
- for (int i = 0; i < markerExploreWayList.size(); i++) {
- if (markerExploreWayList.get(i).getLocation().getLat() == lat) {
- mCurrentPosition = i;
- break;
- }
- }
- Logger.d(TAG, "onMarkerClicked 自己打点数据 mCurrentPosition = " + mCurrentPosition + " >>size = " + markerExploreWayList.size());
- mActionManager.bizInvoke(TanluConstants.MODEL_NAME, mCurrentPosition, markerExploreWayList.get(mCurrentPosition));
- if (markerExploreWayList.size() == 1) {
- //不处理
- } else {
- mLoopRecyclerView.scrollToPosition(mCurrentPosition);
- }
- } else { //大而全数据
- double lat = exploreWay.getLocation().getLat();
- for (int i = 0; i < markerExploreWayList.size(); i++) {
- if (markerExploreWayList.get(i).getLocation().getLat() == lat) {
- mCurrentPosition = i;
- break;
- }
- }
- Logger.d(TAG, "onMarkerClicked 大而全数据 mCurrentPosition = " + mCurrentPosition + " >>size = " + markerExploreWayList.size());
- mActionManager.bizInvoke(TanluConstants.MODEL_NAME, mCurrentPosition, markerExploreWayList.get(mCurrentPosition));
- if (markerExploreWayList.size() == 1) {
- //不处理
- } else {
- mLoopRecyclerView.scrollToPosition(mCurrentPosition);
- }
- }
- return false;
- }
- });
- }
-
- /**
- * 处理关键词搜索
- *
- * @return
- */
- private void handleActionFoo(String keywords) {
- speakSearchingVoice();
- MogoGeocodeQuery geocodeQuery;
- String cityCode = TanluServiceManager.getLocationClient().getLastKnowLocation().getCityCode();
-
- geocodeQuery = new MogoGeocodeQuery();
- geocodeQuery.setLocationName(keywords);
- geocodeQuery.setCity(cityCode);
- mIMogoGeoSearch.getFromLocationNameAsyn(geocodeQuery);
- }
-
- /**
- * poi 搜索
- *
- * @param keywords
- */
- private void handlePoi(String keywords) {
- String cityCode = TanluServiceManager.getLocationClient().getLastKnowLocation().getCityCode();
- MogoPoiSearchQuery poiSearchQuery = new MogoPoiSearchQuery(keywords, "", cityCode);
- IMogoPoiSearch poiSearch = mMogoMapService.getPoiSearch(getContext(), poiSearchQuery);
- poiSearch.setPoiSearchListener(this);
- poiSearch.searchPOIAsyn();
- }
-
- /**
- * 注册listener监听
- */
- private void initListener() {
- mogoIntentManager.registerIntentListener(TanluConstants.SPECIFIEDROAD_SEARCH, mogoIntentListener);
- mogoIntentManager.registerIntentListener(TanluConstants.PLAY_VIDEO_AWAKEN, mogoIntentListener);
- }
-
- /**
- * 唤醒语音
- */
- private IMogoIntentListener mogoIntentListener = new IMogoIntentListener() {
- @Override
- public void onIntentReceived(String intentStr, Intent intent) {
- String data = intent.getStringExtra("data");
- Logger.d(TAG, "唤醒 mogoIntentListener intentStr =" + intentStr + ">>data =" + data);
- if (intentStr.equals(TanluConstants.SPECIFIEDROAD_SEARCH)) { //地点堵不堵 --ok
- try {
- JSONObject jsonObject = new JSONObject(data);
- mKeywords = jsonObject.get("location").toString();
- Logger.d(TAG, "mogoIntentListener specified mKeywords = " + mKeywords);
- handleActionFoo(mKeywords);
- } catch (Exception e) {
- e.printStackTrace();
- }
- } else if (intentStr.equals(TanluConstants.PLAY_VIDEO_AWAKEN)) { //播放路况 唤醒
- Logger.d(TAG, "mogoIntentListener 播放路况 唤醒 ----> ");
- delayTime();
- }
- }
- };
-
-
- /**
- * 免唤醒语音监听
- */
- private IMogoVoiceCmdCallBack mogoVoiceListener = new IMogoVoiceCmdCallBack() {
- @Override
- public void onCmdSelected(String cmd) {
- Logger.d(TAG, "mogoVoiceListener cmd = " + cmd);
- if (cmd.equals(TanluConstants.PLAY_VIDEO)) { //播放路况 --ok
- //语音会中断播放
- AIAssist.getInstance(getContext()).speakTTSVoice(getString(R.string.tanlu_prepare_play), null);
- delayTime();
- }
- }
-
- @Override
- public void onCmdAction(String speakText) {
- }
-
- @Override
- public void onCmdCancel(String speakText) {
- }
-
- @Override
- public void onSpeakEnd(String speakText) {
- }
-
- @Override
- public void onSpeakSelectTimeOut(String speakText) {
- }
- };
-
-
- /**
- * 上一条,下一条
- */
- private IMogoActionListener mogoActionListener = new IMogoActionListener() {
- @Override
- public void onActionDone(MogoAction mogoAction) {
- Logger.d(TAG, "mogoActionListener mogoAction = " + mogoAction);
- if (mogoAction == MogoAction.Prev) {
- EventBus.getDefault().post(new VoiceControlUpInfo("1"));
- } else if (mogoAction == MogoAction.Next) {
- EventBus.getDefault().post(new VoiceControlUpInfo("2"));
- }
- }
- };
-
-
- private void delayTime() {
- new Handler().postDelayed(new Runnable() {
- public void run() {
- EventBus.getDefault().post(new StartPlayInfo(mCurrentPosition));
- }
- }, 1500);
- }
-
- /**
- * type=1 路况
- * type=2 油价
- * type=3 交通检查
- * type=4 封路
- *
- * @param type
- */
- private void traceTypeData(String type) {
- Map properties = new HashMap<>();
- properties.put("type", type);
- mAnalytics.track(TanluConstants.LAUNCHER_SHARE_TYPE, properties);
- }
-
- /**
- * 分享/上报按钮点击 from=1 手动点击 from=2 语音打开
- *
- * @param from
- */
- private void traceData(String from) {
- Map properties = new HashMap<>();
- properties.put("from", from);
- mAnalytics.track(TanluConstants.LAUNCHER_SHARE_CLICK, properties);
- }
-
- private void traceTanluData(String type) {
- Map properties = new HashMap<>();
- properties.put("type", type);
- mAnalytics.track(TanluConstants.CARNET_USER_UPLOAD, properties);
- }
-
- /**
- * 发送广播 audiofocus
- */
- private void sendAudioFocusReceiver() {
- Logger.d(TAG, "TanluCardViewFragment sendAudioFocusReceiver ---->");
- Intent intent = new Intent();
- intent.setAction("com.zhidao.action.audio.package");
- intent.putExtra("package", "com.mogo.module.tanlu");
- getContext().sendBroadcast(intent);
- }
-
- /**
- * 发送广播 type: 1拥堵,2交通检查,3封路,4实时路况,5积水,6积冰,7大雾,8事故
- */
- private void sendShareReceiver(String type) {
- if (!type.equals("0")) {
- mMogoStatusManager.setUploadingStatus("CARD_TYPE_ROAD_CONDITION", true);
- }
-
- Logger.d(TAG, "TanluCardViewFragment sendShareReceiver ---->");
- Intent intent = new Intent();
- intent.setAction("com.zhidao.share.roadcondition.action");
- intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
- intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
- intent.putExtra("type", type);
- getContext().sendBroadcast(intent);
- }
-
-
- private MarkerExploreWay extractFromMarker(IMogoMarker marker) {
- if (marker == null) {
- return null;
- }
- if (marker.getObject() instanceof MarkerShowEntity) {
- MarkerShowEntity showEntity = ((MarkerShowEntity) marker.getObject());
- if (showEntity.getBindObj() instanceof MarkerExploreWay) {
- return ((MarkerExploreWay) showEntity.getBindObj());
- }
- }
-
- return null;
- }
-
- /**
- * @param view
- */
- @Override
- public void onClick(View view) {
- int id = view.getId();
- if (id == R.id.tv_main_empty) { //上报路况
- sendShareReceiver("1");
- }
- }
-
- private void moveToMarcker(double lat, double lon) {
- MogoLatLng latLng = new MogoLatLng(lat, lon);
- mMogoStatusManager.setUserInteractionStatus(TAG, true, false);
- mMApUIController.moveToCenter(latLng);
- }
-
- /**
- * marker点击事件
- *
- * @param marker
- * @return
- */
- @Override
- public boolean onMarkerClicked(IMogoMarker marker) {
- return true;
- }
-
- @NonNull
- @Override
- protected Presenter createPresenter() {
- return new Presenter(this) {
- };
- }
-
- /**
- * C位事件,如何获取数据,需要有默认数据
- * 如果只有一个数据,不显示上下切换按钮,没有数据显示空页面
- */
- @Override
- public void onPerform() {
- //免唤醒
- AIAssist.getInstance(getActivity()).registerUnWakeupCommand(TanluConstants.PLAY_VIDEO,
- TanluConstants.CMD_PLAY_ROAD_CONDITION, mogoVoiceListener);
- mActionManager.registerActionListener(TanluConstants.MODEL_NAME, mogoActionListener);
-
- isCurrentPage = true;
- Logger.d(TAG, "tanlu卡片 onPerform 有效 ---->");
- new Handler().postDelayed(new Runnable() {
- public void run() {
- renderCardViews();
- }
- }, 500);
- }
-
- /**
- * 根据数据展示页面
- */
- private void renderCardViews() {
- if (markerExploreWayList != null && markerExploreWayList.size() > 0) {
- mEmptyLayout.setVisibility(View.GONE);
- mLoopRecyclerView.setVisibility(View.VISIBLE);
- Logger.d(TAG, "renderCardViews size = " + markerExploreWayList.size());
-// mTanluSlideAdapter.setDatas(markerExploreWayList);
-// mTanluSlideAdapter.notifyDataSetChanged();
- } else {
- mLoopRecyclerView.setVisibility(View.GONE);
- mEmptyLayout.setVisibility(View.VISIBLE);
-// mEmptyTv.setText(Html.fromHtml(getContext().getString(R.string.main_empty_content)));
- Logger.e(TAG, "renderCardViews markerExploreWayList == null ");
- }
- }
-
- @Override
- public void onDataSetChanged(Object data) {
- Logger.d(TAG, "receive data changed. isCurrentPage = " + isCurrentPage);
- initData(data);
- if (isCurrentPage) { //更新数据
- Logger.d(TAG, "receive data changed 111 -------> ");
- renderCardViews();
- }
- }
-
- private void initData(Object data) {
- if (markerExploreWayList != null) {
- markerExploreWayList.clear();
- } else {
- markerExploreWayList = new ArrayList<>();
- }
- try {
- markerExploreWayList.addAll((List) data);
- Logger.d(TAG, "initData size = " + markerExploreWayList.size());
- } catch (Exception e) {
- Logger.e(TAG, e, "error.");
- }
- }
-
- /**
- * 离开C位事件
- */
- @Override
- public void onDisable() {
- Logger.d(TAG, "tanlu卡片 无效 ----->");
- isCurrentPage = false;
-
- AIAssist.getInstance(getActivity()).unregisterUnWakeupCommand(TanluConstants.PLAY_VIDEO);
- if (mActionManager != null) {
- mActionManager.unregisterActionListener(TanluConstants.MODEL_NAME, mogoActionListener);
- }
- }
-
- @Override
- public void accOn() {
-
- }
-
- @Override
- public void onMapLoaded() {
- }
-
- @Override
- public void onTouch(MotionEvent motionEvent) {
- }
-
- @Override
- public void onPOIClick(MogoPoi poi) {
- if (poi != null) {
- TipToast.shortTip(poi.getName());
- TanluServiceManager.getPoiSearch().searchPOIIdAsyn(poi.getPoiId());
- }
- }
-
- /**
- * poi
- *
- * @param p0
- * @param p1
- */
- @Override
- public void onPoiSearched(MogoPoiResult p0, int p1) {
- if (p1 == 1000) {
- if (p0.getPois() != null && p0.getPois().size() > 0) {
- MogoPoiItem poi = p0.getPois().get(0);
- MogoLatLng latLon = poi.getPoint();
- Double longit; //经度
- Double lat; //维度
- if (mKeywords.equals("附近")) {
- Logger.d(TAG, "附近 -onPoiSearched---1---");
- longit = TanluServiceManager.getLocationClient().getLastKnowLocation().getLongitude();
- lat = TanluServiceManager.getLocationClient().getLastKnowLocation().getLatitude();
- } else {
- Logger.d(TAG, "其他 -onPoiSearched---1----");
- longit = latLon.lng;
- lat = latLon.lat;
- }
- getVoiceControlRoadData(mKeywords, lat, longit);
- Logger.d(TAG, "setOnPoiSearchListener keywords =" + mKeywords + ">>longitude= " + longit + "--latitude" + lat);
- } else {
- Logger.e(TAG, "poi == null");
- Double longit; //经度
- Double lat; //维度
- if (mKeywords.equals("附近")) {
- Logger.d(TAG, "附近 -onPoiSearched---2---");
- longit = TanluServiceManager.getLocationClient().getLastKnowLocation().getLongitude();
- lat = TanluServiceManager.getLocationClient().getLastKnowLocation().getLatitude();
- getVoiceControlRoadData(mKeywords, lat, longit);
- } else {
- Logger.d(TAG, "其他 -onPoiSearched---2----");
- speakFailVoice(searchfaileVoiceStrings[2]);
- }
- }
- } else {
- Logger.e(TAG, "poi search result p1 = " + p1);
- speakFailVoice(searchfaileVoiceStrings[2]);
- }
- }
-
- @Override
- public void onPoiItemSearched(MogoPoiItem item, int errorCode) {
- if (item == null) {
- return;
- }
- }
-
- @Override
- public void onLocationChanged(MogoLocation location) {
- }
-
- @Override
- public void onMapClick(MogoLatLng latLng) {
-
- }
-
- @Override
- public void onLockMap(boolean isLock) {
-
- }
-
- @Override
- public void onMapModeChanged(EnumMapUI ui) {
- Logger.d(TAG, ui.name());
- }
-
- @Override
- public void onMapChanged(MogoLatLng location, float zoom, float tilt, float bearing) {
-
- }
-
- @Override
- public void onDestroyView() {
- super.onDestroyView();
- EventBus.getDefault().unregister(this);
- getViewLifecycleOwner().getLifecycle().removeObserver(mPresenter);
- TanluServiceManager.getLocationClient().removeLocationListener(this);
- mMogoRegisterCenter.unregisterMogoNaviListener(TanluConstants.MODEL_NAME);
- Logger.d(TAG, "onDestroyView --------> ");
- GSYVideoManager.releaseAllVideos();
-// if (mTanluSlideAdapter != null) {
-// mTanluSlideAdapter.release();
-// }
- }
-
- /**
- * 列表滑动位置
- *
- * @param event
- */
- @Subscribe(threadMode = ThreadMode.MAIN)
- public void onButtonUpAndDown(final ControlClickUpInfo event) {
- if (event != null) {
- Logger.d(TAG, " onButtonUpAndDown event.type = " + event.type + " >>>mCurrentPosition = " + mCurrentPosition);
- if (event.type.equals("1")) { //上一条
- if (mCurrentPosition > 0) {
- mLoopRecyclerView.smoothScrollToPosition(mCurrentPosition - 1);
- } else {
- Logger.e(TAG, " onButtonUpAndDown 上一条 mCurrentPosition <= 0 ");
- TipToast.shortTip("已经是第一条");
- }
- } else if (event.type.equals("2")) { //下一条
- if (mCurrentPosition >= (markerExploreWayList.size() - 1)) {
- TipToast.shortTip("已经是最后一条");
- Logger.e(TAG, " onButtonUpAndDown 下一条 mCurrentPosition >= markerExploreWayList.size() - 1");
- } else {
- mLoopRecyclerView.smoothScrollToPosition(mCurrentPosition + 1);
- }
- }
- } else {
- Logger.e(TAG, "onButtonUpAndDown event == null ");
- }
- }
-
- /**
- * 接收到错误数据信息
- *
- * @param event
- */
- @Subscribe(threadMode = ThreadMode.MAIN)
- public void onDataErrorInfo(final DataErrorInfo event) {
- if (event == null) {
- return;
- }
- Logger.d(TAG, " onDataErrorInfo id = " + event.id + " >>>poiType = " + event.poiType + ">>>updateType = " + event.updateType);
- mTanluModelData.uploadDeleteErrorDataInfo(event.id, event.poiType, event.updateType,
- new UploadShareCallback() {
- @Override
- public void onSuccess(BaseData data) {
- Logger.d(TAG, "uploadDeleteErrorDataInfo onSuccess -----> ");
- }
-
- @Override
- public void onFail(String message, int code) {
- Logger.e(TAG, "uploadDeleteErrorDataInfo onFail -----> message = " + message);
- }
- });
- }
-
- /**
- * 分享弹框
- *
- * @param event
- */
- @Subscribe(threadMode = ThreadMode.MAIN)
- public void onShareDialog(final SharedialogEvent event) {
- if (event == null) {
- return;
- }
-
- if (mADASController != null) {
- mADASController.closeADAS();
- }
-// ShareControl.getInstance(getActivity()).showDialog();
- }
-
- /**
- * 获取情报失败
- */
- @Subscribe(threadMode = ThreadMode.MAIN)
- public void onGetInfoFailed(final GetInfoError error) {
- mMogoStatusManager.setUploadingStatus(TanluConstants.MODEL_NAME, false);
- float bearing = TanluServiceManager.getLocationClient().getLastKnowLocation().getBearing(); //角度
- Logger.d(TAG, "onGetInfoFailed bearing = " + bearing + " >>>type = " + error.type);
- //失败提示框
- if (error == null) {
- return;
- }
-
- if (error.type == null) {
- return;
- }
-
- mErrorType = error.type;
- if (error.type.equals("100")) {
- //网络弹框
- if (errorDialog != null && errorDialog.isShowing()) {
- //TODO
- } else {
- showNetErrorDialog();
- }
- } else {
- if (customDialog != null && customDialog.isShowing()) {
- //TODO
- } else {
- showNormalDialog(error.type);
- }
- }
- }
-
- private UploadFailedDialog customDialog;
- private NetErrorDialog errorDialog;
- private String mErrorType;
-
-
- private void showNormalDialog(final String type) {
- customDialog = new UploadFailedDialog(getActivity());
- customDialog.setContent("抱歉,无法获取到相关数据");
- customDialog.setSubContent("分享失败");
- customDialog.setOnCancelListener("取消", new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- timer.cancel(); //取消倒计时
- }
- });
- customDialog.setOnOkClickListener("重新分享", new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Logger.d(TAG, "重新分享 --------->");
- //发送广播 type:1拥堵,2交通检查,3封路
- sendShareReceiver(type);
- }
- });
- customDialog.show();
- timer.start();
- }
-
- private void showNetErrorDialog() {
- errorDialog = new NetErrorDialog(getActivity());
- errorDialog.setContent("由于网络原因上传失败");
- errorDialog.setSubContent("系统将在网络恢复时自动上传");
- errorDialog.setOnCancelListener("好的", new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- timer.cancel();
- }
- });
- errorDialog.show();
- timer.start();
- }
-
- /**
- * 倒计时
- */
- CountDownTimer timer = new CountDownTimer(11000, 1000) {
- @Override
- public void onTick(long arg) {
- int theTime = (int) (arg / 1000);
- if (mErrorType.equals("100")) { //无网
- if (errorDialog != null) {
- errorDialog.getTxtCancel().setText(getString(R.string.tanlu_neterror_cancle_time, theTime + ""));
- }
- } else {
- if (customDialog != null) {
- customDialog.getTxtCancel().setText(getString(R.string.tanlu_cancle_time, theTime + ""));
- }
- }
- }
-
- @Override
- public void onFinish() {
- if (mErrorType.equals("100")) { //无网
- if (errorDialog != null) {
- errorDialog.dismiss();
- }
- } else {
- if (customDialog != null) {
- customDialog.dismiss();
- }
- }
- }
- };
-
-
- /**
- * 接收到分享对应数据打点
- *
- * @param event
- */
- @Subscribe(threadMode = ThreadMode.MAIN)
- public void onMarkerInfo(final MarkerInfo event) {
- if (event == null) {
- return;
- }
- Logger.d(TAG, "onMarkerInfo event.type =" + event.type + " >>event.lat = " + event.lat + " >>event.lon = " + event.lon + " >>event.imageUrl =" + event.imageUrl);
-
- String poiType = "";
-// if (event.type.equals(TanluConstants.TANLU_ROAD_CONGESTION_COMPAT)) { //上报路况
-// poiType = "100";
-// mMarkerIcon = BitmapFactory.decodeResource(getResources(), R.drawable.tanlu_marker_block_up);
-// } else {
-// poiType = "-1";
-// }
-
- double lat = TanluServiceManager.getLocationClient().getLastKnowLocation().getLatitude();
- double lon = TanluServiceManager.getLocationClient().getLastKnowLocation().getLongitude();
- Logger.d(TAG, "onMarkerInfo share onCompleted ---poiType =" + poiType);
- if (!poiType.equals("-1")) {
- Logger.d(TAG, "onMarkerInfo share onCompleted ---!poiType------->");
- MogoMarkerOptions options = new MogoMarkerOptions()
- .icon(mMarkerIcon)
- .latitude(lat) //event.lat
- .owner("share_tag")
- .longitude(lon); //event.lon
- final IMogoMarker mogoMarker = mMarkerManager.addMarker("share_tag", options); //随便传tag,不可点击 share_tag TanluConstants.MODEL_NAME
- Logger.d(TAG, "getMathRandom() = " + getMathRandom());
- AIAssist.getInstance(getContext()).speakTTSVoice((
- String.format(voiceShareSuccessTts, getMathRandom())), null);
-// ShareControl.getInstance(getActivity()).dismissDialog();
-
- //开启动画
- mogoMarker.startScaleAnimation(0, 1, 0, 1, 300, new LinearInterpolator(), new OnMarkerAnimationListener() {
- @Override
- public void onAnimStart() {
- Logger.d(TAG, " onAnimStart ---1----> ");
- }
-
- @Override
- public void onAnimEnd() {
- Logger.d(TAG, " onAnimEnd -----1---> ");
- showJumpAnimation(mogoMarker);
- }
- });
- } else {
- Logger.d(TAG, "onMarkerInfo share onCompleted ---!poiType--- else ---->");
- }
-
- mMogoStatusManager.setUploadingStatus(TanluConstants.MODEL_NAME, false);
-
- //请求分享接口,只有封路和交通检查走新接口,老接口只有上报拥堵使用,并且定时任务都是拥堵的type
- if (poiType.equals("100") || poiType.equals("-1")) {
- Logger.d(TAG, "poiType = 100 || -1 ");
- } else {
- if (markerExploreWayList != null && markerExploreWayList.size() > 0) {
- MarkerExploreWay markerExploreWay = markerExploreWayList.get(0);
- if (markerExploreWay.getUserInfo() != null && !TextUtils.isEmpty(poiType)) { //上报路况不使用这个接口
- uploadShareInfo(poiType, event.imageUrl, markerExploreWay.getUserInfo().getUserName(),
- markerExploreWay.getUserInfo().getUserHead());
- } else {
- Logger.e(TAG, "onMarkerInfo markerExploreWay.getUserInfo() == null");
- uploadShareInfo(poiType, event.imageUrl, "", "");
- }
- } else {
- Logger.e(TAG, "onMarkerInfo share markerExploreWayList = null");
- uploadShareInfo(poiType, event.imageUrl, "", "");
- }
- }
- }
-
- private void showJumpAnimation(final IMogoMarker mogoMarker) {
- if (mogoMarker == null) {
- return;
- }
-
- mogoMarker.startJumpAnimation(80, 300, new Interpolator() {
- @Override
- public float getInterpolation(float input) {
- if (input <= 0.5) {
- return (float) (0.5f - 2.0 * (0.5 - input) * (0.5 - input));
- } else {
- return (float) (0.5f - Math.sqrt(input - 0.5f) * (1.5f - input));
- }
- }
- }, new OnMarkerAnimationListener() {
- @Override
- public void onAnimStart() {
-// Logger.d(TAG, " onAnimStart ----2--> ");
- }
-
- @Override
- public void onAnimEnd() {
-// Logger.d(TAG, " onAnimEnd ----2--> ");
- }
- });
- }
-
-
- /**
- * 上报分享信息
- */
- private void uploadShareInfo(final String poiType, String poiImgUrl, String nickname, String headImgUrl) {
- double lat = TanluServiceManager.getLocationClient().getLastKnowLocation().getLatitude();
- double lon = TanluServiceManager.getLocationClient().getLastKnowLocation().getLongitude();
- float bearing = TanluServiceManager.getLocationClient().getLastKnowLocation().getBearing(); //角度
-
- String addressStr = TanluServiceManager.getLocationClient().getLastKnowLocation().getAddress();
- Logger.d(TAG, "uploadShareInfo lat =" + lat + ">>>lon =" + lon + ">>>addressStr =" + addressStr + " >>bearing =" + bearing);
- mTanluModelData.addTrafficCheckInfo(poiType, poiImgUrl, nickname, headImgUrl, lat, lon, addressStr, bearing,
- new UploadShareCallback() {
- @Override
- public void onSuccess(BaseData data) {
- Logger.d(TAG, "uploadShareInfo onSuccess -----> poiType = " + poiType);
- }
-
- @Override
- public void onFail(String message, int code) {
- Logger.e(TAG, "uploadShareInfo onFail -----> poiType = " + poiType);
- }
- });
- }
-
-
- /**
- * push 类型,1为导航数据,2为通勤族
- *
- * @param event
- */
- @Subscribe(threadMode = ThreadMode.MAIN)
- public void onPushInfo(final PushTypeInfo event) {
- if (event != null && TextUtils.isEmpty(event.type)) {
- Logger.d(TAG, " onPushInfo event.type =" + event.type);
- if (event.type.equals("1")) {
- getNaviRoadLineInfo();
- } else if (event.type.equals("2")) {
- getRoadLineData();
- }
- } else {
- Logger.e(TAG, "event == null ");
- }
- }
-
-
- /**
- * 导航路线数据事件
- */
- public void getNavigationData() {
- if (mADASController != null) {
- mADASController.closeADAS();
- }
-
- mTanluModelData.getNaviInformation(mMogoMapService.getNavi(getContext()).getCalculatedPathPos(),
- new NaviCallback() {
- @Override
- public void onSuccess(NaviResult data) {
- List informationList = data.getResult().getInformations();
- Logger.d(TAG, "getNavigationData onSuccess informationList =" + informationList);
- if (informationList == null || (informationList != null && informationList.size() == 0)) {
- return;
- }
-
- if (markerExploreWayList != null && markerExploreWayList.size() > 0) {
- markerExploreWayList.clear(); //刷新之前先删除之前的,然后再添加成请求的
- mCurrentPosition = 0;
- }
-
- //转换数据结构
- convertData(informationList);
- //切换到探路卡片
- if (!isCurrentPage) {
- iMogoCardManager.switch2(TanluConstants.MODEL_NAME);
- }
-
- //清除探路之前的数据
- mMarkerManager.removeMarkers(TanluConstants.MODEL_NAME);
-
- //打点
- ArrayList optionList = new ArrayList<>();
- for (int i = 0; i < informationList.size(); i++) {
- //根据type确定添加的图片
- String trafficType = informationList.get(i).trafficInfoType;
-// if (trafficType.equals("traffic_jam")) { //拥堵
-// multiMarkerIcon = BitmapFactory.decodeResource(getResources(), R.drawable.tanlu_marker_block_up);
-// }
-
- MarkerShowEntity markerShowEntity = new MarkerShowEntity();
- markerShowEntity.setBindObj(markerExploreWayList.get(i));
- markerShowEntity.setTextContent(informationList.get(i).addr);
- markerShowEntity.setMarkerType(TanluConstants.MODEL_NAME);
- MogoMarkerOptions options = new MogoMarkerOptions()
- .object(markerShowEntity)
- .icon(multiMarkerIcon)
- .latitude(informationList.get(i).lat)
- .owner(TanluConstants.MODEL_NAME)
- .longitude(informationList.get(i).lon);
-
- optionList.add(options);
- mMarkerManager.addMarker(TanluConstants.MODEL_NAME, options);
- }
- Logger.d(TAG, "getNavigationData optionList.size() = " + optionList.size());
-// mMarkerManager.addMarkers(TanluConstants.MODEL_NAME, optionList, true);
-
- mLoopRecyclerView.scrollToPosition(0);
-
- //播报
-// speakFailVoice(getString(R.string.tanlu_navi_voice_play));
-
- //自身位置和第一个情报自适应显示
- Rect rect = new Rect(
- (int) getContext().getResources().getDimension(R.dimen.tanlu_module_map_left),
- (int) getContext().getResources().getDimension(R.dimen.tanlu_module_map_top),
- (int) getContext().getResources().getDimension(R.dimen.tanlu_module_map_right),
- (int) getContext().getResources().getDimension(R.dimen.tanlu_module_map_bottom));
-
- mMogoStatusManager.setUserInteractionStatus(TAG, true, true);
- //经度
- Double longit = TanluServiceManager.getLocationClient().getLastKnowLocation().getLongitude();
- //纬度
- Double lat = TanluServiceManager.getLocationClient().getLastKnowLocation().getLatitude();
- //第一个参数:调用者,第二个参数:当前自车的位置,第三个参数:需要显示在范围内的点(不包含自车的位置)
- //第四个参数:显示范围的UI边界,第五个参数:是否锁定自车位置(看业务需要)
- if (markerExploreWayList.size() > 0) {
- mMApUIController.showBounds(TanluConstants.MODEL_NAME, new MogoLatLng(lat, longit),
- getList(markerExploreWayList.get(0)), rect, true);
- }
- }
-
- @Override
- public void onFail(String message, int code) {
- Logger.d(TAG, "getNavigationData message = " + message + ">>>code =" + code);
- }
- });
- }
-
- /**
- * 通勤族 事件,监听消息自己请求路线数据
- */
- public void getRoadLineData() {
- mTanluModelData.getRoadLineData(new RoadLineCallback() {
- @Override
- public void onSuccess(PathLineResult o) {
- //绘制线路线
- if (o != null && o.getResult() != null && o.getResult().getPointList() != null
- && o.getResult().getPointList().size() > 0) {
- drawMapLine(o.getResult().getPointList());
- } else {
- Logger.e(TAG, "getRoadLineData onSuccess o.getPointList() == null");
- }
- }
-
- @Override
- public void onFail(String message, int code) {
- Logger.e(TAG, "getRoadLineData onFail message =" + message + ">>>code =" + code);
- }
- });
- }
-
- /**
- * 导航路线,监听消息自己请求路线数据
- */
- public void getNaviRoadLineInfo() {
- mTanluModelData.getNaviRoadLineInfo(new RoadLineCallback() {
- @Override
- public void onSuccess(PathLineResult o) {
- //绘制线路线
- if (o != null && o.getResult() != null && o.getResult().getPointList() != null
- && o.getResult().getPointList().size() > 0) {
- drawMapLine(o.getResult().getPointList());
- } else {
- Logger.e(TAG, "getNaviRoadLineInfo onSuccess o.getPointList() == null");
- }
- }
-
- @Override
- public void onFail(String message, int code) {
- Logger.e(TAG, "getNaviRoadLineInfo onFail message =" + message + ">>>code =" + code);
- }
- });
- }
-
- /**
- * 绘制线路
- */
- private void drawMapLine(List pointList) {
- //避免人为操作,刷新
- mMogoStatusManager.setUserInteractionStatus(TanluConstants.MODEL_NAME, true, true);
-
- int intervalNum = Utils.getIntervalValue(pointList.size());
- Logger.d(TAG, "drawMapLine intervalNum = " + intervalNum + ">>> pointList.size =" + pointList.size());
- int listSize = pointList.size();
- passedByPoints = new ArrayList<>();
-
- //沿途最多15个点
- for (int i = 0; i < listSize; i += intervalNum) {
- passedByPoints.add(new MogoLatLng(pointList.get(i).getLat(), (pointList.get(i).getLon())));
- }
-
- Logger.d(TAG, "drawMapLine passedByPoints.size() ----> " + passedByPoints.size());
- MogoLatLng startLatLng = new MogoLatLng(pointList.get(0).getLat(), pointList.get(0).getLon());
- MogoLatLng endLatLng = new MogoLatLng(pointList.get(listSize - 1).getLat(), pointList.get(listSize - 1).getLon());
- mMarkerManager.addRouteWay(getContext(), startLatLng, endLatLng, passedByPoints);
- }
-
-
- /**
- * 声音控制道路数据
- */
- public void getVoiceControlRoadData(String keywords, final double lat, final double lon) {
- if (mADASController != null) {
- mADASController.closeADAS();
- }
-
- String adCode = TanluServiceManager.getLocationClient().getLastKnowLocation().getAdCode();
- String cityCode = TanluServiceManager.getLocationClient().getLastKnowLocation().getCityCode();
- //移动到具体位置
- mMogoStatusManager.setUserInteractionStatus(TanluConstants.MODEL_NAME, true, true);
- moveToMarcker(lat, lon);
-
- inputlon = lon;
- inputlat = lat;
-
- if (mIMogoFragmentManager.getStackSize() > 0) {
- mIMogoFragmentManager.clearAll();
- }
-
- Logger.d(TAG, "getVoiceControlRoadData lat =" + lat + ">>>lon =" + lon + ">>>cityCode= " + cityCode + " >>>adCode = " + adCode);
- mTanluModelData.getVoiceControlRoadData(keywords, cityCode, lon, lat, adCode, new VoiceSearchCallback() {
- @Override
- public void onSuccess(VoiceSearchResult o) {
- String discription = o.getResult().getDescription();
- Logger.d(TAG, "getVoiceControlRoadData onSuccess ----1--->");
- if (o.getResult().getInformations() != null && o.getResult().getInformations().size() > 0) {
- Logger.d(TAG, "getVoiceControlRoadData onSuccess ----2--->");
- if (markerExploreWayList != null && markerExploreWayList.size() > 0) {
- markerExploreWayList.clear(); //刷新之前先删除之前的,然后再添加成请求的
- mCurrentPosition = 0;
- }
-
- //转换数据结构
- convertData(o.getResult().getInformations());
- //切换到探路卡片
- if (!isCurrentPage) {
- iMogoCardManager.switch2(TanluConstants.MODEL_NAME);
- }
-
- speakSuccessVoice(o.getResult().getInformations(), discription == null ? "" : discription);
-
- List informationList = o.getResult().getInformations();
- Logger.d(TAG, "getVoiceControlRoadData onSuccess informationList =" + informationList);
- if (informationList == null || (informationList != null && informationList.size() == 0)) {
- return;
- }
- //清除探路之前的数据
- mMarkerManager.removeMarkers(TanluConstants.MODEL_NAME);
- //添加埋点数据
- datalon = informationList.get(0).lon;
- datalat = informationList.get(0).lat;
-
- //打点
- ArrayList optionList = new ArrayList<>();
- for (int i = 0; i < informationList.size(); i++) {
- //根据type确定添加的图片
- String trafficType = informationList.get(i).trafficInfoType;
-
- MarkerShowEntity markerShowEntity = new MarkerShowEntity();
- markerShowEntity.setBindObj(markerExploreWayList.get(i));
- markerShowEntity.setTextContent(informationList.get(i).addr);
- markerShowEntity.setMarkerType(TanluConstants.MODEL_NAME);
- MogoMarkerOptions options = new MogoMarkerOptions()
- .object(markerShowEntity)
- .icon(multiMarkerIcon)
- .latitude(informationList.get(i).lat)
- .owner(TanluConstants.MODEL_NAME)
- .longitude(informationList.get(i).lon);
-
-// optionList.add(options);
- mMarkerManager.addMarker(TanluConstants.MODEL_NAME, options);
- }
- Logger.d(TAG, "getVoiceControlRoadData optionList.size() = " + optionList.size());
- mMogoStatusManager.setUserInteractionStatus(TanluConstants.MODEL_NAME, true, true);
-// mMarkerManager.addMarkers(TanluConstants.MODEL_NAME, optionList, true);
-
- //展示6个在区域内显示
- showBonndsRoadtion();
-
- //直接使用当前数据list,作为切换的数据源,切换左侧列表到最新的数据
- mLoopRecyclerView.scrollToPosition(0);
- } else {
- if (!TextUtils.isEmpty(discription)) {
- Logger.d(TAG, "getVoiceControlRoadData discription != null else ----1--->");
- AIAssist.getInstance(getContext()).speakTTSVoice(discription, null);
- } else {
- Logger.d(TAG, "getVoiceControlRoadData discription == null else ----2--->");
-// AIAssist.getInstance(getContext()).speakTTSVoice("未找到其他车主分享的路况信息", null);
- }
- }
- }
-
- @Override
- public void onFail(String message, int code) {
- Logger.e(TAG, "getVoiceControlRoadData onFail message = " + message + ">>>code= " + code);
- speakFailVoice(searchfaileVoiceStrings[2]);
- }
- });
- }
-
-
- private void showBonndsRoadtion() {
- Logger.e(TAG, "showBonndsRoadtion getMogoList markerExploreWayList.size() = " + markerExploreWayList.size());
- //经度
- Double longit = TanluServiceManager.getLocationClient().getLastKnowLocation().getLongitude();
- //纬度
- Double lat = TanluServiceManager.getLocationClient().getLastKnowLocation().getLatitude();
-
- Rect rect = new Rect(
- (int) getContext().getResources().getDimension(R.dimen.tanlu_module_map_left),
- (int) getContext().getResources().getDimension(R.dimen.tanlu_module_map_top),
- (int) getContext().getResources().getDimension(R.dimen.tanlu_module_map_right),
- (int) getContext().getResources().getDimension(R.dimen.tanlu_module_map_bottom));
-
- moveNotFresh();
-
- //第一个参数:调用者,第二个参数:当前自车的位置,第三个参数:需要显示在范围内的点(不包含自车的位置)
- //第四个参数:显示范围的UI边界,第五个参数:是否锁定自车位置(看业务需要)
- mMApUIController.showBounds(TanluConstants.MODEL_NAME, new MogoLatLng(lat, longit),
- getMogoList(), rect, true);
- Logger.d(TAG, " getMogoList() = " + getMogoList().size());
- }
-
-
- /**
- * 构造经纬度列表
- *
- * @return
- */
- private List getMogoList() {
- List list = new ArrayList<>();
- if (markerExploreWayList != null && markerExploreWayList.size() > 0) {
- if (markerExploreWayList.size() < 6) {
- for (int i = 0; i < markerExploreWayList.size(); i++) {
- MarkerLocation location = markerExploreWayList.get(i).getLocation();
- if (location != null) {
- MogoLatLng mogoLatLng = new MogoLatLng(location.getLat(), location.getLon());
- list.add(mogoLatLng);
- } else {
- Logger.e(TAG, "getMogoList() < 6 location == null");
- }
- }
- } else {
- for (int i = 0; i < 6; i++) {
- MarkerLocation location = markerExploreWayList.get(i).getLocation();
- if (location != null) {
- MogoLatLng mogoLatLng = new MogoLatLng(location.getLat(), location.getLon());
- list.add(mogoLatLng);
- } else {
- Logger.e(TAG, "getMogoList() location == null");
- }
- }
- }
- } else {
- Logger.e(TAG, "getMogoList() markerExploreWay == null");
- }
- return list;
- }
-
-
- /**
- * 将探路的数据结构转换成 MarkerExploreWay的列表
- */
- private void convertData(List informations) {
- if (markerExploreWayList != null) {
- markerExploreWayList.clear();
- }
-
- for (int i = 0; i < informations.size(); i++) {
- MarkerExploreWay markerExploreWay = new MarkerExploreWay();
- markerExploreWay.setAddr(informations.get(i).addr);
- markerExploreWay.setCityName(informations.get(i).cityName);
- markerExploreWay.setDistance(informations.get(i).distance);
- markerExploreWay.setFileType(informations.get(i).type);
- markerExploreWay.setItems(convertMediaData(informations.get(i).items));
- markerExploreWay.setLocation(convertLocation(informations.get(i)));
- markerExploreWay.setUserInfo(convertUserInfo(informations.get(i)));
-
- markerExploreWayList.add(markerExploreWay);
- }
-
- //更新数据
- renderCardViews();
- }
-
- /**
- * 转换媒体数据
- *
- * @param items
- * @return
- */
- private List convertMediaData(ArrayList items) {
- List exploreWayItems = new ArrayList<>();
- MarkerExploreWayItem item = new MarkerExploreWayItem();
- if (items != null && items.size() > 0) {
- item.setThumbnail(items.get(0).getThumbnail());
- item.setUrl(items.get(0).getUrl());
-
- exploreWayItems.add(item);
- }
-
- return exploreWayItems;
- }
-
-
- private MarkerLocation convertLocation(Information information) {
- MarkerLocation location = new MarkerLocation();
- location.setAddress(information.addr);
- location.setAngle(0);
- location.setLat(information.lat);
- location.setLon(information.lon);
-
- return location;
- }
-
-
- private MarkerUserInfo convertUserInfo(Information information) {
- MarkerUserInfo userInfo = new MarkerUserInfo();
- userInfo.setUserHead(information.headImgUrl);
- userInfo.setUserName(information.nickName);
-
- return userInfo;
- }
-
-
- Random random = new Random();
-
- private void speakSuccessVoice(List informations, String
- trafficStatus) {
- Logger.d(TAG, "speakSuccessVoice informations.size() = " + informations.size());
- switch (informations.size()) {
- case 0:
- speakFailVoice(searchfaileVoiceStrings[random.nextInt(3)]);
- break;
-
- case 1:
- trackVoiceSearch(1);
- AIAssist.getInstance(getContext()).speakTTSVoice((
- String.format(voiceGetInfoMationTts, "1") + trafficStatus), null);
- break;
-
- case 2:
- trackVoiceSearch(1);
- AIAssist.getInstance(getContext()).speakTTSVoice((
- String.format(
- voiceGetInfoMationTts,
- "2"
- ) + trafficStatus), null);
- break;
- case 3:
- trackVoiceSearch(1);
- AIAssist.getInstance(getContext()).speakTTSVoice((
- String.format(
- voiceGetInfoMationTts,
- "3"
- ) + trafficStatus), null);
- break;
-
- default:
- trackVoiceSearch(1);
- AIAssist.getInstance(getContext()).speakTTSVoice((
- String.format(
- voiceGetInfoMationTts,
- "多"
- ) + trafficStatus), null);
- }
- }
-
- private void initStrings() {
- voiceGetInfoMationTts =
- getContext().getResources().getString(R.string.voice_get_informations_tts);
-// searchingVoiceStrings =
-// getContext().getResources().getStringArray(R.array.searching_voice_string_array);
- searchfaileVoiceStrings =
- getContext().getResources().getStringArray(R.array.search_fail_voice_array);
- voiceShareSuccessTts = getContext().getResources().getString(R.string.tanlu_share_success);
- }
-
- private void speakFailVoice(String string) {
- AIAssist.getInstance(getContext()).speakTTSVoice(string, null);
- }
-
- private void speakSearchingVoice() {
-// AIAssist.getInstance(getContext()).speakTTSVoice(searchingVoiceStrings[random.nextInt(3)], null);
- }
-
-
- Double inputlon = 0.0;//经度
- Double inputlat = 0.0; //维度
- Double datalon = 0.0; //经度
- Double datalat = 0.0; //维度
-
- //上报语音搜索
- private void trackVoiceSearch(int type) {
- Map properties = new HashMap<>();
- properties.put("type", type);
- properties.put("searchtext", mKeywords);
- properties.put("inputlon", inputlon);
- properties.put("inputlat", inputlat);
- properties.put("datalon", datalon);
- properties.put("datalat", datalat);
- mAnalytics.track(TanluConstants.CARNET_VOICE_SEARCH, properties);
- }
-
- private String getMathRandom() {
- Random random = new Random();
- int temp = random.nextInt(50) + 10;
-
- return String.valueOf(temp);
- }
-}
-
-
diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluCardViewProvider.java b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluCardViewProvider.java
index e7485bdc8c..c184721629 100644
--- a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluCardViewProvider.java
+++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluCardViewProvider.java
@@ -2,34 +2,21 @@ package com.mogo.module.tanlu.fragment;
import android.content.Context;
import android.content.Intent;
-import android.os.Bundle;
-import android.view.View;
-
-import androidx.fragment.app.Fragment;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.map.MogoLatLng;
-import com.mogo.map.listener.IMogoMapListener;
-import com.mogo.map.location.IMogoLocationListener;
-import com.mogo.map.marker.IMogoMarkerClickListener;
-import com.mogo.map.navi.IMogoNaviListener;
import com.mogo.module.tanlu.callback.DataSetChangedAdapter;
import com.mogo.module.tanlu.model.event.MarkerInfo;
-import com.mogo.service.module.IMogoModuleLifecycle;
-import com.mogo.service.module.IMogoModuleProvider;
-import com.mogo.service.module.ModuleType;
import com.mogo.module.tanlu.constant.TanluConstants;
-import com.mogo.service.tanlu.IMogoTanluUiProvider;
+import com.mogo.service.share.IMogoTanluUiProvider;
import com.mogo.utils.logger.Logger;
import org.greenrobot.eventbus.EventBus;
import io.reactivex.Single;
-import io.reactivex.SingleEmitter;
import io.reactivex.SingleOnSubscribe;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
-import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
/**
diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluListWindow.java b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluListWindow.java
index cc757b123b..ae0c326c62 100644
--- a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluListWindow.java
+++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluListWindow.java
@@ -4,6 +4,7 @@ import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Rect;
+import android.location.LocationManager;
import android.net.Uri;
import android.os.CountDownTimer;
import android.os.Handler;
@@ -20,6 +21,7 @@ import android.view.animation.LinearInterpolator;
import android.widget.RelativeLayout;
import androidx.annotation.NonNull;
+import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.PagerSnapHelper;
import androidx.recyclerview.widget.RecyclerView;
@@ -29,6 +31,7 @@ import com.mogo.commons.data.BaseData;
import com.mogo.commons.voice.AIAssist;
import com.mogo.commons.voice.IMogoVoiceCmdCallBack;
import com.mogo.map.MogoLatLng;
+import com.mogo.map.location.MogoLocation;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.IMogoMarkerClickListener;
import com.mogo.map.marker.IMogoMarkerManager;
@@ -53,6 +56,9 @@ import com.mogo.module.common.entity.MarkerExploreWayItem;
import com.mogo.module.common.entity.MarkerLocation;
import com.mogo.module.common.entity.MarkerShowEntity;
import com.mogo.module.common.entity.MarkerUserInfo;
+import com.mogo.module.common.entity.V2XMessageEntity;
+import com.mogo.module.common.entity.V2XRoadEventEntity;
+import com.mogo.module.common.utils.Const;
import com.mogo.module.tanlu.R;
import com.mogo.module.tanlu.callback.DataSetChangedAdapter;
import com.mogo.module.tanlu.callback.NaviCallback;
@@ -76,6 +82,7 @@ import com.mogo.module.tanlu.model.event.MarkerInfo;
import com.mogo.module.tanlu.model.event.PushTypeInfo;
import com.mogo.module.tanlu.model.event.StartPlayInfo;
import com.mogo.module.tanlu.model.event.VoiceControlUpInfo;
+import com.mogo.module.tanlu.util.LocationUtils;
import com.mogo.module.tanlu.util.Utils;
import com.mogo.module.tanlu.view.NetErrorDialog;
import com.mogo.module.tanlu.view.UploadFailedDialog;
@@ -162,6 +169,7 @@ public class TanluListWindow extends RelativeLayout implements IMogoMarkerClickL
private List passedByPoints;
private IMogoRegisterCenter mMogoRegisterCenter;
private String mKeywords;
+ private String mCity;
//新修改
private RecyclerView mLoopRecyclerView;
@@ -424,7 +432,6 @@ public class TanluListWindow extends RelativeLayout implements IMogoMarkerClickL
}
});
}
-
private CountDownTimer mHideWindowTimer;
private void hideWindowTimerStart() {
@@ -481,7 +488,7 @@ public class TanluListWindow extends RelativeLayout implements IMogoMarkerClickL
if (mogoIntentManager != null) {
// 同行者 xxx堵不堵唤醒词语音注册
Logger.d(TAG, "initListener====");
- mogoIntentManager.registerIntentListener(TXZ_SPECIFIEDROAD_SEARCH,mogoIntentListener);
+ mogoIntentManager.registerIntentListener(TXZ_SPECIFIEDROAD_SEARCH, mogoIntentListener);
// 通用唤醒词语音注册
mogoIntentManager.registerIntentListener(SPECIFIEDROAD_SEARCH, mogoIntentListener);
mogoIntentManager.registerIntentListener(PLAY_VIDEO_AWAKEN, mogoIntentListener);
@@ -508,7 +515,7 @@ public class TanluListWindow extends RelativeLayout implements IMogoMarkerClickL
// 直接执行相关查询操作
Logger.d(TAG, "智慧出行在前台,可直接分享--->");
realShare(intentStr, intent);
- }else{
+ } else {
// 需要打开智慧驾驶,然后执行操作
Logger.d(TAG, "智慧出行没在前台,需要打开 --->");
intent.setAction(Intent.ACTION_VIEW);
@@ -522,7 +529,7 @@ public class TanluListWindow extends RelativeLayout implements IMogoMarkerClickL
}
};
- public void realShare(String intentStr, Intent intent){
+ public void realShare(String intentStr, Intent intent) {
String data = intent.getStringExtra("data");
Logger.d(TAG, "唤醒 mogoIntentListener intentStr =" + intentStr + ">>data =" + data);
VoiceCmdData voiceData = null;
@@ -545,6 +552,7 @@ public class TanluListWindow extends RelativeLayout implements IMogoMarkerClickL
Logger.d(TAG, "拥堵和路况");
voiceData = Utils.parseTOVoiceCmdData(data);
voiceData.setObj(TYPE_NAME_BLOCK);
+ mKeywords = voiceData.getLocation();
break;
case VOICE_COMMAND_NOVELTY_QUERY:
Logger.d(TAG, "其他");
@@ -557,6 +565,7 @@ public class TanluListWindow extends RelativeLayout implements IMogoMarkerClickL
case TXZ_SPECIFIEDROAD_SEARCH:
Logger.d(TAG, "同行者--xx堵不堵--唤醒--->");
String keyWords = intent.getStringExtra("keywords");
+ mKeywords = keyWords;
String city = intent.getStringExtra("city");
voiceData = new VoiceCmdData("", city + keyWords, TYPE_NAME_BLOCK);
break;
@@ -575,6 +584,10 @@ public class TanluListWindow extends RelativeLayout implements IMogoMarkerClickL
}
Logger.d(TAG, "onQueryRoadInfoSuccess roadInfoList.size() = " + roadInfoList.size()
+ " >>currentLat = " + currentLat + " -->currentLon = " + currentLon);
+ MogoLocation location = TanluServiceManager.getLocationClient().getLastKnowLocation();
+ if (location != null) {
+ mCity = location.getCityName();
+ }
initData(null, (List) roadInfoList);
addMarkersAction((List) roadInfoList, currentLat, currentLon);
}
@@ -667,7 +680,7 @@ public class TanluListWindow extends RelativeLayout implements IMogoMarkerClickL
marker.startScaleAnimation(0, 1.2f, 0, 1.2f, 300, new AccelerateInterpolator(), new OnMarkerAnimationListener() {
@Override
public void onAnimStart() {
- Logger.d(TAG, " onAnimStart ---1----> ");
+// Logger.d(TAG, " onAnimStart ---1----> ");
}
@Override
@@ -974,29 +987,29 @@ public class TanluListWindow extends RelativeLayout implements IMogoMarkerClickL
*/
@Subscribe(threadMode = ThreadMode.MAIN)
public void onGetInfoFailed(final GetInfoError error) {
- mMogoStatusManager.setUploadingStatus(TanluConstants.MODEL_NAME, false);
- float bearing = TanluServiceManager.getLocationClient().getLastKnowLocation().getBearing(); //角度
- Logger.d(TAG, "onGetInfoFailed bearing = " + bearing + " >>>type = " + error.type);
- //失败提示框
- if (error.type == null) {
- return;
- }
-
- mErrorType = error.type;
- if (error.type.equals("100")) {
- //网络弹框
- if (errorDialog != null && errorDialog.isShowing()) {
- //TODO
- } else {
- showNetErrorDialog();
- }
- } else {
- if (customDialog != null && customDialog.isShowing()) {
- //TODO
- } else {
- showNormalDialog(error.type);
- }
- }
+// mMogoStatusManager.setUploadingStatus(TanluConstants.MODEL_NAME, false);
+// float bearing = TanluServiceManager.getLocationClient().getLastKnowLocation().getBearing(); //角度
+// Logger.d(TAG, "onGetInfoFailed bearing = " + bearing + " >>>type = " + error.type);
+// //失败提示框
+// if (error.type == null) {
+// return;
+// }
+//
+// mErrorType = error.type;
+// if (error.type.equals("100")) {
+// //网络弹框
+// if (errorDialog != null && errorDialog.isShowing()) {
+// //TODO
+// } else {
+// showNetErrorDialog();
+// }
+// } else {
+// if (customDialog != null && customDialog.isShowing()) {
+// //TODO
+// } else {
+// showNormalDialog(error.type);
+// }
+// }
}
private UploadFailedDialog customDialog;
@@ -1085,7 +1098,7 @@ public class TanluListWindow extends RelativeLayout implements IMogoMarkerClickL
}
if (!NetworkUtils.isConnected(getContext())) { //没有网络
- TipToast.shortTip("分享失败,请检查网络",new TipDrawable(getResources().getDrawable(R.drawable.module_tanlu_upload_fail)));
+ TipToast.shortTip("分享失败,请检查网络", new TipDrawable(getResources().getDrawable(R.drawable.module_tanlu_upload_fail)));
} else {
float bearing = TanluServiceManager.getLocationClient().getLastKnowLocation().getBearing(); //角度
Logger.d(TAG, "onMarkerInfo event.type = " + event.type + " >>event.lat = " + event.lat + " >>event.lon = " + event.lon + " >>event.imageUrl =" + event.imageUrl);
@@ -1100,7 +1113,7 @@ public class TanluListWindow extends RelativeLayout implements IMogoMarkerClickL
String.format(voiceShareSuccessTts, getMathRandom())), null);
TipToast.shortTip("分享成功", new TipDrawable(getResources().getDrawable(R.drawable.module_tanlu_upload_success)));
- if(TanluServiceManager.getMogoStatusManager().isMainPageOnResume()) {
+ if (TanluServiceManager.getMogoStatusManager().isMainPageOnResume()) {
double lat = TanluServiceManager.getLocationClient().getLastKnowLocation().getLatitude();
double lon = TanluServiceManager.getLocationClient().getLastKnowLocation().getLongitude();
Log.d(TAG, "onMarkerInfo lat = " + lat + " >>>> lon = " + lon);
@@ -1526,16 +1539,14 @@ public class TanluListWindow extends RelativeLayout implements IMogoMarkerClickL
//上报语音搜索
private void trackVoiceSearch(int type) {
+ Log.e(TAG, "type = " + type + "-- mCity =" + mCity + "-- mKeywords =" + mKeywords);
Map properties = new HashMap<>();
- properties.put("type", type);
- properties.put("searchtext", mKeywords);
- properties.put("inputlon", inputlon);
- properties.put("inputlat", inputlat);
- properties.put("datalon", datalon);
- properties.put("datalat", datalat);
+ properties.put("searcharea", mKeywords);
+ properties.put("city", mCity);
mAnalytics.track(TanluConstants.CARNET_VOICE_SEARCH, properties);
}
+
private String getMathRandom() {
Random random = new Random();
int temp = random.nextInt(50) + 10;
diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluServiceManager.java b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluServiceManager.java
index 3709aed460..78d541c5d8 100644
--- a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluServiceManager.java
+++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluServiceManager.java
@@ -25,7 +25,6 @@ import com.zhidao.carchattingprovider.CallChattingProviderConstant;
* 持有服务接口实例
*/
public class TanluServiceManager {
- private static String TAG = "TanluServiceManager";
private static IMogoMapService mMapService;
private static IMogoPoiSearch mPoiSearch;
private static IMogoLocationClient mLocationClient;
diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/recycler/TanluSlideAdapterNew.java b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/recycler/TanluSlideAdapterNew.java
index de39f21bd8..99cf2d9ca7 100644
--- a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/recycler/TanluSlideAdapterNew.java
+++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/recycler/TanluSlideAdapterNew.java
@@ -16,10 +16,12 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
+import com.alibaba.android.arouter.launcher.ARouter;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.map.uicontroller.EnumMapUI;
+import com.mogo.module.carchattingprovider.ICarsChattingProvider;
import com.mogo.module.common.entity.MarkerExploreWay;
import com.mogo.module.common.glide.SkinAbleBitmapTarget;
import com.mogo.module.tanlu.R;
@@ -42,6 +44,8 @@ import com.mogo.skin.support.SkinMode;
import com.mogo.utils.TipToast;
import com.mogo.utils.logger.Logger;
import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder;
+import com.zhidao.carchattingprovider.CallChattingProviderConstant;
+import com.zhidao.carchattingprovider.MogoDriverInfo;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@@ -81,6 +85,7 @@ public class TanluSlideAdapterNew extends RecyclerView.Adapter ");
diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/receiver/MarkerInfoReceiver.kt b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/receiver/MarkerInfoReceiver.kt
index 8edf51634c..563301e998 100644
--- a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/receiver/MarkerInfoReceiver.kt
+++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/receiver/MarkerInfoReceiver.kt
@@ -13,17 +13,15 @@ import org.greenrobot.eventbus.EventBus
*/
class MarkerInfoReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
- if (intent.action == "com.zhidao.roadcondition.marker.info"){
- var type = intent.getStringExtra("type")
- var fromType = intent.getStringExtra("fromType")
- var imageUrl = intent.getStringExtra("imageUrl")
- var lat = intent.getDoubleExtra("lat",0.0)
- var lon = intent.getDoubleExtra("lon",0.0) //经度
- var custom = intent.getBooleanExtra("custom", false)
- Log.d("MarkerInfoReceiver", "type =" + type + "---->lat =" + lat + "----lon =" + lon + " --custom = " + custom + "---imageUrl =" + imageUrl)
- if(DebugConfig.isLauncher()) {
- EventBus.getDefault().post(MarkerInfo(type, imageUrl, lon, lat, custom, fromType))
- }
- }
+// if (intent.action == "com.zhidao.roadcondition.marker.info"){
+// var type = intent.getStringExtra("type")
+// var fromType = intent.getStringExtra("fromType")
+// var imageUrl = intent.getStringExtra("imageUrl")
+// var lat = intent.getDoubleExtra("lat",0.0)
+// var lon = intent.getDoubleExtra("lon",0.0) //经度
+// var custom = intent.getBooleanExtra("custom", false)
+// Log.d("MarkerInfoReceiver", "type =" + type + "---->lat =" + lat + "----lon =" + lon + " --custom = " + custom + "---imageUrl =" + imageUrl)
+// EventBus.getDefault().post(MarkerInfo(type, imageUrl, lon, lat, custom, fromType))
+// }
}
}
diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/video/SimpleCoverVideoPlayer.kt b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/video/SimpleCoverVideoPlayer.kt
index 3096e93c88..82e251d7f1 100644
--- a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/video/SimpleCoverVideoPlayer.kt
+++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/video/SimpleCoverVideoPlayer.kt
@@ -10,6 +10,7 @@ import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.mogo.module.common.glide.SkinAbleBitmapTarget
import com.mogo.module.tanlu.R
+import com.mogo.utils.logger.Logger
import com.shuyu.gsyvideoplayer.GSYVideoManager
import com.shuyu.gsyvideoplayer.utils.GSYVideoType
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer
@@ -22,6 +23,11 @@ class SimpleCoverVideoPlayer : StandardGSYVideoPlayer {
private lateinit var start: ImageView
private lateinit var fullscreen: ImageView
+ companion object {
+ @JvmField
+ val TAG: String = "SimpleCoverVideoPlayer.kt"
+ }
+
constructor(context: Context?) : super(context)
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context?, fullFlag: Boolean?) : super(context, fullFlag)
@@ -131,6 +137,13 @@ class SimpleCoverVideoPlayer : StandardGSYVideoPlayer {
super.onDetachedFromWindow()
mProgressBar.progress = 0
mFullPauseBitmap = null
+ if (mAudioManager != null) {
+ try {
+ mAudioManager.abandonAudioFocus(onAudioFocusChangeListener)
+ } catch (e: Exception) {
+ Logger.e(TAG, e, "onDetachedFromWindow - abandonAudioFocus")
+ }
+ }
}
override fun onClick(v: View?) {
diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/voice/VoiceController.kt b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/voice/VoiceController.kt
deleted file mode 100644
index 5b623fb41f..0000000000
--- a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/voice/VoiceController.kt
+++ /dev/null
@@ -1,57 +0,0 @@
-package com.mogo.module.tanlu.voice
-
-import com.zhidao.auto.platform.voice.VoiceClient
-
-/**
- * @description 声音控制类
- *
- * @author lixiaopeng
- * @since 2019-11-01
- */
-object VoiceController {
- private lateinit var voiceClient: VoiceClient
-
-// fun initVoice() {
-// voiceClient = VoiceClient.getInstance(BaseApplication.getAppContext())
-// }
-
- /**
- * 设置语音命令回调接口
- * @param callBack
- */
- fun setCallBack(callBack: VoiceClient.VoiceCmdCallBack) {
- voiceClient.setCallBack(callBack)
- }
-
- /**
- * @param speakText 语音播报内容
- */
- fun speakVoice(speakText: String) {
- voiceClient.speakDefault(speakText)
- }
-
- /**
- * 注册免唤醒命令
- * @param customType 命令
- * @param customWakeupCmd 命令对应的唤醒词集合
- */
- fun registerCustomWakeupCmd(customType: String, customWakeupCmd: Array) {
- voiceClient.registerCustomWakeupCmd(customType, customWakeupCmd)
- }
-
- /**
- * 取消免唤醒命令
- * @param customType 命令
- */
- fun unRegisterCustomWakeupCmd(customType: String) {
- voiceClient.unRegisterCustomWakeupCmd(customType)
- }
-
- /**
- * 释放资源(界面销毁的时候调用)
- */
- fun release() {
- voiceClient.release()
- }
-
-}
\ No newline at end of file
diff --git a/modules/mogo-module-tanlu/src/main/res/drawable-xhdpi-1920x1000/tanlu_icon_logo.png b/modules/mogo-module-tanlu/src/main/res/drawable-xhdpi-1920x1000/tanlu_icon_logo.png
index dabf25dbbb..957c298fd6 100644
Binary files a/modules/mogo-module-tanlu/src/main/res/drawable-xhdpi-1920x1000/tanlu_icon_logo.png and b/modules/mogo-module-tanlu/src/main/res/drawable-xhdpi-1920x1000/tanlu_icon_logo.png differ
diff --git a/modules/mogo-module-tanlu/src/main/res/drawable-xhdpi/tanlu_icon_logo.png b/modules/mogo-module-tanlu/src/main/res/drawable-xhdpi/tanlu_icon_logo.png
index dabf25dbbb..957c298fd6 100644
Binary files a/modules/mogo-module-tanlu/src/main/res/drawable-xhdpi/tanlu_icon_logo.png and b/modules/mogo-module-tanlu/src/main/res/drawable-xhdpi/tanlu_icon_logo.png differ
diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XServiceManager.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XServiceManager.java
index 823faa7f2f..f4723af8fb 100644
--- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XServiceManager.java
+++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XServiceManager.java
@@ -30,8 +30,9 @@ import com.mogo.service.module.IMogoRegisterCenter;
import com.mogo.service.module.IMogoSearchManager;
import com.mogo.service.share.IMogoShareManager;
import com.mogo.service.statusmanager.IMogoStatusManager;
+import com.mogo.service.strategy.IMogoOnlineCarListPanelProvider;
import com.mogo.service.strategy.IMogoRefreshStrategyController;
-import com.mogo.service.tanlu.IMogoTanluProvider;
+import com.mogo.service.share.IMogoTanluProvider;
import com.mogo.service.windowview.IMogoTopViewManager;
import com.mogo.service.windowview.IMogoWindowManager;
import com.zhidao.carchattingprovider.CallChattingProviderConstant;
@@ -76,6 +77,7 @@ public class V2XServiceManager {
private static IMogoADASController mIMogoADASController;
private static IMogoIntentManager mMogoIntentManager;
private static IMogoEntranceButtonController mMogoEntranceButtonController;
+ private static IMogoOnlineCarListPanelProvider mMogoOnlineCarListPanelProvider;
private static V2XRefreshModel mV2XRefreshModel;
private static V2XMarkerService mV2XMarkerService;
@@ -113,6 +115,7 @@ public class V2XServiceManager {
mIMogoMarkerService = mMogoServiceApis.getMarkerService();
mIMogoShareManager = mMogoServiceApis.getShareManager();
mIMogoTanluProvider = mMogoServiceApis.getTanluApi();
+ mMogoOnlineCarListPanelProvider = mMogoServiceApis.getOnlineCarPanelApi();
mMarkerManager = mMapService.getMarkerManager(context);
mNavi = mMapService.getNavi(context);
@@ -265,4 +268,7 @@ public class V2XServiceManager {
}
+ public static IMogoOnlineCarListPanelProvider getMogoOnlineCarListPanelProvider() {
+ return mMogoOnlineCarListPanelProvider;
+ }
}
diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/adapter/V2XShareEventAdapter.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/adapter/V2XShareEventAdapter.java
index 9412e5dc79..aacc3f1457 100644
--- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/adapter/V2XShareEventAdapter.java
+++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/adapter/V2XShareEventAdapter.java
@@ -12,6 +12,7 @@ import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.alibaba.android.arouter.launcher.ARouter;
+import com.mogo.module.common.view.CustomRatingBar;
import com.mogo.module.v2x.R;
import com.mogo.module.v2x.entity.panel.V2XShareEventDescription;
import com.mogo.module.v2x.entity.panel.V2XShareEventItem;
@@ -90,7 +91,7 @@ public class V2XShareEventAdapter extends RecyclerView.Adapter
extends RecyclerView.ViewHolder
implements IMogoNaviListener {
+ private static final String TAG = "V2XBaseViewHolder";
+ private ICarsChattingProvider mCarsChattingProvider;
+
public V2XBaseViewHolder(@NonNull View itemView) {
super(itemView);
}
@@ -72,6 +83,28 @@ public abstract class V2XBaseViewHolder
delayedCloseWindow();
}
+ public void triggerIVReportHead(MarkerExploreWay noveltyInfo) {
+ Log.d(TAG,"点击头像"+mCarsChattingProvider);
+ try {
+ mCarsChattingProvider = (ICarsChattingProvider) ARouter.getInstance().build(CallChattingProviderConstant.CAR_CALL_PROVIDER).navigation();
+ MogoDriverInfo mogoDriverInfo = new MogoDriverInfo();
+ int ageNumber = noveltyInfo.getUserInfo().getAgeNumber();
+ mogoDriverInfo.setAge(ageNumber);
+ String gender = noveltyInfo.getUserInfo().getGender();
+ mogoDriverInfo.setGender(gender != null ? gender:null);
+ String sn = noveltyInfo.getUserInfo().getSn();
+ mogoDriverInfo.setSn(sn != null ? sn:"");
+ String name = noveltyInfo.getUserInfo().getUserName();
+ mogoDriverInfo.setUserName(name != null ? name:"");
+ mogoDriverInfo.setUserHead(noveltyInfo.getUserInfo().getUserHead());
+ mCarsChattingProvider.showUserWindow(MODULE_NAME, mogoDriverInfo, this.itemView.getContext());
+
+ } catch (Exception e) {
+ Log.d(TAG,"点击头像发生错误--triggerIVReportHead"+e);
+ e.printStackTrace();
+ }
+ }
+
/**
* 打电话
*/
@@ -160,6 +193,7 @@ public abstract class V2XBaseViewHolder
delayedCloseWindow();
}
+
/**
* 显示自定义 Toast
*
diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/adapter/holder/V2XOtherSeekHelpVH.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/adapter/holder/V2XOtherSeekHelpVH.java
index ff0feaf3de..97910f7114 100644
--- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/adapter/holder/V2XOtherSeekHelpVH.java
+++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/adapter/holder/V2XOtherSeekHelpVH.java
@@ -54,7 +54,6 @@ public class V2XOtherSeekHelpVH extends V2XBaseViewHolder {
// 上传事件的用户信息
private MarkerUserInfo mUserInfo = new MarkerUserInfo();
-
// 语音控制导航
private V2XVoiceCallbackListener mNaviCb = (command, intent) -> triggerStartNavi(mNoveltyInfo);
// 语音控制拨打电话
@@ -66,6 +65,8 @@ public class V2XOtherSeekHelpVH extends V2XBaseViewHolder {
e.printStackTrace();
}
};
+ // 查看车辆信息
+ private V2XVoiceCallbackListener mVoiceOpenCarInfoLis = ((command, intent) -> triggerIVReportHead(mNoveltyInfo));
public V2XOtherSeekHelpVH(ViewGroup viewGroup) {
super(LayoutInflater.from(viewGroup.getContext())
@@ -95,7 +96,9 @@ public class V2XOtherSeekHelpVH extends V2XBaseViewHolder {
.registerWakeCmd(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_CALL_CHATTING,
mCallChartingCb)
.registerUnWakeVoice(V2XVoiceConstants.COMMAND_V2X_TO_CHAT_MORE_UN_WAKEUP,
- mCallChartingCb);
+ mCallChartingCb)
+ .registerUnWakeVoice(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_OPEN_CAR_INFO_UN_WAKEUP,
+ mVoiceOpenCarInfoLis);
}
@Override
@@ -106,7 +109,8 @@ public class V2XOtherSeekHelpVH extends V2XBaseViewHolder {
.unRegisterWakeCmd(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_NAVI)
.unRegisterUnWakeVoice(V2XVoiceConstants.COMMAND_V2X_TO_NAVI_UN_WAKEUP)
.unRegisterWakeCmd(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_CALL_CHATTING)
- .unRegisterUnWakeVoice(V2XVoiceConstants.COMMAND_V2X_TO_CHAT_MORE_UN_WAKEUP);
+ .unRegisterUnWakeVoice(V2XVoiceConstants.COMMAND_V2X_TO_CHAT_MORE_UN_WAKEUP)
+ .unRegisterUnWakeVoice(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_OPEN_CAR_INFO_UN_WAKEUP);
}
});
}
@@ -130,6 +134,12 @@ public class V2XOtherSeekHelpVH extends V2XBaseViewHolder {
} catch (Exception e) {
e.printStackTrace();
}
+ ivHead.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ triggerIVReportHead(mNoveltyInfo);
+ }
+ });
// 只有自研车机才会 有车聊聊通话
if (DebugConfig.getCarMachineType() == DebugConfig.CAR_MACHINE_TYPE_SELF_INNOVATE) {
diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/adapter/holder/V2XRoadEventVH.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/adapter/holder/V2XRoadEventVH.java
index aa46a1c0ef..75b246063c 100644
--- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/adapter/holder/V2XRoadEventVH.java
+++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/adapter/holder/V2XRoadEventVH.java
@@ -2,6 +2,7 @@ package com.mogo.module.v2x.adapter.holder;
import android.content.Intent;
import android.text.TextUtils;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -48,9 +49,11 @@ import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
* date : 2020/3/11 4:35 PM
* desc : 道路事件详情
* version: 1.0
+ *
* @author donghongyu
*/
public class V2XRoadEventVH extends V2XBaseViewHolder {
+ private static final String TAG = "V2XRoadEventVH";
private MogoImageView ivEventImg;
private MogoImageView ivReportHead;
private ImageView ivEventPlay;
@@ -109,6 +112,13 @@ public class V2XRoadEventVH extends V2XBaseViewHolder {
showLiveCar(mV2XEventShowEntity);
}
};
+ // 查看车辆信息
+ private V2XVoiceCallbackListener v2xVoiceOpenCarInfoListener = new V2XVoiceCallbackListener() {
+ @Override
+ public void onCallback(String command, Intent intent) {
+ triggerIVReportHead(mNoveltyInfo);
+ }
+ };
private void init(View itemView) {
ivEventImg = itemView.findViewById(R.id.ivEventImg);
@@ -146,12 +156,23 @@ public class V2XRoadEventVH extends V2XBaseViewHolder {
.registerUnWakeVoice(V2XVoiceConstants.COMMAND_V2X_TO_FEEDBACK_TRUE,
v2XVoiceCallbackReportTrueListener)
.registerUnWakeVoice(V2XVoiceConstants.COMMAND_V2X_TO_FEEDBACK_ERROR,
- v2XVoiceCallbackReportErrorListener);
+ v2XVoiceCallbackReportErrorListener)
+ .registerUnWakeVoice(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_OPEN_CAR_INFO_UN_WAKEUP,
+ v2xVoiceOpenCarInfoListener);
}
@Override
public void onViewDetachedFromWindow(View v) {
-// Logger.w(MODULE_NAME, "列表View V2XRoadEventDetailVH 触发 onViewDetachedFromWindow");
+ Log.d(TAG,"onViewDetachedFromWindow unRegister");
+ // 反注册语音交互
+ V2XVoiceManager.INSTANCE
+ .unRegisterWakeCmd(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_CALL_CHATTING)
+ .unRegisterWakeCmd(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_ZAN)
+ .unRegisterUnWakeVoice(V2XVoiceConstants.COMMAND_V2X_TO_CHAT_MORE_UN_WAKEUP)
+ .unRegisterUnWakeVoice(V2XVoiceConstants.COMMAND_V2X_TO_ZAN_UN_WAKEUP)
+ .unRegisterUnWakeVoice(V2XVoiceConstants.COMMAND_V2X_TO_FEEDBACK_TRUE)
+ .unRegisterUnWakeVoice(V2XVoiceConstants.COMMAND_V2X_TO_FEEDBACK_ERROR)
+ .unRegisterUnWakeVoice(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_OPEN_CAR_INFO_UN_WAKEUP);
}
});
}
@@ -239,6 +260,10 @@ public class V2XRoadEventVH extends V2XBaseViewHolder {
ivEventZan.setOnClickListener(v -> {
triggerZan(mNoveltyInfo);
});
+
+ ivReportHead.setOnClickListener(v -> {
+ triggerIVReportHead(mNoveltyInfo);
+ });
}
} catch (Exception e) {
e.printStackTrace();
diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/fragment/V2XEventPanelFragment.kt b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/fragment/V2XEventPanelFragment.kt
index fd51aa6146..0e5f343eb1 100644
--- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/fragment/V2XEventPanelFragment.kt
+++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/fragment/V2XEventPanelFragment.kt
@@ -53,9 +53,16 @@ class V2XEventPanelFragment : MvpFragment poiInfosList = new ArrayList<>();
private IMogoServiceApis mApis;
- private V2XNetworkLoadingView mloadingImage;
+ private NetworkLoadingView mloadingImage;
@Override
@@ -109,8 +106,9 @@ public class V2XSurroundingFragment extends MvpFragment imp
public void show() {
try {
if (getV2XMessageEntity() != null && getV2XMessageEntity().getContent() != null) {
- // 设置TTS
- getV2XMessageEntity().getContent().getTts(false);
- // 广播给ADAS
- ADASUtils.broadcastToADAS(
- V2XServiceManager.getContext(),
- getV2XMessageEntity().getContent());
+ //只展示不播报 不广播
+
+ boolean onlyShow = getV2XMessageEntity().isOnlyShow();
+
+ if (onlyShow == false){
+ // 设置TTS
+ getV2XMessageEntity().getContent().getTts(false);
+ // 广播给ADASzzz
+ ADASUtils.broadcastToADAS(
+ V2XServiceManager.getContext(),
+ getV2XMessageEntity().getContent());
+ }
saveLocalStory(V2XMessageEntity.V2XTypeEnum.ALERT_ROAD_WARNING,
getV2XMessageEntity().getContent().getNoveltyInfo());
@@ -204,7 +206,9 @@ public class V2XRoadEventScenario extends AbsV2XScenario imp
public void onViewAdded(View view) {
Logger.d(MODULE_NAME, "展示 Window 动画结束");
if (V2XServiceManager.getMoGoStatusManager().isMainPageLaunched()) {
- drawPOI();
+ if (getV2XMessageEntity() != null && getV2XMessageEntity().isNeedAddLine() == true){
+ drawPOI();
+ }
}
}
diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/test/V2XTestConsoleWindow.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/test/V2XTestConsoleWindow.java
index bab85f8730..f1ad2a1afc 100644
--- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/test/V2XTestConsoleWindow.java
+++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/test/V2XTestConsoleWindow.java
@@ -22,9 +22,12 @@ import com.mogo.module.v2x.entity.net.V2XSpecialCarRes;
import com.mogo.module.v2x.utils.TestOnLineCarUtils;
import com.mogo.module.v2x.utils.V2XSQLiteUtils;
import com.mogo.utils.TipToast;
+import com.zhidao.carchattingprovider.MogoDriverInfo;
import java.util.List;
+import static android.text.style.TtsSpan.GENDER_MALE;
+
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
@@ -45,6 +48,7 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
private Button mBtnTriggerFatigueDrivingEvent;
private Button mBtnTriggerSeekHelpEvent;
private Button mBtnTriggerParkEvent;
+ private Button mBtnTriggerCallUserInfo;
public static V2XTestConsoleWindow getInstance(Context context) {
if (mV2XTestConsoleWindow == null) {
@@ -83,6 +87,17 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
mBtnTriggerFatigueDrivingEvent = findViewById(R.id.btnTriggerFatigueDrivingEvent);
mBtnTriggerSeekHelpEvent = findViewById(R.id.btnTriggerSeekHelpEvent);
mBtnTriggerParkEvent = findViewById(R.id.btnTriggerParkEvent);
+ mBtnTriggerCallUserInfo = findViewById(R.id.btnTriggerCallUserInfo);
+
+ mBtnTriggerCallUserInfo.setOnClickListener(v -> {
+ MogoDriverInfo mogoDriverInfo = new MogoDriverInfo();
+ mogoDriverInfo.setAge(24);
+ mogoDriverInfo.setGender(GENDER_MALE);
+ mogoDriverInfo.setSn("12345678");
+ mogoDriverInfo.setUserName("测试");
+ mogoDriverInfo.setUserHead("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1600872867592&di=994e371880ca6ae2814f553e0d0e4139&imgtype=0&src=http%3A%2F%2Fp3.ssl.cdn.btime.com%2Ft014c5d8a1e5cef12ba.jpg%3Fsize%3D506x543");
+ V2XServiceManager.getCarsChattingProvider().showUserWindow("CAR_CALL_USER_TO_" + V2XConst.MODULE_NAME,mogoDriverInfo,context);
+ });
mBtnTriggerOpen.setOnClickListener(v ->
V2XServiceManager
diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/SurroundingMarginDecoration.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/SurroundingMarginDecoration.java
index 214a12be31..30dc9326de 100644
--- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/SurroundingMarginDecoration.java
+++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/SurroundingMarginDecoration.java
@@ -12,20 +12,24 @@ import androidx.recyclerview.widget.RecyclerView;
*/
public class SurroundingMarginDecoration extends RecyclerView.ItemDecoration {
private int margin ;
+ private int marginLeft ;
- public SurroundingMarginDecoration(int space) {
+ public SurroundingMarginDecoration(int space, int left) {
margin = space;
+ marginLeft = left;
}
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
outRect.bottom = margin;
- outRect.right = 0;
- //由于每行都只有2个,所以第一个都是2的倍数,把左边距设为0
+
+ //由于每行都只有2个,所以第一个都是2的倍数
if (parent.getChildLayoutPosition(view) % 2 == 0) {
- outRect.left = 0;
+ outRect.left = marginLeft;
+ outRect.right = margin / 2;
} else {
- outRect.left = margin;
+ outRect.left = margin / 2;
+ outRect.right = marginLeft;
}
}
diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/voice/V2XVoiceConstants.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/voice/V2XVoiceConstants.java
index 7c96329347..0d3d373c2d 100644
--- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/voice/V2XVoiceConstants.java
+++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/voice/V2XVoiceConstants.java
@@ -248,6 +248,12 @@ public class V2XVoiceConstants {
public static final String COMMAND_ZHIDAO_V2X_OPEN_SHEAR_EVENT_UN_WAKEUP = "COMMAND_ZHIDAO_V2X_OPEN_SHEAR_EVENT_UN_WAKEUP";
public static final String[] COMMAND_ZHIDAO_V2X_OPEN_SHEAR_EVENT_UN_WAKEUP_WORDS = {"我的分享"};
+ /*
+ * 查看车辆信息
+ * */
+ public static final String COMMAND_ZHIDAO_V2X_OPEN_CAR_INFO_UN_WAKEUP = "COMMAND_ZHIDAO_V2X_OPEN_CAR_INFO_UN_WAKEUP";
+ public static final String[] COMMAND_ZHIDAO_V2X_OPEN_CAR_INFO_UN_WAKEUP_UN_WAKEUP_WORDS = {"查看车辆信息"};
+
static {
// 免唤醒 默认
sVoiceCmds.put(COMMAND_V2X_TO_CHAT_MORE_UN_WAKEUP, COMMAND_V2X_TO_CHAT_MORE_UN_WAKEUP_WORDS);
@@ -274,6 +280,7 @@ public class V2XVoiceConstants {
sVoiceCmds.put(COMMAND_ZHIDAO_V2X_OPEN_HISTORY_EVENT_UN_WAKEUP, COMMAND_ZHIDAO_V2X_OPEN_HISTORY_EVENT_UN_WAKEUP_WORDS);
sVoiceCmds.put(COMMAND_ZHIDAO_V2X_OPEN_SURROUNDING_EVENT_UN_WAKEUP, COMMAND_ZHIDAO_V2X_OPEN_SURROUNDING_EVENT_UN_WAKEUP_WORDS);
sVoiceCmds.put(COMMAND_ZHIDAO_V2X_OPEN_SHEAR_EVENT_UN_WAKEUP, COMMAND_ZHIDAO_V2X_OPEN_SHEAR_EVENT_UN_WAKEUP_WORDS);
+ sVoiceCmds.put(COMMAND_ZHIDAO_V2X_OPEN_CAR_INFO_UN_WAKEUP, COMMAND_ZHIDAO_V2X_OPEN_CAR_INFO_UN_WAKEUP_UN_WAKEUP_WORDS);
//2020-6-24 顺义演示需求添加,现合并至launcher 更新时间:2020-08-25
sVoiceCmds.put(COMMAND_ZHIDAO_V2X_CALL_FRONT_CAR_DEMO_UN_WAKEUP, COMMAND_ZHIDAO_V2X_CALL_FRONT_CAR_DEMO_UN_WAKEUP_WORDS);
diff --git a/modules/mogo-module-v2x/src/main/res/drawable-ldpi/icon_enthusiasm_choose.png b/modules/mogo-module-v2x/src/main/res/drawable-ldpi/icon_enthusiasm_choose.png
deleted file mode 100644
index 48218a14a8..0000000000
Binary files a/modules/mogo-module-v2x/src/main/res/drawable-ldpi/icon_enthusiasm_choose.png and /dev/null differ
diff --git a/modules/mogo-module-v2x/src/main/res/drawable-ldpi/icon_enthusiasm_second.png b/modules/mogo-module-v2x/src/main/res/drawable-ldpi/icon_enthusiasm_second.png
deleted file mode 100644
index 1f42366be2..0000000000
Binary files a/modules/mogo-module-v2x/src/main/res/drawable-ldpi/icon_enthusiasm_second.png and /dev/null differ
diff --git a/modules/mogo-module-v2x/src/main/res/drawable-ldpi/icon_enthusiasm_unchoose.png b/modules/mogo-module-v2x/src/main/res/drawable-ldpi/icon_enthusiasm_unchoose.png
deleted file mode 100644
index 932cb60d44..0000000000
Binary files a/modules/mogo-module-v2x/src/main/res/drawable-ldpi/icon_enthusiasm_unchoose.png and /dev/null differ
diff --git a/modules/mogo-module-v2x/src/main/res/drawable-mdpi/icon_enthusiasm_choose.png b/modules/mogo-module-v2x/src/main/res/drawable-mdpi/icon_enthusiasm_choose.png
deleted file mode 100644
index a4ea109054..0000000000
Binary files a/modules/mogo-module-v2x/src/main/res/drawable-mdpi/icon_enthusiasm_choose.png and /dev/null differ
diff --git a/modules/mogo-module-v2x/src/main/res/drawable-mdpi/icon_enthusiasm_second.png b/modules/mogo-module-v2x/src/main/res/drawable-mdpi/icon_enthusiasm_second.png
deleted file mode 100644
index 6e4cd579d9..0000000000
Binary files a/modules/mogo-module-v2x/src/main/res/drawable-mdpi/icon_enthusiasm_second.png and /dev/null differ
diff --git a/modules/mogo-module-v2x/src/main/res/drawable-mdpi/icon_enthusiasm_unchoose.png b/modules/mogo-module-v2x/src/main/res/drawable-mdpi/icon_enthusiasm_unchoose.png
deleted file mode 100644
index a116ac63ce..0000000000
Binary files a/modules/mogo-module-v2x/src/main/res/drawable-mdpi/icon_enthusiasm_unchoose.png and /dev/null differ
diff --git a/modules/mogo-module-v2x/src/main/res/drawable-xhdpi/icon_enthusiasm_choose.png b/modules/mogo-module-v2x/src/main/res/drawable-xhdpi/icon_enthusiasm_choose.png
deleted file mode 100644
index a62533c607..0000000000
Binary files a/modules/mogo-module-v2x/src/main/res/drawable-xhdpi/icon_enthusiasm_choose.png and /dev/null differ
diff --git a/modules/mogo-module-v2x/src/main/res/drawable-xhdpi/icon_enthusiasm_second.png b/modules/mogo-module-v2x/src/main/res/drawable-xhdpi/icon_enthusiasm_second.png
deleted file mode 100644
index 84c49a0052..0000000000
Binary files a/modules/mogo-module-v2x/src/main/res/drawable-xhdpi/icon_enthusiasm_second.png and /dev/null differ
diff --git a/modules/mogo-module-v2x/src/main/res/drawable-xhdpi/icon_enthusiasm_unchoose.png b/modules/mogo-module-v2x/src/main/res/drawable-xhdpi/icon_enthusiasm_unchoose.png
deleted file mode 100644
index 79ae51a734..0000000000
Binary files a/modules/mogo-module-v2x/src/main/res/drawable-xhdpi/icon_enthusiasm_unchoose.png and /dev/null differ
diff --git a/modules/mogo-module-v2x/src/main/res/drawable/bg_v2x_event_description.xml b/modules/mogo-module-v2x/src/main/res/drawable/bg_v2x_event_description.xml
index 7602d95ba0..dd1f94d092 100644
--- a/modules/mogo-module-v2x/src/main/res/drawable/bg_v2x_event_description.xml
+++ b/modules/mogo-module-v2x/src/main/res/drawable/bg_v2x_event_description.xml
@@ -3,8 +3,8 @@
android:shape="rectangle">
diff --git a/modules/mogo-module-v2x/src/main/res/layout/item_v2x_event_detail.xml b/modules/mogo-module-v2x/src/main/res/layout/item_v2x_event_detail.xml
index 022db7da53..886ad47555 100644
--- a/modules/mogo-module-v2x/src/main/res/layout/item_v2x_event_detail.xml
+++ b/modules/mogo-module-v2x/src/main/res/layout/item_v2x_event_detail.xml
@@ -52,7 +52,7 @@
android:paddingRight="@dimen/dp_10"
android:paddingBottom="@dimen/dp_3"
android:textColor="#fff"
- android:textSize="@dimen/dp_24"
+ android:textSize="@dimen/module_v2x_event_type_title_text_size"
app:layout_constraintStart_toEndOf="@+id/rlRoadEventImg"
app:layout_constraintTop_toTopOf="@+id/rlRoadEventImg"
tools:text="道路施工" />
@@ -66,10 +66,10 @@
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/v2x_FFF_333"
- android:textSize="@dimen/dp_36"
- app:layout_constraintEnd_toStartOf="@+id/ivEventHead"
+ android:textSize="@dimen/module_v2x_event_title_text_size"
android:textStyle="bold"
- app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintEnd_toStartOf="@+id/ivEventHead"
+ app:layout_constraintStart_toStartOf="@+id/tvEventTypeTitle"
app:layout_constraintTop_toBottomOf="@+id/tvEventTypeTitle"
tools:text="东城区北三环中路辅路小黄庄路口" />
@@ -89,7 +89,7 @@
android:layout_marginStart="@dimen/dp_10"
android:alpha="0.6"
android:textColor="@color/v2x_FFF_666"
- android:textSize="@dimen/dp_28"
+ android:textSize="@dimen/module_v2x_event_sub_title_text_size"
app:layout_constraintBottom_toBottomOf="@id/ivEventDistanceLogo"
app:layout_constraintStart_toEndOf="@id/ivEventDistanceLogo"
app:layout_constraintTop_toTopOf="@id/ivEventDistanceLogo"
@@ -102,7 +102,7 @@
android:layout_marginStart="@dimen/dp_30"
android:alpha="0.6"
android:textColor="@color/v2x_FFF_999"
- android:textSize="@dimen/dp_28"
+ android:textSize="@dimen/module_v2x_event_sub_title_text_size"
app:layout_constraintBottom_toBottomOf="@id/ivEventDistanceLogo"
app:layout_constraintStart_toEndOf="@+id/tvEventDistance"
app:layout_constraintTop_toTopOf="@id/ivEventDistanceLogo"
@@ -110,8 +110,8 @@
@@ -23,15 +23,15 @@
android:paddingBottom="@dimen/dp_5"
android:text="求助信息"
android:textColor="@android:color/white"
- android:textSize="@dimen/dp_24"
+ android:textSize="@dimen/module_v2x_event_type_title_text_size"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed" />
@@ -78,7 +78,7 @@
android:layout_marginEnd="@dimen/dp_30"
android:gravity="center_vertical"
android:textColor="@color/v2x_FFF_333"
- android:textSize="@dimen/dp_80"
+ android:textSize="@dimen/module_v2x_event_help_distance_text_size"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@+id/ivFaultHelpEventCall"
app:layout_constraintEnd_toStartOf="@+id/ivFaultHelpEventCall"
diff --git a/modules/mogo-module-v2x/src/main/res/layout/item_v2x_illegal_parking.xml b/modules/mogo-module-v2x/src/main/res/layout/item_v2x_illegal_parking.xml
index 9bd3f76b78..1a0f011c8c 100644
--- a/modules/mogo-module-v2x/src/main/res/layout/item_v2x_illegal_parking.xml
+++ b/modules/mogo-module-v2x/src/main/res/layout/item_v2x_illegal_parking.xml
@@ -33,7 +33,7 @@
android:paddingBottom="@dimen/dp_3"
android:text="违章停车"
android:textColor="#FFFFFF"
- android:textSize="@dimen/dp_24"
+ android:textSize="@dimen/module_v2x_event_type_title_text_size"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/tvAddress"
app:layout_constraintStart_toEndOf="@+id/ivIconP"
@@ -48,7 +48,7 @@
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/v2x_FFF_333"
- android:textSize="@dimen/dp_34"
+ android:textSize="@dimen/module_v2x_event_title_text_size"
app:layout_constraintBottom_toTopOf="@+id/tvAddressDistance"
app:layout_constraintEnd_toStartOf="@+id/llIllegalParkingLike"
app:layout_constraintStart_toStartOf="@+id/tagEventType"
@@ -63,7 +63,7 @@
android:alpha="0.6"
android:gravity="center_vertical"
android:textColor="@color/v2x_FFF_666"
- android:textSize="@dimen/dp_26"
+ android:textSize="@dimen/module_v2x_event_sub_title_text_size"
app:layout_constraintEnd_toEndOf="@+id/tvAddress"
app:layout_constraintStart_toStartOf="@+id/tagEventType"
app:layout_constraintTop_toBottomOf="@+id/tvAddress"
diff --git a/modules/mogo-module-v2x/src/main/res/layout/item_v2x_scennario_history.xml b/modules/mogo-module-v2x/src/main/res/layout/item_v2x_scennario_history.xml
index e47f51edc5..da50969a5e 100644
--- a/modules/mogo-module-v2x/src/main/res/layout/item_v2x_scennario_history.xml
+++ b/modules/mogo-module-v2x/src/main/res/layout/item_v2x_scennario_history.xml
@@ -21,7 +21,7 @@
android:paddingBottom="@dimen/dp_3"
android:text="违章停车"
android:textColor="#ffffff"
- android:textSize="@dimen/dp_28"
+ android:textSize="@dimen/panel_list_item_title_size"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
@@ -38,7 +38,7 @@
android:paddingBottom="@dimen/dp_3"
android:text="待评价"
android:textColor="#ffffff"
- android:textSize="@dimen/dp_28"
+ android:textSize="@dimen/panel_list_item_title_size"
app:layout_constraintBottom_toBottomOf="@+id/tagEventType"
app:layout_constraintStart_toEndOf="@+id/tagEventType"
app:layout_constraintTop_toTopOf="@+id/tagEventType" />
diff --git a/modules/mogo-module-v2x/src/main/res/layout/module_event_panel_fragment_surrounding.xml b/modules/mogo-module-v2x/src/main/res/layout/module_event_panel_fragment_surrounding.xml
index ed78168882..220d67496e 100644
--- a/modules/mogo-module-v2x/src/main/res/layout/module_event_panel_fragment_surrounding.xml
+++ b/modules/mogo-module-v2x/src/main/res/layout/module_event_panel_fragment_surrounding.xml
@@ -52,9 +52,9 @@
android:id="@+id/surrounding_recycleview"
android:layout_width="wrap_content"
android:layout_height="match_parent"
- android:layout_marginLeft="@dimen/module_v2x_surrounding_list_margin_left"
android:layout_marginTop="@dimen/module_v2x_surrounding_empty_tv_margin_top"
android:visibility="visible" />
+
-
+
+
+
-
+
-
+ android:layout_height="wrap_content" />
+ android:textSize="@dimen/panel_list_item_title_size" />
+ android:textSize="@dimen/share_item_address" />
-
-
+
diff --git a/modules/mogo-module-v2x/src/main/res/layout/view_history_empty.xml b/modules/mogo-module-v2x/src/main/res/layout/view_history_empty.xml
index 7e74267929..4707ce5636 100644
--- a/modules/mogo-module-v2x/src/main/res/layout/view_history_empty.xml
+++ b/modules/mogo-module-v2x/src/main/res/layout/view_history_empty.xml
@@ -50,7 +50,7 @@
android:layout_height="@dimen/v2x_share_btn_height"
android:layout_marginStart="@dimen/dp_60"
android:layout_marginTop="@dimen/dp_60"
- android:background="@drawable/v2xt_dw_common_corner_bkg_light"
+ android:background="@drawable/module_dw_common_corner_bkg_light"
android:gravity="center"
android:text="刷新"
android:textColor="#FFFFFF"
diff --git a/modules/mogo-module-v2x/src/main/res/layout/view_video_layout_normal.xml b/modules/mogo-module-v2x/src/main/res/layout/view_video_layout_normal.xml
index 9cbfa8f4ef..99bb075aaf 100644
--- a/modules/mogo-module-v2x/src/main/res/layout/view_video_layout_normal.xml
+++ b/modules/mogo-module-v2x/src/main/res/layout/view_video_layout_normal.xml
@@ -42,7 +42,7 @@
android:layout_marginStart="@dimen/dp_20"
android:text="直播获取失败"
android:textColor="@color/v2x_FFF_333"
- android:textSize="@dimen/dp_36"
+ android:textSize="@dimen/module_v2x_event_live_error_text_size"
app:layout_constraintBottom_toBottomOf="@+id/ivErrorIcon"
app:layout_constraintStart_toEndOf="@+id/ivErrorIcon"
app:layout_constraintTop_toTopOf="@+id/ivErrorIcon" />
@@ -59,7 +59,7 @@
android:paddingBottom="@dimen/dp_25"
android:text="重试"
android:textColor="@color/v2x_FFF_333"
- android:textSize="@dimen/dp_34"
+ android:textSize="@dimen/module_v2x_event_live_error_text_size"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ivErrorIcon" />
diff --git a/modules/mogo-module-v2x/src/main/res/layout/window_fault_help.xml b/modules/mogo-module-v2x/src/main/res/layout/window_fault_help.xml
index e96d3e9056..04ffc5cd62 100644
--- a/modules/mogo-module-v2x/src/main/res/layout/window_fault_help.xml
+++ b/modules/mogo-module-v2x/src/main/res/layout/window_fault_help.xml
@@ -7,6 +7,7 @@
android:layout_height="@dimen/module_v2x_fatigue_driving_window_height_ground"
android:orientation="vertical"
android:overScrollMode="never"
+ android:padding="@dimen/module_v2x_widow_top_gaps"
tools:itemCount="1"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem="@layout/item_v2x_fault_help" />
diff --git a/modules/mogo-module-v2x/src/main/res/layout/window_road_event_detail.xml b/modules/mogo-module-v2x/src/main/res/layout/window_road_event_detail.xml
index c34c2ce6dd..cb599e80c8 100644
--- a/modules/mogo-module-v2x/src/main/res/layout/window_road_event_detail.xml
+++ b/modules/mogo-module-v2x/src/main/res/layout/window_road_event_detail.xml
@@ -12,6 +12,7 @@
android:minHeight="@dimen/module_v2x_event_window_height"
android:orientation="horizontal"
android:overScrollMode="never"
+ android:padding="@dimen/module_v2x_widow_top_gaps"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
@@ -24,7 +25,7 @@
android:layout_width="@dimen/dp_88"
android:layout_height="@dimen/dp_88"
android:layout_marginEnd="@dimen/dp_28"
- android:layout_marginBottom="@dimen/dp_65"
+ android:layout_marginBottom="@dimen/dp_40"
android:background="@drawable/icon_window_close2"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent" />
diff --git a/modules/mogo-module-v2x/src/main/res/layout/window_test_console.xml b/modules/mogo-module-v2x/src/main/res/layout/window_test_console.xml
index 7959d63977..ab57767085 100644
--- a/modules/mogo-module-v2x/src/main/res/layout/window_test_console.xml
+++ b/modules/mogo-module-v2x/src/main/res/layout/window_test_console.xml
@@ -128,5 +128,17 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-v2x/src/main/res/values-ldpi/dimens.xml b/modules/mogo-module-v2x/src/main/res/values-ldpi/dimens.xml
new file mode 100644
index 0000000000..e911308385
--- /dev/null
+++ b/modules/mogo-module-v2x/src/main/res/values-ldpi/dimens.xml
@@ -0,0 +1,102 @@
+
+
+ 445px
+
+ 18px
+ 20px
+
+ 190px
+ 210px
+
+
+ 82px
+
+
+
+ 34px
+ 22px
+
+ 40px
+
+ 6px
+
+ 550px
+ 200px
+ 200px
+ 100px
+ 50px
+ 90px
+ 36px
+ 40px
+ 15px
+ 150px
+ 48px
+ 32px
+ 28px
+ 28px
+ 190px
+ 238px
+ 170px
+ 43px
+ 26px
+ 12px
+ 8px
+ 2px
+ 30px
+ 34px
+
+ 12px
+ 16px
+
+ 24px
+ 18px
+ 20px
+ 16px
+ 28px
+
+ 82px
+ 16px
+ 117px
+ 50px
+ 17px
+ 16px
+ 36px
+ 16px
+ 20px
+ 34px
+ 15px
+ 29px
+ -8px
+ 84px
+
+ 16px
+ 20px
+ 6px
+
+
+ 13px
+ 20px
+ 16px
+ 31px
+ 20px
+ 150px
+ 54px
+ 64px
+
+
+ 190px
+ 250px
+ 156px
+ 234px
+
+
+ 136px
+
+ 41px
+ 18px
+ 14px
+ 44px
+ 19px
+
+
+
diff --git a/modules/mogo-module-v2x/src/main/res/values-mdpi/dimens.xml b/modules/mogo-module-v2x/src/main/res/values-mdpi/dimens.xml
index 16cfb44d2c..17684331f1 100644
--- a/modules/mogo-module-v2x/src/main/res/values-mdpi/dimens.xml
+++ b/modules/mogo-module-v2x/src/main/res/values-mdpi/dimens.xml
@@ -4,21 +4,14 @@
18px
20px
- 190px
- 250px
+
190px
210px
- 136px
82px
- 54px
- 64px
-
- 156px
- 234px
34px
@@ -28,7 +21,6 @@
6px
- 150px
550px
200px
200px
@@ -61,25 +53,51 @@
18px
20px
16px
- 17px
- 14px
+ 28px
+
82px
16px
117px
50px
- 150px
- 48px
17px
16px
36px
16px
20px
34px
- 15px
+ 16px
29px
-8px
- 84px
- 120px
+ 84px w
+
16px
20px
+ 3px
+
+
+ 13px
+ 20px
+ 16px
+ 31px
+ 20px
+ 150px
+ 54px
+ 64px
+
+
+ 190px
+ 250px
+ 156px
+ 234px
+
+
+ 136px
+
+ 41px
+ 18px
+ 14px
+ 44px
+ 19px
+
+
diff --git a/modules/mogo-module-v2x/src/main/res/values-xhdpi-1920x1000/dimens.xml b/modules/mogo-module-v2x/src/main/res/values-xhdpi-1920x1000/dimens.xml
index a7faf7fc01..4d5042d290 100644
--- a/modules/mogo-module-v2x/src/main/res/values-xhdpi-1920x1000/dimens.xml
+++ b/modules/mogo-module-v2x/src/main/res/values-xhdpi-1920x1000/dimens.xml
@@ -4,27 +4,19 @@
32px
32px
- 330px
- 450px
+
390px
410px
- 200px
160px
- 110px
- 100px
-
- 270px
- 480px
60px
40px
80px
- 310px
15px
550px
200px
@@ -58,10 +50,36 @@
32px
36px
30px
- 16px
- 42px
+ 50px
+
120px
158px
+
+ 24px
+ 36px
+ 28px
+ 55px
+ 36px
+ 310px
+ 110px
+ 120px
+
+
+ 270px
+ 480px
+ 330px
+ 450px
+
+
+ 200px
+
+ 75px
+ 32px
+ 26px
+ 80px
+ 34px
+
+
diff --git a/modules/mogo-module-v2x/src/main/res/values-xhdpi/dimens.xml b/modules/mogo-module-v2x/src/main/res/values-xhdpi/dimens.xml
index 40d18b8115..df3fadb8fd 100644
--- a/modules/mogo-module-v2x/src/main/res/values-xhdpi/dimens.xml
+++ b/modules/mogo-module-v2x/src/main/res/values-xhdpi/dimens.xml
@@ -5,29 +5,19 @@
32px
32px
1060px
- 330px
- 450px
390px
410px
670px
- 234px
147px
- 98px
- 130px
-
- 280px
- 421px
-
60px
40px
80px
- 310px
15px
550px
200px
@@ -61,28 +51,51 @@
32px
36px
30px
- 31.9px
- 26px
+ 50px
+
30px
140px
219px
100px
- 281px
- 90px
28px
28px
67.5px
30px
40px
60px
- 36px
+ 31px
54px
-10px
114px
158px
- 300px
26px
25px
+ 2px
+
+ 24px
+ 36px
+ 28px
+ 55px
+ 36px
+ 310px
+ 98px
+ 130px
+
+
+ 330px
+ 450px
+ 280px
+ 421px
+
+
+ 234px
+
+ 75px
+ 32px
+ 26px
+ 80px
+ 34px
+
diff --git a/modules/mogo-module-v2x/src/main/res/values/colors.xml b/modules/mogo-module-v2x/src/main/res/values/colors.xml
index 7df2cc766f..66fbad446e 100644
--- a/modules/mogo-module-v2x/src/main/res/values/colors.xml
+++ b/modules/mogo-module-v2x/src/main/res/values/colors.xml
@@ -13,7 +13,6 @@
#FFFFFF
#FFFFFF
#ff616381
- #FFFFFF
#555A75
#000000
#FFF
diff --git a/modules/mogo-module-v2x/src/main/res/values/dimens.xml b/modules/mogo-module-v2x/src/main/res/values/dimens.xml
index 8d1bd18a1d..4a0b8c8856 100644
--- a/modules/mogo-module-v2x/src/main/res/values/dimens.xml
+++ b/modules/mogo-module-v2x/src/main/res/values/dimens.xml
@@ -5,23 +5,13 @@
18px
20px
642px
- 190px
- 250px
190px
210px
670px
- 136px
82px
- 54px
-
- 64px
-
- 156px
- 234px
-
34px
22px
@@ -30,7 +20,6 @@
6px
- 170px
550px
200px
200px
@@ -59,14 +48,12 @@
18px
20px
16px
- 16px
- 20px
+ 28px
+
82px
16px
117px
200px
- 150px
- 48px
17px
16px
36px
@@ -77,6 +64,31 @@
29px
-8px
84px
- 120px
+
+
+ 13px
+ 20px
+ 16px
+ 31px
+ 20px
+ 150px
+ 54px
+ 64px
+
+
+ 190px
+ 250px
+ 156px
+ 234px
+
+
+ 136px
+
+ 41px
+ 18px
+ 14px
+ 44px
+ 34px
+
diff --git a/modules/mogo-module-v2x/src/main/res/values/style.xml b/modules/mogo-module-v2x/src/main/res/values/style.xml
index a6641ea9c8..41038019b1 100644
--- a/modules/mogo-module-v2x/src/main/res/values/style.xml
+++ b/modules/mogo-module-v2x/src/main/res/values/style.xml
@@ -4,17 +4,6 @@
-
-
diff --git a/modules/mogo-module-widgets/src/main/java/com/mogo/module/widgets/AutoNaviIntentHandler.java b/modules/mogo-module-widgets/src/main/java/com/mogo/module/widgets/AutoNaviIntentHandler.java
index 9602906ce0..f7fc67fe67 100644
--- a/modules/mogo-module-widgets/src/main/java/com/mogo/module/widgets/AutoNaviIntentHandler.java
+++ b/modules/mogo-module-widgets/src/main/java/com/mogo/module/widgets/AutoNaviIntentHandler.java
@@ -2,18 +2,29 @@ package com.mogo.module.widgets;
import android.content.Context;
import android.content.Intent;
+import android.graphics.Rect;
+import android.net.Uri;
import android.text.TextUtils;
import android.view.Gravity;
+import android.view.View;
import android.view.WindowManager;
+import android.widget.ImageView;
+import android.widget.TextView;
+import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.commons.debug.DebugConfig;
+import com.mogo.commons.storage.SpStorage;
import com.mogo.commons.voice.AIAssist;
import com.mogo.commons.voice.IMogoVoiceCmdCallBack;
+import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.wm.WindowManagerView;
+import com.mogo.service.IMogoServiceApis;
import com.mogo.utils.CommonUtils;
import com.mogo.utils.LaunchUtils;
import com.mogo.utils.ResourcesHelper;
+import com.mogo.utils.TipToast;
+import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.logger.Logger;
import java.util.HashMap;
@@ -31,6 +42,9 @@ class AutoNaviIntentHandler implements IMogoVoiceCmdCallBack {
private static final String TAG = "AutoNaviIntentHandler";
public static final String OPEN = "OPEN_APP";
+ // 显示浮窗时,同步状态时间间隔
+ public static final long SYNC_INTERVAL = 60_000L;
+
private static volatile AutoNaviIntentHandler sInstance;
private AutoNaviIntentHandler() {
@@ -50,31 +64,45 @@ class AutoNaviIntentHandler implements IMogoVoiceCmdCallBack {
private WindowManagerView mWindowManagerView;
private Map< String, Object > mProperties = new HashMap<>();
+ private TextView mEnterApp;
+ private TextView mConsult;
+ private View mHandler;
+ private ImageView mHandlerIcon;
+
+ private boolean mLargeStyle = true;
+
public synchronized void release() {
sInstance = null;
}
+ private Runnable mAutoNaviSyncRunnable = () -> {
+ if ( mWindowManagerView != null && mWindowManagerView.isShowing() ) {
+ syncAutoNaviForgroundStatus( AbsMogoApplication.getApp() );
+ }
+ };
+
public void handle( Context context, Intent intent ) {
int keyType = intent.getIntExtra( "KEY_TYPE", 0 );
+ Logger.d( TAG, "KEY_TYPE = " + keyType );
switch ( keyType ) {
case 10021:
closeEntrance();
break;
case 10019:
int extraState = intent.getIntExtra( "EXTRA_STATE", -1 );
+ Logger.d( TAG, "EXTRA_STATE = " + extraState );
switch ( extraState ) {
- case 3:
+ case 3: // 前台
syncAutoNaviNavingStatus( context );
break;
- case 4:
+ case 9: // 非导航
+ SpStorage.setNavigationTarget( "" );
+ case 4: // 后台
closeEntrance();
break;
- case 8:
+ case 8: // 导航
showEntrance( context );
break;
- case 9:
- closeEntrance();
- break;
}
break;
}
@@ -90,6 +118,7 @@ class AutoNaviIntentHandler implements IMogoVoiceCmdCallBack {
}
private void showEntrance( Context context ) {
+
if ( mWindowManagerView == null ) {
mWindowManagerView = new WindowManagerView.Builder( AbsMogoApplication.getApp() )
.contentView( R.layout.module_widgets_app_entrance )
@@ -97,22 +126,105 @@ class AutoNaviIntentHandler implements IMogoVoiceCmdCallBack {
.gravity( Gravity.LEFT | Gravity.TOP )
.position( ResourcesHelper.getDimensionPixelSize( context, R.dimen.module_widgets_app_entrance_x ), ResourcesHelper.getDimensionPixelSize( AbsMogoApplication.getApp(), R.dimen.module_widgets_app_entrance_y ) )
.showInWindowManager();
- mWindowManagerView.attachTouchEvent( view -> {
- enterApp( context );
+ mWindowManagerView.attachTouchEvent( ( view, xPos, yPos ) -> {
+ chooseAction( view, xPos, yPos );
} );
+ mEnterApp = mWindowManagerView.findViewById( R.id.module_widgets_app_entrance );
+ mConsult = mWindowManagerView.findViewById( R.id.module_widgets_app_consult );
+ mHandler = mWindowManagerView.findViewById( R.id.module_widgets_app_handler_container );
+ mHandlerIcon = mWindowManagerView.findViewById( R.id.module_widgets_app_handler );
}
try {
if ( mWindowManagerView.isShowing() ) {
return;
}
+ if ( MogoApisHandler.getInstance()
+ .getApis()
+ .getStatusManagerApi()
+ .isMainPageOnResume() ) {
+ return;
+ }
mWindowManagerView.show();
MogoWidgetManger.getInstance().getApis().getAnalyticsApi().track( "NAVI_button_show", null );
AIAssist.getInstance( context ).registerUnWakeupCommand( OPEN, new String[]{"切换到辅助驾驶模式"}, this );
+ UiThreadHandler.postDelayed( mAutoNaviSyncRunnable, SYNC_INTERVAL );
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
}
}
+ private void chooseAction( View root, float xPos, float yPos ) {
+ if ( isInViewArea( root, mEnterApp, xPos, yPos ) ) {
+ enterApp( root.getContext() );
+ } else if ( isInViewArea( root, mHandler, xPos, yPos ) ) {
+ handleStyle( mHandler.getContext() );
+ } else if ( isInViewArea( root, mConsult, xPos, yPos ) ) {
+ consultUser( root.getContext() );
+ }
+ }
+
+ private boolean isInViewArea( View root, View target, float xPos, float yPos ) {
+ int loc[] = new int[2];
+ root.getLocationOnScreen( loc );
+ int rootX = loc[0];
+ int rootY = loc[1];
+
+ target.getLocationOnScreen( loc );
+ int targetX = loc[0];
+ int targetY = loc[1];
+ int targetWidth = target.getMeasuredWidth();
+ int targetHeight = target.getMeasuredHeight();
+
+ if ( xPos + rootX >= targetX
+ && xPos + rootX <= targetX + targetWidth
+ && yPos + rootY >= targetY
+ && yPos + rootY <= targetY + targetHeight ) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * 目的地车友
+ *
+ * @param context
+ */
+ private void consultUser( Context context ) {
+ mProperties.clear();
+ mProperties.put( "appname", CommonUtils.getAppName( context ) );
+ mProperties.put( "appversion", CommonUtils.getVersionName( context ) );
+ mProperties.put( "from", 9 );
+ mProperties.put( "type", "consult" );
+ MogoWidgetManger.getInstance().getApis().getAnalyticsApi().track( "appenterfront", mProperties );
+ if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isMainPageOnResume() ) {
+ MogoApisHandler.getInstance().getApis().getOnlineCarPanelApi().showPanel();
+ } else {
+ Intent start = new Intent( Intent.ACTION_VIEW );
+ start.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK );
+ start.setData( Uri.parse( "mogo://launcher/main/switch2?type=showOnlineCarPanel" ) );
+ context.startActivity( start );
+ }
+ }
+
+ private void handleStyle( Context context ) {
+ if ( mLargeStyle ) {
+ mEnterApp.setText( R.string.module_widgets_app_entrance_short );
+ mConsult.setText( R.string.module_widgets_app_consult_short );
+ mLargeStyle = false;
+ mHandlerIcon.setImageResource( R.drawable.module_widgets_app_handler_open );
+ } else {
+ mEnterApp.setText( R.string.module_widgets_app_entrance_text );
+ mConsult.setText( R.string.module_widgets_app_entrance_consult );
+ mLargeStyle = true;
+ mHandlerIcon.setImageResource( R.drawable.module_widgets_app_handler_close );
+ }
+ }
+
+ /**
+ * 进入app
+ *
+ * @param context
+ */
private void enterApp( Context context ) {
try {
if ( DebugConfig.isLauncher() ) {
@@ -120,11 +232,10 @@ class AutoNaviIntentHandler implements IMogoVoiceCmdCallBack {
} else {
LaunchUtils.launchByPkg( context, "com.mogo.launcher.app" );
}
- if ( mProperties.isEmpty() ) {
- mProperties.put( "appname", CommonUtils.getAppName( context ) );
- mProperties.put( "appversion", CommonUtils.getVersionName( context ) );
- mProperties.put( "from", 9 );
- }
+ mProperties.clear();
+ mProperties.put( "appname", CommonUtils.getAppName( context ) );
+ mProperties.put( "appversion", CommonUtils.getVersionName( context ) );
+ mProperties.put( "from", 9 );
MogoWidgetManger.getInstance().getApis().getAnalyticsApi().track( "appenterfront", mProperties );
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
@@ -132,6 +243,7 @@ class AutoNaviIntentHandler implements IMogoVoiceCmdCallBack {
}
public void closeEntrance() {
+ UiThreadHandler.removeCallbacks( mAutoNaviSyncRunnable );
if ( mWindowManagerView == null ) {
return;
}
@@ -144,6 +256,7 @@ class AutoNaviIntentHandler implements IMogoVoiceCmdCallBack {
}
public void syncAutoNaviForgroundStatus( Context context ) {
+ Logger.d( TAG, "查询高德前后台状态" );
Intent intent = new Intent();
intent.setAction( "AUTONAVI_STANDARD_BROADCAST_RECV" );
intent.putExtra( "KEY_TYPE", 12404 );
@@ -152,6 +265,7 @@ class AutoNaviIntentHandler implements IMogoVoiceCmdCallBack {
}
public void syncAutoNaviNavingStatus( Context context ) {
+ Logger.d( TAG, "查询高德导航状态" );
Intent intent = new Intent();
intent.setAction( "AUTONAVI_STANDARD_BROADCAST_RECV" );
intent.putExtra( "KEY_TYPE", 12404 );
@@ -162,7 +276,7 @@ class AutoNaviIntentHandler implements IMogoVoiceCmdCallBack {
@Override
public void onCmdSelected( String cmd ) {
if ( TextUtils.equals( OPEN, cmd ) ) {
- Logger.d(TAG, "recognized open command.");
+ Logger.d( TAG, "recognized open command." );
enterApp( AbsMogoApplication.getApp() );
}
}
diff --git a/modules/mogo-module-widgets/src/main/java/com/mogo/module/widgets/MogoWidgetManger.java b/modules/mogo-module-widgets/src/main/java/com/mogo/module/widgets/MogoWidgetManger.java
index 289c0a30ca..8d1e7d41bc 100644
--- a/modules/mogo-module-widgets/src/main/java/com/mogo/module/widgets/MogoWidgetManger.java
+++ b/modules/mogo-module-widgets/src/main/java/com/mogo/module/widgets/MogoWidgetManger.java
@@ -3,12 +3,14 @@ package com.mogo.module.widgets;
import android.content.Context;
import android.content.Intent;
-import com.alibaba.android.arouter.launcher.ARouter;
+import com.mogo.commons.storage.SpStorage;
import com.mogo.map.navi.IMogoNaviListener2;
+import com.mogo.module.common.MogoApisHandler;
import com.mogo.service.IMogoServiceApis;
import com.mogo.service.intent.IMogoIntentListener;
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
import com.mogo.service.statusmanager.StatusDescriptor;
+import com.mogo.utils.UiThreadHandler;
public
/**
@@ -60,11 +62,13 @@ class MogoWidgetManger implements IMogoNaviListener2, IMogoIntentListener, IMogo
public void init( Context context ) {
mContext = context;
- mApis = ARouter.getInstance().navigation( IMogoServiceApis.class );
+ mApis = MogoApisHandler.getInstance().getApis();
initMapStatusListener();
initStatusListener();
initIntentListener();
- AutoNaviIntentHandler.getInstance().syncAutoNaviForgroundStatus( mContext );
+ UiThreadHandler.postDelayed( ()->{
+ AutoNaviIntentHandler.getInstance().syncAutoNaviForgroundStatus( mContext );
+ }, 1_000L );
}
private void initMapStatusListener() {
diff --git a/modules/mogo-module-widgets/src/main/java/com/mogo/module/widgets/MogoWidgetsProvider.java b/modules/mogo-module-widgets/src/main/java/com/mogo/module/widgets/MogoWidgetsProvider.java
index 6cc91544a3..a4985601b7 100644
--- a/modules/mogo-module-widgets/src/main/java/com/mogo/module/widgets/MogoWidgetsProvider.java
+++ b/modules/mogo-module-widgets/src/main/java/com/mogo/module/widgets/MogoWidgetsProvider.java
@@ -94,6 +94,6 @@ class MogoWidgetsProvider implements IMogoModuleProvider {
Logger.d( TAG, "init." );
UiThreadHandler.postDelayed( () -> {
MogoWidgetManger.getInstance().init( context );
- }, 5500 );
+ }, 6_000L );
}
}
diff --git a/modules/mogo-module-widgets/src/main/res/drawable-ldpi/module_widgets_app_entrance_img_bkg.png b/modules/mogo-module-widgets/src/main/res/drawable-ldpi/module_widgets_app_entrance_img_bkg.png
deleted file mode 100644
index 0af1eeda01..0000000000
Binary files a/modules/mogo-module-widgets/src/main/res/drawable-ldpi/module_widgets_app_entrance_img_bkg.png and /dev/null differ
diff --git a/modules/mogo-module-widgets/src/main/res/drawable-ldpi/module_widgets_app_entrance_root_bkg.9.png b/modules/mogo-module-widgets/src/main/res/drawable-ldpi/module_widgets_app_entrance_root_bkg.9.png
new file mode 100644
index 0000000000..c1d5b757c4
Binary files /dev/null and b/modules/mogo-module-widgets/src/main/res/drawable-ldpi/module_widgets_app_entrance_root_bkg.9.png differ
diff --git a/modules/mogo-module-widgets/src/main/res/drawable-ldpi/module_widgets_app_handler_close.png b/modules/mogo-module-widgets/src/main/res/drawable-ldpi/module_widgets_app_handler_close.png
new file mode 100644
index 0000000000..6a4c017737
Binary files /dev/null and b/modules/mogo-module-widgets/src/main/res/drawable-ldpi/module_widgets_app_handler_close.png differ
diff --git a/modules/mogo-module-widgets/src/main/res/drawable-ldpi/module_widgets_app_handler_open.png b/modules/mogo-module-widgets/src/main/res/drawable-ldpi/module_widgets_app_handler_open.png
new file mode 100644
index 0000000000..c878de52df
Binary files /dev/null and b/modules/mogo-module-widgets/src/main/res/drawable-ldpi/module_widgets_app_handler_open.png differ
diff --git a/modules/mogo-module-widgets/src/main/res/drawable-mdpi/module_widgets_app_entrance_root_bkg.9.png b/modules/mogo-module-widgets/src/main/res/drawable-mdpi/module_widgets_app_entrance_root_bkg.9.png
new file mode 100644
index 0000000000..c1d5b757c4
Binary files /dev/null and b/modules/mogo-module-widgets/src/main/res/drawable-mdpi/module_widgets_app_entrance_root_bkg.9.png differ
diff --git a/modules/mogo-module-widgets/src/main/res/drawable-mdpi/module_widgets_app_handler_close.png b/modules/mogo-module-widgets/src/main/res/drawable-mdpi/module_widgets_app_handler_close.png
new file mode 100644
index 0000000000..6a4c017737
Binary files /dev/null and b/modules/mogo-module-widgets/src/main/res/drawable-mdpi/module_widgets_app_handler_close.png differ
diff --git a/modules/mogo-module-widgets/src/main/res/drawable-mdpi/module_widgets_app_handler_open.png b/modules/mogo-module-widgets/src/main/res/drawable-mdpi/module_widgets_app_handler_open.png
new file mode 100644
index 0000000000..c878de52df
Binary files /dev/null and b/modules/mogo-module-widgets/src/main/res/drawable-mdpi/module_widgets_app_handler_open.png differ
diff --git a/modules/mogo-module-widgets/src/main/res/drawable-xhdpi/module_widgets_app_entrance_root_bkg.9.png b/modules/mogo-module-widgets/src/main/res/drawable-xhdpi/module_widgets_app_entrance_root_bkg.9.png
new file mode 100644
index 0000000000..18a9b23349
Binary files /dev/null and b/modules/mogo-module-widgets/src/main/res/drawable-xhdpi/module_widgets_app_entrance_root_bkg.9.png differ
diff --git a/modules/mogo-module-widgets/src/main/res/drawable-xhdpi/module_widgets_app_handler_close.png b/modules/mogo-module-widgets/src/main/res/drawable-xhdpi/module_widgets_app_handler_close.png
new file mode 100644
index 0000000000..2faa623d9a
Binary files /dev/null and b/modules/mogo-module-widgets/src/main/res/drawable-xhdpi/module_widgets_app_handler_close.png differ
diff --git a/modules/mogo-module-widgets/src/main/res/drawable-xhdpi/module_widgets_app_handler_open.png b/modules/mogo-module-widgets/src/main/res/drawable-xhdpi/module_widgets_app_handler_open.png
new file mode 100644
index 0000000000..cb114a6bcc
Binary files /dev/null and b/modules/mogo-module-widgets/src/main/res/drawable-xhdpi/module_widgets_app_handler_open.png differ
diff --git a/modules/mogo-module-widgets/src/main/res/drawable/module_widgets_app_body_bkg.xml b/modules/mogo-module-widgets/src/main/res/drawable/module_widgets_app_body_bkg.xml
new file mode 100644
index 0000000000..f72fea0bbc
--- /dev/null
+++ b/modules/mogo-module-widgets/src/main/res/drawable/module_widgets_app_body_bkg.xml
@@ -0,0 +1,9 @@
+
+
+ -
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-widgets/src/main/res/drawable/module_widgets_app_entrance_img_bkg.png b/modules/mogo-module-widgets/src/main/res/drawable/module_widgets_app_entrance_img_bkg.png
deleted file mode 100644
index 0af1eeda01..0000000000
Binary files a/modules/mogo-module-widgets/src/main/res/drawable/module_widgets_app_entrance_img_bkg.png and /dev/null differ
diff --git a/modules/mogo-module-widgets/src/main/res/drawable/module_widgets_app_entrance_root_bkg.9.png b/modules/mogo-module-widgets/src/main/res/drawable/module_widgets_app_entrance_root_bkg.9.png
new file mode 100644
index 0000000000..c1d5b757c4
Binary files /dev/null and b/modules/mogo-module-widgets/src/main/res/drawable/module_widgets_app_entrance_root_bkg.9.png differ
diff --git a/modules/mogo-module-widgets/src/main/res/drawable/module_widgets_app_handler_bkg.xml b/modules/mogo-module-widgets/src/main/res/drawable/module_widgets_app_handler_bkg.xml
new file mode 100644
index 0000000000..a05ac7bfbc
--- /dev/null
+++ b/modules/mogo-module-widgets/src/main/res/drawable/module_widgets_app_handler_bkg.xml
@@ -0,0 +1,9 @@
+
+
+ -
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-widgets/src/main/res/layout/module_widgets_app_entrance.xml b/modules/mogo-module-widgets/src/main/res/layout/module_widgets_app_entrance.xml
index 5ea9b7fe2a..18772c4556 100644
--- a/modules/mogo-module-widgets/src/main/res/layout/module_widgets_app_entrance.xml
+++ b/modules/mogo-module-widgets/src/main/res/layout/module_widgets_app_entrance.xml
@@ -1,17 +1,66 @@
+ android:background="@drawable/module_widgets_app_entrance_root_bkg"
+ android:gravity="center_vertical"
+ android:padding="@dimen/module_widgets_app_entrance_root_padding">
+
+
+
+
+
+
+ android:textColor="@color/module_widgets_app_entrance_textColor"
+ android:textSize="@dimen/module_widgets_app_entrance_textSize"
+ android:textStyle="bold" />
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-widgets/src/main/res/values-ldpi/dimens.xml b/modules/mogo-module-widgets/src/main/res/values-ldpi/dimens.xml
index bbd70cad6e..5bfa3a220b 100644
--- a/modules/mogo-module-widgets/src/main/res/values-ldpi/dimens.xml
+++ b/modules/mogo-module-widgets/src/main/res/values-ldpi/dimens.xml
@@ -1,11 +1,15 @@
- 20px
+ 22px
15px
2px
- 505px
+ 503px
501px
- 10px
- 15px
+ 20px
+ 27px
71px
+ 4px
+ 56px
+ 40px
+ 7px
\ No newline at end of file
diff --git a/modules/mogo-module-widgets/src/main/res/values-mdpi/dimens.xml b/modules/mogo-module-widgets/src/main/res/values-mdpi/dimens.xml
index bbd70cad6e..5bfa3a220b 100644
--- a/modules/mogo-module-widgets/src/main/res/values-mdpi/dimens.xml
+++ b/modules/mogo-module-widgets/src/main/res/values-mdpi/dimens.xml
@@ -1,11 +1,15 @@
- 20px
+ 22px
15px
2px
- 505px
+ 503px
501px
- 10px
- 15px
+ 20px
+ 27px
71px
+ 4px
+ 56px
+ 40px
+ 7px
\ No newline at end of file
diff --git a/modules/mogo-module-widgets/src/main/res/values-xhdpi-1920x1000/dimens.xml b/modules/mogo-module-widgets/src/main/res/values-xhdpi-1920x1000/dimens.xml
index e4fc6151e3..ab9b044c6c 100644
--- a/modules/mogo-module-widgets/src/main/res/values-xhdpi-1920x1000/dimens.xml
+++ b/modules/mogo-module-widgets/src/main/res/values-xhdpi-1920x1000/dimens.xml
@@ -3,9 +3,13 @@
40px
30px
4px
- 48px
- 1000px
- 10px
- 15px
+ 906px
+ 1316px
+ 37px
+ 50px
71px
+ 8px
+ 100px
+ 85px
+ 8px
\ No newline at end of file
diff --git a/modules/mogo-module-widgets/src/main/res/values-xhdpi/dimens.xml b/modules/mogo-module-widgets/src/main/res/values-xhdpi/dimens.xml
index e4fc6151e3..ab9b044c6c 100644
--- a/modules/mogo-module-widgets/src/main/res/values-xhdpi/dimens.xml
+++ b/modules/mogo-module-widgets/src/main/res/values-xhdpi/dimens.xml
@@ -3,9 +3,13 @@
40px
30px
4px
- 48px
- 1000px
- 10px
- 15px
+ 906px
+ 1316px
+ 37px
+ 50px
71px
+ 8px
+ 100px
+ 85px
+ 8px
\ No newline at end of file
diff --git a/modules/mogo-module-widgets/src/main/res/values/colors.xml b/modules/mogo-module-widgets/src/main/res/values/colors.xml
new file mode 100644
index 0000000000..8184cc697b
--- /dev/null
+++ b/modules/mogo-module-widgets/src/main/res/values/colors.xml
@@ -0,0 +1,4 @@
+
+
+ #FFFFFF
+
\ No newline at end of file
diff --git a/modules/mogo-module-widgets/src/main/res/values/dimens.xml b/modules/mogo-module-widgets/src/main/res/values/dimens.xml
index e4fc6151e3..5bfa3a220b 100644
--- a/modules/mogo-module-widgets/src/main/res/values/dimens.xml
+++ b/modules/mogo-module-widgets/src/main/res/values/dimens.xml
@@ -1,11 +1,15 @@
- 40px
- 30px
- 4px
- 48px
- 1000px
- 10px
- 15px
+ 22px
+ 15px
+ 2px
+ 503px
+ 501px
+ 20px
+ 27px
71px
+ 4px
+ 56px
+ 40px
+ 7px
\ No newline at end of file
diff --git a/modules/mogo-module-widgets/src/main/res/values/strings.xml b/modules/mogo-module-widgets/src/main/res/values/strings.xml
index d824f729d5..1207c6ab0b 100644
--- a/modules/mogo-module-widgets/src/main/res/values/strings.xml
+++ b/modules/mogo-module-widgets/src/main/res/values/strings.xml
@@ -1,4 +1,7 @@
mogo-module-service
- 切换辅助驾驶
+ 辅助驾驶模式
+ 咨询终点车友
+ 辅
+ 咨
diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/IMogoServiceApis.java b/services/mogo-service-api/src/main/java/com/mogo/service/IMogoServiceApis.java
index c542925842..f6e0f9ee03 100644
--- a/services/mogo-service-api/src/main/java/com/mogo/service/IMogoServiceApis.java
+++ b/services/mogo-service-api/src/main/java/com/mogo/service/IMogoServiceApis.java
@@ -30,9 +30,10 @@ import com.mogo.service.passport.IMogoPassportManager;
import com.mogo.service.share.IMogoShareManager;
import com.mogo.service.statusmanager.IMogoMsgCenter;
import com.mogo.service.statusmanager.IMogoStatusManager;
+import com.mogo.service.strategy.IMogoOnlineCarListPanelProvider;
import com.mogo.service.strategy.IMogoRefreshStrategyController;
-import com.mogo.service.tanlu.IMogoTanluProvider;
-import com.mogo.service.tanlu.IMogoTanluUiProvider;
+import com.mogo.service.share.IMogoTanluProvider;
+import com.mogo.service.share.IMogoTanluUiProvider;
import com.mogo.service.windowview.IMogoTopViewManager;
import com.mogo.service.windowview.IMogoWindowManager;
import com.mogo.skin.support.IMogoSkinSupportInstaller;
@@ -58,6 +59,7 @@ public interface IMogoServiceApis extends IProvider {
*
* @return
*/
+ @Deprecated
IMogoCardManager getCardManagerApi();
/**
@@ -269,4 +271,10 @@ public interface IMogoServiceApis extends IProvider {
* @return
*/
IMogoCrashWarnProvider getCrashWarnProvider();
+
+ /**
+ * 在线车辆面板
+ * @return
+ */
+ IMogoOnlineCarListPanelProvider getOnlineCarPanelApi();
}
diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/MogoServicePaths.java b/services/mogo-service-api/src/main/java/com/mogo/service/MogoServicePaths.java
index 0010dcb332..8184350abf 100644
--- a/services/mogo-service-api/src/main/java/com/mogo/service/MogoServicePaths.java
+++ b/services/mogo-service-api/src/main/java/com/mogo/service/MogoServicePaths.java
@@ -261,4 +261,9 @@ public class MogoServicePaths {
* 悬浮小控件
*/
public static final String PATH_WIDGETS = "/widgets/provider";
+
+ /**
+ * 在线好友面板
+ */
+ public static final String PATH_ONLINE_CAR_PANEL = "/onlinecar/panel";
}
diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/adas/IMogoADASController.java b/services/mogo-service-api/src/main/java/com/mogo/service/adas/IMogoADASController.java
index 0af6686b91..0953142c53 100644
--- a/services/mogo-service-api/src/main/java/com/mogo/service/adas/IMogoADASController.java
+++ b/services/mogo-service-api/src/main/java/com/mogo/service/adas/IMogoADASController.java
@@ -68,4 +68,11 @@ public interface IMogoADASController extends IProvider {
* @return
*/
EnumMapUI getCurrentSkinMode();
+
+ /**
+ * 给adas传递数据
+ *
+ * @param json
+ */
+ void notifyAdas( String json );
}
diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/cardmanager/IMogoCardManager.java b/services/mogo-service-api/src/main/java/com/mogo/service/cardmanager/IMogoCardManager.java
index a2eab1d620..74ccb18ef6 100644
--- a/services/mogo-service-api/src/main/java/com/mogo/service/cardmanager/IMogoCardManager.java
+++ b/services/mogo-service-api/src/main/java/com/mogo/service/cardmanager/IMogoCardManager.java
@@ -8,6 +8,7 @@ import com.alibaba.android.arouter.facade.template.IProvider;
*
* 卡片管理
*/
+@Deprecated
public interface IMogoCardManager extends IProvider {
/**
diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/fragmentmanager/IFragmentProvider.java b/services/mogo-service-api/src/main/java/com/mogo/service/fragmentmanager/IFragmentProvider.java
index 548e0f1e0d..d7e96a313c 100644
--- a/services/mogo-service-api/src/main/java/com/mogo/service/fragmentmanager/IFragmentProvider.java
+++ b/services/mogo-service-api/src/main/java/com/mogo/service/fragmentmanager/IFragmentProvider.java
@@ -17,4 +17,6 @@ public
interface IFragmentProvider extends IProvider {
Fragment createFragment( FragmentActivity activity, int containerId, Bundle date );
+
+ public void onDestroy();
}
diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/fragmentmanager/IMogoFragmentManager.java b/services/mogo-service-api/src/main/java/com/mogo/service/fragmentmanager/IMogoFragmentManager.java
index 5a006f9195..937d381963 100644
--- a/services/mogo-service-api/src/main/java/com/mogo/service/fragmentmanager/IMogoFragmentManager.java
+++ b/services/mogo-service-api/src/main/java/com/mogo/service/fragmentmanager/IMogoFragmentManager.java
@@ -43,6 +43,11 @@ public interface IMogoFragmentManager extends IProvider {
*/
void registerMainFragmentStackTransactionListener( FragmentStackTransactionListener listener );
+ /**
+ * 主页移除栈变化监听
+ */
+ void unregisterMainFragmentStackTransactionListener();
+
/**
* 其他注册栈变化监听
*
@@ -67,9 +72,10 @@ public interface IMogoFragmentManager extends IProvider {
/**
* 缓存历史消息
+ *
* @param layoutId
*/
- void initMessageHistoryContainerId(int layoutId);
+ void initMessageHistoryContainerId( int layoutId );
int getMessageHistoryContainerId();
}
diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/module/IMogoModuleProvider.java b/services/mogo-service-api/src/main/java/com/mogo/service/module/IMogoModuleProvider.java
index 524010759b..fec00c557c 100644
--- a/services/mogo-service-api/src/main/java/com/mogo/service/module/IMogoModuleProvider.java
+++ b/services/mogo-service-api/src/main/java/com/mogo/service/module/IMogoModuleProvider.java
@@ -2,6 +2,7 @@ package com.mogo.service.module;
import android.content.Context;
import android.os.Bundle;
+import android.util.Log;
import android.view.View;
import androidx.annotation.NonNull;
@@ -13,6 +14,8 @@ import com.mogo.map.location.IMogoLocationListener;
import com.mogo.map.marker.IMogoMarkerClickListener;
import com.mogo.map.navi.IMogoNaviListener;
+import java.util.logging.Logger;
+
/**
* @author congtaowang
* @since 2019-12-24
@@ -128,4 +131,8 @@ public interface IMogoModuleProvider extends IProvider {
default String getAppName() {
return "";
}
+
+ default void onDestroy(){
+ Log.d( "IMogoModuleProvider", "onDestroy" );
+ }
}
diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/share/IMogoShareManager.java b/services/mogo-service-api/src/main/java/com/mogo/service/share/IMogoShareManager.java
index 17a29d3455..ca0285449c 100644
--- a/services/mogo-service-api/src/main/java/com/mogo/service/share/IMogoShareManager.java
+++ b/services/mogo-service-api/src/main/java/com/mogo/service/share/IMogoShareManager.java
@@ -25,4 +25,6 @@ public interface IMogoShareManager extends IProvider {
* @param context 待重置的上下文
*/
void resetContext(Context context);
+
+ void releaseContext();
}
diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/tanlu/IMogoTanluProvider.java b/services/mogo-service-api/src/main/java/com/mogo/service/share/IMogoTanluProvider.java
similarity index 98%
rename from services/mogo-service-api/src/main/java/com/mogo/service/tanlu/IMogoTanluProvider.java
rename to services/mogo-service-api/src/main/java/com/mogo/service/share/IMogoTanluProvider.java
index 77cebf1b3a..994e811744 100644
--- a/services/mogo-service-api/src/main/java/com/mogo/service/tanlu/IMogoTanluProvider.java
+++ b/services/mogo-service-api/src/main/java/com/mogo/service/share/IMogoTanluProvider.java
@@ -1,4 +1,4 @@
-package com.mogo.service.tanlu;
+package com.mogo.service.share;
import com.alibaba.android.arouter.facade.template.IProvider;
diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/tanlu/IMogoTanluUiProvider.java b/services/mogo-service-api/src/main/java/com/mogo/service/share/IMogoTanluUiProvider.java
similarity index 96%
rename from services/mogo-service-api/src/main/java/com/mogo/service/tanlu/IMogoTanluUiProvider.java
rename to services/mogo-service-api/src/main/java/com/mogo/service/share/IMogoTanluUiProvider.java
index 1b7ce77f3c..53d0aa6cd6 100644
--- a/services/mogo-service-api/src/main/java/com/mogo/service/tanlu/IMogoTanluUiProvider.java
+++ b/services/mogo-service-api/src/main/java/com/mogo/service/share/IMogoTanluUiProvider.java
@@ -1,4 +1,4 @@
-package com.mogo.service.tanlu;
+package com.mogo.service.share;
import com.alibaba.android.arouter.facade.template.IProvider;
import com.mogo.map.MogoLatLng;
diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/tanlu/TanluUploadParams.java b/services/mogo-service-api/src/main/java/com/mogo/service/share/TanluUploadParams.java
similarity index 98%
rename from services/mogo-service-api/src/main/java/com/mogo/service/tanlu/TanluUploadParams.java
rename to services/mogo-service-api/src/main/java/com/mogo/service/share/TanluUploadParams.java
index e63f637d79..448a918057 100644
--- a/services/mogo-service-api/src/main/java/com/mogo/service/tanlu/TanluUploadParams.java
+++ b/services/mogo-service-api/src/main/java/com/mogo/service/share/TanluUploadParams.java
@@ -1,4 +1,4 @@
-package com.mogo.service.tanlu;
+package com.mogo.service.share;
import com.mogo.map.MogoLatLng;
diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/strategy/IMogoOnlineCarListPanelProvider.java b/services/mogo-service-api/src/main/java/com/mogo/service/strategy/IMogoOnlineCarListPanelProvider.java
new file mode 100644
index 0000000000..6daf1c858b
--- /dev/null
+++ b/services/mogo-service-api/src/main/java/com/mogo/service/strategy/IMogoOnlineCarListPanelProvider.java
@@ -0,0 +1,24 @@
+package com.mogo.service.strategy;
+
+import androidx.annotation.IdRes;
+import androidx.fragment.app.FragmentActivity;
+
+import com.alibaba.android.arouter.facade.template.IProvider;
+
+public
+/**
+ * @author congtaowang
+ * @since 2020/9/21
+ *
+ * 描述
+ */
+interface IMogoOnlineCarListPanelProvider extends IProvider {
+
+ void initContainer( @IdRes int containerId, FragmentActivity activity );
+
+ void showPanel();
+
+ void hidePanel();
+
+ void clear();
+}
diff --git a/services/mogo-service/src/main/java/com/mogo/service/impl/MogoServiceApis.java b/services/mogo-service/src/main/java/com/mogo/service/impl/MogoServiceApis.java
index d98c650ad2..36f61a534f 100644
--- a/services/mogo-service/src/main/java/com/mogo/service/impl/MogoServiceApis.java
+++ b/services/mogo-service/src/main/java/com/mogo/service/impl/MogoServiceApis.java
@@ -38,9 +38,10 @@ import com.mogo.service.passport.IMogoPassportManager;
import com.mogo.service.share.IMogoShareManager;
import com.mogo.service.statusmanager.IMogoMsgCenter;
import com.mogo.service.statusmanager.IMogoStatusManager;
+import com.mogo.service.strategy.IMogoOnlineCarListPanelProvider;
import com.mogo.service.strategy.IMogoRefreshStrategyController;
-import com.mogo.service.tanlu.IMogoTanluProvider;
-import com.mogo.service.tanlu.IMogoTanluUiProvider;
+import com.mogo.service.share.IMogoTanluProvider;
+import com.mogo.service.share.IMogoTanluUiProvider;
import com.mogo.service.windowview.IMogoTopViewManager;
import com.mogo.service.windowview.IMogoWindowManager;
import com.mogo.skin.support.IMogoSkinSupportInstaller;
@@ -112,6 +113,7 @@ public class MogoServiceApis implements IMogoServiceApis {
}
@Override
+ @Deprecated
public synchronized IMogoCardManager getCardManagerApi() {
return getApiInstance( IMogoCardManager.class, MogoServicePaths.PATH_CARD_MANAGER );
}
@@ -231,7 +233,12 @@ public class MogoServiceApis implements IMogoServiceApis {
return getApiInstance(IMogoCrashWarnProvider.class, MogoServicePaths.PATH_CRASH_WARNING);
}
- private static < T extends IProvider > T getApiInstance(Class< T > clazz, String path ) {
+ @Override
+ public IMogoOnlineCarListPanelProvider getOnlineCarPanelApi() {
+ return getApiInstance( IMogoOnlineCarListPanelProvider.class, MogoServicePaths.PATH_ONLINE_CAR_PANEL);
+ }
+
+ private static < T extends IProvider > T getApiInstance( Class< T > clazz, String path ) {
T inst = SingletonsHolder.get( clazz );
if ( inst == null ) {
synchronized ( sLock ) {
diff --git a/services/mogo-service/src/main/java/com/mogo/service/impl/adas/MogoADASController.java b/services/mogo-service/src/main/java/com/mogo/service/impl/adas/MogoADASController.java
index 15b69e9ce3..05d216b9b7 100644
--- a/services/mogo-service/src/main/java/com/mogo/service/impl/adas/MogoADASController.java
+++ b/services/mogo-service/src/main/java/com/mogo/service/impl/adas/MogoADASController.java
@@ -5,22 +5,16 @@ import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
-import android.os.RemoteException;
import android.util.Log;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.commons.AbsMogoApplication;
-import com.mogo.commons.debug.DebugConfig;
-import com.mogo.map.MogoOverlayManager;
import com.mogo.map.uicontroller.EnumMapUI;
import com.mogo.module.common.utils.CarSeries;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.adas.IMogoADASController;
-import com.mogo.service.impl.MogoServiceApis;
import com.mogo.service.impl.singleton.SingletonsHolder;
-import com.mogo.service.impl.statusmanager.MogoStatusManager;
import com.mogo.service.statusmanager.IMogoStatusManager;
-import com.mogo.skin.support.SkinMode;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.storage.SharedPrefsMgr;
@@ -35,7 +29,7 @@ import org.json.JSONObject;
import java.util.List;
-import static com.mogo.commons.debug.DebugConfig.getSpGuide;
+import static com.mogo.module.common.utils.SPConst.getSpGuide;
/**
* @author congtaowang
@@ -78,14 +72,9 @@ public class MogoADASController implements IMogoADASController {
@Override
public void showADAS() {
-
- // TODO: 2020/9/4 和引导模块交互
- if ( DebugConfig.isLoadGuideModule() ) {
- if ( !SharedPrefsMgr.getInstance( AbsMogoApplication.getApp() ).getBoolean( getSpGuide(), false ) ) {
- return;
- }
+ if ( !SharedPrefsMgr.getInstance( AbsMogoApplication.getApp() ).getBoolean( getSpGuide(), false ) ) {
+ return;
}
-
Logger.d( TAG, Log.getStackTraceString( new Throwable() ) );
init( AbsMogoApplication.getApp() );
AutopilotServiceManage.getInstance().registerAutopilotServiceStatusListener( new IAutopilotServiceStatusListener() {
@@ -170,40 +159,6 @@ public class MogoADASController implements IMogoADASController {
mIsReleased = false;
}
- //获取已安装应用的 uid,-1 表示未安装此应用或程序异常
- public static int getPackageUid( Context context, String packageName ) {
- try {
- ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo( packageName, 0 );
- if ( applicationInfo != null ) {
- return applicationInfo.uid;
- }
- } catch ( Exception e ) {
- return -1;
- }
- return -1;
- }
-
- /**
- * 判断某一 uid 的程序是否有正在运行的进程,即是否存活
- * Created by cafeting on 2017/2/4.
- *
- * @param context 上下文
- * @param uid 已安装应用的 uid
- * @return true 表示正在运行,false 表示没有运行
- */
- public static boolean isProcessRunning( Context context, int uid ) {
- ActivityManager am = ( ActivityManager ) context.getSystemService( Context.ACTIVITY_SERVICE );
- List< ActivityManager.RunningServiceInfo > runningServiceInfos = am.getRunningServices( 200 );
- if ( runningServiceInfos.size() > 0 ) {
- for ( ActivityManager.RunningServiceInfo appProcess : runningServiceInfos ) {
- if ( uid == appProcess.uid ) {
- return true;
- }
- }
- }
- return false;
- }
-
@Override
public void setSettingStatus( boolean show ) {
AutopilotServiceManage.getInstance().setSettingStatus( show );
@@ -256,6 +211,15 @@ public class MogoADASController implements IMogoADASController {
return EnumMapUI.Type_Light;
}
+ @Override
+ public void notifyAdas( String json ) {
+ try {
+// AutopilotServiceManage.getInstance().aiCloudToAdasData( json );
+ } catch ( Exception e ) {
+ Logger.e( TAG, e, "notifyAdas" );
+ }
+ }
+
@Override
public void release() {
mIsReleased = true;
diff --git a/services/mogo-service/src/main/java/com/mogo/service/impl/fragmentmanager/FragmentStack.java b/services/mogo-service/src/main/java/com/mogo/service/impl/fragmentmanager/FragmentStack.java
index 083ea0ddd8..41eeb123b8 100644
--- a/services/mogo-service/src/main/java/com/mogo/service/impl/fragmentmanager/FragmentStack.java
+++ b/services/mogo-service/src/main/java/com/mogo/service/impl/fragmentmanager/FragmentStack.java
@@ -30,7 +30,6 @@ public class FragmentStack {
private FragmentManager mFragmentManager;
//private FragmentTransaction mFragmentTransaction;
private int mContainerId;
- private Activity mActivity;
private FragmentDescriptor mCurrentFragment;
private FragmentStackTransactionListener mFragmentStackTransactionListener;
@@ -56,7 +55,6 @@ public class FragmentStack {
}
public void init( AppCompatActivity activity, int containerId ) {
- mActivity = activity;
mFragmentManager = activity.getSupportFragmentManager();
mContainerId = containerId;
}
diff --git a/services/mogo-service/src/main/java/com/mogo/service/impl/fragmentmanager/MogoFragmentManager.java b/services/mogo-service/src/main/java/com/mogo/service/impl/fragmentmanager/MogoFragmentManager.java
index 9894728619..249b72a1a5 100644
--- a/services/mogo-service/src/main/java/com/mogo/service/impl/fragmentmanager/MogoFragmentManager.java
+++ b/services/mogo-service/src/main/java/com/mogo/service/impl/fragmentmanager/MogoFragmentManager.java
@@ -44,6 +44,11 @@ public class MogoFragmentManager implements IMogoFragmentManager {
FragmentStack.getInstance().setFragmentStackTransactionListener( listener );
}
+ @Override
+ public void unregisterMainFragmentStackTransactionListener() {
+ FragmentStack.getInstance().setFragmentStackTransactionListener( null );
+ }
+
@Override
public void addMainFragmentStackTransactionListener( FragmentStackTransactionListener listener ) {
FragmentStack.getInstance().addFragmentStackTransactionListener( listener );
diff --git a/settings.gradle b/settings.gradle
index fa434b5b48..9f7e5afea2 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,3 +1,7 @@
+include ':tts:tts-base'
+include ':tts:tts-di'
+include ':tts:tts-zhi'
+include ':tts:tts-noop'
include ':test:crashreport'
include ':test:crashreport-bugly'
include ':test:crashreport-noop'
@@ -58,3 +62,4 @@ include ':modules:mogo-module-tanlu'
include ':libraries:tanlulib'
include ':skin'
include ':test'
+include ':tts'
diff --git a/skin/mogo-skin-light/build.gradle b/skin/mogo-skin-light/build.gradle
index cfcc4a9d2f..8ca29207b3 100644
--- a/skin/mogo-skin-light/build.gradle
+++ b/skin/mogo-skin-light/build.gradle
@@ -41,8 +41,10 @@ android {
'src/main/module-share-res',
'src/main/module-main-res',
'src/main/module-tanlu-res',
+ 'src/main/module-common-res',
'src/main/module-commons-res',
'src/main/module-media-res',
+ 'src/main/mogo-module-widgets-res',
]
}
}
diff --git a/skin/mogo-skin-light/src/main/module-callchat-res/mipmap-ldpi/module_callchatting_user_close_light.png b/skin/mogo-skin-light/src/main/module-callchat-res/mipmap-ldpi/module_callchatting_user_close_light.png
new file mode 100644
index 0000000000..6de4846972
Binary files /dev/null and b/skin/mogo-skin-light/src/main/module-callchat-res/mipmap-ldpi/module_callchatting_user_close_light.png differ
diff --git a/skin/mogo-skin-light/src/main/module-callchat-res/mipmap-ldpi/module_carchatting_user_cover_bg_light.png b/skin/mogo-skin-light/src/main/module-callchat-res/mipmap-ldpi/module_carchatting_user_cover_bg_light.png
new file mode 100644
index 0000000000..bcddfcc01c
Binary files /dev/null and b/skin/mogo-skin-light/src/main/module-callchat-res/mipmap-ldpi/module_carchatting_user_cover_bg_light.png differ
diff --git a/skin/mogo-skin-light/src/main/module-callchat-res/mipmap-mdpi/module_callchatting_user_close_light.png b/skin/mogo-skin-light/src/main/module-callchat-res/mipmap-mdpi/module_callchatting_user_close_light.png
new file mode 100644
index 0000000000..6de4846972
Binary files /dev/null and b/skin/mogo-skin-light/src/main/module-callchat-res/mipmap-mdpi/module_callchatting_user_close_light.png differ
diff --git a/skin/mogo-skin-light/src/main/module-callchat-res/mipmap-mdpi/module_carchatting_user_cover_bg_light.png b/skin/mogo-skin-light/src/main/module-callchat-res/mipmap-mdpi/module_carchatting_user_cover_bg_light.png
new file mode 100644
index 0000000000..bcddfcc01c
Binary files /dev/null and b/skin/mogo-skin-light/src/main/module-callchat-res/mipmap-mdpi/module_carchatting_user_cover_bg_light.png differ
diff --git a/skin/mogo-skin-light/src/main/module-callchat-res/mipmap-xhdpi/module_callchatting_user_close_light.png b/skin/mogo-skin-light/src/main/module-callchat-res/mipmap-xhdpi/module_callchatting_user_close_light.png
new file mode 100644
index 0000000000..cc00f7d153
Binary files /dev/null and b/skin/mogo-skin-light/src/main/module-callchat-res/mipmap-xhdpi/module_callchatting_user_close_light.png differ
diff --git a/skin/mogo-skin-light/src/main/module-callchat-res/mipmap-xhdpi/module_carchatting_user_cover_bg_light.png b/skin/mogo-skin-light/src/main/module-callchat-res/mipmap-xhdpi/module_carchatting_user_cover_bg_light.png
new file mode 100644
index 0000000000..08b2f94b17
Binary files /dev/null and b/skin/mogo-skin-light/src/main/module-callchat-res/mipmap-xhdpi/module_carchatting_user_cover_bg_light.png differ
diff --git a/skin/mogo-skin-light/src/main/module-common-res/drawable-ldpi/icon_heart_choose_light.png b/skin/mogo-skin-light/src/main/module-common-res/drawable-ldpi/icon_heart_choose_light.png
new file mode 100644
index 0000000000..5e35352bfd
Binary files /dev/null and b/skin/mogo-skin-light/src/main/module-common-res/drawable-ldpi/icon_heart_choose_light.png differ
diff --git a/skin/mogo-skin-light/src/main/module-common-res/drawable-ldpi/icon_heart_second_light.png b/skin/mogo-skin-light/src/main/module-common-res/drawable-ldpi/icon_heart_second_light.png
new file mode 100644
index 0000000000..4fda591483
Binary files /dev/null and b/skin/mogo-skin-light/src/main/module-common-res/drawable-ldpi/icon_heart_second_light.png differ
diff --git a/skin/mogo-skin-light/src/main/module-common-res/drawable-ldpi/icon_heart_unchoose_light.png b/skin/mogo-skin-light/src/main/module-common-res/drawable-ldpi/icon_heart_unchoose_light.png
new file mode 100644
index 0000000000..20d32c67f0
Binary files /dev/null and b/skin/mogo-skin-light/src/main/module-common-res/drawable-ldpi/icon_heart_unchoose_light.png differ
diff --git a/skin/mogo-skin-light/src/main/module-common-res/drawable-mdpi/icon_heart_choose_light.png b/skin/mogo-skin-light/src/main/module-common-res/drawable-mdpi/icon_heart_choose_light.png
new file mode 100644
index 0000000000..5e35352bfd
Binary files /dev/null and b/skin/mogo-skin-light/src/main/module-common-res/drawable-mdpi/icon_heart_choose_light.png differ
diff --git a/skin/mogo-skin-light/src/main/module-common-res/drawable-mdpi/icon_heart_second_light.png b/skin/mogo-skin-light/src/main/module-common-res/drawable-mdpi/icon_heart_second_light.png
new file mode 100644
index 0000000000..4fda591483
Binary files /dev/null and b/skin/mogo-skin-light/src/main/module-common-res/drawable-mdpi/icon_heart_second_light.png differ
diff --git a/skin/mogo-skin-light/src/main/module-common-res/drawable-mdpi/icon_heart_unchoose_light.png b/skin/mogo-skin-light/src/main/module-common-res/drawable-mdpi/icon_heart_unchoose_light.png
new file mode 100644
index 0000000000..20d32c67f0
Binary files /dev/null and b/skin/mogo-skin-light/src/main/module-common-res/drawable-mdpi/icon_heart_unchoose_light.png differ
diff --git a/skin/mogo-skin-light/src/main/module-common-res/drawable-xhdpi/icon_heart_choose_light.png b/skin/mogo-skin-light/src/main/module-common-res/drawable-xhdpi/icon_heart_choose_light.png
new file mode 100644
index 0000000000..d6c0f59110
Binary files /dev/null and b/skin/mogo-skin-light/src/main/module-common-res/drawable-xhdpi/icon_heart_choose_light.png differ
diff --git a/skin/mogo-skin-light/src/main/module-common-res/drawable-xhdpi/icon_heart_second_light.png b/skin/mogo-skin-light/src/main/module-common-res/drawable-xhdpi/icon_heart_second_light.png
new file mode 100644
index 0000000000..ba1562ec86
Binary files /dev/null and b/skin/mogo-skin-light/src/main/module-common-res/drawable-xhdpi/icon_heart_second_light.png differ
diff --git a/skin/mogo-skin-light/src/main/module-common-res/drawable-xhdpi/icon_heart_unchoose_light.png b/skin/mogo-skin-light/src/main/module-common-res/drawable-xhdpi/icon_heart_unchoose_light.png
new file mode 100644
index 0000000000..14f81ebe43
Binary files /dev/null and b/skin/mogo-skin-light/src/main/module-common-res/drawable-xhdpi/icon_heart_unchoose_light.png differ
diff --git a/skin/mogo-skin-light/src/main/module-common-res/drawable/module_commons_heart_ratingbar_drawable_light.xml b/skin/mogo-skin-light/src/main/module-common-res/drawable/module_commons_heart_ratingbar_drawable_light.xml
new file mode 100644
index 0000000000..9d7aea6564
--- /dev/null
+++ b/skin/mogo-skin-light/src/main/module-common-res/drawable/module_commons_heart_ratingbar_drawable_light.xml
@@ -0,0 +1,15 @@
+
+
+ -
+
+ -
+
+ -
+
+
\ No newline at end of file
diff --git a/skin/mogo-skin-light/src/main/module-commons-res/drawable-xhdpi/module_common_default_user_head_light.png b/skin/mogo-skin-light/src/main/module-commons-res/drawable-xhdpi/module_common_default_user_head_light.png
new file mode 100644
index 0000000000..eb26174ed6
Binary files /dev/null and b/skin/mogo-skin-light/src/main/module-commons-res/drawable-xhdpi/module_common_default_user_head_light.png differ
diff --git a/skin/mogo-skin-light/src/main/module-commons-res/drawable/module_common_default_user_head_light.png b/skin/mogo-skin-light/src/main/module-commons-res/drawable/module_common_default_user_head_light.png
new file mode 100644
index 0000000000..21805b2ff7
Binary files /dev/null and b/skin/mogo-skin-light/src/main/module-commons-res/drawable/module_common_default_user_head_light.png differ
diff --git a/skin/mogo-skin-light/src/main/module-extensions-res/drawable-xhdpi/module_map_ic_move2_current_location_light.png b/skin/mogo-skin-light/src/main/module-extensions-res/drawable-xhdpi/module_map_ic_move2_current_location_light.png
index d3f83f0530..bc4de1e54d 100644
Binary files a/skin/mogo-skin-light/src/main/module-extensions-res/drawable-xhdpi/module_map_ic_move2_current_location_light.png and b/skin/mogo-skin-light/src/main/module-extensions-res/drawable-xhdpi/module_map_ic_move2_current_location_light.png differ
diff --git a/skin/mogo-skin-light/src/main/module-extensions-res/drawable/module_ext_dw_navi_info_panel_bkg_light.xml b/skin/mogo-skin-light/src/main/module-extensions-res/drawable/module_ext_dw_navi_info_panel_bkg_light.xml
new file mode 100644
index 0000000000..b7a7dc2898
--- /dev/null
+++ b/skin/mogo-skin-light/src/main/module-extensions-res/drawable/module_ext_dw_navi_info_panel_bkg_light.xml
@@ -0,0 +1,9 @@
+
+
+ -
+
+
+
+
+
+
\ No newline at end of file
diff --git a/skin/mogo-skin-light/src/main/module-main-res/drawable/module_main_dw_left_frame_bkg_light.xml b/skin/mogo-skin-light/src/main/module-main-res/drawable/module_main_dw_left_frame_bkg_light.xml
index f3c8c592ef..8127025226 100644
--- a/skin/mogo-skin-light/src/main/module-main-res/drawable/module_main_dw_left_frame_bkg_light.xml
+++ b/skin/mogo-skin-light/src/main/module-main-res/drawable/module_main_dw_left_frame_bkg_light.xml
@@ -2,7 +2,7 @@
-
-
+
\ No newline at end of file
diff --git a/skin/mogo-skin-light/src/main/module-services-res/drawable-ldpi/module_services_close_light.png b/skin/mogo-skin-light/src/main/module-services-res/drawable-ldpi/module_services_close_light.png
new file mode 100755
index 0000000000..d25aa13032
Binary files /dev/null and b/skin/mogo-skin-light/src/main/module-services-res/drawable-ldpi/module_services_close_light.png differ
diff --git a/skin/mogo-skin-light/src/main/module-services-res/drawable-ldpi/module_services_marker_bkg_light.png b/skin/mogo-skin-light/src/main/module-services-res/drawable-ldpi/module_services_marker_bkg_light.png
new file mode 100755
index 0000000000..8044b0458f
Binary files /dev/null and b/skin/mogo-skin-light/src/main/module-services-res/drawable-ldpi/module_services_marker_bkg_light.png differ
diff --git a/skin/mogo-skin-light/src/main/module-services-res/drawable-ldpi/module_services_online_car_panel_background_light.9.png b/skin/mogo-skin-light/src/main/module-services-res/drawable-ldpi/module_services_online_car_panel_background_light.9.png
new file mode 100644
index 0000000000..36ea7d6655
Binary files /dev/null and b/skin/mogo-skin-light/src/main/module-services-res/drawable-ldpi/module_services_online_car_panel_background_light.9.png differ
diff --git a/skin/mogo-skin-light/src/main/module-services-res/drawable-ldpi/module_services_online_car_panel_empty_icon_light.png b/skin/mogo-skin-light/src/main/module-services-res/drawable-ldpi/module_services_online_car_panel_empty_icon_light.png
new file mode 100644
index 0000000000..8fd26c2843
Binary files /dev/null and b/skin/mogo-skin-light/src/main/module-services-res/drawable-ldpi/module_services_online_car_panel_empty_icon_light.png differ
diff --git a/skin/mogo-skin-light/src/main/module-services-res/drawable-mdpi/module_services_close_light.png b/skin/mogo-skin-light/src/main/module-services-res/drawable-mdpi/module_services_close_light.png
new file mode 100755
index 0000000000..d25aa13032
Binary files /dev/null and b/skin/mogo-skin-light/src/main/module-services-res/drawable-mdpi/module_services_close_light.png differ
diff --git a/skin/mogo-skin-light/src/main/module-services-res/drawable-mdpi/module_services_online_car_panel_background_light.9.png b/skin/mogo-skin-light/src/main/module-services-res/drawable-mdpi/module_services_online_car_panel_background_light.9.png
new file mode 100644
index 0000000000..36ea7d6655
Binary files /dev/null and b/skin/mogo-skin-light/src/main/module-services-res/drawable-mdpi/module_services_online_car_panel_background_light.9.png differ
diff --git a/skin/mogo-skin-light/src/main/module-services-res/drawable-mdpi/module_services_online_car_panel_empty_icon_light.png b/skin/mogo-skin-light/src/main/module-services-res/drawable-mdpi/module_services_online_car_panel_empty_icon_light.png
new file mode 100644
index 0000000000..8fd26c2843
Binary files /dev/null and b/skin/mogo-skin-light/src/main/module-services-res/drawable-mdpi/module_services_online_car_panel_empty_icon_light.png differ
diff --git a/skin/mogo-skin-light/src/main/module-services-res/drawable-xhdpi/module_services_close_light.png b/skin/mogo-skin-light/src/main/module-services-res/drawable-xhdpi/module_services_close_light.png
new file mode 100755
index 0000000000..cbf14c5566
Binary files /dev/null and b/skin/mogo-skin-light/src/main/module-services-res/drawable-xhdpi/module_services_close_light.png differ
diff --git a/skin/mogo-skin-light/src/main/module-services-res/drawable-xhdpi/module_services_online_car_panel_background_light.9.png b/skin/mogo-skin-light/src/main/module-services-res/drawable-xhdpi/module_services_online_car_panel_background_light.9.png
new file mode 100644
index 0000000000..51a1e27744
Binary files /dev/null and b/skin/mogo-skin-light/src/main/module-services-res/drawable-xhdpi/module_services_online_car_panel_background_light.9.png differ
diff --git a/skin/mogo-skin-light/src/main/module-services-res/drawable-xhdpi/module_services_online_car_panel_empty_icon_light.png b/skin/mogo-skin-light/src/main/module-services-res/drawable-xhdpi/module_services_online_car_panel_empty_icon_light.png
new file mode 100644
index 0000000000..5307df4308
Binary files /dev/null and b/skin/mogo-skin-light/src/main/module-services-res/drawable-xhdpi/module_services_online_car_panel_empty_icon_light.png differ
diff --git a/skin/mogo-skin-light/src/main/module-services-res/drawable/module_services_close_light.png b/skin/mogo-skin-light/src/main/module-services-res/drawable/module_services_close_light.png
new file mode 100755
index 0000000000..d25aa13032
Binary files /dev/null and b/skin/mogo-skin-light/src/main/module-services-res/drawable/module_services_close_light.png differ
diff --git a/skin/mogo-skin-light/src/main/module-services-res/drawable/module_services_online_car_panel_background_light.9.png b/skin/mogo-skin-light/src/main/module-services-res/drawable/module_services_online_car_panel_background_light.9.png
new file mode 100644
index 0000000000..5ff5526ff8
Binary files /dev/null and b/skin/mogo-skin-light/src/main/module-services-res/drawable/module_services_online_car_panel_background_light.9.png differ
diff --git a/skin/mogo-skin-light/src/main/module-services-res/drawable/module_services_online_car_panel_empty_icon_light.png b/skin/mogo-skin-light/src/main/module-services-res/drawable/module_services_online_car_panel_empty_icon_light.png
new file mode 100644
index 0000000000..8fd26c2843
Binary files /dev/null and b/skin/mogo-skin-light/src/main/module-services-res/drawable/module_services_online_car_panel_empty_icon_light.png differ
diff --git a/skin/mogo-skin-light/src/main/module-services-res/drawable/module_services_panel_item_bkg_light.xml b/skin/mogo-skin-light/src/main/module-services-res/drawable/module_services_panel_item_bkg_light.xml
new file mode 100644
index 0000000000..d126dfc22a
--- /dev/null
+++ b/skin/mogo-skin-light/src/main/module-services-res/drawable/module_services_panel_item_bkg_light.xml
@@ -0,0 +1,9 @@
+
+
+ -
+
+
+
+
+
+
\ No newline at end of file
diff --git a/skin/mogo-skin-light/src/main/module-services-res/drawable/module_services_panel_item_detail_bkg_light.xml b/skin/mogo-skin-light/src/main/module-services-res/drawable/module_services_panel_item_detail_bkg_light.xml
new file mode 100644
index 0000000000..1b3b50d65e
--- /dev/null
+++ b/skin/mogo-skin-light/src/main/module-services-res/drawable/module_services_panel_item_detail_bkg_light.xml
@@ -0,0 +1,9 @@
+
+
+ -
+
+
+
+
+
+
\ No newline at end of file
diff --git a/skin/mogo-skin-light/src/main/module-services-res/drawable/module_services_panel_strategy_button_bkg_light.xml b/skin/mogo-skin-light/src/main/module-services-res/drawable/module_services_panel_strategy_button_bkg_light.xml
new file mode 100644
index 0000000000..89337d1c80
--- /dev/null
+++ b/skin/mogo-skin-light/src/main/module-services-res/drawable/module_services_panel_strategy_button_bkg_light.xml
@@ -0,0 +1,9 @@
+
+
+ -
+
+
+
+
+
+
\ No newline at end of file
diff --git a/skin/mogo-skin-light/src/main/module-services-res/values/colors.xml b/skin/mogo-skin-light/src/main/module-services-res/values/colors.xml
index 823423c2f2..500c03d588 100644
--- a/skin/mogo-skin-light/src/main/module-services-res/values/colors.xml
+++ b/skin/mogo-skin-light/src/main/module-services-res/values/colors.xml
@@ -1,4 +1,14 @@
#333333
+ #FF333333
+ #B2333333
+ #FF333333
+ #333333
+
+ #333333
+ #333333
+ #666666
+
+ #81A4DC
diff --git a/skin/mogo-skin-light/src/main/module-v2x-res/drawable/v2xt_dw_common_corner_bkg_dark_light.xml b/skin/mogo-skin-light/src/main/module-v2x-res/drawable/module_dw_common_corner_bkg_light.xml
similarity index 100%
rename from skin/mogo-skin-light/src/main/module-v2x-res/drawable/v2xt_dw_common_corner_bkg_dark_light.xml
rename to skin/mogo-skin-light/src/main/module-v2x-res/drawable/module_dw_common_corner_bkg_light.xml
diff --git a/skin/mogo-skin-light/src/main/module-v2x-res/drawable/v2x_alert_window_bg_light.xml b/skin/mogo-skin-light/src/main/module-v2x-res/drawable/v2x_alert_window_bg_light.xml
index 8790c3b9a1..cf7e43c2c0 100644
--- a/skin/mogo-skin-light/src/main/module-v2x-res/drawable/v2x_alert_window_bg_light.xml
+++ b/skin/mogo-skin-light/src/main/module-v2x-res/drawable/v2x_alert_window_bg_light.xml
@@ -29,7 +29,7 @@
diff --git a/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable-ldpi/module_widgets_app_entrance_root_bkg_light.9.png b/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable-ldpi/module_widgets_app_entrance_root_bkg_light.9.png
new file mode 100644
index 0000000000..c271d88135
Binary files /dev/null and b/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable-ldpi/module_widgets_app_entrance_root_bkg_light.9.png differ
diff --git a/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable-ldpi/module_widgets_app_handler_close_light.png b/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable-ldpi/module_widgets_app_handler_close_light.png
new file mode 100644
index 0000000000..6f4b2587ae
Binary files /dev/null and b/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable-ldpi/module_widgets_app_handler_close_light.png differ
diff --git a/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable-ldpi/module_widgets_app_handler_open_light.png b/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable-ldpi/module_widgets_app_handler_open_light.png
new file mode 100644
index 0000000000..9372cba743
Binary files /dev/null and b/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable-ldpi/module_widgets_app_handler_open_light.png differ
diff --git a/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable-mdpi/module_widgets_app_entrance_root_bkg_light.9.png b/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable-mdpi/module_widgets_app_entrance_root_bkg_light.9.png
new file mode 100644
index 0000000000..c271d88135
Binary files /dev/null and b/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable-mdpi/module_widgets_app_entrance_root_bkg_light.9.png differ
diff --git a/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable-mdpi/module_widgets_app_handler_close_light.png b/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable-mdpi/module_widgets_app_handler_close_light.png
new file mode 100644
index 0000000000..6f4b2587ae
Binary files /dev/null and b/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable-mdpi/module_widgets_app_handler_close_light.png differ
diff --git a/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable-mdpi/module_widgets_app_handler_open_light.png b/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable-mdpi/module_widgets_app_handler_open_light.png
new file mode 100644
index 0000000000..9372cba743
Binary files /dev/null and b/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable-mdpi/module_widgets_app_handler_open_light.png differ
diff --git a/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable-xhdpi/module_widgets_app_entrance_root_bkg_light.9.png b/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable-xhdpi/module_widgets_app_entrance_root_bkg_light.9.png
new file mode 100644
index 0000000000..2d0ecea687
Binary files /dev/null and b/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable-xhdpi/module_widgets_app_entrance_root_bkg_light.9.png differ
diff --git a/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable-xhdpi/module_widgets_app_handler_close_light.png b/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable-xhdpi/module_widgets_app_handler_close_light.png
new file mode 100644
index 0000000000..adf3a0c94d
Binary files /dev/null and b/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable-xhdpi/module_widgets_app_handler_close_light.png differ
diff --git a/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable-xhdpi/module_widgets_app_handler_open_light.png b/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable-xhdpi/module_widgets_app_handler_open_light.png
new file mode 100644
index 0000000000..56f85a5442
Binary files /dev/null and b/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable-xhdpi/module_widgets_app_handler_open_light.png differ
diff --git a/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable/module_widgets_app_body_bkg_light.xml b/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable/module_widgets_app_body_bkg_light.xml
new file mode 100644
index 0000000000..41e0f22629
--- /dev/null
+++ b/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable/module_widgets_app_body_bkg_light.xml
@@ -0,0 +1,9 @@
+
+
+ -
+
+
+
+
+
+
\ No newline at end of file
diff --git a/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable/module_widgets_app_entrance_root_bkg_light.9.png b/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable/module_widgets_app_entrance_root_bkg_light.9.png
new file mode 100644
index 0000000000..c271d88135
Binary files /dev/null and b/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable/module_widgets_app_entrance_root_bkg_light.9.png differ
diff --git a/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable/module_widgets_app_handler_bkg_light.xml b/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable/module_widgets_app_handler_bkg_light.xml
new file mode 100644
index 0000000000..ebfe29cfd3
--- /dev/null
+++ b/skin/mogo-skin-light/src/main/mogo-module-widgets-res/drawable/module_widgets_app_handler_bkg_light.xml
@@ -0,0 +1,9 @@
+
+
+ -
+
+
+
+
+
+
\ No newline at end of file
diff --git a/skin/mogo-skin-light/src/main/mogo-module-widgets-res/values/colors.xml b/skin/mogo-skin-light/src/main/mogo-module-widgets-res/values/colors.xml
new file mode 100644
index 0000000000..759cfa6b94
--- /dev/null
+++ b/skin/mogo-skin-light/src/main/mogo-module-widgets-res/values/colors.xml
@@ -0,0 +1,4 @@
+
+
+ #333333
+
\ No newline at end of file
diff --git a/skin/mogo-skin-support-impl/build.gradle b/skin/mogo-skin-support-impl/build.gradle
index bff7a262ee..ece5dbcd54 100644
--- a/skin/mogo-skin-support-impl/build.gradle
+++ b/skin/mogo-skin-support-impl/build.gradle
@@ -39,25 +39,22 @@ dependencies {
implementation rootProject.ext.dependencies.arouter
annotationProcessor rootProject.ext.dependencies.aroutercompiler
- // 换肤功能
-// implementation 'skin.support:skin-support:4.0.5' // skin-support
-// implementation 'skin.support:skin-support-appcompat:4.0.5' // skin-support 基础控件支持
-// implementation 'skin.support:skin-support-design:4.0.5' // skin-support-design material design 控件支持[可选]
-// implementation 'skin.support:skin-support-cardview:4.0.5' // skin-support-cardview CardView 控件支持[可选]
-// implementation 'skin.support:skin-support-constraint-layout:4.0.5' // skin-support-constraint-layout ConstraintLayout 控件支持[可选]
-
- implementation project(":skin:skin-support")
- api project(":skin:skin-support-appcompat")
- implementation project(":skin:skin-support-cardview")
- implementation project(":skin:skin-support-constraint-layout")
- implementation project(":skin:skin-support-design")
-
if( Boolean.valueOf(RELEASE) ){
implementation rootProject.ext.dependencies.skinsupport
compileOnly rootProject.ext.dependencies.modulecommon
+ implementation rootProject.ext.dependencies.skinsupportbase
+ implementation rootProject.ext.dependencies.skinsupportappcompat
+ implementation rootProject.ext.dependencies.skinsupportcardview
+ implementation rootProject.ext.dependencies.skinsupportconstraintlayout
+ implementation rootProject.ext.dependencies.skinsupportdesign
} else {
implementation project(":skin:mogo-skin-support")
compileOnly project(':modules:mogo-module-common')
+ implementation project(":skin:skin-support")
+ implementation project(":skin:skin-support-appcompat")
+ implementation project(":skin:skin-support-cardview")
+ implementation project(":skin:skin-support-constraint-layout")
+ implementation project(":skin:skin-support-design")
}
}
diff --git a/skin/skin-support-appcompat/build.gradle b/skin/skin-support-appcompat/build.gradle
index 4942fd6be5..ab7d0959bc 100755
--- a/skin/skin-support-appcompat/build.gradle
+++ b/skin/skin-support-appcompat/build.gradle
@@ -24,17 +24,13 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
- implementation project(':skin:skin-support')
implementation rootProject.ext.dependencies.androidxappcompat
+
+ if( Boolean.valueOf(RELEASE) ){
+ implementation rootProject.ext.dependencies.skinsupportbase
+ } else {
+ implementation project(":skin:skin-support")
+ }
}
-tasks.withType(Javadoc) {
- options.addStringOption('Xdoclint:none', '-quiet')
- options.addStringOption('encoding', 'UTF-8')
- options.addStringOption('charSet', 'UTF-8')
-}
-
-ext {
- moduleName = 'skin-support-appcompat'
- descContent = 'skin-support 基础控件换肤支持包'
-}
\ No newline at end of file
+apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
\ No newline at end of file
diff --git a/skin/skin-support-appcompat/gradle.properties b/skin/skin-support-appcompat/gradle.properties
new file mode 100644
index 0000000000..ab3645e7fe
--- /dev/null
+++ b/skin/skin-support-appcompat/gradle.properties
@@ -0,0 +1,3 @@
+GROUP=com.mogo.skin
+POM_ARTIFACT_ID=skin-support-appcompat
+VERSION_CODE=1
diff --git a/skin/skin-support-cardview/build.gradle b/skin/skin-support-cardview/build.gradle
index 185d983c1f..6452c0cdd5 100755
--- a/skin/skin-support-cardview/build.gradle
+++ b/skin/skin-support-cardview/build.gradle
@@ -21,10 +21,12 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation rootProject.ext.dependencies.androidxcardview
- implementation project(':skin:skin-support')
+
+ if( Boolean.valueOf(RELEASE) ){
+ implementation rootProject.ext.dependencies.skinsupportbase
+ } else {
+ implementation project(":skin:skin-support")
+ }
}
-ext {
- moduleName = "skin-support-cardview"
- descContent = "CardView-v7 换肤支持包"
-}
+apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
diff --git a/skin/skin-support-cardview/gradle.properties b/skin/skin-support-cardview/gradle.properties
new file mode 100644
index 0000000000..752039f8a7
--- /dev/null
+++ b/skin/skin-support-cardview/gradle.properties
@@ -0,0 +1,3 @@
+GROUP=com.mogo.skin
+POM_ARTIFACT_ID=skin-support-cardview
+VERSION_CODE=1
diff --git a/skin/skin-support-constraint-layout/build.gradle b/skin/skin-support-constraint-layout/build.gradle
index 801790ba81..3157b3718c 100755
--- a/skin/skin-support-constraint-layout/build.gradle
+++ b/skin/skin-support-constraint-layout/build.gradle
@@ -20,12 +20,14 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation rootProject.ext.dependencies.androidxconstraintlayout
- implementation project(':skin:skin-support')
- implementation project(':skin:skin-support-appcompat')
-}
-
-ext {
- moduleName = 'skin-support-constraint-layout'
- descContent = 'ConstraintLayout控件换肤支持包'
+
+ if( Boolean.valueOf(RELEASE) ){
+ implementation rootProject.ext.dependencies.skinsupportbase
+ implementation rootProject.ext.dependencies.skinsupportappcompat
+ } else {
+ implementation project(":skin:skin-support")
+ implementation project(":skin:skin-support-appcompat")
+ }
}
+apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
diff --git a/skin/skin-support-constraint-layout/gradle.properties b/skin/skin-support-constraint-layout/gradle.properties
new file mode 100644
index 0000000000..d04ff62a59
--- /dev/null
+++ b/skin/skin-support-constraint-layout/gradle.properties
@@ -0,0 +1,3 @@
+GROUP=com.mogo.skin
+POM_ARTIFACT_ID=skin-support-constraint-layout
+VERSION_CODE=1
diff --git a/skin/skin-support-design/build.gradle b/skin/skin-support-design/build.gradle
index 7864ce3c0a..81d14320e0 100755
--- a/skin/skin-support-design/build.gradle
+++ b/skin/skin-support-design/build.gradle
@@ -21,11 +21,14 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation rootProject.ext.dependencies.androidxappcompat
implementation rootProject.ext.dependencies.material
- implementation project(':skin:skin-support')
- implementation project(':skin:skin-support-appcompat')
+
+ if( Boolean.valueOf(RELEASE) ){
+ implementation rootProject.ext.dependencies.skinsupportbase
+ implementation rootProject.ext.dependencies.skinsupportappcompat
+ } else {
+ implementation project(":skin:skin-support")
+ implementation project(":skin:skin-support-appcompat")
+ }
}
-ext {
- moduleName = 'skin-support-design'
- descContent = 'material design控件换肤支持包'
-}
+apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
diff --git a/skin/skin-support-design/gradle.properties b/skin/skin-support-design/gradle.properties
new file mode 100644
index 0000000000..30288cd0d8
--- /dev/null
+++ b/skin/skin-support-design/gradle.properties
@@ -0,0 +1,3 @@
+GROUP=com.mogo.skin
+POM_ARTIFACT_ID=skin-support-design
+VERSION_CODE=1
diff --git a/skin/skin-support/build.gradle b/skin/skin-support/build.gradle
index b3f218e0b3..dcb7dbe880 100755
--- a/skin/skin-support/build.gradle
+++ b/skin/skin-support/build.gradle
@@ -19,16 +19,11 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
- implementation project(":skin:mogo-skin-support")
+ if( Boolean.valueOf(RELEASE) ){
+ implementation rootProject.ext.dependencies.skinsupport
+ } else {
+ implementation project(":skin:mogo-skin-support")
+ }
}
-tasks.withType(Javadoc) {
- options.addStringOption('Xdoclint:none', '-quiet')
- options.addStringOption('encoding', 'UTF-8')
- options.addStringOption('charSet', 'UTF-8')
-}
-
-ext {
- moduleName = 'skin-support'
- descContent = 'skin-support core'
-}
+apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
diff --git a/skin/skin-support/gradle.properties b/skin/skin-support/gradle.properties
new file mode 100644
index 0000000000..363e181caa
--- /dev/null
+++ b/skin/skin-support/gradle.properties
@@ -0,0 +1,3 @@
+GROUP=com.mogo.skin
+POM_ARTIFACT_ID=skin-support-base
+VERSION_CODE=1
diff --git a/test/crashreport-noop/build.gradle b/test/crashreport-noop/build.gradle
index 2ee98887fe..3f1cdbbea3 100644
--- a/test/crashreport-noop/build.gradle
+++ b/test/crashreport-noop/build.gradle
@@ -48,11 +48,6 @@ dependencies {
implementation project(":foudations:mogo-utils")
implementation project(":foudations:mogo-commons")
}
-
- implementation 'com.tencent.bugly:crashreport:latest.release'
- //其中latest.release指代最新Bugly SDK版本号,也可以指定明确的版本号,例如2.1.9
- implementation 'com.tencent.bugly:nativecrashreport:latest.release'
- //其中latest.release指代最新Bugly NDK版本号,也可以指定明确的版本号,例如3.0
}
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
\ No newline at end of file
diff --git a/tts/tts-base/.gitignore b/tts/tts-base/.gitignore
new file mode 100644
index 0000000000..42afabfd2a
--- /dev/null
+++ b/tts/tts-base/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/tts/tts-base/build.gradle b/tts/tts-base/build.gradle
new file mode 100644
index 0000000000..33c33d627e
--- /dev/null
+++ b/tts/tts-base/build.gradle
@@ -0,0 +1,44 @@
+apply plugin: 'com.android.library'
+apply plugin: 'com.alibaba.arouter'
+
+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"
+
+ javaCompileOptions {
+ annotationProcessorOptions {
+ arguments = [AROUTER_MODULE_NAME: project.getName()]
+ }
+ }
+ }
+
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+}
+
+dependencies {
+ implementation fileTree(dir: "libs", include: ["*.jar"])
+ implementation rootProject.ext.dependencies.androidxappcompat
+ implementation rootProject.ext.dependencies.arouter
+ annotationProcessor rootProject.ext.dependencies.aroutercompiler
+}
+
+apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
\ No newline at end of file
diff --git a/tts/tts-base/consumer-rules.pro b/tts/tts-base/consumer-rules.pro
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tts/tts-base/gradle.properties b/tts/tts-base/gradle.properties
new file mode 100644
index 0000000000..cf1cf442b3
--- /dev/null
+++ b/tts/tts-base/gradle.properties
@@ -0,0 +1,3 @@
+GROUP=com.mogo.tts
+POM_ARTIFACT_ID=tts-base
+VERSION_CODE=1
diff --git a/tts/tts-base/proguard-rules.pro b/tts/tts-base/proguard-rules.pro
new file mode 100644
index 0000000000..481bb43481
--- /dev/null
+++ b/tts/tts-base/proguard-rules.pro
@@ -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
\ No newline at end of file
diff --git a/tts/tts-base/src/main/AndroidManifest.xml b/tts/tts-base/src/main/AndroidManifest.xml
new file mode 100644
index 0000000000..292c8c8a36
--- /dev/null
+++ b/tts/tts-base/src/main/AndroidManifest.xml
@@ -0,0 +1,5 @@
+
+
+ /
+
\ No newline at end of file
diff --git a/tts/tts-base/src/main/java/com/mogo/tts/base/IMogoTTS.java b/tts/tts-base/src/main/java/com/mogo/tts/base/IMogoTTS.java
new file mode 100644
index 0000000000..d9f9ea3e0d
--- /dev/null
+++ b/tts/tts-base/src/main/java/com/mogo/tts/base/IMogoTTS.java
@@ -0,0 +1,153 @@
+package com.mogo.tts.base;
+
+import android.content.Context;
+
+import com.alibaba.android.arouter.facade.template.IProvider;
+
+public
+/**
+ * @author congtaowang
+ * @since 2020/10/12
+ *
+ * 语音抽象
+ */
+interface IMogoTTS extends IProvider {
+
+ /**
+ * 释放资源
+ */
+ void release();
+
+ /**
+ * 缓存的语音指令注册状态
+ *
+ * @return true - 已注册、false - 未注册
+ */
+ default boolean hasFlush() {
+ return true;
+ }
+
+ /**
+ * 将缓存的免唤醒指令全部注册一遍
+ */
+ void flush();
+
+ /**
+ * 播报 tts 语音
+ *
+ * @param tts 语音内容
+ */
+ void speakTTSVoice( String tts );
+
+ /**
+ * 播放 tts 语音
+ *
+ * @param tts 语音内容
+ * @param callback 回调
+ * {@link IMogoTTSCallback#onSpeakEnd(String)}
+ */
+ void speakTTSVoice( String tts, IMogoTTSCallback callback );
+
+ /**
+ * 播放 tts,并设置播报类型
+ *
+ * @param tts 语音内容
+ * @param type 播报类型 {@link PreemptType}
+ * @param callback 回调
+ * {@link IMogoTTSCallback#onSpeakEnd(String)}
+ */
+ void speakTTSVoice( String tts, PreemptType type, IMogoTTSCallback callback );
+
+ /**
+ * 注册问答指令,默认恢复:确认、取消
+ *
+ * @param tts 播报内容
+ * @param callback 回调
+ * {@link IMogoTTSCallback#onCmdAction(String)}
+ * {@link IMogoTTSCallback#onCmdCancel(String)} (String)}
+ * {@link IMogoTTSCallback#onSpeakSelectTimeOut(String)} (String)}
+ */
+ void speakQAndACmd( String tts, IMogoTTSCallback callback );
+
+
+ /**
+ * 注册问答指令,默认恢复:确认、取消
+ *
+ * @param tts 播报内容
+ * @param okWords 确认指令唤醒词
+ * @param cancelWords 取消指令唤醒词
+ * @param callback 回调
+ * {@link IMogoTTSCallback#onCmdAction(String)}
+ * {@link IMogoTTSCallback#onCmdCancel(String)} (String)}
+ * {@link IMogoTTSCallback#onSpeakSelectTimeOut(String)} (String)}
+ */
+ void speakQAndACmd( String tts, String[] okWords, String[] cancelWords, IMogoTTSCallback callback );
+
+
+ /**
+ * 注册免唤醒指令
+ *
+ * @param cmd 免唤醒指令
+ * @param cmdWords 免唤醒词组
+ * @param callback 回调
+ * {@link IMogoTTSCallback#onCmdSelected(String)}
+ */
+ void registerUnWakeupCommand( String cmd, String[] cmdWords, IMogoTTSCallback callback );
+
+ /**
+ * 注销免唤醒指令
+ *
+ * @param cmd 指令
+ */
+ void unregisterUnWakeupCommand( String cmd );
+
+ /**
+ * 注销免唤醒指令
+ *
+ * @param cmd 指令
+ * @param callback 具体注销的回调对象(部分指令复用的情况)
+ */
+ void unregisterUnWakeupCommand( String cmd, IMogoTTSCallback callback );
+
+ /**
+ * 启动语音
+ *
+ * @param context
+ */
+ void startAIAssist( Context context );
+
+ /**
+ * 启动语音
+ *
+ * @param context
+ * @param status window_start_cancel
+ * 0 - 结束
+ * 1 - 显示
+ * 2 - 未激活调试进入
+ */
+
+ void startAIAssist( Context context, int status );
+
+ /**
+ * 中断正在播报的语音内容
+ */
+ void breakOffSpeak();
+
+ // Deprecated api, but should keep...
+
+ @Deprecated
+ default void speakTTSAndDuck( String tts ) {
+ }
+
+ @Deprecated
+ default void speakTTSAndDuck( String tts, IMogoTTSCallback callback ) {
+ }
+
+ @Deprecated
+ default void shutUp( String ttsId, String text ) {
+
+ }
+
+ default void clearTTSCallback( String tts ) {
+ }
+}
diff --git a/tts/tts-base/src/main/java/com/mogo/tts/base/IMogoTTSCallback.java b/tts/tts-base/src/main/java/com/mogo/tts/base/IMogoTTSCallback.java
new file mode 100644
index 0000000000..b39211e24f
--- /dev/null
+++ b/tts/tts-base/src/main/java/com/mogo/tts/base/IMogoTTSCallback.java
@@ -0,0 +1,81 @@
+package com.mogo.tts.base;
+
+public
+/**
+ * @author congtaowang
+ * @since 2020/10/12
+ *
+ * 描述
+ */
+interface IMogoTTSCallback {
+
+ /**
+ * 新SDK接口
+ *
+ * @param ttsId
+ * @param tts
+ */
+ @Deprecated
+ default void onTTSStart( String ttsId, String tts ) {
+ }
+
+ /**
+ * 新SDK接口
+ *
+ * @param ttsId
+ * @param tts
+ */
+ @Deprecated
+ default void onTTSEnd( String ttsId, String tts ) {
+ }
+
+ /**
+ * 新SDK接口
+ *
+ * @param ttsId
+ * @param tts
+ */
+ @Deprecated
+ default void onTTSError( String ttsId, String tts ) {
+ }
+
+ /**
+ * 免唤醒命令响应回调
+ *
+ * @param cmd
+ */
+ default void onCmdSelected( String cmd ) {
+ }
+
+ /**
+ * 语音播报临时免唤醒“确定”命令
+ *
+ * @param speakText 播报内容
+ */
+ default void onCmdAction( String speakText ) {
+ }
+
+ /**
+ * 语音播报临时免唤醒“取消”命令
+ *
+ * @param speakText 播报内容
+ */
+ default void onCmdCancel( String speakText ) {
+ }
+
+ /**
+ * 语音播报完毕
+ *
+ * @param speakText 播报内容
+ */
+ default void onSpeakEnd( String speakText ) {
+ }
+
+ /**
+ * 语音播报完临时命令选择超时
+ *
+ * @param speakText 播报内容
+ */
+ default void onSpeakSelectTimeOut( String speakText ) {
+ }
+}
diff --git a/tts/tts-base/src/main/java/com/mogo/tts/base/MogoTTSConstants.java b/tts/tts-base/src/main/java/com/mogo/tts/base/MogoTTSConstants.java
new file mode 100644
index 0000000000..d6f0e4e0c2
--- /dev/null
+++ b/tts/tts-base/src/main/java/com/mogo/tts/base/MogoTTSConstants.java
@@ -0,0 +1,15 @@
+package com.mogo.tts.base;
+
+public
+/**
+ * @author congtaowang
+ * @since 2020/10/12
+ *
+ * 描述
+ */
+interface MogoTTSConstants {
+
+ String API_PATH = "/tts/api";
+
+ String API_NAME = "TTS";
+}
diff --git a/tts/tts-base/src/main/java/com/mogo/tts/base/PreemptType.java b/tts/tts-base/src/main/java/com/mogo/tts/base/PreemptType.java
new file mode 100644
index 0000000000..b0e1878009
--- /dev/null
+++ b/tts/tts-base/src/main/java/com/mogo/tts/base/PreemptType.java
@@ -0,0 +1,32 @@
+package com.mogo.tts.base;
+
+public
+/**
+ * @author congtaowang
+ * @since 2020/10/12
+ *
+ * 语音打算类型
+ */
+enum PreemptType {
+
+ /**
+ * 不打断
+ */
+ PREEMPT_TYPE_NONE,
+ /**
+ * 立即打断,取消当前的tts插队播放
+ */
+ PREEMPT_TYPE_IMMEDIATELY,
+ /**
+ * 下一个插入,不取消当前的tts,插队下一个播放
+ */
+ PREEMPT_TYPE_NEXT,
+ /**
+ * 清空队列
+ */
+ PREEMPT_TYPE_FLUSH,
+ /**
+ * 立即打断,不取消当前tts
+ */
+ PREEMPT_TYPE_IMMEDIATELY_WITHOUT_CANCEL
+}
diff --git a/tts/tts-di/.gitignore b/tts/tts-di/.gitignore
new file mode 100644
index 0000000000..42afabfd2a
--- /dev/null
+++ b/tts/tts-di/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/tts/tts-di/build.gradle b/tts/tts-di/build.gradle
new file mode 100644
index 0000000000..c18e63eb3f
--- /dev/null
+++ b/tts/tts-di/build.gradle
@@ -0,0 +1,54 @@
+apply plugin: 'com.android.library'
+apply plugin: 'com.alibaba.arouter'
+
+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"
+
+ javaCompileOptions {
+ annotationProcessorOptions {
+ arguments = [AROUTER_MODULE_NAME: project.getName()]
+ }
+ }
+ }
+
+ 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.androidxappcompat
+ implementation rootProject.ext.dependencies.arouter
+ annotationProcessor rootProject.ext.dependencies.aroutercompiler
+
+ if (Boolean.valueOf(RELEASE)) {
+ implementation rootProject.ext.dependencies.ttsbase
+ implementation rootProject.ext.dependencies.mogoutils
+ implementation rootProject.ext.dependencies.mogocommons
+ } else {
+ implementation project(":tts:tts-base")
+ implementation project(":foudations:mogo-utils")
+ implementation project(":foudations:mogo-commons")
+ }
+}
+
+apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
\ No newline at end of file
diff --git a/tts/tts-di/consumer-rules.pro b/tts/tts-di/consumer-rules.pro
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tts/tts-di/gradle.properties b/tts/tts-di/gradle.properties
new file mode 100644
index 0000000000..36ebd8abc6
--- /dev/null
+++ b/tts/tts-di/gradle.properties
@@ -0,0 +1,3 @@
+GROUP=com.mogo.tts
+POM_ARTIFACT_ID=tts-di
+VERSION_CODE=1
diff --git a/tts/tts-di/proguard-rules.pro b/tts/tts-di/proguard-rules.pro
new file mode 100644
index 0000000000..481bb43481
--- /dev/null
+++ b/tts/tts-di/proguard-rules.pro
@@ -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
\ No newline at end of file
diff --git a/tts/tts-di/src/main/AndroidManifest.xml b/tts/tts-di/src/main/AndroidManifest.xml
new file mode 100644
index 0000000000..9992a8a707
--- /dev/null
+++ b/tts/tts-di/src/main/AndroidManifest.xml
@@ -0,0 +1,5 @@
+
+
+ /
+
\ No newline at end of file
diff --git a/tts/tts-di/src/main/java/com/mogo/tts/noop/DiTTS.java b/tts/tts-di/src/main/java/com/mogo/tts/noop/DiTTS.java
new file mode 100644
index 0000000000..284d867bca
--- /dev/null
+++ b/tts/tts-di/src/main/java/com/mogo/tts/noop/DiTTS.java
@@ -0,0 +1,98 @@
+package com.mogo.tts.noop;
+
+import android.content.Context;
+import android.util.Log;
+
+import com.alibaba.android.arouter.facade.annotation.Route;
+import com.mogo.tts.base.IMogoTTS;
+import com.mogo.tts.base.IMogoTTSCallback;
+import com.mogo.tts.base.MogoTTSConstants;
+import com.mogo.tts.base.PreemptType;
+
+public
+/**
+ * @author congtaowang
+ * @since 2020/10/12
+ *
+ * 比亚迪语音播报
+ */
+@Route( path = MogoTTSConstants.API_PATH )
+class DiTTS implements IMogoTTS {
+
+ public static final String TAG = "DiTTS";
+
+ private Context mContext;
+
+
+ @Override
+ public void release() {
+ mContext = null;
+ }
+
+ @Override
+ public void flush() {
+ Log.d( TAG, "noop - flush" );
+ }
+
+ @Override
+ public void speakTTSVoice( String tts ) {
+ TTSManager.getInstance( mContext ).speakTTS( mContext, tts );
+ }
+
+ @Override
+ public void speakTTSVoice( String tts, IMogoTTSCallback callback ) {
+ speakTTSVoice( tts );
+ }
+
+ @Override
+ public void speakTTSVoice( String tts, PreemptType type, IMogoTTSCallback callback ) {
+ speakTTSVoice( tts );
+ }
+
+ @Override
+ public void speakQAndACmd( String tts, IMogoTTSCallback callback ) {
+ Log.d( TAG, "noop - speakQAndACmd" );
+ }
+
+ @Override
+ public void speakQAndACmd( String tts, String[] okWords, String[] cancelWords, IMogoTTSCallback callback ) {
+ Log.d( TAG, "noop - speakQAndACmd2" );
+ }
+
+ @Override
+ public void registerUnWakeupCommand( String cmd, String[] cmdWords, IMogoTTSCallback callback ) {
+ Log.d( TAG, "noop - registerUnWakeupCommand" );
+ }
+
+ @Override
+ public void unregisterUnWakeupCommand( String cmd ) {
+ Log.d( TAG, "noop - unregisterUnWakeupCommand" );
+ }
+
+ @Override
+ public void unregisterUnWakeupCommand( String cmd, IMogoTTSCallback callback ) {
+ Log.d( TAG, "noop - unregisterUnWakeupCommand2" );
+ }
+
+ @Override
+ public void startAIAssist( Context context ) {
+ Log.d( TAG, "noop - startAIAssist" );
+ }
+
+ @Override
+ public void startAIAssist( Context context, int status ) {
+ Log.d( TAG, "noop - startAIAssist2" );
+ }
+
+ @Override
+ public void breakOffSpeak() {
+ TTSManager.getInstance( mContext ).breakOffSpeak( mContext );
+ }
+
+ @Override
+ public void init( Context context ) {
+ if ( context != null ) {
+ mContext = context.getApplicationContext();
+ }
+ }
+}
diff --git a/tts/tts-di/src/main/java/com/mogo/tts/noop/TTSManager.java b/tts/tts-di/src/main/java/com/mogo/tts/noop/TTSManager.java
new file mode 100644
index 0000000000..af28a03c18
--- /dev/null
+++ b/tts/tts-di/src/main/java/com/mogo/tts/noop/TTSManager.java
@@ -0,0 +1,135 @@
+package com.mogo.tts.noop;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.util.Log;
+
+import com.mogo.commons.debug.DebugConfig;
+import com.mogo.utils.logger.Logger;
+
+public
+/**
+ * @author congtaowang
+ * @since 2020/10/12
+ *
+ * 语音播报
+ */
+class TTSManager {
+
+ /**
+ * 语音播报广播 action
+ */
+ public static final String ACTION_SPEAK_TTS = "com.byd.NotifyService.thirdTts";
+ /**
+ * 播报语音内容
+ */
+ public static final String EXTRA_TTS_CONTENT = "thirdVoiceText";
+
+ /**
+ * 发音人:“0”表示使用默认发音人,或设置为“1”表示吉祥物发音人
+ */
+ public static final String EXTRA_TTS_SPEAKER = "thirdSpeaker";
+
+ /**
+ * 值类型为String型,可以设置为“THIRD_PLAY”表示请求播报,或设置为“THIRD_STOP”表示终止播报
+ */
+ public static final String EXTRA_TTS_ACTION = "thirdType";
+ public final String VAL_THIRD_PLAY = "THIRD_PLAY";
+ public final String VAL_THIRD_STOP = "THIRD_STOP";
+
+ /**
+ * 值类型为Boolean 型,可以设置为 true,表示打开语音界面显示文字,并播报内容,或设置 为 false,表示后台播报内容。
+ */
+ public static final String EXTRA_TTS_SHOW_UI = "booleanShowText";
+
+ private static volatile TTSManager sInstance;
+
+ private TTSManager( Context context ) {
+ if ( DebugConfig.isDebug() && context != null ) {
+ TTSStatusReceiver receiver = new TTSStatusReceiver();
+ IntentFilter filter = new IntentFilter();
+ filter.addAction( "com.byd.NotifyService.thirdTtsFeedback" );
+ context.registerReceiver( receiver, filter );
+ }
+ }
+
+ private static class TTSStatusReceiver extends BroadcastReceiver {
+ @Override
+ public void onReceive( Context context, Intent intent ) {
+ Logger.d( DiTTS.TAG, "receive tts callback status" );
+ int state = intent.getExtras().getInt( "thirdTtsFeedback" );
+ switch ( state ) {
+ case 0:
+ Logger.d( DiTTS.TAG, "反馈:" + "state=0 无法播报" );
+ break;
+ case 1:
+ Log.d( DiTTS.TAG, "反馈:" + "state=1 开始播报" );
+ break;
+ case 2:
+ Log.d( DiTTS.TAG, "反馈:" + "state=2 播报完毕" );
+ break;
+ case 3:
+ Log.d( DiTTS.TAG, "反馈:" + "state=3" );
+ break;
+ default:
+ Log.d( DiTTS.TAG, "未收到反馈值" );
+ }
+ }
+ }
+
+ public static TTSManager getInstance( Context context ) {
+ if ( sInstance == null ) {
+ synchronized ( TTSManager.class ) {
+ if ( sInstance == null ) {
+ sInstance = new TTSManager( context );
+ }
+ }
+ }
+ return sInstance;
+ }
+
+ public synchronized void release() {
+ sInstance = null;
+ }
+
+ private Object readResolve() {
+ // 阻止反序列化,必须实现 Serializable 接口
+ return sInstance;
+ }
+
+ /**
+ * 播报 tts
+ *
+ * @param context
+ * @param tts
+ */
+ public void speakTTS( Context context, String tts ) {
+ if ( context == null ) {
+ return;
+ }
+ Intent intent = new Intent();
+ intent.setAction( ACTION_SPEAK_TTS );
+ intent.putExtra( EXTRA_TTS_CONTENT, tts );
+ intent.putExtra( EXTRA_TTS_SPEAKER, 0 );
+ intent.putExtra( EXTRA_TTS_ACTION, VAL_THIRD_PLAY );
+ intent.putExtra( EXTRA_TTS_SHOW_UI, false );
+ context.sendBroadcast( intent );
+ }
+
+ /**
+ * 打断播报
+ *
+ * @param context
+ */
+ public void breakOffSpeak( Context context ) {
+ if ( context == null ) {
+ return;
+ }
+ Intent intent = new Intent();
+ intent.setAction( ACTION_SPEAK_TTS );
+ intent.putExtra( EXTRA_TTS_ACTION, VAL_THIRD_STOP );
+ context.sendBroadcast( intent );
+ }
+}
diff --git a/tts/tts-noop/.gitignore b/tts/tts-noop/.gitignore
new file mode 100644
index 0000000000..42afabfd2a
--- /dev/null
+++ b/tts/tts-noop/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/tts/tts-noop/build.gradle b/tts/tts-noop/build.gradle
new file mode 100644
index 0000000000..caae249d60
--- /dev/null
+++ b/tts/tts-noop/build.gradle
@@ -0,0 +1,50 @@
+apply plugin: 'com.android.library'
+apply plugin: 'com.alibaba.arouter'
+
+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"
+
+ javaCompileOptions {
+ annotationProcessorOptions {
+ arguments = [AROUTER_MODULE_NAME: project.getName()]
+ }
+ }
+ }
+
+ 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.androidxappcompat
+ implementation rootProject.ext.dependencies.arouter
+ annotationProcessor rootProject.ext.dependencies.aroutercompiler
+
+ if (Boolean.valueOf(RELEASE)) {
+ implementation rootProject.ext.dependencies.ttsbase
+ } else {
+ implementation project(":tts:tts-base")
+ }
+}
+
+apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
\ No newline at end of file
diff --git a/tts/tts-noop/consumer-rules.pro b/tts/tts-noop/consumer-rules.pro
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tts/tts-noop/gradle.properties b/tts/tts-noop/gradle.properties
new file mode 100644
index 0000000000..766cca1f72
--- /dev/null
+++ b/tts/tts-noop/gradle.properties
@@ -0,0 +1,3 @@
+GROUP=com.mogo.tts
+POM_ARTIFACT_ID=tts-noop
+VERSION_CODE=1
diff --git a/tts/tts-noop/proguard-rules.pro b/tts/tts-noop/proguard-rules.pro
new file mode 100644
index 0000000000..481bb43481
--- /dev/null
+++ b/tts/tts-noop/proguard-rules.pro
@@ -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
\ No newline at end of file
diff --git a/tts/tts-noop/src/main/AndroidManifest.xml b/tts/tts-noop/src/main/AndroidManifest.xml
new file mode 100644
index 0000000000..9992a8a707
--- /dev/null
+++ b/tts/tts-noop/src/main/AndroidManifest.xml
@@ -0,0 +1,5 @@
+
+
+ /
+
\ No newline at end of file
diff --git a/tts/tts-noop/src/main/java/com/mogo/tts/noop/NoopTTS.java b/tts/tts-noop/src/main/java/com/mogo/tts/noop/NoopTTS.java
new file mode 100644
index 0000000000..717e576b93
--- /dev/null
+++ b/tts/tts-noop/src/main/java/com/mogo/tts/noop/NoopTTS.java
@@ -0,0 +1,91 @@
+package com.mogo.tts.noop;
+
+import android.content.Context;
+import android.util.Log;
+
+import com.alibaba.android.arouter.facade.annotation.Route;
+import com.mogo.tts.base.IMogoTTS;
+import com.mogo.tts.base.IMogoTTSCallback;
+import com.mogo.tts.base.MogoTTSConstants;
+import com.mogo.tts.base.PreemptType;
+
+public
+/**
+ * @author congtaowang
+ * @since 2020/10/13
+ *
+ * 无语音播报
+ */
+@Route( path = MogoTTSConstants.API_PATH )
+class NoopTTS implements IMogoTTS {
+
+ private static final String TAG = "NoopTTS";
+
+ @Override
+ public void release() {
+ }
+
+ @Override
+ public void flush() {
+ Log.d( TAG, "noop - flush" );
+ }
+
+ @Override
+ public void speakTTSVoice( String tts ) {
+ Log.d( TAG, "noop - speakTTSVoice" );
+ }
+
+ @Override
+ public void speakTTSVoice( String tts, IMogoTTSCallback callback ) {
+ speakTTSVoice( tts );
+ }
+
+ @Override
+ public void speakTTSVoice( String tts, PreemptType type, IMogoTTSCallback callback ) {
+ speakTTSVoice( tts );
+ }
+
+ @Override
+ public void speakQAndACmd( String tts, IMogoTTSCallback callback ) {
+ Log.d( TAG, "noop - speakQAndACmd" );
+ }
+
+ @Override
+ public void speakQAndACmd( String tts, String[] okWords, String[] cancelWords, IMogoTTSCallback callback ) {
+ Log.d( TAG, "noop - speakQAndACmd2" );
+ }
+
+ @Override
+ public void registerUnWakeupCommand( String cmd, String[] cmdWords, IMogoTTSCallback callback ) {
+ Log.d( TAG, "noop - registerUnWakeupCommand" );
+ }
+
+ @Override
+ public void unregisterUnWakeupCommand( String cmd ) {
+ Log.d( TAG, "noop - unregisterUnWakeupCommand" );
+ }
+
+ @Override
+ public void unregisterUnWakeupCommand( String cmd, IMogoTTSCallback callback ) {
+ Log.d( TAG, "noop - unregisterUnWakeupCommand2" );
+ }
+
+ @Override
+ public void startAIAssist( Context context ) {
+ Log.d( TAG, "noop - startAIAssist" );
+ }
+
+ @Override
+ public void startAIAssist( Context context, int status ) {
+ Log.d( TAG, "noop - startAIAssist2" );
+ }
+
+ @Override
+ public void breakOffSpeak() {
+ Log.d( TAG, "noop - breakOffSpeak" );
+ }
+
+ @Override
+ public void init( Context context ) {
+ }
+}
diff --git a/tts/tts-zhi/.gitignore b/tts/tts-zhi/.gitignore
new file mode 100644
index 0000000000..42afabfd2a
--- /dev/null
+++ b/tts/tts-zhi/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/tts/tts-zhi/build.gradle b/tts/tts-zhi/build.gradle
new file mode 100644
index 0000000000..6c10fe8722
--- /dev/null
+++ b/tts/tts-zhi/build.gradle
@@ -0,0 +1,54 @@
+apply plugin: 'com.android.library'
+apply plugin: 'com.alibaba.arouter'
+
+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"
+
+ javaCompileOptions {
+ annotationProcessorOptions {
+ arguments = [AROUTER_MODULE_NAME: project.getName()]
+ }
+ }
+ }
+
+ 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.androidxappcompat
+ implementation rootProject.ext.dependencies.arouter
+ annotationProcessor rootProject.ext.dependencies.aroutercompiler
+
+ api rootProject.ext.dependencies.aiassist
+ api rootProject.ext.dependencies.aiassistReplace
+
+ if (Boolean.valueOf(RELEASE)) {
+ implementation rootProject.ext.dependencies.ttsbase
+ implementation rootProject.ext.dependencies.mogoutils
+ } else {
+ implementation project(":tts:tts-base")
+ implementation project(":foudations:mogo-utils")
+ }
+}
+
+apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
\ No newline at end of file
diff --git a/tts/tts-zhi/consumer-rules.pro b/tts/tts-zhi/consumer-rules.pro
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tts/tts-zhi/gradle.properties b/tts/tts-zhi/gradle.properties
new file mode 100644
index 0000000000..297c60e48c
--- /dev/null
+++ b/tts/tts-zhi/gradle.properties
@@ -0,0 +1,3 @@
+GROUP=com.mogo.tts
+POM_ARTIFACT_ID=tts-zhi
+VERSION_CODE=1
diff --git a/tts/tts-zhi/proguard-rules.pro b/tts/tts-zhi/proguard-rules.pro
new file mode 100644
index 0000000000..481bb43481
--- /dev/null
+++ b/tts/tts-zhi/proguard-rules.pro
@@ -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
\ No newline at end of file
diff --git a/tts/tts-zhi/src/main/AndroidManifest.xml b/tts/tts-zhi/src/main/AndroidManifest.xml
new file mode 100644
index 0000000000..a70d8aa41b
--- /dev/null
+++ b/tts/tts-zhi/src/main/AndroidManifest.xml
@@ -0,0 +1,5 @@
+
+
+ /
+
\ No newline at end of file
diff --git a/tts/tts-zhi/src/main/java/com/mogo/tts/zhi/ZhiTTS.java b/tts/tts-zhi/src/main/java/com/mogo/tts/zhi/ZhiTTS.java
new file mode 100644
index 0000000000..808886f611
--- /dev/null
+++ b/tts/tts-zhi/src/main/java/com/mogo/tts/zhi/ZhiTTS.java
@@ -0,0 +1,472 @@
+package com.mogo.tts.zhi;
+
+import android.content.Context;
+import android.content.Intent;
+import android.text.TextUtils;
+
+import com.alibaba.android.arouter.facade.annotation.Route;
+import com.mogo.tts.base.IMogoTTS;
+import com.mogo.tts.base.IMogoTTSCallback;
+import com.mogo.tts.base.MogoTTSConstants;
+import com.mogo.tts.base.PreemptType;
+import com.mogo.utils.AppUtils;
+import com.mogo.utils.logger.Logger;
+import com.zhidao.auto.platform.voice.VoiceClient;
+import com.zhidao.voicesdk.MogoVoiceManager;
+import com.zhidao.voicesdk.MogoVoiceManagerImpl;
+import com.zhidao.voicesdk.callback.OnConnStatusListener;
+import com.zhidao.voicesdk.callback.OnTtsListener;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+public
+/**
+ * @author congtaowang
+ * @since 2020/10/12
+ *
+ * 描述
+ */
+@Route( path = MogoTTSConstants.API_PATH )
+class ZhiTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsListener {
+
+ private static final String TAG = "ZhiTTS";
+ private String mLastQAndASpeakText;
+
+ private boolean mHasFlush = false;
+ private boolean mInitReady = false;
+ private Context mContext;
+
+ public synchronized void release() {
+ Logger.d( TAG, "release" );
+ if ( mCmdMap != null && !mCmdMap.isEmpty() && mVoiceClient != null ) {
+ for ( String cmd : mCmdMap.keySet() ) {
+ mVoiceClient.unRegisterCustomWakeupCmd( cmd );
+ }
+ }
+ mQAndAMap.clear();
+ mVoiceClient.release();
+ mSpeakVoiceMap.clear();
+ mCacheUnWakeupCommands.clear();
+ mContext = null;
+ }
+
+ private VoiceClient mVoiceClient;
+ private MogoVoiceManager mogoVoiceManager;
+ // 免唤醒指令
+ private Map< String, List< IMogoTTSCallback > > mCmdMap = new HashMap<>();
+ // 问答指令
+ private Map< String, IMogoTTSCallback > mQAndAMap = new HashMap<>();
+ // 单独的语音播放
+ private Map< String, IMogoTTSCallback > mSpeakVoiceMap = new HashMap<>();
+
+ private Map< String, String[] > mCacheUnWakeupCommands = new ConcurrentHashMap<>();
+
+ private void initFlushStatus() {
+ if ( !mHasFlush ) {
+ mHasFlush = isVoiceServiceReady( mContext );
+ }
+ }
+
+ /**
+ * 初始化
+ */
+ private void initSpeech( Context context ) {
+ mogoVoiceManager = MogoVoiceManagerImpl.getInstance();
+ mogoVoiceManager.init( context, new OnConnStatusListener() {
+ @Override
+ public void onSuccess() {
+ mInitReady = true;
+ }
+
+ @Override
+ public void onFailed() {
+
+ }
+ } );
+ }
+
+ /**
+ * 是否语音注册成功
+ *
+ * @return
+ */
+ @Override
+ public boolean hasFlush() {
+ return mHasFlush;
+ }
+
+ @Override
+ public void onCmdSelected( String cmd ) {
+ if ( !mCmdMap.containsKey( cmd ) ) {
+ return;
+ }
+ Logger.d( TAG, "received command: %s", cmd );
+
+ Iterator< IMogoTTSCallback > iterator = null;
+ try {
+ List< IMogoTTSCallback > cmdCallBacks = mCmdMap.get( cmd );
+ iterator = new ArrayList<>( cmdCallBacks ).iterator();
+ } catch ( Exception e ) {
+
+ }
+ while ( iterator != null && iterator.hasNext() ) {
+ IMogoTTSCallback callBack = iterator.next();
+ if ( callBack != null ) {
+ callBack.onCmdSelected( cmd );
+ }
+ }
+ }
+
+ @Override
+ public void onCmdAction( String speakText ) {
+ if ( !TextUtils.isEmpty( mLastQAndASpeakText ) ) {
+ IMogoTTSCallback cmdCallBack = mQAndAMap.remove( mLastQAndASpeakText );
+ if ( cmdCallBack != null ) {
+ cmdCallBack.onCmdAction( speakText );
+ }
+ }
+ }
+
+ @Override
+ public void onCmdCancel( String speakText ) {
+ if ( !TextUtils.isEmpty( mLastQAndASpeakText ) ) {
+ IMogoTTSCallback cmdCallBack = mQAndAMap.remove( mLastQAndASpeakText );
+ if ( cmdCallBack != null ) {
+ cmdCallBack.onCmdCancel( speakText );
+ }
+ }
+ }
+
+ @Override
+ public void onSpeakEnd( String speakText ) {
+ if ( mQAndAMap.containsKey( speakText ) ) {
+ mLastQAndASpeakText = speakText;
+ IMogoTTSCallback cmdCallBack = mQAndAMap.get( speakText );
+ if ( cmdCallBack != null ) {
+ cmdCallBack.onSpeakEnd( speakText );
+ return;
+ }
+ }
+ IMogoTTSCallback callBack = mSpeakVoiceMap.remove( speakText );
+ if ( callBack != null ) {
+ callBack.onSpeakEnd( speakText );
+ }
+ }
+
+ @Override
+ public void onSpeakSelectTimeOut( String speakText ) {
+ if ( mQAndAMap.containsKey( speakText ) ) {
+ if ( TextUtils.equals( speakText, mLastQAndASpeakText ) ) {
+ mLastQAndASpeakText = null;
+ }
+ IMogoTTSCallback cmdCallBack = mQAndAMap.remove( speakText );
+ if ( cmdCallBack != null ) {
+ cmdCallBack.onSpeakSelectTimeOut( speakText );
+ return;
+ }
+ }
+ IMogoTTSCallback callBack = mSpeakVoiceMap.remove( speakText );
+ if ( callBack != null ) {
+ callBack.onSpeakSelectTimeOut( speakText );
+ }
+ }
+
+ /**
+ * 语音播报
+ *
+ * @param text
+ */
+ public void speakTTSVoice( String text, IMogoTTSCallback callBack ) {
+ try {
+ initFlushStatus();
+ if ( mHasFlush ) {
+ mSpeakVoiceMap.put( text, callBack );
+ mVoiceClient.speakDefault( text );
+ }
+ } catch ( Exception e ) {
+ }
+ }
+
+ /**
+ * 语音播报
+ *
+ * @param text
+ */
+ public void speakTTSVoice( String text ) {
+ try {
+ initFlushStatus();
+ if ( mHasFlush ) {
+ mVoiceClient.speakDefault( text );
+ }
+ } catch ( Exception e ) {
+ }
+ }
+
+ /**
+ * 语音播报
+ *
+ * @param text 播报内容
+ * @param type 播报策略
+ */
+ public void speakTTSVoice( String text, PreemptType type, IMogoTTSCallback callBack ) {
+ try {
+ initFlushStatus();
+ if ( mHasFlush ) {
+ mSpeakVoiceMap.put( text, callBack );
+ VoiceClient.PreemptType preemptType = VoiceClient.PreemptType.PREEMPT_TYPE_NONE;
+ if ( type != null ) {
+ switch ( type ) {
+ case PREEMPT_TYPE_NEXT:
+ preemptType = VoiceClient.PreemptType.PREEMPT_TYPE_NEXT;
+ break;
+ case PREEMPT_TYPE_FLUSH:
+ preemptType = VoiceClient.PreemptType.PREEMPT_TYPE_FLUSH;
+ break;
+ case PREEMPT_TYPE_IMMEDIATELY:
+ preemptType = VoiceClient.PreemptType.PREEMPT_TYPE_IMMEADIATELY;
+ break;
+ case PREEMPT_TYPE_IMMEDIATELY_WITHOUT_CANCEL:
+ preemptType = VoiceClient.PreemptType.PREEMPT_TYPE_IMMEADIATELY_WITHOUT_CANCLE;
+ break;
+ }
+ }
+ mVoiceClient.speakTypeText( text, preemptType );
+ }
+ } catch ( Exception e ) {
+ }
+ }
+
+ /**
+ * 问答类型语音注册:默认确认和取消
+ *
+ * @param tts 播报内容
+ */
+ public void speakQAndACmd( String tts, IMogoTTSCallback callBack ) {
+ initFlushStatus();
+ if ( mHasFlush ) {
+ mQAndAMap.put( tts, callBack );
+ mVoiceClient.speakTtsAndRegistCmd( tts );
+ }
+ }
+
+ /**
+ * 问答类型语音注册
+ *
+ * @param tts 播报内容
+ * @param okCmds 确认命令唤醒词
+ * @param cancelCmds 取消命令唤醒词
+ */
+ public void speakQAndACmd( String tts, String[] okCmds, String[] cancelCmds, IMogoTTSCallback callBack ) {
+ initFlushStatus();
+ if ( mHasFlush ) {
+ mQAndAMap.put( tts, callBack );
+ mVoiceClient.speakTtsAndRegistCmd( tts, okCmds, cancelCmds );
+ }
+ }
+
+ /**
+ * 注册免唤醒命令
+ *
+ * @param cmd
+ * @param cmdWords
+ * @param callBack
+ */
+ public void registerUnWakeupCommand( String cmd, String[] cmdWords, IMogoTTSCallback callBack ) {
+ if ( !mCmdMap.containsKey( cmd ) ) {
+ mCmdMap.put( cmd, new ArrayList<>() );
+ }
+ mCmdMap.get( cmd ).add( callBack );
+
+ initFlushStatus();
+ if ( mHasFlush ) {
+ mVoiceClient.registerCustomWakeupCmd( cmd, cmdWords );
+ mCacheUnWakeupCommands.remove( cmd );
+ }
+ Logger.i( TAG, "cache un wakeup command2. %s", cmd );
+ mCacheUnWakeupCommands.put( cmd, cmdWords );
+ }
+
+ /**
+ * 注册免唤醒命令
+ *
+ * @param cmd
+ * @param cmdWords
+ */
+ private void registerUnWakeupCommand( String cmd, String[] cmdWords ) {
+ initFlushStatus();
+ if ( mHasFlush ) {
+ mVoiceClient.registerCustomWakeupCmd( cmd, cmdWords );
+ mCacheUnWakeupCommands.remove( cmd );
+ }
+ Logger.i( TAG, "cache un wakeup command. %s", cmd );
+ mCacheUnWakeupCommands.put( cmd, cmdWords );
+ }
+
+ /**
+ * 注销免唤醒命令
+ *
+ * @param cmd
+ */
+ public synchronized void unregisterUnWakeupCommand( String cmd ) {
+ mCmdMap.remove( cmd );
+ mVoiceClient.unRegisterCustomWakeupCmd( cmd );
+ mCacheUnWakeupCommands.remove( cmd );
+ }
+
+ /**
+ * 注销免唤醒命令
+ *
+ * @param cmd
+ */
+ public synchronized void unregisterUnWakeupCommand( String cmd, IMogoTTSCallback callBack ) {
+ if ( mCmdMap.containsKey( cmd ) ) {
+ List< IMogoTTSCallback > callBacks = mCmdMap.get( cmd );
+ if ( callBacks != null ) {
+ callBacks.remove( callBack );
+ }
+ if ( callBacks.isEmpty() ) {
+ mCmdMap.remove( cmd );
+ mVoiceClient.unRegisterCustomWakeupCmd( cmd );
+ mCacheUnWakeupCommands.remove( cmd );
+ }
+ }
+ }
+
+ public static void startAssistant( Context context ) {
+ startAssistant( context, 1 );
+ }
+
+ /**
+ * @param context
+ * @param status window_start_cancel 0 - 结束, 1 - 显示, 2 - 未激活调试进入
+ */
+ public static void startAssistant( Context context, int status ) {
+ final Intent intent = new Intent();
+ intent.setFlags( Intent.FLAG_INCLUDE_STOPPED_PACKAGES );
+ intent.setAction( "pvetec.intent.action.txz.switch" );
+ intent.putExtra( "window_start_cancel", status );
+ intent.putExtra( "extra_switch_type", "window_start_cancel" );
+ Logger.d( TAG, "status = %d", status );
+ context.sendBroadcast( intent );
+ }
+
+ public synchronized void flush() {
+ if ( mCacheUnWakeupCommands.isEmpty() ) {
+ return;
+ }
+ mHasFlush = true;
+ Logger.d( TAG, "flush cache voice command when voice service ready." );
+ final Map< String, String[] > tmp = new HashMap<>( mCacheUnWakeupCommands );
+ for ( String cmd : tmp.keySet() ) {
+ registerUnWakeupCommand( cmd, tmp.get( cmd ) );
+ }
+ }
+
+ private boolean isVoiceServiceReady( Context context ) {
+ if ( AppUtils.isProcessRunning( context, AppUtils.getPackageUid( context, "com.zhidao.speech" ) )
+ && AppUtils.isProcessRunning( context, AppUtils.getPackageUid( context, "com.zhidao.speech.adapter" ) ) ) {
+ return true;
+ } else if ( AppUtils.isProcessRunning( context, AppUtils.getPackageUid( context, "com.txznet.txz" ) )
+ && AppUtils.isProcessRunning( context, AppUtils.getPackageUid( context, "com.txznet.adapter" ) ) ) {
+ Logger.d( TAG, "txz is voiceServiceReady" );
+ return true;
+ }
+ return false;
+ }
+
+ public void speakTTSAndDuck( String text ) {
+ speakTTSAndDuck( text, null );
+ }
+
+ public void speakTTSAndDuck( String text, IMogoTTSCallback callBack ) {
+ try {
+ if ( mInitReady ) {
+ mSpeakVoiceMap.put( text, callBack );
+ mogoVoiceManager.toSpeak( text, -3, this );
+ }
+ } catch ( Exception e ) {
+ }
+ }
+
+ public void shutUp( String ttsId, String text ) {
+ try {
+ mSpeakVoiceMap.remove( text );
+ mogoVoiceManager.shutUp( ttsId );
+ } catch ( Exception e ) {
+
+ }
+ }
+
+ /**
+ * 打断上一条正在播报的语音内容,仅在Speech上生效,TXZ为空实现
+ * 语音SDK生效版本从1.0.8.4版本起
+ */
+ public void breakOffSpeak() {
+ mVoiceClient.breakOffSpeak();
+ }
+
+ public void clearTTSCallback( String text ) {
+ try {
+ mSpeakVoiceMap.remove( text );
+ } catch ( Exception e ) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onTtsStart( String ttsId, String text ) {
+ IMogoTTSCallback callBack = mSpeakVoiceMap.get( text );
+ if ( callBack != null ) {
+ callBack.onTTSStart( ttsId, text );
+ }
+ }
+
+ @Override
+ public void onTtsFinish( String ttsId, String text ) {
+ IMogoTTSCallback callBack = mSpeakVoiceMap.remove( text );
+ if ( callBack != null ) {
+ callBack.onTTSEnd( ttsId, text );
+ }
+ }
+
+ @Override
+ public void onTtsError( String ttsId, String text ) {
+ IMogoTTSCallback callBack = mSpeakVoiceMap.remove( text );
+ if ( callBack != null ) {
+ callBack.onTTSError( ttsId, text );
+ }
+ }
+
+ @Override
+ public void init( Context context ) {
+ if ( context != null ) {
+ mContext = context.getApplicationContext();
+ mVoiceClient = new VoiceClient( mContext );
+ mVoiceClient.setCallBack( this );
+ initFlushStatus();
+ initSpeech( context );
+ Logger.w( TAG, "voice is ready = %s", mHasFlush );
+ }
+ }
+
+ @Override
+ public void startAIAssist( Context context ) {
+ startAssistant( context, 1 );
+ }
+
+ @Override
+ public void startAIAssist( Context context, int status ) {
+ final Intent intent = new Intent();
+ intent.setFlags( Intent.FLAG_INCLUDE_STOPPED_PACKAGES );
+ intent.setAction( "pvetec.intent.action.txz.switch" );
+ intent.putExtra( "window_start_cancel", status );
+ intent.putExtra( "extra_switch_type", "window_start_cancel" );
+ Logger.d( TAG, "status = %d", status );
+ context.sendBroadcast( intent );
+ }
+}
diff --git a/upload.sh b/upload.sh
index 06362bd7db..054ba576f4 100755
--- a/upload.sh
+++ b/upload.sh
@@ -3,17 +3,29 @@
./gradlew :foudations:mogo-utils:clean :foudations:mogo-utils:uploadArchives
if [ $? -ne 0 ];then exit; fi
./gradlew :skin:mogo-skin-support:clean :skin:mogo-skin-support:uploadArchives
-if [ $? -ne 0 ];then exit; fi
+if [ $? -ne 0 ]; then exit; fi
+./gradlew :tts:tts-base:clean :tts:tts-base:uploadArchives
+if [ $? -ne 0 ]; then exit; fi
+./gradlew :tts:tts-zhi:clean :tts:tts-zhi:uploadArchives
+if [ $? -ne 0 ]; then exit; fi
+./gradlew :tts:tts-di:clean :tts:tts-di:uploadArchives
+if [ $? -ne 0 ]; then exit; fi
+./gradlew :tts:tts-noop:clean :tts:tts-noop:uploadArchives
+if [ $? -ne 0 ]; then exit; fi
./gradlew :foudations:mogo-commons:clean :foudations:mogo-commons:uploadArchives
if [ $? -ne 0 ]; then exit; fi
-./gradlew :test:crashreport:clean :test:crashreport:uploadArchives
-if [ $? -ne 0 ];then exit; fi
-./gradlew :test:crashreport-bugly:clean :test:crashreport-bugly:uploadArchives
-if [ $? -ne 0 ];then exit; fi
-./gradlew :test:crashreport-noop:clean :test:crashreport-noop:uploadArchives
-if [ $? -ne 0 ];then exit; fi
./gradlew :libraries:mogo-map-api:clean :libraries:mogo-map-api:uploadArchives
if [ $? -ne 0 ]; then exit; fi
+./gradlew :skin:skin-support:clean :skin:skin-support:uploadArchives
+if [ $? -ne 0 ]; then exit; fi
+./gradlew :skin:skin-support-appcompat:clean :skin:skin-support-appcompat:uploadArchives
+if [ $? -ne 0 ]; then exit; fi
+./gradlew :skin:skin-support-cardview:clean :skin:skin-support-cardview:uploadArchives
+if [ $? -ne 0 ]; then exit; fi
+./gradlew :skin:skin-support-constraint-layout:clean :skin:skin-support-constraint-layout:uploadArchives
+if [ $? -ne 0 ]; then exit; fi
+./gradlew :skin:skin-support-design:clean :skin:skin-support-design:uploadArchives
+if [ $? -ne 0 ]; then exit; fi
./gradlew :services:mogo-service-api:clean :services:mogo-service-api:uploadArchives
if [ $? -ne 0 ]; then exit; fi
./gradlew :libraries:map-amap:clean :libraries:map-amap:uploadArchives
@@ -24,22 +36,18 @@ if [ $? -ne 0 ]; then exit; fi
if [ $? -ne 0 ]; then exit; fi
./gradlew :modules:mogo-module-common:clean :modules:mogo-module-common:uploadArchives
if [ $? -ne 0 ]; then exit; fi
-./gradlew :skin:mogo-skin-light:clean :skin:mogo-skin-light:uploadArchives
-if [ $? -ne 0 ];then exit; fi
./gradlew :skin:mogo-skin-support-impl:clean :skin:mogo-skin-support-impl:uploadArchives
-if [ $? -ne 0 ];then exit; fi
+if [ $? -ne 0 ]; then exit; fi
./gradlew :skin:mogo-skin-support-noop:clean :skin:mogo-skin-support-noop:uploadArchives
-if [ $? -ne 0 ];then exit; fi
-./gradlew :skin:skin-support:clean :skin:skin-support:uploadArchives
-if [ $? -ne 0 ];then exit; fi
-./gradlew :skin:skin-support-appcompat:clean :skin:skin-support-appcompat:uploadArchives
-if [ $? -ne 0 ];then exit; fi
-./gradlew :skin:skin-support-cardview:clean :skin:skin-support-cardview:uploadArchives
-if [ $? -ne 0 ];then exit; fi
-./gradlew :skin:skin-support-constraint-layout:clean :skin:skin-support-constraint-layout:uploadArchives
-if [ $? -ne 0 ];then exit; fi
-./gradlew :skin:skin-support-design:clean :skin:skin-support-design:uploadArchives
-if [ $? -ne 0 ];then exit; fi
+if [ $? -ne 0 ]; then exit; fi
+./gradlew :test:crashreport:clean :test:crashreport:uploadArchives
+if [ $? -ne 0 ]; then exit; fi
+./gradlew :test:crashreport-bugly:clean :test:crashreport-bugly:uploadArchives
+if [ $? -ne 0 ]; then exit; fi
+./gradlew :test:crashreport-noop:clean :test:crashreport-noop:uploadArchives
+if [ $? -ne 0 ]; then exit; fi
+./gradlew :skin:mogo-skin-light:clean :skin:mogo-skin-light:uploadArchives
+if [ $? -ne 0 ]; then exit; fi
./gradlew :services:mogo-service:clean :services:mogo-service:uploadArchives
if [ $? -ne 0 ]; then exit; fi
./gradlew :modules:mogo-module-obu:clean :modules:mogo-module-obu:uploadArchives
@@ -78,10 +86,6 @@ if [ $? -ne 0 ]; then exit; fi
if [ $? -ne 0 ]; then exit; fi
./gradlew :main-extensions:mogo-module-main-launcher:clean :main-extensions:mogo-module-main-launcher:uploadArchives
if [ $? -ne 0 ]; then exit; fi
-./gradlew :modules:mogo-module-event-panel:clean :modules:mogo-module-event-panel:uploadArchives
-if [ $? -ne 0 ]; then exit; fi
-./gradlew :modules:mogo-module-event-panel-noop:clean :modules:mogo-module-event-panel-noop:uploadArchives
-if [ $? -ne 0 ]; then exit; fi
./gradlew :modules:mogo-module-left-panel:clean :modules:mogo-module-left-panel:uploadArchives
if [ $? -ne 0 ]; then exit; fi
./gradlew :modules:mogo-module-left-panel-noop:clean :modules:mogo-module-left-panel-noop:uploadArchives
@@ -96,7 +100,11 @@ if [ $? -ne 0 ]; then exit; fi
if [ $? -ne 0 ]; then exit; fi
./gradlew :modules:mogo-module-push:clean :modules:mogo-module-push:uploadArchives
if [ $? -ne 0 ]; then exit; fi
-./gradlew :modules:mogo-module-widgets:clean :modules:mogo-module-widgets:uploadArchives
+./gradlew :libraries:tanlulib:clean :libraries:tanlulib:uploadArchives
+if [ $? -ne 0 ]; then exit; fi
+./gradlew :libraries:mogo-tanlu-api:clean :libraries:mogo-tanlu-api:uploadArchives
+if [ $? -ne 0 ]; then exit; fi
+./gradlew :modules:mogo-module-monitor:clean :modules:mogo-module-monitor:uploadArchives
if [ $? -ne 0 ]; then exit; fi
./gradlew :modules:mogo-module-splash:clean :modules:mogo-module-splash:uploadArchives
if [ $? -ne 0 ]; then exit; fi
@@ -104,4 +112,5 @@ if [ $? -ne 0 ]; then exit; fi
if [ $? -ne 0 ]; then exit; fi
./gradlew :modules:mogo-module-tanlu:clean :modules:mogo-module-tanlu:uploadArchives
if [ $? -ne 0 ]; then exit; fi
-./gradlew :modules:mogo-module-monitor:clean :modules:mogo-module-monitor:uploadArchives
\ No newline at end of file
+./gradlew :modules:mogo-module-widgets:clean :modules:mogo-module-widgets:uploadArchives
+if [ $? -ne 0 ]; then exit; fi
\ No newline at end of file