Merge branch 'dev' into qa_light
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package com.mogo.launcher;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
@@ -9,7 +8,6 @@ import android.util.Log;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.auto.zhidao.logsdk.CrashSystem;
|
||||
import com.bytedance.boost_multidex.BoostMultiDex;
|
||||
import com.elegant.utils.WindowUtil;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.network.Utils;
|
||||
@@ -18,7 +16,6 @@ import com.mogo.module.back.BackToLauncherConst;
|
||||
import com.mogo.module.carchatting.card.CallChatConstant;
|
||||
import com.mogo.module.common.MogoModule;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.module.guide.GuideConstant;
|
||||
import com.mogo.module.main.service.MogoMainService;
|
||||
import com.mogo.module.media.MediaConstants;
|
||||
import com.mogo.module.push.base.PushUIConstants;
|
||||
@@ -67,7 +64,7 @@ public class MogoApplication extends AbsMogoApplication {
|
||||
Logger.init( BuildConfig.DEBUG ? LogLevel.DEBUG : LogLevel.OFF );
|
||||
|
||||
if ( DebugConfig.isLoadGuideModule() ) {
|
||||
MogoModulePaths.addModule(new MogoModule(PATH_GUIDE_FRAGMENT, PATH_GUIDE_MODULE_NAME));
|
||||
MogoModulePaths.addModule( new MogoModule( PATH_GUIDE_FRAGMENT, PATH_GUIDE_MODULE_NAME ) );
|
||||
}
|
||||
MogoModulePaths.addModule( new MogoModule( MogoServicePaths.PATH_AGREEMENT, AuthorizeConstant.PATH_AGREEMENT_MODULE_NAME ) );
|
||||
|
||||
@@ -140,14 +137,16 @@ public class MogoApplication extends AbsMogoApplication {
|
||||
@Override
|
||||
protected void init() {
|
||||
super.init();
|
||||
prepareBaseService( 2_000L );
|
||||
final IMogoServiceApis apis = ARouter.getInstance().navigation( IMogoServiceApis.class );
|
||||
prepareBaseService( apis, 2_000L );
|
||||
// installSkinManager( this, apis );
|
||||
}
|
||||
|
||||
/**
|
||||
* 基础服务:passport、location、socket
|
||||
*/
|
||||
private void prepareBaseService( long delay ) {
|
||||
final IMogoServiceApis apis = ARouter.getInstance().navigation( IMogoServiceApis.class );
|
||||
private void prepareBaseService( IMogoServiceApis apis, long delay ) {
|
||||
|
||||
UiThreadHandler.postDelayed( () -> {
|
||||
// 第三方平台的sn是服务端生成的,所以必须在返回后才能开启
|
||||
if ( TextUtils.isEmpty( Utils.getSn() ) ) {
|
||||
@@ -159,7 +158,6 @@ public class MogoApplication extends AbsMogoApplication {
|
||||
prepareSocketAndLocationServices( apis );
|
||||
}
|
||||
}, delay );
|
||||
installSkinManager( this, apis );
|
||||
}
|
||||
|
||||
private void preparePassportEnvironment( IMogoServiceApis apis, Runnable after ) {
|
||||
@@ -191,10 +189,6 @@ public class MogoApplication extends AbsMogoApplication {
|
||||
} );
|
||||
}
|
||||
|
||||
private void installSkinManager( Application application, IMogoServiceApis apis ) {
|
||||
apis.getSkinSupportInstallerApi().install( application );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext( Context base ) {
|
||||
super.attachBaseContext( base );
|
||||
|
||||
@@ -29,6 +29,7 @@ public abstract class MvpActivity< V extends IView, P extends Presenter< V > >
|
||||
@Override
|
||||
protected void onCreate( @Nullable Bundle savedInstanceState ) {
|
||||
super.onCreate( savedInstanceState );
|
||||
beforeSetContentView(savedInstanceState);
|
||||
if ( DebugConfig.getCarMachineType() == DebugConfig.CAR_MACHINE_TYPE_BYD ) {
|
||||
requestWindowFeature( Window.FEATURE_NO_TITLE );
|
||||
getWindow().setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN );
|
||||
@@ -39,6 +40,10 @@ public abstract class MvpActivity< V extends IView, P extends Presenter< V > >
|
||||
getLifecycle().addObserver( mPresenter );
|
||||
}
|
||||
|
||||
protected void beforeSetContentView(Bundle savedInstanceState){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 布局资源
|
||||
*
|
||||
|
||||
@@ -2,12 +2,10 @@ package com.mogo.map.impl.amap;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.amap.api.maps.MapView;
|
||||
import com.amap.api.navi.AMapNaviView;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.map.IMogoMapView;
|
||||
import com.mogo.map.MogoBaseMapView;
|
||||
|
||||
@@ -19,6 +17,8 @@ import com.mogo.map.MogoBaseMapView;
|
||||
*/
|
||||
public class AMapBaseMapView extends MogoBaseMapView {
|
||||
|
||||
private static final String TAG = "AMapBaseMapView";
|
||||
|
||||
public AMapBaseMapView( Context context ) {
|
||||
super( context );
|
||||
}
|
||||
@@ -33,9 +33,11 @@ public class AMapBaseMapView extends MogoBaseMapView {
|
||||
|
||||
@Override
|
||||
protected IMogoMapView createMapView( Context context ) {
|
||||
if ( DebugConfig.getCarMachineType() != DebugConfig.CAR_MACHINE_TYPE_BYD ) {
|
||||
return new AMapViewWrapper( new MapView( context ) );
|
||||
IMogoMapView mapView = AMapViewHandler.getMapView();
|
||||
if ( mapView.getMapView().getParent() != null ) {
|
||||
ViewGroup group = ( ViewGroup ) mapView.getMapView().getParent();
|
||||
group.removeView( mapView.getMapView() );
|
||||
}
|
||||
return new AMapNaviViewWrapper( new AMapNaviView( context ) );
|
||||
return AMapViewHandler.getMapView();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.mogo.map.impl.amap;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.amap.api.maps.MapView;
|
||||
import com.amap.api.navi.AMapNaviView;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.map.IMogoMapView;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/9/10
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
class AMapViewHandler {
|
||||
|
||||
private static IMogoMapView sMapView;
|
||||
|
||||
public static void createMapView( Context context ) {
|
||||
if ( DebugConfig.getCarMachineType() == DebugConfig.CAR_MACHINE_TYPE_SELF_INNOVATE ) {
|
||||
sMapView = new AMapViewWrapper( new MapView( context ) );
|
||||
} else {
|
||||
sMapView = new AMapNaviViewWrapper( new AMapNaviView( context ) );
|
||||
}
|
||||
}
|
||||
|
||||
public static IMogoMapView getMapView() {
|
||||
return sMapView;
|
||||
}
|
||||
|
||||
public static void destroy() {
|
||||
sMapView = null;
|
||||
}
|
||||
}
|
||||
@@ -17,8 +17,10 @@ import com.amap.api.maps.AMap;
|
||||
import com.amap.api.maps.AMapUtils;
|
||||
import com.amap.api.maps.CameraUpdateFactory;
|
||||
import com.amap.api.maps.MapView;
|
||||
import com.amap.api.maps.TextureMapView;
|
||||
import com.amap.api.maps.model.BitmapDescriptorFactory;
|
||||
import com.amap.api.maps.model.CameraPosition;
|
||||
import com.amap.api.maps.model.CameraPositionCreator;
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.amap.api.maps.model.LatLngBounds;
|
||||
import com.amap.api.maps.model.Marker;
|
||||
@@ -477,16 +479,41 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
Logger.d( TAG, Log.getStackTraceString( new Throwable() ) );
|
||||
}
|
||||
Logger.d( TAG, "锁车" );
|
||||
MyLocationStyle style = getMyLocationStyle();
|
||||
if ( style == null ) {
|
||||
style = new MyLocationStyle();
|
||||
Location target = NaviClient.getInstance( getContext() ).getCarLocation2();
|
||||
if ( target != null ) {
|
||||
mMapView.getMap().animateCamera( CameraUpdateFactory.newCameraPosition(
|
||||
new CameraPosition( new LatLng( target.getLatitude(), target.getLongitude() ),
|
||||
mDefaultZoomLevel,
|
||||
0,
|
||||
0
|
||||
)
|
||||
), new AMap.CancelableCallback() {
|
||||
@Override
|
||||
public void onFinish() {
|
||||
changeMyLocationStyle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
changeMyLocationStyle();
|
||||
}
|
||||
} );
|
||||
} else {
|
||||
changeMyLocationStyle();
|
||||
}
|
||||
style.myLocationType( MyLocationStyle.LOCATION_TYPE_FOLLOW );
|
||||
mMapView.getMap().setMyLocationStyle( style );
|
||||
mIsCarLocked = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void changeMyLocationStyle() {
|
||||
MyLocationStyle style = getMyLocationStyle();
|
||||
if ( style == null ) {
|
||||
style = new MyLocationStyle();
|
||||
}
|
||||
style.myLocationType( MyLocationStyle.LOCATION_TYPE_FOLLOW );
|
||||
mMapView.getMap().setMyLocationStyle( style );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loseLockMode() {
|
||||
if ( DebugConfig.isDebug() ) {
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.mogo.map;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/9/10
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
interface IMogoMapViewInstanceHandler extends IDestroyable {
|
||||
|
||||
void createMapViewInstance( Context context );
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.mogo.map;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.map.impl.amap.AMapViewHandler;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/9/10
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
class MogoMapViewInstanceHandler implements IMogoMapViewInstanceHandler {
|
||||
|
||||
private static volatile MogoMapViewInstanceHandler sInstance;
|
||||
|
||||
private MogoMapViewInstanceHandler(){}
|
||||
|
||||
public static MogoMapViewInstanceHandler getInstance(){
|
||||
if( sInstance == null ){
|
||||
synchronized( MogoMapViewInstanceHandler.class ) {
|
||||
if( sInstance == null ){
|
||||
sInstance = new MogoMapViewInstanceHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release(){
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMapViewInstance( Context context ) {
|
||||
AMapViewHandler.createMapView( context );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
AMapViewHandler.destroy();
|
||||
}
|
||||
}
|
||||
@@ -198,13 +198,6 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
}
|
||||
mStatusManager.setUserInteractionStatus(TAG, true, false);
|
||||
mMApUIController.recoverLockMode();
|
||||
UiThreadHandler.postDelayed(() -> {
|
||||
if (!mStatusManager.isV2XShow()) {
|
||||
mStatusManager.setUserInteractionStatus(TAG, true, false);
|
||||
mMApUIController.setLockZoom(16);
|
||||
mMApUIController.changeZoom(16.0f);
|
||||
}
|
||||
}, 1_000L);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -32,7 +32,10 @@ class GuideStageFiveFragment : MvpFragment<IView, Presenter<IView>> {
|
||||
super.onResume()
|
||||
containerFragment?.invisibleRight()
|
||||
speak(context!!, context!!.resources.getString(R.string.module_guide_voice_page_five), object : IMogoVoiceCmdCallBack {
|
||||
override fun onTTSEnd(ttsId: String?, tts: String?) {
|
||||
override fun onSpeakEnd(speakText: String?) {
|
||||
if(!isVisible){
|
||||
return
|
||||
}
|
||||
containerFragment?.closeGuideFragment()
|
||||
}
|
||||
})
|
||||
|
||||
@@ -30,9 +30,13 @@ class GuideStageFourFragment : MvpFragment<IView, Presenter<IView>> {
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
containerFragment?.visibleLeft()
|
||||
containerFragment?.visibleRight()
|
||||
speak(context!!, context!!.resources.getString(R.string.module_guide_voice_page_four), object : IMogoVoiceCmdCallBack {
|
||||
override fun onTTSEnd(ttsId: String?, tts: String?) {
|
||||
override fun onSpeakEnd(speakText: String?) {
|
||||
if(!isVisible){
|
||||
return
|
||||
}
|
||||
containerFragment?.moveToNext()
|
||||
}
|
||||
})
|
||||
|
||||
@@ -36,7 +36,10 @@ class GuideStageOneFragment : MvpFragment<IView, Presenter<IView>> {
|
||||
super.onResume()
|
||||
containerFragment?.invisibleLeft()
|
||||
speak(context!!, context!!.resources.getString(R.string.module_guide_voice_page_one), object : IMogoVoiceCmdCallBack {
|
||||
override fun onTTSEnd(ttsId: String?, tts: String?) {
|
||||
override fun onSpeakEnd(speakText: String?) {
|
||||
if(!isVisible){
|
||||
return
|
||||
}
|
||||
containerFragment?.moveToNext()
|
||||
}
|
||||
})
|
||||
|
||||
@@ -30,8 +30,13 @@ class GuideStageThreeFragment : MvpFragment<IView, Presenter<IView>> {
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
containerFragment?.visibleLeft()
|
||||
containerFragment?.visibleRight()
|
||||
speak(context!!, context!!.resources.getString(R.string.module_guide_voice_page_three), object : IMogoVoiceCmdCallBack {
|
||||
override fun onTTSEnd(ttsId: String?, tts: String?) {
|
||||
override fun onSpeakEnd(speakText: String?) {
|
||||
if(!isVisible){
|
||||
return
|
||||
}
|
||||
containerFragment?.moveToNext()
|
||||
}
|
||||
})
|
||||
|
||||
@@ -31,8 +31,12 @@ class GuideStageTwoFragment : MvpFragment<IView, Presenter<IView>> {
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
containerFragment?.visibleLeft()
|
||||
containerFragment?.visibleRight()
|
||||
speak(context!!, context!!.resources.getString(R.string.module_guide_voice_page_two), object : IMogoVoiceCmdCallBack {
|
||||
override fun onTTSEnd(ttsId: String?, tts: String?) {
|
||||
override fun onSpeakEnd(speakText: String?) {
|
||||
if(!isVisible){
|
||||
return
|
||||
}
|
||||
containerFragment?.moveToNext()
|
||||
}
|
||||
})
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/module_guide_page_right"
|
||||
android:layout_width="@dimen/dp_52"
|
||||
android:layout_height="@dimen/dp_87"
|
||||
android:layout_width="@dimen/dp_54"
|
||||
android:layout_height="@dimen/dp_90"
|
||||
android:layout_marginRight="@dimen/dp_92"
|
||||
android:visibility="gone"
|
||||
android:src="@mipmap/module_guide_right_page"
|
||||
@@ -17,8 +17,8 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/module_guide_page_left"
|
||||
android:layout_width="@dimen/dp_52"
|
||||
android:layout_height="@dimen/dp_87"
|
||||
android:layout_width="@dimen/dp_54"
|
||||
android:layout_height="@dimen/dp_90"
|
||||
android:layout_marginLeft="@dimen/dp_92"
|
||||
android:visibility="gone"
|
||||
android:src="@mipmap/module_guide_left_page"
|
||||
|
||||
@@ -52,6 +52,7 @@ dependencies {
|
||||
api rootProject.ext.dependencies.moduleservice
|
||||
api rootProject.ext.dependencies.moduleapps
|
||||
api rootProject.ext.dependencies.moduleextensions
|
||||
compileOnly rootProject.ext.dependencies.skinsupport
|
||||
} else {
|
||||
api project(":foudations:mogo-utils")
|
||||
api project(":foudations:mogo-commons")
|
||||
@@ -62,6 +63,7 @@ dependencies {
|
||||
api project(':services:mogo-service')
|
||||
api project(':modules:mogo-module-apps')
|
||||
api project(':modules:mogo-module-extensions')
|
||||
compileOnly project(':skin:mogo-skin-support')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -73,6 +73,23 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
return R.layout.module_main_activity_main;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void beforeSetContentView( Bundle savedInstanceState ) {
|
||||
init();
|
||||
installSkinManager( savedInstanceState );
|
||||
}
|
||||
|
||||
/**
|
||||
* 安装皮肤支持
|
||||
*
|
||||
* @param savedInstanceState
|
||||
*/
|
||||
private void installSkinManager( Bundle savedInstanceState ) {
|
||||
mServiceApis.getMapServiceApi().getMapViewInstanceHandler().createMapViewInstance( this );
|
||||
mServiceApis.getSkinSupportInstallerApi().install( getApplication() );
|
||||
mServiceApis.getSkinSupportInstallerApi().onCompensateActivityCreated( this, savedInstanceState );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initViews() {
|
||||
|
||||
@@ -113,7 +130,6 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
@Override
|
||||
protected void onCreate( @Nullable Bundle savedInstanceState ) {
|
||||
super.onCreate( savedInstanceState );
|
||||
init();
|
||||
mPresenter.postLoadModuleMsg();
|
||||
}
|
||||
|
||||
@@ -326,6 +342,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
mMogoMapService = null;
|
||||
mMogoMapUIController = null;
|
||||
mMogoFragmentManager = null;
|
||||
mServiceApis.getMapServiceApi().getMapViewInstanceHandler().destroy();
|
||||
AdasConfigApiController.getInstance().release();
|
||||
mServiceApis.getAdasControllerApi().release();
|
||||
Logger.d( TAG, "destroy." );
|
||||
|
||||
@@ -272,7 +272,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
/**
|
||||
* 当前限速
|
||||
*/
|
||||
private int mCurrentLimit = 0;
|
||||
private int mCurrentLimit = -1;
|
||||
|
||||
private boolean mIsMainPageFirstResume = true;
|
||||
|
||||
@@ -821,7 +821,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ( mCurrentLimit == traffic.getSpeedLimit() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.mogo.module.share.bean.StepAfterAuth;
|
||||
import com.mogo.module.share.constant.HttpConstant;
|
||||
import com.mogo.module.share.constant.ShareConstants;
|
||||
import com.mogo.module.share.dialog.GridFixableShareDialog;
|
||||
import com.mogo.module.share.dialog.LaucherShareDialog;
|
||||
import com.mogo.module.share.manager.ServiceApisManager;
|
||||
import com.mogo.module.share.manager.UploadHelper;
|
||||
import com.mogo.module.share.net.ShareApiService;
|
||||
@@ -93,7 +94,8 @@ import static com.mogo.service.tanlu.IMogoTanluProvider.TYPE_TRAFFIC_CHECK;
|
||||
* @since 2020-01-10
|
||||
*/
|
||||
@Route(path = MogoServicePaths.PATH_SHARE)
|
||||
public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMogoVoiceCmdCallBack, Handler.Callback {
|
||||
public class ShareControl implements IMogoShareManager, IMogoIntentListener,
|
||||
IMogoVoiceCmdCallBack, Handler.Callback {
|
||||
private static final String TAG = "ShareControl";
|
||||
|
||||
private Context mContext;
|
||||
@@ -116,7 +118,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo
|
||||
@Override
|
||||
public void dismissShareDialog() {
|
||||
if (mShareDialog != null) {
|
||||
Logger.d(TAG,"dismissShareDialog");
|
||||
Logger.d(TAG, "dismissShareDialog");
|
||||
mShareDialog.dismiss();
|
||||
}
|
||||
}
|
||||
@@ -128,8 +130,12 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo
|
||||
|
||||
private void realShowDialog() {
|
||||
if (mShareDialog == null) {
|
||||
Logger.d(TAG,"realShowDialog context : " + mContext);
|
||||
mShareDialog = new GridFixableShareDialog(mContext);
|
||||
Logger.d(TAG, "realShowDialog context : " + mContext);
|
||||
if(DebugConfig.isLauncher()){
|
||||
mShareDialog = new LaucherShareDialog(mContext);
|
||||
}else {
|
||||
mShareDialog = new GridFixableShareDialog(mContext);
|
||||
}
|
||||
mShareDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
@@ -140,11 +146,11 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo
|
||||
mShareDialog.show();
|
||||
}
|
||||
|
||||
private StepAfterAuth stepAfterAuth = new StepAfterAuth(-1, "",false);
|
||||
private StepAfterAuth stepAfterAuth = new StepAfterAuth(-1, "", false);
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
Logger.d(TAG,"start init====");
|
||||
Logger.d(TAG, "start init====");
|
||||
mContext = context;
|
||||
ServiceApisManager.INSTANCE.init(context);
|
||||
authorizeModuleManager =
|
||||
@@ -158,8 +164,10 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo
|
||||
break;
|
||||
case STEP_AFTER_AUTH_TYPE_UPLOAD:
|
||||
TanluUploadParams params =
|
||||
new TanluUploadParams(stepAfterAuth.getUploadType(), IMogoTanluProvider.UPLOAD_FROM_VOICE);
|
||||
UploadHelper.INSTANCE.upload(mContext, params,stepAfterAuth.getForcePlayVoice());
|
||||
new TanluUploadParams(stepAfterAuth.getUploadType(),
|
||||
IMogoTanluProvider.UPLOAD_FROM_VOICE);
|
||||
UploadHelper.INSTANCE.upload(mContext, params,
|
||||
stepAfterAuth.getForcePlayVoice());
|
||||
dismissShareDialog();
|
||||
break;
|
||||
case STEP_AFTER_AUTH_TYPE_SEEK_HELP:
|
||||
@@ -193,7 +201,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo
|
||||
AIAssist.getInstance(mContext).registerUnWakeupCommand(UNWAKE_UPLOAD_REAL_TIME_TRAFFIC,
|
||||
UPLOAD_REAL_TIME_TRAFFIC, ShareControl.this);
|
||||
|
||||
if(!DebugConfig.isLauncher()) {
|
||||
if (!DebugConfig.isLauncher()) {
|
||||
ServiceApisManager.serviceApis.getStatusManagerApi().registerStatusChangedListener(TAG, StatusDescriptor.MAIN_PAGE_RESUME, new IMogoStatusChangedListener() {
|
||||
@Override
|
||||
public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) {
|
||||
@@ -204,7 +212,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo
|
||||
});
|
||||
}
|
||||
|
||||
if(!DebugConfig.isLauncher()) {
|
||||
if (!DebugConfig.isLauncher()) {
|
||||
ServiceApisManager.serviceApis.getStatusManagerApi().registerStatusChangedListener(TAG, StatusDescriptor.ACC_STATUS, new IMogoStatusChangedListener() {
|
||||
@Override
|
||||
public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) {
|
||||
@@ -219,7 +227,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo
|
||||
queryShareConfigRetryTime = 0;
|
||||
queryShareButtonConfig();
|
||||
}
|
||||
Logger.d(TAG,"init over====");
|
||||
Logger.d(TAG, "init over====");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -231,42 +239,42 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo
|
||||
break;
|
||||
case UNWAKE_UPLOAD_ROAD_BLOCK:
|
||||
if (needAuth()) {
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_BLOCK,false);
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_BLOCK, false);
|
||||
} else {
|
||||
uploadFromVoice(TYPE_BLOCK);
|
||||
}
|
||||
break;
|
||||
case UNWAKE_UPLOAD_TRAFFIC_CHECK:
|
||||
if (needAuth()) {
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_TRAFFIC_CHECK,false);
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_TRAFFIC_CHECK, false);
|
||||
} else {
|
||||
uploadFromVoice(TYPE_TRAFFIC_CHECK);
|
||||
}
|
||||
break;
|
||||
case UNWAKE_UPLOAD_ROAD_CLOSURE:
|
||||
if (needAuth()) {
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_CLOSURE,false);
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_CLOSURE, false);
|
||||
} else {
|
||||
uploadFromVoice(TYPE_CLOSURE);
|
||||
}
|
||||
break;
|
||||
case UNWAKE_UPLOAD_ACCIDENT:
|
||||
if (needAuth()) {
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_ACCIDENT,false);
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_ACCIDENT, false);
|
||||
} else {
|
||||
uploadFromVoice(TYPE_ACCIDENT);
|
||||
}
|
||||
break;
|
||||
case UNWAKE_UPLOAD_REAL_TIME_TRAFFIC:
|
||||
if (needAuth()) {
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_REAL_TIME_TRAFFIC,false);
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_REAL_TIME_TRAFFIC, false);
|
||||
} else {
|
||||
uploadFromVoice(TYPE_REAL_TIME_TRAFFIC);
|
||||
}
|
||||
break;
|
||||
case UNWAKE_UPLOAD_SEEK_HELP:
|
||||
if (needAuth()) {
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_SEEK_HELP, TYPE_BLOCK,false);
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_SEEK_HELP, TYPE_BLOCK, false);
|
||||
} else {
|
||||
seekHelp();
|
||||
}
|
||||
@@ -274,28 +282,28 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo
|
||||
break;
|
||||
case UNWAKE_UPLOAD_STAGNANT_WATER:
|
||||
if (needAuth()) {
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_STAGNANT_WATER,false);
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_STAGNANT_WATER, false);
|
||||
} else {
|
||||
uploadFromVoice(TYPE_STAGNANT_WATER);
|
||||
}
|
||||
break;
|
||||
case UNWAKE_UPLOAD_ROAD_ICY:
|
||||
if (needAuth()) {
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_ROAD_ICY,false);
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_ROAD_ICY, false);
|
||||
} else {
|
||||
uploadFromVoice(TYPE_ROAD_ICY);
|
||||
}
|
||||
break;
|
||||
case UNWAKE_UPLOAD_DENSE_FOG:
|
||||
if (needAuth()) {
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_DENSE_FOG,false);
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_DENSE_FOG, false);
|
||||
} else {
|
||||
uploadFromVoice(TYPE_DENSE_FOG);
|
||||
}
|
||||
break;
|
||||
case UNWAKE_UPLOAD_ROAD_CONSTRUCTION:
|
||||
if (needAuth()) {
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_ROAD_CONSTRUCTION,false);
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_ROAD_CONSTRUCTION, false);
|
||||
} else {
|
||||
uploadFromVoice(TYPE_ROAD_CONSTRUCTION);
|
||||
}
|
||||
@@ -304,6 +312,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIntentReceived(String intentStr, Intent intent) {
|
||||
// 此处只接受处理语音相关广播
|
||||
@@ -312,7 +321,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo
|
||||
switch (intentStr) {
|
||||
case VOICE_CMD_PUB_TROUBLE_HELP:
|
||||
if (needAuth()) {
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_SEEK_HELP, TYPE_DENSE_FOG,false);
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_SEEK_HELP, TYPE_DENSE_FOG, false);
|
||||
} else {
|
||||
// 开启服务,准备上报求助
|
||||
seekHelp();
|
||||
@@ -326,7 +335,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo
|
||||
switch (ob) {
|
||||
case "积水":
|
||||
if (needAuth()) {
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_STAGNANT_WATER,false);
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_STAGNANT_WATER, false);
|
||||
} else {
|
||||
uploadFromVoice(TYPE_STAGNANT_WATER);
|
||||
dismissShareDialog();
|
||||
@@ -334,7 +343,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo
|
||||
break;
|
||||
case "积冰":
|
||||
if (needAuth()) {
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_ROAD_ICY,false);
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_ROAD_ICY, false);
|
||||
} else {
|
||||
uploadFromVoice(TYPE_ROAD_ICY);
|
||||
dismissShareDialog();
|
||||
@@ -342,7 +351,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo
|
||||
break;
|
||||
case "雾":
|
||||
if (needAuth()) {
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_DENSE_FOG,false);
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_DENSE_FOG, false);
|
||||
} else {
|
||||
uploadFromVoice(TYPE_DENSE_FOG);
|
||||
dismissShareDialog();
|
||||
@@ -350,7 +359,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo
|
||||
break;
|
||||
case "交通事故":
|
||||
if (needAuth()) {
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_ACCIDENT,false);
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_ACCIDENT, false);
|
||||
} else {
|
||||
uploadFromVoice(TYPE_ACCIDENT);
|
||||
dismissShareDialog();
|
||||
@@ -358,7 +367,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo
|
||||
break;
|
||||
case "施工":
|
||||
if (needAuth()) {
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_ROAD_CONSTRUCTION,false);
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_ROAD_CONSTRUCTION, false);
|
||||
} else {
|
||||
uploadFromVoice(TYPE_ROAD_CONSTRUCTION);
|
||||
dismissShareDialog();
|
||||
@@ -366,7 +375,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo
|
||||
break;
|
||||
case "封路":
|
||||
if (needAuth()) {
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_CLOSURE,false);
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_CLOSURE, false);
|
||||
} else {
|
||||
uploadFromVoice(TYPE_CLOSURE);
|
||||
dismissShareDialog();
|
||||
@@ -374,7 +383,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo
|
||||
break;
|
||||
case "交通检查":
|
||||
if (needAuth()) {
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_TRAFFIC_CHECK,false);
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_TRAFFIC_CHECK, false);
|
||||
} else {
|
||||
uploadFromVoice(TYPE_TRAFFIC_CHECK);
|
||||
dismissShareDialog();
|
||||
@@ -391,7 +400,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo
|
||||
switch (obCondition) {
|
||||
case "路况":
|
||||
if (needAuth()) {
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_REAL_TIME_TRAFFIC,false);
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_REAL_TIME_TRAFFIC, false);
|
||||
} else {
|
||||
Logger.d(TAG, "分享框准备触发上报实时路况");
|
||||
uploadFromVoice(TYPE_REAL_TIME_TRAFFIC);
|
||||
@@ -400,7 +409,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo
|
||||
break;
|
||||
case "拥堵":
|
||||
if (needAuth()) {
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_BLOCK,false);
|
||||
goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_BLOCK, false);
|
||||
} else {
|
||||
Logger.d(TAG, "分享框准备触发上报拥堵");
|
||||
uploadFromVoice(TYPE_BLOCK);
|
||||
@@ -432,7 +441,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo
|
||||
private void uploadFromVoice(String eventType) {
|
||||
TanluUploadParams params = new TanluUploadParams(eventType,
|
||||
IMogoTanluProvider.UPLOAD_FROM_VOICE);
|
||||
UploadHelper.INSTANCE.upload(mContext, params,false);
|
||||
UploadHelper.INSTANCE.upload(mContext, params, false);
|
||||
}
|
||||
|
||||
private void seekHelp() {
|
||||
@@ -446,19 +455,21 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo
|
||||
return authorizeModuleManager.needAuthorize(AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE);
|
||||
}
|
||||
|
||||
private void goAuth(int type, String uploadType,boolean forcePlayVoice) {
|
||||
private void goAuth(int type, String uploadType, boolean forcePlayVoice) {
|
||||
stepAfterAuth.setType(type);
|
||||
stepAfterAuth.setUploadType(uploadType);
|
||||
stepAfterAuth.setForcePlayVoice(forcePlayVoice);
|
||||
authorizeModuleManager.invokeAuthorization(AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE);
|
||||
}
|
||||
|
||||
private void queryShareButtonConfig(){
|
||||
private void queryShareButtonConfig() {
|
||||
if (NetworkUtils.isConnected(mContext)) {
|
||||
// 有网,直接请求
|
||||
MogoLocation location = ServiceApisManager.serviceApis.getMapServiceApi().getSingletonLocationClient(mContext).getLastKnowLocation();
|
||||
MogoLocation location =
|
||||
ServiceApisManager.serviceApis.getMapServiceApi().getSingletonLocationClient(mContext).getLastKnowLocation();
|
||||
Map<String, String> params = new ArrayMap<>();
|
||||
ShareConfigRequest request = new ShareConfigRequest(Utils.getSn(), location.getAdCode());
|
||||
ShareConfigRequest request = new ShareConfigRequest(Utils.getSn(),
|
||||
location.getAdCode());
|
||||
params.put("data", request.toJson());
|
||||
ServiceApisManager.serviceApis.getNetworkApi().create(ShareApiService.class,
|
||||
HttpConstant.Companion.getNetHost()).queryShareButtonConfig(params).subscribeOn(Schedulers.io()).observeOn(Schedulers.io()).subscribe(new SubscribeImpl<ShareButtonConfigResponse>(RequestOptions.create(mContext)) {
|
||||
@@ -466,16 +477,16 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo
|
||||
public void onSuccess(ShareButtonConfigResponse o) {
|
||||
super.onSuccess(o);
|
||||
String config = "";
|
||||
if (o.getDetailMsg() != null) {
|
||||
List<FixableButton> btnList = o.getDetailMsg().getData();
|
||||
if(btnList != null&&!btnList.isEmpty()) {
|
||||
config = GsonUtil.jsonFromObject(o.getDetailMsg().getData());
|
||||
if (o.getResult() != null) {
|
||||
List<FixableButton> btnList = o.getResult().getData();
|
||||
if (btnList != null && !btnList.isEmpty()) {
|
||||
config = GsonUtil.jsonFromObject(btnList);
|
||||
Logger.d(TAG, "获取分享框成功:" + config);
|
||||
}else {
|
||||
} else {
|
||||
Logger.d(TAG, "获取分享框成功,但是data没有内容");
|
||||
}
|
||||
}else{
|
||||
Logger.d(TAG,"获取分享框成功,但是detailMsg没有内容");
|
||||
} else {
|
||||
Logger.d(TAG, "获取分享框成功,但是detailMsg没有内容");
|
||||
}
|
||||
Logger.d(TAG, "获取分享框配置成功: " + config);
|
||||
SharedPrefsMgr.getInstance(mContext).putString(KEY_SHARE_CONFIG, config);
|
||||
@@ -495,7 +506,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo
|
||||
retryQueryShareConfig();
|
||||
}
|
||||
});
|
||||
}else{
|
||||
} else {
|
||||
// 重试
|
||||
retryQueryShareConfig();
|
||||
}
|
||||
@@ -505,13 +516,15 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo
|
||||
private static final int MSG_QUERY_SHARE_CONFIG_RETRY = 1001;
|
||||
private int queryShareConfigRetryTime = 0;
|
||||
private static final int QUERY_SHARE_CONFIG_RETRY_TIME_THRESHOLD = 10;
|
||||
private void retryQueryShareConfig(){
|
||||
if(queryShareConfigRetryTime > QUERY_SHARE_CONFIG_RETRY_TIME_THRESHOLD){
|
||||
|
||||
private void retryQueryShareConfig() {
|
||||
if (queryShareConfigRetryTime > QUERY_SHARE_CONFIG_RETRY_TIME_THRESHOLD) {
|
||||
// 重试次数超过QUERY_SHARE_CONFIG_RETRY_TIME_THRESHOLD,不再重试
|
||||
return;
|
||||
}
|
||||
handler.sendEmptyMessageDelayed(MSG_QUERY_SHARE_CONFIG_RETRY, 3000);
|
||||
}
|
||||
|
||||
private Handler handler = new Handler(this);
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,15 +2,32 @@ package com.mogo.module.share.bean
|
||||
|
||||
import com.mogo.commons.data.BaseData
|
||||
import com.mogo.module.share.R
|
||||
import com.mogo.service.tanlu.IMogoTanluProvider
|
||||
import com.mogo.service.tanlu.IMogoTanluProvider.*
|
||||
|
||||
/**
|
||||
* 可配置按钮封装
|
||||
* @author tongchenfei
|
||||
*/
|
||||
data class FixableButton(val id:Int = 0,val poiType:String = "10007",val iconUrl:String = "", val iconRes:Int = R.drawable.share_block_up, val title:String="拥堵")
|
||||
|
||||
class ShareButtonConfigResponse:BaseData(){
|
||||
var detailMsg: ShareButtonConfigDetailMsg? = null
|
||||
class FixableButton(val id: Int = 0, val poiType: String = "10007", val iconUrl: String = "", val title: String = "拥堵") {
|
||||
val iconRes: Int
|
||||
get() = when (poiType) {
|
||||
TYPE_SEEK_HELP -> R.drawable.share_seek_help
|
||||
TYPE_DENSE_FOG -> R.drawable.share_dense_fog
|
||||
TYPE_ROAD_ICY -> R.drawable.share_road_icy
|
||||
TYPE_STAGNANT_WATER -> R.drawable.share_stagnant_water
|
||||
TYPE_REAL_TIME_TRAFFIC -> R.drawable.share_real_time_traffic
|
||||
TYPE_ROAD_CONSTRUCTION -> R.drawable.share_road_construction
|
||||
TYPE_ACCIDENT -> R.drawable.share_accident
|
||||
TYPE_CLOSURE -> R.drawable.share_road_closure
|
||||
TYPE_TRAFFIC_CHECK -> R.drawable.share_traffic_check
|
||||
TYPE_BLOCK -> R.drawable.share_block_up
|
||||
else -> R.drawable.share_block_up
|
||||
}
|
||||
}
|
||||
|
||||
data class ShareButtonConfigDetailMsg(var data:List<FixableButton>)
|
||||
class ShareButtonConfigResponse : BaseData() {
|
||||
var result: ShareButtonConfigDetailMsg? = null
|
||||
}
|
||||
|
||||
data class ShareButtonConfigDetailMsg(var data: List<FixableButton>)
|
||||
@@ -35,14 +35,6 @@ class GridFixableShareDialog(context: Context) : BaseFloatDialog(context) {
|
||||
|
||||
private fun setWrapContent() {
|
||||
val window = window
|
||||
// if (DebugConfig.getCarMachineType() != DebugConfig.CAR_MACHINE_TYPE_BYD) {
|
||||
// if (window != null) {
|
||||
// val lp = window.attributes
|
||||
// lp.width = 1024
|
||||
// lp.height = 600
|
||||
// window.attributes = lp
|
||||
// }
|
||||
// } else
|
||||
if (CarSeries.getSeries() == CarSeries.CAR_SERIES_F80X) {
|
||||
if (window != null) {
|
||||
val lp = window.attributes
|
||||
@@ -65,7 +57,7 @@ class GridFixableShareDialog(context: Context) : BaseFloatDialog(context) {
|
||||
Logger.d(TAG, "test-------3")
|
||||
setContentView(R.layout.dialog_share_with_gridlayout)
|
||||
setWrapContent()
|
||||
gridBtnManager = GridBtnManager(context, findViewById(R.id.moduleShareBtnGridLayout))
|
||||
gridBtnManager = GridBtnManager(context, findViewById(R.id.moduleShareBtnGridLayout),findViewById(R.id.ivTmpShow))
|
||||
gridBtnManager.setShareClickListener {
|
||||
Logger.d(TAG, "share btn click: $it")
|
||||
if (it.poiType == IMogoTanluProvider.TYPE_SEEK_HELP) {
|
||||
|
||||
@@ -18,10 +18,11 @@ import com.mogo.utils.storage.SharedPrefsMgr
|
||||
/**
|
||||
* 用来管理生成对应的分享按钮
|
||||
*/
|
||||
class GridBtnManager(val context: Context,private val container: GridLayout) {
|
||||
companion object{
|
||||
class GridBtnManager(val context: Context, private val container: GridLayout, private val tmpImg: ImageView) {
|
||||
companion object {
|
||||
const val TAG = "GridBtnManager"
|
||||
}
|
||||
|
||||
private val inflater = LayoutInflater.from(context)
|
||||
|
||||
fun resetContainer() {
|
||||
@@ -34,9 +35,9 @@ class GridBtnManager(val context: Context,private val container: GridLayout) {
|
||||
val content = view.findViewById<TextView>(R.id.tvShareContent)
|
||||
// 优先加载url图片,然后加载资源图片
|
||||
if (button.iconUrl.isNotEmpty()) {
|
||||
GlideApp.with(context).load(button.iconUrl).centerInside().into(img)
|
||||
GlideApp.with(context).load(button.iconUrl).placeholder(button.iconRes).error(button.iconRes).into(img)
|
||||
} else {
|
||||
GlideApp.with(context).load(button.iconRes).centerInside().into(img)
|
||||
GlideApp.with(context).load(button.iconRes).placeholder(button.iconRes).error(button.iconRes).into(img)
|
||||
}
|
||||
content.text = button.title
|
||||
view.setOnClickListener {
|
||||
@@ -50,21 +51,21 @@ class GridBtnManager(val context: Context,private val container: GridLayout) {
|
||||
resetContainer()
|
||||
val config = SharedPrefsMgr.getInstance(context).getString(ShareConstants.KEY_SHARE_CONFIG)
|
||||
Logger.d(TAG, "showDefaultBtns: $config")
|
||||
if(config.isEmpty()) {
|
||||
if (config.isEmpty()) {
|
||||
// 默认的全部十个按钮
|
||||
generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_BLOCK, iconRes = R.drawable.share_block_up, title = "拥堵"))
|
||||
generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_TRAFFIC_CHECK, iconRes = R.drawable.share_traffic_check, title = "交通检查"))
|
||||
generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_CLOSURE, iconRes = R.drawable.share_road_closure, title = "封路"))
|
||||
generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_ACCIDENT, iconRes = R.drawable.share_accident, title = "事故"))
|
||||
generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_ROAD_CONSTRUCTION, iconRes = R.drawable.share_road_construction, title = "道路施工"))
|
||||
generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_REAL_TIME_TRAFFIC, iconRes = R.drawable.share_real_time_traffic, title = "实时路况"))
|
||||
generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_SEEK_HELP, iconRes = R.drawable.share_seek_help, title = "故障求助"))
|
||||
generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_STAGNANT_WATER, iconRes = R.drawable.share_stagnant_water, title = "道路积水"))
|
||||
generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_ROAD_ICY, iconRes = R.drawable.share_road_icy, title = "道路结冰"))
|
||||
generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_DENSE_FOG, iconRes = R.drawable.share_dense_fog, title = "浓雾"))
|
||||
}else{
|
||||
generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_BLOCK, title = "拥堵"))
|
||||
generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_TRAFFIC_CHECK, title = "交通检查"))
|
||||
generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_CLOSURE, title = "封路"))
|
||||
generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_ACCIDENT, title = "事故"))
|
||||
generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_ROAD_CONSTRUCTION, title = "道路施工"))
|
||||
generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_REAL_TIME_TRAFFIC, title = "实时路况"))
|
||||
generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_SEEK_HELP, title = "故障求助"))
|
||||
generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_STAGNANT_WATER, title = "道路积水"))
|
||||
generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_ROAD_ICY, title = "道路结冰"))
|
||||
generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_DENSE_FOG, title = "浓雾"))
|
||||
} else {
|
||||
val btnList = GsonUtil.arrayFromJson(config, FixableButton::class.java)
|
||||
btnList.forEach {btn->
|
||||
btnList.forEach { btn ->
|
||||
generateShareButton(btn)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,6 @@ interface ShareApiService {
|
||||
* 获取分享框服务端配置
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("/yycp-geoIndex-preSearch-service/car/search/no/searchNearbyInformation/v1")
|
||||
@POST("/deva/car/poiType/no/poiTypeList")
|
||||
fun queryShareButtonConfig(@FieldMap param: Map<String, String>):Observable<ShareButtonConfigResponse>
|
||||
}
|
||||
@@ -39,4 +39,9 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/ivTmpShow" />
|
||||
|
||||
</FrameLayout>
|
||||
@@ -3,6 +3,7 @@ package com.mogo.service.map;
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.mogo.map.IMogoMapViewInstanceHandler;
|
||||
import com.mogo.map.listener.IMogoHosListenerRegister;
|
||||
import com.mogo.map.location.IMogoLocationClient;
|
||||
import com.mogo.map.marker.IMogoMarkerManager;
|
||||
@@ -111,4 +112,11 @@ public interface IMogoMapService extends IProvider {
|
||||
* @return
|
||||
*/
|
||||
IMogoRoadSearch getRoadSearchApi();
|
||||
|
||||
/**
|
||||
* 地图实例
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
IMogoMapViewInstanceHandler getMapViewInstanceHandler();
|
||||
}
|
||||
|
||||
@@ -3,15 +3,17 @@ package com.mogo.service.impl.map;
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.map.MogoRoadSearch;
|
||||
import com.mogo.map.IMogoMapViewInstanceHandler;
|
||||
import com.mogo.map.MogoGeoSearch;
|
||||
import com.mogo.map.MogoInputtipsSearch;
|
||||
import com.mogo.map.MogoLocationClient;
|
||||
import com.mogo.map.MogoMapUIController;
|
||||
import com.mogo.map.MogoMapViewInstanceHandler;
|
||||
import com.mogo.map.MogoMarkerManager;
|
||||
import com.mogo.map.MogoNavi;
|
||||
import com.mogo.map.MogoOverlayManager;
|
||||
import com.mogo.map.MogoPoiSearch;
|
||||
import com.mogo.map.MogoRoadSearch;
|
||||
import com.mogo.map.listener.IMogoHosListenerRegister;
|
||||
import com.mogo.map.listener.MogoHosListenerRegister;
|
||||
import com.mogo.map.location.IMogoLocationClient;
|
||||
@@ -92,7 +94,13 @@ public class MogoMapService implements IMogoMapService {
|
||||
return new MogoRoadSearch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMapViewInstanceHandler getMapViewInstanceHandler() {
|
||||
return MogoMapViewInstanceHandler.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.mogo.skin.support.impl;
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.app.AppCompatCallback;
|
||||
@@ -15,6 +16,7 @@ import com.mogo.skin.support.SkinMode;
|
||||
import com.mogo.skin.support.SkinSupportInstallerConstants;
|
||||
|
||||
import skin.support.SkinCompatManager;
|
||||
import skin.support.app.SkinActivityLifecycle;
|
||||
import skin.support.app.SkinAppCompatViewInflater;
|
||||
import skin.support.app.SkinCardViewInflater;
|
||||
import skin.support.constraint.app.SkinConstraintViewInflater;
|
||||
@@ -60,10 +62,15 @@ class SkinSupportInstaller implements IMogoSkinSupportInstaller {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppCompatDelegate getSkinAppCompatDelegate( AppCompatActivity activity,AppCompatDelegate superDelegate, AppCompatCallback callback ) {
|
||||
public AppCompatDelegate getSkinAppCompatDelegate( AppCompatActivity activity, AppCompatDelegate superDelegate, AppCompatCallback callback ) {
|
||||
return SkinAppCompatDelegateImpl.get( activity, callback );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCompensateActivityCreated( Activity activity, Bundle savedInstanceState ) {
|
||||
SkinActivityLifecycle.init( activity.getApplication() ).onCompensateActivityCreated( activity, savedInstanceState );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.mogo.skin.support.noop;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.app.AppCompatCallback;
|
||||
@@ -40,6 +42,11 @@ class SkinSupportInstaller implements IMogoSkinSupportInstaller {
|
||||
return superDelegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCompensateActivityCreated( Activity activity, Bundle savedInstanceState ) {
|
||||
Logger.d( TAG, "noop - onCompensateActivityCreated" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.mogo.skin.support;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.app.AppCompatCallback;
|
||||
@@ -21,5 +23,7 @@ interface IMogoSkinSupportInstaller extends IProvider {
|
||||
|
||||
void loadSkin( SkinMode skinMode );
|
||||
|
||||
AppCompatDelegate getSkinAppCompatDelegate( AppCompatActivity activity,AppCompatDelegate superDelegate, AppCompatCallback callback );
|
||||
AppCompatDelegate getSkinAppCompatDelegate( AppCompatActivity activity, AppCompatDelegate superDelegate, AppCompatCallback callback );
|
||||
|
||||
void onCompensateActivityCreated( Activity activity, Bundle savedInstanceState );
|
||||
}
|
||||
|
||||
@@ -26,128 +26,135 @@ import static skin.support.widget.SkinCompatHelper.checkResourceId;
|
||||
public class SkinActivityLifecycle implements Application.ActivityLifecycleCallbacks {
|
||||
private static final String TAG = "SkinActivityLifecycle";
|
||||
private static volatile SkinActivityLifecycle sInstance = null;
|
||||
private WeakHashMap<Context, SkinCompatDelegate> mSkinDelegateMap;
|
||||
private WeakHashMap<Context, LazySkinObserver> mSkinObserverMap;
|
||||
private WeakHashMap< Context, SkinCompatDelegate > mSkinDelegateMap;
|
||||
private WeakHashMap< Context, LazySkinObserver > mSkinObserverMap;
|
||||
/**
|
||||
* 用于记录当前Activity,在换肤后,立即刷新当前Activity以及非Activity创建的View。
|
||||
*/
|
||||
private WeakReference<Activity> mCurActivityRef;
|
||||
private WeakReference< Activity > mCurActivityRef;
|
||||
|
||||
public static SkinActivityLifecycle init(Application application) {
|
||||
if (sInstance == null) {
|
||||
synchronized (SkinActivityLifecycle.class) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new SkinActivityLifecycle(application);
|
||||
public static SkinActivityLifecycle init( Application application ) {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( SkinActivityLifecycle.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new SkinActivityLifecycle( application );
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
private SkinActivityLifecycle(Application application) {
|
||||
application.registerActivityLifecycleCallbacks(this);
|
||||
installLayoutFactory(application);
|
||||
SkinCompatManager.getInstance().addObserver(getObserver(application));
|
||||
private SkinActivityLifecycle( Application application ) {
|
||||
application.registerActivityLifecycleCallbacks( this );
|
||||
installLayoutFactory( application );
|
||||
SkinCompatManager.getInstance().addObserver( getObserver( application ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
|
||||
if (isContextSkinEnable(activity)) {
|
||||
installLayoutFactory(activity);
|
||||
updateWindowBackground(activity);
|
||||
if (activity instanceof SkinCompatSupportable) {
|
||||
((SkinCompatSupportable) activity).applySkin();
|
||||
public void onActivityCreated( Activity activity, Bundle savedInstanceState ) {
|
||||
onCompensateActivityCreated( activity, savedInstanceState );
|
||||
}
|
||||
|
||||
/**
|
||||
* 补偿启动页的 create 回调
|
||||
*/
|
||||
public void onCompensateActivityCreated( Activity activity, Bundle savedInstanceState ) {
|
||||
if ( isContextSkinEnable( activity ) ) {
|
||||
installLayoutFactory( activity );
|
||||
updateWindowBackground( activity );
|
||||
if ( activity instanceof SkinCompatSupportable ) {
|
||||
( ( SkinCompatSupportable ) activity ).applySkin();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityStarted(Activity activity) {
|
||||
public void onActivityStarted( Activity activity ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResumed(Activity activity) {
|
||||
mCurActivityRef = new WeakReference<>(activity);
|
||||
if (isContextSkinEnable(activity)) {
|
||||
LazySkinObserver observer = getObserver(activity);
|
||||
SkinCompatManager.getInstance().addObserver(observer);
|
||||
public void onActivityResumed( Activity activity ) {
|
||||
mCurActivityRef = new WeakReference<>( activity );
|
||||
if ( isContextSkinEnable( activity ) ) {
|
||||
LazySkinObserver observer = getObserver( activity );
|
||||
SkinCompatManager.getInstance().addObserver( observer );
|
||||
observer.updateSkinIfNeeded();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityPaused(Activity activity) {
|
||||
public void onActivityPaused( Activity activity ) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityStopped(Activity activity) {
|
||||
public void onActivityStopped( Activity activity ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
|
||||
public void onActivitySaveInstanceState( Activity activity, Bundle outState ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityDestroyed(Activity activity) {
|
||||
if (isContextSkinEnable(activity)) {
|
||||
SkinCompatManager.getInstance().deleteObserver(getObserver(activity));
|
||||
mSkinObserverMap.remove(activity);
|
||||
mSkinDelegateMap.remove(activity);
|
||||
public void onActivityDestroyed( Activity activity ) {
|
||||
if ( isContextSkinEnable( activity ) ) {
|
||||
SkinCompatManager.getInstance().deleteObserver( getObserver( activity ) );
|
||||
mSkinObserverMap.remove( activity );
|
||||
mSkinDelegateMap.remove( activity );
|
||||
}
|
||||
}
|
||||
|
||||
private void installLayoutFactory(Context context) {
|
||||
private void installLayoutFactory( Context context ) {
|
||||
try {
|
||||
LayoutInflater layoutInflater = LayoutInflater.from(context);
|
||||
LayoutInflaterCompat.setFactory2(layoutInflater, getSkinDelegate(context));
|
||||
} catch (Throwable e) {
|
||||
Slog.i("SkinActivity", "A factory has already been set on this LayoutInflater");
|
||||
LayoutInflater layoutInflater = LayoutInflater.from( context );
|
||||
LayoutInflaterCompat.setFactory2( layoutInflater, getSkinDelegate( context ) );
|
||||
} catch ( Throwable e ) {
|
||||
Slog.i( "SkinActivity", "A factory has already been set on this LayoutInflater" );
|
||||
}
|
||||
}
|
||||
|
||||
private SkinCompatDelegate getSkinDelegate(Context context) {
|
||||
if (mSkinDelegateMap == null) {
|
||||
private SkinCompatDelegate getSkinDelegate( Context context ) {
|
||||
if ( mSkinDelegateMap == null ) {
|
||||
mSkinDelegateMap = new WeakHashMap<>();
|
||||
}
|
||||
|
||||
SkinCompatDelegate mSkinDelegate = mSkinDelegateMap.get(context);
|
||||
if (mSkinDelegate == null) {
|
||||
mSkinDelegate = SkinCompatDelegate.create(context);
|
||||
mSkinDelegateMap.put(context, mSkinDelegate);
|
||||
SkinCompatDelegate mSkinDelegate = mSkinDelegateMap.get( context );
|
||||
if ( mSkinDelegate == null ) {
|
||||
mSkinDelegate = SkinCompatDelegate.create( context );
|
||||
mSkinDelegateMap.put( context, mSkinDelegate );
|
||||
}
|
||||
return mSkinDelegate;
|
||||
}
|
||||
|
||||
private LazySkinObserver getObserver(final Context context) {
|
||||
if (mSkinObserverMap == null) {
|
||||
private LazySkinObserver getObserver( final Context context ) {
|
||||
if ( mSkinObserverMap == null ) {
|
||||
mSkinObserverMap = new WeakHashMap<>();
|
||||
}
|
||||
LazySkinObserver observer = mSkinObserverMap.get(context);
|
||||
if (observer == null) {
|
||||
observer = new LazySkinObserver(context);
|
||||
mSkinObserverMap.put(context, observer);
|
||||
LazySkinObserver observer = mSkinObserverMap.get( context );
|
||||
if ( observer == null ) {
|
||||
observer = new LazySkinObserver( context );
|
||||
mSkinObserverMap.put( context, observer );
|
||||
}
|
||||
return observer;
|
||||
}
|
||||
|
||||
private void updateWindowBackground(Activity activity) {
|
||||
if (SkinCompatManager.getInstance().isSkinWindowBackgroundEnable()) {
|
||||
int windowBackgroundResId = SkinCompatThemeUtils.getWindowBackgroundResId(activity);
|
||||
if (checkResourceId(windowBackgroundResId) != INVALID_ID) {
|
||||
Drawable drawable = SkinCompatResources.getDrawable(activity, windowBackgroundResId);
|
||||
if (drawable != null) {
|
||||
activity.getWindow().setBackgroundDrawable(drawable);
|
||||
private void updateWindowBackground( Activity activity ) {
|
||||
if ( SkinCompatManager.getInstance().isSkinWindowBackgroundEnable() ) {
|
||||
int windowBackgroundResId = SkinCompatThemeUtils.getWindowBackgroundResId( activity );
|
||||
if ( checkResourceId( windowBackgroundResId ) != INVALID_ID ) {
|
||||
Drawable drawable = SkinCompatResources.getDrawable( activity, windowBackgroundResId );
|
||||
if ( drawable != null ) {
|
||||
activity.getWindow().setBackgroundDrawable( drawable );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isContextSkinEnable(Context context) {
|
||||
private boolean isContextSkinEnable( Context context ) {
|
||||
return SkinCompatManager.getInstance().isSkinAllActivityEnable()
|
||||
|| context.getClass().getAnnotation(Skinable.class) != null
|
||||
|| context.getClass().getAnnotation( Skinable.class ) != null
|
||||
|| context instanceof SkinCompatSupportable;
|
||||
}
|
||||
|
||||
@@ -155,16 +162,16 @@ public class SkinActivityLifecycle implements Application.ActivityLifecycleCallb
|
||||
private final Context mContext;
|
||||
private boolean mMarkNeedUpdate = false;
|
||||
|
||||
LazySkinObserver(Context context) {
|
||||
LazySkinObserver( Context context ) {
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSkin(SkinObservable observable, Object o) {
|
||||
public void updateSkin( SkinObservable observable, Object o ) {
|
||||
// 当前Activity,或者非Activity,立即刷新,否则延迟到下次onResume方法中刷新。
|
||||
if (mCurActivityRef == null
|
||||
if ( mCurActivityRef == null
|
||||
|| mContext == mCurActivityRef.get()
|
||||
|| !(mContext instanceof Activity)) {
|
||||
|| !( mContext instanceof Activity ) ) {
|
||||
updateSkinForce();
|
||||
} else {
|
||||
mMarkNeedUpdate = true;
|
||||
@@ -172,24 +179,24 @@ public class SkinActivityLifecycle implements Application.ActivityLifecycleCallb
|
||||
}
|
||||
|
||||
void updateSkinIfNeeded() {
|
||||
if (mMarkNeedUpdate) {
|
||||
if ( mMarkNeedUpdate ) {
|
||||
updateSkinForce();
|
||||
}
|
||||
}
|
||||
|
||||
void updateSkinForce() {
|
||||
if (Slog.DEBUG) {
|
||||
Slog.i(TAG, "Context: " + mContext + " updateSkinForce");
|
||||
if ( Slog.DEBUG ) {
|
||||
Slog.i( TAG, "Context: " + mContext + " updateSkinForce" );
|
||||
}
|
||||
if (mContext == null) {
|
||||
if ( mContext == null ) {
|
||||
return;
|
||||
}
|
||||
if (mContext instanceof Activity && isContextSkinEnable(mContext)) {
|
||||
updateWindowBackground((Activity) mContext);
|
||||
if ( mContext instanceof Activity && isContextSkinEnable( mContext ) ) {
|
||||
updateWindowBackground( ( Activity ) mContext );
|
||||
}
|
||||
getSkinDelegate(mContext).applySkin();
|
||||
if (mContext instanceof SkinCompatSupportable) {
|
||||
((SkinCompatSupportable) mContext).applySkin();
|
||||
getSkinDelegate( mContext ).applySkin();
|
||||
if ( mContext instanceof SkinCompatSupportable ) {
|
||||
( ( SkinCompatSupportable ) mContext ).applySkin();
|
||||
}
|
||||
mMarkNeedUpdate = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user