diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index 681f41ae2a..663459aa50 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -1,5 +1,14 @@ + + + - + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 4a9dd4dfa3..33615bd328 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -109,6 +109,10 @@ 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' } // f系列-分体机 f80x { @@ -123,6 +127,10 @@ 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' } // e系列,采用Launcher方案 e8xx { @@ -137,6 +145,10 @@ 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' } // 同上 em4 { @@ -151,6 +163,10 @@ 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' } // e系列-2+32,对标D系列2+32,采用独立app的形式 em3 { @@ -165,6 +181,10 @@ 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' } // e系列-1+16,对标D系列1+16,采用独立app形式 em1 { @@ -179,6 +199,10 @@ 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' } // d系列 d8xx { @@ -193,6 +217,10 @@ 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' } // d系列 2 + 32 d80x { @@ -207,6 +235,10 @@ 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' } // d系列 1+16 版本 d82x { @@ -221,6 +253,10 @@ 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' } // 比亚迪 bydauto { @@ -235,6 +271,10 @@ 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' } qa { dimension "env" @@ -253,6 +293,12 @@ android { packagingOptions { exclude 'META-INF/io.netty.versions.properties' } + + sourceSets { + main { + res.srcDirs = ['src/main/res', 'src/main/res-night'] + } + } } repositories { @@ -269,14 +315,15 @@ dependencies { implementation rootProject.ext.dependencies.androidxappcompat implementation rootProject.ext.dependencies.arouter implementation rootProject.ext.dependencies.boostmultidex - debugImplementation rootProject.ext.dependencies.leakcanary - testImplementation rootProject.ext.dependencies.leakcanary - releaseImplementation rootProject.ext.dependencies.leakcanarynoop + debugImplementation rootProject.ext.dependencies.debugleakcanary + releaseImplementation rootProject.ext.dependencies.releaseleakcanary implementation rootProject.ext.dependencies.carcallprovider implementation rootProject.ext.dependencies.carcall implementation rootProject.ext.dependencies.mogologlib + compileOnly rootProject.ext.dependencies.adasapi + compileOnly rootProject.ext.dependencies.adasconfigapi if (Boolean.valueOf(RELEASE)) { implementation rootProject.ext.dependencies.mogocommons @@ -295,6 +342,7 @@ dependencies { implementation rootProject.ext.dependencies.mogomonitor implementation rootProject.ext.dependencies.mogomodulewidgets implementation rootProject.ext.dependencies.mogomoduleback + implementation rootProject.ext.dependencies.guideshow } else { implementation project(':foudations:mogo-commons') implementation project(':modules:mogo-module-common') @@ -311,6 +359,7 @@ dependencies { implementation project(':modules:mogo-module-monitor') implementation project(':modules:mogo-module-widgets') implementation project(':modules:mogo-module-back') + implementation project(':modules:mogo-module-guide') } apply from: "./functions/perform.gradle" @@ -318,6 +367,8 @@ dependencies { apply from: "./functions/socketpush.gradle" apply from: "./functions/gpssimulator.gradle" apply from: "./functions/leftpanel.gradle" + apply from: "./functions/skin.gradle" + apply from: "./functions/crashreport.gradle" } android.applicationVariants.all { variant -> diff --git a/app/functions/crashreport.gradle b/app/functions/crashreport.gradle new file mode 100644 index 0000000000..7fb0712d47 --- /dev/null +++ b/app/functions/crashreport.gradle @@ -0,0 +1,13 @@ +// bugly 上报,目前仅在debug编译下加载bugly + +project.dependencies { + if (Boolean.valueOf(RELEASE)) { + implementation rootProject.ext.dependencies.crashreport + debugImplementation rootProject.ext.dependencies.crashreportbugly + releaseImplementation rootProject.ext.dependencies.crashreportnoop + } else { + implementation project(':test:crashreport') + debugImplementation project(':test:crashreport-bugly') + releaseImplementation project(':test:crashreport-noop') + } +} \ No newline at end of file diff --git a/app/functions/skin.gradle b/app/functions/skin.gradle new file mode 100644 index 0000000000..5945ee7e4c --- /dev/null +++ b/app/functions/skin.gradle @@ -0,0 +1,48 @@ +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 + + f8xxImplementation rootProject.ext.dependencies.skinsupportimpl + f80xImplementation rootProject.ext.dependencies.skinsupportimpl + em4Implementation rootProject.ext.dependencies.skinsupportimpl + e8xxImplementation rootProject.ext.dependencies.skinsupportimpl + + f8xxImplementation rootProject.ext.dependencies.skinsupportlight + 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 + } 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') + + f8xxImplementation project(':skin:mogo-skin-support-impl') + f80xImplementation project(':skin:mogo-skin-support-impl') + em4Implementation project(':skin:mogo-skin-support-impl') + e8xxImplementation project(':skin:mogo-skin-support-impl') + + f8xxImplementation project(':skin:mogo-skin-light') + 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') + } +} \ No newline at end of file diff --git a/app/src/e8xx/AndroidManifest.xml b/app/src/e8xx/AndroidManifest.xml index d755054676..01afff1292 100644 --- a/app/src/e8xx/AndroidManifest.xml +++ b/app/src/e8xx/AndroidManifest.xml @@ -1,6 +1,5 @@ \ No newline at end of file diff --git a/app/src/em4/AndroidManifest.xml b/app/src/em4/AndroidManifest.xml index d755054676..39c9d3833d 100644 --- a/app/src/em4/AndroidManifest.xml +++ b/app/src/em4/AndroidManifest.xml @@ -3,4 +3,5 @@ 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 6c241e16fd..656fef5fb5 100644 --- a/app/src/main/java/com/mogo/launcher/MogoApplication.java +++ b/app/src/main/java/com/mogo/launcher/MogoApplication.java @@ -26,13 +26,19 @@ import com.mogo.module.widgets.MogoWidgetsProvider; import com.mogo.service.IMogoServiceApis; import com.mogo.service.MogoServicePaths; import com.mogo.service.passport.IMogoTicketCallback; +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; import com.zhidao.mogo.tanlu.api.TanluApiConst; +import static com.mogo.module.guide.GuideConstant.PATH_GUIDE_FRAGMENT; +import static com.mogo.module.guide.GuideConstant.PATH_GUIDE_MODULE_NAME; + /** * @author congtaowang * @since 2019-12-18 @@ -47,6 +53,9 @@ public class MogoApplication extends AbsMogoApplication { public void onCreate() { initDebugConfig(); super.onCreate(); + if ( !shouldInit() ) { + return; + } // Crash 日志收集 final long start = System.currentTimeMillis(); CrashSystem crashSystem = CrashSystem.getInstance( this ); @@ -55,7 +64,11 @@ public class MogoApplication extends AbsMogoApplication { crashSystem.setDebug( BuildConfig.DEBUG ); Logger.init( BuildConfig.DEBUG ? LogLevel.DEBUG : LogLevel.OFF ); -// MogoModulePaths.addModule(new MogoModule(PATH_GUIDE_FRAGMENT, PATH_GUIDE_MODULE_NAME)); + 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( MogoServicePaths.PATH_AGREEMENT, AuthorizeConstant.PATH_AGREEMENT_MODULE_NAME ) ); if ( DebugConfig.isLauncher() ) { @@ -67,16 +80,17 @@ public class MogoApplication extends AbsMogoApplication { if ( DebugConfig.getCarMachineType() != DebugConfig.CAR_MACHINE_TYPE_BYD ) { MogoModulePaths.addModule( new MogoModule( CallChatConstant.PROVIDER, CallChatConstant.MODULE_NAME ) ); } + MogoModulePaths.addModule( new MogoModule( TanluApiConst.MODULE_PATH, TanluApiConst.MODULE_NAME ) ); - MogoModulePaths.addModule( new MogoModule( TanluConstants.TAG, TanluConstants.MODEL_NAME ) ); - MogoModulePaths.addModule( new MogoModule( MogoServicePaths.PATH_SHARE, "ShareControl" ) ); + MogoModulePaths.addBaseModule( new MogoModule( TanluConstants.TAG, TanluConstants.MODEL_NAME ) ); + MogoModulePaths.addBaseModule( new MogoModule( MogoServicePaths.PATH_SHARE, "ShareControl" ) ); MogoModulePaths.addModule( new MogoModule( LeftPanelConst.PATH_NAME, LeftPanelConst.MODULE_NAME ) ); MogoModulePaths.addBaseModule( new MogoModule( ServiceConst.PATH_REFRESH_STRATEGY, ServiceConst.PATH_REFRESH_STRATEGY ) ); 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.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 ) ); @@ -85,10 +99,25 @@ public class MogoApplication extends AbsMogoApplication { Intent intent = new Intent( this, MogoMainService.class ); startService( intent ); } + + LeakCanary.install( this ); + + // debug 下初始化 bugly 上报 + if ( DebugConfig.isDebug() ) { + ARouter.getInstance().navigation( ITestCrashReportProvider.class ); + } Log.i( "timer", "cost " + ( System.currentTimeMillis() - start ) + "ms" ); } + @Override + protected boolean shouldInit() { + return !LeakCanary.isInAnalyzerProcess( this ); + } + private void initDebugConfig() { + if ( !shouldInit() ) { + return; + } DebugConfig.setNetMode( BuildConfig.NET_ENV ); DebugConfig.setDebug( BuildConfig.DEBUG ); DebugConfig.setAIType( BuildConfig.AIType ); @@ -100,20 +129,29 @@ 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 ); + } + + @Override + protected void asyncInitImpl() { + super.asyncInitImpl(); } @Override protected void init() { super.init(); - prepareBaseService( 2_000L ); + final IMogoServiceApis apis = ARouter.getInstance().navigation( IMogoServiceApis.class ); + prepareBaseService( apis, 2_000L ); +// installSkinManager( this, apis ); } /** * 基础服务:passport、location、socket */ - private void prepareBaseService( long delay ) { + private void prepareBaseService( IMogoServiceApis apis, long delay ) { + UiThreadHandler.postDelayed( () -> { - final IMogoServiceApis apis = ARouter.getInstance().navigation( IMogoServiceApis.class ); // 第三方平台的sn是服务端生成的,所以必须在返回后才能开启 if ( TextUtils.isEmpty( Utils.getSn() ) ) { preparePassportEnvironment( apis, () -> { diff --git a/config.gradle b/config.gradle index 436b7c6281..8cbe49b6ab 100644 --- a/config.gradle +++ b/config.gradle @@ -4,20 +4,19 @@ ext { android = [ // applicationId : "com.mogo.launcher", // zhidadoApplicationId: "com.zhidao.launcher", - launcherApplicationId : "com.mogo.launcher", - independentApplicationId : "com.mogo.launcher.app", - fLauncherApplicationId : "com.mogo.launcher.f", - bydautoIndependentApplicationId: "com.mogo.launcher.app.bydauto", - fLauncherAmapApiValue : "aa2c8a0547378ead2f9a37762d9dd179", - bydautoIndependentApiValue : "b1e1d527b02a493913c50985827c943a", - commonLauncherAmapApiValue : "a36b9f7b086fa3951bb35338a5a06dd3", - commonIndependentAmapApiValue : "1c3fbc5f5e183619ffb1e7bc01e6751f", - compileSdkVersion : 28, - buildToolsVersion : "29.0.2", - minSdkVersion : 19, - targetSdkVersion : 22, +launcherApplicationId : "com.mogo.launcher", +independentApplicationId : "com.mogo.launcher.app", +fLauncherApplicationId : "com.mogo.launcher.f", +bydautoIndependentApplicationId: "com.mogo.launcher.app.bydauto", +fLauncherAmapApiValue : "aa2c8a0547378ead2f9a37762d9dd179", +bydautoIndependentApiValue : "b1e1d527b02a493913c50985827c943a", +commonLauncherAmapApiValue : "a36b9f7b086fa3951bb35338a5a06dd3", +commonIndependentAmapApiValue : "1c3fbc5f5e183619ffb1e7bc01e6751f", +compileSdkVersion : 28, +buildToolsVersion : "29.0.2", +minSdkVersion : 19, +targetSdkVersion : 22, ] - dependencies = [ // androidx androidxappcompat : "androidx.appcompat:appcompat:1.1.0", @@ -85,6 +84,7 @@ ext { // material material : 'com.google.android.material:material:1.1.0', + indicator : 'com.github.zhpanvip:viewpagerindicator:1.0.4', // modules moduletanlu : "com.mogo.module:module-tanlu:${MOGO_MODULE_TANLU_VERSION}", @@ -109,7 +109,7 @@ ext { 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}", + 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}", @@ -161,6 +161,7 @@ ext { 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", // 个人中心的SDK personalsdk : "com.zhidaoauto.person.info:data:1.0.1", @@ -198,6 +199,16 @@ ext { // 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}", + + crashreport : "com.mogo.test:crashrepot:${CRASHREPORT_VERSION}", + crashreportbugly : "com.mogo.test:crashreport-bugly:${CRASHREPORT_BUGLY_VERSION}", + crashreportnoop : "com.mogo.test:crashreport-noop:${CRASHREPORT_NOOP_VERSION}", ] + } \ No newline at end of file diff --git a/foudations/mogo-commons/build.gradle b/foudations/mogo-commons/build.gradle index 0f2fc4036c..dcb2e0b323 100644 --- a/foudations/mogo-commons/build.gradle +++ b/foudations/mogo-commons/build.gradle @@ -46,12 +46,12 @@ dependencies { implementation rootProject.ext.dependencies.accountsdk if (Boolean.valueOf(RELEASE)) { implementation rootProject.ext.dependencies.mogoutils + implementation rootProject.ext.dependencies.skinsupport } else { implementation project(":foudations:mogo-utils") + implementation project(":skin:mogo-skin-support") } api 'org.greenrobot:eventbus:3.1.1' - - } apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString() \ No newline at end of file diff --git a/foudations/mogo-commons/src/main/java/com/mogo/commons/AbsMogoApplication.java b/foudations/mogo-commons/src/main/java/com/mogo/commons/AbsMogoApplication.java index 360dbb622b..fa21e41563 100644 --- a/foudations/mogo-commons/src/main/java/com/mogo/commons/AbsMogoApplication.java +++ b/foudations/mogo-commons/src/main/java/com/mogo/commons/AbsMogoApplication.java @@ -4,6 +4,8 @@ import android.app.Application; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; import android.widget.TextView; import com.alibaba.android.arouter.launcher.ARouter; @@ -17,6 +19,7 @@ import com.mogo.commons.network.ParamsUtil; import com.mogo.commons.network.X509TrustManagerImpl; import com.mogo.commons.storage.SpStorage; import com.mogo.utils.ThreadPoolService; +import com.mogo.utils.TipDrawable; import com.mogo.utils.TipToast; import com.mogo.utils.network.NetConfig; @@ -50,7 +53,13 @@ public class AbsMogoApplication extends Application { public void onCreate() { super.onCreate(); sApp = this; - init(); + if ( shouldInit() ) { + init(); + } + } + + protected boolean shouldInit(){ + return true; } protected void init() { @@ -65,13 +74,26 @@ public class AbsMogoApplication extends Application { ARouter.openLog(); } ARouter.init( sApp ); - TipToast.init( this, ( ( context, message ) -> { + TipToast.init( this, ( ( context, message, tipDrawable ) -> { if ( TextUtils.isEmpty( message ) ) { return null; } - View contentView = LayoutInflater.from( context ).inflate( R.layout.module_commons_layout_toast, null ); - TextView txt = contentView.findViewById( R.id.module_commons_toast_msg ); - txt.setText( message ); + View contentView; + if(tipDrawable==null) { + contentView = LayoutInflater.from(context).inflate(R.layout.module_commons_layout_toast, null); + TextView txt = contentView.findViewById(R.id.module_commons_toast_msg); + txt.setText(message); + }else{ + // 有图片,使用带图片的布局,当前只实现了左侧图片 + contentView = LayoutInflater.from(context).inflate(R.layout.module_commons_layout_toast_with_left_drawable, null); + TextView txt = contentView.findViewById(R.id.module_commons_toast_msg); + ImageView img = contentView.findViewById(R.id.module_commons_toast_left_drawable); + img.setImageDrawable(tipDrawable.getDrawable()); + ViewGroup.LayoutParams params = img.getLayoutParams(); + params.width = tipDrawable.getWidth(); + params.height = tipDrawable.getHeight(); + txt.setText(message); + } return contentView; } ) ); } 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 882654d243..4f9761ca27 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 @@ -250,4 +250,31 @@ public class DebugConfig { public static void setRoadEventAnimated( boolean sRoadEventAnimated ) { DebugConfig.sRoadEventAnimated = sRoadEventAnimated; } + + + private static boolean sLoadGuideModule = false; + + public static void setLoadGuideModule( boolean sLoadGuideModule ) { + DebugConfig.sLoadGuideModule = sLoadGuideModule; + } + + public static boolean isLoadGuideModule() { + return sLoadGuideModule; + } + + private static String SP_GUIDE = "SP_GUIDE_2020_09_09"; + + public static String getSpGuide(){ + return SP_GUIDE; + } + + private static boolean isSkinSupported = false; + + public static void setSkinSupported( boolean isSkinSupported ) { + DebugConfig.isSkinSupported = isSkinSupported; + } + + public static boolean isSkinSupported() { + return isSkinSupported; + } } diff --git a/foudations/mogo-commons/src/main/java/com/mogo/commons/mvp/MvpActivity.java b/foudations/mogo-commons/src/main/java/com/mogo/commons/mvp/MvpActivity.java index c31eb8b869..8f165549a0 100644 --- a/foudations/mogo-commons/src/main/java/com/mogo/commons/mvp/MvpActivity.java +++ b/foudations/mogo-commons/src/main/java/com/mogo/commons/mvp/MvpActivity.java @@ -2,7 +2,6 @@ package com.mogo.commons.mvp; import android.content.Context; import android.os.Bundle; - import android.view.MotionEvent; import android.view.Window; import android.view.WindowManager; @@ -10,8 +9,10 @@ import android.view.WindowManager; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.app.AppCompatDelegate; import com.mogo.commons.debug.DebugConfig; +import com.mogo.skin.support.MogoSkinManager; import com.mogo.utils.SoftKeyBoardJobber; /** @@ -28,9 +29,10 @@ public abstract class MvpActivity< V extends IView, P extends Presenter< V > > @Override protected void onCreate( @Nullable Bundle savedInstanceState ) { super.onCreate( savedInstanceState ); - if (DebugConfig.getCarMachineType() == DebugConfig.CAR_MACHINE_TYPE_BYD) { - requestWindowFeature(Window.FEATURE_NO_TITLE); - getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); + beforeSetContentView(savedInstanceState); + if ( DebugConfig.getCarMachineType() == DebugConfig.CAR_MACHINE_TYPE_BYD ) { + requestWindowFeature( Window.FEATURE_NO_TITLE ); + getWindow().setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN ); } setContentView( getLayoutId() ); initViews(); @@ -38,6 +40,10 @@ public abstract class MvpActivity< V extends IView, P extends Presenter< V > > getLifecycle().addObserver( mPresenter ); } + protected void beforeSetContentView(Bundle savedInstanceState){ + + } + /** * 布局资源 * @@ -76,6 +82,7 @@ public abstract class MvpActivity< V extends IView, P extends Presenter< V > > } return onTouchEvent( ev ); } + protected boolean enableDispatchTouchEventToDismissSoftKeyBoard() { return true; } @@ -89,4 +96,11 @@ public abstract class MvpActivity< V extends IView, P extends Presenter< V > > } mPresenter = null; } + + @NonNull + @Override + public AppCompatDelegate getDelegate() { + return MogoSkinManager.getInstance().getInstaller().getSkinAppCompatDelegate(this, + super.getDelegate(), this); + } } diff --git a/foudations/mogo-commons/src/main/java/com/mogo/commons/mvp/MvpFragment.java b/foudations/mogo-commons/src/main/java/com/mogo/commons/mvp/MvpFragment.java index 5d299590a0..b7f21772f4 100644 --- a/foudations/mogo-commons/src/main/java/com/mogo/commons/mvp/MvpFragment.java +++ b/foudations/mogo-commons/src/main/java/com/mogo/commons/mvp/MvpFragment.java @@ -47,7 +47,6 @@ public abstract class MvpFragment> exten @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); - initViews(savedInstanceState); } /** @@ -61,6 +60,7 @@ public abstract class MvpFragment> exten public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); initViews(); + initViews(savedInstanceState); mPresenter = createPresenter(); getViewLifecycleOwner().getLifecycle().addObserver(mPresenter); } diff --git a/foudations/mogo-commons/src/main/java/com/mogo/commons/network/SubscribeImpl.java b/foudations/mogo-commons/src/main/java/com/mogo/commons/network/SubscribeImpl.java index 5d9217849e..ab0aa03504 100644 --- a/foudations/mogo-commons/src/main/java/com/mogo/commons/network/SubscribeImpl.java +++ b/foudations/mogo-commons/src/main/java/com/mogo/commons/network/SubscribeImpl.java @@ -1,6 +1,7 @@ package com.mogo.commons.network; import com.mogo.commons.data.BaseData; +import com.mogo.commons.storage.SpStorage; import com.mogo.utils.logger.Logger; import com.mogo.utils.network.RequestOptions; import com.mogo.utils.network.utils.Util; diff --git a/foudations/mogo-commons/src/main/res/drawable/module_commons_toast_bkg.xml b/foudations/mogo-commons/src/main/res/drawable/module_commons_toast_bkg.xml index 58389abf7c..b43a13e664 100644 --- a/foudations/mogo-commons/src/main/res/drawable/module_commons_toast_bkg.xml +++ b/foudations/mogo-commons/src/main/res/drawable/module_commons_toast_bkg.xml @@ -2,7 +2,7 @@ + android:angle="180" + android:endColor="#FF3F4057" + android:startColor="#FF5E6079" /> \ No newline at end of file diff --git a/foudations/mogo-commons/src/main/res/layout/module_commons_layout_toast.xml b/foudations/mogo-commons/src/main/res/layout/module_commons_layout_toast.xml index 0b01115f63..cbf0032516 100644 --- a/foudations/mogo-commons/src/main/res/layout/module_commons_layout_toast.xml +++ b/foudations/mogo-commons/src/main/res/layout/module_commons_layout_toast.xml @@ -1,27 +1,28 @@ - + android:paddingTop="@dimen/module_commons_toast_marginTop" + android:paddingBottom="@dimen/module_commons_toast_marginBottom" + android:paddingLeft="@dimen/module_commons_toast_marginLeft" + android:paddingRight="@dimen/module_commons_toast_marginRight"> - \ No newline at end of file + tools:text="测试测试测试" /> + + + \ No newline at end of file diff --git a/foudations/mogo-commons/src/main/res/layout/module_commons_layout_toast_with_left_drawable.xml b/foudations/mogo-commons/src/main/res/layout/module_commons_layout_toast_with_left_drawable.xml new file mode 100644 index 0000000000..0f1ee821d3 --- /dev/null +++ b/foudations/mogo-commons/src/main/res/layout/module_commons_layout_toast_with_left_drawable.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/foudations/mogo-commons/src/main/res/values-xhdpi/dimens.xml b/foudations/mogo-commons/src/main/res/values-xhdpi/dimens.xml index c1558d9ba0..ddb78a45af 100644 --- a/foudations/mogo-commons/src/main/res/values-xhdpi/dimens.xml +++ b/foudations/mogo-commons/src/main/res/values-xhdpi/dimens.xml @@ -1,13 +1,18 @@ - 50px - 50px + 63px + 30px + 63px 32px 32px + 19px + 19px 40px 698px 900px 130px + 94px + 21px diff --git a/foudations/mogo-commons/src/main/res/values/colors.xml b/foudations/mogo-commons/src/main/res/values/colors.xml index a6b3daec93..7f7661f567 100644 --- a/foudations/mogo-commons/src/main/res/values/colors.xml +++ b/foudations/mogo-commons/src/main/res/values/colors.xml @@ -1,2 +1,4 @@ - \ No newline at end of file + + #fff + \ No newline at end of file diff --git a/foudations/mogo-commons/src/main/res/values/dimens.xml b/foudations/mogo-commons/src/main/res/values/dimens.xml index 54534fb37b..4056fd470a 100644 --- a/foudations/mogo-commons/src/main/res/values/dimens.xml +++ b/foudations/mogo-commons/src/main/res/values/dimens.xml @@ -1,11 +1,16 @@ - 30px - 30px + 33px + 17px + 33px 16px 16px + 10px + 10px 22px 371px 500px 72px + 50px + 10px \ No newline at end of file diff --git a/foudations/mogo-utils/src/main/java/com/mogo/utils/TipDrawable.java b/foudations/mogo-utils/src/main/java/com/mogo/utils/TipDrawable.java new file mode 100644 index 0000000000..9be08550d2 --- /dev/null +++ b/foudations/mogo-utils/src/main/java/com/mogo/utils/TipDrawable.java @@ -0,0 +1,77 @@ +package com.mogo.utils; + +import android.graphics.drawable.Drawable; + +/** + * TipToast弹出框的图片资源封装类 + * 当前只支持添加一张图片,可添加到文字的 左{@link #TIP_DRAWABLE_GRAVITY_LEFT}, 上{@link #TIP_DRAWABLE_GRAVITY_TOP}, 右{@link #TIP_DRAWABLE_GRAVITY_RIGHT}, 下{@link #TIP_DRAWABLE_GRAVITY_BOTTOM} + * + * 当前仅支持添加左侧图片,所以{@link #gravity} 这个参数形同虚设 + * + * @author tongchenfei + */ +public class TipDrawable { + public static final int TIP_DRAWABLE_GRAVITY_LEFT = 1; + public static final int TIP_DRAWABLE_GRAVITY_TOP = 2; + public static final int TIP_DRAWABLE_GRAVITY_RIGHT = 3; + public static final int TIP_DRAWABLE_GRAVITY_BOTTOM = 4; + private Drawable drawable; + private int gravity; + private int width; + private int height; + + /** + * 默认图片居左,宽高使用{@link Drawable#getIntrinsicWidth()}和{@link Drawable#getIntrinsicHeight()} + * @param drawable 要展示的图片 + */ + public TipDrawable(Drawable drawable) { + this(drawable, TIP_DRAWABLE_GRAVITY_LEFT,drawable.getIntrinsicWidth(),drawable.getIntrinsicHeight()); + } + + /** + * 默认图片居左 + * @param drawable 要展示的图片 + * @param width 要展示的图片宽度 + * @param height 要展示的图片高度 + */ + public TipDrawable(Drawable drawable, int width, int height) { + this(drawable, TIP_DRAWABLE_GRAVITY_LEFT,width,height); + } + + /** + * 默认宽高使用{@link Drawable#getIntrinsicWidth()}和{@link Drawable#getIntrinsicHeight()} + * @param drawable 要展示的图片 + * @param gravity 左{@link #TIP_DRAWABLE_GRAVITY_LEFT}, 上{@link #TIP_DRAWABLE_GRAVITY_TOP}, 右{@link #TIP_DRAWABLE_GRAVITY_RIGHT}, 下{@link #TIP_DRAWABLE_GRAVITY_BOTTOM} + */ + public TipDrawable(Drawable drawable, int gravity) { + this(drawable, gravity,drawable.getIntrinsicWidth(),drawable.getIntrinsicHeight()); + } + + /** + * 可自定义展示位置 + * @param drawable 要展示的图片 + * @param gravity 左{@link #TIP_DRAWABLE_GRAVITY_LEFT}, 上{@link #TIP_DRAWABLE_GRAVITY_TOP}, 右{@link #TIP_DRAWABLE_GRAVITY_RIGHT}, 下{@link #TIP_DRAWABLE_GRAVITY_BOTTOM} + */ + public TipDrawable(Drawable drawable, int gravity, int width, int height) { + this.drawable = drawable; + this.gravity = gravity; + this.width = width; + this.height = height; + } + + public Drawable getDrawable() { + return drawable; + } + + public int getGravity() { + return gravity; + } + + public int getWidth() { + return width; + } + + public int getHeight() { + return height; + } +} diff --git a/foudations/mogo-utils/src/main/java/com/mogo/utils/TipToast.java b/foudations/mogo-utils/src/main/java/com/mogo/utils/TipToast.java index ec457c6b04..446762315f 100644 --- a/foudations/mogo-utils/src/main/java/com/mogo/utils/TipToast.java +++ b/foudations/mogo-utils/src/main/java/com/mogo/utils/TipToast.java @@ -4,6 +4,10 @@ package com.mogo.utils; * 2016/1/1 by congtaowang * * @Version 1.0 + * + * 增加了图片支持 + * + * @Version 1.1 */ import android.content.Context; @@ -45,17 +49,17 @@ public final class TipToast { sGenerator = null; } - private static void tip( final String message, int duration ) { + private static void tip( final String message, int duration ,TipDrawable tipDrawable) { if ( !checkParams() ) { return; } if ( TextUtils.isEmpty( message ) ) { return; } - new ToastThread( new StringToastRunnable( sContext, message, duration ) ).start(); + new ToastThread(new StringToastRunnable(sContext, message, duration, tipDrawable)).start(); } - private static void tip( final int msgId, int duration ) { + private static void tip( final int msgId, int duration,TipDrawable tipDrawable ) { if ( !checkParams() ) { return; } @@ -66,7 +70,7 @@ public final class TipToast { } catch ( Exception e ) { return; } - tip( ResourcesHelper.getString( sContext, msgId ), duration ); + tip( ResourcesHelper.getString( sContext, msgId ), duration ,tipDrawable); } private static boolean checkParams() { @@ -82,27 +86,53 @@ public final class TipToast { } public static void tip( final String message ) { - tip( message, Toast.LENGTH_SHORT ); + tip( message, Toast.LENGTH_SHORT,null ); } public static void tip( final int msgId ) { - tip( msgId, Toast.LENGTH_SHORT ); + tip( msgId, Toast.LENGTH_SHORT ,null); } public static void longTip( String message ) { - tip( message, Toast.LENGTH_LONG ); + tip( message, Toast.LENGTH_LONG ,null); } public static void longTip( int msgId ) { - tip( msgId, Toast.LENGTH_LONG ); + tip( msgId, Toast.LENGTH_LONG ,null); } public static void shortTip( String message ) { - tip( message, Toast.LENGTH_SHORT ); + tip( message, Toast.LENGTH_SHORT ,null); } public static void shortTip( int msgId ) { - tip( msgId, Toast.LENGTH_SHORT ); + tip( msgId, Toast.LENGTH_SHORT ,null); + } + + // -===带图片的方法===- + + public static void tip( final String message,TipDrawable tipDrawable ) { + tip( message, Toast.LENGTH_SHORT,tipDrawable ); + } + + public static void tip( final int msgId,TipDrawable tipDrawable ) { + tip( msgId, Toast.LENGTH_SHORT ,tipDrawable); + } + + public static void longTip( String message,TipDrawable tipDrawable ) { + tip( message, Toast.LENGTH_LONG ,tipDrawable); + } + + public static void longTip( int msgId ,TipDrawable tipDrawable) { + tip( msgId, Toast.LENGTH_LONG ,tipDrawable); + } + + public static void shortTip( String message,TipDrawable tipDrawable ) { + tip( message, Toast.LENGTH_SHORT ,tipDrawable); + } + + public static void shortTip( int msgId,TipDrawable tipDrawable ) { + tip( msgId, Toast.LENGTH_SHORT ,tipDrawable); } static class ToastThread extends Thread { @@ -117,11 +147,13 @@ public final class TipToast { Context context; String msg; int duration; + TipDrawable tipDrawable; - public StringToastRunnable( Context context, String msg, int duration ) { + public StringToastRunnable( Context context, String msg, int duration,TipDrawable tipDrawable ) { this.context = context; this.msg = msg; this.duration = duration; + this.tipDrawable = tipDrawable; } @Override @@ -131,44 +163,40 @@ public final class TipToast { return; } - sHandler.post( new Runnable() { + sHandler.post(() -> { + synchronized ( sSyncObject ) { - @Override - public void run() { - synchronized ( sSyncObject ) { + if ( context == null ) { + return; + } - if ( context == null ) { - return; - } + if ( sToast != null ) { + sToast.cancel(); + } - if ( sToast != null ) { - sToast.cancel(); - } - - if ( sGenerator == null ) { - sToast = Toast.makeText( context, msg, duration ); + if ( sGenerator == null ) { + sToast = Toast.makeText( context, msg, duration ); + } else { + sToast = new Toast( context ); + final View view = sGenerator.make( context, msg, tipDrawable ); + if ( view != null ) { + sToast.setView( view ); + sToast.setGravity( sGenerator.gravity(), sGenerator.xOffset(), sGenerator.yOffset() ); + sToast.setDuration( duration ); } else { - sToast = new Toast( context ); - final View view = sGenerator.make( context, msg ); - if ( view != null ) { - sToast.setView( view ); - sToast.setGravity( sGenerator.gravity(), sGenerator.xOffset(), sGenerator.yOffset() ); - sToast.setDuration( duration ); - } else { - sToast = Toast.makeText( context, msg, duration ); - } - } - if ( sToast != null ) { - sToast.show(); + sToast = Toast.makeText( context, msg, duration ); } } + if ( sToast != null ) { + sToast.show(); + } } - } ); + }); } } public interface ToastViewGenerator { - View make( Context context, String message ); + View make( Context context, String message,TipDrawable tipDrawable ); default int gravity() { return Gravity.CENTER; @@ -182,5 +210,4 @@ public final class TipToast { return 0; } } - } diff --git a/gradle.properties b/gradle.properties index 954f602451..57bdb8d90b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -65,7 +65,7 @@ MOGO_BASE_SERVICES_SDK_VERSION = 1.2.1.22 # 探路 MOGO_MODULE_TANLU_VERSION=1.3.1.24 # 车聊聊 -CARCHATTING_VERSION=1.5.1 +CARCHATTING_VERSION=1.5.3 # 车聊聊接口 CARCHATTINGPROVIDER_VERSION=1.3.4 # 视频引导 @@ -104,12 +104,20 @@ MOGO_MODULE_OBU_VERSION = 1.2.1.10-SNAPSHOT # 闪屏页 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 # 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 applicationName=IntelligentPilot 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 a318034ac3..1ae99ff4d1 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 @@ -2,10 +2,10 @@ package com.mogo.map.impl.amap; import android.content.Context; import android.util.AttributeSet; +import android.view.ViewGroup; import androidx.annotation.Nullable; -import com.amap.api.navi.AMapNaviView; import com.mogo.map.IMogoMapView; import com.mogo.map.MogoBaseMapView; @@ -17,6 +17,8 @@ import com.mogo.map.MogoBaseMapView; */ public class AMapBaseMapView extends MogoBaseMapView { + private static final String TAG = "AMapBaseMapView"; + public AMapBaseMapView( Context context ) { super( context ); } @@ -31,6 +33,11 @@ public class AMapBaseMapView extends MogoBaseMapView { @Override protected IMogoMapView createMapView( Context context ) { - return new AMapNaviViewWrapper( new AMapNaviView( context ) ); + IMogoMapView mapView = AMapViewHandler.getMapView(); + if ( mapView.getMapView().getParent() != null ) { + ViewGroup group = ( ViewGroup ) mapView.getMapView().getParent(); + group.removeView( mapView.getMapView() ); + } + return AMapViewHandler.getMapView(); } } 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 a0cd07579b..0a05343782 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 @@ -93,7 +93,7 @@ public class AMapNaviViewWrapper implements IMogoMapView, public AMapNaviViewWrapper( AMapNaviView mapView ) { this.mMapView = mapView; - this.mIMap = new AMapWrapper( mMapView.getMap(), mMapView, this ); + this.mIMap = new AMapWrapper( mMapView.getMap(), mMapView.getContext(), this ); try { new BnHooker( mMapView.getMap(), mapView.getContext() ); } catch ( Exception e ) { @@ -185,6 +185,7 @@ public class AMapNaviViewWrapper implements IMogoMapView, aMap.setOnCameraChangeListener( this ); aMap.setOnMyLocationChangeListener( this ); } + AMapMessageManager.getInstance().clear(); AMapMessageManager.getInstance().registerAMapMessageListener( this ); } @@ -521,7 +522,7 @@ public class AMapNaviViewWrapper implements IMogoMapView, Logger.d( TAG, Log.getStackTraceString( new Throwable() ) ); } if ( checkAMapView() ) { - MyLocationStyle style = mMapView.getMap().getMyLocationStyle(); + MyLocationStyle style = getMyLocationStyle(); if ( style == null ) { style = new MyLocationStyle(); } @@ -543,7 +544,7 @@ public class AMapNaviViewWrapper implements IMogoMapView, Logger.d( TAG, Log.getStackTraceString( new Throwable() ) ); } if ( checkAMapView() ) { - MyLocationStyle style = mMapView.getMap().getMyLocationStyle(); + MyLocationStyle style = getMyLocationStyle(); if ( style == null ) { style = new MyLocationStyle(); } @@ -556,7 +557,7 @@ public class AMapNaviViewWrapper implements IMogoMapView, public void initMyLocation() { if ( checkAMapView() ) { mMapView.getMap().setMyLocationEnabled( true ); - MyLocationStyle style = mMapView.getMap().getMyLocationStyle(); + MyLocationStyle style = getMyLocationStyle(); style.myLocationType( MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER ); style.interval( 1000 ); style.anchor( 0.5F, 0.5F ); @@ -863,7 +864,7 @@ public class AMapNaviViewWrapper implements IMogoMapView, if ( mMapView.getMap() == null ) { return; } - MyLocationStyle style = mMapView.getMap().getMyLocationStyle(); + MyLocationStyle style = getMyLocationStyle(); if ( mCarCursorOption.getCarCursorBmp() != null && !mCarCursorOption.getCarCursorBmp().isRecycled() ) { style.myLocationIcon( BitmapDescriptorFactory.fromBitmap( mCarCursorOption.getCarCursorBmp() ) ); } else { @@ -876,6 +877,20 @@ public class AMapNaviViewWrapper implements IMogoMapView, mMapView.getMap().setMyLocationStyle( style ); } + private MyLocationStyle getMyLocationStyle() { + MyLocationStyle style = null; + try { + style = mMapView.getMap().getMyLocationStyle(); + } catch ( Exception e ) { + style = new MyLocationStyle(); + } finally { + if ( style == null ) { + style = new MyLocationStyle(); + } + return style; + } + } + @Override public MapCameraPosition getMapCameraPosition() { if ( checkAMapView() ) { diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapViewHandler.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapViewHandler.java new file mode 100644 index 0000000000..1eaa3557a3 --- /dev/null +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapViewHandler.java @@ -0,0 +1,36 @@ +package com.mogo.map.impl.amap; + +import android.content.Context; + +import com.amap.api.maps.MapView; +import com.amap.api.navi.AMapNaviView; +import com.mogo.commons.debug.DebugConfig; +import com.mogo.map.IMogoMapView; + +public +/** + * @author congtaowang + * @since 2020/9/10 + *

