diff --git a/gradle.properties b/gradle.properties index dd1016d5be..65b4818a3b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -32,8 +32,8 @@ MOGO_UTILS_VERSION=1.0.3.3 MAP_AMAP_VERSION=1.0.3.4 MOGO_MAP_VERSION=1.0.3.4 MOGO_MAP_API_VERSION=1.0.3.4 -MOGO_SERVICE_VERSION=1.0.3.4 -MOGO_SERVICE_API_VERSION=1.0.3.4 +MOGO_SERVICE_VERSION=1.0.3.5 +MOGO_SERVICE_API_VERSION=1.0.3.5 MOGO_CONNECTION_VERSION=1.0.3.4 MOGO_MODULE_APPS_VERSION=1.0.3.4 MOGO_MODULE_NAVI_VERSION=1.0.3.4 @@ -42,7 +42,7 @@ MOGO_MODULE_COMMON_VERSION=1.0.3.4 MOGO_MODULE_MAIN_VERSION=1.0.3.4 MOGO_MODULE_MAP_VERSION=1.0.3.4 MOGO_MODULE_SERVICE_VERSION=1.0.3.4 -MOGO_MODULE_EXTENSIONS_VERSION=1.0.3.4 +MOGO_MODULE_EXTENSIONS_VERSION=1.0.3.5 MOGO_MODULE_SEARCH_VERSION=1.0.3.4 MOGO_MODULE_BACK_VERSION=1.0.3.4 MOGO_MODULE_GPS_SIMULATOR_VERSION=1.0.3.4 diff --git a/map-upload.sh b/map-upload.sh index a53d5d66df..eeb258a13e 100755 --- a/map-upload.sh +++ b/map-upload.sh @@ -1,5 +1,5 @@ #!/bin/bash -./gradlew :libraries:mogo-map-api:clean :libraries:mogo-map-api:uploadArchives -./gradlew :libraries:map-amap:clean :libraries:map-amap:uploadArchives -./gradlew :libraries:mogo-map:clean :libraries:mogo-map:uploadArchives \ No newline at end of file +./gradlew :services:mogo-service-api:clean :services:mogo-service-api:uploadArchives +./gradlew :services:mogo-service:clean :services:mogo-service:uploadArchives +./gradlew :modules:mogo-module-extensions:clean :modules:mogo-module-extensions:uploadArchives \ No newline at end of file diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java index 1ba191e0cf..ffe850df7a 100644 --- a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java +++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java @@ -39,6 +39,7 @@ import com.mogo.module.share.ShareControl; import com.mogo.service.IMogoServiceApis; import com.mogo.service.MogoServicePaths; import com.mogo.service.analytics.IMogoAnalytics; +import com.mogo.service.entrance.ButtonIndex; import com.mogo.service.fragmentmanager.IMogoFragmentManager; import com.mogo.service.intent.IMogoIntentListener; import com.mogo.service.map.IMogoMapService; @@ -221,6 +222,8 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent } } } ); + MogoEntranceButtons.save( ButtonIndex.BUTTON1, findViewById( R.id.module_entrance_id_button1 ) ); + MogoEntranceButtons.save( ButtonIndex.BUTTON2, findViewById( R.id.module_entrance_id_button2 ) ); } diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/MogoEntranceButtonControllerImpl.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/MogoEntranceButtonControllerImpl.java new file mode 100644 index 0000000000..2b4f032948 --- /dev/null +++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/MogoEntranceButtonControllerImpl.java @@ -0,0 +1,29 @@ +package com.mogo.module.extensions.entrance; + +import android.content.Context; +import android.widget.TextView; + +import com.alibaba.android.arouter.facade.annotation.Route; +import com.mogo.service.MogoServicePaths; +import com.mogo.service.entrance.ButtonIndex; +import com.mogo.service.entrance.IMogoEntranceButtonController; + +/** + * @author congtaowang + * @since 2020-04-16 + *

