diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 8978cebc20..35c192e3ba 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -52,6 +52,7 @@
+
diff --git a/app/build.gradle b/app/build.gradle
index daa2a53d52..ac5a0db6ae 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -294,6 +294,7 @@ dependencies {
implementation rootProject.ext.dependencies.moduletanluapi
implementation rootProject.ext.dependencies.mogomonitor
+ implementation rootProject.ext.dependencies.mogomodulewidgets
} else {
launcherImplementation project(':main-extensions:mogo-module-main-launcher')
independentImplementation project(':main-extensions:mogo-module-main-independent')
@@ -310,6 +311,7 @@ dependencies {
}
implementation project(':libraries:mogo-tanlu-api')
implementation project(':modules:mogo-module-monitor')
+ implementation project(':modules:mogo-module-widgets')
}
apply from: "./functions/baseservices.gradle"
diff --git a/app/src/main/java/com/mogo/launcher/MogoApplication.java b/app/src/main/java/com/mogo/launcher/MogoApplication.java
index 34312b7381..99cd7e7447 100644
--- a/app/src/main/java/com/mogo/launcher/MogoApplication.java
+++ b/app/src/main/java/com/mogo/launcher/MogoApplication.java
@@ -11,7 +11,6 @@ import com.bytedance.boost_multidex.BoostMultiDex;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.commons.network.Utils;
-import com.mogo.commons.storage.SpStorage;
import com.mogo.module.authorize.authprovider.invoke.AuthorizeConstant;
import com.mogo.module.carchatting.card.CallChatConstant;
import com.mogo.module.common.MogoModule;
@@ -22,6 +21,7 @@ import com.mogo.module.push.base.PushUIConstants;
import com.mogo.module.service.ServiceConst;
import com.mogo.module.tanlu.constant.TanluConstants;
import com.mogo.module.v2x.V2XConst;
+import com.mogo.module.widgets.MogoWidgetsProvider;
import com.mogo.service.IMogoServiceApis;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.passport.IMogoTicketCallback;
@@ -58,14 +58,15 @@ public class MogoApplication extends AbsMogoApplication {
MogoModulePaths.addModule( new MogoModule( MogoServicePaths.PATH_AGREEMENT, AuthorizeConstant.PATH_AGREEMENT_MODULE_NAME ) );
//运营位卡片,需要默认显示,放在第一个加载
- if (DebugConfig.isLauncher() ) {
+ if ( DebugConfig.isLauncher() ) {
MogoModulePaths.addModule( new MogoModule( MediaConstants.TAG, MediaConstants.MODULE_TYPE ) );
+ } else {
+ MogoModulePaths.addBaseModule( new MogoModule( MogoWidgetsProvider.PATH, MogoWidgetsProvider.NAME ) );
}
- if(DebugConfig.getCarMachineType() != DebugConfig.CAR_MACHINE_TYPE_BYD){
+ 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( TanluApiConst.MODULE_PATH, TanluApiConst.MODULE_NAME ) );
MogoModulePaths.addModule( new MogoModule( TanluConstants.TAG, TanluConstants.MODEL_NAME ) );
MogoModulePaths.addModule( new MogoModule( MogoServicePaths.PATH_SHARE, "ShareControl" ) );
@@ -101,13 +102,13 @@ public class MogoApplication extends AbsMogoApplication {
@Override
protected void init() {
super.init();
- prepareBaseService(2_000L);
+ prepareBaseService( 2_000L );
}
/**
* 基础服务:passport、location、socket
*/
- private void prepareBaseService(long delay) {
+ private void prepareBaseService( long delay ) {
UiThreadHandler.postDelayed( () -> {
final IMogoServiceApis apis = ARouter.getInstance().navigation( IMogoServiceApis.class );
// 第三方平台的sn是服务端生成的,所以必须在返回后才能开启
diff --git a/config.gradle b/config.gradle
index 254bff2d5f..6714fbfaaf 100644
--- a/config.gradle
+++ b/config.gradle
@@ -4,18 +4,18 @@ 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 = [
@@ -194,5 +194,8 @@ targetSdkVersion : 22,
androidxroomruntime : "androidx.room:room-runtime:2.2.3",
androidxroomcompiler : "androidx.room:room-compiler:2.2.3",
androidxroomktx : "androidx.room:room-ktx:2.2.3",
+
+ //
+ mogomodulewidgets : "com.mogo.module:module-widgets:${MOGO_MODULE_WIDGETS_VERSION}",
]
}
\ No newline at end of file
diff --git a/gradle.properties b/gradle.properties
index f3910bfae4..90a79fcceb 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -89,6 +89,8 @@ MOGO_MODULE_EVENT_PANEL_NOOP_VERSION = 1.0.0-SNAPSHOT
#左侧面板模块
MOGO_MODULE_LEFT_PANEL_VERSION = 1.2.1.10-SNAPSHOT
MOGO_MODULE_LEFT_PANEL_NOOP_VERSION = 1.2.1.10-SNAPSHOT
+# 小控件
+MOGO_MODULE_WIDGETS_VERSION = 1.2.1.10-SNAPSHOT
# Boost分包
BOOST_MULTIDEX_VERSION=1.0.0
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServices.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServices.java
index 1eb74077a3..9b2a255a28 100644
--- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServices.java
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServices.java
@@ -32,7 +32,6 @@ import com.mogo.module.common.MogoModule;
import com.mogo.module.common.MogoModulePaths;
import com.mogo.module.common.map.MapCenterPointStrategy;
import com.mogo.module.common.map.Scene;
-import com.mogo.module.service.intent.AutoNaviIntentHandler;
import com.mogo.module.service.intent.IntentHandlerFactory;
import com.mogo.module.service.marker.MapMarkerManager;
import com.mogo.module.service.network.RefreshCallback;
@@ -304,11 +303,9 @@ public class MogoServices implements IMogoMapListener,
restartAutoRefreshAtTime( 2_000L );
}
mIsMainPageFirstResume = false;
- AutoNaviIntentHandler.getInstance().closeEntrance();
} else {
unregisterInternalUnWakeupWords();
stopAutoRefreshStrategy();
- AutoNaviIntentHandler.getInstance().syncAutoNaviForgroundStatus( mContext );
}
}
@@ -401,8 +398,6 @@ public class MogoServices implements IMogoMapListener,
initLocationServiceProcess( context );
}
- AutoNaviIntentHandler.getInstance().syncAutoNaviForgroundStatus( mContext );
-
}
private void initLocationServiceProcess( Context context ) {
@@ -924,14 +919,4 @@ public class MogoServices implements IMogoMapListener,
AIAssist.getInstance( mContext ).registerUnWakeupCommand( ServiceConst.CMD_BACK, ServiceConst.CMD_BACK_WORDS, this );
}
}
-
- @Override
- public void onStartNavi() {
- AutoNaviIntentHandler.getInstance().preShowEntrance( mContext );
- }
-
- @Override
- public void onStopNavi() {
- AutoNaviIntentHandler.getInstance().closeEntrance();
- }
}
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/IntentHandlerFactory.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/IntentHandlerFactory.java
index c9887ac462..ea84b182e2 100644
--- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/IntentHandlerFactory.java
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/IntentHandlerFactory.java
@@ -37,8 +37,6 @@ public class IntentHandlerFactory {
mHandlers.put( MogoReceiver.ACTIION_ADAS, ADASStatusIntentHandler.getInstance() );
mHandlers.put( MogoReceiver.ACTION_VOICE_READY, new AIAssistIntentHandler() );
mHandlers.put( ServiceConst.COMMAND_BACK, WholeVoiceCommandIntentHandler.getInstance() );
- mHandlers.put( MogoReceiver.ACTION_AUTO_NAVI_RECEIVER, AutoNaviIntentHandler.getInstance() );
- mHandlers.put( MogoReceiver.ACTION_AUTO_NAVI_SEND, AutoNaviIntentHandler.getInstance() );
}
private static final class InstanceHolder {
diff --git a/modules/mogo-module-service/src/main/res/layout/module_service_app_entrance.xml b/modules/mogo-module-service/src/main/res/layout/module_service_app_entrance.xml
deleted file mode 100644
index 0c8bb8cadd..0000000000
--- a/modules/mogo-module-service/src/main/res/layout/module_service_app_entrance.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
* 描述
*/
-class AutoNaviIntentHandler implements IntentHandler {
+class AutoNaviIntentHandler {
private static final String TAG = "AutoNaviIntentHandler";
@@ -47,16 +45,11 @@ class AutoNaviIntentHandler implements IntentHandler {
sInstance = null;
}
- @Override
public void handle( Context context, Intent intent ) {
int keyType = intent.getIntExtra( "KEY_TYPE", 0 );
switch ( keyType ) {
case 10021:
closeEntrance();
- MarkerServiceHandler.getADASController().showADAS();
- break;
- case 20009:
- MarkerServiceHandler.getADASController().closeADAS();
break;
case 10019:
int extraState = intent.getIntExtra( "EXTRA_STATE", -1 );
@@ -90,15 +83,15 @@ class AutoNaviIntentHandler implements IntentHandler {
private void showEntrance( Context context ) {
if ( mWindowManagerView == null ) {
mWindowManagerView = new WindowManagerView.Builder( AbsMogoApplication.getApp() )
- .contentView( R.layout.module_service_app_entrance )
+ .contentView( R.layout.module_widgets_app_entrance )
.size( WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT )
.gravity( Gravity.LEFT | Gravity.TOP )
- .position( ResourcesHelper.getDimensionPixelSize( context, R.dimen.module_services_app_entrance_x ), ResourcesHelper.getDimensionPixelSize( AbsMogoApplication.getApp(), R.dimen.module_services_app_entrance_y ) )
+ .position( ResourcesHelper.getDimensionPixelSize( context, R.dimen.module_widgets_app_entrance_x ), ResourcesHelper.getDimensionPixelSize( AbsMogoApplication.getApp(), R.dimen.module_widgets_app_entrance_y ) )
.showInWindowManager();
mWindowManagerView.attachTouchEvent( view -> {
try {
if ( DebugConfig.isLauncher() ) {
- MarkerServiceHandler.getLauncher().backToLauncher( context );
+ MogoWidgetManger.getInstance().getApis().getLauncherApi().backToLauncher( context );
} else {
LaunchUtils.launchByPkg( context, "com.mogo.launcher.app" );
}
diff --git a/modules/mogo-module-widgets/src/main/java/com/mogo/module/widgets/MogoWidgetManger.java b/modules/mogo-module-widgets/src/main/java/com/mogo/module/widgets/MogoWidgetManger.java
new file mode 100644
index 0000000000..289c0a30ca
--- /dev/null
+++ b/modules/mogo-module-widgets/src/main/java/com/mogo/module/widgets/MogoWidgetManger.java
@@ -0,0 +1,108 @@
+package com.mogo.module.widgets;
+
+import android.content.Context;
+import android.content.Intent;
+
+import com.alibaba.android.arouter.launcher.ARouter;
+import com.mogo.map.navi.IMogoNaviListener2;
+import com.mogo.service.IMogoServiceApis;
+import com.mogo.service.intent.IMogoIntentListener;
+import com.mogo.service.statusmanager.IMogoStatusChangedListener;
+import com.mogo.service.statusmanager.StatusDescriptor;
+
+public
+/**
+ * @author congtaowang
+ * @since 2020/8/12
+ *
+ * 描述
+ */
+class MogoWidgetManger implements IMogoNaviListener2, IMogoIntentListener, IMogoStatusChangedListener {
+
+ // 接受其他app发给高德的广播
+ public static final String ACTION_AUTO_NAVI_RECEIVER = "AUTONAVI_STANDARD_BROADCAST_RECV";
+ // 接受高德发过来的广播
+ public static final String ACTION_AUTO_NAVI_SEND = "AUTONAVI_STANDARD_BROADCAST_SEND";
+
+ private static final String TAG = "MogoWidgetManger";
+
+ private static volatile MogoWidgetManger sInstance;
+
+ private MogoWidgetManger() {
+ }
+
+ public static MogoWidgetManger getInstance() {
+ if ( sInstance == null ) {
+ synchronized ( MogoWidgetManger.class ) {
+ if ( sInstance == null ) {
+ sInstance = new MogoWidgetManger();
+ }
+ }
+ }
+ return sInstance;
+ }
+
+ public synchronized void release() {
+ sInstance = null;
+ }
+
+ private Object readResolve() {
+ // 阻止反序列化,必须实现 Serializable 接口
+ return sInstance;
+ }
+
+ private IMogoServiceApis mApis;
+ private Context mContext;
+
+ public IMogoServiceApis getApis() {
+ return mApis;
+ }
+
+ public void init( Context context ) {
+ mContext = context;
+ mApis = ARouter.getInstance().navigation( IMogoServiceApis.class );
+ initMapStatusListener();
+ initStatusListener();
+ initIntentListener();
+ AutoNaviIntentHandler.getInstance().syncAutoNaviForgroundStatus( mContext );
+ }
+
+ private void initMapStatusListener() {
+ mApis.getRegisterCenterApi().registerMogoNaviListener( TAG, this );
+ }
+
+ private void initIntentListener() {
+ mApis.getIntentManagerApi().registerIntentListener( ACTION_AUTO_NAVI_RECEIVER, this );
+ mApis.getIntentManagerApi().registerIntentListener( ACTION_AUTO_NAVI_SEND, this );
+ }
+
+ private void initStatusListener() {
+ mApis.getStatusManagerApi().registerStatusChangedListener( TAG, StatusDescriptor.MAIN_PAGE_RESUME, this );
+ }
+
+ @Override
+ public void onStopNavi() {
+ AutoNaviIntentHandler.getInstance().closeEntrance();
+ }
+
+ @Override
+ public void onStartNavi() {
+ AutoNaviIntentHandler.getInstance().preShowEntrance( mContext );
+ }
+
+ @Override
+ public void onIntentReceived( String intentStr, Intent intent ) {
+ AutoNaviIntentHandler.getInstance().handle( mContext, intent );
+ }
+
+ @Override
+ public void onStatusChanged( StatusDescriptor descriptor, boolean isTrue ) {
+ if ( descriptor == StatusDescriptor.MAIN_PAGE_RESUME ) {
+ if ( isTrue ) {
+ AutoNaviIntentHandler.getInstance().closeEntrance();
+ } else {
+ AutoNaviIntentHandler.getInstance().syncAutoNaviForgroundStatus( mContext );
+ }
+ }
+ }
+}
diff --git a/modules/mogo-module-widgets/src/main/java/com/mogo/module/widgets/MogoWidgetsProvider.java b/modules/mogo-module-widgets/src/main/java/com/mogo/module/widgets/MogoWidgetsProvider.java
new file mode 100644
index 0000000000..6cc91544a3
--- /dev/null
+++ b/modules/mogo-module-widgets/src/main/java/com/mogo/module/widgets/MogoWidgetsProvider.java
@@ -0,0 +1,99 @@
+package com.mogo.module.widgets;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.view.View;
+
+import androidx.annotation.NonNull;
+import androidx.fragment.app.Fragment;
+
+import com.alibaba.android.arouter.facade.annotation.Route;
+import com.mogo.map.listener.IMogoMapListener;
+import com.mogo.map.location.IMogoLocationListener;
+import com.mogo.map.marker.IMogoMarkerClickListener;
+import com.mogo.map.navi.IMogoNaviListener;
+import com.mogo.service.module.IMogoModuleLifecycle;
+import com.mogo.service.module.IMogoModuleProvider;
+import com.mogo.service.module.ModuleType;
+import com.mogo.utils.UiThreadHandler;
+import com.mogo.utils.logger.Logger;
+
+public
+/**
+ * @author congtaowang
+ * @since 2020/8/12
+ *
+ * 描述
+ */
+@Route( path = MogoWidgetsProvider.PATH )
+class MogoWidgetsProvider implements IMogoModuleProvider {
+
+ private static final String TAG = "MogoWidgetsProvider";
+
+ public static final String PATH = "/widgets/provider";
+ public static final String NAME = "MogoWidgetProvider";
+
+ @Override
+ public Fragment createFragment( Context context, Bundle data ) {
+ return null;
+ }
+
+ @Override
+ public View createView( Context context ) {
+ return null;
+ }
+
+ @NonNull
+ @Override
+ public String getModuleName() {
+ return null;
+ }
+
+ @Override
+ public IMogoModuleLifecycle getCardLifecycle() {
+ return null;
+ }
+
+ @Override
+ public IMogoMapListener getMapListener() {
+ return null;
+ }
+
+ @Override
+ public int getType() {
+ return ModuleType.TYPE_SERVICE;
+ }
+
+ @Override
+ public IMogoNaviListener getNaviListener() {
+ return null;
+ }
+
+ @Override
+ public IMogoLocationListener getLocationListener() {
+ return null;
+ }
+
+ @Override
+ public IMogoMarkerClickListener getMarkerClickListener() {
+ return null;
+ }
+
+ @Override
+ public String getAppPackage() {
+ return null;
+ }
+
+ @Override
+ public String getAppName() {
+ return null;
+ }
+
+ @Override
+ public void init( Context context ) {
+ Logger.d( TAG, "init." );
+ UiThreadHandler.postDelayed( () -> {
+ MogoWidgetManger.getInstance().init( context );
+ }, 5500 );
+ }
+}
diff --git a/modules/mogo-module-service/src/main/res/drawable/module_services_app_entrance_bkg.xml b/modules/mogo-module-widgets/src/main/res/drawable/module_widgets_app_entrance_bkg.xml
similarity index 75%
rename from modules/mogo-module-service/src/main/res/drawable/module_services_app_entrance_bkg.xml
rename to modules/mogo-module-widgets/src/main/res/drawable/module_widgets_app_entrance_bkg.xml
index 31b2c574f5..b46cff52de 100644
--- a/modules/mogo-module-service/src/main/res/drawable/module_services_app_entrance_bkg.xml
+++ b/modules/mogo-module-widgets/src/main/res/drawable/module_widgets_app_entrance_bkg.xml
@@ -3,7 +3,7 @@