This commit is contained in:
wangcongtao
2020-04-13 19:07:05 +08:00
parent 9f4c8a704f
commit dccc9be8be
44 changed files with 1151 additions and 448 deletions

3
.idea/gradle.xml generated
View File

@@ -24,6 +24,9 @@
<option value="$PROJECT_DIR$/modules/mogo-module-back" />
<option value="$PROJECT_DIR$/modules/mogo-module-common" />
<option value="$PROJECT_DIR$/modules/mogo-module-extensions" />
<option value="$PROJECT_DIR$/modules/mogo-module-gps-simulator" />
<option value="$PROJECT_DIR$/modules/mogo-module-gps-simulator-debug" />
<option value="$PROJECT_DIR$/modules/mogo-module-gps-simulator-noop" />
<option value="$PROJECT_DIR$/modules/mogo-module-guide" />
<option value="$PROJECT_DIR$/modules/mogo-module-main" />
<option value="$PROJECT_DIR$/modules/mogo-module-map" />

View File

@@ -172,6 +172,8 @@ dependencies {
implementation rootProject.ext.dependencies.mogomoduleback
implementation rootProject.ext.dependencies.mogomoduleguide
implementation rootProject.ext.dependencies.mogomoduleauth
debugImplementation rootProject.ext.dependencies.gpssimulatordebug
releaseImplementation rootProject.ext.dependencies.gpssimulatornoop
} else {
implementation project(':modules:mogo-module-main')
implementation project(':foudations:mogo-commons')
@@ -180,6 +182,8 @@ dependencies {
implementation project(':modules:mogo-module-back')
implementation project(':modules:mogo-module-guide')
implementation project(':modules:mogo-module-authorize')
debugImplementation project(':modules:mogo-module-gps-simulator-debug')
releaseImplementation project(':modules:mogo-module-gps-simulator-noop')
}
}

View File

@@ -6,7 +6,7 @@ ext {
buildToolsVersion : "29.0.2",
minSdkVersion : 19,
targetSdkVersion : 22,
versionName : "8.0.4",
versionName : "8.0.4",
]
dependencies = [
@@ -136,5 +136,10 @@ ext {
coroutinesandroid : "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1",
aspectj : "org.aspectj:aspectjrt:1.8.9",
// gps 模拟
gpssimulator : "com.mogo.module:module-gps-simulator:${MOGO_MODULE_GPS_SIMULATOR_VERSION}",
gpssimulatordebug : "com.mogo.module:mogo-module-gps-simulator-debug:${MOGO_MODULE_GPS_SIMULATOR_DEBUG_VERSION}",
gpssimulatornoop : "com.mogo.module:mogo-module-gps-simulator-noop:${MOGO_MODULE_GPS_SIMULATOR_NOOP_VERSION}",
]
}

View File

@@ -45,6 +45,10 @@ MOGO_MODULE_SERVICE_VERSION=1.0.3.1
MOGO_MODULE_EXTENSIONS_VERSION=1.0.3.1
MOGO_MODULE_SEARCH_VERSION=1.0.3.1
MOGO_MODULE_BACK_VERSION=1.0.3.1
MOGO_MODULE_GPS_SIMULATOR_VERSION=1.0.3.1
MOGO_MODULE_GPS_SIMULATOR_DEBUG_VERSION=1.0.3.1
MOGO_MODULE_GPS_SIMULATOR_NOOP_VERSION=1.0.3.1
MOGO_MODULE_AUTHORIZE_VERSION=1.0.0
MOGO_MODULE_GUIDE_VERSION=1.0.0

View File

@@ -82,8 +82,6 @@ public class AMapNaviViewWrapper implements IMogoMapView,
private AMapMarkerClickHandler mMarkerClickHandler;
private EnumMapUI mCurrentUIMode;
// 自定义定位源的回调信息,前瞻线
private LocationSource.OnLocationChangedListener mOnLocationChangedListener;
private boolean mIsCarLocked = false;
private float mDefaultZoomLevel = 16.0f;
@@ -212,7 +210,6 @@ public class AMapNaviViewWrapper implements IMogoMapView,
initMapView();
initListeners();
initMyLocation();
// initLocationSource();
}
}
@@ -554,21 +551,8 @@ public class AMapNaviViewWrapper implements IMogoMapView,
style.strokeWidth( 0 );
style.radiusFillColor( Color.TRANSPARENT );
mMapView.getMap().setMyLocationStyle( style );
}
}
private void initLocationSource() {
if ( checkAMapView() ) {
mMapView.getMap().setLocationSource( new LocationSource() {
@Override
public void activate( OnLocationChangedListener onLocationChangedListener ) {
AMapNaviViewWrapper.this.mOnLocationChangedListener = onLocationChangedListener;
}
@Override
public void deactivate() {
}
mMapView.getMap().setOnMyLocationChangeListener( location -> {
Logger.d( TAG, "%s", location );
} );
}
}
@@ -835,9 +819,6 @@ public class AMapNaviViewWrapper implements IMogoMapView,
@Override
public void changeMyLocation( Location location ) {
if ( mOnLocationChangedListener != null ) {
mOnLocationChangedListener.onLocationChanged( location );
}
}
@Override

View File

@@ -4,12 +4,14 @@ import android.content.Context;
import android.graphics.Rect;
import android.location.Location;
import com.amap.api.maps.LocationSource;
import com.amap.api.maps.model.Polyline;
import com.amap.api.navi.AMapNavi;
import com.amap.api.navi.enums.AimLessMode;
import com.amap.api.navi.enums.NaviType;
import com.amap.api.navi.model.NaviLatLng;
import com.mogo.map.MogoLatLng;
import com.mogo.map.impl.amap.AMapWrapper;
import com.mogo.map.impl.amap.message.AMapMessageManager;
import com.mogo.map.impl.amap.utils.ObjectUtils;
import com.mogo.map.navi.IMogoCarLocationChangedListener;
@@ -51,6 +53,7 @@ public class NaviClient implements IMogoNavi {
private Location mCarLocation;
private IMogoCarLocationChangedListener mCarLocationChangedListener;
private LocationSource.OnLocationChangedListener mOnLocationChangedListener;
private NaviClient( Context context ) {
mAMapNavi = AMapNavi.getInstance( context );
@@ -289,4 +292,45 @@ public class NaviClient implements IMogoNavi {
mAMapNaviListener.displayOverview();
}
}
@Override
public void setUseExtraGPSData( boolean use ) {
Logger.d( TAG, "设置外部gps源状态 %s", use );
mAMapNavi.setIsUseExtraGPSData( use );
if ( use ) {
AMapWrapper.getAMap().setLocationSource( new LocationSource() {
@Override
public void activate( OnLocationChangedListener onLocationChangedListener ) {
NaviClient.this.mOnLocationChangedListener = onLocationChangedListener;
}
@Override
public void deactivate() {
}
} );
} else {
AMapWrapper.getAMap().setLocationSource( null );
mOnLocationChangedListener = null;
}
}
@Override
public void setExtraGPSData( double lon, double lat, float speed, float accuracy, float bearing, long timestamp ) {
if ( !mAMapNavi.getIsUseExtraGPSData() ) {
Logger.d( TAG, "拒绝外部GPS数据" );
return;
}
Location location = new Location( "外部GPS源" );
location.setLongitude( lon );
location.setLatitude( lat );
location.setSpeed( speed );
location.setAccuracy( accuracy );
location.setBearing( bearing );
location.setTime( timestamp );
//type字段传1时代表WGS84坐标
mAMapNavi.setExtraGPSData( 2, location );
if ( mOnLocationChangedListener != null ) {
mOnLocationChangedListener.onLocationChanged( location );
}
}
}

View File

@@ -1,8 +1,10 @@
package com.mogo.map.navi;
import android.graphics.Rect;
import android.location.Location;
import com.mogo.map.MogoLatLng;
import com.mogo.map.location.MogoLocation;
import java.util.List;
@@ -163,4 +165,16 @@ public interface IMogoNavi {
* 查看全程
*/
void displayOverview();
/**
* 设置使用外部定位源
*
* @param use true - 使用false - 不适用
*/
void setUseExtraGPSData( boolean use );
/**
* 设置外部数据源
*/
void setExtraGPSData( double lon, double lat, float speed, float accuracy, float bearing, long timestamp );
}

View File

@@ -2,6 +2,7 @@ package com.mogo.map;
import android.content.Context;
import android.graphics.Rect;
import android.location.Location;
import com.mogo.map.impl.amap.navi.NaviClient;
import com.mogo.map.navi.IMogoCarLocationChangedListener;
@@ -201,4 +202,18 @@ public class MogoNavi implements IMogoNavi {
mDelegate.displayOverview();
}
}
@Override
public void setUseExtraGPSData( boolean use ) {
if ( mDelegate != null ) {
mDelegate.setUseExtraGPSData( use );
}
}
@Override
public void setExtraGPSData( double lon, double lat, float speed, float accuracy, float bearing, long timestamp ) {
if ( mDelegate != null ) {
mDelegate.setExtraGPSData( lon, lat, speed, accuracy, bearing, timestamp );
}
}
}

