note the problem dialog
This commit is contained in:
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -4,7 +4,7 @@
|
||||
<asm skipDebug="false" skipFrames="false" skipCode="false" expandFrames="false" />
|
||||
<groovy codeStyle="LEGACY" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="JDK" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -2,7 +2,6 @@ package com.mogo.launcher;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
@@ -54,7 +53,7 @@ public class MogoApplication extends AbsMogoApplication {
|
||||
Logger.init( BuildConfig.DEBUG ? LogLevel.DEBUG : LogLevel.OFF );
|
||||
|
||||
// MogoModulePaths.addModule(new MogoModule(PATH_GUIDE_FRAGMENT, PATH_GUIDE_MODULE_NAME));
|
||||
MogoModulePaths.addModule( new MogoModule( AuthorizeConstant.PATH_AGREEMENT_FRAGMENT, AuthorizeConstant.PATH_AGREEMENT_MODULE_NAME ) );
|
||||
MogoModulePaths.addModule( new MogoModule( MogoServicePaths.PATH_AGREEMENT, AuthorizeConstant.PATH_AGREEMENT_MODULE_NAME ) );
|
||||
|
||||
//运营位卡片,需要默认显示,放在第一个加载
|
||||
if ( DebugConfig.isLauncher() ) {
|
||||
|
||||
@@ -9,17 +9,16 @@ import com.mogo.map.listener.IMogoMapListener
|
||||
import com.mogo.map.location.IMogoLocationListener
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener
|
||||
import com.mogo.map.navi.IMogoNaviListener
|
||||
import com.mogo.module.authorize.authprovider.invoke.AuthorizeConstant.Companion.PATH_AGREEMENT_FRAGMENT
|
||||
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.MogoServicePaths
|
||||
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)
|
||||
@Route(path = MogoServicePaths.PATH_AGREEMENT)
|
||||
class MogoAuthorizeProvider : IMogoAuthManager {
|
||||
|
||||
companion object {
|
||||
@@ -49,7 +48,7 @@ class MogoAuthorizeProvider : IMogoAuthManager {
|
||||
}
|
||||
|
||||
override fun getType(): Int {
|
||||
return ModuleType.TYPE_SERVICE
|
||||
return 0
|
||||
}
|
||||
|
||||
override fun getNaviListener(): IMogoNaviListener? {
|
||||
@@ -66,12 +65,6 @@ class MogoAuthorizeProvider : IMogoAuthManager {
|
||||
|
||||
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(mContext!!)
|
||||
} else {
|
||||
@@ -81,6 +74,13 @@ class MogoAuthorizeProvider : IMogoAuthManager {
|
||||
}
|
||||
}
|
||||
|
||||
override fun init(context: Context) {
|
||||
//todo 引导判断暂时去掉 后续引导流程更改完再放开
|
||||
// todo if (isDeviceOfD() && hasGuide() && mogoAuthShow.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_MAIN)) {
|
||||
// todo F系列暂时没有授权功能 1.1需求中添加 全量上
|
||||
|
||||
}
|
||||
|
||||
override fun getAppPackage(): String? {
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -6,11 +6,6 @@ class AuthorizeConstant {
|
||||
const val PROVIDER_MODULE = "/authorize/biz"
|
||||
const val PROVIDER_LAUNCHER = "/authorize/showbiz"
|
||||
|
||||
/**
|
||||
* 展示用户协议模块地址
|
||||
*/
|
||||
const val PATH_AGREEMENT_FRAGMENT = "/agreement/showFragment"
|
||||
|
||||
/**
|
||||
* provider模块实例名称(暂时仅有卡片用到)
|
||||
*/
|
||||
|
||||
@@ -2,15 +2,12 @@ package com.mogo.module.authorize.authprovider.launcher
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Looper
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.module.authorize.authprovider.biz.MogoAuthorizeManagerImpl
|
||||
import com.mogo.module.authorize.authprovider.biz.MogoAuthorizeRegisterHandler
|
||||
import com.mogo.module.authorize.authprovider.invoke.AuthorizeInvokerConstant
|
||||
import com.mogo.module.authorize.authprovider.invoke.AuthorizeInvokerConstant.Companion.AUTHORIZE_TYPE_LAUNCHER_MAIN
|
||||
import com.mogo.module.authorize.layout.AuthorizeLayout
|
||||
import com.mogo.module.authorize.layout.AuthorizeDialog
|
||||
import com.mogo.module.authorize.model.proxy.toAuthorizeType
|
||||
import com.mogo.module.authorize.util.SharedPreferenceUtil.hasAuth
|
||||
import com.mogo.module.common.wm.WindowManagerView
|
||||
import com.mogo.utils.logger.Logger
|
||||
|
||||
class MogoMainAuthorize private constructor() : MogoAuthorizeManagerImpl(), IMogoAuthorizeMainProvider {
|
||||
@@ -26,7 +23,7 @@ class MogoMainAuthorize private constructor() : MogoAuthorizeManagerImpl(), IMog
|
||||
|
||||
private var mContext:Context? = null
|
||||
|
||||
private var windowManagerView: WindowManagerView? = null
|
||||
private var authorizeDialog: AuthorizeDialog? = null
|
||||
|
||||
override fun hasRegister(tag: String): Boolean {
|
||||
if (tag.isNullOrBlank()) return false
|
||||
@@ -44,7 +41,7 @@ class MogoMainAuthorize private constructor() : MogoAuthorizeManagerImpl(), IMog
|
||||
|
||||
fun invokeAuthorizeForShow(context: Context) {
|
||||
mContext = context
|
||||
pushLayoutToMainWindow(AUTHORIZE_TYPE_LAUNCHER_MAIN)
|
||||
// pushLayoutToMainWindow(AUTHORIZE_TYPE_LAUNCHER_MAIN)
|
||||
}
|
||||
|
||||
fun showAuthorizeView(tag: String, forbiddenVoice: (() -> Unit), onError: ((String) -> Unit)) {
|
||||
@@ -67,25 +64,23 @@ class MogoMainAuthorize private constructor() : MogoAuthorizeManagerImpl(), IMog
|
||||
Logger.d(TAG, "ready to forbidden voice")
|
||||
forbiddenVoice.invoke()
|
||||
Logger.d(TAG, "ready to push fragment")
|
||||
pushLayoutToMainWindow(tag)
|
||||
// pushLayoutToMainWindow(tag)
|
||||
}
|
||||
|
||||
fun hideAuthorizeView() {
|
||||
windowManagerView?.dismiss()
|
||||
authorizeDialog?.dismiss()
|
||||
}
|
||||
|
||||
private fun pushLayoutToMainWindow(tag: String) {
|
||||
if (windowManagerView == null) {
|
||||
val authorizeLayout = AuthorizeLayout(tag)
|
||||
val view = authorizeLayout.getLayoutView()
|
||||
windowManagerView = WindowManagerView.Builder(mContext).contentView(view).build()
|
||||
if (authorizeDialog == null) {
|
||||
authorizeDialog = AuthorizeDialog(tag,mContext!!)
|
||||
}
|
||||
if (windowManagerView!!.isShowing) {
|
||||
if (authorizeDialog!!.isShowing) {
|
||||
Logger.d(TAG, "User is operation authorization, do not repeat invoke")
|
||||
return
|
||||
} else {
|
||||
Logger.d(TAG, "pushLayoutToMainWindow")
|
||||
windowManagerView!!.show()
|
||||
authorizeDialog!!.show()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,176 @@
|
||||
package com.mogo.module.authorize.layout
|
||||
|
||||
import android.content.Context
|
||||
import android.text.Html
|
||||
import android.view.View
|
||||
import android.widget.Button
|
||||
import android.widget.TextView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.module.authorize.R
|
||||
import com.mogo.module.authorize.util.AnalyticsUtil
|
||||
import com.mogo.module.authorize.voice.IVoiceAuthorizeIntentListener
|
||||
import com.mogo.module.authorize.voice.IVoiceCommandListener
|
||||
import com.mogo.module.authorize.voice.VoiceUtil
|
||||
import com.mogo.module.common.dialog.BaseFloatDialog
|
||||
import com.mogo.utils.logger.Logger
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
class AuthorizeDialog : BaseFloatDialog, View.OnClickListener, IVoiceCommandListener, IVoiceAuthorizeIntentListener {
|
||||
|
||||
private var mContext: Context? = null
|
||||
private var invokeTag: String? = null
|
||||
|
||||
private var agreementId: Long = 0L
|
||||
|
||||
private var clTopParent: ConstraintLayout? = null
|
||||
private var clErrorContainer: ConstraintLayout? = null
|
||||
private var clLoadAuthorizeContainer: ConstraintLayout? = null
|
||||
private var clContainer: ConstraintLayout? = null
|
||||
private var clAuthorizeLoading: ConstraintLayout? = null
|
||||
private var btnAgree: Button? = null
|
||||
private var btnDisAgree: Button? = null
|
||||
private var btnLoadingError: Button? = null
|
||||
private var tvTitle: TextView? = null
|
||||
private var tvContent: TextView? = null
|
||||
private var tvButtonContent: TextView? = null
|
||||
private var tvLastContent: TextView? = null
|
||||
|
||||
private var authorizeController: AuthorizeController? = null
|
||||
|
||||
constructor(invokeTag: String, context: Context) : super(context) {
|
||||
mContext = context
|
||||
this.invokeTag = invokeTag
|
||||
initView()
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
setContentView(R.layout.module_authorize_fragment)
|
||||
initViews()
|
||||
}
|
||||
|
||||
fun initViews() {
|
||||
Logger.d(AuthorizeLayout.TAG, "initView ")
|
||||
AnalyticsUtil.track(AnalyticsUtil.INVOKE_TRACK_AUTHORIZE_SHOW)
|
||||
init()
|
||||
Logger.d(AuthorizeLayout.TAG, "invokeTag :$invokeTag")
|
||||
authorizeController = AuthorizeController(invokeTag!!)
|
||||
invokeAuthorizationContent()
|
||||
VoiceUtil.registerAll(this, this)
|
||||
}
|
||||
|
||||
private fun init() {
|
||||
clTopParent = findViewById(R.id.clAuthorizeTopParent)
|
||||
clErrorContainer = findViewById(R.id.clLoadingErrorContainer)
|
||||
clLoadAuthorizeContainer = findViewById(R.id.clLoadingAuthorizeContainer)
|
||||
clContainer = findViewById(R.id.clAuthorizeContainer)
|
||||
clAuthorizeLoading = findViewById(R.id.clAuthorizeLoading)
|
||||
btnAgree = findViewById(R.id.btnAuthorizeAgree)
|
||||
btnDisAgree = findViewById(R.id.btnAuthorizeDisAgree)
|
||||
btnLoadingError = findViewById(R.id.btnAuthorizeLoadingError)
|
||||
tvTitle = findViewById(R.id.tvAuthorizeTitle)
|
||||
tvContent = findViewById(R.id.tvAuthorizeContent)
|
||||
tvButtonContent = findViewById(R.id.tvAuthorizeButtonContent)
|
||||
tvLastContent = findViewById(R.id.tvAuthorizeLastContent)
|
||||
btnAgree?.setOnClickListener(this)
|
||||
btnDisAgree?.setOnClickListener(this)
|
||||
btnLoadingError?.setOnClickListener(this)
|
||||
clTopParent?.setOnClickListener(this)
|
||||
clContainer?.setOnClickListener(this)
|
||||
clErrorContainer?.setOnClickListener(this)
|
||||
clLoadAuthorizeContainer?.setOnClickListener(this)
|
||||
clAuthorizeLoading?.setOnClickListener(this)
|
||||
}
|
||||
|
||||
private fun readyToAuthorize() {
|
||||
clErrorContainer?.visibility = View.GONE
|
||||
clLoadAuthorizeContainer?.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
private fun showAuthorizationAgreementContent(
|
||||
agreementId: Long,
|
||||
agreementContent: String,
|
||||
agreementTitle: String,
|
||||
agreementBottom: String,
|
||||
agreementLast: String) {
|
||||
VoiceUtil.speak(AbsMogoApplication.getApp().applicationContext.resources.getString(R.string.module_authorize_agreement_tip), AbsMogoApplication.getApp().applicationContext, this)
|
||||
this.agreementId = agreementId
|
||||
clLoadAuthorizeContainer?.visibility = View.GONE
|
||||
clContainer?.visibility = View.VISIBLE
|
||||
tvTitle?.text = Html.fromHtml(agreementTitle)
|
||||
GlobalScope.async(Dispatchers.IO) {
|
||||
val spannable = Html.fromHtml(agreementContent)
|
||||
withContext(Dispatchers.Main) {
|
||||
tvContent?.text = spannable
|
||||
}
|
||||
}
|
||||
tvButtonContent?.text = Html.fromHtml(agreementBottom)
|
||||
tvLastContent?.text = Html.fromHtml(agreementLast)
|
||||
}
|
||||
|
||||
private fun showAuthorizationError() {
|
||||
clLoadAuthorizeContainer?.visibility = View.GONE
|
||||
clErrorContainer?.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
private fun voiceAuthorizeError() {
|
||||
VoiceUtil.speak(AbsMogoApplication.getApp().applicationContext.getString(R.string.module_authorize_failed), AbsMogoApplication.getApp().applicationContext, this)
|
||||
Logger.d(AuthorizeLayout.TAG, "onDestroy")
|
||||
VoiceUtil.unregisterAll(AbsMogoApplication.getApp().applicationContext, this)
|
||||
}
|
||||
|
||||
override fun onClick(v: View) {
|
||||
when (v.id) {
|
||||
R.id.btnAuthorizeAgree -> {
|
||||
AnalyticsUtil.track(AnalyticsUtil.INVOKE_TRACK_AUTHORIZE_CLICK, hashMapOf("operation_type" to 1, "operation_result" to 1))
|
||||
agreeAuthorize()
|
||||
}
|
||||
R.id.btnAuthorizeDisAgree -> {
|
||||
AnalyticsUtil.track(AnalyticsUtil.INVOKE_TRACK_AUTHORIZE_CLICK, hashMapOf("operation_type" to 1, "operation_result" to 2))
|
||||
disAgreeAuthorize()
|
||||
}
|
||||
R.id.clLoadingErrorContainer, R.id.btnAuthorizeLoadingError -> {
|
||||
invokeAuthorizationContent()
|
||||
}
|
||||
R.id.clAuthorizeTopParent -> {
|
||||
Logger.i(AuthorizeLayout.TAG, "dismiss authorizeView")
|
||||
authorizeController?.onDestroy()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onVoiceCmdAgree() {
|
||||
AnalyticsUtil.track(AnalyticsUtil.INVOKE_TRACK_AUTHORIZE_CLICK, hashMapOf("operation_type" to 2, "operation_result" to 1))
|
||||
agreeAuthorize()
|
||||
}
|
||||
|
||||
override fun onVoiceCmdDisAgree() {
|
||||
AnalyticsUtil.track(AnalyticsUtil.INVOKE_TRACK_AUTHORIZE_CLICK, hashMapOf("operation_type" to 2, "operation_result" to 2))
|
||||
disAgreeAuthorize()
|
||||
}
|
||||
|
||||
private fun agreeAuthorize() {
|
||||
authorizeController?.agreeAuthorize(invokeTag!!, agreementId) {
|
||||
voiceAuthorizeError()
|
||||
}
|
||||
}
|
||||
|
||||
private fun disAgreeAuthorize() {
|
||||
authorizeController?.disAgreeAuthorize(invokeTag!!, agreementId) {
|
||||
voiceAuthorizeError()
|
||||
}
|
||||
}
|
||||
|
||||
private fun invokeAuthorizationContent() {
|
||||
authorizeController?.invokeAuthorizationContent(invokeTag!!, {
|
||||
readyToAuthorize()
|
||||
}, { id: Long, content: String, title: String, bottomContent: String, lastContent: String ->
|
||||
showAuthorizationAgreementContent(id, content, title, bottomContent, lastContent)
|
||||
}, {
|
||||
showAuthorizationError()
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -50,11 +50,11 @@ class AuthorizeLayout(private val invokeTag: String) : View.OnClickListener, IVo
|
||||
return layoutInflater
|
||||
}
|
||||
|
||||
private fun getLayoutId(): Int {
|
||||
fun getLayoutId(): Int {
|
||||
return R.layout.module_authorize_fragment
|
||||
}
|
||||
|
||||
private fun initViews(mRootView: View) {
|
||||
fun initViews(mRootView: View) {
|
||||
Logger.d(TAG, "initView ")
|
||||
AnalyticsUtil.track(INVOKE_TRACK_AUTHORIZE_SHOW)
|
||||
init(mRootView)
|
||||
|
||||
@@ -16,6 +16,7 @@ class DialogImpl implements IWindowManagerView {
|
||||
public void init(WindowManagerView.WMViewParams params) {
|
||||
Logger.d("DialogImpl", "init====");
|
||||
dialog = new BaseFloatDialog(params.mContext);
|
||||
Logger.d("DialogImpl","params view : " + params.mContentView);
|
||||
dialog.setContentView(params.mContentView);
|
||||
}
|
||||
|
||||
|
||||
@@ -1016,7 +1016,9 @@
|
||||
<dimen name="dp_997">997px</dimen>
|
||||
<dimen name="dp_998">998px</dimen>
|
||||
<dimen name="dp_999">999px</dimen>
|
||||
<dimen name="dp_1000">1000px</dimen>
|
||||
<dimen name="dp_1300">1300px</dimen>
|
||||
<dimen name="dp_1920">1920px</dimen>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -115,7 +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);
|
||||
// mServiceApis.getAuthManagerApi().resetContext(this);
|
||||
mMogoStatusManager = mServiceApis.getStatusManagerApi();
|
||||
mMogoStatusManager.setMainPageLaunchedStatus( TAG, true );
|
||||
AutopilotServiceManage.getInstance().init( getContext() );
|
||||
|
||||
Reference in New Issue
Block a user