opt
This commit is contained in:
@@ -177,10 +177,6 @@ public class AppNavigatorFragment extends MvpFragment<AppNavigatorView, AppNavig
|
||||
mMogoAnalytics.track("Launcher_APP_Icon", properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeAppsPanel() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
|
||||
@@ -7,6 +7,8 @@ import androidx.lifecycle.LifecycleOwner;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.commons.voice.IMogoVoiceCmdCallBack;
|
||||
import com.mogo.module.apps.model.AppsModel;
|
||||
import com.mogo.module.apps.utils.LaunchUtils;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
@@ -24,7 +26,7 @@ import org.json.JSONObject;
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class AppNavigatorPresenter extends Presenter< AppNavigatorView > implements IMogoIntentListener {
|
||||
public class AppNavigatorPresenter extends Presenter< AppNavigatorView > implements IMogoIntentListener, IMogoVoiceCmdCallBack {
|
||||
|
||||
private static final String TAG = "AppNavigatorPresenter";
|
||||
|
||||
@@ -41,12 +43,14 @@ public class AppNavigatorPresenter extends Presenter< AppNavigatorView > impleme
|
||||
mIntentManager = ( IMogoIntentManager ) ARouter.getInstance().build( MogoServicePaths.PATH_INTENT_MANAGER ).navigation( getContext() );
|
||||
mMogoStatusManager = ( IMogoStatusManager ) ARouter.getInstance().build( MogoServicePaths.PATH_STATUS_MANAGER ).navigation( getContext() );
|
||||
// 预加载应用列表,空间换时间
|
||||
AppsModel.getInstance(getContext()).load( null );
|
||||
AppsModel.getInstance( getContext() ).load( null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume( @NonNull LifecycleOwner owner ) {
|
||||
super.onResume( owner );
|
||||
AIAssist.getInstance( getContext() ).registerUnWakeupCommand( AppsConst.CMD_UN_WAKE_OPEN_APP_LIST, AppsConst.CMD_UN_WAKE_WORDS_OPEN_APP_LIST, this );
|
||||
AIAssist.getInstance( getContext() ).registerUnWakeupCommand( AppsConst.CMD_UN_WAKE_OPEN_CAR_SETTINGS, AppsConst.CMD_UN_WAKE_WORDS_OPEN_CAR_SETTINGS, this );
|
||||
mIntentManager.registerIntentListener( AppsConst.COMMAND_OPERATION, this );
|
||||
}
|
||||
|
||||
@@ -54,6 +58,8 @@ public class AppNavigatorPresenter extends Presenter< AppNavigatorView > impleme
|
||||
public void onPause( @NonNull LifecycleOwner owner ) {
|
||||
super.onPause( owner );
|
||||
mIntentManager.unregisterIntentListener( AppsConst.COMMAND_OPERATION, this );
|
||||
AIAssist.getInstance( getContext() ).unregisterUnWakeupCommand( AppsConst.CMD_UN_WAKE_OPEN_APP_LIST );
|
||||
AIAssist.getInstance( getContext() ).unregisterUnWakeupCommand( AppsConst.CMD_UN_WAKE_OPEN_CAR_SETTINGS );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -83,6 +89,42 @@ public class AppNavigatorPresenter extends Presenter< AppNavigatorView > impleme
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCmdSelected( String cmd ) {
|
||||
switch ( cmd ) {
|
||||
case AppsConst.CMD_UN_WAKE_OPEN_APP_LIST:
|
||||
mView.openAppsPanel();
|
||||
break;
|
||||
case AppsConst.CMD_UN_WAKE_OPEN_CAR_SETTINGS:
|
||||
try {
|
||||
LaunchUtils.launchByPkg( getContext(), AppsConst.APP_PKG_CAR_SETTINGS );
|
||||
} catch ( Exception e ) {
|
||||
TipToast.shortTip( R.string.module_apps_str_no_app );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@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 ) {
|
||||
|
||||
@@ -15,9 +15,4 @@ public interface AppNavigatorView extends IView {
|
||||
* 打开全部应用
|
||||
*/
|
||||
void openAppsPanel();
|
||||
|
||||
/**
|
||||
* 关闭全部应用
|
||||
*/
|
||||
void closeAppsPanel();
|
||||
}
|
||||
|
||||
@@ -18,10 +18,6 @@ public class AppsConst {
|
||||
*/
|
||||
public static final int TOTAL_SIZE_EACH_PAGE = 12;
|
||||
|
||||
/**
|
||||
* 媒体跳转
|
||||
*/
|
||||
public static final String APP_PKG_MUSIC = "com.pvetec.musics";
|
||||
/**
|
||||
* 车辆设置跳转
|
||||
*/
|
||||
@@ -32,5 +28,13 @@ public class AppsConst {
|
||||
public static final String OPERATION_OPEN = "打开";
|
||||
public static final String OPERATION_CLOSE = "关闭";
|
||||
|
||||
public static final String CMD_UN_WAKE_OPEN_APP_LIST = "CMD_UN_WAKE_OPEN_APP_LIST";
|
||||
public static final String[] CMD_UN_WAKE_WORDS_OPEN_APP_LIST = new String[]{"打开全部应用"};
|
||||
|
||||
public static final String CMD_UN_WAKE_CLOSE_APP_LIST = "CMD_UN_WAKE_CLOSE_APP_LIST";
|
||||
public static final String[] CMD_UN_WAKE_WORDS_CLOSE_APP_LIST = new String[]{"关闭全部应用"};
|
||||
|
||||
public static final String CMD_UN_WAKE_OPEN_CAR_SETTINGS = "CMD_UN_WAKE_OPEN_CAR_SETTINGS";
|
||||
public static final String[] CMD_UN_WAKE_WORDS_OPEN_CAR_SETTINGS = new String[]{"打开快捷设置"};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package com.mogo.module.apps;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.commons.voice.IMogoVoiceCmdCallBack;
|
||||
import com.mogo.module.apps.utils.LaunchUtils;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
@@ -22,7 +25,7 @@ import org.json.JSONObject;
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class AppsListPresenter extends Presenter< AppsListView > implements IMogoIntentListener {
|
||||
public class AppsListPresenter extends Presenter< AppsListView > implements IMogoIntentListener, IMogoVoiceCmdCallBack {
|
||||
|
||||
private static final String TAG = "AppsListPresenter";
|
||||
|
||||
@@ -37,30 +40,59 @@ public class AppsListPresenter extends Presenter< AppsListView > implements IMog
|
||||
super.onCreate( owner );
|
||||
mIntentManager = ( IMogoIntentManager ) ARouter.getInstance().build( MogoServicePaths.PATH_INTENT_MANAGER ).navigation( getContext() );
|
||||
mIntentManager.registerIntentListener( AppsConst.COMMAND_OPERATION, this );
|
||||
AIAssist.getInstance( getContext() ).registerUnWakeupCommand( AppsConst.CMD_UN_WAKE_CLOSE_APP_LIST, AppsConst.CMD_UN_WAKE_WORDS_CLOSE_APP_LIST, this );
|
||||
AIAssist.getInstance( getContext() ).registerUnWakeupCommand( AppsConst.CMD_GLOBAL_UN_WAKEUP_CLOSE_APP_LIST, AppsConst.CMD_UN_WAKE_WORDS_CLOSE_APP_LIST, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIntentReceived( String intentStr, Intent intent ) {
|
||||
if ( !AppsConst.COMMAND_OPERATION.equals( intentStr ) ) {
|
||||
return;
|
||||
}
|
||||
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_CLOSE.equals( operation ) ) {
|
||||
mView.closeAppsPanel();
|
||||
if ( AppsConst.COMMAND_OPERATION.equals( intentStr ) ) {
|
||||
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_CLOSE.equals( operation ) ) {
|
||||
mView.closeAppsPanel();
|
||||
}
|
||||
}
|
||||
} catch ( JSONException e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch ( JSONException e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCmdSelected( String cmd ) {
|
||||
if ( TextUtils.equals( AppsConst.CMD_UN_WAKE_CLOSE_APP_LIST, cmd ) ) {
|
||||
mView.closeAppsPanel();
|
||||
}
|
||||
}
|
||||
|
||||
@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 ) {
|
||||
super.onDestroy( owner );
|
||||
mIntentManager.unregisterIntentListener( AppsConst.COMMAND_OPERATION, this );
|
||||
AIAssist.getInstance( getContext() ).unregisterUnWakeupCommand( AppsConst.CMD_UN_WAKE_CLOSE_APP_LIST );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user