add voice control
This commit is contained in:
@@ -32,6 +32,15 @@ public class ExtensionsModuleConst {
|
||||
public static final String CANCLE_SHARE = "com.zhidao.launcher.cancle.share";
|
||||
public static final String CLOSE_PAGE = "com.zhidao.launcher.close.page";
|
||||
public static final String CLOSE = "com.zhidao.launcher.close";
|
||||
|
||||
//唤醒指令
|
||||
//分享路况/上报路况/上报拥堵/上报交通检查/上报封路 唤醒
|
||||
public static final String UPLOAD_ROAD_CONDITION_AWAKEN = "com.zhidao.pathfinder.report.roadCondition";
|
||||
//关闭分享框 唤醒
|
||||
public static final String SHARE_DIALOG_CLOSE = "com.zhidao.share.close";
|
||||
//我要分享
|
||||
public static final String GO_TO_SHARE = "com.zhidao.share";
|
||||
|
||||
/*** 分享 结束 **/
|
||||
|
||||
|
||||
@@ -58,4 +67,5 @@ public class ExtensionsModuleConst {
|
||||
public static final String LAUNCHER_SHARE_CLICK = "Launcher_Share_Click";
|
||||
public static final String CARNET_USER_UPLOAD = "CarNet_user_upload";
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.mogo.module.extensions.entrance;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
@@ -12,8 +14,12 @@ import com.mogo.module.extensions.ExtensionsModuleConst;
|
||||
import com.mogo.module.share.ShareControl;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.analytics.IMogoAnalytics;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.service.intent.IMogoIntentManager;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -27,13 +33,18 @@ public class EntrancePresenter extends Presenter<EntranceView> {
|
||||
|
||||
private Context mContext;
|
||||
private IMogoAnalytics mAnalytics;
|
||||
private static final String TAG = "EntrancePresenter";
|
||||
private IMogoIntentManager mogoIntentManager;
|
||||
|
||||
|
||||
public EntrancePresenter(Context context, EntranceView view) {
|
||||
super(view);
|
||||
mContext = context;
|
||||
mAnalytics = (IMogoAnalytics) ARouter.getInstance().build(MogoServicePaths.PATH_UTILS_ANALYTICS).navigation(getContext());
|
||||
mogoIntentManager = (IMogoIntentManager) ARouter.getInstance().build(MogoServicePaths.PATH_INTENT_MANAGER).navigation(getContext());
|
||||
|
||||
registerUnWake();
|
||||
registerAwakeVoice();
|
||||
}
|
||||
|
||||
private void registerUnWake() {
|
||||
@@ -48,8 +59,6 @@ public class EntrancePresenter extends Presenter<EntranceView> {
|
||||
ExtensionsModuleConst.CMD_TRAFFIC_CHECK, mogoVoiceListener);
|
||||
AIAssist.getInstance(mContext).registerUnWakeupCommand(ExtensionsModuleConst.UPLOAD_ROAD_CLOSURE,
|
||||
ExtensionsModuleConst.CMD_ROAD_CLOSURE, mogoVoiceListener);
|
||||
// AIAssist.getInstance(mContext).registerUnWakeupCommand(ExtensionsModuleConst.SHARE_OIL_PRICE,
|
||||
// ExtensionsModuleConst.CMD_SHARE_OIL_PRICE, mogoVoiceListener);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,8 +76,6 @@ public class EntrancePresenter extends Presenter<EntranceView> {
|
||||
uploadTrfficCheck();
|
||||
} else if (cmd.equals(ExtensionsModuleConst.UPLOAD_ROAD_CLOSURE)) { //上报封路
|
||||
uploadRoadClosed();
|
||||
// } else if (cmd.equals(ExtensionsModuleConst.SHARE_OIL_PRICE)) { //分享油价
|
||||
// shareOilPrice();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,6 +96,62 @@ public class EntrancePresenter extends Presenter<EntranceView> {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 注册唤醒命令
|
||||
*/
|
||||
private void registerAwakeVoice() {
|
||||
mogoIntentManager.registerIntentListener(ExtensionsModuleConst.GO_TO_SHARE, mogoIntentListener);
|
||||
mogoIntentManager.registerIntentListener(ExtensionsModuleConst.SHARE_DIALOG_CLOSE, mogoIntentListener);
|
||||
mogoIntentManager.registerIntentListener(ExtensionsModuleConst.UPLOAD_ROAD_CONDITION_AWAKEN, mogoIntentListener);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 唤醒语音
|
||||
*/
|
||||
private IMogoIntentListener mogoIntentListener = new IMogoIntentListener() {
|
||||
@Override
|
||||
public void onIntentReceived(String intentStr, Intent intent) {
|
||||
String data = intent.getStringExtra("data");
|
||||
Logger.d(TAG, "唤醒 mogoIntentListener intentStr =" + intentStr + ">>data =" + data);
|
||||
if (intentStr.equals(ExtensionsModuleConst.GO_TO_SHARE)) { //我要分享 --ok
|
||||
String conditionData = intent.getStringExtra("data");
|
||||
Log.d(TAG, "唤醒 mogoIntentListener intentStr =" + intentStr + ">>conditionData =" + conditionData);
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(data);
|
||||
String typeString = jsonObject.get("ob").toString();
|
||||
Log.d(TAG, "mogoIntentListener specified typeString = " + typeString);
|
||||
if (!TextUtils.isEmpty(typeString)) {
|
||||
if (typeString.equals("封路")) {
|
||||
Log.d(TAG, "mogoIntentListener 封路 -------> ");
|
||||
uploadRoadClosed();
|
||||
} else if (typeString.equals("油价")) {
|
||||
Log.d(TAG, "mogoIntentListener 油价 -------> ");
|
||||
shareOilPrice();
|
||||
} else if (typeString.equals("交通检查")) {
|
||||
Log.d(TAG, "mogoIntentListener 交通检查 -------> ");
|
||||
uploadTrfficCheck();
|
||||
}
|
||||
} else {
|
||||
ShareControl.getInstance(mContext).showDialog();
|
||||
Log.d(TAG, "mogoIntentListener 我要分享 ----> ");
|
||||
traceData("2");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if (intentStr.equals(ExtensionsModuleConst.UPLOAD_ROAD_CONDITION_AWAKEN)) {
|
||||
//分享路况/上报路况/上报拥堵 唤醒
|
||||
Log.d(TAG, "mogoIntentListener 分享路况 唤醒 ----> ");
|
||||
uploadRoadCondition();
|
||||
} else if (intentStr.equals(ExtensionsModuleConst.SHARE_DIALOG_CLOSE)) { //关闭分享框 唤醒
|
||||
ShareControl.getInstance(mContext).dismissDialog();
|
||||
Log.d(TAG, "mogoIntentListener 关闭分享框 唤醒 ----> ");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private void uploadRoadCondition() {
|
||||
traceTanluData("2");
|
||||
sendShareReceiver("1");
|
||||
@@ -97,13 +160,6 @@ public class EntrancePresenter extends Presenter<EntranceView> {
|
||||
ShareControl.getInstance(mContext).dismissDialog();
|
||||
}
|
||||
|
||||
private void shareOilPrice() {
|
||||
Intent intent = new Intent();
|
||||
intent.setData(Uri.parse("freshthing://com.zhidao.fresh.things/shareOilPrice"));
|
||||
mContext.startActivity(intent);
|
||||
traceTypeData("2");
|
||||
}
|
||||
|
||||
private void uploadTrfficCheck() {
|
||||
sendShareReceiver("2");
|
||||
Logger.d("EntrancePresenter", "mogoIntentListener 分享交通检查 ----> ");
|
||||
@@ -118,6 +174,25 @@ public class EntrancePresenter extends Presenter<EntranceView> {
|
||||
ShareControl.getInstance(mContext).dismissDialog();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分享/上报按钮点击 from=1 手动点击 from=2 语音打开
|
||||
*
|
||||
* @param from
|
||||
*/
|
||||
private void traceData(String from) {
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
properties.put("from", from);
|
||||
mAnalytics.track(ExtensionsModuleConst.LAUNCHER_SHARE_CLICK, properties);
|
||||
}
|
||||
|
||||
private void shareOilPrice() {
|
||||
Intent intent = new Intent();
|
||||
intent.setData(Uri.parse("freshthing://com.zhidao.fresh.things/shareOilPrice"));
|
||||
getContext().startActivity(intent);
|
||||
traceTypeData("2");
|
||||
ShareControl.getInstance(mContext).dismissDialog();
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送广播 1拥堵,2交通检查,3封路
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user