+ * 描述 + */ +@Route( path = MogoServicePaths.PATH_ENTRANCE_BUTTON_API ) +public class MogoEntranceButtonControllerImpl implements IMogoEntranceButtonController { + + @Override + public TextView getButton( ButtonIndex index ) { + return MogoEntranceButtons.getButton( index ); + } + + @Override + public void init( Context context ) { + + } +} diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/MogoEntranceButtons.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/MogoEntranceButtons.java new file mode 100644 index 0000000000..686d01e72e --- /dev/null +++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/MogoEntranceButtons.java @@ -0,0 +1,31 @@ +package com.mogo.module.extensions.entrance; + +import android.widget.TextView; + +import com.mogo.service.entrance.ButtonIndex; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author congtaowang + * @since 2020-04-16 + *

+ * 描述 + */ +public class MogoEntranceButtons { + + private static Map< ButtonIndex, TextView > sButtons = new HashMap<>(); + + public static void save( ButtonIndex index, TextView btn ) { + sButtons.put( index, btn ); + } + + public static TextView getButton( ButtonIndex index ) { + return sButtons.get( index ); + } + + public static void clear() { + sButtons.clear(); + } +} diff --git a/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_entrance.xml b/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_entrance.xml index 2fb0371afd..4dac1458fd 100644 --- a/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_entrance.xml +++ b/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_entrance.xml @@ -80,8 +80,8 @@ android:layout_marginRight="@dimen/module_ext_speed_limit_marginRight" android:background="@drawable/module_ext_dw_speed_limit_bkg" android:gravity="center" - android:visibility="invisible" android:orientation="vertical" + android:visibility="invisible" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent"> @@ -116,18 +116,18 @@ + app:layout_constraintTop_toBottomOf="@+id/module_entrance_id_navi_info_panel" /> - + app:layout_constraintLeft_toLeftOf="parent"> + + + + + + + \ No newline at end of file diff --git a/modules/mogo-module-extensions/src/main/res/values-ldpi/dimens.xml b/modules/mogo-module-extensions/src/main/res/values-ldpi/dimens.xml index 1436b11965..57dca9bae6 100644 --- a/modules/mogo-module-extensions/src/main/res/values-ldpi/dimens.xml +++ b/modules/mogo-module-extensions/src/main/res/values-ldpi/dimens.xml @@ -46,11 +46,14 @@ 20px - 130px - 58px + 64px + 64px 20px 32px + 20px + 30px 22px + 8px 64px diff --git a/modules/mogo-module-extensions/src/main/res/values-xhdpi/dimens.xml b/modules/mogo-module-extensions/src/main/res/values-xhdpi/dimens.xml index faf483cc84..c4c5d9e9a2 100644 --- a/modules/mogo-module-extensions/src/main/res/values-xhdpi/dimens.xml +++ b/modules/mogo-module-extensions/src/main/res/values-xhdpi/dimens.xml @@ -44,11 +44,14 @@ 32px 32px - 200px - 90px + 120px + 120px 32px 60px + 32px + 60px 32px + 20px 120px diff --git a/modules/mogo-module-extensions/src/main/res/values/dimens.xml b/modules/mogo-module-extensions/src/main/res/values/dimens.xml index 5e54d8ef68..027c19d25e 100644 --- a/modules/mogo-module-extensions/src/main/res/values/dimens.xml +++ b/modules/mogo-module-extensions/src/main/res/values/dimens.xml @@ -44,11 +44,14 @@ 32px 32px - 200px - 90px + 120px + 120px 32px 60px + 32px + 60px 32px + 20px 120px diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MarkerServiceHandler.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MarkerServiceHandler.java index 7d843891ca..089851d54e 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MarkerServiceHandler.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MarkerServiceHandler.java @@ -82,6 +82,10 @@ public class MarkerServiceHandler { mMapMarkerManager.init( context ); } + public static IMogoServiceApis getApis(){ + return mApis; + } + public static IMogoMapService getMapService() { return mMapService; } diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServices.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServices.java index a3ae5c5cc4..8b4bced18e 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServices.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServices.java @@ -8,7 +8,6 @@ import android.location.LocationManager; import android.os.Handler; import android.os.Looper; import android.os.Message; -import android.os.Trace; import android.text.TextUtils; import android.util.Log; import android.view.MotionEvent; @@ -30,7 +29,6 @@ import com.mogo.map.navi.IMogoNaviListener; import com.mogo.map.navi.MogoCongestionInfo; import com.mogo.map.navi.MogoNaviInfo; import com.mogo.map.navi.MogoTraffic; -import com.mogo.map.uicontroller.CarCursorOption; import com.mogo.map.uicontroller.EnumMapUI; import com.mogo.map.uicontroller.IMogoMapUIController; import com.mogo.module.common.MogoModule; @@ -38,6 +36,7 @@ import com.mogo.module.common.MogoModulePaths; import com.mogo.module.common.map.MapCenterPointStrategy; import com.mogo.module.common.map.Scene; import com.mogo.module.service.carinfo.CarStateInfo; +import com.mogo.module.service.intent.IntentHandlerFactory; import com.mogo.module.service.marker.MapMarkerManager; import com.mogo.module.service.network.RefreshCallback; import com.mogo.module.service.network.RefreshModel; @@ -60,14 +59,11 @@ import com.mogo.service.module.MogoAction; import com.mogo.service.statusmanager.IMogoStatusChangedListener; import com.mogo.service.statusmanager.IMogoStatusManager; import com.mogo.service.statusmanager.StatusDescriptor; -import com.mogo.utils.AppUtils; -import com.mogo.utils.TipToast; import com.mogo.utils.UiThreadHandler; import com.mogo.utils.WorkThreadHandler; import com.mogo.utils.logger.Logger; import com.mogo.utils.network.utils.GsonUtil; -import org.json.JSONException; import org.json.JSONObject; import java.util.List; @@ -796,24 +792,7 @@ public class MogoServices implements IMogoMapListener, mActionManager.invoke( MapMarkerManager.getInstance().getCurrentModuleName(), MogoAction.Prev ); } } else if ( ServiceConst.COMMAND_SWITCH_CARD.equals( command ) ) { - String data = intent.getStringExtra( "data" ); - try { - JSONObject jsonObject = new JSONObject( data ); - String card = jsonObject.getString( "card" ); - if ( TextUtils.equals( "多媒体卡片", card ) - || TextUtils.equals( "媒体中心卡片", card ) - || TextUtils.equals( "音乐卡片", card ) ) { - switchCard2( ServiceConst.CARD_TYPE_SHARE_MUSIC ); - } else if ( TextUtils.equals( "探路卡片", card ) ) { - switchCard2( ServiceConst.CARD_TYPE_ROAD_CONDITION ); - } else if ( TextUtils.equals( "在线车辆卡片", card ) ) { - switchCard2( ServiceConst.CARD_TYPE_USER_DATA ); - } else if ( TextUtils.equals( "新鲜事卡片", card ) ) { - switchCard2( ServiceConst.CARD_TYPE_NOVELTY ); - } - } catch ( JSONException e ) { - e.printStackTrace(); - } + IntentHandlerFactory.getInstance().handle( mContext, command, intent ); } else if ( MogoReceiver.ACTION_ADAS_STATUS.equals( command ) ) { String msg = intent.getStringExtra( "adasMsg" ); if ( TextUtils.isEmpty( msg ) ) { @@ -825,82 +804,14 @@ public class MogoServices implements IMogoMapListener, // changeMyLocation( stateInfo.getValues() ); } } else if ( ServiceConst.COMMAND_OPERATION.equals( command ) ) { - try { - JSONObject object = new JSONObject( intent.getStringExtra( "data" ) ); - String app = object.optString( "object" ); - String operation = object.optString( "operation" ); - if ( TextUtils.equals( app, "车聊聊" ) ) { - 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(); - } + IntentHandlerFactory.getInstance().handle( mContext, command, intent ); } else if ( MogoReceiver.ACTION_VOICE_READY.equals( command ) ) { AIAssist.getInstance( mContext ).flush(); mStatusManager.setAIAssistReady( TAG, true ); } else if ( ServiceConst.COMMAND_MY_LOCATION.equals( command ) ) { - if ( mStatusManager.isSearchUIShow() ) { - return; - } - if ( mStatusManager.isMainPageOnResume() ) { - mUiController.recoverLockMode(); - } else { - mLauncher.backToLauncher( mContext ); - UiThreadHandler.postDelayed( () -> { - mUiController.recoverLockMode(); - }, 2_000L ); - } + IntentHandlerFactory.getInstance().handle( mContext, command, intent ); } else if ( MogoReceiver.ACTION_MOCK.equals( command ) ) { - - if ( !DebugConfig.isDebug() ) { - return; - } - - final int oper = intent.getIntExtra( "oper", -1 ); - switch ( oper ) { - case 1: - mUiController.showMyLocation( true ); - break; - case 2: - boolean status = intent.getBooleanExtra( "status", false ); - mStatusManager.setSeekHelping( TAG, status ); - break; - case 3: - String msg = intent.getStringExtra( "msg" ); - if ( !TextUtils.isEmpty( msg ) ) { - TipToast.shortTip( msg ); - } - break; - } - } - } - - /** - * 切换卡片 - */ - private void switchCard2( String card ) { - if ( AppUtils.isApplicationBroughtToBackground( mContext ) ) { - mLauncher.backToLauncher( mContext ); - UiThreadHandler.postDelayed( () -> { - if ( mStatusManager.isADASShow() ) { - mADASController.closeADAS(); - } - mCardManager.switch2( card, true ); - }, 2000L ); - } else { - mFragmentManager.clearAll(); - if ( mStatusManager.isADASShow() ) { - mADASController.closeADAS(); - } - mCardManager.switch2( card, true ); + IntentHandlerFactory.getInstance().handle( mContext, command, intent ); } } diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/AppOperationIntentHandler.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/AppOperationIntentHandler.java new file mode 100644 index 0000000000..66ca68b304 --- /dev/null +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/AppOperationIntentHandler.java @@ -0,0 +1,41 @@ +package com.mogo.module.service.intent; + +import android.content.Context; +import android.content.Intent; +import android.text.TextUtils; + +import com.mogo.module.service.ServiceConst; + +import org.json.JSONException; +import org.json.JSONObject; + +/** + * @author congtaowang + * @since 2020-04-17 + *

