This commit is contained in:
wangcongtao
2020-06-05 12:19:13 +08:00
parent 075ca7d3a9
commit 44ec5cdcfe
15 changed files with 317 additions and 79 deletions

View File

@@ -8,7 +8,6 @@
<intent-filter>
<!-- 一个新应用包已经安装在设备上,数据包括包名(最新安装的包程序不能接收到这个广播)-->
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_INSTALL" />
<!-- 一个新版本的应用安装到设备,替换之前已经存在的版本-->
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<!-- 一个已存在的应用程序包已经从设备上移除,包括包名(正在被安装的包程序不能接收到这个广播)-->

View File

@@ -0,0 +1,48 @@
package com.mogo.module.common.map;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.utils.AppUtils;
import com.mogo.utils.logger.Logger;
public
/**
* @author congtaowang
* @since 2020/6/5
* <p>
* 自定义导航功能拦截器
*/
class CustomNaviInterrupter implements Interrupter {
private static final String TAG = "CustomNaviInterrupter";
private static volatile CustomNaviInterrupter sInstance;
private CustomNaviInterrupter() {
}
public static CustomNaviInterrupter getInstance() {
if ( sInstance == null ) {
synchronized ( CustomNaviInterrupter.class ) {
if ( sInstance == null ) {
sInstance = new CustomNaviInterrupter();
}
}
}
return sInstance;
}
public synchronized void release() {
sInstance = null;
}
@Override
public boolean interrupt() {
if ( AppUtils.isAppInstalled( AbsMogoApplication.getApp(), "com.autonavi.amapauto" )
|| DebugConfig.isUseCustomNavi() ) {
Logger.d( TAG, "do not use custom map function." );
return true;
}
return false;
}
}

View File

@@ -188,7 +188,7 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
return R.layout.module_ext_layout_entrance;
}
private List<View> demoCache = new ArrayList<>();
private List< View > demoCache = new ArrayList<>();
@Override
protected void initViews() {
@@ -279,9 +279,9 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
} );
// mNaviInfo = findViewById( R.id.module_entrance_id_navi_info_panel );
ConstraintLayout rootView = findViewById(R.id.module_entrance_id_top_motion_layout);
if(rootView!=null) {
TopViewAnimHelper.getInstance().init(rootView);
ConstraintLayout rootView = findViewById( R.id.module_entrance_id_top_motion_layout );
if ( rootView != null ) {
TopViewAnimHelper.getInstance().init( rootView );
}
mExitNavi = findViewById( R.id.module_entrance_id_exit_navi );
@@ -419,6 +419,7 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
return;
}
if ( mExitNavi.getVisibility() == View.GONE ) {
// 避免先导航后启动app导致无法显示控件
onStartNavi();
}
mNaviInfo.notifyChanged( naviinfo );
@@ -550,7 +551,7 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
}
@Override
public void refreshUserInfo(UserInfo userInfo) {
Logger.d(TAG, "刷新用户信息: " + userInfo);
public void refreshUserInfo( UserInfo userInfo ) {
Logger.d( TAG, "刷新用户信息: " + userInfo );
}
}

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -60,4 +60,4 @@
android:background="@drawable/module_main_launcher_bg"
android:visibility="visible"
tools:visibility="gone" />
</RelativeLayout>
</FrameLayout>

View File