View File

@@ -0,0 +1 @@
/build

View File

@@ -0,0 +1,53 @@
apply plugin: 'com.android.library'
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")
javaCompileOptions {
annotationProcessorOptions {
arguments = [AROUTER_MODULE_NAME: project.getName()]
}
}
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation rootProject.ext.dependencies.arouter
annotationProcessor rootProject.ext.dependencies.aroutercompiler
implementation "org.java-websocket:Java-WebSocket:1.4.0"
if (Boolean.valueOf(RELEASE)) {
implementation rootProject.ext.dependencies.mogoutils
implementation rootProject.ext.dependencies.mogocommons
implementation rootProject.ext.dependencies.gpssimulator
implementation rootProject.ext.dependencies.mogoserviceapi
} else {
implementation project(':foudations:mogo-utils')
implementation project(":foudations:mogo-commons")
implementation project(':modules:mogo-module-gps-simulator')
implementation project(':services:mogo-service-api')
}
}

View File

@@ -0,0 +1,3 @@
GROUP=com.mogo.module
POM_ARTIFACT_ID=module-gps-simulator-debug
VERSION_CODE=1

View File

@@ -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

View File

@@ -0,0 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mogo.module.gps.simulator.debug" />

View File

@@ -0,0 +1,134 @@
package com.mogo.module.gps.simulator;
/**
* @author zyz
* 2020-04-08.
*/
public class CationVo {
/**
* vehicleSpeed : 1.0
* instantSpeed : 1.0
* lon : 116.401615
* lat : 39.968812
* carStatus : 1
* direction : 267
* sn : ZD801C1928L00371
* locationTime : 1586339911534
* distance : 0.0
* adCode : 2
* cityCode : 3
* vehicleType : 0
*/
private float vehicleSpeed;
private double instantSpeed;
private double lon;
private double lat;
private int carStatus;
private int direction;
private String sn;
private long locationTime;
private double distance;
private String adCode;
private String cityCode;
private int vehicleType;
public float getVehicleSpeed() {
return vehicleSpeed;
}
public void setVehicleSpeed( float vehicleSpeed ) {
this.vehicleSpeed = vehicleSpeed;
}
public double getInstantSpeed() {
return instantSpeed;
}
public void setInstantSpeed( double instantSpeed ) {
this.instantSpeed = instantSpeed;
}
public double getLon() {
return lon;
}
public void setLon( double lon ) {
this.lon = lon;
}
public double getLat() {
return lat;
}
public void setLat( double lat ) {
this.lat = lat;
}
public int getCarStatus() {
return carStatus;
}
public void setCarStatus( int carStatus ) {
this.carStatus = carStatus;
}
public int getDirection() {
return direction;
}
public void setDirection( int direction ) {
this.direction = direction;
}
public String getSn() {
return sn;
}
public void setSn( String sn ) {
this.sn = sn;
}
public long getLocationTime() {
return locationTime;
}
public void setLocationTime( long locationTime ) {
this.locationTime = locationTime;
}
public double getDistance() {
return distance;
}
public void setDistance( double distance ) {
this.distance = distance;
}
public String getAdCode() {
return adCode;
}
public void setAdCode( String adCode ) {
this.adCode = adCode;
}
public String getCityCode() {
return cityCode;
}
public void setCityCode( String cityCode ) {
this.cityCode = cityCode;
}
public int getVehicleType() {
return vehicleType;
}
public void setVehicleType( int vehicleType ) {
this.vehicleType = vehicleType;
}
}

View File

