Merge branch 'feature/v2.0.0' of gitlab.zhidaoauto.com:ecos/yycp-service/Launcher into feature/v2.0.0
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package com.mogo.module.authorize.authprovider.biz
|
||||
|
||||
import com.google.gson.Gson
|
||||
import com.mogo.module.authorize.authprovider.invoke.IMogoAuthorizeContentListener
|
||||
import com.mogo.module.authorize.model.BaseResponse
|
||||
import com.mogo.module.authorize.model.IMogoAuthorizeModel
|
||||
|
||||
@@ -63,11 +63,11 @@ class MogoAuthorizeProvider : IMogoModuleProvider {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
override fun init(context: Context) {
|
||||
//todo 引导判断暂时去掉 后续引导流程更改完再放开
|
||||
// todo if (isDeviceOfD() && hasGuide() && mogoAuthShow.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_MAIN)) {
|
||||
if (isDeviceOfD() && mogoAuthShow.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_MAIN)) {
|
||||
mogoAuthShow.invokeAuthorizeForShow()
|
||||
mogoAuthShow.invokeAuthorizeForShow(context)
|
||||
} else {
|
||||
//首次进入Launcher同步一下授权状态,防止由于用户清除数据造成首次加载还会出现授权状态不同步问题
|
||||
mogoAuthShow.updateAuthorizeStatus(AUTHORIZE_TYPE_LAUNCHER_MAIN)
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
package com.mogo.module.authorize.authprovider.launcher
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Looper
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
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.AuthorizeConstant.Companion.PATH_AGREEMENT_MODULE_NAME
|
||||
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.fragment.AuthorizeFragment
|
||||
import com.mogo.module.authorize.layout.AuthorizeLayout
|
||||
import com.mogo.module.authorize.model.proxy.toAuthorizeType
|
||||
import com.mogo.module.authorize.util.SharedPreferenceUtil.hasAuth
|
||||
import com.mogo.service.IMogoServiceApis
|
||||
import com.mogo.service.MogoServicePaths
|
||||
import com.mogo.service.fragmentmanager.FragmentDescriptor
|
||||
import com.mogo.module.common.wm.WindowManagerView
|
||||
import com.mogo.utils.logger.Logger
|
||||
|
||||
class MogoMainAuthorize private constructor() : MogoAuthorizeManagerImpl(), IMogoAuthorizeMainProvider {
|
||||
@@ -25,8 +24,7 @@ class MogoMainAuthorize private constructor() : MogoAuthorizeManagerImpl(), IMog
|
||||
}
|
||||
}
|
||||
|
||||
@Volatile
|
||||
private var showAuthorizeView: Boolean = false
|
||||
private var windowManagerView: WindowManagerView? = null
|
||||
|
||||
override fun hasRegister(tag: String): Boolean {
|
||||
if (tag.isNullOrBlank()) return false
|
||||
@@ -42,14 +40,8 @@ class MogoMainAuthorize private constructor() : MogoAuthorizeManagerImpl(), IMog
|
||||
MogoAuthorizeMainController.disAgreeAuthorize(tag, agrId, onSuccess, onError)
|
||||
}
|
||||
|
||||
fun invokeAuthorizeForShow() {
|
||||
if (showAuthorizeView) {
|
||||
Logger.d(TAG, "User is operation authorization, do not repeat invoke")
|
||||
return
|
||||
}
|
||||
pushFragmentToMainView(AUTHORIZE_TYPE_LAUNCHER_MAIN) {
|
||||
showAuthorizeView = true
|
||||
}
|
||||
fun invokeAuthorizeForShow(context: Context) {
|
||||
pushLayoutToMainWindow(context, AUTHORIZE_TYPE_LAUNCHER_MAIN)
|
||||
}
|
||||
|
||||
fun showAuthorizeView(tag: String, forbiddenVoice: (() -> Unit), onError: ((String) -> Unit)) {
|
||||
@@ -69,44 +61,28 @@ class MogoMainAuthorize private constructor() : MogoAuthorizeManagerImpl(), IMog
|
||||
onError.invoke("already authorize,do not repeat operation")
|
||||
return
|
||||
}
|
||||
if (showAuthorizeView) {
|
||||
onError.invoke("User is operation authorization, do not repeat invoke")
|
||||
return
|
||||
}
|
||||
Logger.d(TAG, "ready to forbidden voice")
|
||||
forbiddenVoice.invoke()
|
||||
Logger.d(TAG, "ready to push fragment")
|
||||
pushFragmentToMainView(tag) {
|
||||
showAuthorizeView = true
|
||||
}
|
||||
pushLayoutToMainWindow(AbsMogoApplication.getApp().applicationContext,tag)
|
||||
}
|
||||
|
||||
fun hideAuthorizeView() {
|
||||
popFragmentFromMainView {
|
||||
showAuthorizeView = false
|
||||
windowManagerView?.dismiss()
|
||||
}
|
||||
|
||||
private fun pushLayoutToMainWindow(context: Context,tag: String) {
|
||||
if (windowManagerView == null) {
|
||||
val authorizeLayout = AuthorizeLayout(tag)
|
||||
val view = authorizeLayout.getLayoutView()
|
||||
windowManagerView = WindowManagerView.Builder(context).contentView(view).build()
|
||||
}
|
||||
}
|
||||
|
||||
fun resetShowStatus() {
|
||||
showAuthorizeView = false
|
||||
}
|
||||
|
||||
private inline fun pushFragmentToMainView(tag: String, push: (() -> Unit)) {
|
||||
val builderWrapper = FragmentDescriptor.Builder().fragment(AuthorizeFragment.newInstance(tag))
|
||||
.tag(PATH_AGREEMENT_MODULE_NAME).notifyMainModule(false).build()
|
||||
Logger.d(TAG, "pushFragmentToMainView")
|
||||
val mogoService = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation()
|
||||
if (mogoService is IMogoServiceApis) {
|
||||
push.invoke()
|
||||
mogoService.fragmentManagerApi.push(builderWrapper)
|
||||
}
|
||||
}
|
||||
|
||||
private inline fun popFragmentFromMainView(pop: (() -> Unit)) {
|
||||
val mogoService = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation()
|
||||
if (mogoService is IMogoServiceApis) {
|
||||
pop.invoke()
|
||||
mogoService.fragmentManagerApi.pop()
|
||||
if (windowManagerView!!.isShowing) {
|
||||
Logger.d(TAG, "User is operation authorization, do not repeat invoke")
|
||||
return
|
||||
} else {
|
||||
Logger.d(TAG, "pushLayoutToMainWindow")
|
||||
windowManagerView!!.show()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.mogo.module.authorize.authprovider.module
|
||||
|
||||
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.launcher.MogoMainAuthorize.Companion.mogoAuthShow
|
||||
@@ -13,7 +14,7 @@ class MogoModuleAuthorize private constructor() : MogoAuthorizeManagerImpl(), IM
|
||||
}
|
||||
|
||||
override fun invokeAuthorizeForShow() {
|
||||
mogoAuthShow.invokeAuthorizeForShow()
|
||||
mogoAuthShow.invokeAuthorizeForShow(AbsMogoApplication.getApp().applicationContext)
|
||||
}
|
||||
|
||||
override fun invokeAuthorization(tag: String) {
|
||||
@@ -28,12 +29,12 @@ class MogoModuleAuthorize private constructor() : MogoAuthorizeManagerImpl(), IM
|
||||
|
||||
fun forbiddenVoiceWhenAuthorize(cmd: String) {
|
||||
val tmpMap = MogoAuthorizeRegisterHandler.getAllAuthorizeListener()
|
||||
if (tmpMap == null || tmpMap.size == 0) {
|
||||
if (tmpMap.isEmpty()) {
|
||||
return
|
||||
}
|
||||
tmpMap.forEach {
|
||||
val acquireListener = it.value
|
||||
acquireListener?.forbiddenVoiceWhenAuthorize(cmd)
|
||||
acquireListener.forbiddenVoiceWhenAuthorize(cmd)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.mogo.module.authorize.fragment
|
||||
|
||||
import com.mogo.commons.mvp.IView
|
||||
|
||||
class AuthorizeContract {
|
||||
|
||||
interface View : IView {
|
||||
fun showAuthorizationAgreementContent(agreementId: Long, agreementContent: String, agreementTitle: String, agreementBottom: String, agreementLast: String)
|
||||
|
||||
fun readyToAuthorize()
|
||||
|
||||
fun showAuthorizationError()
|
||||
|
||||
fun voiceAuthorizeError()
|
||||
}
|
||||
|
||||
interface Biz {
|
||||
fun invokeAuthorizationContent(invokeTag: String)
|
||||
|
||||
fun agreeAuthorize(tag: String, agreementId: Long)
|
||||
|
||||
fun disAgreeAuthorize(tag: String, agreementId: Long)
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.mogo.module.authorize.fragment
|
||||
package com.mogo.module.authorize.layout
|
||||
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import com.mogo.commons.mvp.Presenter
|
||||
import com.mogo.module.authorize.authprovider.biz.MogoAuthorizeRegisterHandler
|
||||
import com.mogo.module.authorize.authprovider.launcher.MogoAuthorizeMainController
|
||||
import com.mogo.module.authorize.authprovider.launcher.MogoMainAuthorize.Companion.mogoAuthShow
|
||||
@@ -10,40 +8,41 @@ import com.mogo.module.authorize.util.DateUtil.parseDateToTime
|
||||
import com.mogo.module.authorize.util.SharedPreferenceUtil.updateAuthorizeVersion
|
||||
import com.mogo.utils.logger.Logger
|
||||
|
||||
class AuthorizePresenter : Presenter<AuthorizeContract.View>, AuthorizeContract.Biz {
|
||||
class AuthorizeController {
|
||||
|
||||
companion object {
|
||||
const val TAG = "AuthorizePresenter"
|
||||
const val TAG = "AuthorizeController"
|
||||
}
|
||||
|
||||
private var invokeTag: String? = null
|
||||
private var updateTime: Long = 0L
|
||||
|
||||
constructor(invokeTag: String, view: AuthorizeContract.View?) : super(view) {
|
||||
private constructor()
|
||||
|
||||
constructor(invokeTag: String) {
|
||||
this.invokeTag = invokeTag
|
||||
}
|
||||
|
||||
override fun onCreate(owner: LifecycleOwner) {
|
||||
super.onCreate(owner)
|
||||
Logger.d(TAG, "onCreate invokeTag:$invokeTag")
|
||||
invokeAuthorizationContent(invokeTag!!)
|
||||
}
|
||||
|
||||
override fun invokeAuthorizationContent(invokeTag: String) {
|
||||
mView.readyToAuthorize()
|
||||
fun invokeAuthorizationContent(invokeTag: String, before: () -> Unit,
|
||||
agreementContent: (id: Long, content: String, title: String, bottomContent: String, lastContent: String) -> Unit,
|
||||
agreementError: () -> Unit) {
|
||||
before.invoke()
|
||||
this.invokeTag = invokeTag
|
||||
MogoAuthorizeMainController.getAuthorizeContent({
|
||||
Logger.d(TAG, "ready to get Authorize Content")
|
||||
}, {
|
||||
getContentSuccess(it)
|
||||
getContentSuccess(it, agreementContent, agreementError)
|
||||
}, { msg: String ->
|
||||
getContentFailed(msg)
|
||||
getContentFailed(msg, agreementError)
|
||||
})
|
||||
}
|
||||
|
||||
private fun getContentSuccess(userAgreement: Agreement) {
|
||||
private fun getContentSuccess(userAgreement: Agreement,
|
||||
agreementContent: (id: Long, content: String, title: String, bottomContent: String, lastContent: String) -> Unit,
|
||||
agreementError: () -> Unit) {
|
||||
Logger.d(TAG, "requestContentSuccess userAgreement:$userAgreement")
|
||||
if (userAgreement?.agreementContent != null && userAgreement?.agreementContent.isNotEmpty()) {
|
||||
if (userAgreement.agreementContent.isNotEmpty()) {
|
||||
val id = userAgreement.tUserAgreementEntity.id
|
||||
val content = userAgreement.agreementContent[0]
|
||||
val title = userAgreement.tUserAgreementEntity.title
|
||||
@@ -52,38 +51,38 @@ class AuthorizePresenter : Presenter<AuthorizeContract.View>, AuthorizeContract.
|
||||
val tmpUpdate = userAgreement.tUserAgreementEntity.updateTime
|
||||
updateTime = parseDateToTime(tmpUpdate)
|
||||
Logger.d(TAG, "updateTime ===== $updateTime")
|
||||
mView.showAuthorizationAgreementContent(id, content, title, bottomContent, lastContent)
|
||||
agreementContent.invoke(id, content, title, bottomContent, lastContent)
|
||||
} else {
|
||||
mView.showAuthorizationError()
|
||||
agreementError.invoke()
|
||||
}
|
||||
}
|
||||
|
||||
private fun getContentFailed(errorMsg: String) {
|
||||
private fun getContentFailed(errorMsg: String, agreementError: () -> Unit) {
|
||||
Logger.d(TAG, "requestContentFailed errorMsg:$errorMsg")
|
||||
mView.showAuthorizationError()
|
||||
agreementError.invoke()
|
||||
}
|
||||
|
||||
override fun agreeAuthorize(tag: String, agreementId: Long) {
|
||||
fun agreeAuthorize(tag: String, agreementId: Long, voiceAuthorizeError: () -> Unit) {
|
||||
mogoAuthShow.agreeAuthorize(tag, agreementId, {
|
||||
Logger.d(TAG, "agreeAuthorize success")
|
||||
updateAuthorizeVersion(updateTime)
|
||||
closeAuthorizeView()
|
||||
}, {
|
||||
Logger.d(TAG, "agreeAuthorize failed")
|
||||
authorizeFailed()
|
||||
authorizeFailed(voiceAuthorizeError)
|
||||
})
|
||||
}
|
||||
|
||||
override fun disAgreeAuthorize(tag: String, agreementId: Long) {
|
||||
fun disAgreeAuthorize(tag: String, agreementId: Long, voiceAuthorizeError: () -> Unit) {
|
||||
mogoAuthShow.disAgreeAuthorize(tag, agreementId, {
|
||||
authorizeFailed()
|
||||
authorizeFailed(voiceAuthorizeError)
|
||||
}, {
|
||||
authorizeFailed()
|
||||
authorizeFailed(voiceAuthorizeError)
|
||||
})
|
||||
}
|
||||
|
||||
private fun authorizeFailed() {
|
||||
mView.voiceAuthorizeError()
|
||||
private inline fun authorizeFailed(voiceAuthorizeError: () -> Unit) {
|
||||
voiceAuthorizeError.invoke()
|
||||
closeAuthorizeView()
|
||||
}
|
||||
|
||||
@@ -92,13 +91,12 @@ class AuthorizePresenter : Presenter<AuthorizeContract.View>, AuthorizeContract.
|
||||
mogoAuthShow.hideAuthorizeView()
|
||||
}
|
||||
|
||||
override fun onDestroy(owner: LifecycleOwner) {
|
||||
super.onDestroy(owner)
|
||||
fun onDestroy() {
|
||||
Logger.d(TAG, "onDestroy invokeTag : $invokeTag")
|
||||
mogoAuthShow.resetShowStatus()
|
||||
invokeTag?.let {
|
||||
MogoAuthorizeRegisterHandler.getAuthorizeContentListener(it)?.requestContentFailed("user exit authorize --- onDestroy")
|
||||
MogoAuthorizeRegisterHandler.getAuthorizeListener(it)?.authorizeFailed("user exit authorize --- onDestroy")
|
||||
}
|
||||
mogoAuthShow.hideAuthorizeView()
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,18 @@
|
||||
package com.mogo.module.authorize.fragment
|
||||
package com.mogo.module.authorize.layout
|
||||
|
||||
import android.os.Bundle
|
||||
import android.text.Html
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.Button
|
||||
import android.widget.TextView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.mogo.commons.mvp.MvpFragment
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.module.authorize.R
|
||||
import com.mogo.module.authorize.util.AnalyticsUtil
|
||||
import com.mogo.module.authorize.util.AnalyticsUtil.INVOKE_TRACK_AUTHORIZE_CLICK
|
||||
import com.mogo.module.authorize.util.AnalyticsUtil.INVOKE_TRACK_AUTHORIZE_SHOW
|
||||
import com.mogo.module.authorize.voice.IVoiceCommandListener
|
||||
import com.mogo.module.authorize.voice.IVoiceAuthorizeIntentListener
|
||||
import com.mogo.module.authorize.voice.IVoiceCommandListener
|
||||
import com.mogo.module.authorize.voice.VoiceUtil
|
||||
import com.mogo.utils.logger.Logger
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -20,27 +20,19 @@ import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
class AuthorizeFragment : MvpFragment<AuthorizeContract.View, AuthorizePresenter>(), AuthorizeContract.View, View.OnClickListener, IVoiceCommandListener, IVoiceAuthorizeIntentListener {
|
||||
class AuthorizeLayout(private val invokeTag: String) : View.OnClickListener, IVoiceCommandListener, IVoiceAuthorizeIntentListener {
|
||||
|
||||
companion object {
|
||||
const val TAG = "AuthorizeFragment"
|
||||
private const val INVOKE = "INVOKE"
|
||||
|
||||
fun newInstance(invokeTag: String): AuthorizeFragment {
|
||||
val fragment = AuthorizeFragment()
|
||||
val args = Bundle()
|
||||
args.putString(INVOKE, invokeTag)
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
const val TAG = "AuthorizeLayout"
|
||||
}
|
||||
|
||||
private var agreementId: Long = 0L
|
||||
private var invokeTag: String? = null
|
||||
|
||||
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
|
||||
@@ -49,33 +41,35 @@ class AuthorizeFragment : MvpFragment<AuthorizeContract.View, AuthorizePresenter
|
||||
private var tvButtonContent: TextView? = null
|
||||
private var tvLastContent: TextView? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
arguments?.let {
|
||||
invokeTag = it.getString(INVOKE)
|
||||
}
|
||||
private lateinit var layoutInflater: View
|
||||
private var authorizeController: AuthorizeController? = null
|
||||
|
||||
fun getLayoutView(): View {
|
||||
layoutInflater = LayoutInflater.from(AbsMogoApplication.getApp().applicationContext).inflate(getLayoutId(), null)
|
||||
initViews(layoutInflater)
|
||||
return layoutInflater
|
||||
}
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
private fun getLayoutId(): Int {
|
||||
return R.layout.module_authorize_fragment
|
||||
}
|
||||
|
||||
override fun initViews() {
|
||||
private fun initViews(mRootView: View) {
|
||||
Logger.d(TAG, "initView ")
|
||||
AnalyticsUtil.track(INVOKE_TRACK_AUTHORIZE_SHOW)
|
||||
init()
|
||||
init(mRootView)
|
||||
Logger.d(TAG, "invokeTag :$invokeTag")
|
||||
VoiceUtil.registerAll(context!!, this, this)
|
||||
authorizeController = AuthorizeController(invokeTag)
|
||||
invokeAuthorizationContent()
|
||||
VoiceUtil.registerAll(this, this)
|
||||
}
|
||||
|
||||
private fun init() {
|
||||
if (mRootView == null) {
|
||||
Logger.d(TAG, "joker ?")
|
||||
mRootView = view
|
||||
}
|
||||
private fun init(mRootView: View) {
|
||||
clTopParent = mRootView.findViewById(R.id.clAuthorizeTopParent)
|
||||
clErrorContainer = mRootView.findViewById(R.id.clLoadingErrorContainer)
|
||||
clLoadAuthorizeContainer = mRootView.findViewById(R.id.clLoadingAuthorizeContainer)
|
||||
clContainer = mRootView.findViewById(R.id.clAuthorizeContainer)
|
||||
clAuthorizeLoading = mRootView.findViewById(R.id.clAuthorizeLoading)
|
||||
btnAgree = mRootView.findViewById(R.id.btnAuthorizeAgree)
|
||||
btnDisAgree = mRootView.findViewById(R.id.btnAuthorizeDisAgree)
|
||||
btnLoadingError = mRootView.findViewById(R.id.btnAuthorizeLoadingError)
|
||||
@@ -86,32 +80,32 @@ class AuthorizeFragment : MvpFragment<AuthorizeContract.View, AuthorizePresenter
|
||||
btnAgree?.setOnClickListener(this)
|
||||
btnDisAgree?.setOnClickListener(this)
|
||||
btnLoadingError?.setOnClickListener(this)
|
||||
clTopParent?.setOnClickListener(this)
|
||||
clContainer?.setOnClickListener(this)
|
||||
clErrorContainer?.setOnClickListener(this)
|
||||
clLoadAuthorizeContainer?.setOnClickListener(this)
|
||||
clAuthorizeLoading?.setOnClickListener(this)
|
||||
}
|
||||
|
||||
override fun createPresenter(): AuthorizePresenter {
|
||||
return AuthorizePresenter(invokeTag!!, this)
|
||||
}
|
||||
|
||||
override fun readyToAuthorize() {
|
||||
private fun readyToAuthorize() {
|
||||
clErrorContainer?.visibility = View.GONE
|
||||
clLoadAuthorizeContainer?.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
override fun showAuthorizationAgreementContent(
|
||||
private fun showAuthorizationAgreementContent(
|
||||
agreementId: Long,
|
||||
agreementContent: String,
|
||||
agreementTitle: String,
|
||||
agreementBottom: String,
|
||||
agreementLast: String) {
|
||||
VoiceUtil.speak(context!!.resources.getString(R.string.module_authorize_agreement_tip), context!!, this)
|
||||
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){
|
||||
withContext(Dispatchers.Main) {
|
||||
tvContent?.text = spannable
|
||||
}
|
||||
}
|
||||
@@ -119,45 +113,67 @@ class AuthorizeFragment : MvpFragment<AuthorizeContract.View, AuthorizePresenter
|
||||
tvLastContent?.text = Html.fromHtml(agreementLast)
|
||||
}
|
||||
|
||||
override fun showAuthorizationError() {
|
||||
private fun showAuthorizationError() {
|
||||
clLoadAuthorizeContainer?.visibility = View.GONE
|
||||
clErrorContainer?.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
override fun voiceAuthorizeError() {
|
||||
VoiceUtil.speak(context!!.getString(R.string.module_authorize_failed), context!!, this)
|
||||
private fun voiceAuthorizeError() {
|
||||
VoiceUtil.speak(AbsMogoApplication.getApp().applicationContext.getString(R.string.module_authorize_failed), AbsMogoApplication.getApp().applicationContext, this)
|
||||
Logger.d(TAG, "onDestroy")
|
||||
VoiceUtil.unregisterAll(AbsMogoApplication.getApp().applicationContext, this)
|
||||
}
|
||||
|
||||
override fun onClick(v: View) {
|
||||
when (v.id) {
|
||||
R.id.btnAuthorizeAgree -> {
|
||||
AnalyticsUtil.track(INVOKE_TRACK_AUTHORIZE_CLICK, hashMapOf("operation_type" to 1, "operation_result" to 1))
|
||||
mPresenter.agreeAuthorize(invokeTag!!, agreementId)
|
||||
agreeAuthorize()
|
||||
}
|
||||
R.id.btnAuthorizeDisAgree -> {
|
||||
AnalyticsUtil.track(INVOKE_TRACK_AUTHORIZE_CLICK, hashMapOf("operation_type" to 1, "operation_result" to 2))
|
||||
mPresenter.disAgreeAuthorize(invokeTag!!, agreementId)
|
||||
disAgreeAuthorize()
|
||||
}
|
||||
R.id.clLoadingErrorContainer, R.id.btnAuthorizeLoadingError -> {
|
||||
mPresenter.invokeAuthorizationContent(invokeTag!!)
|
||||
invokeAuthorizationContent()
|
||||
}
|
||||
R.id.clAuthorizeTopParent-> {
|
||||
Logger.i(TAG,"dismiss authorizeView")
|
||||
authorizeController?.onDestroy()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onVoiceCmdAgree() {
|
||||
AnalyticsUtil.track(INVOKE_TRACK_AUTHORIZE_CLICK, hashMapOf("operation_type" to 2, "operation_result" to 1))
|
||||
mPresenter.agreeAuthorize(invokeTag!!, agreementId)
|
||||
agreeAuthorize()
|
||||
}
|
||||
|
||||
override fun onVoiceCmdDisAgree() {
|
||||
AnalyticsUtil.track(INVOKE_TRACK_AUTHORIZE_CLICK, hashMapOf("operation_type" to 2, "operation_result" to 2))
|
||||
mPresenter.disAgreeAuthorize(invokeTag!!, agreementId)
|
||||
disAgreeAuthorize()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
Logger.d(TAG, "onDestroy")
|
||||
VoiceUtil.unregisterAll(context!!, this)
|
||||
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()
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.mogo.module.authorize.voice
|
||||
|
||||
import android.content.Context
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.commons.voice.AIAssist
|
||||
import com.mogo.service.IMogoServiceApis
|
||||
import com.mogo.service.MogoServicePaths
|
||||
@@ -39,9 +40,8 @@ object VoiceUtil {
|
||||
}
|
||||
|
||||
fun registerAll(
|
||||
context: Context,
|
||||
voiceCommand: IVoiceCommandListener,
|
||||
intentCommand: IVoiceAuthorizeIntentListener
|
||||
intentCommand: IVoiceAuthorizeIntentListener, context: Context = AbsMogoApplication.getApp().applicationContext
|
||||
) {
|
||||
if (!hasRegister) {
|
||||
hasRegister = true
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/clAuthorizeTopParent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#CC000000">
|
||||
@@ -19,6 +20,7 @@
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/clAuthorizeLoading"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
|
||||
Reference in New Issue
Block a user