diff --git a/.idea/misc.xml b/.idea/misc.xml
index 707ee6e613..2dc54c489f 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,6 +1,6 @@
* 描述 */ -public class AppNavigatorPresenter extends Presenter< AppNavigatorView > implements IMogoVoiceCmdCallBack { +public class AppNavigatorPresenter extends Presenter< AppNavigatorView > implements IMogoIntentListener { + + IMogoIntentManager mIntentManager; public AppNavigatorPresenter( AppNavigatorView view ) { super( view ); @@ -22,59 +35,55 @@ public class AppNavigatorPresenter extends Presenter< AppNavigatorView > impleme @Override public void onCreate( @NonNull LifecycleOwner owner ) { super.onCreate( owner ); + mIntentManager = ( IMogoIntentManager ) ARouter.getInstance().build( MogoServicePaths.PATH_INTENT_MANAGER ).navigation( getContext() ); } @Override public void onResume( @NonNull LifecycleOwner owner ) { super.onResume( owner ); - AIAssist.getInstance( getContext() ).registerUnWakeupCommand( AppsConst.CMD_OPEN_APPS_PANEL, AppsConst.CMD_OPEN_APPS_PANEL_UN_WAKEUP_WORDS, this ); - AIAssist.getInstance( getContext() ).registerUnWakeupCommand( AppsConst.CMD_CLOSE_APPS_PANEL, AppsConst.CMD_CLOSE_APPS_PANEL_UN_WAKEUP_WORDS, this ); + mIntentManager.registerIntentListener( AppsConst.COMMAND_OPERATION, this ); } @Override public void onPause( @NonNull LifecycleOwner owner ) { super.onPause( owner ); - AIAssist.getInstance( getContext() ).unregisterUnWakeupCommand( AppsConst.CMD_OPEN_APPS_PANEL ); - AIAssist.getInstance( getContext() ).unregisterUnWakeupCommand( AppsConst.CMD_CLOSE_APPS_PANEL ); + mIntentManager.unregisterIntentListener( AppsConst.COMMAND_OPERATION ); } @Override - public void onCmdSelected( String cmd ) { - if ( mView == null ) { + public void onIntentReceived( String intentStr, Intent intent ) { + if ( !AppsConst.COMMAND_OPERATION.equals( intentStr ) ) { return; } - switch ( cmd ) { - case AppsConst.CMD_OPEN_APPS_PANEL: - mView.openAppsPanel(); - break; - case AppsConst.CMD_CLOSE_APPS_PANEL: - mView.closeAppsPanel(); - break; + try { + JSONObject object = new JSONObject( intent.getStringExtra( "data" ) ); + String app = object.optString( "object" ); + String operation = object.optString( "operation" ); + if ( AppsConst.OBJECT_ALL_APPS.equals( app ) ) { + if ( AppsConst.OPERATION_OPEN.equals( operation ) ) { + mView.openAppsPanel(); + } else if ( AppsConst.OPERATION_CLOSE.equals( operation ) ) { + mView.closeAppsPanel(); + } + } else if ( AppsConst.OBJECT_FAST_SETTINGS.equals( app ) ) { + if ( AppsConst.OPERATION_OPEN.equals( operation ) ) { + try { + LaunchUtils.launchByPkg( getContext(), AppsConst.APP_PKG_CAR_SETTINGS ); + } catch ( Exception e ) { + TipToast.shortTip( R.string.module_apps_str_no_app ); + } + } + } + } catch ( JSONException e ) { + e.printStackTrace(); } } - @Override - public void onCmdAction( String speakText ) { - - } - - @Override - public void onCmdCancel( String speakText ) { - - } - - @Override - public void onSpeakEnd( String speakText ) { - - } - - @Override - public void onSpeakSelectTimeOut( String speakText ) { - - } - @Override public void onDestroy( @NonNull LifecycleOwner owner ) { + if ( mIntentManager != null ) { + mIntentManager.unregisterIntentListener( AppsConst.COMMAND_OPERATION ); + } super.onDestroy( owner ); } } diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsConst.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsConst.java index aea6b2cad4..142822b9d5 100644 --- a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsConst.java +++ b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsConst.java @@ -8,17 +8,16 @@ package com.mogo.module.apps; */ public class AppsConst { + /** + * 打开/关闭全部应用、打开/关闭车辆设置 + */ + public static final String COMMAND_OPERATION = "system.application.operation"; + /** * 每页显示多少个app */ public static final int TOTAL_SIZE_EACH_PAGE = 12; - public static final String CMD_OPEN_APPS_PANEL = "CMD_OPEN_APPS_PANEL"; - public static final String[] CMD_OPEN_APPS_PANEL_UN_WAKEUP_WORDS = {"打开全部应用"}; - - public static final String CMD_CLOSE_APPS_PANEL = "CMD_CLOSE_APPS_PANEL"; - public static final String[] CMD_CLOSE_APPS_PANEL_UN_WAKEUP_WORDS = {"关闭全部应用"}; - /** * 媒体跳转 */ @@ -27,4 +26,11 @@ public class AppsConst { * 车辆设置跳转 */ public static final String APP_PKG_CAR_SETTINGS = "com.zhidao.settings"; + + public static final String OBJECT_ALL_APPS = "全部应用"; + public static final String OBJECT_FAST_SETTINGS = "快捷设置"; + public static final String OPERATION_OPEN = "打开"; + public static final String OPERATION_CLOSE = "关闭"; + + }