diff --git a/.idea/misc.xml b/.idea/misc.xml index 707ee6e613..2dc54c489f 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java index 9ade3e9fa8..1c66284099 100644 --- a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java +++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java @@ -271,7 +271,6 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent @Override public void onIntentReceived( String intentStr, Intent intent ) { int key_type = intent.getIntExtra( "KEY_TYPE", 0 ); - int type = intent.getIntExtra( "EXTRA_TYPE", -1 ); int opera_type = intent.getIntExtra( "EXTRA_OPERA", -1 ); if ( key_type == 10027 ) { diff --git a/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapPresenter.java b/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapPresenter.java index 587133880e..127ad28b9e 100644 --- a/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapPresenter.java +++ b/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapPresenter.java @@ -15,8 +15,10 @@ import com.mogo.commons.mvp.Presenter; import com.mogo.commons.voice.AIAssist; import com.mogo.commons.voice.IMogoVoiceCmdCallBack; import com.mogo.commons.voice.VoicePreemptType; +import com.mogo.map.MogoLatLng; import com.mogo.map.navi.IMogoNavi; import com.mogo.map.navi.IMogoNaviListener2; +import com.mogo.map.navi.MogoNaviConfig; import com.mogo.map.navi.MogoNaviInfo; import com.mogo.map.navi.MogoTraffic; import com.mogo.map.uicontroller.EnumMapUI; @@ -80,81 +82,68 @@ public class MapPresenter extends Presenter< MapView > implements public void onReceive( Context context, Intent intent ) { String action = intent.getAction(); Logger.d( TAG, "action = %s", action ); - if ( TextUtils.equals( action, AUTONAVI_STANDARD_BROADCAST_RECV ) ) { - int key_type = intent.getIntExtra( "KEY_TYPE", 0 ); - int type = intent.getIntExtra( "EXTRA_TYPE", -1 ); - int opera_type = intent.getIntExtra( "EXTRA_OPERA", -1 ); - Logger.d( "NaviManager", "key_type" + key_type ); - if ( key_type == 10027 ) { - - if ( type == 0 ) { - mView.getUIController().setTrafficEnabled( opera_type == 0 ); - } else if ( type == 1 ) { - zoomMap( opera_type == 0 ); - } else if ( type == 2 ) { - - mMogoIntentManager.invoke( AUTONAVI_STANDARD_BROADCAST_RECV, intent ); - if ( opera_type == 0 ) { - mView.getUIController().changeMapMode( EnumMapUI.CarUp_2D ); - } else if ( opera_type == 1 ) { - mView.getUIController().changeMapMode( EnumMapUI.NorthUP_2D ); - } else if ( opera_type == 2 ) { - mView.getUIController().changeMapMode( EnumMapUI.CarUp_3D ); - } - - } - } else if ( key_type == 10048 ) { - //* @param type 0:自动; 1:白天; 2:黑夜 - int day_night_mode = intent.getIntExtra( "EXTRA_DAY_NIGHT_MODE", -1 ); - if ( day_night_mode == 0 ) { - mView.getUIController().changeMapMode( EnumMapUI.Type_AUTO_LIGHT_Night ); - } else if ( day_night_mode == 1 ) { - mView.getUIController().changeMapMode( EnumMapUI.Type_Light ); - } else if ( day_night_mode == 2 ) { - mView.getUIController().changeMapMode( EnumMapUI.Type_Night ); - } - - //intent.setAction("AUTONAVI_STANDARD_BROADCAST_RECV"); - //intent.putExtra("KEY_TYPE", 10049); - //intent.putExtra("EXTRA_ENDURANCE_DATA", continueNavi); - //继续导航 - } else if ( key_type == 10049 ) { - 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 ); -// if ( extra_is_show == 0 ) { -// onDisplayOverview(); -// } else { -// onContinueNavigation(); -// } - } else if ( key_type == 10005 ) { - int navi_route_prefer = intent.getIntExtra( "NAVI_ROUTE_PREFER", type ); - - - } else if ( key_type == 20009 ) { - onOpenNavi(); + if ( !TextUtils.equals( action, AUTONAVI_STANDARD_BROADCAST_RECV ) ) { + return; + } + int key_type = intent.getIntExtra( "KEY_TYPE", 0 ); + int type = intent.getIntExtra( "EXTRA_TYPE", -1 ); + int opera_type = intent.getIntExtra( "EXTRA_OPERA", -1 ); + Logger.d( TAG, "key_type" + key_type ); + if ( key_type == 10027 ) { + if ( type == 0 ) { + onChangeTrafficMode( opera_type ); + } else if ( type == 1 ) { + zoomMap( opera_type == 0 ); + } else if ( type == 2 ) { + mMogoIntentManager.invoke( AUTONAVI_STANDARD_BROADCAST_RECV, intent ); + onChangeCameraMode( opera_type ); } - - ///** - // * 仅在导航场景下,⽀持第三⽅进⾏路线偏好的重新选择。 - // * `避免收费` |`1` `多策略算路` |`2` `不走高速` |`3` ` 躲避拥堵` |`4` `不走高速且避免收费` |`5` `不走高速且躲避拥堵` |`6` - // * `躲避收费和拥堵` |`7` `不走高速躲避收费和拥堵` |`8` `高速优先` |`20` `躲避拥堵且高速优先` |`24` - // * - // * @param context - // * @param type - // */ - //public static void setUserPreference(Context context, int type) { - // Intent intent = new Intent(); - // intent.setAction("AUTONAVI_STANDARD_BROADCAST_RECV"); - // intent.putExtra("KEY_TYPE", 10005); - // intent.putExtra("NAVI_ROUTE_PREFER", type); - // context.sendBroadcast(intent); + } else if ( key_type == 10048 ) { + //0:自动; 1:白天; 2:黑夜; + int day_night_mode = intent.getIntExtra( "EXTRA_DAY_NIGHT_MODE", -1 ); + onChangeDayNightMode( day_night_mode ); + //继续导航 + } else if ( key_type == 10049 ) { + 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 ); + //if ( extra_is_show == 0 ) { + // onDisplayOverview(); + //} else { + // onContinueNavigation(); //} - // + } else if ( key_type == 10005 ) { + int navi_route_prefer = intent.getIntExtra( "NAVI_ROUTE_PREFER", type ); + } else if ( key_type == 20009 ) { + onOpenNavi(); + } else if ( key_type == 10038 || key_type == 10007 ) { + mLauncher.backToLauncher( getContext() ); + onChoosePath( intent, key_type ); + } else if ( key_type == 10021 ) { + onStopNaviInternal(); + } else if ( key_type == 10005 ) { + // 仅在导航场景下,⽀持第三⽅进⾏路线偏好的重新选择。 + // 避免收费 | 1 + // 多策略算路 | 2 + // 不走高速 | 3 + // 躲避拥堵 | 4 + // 不走高速且避免收费 | 5 + // 不走高速且躲避拥堵 | 6 + // 躲避收费和拥堵 | 7 + // 不走高速躲避收费和拥堵 | 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 ); } } @@ -165,6 +154,66 @@ public class MapPresenter extends Presenter< MapView > implements getContext().registerReceiver( broadcastReceiver, inputFilter ); } + /** + * 切换交通态势模式 + * + * @param mode + */ + private void onChangeTrafficMode( int mode ) { + mView.getUIController().setTrafficEnabled( mode == 0 ); + } + + /** + * 切换地图视图朝向模式 + */ + private void onChangeCameraMode( int mode ) { + if ( mode == 0 ) { + mView.getUIController().changeMapMode( EnumMapUI.CarUp_2D ); + } else if ( mode == 1 ) { + mView.getUIController().changeMapMode( EnumMapUI.NorthUP_2D ); + } else if ( mode == 2 ) { + mView.getUIController().changeMapMode( EnumMapUI.CarUp_3D ); + } + } + + /** + * 切换白天黑夜模式 + * + * @param mode + */ + private void onChangeDayNightMode( int mode ) { + if ( mode == 0 ) { + mView.getUIController().changeMapMode( EnumMapUI.Type_AUTO_LIGHT_Night ); + } else if ( mode == 1 ) { + mView.getUIController().changeMapMode( EnumMapUI.Type_Light ); + } else if ( mode == 2 ) { + mView.getUIController().changeMapMode( EnumMapUI.Type_Night ); + } + } + + private void onStopNaviInternal() { + mMogoMapService.getNavi( getContext() ).stopNavi(); + } + + + /** + * 唤醒指令导航去哪里 + */ + private void onChoosePath( Intent intent, int type ) { + double lat; + double lon; + + if ( type == 10007 ) { + lat = intent.getDoubleExtra( "ENTRY_LAT", 0.0 ); + lon = intent.getDoubleExtra( "ENTRY_LON", 0.0 ); + } else { + lat = intent.getDoubleExtra( "LAT", 0.0 ); + lon = intent.getDoubleExtra( "LON", 0.0 ); + + } + mMogoAddressManager.calculatePath( new MogoLatLng( lat, lon ) ); + } + /** * 继续导航 */ diff --git a/modules/mogo-module-search/src/main/java/com/mogo/module/navi/manager/MogoAddressManager.java b/modules/mogo-module-search/src/main/java/com/mogo/module/navi/manager/MogoAddressManager.java index 27790e3ad2..6c290d1675 100644 --- a/modules/mogo-module-search/src/main/java/com/mogo/module/navi/manager/MogoAddressManager.java +++ b/modules/mogo-module-search/src/main/java/com/mogo/module/navi/manager/MogoAddressManager.java @@ -46,6 +46,5 @@ public class MogoAddressManager implements IMogoAddressManager { AddressManager.INSTANCE.init(context); SearchServiceHolder.INSTANCE.init(context); SettingManager.INSTANCE.init(context); - NaviManager.INSTANCE.init(context); } } diff --git a/modules/mogo-module-search/src/main/java/com/mogo/module/navi/manager/NaviManager.kt b/modules/mogo-module-search/src/main/java/com/mogo/module/navi/manager/NaviManager.kt deleted file mode 100644 index 59bdc35972..0000000000 --- a/modules/mogo-module-search/src/main/java/com/mogo/module/navi/manager/NaviManager.kt +++ /dev/null @@ -1,86 +0,0 @@ -package com.mogo.module.navi.manager - -import android.content.BroadcastReceiver -import android.content.Context -import android.content.Intent -import android.content.IntentFilter -import android.text.TextUtils -import com.mogo.map.MogoLatLng -import com.mogo.map.navi.MogoNaviConfig -import com.mogo.module.common.MogoModulePaths -import com.mogo.module.navi.constants.SearchServiceHolder -import com.mogo.module.navi.ui.search.ChoosePathFragment -import com.mogo.module.navi.ui.search.SearchFragment -import com.mogo.service.fragmentmanager.FragmentDescriptor -import com.mogo.utils.logger.Logger - -/** - *@author zyz - * 2020-01-18. - */ -object NaviManager { - private lateinit var mReceiver: BroadcastReceiver - private val AUTONAVI_STANDARD_BROADCAST_RECV = "AUTONAVI_STANDARD_BROADCAST_RECV" - - fun init(context: Context) { - mReceiver = object : BroadcastReceiver() { - override fun onReceive(context: Context, intent: Intent) { - val action = intent.action - if (TextUtils.equals(action, AUTONAVI_STANDARD_BROADCAST_RECV)) { - val key_type = intent.getIntExtra("KEY_TYPE", 0) - Logger.d("NaviManager", "key_type" + key_type, null) - if (key_type == 10038 || key_type == 10007) { - SearchServiceHolder.mogoLauncher.backToLauncher(context) - choosePath(intent, key_type) - } else if (key_type == 10021) { - SearchServiceHolder.getNavi().stopNavi() - } else if (key_type == 10005) { - -// * 仅在导航场景下,⽀持第三⽅进⾏路线偏好的重新选择。 -// * `避免收费` |`1` `多策略算路` |`2` `不走高速` |`3` ` 躲避拥堵` |`4` `不走高速且避免收费` |`5` `不走高速且躲避拥堵` |`6` -// * `躲避收费和拥堵` |`7` `不走高速躲避收费和拥堵` |`8` `高速优先` |`20` `躲避拥堵且高速优先` |`24` -// * - var prefer = intent.getIntExtra("NAVI_ROUTE_PREFER", 0) - - var avoidSpeed = MogoNaviConfig().congestion(prefer == 4) - .cost(prefer == 1 || prefer == 7) - .highSpeed(prefer == 20) - .avoidSpeed(prefer == 3) - SearchServiceHolder.getNavi().reCalculateRoute(avoidSpeed) - - } - - } - } - - /** - * 打开地图 - */ - private fun gotoSearch() { - AddressManager.goSearch() - } - - /** - * 唤醒指令导航去哪里 - */ - private fun choosePath(intent: Intent, type: Int) { - val lat: Double - val lon: Double - - if (type == 10007) { - lat = intent.getDoubleExtra("ENTRY_LAT", 0.0) - lon = intent.getDoubleExtra("ENTRY_LON", 0.0) - } else { - lat = intent.getDoubleExtra("LAT", 0.0) - lon = intent.getDoubleExtra("LON", 0.0) - - } - AddressManager.calculatePath(MogoLatLng(lat, lon)) - } - } - val inputFilter = IntentFilter() - inputFilter.addAction(AUTONAVI_STANDARD_BROADCAST_RECV) - context.registerReceiver(mReceiver, inputFilter) - - } -} \ No newline at end of file