{
- if (!isTrue) {
- TopViewAnimHelper.getInstance().removeAllView();
- }
- });
}
@Override
diff --git a/modules/mogo-module-map/src/main/java/com/mogo/module/map/AutoNaviBroadcastReceiver.java b/modules/mogo-module-map/src/main/java/com/mogo/module/map/AutoNaviBroadcastReceiver.java
new file mode 100644
index 0000000000..242bbbce63
--- /dev/null
+++ b/modules/mogo-module-map/src/main/java/com/mogo/module/map/AutoNaviBroadcastReceiver.java
@@ -0,0 +1,127 @@
+package com.mogo.module.map;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.text.TextUtils;
+
+import com.mogo.commons.AbsMogoApplication;
+import com.mogo.map.navi.MogoNaviConfig;
+import com.mogo.map.uicontroller.EnumMapUI;
+import com.mogo.utils.logger.Logger;
+
+public
+/**
+ * @author congtaowang
+ * @since 2020/7/30
+ *
+ * 接收高德地图车机版广播
+ */
+class AutoNaviBroadcastReceiver extends BroadcastReceiver {
+
+ public static final String TAG = "AutoNaviBroadcastReceiver";
+
+ public static final String AUTONAVI_STANDARD_BROADCAST_RECV = "AUTONAVI_STANDARD_BROADCAST_RECV";
+
+ public void register() {
+ IntentFilter inputFilter = new IntentFilter();
+ inputFilter.addAction( AUTONAVI_STANDARD_BROADCAST_RECV );
+ AbsMogoApplication.getApp().registerReceiver( this, inputFilter );
+ }
+
+ public void unregister() {
+ mCallback = null;
+ AbsMogoApplication.getApp().unregisterReceiver( this );
+ }
+
+ private OnMapControlCallback mCallback;
+
+ public void setCallback( OnMapControlCallback mCallback ) {
+ this.mCallback = mCallback;
+ }
+
+ @Override
+ public void onReceive( Context context, Intent intent ) {
+ String action = intent.getAction();
+
+ int keyType = intent.getIntExtra( "KEY_TYPE", 0 );
+ int type = intent.getIntExtra( "EXTRA_TYPE", -1 );
+ int operaType = intent.getIntExtra( "EXTRA_OPERA", -1 );
+
+ Logger.d( TAG, "action = %s, keyType=%s, type=%s, operType=%s", action, keyType, type, operaType );
+
+ if ( !TextUtils.equals( action, AUTONAVI_STANDARD_BROADCAST_RECV ) ) {
+ return;
+ }
+
+ if ( mCallback == null ) {
+ return;
+ }
+
+ if ( keyType == 10027 ) {
+ if ( type == 0 ) {
+ mCallback.onTrafficModeChanged( operaType == 0 );
+ } else if ( type == 2 ) {
+ if ( operaType == 0 ) {
+ mCallback.onCameraModeChanged( EnumMapUI.CarUp_2D );
+ } else if ( operaType == 1 ) {
+ mCallback.onCameraModeChanged( EnumMapUI.NorthUP_2D );
+ } else if ( operaType == 2 ) {
+ mCallback.onCameraModeChanged( EnumMapUI.CarUp_3D );
+ }
+ }
+ } else if ( keyType == 10048 ) {
+ //0:自动; 1:白天; 2:黑夜;
+ int dayNightMode = intent.getIntExtra( "EXTRA_DAY_NIGHT_MODE", -1 );
+ if ( dayNightMode == 0 ) {
+ mCallback.onDayNightModeChanged( EnumMapUI.Type_AUTO_LIGHT_Night );
+ } else if ( dayNightMode == 1 ) {
+ mCallback.onDayNightModeChanged( EnumMapUI.Type_Light );
+ } else if ( dayNightMode == 2 ) {
+ mCallback.onDayNightModeChanged( EnumMapUI.Type_Night );
+ }
+ } else if ( keyType == 10049 ) {
+ //继续导航
+ boolean extraEnduranceData = intent.getBooleanExtra( "EXTRA_ENDURANCE_DATA", false );
+ if ( extraEnduranceData ) {
+ mCallback.onContinueNavi();
+ }
+ } else if ( keyType == 20009 ) {
+ mCallback.onOpenNavi();
+ } else if ( keyType == 10038 || keyType == 10007 ) {
+ 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 );
+ }
+ mCallback.onCalculatePath( lon, lat );
+ } else if ( keyType == 10021 ) {
+ mCallback.onStopNaviInternal( intent );
+ } else if ( keyType == 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 );
+ mCallback.onReCalculatePath( config );
+ }
+ mCallback.onEnd( intent );
+ }
+}
diff --git a/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapControlCommandHandler.java b/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapControlCommandHandler.java
new file mode 100644
index 0000000000..e8a38b4c45
--- /dev/null
+++ b/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapControlCommandHandler.java
@@ -0,0 +1,94 @@
+package com.mogo.module.map;
+
+import com.mogo.map.uicontroller.EnumMapUI;
+import com.mogo.utils.logger.Logger;
+
+public
+/**
+ * @author congtaowang
+ * @since 2020/7/30
+ *
+ * 语音控制地图
+ */
+class MapControlCommandHandler {
+
+ private static final String TAG = "CustomVoiceCommandHandler";
+
+ private OnMapControlCallback mCallback;
+
+ public void setCallback( OnMapControlCallback mCallback ) {
+ this.mCallback = mCallback;
+ }
+
+ public void handleVoiceCommand( String cmd ) {
+ Logger.d( TAG, cmd );
+ switch ( cmd ) {
+ case VoiceConstants.CMD_MAP_TRAFFIC_MODE_UN_WAKEUP:
+ case VoiceConstants.CMD_MAP_TRAFFIC_MODE:
+ mCallback.onTrafficModeChanged( true );
+ break;
+ case VoiceConstants.CMD_MAP_UN_TRAFFIC_MODE_UN_WAKEUP:
+ case VoiceConstants.CMD_MAP_UN_TRAFFIC_MODE:
+ mCallback.onTrafficModeChanged( false );
+ break;
+ case VoiceConstants.CMD_MAP_ZOOM_IN_UN_WAKEUP:
+ case VoiceConstants.CMD_MAP_ZOOM_IN:
+ mCallback.onZoomMap( true );
+ break;
+ case VoiceConstants.CMD_MAP_ZOOM_OUT_UN_WAKEUP:
+ case VoiceConstants.CMD_MAP_ZOOM_OUT:
+ mCallback.onZoomMap( false );
+ break;
+ case VoiceConstants.CMD_MAP_2D_UN_WAKEUP:
+ case VoiceConstants.CMD_MAP_2D:
+ case VoiceConstants.CMD_MAP_NORTH_UP_MODE_UN_WAKEUP:
+ case VoiceConstants.CMD_MAP_NORTH_UP_MODE:
+ mCallback.onCameraModeChanged( EnumMapUI.NorthUP_2D );
+ break;
+ case VoiceConstants.CMD_MAP_3D_UN_WAKEUP:
+ case VoiceConstants.CMD_MAP_3D:
+ mCallback.onCameraModeChanged( EnumMapUI.CarUp_3D );
+ break;
+ case VoiceConstants.CMD_MAP_DAY_TIME_MODE_UN_WAKEUP:
+ case VoiceConstants.CMD_MAP_DAY_TIME_MODE:
+ mCallback.onDayNightModeChanged( EnumMapUI.Type_Light );
+ break;
+ case VoiceConstants.CMD_MAP_HISTORY_UN_WAKEUP:
+ case VoiceConstants.CMD_MAP_HISTORY:
+ mCallback.onOpenNavi();
+ break;
+ case VoiceConstants.CMD_MAP_STOP_NAVI_MODE_UN_WAKEUP:
+ case VoiceConstants.CMD_MAP_STOP_NAVI_MODE:
+ break;
+ case VoiceConstants.CMD_MAP_NIGHT_MODE_UN_WAKEUP:
+ case VoiceConstants.CMD_MAP_NIGHT_MODE:
+ mCallback.onDayNightModeChanged( EnumMapUI.Type_Night );
+ break;
+ case VoiceConstants.CMD_MAP_AUTO_LIGHT_NIGHT_MODE_UN_WAKEUP:
+ case VoiceConstants.CMD_MAP_AUTO_LIGHT_NIGHT_MODE:
+ mCallback.onDayNightModeChanged( EnumMapUI.Type_AUTO_LIGHT_Night );
+ break;
+ case VoiceConstants.CMD_MAP_DISPLAY_OVERVIEW_MODE:
+ mCallback.onDisplayOverview();
+ break;
+ case VoiceConstants.CMD_MAP_CONTINUE_NAVI_MODE:
+ mCallback.onContinueNavi();
+ break;
+ case VoiceConstants.CMD_MAP_CAR_UP_MODE_UN_WAKEUP:
+ case VoiceConstants.CMD_MAP_CAR_UP_MODE:
+ mCallback.onCameraModeChanged( EnumMapUI.CarUp_2D );
+ break;
+ case VoiceConstants.CMD_MAP_SPEAK_DRAFT_MODE:
+ case VoiceConstants.CMD_MAP_SPEAK_DRAFT_MODE_UN_WAKEUP:
+ break;
+ case VoiceConstants.CMD_MAP_SPEAK_DETAIL_MODE:
+ case VoiceConstants.CMD_MAP_SPEAK_DETAIL_MODE_UN_WAKEUP:
+ break;
+ case VoiceConstants.CMD_MAP_SPEAK_REMAIN:
+ break;
+ default:
+ break;
+
+ }
+ }
+}
diff --git a/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapFragment.java b/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapFragment.java
index 9a51a52573..a563efc7da 100644
--- a/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapFragment.java
+++ b/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapFragment.java
@@ -39,9 +39,6 @@ public class MapFragment extends MvpFragment< MapView, MapPresenter > implements
@Override
protected void initViews() {
- //mMogoMapView = findViewById( R.id.module_map_id_map );
- //mMogoMap = mMogoMapView.getMap();
- //mMogoMap.getUIController().showMyLocation( true );
}
@Override
@@ -63,9 +60,6 @@ public class MapFragment extends MvpFragment< MapView, MapPresenter > implements
@Override
public void onActivityCreated( @Nullable Bundle savedInstanceState ) {
super.onActivityCreated( savedInstanceState );
- //if ( mMogoMapView != null ) {
- // mMogoMapView.onCreate( savedInstanceState );
- //}
initMapView();
}
@@ -125,7 +119,7 @@ public class MapFragment extends MvpFragment< MapView, MapPresenter > implements
uiSettings.setZoomControlsEnabled( false );
//设置双指缩放手势是否可用。
uiSettings.setZoomGesturesEnabled( true );
- mMogoMap.getUIController().changeMapMode(EnumMapUI.NorthUP_2D);
+ mMogoMap.getUIController().changeMapMode( EnumMapUI.NorthUP_2D );
}
}
}
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 0812fb9e2e..f72c5dea25 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
@@ -1,16 +1,12 @@
package com.mogo.module.map;
import android.app.ActivityManager;
-import android.content.BroadcastReceiver;
-import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
-import android.content.IntentFilter;
import android.graphics.Rect;
import android.text.TextUtils;
import androidx.annotation.NonNull;
-import androidx.annotation.UiThread;
import androidx.lifecycle.LifecycleOwner;
import com.alibaba.android.arouter.launcher.ARouter;
@@ -34,10 +30,8 @@ import com.mogo.service.launcher.IMogoLauncher;
import com.mogo.service.map.IMogoMapService;
import com.mogo.service.module.IMogoRegisterCenter;
import com.mogo.service.module.IMogoSearchManager;
-import com.mogo.service.module.IMogoSettingManager;
import com.mogo.service.statusmanager.IMogoStatusManager;
import com.mogo.service.strategy.IMogoRefreshStrategyController;
-import com.mogo.utils.AppUtils;
import com.mogo.utils.ResourcesHelper;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.logger.Logger;
@@ -54,10 +48,10 @@ import java.util.Map;
public class MapPresenter extends Presenter< MapView > implements
IMogoIntentListener,
IMogoVoiceCmdCallBack,
- IMogoNaviListener2 {
+ IMogoNaviListener2,
+ OnMapControlCallback {
private static final String TAG = "MapPresenter";
- private static final String AUTONAVI_STANDARD_BROADCAST_RECV = "AUTONAVI_STANDARD_BROADCAST_RECV";
private IMogoMapService mMogoMapService;
private IMogoIntentManager mMogoIntentManager;
private IMogoSearchManager mSearchManager;
@@ -66,7 +60,6 @@ public class MapPresenter extends Presenter< MapView > implements
private IMogoRegisterCenter mRegisterCenter;
private IMogoLauncher mLauncher;
private IMogoSearchManager mMogoSearchManager;
- private IMogoSettingManager mSettingManager;
private Rect mDisplayOverviewBounds;
@@ -80,114 +73,112 @@ public class MapPresenter extends Presenter< MapView > implements
mView.getUIController().recoverLockMode();
}
};
+ private AutoNaviBroadcastReceiver mAutoNaviReceiver;
+ private MapControlCommandHandler mCustomVoiceCommandHandler;
public MapPresenter( MapView view ) {
super( view );
initBroadcast();
+ mCustomVoiceCommandHandler = new MapControlCommandHandler();
+ mCustomVoiceCommandHandler.setCallback( this );
}
- private BroadcastReceiver broadcastReceiver;
-
/**
* opera type为0:0 实时路况开;1实时路况关 type为1:0 放大地图; 1缩小地图 type为2:0切换2d车上; 1切换2d北上;2切换3d车上支持
*/
private void initBroadcast() {
- // 高德地图免唤醒
- broadcastReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive( Context context, Intent intent ) {
- String action = intent.getAction();
- Logger.d( TAG, "action = %s", action );
+ mAutoNaviReceiver = new AutoNaviBroadcastReceiver();
+ mAutoNaviReceiver.setCallback( this );
+ mAutoNaviReceiver.register();
+ }
- if ( !TextUtils.equals( action, AUTONAVI_STANDARD_BROADCAST_RECV ) ) {
- return;
+ @Override
+ public void onTrafficModeChanged( boolean open ) {
+ mView.getUIController().setTrafficEnabled( open );
+ }
+
+ @Override
+ public void onCameraModeChanged( EnumMapUI mode ) {
+ mView.getUIController().changeMapMode( mode );
+ }
+
+ @Override
+ public void onDayNightModeChanged( EnumMapUI mode ) {
+ mView.getUIController().changeMapMode( mode );
+ }
+
+ @Override
+ public void onContinueNavi() {
+ if ( CustomNaviInterrupter.getInstance().interrupt() ) {
+ return;
+ }
+ if ( mStatusManager.isMainPageOnResume() ) {
+ mStatusManager.setDisplayOverview( TAG, false );
+ mView.getUIController().recoverLockMode();
+ AIAssist.getInstance( getContext() ).speakTTSVoice( "已为您继续导航" );
+ UiThreadHandler.removeCallbacks( mLockCarRunnable );
+ } else {
+ mLauncher.backToLauncher( getContext() );
+ UiThreadHandler.postDelayed( () -> {
+ try {
+ mStatusManager.setDisplayOverview( TAG, false );
+ mView.getUIController().recoverLockMode();
+ AIAssist.getInstance( getContext() ).speakTTSVoice( "已为您继续导航" );
+ UiThreadHandler.removeCallbacks( mLockCarRunnable );
+ } catch ( Exception e ) {
+ e.printStackTrace();
}
- 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 == 2 ) {
- onChangeCameraMode( opera_type );
- }
- } 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 ) {
- 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 );
- //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 ) {
- if ( CustomNaviInterrupter.getInstance().interrupt() ) {
- return;
- }
- onOpenNavi();
- } else if ( key_type == 10038 || key_type == 10007 ) {
- if ( CustomNaviInterrupter.getInstance().interrupt() ) {
- return;
- }
+ }, 2_000L );
+ }
+ }
+
+ @Override
+ public void onOpenNavi() {
+ if ( CustomNaviInterrupter.getInstance().interrupt() ) {
+ return;
+ }
+ mLauncher.backToLauncher( getContext() );
+ if ( !mMogoMapService.getNavi( getContext() ).isNaviing() && !mStatusManager.isSearchUIShow() ) {
+ mSearchManager.showSearch();
+ }
+ AIAssist.getInstance( getContext() ).speakTTSVoice( "已打开" );
+ }
+
+ @Override
+ public void onCalculatePath( double lon, double lat ) {
+ if ( CustomNaviInterrupter.getInstance().interrupt() ) {
+ return;
+ }
+ mLauncher.backToLauncher( getContext() );
+ mMogoSearchManager.calculatePath( new MogoLatLng( lat, lon ) );
+ }
+
+ @Override
+ public void onStopNaviInternal( Intent intent ) {
+ if ( CustomNaviInterrupter.getInstance().interrupt() ) {
+ // 导航过程中语音指令退出导航,会出现 activity 不走 onResume 的情况
+ UiThreadHandler.postDelayed( () -> {
+ if ( isForeground( getContext() ) && !hasOthersActivity() && !mStatusManager.isMainPageOnResume() ) {
mLauncher.backToLauncher( getContext() );
- onChoosePath( intent, key_type );
- } else if ( key_type == 10021 ) {
- if ( CustomNaviInterrupter.getInstance().interrupt() ) {
- // 导航过程中语音指令退出导航,会出现 activity 不走 onResume 的情况
- UiThreadHandler.postDelayed( () -> {
- if ( isForeground( getContext() ) && !hasOthersActivity() && !mStatusManager.isMainPageOnResume() ) {
- mLauncher.backToLauncher( getContext() );
- }
- }, 500L );
- mMogoIntentManager.invoke( AUTONAVI_STANDARD_BROADCAST_RECV, intent );
- return;
- }
- onStopNaviInternal();
- } else if ( key_type == 10005 ) {
- // 仅在导航场景下,⽀持第三⽅进⾏路线偏好的重新选择。
- // 避免收费 | 1
- // 多策略算路 | 2
- // 不走高速 | 3
- // 躲避拥堵 | 4
- // 不走高速且避免收费 | 5
- // 不走高速且躲避拥堵 | 6
- // 躲避收费和拥堵 | 7
- // 不走高速躲避收费和拥堵 | 8
- // 高速优先 | 20
- // 躲避拥堵且高速优先 | 24
- 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 );
-
}
- mMogoIntentManager.invoke( AUTONAVI_STANDARD_BROADCAST_RECV, intent );
- }
- };
+ }, 500L );
+ onEnd( intent );
+ return;
+ }
+ mMogoMapService.getNavi( getContext() ).stopNavi();
+ }
- IntentFilter inputFilter = new IntentFilter();
- inputFilter.addAction( AUTONAVI_STANDARD_BROADCAST_RECV );
- getContext().registerReceiver( broadcastReceiver, inputFilter );
+ @Override
+ public void onReCalculatePath( MogoNaviConfig config ) {
+ if ( CustomNaviInterrupter.getInstance().interrupt() ) {
+ return;
+ }
+ mMogoMapService.getNavi( getContext() ).reCalculateRoute( config );
+ }
+
+ @Override
+ public void onEnd( Intent intent ) {
+ mMogoIntentManager.invoke( AutoNaviBroadcastReceiver.AUTONAVI_STANDARD_BROADCAST_RECV, intent );
}
private boolean isForeground( Context context ) {
@@ -218,91 +209,8 @@ public class MapPresenter extends Presenter< MapView > implements
return true;
}
- /**
- * 切换交通态势模式
- *
- * @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 );
- }
- mMogoSearchManager.calculatePath( new MogoLatLng( lat, lon ) );
- }
-
- /**
- * 继续导航
- */
- private void onContinueNavigation() {
-
- if ( mStatusManager.isMainPageOnResume() ) {
- mStatusManager.setDisplayOverview( TAG, false );
- mView.getUIController().recoverLockMode();
- AIAssist.getInstance( getContext() ).speakTTSVoice( "已为您继续导航" );
- UiThreadHandler.removeCallbacks( mLockCarRunnable );
- } else {
- mLauncher.backToLauncher( getContext() );
- UiThreadHandler.postDelayed( () -> {
- try {
- mStatusManager.setDisplayOverview( TAG, false );
- mView.getUIController().recoverLockMode();
- AIAssist.getInstance( getContext() ).speakTTSVoice( "已为您继续导航" );
- UiThreadHandler.removeCallbacks( mLockCarRunnable );
- } catch ( Exception e ) {
- e.printStackTrace();
- }
- }, 2_000L );
- }
- }
-
- private void onDisplayOverview() {
+ @Override
+ public void onDisplayOverview() {
if ( !mMogoMapService.getNavi( getContext() ).isNaviing() ) {
Logger.d( TAG, "未开始导航." );
return;
@@ -329,7 +237,8 @@ public class MapPresenter extends Presenter< MapView > implements
UiThreadHandler.postDelayed( mLockCarRunnable, 20_000 );
}
- private void zoomMap( boolean zoomIn ) {
+ @Override
+ public void onZoomMap( boolean zoomIn ) {
boolean isLocked = mMogoMapService.getMapUIController().isCarLocked();
MapControlResult result = mView.getUIController().changeZoom( zoomIn );
if ( !CustomNaviInterrupter.getInstance().interrupt() ) {
@@ -356,14 +265,6 @@ public class MapPresenter extends Presenter< MapView > implements
}
}
- private void onOpenNavi() {
- mLauncher.backToLauncher( getContext() );
- if ( !mMogoMapService.getNavi( getContext() ).isNaviing() && !mStatusManager.isSearchUIShow() ) {
- mSearchManager.showSearch();
- }
- AIAssist.getInstance( getContext() ).speakTTSVoice( "已打开" );
- }
-
@Override
public void onCreate( @NonNull LifecycleOwner owner ) {
super.onCreate( owner );
@@ -378,7 +279,6 @@ public class MapPresenter extends Presenter< MapView > implements
mRegisterCenter.registerMogoNaviListener( TAG, this );
mLauncher = apis.getLauncherApi();
mMogoSearchManager = apis.getSearchManagerApi();
- mSettingManager = apis.getSettingManagerApi();
IMogoNavi mogoNavi = mMogoMapService.getNavi( getContext() );
mogoNavi.setCalculatePathDisplayBounds( new Rect(
@@ -416,8 +316,8 @@ public class MapPresenter extends Presenter< MapView > implements
@Override
public void onDestroy( @NonNull LifecycleOwner owner ) {
super.onDestroy( owner );
- if ( broadcastReceiver != null ) {
- getContext().unregisterReceiver( broadcastReceiver );
+ if ( mAutoNaviReceiver != null ) {
+ mAutoNaviReceiver.unregister();
}
}
@@ -454,82 +354,7 @@ public class MapPresenter extends Presenter< MapView > implements
@Override
public void onCmdSelected( String cmd ) {
Logger.d( TAG, cmd );
- switch ( cmd ) {
- case VoiceConstants.CMD_MAP_TRAFFIC_MODE_UN_WAKEUP:
- case VoiceConstants.CMD_MAP_TRAFFIC_MODE:
- mView.getUIController().setTrafficEnabled( true );
- break;
- case VoiceConstants.CMD_MAP_UN_TRAFFIC_MODE_UN_WAKEUP:
- case VoiceConstants.CMD_MAP_UN_TRAFFIC_MODE:
- mView.getUIController().setTrafficEnabled( false );
- break;
- case VoiceConstants.CMD_MAP_ZOOM_IN_UN_WAKEUP:
- case VoiceConstants.CMD_MAP_ZOOM_IN:
- zoomMap( true );
- break;
- case VoiceConstants.CMD_MAP_ZOOM_OUT_UN_WAKEUP:
- case VoiceConstants.CMD_MAP_ZOOM_OUT:
- zoomMap( false );
- break;
- case VoiceConstants.CMD_MAP_2D_UN_WAKEUP:
- case VoiceConstants.CMD_MAP_2D:
- case VoiceConstants.CMD_MAP_NORTH_UP_MODE_UN_WAKEUP:
- case VoiceConstants.CMD_MAP_NORTH_UP_MODE:
- mView.getUIController().changeMapMode( EnumMapUI.NorthUP_2D );
- break;
- case VoiceConstants.CMD_MAP_3D_UN_WAKEUP:
- case VoiceConstants.CMD_MAP_3D:
- mView.getUIController().changeMapMode( EnumMapUI.CarUp_3D );
- break;
- case VoiceConstants.CMD_MAP_DAY_TIME_MODE_UN_WAKEUP:
- case VoiceConstants.CMD_MAP_DAY_TIME_MODE:
- mView.getUIController().changeMapMode( EnumMapUI.Type_Light );
- AIAssist.getInstance( getContext() ).speakTTSVoice( "已切换", null );
- break;
- case VoiceConstants.CMD_MAP_HISTORY_UN_WAKEUP:
- case VoiceConstants.CMD_MAP_HISTORY:
- onOpenNavi();
- break;
- case VoiceConstants.CMD_MAP_STOP_NAVI_MODE_UN_WAKEUP:
- case VoiceConstants.CMD_MAP_STOP_NAVI_MODE:
- mLauncher.backToLauncher( getContext() );
- break;
- case VoiceConstants.CMD_MAP_NIGHT_MODE_UN_WAKEUP:
- case VoiceConstants.CMD_MAP_NIGHT_MODE:
- mView.getUIController().changeMapMode( EnumMapUI.Type_Night );
- AIAssist.getInstance( getContext() ).speakTTSVoice( "已切换", null );
- break;
- case VoiceConstants.CMD_MAP_AUTO_LIGHT_NIGHT_MODE_UN_WAKEUP:
- case VoiceConstants.CMD_MAP_AUTO_LIGHT_NIGHT_MODE:
- mView.getUIController().changeMapMode( EnumMapUI.Type_AUTO_LIGHT_Night );
- AIAssist.getInstance( getContext() ).speakTTSVoice( "已切换", null );
- break;
- case VoiceConstants.CMD_MAP_DISPLAY_OVERVIEW_MODE:
- onDisplayOverview();
- break;
- case VoiceConstants.CMD_MAP_CONTINUE_NAVI_MODE:
- onContinueNavigation();
- break;
- case VoiceConstants.CMD_MAP_CAR_UP_MODE_UN_WAKEUP:
- case VoiceConstants.CMD_MAP_CAR_UP_MODE:
- mView.getUIController().changeMapMode( EnumMapUI.CarUp_2D );
- AIAssist.getInstance( getContext() ).speakTTSVoice( "已切换", null );
- break;
- case VoiceConstants.CMD_MAP_SPEAK_DRAFT_MODE:
- case VoiceConstants.CMD_MAP_SPEAK_DRAFT_MODE_UN_WAKEUP:
- mSettingManager.speakDraft();
- AIAssist.getInstance( getContext() ).speakTTSVoice( "已切换", null );
- break;
- case VoiceConstants.CMD_MAP_SPEAK_DETAIL_MODE:
- case VoiceConstants.CMD_MAP_SPEAK_DETAIL_MODE_UN_WAKEUP:
- mSettingManager.speakDetail();
- AIAssist.getInstance( getContext() ).speakTTSVoice( "已切换", null );
- break;
- case VoiceConstants.CMD_MAP_SPEAK_REMAIN:
- break;
- default:
- break;
- }
+ mCustomVoiceCommandHandler.handleVoiceCommand( cmd );
}
@Override
diff --git a/modules/mogo-module-map/src/main/java/com/mogo/module/map/OnMapControlCallback.java b/modules/mogo-module-map/src/main/java/com/mogo/module/map/OnMapControlCallback.java
new file mode 100644
index 0000000000..d0d074da5e
--- /dev/null
+++ b/modules/mogo-module-map/src/main/java/com/mogo/module/map/OnMapControlCallback.java
@@ -0,0 +1,42 @@
+package com.mogo.module.map;
+
+import android.content.Intent;
+
+import com.mogo.map.navi.MogoNaviConfig;
+import com.mogo.map.uicontroller.EnumMapUI;
+
+public interface OnMapControlCallback {
+
+ // 交通态势
+ void onTrafficModeChanged( boolean open );
+
+ // 2d、3d模式切换、正北、车头
+ void onCameraModeChanged( EnumMapUI mode);
+
+ // 白天、黑夜模式切换
+ void onDayNightModeChanged( EnumMapUI mode );
+
+ // 继续导航
+ void onContinueNavi();
+
+ // 打开导航
+ void onOpenNavi();
+
+ // 开始路径规划
+ void onCalculatePath( double lon, double lat );
+
+ // 调用停止导航方法
+ void onStopNaviInternal( Intent intent );
+
+ // 重新规划路线
+ void onReCalculatePath( MogoNaviConfig config );
+
+ // 结束
+ void onEnd( Intent intent );
+
+ // 查看全程
+ void onDisplayOverview();
+
+ // 缩放地图
+ void onZoomMap( boolean zoomIn );
+}
\ No newline at end of file
diff --git a/modules/mogo-module-push-base/.gitignore b/modules/mogo-module-push-base/.gitignore
new file mode 100644
index 0000000000..796b96d1c4
--- /dev/null
+++ b/modules/mogo-module-push-base/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/modules/mogo-module-push-base/build.gradle b/modules/mogo-module-push-base/build.gradle
new file mode 100644
index 0000000000..3f5839e3b9
--- /dev/null
+++ b/modules/mogo-module-push-base/build.gradle
@@ -0,0 +1,47 @@
+apply plugin: 'com.android.library'
+apply plugin: 'kotlin-android'
+apply plugin: 'kotlin-android-extensions'
+apply plugin: 'kotlin-kapt'
+android {
+ compileSdkVersion rootProject.ext.android.compileSdkVersion
+ buildToolsVersion rootProject.ext.android.buildToolsVersion
+
+
+ defaultConfig {
+ minSdkVersion rootProject.ext.android.minSdkVersion
+ targetSdkVersion rootProject.ext.android.targetSdkVersion
+ versionCode Integer.valueOf(VERSION_CODE)
+ versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
+
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ consumerProguardFiles 'consumer-rules.pro'
+ kapt {
+ arguments {
+ arg("AROUTER_MODULE_NAME", project.getName())
+ }
+ }
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+
+ compileOptions {
+ targetCompatibility 1.8
+ sourceCompatibility 1.8
+ }
+
+ kotlinOptions {
+ jvmTarget = "1.8"
+ }
+
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+}
+
+apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
diff --git a/modules/mogo-module-push-base/consumer-rules.pro b/modules/mogo-module-push-base/consumer-rules.pro
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/modules/mogo-module-push-base/gradle.properties b/modules/mogo-module-push-base/gradle.properties
new file mode 100644
index 0000000000..653f4713ca
--- /dev/null
+++ b/modules/mogo-module-push-base/gradle.properties
@@ -0,0 +1,3 @@
+GROUP=com.mogo.module
+POM_ARTIFACT_ID=module-push-base
+VERSION_CODE=1
diff --git a/modules/mogo-module-push-base/proguard-rules.pro b/modules/mogo-module-push-base/proguard-rules.pro
new file mode 100644
index 0000000000..f1b424510d
--- /dev/null
+++ b/modules/mogo-module-push-base/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
diff --git a/modules/mogo-module-push-base/src/main/AndroidManifest.xml b/modules/mogo-module-push-base/src/main/AndroidManifest.xml
new file mode 100644
index 0000000000..9a8574da7b
--- /dev/null
+++ b/modules/mogo-module-push-base/src/main/AndroidManifest.xml
@@ -0,0 +1,3 @@
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-push-base/src/main/java/com/mogo/module/push/base/PushUIConstants.java b/modules/mogo-module-push-base/src/main/java/com/mogo/module/push/base/PushUIConstants.java
new file mode 100644
index 0000000000..4cfde10760
--- /dev/null
+++ b/modules/mogo-module-push-base/src/main/java/com/mogo/module/push/base/PushUIConstants.java
@@ -0,0 +1,7 @@
+package com.mogo.module.push.base;
+
+public class PushUIConstants {
+ public static final String NAME = "PUSH_UI";
+ public static final String PATH = "/push/ui";
+ public static final String Push_MESSAGE_ACTIVITY_PATH = "/push/ui/message"; //消息列表activity
+}
diff --git a/modules/mogo-module-push-noop/.gitignore b/modules/mogo-module-push-noop/.gitignore
new file mode 100644
index 0000000000..796b96d1c4
--- /dev/null
+++ b/modules/mogo-module-push-noop/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/modules/mogo-module-push-noop/README.md b/modules/mogo-module-push-noop/README.md
new file mode 100644
index 0000000000..a15717364f
--- /dev/null
+++ b/modules/mogo-module-push-noop/README.md
@@ -0,0 +1,4 @@
+# 基于 socketserver 实现的push推送(空)
+
+---
+目前,仅 launcher 实现推送,独立 app 不用
\ No newline at end of file
diff --git a/modules/mogo-module-push-noop/build.gradle b/modules/mogo-module-push-noop/build.gradle
new file mode 100644
index 0000000000..369d2a1a49
--- /dev/null
+++ b/modules/mogo-module-push-noop/build.gradle
@@ -0,0 +1,57 @@
+apply plugin: 'com.android.library'
+apply plugin: 'kotlin-android'
+apply plugin: 'kotlin-android-extensions'
+apply plugin: 'kotlin-kapt'
+android {
+ compileSdkVersion rootProject.ext.android.compileSdkVersion
+ buildToolsVersion rootProject.ext.android.buildToolsVersion
+
+
+ defaultConfig {
+ minSdkVersion rootProject.ext.android.minSdkVersion
+ targetSdkVersion rootProject.ext.android.targetSdkVersion
+ versionCode Integer.valueOf(VERSION_CODE)
+ versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
+
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ consumerProguardFiles 'consumer-rules.pro'
+ kapt {
+ arguments {
+ arg("AROUTER_MODULE_NAME", project.getName())
+ }
+ }
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+
+ compileOptions {
+ targetCompatibility 1.8
+ sourceCompatibility 1.8
+ }
+
+ kotlinOptions {
+ jvmTarget = "1.8"
+ }
+
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ // 小智语音,免唤醒词等服务
+ compileOnly rootProject.ext.dependencies.mogoserviceapi
+ compileOnly rootProject.ext.dependencies.arouter
+ kapt rootProject.ext.dependencies.aroutercompiler
+
+ if( Boolean.valueOf(RELEASE) ){
+ implementation rootProject.ext.dependencies.modulepushbase
+ } else {
+ implementation project(":modules:mogo-module-push-base")
+ }
+}
+
+apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
diff --git a/modules/mogo-module-push-noop/consumer-rules.pro b/modules/mogo-module-push-noop/consumer-rules.pro
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/modules/mogo-module-push-noop/gradle.properties b/modules/mogo-module-push-noop/gradle.properties
new file mode 100644
index 0000000000..9142345995
--- /dev/null
+++ b/modules/mogo-module-push-noop/gradle.properties
@@ -0,0 +1,3 @@
+GROUP=com.mogo.module
+POM_ARTIFACT_ID=module-push-noop
+VERSION_CODE=1
diff --git a/modules/mogo-module-push-noop/proguard-rules.pro b/modules/mogo-module-push-noop/proguard-rules.pro
new file mode 100644
index 0000000000..f1b424510d
--- /dev/null
+++ b/modules/mogo-module-push-noop/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
diff --git a/modules/mogo-module-push-noop/src/main/AndroidManifest.xml b/modules/mogo-module-push-noop/src/main/AndroidManifest.xml
new file mode 100644
index 0000000000..50c17495d9
--- /dev/null
+++ b/modules/mogo-module-push-noop/src/main/AndroidManifest.xml
@@ -0,0 +1,3 @@
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-push-noop/src/main/java/com/mogo/module/push/noop/PushModuleProvider.java b/modules/mogo-module-push-noop/src/main/java/com/mogo/module/push/noop/PushModuleProvider.java
new file mode 100644
index 0000000000..11555a184c
--- /dev/null
+++ b/modules/mogo-module-push-noop/src/main/java/com/mogo/module/push/noop/PushModuleProvider.java
@@ -0,0 +1,80 @@
+package com.mogo.module.push.noop;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.view.View;
+
+import androidx.annotation.NonNull;
+import androidx.fragment.app.Fragment;
+
+import com.alibaba.android.arouter.facade.annotation.Route;
+import com.mogo.map.listener.IMogoMapListener;
+import com.mogo.map.location.IMogoLocationListener;
+import com.mogo.map.marker.IMogoMarkerClickListener;
+import com.mogo.map.navi.IMogoNaviListener;
+import com.mogo.module.push.base.PushUIConstants;
+import com.mogo.service.module.IMogoModuleLifecycle;
+import com.mogo.service.module.IMogoModuleProvider;
+
+@Route(path = PushUIConstants.PATH)
+public class PushModuleProvider implements IMogoModuleProvider {
+ @Override
+ public Fragment createFragment(Context context, Bundle data) {
+ return null;
+ }
+
+ @Override
+ public View createView(Context context) {
+ return null;
+ }
+
+ @NonNull
+ @Override
+ public String getModuleName() {
+ return "";
+ }
+
+ @Override
+ public IMogoModuleLifecycle getCardLifecycle() {
+ return null;
+ }
+
+ @Override
+ public IMogoMapListener getMapListener() {
+ return null;
+ }
+
+ @Override
+ public int getType() {
+ return 0;
+ }
+
+ @Override
+ public IMogoNaviListener getNaviListener() {
+ return null;
+ }
+
+ @Override
+ public IMogoLocationListener getLocationListener() {
+ return null;
+ }
+
+ @Override
+ public IMogoMarkerClickListener getMarkerClickListener() {
+ return null;
+ }
+
+ @Override
+ public String getAppPackage() {
+ return " ";
+ }
+
+ @Override
+ public String getAppName() {
+ return " ";
+ }
+
+ @Override
+ public void init(final Context context) {
+ }
+}
diff --git a/modules/mogo-module-push/.gitignore b/modules/mogo-module-push/.gitignore
new file mode 100644
index 0000000000..796b96d1c4
--- /dev/null
+++ b/modules/mogo-module-push/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/modules/mogo-module-push/README.md b/modules/mogo-module-push/README.md
new file mode 100644
index 0000000000..e262a8de52
--- /dev/null
+++ b/modules/mogo-module-push/README.md
@@ -0,0 +1,12 @@
+# 基于 socketserver 实现的push推送
+
+---
+目前,仅 launcher 实现推送,独立 app 不用
+
+## launcher 在前台
+
+ 通过launcher内部空白区域的弹层承载推送内容
+
+## launcher 在后台
+
+ 通过 windowmanger 方式承载推送内容
\ No newline at end of file
diff --git a/modules/mogo-module-push/build.gradle b/modules/mogo-module-push/build.gradle
new file mode 100644
index 0000000000..80fa923f80
--- /dev/null
+++ b/modules/mogo-module-push/build.gradle
@@ -0,0 +1,71 @@
+apply plugin: 'com.android.library'
+apply plugin: 'kotlin-android'
+apply plugin: 'kotlin-android-extensions'
+apply plugin: 'kotlin-kapt'
+android {
+ compileSdkVersion rootProject.ext.android.compileSdkVersion
+ buildToolsVersion rootProject.ext.android.buildToolsVersion
+
+
+ defaultConfig {
+ minSdkVersion rootProject.ext.android.minSdkVersion
+ targetSdkVersion rootProject.ext.android.targetSdkVersion
+ versionCode Integer.valueOf(VERSION_CODE)
+ versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
+
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ consumerProguardFiles 'consumer-rules.pro'
+ kapt {
+ arguments {
+ arg("AROUTER_MODULE_NAME", project.getName())
+ }
+ }
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+
+ compileOptions {
+ targetCompatibility 1.8
+ sourceCompatibility 1.8
+ }
+
+ kotlinOptions {
+ jvmTarget = "1.8"
+ }
+
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ // 小智语音,免唤醒词等服务
+ compileOnly rootProject.ext.dependencies.mogomap
+ compileOnly rootProject.ext.dependencies.mogoutils
+ compileOnly rootProject.ext.dependencies.mogocommons
+ compileOnly rootProject.ext.dependencies.mogoserviceapi
+ compileOnly rootProject.ext.dependencies.modulecommon
+ compileOnly rootProject.ext.dependencies.androidxconstraintlayout
+ compileOnly rootProject.ext.dependencies.arouter
+ compileOnly rootProject.ext.dependencies.aiassist
+ kapt rootProject.ext.dependencies.aroutercompiler
+ compileOnly rootProject.ext.dependencies.androidxrecyclerview
+ implementation rootProject.ext.dependencies.androidxappcompat
+ implementation rootProject.ext.dependencies.kotlinstdlibjdk7
+ implementation rootProject.ext.dependencies.androidxccorektx
+ implementation rootProject.ext.dependencies.litezxing
+ implementation rootProject.ext.dependencies.androidxroomruntime
+ implementation rootProject.ext.dependencies.androidxroomktx
+ kapt rootProject.ext.dependencies.androidxroomcompiler
+
+ if( Boolean.valueOf(RELEASE) ){
+ implementation rootProject.ext.dependencies.modulepushbase
+ } else {
+ implementation project(":modules:mogo-module-push-base")
+ }
+}
+
+apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
diff --git a/modules/mogo-module-push/consumer-rules.pro b/modules/mogo-module-push/consumer-rules.pro
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/modules/mogo-module-push/gradle.properties b/modules/mogo-module-push/gradle.properties
new file mode 100644
index 0000000000..cf466ecef3
--- /dev/null
+++ b/modules/mogo-module-push/gradle.properties
@@ -0,0 +1,3 @@
+GROUP=com.mogo.module
+POM_ARTIFACT_ID=module-push
+VERSION_CODE=1
diff --git a/modules/mogo-module-push/proguard-rules.pro b/modules/mogo-module-push/proguard-rules.pro
new file mode 100644
index 0000000000..f1b424510d
--- /dev/null
+++ b/modules/mogo-module-push/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
diff --git a/modules/mogo-module-push/src/main/AndroidManifest.xml b/modules/mogo-module-push/src/main/AndroidManifest.xml
new file mode 100644
index 0000000000..3334a218b2
--- /dev/null
+++ b/modules/mogo-module-push/src/main/AndroidManifest.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-push/src/main/java/com/mogo/module/push/Config.kt b/modules/mogo-module-push/src/main/java/com/mogo/module/push/Config.kt
new file mode 100644
index 0000000000..d5de33e9d7
--- /dev/null
+++ b/modules/mogo-module-push/src/main/java/com/mogo/module/push/Config.kt
@@ -0,0 +1,20 @@
+package com.mogo.module.push
+
+object Config {
+ const val PUSH_TYPE = 100 //注册长连接类型
+ const val NEWS_ARRIVE = "news_arrive" //Push到达
+ const val NEWS_CARD_SHOW = "news_card_show"//push 展示
+ const val NEWS_CARD_DISAPPEAR = "news_card_disappear"// push 展示到期,自动消失
+ const val NEWS_CARD_CLICK = "news_card_click"//点击消息体
+ const val NEWS_CARD_SWIPE = "news_card_swipe"//划掉消息
+ const val NEWS_CARD_CLICK_BTN = "news_card_click_btn"//点击按钮
+
+
+ const val NEWS_HISTORY_OPEN = "news_history_open"//打开消息列表
+ const val NEWS_HISTORY_CLOSE = "news_history_close"//关闭消息列表
+ const val NEWS_HISTORY_ALL_CLEAR = "news_history_all_clear"//清除消息列表
+ const val NEWS_HISTORY_ONE_CLEAR = "news_history_one_clear"//清除消息历史中的消息
+ const val NEWS_HISTORY_ONE_CLICK = "news_history_one_click"//点击消息历史中的消息
+
+
+}
\ No newline at end of file
diff --git a/modules/mogo-module-push/src/main/java/com/mogo/module/push/PushModuleProvider.java b/modules/mogo-module-push/src/main/java/com/mogo/module/push/PushModuleProvider.java
new file mode 100644
index 0000000000..83ef3d1b42
--- /dev/null
+++ b/modules/mogo-module-push/src/main/java/com/mogo/module/push/PushModuleProvider.java
@@ -0,0 +1,89 @@
+package com.mogo.module.push;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.view.View;
+
+import androidx.annotation.NonNull;
+import androidx.fragment.app.Fragment;
+
+import com.alibaba.android.arouter.facade.annotation.Route;
+import com.mogo.map.listener.IMogoMapListener;
+import com.mogo.map.location.IMogoLocationListener;
+import com.mogo.map.marker.IMogoMarkerClickListener;
+import com.mogo.map.navi.IMogoNaviListener;
+import com.mogo.module.push.base.PushUIConstants;
+import com.mogo.module.push.repository.PushRepository;
+import com.mogo.module.push.utils.HandlerUtils;
+import com.mogo.service.module.IMogoModuleLifecycle;
+import com.mogo.service.module.IMogoModuleProvider;
+
+
+@Route(path = PushUIConstants.PATH)
+public class PushModuleProvider implements IMogoModuleProvider {
+ @Override
+ public Fragment createFragment(Context context, Bundle data) {
+ return null;
+ }
+
+ @Override
+ public View createView(Context context) {
+ return null;
+ }
+
+ @NonNull
+ @Override
+ public String getModuleName() {
+ return "";
+ }
+
+ @Override
+ public IMogoModuleLifecycle getCardLifecycle() {
+ return null;
+ }
+
+ @Override
+ public IMogoMapListener getMapListener() {
+ return null;
+ }
+
+ @Override
+ public int getType() {
+ return 0;
+ }
+
+ @Override
+ public IMogoNaviListener getNaviListener() {
+ return null;
+ }
+
+ @Override
+ public IMogoLocationListener getLocationListener() {
+ return null;
+ }
+
+ @Override
+ public IMogoMarkerClickListener getMarkerClickListener() {
+ return null;
+ }
+
+ @Override
+ public String getAppPackage() {
+ return " ";
+ }
+
+ @Override
+ public String getAppName() {
+ return " ";
+ }
+
+ @Override
+ public void init(final Context context) {
+ HandlerUtils.INSTANCE.getMBgHandler().post(new Runnable() {
+ @Override
+ public void run() {
+ PushRepository.Companion.init(context);
+ }
+ });
+ }
+}
diff --git a/modules/mogo-module-push/src/main/java/com/mogo/module/push/activity/PushMessageActivity.kt b/modules/mogo-module-push/src/main/java/com/mogo/module/push/activity/PushMessageActivity.kt
new file mode 100644
index 0000000000..195aa828ab
--- /dev/null
+++ b/modules/mogo-module-push/src/main/java/com/mogo/module/push/activity/PushMessageActivity.kt
@@ -0,0 +1,126 @@
+package com.mogo.module.push.activity
+
+import android.content.Intent
+import android.os.Bundle
+import android.view.View
+import androidx.appcompat.app.AppCompatActivity
+import androidx.recyclerview.widget.LinearLayoutManager
+import com.alibaba.android.arouter.facade.annotation.Route
+import com.mogo.module.push.Config
+import com.mogo.module.push.R
+import com.mogo.module.push.adapter.PushMessageAdapter
+import com.mogo.module.push.base.PushUIConstants
+import com.mogo.module.push.model.PushBean
+import com.mogo.module.push.repository.PushRepository
+import com.mogo.module.push.utils.AnalyticsUtils
+import com.mogo.module.push.utils.HandlerUtils
+import com.mogo.module.push.utils.startClearAnimator
+import com.mogo.module.push.view.PushItemAnimator
+import com.mogo.module.push.view.SwipeItemLayout
+import com.mogo.module.push.view.getApis
+import com.mogo.module.push.viewmodel.MessageViewModel
+import com.mogo.service.intent.IMogoIntentListener
+import com.mogo.utils.UiThreadHandler
+import com.mogo.utils.logger.Logger
+import kotlinx.android.synthetic.main.module_push_message_activity.*
+
+@Route(path = PushUIConstants.Push_MESSAGE_ACTIVITY_PATH)
+class PushMessageActivity : AppCompatActivity(), IMogoIntentListener {
+ private lateinit var viewModel: MessageViewModel
+ private var adapter = PushMessageAdapter()
+ private var clearing = false
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+// window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
+ setContentView(R.layout.module_push_message_activity)
+ AnalyticsUtils.track(Config.NEWS_HISTORY_OPEN)
+ module_push_activity_close.setOnClickListener {
+ AnalyticsUtils.track(Config.NEWS_HISTORY_CLOSE)
+ finish()
+ }
+ module_push_activity_clear.setOnClickListener {
+ AnalyticsUtils.track(Config.NEWS_HISTORY_ALL_CLEAR)
+ if (!clearing) {
+ clearing = true
+ startClearAnimator(module_push_activity_recycler_view) {
+ viewModel.deleteAll()
+ clearing = false
+ }
+ }
+ }
+ adapter.deletePushBean = object : PushMessageAdapter.PushAdapterListener {
+ override fun lastItemShow(show: Boolean) {
+ if (!show && !clearing) {
+ val size = viewModel.list?.size ?: 0
+ if (size > 0 && size < module_push_activity_recycler_view.childCount) {
+ return
+ }
+ }
+ module_push_activity_clear.visibility =
+ if (show) View.VISIBLE else View.GONE
+ }
+
+ override fun deleteBean(bean: PushBean, action: Boolean) {
+ if (clearing) return
+ viewModel.delete(bean)
+ if (action) {
+ AnalyticsUtils.track(Config.NEWS_HISTORY_ONE_CLICK, "title", bean.title)
+ finish()
+ } else {
+ AnalyticsUtils.track(Config.NEWS_HISTORY_ONE_CLEAR, "title", bean.title)
+ adapter.removeItem(bean)
+ if (adapter.datas?.size ?: 0 == 0) {
+ module_push_activity_not_data.visibility = View.VISIBLE
+ }
+ updateHistoryMessageCount()
+ }
+ }
+ }
+ module_push_activity_recycler_view.layoutManager = LinearLayoutManager(this)
+ module_push_activity_recycler_view.adapter = adapter
+ module_push_activity_recycler_view.itemAnimator = PushItemAnimator()
+ module_push_activity_recycler_view.addOnItemTouchListener(
+ SwipeItemLayout.OnSwipeItemTouchListener(this)
+ )
+ viewModel = MessageViewModel(object :
+ MessageViewModel.MessageListChange {
+ override fun messageListChange(list: MutableList?) {
+ runOnUiThread {
+ var size = list?.size ?: 0
+ adapter.datas = list
+ module_push_activity_not_data.visibility = if (size > 0) View.GONE else View.VISIBLE
+ updateHistoryMessageCount()
+ }
+ }
+ })
+
+ getApis(this).intentManagerApi.registerIntentListener(Intent.ACTION_CLOSE_SYSTEM_DIALOGS, this)
+ }
+
+ private fun updateHistoryMessageCount(){
+ HandlerUtils.mBgHandler.post{
+ var count = PushRepository.pushRepository.pushBeanDao.getAllCount()
+ UiThreadHandler.post {
+ module_push_activity_title.text = if (count > 0) "历史消息(${count})" else "历史消息"
+ }
+ }
+ }
+
+ override fun onResume() {
+ super.onResume()
+ adapter.notifyDataSetChanged()
+ }
+
+ override fun onIntentReceived(intentStr: String?, intent: Intent?) {
+ if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(intentStr)) {
+ Logger.d("PushMessageActivity", "close by home key.")
+ finish()
+ }
+ }
+
+ override fun onDestroy() {
+ super.onDestroy()
+ getApis(this).intentManagerApi.unregisterIntentListener(Intent.ACTION_CLOSE_SYSTEM_DIALOGS, this)
+ }
+}
\ No newline at end of file
diff --git a/modules/mogo-module-push/src/main/java/com/mogo/module/push/adapter/PushMessageAdapter.kt b/modules/mogo-module-push/src/main/java/com/mogo/module/push/adapter/PushMessageAdapter.kt
new file mode 100644
index 0000000000..868a609d29
--- /dev/null
+++ b/modules/mogo-module-push/src/main/java/com/mogo/module/push/adapter/PushMessageAdapter.kt
@@ -0,0 +1,127 @@
+package com.mogo.module.push.adapter
+
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.TextView
+import androidx.recyclerview.widget.RecyclerView
+import com.mogo.module.push.R
+import com.mogo.module.push.model.PushBean
+import com.mogo.module.push.repository.PushRepository
+import com.mogo.module.push.utils.dealSchema
+import com.mogo.module.push.utils.stringConverterBitmap
+import com.mogo.module.push.view.getApis
+import com.mogo.service.imageloader.MogoImageView
+import kotlin.math.abs
+
+class PushMessageAdapter : RecyclerView.Adapter() {
+ interface PushAdapterListener {
+ fun deleteBean(bean: PushBean, action: Boolean)
+
+ fun lastItemShow(show: Boolean)
+ }
+
+ var onAttachStateChangeListener = object : View.OnAttachStateChangeListener {
+ override fun onViewDetachedFromWindow(p0: View?) {
+ deletePushBean.lastItemShow(false)
+ }
+
+ override fun onViewAttachedToWindow(p0: View?) {
+ deletePushBean.lastItemShow(true)
+ }
+
+ }
+
+ lateinit var deletePushBean: PushAdapterListener
+
+ var datas: MutableList? = null
+ set(value) {
+ field = value
+ notifyDataSetChanged()
+ }
+
+ fun removeItem(bean: PushBean) {
+ datas?.let {
+ val position = it.indexOf(bean)
+ if (position >= 0) {
+ it.removeAt(position)
+ notifyItemRemoved(position)
+ }
+ if (itemCount == 0) {
+ deletePushBean.lastItemShow(false)
+ }
+ }
+ }
+
+ override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MessageViewHolder {
+ return MessageViewHolder(
+ LayoutInflater.from(parent.context).inflate(
+ R.layout.module_push_message_item,
+ parent,
+ false
+ )
+ )
+ }
+
+ override fun getItemCount(): Int {
+ return datas?.size ?: 0
+ }
+
+ override fun onBindViewHolder(holder: MessageViewHolder, position: Int) {
+ holder.setPushBean(datas!![position], position)
+ }
+
+
+ inner class MessageViewHolder(view: View) : RecyclerView.ViewHolder(view) {
+ private val pushAppIcon: MogoImageView = view.findViewById(R.id.module_push_item_app_icon)
+ private val pushTitle: TextView = view.findViewById(R.id.module_push_item_title)
+ private val pushContent: TextView = view.findViewById(R.id.module_push_item_content)
+ private val pushImage: MogoImageView = view.findViewById(R.id.module_push_item_image)
+ private val pushTimer: TextView = view.findViewById(R.id.module_push_item_time)
+ private val pushDelete: TextView = view.findViewById(R.id.module_push_item_delete)
+ private val pushClick: View = view.findViewById(R.id.module_push_item_click)
+
+ fun setPushBean(bean: PushBean, position: Int) {
+ if (position == (datas?.size ?: 0) - 1) {
+ itemView.addOnAttachStateChangeListener(onAttachStateChangeListener)
+ } else {
+ itemView.removeOnAttachStateChangeListener(onAttachStateChangeListener)
+ }
+ pushDelete.setOnClickListener {
+ deletePushBean.deleteBean(bean, false)
+ }
+ if (!bean.mainSchema.isNullOrEmpty()) {
+ pushClick.setOnClickListener {
+ dealSchema(bean.mainSchema, itemView.context)
+ deletePushBean.deleteBean(bean, true)
+ }
+ } else {
+ pushClick.setOnClickListener(null)
+ }
+ getApis(itemView.context).imageLoaderApi.displayImage(bean.appIcon, pushAppIcon)
+ pushTitle.text = bean.title
+ pushContent.text = bean.content
+ pushContent.visibility = if (bean.content.isNullOrEmpty()) View.GONE else View.VISIBLE
+ if (bean.QRCode.isNullOrEmpty() && bean.imageUrl.isNotEmpty()) {
+ getApis(itemView.context).imageLoaderApi.displayImage(bean.imageUrl, pushImage)
+ }
+ if (!bean.QRCode.isNullOrEmpty()) {
+ pushImage.setImageBitmap(
+ stringConverterBitmap(
+ bean.QRCode,
+ pushImage.context.resources.getDimensionPixelSize(R.dimen.module_push_message_item_image_size),
+ pushImage.context.resources.getDimensionPixelSize(R.dimen.module_push_message_item_image_size)
+ )
+ )
+ }
+ val diff = abs((System.currentTimeMillis() - bean.timestamp) / 1000).toInt()
+ pushTimer.text = when {
+ diff == 0 -> "现在"
+ diff < 60 -> "${diff}秒前"
+ diff < 60 * 60 -> "${diff / 60}分钟前"
+ diff < 60 * 60 * 24 -> "${diff / 60 / 60}小时前"
+ else -> "${diff / 60 / 60 / 24}天前"
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/mogo-module-push/src/main/java/com/mogo/module/push/dao/PushBeanDao.kt b/modules/mogo-module-push/src/main/java/com/mogo/module/push/dao/PushBeanDao.kt
new file mode 100644
index 0000000000..ff2548093d
--- /dev/null
+++ b/modules/mogo-module-push/src/main/java/com/mogo/module/push/dao/PushBeanDao.kt
@@ -0,0 +1,25 @@
+package com.mogo.module.push.dao
+
+import androidx.room.*
+import com.mogo.module.push.model.PushBean
+
+@Dao
+interface PushBeanDao {
+ @Query("SELECT * FROM pushBean ORDER BY timestamp DESC")
+ fun getAll(): MutableList
+
+ @Insert(onConflict = OnConflictStrategy.REPLACE)
+ fun insertAll(vararg bean: PushBean)
+
+ @Delete
+ fun delete(vararg bean: PushBean)
+
+ @Query("DELETE FROM pushBean")
+ fun deleteAll()
+
+ @Query("SELECT count(1) FROM pushBean")
+ fun getAllCount(): Int
+
+ @Query("DELETE FROM pushBean WHERE timestamp IN (SELECT MIN(timestamp) FROM pushBean)")
+ fun deleteMin()
+}
\ No newline at end of file
diff --git a/modules/mogo-module-push/src/main/java/com/mogo/module/push/dao/PushBeanDatabase.kt b/modules/mogo-module-push/src/main/java/com/mogo/module/push/dao/PushBeanDatabase.kt
new file mode 100644
index 0000000000..7631c88a18
--- /dev/null
+++ b/modules/mogo-module-push/src/main/java/com/mogo/module/push/dao/PushBeanDatabase.kt
@@ -0,0 +1,10 @@
+package com.mogo.module.push.dao
+
+import androidx.room.Database
+import androidx.room.RoomDatabase
+import com.mogo.module.push.model.PushBean
+
+@Database(entities = [PushBean::class], version = 1)
+abstract class PushBeanDatabase : RoomDatabase() {
+ abstract fun pushBeanDao(): PushBeanDao
+}
\ No newline at end of file
diff --git a/modules/mogo-module-push/src/main/java/com/mogo/module/push/model/PushBean.kt b/modules/mogo-module-push/src/main/java/com/mogo/module/push/model/PushBean.kt
new file mode 100644
index 0000000000..452a62f19e
--- /dev/null
+++ b/modules/mogo-module-push/src/main/java/com/mogo/module/push/model/PushBean.kt
@@ -0,0 +1,54 @@
+package com.mogo.module.push.model
+
+import androidx.room.ColumnInfo
+import androidx.room.Entity
+import androidx.room.Ignore
+import androidx.room.PrimaryKey
+import com.google.gson.annotations.SerializedName
+
+@Entity
+data class PushBean(
+ @Ignore
+ val speedLimit: Int = 0, //超过速度后延迟显示
+ @Ignore
+ var showTimeout: Int = 0, //显示等待时长
+ @Ignore
+ var showTimeoutShadow: Int = 0, // 显示等待时长备份
+ @ColumnInfo(name = "icon")
+ var appIcon: String = "", //目标app icon图标地址
+ @ColumnInfo(name = "title")
+ var title: String = "", //标题
+ @ColumnInfo(name = "content")
+ var content: String = "", //详细内容
+ @ColumnInfo(name = "image")
+ var imageUrl: String = "", //图片地址
+ @ColumnInfo(name = "qr")
+ var QRCode: String = "", //二维码地址
+ @Ignore
+ val tts: String = "", //语音播报词
+ @ColumnInfo(name = "scheme")
+ var mainSchema: String = "", //schema跳转协议
+ @Ignore
+ val mainVoiceCmd: List? = null, //触发主schema 命令词
+ @Ignore
+ val cancelVoiceCmd: List? = null, //隐藏当前push命令词
+ @Ignore
+ val buttons: List