changed the auth view interface impl
This commit is contained in:
@@ -13,18 +13,21 @@ import com.mogo.module.authorize.authprovider.invoke.AuthorizeConstant.Companion
|
||||
import com.mogo.module.authorize.authprovider.invoke.AuthorizeConstant.Companion.PATH_AGREEMENT_MODULE_NAME
|
||||
import com.mogo.module.authorize.authprovider.invoke.AuthorizeInvokerConstant.Companion.AUTHORIZE_TYPE_LAUNCHER_MAIN
|
||||
import com.mogo.module.authorize.authprovider.launcher.MogoMainAuthorize.Companion.mogoAuthShow
|
||||
import com.mogo.service.auth.IMogoAuthManager
|
||||
import com.mogo.service.module.IMogoModuleLifecycle
|
||||
import com.mogo.service.module.IMogoModuleProvider
|
||||
import com.mogo.service.module.ModuleType
|
||||
import com.mogo.utils.logger.Logger
|
||||
|
||||
@Route(path = PATH_AGREEMENT_FRAGMENT)
|
||||
class MogoAuthorizeProvider : IMogoModuleProvider {
|
||||
class MogoAuthorizeProvider : IMogoAuthManager {
|
||||
|
||||
companion object {
|
||||
const val TAG = "MogoAuthorizeProvider"
|
||||
}
|
||||
|
||||
private var mContext:Context? = null
|
||||
|
||||
override fun createFragment(context: Context?, data: Bundle?): Fragment? {
|
||||
return null
|
||||
}
|
||||
@@ -61,12 +64,16 @@ class MogoAuthorizeProvider : IMogoModuleProvider {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun resetContext(context: Context?) {
|
||||
mContext = context
|
||||
}
|
||||
|
||||
override fun init(context: Context) {
|
||||
//todo 引导判断暂时去掉 后续引导流程更改完再放开
|
||||
// todo if (isDeviceOfD() && hasGuide() && mogoAuthShow.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_MAIN)) {
|
||||
// todo F系列暂时没有授权功能 1.1需求中添加 全量上
|
||||
if (mogoAuthShow.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_MAIN)) {
|
||||
mogoAuthShow.invokeAuthorizeForShow(context)
|
||||
mogoAuthShow.invokeAuthorizeForShow(mContext!!)
|
||||
} else {
|
||||
//首次进入Launcher同步一下授权状态,防止由于用户清除数据造成首次加载还会出现授权状态不同步问题
|
||||
mogoAuthShow.updateAuthorizeStatus(AUTHORIZE_TYPE_LAUNCHER_MAIN)
|
||||
@@ -81,4 +88,5 @@ class MogoAuthorizeProvider : IMogoModuleProvider {
|
||||
override fun getAppName(): String? {
|
||||
return null
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,6 +24,8 @@ class MogoMainAuthorize private constructor() : MogoAuthorizeManagerImpl(), IMog
|
||||
}
|
||||
}
|
||||
|
||||
private var mContext:Context? = null
|
||||
|
||||
private var windowManagerView: WindowManagerView? = null
|
||||
|
||||
override fun hasRegister(tag: String): Boolean {
|
||||
@@ -41,7 +43,8 @@ class MogoMainAuthorize private constructor() : MogoAuthorizeManagerImpl(), IMog
|
||||
}
|
||||
|
||||
fun invokeAuthorizeForShow(context: Context) {
|
||||
pushLayoutToMainWindow(context, AUTHORIZE_TYPE_LAUNCHER_MAIN)
|
||||
mContext = context
|
||||
pushLayoutToMainWindow(AUTHORIZE_TYPE_LAUNCHER_MAIN)
|
||||
}
|
||||
|
||||
fun showAuthorizeView(tag: String, forbiddenVoice: (() -> Unit), onError: ((String) -> Unit)) {
|
||||
@@ -64,18 +67,18 @@ class MogoMainAuthorize private constructor() : MogoAuthorizeManagerImpl(), IMog
|
||||
Logger.d(TAG, "ready to forbidden voice")
|
||||
forbiddenVoice.invoke()
|
||||
Logger.d(TAG, "ready to push fragment")
|
||||
pushLayoutToMainWindow(AbsMogoApplication.getApp().applicationContext,tag)
|
||||
pushLayoutToMainWindow(tag)
|
||||
}
|
||||
|
||||
fun hideAuthorizeView() {
|
||||
windowManagerView?.dismiss()
|
||||
}
|
||||
|
||||
private fun pushLayoutToMainWindow(context: Context,tag: String) {
|
||||
private fun pushLayoutToMainWindow(tag: String) {
|
||||
if (windowManagerView == null) {
|
||||
val authorizeLayout = AuthorizeLayout(tag)
|
||||
val view = authorizeLayout.getLayoutView()
|
||||
windowManagerView = WindowManagerView.Builder(context).contentView(view).build()
|
||||
windowManagerView = WindowManagerView.Builder(mContext).contentView(view).build()
|
||||
}
|
||||
if (windowManagerView!!.isShowing) {
|
||||
Logger.d(TAG, "User is operation authorization, do not repeat invoke")
|
||||
|
||||
@@ -115,6 +115,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
mServiceApis = ( IMogoServiceApis ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICE_APIS ).navigation();
|
||||
}
|
||||
mServiceApis.getShareManager().resetContext(this);
|
||||
mServiceApis.getAuthManagerApi().resetContext(this);
|
||||
mMogoStatusManager = mServiceApis.getStatusManagerApi();
|
||||
mMogoStatusManager.setMainPageLaunchedStatus( TAG, true );
|
||||
AutopilotServiceManage.getInstance().init( getContext() );
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.content.Context;
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.mogo.service.adas.IMogoADASController;
|
||||
import com.mogo.service.analytics.IMogoAnalytics;
|
||||
import com.mogo.service.auth.IMogoAuthManager;
|
||||
import com.mogo.service.cardmanager.IMogoCardManager;
|
||||
import com.mogo.service.connection.IMogoSocketManager;
|
||||
import com.mogo.service.datamanager.IMogoDataManager;
|
||||
@@ -236,4 +237,10 @@ public interface IMogoServiceApis extends IProvider {
|
||||
* @return
|
||||
*/
|
||||
IMogoPassportManager getPassportManagerApi();
|
||||
|
||||
/**
|
||||
* 获取授权服务
|
||||
* @return
|
||||
*/
|
||||
IMogoAuthManager getAuthManagerApi();
|
||||
}
|
||||
|
||||
@@ -220,4 +220,10 @@ public class MogoServicePaths {
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String PATH_PASSPORT = "/passport/api";
|
||||
|
||||
/**
|
||||
* 授权服务
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String PATH_AGREEMENT = "/agreement/showFragment";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.mogo.service.auth;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
|
||||
public interface IMogoAuthManager extends IMogoModuleProvider {
|
||||
|
||||
/**
|
||||
* 重置授权页面弹起时展示View Context
|
||||
*/
|
||||
void resetContext(Context context);
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.adas.IMogoADASController;
|
||||
import com.mogo.service.analytics.IMogoAnalytics;
|
||||
import com.mogo.service.auth.IMogoAuthManager;
|
||||
import com.mogo.service.cardmanager.IMogoCardManager;
|
||||
import com.mogo.service.connection.IMogoSocketManager;
|
||||
import com.mogo.service.datamanager.IMogoDataManager;
|
||||
@@ -200,6 +201,11 @@ public class MogoServiceApis implements IMogoServiceApis {
|
||||
return getApiInstance( IMogoPassportManager.class, MogoServicePaths.PATH_PASSPORT );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoAuthManager getAuthManagerApi() {
|
||||
return getApiInstance( IMogoAuthManager.class, MogoServicePaths.PATH_AGREEMENT );
|
||||
}
|
||||
|
||||
private static < T extends IProvider > T getApiInstance( Class< T > clazz, String path ) {
|
||||
T inst = SingletonsHolder.get( clazz );
|
||||
if ( inst == null ) {
|
||||
|
||||
Reference in New Issue
Block a user