opt
This commit is contained in:
@@ -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" );
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<corners android:radius="90dp" />
|
||||
<gradient
|
||||
android:angle="270"
|
||||
android:endColor="#2A2B38"
|
||||
android:startColor="#3F4057" />
|
||||
</shape>
|
||||
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/module_commons_toast_bkg"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_commons_toast_msg"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginLeft="@dimen/module_commons_toast_marginLeft"
|
||||
android:layout_marginTop="@dimen/module_commons_toast_marginTop"
|
||||
android:layout_marginRight="@dimen/module_commons_toast_marginRight"
|
||||
android:layout_marginBottom="@dimen/module_commons_toast_marginBottom"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:maxWidth="@dimen/module_commons_toast_minWidth"
|
||||
android:maxLines="2"
|
||||
android:minWidth="@dimen/module_commons_toast_maxWidth"
|
||||
android:textColor="#FFFF"
|
||||
android:textSize="@dimen/module_commons_toast_textSize"
|
||||
tools:text="测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试" />
|
||||
</LinearLayout>
|
||||
11
foudations/mogo-commons/src/main/res/values-ldpi/dimens.xml
Normal file
11
foudations/mogo-commons/src/main/res/values-ldpi/dimens.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="module_commons_toast_marginLeft">30px</dimen>
|
||||
<dimen name="module_commons_toast_marginRight">30px</dimen>
|
||||
<dimen name="module_commons_toast_marginTop">16px</dimen>
|
||||
<dimen name="module_commons_toast_marginBottom">16px</dimen>
|
||||
<dimen name="module_commons_toast_textSize">22px</dimen>
|
||||
<dimen name="module_commons_toast_maxWidth">75px</dimen>
|
||||
<dimen name="module_commons_toast_minWidth">500px</dimen>
|
||||
<dimen name="module_commons_toast_y_offset">108px</dimen>
|
||||
</resources>
|
||||
13
foudations/mogo-commons/src/main/res/values-xhdpi/dimens.xml
Normal file
13
foudations/mogo-commons/src/main/res/values-xhdpi/dimens.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="module_commons_toast_marginLeft">50px</dimen>
|
||||
<dimen name="module_commons_toast_marginRight">50px</dimen>
|
||||
<dimen name="module_commons_toast_marginTop">32px</dimen>
|
||||
<dimen name="module_commons_toast_marginBottom">32px</dimen>
|
||||
<dimen name="module_commons_toast_textSize">40px</dimen>
|
||||
<dimen name="module_commons_toast_maxWidth">150px</dimen>
|
||||
<dimen name="module_commons_toast_minWidth">900px</dimen>
|
||||
<dimen name="module_commons_toast_y_offset">172px</dimen>
|
||||
</resources>
|
||||
|
||||
|
||||
13
foudations/mogo-commons/src/main/res/values/dimens.xml
Normal file
13
foudations/mogo-commons/src/main/res/values/dimens.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="module_commons_toast_marginLeft">50px</dimen>
|
||||
<dimen name="module_commons_toast_marginRight">50px</dimen>
|
||||
<dimen name="module_commons_toast_marginTop">32px</dimen>
|
||||
<dimen name="module_commons_toast_marginBottom">32px</dimen>
|
||||
<dimen name="module_commons_toast_textSize">40px</dimen>
|
||||
<dimen name="module_commons_toast_maxWidth">150px</dimen>
|
||||
<dimen name="module_commons_toast_minWidth">900px</dimen>
|
||||
<dimen name="module_commons_toast_y_offset">172px</dimen>
|
||||
</resources>
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 62 KiB |
Reference in New Issue
Block a user