Merge remote-tracking branch 'origin/feature/v1.0.3' into feature/v1.0.3

This commit is contained in:
zhangyuanzhen
2020-03-30 10:11:54 +08:00
32 changed files with 542 additions and 288 deletions

2
.idea/misc.xml generated
View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<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>

View File

@@ -98,6 +98,8 @@ dependencies {
// implementation rootProject.ext.dependencies.moduledemo2
implementation rootProject.ext.dependencies.carcallprovider
implementation rootProject.ext.dependencies.carcall
implementation rootProject.ext.dependencies.guideshowprovider
implementation rootProject.ext.dependencies.guideshow
implementation rootProject.ext.dependencies.modulemedia
implementation rootProject.ext.dependencies.modulefreshnews,{
exclude group:'com.mogo.module',module:'module-onlinecar'
@@ -121,6 +123,7 @@ dependencies {
implementation rootProject.ext.dependencies.modulesearch
implementation rootProject.ext.dependencies.mogomoduleback
implementation rootProject.ext.dependencies.mogomoduleguide
implementation rootProject.ext.dependencies.mogomoduleauth
} else {
implementation project(':modules:mogo-module-main')
implementation project(':foudations:mogo-commons')
@@ -128,6 +131,7 @@ dependencies {
implementation project(':modules:mogo-module-search')
implementation project(':modules:mogo-module-back')
implementation project(':modules:mogo-module-guide')
implementation project(':modules:mogo-module-authorize')
}
}

View File

@@ -15,6 +15,7 @@ import com.mogo.module.back.BackToLauncherConst;
import com.mogo.module.carchatting.card.CallChatConstant;
import com.mogo.module.common.MogoModule;
import com.mogo.module.common.MogoModulePaths;
import com.mogo.module.guideshow.provider.GuideShowProviderConstant;
import com.mogo.module.media.MediaConstants;
import com.mogo.module.onlinecar.OnLineCarConstants;
import com.mogo.module.push.PushUIConstants;
@@ -25,8 +26,10 @@ import com.mogo.service.connection.IMogoSocketManager;
import com.mogo.utils.logger.LogLevel;
import com.mogo.utils.logger.Logger;
import static com.mogo.module.guide.GuideConstant.PATH_GUIDE_AGREEMENT_FRAGMENT;
import static com.mogo.module.guide.GuideConstant.PATH_GUIDE_AGREEMENT_MODULE_NAME;
import static com.mogo.module.authorize.authprovider.invoke.AuthorizeConstant.PATH_AGREEMENT_FRAGMENT;
import static com.mogo.module.authorize.authprovider.invoke.AuthorizeConstant.PATH_AGREEMENT_MODULE_NAME;
import static com.mogo.module.guide.GuideConstant.PATH_GUIDE_FRAGMENT;
import static com.mogo.module.guide.GuideConstant.PATH_GUIDE_MODULE_NAME;
/**
* @author congtaowang
@@ -47,7 +50,10 @@ public class MogoApplication extends AbsMogoApplication {
crashSystem.setDebug(BuildConfig.DEBUG);
Logger.init(BuildConfig.DEBUG ? LogLevel.DEBUG : LogLevel.OFF);
MogoModulePaths.addModule(new MogoModule(PATH_GUIDE_AGREEMENT_FRAGMENT, PATH_GUIDE_AGREEMENT_MODULE_NAME));
MogoModulePaths.addModule(new MogoModule(PATH_GUIDE_FRAGMENT, PATH_GUIDE_MODULE_NAME));
MogoModulePaths.addModule(new MogoModule(PATH_AGREEMENT_FRAGMENT, PATH_AGREEMENT_MODULE_NAME));
MogoModulePaths.addModule(new MogoModule(GuideShowProviderConstant.PATH_GUIDE_SHOW_FRAGMENT, GuideShowProviderConstant.PATH_GUIDE_SHOW_MODULE_NAME));
//运营位卡片,需要默认显示,放在第一个加载
MogoModulePaths.addModule(new MogoModule(AdCardConstants.TAG, AdCardConstants.MODULE_NAME));
MogoModulePaths.addModule(new MogoModule(MediaConstants.TAG, MediaConstants.MODULE_TYPE));

View File

@@ -96,6 +96,8 @@ ext {
moduleextensions : "com.mogo.module:module-extensions:${MOGO_MODULE_EXTENSIONS_VERSION}",
carcall : "com.mogo.module.carchatting:module-carchatting:${CARCHATTING_VERSION}",
carcallprovider : "com.mogo.module.carchatting:module-carchatting-provider:${CARCHATTINGPROVIDER_VERSION}",
guideshow : "com.mogo.module.guideshow:module-guideshow:${MOGO_MODULE_GUIDESHOW_VERSION}",
guideshowprovider : "com.mogo.module.guideshow:module-guideshow-provider:${MOGO_MODULE_GUIDESHOW_PROVIDER_VERSION}",
// 在线车辆
moduleonlinecar : "com.mogo.module:module-onlinecar:${MOGO_MODULE_ONLINECAR_VERSION}",
// V2X

View File

@@ -55,6 +55,10 @@ MOGO_MODULE_TANLU_VERSION=1.0.3-SNAPSHOT
CARCHATTING_VERSION=1.0.2.3-SNAPSHOT
# 车聊聊接口
CARCHATTINGPROVIDER_VERSION=1.0.2.3-SNAPSHOT
# 视频引导
MOGO_MODULE_GUIDESHOW_VERSION=1.0.0-SNAPSHOT
# 视频引导接口
MOGO_MODULE_GUIDESHOW_PROVIDER_VERSION=1.0.1-SNAPSHOT
# 在线车辆F
MOGO_MODULE_ONLINECAR_VERSION=1.0.2-SNAPSHOT
# v2x

View File

@@ -570,6 +570,7 @@ public class AMapNaviViewWrapper implements IMogoMapView,
if ( DebugConfig.isDebug() ) {
Logger.d( TAG, Log.getStackTraceString( new Throwable() ) );
}
Logger.d( TAG, "解锁锁车" );
mockTouchEvent();
}

View File

@@ -89,7 +89,6 @@ public class MogoMapUtils {
south = tmp;
}
Logger.d( TAG, "west = %s, east = %s, north = %s, south = %s", west, east, north, south );
return new LatLngBounds.Builder().include( new LatLng( east, north ) ).include( new LatLng( west, south ) ).build();

View File

@@ -5,6 +5,10 @@ import com.mogo.module.authorize.model.BaseResponse
import com.mogo.module.authorize.model.IMogoAuthorizeModel
import com.mogo.module.authorize.model.bean.AgreementData
import com.mogo.module.authorize.net.request
import com.mogo.module.authorize.util.DateUtil.parseDateToTime
import com.mogo.module.authorize.util.SharedPreferenceUtil.getAuthorizeVersion
import com.mogo.module.authorize.util.SharedPreferenceUtil.setAuthorizeStatus
import com.mogo.module.authorize.util.SharedPreferenceUtil.updateAuthorizeVersion
import com.mogo.utils.logger.Logger
open class IMogoAuthorizeController {
@@ -16,40 +20,51 @@ open class IMogoAuthorizeController {
private val authorizeModel: IMogoAuthorizeModel by lazy { IMogoAuthorizeModel() }
fun invokeAuthorizeContent(tag: String, agreementType: Int) {
if (agreementType == -1) {
realInvokeAuthorizeContent(agreementType, {
if (agreementType == -1) {
getAuthorizeContentListener(tag, { listener ->
listener.requestContentFailed("invokeAuthorizeContent param tag is not right")
}, {
Logger.d(TAG, "invokeAuthorizeContent ---checkAgreementType can not find tag :$tag")
})
}
}, {
getAuthorizeContentListener(tag, { listener ->
listener.requestContentFailed("invokeAuthorizeContent param tag is not right")
if (it.result != null && it.result.agreement.agreementContent != null) {
listener.requestContentSuccess(it.result.agreement)
} else {
listener.requestContentFailed("request authorize content success ,but result data is :${it.result}")
}
}, {
Logger.d(TAG, "invokeAuthorizeContent ---checkAgreementType can not find tag :$tag")
Logger.d(TAG, "invokeAuthorizeContent --- can not find listener by this tag :$tag")
})
}
}, { msg: String ->
getAuthorizeContentListener(tag, { listener ->
listener.requestContentFailed(msg)
}, {
Logger.d(TAG, "invokeAuthorizeContent --- can not find listener by this tag :$tag")
})
})
}
private fun realInvokeAuthorizeContent(agreementType: Int, onStart: (() -> Unit), onSuccess: ((BaseResponse<AgreementData>) -> Unit), onError: ((String) -> Unit)) {
onStart.invoke()
try {
request<BaseResponse<AgreementData>> {
loader {
authorizeModel.invokeAuthorizeContent(agreementType)
}
onSuccess {
getAuthorizeContentListener(tag, { listener ->
if (it.result != null && it.result.agreement.agreementContent != null) {
listener.requestContentSuccess(it.result.agreement)
} else {
listener.requestContentFailed("request authorize content success ,but result data is :${it.result}")
}
}, {
Logger.d(TAG, "invokeAuthorizeContent --- can not find listener by this tag :$tag")
})
onSuccess.invoke(it)
}
onError {
getAuthorizeContentListener(tag, { listener ->
listener.requestContentFailed(it.message
?: "request authorize content failedplease check network")
}, {
Logger.d(TAG, "invokeAuthorizeContent --- can not find listener by this tag :$tag")
})
onError.invoke(it.message
?: "realInvokeAuthorizeContent onError, message is null")
}
}
} catch (e: Exception) {
e.printStackTrace()
onError.invoke(e.message ?: "realInvokeAuthorizeContent has exception, message is null")
}
}
@@ -62,4 +77,28 @@ open class IMogoAuthorizeController {
}
}
fun updateAgreementVersion(agreementType: Int) {
realInvokeAuthorizeContent(agreementType, {
Logger.d(TAG, "ready to update agreement")
}, {
if (it.result != null) {
val agreement = it.result.agreement
val updateTime = agreement.tUserAgreementEntity.updateTime
val currentTime = parseDateToTime(updateTime)
if (hasNewVersion(currentTime)) {
updateAuthorizeVersion(currentTime)
setAuthorizeStatus(agreementType, false)
}else{
Logger.d(TAG,"no new version")
}
}
}, { s: String ->
Logger.d(TAG, "updateAgreementAndAuthorization reason:$s")
})
}
private fun hasNewVersion(currentTime: Long): Boolean {
val oldVersion = getAuthorizeVersion()
return currentTime > oldVersion
}
}

View File

@@ -4,23 +4,29 @@ import com.mogo.module.authorize.authprovider.invoke.IMogoAuthorizeContentListen
import com.mogo.module.authorize.authprovider.invoke.IMogoAuthorizeInvoke
import com.mogo.module.authorize.authprovider.module.IMogoAcquireAuthorizeListener
import com.mogo.module.authorize.model.proxy.AuthorizeProxy
import com.mogo.module.authorize.model.proxy.toAuthorizeType
import com.mogo.module.authorize.util.SharedPreferenceUtil.needAuthorization
import com.mogo.utils.logger.Logger
open abstract class MogoAuthorizeManagerImpl : IMogoAuthorizeInvoke {
companion object {
const val TAG = "AuthorizeManagerImpl"
}
private val baseController: IMogoAuthorizeController by lazy { IMogoAuthorizeController() }
override fun needAuthorize(): Boolean {
return needAuthorization()
override fun needAuthorize(tag: String): Boolean {
Logger.d(TAG, "needAuthorize update agreement in background")
baseController.updateAgreementVersion(tag.toAuthorizeType())
return needAuthorization(tag.toAuthorizeType())
}
override fun invokeAuthorizeContent(tag: String) {
//todo 后面动态代理统一处理校验问题
Logger.d("invokeAuthorizeContent","tag:$tag")
Logger.d(TAG, "tag:$tag")
val agreementType = AuthorizeProxy.getAuthorizeType(tag)
Logger.d("invokeAuthorizeContent","agreementType:$agreementType")
Logger.d(TAG, "agreementType:$agreementType")
baseController.invokeAuthorizeContent(tag, agreementType)
}
@@ -33,7 +39,7 @@ open abstract class MogoAuthorizeManagerImpl : IMogoAuthorizeInvoke {
}
override fun registerAuthorizeListener(tag: String, listener: IMogoAcquireAuthorizeListener) {
Logger.d("AuthorizeManager", "registerAuthorize tag : $tag listener:$listener")
Logger.d(TAG, "registerAuthorize tag : $tag listener:$listener")
MogoAuthorizeRegisterHandler.registerAuthorizeListener(tag, listener)
}

View File

@@ -0,0 +1,80 @@
package com.mogo.module.authorize.authprovider.biz
import android.content.Context
import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
import com.alibaba.android.arouter.facade.annotation.Route
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.module.authorize.util.SharedPreferenceUtil.hasGuide
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 {
companion object {
const val TAG = "MogoAuthorizeProvider"
}
override fun createFragment(context: Context?, data: Bundle?): Fragment? {
return null
}
override fun createView(context: Context?): View? {
return null
}
override fun getModuleName(): String {
return PATH_AGREEMENT_MODULE_NAME
}
override fun getCardLifecycle(): IMogoModuleLifecycle? {
return null
}
override fun getMapListener(): IMogoMapListener? {
return null
}
override fun getType(): Int {
return ModuleType.TYPE_SERVICE
}
override fun getNaviListener(): IMogoNaviListener? {
return null
}
override fun getLocationListener(): IMogoLocationListener? {
return null
}
override fun getMarkerClickListener(): IMogoMarkerClickListener? {
return null
}
override fun init(context: Context?) {
if (hasGuide() && mogoAuthShow.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_MAIN)) {
mogoAuthShow.invokeAuthorizeForShow()
} else {
Logger.d(TAG, "wait for guide invoke")
}
}
override fun getAppPackage(): String? {
return null
}
override fun getAppName(): String? {
return null
}
}

View File

@@ -5,5 +5,15 @@ class AuthorizeConstant {
companion object{
const val PROVIDER_MODULE = "/authorize/biz"
const val PROVIDER_LAUNCHER = "/authorize/showbiz"
/**
* 展示用户协议模块地址
*/
const val PATH_AGREEMENT_FRAGMENT = "/agreement/showFragment"
/**
* provider模块实例名称(暂时仅有卡片用到)
*/
const val PATH_AGREEMENT_MODULE_NAME = "AGREEMENT_MODULE_NAME"
}
}