@@ -6,6 +6,7 @@ import android.util.Log;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.map.navi.MogoNaviInfo;
import com.mogo.module.common.map.CustomNaviInterrupter;
import com.mogo.service.IMogoServiceApis;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
@@ -46,14 +47,17 @@ public class MapBroadCastHelper implements IMogoStatusChangedListener {
}
public void notifyXiaozhi( MogoNaviInfo naviinfo ) {
// Intent intent = new Intent( ACTION_NAV_SEND );
// intent.putExtra( "KEY_TYPE", 10001 );
// intent.putExtra( "NEXT_ROAD_NAME", naviinfo.getNextRoadName() );
// intent.putExtra( "ROUTE_REMAIN_TIME_AUTO", naviinfo.getVoiceRetainTime() );
// intent.putExtra( "ROUTE_REMAIN_DIS_AUTO", naviinfo.getVoiceRetainDistance() );
// intent.putExtra( "ICON", naviinfo.getIconResId() );
// mContext.sendBroadcast( intent );
// Log.v( "MapBroadCastHelper", "action=" + ACTION_NAV_SEND + " NaviInfo" );
if ( CustomNaviInterrupter.getInstance().interrupt() ) {
return;
}
Intent intent = new Intent( ACTION_NAV_SEND );
intent.putExtra( "KEY_TYPE", 10001 );
intent.putExtra( "NEXT_ROAD_NAME", naviinfo.getNextRoadName() );
intent.putExtra( "ROUTE_REMAIN_TIME_AUTO", naviinfo.getVoiceRetainTime() );
intent.putExtra( "ROUTE_REMAIN_DIS_AUTO", naviinfo.getVoiceRetainDistance() );
intent.putExtra( "ICON", naviinfo.getIconResId() );
mContext.sendBroadcast( intent );
Log.v( "MapBroadCastHelper", "action=" + ACTION_NAV_SEND + " NaviInfo" );
}
@@ -67,30 +71,30 @@ public class MapBroadCastHelper implements IMogoStatusChangedListener {
}
public void mapFrount() {
// notifyXizhiNavStatus( STATUS_NAV_FRONT );
notifyXizhiNavStatus( STATUS_NAV_FRONT );
}
public void mapBackground() {
// notifyXizhiNavStatus( STATUS_NAV_BACKGROUND );
notifyXizhiNavStatus( STATUS_NAV_BACKGROUND );
}
public void startNavi() {
// notifyXizhiNavStatus( STATUS_NAV_START );
notifyXizhiNavStatus( STATUS_NAV_START );
}
public void stopNavi() {
// notifyXizhiNavStatus( STATUS_NAV_STOP );
notifyXizhiNavStatus( STATUS_NAV_STOP );
}
@Override
public void onStatusChanged( StatusDescriptor descriptor, boolean isTrue ) {
if ( descriptor == StatusDescriptor.AI_ASSIST_READY ) {
if ( isTrue ) {
// if ( AppUtils.isApplicationBroughtToBackground( mContext ) ) {
// mapBackground();
// } else {
// mapFrount();
// }
if ( AppUtils.isApplicationBroughtToBackground( mContext ) ) {
mapBackground();
} else {
mapFrount();
}
}
}
}

View File

@@ -23,6 +23,7 @@ import com.mogo.map.navi.MogoNaviConfig;
import com.mogo.map.navi.MogoNaviInfo;
import com.mogo.map.uicontroller.EnumMapUI;
import com.mogo.map.uicontroller.MapControlResult;
import com.mogo.module.common.map.CustomNaviInterrupter;
import com.mogo.service.IMogoServiceApis;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.intent.IMogoIntentListener;
@@ -116,10 +117,13 @@ public class MapPresenter extends Presenter< MapView > implements
onChangeDayNightMode( day_night_mode );
//继续导航
} else if ( key_type == 10049 ) {
// boolean extra_endurance_data = intent.getBooleanExtra( "EXTRA_ENDURANCE_DATA", false );
// if ( extra_endurance_data ) {
// onContinueNavigation();
// }
if ( CustomNaviInterrupter.getInstance().interrupt() ) {
return;
}
boolean extra_endurance_data = intent.getBooleanExtra( "EXTRA_ENDURANCE_DATA", false );
if ( extra_endurance_data ) {
onContinueNavigation();
}
} else if ( key_type == 10006 ) {
// 避免冲突,会同时发送两个广播,这里不操作。
//int extra_is_show = intent.getIntExtra( "EXTRA_IS_SHOW", 0 );
@@ -131,12 +135,21 @@ public class MapPresenter extends Presenter< MapView > implements
} else if ( key_type == 10005 ) {
int navi_route_prefer = intent.getIntExtra( "NAVI_ROUTE_PREFER", type );
} else if ( key_type == 20009 ) {
// onOpenNavi();
if ( CustomNaviInterrupter.getInstance().interrupt() ) {
return;
}
onOpenNavi();
} else if ( key_type == 10038 || key_type == 10007 ) {
// mLauncher.backToLauncher( getContext() );
// onChoosePath( intent, key_type );
if ( CustomNaviInterrupter.getInstance().interrupt() ) {
return;
}
mLauncher.backToLauncher( getContext() );
onChoosePath( intent, key_type );
} else if ( key_type == 10021 ) {
// onStopNaviInternal();
if ( CustomNaviInterrupter.getInstance().interrupt() ) {
return;
}
onStopNaviInternal();
} else if ( key_type == 10005 ) {
// 仅在导航场景下,⽀持第三⽅进⾏路线偏好的重新选择。
// 避免收费 | 1
@@ -149,12 +162,15 @@ public class MapPresenter extends Presenter< MapView > implements
// 不走高速躲避收费和拥堵 | 8
// 高速优先 | 20
// 躲避拥堵且高速优先 | 24
// int prefer = intent.getIntExtra( "NAVI_ROUTE_PREFER", 0 );
// MogoNaviConfig config = new MogoNaviConfig().congestion( prefer == 4 )
// .cost( prefer == 1 || prefer == 7 )
// .highSpeed( prefer == 20 )
// .avoidSpeed( prefer == 3 );
// mMogoMapService.getNavi( getContext() ).reCalculateRoute( config );
if ( CustomNaviInterrupter.getInstance().interrupt() ) {
return;
}
int prefer = intent.getIntExtra( "NAVI_ROUTE_PREFER", 0 );
MogoNaviConfig config = new MogoNaviConfig().congestion( prefer == 4 )
.cost( prefer == 1 || prefer == 7 )
.highSpeed( prefer == 20 )
.avoidSpeed( prefer == 3 );
mMogoMapService.getNavi( getContext() ).reCalculateRoute( config );
}
}
@@ -279,16 +295,18 @@ public class MapPresenter extends Presenter< MapView > implements
private void zoomMap( boolean zoomIn ) {
boolean isLocked = mMogoMapService.getMapUIController().isCarLocked();
MapControlResult result = mView.getUIController().changeZoom( zoomIn );
// if ( result == MapControlResult.TARGET ) {
// UiThreadHandler.postDelayed( () -> {
// if ( zoomIn ) {
// AIAssist.getInstance( getContext() ).speakTTSVoice( "地图已是最大", VoicePreemptType.PREEMPT_TYPE_NEXT, null );
// } else {
// AIAssist.getInstance( getContext() ).speakTTSVoice( "地图已是最小", VoicePreemptType.PREEMPT_TYPE_NEXT, null );
// }
// }, 1_000L ); // 避免小智障播放完毕之前播报
// return;
// }
if (! CustomNaviInterrupter.getInstance().interrupt() ) {
if ( result == MapControlResult.TARGET ) {
UiThreadHandler.postDelayed( () -> {
if ( zoomIn ) {
AIAssist.getInstance( getContext() ).speakTTSVoice( "地图已是最大", VoicePreemptType.PREEMPT_TYPE_NEXT, null );
} else {
AIAssist.getInstance( getContext() ).speakTTSVoice( "地图已是最小", VoicePreemptType.PREEMPT_TYPE_NEXT, null );
}
}, 1_000L ); // 避免小智障播放完毕之前播报
return;
}
}
if ( isLocked ) {
// 保持锁车状态
UiThreadHandler.postDelayed( () -> {

View File

@@ -2,14 +2,19 @@ package com.mogo.module.service.intent;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.net.Uri;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.map.MogoLatLng;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.MogoMarkerOptions;
import com.mogo.map.search.geo.IMogoGeoSearch;
import com.mogo.map.search.geo.IMogoGeoSearchListener;
import com.mogo.map.search.geo.MogoGeocodeResult;
@@ -24,6 +29,9 @@ import com.mogo.utils.TipToast;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.network.utils.GsonUtil;
import java.util.ArrayList;
import java.util.List;
/**
* @author congtaowang
* @since 2020-04-17
@@ -148,6 +156,120 @@ public class MockIntentHandler implements IntentHandler {
double lon = intent.getFloatExtra( "lon", 0.0f );
MarkerServiceHandler.getNavi().naviTo( new MogoLatLng( lat, lon ) );
}
case 14: {
List< MogoLatLng > mogoLatLngs = new ArrayList<>();
mogoLatLngs.add(new MogoLatLng(116.396716,39.615986));
mogoLatLngs.add(new MogoLatLng(116.396995,39.616007));
mogoLatLngs.add(new MogoLatLng(116.397169,39.616012));
mogoLatLngs.add(new MogoLatLng(116.397343,39.616017));
mogoLatLngs.add(new MogoLatLng(116.397517,39.616022));
mogoLatLngs.add(new MogoLatLng(116.397693,39.616029));
mogoLatLngs.add(new MogoLatLng(116.397896,39.616039));
mogoLatLngs.add(new MogoLatLng(116.3981,39.616051));
mogoLatLngs.add(new MogoLatLng(116.39827,39.616058));
mogoLatLngs.add(new MogoLatLng(116.398441,39.616066));
mogoLatLngs.add(new MogoLatLng(116.398612,39.616074));
mogoLatLngs.add(new MogoLatLng(116.398787,39.616083));
mogoLatLngs.add(new MogoLatLng(116.39899,39.616093));
mogoLatLngs.add(new MogoLatLng(116.399195,39.616105));
mogoLatLngs.add(new MogoLatLng(116.399334,39.616112));
mogoLatLngs.add(new MogoLatLng(116.399473,39.61612));
mogoLatLngs.add(new MogoLatLng(116.399612,39.616128));
mogoLatLngs.add(new MogoLatLng(116.399751,39.616136));
mogoLatLngs.add(new MogoLatLng(116.399893,39.616148));
mogoLatLngs.add(new MogoLatLng(116.40008,39.616153));
mogoLatLngs.add(new MogoLatLng(116.400301,39.616159));
mogoLatLngs.add(new MogoLatLng(116.400471,39.616167));
mogoLatLngs.add(new MogoLatLng(116.400642,39.616175));
mogoLatLngs.add(new MogoLatLng(116.400813,39.616183));
mogoLatLngs.add(new MogoLatLng(116.400988,39.616192));
mogoLatLngs.add(new MogoLatLng(116.401191,39.616201));
mogoLatLngs.add(new MogoLatLng(116.401396,39.616213));
mogoLatLngs.add(new MogoLatLng(116.401728,39.616235));
mogoLatLngs.add(new MogoLatLng(116.401986,39.616246));
mogoLatLngs.add(new MogoLatLng(116.402146,39.61625));
mogoLatLngs.add(new MogoLatLng(116.402307,39.616255));
mogoLatLngs.add(new MogoLatLng(116.402468,39.61626));
mogoLatLngs.add(new MogoLatLng(116.40263,39.616267));
mogoLatLngs.add(new MogoLatLng(116.402762,39.616272));
mogoLatLngs.add(new MogoLatLng(116.402894,39.616277));
mogoLatLngs.add(new MogoLatLng(116.403026,39.616282));
mogoLatLngs.add(new MogoLatLng(116.403158,39.616287));
mogoLatLngs.add(new MogoLatLng(116.40329,39.616292));
mogoLatLngs.add(new MogoLatLng(116.403422,39.616297));
mogoLatLngs.add(new MogoLatLng(116.403554,39.616302));
mogoLatLngs.add(new MogoLatLng(116.403686,39.616307));
mogoLatLngs.add(new MogoLatLng(116.403821,39.616321));
mogoLatLngs.add(new MogoLatLng(116.404045,39.616331));
mogoLatLngs.add(new MogoLatLng(116.404272,39.616343));
mogoLatLngs.add(new MogoLatLng(116.404551,39.616353));
mogoLatLngs.add(new MogoLatLng(116.404753,39.616363));
mogoLatLngs.add(new MogoLatLng(116.404958,39.616375));
mogoLatLngs.add(new MogoLatLng(116.405055,39.616375));
mogoLatLngs.add(new MogoLatLng(116.405184,39.616379));
mogoLatLngs.add(new MogoLatLng(116.405313,39.616384));
mogoLatLngs.add(new MogoLatLng(116.405442,39.616389));
mogoLatLngs.add(new MogoLatLng(116.405571,39.616394));
mogoLatLngs.add(new MogoLatLng(116.4057,39.616399));
mogoLatLngs.add(new MogoLatLng(116.405829,39.616404));
mogoLatLngs.add(new MogoLatLng(116.405958,39.616409));
mogoLatLngs.add(new MogoLatLng(116.406087,39.616414));
mogoLatLngs.add(new MogoLatLng(116.406216,39.616419));
mogoLatLngs.add(new MogoLatLng(116.406345,39.616424));
mogoLatLngs.add(new MogoLatLng(116.406474,39.616429));
mogoLatLngs.add(new MogoLatLng(116.406611,39.61644));
mogoLatLngs.add(new MogoLatLng(116.406879,39.616461));
mogoLatLngs.add(new MogoLatLng(116.407033,39.616465));
mogoLatLngs.add(new MogoLatLng(116.407187,39.616469));
mogoLatLngs.add(new MogoLatLng(116.407341,39.616473));
mogoLatLngs.add(new MogoLatLng(116.407495,39.616477));
mogoLatLngs.add(new MogoLatLng(116.407694,39.616483));
mogoLatLngs.add(new MogoLatLng(116.407876,39.616493));
mogoLatLngs.add(new MogoLatLng(116.408059,39.616504));
mogoLatLngs.add(new MogoLatLng(116.408327,39.616515));
mogoLatLngs.add(new MogoLatLng(116.408596,39.616526));
mogoLatLngs.add(new MogoLatLng(116.408757,39.616536));
mogoLatLngs.add(new MogoLatLng(116.409025,39.616547));
mogoLatLngs.add(new MogoLatLng(116.409227,39.616556));
mogoLatLngs.add(new MogoLatLng(116.409432,39.616568));
mogoLatLngs.add(new MogoLatLng(116.409711,39.616579));
mogoLatLngs.add(new MogoLatLng(116.409914,39.61659));
mogoLatLngs.add(new MogoLatLng(116.410119,39.616601));
mogoLatLngs.add(new MogoLatLng(116.410387,39.616601));
mogoLatLngs.add(new MogoLatLng(116.410602,39.616601));
mogoLatLngs.add(new MogoLatLng(116.410816,39.616622));
mogoLatLngs.add(new MogoLatLng(116.411084,39.616633));
mogoLatLngs.add(new MogoLatLng(116.411395,39.616643));
mogoLatLngs.add(new MogoLatLng(116.411492,39.616654));
mogoLatLngs.add(new MogoLatLng(116.411771,39.616665));
mogoLatLngs.add(new MogoLatLng(116.411974,39.616674));
mogoLatLngs.add(new MogoLatLng(116.412178,39.616686));
mogoLatLngs.add(new MogoLatLng(116.412447,39.616697));
mogoLatLngs.add(new MogoLatLng(116.412586,39.616697));
mogoLatLngs.add(new MogoLatLng(116.412876,39.616718));
mogoLatLngs.add(new MogoLatLng(116.413144,39.616729));
mogoLatLngs.add(new MogoLatLng(116.413347,39.616738));
mogoLatLngs.add(new MogoLatLng(116.413551,39.61675));
mogoLatLngs.add(new MogoLatLng(116.41383,39.61675));
mogoLatLngs.add(new MogoLatLng(116.414002,39.616761));
mogoLatLngs.add(new MogoLatLng(116.414098,39.616761));
mogoLatLngs.add(new MogoLatLng(116.414279,39.616767));
mogoLatLngs.add(new MogoLatLng(116.414461,39.616774));
mogoLatLngs.add(new MogoLatLng(116.414645,39.616782));
mogoLatLngs.add(new MogoLatLng(116.41483,39.616792));
mogoLatLngs.add(new MogoLatLng(116.415016,39.616802));
mogoLatLngs.add(new MogoLatLng(116.415203,39.616814));
mogoLatLngs.add(new MogoLatLng(116.415395,39.616824));
mogoLatLngs.add(new MogoLatLng(116.415589,39.616836));
mogoLatLngs.add(new MogoLatLng(116.415745,39.616842));
mogoLatLngs.add(new MogoLatLng(116.415902,39.616849));
mogoLatLngs.add(new MogoLatLng(116.416061,39.616857));
mogoLatLngs.add(new MogoLatLng(116.416307,39.616868));
MogoMarkerOptions options = new MogoMarkerOptions();
options.icon( BitmapFactory.decodeResource( AbsMogoApplication.getApp().getResources(), R.drawable.icon_map_marker_car_gray ) )
.position( mogoLatLngs.get( 0 ) );
IMogoMarker marker = MarkerServiceHandler.getMarkerManager().addMarker( TAG, options );
}
break;
}
}