From 45bcbaf979c2c29f718022c13c2bbe56fcdcc54b Mon Sep 17 00:00:00 2001 From: wangcongtao Date: Thu, 30 Jul 2020 17:44:37 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E5=8D=87=E7=BA=A7passport=E7=9B=B8?= =?UTF-8?q?=E5=85=B3sdk=E3=80=81=E4=BF=AE=E6=94=B9=E5=9C=B0=E5=9B=BE"?= =?UTF-8?q?=E7=BB=A7=E7=BB=AD=E5=AF=BC=E8=88=AA"=E6=8C=87=E4=BB=A4?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.gradle | 2 +- foudations/mogo-base-services-sdk/build.gradle | 2 +- .../src/main/java/com/mogo/module/map/MapPresenter.java | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/config.gradle b/config.gradle index f0a58756c4..161085a014 100644 --- a/config.gradle +++ b/config.gradle @@ -130,7 +130,7 @@ targetSdkVersion : 22, jetbrainsannotationsjava5: "org.jetbrains:annotations-java5:15.0", // 统一登录 - accountsdk : "com.zhidao.accountservice:account-sdk:1.0.8", + accountsdk : "com.zhidao.accountservice:account-sdk:1.0.11", // crash crashSdk : "com.zhidaoauto.crash.log:library:1.0.5", kotlinstdlibjdk7 : "org.jetbrains.kotlin:kotlin-stdlib-jdk7", diff --git a/foudations/mogo-base-services-sdk/build.gradle b/foudations/mogo-base-services-sdk/build.gradle index 7237542631..6a9ad088e4 100644 --- a/foudations/mogo-base-services-sdk/build.gradle +++ b/foudations/mogo-base-services-sdk/build.gradle @@ -34,7 +34,7 @@ dependencies { // 长链 implementation 'com.zhidao.socket:built-in-socket:1.0.15' // passport - implementation 'com.zhidao.tcloginsdk:tclogin:1.1.0' + implementation 'com.zhidao.tcloginsdk:tclogin:1.1.3' annotationProcessor 'com.elegant.spi:compiler:1.0.3' 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..6340143aad 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 @@ -508,6 +508,9 @@ public class MapPresenter extends Presenter< MapView > implements onDisplayOverview(); break; case VoiceConstants.CMD_MAP_CONTINUE_NAVI_MODE: + if ( CustomNaviInterrupter.getInstance().interrupt() ) { + return; + } onContinueNavigation(); break; case VoiceConstants.CMD_MAP_CAR_UP_MODE_UN_WAKEUP: From 1153813221c4bcf3c1f2e0a8e8274a5ef51f68bf Mon Sep 17 00:00:00 2001 From: wangcongtao Date: Fri, 31 Jul 2020 11:09:45 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E8=9E=8D=E5=90=88=E9=AB=98=E5=BE=B7?= =?UTF-8?q?=E5=B9=BF=E6=92=AD=E5=92=8C=E8=AF=AD=E9=9F=B3=E6=8C=87=E4=BB=A4?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E5=9C=B0=E5=9B=BE=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../services/passport/PassportManager.java | 30 +- .../module/map/AutoNaviBroadcastReceiver.java | 127 ++++++ .../module/map/MapControlCommandHandler.java | 94 +++++ .../java/com/mogo/module/map/MapFragment.java | 8 +- .../com/mogo/module/map/MapPresenter.java | 378 +++++------------- .../mogo/module/map/OnMapControlCallback.java | 42 ++ 6 files changed, 387 insertions(+), 292 deletions(-) create mode 100644 modules/mogo-module-map/src/main/java/com/mogo/module/map/AutoNaviBroadcastReceiver.java create mode 100644 modules/mogo-module-map/src/main/java/com/mogo/module/map/MapControlCommandHandler.java create mode 100644 modules/mogo-module-map/src/main/java/com/mogo/module/map/OnMapControlCallback.java diff --git a/foudations/mogo-base-services-apk/src/main/java/com/mogo/base/services/passport/PassportManager.java b/foudations/mogo-base-services-apk/src/main/java/com/mogo/base/services/passport/PassportManager.java index 2a23051695..ede1bc990e 100644 --- a/foudations/mogo-base-services-apk/src/main/java/com/mogo/base/services/passport/PassportManager.java +++ b/foudations/mogo-base-services-apk/src/main/java/com/mogo/base/services/passport/PassportManager.java @@ -10,6 +10,7 @@ import com.mogo.service.passport.IMogoPassportManager; import com.mogo.service.passport.IMogoTicketCallback; import com.mogo.utils.logger.Logger; import com.zhidao.account.sdk.AccountClientManager; +import com.zhidao.account.sdk.Environment; import com.zhidao.account.sdk.callback.TicketInfoCallback; import com.zhidao.account.sdk.network.NetEnvironManager; @@ -27,13 +28,14 @@ class PassportManager implements IMogoPassportManager { private static volatile PassportManager sInstance; - private PassportManager(){} + private PassportManager() { + } @Keep - public static PassportManager getInstance(){ - if( sInstance == null ){ - synchronized( PassportManager.class ) { - if( sInstance == null ){ + public static PassportManager getInstance() { + if ( sInstance == null ) { + synchronized ( PassportManager.class ) { + if ( sInstance == null ) { sInstance = new PassportManager(); } } @@ -41,7 +43,7 @@ class PassportManager implements IMogoPassportManager { return sInstance; } - public synchronized void release(){ + public synchronized void release() { sInstance = null; } @@ -77,11 +79,25 @@ class PassportManager implements IMogoPassportManager { @Override public void init( Context context ) { + AccountClientManager.init( context.getApplicationContext(), getNetEnvironment(), NetEnvironManager.OS_2C, "os2.0-launcher" ); + } + + private Environment getNetEnvironment() { int mode = DebugConfig.getNetMode(); if ( mode == DebugConfig.NET_MODE_DEMO ) { // 演示环境用 qa 的 mode = DebugConfig.NET_MODE_QA; } - AccountClientManager.init( context.getApplicationContext(), mode, NetEnvironManager.OS_2C, "os2.0-launcher" ); + switch ( mode ) { + case DebugConfig.NET_MODE_DEV: + return Environment.dev; + case DebugConfig.NET_MODE_DEMO: + case DebugConfig.NET_MODE_QA: + return Environment.qa; + case DebugConfig.NET_MODE_RELEASE: + default: + return Environment.release; + + } } } 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 6340143aad..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,85 +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: - if ( CustomNaviInterrupter.getInstance().interrupt() ) { - return; - } - 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 From 1bf436d8267386f5c701bd382252033d8676cd4f Mon Sep 17 00:00:00 2001 From: wangcongtao Date: Fri, 31 Jul 2020 12:29:53 +0800 Subject: [PATCH 3/7] =?UTF-8?q?1.=20=E8=A7=A3=E5=86=B3push=E6=8E=A8?= =?UTF-8?q?=E9=80=81=E7=9B=B8=E5=85=B3=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 2 +- .../main/java/com/mogo/module/apps/AppsListActivity.java | 5 +++++ .../main/java/com/mogo/module/apps/AppsListPresenter.java | 6 ++++++ .../src/main/java/com/mogo/module/apps/AppsListView.java | 2 ++ .../mogo-module-extensions/src/main/res/values/strings.xml | 2 +- 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 316601007d..105d223f6c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -73,7 +73,7 @@ MOGO_MODULE_ONLINECAR_VERSION=1.0.3.2 # v2x MOGO_MODULE_V2X_VERSION=1.1.534 # 推送 -MOGO_MODULE_PUSH_VERSION=1.1.5.7 +MOGO_MODULE_PUSH_VERSION=1.1.6 MOGO_MODULE_PUSH_BASE_VERSION=1.1.5.5 MOGO_MODULE_PUSH_NOOP_VERSION=1.1.5.6 # 广告资源位 diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsListActivity.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsListActivity.java index fbaae3255b..1adc5272ea 100644 --- a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsListActivity.java +++ b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsListActivity.java @@ -129,6 +129,11 @@ public class AppsListActivity extends MvpActivity< AppsListView, AppsListPresent overridePendingTransition( R.anim.module_apps_anim_enter, R.anim.module_apps_anim_exit ); } + @Override + public void executeFinish() { + finish(); + } + @Override protected void onDestroy() { super.onDestroy(); diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsListPresenter.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsListPresenter.java index caf44c1c72..0ad09a3b10 100644 --- a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsListPresenter.java +++ b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsListPresenter.java @@ -13,6 +13,7 @@ import com.mogo.commons.voice.IMogoVoiceCmdCallBack; import com.mogo.service.MogoServicePaths; import com.mogo.service.intent.IMogoIntentListener; import com.mogo.service.intent.IMogoIntentManager; +import com.mogo.utils.logger.Logger; import org.json.JSONException; import org.json.JSONObject; @@ -38,6 +39,7 @@ public class AppsListPresenter extends Presenter< AppsListView > implements IMog super.onCreate( owner ); mIntentManager = ( IMogoIntentManager ) ARouter.getInstance().build( MogoServicePaths.PATH_INTENT_MANAGER ).navigation( getContext() ); mIntentManager.registerIntentListener( AppsConst.COMMAND_OPERATION, this ); + mIntentManager.registerIntentListener( Intent.ACTION_CLOSE_SYSTEM_DIALOGS, this ); AIAssist.getInstance( getContext() ).registerUnWakeupCommand( AppsConst.CMD_UN_WAKE_CLOSE_APP_LIST, AppsConst.CMD_UN_WAKE_WORDS_CLOSE_APP_LIST, this ); } @@ -56,6 +58,9 @@ public class AppsListPresenter extends Presenter< AppsListView > implements IMog } catch ( JSONException e ) { e.printStackTrace(); } + } else if ( Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals( intentStr ) ) { + Logger.d( TAG, "home 键导致 app 列表关闭" ); + mView.executeFinish(); } } @@ -90,6 +95,7 @@ public class AppsListPresenter extends Presenter< AppsListView > implements IMog public void onDestroy( @NonNull LifecycleOwner owner ) { super.onDestroy( owner ); mIntentManager.unregisterIntentListener( AppsConst.COMMAND_OPERATION, this ); + mIntentManager.unregisterIntentListener( Intent.ACTION_CLOSE_SYSTEM_DIALOGS, this ); AIAssist.getInstance( getContext() ).unregisterUnWakeupCommand( AppsConst.CMD_UN_WAKE_CLOSE_APP_LIST ); } } diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsListView.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsListView.java index d3ec317ed7..ee38e7c05d 100644 --- a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsListView.java +++ b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsListView.java @@ -11,4 +11,6 @@ import com.mogo.commons.mvp.IView; public interface AppsListView extends IView { void closeAppsPanel(); + + void executeFinish(); } diff --git a/modules/mogo-module-extensions/src/main/res/values/strings.xml b/modules/mogo-module-extensions/src/main/res/values/strings.xml index def8fbcd0e..bcfcbae52f 100644 --- a/modules/mogo-module-extensions/src/main/res/values/strings.xml +++ b/modules/mogo-module-extensions/src/main/res/values/strings.xml @@ -13,7 +13,7 @@ 周五 周六 - ··· + 99+ 搜索目的地 分享 From 5a2d3183c2640bdaf2547cf6ba7db756dcc3c1d6 Mon Sep 17 00:00:00 2001 From: wangcongtao Date: Fri, 31 Jul 2020 12:37:07 +0800 Subject: [PATCH 4/7] opt --- .idea/misc.xml | 2 +- gradle.properties | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index cd77a1f062..21e99e2dc0 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -4,7 +4,7 @@ - + \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 86ca97cfd3..c6d8783b95 100644 --- a/gradle.properties +++ b/gradle.properties @@ -100,8 +100,8 @@ MOGO_MODULE_OBU_VERSION = 1.2.1.10-SNAPSHOT MOGO_MODULE_SPLASH_VERSION = 1.0.0-SNAPSHOT MOGO_MODULE_SPLASH_NOOP_VERSION = 1.0.0-SNAPSHOT -## 产品库必备配置 +## 产品库必备配置,产品库自动对versionCode和versionName版本进行升级 applicationId=com.mogo.launcer applicationName=IntelligentPilot versionCode=80007 -versionName=8.0.7-qa_1.1 \ No newline at end of file +versionName=8.0.7 \ No newline at end of file From e16fff638cafaba020df8ba035b7e8af071a8622 Mon Sep 17 00:00:00 2001 From: wangcongtao Date: Fri, 31 Jul 2020 13:22:26 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E5=B0=86=E6=8E=A8=E9=80=81=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=8E=A5=E5=85=A5=E4=B8=BB=E5=B7=A5=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/functions/socketpush.gradle | 12 +- .../com/mogo/launcher/MogoApplication.java | 6 +- config.gradle | 9 + modules/mogo-module-push-base/.gitignore | 1 + modules/mogo-module-push-base/build.gradle | 47 ++ .../mogo-module-push-base/consumer-rules.pro | 0 .../mogo-module-push-base/gradle.properties | 3 + .../mogo-module-push-base/proguard-rules.pro | 21 + .../src/main/AndroidManifest.xml | 3 + .../module/push/base/PushUIConstants.java | 7 + modules/mogo-module-push-noop/.gitignore | 1 + modules/mogo-module-push-noop/README.md | 4 + modules/mogo-module-push-noop/build.gradle | 57 ++ .../mogo-module-push-noop/consumer-rules.pro | 0 .../mogo-module-push-noop/gradle.properties | 3 + .../mogo-module-push-noop/proguard-rules.pro | 21 + .../src/main/AndroidManifest.xml | 3 + .../module/push/noop/PushModuleProvider.java | 80 ++ modules/mogo-module-push/.gitignore | 1 + modules/mogo-module-push/README.md | 12 + modules/mogo-module-push/build.gradle | 71 ++ modules/mogo-module-push/consumer-rules.pro | 0 modules/mogo-module-push/gradle.properties | 3 + modules/mogo-module-push/proguard-rules.pro | 21 + .../src/main/AndroidManifest.xml | 17 + .../main/java/com/mogo/module/push/Config.kt | 20 + .../mogo/module/push/PushModuleProvider.java | 89 ++ .../push/activity/PushMessageActivity.kt | 108 +++ .../module/push/adapter/PushMessageAdapter.kt | 127 +++ .../com/mogo/module/push/dao/PushBeanDao.kt | 25 + .../mogo/module/push/dao/PushBeanDatabase.kt | 10 + .../com/mogo/module/push/model/PushBean.kt | 54 ++ .../module/push/repository/PushRepository.kt | 233 ++++++ .../mogo/module/push/utils/AnalyticsUtils.kt | 22 + .../mogo/module/push/utils/AnimatorUtils.kt | 25 + .../mogo/module/push/utils/HandlerUtils.kt | 14 + .../com/mogo/module/push/utils/SchemaUtils.kt | 130 +++ .../java/com/mogo/module/push/utils/Utils.kt | 33 + .../com/mogo/module/push/view/FloatView.kt | 563 +++++++++++++ .../com/mogo/module/push/view/GlobalTools.kt | 40 + .../module/push/view/PushItemAnimator.java | 657 +++++++++++++++ .../module/push/view/SwipeItemLayout.java | 790 ++++++++++++++++++ .../module/push/view/roundimage/Corner.java | 19 + .../push/view/roundimage/RoundedDrawable.java | 633 ++++++++++++++ .../view/roundimage/RoundedImageView.java | 587 +++++++++++++ .../module/push/viewmodel/MessageViewModel.kt | 33 + .../module/push/viewmodel/PushViewModel.kt | 192 +++++ .../res/drawable-ldpi/module_push_close.png | Bin 0 -> 1072 bytes .../res/drawable-xhdpi/module_push_close.png | Bin 0 -> 1815 bytes .../module_push_activity_clear_bg.xml | 7 + .../main/res/drawable/module_push_close.png | Bin 0 -> 1815 bytes .../module_push_content_background.xml | 6 + .../module_push_decrease_timer_bkg.xml | 9 + .../drawable/module_push_item_background.xml | 7 + .../res/drawable/module_push_left_button.xml | 15 + ...odule_push_message_activity_background.xml | 5 + .../module_push_recycler_item_background.xml | 12 + .../res/drawable/module_push_right_button.xml | 16 + .../module_push_ui_delay_background.xml | 19 + .../drawable/module_push_ui_ic_message2.png | Bin 0 -> 1152 bytes .../src/main/res/layout/module_push_item.xml | 146 ++++ .../res/layout/module_push_item_vertical.xml | 136 +++ .../layout/module_push_message_activity.xml | 57 ++ .../res/layout/module_push_message_item.xml | 106 +++ .../src/main/res/values-ldpi/dimens.xml | 90 ++ .../src/main/res/values-mdpi/dimens.xml | 90 ++ .../src/main/res/values-xhdpi/dimens.xml | 90 ++ .../src/main/res/values/attr.xml | 30 + .../src/main/res/values/dimens.xml | 90 ++ .../src/main/res/values/strings.xml | 3 + .../src/main/res/values/styles.xml | 9 + settings.gradle | 6 +- upload.sh | 8 +- 73 files changed, 5754 insertions(+), 10 deletions(-) create mode 100644 modules/mogo-module-push-base/.gitignore create mode 100644 modules/mogo-module-push-base/build.gradle create mode 100644 modules/mogo-module-push-base/consumer-rules.pro create mode 100644 modules/mogo-module-push-base/gradle.properties create mode 100644 modules/mogo-module-push-base/proguard-rules.pro create mode 100644 modules/mogo-module-push-base/src/main/AndroidManifest.xml create mode 100644 modules/mogo-module-push-base/src/main/java/com/mogo/module/push/base/PushUIConstants.java create mode 100644 modules/mogo-module-push-noop/.gitignore create mode 100644 modules/mogo-module-push-noop/README.md create mode 100644 modules/mogo-module-push-noop/build.gradle create mode 100644 modules/mogo-module-push-noop/consumer-rules.pro create mode 100644 modules/mogo-module-push-noop/gradle.properties create mode 100644 modules/mogo-module-push-noop/proguard-rules.pro create mode 100644 modules/mogo-module-push-noop/src/main/AndroidManifest.xml create mode 100644 modules/mogo-module-push-noop/src/main/java/com/mogo/module/push/noop/PushModuleProvider.java create mode 100644 modules/mogo-module-push/.gitignore create mode 100644 modules/mogo-module-push/README.md create mode 100644 modules/mogo-module-push/build.gradle create mode 100644 modules/mogo-module-push/consumer-rules.pro create mode 100644 modules/mogo-module-push/gradle.properties create mode 100644 modules/mogo-module-push/proguard-rules.pro create mode 100644 modules/mogo-module-push/src/main/AndroidManifest.xml create mode 100644 modules/mogo-module-push/src/main/java/com/mogo/module/push/Config.kt create mode 100644 modules/mogo-module-push/src/main/java/com/mogo/module/push/PushModuleProvider.java create mode 100644 modules/mogo-module-push/src/main/java/com/mogo/module/push/activity/PushMessageActivity.kt create mode 100644 modules/mogo-module-push/src/main/java/com/mogo/module/push/adapter/PushMessageAdapter.kt create mode 100644 modules/mogo-module-push/src/main/java/com/mogo/module/push/dao/PushBeanDao.kt create mode 100644 modules/mogo-module-push/src/main/java/com/mogo/module/push/dao/PushBeanDatabase.kt create mode 100644 modules/mogo-module-push/src/main/java/com/mogo/module/push/model/PushBean.kt create mode 100644 modules/mogo-module-push/src/main/java/com/mogo/module/push/repository/PushRepository.kt create mode 100644 modules/mogo-module-push/src/main/java/com/mogo/module/push/utils/AnalyticsUtils.kt create mode 100644 modules/mogo-module-push/src/main/java/com/mogo/module/push/utils/AnimatorUtils.kt create mode 100644 modules/mogo-module-push/src/main/java/com/mogo/module/push/utils/HandlerUtils.kt create mode 100644 modules/mogo-module-push/src/main/java/com/mogo/module/push/utils/SchemaUtils.kt create mode 100644 modules/mogo-module-push/src/main/java/com/mogo/module/push/utils/Utils.kt create mode 100644 modules/mogo-module-push/src/main/java/com/mogo/module/push/view/FloatView.kt create mode 100644 modules/mogo-module-push/src/main/java/com/mogo/module/push/view/GlobalTools.kt create mode 100644 modules/mogo-module-push/src/main/java/com/mogo/module/push/view/PushItemAnimator.java create mode 100644 modules/mogo-module-push/src/main/java/com/mogo/module/push/view/SwipeItemLayout.java create mode 100644 modules/mogo-module-push/src/main/java/com/mogo/module/push/view/roundimage/Corner.java create mode 100644 modules/mogo-module-push/src/main/java/com/mogo/module/push/view/roundimage/RoundedDrawable.java create mode 100644 modules/mogo-module-push/src/main/java/com/mogo/module/push/view/roundimage/RoundedImageView.java create mode 100644 modules/mogo-module-push/src/main/java/com/mogo/module/push/viewmodel/MessageViewModel.kt create mode 100644 modules/mogo-module-push/src/main/java/com/mogo/module/push/viewmodel/PushViewModel.kt create mode 100644 modules/mogo-module-push/src/main/res/drawable-ldpi/module_push_close.png create mode 100644 modules/mogo-module-push/src/main/res/drawable-xhdpi/module_push_close.png create mode 100644 modules/mogo-module-push/src/main/res/drawable/module_push_activity_clear_bg.xml create mode 100644 modules/mogo-module-push/src/main/res/drawable/module_push_close.png create mode 100644 modules/mogo-module-push/src/main/res/drawable/module_push_content_background.xml create mode 100644 modules/mogo-module-push/src/main/res/drawable/module_push_decrease_timer_bkg.xml create mode 100644 modules/mogo-module-push/src/main/res/drawable/module_push_item_background.xml create mode 100644 modules/mogo-module-push/src/main/res/drawable/module_push_left_button.xml create mode 100644 modules/mogo-module-push/src/main/res/drawable/module_push_message_activity_background.xml create mode 100644 modules/mogo-module-push/src/main/res/drawable/module_push_recycler_item_background.xml create mode 100644 modules/mogo-module-push/src/main/res/drawable/module_push_right_button.xml create mode 100644 modules/mogo-module-push/src/main/res/drawable/module_push_ui_delay_background.xml create mode 100644 modules/mogo-module-push/src/main/res/drawable/module_push_ui_ic_message2.png create mode 100644 modules/mogo-module-push/src/main/res/layout/module_push_item.xml create mode 100644 modules/mogo-module-push/src/main/res/layout/module_push_item_vertical.xml create mode 100644 modules/mogo-module-push/src/main/res/layout/module_push_message_activity.xml create mode 100644 modules/mogo-module-push/src/main/res/layout/module_push_message_item.xml create mode 100644 modules/mogo-module-push/src/main/res/values-ldpi/dimens.xml create mode 100644 modules/mogo-module-push/src/main/res/values-mdpi/dimens.xml create mode 100644 modules/mogo-module-push/src/main/res/values-xhdpi/dimens.xml create mode 100644 modules/mogo-module-push/src/main/res/values/attr.xml create mode 100644 modules/mogo-module-push/src/main/res/values/dimens.xml create mode 100644 modules/mogo-module-push/src/main/res/values/strings.xml create mode 100644 modules/mogo-module-push/src/main/res/values/styles.xml diff --git a/app/functions/socketpush.gradle b/app/functions/socketpush.gradle index ef9923abfd..b42be11b59 100644 --- a/app/functions/socketpush.gradle +++ b/app/functions/socketpush.gradle @@ -1,7 +1,13 @@ // 基于socket长链的push推送 project.dependencies { - implementation rootProject.ext.dependencies.modulepushbase - launcherImplementation rootProject.ext.dependencies.modulepush - independentImplementation rootProject.ext.dependencies.modulepushnoop + if (Boolean.valueOf(RELEASE)) { + implementation rootProject.ext.dependencies.modulepushbase + launcherImplementation rootProject.ext.dependencies.modulepush + independentImplementation rootProject.ext.dependencies.modulepushnoop + } else { + implementation project(":modules:mogo-module-push-base") + launcherImplementation project(":modules:mogo-module-push") + independentImplementation project(":modules:mogo-module-push-noop") + } } \ No newline at end of file diff --git a/app/src/main/java/com/mogo/launcher/MogoApplication.java b/app/src/main/java/com/mogo/launcher/MogoApplication.java index 2fd042befb..a067f4bf8e 100644 --- a/app/src/main/java/com/mogo/launcher/MogoApplication.java +++ b/app/src/main/java/com/mogo/launcher/MogoApplication.java @@ -67,10 +67,8 @@ public class MogoApplication extends AbsMogoApplication { MogoModulePaths.addModule( new MogoModule( TanluConstants.TAG, TanluConstants.MODEL_NAME ) ); MogoModulePaths.addModule( new MogoModule( MogoServicePaths.PATH_SHARE, "ShareControl" ) ); - MogoModulePaths.addModule( new MogoModule( EventPanelConstants.PATH_NAME, - EventPanelConstants.MODULE_NAME ) ); - MogoModulePaths.addModule( new MogoModule( LeftPanelConst.PATH_NAME, - LeftPanelConst.MODULE_NAME ) ); + MogoModulePaths.addModule( new MogoModule( EventPanelConstants.PATH_NAME, EventPanelConstants.MODULE_NAME ) ); + MogoModulePaths.addModule( new MogoModule( LeftPanelConst.PATH_NAME, LeftPanelConst.MODULE_NAME ) ); MogoModulePaths.addBaseModule( new MogoModule( ServiceConst.PATH_REFRESH_STRATEGY, ServiceConst.PATH_REFRESH_STRATEGY ) ); MogoModulePaths.addBaseModule( new MogoModule( V2XConst.PATH_V2X_UI, V2XConst.PATH_V2X_UI ) ); diff --git a/config.gradle b/config.gradle index 161085a014..e4e542a469 100644 --- a/config.gradle +++ b/config.gradle @@ -172,5 +172,14 @@ targetSdkVersion : 22, // 基础服务实现 mogobaseservicesdk : "com.mogo.base:services-sdk:${MOGO_BASE_SERVICES_SDK_VERSION}", mogobaseserviceapk : "com.mogo.base:services-apk:${MOGO_BASE_SERVICES_APK_VERSION}", + + // google + googlezxing : "com.google.zxing:core:3.3.3", + litezxing : "com.google.zxing:litezxing:1.0.29.8", + + // android - room + androidxroomruntime : "androidx.room:room-runtime:2.2.3", + androidxroomcompiler : "androidx.room:room-compiler:2.2.3", + androidxroomktx : "androidx.room:room-ktx:2.2.3", ] } \ 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..a77b140ebb --- /dev/null +++ b/modules/mogo-module-push/src/main/java/com/mogo/module/push/activity/PushMessageActivity.kt @@ -0,0 +1,108 @@ +package com.mogo.module.push.activity + +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.base.PushUIConstants +import com.mogo.module.push.R +import com.mogo.module.push.adapter.PushMessageAdapter +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.viewmodel.MessageViewModel +import com.mogo.utils.UiThreadHandler +import kotlinx.android.synthetic.main.module_push_message_activity.* + +@Route(path = PushUIConstants.Push_MESSAGE_ACTIVITY_PATH) +class PushMessageActivity : AppCompatActivity() { + 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() + } + } + }) + } + + 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() + } +} \ 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