+ * 描述 + */ +class AMapViewHandler { + + private static IMogoMapView sMapView; + + public static void createMapView( Context context ) { + if ( DebugConfig.getCarMachineType() == DebugConfig.CAR_MACHINE_TYPE_SELF_INNOVATE ) { + sMapView = new AMapViewWrapper( new MapView( context ) ); + } else { + sMapView = new AMapNaviViewWrapper( new AMapNaviView( context ) ); + } + } + + public static IMogoMapView getMapView() { + return sMapView; + } + + public static void destroy() { + sMapView = null; + } +} 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 new file mode 100644 index 0000000000..2c70ee3345 --- /dev/null +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapViewWrapper.java @@ -0,0 +1,827 @@ +package com.mogo.map.impl.amap; + +import android.content.Context; +import android.graphics.Color; +import android.graphics.Point; +import android.graphics.Rect; +import android.location.Location; +import android.os.Bundle; +import android.os.SystemClock; +import android.os.Trace; +import android.util.Log; +import android.view.MotionEvent; +import android.view.View; +import android.view.animation.Interpolator; + +import com.amap.api.maps.AMap; +import com.amap.api.maps.AMapUtils; +import com.amap.api.maps.CameraUpdateFactory; +import com.amap.api.maps.MapView; +import com.amap.api.maps.TextureMapView; +import com.amap.api.maps.model.BitmapDescriptorFactory; +import com.amap.api.maps.model.CameraPosition; +import com.amap.api.maps.model.CameraPositionCreator; +import com.amap.api.maps.model.LatLng; +import com.amap.api.maps.model.LatLngBounds; +import com.amap.api.maps.model.Marker; +import com.amap.api.maps.model.MyLocationStyle; +import com.amap.api.maps.model.Poi; +import com.amap.api.maps.model.Polyline; +import com.amap.api.maps.model.animation.Animation; +import com.amap.api.maps.model.animation.TranslateAnimation; +import com.amap.api.navi.model.NaviInfo; +import com.mogo.commons.debug.DebugConfig; +import com.mogo.map.IMogoMap; +import com.mogo.map.IMogoMapView; +import com.mogo.map.MogoLatLng; +import com.mogo.map.impl.amap.hook.BnHooker; +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.utils.MogoMapUtils; +import com.mogo.map.impl.amap.utils.ObjectUtils; +import com.mogo.map.listener.MogoMapListenerHandler; +import com.mogo.map.marker.IMogoMarker; +import com.mogo.map.uicontroller.CarCursorOption; +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.WindowUtils; +import com.mogo.utils.logger.Logger; + +import java.util.List; + +/** + * @author congtaowang + * @since 2019-12-18 + *

+ * 代理高德导航地图 + */ +public class AMapViewWrapper implements IMogoMapView, + IMogoMapUIController, + AMap.OnMarkerClickListener, + AMap.OnMapLoadedListener, + AMap.OnMapTouchListener, + AMap.OnPOIClickListener, + AMap.OnMapClickListener, + AMap.OnPolylineClickListener, + AMapMessageListener, + AMap.OnCameraChangeListener, + AMap.OnMyLocationChangeListener { + + private static final String TAG = "AMapViewWrapper"; + + private final MapView mMapView; + private IMogoMap mIMap; + + private AMapMarkerClickHandler mMarkerClickHandler; + private EnumMapUI mCurrentUIMode; + + private boolean mIsCarLocked = false; + + private float mDefaultZoomLevel = 16.0f; + private final CarCursorOption DEFAULT_OPTION = new CarCursorOption.Builder() + .carCursorRes( R.drawable.map_api_ic_current_location2 ) + .naviCursorRes( R.drawable.ic_amap_navi_cursor ) + .build(); + private CarCursorOption mCarCursorOption = DEFAULT_OPTION; + + public AMapViewWrapper( MapView mapView ) { + this.mMapView = mapView; + this.mIMap = new AMapWrapper( mMapView.getMap(), mMapView.getContext(), this ); + try { + new BnHooker( mMapView.getMap(), mapView.getContext() ); + } catch ( Exception e ) { + e.printStackTrace(); + } + } + + private void initMapView() { + if ( mMapView == null ) { + return; + } +// AMapNaviViewOptions options = mMapView.getViewOptions(); +// if ( options != null ) { +// // 设置是否开启自动黑夜模式切换,默认为false,不自动切换 +// options.setAutoNaviViewNightMode( false ); +// // 设置6秒后是否自动锁车 +// options.setAutoLockCar( false ); +// // 设置路线上的摄像头气泡是否显示 +// options.setCameraBubbleShow( true ); +// // 设置路线相关的配置属性,如:路线的路况颜色,路线上是否显示摄像头气泡等。 +// // options.setRouteOverlayOptions( MapStyleUtils.getRouteOverlayOptions() ); +// // 设置自车的图片对象 +// options.setCarBitmap( BitmapFactory.decodeResource( getContext().getResources(), DEFAULT_OPTION.getNaviCursorRes() ) ); +// // 设置指南针图标否在导航界面显示,默认显示。true,显示;false,隐藏。 +// options.setCompassEnabled( false ); +// // 黑夜模式 +// options.setNaviNight( true ); +// //设置路况光柱条是否显示(只适用于驾车导航,需要联网)。 +// options.setTrafficBarEnabled( false ); +// // 设置[实时交通图层开关按钮]是否显示(只适用于驾车导航,需要联网)。 +// options.setTrafficLayerEnabled( false ); +// // 设置导航界面是否显示路线全览按钮。 +// options.setRouteListButtonShow( false ); +// // 设置屏幕是否常亮,默认开启 +// options.setScreenAlwaysBright( false ); +// // 设置交通播报是否打开(只适用于驾车导航,需要联网)。 +// options.setTrafficInfoUpdateEnabled( true ); +// // 设置摄像头播报是否打开(只适用于驾车导航)。 +// options.setCameraInfoUpdateEnabled( true ); +// // 设置菜单按钮是否在导航界面显示。 +// options.setSettingMenuEnabled( false ); +// // 设置是否绘制显示交通路况的线路(彩虹线),拥堵-红色,畅通-绿色,缓慢-黄色,未知-蓝色。默认不绘制彩虹线。 +// options.setTrafficLine( true ); +// // 设置是否绘制牵引线(当前位置到目的地的指引线)。默认不绘制牵引线。 +// options.setLeaderLineEnabled( -1 ); +// // 设置导航界面UI是否显示。 +// options.setLayoutVisible( false ); +// // 设置是否自动画路 +// options.setAutoDrawRoute( false ); +// // 设置是否显示路口放大图(实景图) +// options.setRealCrossDisplayShow( false ); +// // 设置是否显示路口放大图(路口模型图) +// options.setModeCrossDisplayShow( false ); +// // 设置是否显示道路信息view +// options.setLaneInfoShow( false ); +// // 设置是否自动改变缩放等级 +// options.setAutoChangeZoom( false ); +// // 设置是否自动全览模式,即在算路成功后自动进入全览模式 +// options.setAutoDisplayOverview( false ); +// // 设置路线转向箭头隐藏和显示 +// options.setNaviArrowVisible( false ); +// // 通过路线是否自动置灰,仅支持驾车导航 +// options.setAfterRouteAutoGray( true ); +// options.setZoom( ( ( int ) mDefaultZoomLevel ) ); +// options.setPointToCenter( 0.7D, 0.5D ); +// // 2D模式 +// options.setTilt( 0 ); +// mMapView.setViewOptions( options ); +// } +// mMapView.setRouteOverlayVisible( false ); +// mMapView.setCarOverlayVisible( false ); + changeMapMode( EnumMapUI.CarUp_2D ); + setTrafficEnabled( true ); + mMapView.getMap().moveCamera( CameraUpdateFactory.zoomTo( mDefaultZoomLevel ) ); + } + + private void initListeners() { + + mMarkerClickHandler = new AMapMarkerClickHandler(); + final AMap aMap = mMapView.getMap(); + if ( aMap != null ) { + aMap.setOnMarkerClickListener( this ); + aMap.setOnMapLoadedListener( this ); + aMap.setOnMapTouchListener( this ); + aMap.setOnPolylineClickListener( this ); + aMap.setOnCameraChangeListener( this ); + aMap.setOnPOIClickListener( this ); + aMap.setOnMapClickListener( this ); + aMap.setOnCameraChangeListener( this ); + aMap.setOnMyLocationChangeListener( this ); + } + AMapMessageManager.getInstance().clear(); + AMapMessageManager.getInstance().registerAMapMessageListener( this ); + } + + private Context getContext() { + return mMapView.getContext(); + } + + @Override + public View getMapView() { + return mMapView; + } + + @Override + public IMogoMap getMap() { + return mIMap; + } + + @Override + public void onCreate( Bundle bundle ) { + if ( mMapView != null ) { + mMapView.onCreate( bundle ); + Logger.d( TAG, "map onCreate" ); + initMapView(); + initListeners(); + initMyLocation(); + } + } + + @Override + public void onResume() { + if ( mMapView != null ) { + mMapView.onResume(); + Logger.d( TAG, Log.getStackTraceString( new Throwable() ) ); + Logger.d( TAG, "map onResume" ); + } + } + + @Override + public void onPause() { + if ( mMapView != null ) { + mMapView.onPause(); + Logger.d( TAG, "map onPause" ); + } + } + + @Override + public void onDestroy() { + if ( mMapView != null ) { + mMapView.onDestroy(); + Logger.d( TAG, "map onDestroy" ); + } + } + + @Override + public void onSaveInstanceState( Bundle outState ) { + if ( mMapView != null ) { + mMapView.onSaveInstanceState( outState ); + Logger.d( TAG, "map onSaveInstanceState" ); + } + } + + @Override + public void onLowMemory() { + if ( mMapView != null ) { + mMapView.onLowMemory(); + } + Logger.d( TAG, "map onLowMemory" ); + } + + /** + * 地图marker点击 + */ + @Override + public boolean onMarkerClick( Marker marker ) { + return mMarkerClickHandler.handleMarkerClicked( marker ); + } + + /** + * 地图加载完毕 + */ + @Override + public void onMapLoaded() { + MogoMapListenerHandler.getInstance().onMapLoaded(); + } + + /** + * 地图点击回调 + */ + @Override + public void onTouch( MotionEvent motionEvent ) { + MogoMapListenerHandler.getInstance().onTouch( motionEvent ); + if ( mIsCarLocked ) { + loseLockMode(); + } + } + + /** + * POI 点击 + */ + @Override + public void onPOIClick( Poi poi ) { + if ( InterceptorHandler.getInstance().ignorePoiClicked( getContext() ) ) { + return; + } + MogoMapListenerHandler.getInstance().onPOIClick( ObjectUtils.fromAMap( poi ) ); + } + + @Override + public void onMapClick( LatLng latLng ) { + if ( InterceptorHandler.getInstance().ignoreMapClicked( getContext() ) ) { + return; + } + MogoMapListenerHandler.getInstance().onMapClick( ObjectUtils.fromAMap( latLng ) ); + } + + @Override + public void onPolylineClick( Polyline polyline ) { + if ( !NaviClient.getInstance( getContext() ).isNaviing() ) { + NaviClient.getInstance( getContext() ).handleClickedPolyline( polyline ); + } + } + + @Override + public void setTrafficEnabled( boolean visible ) { + if ( checkMapView() ) { + mMapView.getMap().setTrafficEnabled( true ); + } + } + + @Override + public MapControlResult changeZoom( boolean zoom ) { + if ( checkMapView() ) { + mDefaultZoomLevel = ( int ) ( getMap().getZoomLevel() + 0.5f ); + + if ( zoom ) { + if ( mDefaultZoomLevel >= 20 ) { + return MapControlResult.TARGET; + } + } else { + if ( mDefaultZoomLevel <= 3 ) { + return MapControlResult.TARGET; + } + } + + if ( zoom ) { + mDefaultZoomLevel += 2f; + if ( mDefaultZoomLevel > 20 ) { + mDefaultZoomLevel = 20; + } + } else { + mDefaultZoomLevel -= 2f; + if ( mDefaultZoomLevel < 1 ) { + mDefaultZoomLevel = 1; + } + } + changeZoom( ( int ) mDefaultZoomLevel ); + } + return MapControlResult.SUCCESS; + } + + @Override + public MapControlResult changeZoom( float zoom ) { + Logger.d( TAG, "changeZoom %s", zoom ); + if ( DebugConfig.isDebug() ) { + Logger.d( TAG, Log.getStackTraceString( new Throwable() ) ); + } + getMap().changeZoom( zoom ); + return MapControlResult.SUCCESS; + } + + @Override + public void changeMapMode( EnumMapUI ui ) { + if ( ui == null ) { + return; + } + if ( checkMapView() ) { + switch ( ui ) { + + case CarUp_3D: + mMapView.getMap().moveCamera( CameraUpdateFactory.changeTilt( 60 ) ); + break; + case NorthUP_2D: + mMapView.getMap().moveCamera( CameraUpdateFactory.changeTilt( 0 ) ); + break; + case CarUp_2D: + mMapView.getMap().moveCamera( CameraUpdateFactory.changeTilt( 0 ) ); + break; + case Type_Light: + mMapView.getMap().setMapType( AMap.MAP_TYPE_NORMAL ); + break; + case Type_Night: + mMapView.getMap().setMapType( AMap.MAP_TYPE_NIGHT ); + break; + case Type_AUTO_LIGHT_Night: + break; + } + } + } + + private boolean checkMapView() { + if ( mMapView == null || mMapView.getMap() == null ) { + Logger.e( TAG, "高德mapView实例为空,请检查" ); + return false; + } + return true; + } + + @Override + public void moveToCenter( MogoLatLng latLng, boolean animate ) { + Logger.d( TAG, "move to center %s", latLng ); + if ( latLng == null || latLng.lat == 0.0d || latLng.lng == 0.0d ) { + Logger.e( TAG, "latlng = null or is illegal" ); + return; + } + if ( DebugConfig.isDebug() ) { + Logger.d( TAG, Log.getStackTraceString( new Throwable() ) ); + } + loseLockMode(); + if ( animate ) { + mMapView.getMap().animateCamera( CameraUpdateFactory.newLatLng( new LatLng( latLng.lat, latLng.lng ) ) ); + } else { + mMapView.getMap().moveCamera( CameraUpdateFactory.newLatLng( new LatLng( latLng.lat, latLng.lng ) ) ); + } + } + + @Override + public void showMyLocation( boolean visible ) { + Logger.d( TAG, "showMyLocation1 %s", visible ); + if ( visible && NaviClient.getInstance( getContext() ).isNaviing() ) { + return; + } + if ( DebugConfig.isDebug() ) { + Logger.d( TAG, Log.getStackTraceString( new Throwable() ) ); + } + if ( checkMapView() ) { + MyLocationStyle style = getMyLocationStyle(); + if ( style == null ) { + style = new MyLocationStyle(); + } + style.showMyLocation( visible ); + if ( visible ) { + // 强制刷新一遍车标 + style.myLocationIcon( BitmapDescriptorFactory.fromResource( mCarCursorOption.getCarCursorRes() ) ); + } + mMapView.getMap().setMyLocationStyle( style ); + } + } + + @Override + public void showMyLocation( View view ) { + if ( NaviClient.getInstance( getContext() ).isNaviing() ) { + return; + } + if ( DebugConfig.isDebug() ) { + Logger.d( TAG, Log.getStackTraceString( new Throwable() ) ); + } + if ( checkMapView() ) { + MyLocationStyle style = getMyLocationStyle(); + if ( style == null ) { + style = new MyLocationStyle(); + } + style.showMyLocation( true ); + style.myLocationIcon( BitmapDescriptorFactory.fromView( view ) ); + mMapView.getMap().setMyLocationStyle( style ); + } + } + + public void initMyLocation() { + if ( checkMapView() ) { + mMapView.getMap().setMyLocationEnabled( true ); + MyLocationStyle style = getMyLocationStyle(); + style.myLocationType( MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER ); + style.interval( 1000 ); + style.anchor( 0.5F, 0.5F ); + style.strokeColor( Color.TRANSPARENT ); + style.strokeWidth( 0 ); + style.radiusFillColor( Color.TRANSPARENT ); + mMapView.getMap().setMyLocationStyle( style ); + } + } + + private MyLocationStyle getMyLocationStyle() { + MyLocationStyle style = null; + try { + style = mMapView.getMap().getMyLocationStyle(); + } catch ( Exception e ) { + style = new MyLocationStyle(); + } finally { + if ( style == null ) { + style = new MyLocationStyle(); + } + return style; + } + } + + @Override + public void recoverLockMode() { + if ( checkMapView() ) { + if ( DebugConfig.isDebug() ) { + Logger.d( TAG, Log.getStackTraceString( new Throwable() ) ); + } + Logger.d( TAG, "锁车" ); + Location target = NaviClient.getInstance( getContext() ).getCarLocation2(); + if ( target != null ) { + mMapView.getMap().animateCamera( CameraUpdateFactory.newCameraPosition( + new CameraPosition( new LatLng( target.getLatitude(), target.getLongitude() ), + mDefaultZoomLevel, + 0, + 0 + ) + ), new AMap.CancelableCallback() { + @Override + public void onFinish() { + changeMyLocationStyle(); + } + + @Override + public void onCancel() { + changeMyLocationStyle(); + } + } ); + } else { + changeMyLocationStyle(); + } + mIsCarLocked = true; + } + } + + private void changeMyLocationStyle() { + MyLocationStyle style = getMyLocationStyle(); + if ( style == null ) { + style = new MyLocationStyle(); + } + style.myLocationType( MyLocationStyle.LOCATION_TYPE_FOLLOW ); + mMapView.getMap().setMyLocationStyle( style ); + } + + @Override + public void loseLockMode() { + if ( DebugConfig.isDebug() ) { + Logger.d( TAG, Log.getStackTraceString( new Throwable() ) ); + } + Logger.d( TAG, "解锁锁车" ); + MyLocationStyle style = getMyLocationStyle(); + style.myLocationType( MyLocationStyle.LOCATION_TYPE_FOLLOW_NO_CENTER ); + mMapView.getMap().setMyLocationStyle( style ); + mIsCarLocked = false; + } + + /** + * 模拟点击事件,达到锁车->普通事件 + */ + private void mockTouchEvent() { + long downTime = SystemClock.uptimeMillis(); + long eventTime = downTime + 1; + int metaState = 0; + MotionEvent motionEvent = MotionEvent.obtain( downTime, eventTime, MotionEvent.ACTION_DOWN, 0, 0, metaState ); + mMapView.dispatchTouchEvent( motionEvent ); + MotionEvent upEvent = MotionEvent.obtain( downTime + 1, eventTime + 2, MotionEvent.ACTION_UP, 0, 0, metaState ); + mMapView.dispatchTouchEvent( upEvent ); + } + + @Override + public void setLockZoom( int var1 ) { + if ( checkMapView() ) { + if ( DebugConfig.isDebug() ) { + Logger.d( TAG, Log.getStackTraceString( new Throwable() ) ); + } + Logger.d( TAG, "Zoom锁定锁车比例尺 %s", var1 ); + // TODO: 2020/8/27 设置锁车比例尺 +// mMapView.setLockZoom( var1 ); + } + } + + @Override + public void displayOverview( Rect bounds ) { + if ( checkMapView() ) { + if ( NaviClient.getInstance( getContext() ).isNaviing() ) { + loseLockMode(); + NaviClient.getInstance( getContext() ).displayOverview( bounds ); + } + } + } + + @Override + public float getScalePerPixel() { + return getMap().getScalePerPixel(); + } + + @Override + public float getZoomLevel() { + return getMap().getZoomLevel(); + } + + @Override + public void onNaviStarted() { + if ( checkMapView() ) { + showMyLocation( false ); + } + } + + @Override + public void onNaviStopped() { + if ( checkMapView() ) { + showMyLocation( true ); + NaviClient.getInstance( getContext() ).startAimlessMode(); + } + } + + @Override + public void onNaviInfoUpdat( NaviInfo naviInfo ) { + + } + + @Override + public void onCalculateSuccess() { + loseLockMode(); + } + + @Override + public void onCameraChange( CameraPosition cameraPosition ) { + } + + @Override + public void onCameraChangeFinish( CameraPosition cameraPosition ) { + if ( cameraPosition != null ) { + Trace.beginSection( "timer.onCameraChangeFinish" ); + MogoMapListenerHandler.getInstance().onMapChanged( ObjectUtils.fromAMap( cameraPosition.target ), + cameraPosition.zoom, + cameraPosition.tilt, + cameraPosition.bearing ); + Trace.endSection(); + } + } + + @Override + public MogoLatLng getCameraNorthEastPosition() { + try { + return ObjectUtils.fromAMap( mMapView.getMap().getProjection().getVisibleRegion().latLngBounds.northeast ); + } catch ( Exception e ) { + + } + return null; + } + + @Override + public MogoLatLng getCameraSouthWestPosition() { + try { + return ObjectUtils.fromAMap( mMapView.getMap().getProjection().getVisibleRegion().latLngBounds.southwest ); + } catch ( Exception e ) { + + } + return null; + } + + @Override + public MogoLatLng getWindowCenterLocation() { + try { + return ObjectUtils.fromAMap( mMapView.getMap().getCameraPosition().target ); + } catch ( Exception e ) { + + } + return null; + } + + @Override + public void setPointToCenter( double mapCenterX, double mapCenterY ) { + if ( checkMapView() ) { + if ( DebugConfig.isDebug() ) { + Logger.d( TAG, Log.getStackTraceString( new Throwable() ) ); + } + Logger.d( TAG, "setPointToCenter(%s, %s)", mapCenterX, mapCenterY ); + mMapView.getMap().setPointToCenter( ( ( int ) ( mapCenterX * WindowUtils.getScreenWidth( getContext() ) ) ), + ( ( int ) ( mapCenterY * WindowUtils.getScreenHeight( getContext() ) ) ) ); + } + } + + @Override + public Point getLocationPointInScreen( MogoLatLng latLng ) { + if ( checkMapView() ) { + try { + return mMapView.getMap() + .getProjection() + .toScreenLocation( ObjectUtils.fromMogo2( latLng ) ); + } catch ( Exception e ) { + return null; + } + } + return null; + } + + @Override + public MogoLatLng getLocationMogoLatLngInScreen( Point point ) { + if ( checkMapView() ) { + try { + return ObjectUtils.fromAMap( + mMapView.getMap().getProjection().fromScreenLocation( point ) ); + } catch ( Exception e ) { + return null; + } + } + return null; + } + + @Override + public void startJumpAnimation( IMogoMarker marker, float high, Interpolator interpolator, + long duration ) { + if ( marker == null || high <= 0.0f || interpolator == null || duration < 0 ) { + return; + } + try { + final LatLng latLng = ObjectUtils.fromMogo2( marker.getPosition() ); + Point point = mMapView.getMap().getProjection().toScreenLocation( latLng ); + point.y -= WindowUtils.dip2px( getContext(), high ); + LatLng target = mMapView.getMap().getProjection().fromScreenLocation( point ); + //使用TranslateAnimation,填写一个需要移动的目标点 + Animation animation = new TranslateAnimation( target ); + animation.setInterpolator( interpolator ); + //整个移动所需要的时间 + animation.setDuration( duration ); + //设置动画 + if ( marker instanceof AMapMarkerWrapper ) { + ( ( AMapMarkerWrapper ) marker ).getMarker().setAnimation( animation ); + ( ( AMapMarkerWrapper ) marker ).getMarker().startAnimation(); + } + } catch ( Exception e ) { + Logger.e( TAG, e, "error." ); + } + } + + @Override + public void setRenderFps( int fps ) { + if ( checkMapView() ) { + if ( mMapView.getMap() != null ) { + mMapView.getMap().setRenderFps( fps ); + Logger.d( TAG, "设置刷新帧率 fps = %s", fps ); + } + } + } + + @Override + public void showBounds( String tag, MogoLatLng carPosition, List< MogoLatLng > lonLats, Rect bound, boolean lockCarPosition ) { + if ( !checkMapView() ) { + return; + } + try { + if ( DebugConfig.isDebug() ) { + Logger.d( TAG, Log.getStackTraceString( new Throwable() ) ); + } + LatLngBounds latLngBounds = MogoMapUtils.getLatLngBounds( carPosition, lonLats, lockCarPosition ); + if ( !lockCarPosition ) { + loseLockMode(); + } + mMapView.getMap().moveCamera( CameraUpdateFactory.newLatLngBoundsRect( latLngBounds, bound.left, bound.right, bound.top, bound.bottom ) ); + } catch ( Exception e ) { + Logger.e( TAG, e, "%s error.", tag ); + } + } + + @Override + public void forceRender() { + if ( checkMapView() ) { + mMapView.getMap().runOnDrawFrame(); + } + } + + @Override + public float calculateLineDistance( MogoLatLng p1, MogoLatLng p2 ) throws Exception { + if ( p1 == null || p2 == null ) { + throw new Exception( "计算距离的点不能为 null" ); + } + return AMapUtils.calculateLineDistance( ObjectUtils.fromMogo2( p1 ), ObjectUtils.fromMogo2( p2 ) ); + } + + @Override + public void onMyLocationChange( Location location ) { + NaviClient.getInstance( getContext() ).syncCarLocation( location ); + } + + @Override + public EnumMapUI getCurrentUiMode() { + return mCurrentUIMode; + } + + @Override + public void changeMyLocation( Location location ) { + } + + @Override + public synchronized boolean isCarLocked() { + return mIsCarLocked; + } + + @Override + public void setCarCursorOption( CarCursorOption option ) { + if ( mCarCursorOption != null && mCarCursorOption != DEFAULT_OPTION ) { + mCarCursorOption.destroy(); + } + if ( option != null ) { + try { + mCarCursorOption = option.clone(); + } catch ( Exception e ) { + mCarCursorOption = DEFAULT_OPTION; + } + } else { + mCarCursorOption = DEFAULT_OPTION; + } + if ( !checkMapView() ) { + return; + } + if ( mMapView.getMap() == null ) { + return; + } + MyLocationStyle style = getMyLocationStyle(); + if ( mCarCursorOption.getCarCursorBmp() != null && !mCarCursorOption.getCarCursorBmp().isRecycled() ) { + style.myLocationIcon( BitmapDescriptorFactory.fromBitmap( mCarCursorOption.getCarCursorBmp() ) ); + } else { + if ( mCarCursorOption.getCarCursorRes() != 0 ) { + style.myLocationIcon( BitmapDescriptorFactory.fromResource( mCarCursorOption.getCarCursorRes() ) ); + } else { + style.myLocationIcon( BitmapDescriptorFactory.fromResource( DEFAULT_OPTION.getCarCursorRes() ) ); + } + } + mMapView.getMap().setMyLocationStyle( style ); + } + + @Override + public MapCameraPosition getMapCameraPosition() { + if ( checkMapView() ) { + CameraPosition cameraPosition = mMapView.getMap().getCameraPosition(); + return ObjectUtils.fromAMap( cameraPosition ); + } + return null; + } + + @Override + public void changeBearing( float bearing ) { + if ( checkMapView() ) { + mMapView.getMap().moveCamera( CameraUpdateFactory.changeBearing( bearing ) ); + } + } +} 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 ae7aef62c8..2965606844 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 @@ -37,15 +37,15 @@ public class AMapWrapper implements IMogoMap { private static final String TAG = "AMapWrapper"; private static AMap sAMap; + private final Context mContext; private IMogoMapUIController mUIcontroller; private AMap mAMap; - private AMapNaviView mMapView; private IMogoUiSettings mUiSettings; - public AMapWrapper( AMap map, AMapNaviView mapView, IMogoMapUIController controller ) { + public AMapWrapper( AMap map, Context context, IMogoMapUIController controller ) { this.mAMap = map; sAMap = map; - this.mMapView = mapView; + mContext = context; mUIcontroller = controller; // 设置实现自定义 info window mAMap.setInfoWindowAdapter( new AMapInfoWindowAdapter() ); @@ -248,6 +248,6 @@ public class AMapWrapper implements IMogoMap { } private Context getContext() { - return mMapView.getContext(); + return mContext; } } diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/location/ALocationClient.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/location/ALocationClient.java index 89dfeac7f4..daa049b376 100644 --- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/location/ALocationClient.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/location/ALocationClient.java @@ -145,7 +145,7 @@ public class ALocationClient implements IMogoLocationClient { synchronized ( sListeners ) { Iterator< IMogoLocationListener > listenerIterator = sListeners.iterator(); while ( listenerIterator.hasNext() ) { - listenerIterator.next().onLocationChanged( mLastLocation.clone() ); + listenerIterator.next().onLocationChanged( mLastLocation ); } } Trace.endSection(); diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/marker/AMapMarkerWrapper.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/marker/AMapMarkerWrapper.java index 8935812bcd..679e008277 100644 --- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/marker/AMapMarkerWrapper.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/marker/AMapMarkerWrapper.java @@ -82,8 +82,8 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer { mMogoMarkerOptions = null; } if ( mMarker != null ) { - mMarker.remove(); mMarker.setObject( null ); + mMarker.remove(); mMarker = null; } if ( mMovingPointOverlay != null ) { @@ -398,7 +398,7 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer { AnimationSet animationSet = new AnimationSet( true ); animationSet.setDuration( duration ); - animationSet.setInterpolator( interpolator); + animationSet.setInterpolator( interpolator ); animationSet.setAnimationListener( new Animation.AnimationListener() { @Override public void onAnimationStart() { @@ -510,4 +510,11 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer { mMovingPointOverlay.startSmoothMove(); } + @Override + public boolean isInfoWindowShowing() { + if ( mMarker == null ) { + return false; + } + return mMarker.isInfoWindowShown(); + } } diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/message/AMapMessageManager.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/message/AMapMessageManager.java index dc3782aadc..caccdd97b0 100644 --- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/message/AMapMessageManager.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/message/AMapMessageManager.java @@ -47,6 +47,12 @@ public class AMapMessageManager { } } + public synchronized void clear(){ + if ( mListeners != null ) { + mListeners.clear(); + } + } + public synchronized void unregisterAMapMessageListener( AMapMessageListener listener ) { mListeners.remove( listener ); } 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 4d6edfbc86..516be8652e 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 @@ -26,6 +26,9 @@ public class AutoNaviReceiver extends BroadcastReceiver { private static AutoNaviReceiver autoNaviReceiver; private static boolean sRegisterFlag = false; + private static MogoNaviInfo sNaviInfo; + private static MogoTraffic sTraffic; + public static void register( Context context ) { IntentFilter filter = new IntentFilter(); @@ -85,23 +88,28 @@ public class AutoNaviReceiver extends BroadcastReceiver { MapState.getInstance().setNaving( true ); MogoNaviListenerHandler.getInstance().onStartNavi(); } - MogoNaviInfo naviInfo = new MogoNaviInfo(); - naviInfo.setCurrentLimitSpeed( cameraSpeed ); - naviInfo.setCurrentRoadName( intent.getStringExtra( GuideInfoExtraKey.CUR_ROAD_NAME ) ); - naviInfo.setCurrentSpeed( intent.getIntExtra( GuideInfoExtraKey.CUR_SPEED, 0 ) ); - naviInfo.setCurStepRetainDistance( intent.getIntExtra( GuideInfoExtraKey.SEG_REMAIN_DIS, 0 ) ); - naviInfo.setCurStepRetainTime( intent.getIntExtra( GuideInfoExtraKey.SEG_REMAIN_TIME, 0 ) ); - naviInfo.setIconResId( IconTypeUtils.getResIdByIconType( context, intent.getIntExtra( GuideInfoExtraKey.NEW_ICON, 0 ) ) ); - naviInfo.setNextRoadName( intent.getStringExtra( GuideInfoExtraKey.NEXT_ROAD_NAME ) ); - naviInfo.setPathRetainDistance( intent.getIntExtra( GuideInfoExtraKey.ROUTE_REMAIN_DIS, 0 ) ); - naviInfo.setPathRetainTime( intent.getIntExtra( GuideInfoExtraKey.ROUTE_REMAIN_TIME, 0 ) ); - MogoNaviListenerHandler.getInstance().onNaviInfoUpdate( naviInfo ); + if ( sNaviInfo == null ) { + sNaviInfo = new MogoNaviInfo(); + } + sNaviInfo.setCurrentLimitSpeed( cameraSpeed ); + sNaviInfo.setCurrentRoadName( intent.getStringExtra( GuideInfoExtraKey.CUR_ROAD_NAME ) ); + sNaviInfo.setCurrentSpeed( intent.getIntExtra( GuideInfoExtraKey.CUR_SPEED, 0 ) ); + sNaviInfo.setCurStepRetainDistance( intent.getIntExtra( GuideInfoExtraKey.SEG_REMAIN_DIS, 0 ) ); + sNaviInfo.setCurStepRetainTime( intent.getIntExtra( GuideInfoExtraKey.SEG_REMAIN_TIME, 0 ) ); + sNaviInfo.setIconResId( IconTypeUtils.getResIdByIconType( context, intent.getIntExtra( GuideInfoExtraKey.NEW_ICON, 0 ) ) ); + sNaviInfo.setNextRoadName( intent.getStringExtra( GuideInfoExtraKey.NEXT_ROAD_NAME ) ); + sNaviInfo.setPathRetainDistance( intent.getIntExtra( GuideInfoExtraKey.ROUTE_REMAIN_DIS, 0 ) ); + sNaviInfo.setPathRetainTime( intent.getIntExtra( GuideInfoExtraKey.ROUTE_REMAIN_TIME, 0 ) ); + MogoNaviListenerHandler.getInstance().onNaviInfoUpdate( sNaviInfo ); } - MogoTraffic mogoTraffic = new MogoTraffic( MapState.getInstance().isAimless() ? MogoTraffic.TYPE_AIM : MogoTraffic.TYPE_NAVI ); - mogoTraffic.setDistance( cameraDisc ); - mogoTraffic.setSpeedLimit( cameraSpeed ); - mogoTraffic.setTrafficType( cameraType ); - MogoNaviListenerHandler.getInstance().onUpdateTraffic2( mogoTraffic ); + if ( sTraffic == null ) { + sTraffic = new MogoTraffic( MapState.getInstance().isAimless() ? MogoTraffic.TYPE_AIM : MogoTraffic.TYPE_NAVI ); + } + sTraffic.setFromType( MapState.getInstance().isAimless() ? MogoTraffic.TYPE_AIM : MogoTraffic.TYPE_NAVI ); + sTraffic.setDistance( cameraDisc ); + sTraffic.setSpeedLimit( cameraSpeed ); + sTraffic.setTrafficType( cameraType ); + MogoNaviListenerHandler.getInstance().onUpdateTraffic2( sTraffic ); } /** diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/IMogoMapViewInstanceHandler.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/IMogoMapViewInstanceHandler.java new file mode 100644 index 0000000000..55d5b23a2f --- /dev/null +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/IMogoMapViewInstanceHandler.java @@ -0,0 +1,15 @@ +package com.mogo.map; + +import android.content.Context; + +public +/** + * @author congtaowang + * @since 2020/9/10 + * + * 描述 + */ +interface IMogoMapViewInstanceHandler extends IDestroyable { + + void createMapViewInstance( Context context ); +} 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 ddfd895697..e51e933608 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 @@ -37,7 +37,7 @@ public abstract class MogoBaseMapView extends FrameLayout implements ILifeCycle init( context ); } - private void init( Context context ) { + protected void init( Context context ) { mMapView = createMapView( context ); if ( mMapView != null ) { final View mapView = mMapView.getMapView(); diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/marker/IMogoMarker.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/marker/IMogoMarker.java index 8301124d8b..841a240338 100644 --- a/libraries/mogo-map-api/src/main/java/com/mogo/map/marker/IMogoMarker.java +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/marker/IMogoMarker.java @@ -318,4 +318,10 @@ public interface IMogoMarker { * @param duration 时长 */ void startSmooth( List< MogoLatLng > points, int duration ); + + /** + * info window 是否正在显示 + * @return + */ + boolean isInfoWindowShowing(); } diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapView.java b/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapView.java index 20c21725d2..a848c57f7a 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapView.java +++ b/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapView.java @@ -3,9 +3,12 @@ package com.mogo.map; import android.content.Context; import android.os.Bundle; import android.util.AttributeSet; +import android.view.View; +import android.view.ViewGroup; import androidx.annotation.Nullable; +import com.amap.api.col.n3.lg; import com.mogo.map.impl.amap.AMapBaseMapView; import com.mogo.utils.logger.Logger; @@ -30,6 +33,11 @@ public class MogoMapView extends AMapBaseMapView implements ILifeCycle { super( context, attrs, defStyleAttr ); } + @Override + protected void init( Context context ) { + super.init( context ); + } + @Override public IMogoMap getMap() { return super.getMap(); diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapViewInstanceHandler.java b/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapViewInstanceHandler.java new file mode 100644 index 0000000000..b3e6bf7a2b --- /dev/null +++ b/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapViewInstanceHandler.java @@ -0,0 +1,49 @@ +package com.mogo.map; + +import android.content.Context; + +import com.mogo.map.impl.amap.AMapViewHandler; + +public +/** + * @author congtaowang + * @since 2020/9/10 + * + * 描述 + */ +class MogoMapViewInstanceHandler implements IMogoMapViewInstanceHandler { + + private static volatile MogoMapViewInstanceHandler sInstance; + + private MogoMapViewInstanceHandler(){} + + public static MogoMapViewInstanceHandler getInstance(){ + if( sInstance == null ){ + synchronized( MogoMapViewInstanceHandler.class ) { + if( sInstance == null ){ + sInstance = new MogoMapViewInstanceHandler(); + } + } + } + return sInstance; + } + + public synchronized void release(){ + sInstance = null; + } + + private Object readResolve() { + // 阻止反序列化,必须实现 Serializable 接口 + return sInstance; + } + + @Override + public void createMapViewInstance( Context context ) { + AMapViewHandler.createMapView( context ); + } + + @Override + public void destroy() { + AMapViewHandler.destroy(); + } +} diff --git a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/constant/Const.kt b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/constant/Const.kt index 889aedacc7..cd278e9299 100644 --- a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/constant/Const.kt +++ b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/constant/Const.kt @@ -68,6 +68,11 @@ const val UPLOAD_FROM_STRATEGY_CLOUD_CHECK = "4" */ const val UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO = "5" +/** + * 策略上报集合 + */ +val STRATEGY_UPLOAD_TYPE_ARRAY = arrayOf(UPLOAD_FROM_STRATEGY_BLOCK_AUTO, + UPLOAD_FROM_STRATEGY_CLOUD_CHECK, UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO) /** * 默认视频抓取时长,单位是秒 */ diff --git a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CarCorderController.kt b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CarCorderController.kt index 1cde4c21cf..a0ce977eba 100644 --- a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CarCorderController.kt +++ b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CarCorderController.kt @@ -108,7 +108,7 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { this.mLatitude = latitude if (DebugConfig.getCarMachineType() == 0) { //自研车机 outputVideoPath = getCompressVideoPath() - CustomStatusHandler.offerVideoStatus(TakeEntity(isCustom, id)) + CustomStatusHandler.offerVideoStatus(TakeEntity(isCustom, id,fromType)) zdCarCoderController.takeVideo(cameraId, duration) trackGetVideo(1) } else { //比亚迪 @@ -117,7 +117,7 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { // TipToast.shortTip("分享失败,请检查网络") // } else { //失败了,传空地址,发起请求 - val entity = TakeEntity(isCustom, id) + val entity = TakeEntity(isCustom, id,fromType) videoAndThumbMap["video"] = "" videoAndThumbMap["thumb"] = "" @@ -159,16 +159,16 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { val entity = TakeEntity(isCustom, 0L) Log.e(TAG, "onTakePhotoFail -----mType = $mType --- isCustom = $isCustom") //语音播报 1:上报路况,2:交通检查,3:封路 默认 mType 应该为null - if (mType.equals(TANLU_ROAD_CONGESTION) || mType.equals(TANLU_TRAFFIC_CHECK) || mType.equals( - TANLU_ROAD_CLOSURE - ) - || mType.equals(TANLU_ROAD_CURRENT) || mType.equals(TANLU_ROAD_PONDING) || mType.equals( - TANLU_ROAD_ICING - ) - || mType.equals(TANLU_ROAD_HEAVY_FOG) || mType.equals(TANLU_ROAD_ACCIDENT) || mType.equals( - TANLU_ROAD_WORK - ) - ) { +// if (mType.equals(TANLU_ROAD_CONGESTION) || mType.equals(TANLU_TRAFFIC_CHECK) || mType.equals( +// TANLU_ROAD_CLOSURE +// ) +// || mType.equals(TANLU_ROAD_CURRENT) || mType.equals(TANLU_ROAD_PONDING) || mType.equals( +// TANLU_ROAD_ICING +// ) +// || mType.equals(TANLU_ROAD_HEAVY_FOG) || mType.equals(TANLU_ROAD_ACCIDENT) || mType.equals( +// TANLU_ROAD_WORK +// ) +// ) { taskAsync(1_500) { try { // VoiceController.speakVoice("上报失败") @@ -190,9 +190,9 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { mainInfoId, mLongitude, mLatitude - ); + ) } - } +// } } //拍照成功回调返回图片本地路径 @@ -271,6 +271,7 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { } } + //获取视频成功 override fun onTakeVideoSuccess(camera: Int, videoPath: String?) { var thumbnailPath = @@ -282,8 +283,11 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { ) val entity = CustomStatusHandler.pollVideoStatus() - if (!entity?.isCustom) { - trackNormalEvent(CarNet_auto_upload_video, null) + + entity?.let { + if (!entity.isCustom) { + trackNormalEvent(CarNet_auto_upload_video, null) + } } if (isSuccess) { @@ -297,25 +301,30 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { ) var speed = LocationUtil.getInstance().getSpeed() - if (entity?.isCustom) { - compressVideo(videoPath, thumbnailPath, entity) - } else { - Log.d( - TAG, - "onTakeVideoSuccess maxSpeedVideo = $maxSpeedVideo --->speed= $speed + minSpeedVideo = $minSpeedVideo" - ) - if (maxSpeedVideo == -1) { - Log.d(TAG, "onTakeVideoSuccess 111 abs =" + (Math.abs(minSpeedVideo) / 3.6f)) - if (speed >= (Math.abs(minSpeedVideo) / 3.6f)) { - //获取视频以及缩略图成功,开始上报 - compressVideo(videoPath, thumbnailPath, entity) + entity?.let { + if (entity.isCustom) { + compressVideo(videoPath, thumbnailPath, entity) + }else if (entity.fromType in STRATEGY_UPLOAD_TYPE_ARRAY) { + // 属于策略上报 + compressVideo(videoPath, thumbnailPath, entity) + } else { + Log.d( + TAG, + "onTakeVideoSuccess maxSpeedVideo = $maxSpeedVideo --->speed= $speed + minSpeedVideo = $minSpeedVideo" + ) + if (maxSpeedVideo == -1) { + Log.d(TAG, "onTakeVideoSuccess 111 abs =" + (Math.abs(minSpeedVideo) / 3.6f)) + if (speed >= (Math.abs(minSpeedVideo) / 3.6f)) { + //获取视频以及缩略图成功,开始上报 + compressVideo(videoPath, thumbnailPath, entity) + } } - } - if (minSpeedVideo > 0 && maxSpeedVideo > 0) { - Log.d(TAG, "onTakeVideoSuccess minSpeedVideo > 0 -- speed = $speed") - if ((speed >= (minSpeedVideo / 3.6f)) && speed <= (maxSpeedVideo / 3.6f)) { - compressVideo(videoPath, thumbnailPath, entity) + if (minSpeedVideo > 0 && maxSpeedVideo > 0) { + Log.d(TAG, "onTakeVideoSuccess minSpeedVideo > 0 -- speed = $speed") + if ((speed >= (minSpeedVideo / 3.6f)) && speed <= (maxSpeedVideo / 3.6f)) { + compressVideo(videoPath, thumbnailPath, entity) + } } } } @@ -332,10 +341,13 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { Log.e(TAG, "getVideo onTakeVideoFail") getVideoFailed?.invoke() val entity = CustomStatusHandler.pollVideoStatus() - InformationUploadController.release(entity?.id) - Log.e(TAG, "getVideo onTakeVideoFail entity?.isCustom =" + entity?.isCustom) - if (entity?.isCustom) { + + entity?.let { + InformationUploadController.release(entity.id) + Log.e(TAG, "getVideo onTakeVideoFail entity?.isCustom =" + entity?.isCustom) + if (entity?.isCustom) { // sendGetInfoFailedReceiver(mType) + } } //失败了,传空地址,发起请求 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 8502395eb3..502e6b1c5a 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 @@ -4,6 +4,8 @@ import android.content.Intent import android.util.Log import com.google.gson.Gson import com.mogo.commons.AbsMogoApplication +import com.mogo.commons.debug.DebugConfig +import com.mogo.utils.TipToast import com.zhidao.cosupload.DbPriorityConfig import com.zhidao.cosupload.callback.CosStatusCallback import com.zhidao.cosupload.manager.CosUploadManagerImpl @@ -12,10 +14,7 @@ import com.zhidao.roadcondition.event.GetImageSuccessEvent import com.zhidao.roadcondition.event.LatLngStickyEventBus import com.zhidao.roadcondition.model.proxy.INFO_TYPE_IMG import com.zhidao.roadcondition.model.proxy.INFO_TYPE_VIDEO -import com.zhidao.roadcondition.util.CarNet_Cos_Upload -import com.zhidao.roadcondition.util.LocationUtil -import com.zhidao.roadcondition.util.deletePicFile -import com.zhidao.roadcondition.util.trackNormalEvent +import com.zhidao.roadcondition.util.* /** * @description cos上传操作 @@ -25,8 +24,10 @@ import com.zhidao.roadcondition.util.trackNormalEvent */ class CosStatusController : CosStatusCallback { val TAG: String = this.javaClass.simpleName + //存储单次请求的视频和缩略图url var videoAndThumbMap: MutableMap = mutableMapOf() + //图片上传的eventId lateinit var mPicEventId: String private var isRetry = false //是否重试上传过图片 @@ -79,40 +80,46 @@ class CosStatusController : CosStatusCallback { Log.d(TAG, "uploadCosFailed = $localPath") trackUploadCos(2) //语音播报 1:上报路况,2:交通检查,3:封路 默认 mType 应该为null - if (CarCorderController.mType.equals(TANLU_ROAD_CONGESTION) || CarCorderController.mType.equals( - TANLU_TRAFFIC_CHECK - ) || CarCorderController.mType.equals(TANLU_ROAD_CLOSURE) - || CarCorderController.mType.equals(TANLU_ROAD_CURRENT) || CarCorderController.mType.equals( - TANLU_ROAD_PONDING - ) || CarCorderController.mType.equals(TANLU_ROAD_ICING) - || CarCorderController.mType.equals(TANLU_ROAD_HEAVY_FOG) || CarCorderController.mType.equals( - TANLU_ROAD_ACCIDENT - ) || CarCorderController.mType.equals(TANLU_ROAD_WORK) - ) { +// if (CarCorderController.mType.equals(TANLU_ROAD_CONGESTION) || CarCorderController.mType.equals( +// TANLU_TRAFFIC_CHECK +// ) || CarCorderController.mType.equals(TANLU_ROAD_CLOSURE) +// || CarCorderController.mType.equals(TANLU_ROAD_CURRENT) || CarCorderController.mType.equals( +// TANLU_ROAD_PONDING +// ) || CarCorderController.mType.equals(TANLU_ROAD_ICING) +// || CarCorderController.mType.equals(TANLU_ROAD_HEAVY_FOG) || CarCorderController.mType.equals( +// TANLU_ROAD_ACCIDENT +// ) || CarCorderController.mType.equals(TANLU_ROAD_WORK) +// ) { // VoiceController.speakVoice("cos上报失败") - Log.d(TAG, "uploadCosFailed mType = $mType") - if (entity?.isCustom && mFromType != UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO) { - sendGetInfoFailedReceiver("100") - } - } + Log.d(TAG, "uploadCosFailed mType = $mType") if (!isRetry) { isRetry = true -// taskAsync(30_000) { //去掉重试 -// try { -// uploadFile(mutableListOf(localPath as String), entity, mType) -// } catch (e: Exception) { -// e.printStackTrace() -// } -// } + taskAsync(5_000) { + //去掉重试 + try { + uploadFile(mutableListOf(localPath as String), entity, mType, mainInfoId, mFromType, mLongitude, mLatitude) + } catch (e: Exception) { + e.printStackTrace() + } + } } else { + //重试一次,如果还失败就提示 + if (entity?.isCustom && mFromType != UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO) { + if(DebugConfig.isLauncher()) { + // 只有Launcher上报的时候,失败会提示,独立app不会提示 + sendGetInfoFailedReceiver("100") + } + } + if (localPath!!.endsWith("mp4") || localPath!!.contains("Thumbnail")) { CosCallbackMapController.uploadFailed?.invoke() } CosCallbackMapController.unregisterCallback(localPath) InformationUploadController.release(entity?.id) -// deletePicFile(localPath) + deletePicFile(localPath) } + } override fun uploadCosCompleted( @@ -121,7 +128,6 @@ class CosStatusController : CosStatusCallback { downloadUrl: String?, localPath: String? ) { - Log.d(TAG, "uploadFile mType= $mType") Log.d(TAG, "uploadCosCompleted localPath = $localPath") Log.d(TAG, "uploadCosCompleted downloadUrl = $downloadUrl") Log.d(TAG, "uploadCosCompleted cosPath = $cosPath") @@ -137,30 +143,30 @@ class CosStatusController : CosStatusCallback { } Log.d(TAG, "videoAndThumbMap ${videoAndThumbMap}") if (videoAndThumbMap.size == 2) { + trackUploadCos(4) Log.d(TAG, "videoAndThumbMap.size == 2 ") var locationInfo = LocationUtil.getInstance().getLocationInfo() val locationStr: String = Gson().toJson(locationInfo) Log.d(TAG, "locationStr = " + locationStr) //如果失败,需要提示失败弹框 - if (locationInfo.address.isNullOrEmpty() || locationInfo.cityName.isNullOrEmpty() || locationInfo.cityCode.isNullOrEmpty() - || locationInfo.latitude == 0.0 || locationInfo.areaName.isNullOrEmpty() || locationInfo.street.isNullOrEmpty() - || locationInfo.areaCode.isNullOrEmpty() || locationInfo.provinceName.isNullOrEmpty() - ) { - if (entity?.isCustom && mFromType != UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO) { - sendGetInfoFailedReceiver("100") - } - } else { - //分享成功,并打点,如果是上报拥堵,需要takeVideo - LatLngStickyEventBus.getInstance() - .postSticky(GetImageSuccessEvent(downloadUrl, mType)) - //上传录像以及缩略图成功 - sendInformation(INFO_TYPE_VIDEO, videoAndThumbMap) - } +// if (locationInfo.address.isNullOrEmpty() || locationInfo.cityName.isNullOrEmpty() || locationInfo.cityCode.isNullOrEmpty() +// || locationInfo.latitude == 0.0 || locationInfo.areaName.isNullOrEmpty() || locationInfo.street.isNullOrEmpty() +// || locationInfo.areaCode.isNullOrEmpty() || locationInfo.provinceName.isNullOrEmpty() +// ) { +// if (entity?.isCustom && mFromType != UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO) { +// sendGetInfoFailedReceiver("100") +// } +// } else { + + //上传录像以及缩略图成功 + sendInformation(INFO_TYPE_VIDEO, videoAndThumbMap) +// } + } else { + trackUploadCos(5) } } else { - //上传图片成功, 如果是上报路况,直接上传,TODO - Log.d(TAG, "uploadCosCompleted 分享成功 ----mType = $mType") -// if (mType.equals("1") || mType.equals("-1")) { + //上传图片成功, 如果是上报路况,直接上传 + Log.d(TAG, "uploadCosCompleted 分享成功 ---- mType = $mType") sendInformationDirectly( INFO_TYPE_IMG, mutableMapOf("pic" to downloadUrl as String), @@ -170,7 +176,6 @@ class CosStatusController : CosStatusCallback { mLongitude, mLatitude ) -// } } Log.d(TAG, "delete file: ${localPath!!}") CosCallbackMapController.unregisterCallback(localPath) @@ -195,25 +200,43 @@ class CosStatusController : CosStatusCallback { type: Int, map: Map, poiType: String, - entity: TakeEntity, + entity: TakeEntity?, mainInfoId: Long, longitude: Double, latitude: Double ) { - Log.d(TAG, "sendInformationDirectly isCustomSend = ${entity?.isCustom}") Log.d(TAG, "sendInformationDirectly poiType= $poiType ---- mainInfoId= $mainInfoId") - mainServiceHttpModel.sendInformationMessage( - type = type, - url = map, - isCustom = entity?.isCustom, - poiType = poiType, - mainInfoId = mainInfoId, - longitude = longitude, - latitude = latitude - ) { success -> - CosCallbackMapController.unregisterCallbacks(map) - CosCallbackMapController.mainService?.let { - CosCallbackMapController.mainService?.sendCustomResult(success) + //开始上传 + entity?.isCustom?.let { + mainServiceHttpModel.sendInformationMessage( + type = type, + url = map, + isCustom = it, + poiType = poiType, + mainInfoId = mainInfoId, + longitude = longitude, + latitude = latitude + ) { success -> + CosCallbackMapController.unregisterCallbacks(map) + CosCallbackMapController.mainService?.let { + CosCallbackMapController.mainService?.sendCustomResult(success) + } + Log.d(TAG, "type = $type ----success = $success") + if (success) { + //分享成功,并打点,如果是上报拥堵,需要takeVideo + if (type == INFO_TYPE_VIDEO) { + try { + LatLngStickyEventBus.getInstance() + .postSticky(GetImageSuccessEvent("", poiType)) + } catch (e: java.lang.Exception) { + e.printStackTrace() + } + } + } else { + if (type == INFO_TYPE_VIDEO) { + TipToast.shortTip("分享失败,请检查网络") + } + } } } } @@ -228,6 +251,5 @@ class CosStatusController : CosStatusCallback { AbsMogoApplication.getApp().applicationContext ) } - } diff --git a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CustomStatusHandler.kt b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CustomStatusHandler.kt index bb31cb71f3..65955f847b 100644 --- a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CustomStatusHandler.kt +++ b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CustomStatusHandler.kt @@ -23,9 +23,9 @@ object CustomStatusHandler { takeVideoStatusQueue.offer(entity) } - fun pollVideoStatus(): TakeEntity = takeVideoStatusQueue.poll() + fun pollVideoStatus(): TakeEntity? = takeVideoStatusQueue.poll() } class TakeEntity( - var isCustom: Boolean, var id: Long + var isCustom: Boolean, var id: Long, var fromType: String = "0" ) \ No newline at end of file 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 70e1074285..87ac502a8b 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 @@ -80,7 +80,7 @@ class MainService : Service() { Analytics.getInstance().start(this) //参数说明:appKey: app唯一标识(比如:包名) CosUploadManagerImpl.getInstance(AbsMogoApplication.getApp().applicationContext) - .init(BuildConfig.APPLICATION_ID, 2) + .init(BuildConfig.APPLICATION_ID, 0) //初始化语音 VoiceController.initVoice() @@ -93,17 +93,18 @@ class MainService : Service() { mLongitude = it.lon mLatitude = it.lat Log.d(TAG, "onStartCommand shareType = $shareType --fromType = $fromType --mainInfoId = $mainInfoId -- mLongitude = $mLongitude --mLatitude = $mLatitude --it.duration = ${it.duration} ") - if (shareType == TANLU_ROAD_CONGESTION || shareType == TANLU_TRAFFIC_CHECK || shareType == TANLU_ROAD_CLOSURE || shareType == TANLU_ROAD_CURRENT - || shareType == TANLU_ROAD_PONDING || shareType == TANLU_ROAD_ICING || shareType == TANLU_ROAD_HEAVY_FOG - || shareType == TANLU_ROAD_ACCIDENT || shareType == TANLU_ROAD_WORK - ) { +// if (shareType == TANLU_ROAD_CONGESTION || shareType == TANLU_TRAFFIC_CHECK || shareType == TANLU_ROAD_CLOSURE || shareType == TANLU_ROAD_CURRENT +// || shareType == TANLU_ROAD_PONDING || shareType == TANLU_ROAD_ICING || shareType == TANLU_ROAD_HEAVY_FOG +// || shareType == TANLU_ROAD_ACCIDENT || shareType == TANLU_ROAD_WORK +// ) { // takePhoto(1, false, true) - if (fromType != UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO) { // 是策略触发,不提示 - takeVideo(it.duration, isCustom = true, id = id) - } else { + if (fromType == UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO || fromType == UPLOAD_FROM_STRATEGY_BLOCK_AUTO) { + // 如果是策略上报,isCustom = false takeVideo(it.duration) + } else { + takeVideo(it.duration, isCustom = true, id = id) } - } +// } } } else { Log.e(TAG, "intent == null ") @@ -247,6 +248,7 @@ class MainService : Service() { getStrategyType("video") ) Log.d("MainService", "handleReportStrategy picType = $picType ---videoType = $videoType") + shareType = TANLU_ROAD_CURRENT if (picType == 1) { takePhoto(1) } else if (picType == 2) { @@ -301,7 +303,7 @@ class MainService : Service() { Log.d("MainService", "takeVideo --------1---->") // if (isAuthorization(BaseApplication.getAppContext())) { // log(TAG, "takeVideo --------2---->") - CarCorderController.takeVideo(1, duration, isCustom, id, if (isCustom) shareType else TANLU_ROAD_CURRENT, mainInfoId, fromType, mLongitude, mLatitude) + CarCorderController.takeVideo(1, duration, isCustom, id, shareType, mainInfoId, fromType, mLongitude, mLatitude) // } postVideoAlarmTask(isInterval) 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 f867e16f6f..64eb300bb4 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 @@ -2,7 +2,10 @@ package com.zhidao.roadcondition.service import android.util.Log import com.mogo.commons.AbsMogoApplication +import com.zhidao.roadcondition.event.GetImageSuccessEvent +import com.zhidao.roadcondition.event.LatLngStickyEventBus import com.zhidao.roadcondition.model.* +import com.zhidao.roadcondition.model.proxy.INFO_TYPE_VIDEO import com.zhidao.roadcondition.net.request import com.zhidao.roadcondition.util.* import com.zhidao.roadcondition.util.StrategyPreferenceUtil.Companion.setStrategyFrequency @@ -274,6 +277,12 @@ class MainServiceController { geoLocation(type, url, locationInfo, isCustom, trafficInfoType, isShare, customSend, poiType,mainInfoId,longitude,latitude) true } else { + //如果两次都失败,直接上报服务端 + postInformationMessage( + getInformationBody(type, url, locationInfo, isCustom, trafficInfoType, isShare, poiType,mainInfoId,longitude,latitude), + customSend + ) + false } }) @@ -294,7 +303,6 @@ class MainServiceController { trackUploadServer(1) // CosStatusController().videoAndThumbMap.clear() customSend?.invoke(true) - } onError { Log.i(TAG, "$it upload message ${it.message}") diff --git a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/util/AnalyticsUtil.kt b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/util/AnalyticsUtil.kt index 1e48a22717..a3976af13d 100644 --- a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/util/AnalyticsUtil.kt +++ b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/util/AnalyticsUtil.kt @@ -28,7 +28,7 @@ const val CarNet_Get_Strategy:String = "CarNet_Get_Strategy" //策略拉取成 const val CarNet_Create_Task:String = "CarNet_Create_Task" //创建定时任务 const val CarNet_Get_Picture:String = "CarNet_Get_Picture" //获取图片,type=1 调用, type=2 成功, type=3 失败 const val CarNet_Get_Video:String = "CarNet_Get_Video" //获取视频,type=1 调用,type=2 成功,type=3 失败 -const val CarNet_Cos_Upload:String = "CarNet_Cos_Upload" //上传COS, type=1 成功, type=2 失败, type=3 开始 +const val CarNet_Cos_Upload:String = "CarNet_Cos_Upload" //上传COS, type=1 成功, type=2 失败, type=3 开始, type=4 成功返回视频和缩略图,type=5 成功但没有返回全视频和缩略图 const val CarNet_Servers_Upload:String = "CarNet_Servers_Upload" //上传服务端, type=1 成功,type=2 失败, type=3 开始 const val CarNet_Voice_Search:String = "CarNet_Voice_Search" //语音搜索路况,type=1 成功,type=2 失败 const val CarNet_USER_SHOW:String = "CarNet_user_show" //情报展示时长,showtime 加载列表时长 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 5e8642fa01..f3ae390679 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 @@ -46,9 +46,6 @@ public class MainIndependentActivity extends MainActivity { @Override protected void onResume() { super.onResume(); - if ( mCoverUpLayout.getVisibility() != View.VISIBLE ) { - mServiceApis.getAdasControllerApi().setUseAlgorithm( true ); - } if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.N){ fixInMultiWindowMode(); } @@ -65,7 +62,6 @@ public class MainIndependentActivity extends MainActivity { @Override protected void onPause() { super.onPause(); - mServiceApis.getAdasControllerApi().setUseAlgorithm( false ); } @Override diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsListChangedLiveData.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsListChangedLiveData.java index 46ff541f23..225c7167c9 100644 --- a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsListChangedLiveData.java +++ b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsListChangedLiveData.java @@ -14,21 +14,24 @@ public class AppsListChangedLiveData extends MutableLiveData { private Observer mObserver; - private AppsListChangedLiveData(){ - // private constructor - } + private static volatile AppsListChangedLiveData sInstance; - private static final class InstanceHolder{ - private static final AppsListChangedLiveData INSTANCE = new AppsListChangedLiveData(); - } + private AppsListChangedLiveData(){} public static AppsListChangedLiveData getInstance(){ - return InstanceHolder.INSTANCE; + if( sInstance == null ){ + synchronized( AppsListChangedLiveData.class ) { + if( sInstance == null ){ + sInstance = new AppsListChangedLiveData(); + } + } + } + return sInstance; } - private Object readResolve(){ - // 阻止反序列化,必须实现 Serializable 接口 - return InstanceHolder.INSTANCE; + private Object readResolve() { + // 阻止反序列化,必须实现 Serializable 接口 + return sInstance; } @Override @@ -37,7 +40,9 @@ public class AppsListChangedLiveData extends MutableLiveData { mObserver = observer; } - public void release(){ + public synchronized void release(){ removeObserver( mObserver ); + mObserver = null; + sInstance = null; } } 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 d1a51e55a8..ed8d6d9ca8 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 @@ -174,12 +174,7 @@ public class AppsPresenter extends Presenter< AppsView > { int page = 0; int counter = 0; for ( AppInfo appInfo : list ) { - if ( counter < AppsConst.TOTAL_SIZE_EACH_PAGE ) { - counter++; - } else { - page++; - counter = 0; - } + page = counter++ / AppsConst.TOTAL_SIZE_EACH_PAGE; if ( !result.containsKey( page ) ) { result.put( page, new ArrayList<>() ); } @@ -221,6 +216,12 @@ public class AppsPresenter extends Presenter< AppsView > { AppsListChangedLiveData.getInstance().release(); mView = null; mLauncher.destroy(); + mAnalytics = null; + mCardManager = null; + if ( mLauncher != null ) { + mLauncher.destroy(); + } + mLauncher = null; } public void exit() { diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/anim/AnimWrapper.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/anim/AnimWrapper.java index bf38719907..aad3f187c8 100644 --- a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/anim/AnimWrapper.java +++ b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/anim/AnimWrapper.java @@ -28,17 +28,8 @@ public class AnimWrapper implements Anim { public void initAnim( ImageView target ) { mTarget = target; if ( CarSeries.getSeries() == CarSeries.CAR_SERIES_F80X ) { - ThreadPoolService.execute( () -> { - final AnimationDrawable drawable = new AnimationDrawable(); - for ( int i = 0; i < AnimRes.sRes.length; i++ ) { - drawable.addFrame( target.getResources().getDrawable( AnimRes.sRes[i] ), 100 ); - } - UiThreadHandler.post( () -> { - target.setBackground( drawable ); - mDelegate = new OthersAnim( drawable ); - start(); - } ); - } ); + mDelegate = new OthersAnim( target ); + start(); } else { mTarget.setImageResource( R.drawable.mogo_tts_icon_00000 ); } diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/anim/OthersAnim.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/anim/OthersAnim.java index 13156b1e7c..aa7259c6ae 100644 --- a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/anim/OthersAnim.java +++ b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/anim/OthersAnim.java @@ -1,6 +1,9 @@ package com.mogo.module.apps.anim; -import android.graphics.drawable.AnimationDrawable; +import android.os.Handler; +import android.os.Looper; +import android.os.Message; +import android.widget.ImageView; /** * @author congtaowang @@ -8,25 +11,44 @@ import android.graphics.drawable.AnimationDrawable; *

* 描述 */ -public class OthersAnim implements Anim{ +public class OthersAnim implements Anim { - private AnimationDrawable mDrawable; + private int mStartIndex = 0; - public OthersAnim( AnimationDrawable drawable ) { - this.mDrawable = drawable; + private final static int MSG_LOOP = 3003; + public static final long INTERVAL = 100L; + private boolean mStarted = false; + + private final ImageView mImageView; + + private Handler mHandler = new Handler( Looper.getMainLooper() ) { + @Override + public void handleMessage( Message msg ) { + super.handleMessage( msg ); + switch ( msg.what ) { + case MSG_LOOP: + if ( mStarted ) { + mImageView.setImageResource( AnimRes.sRes[mStartIndex++ % AnimRes.sRes.length] ); + mHandler.sendEmptyMessageDelayed( MSG_LOOP, INTERVAL ); + } + break; + } + } + }; + + public OthersAnim( ImageView imageView ) { + this.mImageView = imageView; } @Override public void start() { - if ( mDrawable != null ) { - mDrawable.start(); - } + mStarted = true; + mHandler.sendEmptyMessage( MSG_LOOP ); } @Override public void stop() { - if ( mDrawable != null ) { - mDrawable.stop(); - } + mStarted = false; + mHandler.removeMessages( MSG_LOOP ); } } diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/applaunch/InternalFunctionLauncher.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/applaunch/InternalFunctionLauncher.java index 75af6c4455..8a948631fb 100644 --- a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/applaunch/InternalFunctionLauncher.java +++ b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/applaunch/InternalFunctionLauncher.java @@ -103,6 +103,7 @@ public class InternalFunctionLauncher extends BaseAppLauncher { public void destroy() { 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 4463a9e69c..7bf13bcf63 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 @@ -36,7 +36,7 @@ public class AppsModel { private Map< Integer, List< AppInfo > > mPagedApps = new HashMap<>(); private AppsModel( Context context ) { - mContext = context; + mContext = context.getApplicationContext(); } public static AppsModel getInstance( Context context ) { diff --git a/modules/mogo-module-apps/src/main/res/drawable-mdpi/module_apps_ic_ai_assist_bkg.png b/modules/mogo-module-apps/src/main/res/drawable-mdpi/module_apps_ic_ai_assist_bkg.png new file mode 100755 index 0000000000..c340cb9785 Binary files /dev/null and b/modules/mogo-module-apps/src/main/res/drawable-mdpi/module_apps_ic_ai_assist_bkg.png differ diff --git a/modules/mogo-module-apps/src/main/res/drawable-mdpi/module_apps_ic_navigator_applist.png b/modules/mogo-module-apps/src/main/res/drawable-mdpi/module_apps_ic_navigator_applist.png old mode 100644 new mode 100755 index f884758d3d..74d147a76d Binary files a/modules/mogo-module-apps/src/main/res/drawable-mdpi/module_apps_ic_navigator_applist.png and b/modules/mogo-module-apps/src/main/res/drawable-mdpi/module_apps_ic_navigator_applist.png differ diff --git a/modules/mogo-module-apps/src/main/res/drawable-mdpi/module_apps_ic_navigator_im.png b/modules/mogo-module-apps/src/main/res/drawable-mdpi/module_apps_ic_navigator_im.png old mode 100644 new mode 100755 index 7a959f1ca1..e15c5811c7 Binary files a/modules/mogo-module-apps/src/main/res/drawable-mdpi/module_apps_ic_navigator_im.png and b/modules/mogo-module-apps/src/main/res/drawable-mdpi/module_apps_ic_navigator_im.png differ diff --git a/modules/mogo-module-apps/src/main/res/drawable-mdpi/module_apps_ic_navigator_media.png b/modules/mogo-module-apps/src/main/res/drawable-mdpi/module_apps_ic_navigator_media.png old mode 100644 new mode 100755 index d9f6df313d..d84c66fd70 Binary files a/modules/mogo-module-apps/src/main/res/drawable-mdpi/module_apps_ic_navigator_media.png and b/modules/mogo-module-apps/src/main/res/drawable-mdpi/module_apps_ic_navigator_media.png differ diff --git a/modules/mogo-module-apps/src/main/res/drawable-mdpi/module_apps_ic_navigator_navi.png b/modules/mogo-module-apps/src/main/res/drawable-mdpi/module_apps_ic_navigator_navi.png old mode 100644 new mode 100755 index 2401ce7c2a..0a756a1ecc Binary files a/modules/mogo-module-apps/src/main/res/drawable-mdpi/module_apps_ic_navigator_navi.png and b/modules/mogo-module-apps/src/main/res/drawable-mdpi/module_apps_ic_navigator_navi.png differ diff --git a/modules/mogo-module-apps/src/main/res/drawable-mdpi/module_apps_ic_navigator_navi_disable.png b/modules/mogo-module-apps/src/main/res/drawable-mdpi/module_apps_ic_navigator_navi_disable.png old mode 100644 new mode 100755 index 3df9f14026..d4765dae41 Binary files a/modules/mogo-module-apps/src/main/res/drawable-mdpi/module_apps_ic_navigator_navi_disable.png and b/modules/mogo-module-apps/src/main/res/drawable-mdpi/module_apps_ic_navigator_navi_disable.png differ diff --git a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_ai_assist_bkg.png b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_ai_assist_bkg.png old mode 100644 new mode 100755 index e86c3454df..79761a6c19 Binary files a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_ai_assist_bkg.png and b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_ai_assist_bkg.png differ diff --git a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_apps.png b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_apps.png old mode 100755 new mode 100644 diff --git a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_chat_icon.png b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_chat_icon.png old mode 100755 new mode 100644 diff --git a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_chat_unchecked.png b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_chat_unchecked.png old mode 100755 new mode 100644 diff --git a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_equlizer.png b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_equlizer.png old mode 100755 new mode 100644 diff --git a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_fm.png b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_fm.png old mode 100755 new mode 100644 diff --git a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_fota.png b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_fota.png old mode 100755 new mode 100644 diff --git a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_icon_map.png b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_icon_map.png old mode 100755 new mode 100644 diff --git a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_interest.png b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_interest.png old mode 100755 new mode 100644 diff --git a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_interest_unchecked.png b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_interest_unchecked.png old mode 100755 new mode 100644 diff --git a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_lrts.png b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_lrts.png old mode 100755 new mode 100644 diff --git a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_media_center.png b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_media_center.png old mode 100755 new mode 100644 diff --git a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_media_center_checked.png b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_media_center_checked.png old mode 100755 new mode 100644 diff --git a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_music.png b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_music.png old mode 100755 new mode 100644 diff --git a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_navigation.png b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_navigation.png old mode 100755 new mode 100644 diff --git a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_navigator_applist.png b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_navigator_applist.png index b95bc4576f..5bf7356145 100755 Binary files a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_navigator_applist.png and b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_navigator_applist.png differ diff --git a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_navigator_im.png b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_navigator_im.png old mode 100755 new mode 100644 index 3ee3703675..0b47d2f33c Binary files a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_navigator_im.png and b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_navigator_im.png differ diff --git a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_navigator_media.png b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_navigator_media.png index bcfdb9cfa9..a27975f9fb 100755 Binary files a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_navigator_media.png and b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_navigator_media.png differ diff --git a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_navigator_navi.png b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_navigator_navi.png index deee86ed15..930b016a25 100755 Binary files a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_navigator_navi.png and b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_navigator_navi.png differ diff --git a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_navigator_navi_disable.png b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_navigator_navi_disable.png old mode 100644 new mode 100755 index 6a00c94c9d..0cfd3f47cb Binary files a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_navigator_navi_disable.png and b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_navigator_navi_disable.png differ diff --git a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_news.png b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_news.png old mode 100755 new mode 100644 diff --git a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_news_unchecked.png b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_news_unchecked.png old mode 100755 new mode 100644 diff --git a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_online_car.png b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_online_car.png old mode 100755 new mode 100644 diff --git a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_online_car_unchecked.png b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_online_car_unchecked.png old mode 100755 new mode 100644 diff --git a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_qiyi.png b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_qiyi.png old mode 100755 new mode 100644 diff --git a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_qq_music.png b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_qq_music.png old mode 100755 new mode 100644 diff --git a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_retract.png b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_retract.png old mode 100755 new mode 100644 diff --git a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_stee_product.png b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_stee_product.png old mode 100755 new mode 100644 diff --git a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_tanlu.png b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_tanlu.png old mode 100755 new mode 100644 diff --git a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_tanlu_unchecked.png b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_tanlu_unchecked.png old mode 100755 new mode 100644 diff --git a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_welfare.png b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_welfare.png old mode 100755 new mode 100644 diff --git a/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_ximalaya.png b/modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_ximalaya.png old mode 100755 new mode 100644 diff --git a/modules/mogo-module-apps/src/main/res/layout/module_apps_fragment_apps.xml b/modules/mogo-module-apps/src/main/res/layout/module_apps_fragment_apps.xml index 4218f100d9..8cb7bec0c1 100644 --- a/modules/mogo-module-apps/src/main/res/layout/module_apps_fragment_apps.xml +++ b/modules/mogo-module-apps/src/main/res/layout/module_apps_fragment_apps.xml @@ -4,7 +4,7 @@ android:id="@+id/module_apps_id_apps_container" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="#0C0C0C"> + android:background="@color/module_app_page_bkg_color"> \ No newline at end of file diff --git a/modules/mogo-module-apps/src/main/res/values-xhdpi/dimens.xml b/modules/mogo-module-apps/src/main/res/values-xhdpi/dimens.xml index a9ba5a2fef..c335dd18d9 100644 --- a/modules/mogo-module-apps/src/main/res/values-xhdpi/dimens.xml +++ b/modules/mogo-module-apps/src/main/res/values-xhdpi/dimens.xml @@ -21,8 +21,8 @@ 94px 94px - 140px - 140px + 160px + 160px 30px 100px 100px diff --git a/modules/mogo-module-apps/src/main/res/values/colors.xml b/modules/mogo-module-apps/src/main/res/values/colors.xml index 6fb34a3513..155daf49f1 100644 --- a/modules/mogo-module-apps/src/main/res/values/colors.xml +++ b/modules/mogo-module-apps/src/main/res/values/colors.xml @@ -16,5 +16,7 @@ #080625 #3E7FFC + #E6000000 + #FFFFFF diff --git a/modules/mogo-module-apps/src/main/res/values/dimens.xml b/modules/mogo-module-apps/src/main/res/values/dimens.xml index 679816b821..d335541a42 100644 --- a/modules/mogo-module-apps/src/main/res/values/dimens.xml +++ b/modules/mogo-module-apps/src/main/res/values/dimens.xml @@ -24,6 +24,6 @@ 78px 78px 17px - 60px - 60px + 55px + 55px \ No newline at end of file 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 beac0c0246..00261fe76b 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 @@ -12,6 +12,7 @@ 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.Companion.mogoAuthShow +import com.mogo.module.authorize.util.SharedPreferenceUtil.hasGuide import com.mogo.service.MogoServicePaths import com.mogo.service.auth.IMogoAuthManager import com.mogo.service.module.IMogoModuleLifecycle @@ -24,7 +25,7 @@ class MogoAuthorizeProvider : IMogoAuthManager { const val TAG = "MogoAuthorizeProvider" } - private var mContext:Context? = null + private var mContext: Context? = null override fun createFragment(context: Context?, data: Bundle?): Fragment? { return null @@ -62,10 +63,11 @@ class MogoAuthorizeProvider : IMogoAuthManager { return null } - override fun showAuth(context: Context?) { + override fun showAuth(context: Context) { mContext = context - if (mogoAuthShow.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_MAIN)) { - mogoAuthShow.invokeAuthorizeForShow(mContext!!) + mogoAuthShow.initContext(context) + if (hasGuide() && mogoAuthShow.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_MAIN)) { + mogoAuthShow.invokeAuthorizeForShow() } else { //首次进入Launcher同步一下授权状态,防止由于用户清除数据造成首次加载还会出现授权状态不同步问题 mogoAuthShow.updateAuthorizeStatus(AUTHORIZE_TYPE_LAUNCHER_MAIN) @@ -78,9 +80,7 @@ class MogoAuthorizeProvider : IMogoAuthManager { } override fun init(context: Context) { - //todo 引导判断暂时去掉 后续引导流程更改完再放开 -// todo if (isDeviceOfD() && hasGuide() && mogoAuthShow.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_MAIN)) { - // todo F系列暂时没有授权功能 1.1需求中添加 全量上 + } override fun getAppPackage(): String? { 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 a8102b84ad..681ffbd91e 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 @@ -39,8 +39,11 @@ class MogoMainAuthorize private constructor() : MogoAuthorizeManagerImpl(), IMog MogoAuthorizeMainController.disAgreeAuthorize(tag, agrId, onSuccess, onError) } - fun invokeAuthorizeForShow(context: Context) { - mContext = context + fun initContext(mContext: Context) { + this.mContext = mContext + } + + fun invokeAuthorizeForShow() { pushLayoutToMainWindow(AUTHORIZE_TYPE_LAUNCHER_MAIN) } @@ -74,7 +77,7 @@ class MogoMainAuthorize private constructor() : MogoAuthorizeManagerImpl(), IMog } private fun pushLayoutToMainWindow(tag: String) { - if(mContext == null){ + if (mContext == null) { Logger.d(TAG, "Because of mContext has no init, the application has in background now") return } 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 e698249eee..c6061c6e64 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 @@ -1,9 +1,13 @@ package com.mogo.module.authorize.authprovider.module +import com.alibaba.android.arouter.launcher.ARouter import com.mogo.commons.AbsMogoApplication 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 { @@ -14,13 +18,21 @@ class MogoModuleAuthorize private constructor() : MogoAuthorizeManagerImpl(), IM } override fun invokeAuthorizeForShow() { - mogoAuthShow.invokeAuthorizeForShow(AbsMogoApplication.getApp().applicationContext) + mogoAuthShow.invokeAuthorizeForShow() } override fun invokeAuthorization(tag: String) { + if(isDeviceOfD() && !SharedPreferenceUtil.hasGuide()){ + val guideService = ARouter.getInstance().build("/guide/showFragment").navigation() + if(guideService is IMogoModuleProvider){ + guideService.init(AbsMogoApplication.getApp().applicationContext) + } + val listener = MogoAuthorizeRegisterHandler.getAuthorizeListener(tag) + listener?.authorizeFailed("需要先执行用户引导") + return + } mogoAuthShow.showAuthorizeView(tag, { //todo SP存储状态 - }, { errorMsg -> val listener = MogoAuthorizeRegisterHandler.getAuthorizeListener(tag) listener?.authorizeFailed(errorMsg) 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 5d74894005..abe1cd043a 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,6 +1,7 @@ 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 @@ -14,6 +15,7 @@ import com.mogo.module.authorize.voice.IVoiceAuthorizeIntentListener import com.mogo.module.authorize.voice.IVoiceCommandListener import com.mogo.module.authorize.voice.VoiceUtil import com.mogo.module.common.dialog.BaseFloatDialog +import com.mogo.module.common.utils.CarSeries import com.mogo.utils.TipToast import com.mogo.utils.logger.Logger import kotlinx.coroutines.Dispatchers @@ -62,7 +64,12 @@ class AuthorizeDialog : BaseFloatDialog, View.OnClickListener, IVoiceCommandList private fun setWrapContent() { val mWindow = window if(DebugConfig.getCarMachineType() != DebugConfig.CAR_MACHINE_TYPE_BYD){ - if (mWindow != null) { + if (mWindow != null && CarSeries.getSeries() == CarSeries.CAR_SERIES_F80X) { + val lp = mWindow.attributes + lp.width = 1920 + lp.height = 1080 + mWindow.attributes = lp + }else{ val lp = mWindow.attributes lp.width = 1024 lp.height = 600 @@ -78,7 +85,7 @@ class AuthorizeDialog : BaseFloatDialog, View.OnClickListener, IVoiceCommandList } } - fun initViews() { + private fun initViews() { Logger.d(TAG, "initView ") AnalyticsUtil.track(AnalyticsUtil.INVOKE_TRACK_AUTHORIZE_SHOW) init() 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 new file mode 100644 index 0000000000..8884512894 --- /dev/null +++ b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/util/DeviceUtil.kt @@ -0,0 +1,10 @@ +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 d585622cde..6418cae142 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,12 +1,12 @@ package com.mogo.module.authorize.util import com.mogo.commons.AbsMogoApplication +import com.mogo.commons.debug.DebugConfig.getSpGuide import com.mogo.utils.storage.SharedPrefsMgr object SharedPreferenceUtil { private const val HAS_AUTH = "HAS_AUTH" - private const val HAS_GUIDE = "HAS_GUIDE" private const val AUTHORIZE_UPDATE_TIME = "AUTHORIZE_UPDATE_TIME" fun needAuthorization(type: Int): Boolean { @@ -30,6 +30,6 @@ object SharedPreferenceUtil { } fun hasGuide(): Boolean { - return SharedPrefsMgr.getInstance(AbsMogoApplication.getApp()).getBoolean(HAS_GUIDE, false) + return SharedPrefsMgr.getInstance(AbsMogoApplication.getApp()).getBoolean(getSpGuide(), false) } } \ No newline at end of file diff --git a/modules/mogo-module-authorize/src/main/res/drawable-xhdpi-1920x1000/module_authorize_selector_blue_corner.xml b/modules/mogo-module-authorize/src/main/res/drawable-xhdpi-1920x1000/module_authorize_selector_blue_corner.xml index c2d1fec152..93b269154a 100644 --- a/modules/mogo-module-authorize/src/main/res/drawable-xhdpi-1920x1000/module_authorize_selector_blue_corner.xml +++ b/modules/mogo-module-authorize/src/main/res/drawable-xhdpi-1920x1000/module_authorize_selector_blue_corner.xml @@ -3,13 +3,13 @@ - + - + \ No newline at end of file diff --git a/modules/mogo-module-authorize/src/main/res/drawable-xhdpi-1920x1000/module_authorize_selector_blue_left_corner.xml b/modules/mogo-module-authorize/src/main/res/drawable-xhdpi-1920x1000/module_authorize_selector_blue_left_corner.xml index 8c950afee3..9d0ac5061d 100644 --- a/modules/mogo-module-authorize/src/main/res/drawable-xhdpi-1920x1000/module_authorize_selector_blue_left_corner.xml +++ b/modules/mogo-module-authorize/src/main/res/drawable-xhdpi-1920x1000/module_authorize_selector_blue_left_corner.xml @@ -3,13 +3,13 @@ - + - + \ No newline at end of file diff --git a/modules/mogo-module-authorize/src/main/res/drawable-xhdpi-1920x1000/module_authorize_selector_dark_corner.xml b/modules/mogo-module-authorize/src/main/res/drawable-xhdpi-1920x1000/module_authorize_selector_dark_corner.xml index 86e673bca6..e9cb674da9 100644 --- a/modules/mogo-module-authorize/src/main/res/drawable-xhdpi-1920x1000/module_authorize_selector_dark_corner.xml +++ b/modules/mogo-module-authorize/src/main/res/drawable-xhdpi-1920x1000/module_authorize_selector_dark_corner.xml @@ -2,6 +2,7 @@ + android:startColor="#2A2B38 " /> \ No newline at end of file diff --git a/modules/mogo-module-authorize/src/main/res/drawable-xhdpi-1920x1000/module_authorize_shape_drak_top_corner.xml b/modules/mogo-module-authorize/src/main/res/drawable-xhdpi-1920x1000/module_authorize_shape_drak_top_corner.xml deleted file mode 100644 index 38ff34eb71..0000000000 --- a/modules/mogo-module-authorize/src/main/res/drawable-xhdpi-1920x1000/module_authorize_shape_drak_top_corner.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - \ No newline at end of file diff --git a/modules/mogo-module-authorize/src/main/res/drawable-xhdpi-1920x1080/module_authorize_selector_blue_corner.xml b/modules/mogo-module-authorize/src/main/res/drawable-xhdpi-1920x1080/module_authorize_selector_blue_corner.xml new file mode 100644 index 0000000000..63144dcf3c --- /dev/null +++ b/modules/mogo-module-authorize/src/main/res/drawable-xhdpi-1920x1080/module_authorize_selector_blue_corner.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/mogo-module-guide/src/main/res/drawable/module_guide_selector_blue.xml b/modules/mogo-module-authorize/src/main/res/drawable-xhdpi-1920x1080/module_authorize_selector_blue_left_corner.xml similarity index 70% rename from modules/mogo-module-guide/src/main/res/drawable/module_guide_selector_blue.xml rename to modules/mogo-module-authorize/src/main/res/drawable-xhdpi-1920x1080/module_authorize_selector_blue_left_corner.xml index 598aa0aa6d..9d0ac5061d 100644 --- a/modules/mogo-module-guide/src/main/res/drawable/module_guide_selector_blue.xml +++ b/modules/mogo-module-authorize/src/main/res/drawable-xhdpi-1920x1080/module_authorize_selector_blue_left_corner.xml @@ -2,14 +2,14 @@ - - + + - - + + \ No newline at end of file diff --git a/modules/mogo-module-authorize/src/main/res/drawable-xhdpi-1920x1080/module_authorize_selector_dark_corner.xml b/modules/mogo-module-authorize/src/main/res/drawable-xhdpi-1920x1080/module_authorize_selector_dark_corner.xml new file mode 100644 index 0000000000..e9cb674da9 --- /dev/null +++ b/modules/mogo-module-authorize/src/main/res/drawable-xhdpi-1920x1080/module_authorize_selector_dark_corner.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/modules/mogo-module-authorize/src/main/res/drawable-xhdpi-1920x1080/module_authorize_selector_dark_right_corner.xml b/modules/mogo-module-authorize/src/main/res/drawable-xhdpi-1920x1080/module_authorize_selector_dark_right_corner.xml new file mode 100644 index 0000000000..086f0e93fa --- /dev/null +++ b/modules/mogo-module-authorize/src/main/res/drawable-xhdpi-1920x1080/module_authorize_selector_dark_right_corner.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/mogo-module-authorize/src/main/res/drawable-xhdpi-1920x1080/module_authorize_shape_top_corner.xml b/modules/mogo-module-authorize/src/main/res/drawable-xhdpi-1920x1080/module_authorize_shape_top_corner.xml new file mode 100644 index 0000000000..47a3428433 --- /dev/null +++ b/modules/mogo-module-authorize/src/main/res/drawable-xhdpi-1920x1080/module_authorize_shape_top_corner.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/modules/mogo-module-authorize/src/main/res/drawable/module_authorize_selector_blue_corner.xml b/modules/mogo-module-authorize/src/main/res/drawable/module_authorize_selector_blue_corner.xml index c2d1fec152..63144dcf3c 100644 --- a/modules/mogo-module-authorize/src/main/res/drawable/module_authorize_selector_blue_corner.xml +++ b/modules/mogo-module-authorize/src/main/res/drawable/module_authorize_selector_blue_corner.xml @@ -2,14 +2,14 @@ - - + + - - + + \ No newline at end of file diff --git a/modules/mogo-module-authorize/src/main/res/drawable/module_authorize_selector_blue_left_corner.xml b/modules/mogo-module-authorize/src/main/res/drawable/module_authorize_selector_blue_left_corner.xml index 6399ca294a..536fc2c742 100644 --- a/modules/mogo-module-authorize/src/main/res/drawable/module_authorize_selector_blue_left_corner.xml +++ b/modules/mogo-module-authorize/src/main/res/drawable/module_authorize_selector_blue_left_corner.xml @@ -3,13 +3,13 @@ - + - + \ No newline at end of file diff --git a/modules/mogo-module-authorize/src/main/res/drawable/module_authorize_selector_dark_corner.xml b/modules/mogo-module-authorize/src/main/res/drawable/module_authorize_selector_dark_corner.xml index 1b8bbd3159..c366e79eea 100644 --- a/modules/mogo-module-authorize/src/main/res/drawable/module_authorize_selector_dark_corner.xml +++ b/modules/mogo-module-authorize/src/main/res/drawable/module_authorize_selector_dark_corner.xml @@ -2,6 +2,7 @@ + android:startColor="#2A2B38" /> \ No newline at end of file diff --git a/modules/mogo-module-authorize/src/main/res/drawable/module_authorize_shape_drak_top_corner.xml b/modules/mogo-module-authorize/src/main/res/drawable/module_authorize_shape_drak_top_corner.xml deleted file mode 100644 index 0f2dab89cb..0000000000 --- a/modules/mogo-module-authorize/src/main/res/drawable/module_authorize_shape_drak_top_corner.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - \ No newline at end of file diff --git a/modules/mogo-module-authorize/src/main/res/drawable/module_authorize_shape_top_corner.xml b/modules/mogo-module-authorize/src/main/res/drawable/module_authorize_shape_top_corner.xml new file mode 100644 index 0000000000..47e186f1e7 --- /dev/null +++ b/modules/mogo-module-authorize/src/main/res/drawable/module_authorize_shape_top_corner.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/modules/mogo-module-authorize/src/main/res/layout-xhdpi-1920x1000/module_authorize_fragment.xml b/modules/mogo-module-authorize/src/main/res/layout-xhdpi-1920x1000/module_authorize_fragment.xml index f3d940ee26..e3a16367f6 100644 --- a/modules/mogo-module-authorize/src/main/res/layout-xhdpi-1920x1000/module_authorize_fragment.xml +++ b/modules/mogo-module-authorize/src/main/res/layout-xhdpi-1920x1000/module_authorize_fragment.xml @@ -207,4 +207,4 @@ app:layout_constraintTop_toTopOf="parent" /> - \ No newline at end of file + diff --git a/modules/mogo-module-authorize/src/main/res/layout-xhdpi-1920x1080/module_authorize_fragment.xml b/modules/mogo-module-authorize/src/main/res/layout-xhdpi-1920x1080/module_authorize_fragment.xml new file mode 100644 index 0000000000..1642421fb0 --- /dev/null +++ b/modules/mogo-module-authorize/src/main/res/layout-xhdpi-1920x1080/module_authorize_fragment.xml @@ -0,0 +1,236 @@ + + + + + + + + + + + + + + + + + +