View File

@@ -8,7 +8,7 @@ interface IMogoAuthorizeInvoke : IMogoAuthorizeRegister {
/**
* 是否需要授权
*/
fun needAuthorize(): Boolean
fun needAuthorize(tag: String): Boolean
/**
* 获取授权内容

View File

@@ -13,8 +13,8 @@ class IMogoAuthorizeMainManager : IMogoAuthorizeMainProvider {
return mogoAuthShow.hasRegister(tag)
}
override fun needAuthorize(): Boolean {
return mogoAuthShow.needAuthorize()
override fun needAuthorize(tag: String): Boolean {
return mogoAuthShow.needAuthorize(tag)
}
override fun invokeAuthorizeContent(tag: String) {

View File

@@ -5,7 +5,9 @@ import com.mogo.module.authorize.authprovider.biz.MogoAuthorizeRegisterHandler
import com.mogo.module.authorize.model.BaseResponse
import com.mogo.module.authorize.model.bean.AGREEMENT_EFFECT
import com.mogo.module.authorize.model.bean.AGREEMENT_NOT_EFFECT
import com.mogo.module.authorize.model.proxy.toAuthorizeType
import com.mogo.module.authorize.net.request
import com.mogo.module.authorize.util.SharedPreferenceUtil.setAuthorizeStatus
import com.mogo.utils.logger.Logger
object MogoAuthorizeMainController : IMogoAuthorizeController() {
@@ -14,30 +16,27 @@ object MogoAuthorizeMainController : IMogoAuthorizeController() {
@Synchronized
fun agreeAuthorize(tag: String, agrId: Long, onSuccess: (() -> Unit), onError: ((String) -> Unit)) {
val acquireAuthListener = MogoAuthorizeRegisterHandler.getAuthorizeListener(tag)
updateAuthorize(agrId, AGREEMENT_EFFECT, {
if (acquireAuthListener != null) {
onSuccess.invoke()
acquireAuthListener.authorizeSuccess()
} else {
Logger.d(TAG, "agreeAuthorize --- can not find listener by this tag :$tag ")
}
authorizeSuccess(tag)
setAuthorizeStatus(tag.toAuthorizeType(), true)
onSuccess.invoke()
}, {
val errorMsg = it ?: "agreeAuthorize failed,please check network"
onError.invoke(errorMsg)
authorizeFailed(tag, errorMsg)
onError.invoke(errorMsg)
})
}
@Synchronized
fun disAgreeAuthorize(tag: String, agrId: Long, onSuccess: (() -> Unit), onError: ((String) -> Unit)) {
updateAuthorize(agrId, AGREEMENT_NOT_EFFECT, {
onSuccess.invoke()
authorizeFailed(tag, "UserDisAgree authorize")
onSuccess.invoke()
}, {
val errorMsg = it ?: "disAgreeAuthorize failed,please check network"
onError.invoke(errorMsg)
authorizeFailed(tag, errorMsg)
onError.invoke(errorMsg)
})
}
@@ -64,4 +63,12 @@ object MogoAuthorizeMainController : IMogoAuthorizeController() {
}
}
private fun authorizeSuccess(tag: String) {
val acquireAuthListener = MogoAuthorizeRegisterHandler.getAuthorizeListener(tag)
if (acquireAuthListener != null) {
acquireAuthListener.authorizeSuccess()
} else {
Logger.d(TAG, "agreeAuthorize --- can not find listener by this tag :$tag ")
}
}
}

View File

@@ -6,6 +6,7 @@ import com.mogo.module.authorize.authprovider.biz.MogoAuthorizeManagerImpl
import com.mogo.module.authorize.authprovider.biz.MogoAuthorizeRegisterHandler
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.model.proxy.toAuthorizeType
import com.mogo.module.authorize.util.SharedPreferenceUtil.hasAuth
import com.mogo.service.IMogoServiceApis
import com.mogo.service.MogoServicePaths
@@ -60,7 +61,7 @@ class MogoMainAuthorize private constructor() : MogoAuthorizeManagerImpl(), IMog
onError.invoke("invoke should be in main thread")
return
}
if (hasAuth()) {
if (hasAuth(tag.toAuthorizeType())) {
onError.invoke("already authorize,do not repeat operation")
return
}
@@ -87,17 +88,17 @@ class MogoMainAuthorize private constructor() : MogoAuthorizeManagerImpl(), IMog
Logger.d(TAG, "pushFragmentToMainView")
val mogoService = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation()
if (mogoService is IMogoServiceApis) {
push.invoke()
mogoService.fragmentManagerApi.push(builderWrapper)
}
push.invoke()
}
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()
}
pop.invoke()
}
}

View File

@@ -8,8 +8,8 @@ import com.mogo.module.authorize.authprovider.module.MogoModuleAuthorize.Compani
@Route(path = AuthorizeConstant.PROVIDER_MODULE)
class IMogoAuthorizeModuleManager : IMogoAuthorizeModuleProvider {
override fun needAuthorize(): Boolean {
return mogoAuth.needAuthorize()
override fun needAuthorize(tag: String): Boolean {
return mogoAuth.needAuthorize(tag)
}
override fun invokeAuthorizeForShow() {

View File

@@ -93,6 +93,7 @@ class AuthorizeFragment(private val invokeTag: String) : MvpFragment<AuthorizeCo
override fun onDestroy() {
super.onDestroy()
Logger.d(TAG,"onDestroy")
VoiceUtil.unregisterAll(context!!, this)
}

View File

@@ -2,9 +2,12 @@ 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.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 {
@@ -14,6 +17,7 @@ class AuthorizePresenter : Presenter<AuthorizeContract.View>, AuthorizeContract.
}
private var invokeTag: String? = null
private var updateTime: Long = 0L
constructor(invokeTag: String, view: AuthorizeContract.View?) : super(view) {
this.invokeTag = invokeTag
@@ -42,6 +46,9 @@ class AuthorizePresenter : Presenter<AuthorizeContract.View>, AuthorizeContract.
val title = userAgreement.tUserAgreementEntity.title
val bottomContent = userAgreement.tUserAgreementEntity.agreementButtonFirst
val lastContent = userAgreement.tUserAgreementEntity.agreementButtonSecond
val tmpUpdate = userAgreement.tUserAgreementEntity.updateTime
updateTime = parseDateToTime(tmpUpdate)
Logger.d(TAG, "updateTime ===== $updateTime")
mView.showAuthorizationAgreementContent(id, content, title, bottomContent, lastContent)
} else {
mView.showAuthorizationError()
@@ -50,15 +57,15 @@ class AuthorizePresenter : Presenter<AuthorizeContract.View>, AuthorizeContract.
override fun requestContentFailed(errorMsg: String) {
Logger.d(TAG, "requestContentFailed errorMsg:$errorMsg")
// mView.showAuthorizationAgreementContent(0, "123", "123456", "34234", "3543535")
mView.showAuthorizationError()
}
override fun agreeAuthorize(tag: String, agreementId: Long) {
mogoAuthShow.agreeAuthorize(tag, agreementId, {
Logger.d(TAG, "agreeAuthorize success")
updateAuthorizeVersion(updateTime)
closeAuthorizeView()
}, { s: String ->
}, {
Logger.d(TAG, "agreeAuthorize failed")
closeAuthorizeView()
})
@@ -67,7 +74,7 @@ class AuthorizePresenter : Presenter<AuthorizeContract.View>, AuthorizeContract.
override fun disAgreeAuthorize(tag: String, agreementId: Long) {
mogoAuthShow.disAgreeAuthorize(tag, agreementId, {
closeAuthorizeView()
}, { s: String ->
}, {
closeAuthorizeView()
})
}
@@ -80,8 +87,8 @@ class AuthorizePresenter : Presenter<AuthorizeContract.View>, AuthorizeContract.
super.onDestroy(owner)
Logger.d(TAG, "onDestroy invokeTag : $invokeTag")
invokeTag?.let {
mogoAuthShow.unregisterInvokeAuthorizeContentListener(it)
mogoAuthShow.unregisterAuthorizeListener(it)
MogoAuthorizeRegisterHandler.getAuthorizeContentListener(it)?.requestContentFailed("user exit authorize by back press")
MogoAuthorizeRegisterHandler.getAuthorizeListener(it)?.authorizeFailed("user exit authorize by back press")
}
}
}

View File

@@ -9,6 +9,11 @@ import com.mogo.module.authorize.authprovider.invoke.AuthorizeInvokerConstant.Co
import com.mogo.module.authorize.authprovider.invoke.AuthorizeInvokerConstant.Companion.AUTHORIZE_TYPE_NOVELTY
import com.mogo.module.authorize.authprovider.invoke.AuthorizeInvokerConstant.Companion.AUTHORIZE_TYPE_TAN_LU
fun String.toAuthorizeType(): Int {
return AuthorizeProxy.getAuthorizeType(this)
}
class AuthorizeProxy {
companion object {

View File

@@ -0,0 +1,11 @@
package com.mogo.module.authorize.util
import java.util.*
object DateUtil {
fun parseDateToTime(tmpDate: String): Long {
val time = Date(tmpDate)
return time.time
}
}

View File

@@ -6,16 +6,30 @@ import com.mogo.utils.storage.SharedPrefsMgr
object SharedPreferenceUtil {
private const val HAS_AUTH = "HAS_AUTH"
private const val HAS_GUIDE = "HAS_GUIDE"
private const val AUTHORIZE_UPDATE_TIME = "AUTHORIZE_UPDATE_TIME"
fun needAuthorization(): Boolean {
return !hasAuth()
fun needAuthorization(type: Int): Boolean {
return !hasAuth(type)
}
fun hasAuth(): Boolean {
return SharedPrefsMgr.getInstance(AbsMogoApplication.getApp()).getBoolean(HAS_AUTH, false)
fun hasAuth(type: Int): Boolean {
return SharedPrefsMgr.getInstance(AbsMogoApplication.getApp()).getBoolean(HAS_AUTH + type, false)
}
fun setAuthorizeStatus() {
SharedPrefsMgr.getInstance(AbsMogoApplication.getApp()).putBoolean(HAS_AUTH, true)
fun setAuthorizeStatus(type: Int, authorize: Boolean) {
SharedPrefsMgr.getInstance(AbsMogoApplication.getApp()).putBoolean(HAS_AUTH + type, authorize)
}
fun updateAuthorizeVersion(updateTime: Long) {
SharedPrefsMgr.getInstance(AbsMogoApplication.getApp()).putLong(AUTHORIZE_UPDATE_TIME, updateTime)
}
fun getAuthorizeVersion(): Long {
return SharedPrefsMgr.getInstance(AbsMogoApplication.getApp()).getLong(AUTHORIZE_UPDATE_TIME, 0L)
}
fun hasGuide(): Boolean {
return SharedPrefsMgr.getInstance(AbsMogoApplication.getApp()).getBoolean(HAS_GUIDE, false)
}
}

View File

@@ -23,8 +23,8 @@ object VoiceUtil {
}
//WakeUp Command (Intent)
const val VOICE_INTENT_AGREE = "system.application.operation" //同意
const val VOICE_INTENT_DISAGREE = "system.application.operation" //不同意
const val VOICE_INTENT_AGREE = "com.zhidao.agree" //同意
const val VOICE_INTENT_DISAGREE = "com.zhiao.disagree" //不同意
//unWakeUp Command
const val VOICE_REGISTER_AUTHORIZE_AGREE = "CMD_AUTHORIZATION_AGREE"

View File

@@ -65,6 +65,8 @@ import java.util.Map;
import retrofit2.http.HEAD;
import static com.mogo.module.authorize.authprovider.invoke.AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE;
/**
* @author congtaowang
* @since 2020-01-07
@@ -121,6 +123,7 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
private TextView ivMode;
private IMogoPolyline iMogoPolyline;
public static boolean isClickShare;
@Override
protected int getLayoutId() {
@@ -131,7 +134,7 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
protected void initViews() {
mApis = ( IMogoServiceApis ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICE_APIS ).navigation( getContext() );
mIMogoAuthorizeModuleManager = (IMogoAuthorizeModuleManager) ARouter.getInstance().build(AuthorizeConstant.PROVIDER_MODULE).navigation(getContext());
mIMogoAuthorizeModuleManager.registerAuthorizeListener(AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE, this);
mIMogoAuthorizeModuleManager.registerAuthorizeListener(AUTHORIZE_TYPE_LAUNCHER_SHARE, this);
mEntrancePresenter = new EntrancePresenter( getContext(), this, mIMogoAuthorizeModuleManager );
mMogoFragmentManager = mApis.getFragmentManagerApi();
@@ -173,31 +176,16 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
mUploadRoadCondition = findViewById( R.id.module_entrance_id_upload_road_condition );
mUploadRoadCondition.setOnClickListener( view -> {
ShareControl.getInstance( getActivity() ).showDialog();
traceData( "1" );
isClickShare = true;
if (mIMogoAuthorizeModuleManager.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_SHARE)) {
mIMogoAuthorizeModuleManager.invokeAuthorization(AUTHORIZE_TYPE_LAUNCHER_SHARE);
} else {
ShareControl.getInstance( getActivity() ).showDialog();
traceData( "1" );
}
} );
mVRMode = findViewById( R.id.module_entrance_id_vr_mode );
mVRMode.setOnClickListener( view -> {
mMogoStatusManager.setUserInteractionStatus( TAG, true, false );
Rect mBoundRect = new Rect();
final int paddingTop = WindowUtils.dip2px( getContext(), 250 );
final int paddingBottom = WindowUtils.dip2px( getContext(), 150 );
final int paddingRight = WindowUtils.dip2px( getContext(), 150 );
final int paddingLeft = WindowUtils.dip2px( getContext(), 650 );
mBoundRect.bottom = paddingBottom;
mBoundRect.top = paddingTop;
mBoundRect.left = paddingLeft;
mBoundRect.right = paddingRight;
mMApUIController.showBounds( TAG,
new MogoLatLng(
mService.getSingletonLocationClient( getContext() ).getLastKnowLocation().getLatitude(),
mService.getSingletonLocationClient( getContext() ).getLastKnowLocation().getLongitude()
),
Arrays.asList( new MogoLatLng( 39.9736012000, 116.4220762300 ) ),
mBoundRect,
false );
} );
mMove2CurrentLocation = findViewById( R.id.module_entrance_id_move2_current_location );
@@ -206,8 +194,8 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
if ( location != null ) {
if ( !mMogoStatusManager.isADASShow() ) {
mMogoStatusManager.setUserInteractionStatus( TAG, true, false );
mMApUIController.changeZoom( 16.0f );
mMApUIController.setLockZoom( 16 );
mMApUIController.changeZoom( 16.0f );
}
mMogoStatusManager.setUserInteractionStatus( TAG, true, false );
mMApUIController.recoverLockMode();
@@ -310,14 +298,20 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
mEntrancePresenter.unregisterUnWake();
}
mIMogoAuthorizeModuleManager.unregisterAuthorizeListener(AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE);
isClickShare = false;
mIMogoAuthorizeModuleManager.unregisterAuthorizeListener(AUTHORIZE_TYPE_LAUNCHER_SHARE);
}
@Override
public void authorizeSuccess() {
Log.d( TAG, "authorizeSuccess --------> " );
mEntrancePresenter.handleNeedAuthorizeCmd();
Log.d(TAG, "authorizeSuccess --------> isClickShare = " + isClickShare);
if (isClickShare) {
ShareControl.getInstance( getActivity() ).showDialog();
traceData( "1" );
} else {
mEntrancePresenter.handleNeedAuthorizeCmd();
}
}
@Override

View File

@@ -25,6 +25,8 @@ import org.json.JSONObject;
import java.util.HashMap;
import java.util.Map;
import static com.mogo.module.authorize.authprovider.invoke.AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE;
/**
* @author congtaowang
* @since 2020-01-07
@@ -74,30 +76,30 @@ public class EntrancePresenter extends Presenter<EntranceView> {
private IMogoVoiceCmdCallBack mogoVoiceListener = new IMogoVoiceCmdCallBack() {
@Override
public void onCmdSelected(String cmd) {
Log.d(TAG, "免唤醒 mogoVoiceListener needAuthorize = " + mIMogoAuthorizeModuleManager.needAuthorize() + " >>>cmd = " + cmd);
Log.d(TAG, "免唤醒 mogoVoiceListener needAuthorize = " + mIMogoAuthorizeModuleManager.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_SHARE) + " >>>cmd = " + cmd);
mVoiceCmdType = cmd;
if (cmd.equals(ExtensionsModuleConst.CANCLE_SHARE)
|| cmd.equals(ExtensionsModuleConst.CLOSE)) { //取消分享,关闭页面
if (mIMogoAuthorizeModuleManager.needAuthorize()) {
mIMogoAuthorizeModuleManager.invokeAuthorization(AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE_NOVELTY);
if (mIMogoAuthorizeModuleManager.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_SHARE)) {
mIMogoAuthorizeModuleManager.invokeAuthorization(AUTHORIZE_TYPE_LAUNCHER_SHARE);
} else {
ShareControl.getInstance(mContext).dismissDialog();
}
} else if (cmd.equals(ExtensionsModuleConst.UPLOAD_ROAD_BLOCK)) { //上报拥堵
if (mIMogoAuthorizeModuleManager.needAuthorize()) {
mIMogoAuthorizeModuleManager.invokeAuthorization(AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE_NOVELTY);
if (mIMogoAuthorizeModuleManager.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_SHARE)) {
mIMogoAuthorizeModuleManager.invokeAuthorization(AUTHORIZE_TYPE_LAUNCHER_SHARE);
} else {
uploadRoadCondition();
}
} else if (cmd.equals(ExtensionsModuleConst.UPLOAD_TRAFFIC_CHECK)) { //上报交通检查
if (mIMogoAuthorizeModuleManager.needAuthorize()) {
mIMogoAuthorizeModuleManager.invokeAuthorization(AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE_NOVELTY);
if (mIMogoAuthorizeModuleManager.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_SHARE)) {
mIMogoAuthorizeModuleManager.invokeAuthorization(AUTHORIZE_TYPE_LAUNCHER_SHARE);
} else {
uploadTrfficCheck();
}
} else if (cmd.equals(ExtensionsModuleConst.UPLOAD_ROAD_CLOSURE)) { //上报封路
if (mIMogoAuthorizeModuleManager.needAuthorize()) {
mIMogoAuthorizeModuleManager.invokeAuthorization(AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE_NOVELTY);
if (mIMogoAuthorizeModuleManager.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_SHARE)) {
mIMogoAuthorizeModuleManager.invokeAuthorization(AUTHORIZE_TYPE_LAUNCHER_SHARE);
} else {
uploadRoadClosed();
}
@@ -140,8 +142,10 @@ public class EntrancePresenter extends Presenter<EntranceView> {
@Override
public void onIntentReceived(String intentStr, Intent intent) {
mVoiceCmdType = intentStr;
EntranceFragment.isClickShare = false;
String data = intent.getStringExtra("data");
Log.d(TAG, "唤醒 mogoIntentListener intentStr =" + intentStr + ">>data =" + data + " >>> needAuthorize = " + mIMogoAuthorizeModuleManager.needAuthorize());
Log.d(TAG, "唤醒 mogoIntentListener intentStr =" + intentStr + ">>data =" + data + " >>> needAuthorize = " + mIMogoAuthorizeModuleManager.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_SHARE));
if (intentStr.equals(ExtensionsModuleConst.GO_TO_SHARE)) { //我要分享 --ok
String conditionData = intent.getStringExtra("data");
Log.d(TAG, "唤醒 mogoIntentListener intentStr =" + intentStr + ">>conditionData =" + conditionData);
@@ -152,30 +156,30 @@ public class EntrancePresenter extends Presenter<EntranceView> {
mVoiceCmdShareType = typeString;
if (!TextUtils.isEmpty(typeString)) {
if (typeString.equals("封路")) {
if (mIMogoAuthorizeModuleManager.needAuthorize()) {
mIMogoAuthorizeModuleManager.invokeAuthorization(AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE_NOVELTY);
if (mIMogoAuthorizeModuleManager.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_SHARE)) {
mIMogoAuthorizeModuleManager.invokeAuthorization(AUTHORIZE_TYPE_LAUNCHER_SHARE);
} else {
Log.d(TAG, "mogoIntentListener 封路 -------> ");
uploadRoadClosed();
}
} else if (typeString.equals("油价")) {
if (mIMogoAuthorizeModuleManager.needAuthorize()) {
mIMogoAuthorizeModuleManager.invokeAuthorization(AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE_NOVELTY);
if (mIMogoAuthorizeModuleManager.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_SHARE)) {
mIMogoAuthorizeModuleManager.invokeAuthorization(AUTHORIZE_TYPE_LAUNCHER_SHARE);
} else {
Log.d(TAG, "mogoIntentListener 油价 -------> ");
shareOilPrice();
}
} else if (typeString.equals("交通检查")) {
if (mIMogoAuthorizeModuleManager.needAuthorize()) {
mIMogoAuthorizeModuleManager.invokeAuthorization(AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE_NOVELTY);
if (mIMogoAuthorizeModuleManager.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_SHARE)) {
mIMogoAuthorizeModuleManager.invokeAuthorization(AUTHORIZE_TYPE_LAUNCHER_SHARE);
} else {
Log.d(TAG, "mogoIntentListener 交通检查 -------> ");
uploadTrfficCheck();
}
}
} else {
if (mIMogoAuthorizeModuleManager.needAuthorize()) {
mIMogoAuthorizeModuleManager.invokeAuthorization(AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE_NOVELTY);
if (mIMogoAuthorizeModuleManager.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_SHARE)) {
mIMogoAuthorizeModuleManager.invokeAuthorization(AUTHORIZE_TYPE_LAUNCHER_SHARE);
} else {
ShareControl.getInstance(mContext).showDialog();
Log.d(TAG, "mogoIntentListener 我要分享 ----> ");
@@ -187,30 +191,30 @@ public class EntrancePresenter extends Presenter<EntranceView> {
}
} else if (intentStr.equals(ExtensionsModuleConst.UPLOAD_ROAD_CONDITION_AWAKEN)) {
//分享路况/上报路况/上报拥堵 唤醒
if (mIMogoAuthorizeModuleManager.needAuthorize()) {
mIMogoAuthorizeModuleManager.invokeAuthorization(AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE_NOVELTY);
if (mIMogoAuthorizeModuleManager.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_SHARE)) {
mIMogoAuthorizeModuleManager.invokeAuthorization(AUTHORIZE_TYPE_LAUNCHER_SHARE);
} else {
uploadRoadCondition();
Log.d(TAG, "mogoIntentListener 分享路况 唤醒 ----> ");
}
} else if (intentStr.equals(ExtensionsModuleConst.SHARE_DIALOG_CLOSE)) { //关闭分享框 唤醒
if (mIMogoAuthorizeModuleManager.needAuthorize()) {
mIMogoAuthorizeModuleManager.invokeAuthorization(AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE_NOVELTY);
if (mIMogoAuthorizeModuleManager.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_SHARE)) {
mIMogoAuthorizeModuleManager.invokeAuthorization(AUTHORIZE_TYPE_LAUNCHER_SHARE);
} else {
ShareControl.getInstance(mContext).dismissDialog();
Log.d(TAG, "mogoIntentListener 关闭分享框 唤醒 ----> ");
}
} else if (intentStr.equals(ExtensionsModuleConst.NO_REPLY_SHARE_DIALOG_CLOSE)) {
// 两次未回复关闭对话框
if (mIMogoAuthorizeModuleManager.needAuthorize()) {
mIMogoAuthorizeModuleManager.invokeAuthorization(AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE_NOVELTY);
if (mIMogoAuthorizeModuleManager.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_SHARE)) {
mIMogoAuthorizeModuleManager.invokeAuthorization(AUTHORIZE_TYPE_LAUNCHER_SHARE);
} else {
ShareControl.getInstance(mContext).dismissDialog();
Logger.d(TAG, "mogoIntentListener 两次未回复关闭对话框");
}
} else if (intentStr.equals(ExtensionsModuleConst.UPLOAD_ROAD_CONDITION)) { //上报路况 免唤醒 --ok
if (mIMogoAuthorizeModuleManager.needAuthorize()) {
mIMogoAuthorizeModuleManager.invokeAuthorization(AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE_NOVELTY);
if (mIMogoAuthorizeModuleManager.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_SHARE)) {
mIMogoAuthorizeModuleManager.invokeAuthorization(AUTHORIZE_TYPE_LAUNCHER_SHARE);
} else {
uploadRoadCondition();
}

View File

@@ -146,7 +146,7 @@
android:layout_height="@dimen/module_ext_operation_panel_vr_height"
android:background="@drawable/module_ext_dw_top_corner_bkg"
android:orientation="vertical"
android:visibility="visible">
android:visibility="gone">
<TextView
android:layout_width="wrap_content"

View File

@@ -2,6 +2,8 @@ package com.mogo.module.guide
import com.alibaba.android.arouter.launcher.ARouter
import com.mogo.module.authorize.authprovider.invoke.AuthorizeConstant
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.authprovider.module.IMogoAuthorizeModuleManager
import com.mogo.module.guide.fragment.GuideFragment
import com.mogo.module.guide.util.SharedPreferenceUtil.hasGuide
@@ -48,7 +50,7 @@ object GuideBizManager {
fun invokeAuthorize() {
val authorizeInvoke = ARouter.getInstance().build(AuthorizeConstant.PROVIDER_MODULE).navigation()
if (authorizeInvoke is IMogoAuthorizeModuleManager) {
if (authorizeInvoke.needAuthorize()) {
if (authorizeInvoke.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_MAIN)) {
authorizeInvoke.invokeAuthorizeForShow()
}
}

View File

@@ -4,13 +4,13 @@ class GuideConstant {
companion object {
/**
* 展示用户引导或者用户协议模块地址
* 展示用户引导模块地址
*/
const val PATH_GUIDE_AGREEMENT_FRAGMENT = "/guideAgreement/showFragment"
const val PATH_GUIDE_FRAGMENT = "/guide/showFragment"
/**
* provider模块实例名称(暂时仅有卡片用到)
*/
const val PATH_GUIDE_AGREEMENT_MODULE_NAME = "GUIDE_AND_AGREEMENT"
const val PATH_GUIDE_MODULE_NAME = "GUIDE_MODULE_NAME"
}
}

