opt
This commit is contained in:
@@ -5,10 +5,14 @@ import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.map.IMogoMap;
|
||||
import com.mogo.map.IMogoUiSettings;
|
||||
import com.mogo.map.MogoMapView;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.voice.IMogoVoiceManager;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -23,6 +27,8 @@ public class MapFragment extends MvpFragment< MapView, MapPresenter > implements
|
||||
private MogoMapView mMogoMapView;
|
||||
private IMogoMap mMogoMap;
|
||||
|
||||
private IMogoVoiceManager mMogoVoiceManager;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.module_map_fragment_map;
|
||||
@@ -48,6 +54,8 @@ public class MapFragment extends MvpFragment< MapView, MapPresenter > implements
|
||||
mMogoMapView.onCreate( savedInstanceState );
|
||||
}
|
||||
initMapView();
|
||||
mMogoVoiceManager = ( IMogoVoiceManager ) ARouter.getInstance().build( MogoServicePaths.PATH_VOICE_MANAGER ).navigation( getContext() );
|
||||
mMogoVoiceManager.registerIntentListener( VoiceConstants.ACTION_GAODE_SDK_NAVI_RECV, mPresenter );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,14 +74,6 @@ public class MapFragment extends MvpFragment< MapView, MapPresenter > implements
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
if ( mMogoMapView != null ) {
|
||||
mMogoMapView.onDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLowMemory() {
|
||||
super.onLowMemory();
|
||||
@@ -109,4 +109,20 @@ public class MapFragment extends MvpFragment< MapView, MapPresenter > implements
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMapUIController getUIController() {
|
||||
return mMogoMap.getUIController();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
if ( mMogoMapView != null ) {
|
||||
mMogoMapView.onDestroy();
|
||||
}
|
||||
if ( mMogoVoiceManager != null ) {
|
||||
mMogoVoiceManager.unregisterIntentListener( VoiceConstants.ACTION_GAODE_SDK_NAVI_RECV );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
package com.mogo.module.map;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.commons.voice.IMogoVoiceCmdCallBack;
|
||||
import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.service.voice.IMogoVoiceListener;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -8,11 +19,185 @@ import com.mogo.commons.mvp.Presenter;
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class MapPresenter extends Presenter< MapView > {
|
||||
public class MapPresenter extends Presenter< MapView > implements IMogoVoiceListener, IMogoVoiceCmdCallBack {
|
||||
|
||||
|
||||
public MapPresenter( MapView view ) {
|
||||
super( view );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate( @NonNull LifecycleOwner owner ) {
|
||||
super.onCreate( owner );
|
||||
registerUnWakeupCmd();
|
||||
}
|
||||
|
||||
private void registerUnWakeupCmd() {
|
||||
AIAssist.getInstance( getContext() ).registerUnWakeupCommand( VoiceConstants.CMD_MAP_ZOOM_IN, VoiceConstants.CMD_MAP_ZOOM_IN_WAKE_UP_WORDS, this );
|
||||
AIAssist.getInstance( getContext() ).registerUnWakeupCommand( VoiceConstants.CMD_MAP_ZOOM_OUT, VoiceConstants.CMD_MAP_ZOOM_OUT_WAKE_UP_WORDS, this );
|
||||
AIAssist.getInstance( getContext() ).registerUnWakeupCommand( VoiceConstants.CMD_MAP_2D, VoiceConstants.CMD_MAP_2D_WAKE_UP_WORDS, this );
|
||||
AIAssist.getInstance( getContext() ).registerUnWakeupCommand( VoiceConstants.CMD_MAP_3D, VoiceConstants.CMD_MAP_3D_WAKE_UP_WORDS, this );
|
||||
AIAssist.getInstance( getContext() ).registerUnWakeupCommand( VoiceConstants.CMD_MAP_LIGHT_MODE, VoiceConstants.CMD_MAP_LIGHT_MODE_WAKE_UP_WORDS, this );
|
||||
AIAssist.getInstance( getContext() ).registerUnWakeupCommand( VoiceConstants.CMD_MAP_NIGHT_MODE, VoiceConstants.CMD_MAP_NIGHT_MODE_WAKE_UP_WORDS, this );
|
||||
AIAssist.getInstance( getContext() ).registerUnWakeupCommand( VoiceConstants.CMD_MAP_TRAFFIC_MODE, VoiceConstants.CMD_MAP_TRAFFIC_MODE_WAKE_UP_WORDS, this );
|
||||
AIAssist.getInstance( getContext() ).registerUnWakeupCommand( VoiceConstants.CMD_MAP_UN_TRAFFIC_MODE, VoiceConstants.CMD_MAP_UN_TRAFFIC_MODE_WAKE_UP_WORDS, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIntentReceived( String action, Intent intent ) {
|
||||
if ( !TextUtils.equals( action, VoiceConstants.ACTION_GAODE_SDK_NAVI_RECV ) ) {
|
||||
return;
|
||||
}
|
||||
int type = intent.getExtras().getInt( VoiceConstants.EXTRA_KEY_TYPE );
|
||||
Bundle data = intent.getExtras();
|
||||
switch ( type ) {
|
||||
case VoiceConstants.TYPE_START_NAVI:
|
||||
// actions.onStartNavi();
|
||||
break;
|
||||
case VoiceConstants.TYPE_STOP_NAVI:
|
||||
// actions.onStopNavi();
|
||||
break;
|
||||
case VoiceConstants.TYPE_NAVI_GUIDE_INFO:
|
||||
// actions.onSpeakNaviGuideInfo();
|
||||
break;
|
||||
case VoiceConstants.TYPE_MAP_UI_SETTING:
|
||||
final int actionType = data.getInt( VoiceConstants.EXTRA_TYPE, 0 );
|
||||
final int operateAction = data.getInt( VoiceConstants.EXTRA_OPERA, 0 );
|
||||
onMapUISetting( actionType, operateAction );
|
||||
break;
|
||||
case VoiceConstants.TYPE_NAVI_STRATEGY:
|
||||
// actions.onNaviStrategySetting( data.getInt( VoiceConstants.EXTRA_M, 1 ) );
|
||||
break;
|
||||
case VoiceConstants.TYPE_NAVI_OVERVIEW:
|
||||
final int overview = data.getInt( VoiceConstants.EXTRA_IS_SHOW, -1 );
|
||||
// if ( overview == 0 ) {
|
||||
// actions.onNaviOverview();
|
||||
// } else {
|
||||
// actions.onNaviContinue();
|
||||
// }
|
||||
break;
|
||||
case VoiceConstants.TYPE_NAVI_SPEAK:
|
||||
// actions.onNaviSpeak( data.getInt( VoiceConstants.EXTRA_MUTE, 0 ) );
|
||||
break;
|
||||
case VoiceConstants.TYPE_COMMON_ADDRESS_SETTING:
|
||||
// actions.onAddressSetting();
|
||||
break;
|
||||
case VoiceConstants.TYPE_COMMON_ADDRESS_CHANGED:
|
||||
// actions.onAddressUpdate();
|
||||
break;
|
||||
case VoiceConstants.TYPE_NAVI_ADD_POINT:
|
||||
// final int updateType = intent.getIntExtra( "TYPE", -1 );
|
||||
// final String name = intent.getStringExtra( "POINAME" );
|
||||
// final String address = intent.getStringExtra( "ADDRESS" );
|
||||
// final double lat = intent.getDoubleExtra( "LAT", 0.0 );
|
||||
// final double lng = intent.getDoubleExtra( "LON", 0.0 );
|
||||
// actions.onUpdateNaviPoint( updateType, name, address, lat, lng );
|
||||
break;
|
||||
case VoiceConstants.TYPE_SPEAK_NAVI_INFO:
|
||||
// actions.onSpeakPathRetainDistanceInfo();
|
||||
break;
|
||||
case VoiceConstants.TYPE_SPEAK_SPEED_LIMIT_INFO:
|
||||
// actions.onSpeakSpeedLimitInfo();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param actionType 0 - 实时路况
|
||||
* 1 - 地图缩放
|
||||
* 2 - 视图模式
|
||||
* 3 - 夜间模式
|
||||
* @param action actionType = 0 -> 0 - 开、1 - 关
|
||||
* actionType = 1 -> 0 - 放大地图、1 - 缩小地图
|
||||
* actionType = 2 -> 0 - 切换到2D车头朝上、1 - 切换2D正北模式、2 - 切换3D车头朝上
|
||||
* actionType = 3 -> 0 - 黑夜、1 - 正常
|
||||
*/
|
||||
public void onMapUISetting( int actionType, int action ) {
|
||||
switch ( actionType ) {
|
||||
case 0:
|
||||
if ( action == 0 ) {
|
||||
mView.getUIController().setTrafficEnabled( true );
|
||||
} else if ( action == 1 ) {
|
||||
mView.getUIController().setTrafficEnabled( false );
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if ( action == 0 ) {
|
||||
mView.getUIController().changeZoom( true );
|
||||
} else if ( action == 1 ) {
|
||||
mView.getUIController().changeZoom( false );
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if ( action == 0 ) {
|
||||
// 车头朝上,2D
|
||||
mView.getUIController().changeMapMode( EnumMapUI.CarUp_2D );
|
||||
} else if ( action == 1 ) {
|
||||
// 北朝上,2D
|
||||
mView.getUIController().changeMapMode( EnumMapUI.NorthUP_2D );
|
||||
} else if ( action == 2 ) {
|
||||
// 车头朝上,3D
|
||||
mView.getUIController().changeMapMode( EnumMapUI.CarUp_3D );
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if ( action == 0 ) {
|
||||
mView.getUIController().changeMapMode( EnumMapUI.Type_Night );
|
||||
} else if ( action == 1 ) {
|
||||
mView.getUIController().changeMapMode( EnumMapUI.Type_Light );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCmdSelected( String cmd ) {
|
||||
switch ( cmd ) {
|
||||
case VoiceConstants.CMD_MAP_TRAFFIC_MODE:
|
||||
onMapUISetting( 0, 0 );
|
||||
break;
|
||||
case VoiceConstants.CMD_MAP_UN_TRAFFIC_MODE:
|
||||
onMapUISetting( 0, 1 );
|
||||
break;
|
||||
case VoiceConstants.CMD_MAP_ZOOM_IN:
|
||||
onMapUISetting( 1, 0 );
|
||||
break;
|
||||
case VoiceConstants.CMD_MAP_ZOOM_OUT:
|
||||
onMapUISetting( 1, 1 );
|
||||
break;
|
||||
case VoiceConstants.CMD_MAP_2D:
|
||||
onMapUISetting( 2, 1 );
|
||||
break;
|
||||
case VoiceConstants.CMD_MAP_3D:
|
||||
onMapUISetting( 2, 2 );
|
||||
break;
|
||||
case VoiceConstants.CMD_MAP_LIGHT_MODE:
|
||||
onMapUISetting( 3, 1 );
|
||||
break;
|
||||
case VoiceConstants.CMD_MAP_NIGHT_MODE:
|
||||
onMapUISetting( 3, 0 );
|
||||
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 ) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.module.map;
|
||||
|
||||
import com.mogo.commons.mvp.IView;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -9,4 +10,11 @@ import com.mogo.commons.mvp.IView;
|
||||
* 地图view
|
||||
*/
|
||||
public interface MapView extends IView {
|
||||
|
||||
/**
|
||||
* 地图控制接口
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
IMogoMapUIController getUIController();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
package com.mogo.module.map;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-09
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class VoiceConstants {
|
||||
|
||||
// 同行者Adapter接受action
|
||||
public static final String ACTION_GAODE_SDK_NAVI_RECV = "ACTION_GAODE_SDK_NAVI_RECV";
|
||||
// 同行者Adapter发送action
|
||||
public static final String ACTION_GAODE_SDK_NAVI_SEND = "ACTION_GAODE_SDK_NAVI_SEND";
|
||||
|
||||
public static final String EXTRA_KEY_TYPE = "KEY_TYPE";
|
||||
public static final String EXTRA_TYPE = "EXTRA_TYPE";//操作地图
|
||||
public static final String EXTRA_OPERA = "EXTRA_OPERA";//操作地图
|
||||
public static final String EXTRA_MUTE = "EXTRA_MUTE";
|
||||
public static final String EXTRA_IS_SHOW = "EXTRA_IS_SHOW";//预览全路径还是继续导航
|
||||
public static final String EXTRA_M = "EXTRA_M";// 导航策略:1(避免收费) 3(不走高速) 4(躲避拥堵) 20 (高速优先)
|
||||
|
||||
/**
|
||||
* 直接导航
|
||||
*/
|
||||
public static final int TYPE_START_NAVI = 110009;
|
||||
|
||||
/**
|
||||
* 导航预览or继续导航
|
||||
*/
|
||||
public static final int TYPE_NAVI_OVERVIEW = 110006;
|
||||
|
||||
/**
|
||||
* 地图控制:缩放、路况、车头、2/3D
|
||||
*/
|
||||
public static final int TYPE_MAP_UI_SETTING = 110027;
|
||||
|
||||
/**
|
||||
* 重新计算导航策略
|
||||
*/
|
||||
public static final int TYPE_NAVI_STRATEGY = 110032;
|
||||
|
||||
/**
|
||||
* 提箱前方路线方案
|
||||
* <p>
|
||||
* 未实现
|
||||
*/
|
||||
public static final int TYPE_NAVI_GUIDE_INFO = 120004;
|
||||
|
||||
/**
|
||||
* 播放当前剩余里程和时间
|
||||
* <p>
|
||||
* 未实现
|
||||
*/
|
||||
public static final int TYPE_SPEAK_NAVI_INFO = 120001;
|
||||
|
||||
/**
|
||||
* 播放当前限速信息
|
||||
* <p>
|
||||
* 未实现
|
||||
*/
|
||||
public static final int TYPE_SPEAK_SPEED_LIMIT_INFO = 120002;
|
||||
|
||||
/**
|
||||
* 停止导航,但是不退出地图
|
||||
*/
|
||||
public static final int TYPE_STOP_NAVI = 110010;
|
||||
|
||||
/**
|
||||
* 退出地图应用
|
||||
*/
|
||||
@Deprecated
|
||||
public static final int TYPE_EXIT_NAVI = 120003;
|
||||
|
||||
/**
|
||||
* 插入途经点
|
||||
*/
|
||||
public static final int TYPE_NAVI_ADD_POINT = 210009;
|
||||
|
||||
public static final int TYPE_NAVI_SPEAK = 10011;
|
||||
public static final int TYPE_COMMON_ADDRESS_SETTING = 10007;
|
||||
public static final int TYPE_COMMON_ADDRESS_CHANGED = 10008;
|
||||
public static final int TYPE_NAVI_TO = 110027;
|
||||
|
||||
// 地图免唤醒语音注册
|
||||
/**
|
||||
* 放大地图
|
||||
*/
|
||||
public static final String CMD_MAP_ZOOM_IN = "CMD_MAP_ZOOM_IN";
|
||||
public static final String[] CMD_MAP_ZOOM_IN_WAKE_UP_WORDS = {"放大地图"};
|
||||
|
||||
/**
|
||||
* 缩小地图
|
||||
*/
|
||||
public static final String CMD_MAP_ZOOM_OUT = "CMD_MAP_ZOOM_OUT";
|
||||
public static final String[] CMD_MAP_ZOOM_OUT_WAKE_UP_WORDS = {"缩小地图"};
|
||||
|
||||
/**
|
||||
* 2D模式
|
||||
*/
|
||||
public static final String CMD_MAP_2D = "CMD_MAP_2D";
|
||||
public static final String[] CMD_MAP_2D_WAKE_UP_WORDS = {"2D模式"};
|
||||
/**
|
||||
* 3D模式
|
||||
*/
|
||||
public static final String CMD_MAP_3D = "CMD_MAP_3D";
|
||||
public static final String[] CMD_MAP_3D_WAKE_UP_WORDS = {"3D模式"};
|
||||
|
||||
/**
|
||||
* 白天模式
|
||||
*/
|
||||
public static final String CMD_MAP_LIGHT_MODE = "CMD_MAP_LIGHT_MODE";
|
||||
public static final String[] CMD_MAP_LIGHT_MODE_WAKE_UP_WORDS = {"白天模式"};
|
||||
|
||||
/**
|
||||
* 黑夜模式
|
||||
*/
|
||||
public static final String CMD_MAP_NIGHT_MODE = "CMD_MAP_NIGHT_MODE";
|
||||
public static final String[] CMD_MAP_NIGHT_MODE_WAKE_UP_WORDS = {"黑夜模式"};
|
||||
|
||||
/**
|
||||
* 查看路况
|
||||
*/
|
||||
public static final String CMD_MAP_TRAFFIC_MODE = "CMD_MAP_TRAFFIC_MODE";
|
||||
public static final String[] CMD_MAP_TRAFFIC_MODE_WAKE_UP_WORDS = {"查看路况"};
|
||||
/**
|
||||
* 关闭路况
|
||||
*/
|
||||
public static final String CMD_MAP_UN_TRAFFIC_MODE = "CMD_MAP_UN_TRAFFIC_MODE";
|
||||
public static final String[] CMD_MAP_UN_TRAFFIC_MODE_WAKE_UP_WORDS = {"关闭路况"};
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user