@@ -0,0 +1,47 @@
package com.mogo.module.gps.simulator;
import com.mogo.utils.logger.Logger;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.drafts.Draft_6455;
import org.java_websocket.handshake.ServerHandshake;
import java.net.URI;
/**
* @author zyz
* 2020-04-07.
*/
public class JWebSocketClient extends WebSocketClient {
public JWebSocketClient( URI serverUri ) {
super( serverUri, new Draft_6455() );
}
@Override
public void onOpen( ServerHandshake handshakedata ) {
Logger.e( "JWebSocketClient", "onOpen()" );
bindSN();
}
private void bindSN() {
String data = String.format( "{ \"sn\": \"%s\", \"bind\": true }", Utils.getSn() );
send( data );
}
@Override
public void onMessage( String message ) {
Logger.e( "JWebSocketClient", "onMessage()" );
}
@Override
public void onClose( int code, String reason, boolean remote ) {
Logger.e( "JWebSocketClient", "onClose()" );
}
@Override
public void onError( Exception ex ) {
Logger.e( "JWebSocketClient", "onError()" );
ex.printStackTrace();
}
}

View File

@@ -0,0 +1,33 @@
package com.mogo.module.gps.simulator;
import android.content.Context;
import com.alibaba.android.arouter.facade.annotation.Route;
/**
* @author congtaowang
* @since 2020-04-13
* <p>
* 描述
*/
@Route( path = GpsSimulatorConstants.API_PATH )
public class MogoGpsSimulatorManagerDebug implements IMogoGpsSimulatorManager {
private static final String TAG = "MogoGpsSimulatorManagerDebug";
@Override
public void open() {
WebSocketManager.getInstance().connect( true );
}
@Override
public void close() {
WebSocketManager.getInstance().disConnect();
}
@Override
public void init( Context context ) {
}
}

View File

@@ -0,0 +1,43 @@
package com.mogo.module.gps.simulator;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
/**
* Created by congtaowang on 2018/3/29.
*/
class Utils {
public static final String GET = "get";
public static final String GSM_SERIAL = "gsm.serial";
public static final String FOTA_VERSION = "ro.fota.version";
public static final String PROPERTIES = "android.os.SystemProperties";
public static String getSn() {
return getSystemProperties( GSM_SERIAL );
}
public static String getFotaVersion() {
return getSystemProperties( FOTA_VERSION );
}
public static String getSystemProperties( String name ) {
String value = "";
try {
Class< ? > c = Class.forName( PROPERTIES );
Method get = c.getMethod( GET, String.class );
value = ( String ) get.invoke( c, name );
} catch ( ClassNotFoundException var3 ) {
var3.printStackTrace();
} catch ( NoSuchMethodException var4 ) {
var4.printStackTrace();
} catch ( InvocationTargetException var5 ) {
var5.printStackTrace();
} catch ( IllegalAccessException var6 ) {
var6.printStackTrace();
}
return value;
}
}

View File

@@ -0,0 +1,122 @@
package com.mogo.module.gps.simulator;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.map.navi.IMogoNavi;
import com.mogo.service.IMogoServiceApis;
import com.mogo.service.MogoServicePaths;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.network.utils.GsonUtil;
import org.json.JSONObject;
import java.net.URI;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* @author zyz
* 2020-04-07.
*/
public class WebSocketManager {
private static final String TAG = "WebSocketManager";
private static Object sLock = new Object();
private static WebSocketManager sWebSocketManager;
private IMogoNavi mNavi;
private JWebSocketClient mClient;
private URI mUri;
private ExecutorService mService = Executors.newSingleThreadExecutor();
public static WebSocketManager getInstance() {
if ( sWebSocketManager == null ) {
synchronized ( sLock ) {
if ( sWebSocketManager == null ) {
sWebSocketManager = new WebSocketManager();
}
}
}
return sWebSocketManager;
}
private WebSocketManager() {
final IMogoServiceApis mServiceApis = ( IMogoServiceApis ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICE_APIS ).navigation();
mNavi = mServiceApis.getMapServiceApi().getNavi( AbsMogoApplication.getApp() );
mUri = URI.create( "ws://152.136.10.223:4001/realtimeLocations-ws" );
mClient = new JWebSocketClient( mUri ) {
@Override
public void onMessage( String message ) {
try {
parseMessage( message );
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
}
}
};
}
private void parseMessage( String jsonStr ) throws Exception {
//message就是接收到的消息
Logger.d( TAG, jsonStr );
JSONObject jsonObject = new JSONObject( jsonStr );
if ( jsonObject.has( "detailMsg" ) ) {
Logger.d( TAG, "绑定成功" );
} else if ( jsonObject.has( "realTimeLocationVo" ) ) {
Logger.d( TAG, "收到定位消息" );
CationVo realTimeLocationVo = GsonUtil.objectFromJson( jsonObject.getString( "realTimeLocationVo" ), CationVo.class );
mNavi.setExtraGPSData(
realTimeLocationVo.getLon(),
realTimeLocationVo.getLat(),
realTimeLocationVo.getVehicleSpeed(),
1,
realTimeLocationVo.getDirection(),
realTimeLocationVo.getLocationTime()
);
}
}
public void connect( final boolean block ) {
if ( mClient == null ) {
return;
}
if ( mClient.isOpen() ) {
return;
}
mService.execute( () -> {
if ( block ) {
try {
if ( mClient.isClosed() ) {
mClient.reconnectBlocking();
} else {
mClient.connectBlocking();
}
} catch ( InterruptedException e ) {
Logger.e( TAG, e, "error." );
}
} else {
if ( mClient.isClosed() ) {
mClient.reconnect();
} else {
mClient.connect();
}
}
} );
}
public void disConnect() {
if ( mClient == null ) {
return;
}
if ( mClient.isClosing() || mClient.isClosed() || !mClient.isOpen() ) {
return;
}
try {
mService.execute( () -> { mClient.close(); } );
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
}
}
}

View File

@@ -0,0 +1,3 @@
<resources>
<string name="app_name">mogo-module-gps-simulator</string>
</resources>

View File

@@ -0,0 +1 @@
/build

View File

@@ -0,0 +1,48 @@
apply plugin: 'com.android.library'
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")
javaCompileOptions {
annotationProcessorOptions {
arguments = [AROUTER_MODULE_NAME: project.getName()]
}
}
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation rootProject.ext.dependencies.arouter
annotationProcessor rootProject.ext.dependencies.aroutercompiler
if (Boolean.valueOf(RELEASE)) {
implementation rootProject.ext.dependencies.mogoutils
implementation rootProject.ext.dependencies.gpssimulator
} else {
implementation project(':foudations:mogo-utils')
implementation project(':modules:mogo-module-gps-simulator')
}
}

View File

@@ -0,0 +1,3 @@
GROUP=com.mogo.module
POM_ARTIFACT_ID=module-gps-simulator-noop
VERSION_CODE=1

View File

@@ -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

View File

@@ -0,0 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mogo.module.gps.simulator.noop" />

