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

# Conflicts:
#	modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerManager.java
This commit is contained in:
ihoudf
2020-04-20 18:31:33 +08:00
158 changed files with 2295 additions and 1293 deletions

View File

@@ -601,11 +601,11 @@ public class AMapNaviViewWrapper implements IMogoMapView,
}
@Override
public void displayOverview() {
public void displayOverview( Rect bounds ) {
if ( checkAMapView() ) {
if ( NaviClient.getInstance( getContext() ).isNaviing() ) {
loseLockMode();
NaviClient.getInstance( getContext() ).displayOverview();
NaviClient.getInstance( getContext() ).displayOverview( bounds );
}
}
}
@@ -633,6 +633,7 @@ public class AMapNaviViewWrapper implements IMogoMapView,
if ( checkAMapView() ) {
mMapView.setCarOverlayVisible( false );
showMyLocation( true );
NaviClient.getInstance( getContext() ).startAimlessMode();
}
}
@@ -823,12 +824,16 @@ public class AMapNaviViewWrapper implements IMogoMapView,
@Override
public void setCarCursorOption( CarCursorOption option ) {
if ( mCarCursorOption != null ) {
if ( mCarCursorOption != null && mCarCursorOption != DEFAULT_OPTION ) {
mCarCursorOption.destroy();
}
try {
mCarCursorOption = option.clone();
} catch ( CloneNotSupportedException e ) {
if ( option != null ) {
try {
mCarCursorOption = option.clone();
} catch ( Exception e ) {
mCarCursorOption = DEFAULT_OPTION;
}
} else {
mCarCursorOption = DEFAULT_OPTION;
}
if ( !checkAMapView() ) {
@@ -837,8 +842,10 @@ public class AMapNaviViewWrapper implements IMogoMapView,
AMapNaviViewOptions options = mMapView.getViewOptions();
if ( options != null && mCarCursorOption.getNaviCursorRes() != 0 ) {
options.setCarBitmap( BitmapFactory.decodeResource( getContext().getResources(), mCarCursorOption.getNaviCursorRes() ) );
mMapView.setViewOptions( options );
} else {
options.setCarBitmap( BitmapFactory.decodeResource( getContext().getResources(), DEFAULT_OPTION.getNaviCursorRes() ) );
}
mMapView.setViewOptions( options );
if ( mMapView.getMap() == null ) {
return;
@@ -849,6 +856,8 @@ public class AMapNaviViewWrapper implements IMogoMapView,
} else {
if ( mCarCursorOption.getCarCursorRes() != 0 ) {
style.myLocationIcon( BitmapDescriptorFactory.fromResource( mCarCursorOption.getCarCursorRes() ) );
} else {
style.myLocationIcon( BitmapDescriptorFactory.fromResource( DEFAULT_OPTION.getCarCursorRes() ) );
}
}
mMapView.getMap().setMyLocationStyle( style );

View File

@@ -15,6 +15,8 @@ import com.amap.api.navi.model.AimLessModeCongestionInfo;
import com.amap.api.navi.model.AimLessModeStat;
import com.amap.api.navi.model.NaviInfo;
import com.autonavi.tbt.TrafficFacilityInfo;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.commons.voice.AIAssist;
import com.mogo.map.MogoLatLng;
import com.mogo.utils.logger.Logger;
import java.util.List;
@@ -64,6 +66,7 @@ public abstract class AMapNaviListenerAdapter implements AMapNaviListener {
public void onGetNavigationText( String s ) {
mLastSpeakWord = s;
Logger.d( TAG, s );
AIAssist.getInstance(AbsMogoApplication.getApp()).speakTTSAndDuck(s);
}
@Override

View File

@@ -11,17 +11,20 @@ import com.amap.api.navi.enums.AimLessMode;
import com.amap.api.navi.enums.NaviType;
import com.amap.api.navi.model.NaviLatLng;
import com.mogo.commons.AbsMogoApplication;
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;
import com.mogo.map.impl.amap.utils.ObjectUtils;
import com.mogo.map.navi.IMogoCarLocationChangedListener;
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
import com.mogo.map.navi.IMogoNavi;
import com.mogo.map.navi.MogoCalculatePath;
import com.mogo.map.navi.MogoNaviConfig;
import com.mogo.map.navi.MogoNaviListenerHandler;
import com.mogo.map.navi.OnCalculatePathItemClickInteraction;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.storage.SharedPrefsMgr;
import java.util.ArrayList;
import java.util.Arrays;
@@ -35,7 +38,13 @@ import java.util.List;
*/
public class NaviClient implements IMogoNavi {
/**
* 巡航状态控制
*/
public static final String KEY_AIMLESS_STATUS = "KEY_AIMLESS_STATUS";
private static final String TAG = "NaviClient";
private final Context mContext;
private AMapNavi mAMapNavi;
private final NaviListenerAdapter mAMapNaviListener;
@@ -53,10 +62,20 @@ public class NaviClient implements IMogoNavi {
private boolean mIsRealNavi;
private Location mCarLocation;
private IMogoCarLocationChangedListener mCarLocationChangedListener;
private IMogoCarLocationChangedListener2 mCarLocationChangedListener;
private LocationSource.OnLocationChangedListener mOnLocationChangedListener;
/**
* 巡航模式配置状态
*/
private boolean mAimlessModeStatus;
/**
* 巡航状态
*/
private boolean mAimlessStatus;
private NaviClient( Context context ) {
mContext = context;
mAMapNavi = AMapNavi.getInstance( context );
mAMapNavi.setEmulatorNaviSpeed( 120 );
mAMapNavi.setUseInnerVoice( false, true );
@@ -65,6 +84,7 @@ public class NaviClient implements IMogoNavi {
};
mAMapNavi.addAMapNaviListener( mAMapNaviListener );
mAMapNavi.addAimlessModeListener( mAimlessModeListener );
mAimlessModeStatus = SharedPrefsMgr.getInstance( mContext ).getBoolean( KEY_AIMLESS_STATUS, false );
}
public static NaviClient getInstance( Context context ) {
@@ -151,7 +171,7 @@ public class NaviClient implements IMogoNavi {
return;
}
mIsRealNavi = isRealNavi;
stopAimlessMode();
boolean isNaving = isNaviing();
boolean result = mAMapNavi.startNavi( isRealNavi ? NaviType.GPS : NaviType.EMULATOR );
if ( isNaving && !result ) {
@@ -241,7 +261,12 @@ public class NaviClient implements IMogoNavi {
}
@Override
public void registerCarLocationChangedListener( IMogoCarLocationChangedListener listener ) {
public Location getCarLocation2() {
return mCarLocation;
}
@Override
public void registerCarLocationChangedListener( IMogoCarLocationChangedListener2 listener ) {
mCarLocationChangedListener = listener;
}
@@ -250,7 +275,7 @@ public class NaviClient implements IMogoNavi {
public void syncCarLocation( Location location ) {
mCarLocation = location;
if ( mCarLocationChangedListener != null ) {
mCarLocationChangedListener.onCarLocationChanged( getCarLocation() );
mCarLocationChangedListener.onCarLocationChanged2( mCarLocation );
}
}
@@ -274,18 +299,42 @@ public class NaviClient implements IMogoNavi {
@Override
public void startAimlessMode() {
mAMapNavi.startAimlessMode( AimLessMode.CAMERA_AND_SPECIALROAD_DETECTED );
if ( mAimlessModeStatus && !isNaviing() ) {
mAMapNavi.startAimlessMode( AimLessMode.CAMERA_AND_SPECIALROAD_DETECTED );
mAimlessStatus = true;
Logger.d( TAG, "开启巡航成功" );
} else {
mAimlessStatus = false;
Logger.d( TAG, "开启巡航失败" );
}
}
@Override
public void stopAimlessMode() {
mAMapNavi.stopAimlessMode();
mAimlessStatus = false;
Logger.d( TAG, "关闭巡航成功" );
}
@Override
public void displayOverview() {
public void setAimlessModeStatus( boolean open ) {
this.mAimlessModeStatus = open;
SharedPrefsMgr.getInstance( mContext ).putBoolean( KEY_AIMLESS_STATUS, open );
if ( open ) {
if ( !mAimlessStatus ) {
startAimlessMode();
}
} else {
if ( mAimlessStatus ) {
stopAimlessMode();
}
}
}
@Override
public void displayOverview( Rect bounds ) {
if ( mAMapNaviListener != null ) {
mAMapNaviListener.displayOverview();
mAMapNaviListener.displayOverview( bounds );
}
}

View File

@@ -95,6 +95,7 @@ public class NaviListenerAdapter extends AMapNaviListenerAdapter {
@Override
public void onInitNaviSuccess() {
MogoNaviListenerHandler.getInstance().onInitNaviSuccess();
NaviClient.getInstance( mContext ).startAimlessMode();
}
@Override
@@ -245,9 +246,10 @@ public class NaviListenerAdapter extends AMapNaviListenerAdapter {
public void handleClickedPolyline( Polyline polyline ) {
if ( mNaviOverlayHelper != null ) {
mNaviOverlayHelper.handleClickedPolyline( polyline, isNaviing() );
mAMapNavi.selectRouteId( mNaviOverlayHelper.getSelectedPathId() );
mNaviOverlayHelper.showBounds();
mNaviOverlayHelper.showBoundsWithSettingBounds();
}
}
@@ -291,9 +293,9 @@ public class NaviListenerAdapter extends AMapNaviListenerAdapter {
}
}
public void displayOverview(){
public void displayOverview( Rect bounds ) {
if ( mNaviOverlayHelper != null ) {
mNaviOverlayHelper.displayOverview();
mNaviOverlayHelper.displayOverview( bounds );
}
}
}

View File

@@ -99,7 +99,7 @@ public class NaviOverlayHelper implements OnCalculatePathItemClickInteraction {
if ( after != null ) {
after.run();
}
} );
}, mBoundRect );
}
private LatLngBounds getBounds() {
@@ -169,25 +169,32 @@ public class NaviOverlayHelper implements OnCalculatePathItemClickInteraction {
}
}
public void showBounds() {
public void showBoundsWithSettingBounds() {
showBounds( mBoundRect );
}
public void showBounds( Rect bounds ) {
Logger.d( TAG, "showBounds" );
showPathsBound( getBounds(), null );
showPathsBound( getBounds(), null, bounds );
}
/**
* 将规划好的路径显示在视野内
*/
private void showPathsBound( LatLngBounds bounds, Runnable after ) {
private void showPathsBound( LatLngBounds bounds, Runnable after, Rect rect ) {
if ( bounds == null ) {
return;
}
if ( rect == null ) {
rect = new Rect();
}
checkAMapInstance();
mAMap.moveCamera( CameraUpdateFactory.newLatLngBoundsRect(
bounds,
mBoundRect.left,
mBoundRect.right,
mBoundRect.top,
mBoundRect.bottom ));
rect.left,
rect.right,
rect.top,
rect.bottom ) );
if ( after != null ) {
after.run();
}
@@ -431,7 +438,7 @@ public class NaviOverlayHelper implements OnCalculatePathItemClickInteraction {
public void onItemClicked( String tagId ) {
handleClickedPolyline( tagId );
mAMapNavi.selectRouteId( getSelectedPathId() );
showBounds();
showBounds( mBoundRect );
}
public OnCalculatePathItemClickInteraction getItemClickInteraction() {
@@ -451,7 +458,7 @@ public class NaviOverlayHelper implements OnCalculatePathItemClickInteraction {
/**
* 展示全程
*/
public void displayOverview(){
showBounds();
public void displayOverview( Rect bounds ) {
showBounds( bounds );
}
}

View File

@@ -126,9 +126,9 @@ public class AMapUIController implements IMogoMapUIController {
}
@Override
public void displayOverview() {
public void displayOverview( Rect bounds ) {
if (mClient != null) {
mClient.displayOverview();
mClient.displayOverview(bounds);
}
}