+ * 描述 + */ +public class AppOperationIntentHandler implements IntentHandler { + + @Override + public void handle( Context context, Intent intent ) { + try { + JSONObject object = new JSONObject( intent.getStringExtra( "data" ) ); + String app = object.optString( "object" ); + String operation = object.optString( "operation" ); + if ( TextUtils.equals( app, "车聊聊" ) ) { + if ( TextUtils.equals( "打开", operation ) ) { + SwitchCardIntentHandler.switchCard2( context, ServiceConst.CARD_TYPE_CARS_CHATTING ); + } + } else { + if ( TextUtils.equals( app, "探路" ) ) { + if ( TextUtils.equals( "打开", operation ) ) { + SwitchCardIntentHandler.switchCard2( context, ServiceConst.CARD_TYPE_ROAD_CONDITION ); + } + } + } + } catch ( JSONException e ) { + e.printStackTrace(); + } + } +} diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/EmptyIntentHandler.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/EmptyIntentHandler.java new file mode 100644 index 0000000000..64d6edd24a --- /dev/null +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/EmptyIntentHandler.java @@ -0,0 +1,22 @@ +package com.mogo.module.service.intent; + +import android.content.Context; +import android.content.Intent; + +import com.mogo.utils.logger.Logger; + +/** + * @author congtaowang + * @since 2020-04-17 + *

+ * 描述 + */ +public class EmptyIntentHandler implements IntentHandler { + + private static final String TAG = "EmptyIntentHandler"; + + @Override + public void handle( Context context, Intent intent ) { + Logger.w( TAG, "空实现." ); + } +} diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/IntentHandler.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/IntentHandler.java new file mode 100644 index 0000000000..cf040875d5 --- /dev/null +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/IntentHandler.java @@ -0,0 +1,15 @@ +package com.mogo.module.service.intent; + +import android.content.Context; +import android.content.Intent; + +/** + * @author congtaowang + * @since 2020-04-17 + *

+ * 描述 + */ +public interface IntentHandler { + + void handle( Context context, Intent intent ); +} diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/IntentHandlerFactory.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/IntentHandlerFactory.java new file mode 100644 index 0000000000..fbba17c7b6 --- /dev/null +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/IntentHandlerFactory.java @@ -0,0 +1,59 @@ +package com.mogo.module.service.intent; + +import android.content.Context; +import android.content.Intent; + +import com.mogo.module.service.ServiceConst; +import com.mogo.module.service.receiver.MogoReceiver; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author congtaowang + * @since 2020-04-17 + *

