抽离分享模块中的唤醒词和免唤醒指令,取消分享模块的baseModule

This commit is contained in:
tongchenfei
2020-10-20 20:21:06 +08:00
parent d0b0cc1236
commit d158ab5ba2
8 changed files with 150 additions and 94 deletions

View File

@@ -7,7 +7,6 @@ package com.mogo.module.service.unwake;
*/
public class GlobalUnwakeConst {
public static final String MODULE_NAME = "GlobalUnwakeManager";
public static final String PATH_NAME = "/global/unwake";
// command
public static final String VOICE_CMD_GO_TO_SHARE = "com.zhidao.share";
@@ -38,6 +37,10 @@ public class GlobalUnwakeConst {
*/
public static final String UNWAKE_UPLOAD_REAL_TIME_TRAFFIC = "command_upload_real_time_traffic";
/**
* 唤醒词查询热心指数
*/
public static final String VOICE_QUERY_HEART_INDEX = "com.zhidao.query.myshare.index";
// 词
public static final String[] UPLOAD_REAL_TIME_TRAFFIC = {"上报实时路况", "上报路况"};

View File

@@ -2,11 +2,14 @@ package com.mogo.module.service.unwake;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.facade.template.IProvider;
import com.mogo.commons.voice.AIAssist;
import com.mogo.commons.voice.IMogoVoiceCmdCallBack;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.intent.IMogoIntentListener;
import com.mogo.service.intent.IMogoIntentManager;
import com.mogo.utils.logger.Logger;
@@ -19,18 +22,23 @@ import static com.mogo.module.service.unwake.GlobalUnwakeConst.VOICE_CMD_NO_REPL
import static com.mogo.module.service.unwake.GlobalUnwakeConst.VOICE_CMD_PUB_ROAD_CONDITION;
import static com.mogo.module.service.unwake.GlobalUnwakeConst.VOICE_CMD_PUB_TROUBLE_HELP;
import static com.mogo.module.service.unwake.GlobalUnwakeConst.VOICE_CMD_SHARE_DIALOG_CLOSE;
import static com.mogo.module.service.unwake.GlobalUnwakeConst.VOICE_QUERY_HEART_INDEX;
/**
* 全局免唤醒管理
* 包括唤醒词指令和全局免唤醒词指令
* 有几个Module仅仅是因为要注册全局免唤醒词加到了BaseModule中为了将这部分Module从BaseModule中去掉特抽离全局免唤醒词注册监听逻辑
*
* @author tongchenfei
*/
@Route(path = MogoServicePaths.PATH_GLOBAL_UNWAKE)
public class GlobalUnwakeManager implements IProvider, IMogoIntentListener, IMogoVoiceCmdCallBack {
private IMogoIntentManager intentManager;
private Context context;
private static final String TAG = "GlobalUnwakeManager";
@Override
public void init(Context context) {
Logger.d(TAG, "全局免唤醒模块初始化====");
intentManager = MogoApisHandler.getInstance().getApis().getIntentManagerApi();
intentManager.registerIntentListener(VOICE_CMD_GO_TO_SHARE, this);
intentManager.registerIntentListener(VOICE_CMD_PUB_TROUBLE_HELP, this);
@@ -49,9 +57,31 @@ public class GlobalUnwakeManager implements IProvider, IMogoIntentListener, IMog
// 此处只接受处理语音相关广播
Logger.d(TAG, "收到唤醒词指令: " + intentStr);
switch (intentStr) {
// 分享相关唤醒词
case VOICE_CMD_GO_TO_SHARE:
case VOICE_CMD_PUB_TROUBLE_HELP:
case VOICE_CMD_PUB_ROAD_CONDITION:
case VOICE_CMD_SHARE_DIALOG_CLOSE:
case VOICE_CMD_NO_REPLY_SHARE_DIALOG_CLOSE:
case UNWAKE_UPLOAD_ROAD_CONDITION:
MogoApisHandler.getInstance().getApis().getShareManager().onGlobalUnwake(intentStr, intent);
break;
case VOICE_QUERY_HEART_INDEX:
Intent start = new Intent( Intent.ACTION_VIEW );
start.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK );
start.setData( Uri.parse( "mogo://launcher/main/switch2?type=showSharePanel" ) );
context.startActivity( start );
break;
default:
break;
}
}
@Override
public void onCmdSelected(String cmd) {
Logger.d(TAG, "收到免唤醒词指令: " + cmd);
if (UNWAKE_UPLOAD_REAL_TIME_TRAFFIC.equals(cmd)) {
MogoApisHandler.getInstance().getApis().getShareManager().onGlobalUnwake(cmd, null);
}
}
}