[语音] 查询事件面板 等语音指令定义替换

This commit is contained in:
liujing
2020-11-17 16:29:13 +08:00
parent 012abd52bc
commit 096c3b922a
7 changed files with 128 additions and 76 deletions

View File

@@ -39,6 +39,8 @@ public class SchemeIntent implements IMogoStatusChangedListener {
public static final String TYPE_SHOW_ONLINE_CAR_PANEL = "showOnlineCarPanel";
public static final String TYPE_SHOW_SHARE_PANEL = "showSharePanel";
public static final String TYPE_SHOW_HISTORY_PANEL = "showHistoryPanel";
public static final String TYPE_SHOW_SURROUNDING_PANEL = "showSurroundingPanel";
private IMogoServiceApis mApis;
private Context mContext;
@@ -49,7 +51,7 @@ public class SchemeIntent implements IMogoStatusChangedListener {
public Intent mIntent;
public long mDelay = 0L;
public IntentWrapper( Intent intent, long delay ) {
public IntentWrapper(Intent intent, long delay) {
this.mIntent = intent;
this.mDelay = delay;
}
@@ -61,9 +63,9 @@ public class SchemeIntent implements IMogoStatusChangedListener {
}
public static SchemeIntent getInstance() {
if ( sInstance == null ) {
synchronized ( SchemeIntent.class ) {
if ( sInstance == null ) {
if (sInstance == null) {
synchronized (SchemeIntent.class) {
if (sInstance == null) {
sInstance = new SchemeIntent();
}
}
@@ -75,14 +77,14 @@ public class SchemeIntent implements IMogoStatusChangedListener {
sInstance = null;
}
public void init( Context context, IMogoServiceApis apis ) {
public void init(Context context, IMogoServiceApis apis) {
mContext = context;
mApis = apis;
mApis.getStatusManagerApi().registerStatusChangedListener( TAG, StatusDescriptor.MAIN_PAGE_RESUME, this );
mApis.getStatusManagerApi().registerStatusChangedListener(TAG, StatusDescriptor.MAIN_PAGE_RESUME, this);
}
public void clear() {
mApis.getStatusManagerApi().unregisterStatusChangedListener( TAG, StatusDescriptor.MAIN_PAGE_RESUME, this );
mApis.getStatusManagerApi().unregisterStatusChangedListener(TAG, StatusDescriptor.MAIN_PAGE_RESUME, this);
mContext = null;
mApis = null;
@@ -90,38 +92,39 @@ public class SchemeIntent implements IMogoStatusChangedListener {
/**
* 处理scheme
* @param intent 跳转的intent
*
* @param intent 跳转的intent
* @param isOnNewIntent 根据这个参数判断是从onCreate过来还是从onNewIntent过来从而可以在{@link #isDelay(Intent, boolean)}里面确定延时逻辑如果是从onNewIntent过来是不需要延时的
*/
public void handle( Intent intent, boolean isOnNewIntent ) {
if ( intent == null || intent.getData() == null ) {
public void handle(Intent intent, boolean isOnNewIntent) {
if (intent == null || intent.getData() == null) {
return;
}
Uri target = intent.getData();
String path = target.getPath();
if ( path == null || path.isEmpty() ) {
if (path == null || path.isEmpty()) {
return;
}
if ( !mApis.getStatusManagerApi().isMainPageOnResume() ) {
if (!mApis.getStatusManagerApi().isMainPageOnResume()) {
long delay = 0L;
if ( isDelay( intent, isOnNewIntent ) ) {
if (isDelay(intent, isOnNewIntent)) {
delay = 5_000L;
}
mNextIntent = new IntentWrapper( intent, delay );
mApis.getLauncherApi().backToLauncher( mContext );
mNextIntent = new IntentWrapper(intent, delay);
mApis.getLauncherApi().backToLauncher(mContext);
return;
}
switch ( path ) {
switch (path) {
case "/main/switch2":
handleSwitch2Action( target );
handleSwitch2Action(target);
break;
case "/main/share":
Logger.d( TAG, "收到打开分享框的scheme准备打开分享框" );
Map< String, Object > properties = new HashMap<>();
properties.put( "from", "1" );
mApis.getAnalyticsApi().track( "v2x_share_click", properties );
Logger.d(TAG, "收到打开分享框的scheme准备打开分享框");
Map<String, Object> properties = new HashMap<>();
properties.put("from", "1");
mApis.getAnalyticsApi().track("v2x_share_click", properties);
mApis.getShareManager().showShareDialog();
break;
default:
@@ -132,34 +135,38 @@ public class SchemeIntent implements IMogoStatusChangedListener {
mNextIntent = null;
}
private boolean isDelay(Intent intent, boolean isOnNewIntent ) {
if ( isOnNewIntent || intent == null || intent.getData() == null ) {
private boolean isDelay(Intent intent, boolean isOnNewIntent) {
if (isOnNewIntent || intent == null || intent.getData() == null) {
return false;
}
Uri target = intent.getData();
String type = target.getQueryParameter( "type" );
String type = target.getQueryParameter("type");
return TextUtils.equals(TYPE_NAVI, type) || TextUtils.equals(TYPE_SHOW_SHARE_PANEL, type);
}
private void handleSwitch2Action( Uri target ) {
String type = target.getQueryParameter( "type" );
if ( TextUtils.isEmpty( type ) ) {
private void handleSwitch2Action(Uri target) {
String type = target.getQueryParameter("type");
if (TextUtils.isEmpty(type)) {
return;
}
switch ( type ) {
switch (type) {
case TYPE_NAVI:
handleNaviIntent( target );
handleNaviIntent(target);
break;
case TYPE_LAUNCH:
handleLaunchIntent( target );
handleLaunchIntent(target);
break;
case TYPE_SEARCH_ROAD_CONDITION:
handleSearchRoadCondition( target );
handleSearchRoadCondition(target);
break;
case TYPE_SHOW_ONLINE_CAR_PANEL:
handleShowOnlineCarPanel( target );
handleShowOnlineCarPanel(target);
case TYPE_SHOW_HISTORY_PANEL:
handleShowSharePanel(0);
case TYPE_SHOW_SURROUNDING_PANEL:
handleShowSharePanel(1);
case TYPE_SHOW_SHARE_PANEL:
handleShowSharePanel();
handleShowSharePanel(2);
break;
default:
break;
@@ -167,71 +174,71 @@ public class SchemeIntent implements IMogoStatusChangedListener {
}
}
private void handleSearchRoadCondition( Uri target ) {
if ( mApis == null ) {
private void handleSearchRoadCondition(Uri target) {
if (mApis == null) {
return;
}
Log.d("TanluManager", "handleSearchRoadCondition intentStr =" + target.getQueryParameter( "intentStr" ) + ">> data = " + target.getQueryParameter( "data" )
+ "-----city = " + target.getQueryParameter( "city" ) + "----keywords = " + target.getQueryParameter( "keywords" ));
mApis.getTanluUiApi().searchRoadCondition( target.getQueryParameter( "intentStr" ),
target.getQueryParameter( "data" ), target.getQueryParameter( "city" ),
target.getQueryParameter( "keywords" ) );
Log.d("TanluManager", "handleSearchRoadCondition intentStr =" + target.getQueryParameter("intentStr") + ">> data = " + target.getQueryParameter("data")
+ "-----city = " + target.getQueryParameter("city") + "----keywords = " + target.getQueryParameter("keywords"));
mApis.getTanluUiApi().searchRoadCondition(target.getQueryParameter("intentStr"),
target.getQueryParameter("data"), target.getQueryParameter("city"),
target.getQueryParameter("keywords"));
}
private void handleNaviIntent( Uri naviUri ) {
if ( mApis == null ) {
private void handleNaviIntent(Uri naviUri) {
if (mApis == null) {
return;
}
String lon = naviUri.getQueryParameter( "lon" );
String lat = naviUri.getQueryParameter( "lat" );
String lon = naviUri.getQueryParameter("lon");
String lat = naviUri.getQueryParameter("lat");
try {
double dlon = Double.valueOf( lon );
double dlat = Double.valueOf( lat );
if ( mApis.getMapServiceApi().getNavi( mContext ).isNaviing() ) {
mApis.getMapServiceApi().getNavi( mContext ).naviTo( new MogoLatLng( dlat, dlon ) );
double dlon = Double.valueOf(lon);
double dlat = Double.valueOf(lat);
if (mApis.getMapServiceApi().getNavi(mContext).isNaviing()) {
mApis.getMapServiceApi().getNavi(mContext).naviTo(new MogoLatLng(dlat, dlon));
} else {
mApis.getSearchManagerApi().calculatePath( new MogoLatLng( dlat, dlon ) );
mApis.getSearchManagerApi().calculatePath(new MogoLatLng(dlat, dlon));
}
} catch ( Exception e ) {
TipToast.shortTip( "目的地异常,不能导航" );
Logger.e( TAG, e, "error." );
} catch (Exception e) {
TipToast.shortTip("目的地异常,不能导航");
Logger.e(TAG, e, "error.");
}
}
private void handleLaunchIntent( Uri uri ) {
String type = uri.getQueryParameter( "channelType" );
Map< String, Object > properties = new HashMap<>();
properties.put( "appname", CommonUtils.getAppName( mContext ) );
properties.put( "appversion", CommonUtils.getVersionName( mContext ) );
properties.put( "from", type );
mApis.getAnalyticsApi().track( "appenterfront", properties );
private void handleLaunchIntent(Uri uri) {
String type = uri.getQueryParameter("channelType");
Map<String, Object> properties = new HashMap<>();
properties.put("appname", CommonUtils.getAppName(mContext));
properties.put("appversion", CommonUtils.getVersionName(mContext));
properties.put("from", type);
mApis.getAnalyticsApi().track("appenterfront", properties);
}
private void handleShowOnlineCarPanel( Uri uri ) {
private void handleShowOnlineCarPanel(Uri uri) {
mApis.getOnlineCarPanelApi().showPanel();
}
private void handleShowSharePanel() {
private void handleShowSharePanel(int item) {
Logger.d(TAG, "handleShowSharePanel");
// todo 跳转到热心指数
mApis.getEventPanelManager().showPanelWithSelectedItem(2);
mApis.getEventPanelManager().showPanelWithSelectedItem(item);
}
@Override
public void onStatusChanged( StatusDescriptor descriptor, boolean isTrue ) {
if ( descriptor == StatusDescriptor.MAIN_PAGE_RESUME ) {
if ( mNextIntent == null ) {
public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) {
if (descriptor == StatusDescriptor.MAIN_PAGE_RESUME) {
if (mNextIntent == null) {
return;
}
if ( isTrue ) {
if (isTrue) {
// 保证回到桌面后在开始该规划路线。
UiThreadHandler.postDelayed( () -> {
if ( mNextIntent == null ) {
UiThreadHandler.postDelayed(() -> {
if (mNextIntent == null) {
return;
}
handle( mNextIntent.mIntent, false );
}, mNextIntent.mDelay );
handle(mNextIntent.mIntent, false);
}, mNextIntent.mDelay);
}
}
}