diff --git a/foudations/mogo-commons/src/main/java/com/mogo/commons/AbsMogoApplication.java b/foudations/mogo-commons/src/main/java/com/mogo/commons/AbsMogoApplication.java index 785c282c6c..f12e737695 100644 --- a/foudations/mogo-commons/src/main/java/com/mogo/commons/AbsMogoApplication.java +++ b/foudations/mogo-commons/src/main/java/com/mogo/commons/AbsMogoApplication.java @@ -1,6 +1,12 @@ package com.mogo.commons; import android.app.Application; +import android.content.Context; +import android.text.TextUtils; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.TextView; import com.alibaba.android.arouter.launcher.ARouter; import com.elegant.analytics.Analytics; @@ -57,13 +63,40 @@ public class AbsMogoApplication extends Application { asyncInit(); } - private void syncInit(){ + private void syncInit() { // 初始化 arouter if ( DebugConfig.isDebug() ) { ARouter.openDebug(); ARouter.openLog(); } ARouter.init( sApp ); + TipToast.init( this, new TipToast.ToastViewGenerator() { + @Override + public View make( Context context, String message ) { + if ( TextUtils.isEmpty( message ) ) { + return null; + } + View contentView = LayoutInflater.from( context ).inflate( R.layout.module_commons_layout_toast, null ); + TextView txt = contentView.findViewById( R.id.module_commons_toast_msg ); + txt.setText( message ); + return contentView; + } + + @Override + public int gravity() { + return Gravity.TOP | Gravity.CENTER_HORIZONTAL; + } + + @Override + public int yOffset() { + return sApp.getResources().getDimensionPixelSize( R.dimen.module_commons_toast_y_offset ); + } + + @Override + public int xOffset() { + return 0; + } + } ); } /** @@ -79,12 +112,11 @@ public class AbsMogoApplication extends Application { return sc; } - private void asyncInit(){ - ThreadPoolService.execute( ()->{ + private void asyncInit() { + ThreadPoolService.execute( () -> { initNetConfig(); initAccountSdk(); // 初始化toast - TipToast.init( sApp, null ); // 初始化埋点 Analytics.getInstance().start( sApp ); Analytics.getInstance().setAppKey( "6bbe7e0e1ecd8e2f8dc336e1678a2791" ); diff --git a/foudations/mogo-commons/src/main/res/drawable/module_commons_toast_bkg.xml b/foudations/mogo-commons/src/main/res/drawable/module_commons_toast_bkg.xml new file mode 100644 index 0000000000..ccf2eaa4d0 --- /dev/null +++ b/foudations/mogo-commons/src/main/res/drawable/module_commons_toast_bkg.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/foudations/mogo-commons/src/main/res/layout/module_commons_layout_toast.xml b/foudations/mogo-commons/src/main/res/layout/module_commons_layout_toast.xml new file mode 100644 index 0000000000..efe4b588cc --- /dev/null +++ b/foudations/mogo-commons/src/main/res/layout/module_commons_layout_toast.xml @@ -0,0 +1,26 @@ + + + + + \ No newline at end of file diff --git a/foudations/mogo-commons/src/main/res/values-ldpi/dimens.xml b/foudations/mogo-commons/src/main/res/values-ldpi/dimens.xml new file mode 100644 index 0000000000..619981847d --- /dev/null +++ b/foudations/mogo-commons/src/main/res/values-ldpi/dimens.xml @@ -0,0 +1,11 @@ + + + 30px + 30px + 16px + 16px + 22px + 75px + 500px + 108px + \ No newline at end of file diff --git a/foudations/mogo-commons/src/main/res/values-xhdpi/dimens.xml b/foudations/mogo-commons/src/main/res/values-xhdpi/dimens.xml new file mode 100644 index 0000000000..8e64c9541c --- /dev/null +++ b/foudations/mogo-commons/src/main/res/values-xhdpi/dimens.xml @@ -0,0 +1,13 @@ + + + 50px + 50px + 32px + 32px + 40px + 150px + 900px + 172px + + + diff --git a/foudations/mogo-commons/src/main/res/values/dimens.xml b/foudations/mogo-commons/src/main/res/values/dimens.xml new file mode 100644 index 0000000000..8e64c9541c --- /dev/null +++ b/foudations/mogo-commons/src/main/res/values/dimens.xml @@ -0,0 +1,13 @@ + + + 50px + 50px + 32px + 32px + 40px + 150px + 900px + 172px + + + diff --git a/foudations/mogo-utils/src/main/java/com/mogo/utils/TipToast.java b/foudations/mogo-utils/src/main/java/com/mogo/utils/TipToast.java index 93af03bbae..540fa45017 100644 --- a/foudations/mogo-utils/src/main/java/com/mogo/utils/TipToast.java +++ b/foudations/mogo-utils/src/main/java/com/mogo/utils/TipToast.java @@ -9,6 +9,7 @@ package com.mogo.utils; import android.content.Context; import android.os.Handler; import android.text.TextUtils; +import android.view.Gravity; import android.view.View; import android.widget.Toast; @@ -144,10 +145,6 @@ public final class TipToast { sToast.cancel(); } - if ( sGenerator == null ) { - sToast = Toast.makeText( context, msg, duration ); - } - if ( sGenerator == null ) { sToast = Toast.makeText( context, msg, duration ); } else { @@ -155,6 +152,7 @@ public final class TipToast { final View view = sGenerator.make( context, msg ); if ( view != null ) { sToast.setView( view ); + sToast.setGravity( sGenerator.gravity(), sGenerator.xOffset(), sGenerator.yOffset() ); sToast.setDuration( duration ); } else { sToast = Toast.makeText( context, msg, duration ); @@ -171,6 +169,12 @@ public final class TipToast { public interface ToastViewGenerator { View make( Context context, String message ); + + int gravity(); + + int yOffset(); + + int xOffset(); } } diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java index 582be511b8..26f0836020 100644 --- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java @@ -605,7 +605,7 @@ public class AMapNaviViewWrapper implements IMogoMapView, if ( checkAMapView() ) { if ( NaviClient.getInstance( getContext() ).isNaviing() ) { loseLockMode(); - NaviClient.getInstance( getContext() ).displayOverview(bounds); + NaviClient.getInstance( getContext() ).displayOverview( bounds ); } } } @@ -824,12 +824,16 @@ public class AMapNaviViewWrapper implements IMogoMapView, @Override public void setCarCursorOption( CarCursorOption option ) { - if ( mCarCursorOption != null ) { + if ( mCarCursorOption != null && mCarCursorOption != DEFAULT_OPTION ) { mCarCursorOption.destroy(); } - try { - mCarCursorOption = option.clone(); - } catch ( CloneNotSupportedException e ) { + if ( option != null ) { + try { + mCarCursorOption = option.clone(); + } catch ( Exception e ) { + mCarCursorOption = DEFAULT_OPTION; + } + } else { mCarCursorOption = DEFAULT_OPTION; } if ( !checkAMapView() ) { @@ -838,8 +842,10 @@ public class AMapNaviViewWrapper implements IMogoMapView, AMapNaviViewOptions options = mMapView.getViewOptions(); if ( options != null && mCarCursorOption.getNaviCursorRes() != 0 ) { options.setCarBitmap( BitmapFactory.decodeResource( getContext().getResources(), mCarCursorOption.getNaviCursorRes() ) ); - mMapView.setViewOptions( options ); + } else { + options.setCarBitmap( BitmapFactory.decodeResource( getContext().getResources(), DEFAULT_OPTION.getNaviCursorRes() ) ); } + mMapView.setViewOptions( options ); if ( mMapView.getMap() == null ) { return; @@ -850,6 +856,8 @@ public class AMapNaviViewWrapper implements IMogoMapView, } else { if ( mCarCursorOption.getCarCursorRes() != 0 ) { style.myLocationIcon( BitmapDescriptorFactory.fromResource( mCarCursorOption.getCarCursorRes() ) ); + } else { + style.myLocationIcon( BitmapDescriptorFactory.fromResource( DEFAULT_OPTION.getCarCursorRes() ) ); } } mMapView.getMap().setMyLocationStyle( style ); diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/IMogoMapUIController.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/IMogoMapUIController.java index a9dd283213..e8a557dd79 100644 --- a/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/IMogoMapUIController.java +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/IMogoMapUIController.java @@ -7,6 +7,7 @@ import android.view.View; import android.view.animation.Interpolator; import androidx.annotation.DrawableRes; +import androidx.annotation.Nullable; import com.mogo.map.MogoLatLng; import com.mogo.map.marker.IMogoMarker; @@ -194,7 +195,7 @@ public interface IMogoMapUIController { /** * 配置自车图标样式 * - * @param option + * @param option 为空时使用默认配置 */ - void setCarCursorOption( CarCursorOption option ); + void setCarCursorOption( @Nullable CarCursorOption option ); } 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 ff82c148d7..d5db0d506d 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 @@ -270,8 +270,7 @@ public class MapPresenter extends Presenter< MapView > implements private void registerVoiceCmd() { for ( Map.Entry< String, String[] > entry : VoiceConstants.sVoiceCmds.entrySet() ) { - AIAssist.getInstance( getContext() ) - .registerUnWakeupCommand( entry.getKey(), entry.getValue(), this ); + AIAssist.getInstance( getContext() ).registerUnWakeupCommand( entry.getKey(), entry.getValue(), this ); } for ( String cmd : VoiceConstants.sCmds ) { @@ -304,12 +303,10 @@ public class MapPresenter extends Presenter< MapView > implements switch ( cmd ) { case VoiceConstants.CMD_MAP_TRAFFIC_MODE_UN_WAKEUP: case VoiceConstants.CMD_MAP_TRAFFIC_MODE: - AIAssist.getInstance( getContext() ).speakTTSVoice( "已打开", null ); mView.getUIController().setTrafficEnabled( true ); break; case VoiceConstants.CMD_MAP_UN_TRAFFIC_MODE_UN_WAKEUP: case VoiceConstants.CMD_MAP_UN_TRAFFIC_MODE: - AIAssist.getInstance( getContext() ).speakTTSVoice( "已关闭", null ); mView.getUIController().setTrafficEnabled( false ); break; case VoiceConstants.CMD_MAP_ZOOM_IN_UN_WAKEUP: diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServices.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServices.java index 9f01b0e2b7..d4927ae776 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServices.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServices.java @@ -30,6 +30,7 @@ import com.mogo.map.navi.IMogoNaviListener; import com.mogo.map.navi.MogoCongestionInfo; import com.mogo.map.navi.MogoNaviInfo; import com.mogo.map.navi.MogoTraffic; +import com.mogo.map.uicontroller.CarCursorOption; import com.mogo.map.uicontroller.EnumMapUI; import com.mogo.map.uicontroller.IMogoMapUIController; import com.mogo.module.common.MogoModule; @@ -667,6 +668,11 @@ public class MogoServices implements IMogoMapListener, } break; case SEEK_HELPING: + if ( isTrue ) { + mUiController.setCarCursorOption( new CarCursorOption.Builder().carCursorRes( R.drawable.module_service_ic_seek_helping ).build() ); + } else { + mUiController.setCarCursorOption( null ); + } notifySeekHelpingStatusChanged( isTrue ); break; } @@ -785,13 +791,11 @@ public class MogoServices implements IMogoMapListener, } } else if ( ServiceConst.COMMAND_NEXT.equals( command ) ) { if ( mStatusManager.isMainPageOnResume() ) { - mActionManager.invoke( MapMarkerManager.getInstance().getCurrentModuleName(), - MogoAction.Next ); + mActionManager.invoke( MapMarkerManager.getInstance().getCurrentModuleName(), MogoAction.Next ); } } else if ( ServiceConst.COMMAND_PREVIOUS.equals( command ) ) { if ( mStatusManager.isMainPageOnResume() ) { - mActionManager.invoke( MapMarkerManager.getInstance().getCurrentModuleName(), - MogoAction.Prev ); + mActionManager.invoke( MapMarkerManager.getInstance().getCurrentModuleName(), MogoAction.Prev ); } } else if ( ServiceConst.COMMAND_SWITCH_CARD.equals( command ) ) { String data = intent.getStringExtra( "data" ); @@ -850,6 +854,11 @@ public class MogoServices implements IMogoMapListener, } if ( mStatusManager.isMainPageOnResume() ) { mUiController.recoverLockMode(); + } else { + mLauncher.backToLauncher( mContext ); + UiThreadHandler.postDelayed( () -> { + mUiController.recoverLockMode(); + }, 2_000L ); } } else if ( MogoReceiver.ACTION_MOCK.equals( command ) ) { final int oper = intent.getIntExtra( "oper", -1 ); @@ -857,6 +866,9 @@ public class MogoServices implements IMogoMapListener, case 1: mUiController.showMyLocation( true ); break; + case 2: + mStatusManager.setSeekHelping( TAG, false ); + break; } } } diff --git a/modules/mogo-module-service/src/main/res/drawable-ldpi/module_service_ic_seek_helping.png b/modules/mogo-module-service/src/main/res/drawable-ldpi/module_service_ic_seek_helping.png new file mode 100755 index 0000000000..ed3ff999dd Binary files /dev/null and b/modules/mogo-module-service/src/main/res/drawable-ldpi/module_service_ic_seek_helping.png differ diff --git a/modules/mogo-module-service/src/main/res/drawable-xhdpi/module_service_ic_seek_helping.png b/modules/mogo-module-service/src/main/res/drawable-xhdpi/module_service_ic_seek_helping.png new file mode 100755 index 0000000000..aa6eb75043 Binary files /dev/null and b/modules/mogo-module-service/src/main/res/drawable-xhdpi/module_service_ic_seek_helping.png differ