This commit is contained in:
wangcongtao
2020-03-19 16:24:14 +08:00
parent 0061b47744
commit a83c528b5d
18 changed files with 146 additions and 33 deletions

View File

@@ -468,8 +468,16 @@ public class AMapNaviViewWrapper implements IMogoMapView,
@Override
public void showMyLocation( boolean visible ) {
Logger.d( TAG, "showMyLocation1" );
if ( checkAMapView() ) {
MyLocationStyle style = mMapView.getMap().getMyLocationStyle();
if ( visible ) {
if ( NaviClient.getInstance( getContext() ).isNaviing() ) {
return;
}
}
style.showMyLocation( visible );
if ( visible ) {
// 强制刷新一遍车标
@@ -483,6 +491,9 @@ public class AMapNaviViewWrapper implements IMogoMapView,
@Override
public void showMyLocation( float degree ) {
if ( NaviClient.getInstance( getContext() ).isNaviing() ) {
return;
}
if ( checkAMapView() ) {
mCursorView = View.inflate( getContext(), R.layout.map_amap_cursor, null );
mCursorView.setRotation( degree );

View File

@@ -28,6 +28,7 @@ import java.util.List;
public abstract class AMapNaviListenerAdapter implements AMapNaviListener {
private static final String TAG = "AMapNaviListenerAdapter";
protected String mLastSpeakWord;
@Override
public void onInitNaviFailure() {
@@ -61,7 +62,8 @@ public abstract class AMapNaviListenerAdapter implements AMapNaviListener {
@Override
public void onGetNavigationText( String s ) {
mLastSpeakWord = s;
Logger.d( TAG, s );
}
@Override

View File

@@ -51,7 +51,7 @@ public class NaviClient implements IMogoNavi {
private NaviClient( Context context ) {
mAMapNavi = AMapNavi.getInstance( context );
mAMapNavi.setEmulatorNaviSpeed( 120 );
mAMapNavi.setUseInnerVoice( true );
mAMapNavi.setUseInnerVoice( true, true );
mAMapNaviListener = new NaviListenerAdapter( context, mAMapNavi, this );
mAimlessModeListener = new AimlessModeListenerAdapter() {
};

View File

@@ -3,6 +3,7 @@ package com.mogo.map.impl.amap.navi;
import android.content.Context;
import android.graphics.Rect;
import android.os.Trace;
import android.text.TextUtils;
import com.amap.api.maps.model.Polyline;
import com.amap.api.navi.AMapNavi;
@@ -16,6 +17,7 @@ import com.amap.api.navi.model.AMapNaviCameraInfo;
import com.amap.api.navi.model.AMapNaviInfo;
import com.amap.api.navi.model.AMapNaviLocation;
import com.amap.api.navi.model.NaviInfo;
import com.mogo.commons.voice.AIAssist;
import com.mogo.map.MogoLatLng;
import com.mogo.map.impl.amap.AMapWrapper;
import com.mogo.map.impl.amap.message.AMapMessageManager;
@@ -182,6 +184,10 @@ public class NaviListenerAdapter extends AMapNaviListenerAdapter {
*/
private void stopNaviDelay() {
UiThreadHandler.postDelayed( () -> {
if ( TextUtils.isEmpty( mLastSpeakWord ) || !mLastSpeakWord.contains( "结束" ) ) {
AIAssist.getInstance( mContext ).speakTTSVoice( "到达目的地附近,本次导航结束" );
}
mLastSpeakWord = "";
stopNavi();
}, 5_000L );
}

View File

@@ -177,10 +177,6 @@ public class AppNavigatorFragment extends MvpFragment<AppNavigatorView, AppNavig
mMogoAnalytics.track("Launcher_APP_Icon", properties);
}
@Override
public void closeAppsPanel() {
}
@Override
public void onDestroyView() {
super.onDestroyView();

View File

@@ -7,6 +7,8 @@ import androidx.lifecycle.LifecycleOwner;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.commons.mvp.Presenter;
import com.mogo.commons.voice.AIAssist;
import com.mogo.commons.voice.IMogoVoiceCmdCallBack;
import com.mogo.module.apps.model.AppsModel;
import com.mogo.module.apps.utils.LaunchUtils;
import com.mogo.service.MogoServicePaths;
@@ -24,7 +26,7 @@ import org.json.JSONObject;
* <p>
* 描述
*/
public class AppNavigatorPresenter extends Presenter< AppNavigatorView > implements IMogoIntentListener {
public class AppNavigatorPresenter extends Presenter< AppNavigatorView > implements IMogoIntentListener, IMogoVoiceCmdCallBack {
private static final String TAG = "AppNavigatorPresenter";
@@ -41,12 +43,14 @@ public class AppNavigatorPresenter extends Presenter< AppNavigatorView > impleme
mIntentManager = ( IMogoIntentManager ) ARouter.getInstance().build( MogoServicePaths.PATH_INTENT_MANAGER ).navigation( getContext() );
mMogoStatusManager = ( IMogoStatusManager ) ARouter.getInstance().build( MogoServicePaths.PATH_STATUS_MANAGER ).navigation( getContext() );
// 预加载应用列表,空间换时间
AppsModel.getInstance(getContext()).load( null );
AppsModel.getInstance( getContext() ).load( null );
}
@Override
public void onResume( @NonNull LifecycleOwner owner ) {
super.onResume( owner );
AIAssist.getInstance( getContext() ).registerUnWakeupCommand( AppsConst.CMD_UN_WAKE_OPEN_APP_LIST, AppsConst.CMD_UN_WAKE_WORDS_OPEN_APP_LIST, this );
AIAssist.getInstance( getContext() ).registerUnWakeupCommand( AppsConst.CMD_UN_WAKE_OPEN_CAR_SETTINGS, AppsConst.CMD_UN_WAKE_WORDS_OPEN_CAR_SETTINGS, this );
mIntentManager.registerIntentListener( AppsConst.COMMAND_OPERATION, this );
}
@@ -54,6 +58,8 @@ public class AppNavigatorPresenter extends Presenter< AppNavigatorView > impleme
public void onPause( @NonNull LifecycleOwner owner ) {
super.onPause( owner );
mIntentManager.unregisterIntentListener( AppsConst.COMMAND_OPERATION, this );
AIAssist.getInstance( getContext() ).unregisterUnWakeupCommand( AppsConst.CMD_UN_WAKE_OPEN_APP_LIST );
AIAssist.getInstance( getContext() ).unregisterUnWakeupCommand( AppsConst.CMD_UN_WAKE_OPEN_CAR_SETTINGS );
}
@Override
@@ -83,6 +89,42 @@ public class AppNavigatorPresenter extends Presenter< AppNavigatorView > impleme
}
}
@Override
public void onCmdSelected( String cmd ) {
switch ( cmd ) {
case AppsConst.CMD_UN_WAKE_OPEN_APP_LIST:
mView.openAppsPanel();
break;
case AppsConst.CMD_UN_WAKE_OPEN_CAR_SETTINGS:
try {
LaunchUtils.launchByPkg( getContext(), AppsConst.APP_PKG_CAR_SETTINGS );
} catch ( Exception e ) {
TipToast.shortTip( R.string.module_apps_str_no_app );
}
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 ) {
}
@Override
public void onDestroy( @NonNull LifecycleOwner owner ) {
if ( mIntentManager != null ) {

View File

@@ -15,9 +15,4 @@ public interface AppNavigatorView extends IView {
* 打开全部应用
*/
void openAppsPanel();
/**
* 关闭全部应用
*/
void closeAppsPanel();
}

View File

@@ -18,10 +18,6 @@ public class AppsConst {
*/
public static final int TOTAL_SIZE_EACH_PAGE = 12;
/**
* 媒体跳转
*/
public static final String APP_PKG_MUSIC = "com.pvetec.musics";
/**
* 车辆设置跳转
*/
@@ -32,5 +28,13 @@ public class AppsConst {
public static final String OPERATION_OPEN = "打开";
public static final String OPERATION_CLOSE = "关闭";
public static final String CMD_UN_WAKE_OPEN_APP_LIST = "CMD_UN_WAKE_OPEN_APP_LIST";
public static final String[] CMD_UN_WAKE_WORDS_OPEN_APP_LIST = new String[]{"打开全部应用"};
public static final String CMD_UN_WAKE_CLOSE_APP_LIST = "CMD_UN_WAKE_CLOSE_APP_LIST";
public static final String[] CMD_UN_WAKE_WORDS_CLOSE_APP_LIST = new String[]{"关闭全部应用"};
public static final String CMD_UN_WAKE_OPEN_CAR_SETTINGS = "CMD_UN_WAKE_OPEN_CAR_SETTINGS";
public static final String[] CMD_UN_WAKE_WORDS_OPEN_CAR_SETTINGS = new String[]{"打开快捷设置"};
}

View File

@@ -1,12 +1,15 @@
package com.mogo.module.apps;
import android.content.Intent;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.lifecycle.LifecycleOwner;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.commons.mvp.Presenter;
import com.mogo.commons.voice.AIAssist;
import com.mogo.commons.voice.IMogoVoiceCmdCallBack;
import com.mogo.module.apps.utils.LaunchUtils;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.intent.IMogoIntentListener;
@@ -22,7 +25,7 @@ import org.json.JSONObject;
* <p>
* 描述
*/
public class AppsListPresenter extends Presenter< AppsListView > implements IMogoIntentListener {
public class AppsListPresenter extends Presenter< AppsListView > implements IMogoIntentListener, IMogoVoiceCmdCallBack {
private static final String TAG = "AppsListPresenter";
@@ -37,30 +40,59 @@ public class AppsListPresenter extends Presenter< AppsListView > implements IMog
super.onCreate( owner );
mIntentManager = ( IMogoIntentManager ) ARouter.getInstance().build( MogoServicePaths.PATH_INTENT_MANAGER ).navigation( getContext() );
mIntentManager.registerIntentListener( AppsConst.COMMAND_OPERATION, this );
AIAssist.getInstance( getContext() ).registerUnWakeupCommand( AppsConst.CMD_UN_WAKE_CLOSE_APP_LIST, AppsConst.CMD_UN_WAKE_WORDS_CLOSE_APP_LIST, this );
AIAssist.getInstance( getContext() ).registerUnWakeupCommand( AppsConst.CMD_GLOBAL_UN_WAKEUP_CLOSE_APP_LIST, AppsConst.CMD_UN_WAKE_WORDS_CLOSE_APP_LIST, this );
}
@Override
public void onIntentReceived( String intentStr, Intent intent ) {
if ( !AppsConst.COMMAND_OPERATION.equals( intentStr ) ) {
return;
}
try {
JSONObject object = new JSONObject( intent.getStringExtra( "data" ) );
String app = object.optString( "object" );
String operation = object.optString( "operation" );
if ( AppsConst.OBJECT_ALL_APPS.equals( app ) ) {
if ( AppsConst.OPERATION_CLOSE.equals( operation ) ) {
mView.closeAppsPanel();
if ( AppsConst.COMMAND_OPERATION.equals( intentStr ) ) {
try {
JSONObject object = new JSONObject( intent.getStringExtra( "data" ) );
String app = object.optString( "object" );
String operation = object.optString( "operation" );
if ( AppsConst.OBJECT_ALL_APPS.equals( app ) ) {
if ( AppsConst.OPERATION_CLOSE.equals( operation ) ) {
mView.closeAppsPanel();
}
}
} catch ( JSONException e ) {
e.printStackTrace();
}
} catch ( JSONException e ) {
e.printStackTrace();
}
}
@Override
public void onCmdSelected( String cmd ) {
if ( TextUtils.equals( AppsConst.CMD_UN_WAKE_CLOSE_APP_LIST, cmd ) ) {
mView.closeAppsPanel();
}
}
@Override
public void onCmdAction( String speakText ) {
}
@Override
public void onCmdCancel( String speakText ) {
}
@Override
public void onSpeakEnd( String speakText ) {
}
@Override
public void onSpeakSelectTimeOut( String speakText ) {
}
@Override
public void onDestroy( @NonNull LifecycleOwner owner ) {
super.onDestroy( owner );
mIntentManager.unregisterIntentListener( AppsConst.COMMAND_OPERATION, this );
AIAssist.getInstance( getContext() ).unregisterUnWakeupCommand( AppsConst.CMD_UN_WAKE_CLOSE_APP_LIST );
}
}

View File

@@ -114,7 +114,9 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
final long start = System.currentTimeMillis();
try {
IMogoModuleProvider provider = mCardModulesAdapter.getProvider( mCurrentPosition );
mPresenter.postTrackLastCardShowEvent( provider );
if ( mCurrentPosition != position ) {
mPresenter.postTrackLastCardShowEvent( provider );
}
mCurrentPosition = position;
provider = mCardModulesAdapter.getProvider( mCurrentPosition );
mMogoModuleHandler.setModuleEnable( provider.getModuleName() );

View File

@@ -64,6 +64,7 @@ public class MainPresenter extends Presenter< MainView > {
public MainPresenter( MainView view ) {
super( view );
mCardStartShowTime = System.currentTimeMillis();
}
@Override
@@ -76,7 +77,6 @@ public class MainPresenter extends Presenter< MainView > {
mView.switch2Card( cardInfo.mCardName, cardInfo.mLockCar );
} );
mAnalytics = ( IMogoAnalytics ) ARouter.getInstance().build( MogoServicePaths.PATH_UTILS_ANALYTICS ).navigation( getContext() );
mCardStartShowTime = System.currentTimeMillis();
}
/**

View File

@@ -299,6 +299,7 @@ public class MogoServices implements IMogoMapListener,
mIntentManager.registerIntentListener( ServiceConst.COMMAND_NEXT, this );
mIntentManager.registerIntentListener( ServiceConst.COMMAND_PREVIOUS, this );
mIntentManager.registerIntentListener( ServiceConst.COMMAND_SWITCH_CARD, this );
mIntentManager.registerIntentListener( ServiceConst.COMMAND_MY_LOCATION, this );
mIntentManager.registerIntentListener( MogoReceiver.ACTION_ADAS_STATUS, this );
mIntentManager.registerIntentListener( ServiceConst.COMMAND_OPERATION, this );
mIntentManager.registerIntentListener( MogoReceiver.ACTION_VOICE_READY, this );
@@ -788,8 +789,12 @@ public class MogoServices implements IMogoMapListener,
} catch ( JSONException e ) {
e.printStackTrace();
}
} else if( MogoReceiver.ACTION_VOICE_READY.equals( command ) ){
} else if ( MogoReceiver.ACTION_VOICE_READY.equals( command ) ) {
AIAssist.getInstance( mContext ).flush();
} else if ( ServiceConst.COMMAND_MY_LOCATION.equals( command ) ) {
if ( mStatusManager.isMainPageOnResume() ) {
mUiController.recoverLockMode();
}
}
}
@@ -854,6 +859,7 @@ public class MogoServices implements IMogoMapListener,
mInternalUnWakeupRegisterStatus = true;
AIAssist.getInstance( mContext ).registerUnWakeupCommand( ServiceConst.CMD_UN_WAKE_PREV, ServiceConst.CMD_UN_WAKE_PREV_UN_WAKE_WORDS, this );
AIAssist.getInstance( mContext ).registerUnWakeupCommand( ServiceConst.CMD_UN_WAKE_NEXT, ServiceConst.CMD_UN_WAKE_NEXT_UN_WAKE_WORDS, this );
AIAssist.getInstance( mContext ).registerUnWakeupCommand( ServiceConst.CMD_UN_WAKEUP_MY_LOCATION, ServiceConst.CMD_UN_WAKEUP_WORDS_MY_LOCATION, this );
}
/**
@@ -866,6 +872,7 @@ public class MogoServices implements IMogoMapListener,
mInternalUnWakeupRegisterStatus = false;
AIAssist.getInstance( mContext ).unregisterUnWakeupCommand( ServiceConst.CMD_UN_WAKE_PREV, this );
AIAssist.getInstance( mContext ).unregisterUnWakeupCommand( ServiceConst.CMD_UN_WAKE_NEXT, this );
AIAssist.getInstance( mContext ).unregisterUnWakeupCommand( ServiceConst.CMD_UN_WAKEUP_MY_LOCATION, this );
}
@Override
@@ -874,6 +881,10 @@ public class MogoServices implements IMogoMapListener,
mActionManager.invoke( MapMarkerManager.getInstance().getCurrentModuleName(), MogoAction.Prev );
} else if ( TextUtils.equals( ServiceConst.CMD_UN_WAKE_NEXT, cmd ) ) {
mActionManager.invoke( MapMarkerManager.getInstance().getCurrentModuleName(), MogoAction.Next );
} else if ( TextUtils.equals( ServiceConst.CMD_UN_WAKEUP_MY_LOCATION, cmd ) ) {
if ( mStatusManager.isMainPageOnResume() ) {
mUiController.recoverLockMode();
}
}
}

View File

@@ -137,5 +137,17 @@ public class ServiceConst {
*/
public static final String COMMAND_OPERATION = "system.application.operation";
/**
* 回到自车
*/
public static final String COMMAND_MY_LOCATION = "com.zhidao.desk.backToMyLocation";
public static final String CMD_UN_WAKEUP_MY_LOCATION = "CMD_UN_WAKEUP_MY_LOCATION";
public static final String[] CMD_UN_WAKEUP_WORDS_MY_LOCATION = new String[]{
"回到我的位置",
"返回我的位置",
"定位我的位置"
};
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 902 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 883 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB