准备接入语音
This commit is contained in:
@@ -4,22 +4,49 @@ import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.mogo.module.share.constant.ShareConstants
|
||||
import com.mogo.module.share.constant.ShareConstants.VOICE_CMD_PUB_TROUBLE_HELP
|
||||
import com.mogo.module.share.constant.ShareConstants.*
|
||||
import com.mogo.module.share.manager.UploadHelper
|
||||
import com.mogo.utils.logger.Logger
|
||||
|
||||
/**
|
||||
* 用于接收唤醒词指令,现在只接收 com.zhidao.speech.awake.notify 这一条广播
|
||||
*/
|
||||
class ShareVoiceCmdReceiver : BroadcastReceiver() {
|
||||
private val TAG = "ShareVoiceCmdReceiver"
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
// 接收唤醒词指令
|
||||
val command = intent.getStringExtra("command")
|
||||
Logger.d("ShareCmdReceiver", "收到唤醒词指令: $command")
|
||||
if (command == VOICE_CMD_PUB_TROUBLE_HELP) {
|
||||
// 开启服务,准备上报求助
|
||||
val seekHelp = Intent(context, VoiceCmdService::class.java)
|
||||
seekHelp.putExtra(ShareConstants.VOICE_CMD_SERVICE_EVENT_KEY, ShareConstants.VOICE_CMD_SERVICE_SEEK_HELP)
|
||||
context.startService(seekHelp)
|
||||
val command = intent.getStringExtra("command")?:""
|
||||
Logger.d(TAG, "收到唤醒词指令: $command")
|
||||
when (command) {
|
||||
VOICE_CMD_PUB_TROUBLE_HELP -> {
|
||||
// 开启服务,准备上报求助
|
||||
val seekHelp = Intent(context, VoiceCmdService::class.java)
|
||||
seekHelp.putExtra(ShareConstants.VOICE_CMD_SERVICE_EVENT_KEY, ShareConstants.VOICE_CMD_SERVICE_SEEK_HELP)
|
||||
context.startService(seekHelp)
|
||||
}
|
||||
VOICE_CMD_GO_TO_SHARE ->{
|
||||
when (intent.getStringExtra("ob") ?: "") {
|
||||
"积水"->{
|
||||
UploadHelper.upload(context, TYPE_STAGNANT_WATER)
|
||||
}
|
||||
"积冰"->{
|
||||
UploadHelper.upload(context, TYPE_ROAD_ICY)
|
||||
}
|
||||
"大雾"->{
|
||||
UploadHelper.upload(context, TYPE_DENSE_FOG)
|
||||
}
|
||||
"事故"->{
|
||||
UploadHelper.upload(context, TYPE_ACCIDENT)
|
||||
}
|
||||
}
|
||||
}
|
||||
VOICE_CMD_PUB_ROAD_CONDITION->{
|
||||
if(intent.getStringExtra("ob")?:"" == "路况") {
|
||||
// 上报实时路况
|
||||
Logger.d(TAG, "分享框准备触发上报实时路况")
|
||||
UploadHelper.upload(context, TYPE_REAL_TIME_TRAFFIC)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,4 +6,4 @@ package com.mogo.module.share.bean
|
||||
* @param icon 分享按钮图标资源,暂时用不到,默认为空,以后如果引入服务端配置按钮,图片资源可以用这个参数
|
||||
* @param iconRes 分享按钮图标本地资源id,默认是-1
|
||||
*/
|
||||
data class ShareBtn(var type: Int, var icon: String = "", var iconRes: Int = -1, var content: String)
|
||||
data class ShareBtn(var type: String, var icon: String = "", var iconRes: Int = -1, var content: String)
|
||||
|
||||
@@ -19,15 +19,22 @@ public class ShareConstants {
|
||||
public static final String VOICE_CMD_SERVICE_EVENT_KEY = "type";
|
||||
public static final int VOICE_CMD_SERVICE_SEEK_HELP = 1;
|
||||
|
||||
// 此处只记录了事故、实时路况、道路积水、道路结冰、浓雾,至于拥堵、交通检查和封路是在extention模块里面管理
|
||||
public static final String VOICE_CMD_PUB_TROUBLE_HELP = "com.zhidao.auxiliaryDriving.pubTroubleHelp";
|
||||
public static final String VOICE_CMD_GO_TO_SHARE = "com.zhidao.share";
|
||||
/**
|
||||
* 这个是实时路况,不是拥堵,拥堵放在了extention模块里面处理
|
||||
*/
|
||||
public static final String VOICE_CMD_PUB_ROAD_CONDITION = "com.zhidao.pathfinder.report" +
|
||||
".roadCondition";
|
||||
|
||||
public static final int TYPE_BLOCK = 1;
|
||||
public static final int TYPE_TRAFFIC_CHECK = 2;
|
||||
public static final int TYPE_CLOSURE = 3;
|
||||
public static final int TYPE_ACCIDENT = 4;
|
||||
public static final int TYPE_REAL_TIME_TRAFFIC = 5;
|
||||
public static final int TYPE_SEEK_HELP = 6;
|
||||
public static final int TYPE_STAGNANT_WATER = 7;
|
||||
public static final int TYPE_ROAD_ICY = 8;
|
||||
public static final int TYPE_DENSE_FOG = 9;
|
||||
public static final String TYPE_BLOCK = "1";
|
||||
public static final String TYPE_TRAFFIC_CHECK = "2";
|
||||
public static final String TYPE_CLOSURE = "3";
|
||||
public static final String TYPE_ACCIDENT = "10013";
|
||||
public static final String TYPE_REAL_TIME_TRAFFIC = "10015";
|
||||
public static final String TYPE_SEEK_HELP = "6";
|
||||
public static final String TYPE_STAGNANT_WATER = "10008";
|
||||
public static final String TYPE_ROAD_ICY = "10011";
|
||||
public static final String TYPE_DENSE_FOG = "10010";
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.mogo.module.share.constant.ShareConstants;
|
||||
import com.mogo.module.share.listener.OnShareBtnClickListener;
|
||||
import com.mogo.module.share.manager.ISeekHelpListener;
|
||||
import com.mogo.module.share.manager.SeekHelpManager;
|
||||
import com.mogo.module.share.manager.UploadHelper;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.analytics.IMogoAnalytics;
|
||||
@@ -106,19 +107,18 @@ public class LaucherShareDialog implements View.OnClickListener {
|
||||
|
||||
|
||||
private void initListener() {
|
||||
|
||||
adapter.setOnShareBtnClickListener(new OnShareBtnClickListener() {
|
||||
@Override
|
||||
public void onShareBtnClick(@NotNull ShareBtn shareBtn) {
|
||||
Logger.d(TAG,"分享按钮点击: "+shareBtn);
|
||||
// traceData("1");
|
||||
// if (shareBtn.getType() == ShareConstants.TYPE_SEEK_HELP) {
|
||||
// // 点击发起求助
|
||||
// SeekHelpManager.INSTANCE.seekHelp(mContext,seekListener,true);
|
||||
// }else{
|
||||
// sendShareReceiver(shareBtn.getType() + "");
|
||||
// dismiss();
|
||||
// }
|
||||
traceData("1");
|
||||
if (ShareConstants.TYPE_SEEK_HELP.equalsIgnoreCase(shareBtn.getType())) {
|
||||
// 点击发起求助
|
||||
SeekHelpManager.INSTANCE.seekHelp(mContext,seekListener,true);
|
||||
}else{
|
||||
sendShareReceiver(shareBtn.getType());
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -211,15 +211,7 @@ public class LaucherShareDialog implements View.OnClickListener {
|
||||
* 发送广播 1拥堵,2交通检查,3封路
|
||||
*/
|
||||
private void sendShareReceiver(String type) {
|
||||
mStatusManager.setUploadingStatus("CARD_TYPE_ROAD_CONDITION", true);
|
||||
|
||||
Logger.d("LaucherShareDialog", "LaucherShareDialog sendShareReceiver ---->");
|
||||
Intent intent = new Intent();
|
||||
intent.setAction("com.zhidao.roadcondition.share");
|
||||
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
intent.putExtra("type", type);
|
||||
mContext.sendBroadcast(intent);
|
||||
UploadHelper.INSTANCE.upload(mContext, type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.mogo.module.share.manager
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.mogo.module.share.ShareControl
|
||||
import com.mogo.module.share.dialog.LaucherShareDialog
|
||||
import com.mogo.utils.logger.Logger
|
||||
|
||||
/**
|
||||
* 上报工具类
|
||||
*/
|
||||
object UploadHelper {
|
||||
fun upload(context:Context, type: String) {
|
||||
ShareControl.getInstance(context).mogoServiceApis.statusManagerApi.setUploadingStatus("CARD_TYPE_ROAD_CONDITION", true)
|
||||
Logger.d("UploadHelper", "upload ---->")
|
||||
val intent = Intent()
|
||||
intent.action = "com.zhidao.roadcondition.share"
|
||||
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND)
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES)
|
||||
intent.putExtra("type", type)
|
||||
context.sendBroadcast(intent)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user