View File

@@ -0,0 +1,32 @@
package com.mogo.module.gps.simulator;
import android.content.Context;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.utils.logger.Logger;
/**
* @author congtaowang
* @since 2020-04-13
* <p>
* 描述
*/
@Route( path = GpsSimulatorConstants.API_PATH )
public class MogoGpsSimulatorManagerNoop implements IMogoGpsSimulatorManager {
private static final String TAG = "MogoGpsSimulatorManagerNoop";
@Override
public void open() {
Logger.e( TAG, "no operation when release." );
}
@Override
public void close() {
Logger.e( TAG, "no operation when release." );
}
@Override
public void init( Context context ) {
}
}

View File

@@ -0,0 +1,3 @@
<resources>
<string name="app_name">mogo-module-gps-simulator</string>
</resources>

View File

@@ -0,0 +1 @@
/build

View File

@@ -0,0 +1,39 @@
apply plugin: 'com.android.library'
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'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation rootProject.ext.dependencies.arouter
if (Boolean.valueOf(RELEASE)) {
implementation rootProject.ext.dependencies.mogomoduleauth
} else {
implementation project(':modules:mogo-module-authorize')
}
}

View File

@@ -0,0 +1,3 @@
GROUP=com.mogo.module
POM_ARTIFACT_ID=module-gps-simulator
VERSION_CODE=1

View File

@@ -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

View File

@@ -0,0 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mogo.module.gps.simulator" />

View File

@@ -0,0 +1,12 @@
package com.mogo.module.gps.simulator;
/**
* @author congtaowang
* @since 2020-04-13
* <p>
* 描述
*/
public class GpsSimulatorConstants {
public static final String API_PATH = "/gpssimulator/api";
}

View File

@@ -0,0 +1,22 @@
package com.mogo.module.gps.simulator;
import com.alibaba.android.arouter.facade.template.IProvider;
/**
* @author congtaowang
* @since 2020-04-13
* <p>
* gps 模拟控制开关
*/
public interface IMogoGpsSimulatorManager extends IProvider {
/**
* 打开 gps 模拟
*/
void open();
/**
* 关闭 gps 模拟
*/
void close();
}

View File

@@ -0,0 +1,3 @@
<resources>
<string name="app_name">mogo-module-gps-simulator</string>
</resources>

View File

@@ -3,80 +3,72 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion rootProject.ext.android.compileSdkVersion
// buildToolsVersion rootProject.ext.android.buildToolsVersion
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")
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'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
kapt {
useBuildCache = false
arguments {
arg("AROUTER_MODULE_NAME", project.getName())
}
kapt {
useBuildCache = false
arguments {
arg("AROUTER_MODULE_NAME", project.getName())
}
}
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation rootProject.ext.dependencies.androidxappcompat
implementation rootProject.ext.dependencies.androidxconstraintlayout
implementation rootProject.ext.dependencies.arouter
implementation rootProject.ext.dependencies.room
kapt rootProject.ext.dependencies.roomAnnotationProcessor
implementation rootProject.ext.dependencies.roomRxjava
implementation rootProject.ext.dependencies.androidxrecyclerview
implementation rootProject.ext.dependencies.androidxcardview
kapt rootProject.ext.dependencies.aroutercompiler
// implementation rootProject.ext.dependencies.jetbrainsannotationsjava5
implementation rootProject.ext.dependencies.rxandroid
// api project(path: ':modules:mogo-module-common')
// api project(path: ':foudations:mogo-utils')
// api project(path: ':modules:mogo-module-map')
implementation rootProject.ext.dependencies.guideshowprovider
implementation rootProject.ext.dependencies.androidxappcompat
implementation rootProject.ext.dependencies.androidxconstraintlayout
implementation rootProject.ext.dependencies.arouter
implementation rootProject.ext.dependencies.room
kapt rootProject.ext.dependencies.roomAnnotationProcessor
implementation rootProject.ext.dependencies.roomRxjava
implementation rootProject.ext.dependencies.androidxrecyclerview
implementation rootProject.ext.dependencies.androidxcardview
kapt rootProject.ext.dependencies.aroutercompiler
implementation rootProject.ext.dependencies.rxandroid
implementation rootProject.ext.dependencies.guideshowprovider
if (Boolean.valueOf(RELEASE)) {
// implementation rootProject.ext.dependencies.mogomap
implementation rootProject.ext.dependencies.mogomapapi
implementation rootProject.ext.dependencies.mogoutils
implementation rootProject.ext.dependencies.mogocommons
implementation rootProject.ext.dependencies.mogoserviceapi
implementation rootProject.ext.dependencies.modulecommon
// implementation rootProject.ext.dependencies.modulemap
} else {
// implementation project(":libraries:mogo-map")
implementation project(":libraries:mogo-map-api")
implementation project(":foudations:mogo-utils")
api project(":foudations:mogo-commons")
api project(':services:mogo-service-api')
api project(':modules:mogo-module-common')
// implementation project(':modules:mogo-module-map')
}
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'com.zhidaoauto.voice.controller:api:1.0.2'
if (Boolean.valueOf(RELEASE)) {
implementation rootProject.ext.dependencies.mogomapapi
implementation rootProject.ext.dependencies.mogoutils
implementation rootProject.ext.dependencies.mogocommons
implementation rootProject.ext.dependencies.mogoserviceapi
implementation rootProject.ext.dependencies.modulecommon
implementation rootProject.ext.dependencies.gpssimulator
} else {
implementation project(":libraries:mogo-map-api")
implementation project(":foudations:mogo-utils")
implementation project(":foudations:mogo-commons")
implementation project(':services:mogo-service-api')
implementation project(':modules:mogo-module-common')
implementation project(':modules:mogo-module-gps-simulator')
}
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'com.zhidaoauto.voice.controller:api:1.0.2'
}

View File