+ * 描述 + */ +public class IntentHandlerFactory { + + private IntentHandlerFactory() { + // private constructor + mHandlers.put( MogoReceiver.ACTION_MOCK, new MockIntentHandler() ); + mHandlers.put( ServiceConst.COMMAND_SWITCH_CARD, new SwitchCardIntentHandler() ); + mHandlers.put( ServiceConst.COMMAND_OPERATION, new AppOperationIntentHandler() ); + mHandlers.put( ServiceConst.COMMAND_MY_LOCATION, new MyLocationHandler() ); + } + + private static final class InstanceHolder { + private static final IntentHandlerFactory INSTANCE = new IntentHandlerFactory(); + } + + public static IntentHandlerFactory getInstance() { + return InstanceHolder.INSTANCE; + } + + private Object readResolve() { + // 阻止反序列化,必须实现 Serializable 接口 + return InstanceHolder.INSTANCE; + } + + private Map< String, IntentHandler > mHandlers = new HashMap<>(); + + private IntentHandler DEFAULT = new EmptyIntentHandler(); + + private IntentHandler getIntentHandler( String intent ) { + if ( mHandlers.containsKey( intent ) && mHandlers.get( intent ) != null ) { + return mHandlers.get( intent ); + } + return DEFAULT; + } + + public void handle( Context context, String intent, Intent obj ) { + IntentHandler handler = getIntentHandler( intent ); + if ( handler != null ) { + handler.handle( context, obj ); + } + } + +} diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/MockIntentHandler.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/MockIntentHandler.java new file mode 100644 index 0000000000..cc1ccbd4fa --- /dev/null +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/MockIntentHandler.java @@ -0,0 +1,65 @@ +package com.mogo.module.service.intent; + +import android.content.Context; +import android.content.Intent; +import android.graphics.Color; +import android.text.TextUtils; +import android.view.View; +import android.widget.TextView; + +import com.mogo.commons.debug.DebugConfig; +import com.mogo.module.service.MarkerServiceHandler; +import com.mogo.service.entrance.ButtonIndex; +import com.mogo.utils.TipToast; + +/** + * @author congtaowang + * @since 2020-04-17 + *

+ * 描述 + */ +public class MockIntentHandler implements IntentHandler { + + private static final String TAG = "MockIntentHandler"; + + @Override + public void handle( Context context, Intent intent ) { + if ( !DebugConfig.isDebug() ) { + return; + } + + final int oper = intent.getIntExtra( "oper", -1 ); + switch ( oper ) { + case 1: + MarkerServiceHandler.getMapUIController().showMyLocation( true ); + break; + case 2: + boolean status = intent.getBooleanExtra( "status", false ); + MarkerServiceHandler.getMogoStatusManager().setSeekHelping( TAG, status ); + break; + case 3: + String msg = intent.getStringExtra( "msg" ); + if ( !TextUtils.isEmpty( msg ) ) { + TipToast.shortTip( msg ); + } + break; + case 4: + TextView button1 = MarkerServiceHandler.getApis().getEntranceButtonController().getButton( ButtonIndex.BUTTON1 ); + if ( button1 != null ) { + button1.setVisibility( View.VISIBLE ); + button1.setBackgroundColor( Color.RED ); + button1.setOnClickListener( view -> { + TipToast.shortTip( "测试" ); + } ); + } + break; + case 5: + TextView button2 = MarkerServiceHandler.getApis().getEntranceButtonController().getButton( ButtonIndex.BUTTON1 ); + if ( button2 != null ) { + button2.setOnClickListener( null ); + button2.setVisibility( View.GONE ); + } + break; + } + } +} diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/MyLocationHandler.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/MyLocationHandler.java new file mode 100644 index 0000000000..4504dd7e01 --- /dev/null +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/MyLocationHandler.java @@ -0,0 +1,31 @@ +package com.mogo.module.service.intent; + +import android.content.Context; +import android.content.Intent; + +import com.mogo.module.service.MarkerServiceHandler; +import com.mogo.utils.UiThreadHandler; + +/** + * @author congtaowang + * @since 2020-04-17 + *

+ * 语音指令:定位我的位置等处理 + */ +public class MyLocationHandler implements IntentHandler { + + @Override + public void handle( Context context, Intent intent ) { + if ( MarkerServiceHandler.getMogoStatusManager().isSearchUIShow() ) { + return; + } + if ( MarkerServiceHandler.getMogoStatusManager().isMainPageOnResume() ) { + MarkerServiceHandler.getMapUIController().recoverLockMode(); + } else { + MarkerServiceHandler.getLauncher().backToLauncher( context ); + UiThreadHandler.postDelayed( () -> { + MarkerServiceHandler.getMapUIController().recoverLockMode(); + }, 2_000L ); + } + } +} diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/SwitchCardIntentHandler.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/SwitchCardIntentHandler.java new file mode 100644 index 0000000000..1c3e56567a --- /dev/null +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/SwitchCardIntentHandler.java @@ -0,0 +1,65 @@ +package com.mogo.module.service.intent; + +import android.content.Context; +import android.content.Intent; +import android.text.TextUtils; + +import com.mogo.module.service.MarkerServiceHandler; +import com.mogo.module.service.ServiceConst; +import com.mogo.utils.AppUtils; +import com.mogo.utils.UiThreadHandler; + +import org.json.JSONException; +import org.json.JSONObject; + +/** + * @author congtaowang + * @since 2020-04-17 + *

+ * 描述 + */ +public class SwitchCardIntentHandler implements IntentHandler { + + @Override + public void handle( Context context, Intent intent ) { + String data = intent.getStringExtra( "data" ); + try { + JSONObject jsonObject = new JSONObject( data ); + String card = jsonObject.getString( "card" ); + if ( TextUtils.equals( "多媒体卡片", card ) + || TextUtils.equals( "媒体中心卡片", card ) + || TextUtils.equals( "音乐卡片", card ) ) { + switchCard2( context, ServiceConst.CARD_TYPE_SHARE_MUSIC ); + } else if ( TextUtils.equals( "探路卡片", card ) ) { + switchCard2( context, ServiceConst.CARD_TYPE_ROAD_CONDITION ); + } else if ( TextUtils.equals( "在线车辆卡片", card ) ) { + switchCard2( context, ServiceConst.CARD_TYPE_USER_DATA ); + } else if ( TextUtils.equals( "新鲜事卡片", card ) ) { + switchCard2( context, ServiceConst.CARD_TYPE_NOVELTY ); + } + } catch ( JSONException e ) { + e.printStackTrace(); + } + } + + /** + * 切换卡片 + */ + public static void switchCard2( Context context, String card ) { + if ( AppUtils.isApplicationBroughtToBackground( context ) ) { + MarkerServiceHandler.getLauncher().backToLauncher( context ); + UiThreadHandler.postDelayed( () -> { + if ( MarkerServiceHandler.getMogoStatusManager().isADASShow() ) { + MarkerServiceHandler.getADASController().closeADAS(); + } + MarkerServiceHandler.getMogoCardManager().switch2( card, true ); + }, 2000L ); + } else { + MarkerServiceHandler.getFragmentManager().clearAll(); + if ( MarkerServiceHandler.getMogoStatusManager().isADASShow() ) { + MarkerServiceHandler.getADASController().closeADAS(); + } + MarkerServiceHandler.getMogoCardManager().switch2( card, true ); + } + } +} diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/IMogoServiceApis.java b/services/mogo-service-api/src/main/java/com/mogo/service/IMogoServiceApis.java index 829f3c866b..b2c827db12 100644 --- a/services/mogo-service-api/src/main/java/com/mogo/service/IMogoServiceApis.java +++ b/services/mogo-service-api/src/main/java/com/mogo/service/IMogoServiceApis.java @@ -8,6 +8,7 @@ import com.mogo.service.analytics.IMogoAnalytics; import com.mogo.service.cardmanager.IMogoCardManager; import com.mogo.service.connection.IMogoSocketManager; import com.mogo.service.datamanager.IMogoDataManager; +import com.mogo.service.entrance.IMogoEntranceButtonController; import com.mogo.service.fragmentmanager.IMogoFragmentManager; import com.mogo.service.imageloader.IMogoImageloader; import com.mogo.service.intent.IMogoIntentManager; @@ -170,4 +171,11 @@ public interface IMogoServiceApis extends IProvider { * @return */ IMogoLauncher getLauncherApi(); + + /** + * 获取入口按钮控制器 + * + * @return + */ + IMogoEntranceButtonController getEntranceButtonController(); } diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/MogoServicePaths.java b/services/mogo-service-api/src/main/java/com/mogo/service/MogoServicePaths.java index c422f05b1a..ca78173ea3 100644 --- a/services/mogo-service-api/src/main/java/com/mogo/service/MogoServicePaths.java +++ b/services/mogo-service-api/src/main/java/com/mogo/service/MogoServicePaths.java @@ -160,4 +160,10 @@ public class MogoServicePaths { */ @Deprecated public static final String PATH_LAUNCHER_API = "/launcher/api"; + + /** + * 入口按钮 + */ + @Deprecated + public static final String PATH_ENTRANCE_BUTTON_API = "/entrancebutton/api"; } diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/entrance/ButtonIndex.java b/services/mogo-service-api/src/main/java/com/mogo/service/entrance/ButtonIndex.java new file mode 100644 index 0000000000..1c4e955019 --- /dev/null +++ b/services/mogo-service-api/src/main/java/com/mogo/service/entrance/ButtonIndex.java @@ -0,0 +1,20 @@ +package com.mogo.service.entrance; + +/** + * @author congtaowang + * @since 2020-04-16 + *

+ * 入口按钮顺序:从上到下 + */ +public enum ButtonIndex { + + /** + * 第一个 + */ + BUTTON1, + + /** + * 第二个 + */ + BUTTON2; +} diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/entrance/IMogoEntranceButtonController.java b/services/mogo-service-api/src/main/java/com/mogo/service/entrance/IMogoEntranceButtonController.java new file mode 100644 index 0000000000..254109c16b --- /dev/null +++ b/services/mogo-service-api/src/main/java/com/mogo/service/entrance/IMogoEntranceButtonController.java @@ -0,0 +1,22 @@ +package com.mogo.service.entrance; + +import android.widget.TextView; + +import com.alibaba.android.arouter.facade.template.IProvider; + +/** + * @author congtaowang + * @since 2020-04-16 + *

+ * 入口按钮 + */ +public interface IMogoEntranceButtonController extends IProvider { + + /** + * 获取入口按钮实例 + * + * @param index + * @return + */ + TextView getButton( ButtonIndex index ); +} diff --git a/services/mogo-service/src/main/java/com/mogo/service/impl/MogoServiceApis.java b/services/mogo-service/src/main/java/com/mogo/service/impl/MogoServiceApis.java index b23dddd85a..462e799b7a 100644 --- a/services/mogo-service/src/main/java/com/mogo/service/impl/MogoServiceApis.java +++ b/services/mogo-service/src/main/java/com/mogo/service/impl/MogoServiceApis.java @@ -13,6 +13,7 @@ import com.mogo.service.analytics.IMogoAnalytics; import com.mogo.service.cardmanager.IMogoCardManager; import com.mogo.service.connection.IMogoSocketManager; import com.mogo.service.datamanager.IMogoDataManager; +import com.mogo.service.entrance.IMogoEntranceButtonController; import com.mogo.service.fragmentmanager.IMogoFragmentManager; import com.mogo.service.imageloader.IMogoImageloader; import com.mogo.service.impl.analytics.impl.MogoAnalyticsImpl; @@ -153,6 +154,11 @@ public class MogoServiceApis implements IMogoServiceApis { return getApiInstance( IMogoLauncher.class, MogoServicePaths.PATH_LAUNCHER_API ); } + @Override + public IMogoEntranceButtonController getEntranceButtonController() { + return getApiInstance( IMogoEntranceButtonController.class, MogoServicePaths.PATH_ENTRANCE_BUTTON_API ); + } + private static < T extends IProvider > T getApiInstance( Class< T > clazz, String path ) { T inst = SingletonsHolder.get( clazz ); if ( inst == null ) {