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:
@@ -39,10 +39,12 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.mogoutils
|
||||
implementation rootProject.ext.dependencies.mogomapapi
|
||||
implementation rootProject.ext.dependencies.mogocommons
|
||||
implementation rootProject.ext.dependencies.mogomapapi
|
||||
} else {
|
||||
implementation project(':foudations:mogo-utils')
|
||||
implementation project(':libraries:mogo-map-api')
|
||||
implementation project(':foudations:mogo-commons')
|
||||
implementation project(':services:mogo-service-api')
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.mogo.map.navi;
|
||||
|
||||
import android.location.Location;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-03-14
|
||||
* <p>
|
||||
* 车辆位置变化
|
||||
*/
|
||||
public interface IMogoCarLocationChangedListener2 extends IMogoCarLocationChangedListener {
|
||||
|
||||
void onCarLocationChanged2( Location latLng );
|
||||
}
|
||||
@@ -144,12 +144,19 @@ public interface IMogoNavi {
|
||||
*/
|
||||
MogoLatLng getCarLocation();
|
||||
|
||||
/**
|
||||
* 获取车标经纬度
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Location getCarLocation2();
|
||||
|
||||
/**
|
||||
* 注册车辆位置变化监听,非业务使用
|
||||
*
|
||||
* @param listener
|
||||
*/
|
||||
void registerCarLocationChangedListener( IMogoCarLocationChangedListener listener );
|
||||
void registerCarLocationChangedListener( IMogoCarLocationChangedListener2 listener );
|
||||
|
||||
/**
|
||||
* 打开巡航模式
|
||||
@@ -161,10 +168,17 @@ public interface IMogoNavi {
|
||||
*/
|
||||
void stopAimlessMode();
|
||||
|
||||
/**
|
||||
* 设置巡航模式状态
|
||||
*
|
||||
* @param open
|
||||
*/
|
||||
void setAimlessModeStatus( boolean open );
|
||||
|
||||
/**
|
||||
* 查看全程
|
||||
*/
|
||||
void displayOverview();
|
||||
void displayOverview( Rect bounds );
|
||||
|
||||
/**
|
||||
* 设置使用外部定位源
|
||||
|
||||
@@ -7,6 +7,7 @@ import android.view.View;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
@@ -88,8 +89,10 @@ public interface IMogoMapUIController {
|
||||
|
||||
/**
|
||||
* 预览全程
|
||||
*
|
||||
* @param bounds 显示范围
|
||||
*/
|
||||
void displayOverview();
|
||||
void displayOverview( Rect bounds );
|
||||
|
||||
/**
|
||||
* 获取比例尺数据
|
||||
@@ -192,7 +195,7 @@ public interface IMogoMapUIController {
|
||||
/**
|
||||
* 配置自车图标样式
|
||||
*
|
||||
* @param option
|
||||
* @param option 为空时使用默认配置
|
||||
*/
|
||||
void setCarCursorOption( CarCursorOption option );
|
||||
void setCarCursorOption( @Nullable CarCursorOption option );
|
||||
}
|
||||
|
||||
@@ -120,9 +120,9 @@ public class MogoMapUIController implements IMogoMapUIController {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayOverview() {
|
||||
public void displayOverview( Rect bounds ) {
|
||||
if (mDelegate != null) {
|
||||
mDelegate.displayOverview();
|
||||
mDelegate.displayOverview(bounds);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.location.Location;
|
||||
|
||||
import com.mogo.map.impl.amap.navi.NaviClient;
|
||||
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;
|
||||
@@ -176,7 +177,15 @@ public class MogoNavi implements IMogoNavi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCarLocationChangedListener( IMogoCarLocationChangedListener listener ) {
|
||||
public Location getCarLocation2() {
|
||||
if ( mDelegate != null ) {
|
||||
return mDelegate.getCarLocation2();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCarLocationChangedListener( IMogoCarLocationChangedListener2 listener ) {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.registerCarLocationChangedListener( listener );
|
||||
}
|
||||
@@ -197,9 +206,16 @@ public class MogoNavi implements IMogoNavi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayOverview() {
|
||||
public void setAimlessModeStatus( boolean open ) {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.displayOverview();
|
||||
mDelegate.setAimlessModeStatus( open );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayOverview( Rect bounds ) {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.displayOverview(bounds);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user