@@ -10,6 +10,8 @@ import com.mogo.map.navi.IMogoNavi
import com.mogo.map.search.geo.IMogoGeoSearch
import com.mogo.map.uicontroller.IMogoMapUIController
import com.mogo.module.common.MogoModulePaths
import com.mogo.module.gps.simulator.GpsSimulatorConstants
import com.mogo.module.gps.simulator.IMogoGpsSimulatorManager
import com.mogo.module.guideshow.provider.GuideShowProviderConstant
import com.mogo.module.guideshow.provider.IGuideShowProvider
import com.mogo.service.MogoServicePaths
@@ -26,55 +28,53 @@ import com.mogo.service.statusmanager.IMogoStatusManager
* 2020-01-08.
*/
@SuppressLint("StaticFieldLeak")
object SearchServiceHolder{
// 单例对象要使用Application Context
private lateinit var context: Context
object SearchServiceHolder {
// 单例对象要使用Application Context
private lateinit var context: Context
val fragmentManager: IMogoFragmentManager = ARouter.getInstance().build(MogoServicePaths.PATH_FRAGMENT_MANAGER).navigation() as IMogoFragmentManager
val mapService: IMogoMapService = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICES_MAP).navigation() as IMogoMapService
val listenerCenter: IMogoRegisterCenter = ARouter.getInstance().build(MogoServicePaths.PATH_REGISTER_CENTER).navigation() as IMogoRegisterCenter
val statusManager: IMogoStatusManager = ARouter.getInstance().build(MogoServicePaths.PATH_STATUS_MANAGER).navigation() as IMogoStatusManager
val analyticsManager: IMogoAnalytics = ARouter.getInstance().build(MogoServicePaths.PATH_UTILS_ANALYTICS).navigation() as IMogoAnalytics
val guideShowProvider: IGuideShowProvider = ARouter.getInstance().build(GuideShowProviderConstant.GUIDE_SHOW_PROVIDER).navigation() as IGuideShowProvider
val mogoLauncher: IMogoLauncher = ARouter.getInstance().build(MogoServicePaths.PATH_LAUNCHER_API).navigation() as IMogoLauncher
val fragmentManager: IMogoFragmentManager = ARouter.getInstance().build(MogoServicePaths.PATH_FRAGMENT_MANAGER).navigation() as IMogoFragmentManager
val mapService: IMogoMapService = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICES_MAP).navigation() as IMogoMapService
val listenerCenter: IMogoRegisterCenter = ARouter.getInstance().build(MogoServicePaths.PATH_REGISTER_CENTER).navigation() as IMogoRegisterCenter
val statusManager: IMogoStatusManager = ARouter.getInstance().build(MogoServicePaths.PATH_STATUS_MANAGER).navigation() as IMogoStatusManager
val analyticsManager: IMogoAnalytics = ARouter.getInstance().build(MogoServicePaths.PATH_UTILS_ANALYTICS).navigation() as IMogoAnalytics
val guideShowProvider: IGuideShowProvider = ARouter.getInstance().build(GuideShowProviderConstant.GUIDE_SHOW_PROVIDER).navigation() as IGuideShowProvider
val mogoLauncher: IMogoLauncher = ARouter.getInstance().build(MogoServicePaths.PATH_LAUNCHER_API).navigation() as IMogoLauncher
val gpsSimulator = ARouter.getInstance().build(GpsSimulatorConstants.API_PATH).navigation() as IMogoGpsSimulatorManager
var geoSearch: IMogoGeoSearch? = null
fun init(context: Context) {
this.context = context
}
var geoSearch: IMogoGeoSearch? = null
fun init(context: Context) {
this.context = context
fun push(
fragment: Fragment,
tag: String
) {
val builder = FragmentDescriptor.Builder()
builder.fragment(fragment)
val build = builder.tag(tag)
.build()
fragmentManager.push(build)
}
fun getNavi(): IMogoNavi {
return mapService.getNavi(context)
}
fun getLocationClient(): IMogoLocationClient {
return mapService.getLocationClient(context)
}
fun getMapUIController(): IMogoMapUIController {
return mapService.mapUIController
}
fun getMarkerManger(): IMogoMarkerManager {
return mapService.getMarkerManager(context)
}
fun getGeoSearcher(): IMogoGeoSearch {
if (geoSearch == null) {
geoSearch = mapService.getGeoSearch(context)
}
return geoSearch!!
}
fun push(fragment: Fragment, tag: String) {
val builder = FragmentDescriptor.Builder()
builder.fragment(fragment)
val build = builder.tag(tag).build()
fragmentManager.push(build)
}
fun getNavi(): IMogoNavi {
return mapService.getNavi(context)
}
fun getLocationClient(): IMogoLocationClient {
return mapService.getLocationClient(context)
}
fun getMapUIController(): IMogoMapUIController {
return mapService.mapUIController
}
fun getMarkerManger(): IMogoMarkerManager {
return mapService.getMarkerManager(context)
}
fun getGeoSearcher(): IMogoGeoSearch {
if (geoSearch == null) {
geoSearch = mapService.getGeoSearch(context)
}
return geoSearch!!
}
}

View File