View File

@@ -9,13 +9,13 @@ 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.guide.GuideConstant.Companion.PATH_GUIDE_AGREEMENT_FRAGMENT
import com.mogo.module.guide.GuideConstant.Companion.PATH_GUIDE_AGREEMENT_MODULE_NAME
import com.mogo.module.guide.GuideConstant.Companion.PATH_GUIDE_FRAGMENT
import com.mogo.module.guide.GuideConstant.Companion.PATH_GUIDE_MODULE_NAME
import com.mogo.service.module.IMogoModuleLifecycle
import com.mogo.service.module.IMogoModuleProvider
import com.mogo.service.module.ModuleType
@Route(path = PATH_GUIDE_AGREEMENT_FRAGMENT)
@Route(path = PATH_GUIDE_FRAGMENT)
class MogoGuideProvider : IMogoModuleProvider {
/**
@@ -30,7 +30,7 @@ class MogoGuideProvider : IMogoModuleProvider {
}
override fun getModuleName(): String {
return PATH_GUIDE_AGREEMENT_MODULE_NAME
return PATH_GUIDE_MODULE_NAME
}
override fun getCardLifecycle(): IMogoModuleLifecycle? {

View File

@@ -1,2 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mogo.module.share" />
package="com.mogo.module.share" >
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
</manifest>

View File

@@ -45,12 +45,12 @@ public class ShareControl implements IShareControl {
boolean isAdasShow = mogoServiceApis.getStatusManagerApi().isADASShow();
Logger.d("ShareControl", "showDialog 判断adas是否展示: " + isAdasShow);
if (isAdasShow) {
mogoServiceApis.getAdasControllerApi().closeADAS();
}
// if (isAdasShow) {
// mogoServiceApis.getAdasControllerApi().closeADAS();
// }
mShareDialog = new LaucherShareDialog(mContext);
mShareDialog.setCanceledOnTouchOutside(true);
// mShareDialog.setCanceledOnTouchOutside(true);
mShareDialog.show();
}

View File

@@ -1,11 +1,14 @@
package com.mogo.module.share.dialog;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.PixelFormat;
import android.net.Uri;
import android.os.Bundle;
import android.os.Build;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.RelativeLayout;
import android.widget.TextView;
@@ -16,6 +19,7 @@ import com.mogo.module.share.R;
import com.mogo.module.share.constant.ShareConstants;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.analytics.IMogoAnalytics;
import com.mogo.utils.WindowUtils;
import com.mogo.utils.logger.Logger;
import java.util.HashMap;
@@ -25,9 +29,15 @@ import java.util.Map;
/**
* @author lixiaopeng
* @description 通用分享dialog
*
* 由于和左侧Adas冲突改成了windowManager方式实现这种实现方式的问题是无法监测back键的事件
* @since 2020-01-10
*/
public class LaucherShareDialog extends Dialog implements View.OnClickListener {
public class LaucherShareDialog implements View.OnClickListener {
private static final String TAG = "LaucherShareDialog";
private boolean isShown = false;
private TextView txtOk;
private RelativeLayout mBlockLayout;
private RelativeLayout mOilPriceLayout;
@@ -36,33 +46,29 @@ public class LaucherShareDialog extends Dialog implements View.OnClickListener {
private Context mContext;
private IMogoAnalytics mAnalytics;
private WindowManager windowManager;
private WindowManager.LayoutParams layoutParams;
public LaucherShareDialog(@NonNull Context context) {
super(context, R.style.BottomDialog);
this.mContext = context;
getWindow().setBackgroundDrawableResource(android.R.color.transparent);
mAnalytics = (IMogoAnalytics) ARouter.getInstance().build(MogoServicePaths.PATH_UTILS_ANALYTICS).navigation(mContext);
}
public LaucherShareDialog(@NonNull Context context, int themeResId) {
super(context, R.style.BottomDialog);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initView();
initListener();
}
private View body;
private void initView() {
setContentView(R.layout.launcher_dialog_share);
txtOk = findViewById(R.id.btn_share_title);
mBlockLayout = findViewById(R.id.btn_block_layout);
mOilPriceLayout = findViewById(R.id.oil_price_layout);
mTrafficCheckLayout = findViewById(R.id.traffic_check_layout);
mRoadClosureLayout = findViewById(R.id.road_closure_layout);
Logger.d(TAG, "test-------3");
body = LayoutInflater.from(mContext).inflate(R.layout.launcher_dialog_share, null);
body.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
txtOk = body.findViewById(R.id.btn_share_title);
mBlockLayout = body.findViewById(R.id.btn_block_layout);
mOilPriceLayout = body.findViewById(R.id.oil_price_layout);
mTrafficCheckLayout = body.findViewById(R.id.traffic_check_layout);
mRoadClosureLayout = body.findViewById(R.id.road_closure_layout);
}
@@ -73,31 +79,34 @@ public class LaucherShareDialog extends Dialog implements View.OnClickListener {
mRoadClosureLayout.setOnClickListener(this);
}
@Override
public void onClick(View view) {
int id = view.getId();
Logger.d(TAG, "onClick: " + id);
if (id == R.id.btn_block_layout) { //拥堵
traceTanluData("1");
sendShareReceiver("1");
traceTypeData("1");
dismiss();
} else if (id == R.id.oil_price_layout) {
traceData("1");
Intent intent = new Intent();
intent.setData(Uri.parse("freshthing://com.zhidao.fresh.things/shareOilPrice"));
mContext.startActivity(intent);
traceTypeData("2");
dismiss();
} else if (id == R.id.traffic_check_layout) { //交通检查
traceData("1");
sendShareReceiver("2");
traceTypeData("3");
dismiss();
} else if (id == R.id.road_closure_layout) { //封路
traceData("1");
sendShareReceiver("3");
traceTypeData("4");
dismiss();
}
dismiss();
}
/**
@@ -143,4 +152,39 @@ public class LaucherShareDialog extends Dialog implements View.OnClickListener {
}
public void show(){
Logger.d(TAG,"使用windowManager实现");
if (!isShown) {
windowManager = (WindowManager) mContext.getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
layoutParams = new WindowManager.LayoutParams();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
layoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
} else {
layoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
}
layoutParams.format = PixelFormat.TRANSLUCENT;
layoutParams.gravity = Gravity.LEFT | Gravity.TOP;
// mWindowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
// FLAG_LAYOUT_IN_SCREEN将window放置在整个屏幕之内,无视其他的装饰(比如状态栏) FLAG_NOT_TOUCH_MODAL不阻塞事件传递到后面的窗口
layoutParams.flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
layoutParams.width = WindowUtils.getScreenWidth(mContext);
layoutParams.height = WindowUtils.getScreenHeight(mContext);
layoutParams.dimAmount = 0;//后面变暗区域透明...
layoutParams.x = 0;
layoutParams.y = 0;
initView();
initListener();
windowManager.addView(body, layoutParams);
isShown = true;
}
}
public void dismiss(){
if (isShown && windowManager != null && body != null) {
windowManager.removeViewImmediate(body);
windowManager = null;
isShown = false;
}
}
}

View File

@@ -1,146 +1,157 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="@dimen/share_module_width"
android:layout_height="@dimen/share_module_height"
android:background="@drawable/shape_bg_222533_20px">
<TextView
android:id="@+id/btn_share_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="@dimen/share_module_title_margin_top"
android:gravity="center"
android:text="一 我要分享 一"
android:textStyle="bold"
android:textColor="@color/white"
android:textSize="@dimen/share_module_title_content" />
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:focusable="true"
android:background="#88000000">
<RelativeLayout
android:id="@+id/tu_block_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/btn_share_title"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/share_module_margin_top">
<RelativeLayout
android:id="@+id/btn_block_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/share_module_margin_left"
android:layout_toLeftOf="@+id/traffic_check_layout">
<ImageView
android:id="@+id/block_up_iv"
android:layout_width="@dimen/share_module_image_width"
android:layout_height="@dimen/share_module_image_width"
android:src="@drawable/share_block_up" />
<TextView
android:id="@+id/block_up_tv"
android:layout_width="@dimen/share_module_image_width"
android:layout_height="wrap_content"
android:layout_below="@+id/block_up_iv"
android:layout_marginTop="@dimen/share_module_tv_margin_top"
android:gravity="center"
android:text="上报拥堵"
android:textColor="@color/white"
android:textSize="@dimen/share_module_item"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/oil_price_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:layout_marginLeft="@dimen/share_module_margin_left"
android:layout_toRightOf="@+id/btn_block_layout">
<ImageView
android:id="@+id/oil_price_iv"
android:layout_width="@dimen/share_module_image_width"
android:layout_height="@dimen/share_module_image_width"
android:src="@drawable/share_oil_price" />
<TextView
android:id="@+id/oil_price_tv"
android:layout_width="@dimen/share_module_image_width"
android:layout_height="wrap_content"
android:layout_below="@+id/oil_price_iv"
android:layout_marginTop="@dimen/share_module_tv_margin_top"
android:gravity="center"
android:text="分享油价"
android:textColor="@color/white"
android:textSize="@dimen/share_module_item"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/traffic_check_layout"
android:layout_width="@dimen/share_module_image_width_second"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true">
<ImageView
android:id="@+id/traffic_check_iv"
android:layout_width="@dimen/share_module_image_width"
android:layout_height="@dimen/share_module_image_width"
android:layout_centerHorizontal="true"
android:src="@drawable/share_traffic_check" />
<TextView
android:id="@+id/traffic_check_tv"
android:layout_width="@dimen/share_module_image_width_second"
android:layout_height="wrap_content"
android:layout_below="@+id/traffic_check_iv"
android:layout_marginTop="@dimen/share_module_tv_margin_top"
android:gravity="center"
android:text="上报交通检查"
android:textColor="@color/white"
android:textSize="@dimen/share_module_item"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/road_closure_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/share_module_margin_left"
android:layout_toRightOf="@+id/traffic_check_layout">
<ImageView
android:id="@+id/road_closure_iv"
android:layout_width="@dimen/share_module_image_width"
android:layout_height="@dimen/share_module_image_width"
android:src="@drawable/share_road_closure" />
<TextView
android:id="@+id/road_closure_tv"
android:layout_width="@dimen/share_module_image_width"
android:layout_height="wrap_content"
android:layout_below="@+id/road_closure_iv"
android:layout_marginTop="@dimen/share_module_tv_margin_top"
android:gravity="center"
android:text="上报封路"
android:textColor="@color/white"
android:textSize="@dimen/share_module_item"
android:textStyle="bold" />
</RelativeLayout>
android:layout_width="@dimen/share_module_width"
android:layout_height="@dimen/share_module_height"
android:clickable="true"
android:focusable="true"
android:layout_gravity="center"
android:background="@drawable/shape_bg_222533_20px">
<TextView
android:id="@+id/btn_share_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/btn_block_layout"
android:layout_marginTop="@dimen/share_module_bottom_margin_top"
android:layout_alignParentTop="true"
android:layout_marginTop="@dimen/share_module_title_margin_top"
android:gravity="center"
android:text="可以对小智说:上报拥堵、上报交通检查、上报封路"
android:textColor="@color/white_40"
android:textSize="@dimen/share_module_bottom_size"
android:text="一 我要分享 一"
android:textColor="@color/white"
android:textSize="@dimen/share_module_title_content"
android:textStyle="bold" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="@+id/tu_block_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/btn_share_title"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/share_module_margin_top">
<RelativeLayout
android:id="@+id/btn_block_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/share_module_margin_left"
android:layout_toLeftOf="@+id/traffic_check_layout">
<ImageView
android:id="@+id/block_up_iv"
android:layout_width="@dimen/share_module_image_width"
android:layout_height="@dimen/share_module_image_width"
android:src="@drawable/share_block_up" />
<TextView
android:id="@+id/block_up_tv"
android:layout_width="@dimen/share_module_image_width"
android:layout_height="wrap_content"
android:layout_below="@+id/block_up_iv"
android:layout_marginTop="@dimen/share_module_tv_margin_top"
android:gravity="center"
android:text="上报拥堵"
android:textColor="@color/white"
android:textSize="@dimen/share_module_item"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/oil_price_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/share_module_margin_left"
android:layout_toRightOf="@+id/btn_block_layout"
android:visibility="gone">
<ImageView
android:id="@+id/oil_price_iv"
android:layout_width="@dimen/share_module_image_width"
android:layout_height="@dimen/share_module_image_width"
android:src="@drawable/share_oil_price" />
<TextView
android:id="@+id/oil_price_tv"
android:layout_width="@dimen/share_module_image_width"
android:layout_height="wrap_content"
android:layout_below="@+id/oil_price_iv"
android:layout_marginTop="@dimen/share_module_tv_margin_top"
android:gravity="center"
android:text="分享油价"
android:textColor="@color/white"
android:textSize="@dimen/share_module_item"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/traffic_check_layout"
android:layout_width="@dimen/share_module_image_width_second"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true">
<ImageView
android:id="@+id/traffic_check_iv"
android:layout_width="@dimen/share_module_image_width"
android:layout_height="@dimen/share_module_image_width"
android:layout_centerHorizontal="true"
android:src="@drawable/share_traffic_check" />
<TextView
android:id="@+id/traffic_check_tv"
android:layout_width="@dimen/share_module_image_width_second"
android:layout_height="wrap_content"
android:layout_below="@+id/traffic_check_iv"
android:layout_marginTop="@dimen/share_module_tv_margin_top"
android:gravity="center"
android:text="上报交通检查"
android:textColor="@color/white"
android:textSize="@dimen/share_module_item"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/road_closure_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/share_module_margin_left"
android:layout_toRightOf="@+id/traffic_check_layout">
<ImageView
android:id="@+id/road_closure_iv"
android:layout_width="@dimen/share_module_image_width"
android:layout_height="@dimen/share_module_image_width"
android:src="@drawable/share_road_closure" />
<TextView
android:id="@+id/road_closure_tv"
android:layout_width="@dimen/share_module_image_width"
android:layout_height="wrap_content"
android:layout_below="@+id/road_closure_iv"
android:layout_marginTop="@dimen/share_module_tv_margin_top"
android:gravity="center"
android:text="上报封路"
android:textColor="@color/white"
android:textSize="@dimen/share_module_item"
android:textStyle="bold" />
</RelativeLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/btn_block_layout"
android:layout_marginTop="@dimen/share_module_bottom_margin_top"
android:gravity="center"
android:text="可以对小智说:上报拥堵、上报交通检查、上报封路"
android:textColor="@color/white_40"
android:textSize="@dimen/share_module_bottom_size"
android:textStyle="bold" />
</RelativeLayout>
</RelativeLayout>
</FrameLayout>