This commit is contained in:
unknown
2020-03-31 16:41:18 +08:00
parent 6fc9985ad2
commit 91dbfe1862
14 changed files with 190 additions and 91 deletions

View File

@@ -21,6 +21,10 @@ public class GuideShowLauncher extends BaseAppLauncher {
Logger.d(TAG, s);
return Unit.INSTANCE;
});
}else{
if ( getNext() != null ) {
getNext().launch( context, appInfo );
}
}
}

View File

@@ -1,8 +1,8 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.alibaba.arouter'
apply plugin: 'kotlin-kapt'
apply plugin: 'android-aspectjx'
android {

View File

@@ -1,3 +1,3 @@
GROUP=com.mogo.module
POM_ARTIFACT_ID=module-authorize
VERSION_CODE=1
VERSION_CODE=1

View File

@@ -3,6 +3,7 @@ package com.mogo.module.authorize.authprovider.biz
import com.mogo.module.authorize.authprovider.invoke.IMogoAuthorizeContentListener
import com.mogo.module.authorize.model.BaseResponse
import com.mogo.module.authorize.model.IMogoAuthorizeModel
import com.mogo.module.authorize.model.bean.Agreement
import com.mogo.module.authorize.model.bean.AgreementData
import com.mogo.module.authorize.net.request
import com.mogo.module.authorize.util.DateUtil.parseDateToTime
@@ -19,6 +20,20 @@ open class IMogoAuthorizeController {
private val authorizeModel: IMogoAuthorizeModel by lazy { IMogoAuthorizeModel() }
fun getAuthorizeContent(onStart: () -> Unit, onSuccess: (Agreement) -> Unit, onError: (String) -> Unit) {
realInvokeAuthorizeContent(0, {
onStart.invoke()
}, {
if (it.result != null && it.result.agreement.agreementContent != null) {
onSuccess.invoke(it.result.agreement)
} else {
onError.invoke("data is null")
}
}, { msg: String ->
onError.invoke(msg)
})
}
fun invokeAuthorizeContent(tag: String, agreementType: Int) {
realInvokeAuthorizeContent(agreementType, {
if (agreementType == -1) {
@@ -88,8 +103,8 @@ open class IMogoAuthorizeController {
if (hasNewVersion(currentTime)) {
updateAuthorizeVersion(currentTime)
setAuthorizeStatus(agreementType, false)
}else{
Logger.d(TAG,"no new version")
} else {
Logger.d(TAG, "no new version")
}
}
}, { s: String ->

View File

@@ -92,8 +92,8 @@ class MogoMainAuthorize private constructor() : MogoAuthorizeManagerImpl(), IMog
}
private inline fun pushFragmentToMainView(tag: String, push: (() -> Unit)) {
val builderWrapper = FragmentDescriptor.Builder().fragment(AuthorizeFragment(tag))
.tag(PATH_AGREEMENT_MODULE_NAME).build()
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) {

View File

@@ -1,5 +1,6 @@
package com.mogo.module.authorize.fragment
import android.os.Bundle
import android.text.Html
import android.view.View
import android.widget.Button
@@ -15,52 +16,77 @@ import com.mogo.module.authorize.voice.IVoiceIntentListener
import com.mogo.module.authorize.voice.VoiceUtil
import com.mogo.utils.logger.Logger
class AuthorizeFragment(private val invokeTag: String) : MvpFragment<AuthorizeContract.View, AuthorizePresenter>(), AuthorizeContract.View, View.OnClickListener, IVoiceCommandListener, IVoiceIntentListener {
class AuthorizeFragment : MvpFragment<AuthorizeContract.View, AuthorizePresenter>(), AuthorizeContract.View, View.OnClickListener, IVoiceCommandListener, IVoiceIntentListener {
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
}
}
private var agreementId: Long = 0L
private var invokeTag:String? = null
private var clErrorContainer:ConstraintLayout? = null
private var clLoadAuthorizeContainer:ConstraintLayout? = null
private var clContainer: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 clErrorContainer: ConstraintLayout? = null
private var clLoadAuthorizeContainer: ConstraintLayout? = null
private var clContainer: 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
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
arguments?.let {
invokeTag = it.getString(INVOKE)
}
}
override fun getLayoutId(): Int {
return R.layout.module_authorize_fragment
}
override fun initViews() {
Logger.d(TAG,"initView : ${this.hashCode()}")
Logger.d(TAG, "initView : ${this.javaClass.hashCode()}")
AnalyticsUtil.track(INVOKE_TRACK_AUTHORIZE_SHOW)
clErrorContainer = this.findViewById(R.id.clLoadingErrorContainer)
clLoadAuthorizeContainer = this.findViewById(R.id.clLoadingAuthorizeContainer)
clContainer = this.findViewById(R.id.clAuthorizeContainer)
btnAgree = this.findViewById(R.id.btnAuthorizeAgree)
btnDisAgree = this.findViewById(R.id.btnAuthorizeDisAgree)
btnLoadingError = this.findViewById(R.id.btnAuthorizeLoadingError)
tvTitle = this.findViewById(R.id.tvAuthorizeTitle)
tvContent = this.findViewById(R.id.tvAuthorizeContent)
tvButtonContent = this.findViewById(R.id.tvAuthorizeButtonContent)
tvLastContent = this.findViewById(R.id.tvAuthorizeLastContent)
btnAgree?.setOnClickListener(this)
btnDisAgree?.setOnClickListener(this)
btnLoadingError?.setOnClickListener(this)
clErrorContainer?.setOnClickListener(this)
init()
Logger.d(TAG, "invokeTag :$invokeTag")
VoiceUtil.registerAll(context!!, this, this)
}
private fun init(){
if(mRootView == null){
Logger.d(TAG,"joker ?")
mRootView = view
}
clErrorContainer = mRootView.findViewById(R.id.clLoadingErrorContainer)
clLoadAuthorizeContainer = mRootView.findViewById(R.id.clLoadingAuthorizeContainer)
clContainer = mRootView.findViewById(R.id.clAuthorizeContainer)
btnAgree = mRootView.findViewById(R.id.btnAuthorizeAgree)
btnDisAgree = mRootView.findViewById(R.id.btnAuthorizeDisAgree)
btnLoadingError = mRootView.findViewById(R.id.btnAuthorizeLoadingError)
tvTitle = mRootView.findViewById(R.id.tvAuthorizeTitle)
tvContent = mRootView.findViewById(R.id.tvAuthorizeContent)
tvButtonContent = mRootView.findViewById(R.id.tvAuthorizeButtonContent)
tvLastContent = mRootView.findViewById(R.id.tvAuthorizeLastContent)
btnAgree?.setOnClickListener(this)
btnDisAgree?.setOnClickListener(this)
btnLoadingError?.setOnClickListener(this)
clErrorContainer?.setOnClickListener(this)
}
override fun createPresenter(): AuthorizePresenter {
return AuthorizePresenter(invokeTag, this)
return AuthorizePresenter(invokeTag!!, this)
}
override fun readyToAuthorize() {
@@ -75,9 +101,10 @@ class AuthorizeFragment(private val invokeTag: String) : MvpFragment<AuthorizeCo
agreementBottom: String,
agreementLast: String) {
VoiceUtil.speak(context!!.resources.getString(R.string.module_authorize_agreement_tip), context!!, this)
this.agreementId = agreementId
init()
clLoadAuthorizeContainer?.visibility = View.GONE
clContainer?.visibility = View.VISIBLE
this.agreementId = agreementId
tvTitle?.text = Html.fromHtml(agreementTitle)
tvContent?.text = Html.fromHtml(agreementContent)
tvButtonContent?.text = Html.fromHtml(agreementBottom)
@@ -93,31 +120,31 @@ class AuthorizeFragment(private val invokeTag: String) : MvpFragment<AuthorizeCo
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)
mPresenter.agreeAuthorize(invokeTag!!, agreementId)
}
R.id.btnAuthorizeDisAgree -> {
AnalyticsUtil.track(INVOKE_TRACK_AUTHORIZE_CLICK, hashMapOf("operation_type" to 1, "operation_result" to 2))
mPresenter.disAgreeAuthorize(invokeTag, agreementId)
mPresenter.disAgreeAuthorize(invokeTag!!, agreementId)
}
R.id.clLoadingErrorContainer, R.id.btnAuthorizeLoadingError -> {
mPresenter.invokeAuthorizationContent(invokeTag)
mPresenter.invokeAuthorizationContent(invokeTag!!)
}
}
}
override fun onVoiceCmdAgree() {
AnalyticsUtil.track(INVOKE_TRACK_AUTHORIZE_CLICK, hashMapOf("operation_type" to 2, "operation_result" to 1))
mPresenter.agreeAuthorize(invokeTag, agreementId)
mPresenter.agreeAuthorize(invokeTag!!, agreementId)
}
override fun onVoiceCmdDisAgree() {
AnalyticsUtil.track(INVOKE_TRACK_AUTHORIZE_CLICK, hashMapOf("operation_type" to 2, "operation_result" to 2))
mPresenter.disAgreeAuthorize(invokeTag, agreementId)
mPresenter.disAgreeAuthorize(invokeTag!!, agreementId)
}
override fun onDestroy() {
super.onDestroy()
Logger.d(TAG,"onDestroy")
Logger.d(TAG, "onDestroy")
VoiceUtil.unregisterAll(context!!, this)
}

View File

@@ -3,14 +3,14 @@ package com.mogo.module.authorize.fragment
import androidx.lifecycle.LifecycleOwner
import com.mogo.commons.mvp.Presenter
import com.mogo.module.authorize.authprovider.biz.MogoAuthorizeRegisterHandler
import com.mogo.module.authorize.authprovider.invoke.IMogoAuthorizeContentListener
import com.mogo.module.authorize.authprovider.launcher.MogoAuthorizeMainController
import com.mogo.module.authorize.authprovider.launcher.MogoMainAuthorize.Companion.mogoAuthShow
import com.mogo.module.authorize.model.bean.Agreement
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, IMogoAuthorizeContentListener {
class AuthorizePresenter : Presenter<AuthorizeContract.View>, AuthorizeContract.Biz {
companion object {
const val TAG = "AuthorizePresenter"
@@ -32,13 +32,16 @@ class AuthorizePresenter : Presenter<AuthorizeContract.View>, AuthorizeContract.
override fun invokeAuthorizationContent(invokeTag: String) {
mView.readyToAuthorize()
this.invokeTag = invokeTag
if (!mogoAuthShow.hasRegister(invokeTag)) {
mogoAuthShow.registerInvokeAuthorizeContentListener(invokeTag, this)
}
mogoAuthShow.invokeAuthorizeContent(invokeTag)
MogoAuthorizeMainController.getAuthorizeContent({
Logger.d(TAG, "ready to get Authorize Content")
}, {
getContentSuccess(it)
}, { msg: String ->
getContentFailed(msg)
})
}
override fun requestContentSuccess(userAgreement: Agreement) {
private fun getContentSuccess(userAgreement: Agreement) {
Logger.d(TAG, "requestContentSuccess userAgreement:$userAgreement")
if (userAgreement?.agreementContent != null && userAgreement?.agreementContent.isNotEmpty()) {
val id = userAgreement.tUserAgreementEntity.id
@@ -55,7 +58,7 @@ class AuthorizePresenter : Presenter<AuthorizeContract.View>, AuthorizeContract.
}
}
override fun requestContentFailed(errorMsg: String) {
private fun getContentFailed(errorMsg: String) {
Logger.d(TAG, "requestContentFailed errorMsg:$errorMsg")
mView.showAuthorizationError()
}

View File

@@ -10,8 +10,7 @@ object SharedPreferenceUtil {
private const val AUTHORIZE_UPDATE_TIME = "AUTHORIZE_UPDATE_TIME"
fun needAuthorization(type: Int): Boolean {
// return !hasAuth(type) //todo test
return false
return !hasAuth(type)
}
fun hasAuth(type: Int): Boolean {

View File

@@ -0,0 +1,53 @@
package com.mogo.module.authorize.view
import android.content.Context
import android.graphics.Canvas
import android.graphics.Paint
import android.util.AttributeSet
import android.widget.TextView
class AutoSplitTextView : TextView {
private var textShowWidth: Float = 0f
private var paint: Paint? = null
constructor(context: Context?) : super(context, null)
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) {
init()
}
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
init()
}
private fun init() {
paint = Paint()
}
override fun onDraw(canvas: Canvas) {
super.onDraw(canvas)
textShowWidth = (this.measuredWidth - paddingLeft - paddingRight).toFloat()
var lineCount = 0
if (text.toString().isNullOrBlank()) return
val textCharArray = text.toString().toCharArray()
var drawWidth = 0f
var charWidth: Float
for (i in 0..textCharArray.size) {
charWidth = paint!!.measureText(textCharArray, i, 1)
if (textCharArray[i] == '\n') {
lineCount++
drawWidth = 0f
continue
}
if (textShowWidth - drawWidth < charWidth) {
lineCount++
drawWidth = 0f
}
canvas.drawText(textCharArray, i, 1, paddingLeft + drawWidth, (lineCount + 1) * textSize, paint)
drawWidth += charWidth
}
height = (lineCount + 1) * textSize as Int
}
}

View File

@@ -28,13 +28,13 @@ class VoiceForbiddenWhenGuide {
@Before("authorizeTrackPoint()")
fun trackVoiceWhenAuthorize(joinPoint: ProceedingJoinPoint) {
Logger.d(TAG, "trackVoiceWhenAuthorize")
val msg = joinPoint.args[0] as String
if (SharedPreferenceUtil.hasGuide()) {
Logger.d(TAG, "proceed,no interception")
joinPoint.proceed()
} else {
return
}
// Logger.d(TAG, "trackVoiceWhenAuthorize")
// val msg = joinPoint.args[0] as String
// if (SharedPreferenceUtil.hasGuide()) {
// Logger.d(TAG, "proceed,no interception")
// joinPoint.proceed()
// } else {
// return
// }
}
}

View File

@@ -64,7 +64,6 @@ public class MogoReceiver extends BroadcastReceiver {
mMogoIntentManager = (IMogoIntentManager) ARouter.getInstance().build(MogoServicePaths.PATH_INTENT_MANAGER).navigation(context);
}
@VoiceIntentTrack
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();