@@ -42,6 +42,11 @@ object SettingManager : IMogoSettingManager {
*/
private var isMonitor: Boolean = false
/**
* GPS 模拟
*/
private var isGpsSimulator: Boolean = false
override fun getPathPrefer(): Int {
return settings!!.getInt(KEY_PAHT_PREFER, 0)
}
@@ -90,6 +95,14 @@ object SettingManager : IMogoSettingManager {
return isMonitor
}
fun setGpsSimulator(type:Boolean){
isGpsSimulator = type
}
fun isGpsSimulator(): Boolean {
return isGpsSimulator
}
/**
* 是否躲避拥堵
*/

View File

@@ -4,6 +4,7 @@ import android.os.Bundle
import android.view.View
import android.widget.CompoundButton
import android.widget.CompoundButton.OnCheckedChangeListener
import android.widget.CompoundButton.VISIBLE
import android.widget.SeekBar
import android.widget.SeekBar.OnSeekBarChangeListener
import com.alibaba.android.arouter.facade.annotation.Route
@@ -32,279 +33,259 @@ import org.greenrobot.eventbus.ThreadMode
*/
class NaviSettingFragment : BaseFragment(), OnCheckedChangeListener {
private var type: Int = 0
private var type: Int = 0
override fun onCheckedChanged(
buttonView: CompoundButton?,
isChecked: Boolean
) {
if (buttonView?.id == R.id.rb_navi_fee) {
SettingManager.cost(isChecked)
if (isChecked) {
type = 2
rb_navi_high_way.isChecked = false
}
} else if (buttonView?.id == R.id.rb_navi_high_way) {
SettingManager.highSpeed(isChecked)
type = 4
override fun onCheckedChanged(
buttonView: CompoundButton?,
isChecked: Boolean) {
if (buttonView?.id == R.id.rb_navi_fee) {
SettingManager.cost(isChecked)
if (isChecked) {
type = 2
rb_navi_high_way.isChecked = false
}
} else if (buttonView?.id == R.id.rb_navi_high_way) {
SettingManager.highSpeed(isChecked)
type = 4
if (isChecked) {
rb_navi_no_high_way.isChecked = false
rb_navi_fee.isChecked = false
}
} else if (buttonView?.id == R.id.rb_navi_no_high_way) {
SettingManager.avoidSpeed(isChecked)
type = 3
if (isChecked) {
rb_navi_no_high_way.isChecked = false
rb_navi_fee.isChecked = false
}
} else if (buttonView?.id == R.id.rb_navi_no_high_way) {
SettingManager.avoidSpeed(isChecked)
type = 3
if (isChecked) {
rb_navi_high_way.isChecked = false
}
} else if (buttonView?.id == R.id.rb_navi_jam) {
SettingManager.congestion(isChecked)
type = 1
if (isChecked) {
rb_navi_high_way.isChecked = false
}
} else if (buttonView?.id == R.id.rb_navi_jam) {
SettingManager.congestion(isChecked)
type = 1
}
if (isChecked) {
SearchServiceHolder.analyticsManager.track("Navigation_preference", mapOf("type" to type))
}
}
if (isChecked) {
SearchServiceHolder.analyticsManager.track("Navigation_preference", mapOf("type" to type))
override fun getLayoutId(): Int {
return R.layout.fragment_navi_setting
}
}
override fun onViewCreated(
view: View,
savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
override fun getLayoutId(): Int {
return R.layout.fragment_navi_setting
}
override fun onViewCreated(
view: View,
savedInstanceState: Bundle?
) {
super.onViewCreated(view, savedInstanceState)
iv_back.setOnClickListener {
SearchServiceHolder.fragmentManager.pop()
}
initViews()
initEvent()
EventBus.getDefault()
.register(this)
}
private fun initViews() {
rb_navi_high_way.isChecked = SettingManager.isHighSpeed()
rb_navi_jam.isChecked = SettingManager.isCongestion()
rb_navi_no_high_way.isChecked = SettingManager.isAvoidSpeed()
rb_navi_fee.isChecked = SettingManager.isCost()
sb_navi_volume_progress.progress = SettingManager.volume
rb_navi_day.isChecked = SettingManager.mapType == R.id.rb_navi_day
rb_navi_night.isChecked = SettingManager.mapType == R.id.rb_navi_night
rb_navi_auto.isChecked = SettingManager.mapType == R.id.rb_navi_auto
rb_navi_detail.isChecked = SettingManager.voiceStyle == R.id.rb_navi_detail
rb_navi_draft.isChecked = SettingManager.voiceStyle == R.id.rb_navi_draft
updateHome()
updateCompany()
}
private fun initEvent() {
iv_sound_plus.setOnClickListener {
VolumeManager.getInstance(context)
.incVolume()
sb_navi_volume_progress.progress = sb_navi_volume_progress.progress.plus(10)
SettingManager.volume = sb_navi_volume_progress.progress
}
iv_sound_minus.setOnClickListener {
VolumeManager.getInstance(context)
.decVolume()
sb_navi_volume_progress.progress = sb_navi_volume_progress.progress.minus(10)
SettingManager.volume = sb_navi_volume_progress.progress
iv_back.setOnClickListener {
SearchServiceHolder.fragmentManager.pop()
}
initViews()
initEvent()
EventBus.getDefault().register(this)
}
rb_navi_jam.setOnCheckedChangeListener(this)
rb_navi_high_way.setOnCheckedChangeListener(this)
rb_navi_no_high_way.setOnCheckedChangeListener(this)
rb_navi_fee.setOnCheckedChangeListener(this)
private fun initViews() {
sb_navi_volume_progress.max = VolumeManager.getInstance(context)
.getMaxVol()
sb_navi_volume_progress.progress = VolumeManager.getInstance(context)
.sysVolume
rb_navi_high_way.isChecked = SettingManager.isHighSpeed()
rb_navi_jam.isChecked = SettingManager.isCongestion()
rb_navi_no_high_way.isChecked = SettingManager.isAvoidSpeed()
rb_navi_fee.isChecked = SettingManager.isCost()
sb_navi_volume_progress.progress = SettingManager.volume
rb_navi_day.isChecked = SettingManager.mapType == R.id.rb_navi_day
rb_navi_night.isChecked = SettingManager.mapType == R.id.rb_navi_night
rb_navi_auto.isChecked = SettingManager.mapType == R.id.rb_navi_auto
rb_navi_detail.isChecked = SettingManager.voiceStyle == R.id.rb_navi_detail
rb_navi_draft.isChecked = SettingManager.voiceStyle == R.id.rb_navi_draft
sb_navi_volume_progress.setOnSeekBarChangeListener(object : OnSeekBarChangeListener {
override fun onProgressChanged(
seekBar: SeekBar?,
progress: Int,
fromUser: Boolean
) {
if (fromUser) {
VolumeManager.getInstance(context)
.setSysVolume(progress)
SettingManager.volume = sb_navi_volume_progress.progress
updateHome()
updateCompany()
}
private fun initEvent() {
iv_sound_plus.setOnClickListener {
VolumeManager.getInstance(context).incVolume()
sb_navi_volume_progress.progress = sb_navi_volume_progress.progress.plus(10)
SettingManager.volume = sb_navi_volume_progress.progress
}
iv_sound_minus.setOnClickListener {
VolumeManager.getInstance(context).decVolume()
sb_navi_volume_progress.progress = sb_navi_volume_progress.progress.minus(10)
SettingManager.volume = sb_navi_volume_progress.progress
}
rb_navi_jam.setOnCheckedChangeListener(this)
rb_navi_high_way.setOnCheckedChangeListener(this)
rb_navi_no_high_way.setOnCheckedChangeListener(this)
rb_navi_fee.setOnCheckedChangeListener(this)
sb_navi_volume_progress.max = VolumeManager.getInstance(context).getMaxVol()
sb_navi_volume_progress.progress = VolumeManager.getInstance(context).sysVolume
sb_navi_volume_progress.setOnSeekBarChangeListener(object : OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
if (fromUser) {
VolumeManager.getInstance(context)
.setSysVolume(progress)
SettingManager.volume = sb_navi_volume_progress.progress
}
// audioManager.setStreamVolume( AudioManager.STREAM_MUSIC, progress, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE )
}
override fun onStartTrackingTouch(seekBar: SeekBar?) {
}
override fun onStopTrackingTouch(seekBar: SeekBar?) {
}
})
rg_navi_day_night.setOnCheckedChangeListener { group, checkedId ->
SettingManager.mapType = checkedId
when (checkedId) {
R.id.rb_navi_day -> {
SearchServiceHolder.getMapUIController().changeMapMode(EnumMapUI.Type_Light)
}
R.id.rb_navi_night -> {
SearchServiceHolder.getMapUIController().changeMapMode(EnumMapUI.Type_Night)
}
R.id.rb_navi_auto -> {
SearchServiceHolder.getMapUIController().changeMapMode(EnumMapUI.Type_AUTO_LIGHT_Night)
}
}
}
rg_navi_sound_type.setOnCheckedChangeListener { group, checkedId ->
SettingManager.voiceStyle = checkedId
SearchServiceHolder.getNavi().setBroadcastMode(
if (checkedId == R.id.rb_navi_detail) BroadcastMode.DETAIL else BroadcastMode.CONCISE
)
if (checkedId == R.id.rb_navi_detail) {
SearchServiceHolder.analyticsManager.track("Navigation_guide_type", mapOf("type" to 1))
} else {
SearchServiceHolder.analyticsManager.track("Navigation_guide_type", mapOf("type" to 2))
}
}
tv_navi_clear_home_address.setOnClickListener {
AddressManager.deleteHome(context!!)
clearHome()
}
tv_navi_clear_company_address.setOnClickListener {
AddressManager.deleteCompany(context!!)
clearCompany()
}
tv_navi_company_address.setOnClickListener {
if (!AddressManager.hasCompany()) {
AddressManager.goCompany()
}
}
tv_navi_home_address.setOnClickListener {
if (!AddressManager.hasHome()) {
AddressManager.goHome()
}
}
if (DebugConfig.isDebug()) {
tb_navi.setOnCheckedChangeListener { _, isChecked ->
SettingManager.setMonitor(isChecked)
}
tb_navi.isChecked = SettingManager.isMonitor()
tb_gps.isChecked = SettingManager.isGpsSimulator()
tb_gps.setOnCheckedChangeListener { _, isChecked ->
if (SettingManager.isGpsSimulator() == isChecked) {
return@setOnCheckedChangeListener
}
SettingManager.setGpsSimulator(isChecked)
SearchServiceHolder.getNavi().setUseExtraGPSData(isChecked)
if (isChecked) {
SearchServiceHolder.gpsSimulator.open()
} else {
SearchServiceHolder.gpsSimulator.close()
}
}
ll_navi_simulator.visibility = View.VISIBLE
tv_navi_simulator.visibility = View.VISIBLE
} else {
ll_navi_simulator.visibility = View.GONE
tv_navi_simulator.visibility = View.GONE
}
}
private fun updateHome() {
if (AddressManager.hasHome()) {
tv_navi_home_address.text = AddressManager.homeAddress?.address
tv_navi_clear_home_address.visibility = View.VISIBLE
} else {
tv_navi_clear_home_address.visibility = View.GONE
}
}
private fun clearHome() {
tv_navi_clear_home_address.visibility = View.GONE
tv_navi_home_address.text = getString(R.string.navi_set_home)
}
private fun clearCompany() {
tv_navi_clear_company_address.visibility = View.GONE
tv_navi_company_address.text = getString(R.string.navi_set_company)
}
private fun updateCompany() {
if (AddressManager.hasCompany()) {
tv_navi_company_address.text = AddressManager.companyAddress?.address
tv_navi_clear_company_address.visibility = View.VISIBLE
} else {
tv_navi_clear_company_address.visibility = View.GONE
}
}
/**
* 分享弹框
* @param event
*/
@Subscribe(threadMode = ThreadMode.MAIN)
fun onEventBus(searchPoi: SearchPoi?) {
if (searchPoi == null) {
return
}
if (searchPoi?.type == DataConstants.TYPE_COMPANY_ADDRESS) {
tv_navi_company_address.text = searchPoi.address
tv_navi_clear_company_address.visibility = View.VISIBLE
} else {
tv_navi_home_address.text = searchPoi.address
tv_navi_clear_home_address.visibility = View.VISIBLE
}
// audioManager.setStreamVolume(
// AudioManager.STREAM_MUSIC, progress, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE
// )
}
override fun onStartTrackingTouch(seekBar: SeekBar?) {
}
override fun onStopTrackingTouch(seekBar: SeekBar?) {
}
}
)
rg_navi_day_night.setOnCheckedChangeListener { group, checkedId ->
SettingManager.mapType = checkedId
when (checkedId) {
R.id.rb_navi_day -> {
SearchServiceHolder.getMapUIController()
.changeMapMode(EnumMapUI.Type_Light)
}
R.id.rb_navi_night -> {
SearchServiceHolder.getMapUIController()
.changeMapMode(EnumMapUI.Type_Night)
}
R.id.rb_navi_auto -> {
SearchServiceHolder.getMapUIController()
.changeMapMode(EnumMapUI.Type_AUTO_LIGHT_Night)
}
}
}
rg_navi_sound_type.setOnCheckedChangeListener { group, checkedId ->
SettingManager.voiceStyle = checkedId
SearchServiceHolder.getNavi()
.setBroadcastMode(
if (checkedId == R.id.rb_navi_detail) BroadcastMode.DETAIL else BroadcastMode.CONCISE
)
if (checkedId == R.id.rb_navi_detail) {
SearchServiceHolder.analyticsManager.track("Navigation_guide_type", mapOf("type" to 1))
} else {
SearchServiceHolder.analyticsManager.track("Navigation_guide_type", mapOf("type" to 2))
}
}
tv_navi_clear_home_address.setOnClickListener {
AddressManager.deleteHome(context!!)
clearHome()
}
tv_navi_clear_company_address.setOnClickListener {
AddressManager.deleteCompany(context!!)
clearCompany()
}
tv_navi_company_address.setOnClickListener {
if (!AddressManager.hasCompany()) {
AddressManager.goCompany()
}
}
tv_navi_home_address.setOnClickListener {
if (!AddressManager.hasHome()) {
AddressManager.goHome()
}
}
if (DebugConfig.isDebug()) {
sb_navi_fps_progress.setOnSeekBarChangeListener(object : OnSeekBarChangeListener{
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
if (progress == 0) {
tv_fps_value.text = "-1"
SearchServiceHolder.getMapUIController().setRenderFps(-1)
} else {
tv_fps_value.text = "${progress}"
SearchServiceHolder.getMapUIController().setRenderFps(progress)
}
}
override fun onStartTrackingTouch(seekBar: SeekBar?) {
}
override fun onStopTrackingTouch(seekBar: SeekBar?) {
}
})
cb_navi.setOnCheckedChangeListener { buttonView, isChecked ->
SettingManager.setMonitor(isChecked)
}
cb_navi.isChecked=SettingManager.isMonitor()
} else {
tv_navi_fps.visibility = View.GONE
ll_navi_fps.visibility = View.GONE
cb_navi.visibility = View.GONE
}
}
private fun updateHome() {
if (AddressManager.hasHome()) {
tv_navi_home_address.text = AddressManager.homeAddress?.address
tv_navi_clear_home_address.visibility = View.VISIBLE
} else {
tv_navi_clear_home_address.visibility = View.GONE
}
}
private fun clearHome() {
tv_navi_clear_home_address.visibility = View.GONE
tv_navi_home_address.text = getString(R.string.navi_set_home)
}
private fun clearCompany() {
tv_navi_clear_company_address.visibility = View.GONE
tv_navi_company_address.text = getString(R.string.navi_set_company)
}
private fun updateCompany() {
if (AddressManager.hasCompany()) {
tv_navi_company_address.text = AddressManager.companyAddress?.address
tv_navi_clear_company_address.visibility = View.VISIBLE
} else {
tv_navi_clear_company_address.visibility = View.GONE
}
}
/**
* 分享弹框
* @param event
*/
@Subscribe(threadMode = ThreadMode.MAIN)
fun onEventBus(searchPoi: SearchPoi?) {
if (searchPoi == null) {
return
}
if (searchPoi?.type == DataConstants.TYPE_COMPANY_ADDRESS) {
tv_navi_company_address.text = searchPoi.address
tv_navi_clear_company_address.visibility = View.VISIBLE
} else {
tv_navi_home_address.text = searchPoi.address
tv_navi_clear_home_address.visibility = View.VISIBLE
}
}
override fun onDestroyView() {
super.onDestroyView()
EventBus.getDefault()
.unregister(this)
}
override fun onDestroyView() {
super.onDestroyView()
EventBus.getDefault().unregister(this)
}
}

View File

@@ -406,12 +406,13 @@
</LinearLayout>
<TextView
android:id="@+id/tv_navi_fps"
android:id="@+id/tv_navi_simulator"
android:layout_width="wrap_content"
android:layout_height="@dimen/module_search_txt_setting_width"
android:layout_marginTop="@dimen/dp_40"
android:text="@string/set_fps"
android:text="调试模式"
android:textColor="@color/white_80"
android:textSize="@dimen/txt_normal"
app:layout_constraintTop_toBottomOf="@id/ll_navi_set_company"
@@ -419,77 +420,39 @@
/>
<LinearLayout
android:id="@+id/ll_navi_fps"
android:layout_width="match_parent"
android:orientation="horizontal"
android:id="@+id/ll_navi_simulator"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_marginTop="@dimen/dp_40"
app:layout_constraintTop_toBottomOf="@id/tv_navi_fps"
android:layout_height="@dimen/dp_120">
app:layout_constraintTop_toBottomOf="@id/tv_navi_simulator">
<TextView
android:id="@+id/tv_fps_value"
android:layout_width="wrap_content"
android:layout_height="@dimen/module_search_txt_setting_width"
android:text="20"
android:textColor="@color/white_80"
android:textSize="@dimen/txt_normal"
app:layout_constraintTop_toBottomOf="@id/ll_navi_set_company"
<ToggleButton
android:id="@+id/tb_navi"
android:textOn="模拟导航开"
android:textOff="模拟导航关"
android:checked="false"
app:layout_constraintLeft_toLeftOf="parent"
/>
<TextView
android:id="@+id/tv_fps_reduce"
android:layout_width="wrap_content"
android:layout_height="@dimen/module_search_txt_setting_width"
android:text="-"
android:layout_marginLeft="30px"
android:textColor="@color/white_80"
android:textSize="@dimen/txt_normal"
app:layout_constraintTop_toBottomOf="@id/ll_navi_set_company"
app:layout_constraintLeft_toLeftOf="parent"
/>
<SeekBar
android:id="@+id/sb_navi_fps_progress"
android:layout_width="300px"
android:layout_height="wrap_content"
android:splitTrack="false"
android:layout_marginLeft="@dimen/dp_40"
android:layout_marginRight="@dimen/dp_40"
android:maxHeight="@dimen/dp_11"
android:progressDrawable="@drawable/shape_seek_bar"
android:thumb="@mipmap/icon_pb_thumb"
android:progress="10"
app:layout_constraintLeft_toRightOf="@id/iv_navi_sound_low"
app:layout_constraintRight_toLeftOf="@id/iv_navi_sound_high"
app:layout_constraintTop_toTopOf="@id/iv_navi_sound_low"
app:layout_constraintBottom_toBottomOf="@id/iv_navi_sound_low"
/>
<TextView
android:id="@+id/tv_fps_plus"
android:textSize="@dimen/module_search_txt_setting_width"
android:layout_width="wrap_content"
android:layout_height="@dimen/module_search_txt_setting_width"
android:text="+"
android:textColor="@color/white_80"
android:textSize="@dimen/txt_normal"
app:layout_constraintTop_toBottomOf="@id/ll_navi_set_company"
android:layout_height="wrap_content"/>
<ToggleButton
android:id="@+id/tb_gps"
android:layout_marginLeft="50dp"
android:checked="false"
android:textOn="模拟GPS开"
android:textOff="模拟GPS关"
app:layout_constraintLeft_toLeftOf="parent"
/>
android:textColor="@color/white_80"
android:textSize="@dimen/module_search_txt_setting_width"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<CheckBox
android:id="@+id/cb_navi"
android:text="模拟导航"
app:layout_constraintTop_toBottomOf="@+id/ll_navi_fps"
app:layout_constraintLeft_toLeftOf="parent"
android:textColor="@color/white"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>

View File

@@ -811,6 +811,12 @@ public class MogoServices implements IMogoMapListener,
if ( TextUtils.equals( "打开", operation ) ) {
switchCard2( ServiceConst.CARD_TYPE_CARS_CHATTING );
}
} else {
if ( TextUtils.equals( app, "探路" ) ) {
if ( TextUtils.equals( "打开", operation ) ) {
switchCard2( ServiceConst.CARD_TYPE_ROAD_CONDITION );
}
}
}
} catch ( JSONException e ) {
e.printStackTrace();

View File

@@ -21,3 +21,6 @@ include ':libraries:mogo-map-api'
include ':modules:mogo-module-apps'
include ':modules:mogo-module-extensions'
include ':foudations:mogo-connection'
include ':modules:mogo-module-gps-simulator'
include ':modules:mogo-module-gps-simulator-debug'
include ':modules:mogo-module-gps-simulator-noop'