Merge remote-tracking branch 'origin/feature/v1.0.0' into feature/v1.0.0

This commit is contained in:
董宏宇
2020-01-13 19:17:54 +08:00
6 changed files with 195 additions and 63 deletions

View File

@@ -15,6 +15,7 @@ import com.mogo.map.navi.IMogoNavi;
import com.mogo.map.uicontroller.EnumMapUI;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.map.IMogoMapService;
import com.mogo.service.module.IMogoSearchManager;
import com.mogo.service.voice.IMogoVoiceListener;
import com.mogo.service.voice.IMogoVoiceManager;
import com.mogo.utils.ResourcesHelper;
@@ -29,150 +30,183 @@ import java.util.Map;
* <p>
* 描述
*/
public class MapPresenter extends Presenter< MapView > implements IMogoVoiceListener, IMogoVoiceCmdCallBack {
public class MapPresenter extends Presenter<MapView>
implements IMogoVoiceListener, IMogoVoiceCmdCallBack {
private static final String TAG = "MapPresenter";
private IMogoMapService mMogoMapService;
private IMogoVoiceManager mMogoVoiceManager;
private IMogoSearchManager mSearchManager;
public MapPresenter( MapView view ) {
super( view );
public MapPresenter(MapView view) {
super(view);
}
@Override
public void onCreate( @NonNull LifecycleOwner owner ) {
super.onCreate( owner );
mMogoMapService = ( IMogoMapService ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICES_MAP ).navigation( getContext() );
mMogoVoiceManager = ( IMogoVoiceManager ) ARouter.getInstance().build( MogoServicePaths.PATH_VOICE_MANAGER ).navigation( getContext() );
public void onCreate(@NonNull LifecycleOwner owner) {
super.onCreate(owner);
mMogoMapService = (IMogoMapService) ARouter.getInstance()
.build(MogoServicePaths.PATH_SERVICES_MAP)
.navigation(getContext());
mMogoVoiceManager = (IMogoVoiceManager) ARouter.getInstance()
.build(MogoServicePaths.PATH_VOICE_MANAGER)
.navigation(getContext());
mSearchManager = (IMogoSearchManager) ARouter.getInstance()
.build(MogoServicePaths.PATH_SEARCH_MANAGER)
.navigation(getContext());
registerVoiceCmd();
IMogoNavi mogoNavi = mMogoMapService.getNavi( getContext() );
mogoNavi.setCalculatePathDisplayBounds( new Rect(
ResourcesHelper.getDimensionPixelSize( getContext(), R.dimen.dp_730 ) + WindowUtils.dip2px( getContext(), 80 ),
ResourcesHelper.getDimensionPixelSize( getContext(), R.dimen.dp_120 ) + WindowUtils.dip2px( getContext(), 80 ),
WindowUtils.dip2px( getContext(), 80 ),
WindowUtils.dip2px( getContext(), 80 )
) );
IMogoNavi mogoNavi = mMogoMapService.getNavi(getContext());
mogoNavi.setCalculatePathDisplayBounds(new Rect(
ResourcesHelper.getDimensionPixelSize(getContext(), R.dimen.dp_730)
+ WindowUtils.dip2px(getContext(), 80),
ResourcesHelper.getDimensionPixelSize(getContext(), R.dimen.dp_120)
+ WindowUtils.dip2px(getContext(), 80),
WindowUtils.dip2px(getContext(), 80),
WindowUtils.dip2px(getContext(), 80)
));
}
@Override
public void onResume( @NonNull LifecycleOwner owner ) {
super.onResume( owner );
public void onResume(@NonNull LifecycleOwner owner) {
super.onResume(owner);
registerVoiceCmd();
}
@Override
public void onPause( @NonNull LifecycleOwner owner ) {
super.onPause( owner );
public void onPause(@NonNull LifecycleOwner owner) {
super.onPause(owner);
unregisterVoiceCmd();
}
private void registerVoiceCmd() {
if ( VoiceConstants.sVoiceCmds.isEmpty() ) {
Logger.w( TAG, "no unwakeup words" );
if (VoiceConstants.sVoiceCmds.isEmpty()) {
Logger.w(TAG, "no unwakeup words");
return;
}
for ( Map.Entry< String, String[] > entry : VoiceConstants.sVoiceCmds.entrySet() ) {
mMogoVoiceManager.registerIntentListener( entry.getKey(), this );
AIAssist.getInstance( getContext() ).registerUnWakeupCommand( entry.getKey(), entry.getValue(), this );
for (Map.Entry<String, String[]> entry : VoiceConstants.sVoiceCmds.entrySet()) {
mMogoVoiceManager.registerIntentListener(entry.getKey(), this);
AIAssist.getInstance(getContext())
.registerUnWakeupCommand(entry.getKey(), entry.getValue(), this);
}
}
private void unregisterVoiceCmd() {
if ( VoiceConstants.sVoiceCmds.isEmpty() ) {
Logger.w( TAG, "no unwakeup words" );
if (VoiceConstants.sVoiceCmds.isEmpty()) {
Logger.w(TAG, "no unwakeup words");
return;
}
for ( Map.Entry< String, String[] > entry : VoiceConstants.sVoiceCmds.entrySet() ) {
mMogoVoiceManager.unregisterIntentListener( entry.getKey() );
AIAssist.getInstance( getContext() ).unregisterUnWakeupCommand( entry.getKey(), this );
for (Map.Entry<String, String[]> entry : VoiceConstants.sVoiceCmds.entrySet()) {
mMogoVoiceManager.unregisterIntentListener(entry.getKey());
AIAssist.getInstance(getContext()).unregisterUnWakeupCommand(entry.getKey(), this);
}
}
@Override
public void onIntentReceived( String command, Intent intent ) {
if ( TextUtils.isEmpty( command ) ) {
public void onIntentReceived(String command, Intent intent) {
if (TextUtils.isEmpty(command)) {
return;
}
onCmdSelected( command );
onCmdSelected(command);
}
@Override
public void onCmdSelected( String cmd ) {
switch ( cmd ) {
public void onCmdSelected(String cmd) {
switch (cmd) {
case VoiceConstants.CMD_MAP_TRAFFIC_MODE:
mView.getUIController().setTrafficEnabled( true );
AIAssist.getInstance( getContext() ).speakTTSVoice( "已打开", null );
mView.getUIController().setTrafficEnabled(true);
mSearchManager.showSearch();
AIAssist.getInstance(getContext()).speakTTSVoice("已打开", null);
break;
case VoiceConstants.CMD_MAP_UN_TRAFFIC_MODE:
mView.getUIController().setTrafficEnabled( false );
AIAssist.getInstance( getContext() ).speakTTSVoice( "已关闭", null );
mView.getUIController().setTrafficEnabled(false);
mSearchManager.showMain();
AIAssist.getInstance(getContext()).speakTTSVoice("已关闭", null);
break;
case VoiceConstants.CMD_MAP_ZOOM_IN:
AIAssist.getInstance( getContext() ).speakTTSVoice( "已缩小", null );
mView.getUIController().changeZoom( true );
AIAssist.getInstance(getContext()).speakTTSVoice("已缩小", null);
mView.getUIController().changeZoom(true);
break;
case VoiceConstants.CMD_MAP_ZOOM_OUT:
AIAssist.getInstance( getContext() ).speakTTSVoice( "已放大", null );
mView.getUIController().changeZoom( false );
AIAssist.getInstance(getContext()).speakTTSVoice("已放大", null);
mView.getUIController().changeZoom(false);
break;
case VoiceConstants.CMD_MAP_2D:
case VoiceConstants.CMD_MAP_NORTH_UP_MODE:
mView.getUIController().changeMapMode( EnumMapUI.NorthUP_2D );
AIAssist.getInstance( getContext() ).speakTTSVoice( "已切换", null );
mView.getUIController().changeMapMode(EnumMapUI.NorthUP_2D);
AIAssist.getInstance(getContext()).speakTTSVoice("已切换", null);
break;
case VoiceConstants.CMD_MAP_3D:
mView.getUIController().changeMapMode( EnumMapUI.CarUp_3D );
AIAssist.getInstance( getContext() ).speakTTSVoice( "已切换", null );
mView.getUIController().changeMapMode(EnumMapUI.CarUp_3D);
AIAssist.getInstance(getContext()).speakTTSVoice("已切换", null);
break;
case VoiceConstants.CMD_MAP_DAY_TIME_MODE:
mView.getUIController().changeMapMode( EnumMapUI.Type_Light );
AIAssist.getInstance( getContext() ).speakTTSVoice( "已切换", null );
mView.getUIController().changeMapMode(EnumMapUI.Type_Light);
AIAssist.getInstance(getContext()).speakTTSVoice("已切换", null);
break;
case VoiceConstants.CMD_MAP_GO_COMPANY:
mSearchManager.goCompany();
break;
case VoiceConstants.CMD_MAP_GO_HOME:
mSearchManager.goHome();
break;
case VoiceConstants.CMD_MAP_HISTORY:
mSearchManager.showSearch();
break;
case VoiceConstants.CMD_MAP_STOP_NAVI_MODE:
mSearchManager.showMain();
break;
case VoiceConstants.CMD_MAP_NIGHT_MODE:
mView.getUIController().changeMapMode( EnumMapUI.Type_Night );
AIAssist.getInstance( getContext() ).speakTTSVoice( "已切换", null );
mView.getUIController().changeMapMode(EnumMapUI.Type_Night);
AIAssist.getInstance(getContext()).speakTTSVoice("已切换", null);
break;
case VoiceConstants.CMD_MAP_AUTO_LIGHT_NIGHT_MODE:
mView.getUIController().changeMapMode( EnumMapUI.Type_AUTO_LIGHT_Night );
AIAssist.getInstance( getContext() ).speakTTSVoice( "已切换", null );
mView.getUIController().changeMapMode(EnumMapUI.Type_AUTO_LIGHT_Night);
AIAssist.getInstance(getContext()).speakTTSVoice("已切换", null);
break;
case VoiceConstants.CMD_MAP_DISPLAY_OVERVIEW_MODE:
mView.getUIController().displayOverview();
AIAssist.getInstance( getContext() ).speakTTSVoice( "已切换", null );
AIAssist.getInstance(getContext()).speakTTSVoice("已切换", null);
break;
case VoiceConstants.CMD_MAP_CONTINUE_NAVI_MODE:
mView.getUIController().recoverLockMode();
AIAssist.getInstance( getContext() ).speakTTSVoice( "已切换", null );
AIAssist.getInstance(getContext()).speakTTSVoice("已切换", null);
break;
case VoiceConstants.CMD_MAP_CAR_UP_MODE:
mView.getUIController().changeMapMode( EnumMapUI.CarUp_2D );
AIAssist.getInstance( getContext() ).speakTTSVoice( "已切换", null );
mView.getUIController().changeMapMode(EnumMapUI.CarUp_2D);
AIAssist.getInstance(getContext()).speakTTSVoice("已切换", null);
break;
default:
break;
}
}
@Override
public void onCmdAction( String speakText ) {
public void onCmdAction(String speakText) {
}
@Override
public void onCmdCancel( String speakText ) {
public void onCmdCancel(String speakText) {
}
@Override
public void onSpeakEnd( String speakText ) {
public void onSpeakEnd(String speakText) {
}
@Override
public void onSpeakSelectTimeOut( String speakText ) {
public void onSpeakSelectTimeOut(String speakText) {
}
}

View File

@@ -18,6 +18,26 @@ public class VoiceConstants {
public static final String CMD_MAP_ZOOM_IN = "com.ileja.navi.map.enlarge";
public static final String[] CMD_MAP_ZOOM_IN_TRIGGER_WORDS = {"放大地图"};
/**
* 回家
*/
public static final String CMD_MAP_GO_HOME = "com.ileja.navi.map.go.home";
public static final String[] CMD_MAP_ZOOM_IN_GO_HOME = {"我要回家","导航回家","带我回家"};
/**
* 去公司
*/
public static final String CMD_MAP_GO_COMPANY = "com.ileja.navi.map.go.company";
public static final String[] CMD_MAP_ZOOM_IN_GO_COMPANY = {"我要去公司","导航去公司","带我去公司"};
/**
* 导航历史记录
*/
public static final String CMD_MAP_HISTORY = "com.ileja.navi.map.history";
public static final String[] CMD_MAP_HISTORY_TRIGGER_WORDS = {"查询导航历史记录"};
/**
* 缩小地图
*/
@@ -77,6 +97,15 @@ public class VoiceConstants {
public static final String CMD_MAP_CONTINUE_NAVI_MODE = "com.ileja.navi.route.continue";
public static final String[] CMD_MAP_CONTINUE_NAVI_MODE_MODE_TRIGGER_WORDS = {"继续导航"};
/**
* 停止导航
*/
public static final String CMD_MAP_STOP_NAVI_MODE = "com.ileja.navi.route.stop";
public static final String[] CMD_MAP_STOP_NAVI_MODE_TRIGGER_WORDS = {"停止导航/结束导航/取消导航/放弃导航/退出导航/关闭导航"};
/**
* 车头朝上
*/
@@ -105,5 +134,9 @@ public class VoiceConstants {
sVoiceCmds.put( VoiceConstants.CMD_MAP_CONTINUE_NAVI_MODE, VoiceConstants.CMD_MAP_CONTINUE_NAVI_MODE_MODE_TRIGGER_WORDS );
sVoiceCmds.put( VoiceConstants.CMD_MAP_CAR_UP_MODE, VoiceConstants.CMD_MAP_CAR_UP_MODE_TRIGGER_WORDS );
sVoiceCmds.put( VoiceConstants.CMD_MAP_NORTH_UP_MODE, VoiceConstants.CMD_MAP_NORTH_UP_MODE_TRIGGER_WORDS );
sVoiceCmds.put( VoiceConstants.CMD_MAP_GO_HOME, VoiceConstants.CMD_MAP_ZOOM_IN_GO_HOME );
sVoiceCmds.put( VoiceConstants.CMD_MAP_GO_COMPANY, VoiceConstants.CMD_MAP_ZOOM_IN_GO_COMPANY );
sVoiceCmds.put( VoiceConstants.CMD_MAP_HISTORY, VoiceConstants.CMD_MAP_HISTORY_TRIGGER_WORDS );
sVoiceCmds.put( VoiceConstants.CMD_MAP_STOP_NAVI_MODE, VoiceConstants.CMD_MAP_STOP_NAVI_MODE_TRIGGER_WORDS );
}
}

View File

@@ -0,0 +1,43 @@
package com.mogo.module.navi.manager;
import android.content.Context;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.module.common.MogoModulePaths;
import com.mogo.module.navi.constants.SearchServiceHolder;
import com.mogo.module.navi.ui.search.SearchFragment;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.fragmentmanager.FragmentDescriptor;
import com.mogo.service.module.IMogoSearchManager;
/**
* @author zyz
* 2020-01-13.
*/
@Route(path = MogoServicePaths.PATH_SEARCH_MANAGER)
public class MogoSearchManager implements IMogoSearchManager {
@Override public void goHome() {
AddressManager.INSTANCE.goHome();
}
@Override public void goCompany() {
AddressManager.INSTANCE.goCompany();
}
@Override public void showSearch() {
SearchFragment searchFragment = new SearchFragment();
SearchServiceHolder.INSTANCE.getFragmentManager()
.push(new FragmentDescriptor.Builder().fragment(searchFragment)
.tag(MogoModulePaths.PATH_FRAGMENT_SEARCH)
.notifyMainModule(true)
.build());
}
@Override public void showMain() {
SearchServiceHolder.INSTANCE.getFragmentManager()
.clearAll();
}
@Override public void init(Context context) {
}
}

View File

@@ -187,7 +187,7 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
getViewLifecycleOwner().getLifecycle().addObserver(mPresenter);
EventBus.getDefault().register(this);
initInterface();
mTanluModelData = new TanluModelData(getContext());
initModelData();
handleRoadLineMessage();
initMap();
initStrings();
@@ -196,6 +196,11 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
// iMogoCardManager.switch2(TanluConstants.MODEL_NAME);
}
private void initModelData() {
if (mTanluModelData == null) {
mTanluModelData = new TanluModelData(getContext());
}
}
/**
* 初始化导航 TODO
@@ -219,9 +224,7 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
@Override
public void onStartNavi() {
if (mTanluModelData == null) {
mTanluModelData = new TanluModelData(getContext());
}
initModelData();
getNavigationLineData();
}

View File

@@ -86,6 +86,10 @@ public class MogoServicePaths {
*/
public static final String PATH_ADDRESS_MANAGER = "/addressmanager/api";
/**
* 导航搜索模块管理
*/
public static final String PATH_SEARCH_MANAGER = "/searchmanager/api";
/**
* 基础设置参数管理

View File

@@ -0,0 +1,15 @@
package com.mogo.service.module;
import com.alibaba.android.arouter.facade.template.IProvider;
/**
* @author zyz
* 2020-01-12.
*/
public interface IMogoSearchManager extends IProvider {
void goHome();
void goCompany();
void showSearch();
void showMain();
}