add module of authorize and guide ,wait to finish
2
.idea/gradle.xml
generated
@@ -20,9 +20,11 @@
|
||||
<option value="$PROJECT_DIR$/libraries/mogo-map-api" />
|
||||
<option value="$PROJECT_DIR$/modules" />
|
||||
<option value="$PROJECT_DIR$/modules/mogo-module-apps" />
|
||||
<option value="$PROJECT_DIR$/modules/mogo-module-authorize" />
|
||||
<option value="$PROJECT_DIR$/modules/mogo-module-back" />
|
||||
<option value="$PROJECT_DIR$/modules/mogo-module-common" />
|
||||
<option value="$PROJECT_DIR$/modules/mogo-module-extensions" />
|
||||
<option value="$PROJECT_DIR$/modules/mogo-module-guide" />
|
||||
<option value="$PROJECT_DIR$/modules/mogo-module-main" />
|
||||
<option value="$PROJECT_DIR$/modules/mogo-module-map" />
|
||||
<option value="$PROJECT_DIR$/modules/mogo-module-search" />
|
||||
|
||||
@@ -109,7 +109,10 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.moduleadcard
|
||||
|
||||
implementation rootProject.ext.dependencies.moduleonlinecar
|
||||
implementation rootProject.ext.dependencies.moduleV2x
|
||||
implementation rootProject.ext.dependencies.moduleV2x,{
|
||||
exclude group:'com.mogo.module.carchatting',module:'module-carchatting'
|
||||
exclude group:'com.mogo.module.carchatting',module:'module-carchatting-provider'
|
||||
}
|
||||
implementation rootProject.ext.dependencies.moduletanlu,{
|
||||
exclude group:'com.mogo.module',module:'module-share'
|
||||
}
|
||||
@@ -120,12 +123,14 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.modulecommon
|
||||
implementation rootProject.ext.dependencies.modulesearch
|
||||
implementation rootProject.ext.dependencies.mogomoduleback
|
||||
implementation rootProject.ext.dependencies.mogomoduleguide
|
||||
} else {
|
||||
implementation project(':modules:mogo-module-main')
|
||||
implementation project(':foudations:mogo-commons')
|
||||
implementation project(':modules:mogo-module-common')
|
||||
implementation project(':modules:mogo-module-search')
|
||||
implementation project(':modules:mogo-module-back')
|
||||
implementation project(':modules:mogo-module-guide')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,9 @@ 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;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-18
|
||||
@@ -42,7 +45,7 @@ public class MogoApplication extends AbsMogoApplication {
|
||||
crashSystem.init();
|
||||
//设置debug模式,日志不上传
|
||||
crashSystem.setDebug(BuildConfig.DEBUG);
|
||||
Logger.init( BuildConfig.DEBUG ? LogLevel.DEBUG : LogLevel.OFF );
|
||||
Logger.init(BuildConfig.DEBUG ? LogLevel.DEBUG : LogLevel.OFF);
|
||||
|
||||
//运营位卡片,需要默认显示,放在第一个加载
|
||||
MogoModulePaths.addModule(new MogoModule(AdCardConstants.TAG, AdCardConstants.MODULE_NAME));
|
||||
@@ -50,11 +53,12 @@ public class MogoApplication extends AbsMogoApplication {
|
||||
MogoModulePaths.addModule(new MogoModule(CallChatConstant.PROVIDER, CallChatConstant.MODULE_NAME));
|
||||
MogoModulePaths.addModule(new MogoModule(TanluConstants.TAG, TanluConstants.MODEL_NAME));
|
||||
MogoModulePaths.addModule(new MogoModule(OnLineCarConstants.TAG, OnLineCarConstants.MODULE_NAME));
|
||||
MogoModulePaths.addModule(new MogoModule( FreshNewsConstants.TAG, FreshNewsConstants.MODULE_NAME));
|
||||
|
||||
MogoModulePaths.addModule(new MogoModule(FreshNewsConstants.TAG, FreshNewsConstants.MODULE_NAME));
|
||||
|
||||
MogoModulePaths.addModule(new MogoModule(V2XConst.PATH_V2X_UI, V2XConst.PATH_V2X_UI));
|
||||
MogoModulePaths.addModule(new MogoModule(PushUIConstants.TAG, PushUIConstants.TAG));
|
||||
MogoModulePaths.addModule(new MogoModule( BackToLauncherConst.MODULE_PATH, BackToLauncherConst.MODULE_NAME));
|
||||
MogoModulePaths.addModule(new MogoModule(BackToLauncherConst.MODULE_PATH, BackToLauncherConst.MODULE_NAME));
|
||||
MogoModulePaths.addModule(new MogoModule(PATH_GUIDE_AGREEMENT_FRAGMENT, PATH_GUIDE_AGREEMENT_MODULE_NAME));
|
||||
Log.i("timer", "cost " + (System.currentTimeMillis() - start) + "ms");
|
||||
}
|
||||
|
||||
@@ -70,6 +74,6 @@ public class MogoApplication extends AbsMogoApplication {
|
||||
super.attachBaseContext(base);
|
||||
MultiDex.install(base);
|
||||
DebugConfig.setNetMode(BuildConfig.NET_ENV);
|
||||
DebugConfig.setDebug( BuildConfig.DEBUG );
|
||||
DebugConfig.setDebug(BuildConfig.DEBUG);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.mogo.launcher"
|
||||
android:sharedUserId="android.uid.system">
|
||||
package="com.mogo.launcher">
|
||||
<!-- android:sharedUserId="android.uid.system">-->
|
||||
|
||||
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
apply from: "config.gradle"
|
||||
apply from: "javadoc.gradle"
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.3.41'
|
||||
|
||||
ext.kotlin_version = '1.3.61'
|
||||
ext.kotlin_version = '1.3.61+'
|
||||
repositories {
|
||||
|
||||
@@ -109,6 +109,8 @@ ext {
|
||||
modulefreshnews : "com.mogo.module:module-freshnews:${MOGO_MODULE_FRESH_NEWS_VERSION}",
|
||||
//统一返回键
|
||||
mogomoduleback : "com.mogo.module:module-back:${MOGO_MODULE_BACK_VERSION}",
|
||||
mogomoduleauth : "com.mogo.module:module-authorize:${MOGO_MODULE_AUTHORIZE_VERSION}",
|
||||
mogomoduleguide : "com.mogo.module:module-guide:${MOGO_MODULE_GUIDE_VERSION}",
|
||||
// 长链
|
||||
socketsdk : 'com.zhidao.socketsdk:socketsdk:2.1.1',
|
||||
socketsdkconnsvrprotoco : 'com.zhidao.ptech:connsvr-protoco:0.1.23',
|
||||
@@ -128,5 +130,8 @@ ext {
|
||||
videoarm64 : "com.shuyu:gsyVideoPlayer-arm64:7.1.2",
|
||||
videojava : "com.shuyu:gsyVideoPlayer-java:7.1.2",
|
||||
eventbus : "org.greenrobot:eventbus:3.1.1",
|
||||
|
||||
coroutinescore : "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1",
|
||||
coroutinesandroid : "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1"
|
||||
]
|
||||
}
|
||||
@@ -45,14 +45,16 @@ MOGO_MODULE_SERVICE_VERSION=1.0.2-SNAPSHOT
|
||||
MOGO_MODULE_EXTENSIONS_VERSION=1.0.2-SNAPSHOT
|
||||
MOGO_MODULE_SEARCH_VERSION=1.0.2-SNAPSHOT
|
||||
MOGO_MODULE_BACK_VERSION=1.0.2-SNAPSHOT
|
||||
MOGO_MODULE_AUTHORIZE_VERSION=1.0.0-SNAPSHOT
|
||||
MOGO_MODULE_GUIDE_VERSION=1.0.0-SNAPSHOT
|
||||
|
||||
## 工程外部模块
|
||||
# 探路
|
||||
MOGO_MODULE_TANLU_VERSION=1.0.2-SNAPSHOT
|
||||
# 车聊聊
|
||||
CARCHATTING_VERSION=1.0.2.2-SNAPSHOT
|
||||
CARCHATTING_VERSION=1.0.2.3-SNAPSHOT
|
||||
# 车聊聊接口
|
||||
CARCHATTINGPROVIDER_VERSION=1.0.2.2-SNAPSHOT
|
||||
CARCHATTINGPROVIDER_VERSION=1.0.2.3-SNAPSHOT
|
||||
# 在线车辆F
|
||||
MOGO_MODULE_ONLINECAR_VERSION=1.0.1-SNAPSHOT
|
||||
# v2x
|
||||
|
||||
1
modules/mogo-module-authorize/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
||||
65
modules/mogo-module-authorize/build.gradle
Normal file
@@ -0,0 +1,65 @@
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
apply plugin: 'com.alibaba.arouter'
|
||||
|
||||
android {
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||
versionCode Integer.valueOf(VERSION_CODE)
|
||||
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles 'consumer-rules.pro'
|
||||
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
arguments = [AROUTER_MODULE_NAME: project.getName()]
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation rootProject.ext.dependencies.kotlinstdlibjdk7
|
||||
implementation rootProject.ext.dependencies.androidxccorektx
|
||||
implementation rootProject.ext.dependencies.coroutinescore
|
||||
implementation rootProject.ext.dependencies.coroutinesandroid
|
||||
implementation rootProject.ext.dependencies.androidxappcompat
|
||||
implementation rootProject.ext.dependencies.androidxconstraintlayout
|
||||
implementation rootProject.ext.dependencies.arouter
|
||||
annotationProcessor rootProject.ext.dependencies.aroutercompiler
|
||||
|
||||
if (Boolean.valueOf(RELEASE)) {
|
||||
implementation rootProject.ext.dependencies.mogoutils
|
||||
implementation rootProject.ext.dependencies.mogocommons
|
||||
implementation rootProject.ext.dependencies.mogoserviceapi
|
||||
} else {
|
||||
implementation project(":foudations:mogo-utils")
|
||||
implementation project(":foudations:mogo-commons")
|
||||
implementation project(':services:mogo-service-api')
|
||||
}
|
||||
}
|
||||
|
||||
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
0
modules/mogo-module-authorize/consumer-rules.pro
Normal file
3
modules/mogo-module-authorize/gradle.properties
Normal file
@@ -0,0 +1,3 @@
|
||||
GROUP=com.mogo.module
|
||||
POM_ARTIFACT_ID=module-authorize
|
||||
VERSION_CODE=1
|
||||
21
modules/mogo-module-authorize/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.mogo.module.authorize
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class ExampleInstrumentedTest {
|
||||
@Test
|
||||
fun useAppContext() {
|
||||
// Context of the app under test.
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
assertEquals("com.mogo.module.authorize.test", appContext.packageName)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.mogo.module.authorize" />
|
||||
@@ -0,0 +1,62 @@
|
||||
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.UserAgreement
|
||||
import com.mogo.module.authorize.net.request
|
||||
import com.mogo.utils.logger.Logger
|
||||
|
||||
open class IMogoAuthorizeController {
|
||||
|
||||
companion object {
|
||||
const val TAG = "IMogoAuthorizeController"
|
||||
}
|
||||
|
||||
private val authorizeModel: IMogoAuthorizeModel by lazy { IMogoAuthorizeModel() }
|
||||
|
||||
fun invokeAuthorizeContent(tag: String, agreementType: Int) {
|
||||
if (agreementType == -1) {
|
||||
getAuthorizeContentListener(tag, { listener ->
|
||||
listener.requestContentFailed("invokeAuthorizeContent param tag is not right")
|
||||
}, {
|
||||
Logger.d(TAG, "invokeAuthorizeContent ---checkAgreementType can not find tag :$tag")
|
||||
})
|
||||
}
|
||||
request<BaseResponse<UserAgreement>> {
|
||||
loader {
|
||||
authorizeModel.invokeAuthorizeContent(agreementType)
|
||||
}
|
||||
onSuccess {
|
||||
Logger.d(TAG, "invokeAuthorizeContent onSuccess data: ${it.result}")
|
||||
getAuthorizeContentListener(tag, { listener ->
|
||||
if (it.result != null) {
|
||||
listener.requestContentSuccess(it.result)
|
||||
} 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")
|
||||
})
|
||||
}
|
||||
onError {
|
||||
getAuthorizeContentListener(tag, { listener ->
|
||||
listener.requestContentFailed(it.message
|
||||
?: "request authorize content failed,please check network")
|
||||
}, {
|
||||
Logger.d(TAG, "invokeAuthorizeContent --- can not find listener by this tag :$tag")
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private inline fun getAuthorizeContentListener(tag: String, blockSuccess: ((IMogoAuthorizeContentListener) -> Unit), blockNull: (() -> Unit)) {
|
||||
val authorizeContentListener = MogoAuthorizeRegisterHandler.getAuthorizeContentListener(tag)
|
||||
if (authorizeContentListener != null) {
|
||||
blockSuccess(authorizeContentListener)
|
||||
} else {
|
||||
blockNull()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.mogo.module.authorize.authprovider.biz
|
||||
|
||||
import com.mogo.module.authorize.authprovider.invoke.IMogoAuthorizeContentListener
|
||||
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.util.SharedPreferenceUtil.hasAuth
|
||||
|
||||
open abstract class MogoAuthorizeManagerImpl : IMogoAuthorizeInvoke {
|
||||
|
||||
private val baseController: IMogoAuthorizeController by lazy { IMogoAuthorizeController() }
|
||||
|
||||
override fun needAuthorize(): Boolean {
|
||||
return hasAuth()
|
||||
}
|
||||
|
||||
override fun invokeAuthorizeContent(tag: String) {
|
||||
//todo 后面动态代理统一处理校验问题
|
||||
val agreementType = AuthorizeProxy.getAuthorizeType(tag)
|
||||
baseController.invokeAuthorizeContent(tag, agreementType)
|
||||
}
|
||||
|
||||
override fun registerInvokeAuthorizeContentListener(tag: String, listener: IMogoAuthorizeContentListener) {
|
||||
MogoAuthorizeRegisterHandler.registerInvokeAuthorizeContentListener(tag, listener)
|
||||
}
|
||||
|
||||
override fun unregisterInvokeAuthorizeContentListener(tag: String) {
|
||||
MogoAuthorizeRegisterHandler.unregisterInvokeAuthorizeContentListener(tag)
|
||||
}
|
||||
|
||||
override fun registerAuthorizeListener(tag: String, listener: IMogoAcquireAuthorizeListener) {
|
||||
MogoAuthorizeRegisterHandler.registerAuthorizeListener(tag, listener)
|
||||
}
|
||||
|
||||
override fun unregisterAuthorizeListener(tag: String) {
|
||||
MogoAuthorizeRegisterHandler.unregisterAuthorizeListener(tag)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.mogo.module.authorize.authprovider.biz
|
||||
|
||||
import com.mogo.module.authorize.authprovider.invoke.IMogoAuthorizeContentListener
|
||||
import com.mogo.module.authorize.authprovider.invoke.IMogoAuthorizeRegister
|
||||
import com.mogo.module.authorize.authprovider.module.IMogoAcquireAuthorizeListener
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
object MogoAuthorizeRegisterHandler : IMogoAuthorizeRegister {
|
||||
|
||||
private val authMap: ConcurrentHashMap<String, IMogoAcquireAuthorizeListener> = ConcurrentHashMap()
|
||||
private val authContentMap: ConcurrentHashMap<String, IMogoAuthorizeContentListener> = ConcurrentHashMap()
|
||||
|
||||
override fun registerAuthorizeListener(tag: String, listener: IMogoAcquireAuthorizeListener) {
|
||||
authMap[tag] = listener
|
||||
}
|
||||
|
||||
override fun unregisterAuthorizeListener(tag: String) {
|
||||
authMap.remove(tag)
|
||||
}
|
||||
|
||||
fun getAuthorizeListener(tag: String): IMogoAcquireAuthorizeListener? {
|
||||
return authMap[tag]
|
||||
}
|
||||
|
||||
fun getAllAuthorizeListener(): ConcurrentHashMap<String, IMogoAcquireAuthorizeListener> {
|
||||
return authMap
|
||||
}
|
||||
|
||||
override fun registerInvokeAuthorizeContentListener(tag: String, listener: IMogoAuthorizeContentListener) {
|
||||
authContentMap[tag] = listener
|
||||
}
|
||||
|
||||
override fun unregisterInvokeAuthorizeContentListener(tag: String) {
|
||||
authContentMap.remove(tag)
|
||||
}
|
||||
|
||||
fun getAuthorizeContentListener(tag: String): IMogoAuthorizeContentListener? {
|
||||
return authContentMap[tag]
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.mogo.module.authorize.authprovider.invoke
|
||||
|
||||
class AuthorizeConstant {
|
||||
|
||||
companion object{
|
||||
const val PROVIDER_MODULE = "/authorize/biz"
|
||||
const val PROVIDER_LAUNCHER = "/authorize/showbiz"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.mogo.module.authorize.authprovider.invoke
|
||||
|
||||
class AuthorizeInvokerConstant {
|
||||
|
||||
companion object {
|
||||
const val AUTHORIZE_TYPE_LAUNCHER_MAIN = "AUTHORIZE_TYPE_LAUNCHER_MAIN" //launcher
|
||||
const val AUTHORIZE_TYPE_LAUNCHER_SHARE = "AUTHORIZE_TYPE_LAUNCHER_SHARE" //launcher
|
||||
const val AUTHORIZE_TYPE_TAN_LU = "AUTHORIZE_TYPE_TAN_LU" //探路
|
||||
const val AUTHORIZE_TYPE_CALL_CHAT = "AUTHORIZE_TYPE_CALL_CHAT" //车聊聊
|
||||
const val AUTHORIZE_TYPE_NOVELTY = "AUTHORIZE_TYPE_NOVELTY" //新鲜事
|
||||
const val AUTHORIZE_TYPE_AUXILIARY_DRIVING = "AUTHORIZE_TYPE_AUXILIARY_DRIVING" //辅助驾驶
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.mogo.module.authorize.authprovider.invoke
|
||||
|
||||
import com.mogo.module.authorize.model.bean.UserAgreement
|
||||
|
||||
/**
|
||||
* 获取授权信息回调
|
||||
*/
|
||||
interface IMogoAuthorizeContentListener {
|
||||
|
||||
fun requestContentSuccess(userAgreement: UserAgreement)
|
||||
|
||||
fun requestContentFailed(errorMsg: String)
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.mogo.module.authorize.authprovider.invoke
|
||||
|
||||
interface IMogoAuthorizeForbiddenVoice {
|
||||
|
||||
/**
|
||||
* 当授权页面展示时,语音回调不生效(唤醒、免唤醒)
|
||||
*/
|
||||
fun forbiddenVoiceWhenAuthorize(cmd: String)
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.mogo.module.authorize.authprovider.invoke
|
||||
|
||||
/**
|
||||
* 公共Business业务
|
||||
*/
|
||||
interface IMogoAuthorizeInvoke : IMogoAuthorizeRegister {
|
||||
|
||||
/**
|
||||
* 是否需要授权
|
||||
*/
|
||||
fun needAuthorize(): Boolean
|
||||
|
||||
/**
|
||||
* 获取授权内容
|
||||
* tag:模块ID
|
||||
*/
|
||||
fun invokeAuthorizeContent(tag: String)
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.mogo.module.authorize.authprovider.invoke
|
||||
|
||||
import com.mogo.module.authorize.authprovider.module.IMogoAcquireAuthorizeListener
|
||||
|
||||
interface IMogoAuthorizeRegister {
|
||||
|
||||
/**
|
||||
* 注冊授权回调
|
||||
* tag:module tag
|
||||
* @see IMogoAcquireAuthorizeListener
|
||||
*/
|
||||
fun registerAuthorizeListener(tag: String, listener: IMogoAcquireAuthorizeListener) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 反注册授权回调
|
||||
* tag:module tag
|
||||
*/
|
||||
fun unregisterAuthorizeListener(tag: String) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册授权信息内容回调
|
||||
* tag:module tag
|
||||
* @see IMogoAuthorizeContentListener
|
||||
*/
|
||||
fun registerInvokeAuthorizeContentListener(tag: String, listener: IMogoAuthorizeContentListener) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 反注册授权信息内容回调
|
||||
* tag:module tag
|
||||
*/
|
||||
fun unregisterInvokeAuthorizeContentListener(tag: String) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.mogo.module.authorize.authprovider.launcher
|
||||
|
||||
import com.mogo.module.authorize.authprovider.invoke.IMogoAuthorizeInvoke
|
||||
|
||||
//与Biz业务相同接口实现
|
||||
interface IAuthorizeMainInvoke : IMogoAuthorizeInvoke {
|
||||
|
||||
/**
|
||||
* 同意授权
|
||||
* tag:透传模块ID
|
||||
*/
|
||||
fun agreeAuthorize(tag: String, agrId: Long)
|
||||
|
||||
/**
|
||||
* 不同意授权
|
||||
* tag:透传模块ID
|
||||
*/
|
||||
fun disAgreeAuthorize(tag: String, agrId: Long)
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.mogo.module.authorize.authprovider.launcher
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.mogo.module.authorize.authprovider.invoke.AuthorizeConstant
|
||||
import com.mogo.module.authorize.authprovider.invoke.IMogoAuthorizeContentListener
|
||||
import com.mogo.module.authorize.authprovider.launcher.MogoMainAuthorize.Companion.mogoAuthShow
|
||||
|
||||
@Route(path = AuthorizeConstant.PROVIDER_LAUNCHER)
|
||||
class IMogoAuthorizeMainManager : IMogoAuthorizeMainProvider {
|
||||
|
||||
override fun needAuthorize(): Boolean {
|
||||
return mogoAuthShow.needAuthorize()
|
||||
}
|
||||
|
||||
override fun invokeAuthorizeContent(tag: String) {
|
||||
mogoAuthShow.invokeAuthorizeContent(tag)
|
||||
}
|
||||
|
||||
override fun agreeAuthorize(tag: String, agrId: Long) {
|
||||
mogoAuthShow.agreeAuthorize(tag, agrId)
|
||||
}
|
||||
|
||||
override fun disAgreeAuthorize(tag: String, agrId: Long) {
|
||||
mogoAuthShow.disAgreeAuthorize(tag, agrId)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.mogo.module.authorize.authprovider.launcher
|
||||
|
||||
import android.content.Context
|
||||
import com.alibaba.android.arouter.facade.template.IProvider
|
||||
import com.mogo.module.authorize.authprovider.invoke.IMogoAuthorizeInvoke
|
||||
|
||||
//仅提供给调用业务端(主launcher)使用
|
||||
interface IMogoAuthorizeMainProvider : IProvider, IAuthorizeMainInvoke {
|
||||
|
||||
override fun init(context: Context?) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.mogo.module.authorize.authprovider.launcher
|
||||
|
||||
import com.mogo.module.authorize.authprovider.invoke.IMogoAuthorizeForbiddenVoice
|
||||
|
||||
interface IMogoAuthorizeShow : IMogoAuthorizeForbiddenVoice {
|
||||
|
||||
fun showAuthorizeView()
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.mogo.module.authorize.authprovider.launcher
|
||||
|
||||
import com.mogo.module.authorize.authprovider.biz.IMogoAuthorizeController
|
||||
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.net.request
|
||||
import com.mogo.utils.logger.Logger
|
||||
|
||||
object MogoAuthorizeMainController : IMogoAuthorizeController() {
|
||||
|
||||
private val authorizeShowModel: MogoAuthorizeMainModel by lazy { MogoAuthorizeMainModel() }
|
||||
|
||||
@Synchronized
|
||||
fun agreeAuthorize(tag: String, agrId: Long) {
|
||||
val acquireAuthListener = MogoAuthorizeRegisterHandler.getAuthorizeListener(tag)
|
||||
updateAuthorize(agrId, AGREEMENT_EFFECT, {
|
||||
if (acquireAuthListener != null) {
|
||||
acquireAuthListener.authorizeSuccess()
|
||||
} else {
|
||||
Logger.d(TAG, "agreeAuthorize --- can not find listener by this tag :$tag ")
|
||||
}
|
||||
}, {
|
||||
authorizeFailed(tag, it ?: "agreeAuthorize failed,please check network")
|
||||
})
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun disAgreeAuthorize(tag: String, agrId: Long) {
|
||||
updateAuthorize(agrId, AGREEMENT_NOT_EFFECT, {
|
||||
authorizeFailed(tag, "UserDisAgree authorize")
|
||||
}, {
|
||||
authorizeFailed(tag, it ?: "disAgreeAuthorize failed,please check network")
|
||||
})
|
||||
}
|
||||
|
||||
private fun updateAuthorize(agrId: Long, agreementStatus: Int, onSuccess: (() -> Unit), onError: ((String?) -> Unit)) {
|
||||
request<BaseResponse<Any>> {
|
||||
loader {
|
||||
authorizeShowModel.updateAuthorize(agrId, agreementStatus)
|
||||
}
|
||||
onSuccess {
|
||||
onSuccess.invoke()
|
||||
}
|
||||
onError {
|
||||
onError.invoke(it.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun authorizeFailed(tag: String, errorMsg: String) {
|
||||
val acquireAuthorizeListener = MogoAuthorizeRegisterHandler.getAuthorizeListener(tag)
|
||||
if (acquireAuthorizeListener != null) {
|
||||
acquireAuthorizeListener.authorizeFailed(errorMsg)
|
||||
} else {
|
||||
Logger.d(TAG, "disAgreeAuthorize --- can not find listener by this tag :$tag ")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.mogo.module.authorize.authprovider.launcher
|
||||
|
||||
import com.google.gson.Gson
|
||||
import com.mogo.commons.network.Utils.getSn
|
||||
import com.mogo.module.authorize.model.BaseResponse
|
||||
import com.mogo.module.authorize.model.IMogoAuthorizeModel
|
||||
import com.mogo.module.authorize.model.bean.UpdateAuthorize
|
||||
import com.mogo.module.authorize.util.ServiceUtil.getNetWorkApi
|
||||
|
||||
class MogoAuthorizeMainModel : IMogoAuthorizeModel() {
|
||||
|
||||
suspend fun updateAuthorize(agrId: Long, agreementStatus: Int): BaseResponse<Any> {
|
||||
val updateAuthorize = Gson().toJson(UpdateAuthorize(agrId, agreementStatus))
|
||||
val map = mapOf("sn" to getSn(), "data" to updateAuthorize)
|
||||
return apiCall { getNetWorkApi().updateAuthorize(map) }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.mogo.module.authorize.authprovider.launcher
|
||||
|
||||
import android.os.Looper
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.mogo.module.authorize.authprovider.biz.MogoAuthorizeManagerImpl
|
||||
import com.mogo.module.authorize.authprovider.biz.MogoAuthorizeRegisterHandler
|
||||
import com.mogo.module.authorize.fragment.AuthorizeFragment
|
||||
import com.mogo.module.authorize.util.SharedPreferenceUtil.hasAuth
|
||||
import com.mogo.service.IMogoServiceApis
|
||||
import com.mogo.service.MogoServicePaths
|
||||
import com.mogo.service.fragmentmanager.FragmentDescriptor
|
||||
|
||||
class MogoMainAuthorize private constructor() : MogoAuthorizeManagerImpl(), IMogoAuthorizeMainProvider {
|
||||
|
||||
companion object {
|
||||
|
||||
const val TAG = "MogoMainAuthorize"
|
||||
|
||||
val mogoAuthShow by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
|
||||
MogoMainAuthorize()
|
||||
}
|
||||
}
|
||||
|
||||
private var serviceApi: IMogoServiceApis? = null
|
||||
|
||||
override fun agreeAuthorize(tag: String, agrId: Long) {
|
||||
MogoAuthorizeMainController.agreeAuthorize(tag, agrId)
|
||||
}
|
||||
|
||||
override fun disAgreeAuthorize(tag: String, agrId: Long) {
|
||||
MogoAuthorizeMainController.disAgreeAuthorize(tag, agrId)
|
||||
}
|
||||
|
||||
fun showAuthorizeView(tag: String, forbiddenVoice: (() -> Unit), onError: ((String) -> Unit)) {
|
||||
val listener = MogoAuthorizeRegisterHandler.getAuthorizeListener(tag)
|
||||
if (listener == null) {
|
||||
onError.invoke("launcher authorizeShowListener is null,must register in MainActivity")
|
||||
}
|
||||
forbiddenVoice()
|
||||
|
||||
if (Thread.currentThread() != Looper.getMainLooper().thread) {
|
||||
onError.invoke("invoke should be in main thread")
|
||||
}
|
||||
val mogoService = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation()
|
||||
if (mogoService is IMogoServiceApis) {
|
||||
serviceApi = mogoService
|
||||
}
|
||||
if (hasAuth()) {
|
||||
onError.invoke("already authorize,do not repeat operation")
|
||||
}
|
||||
serviceApi?.let {
|
||||
val builderWrapper = FragmentDescriptor.Builder().fragment(AuthorizeFragment()).build()
|
||||
it.fragmentManagerApi.push(builderWrapper)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.mogo.module.authorize.authprovider.module
|
||||
|
||||
import com.mogo.module.authorize.authprovider.invoke.IMogoAuthorizeInvoke
|
||||
|
||||
//与Biz业务相同接口实现
|
||||
interface IAuthorizeModuleInvoke : IMogoAuthorizeInvoke {
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.mogo.module.authorize.authprovider.module
|
||||
|
||||
import com.mogo.module.authorize.authprovider.invoke.IMogoAuthorizeForbiddenVoice
|
||||
|
||||
interface IMogoAcquireAuthorizeListener : IMogoAuthorizeForbiddenVoice {
|
||||
|
||||
fun authorizeSuccess()
|
||||
|
||||
fun authorizeFailed(errorMsg: String)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.mogo.module.authorize.authprovider.module
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.mogo.module.authorize.authprovider.invoke.AuthorizeConstant
|
||||
import com.mogo.module.authorize.authprovider.invoke.IMogoAuthorizeContentListener
|
||||
import com.mogo.module.authorize.authprovider.module.MogoModuleAuthorize.Companion.mogoAuth
|
||||
|
||||
@Route(path = AuthorizeConstant.PROVIDER_MODULE)
|
||||
class IMogoAuthorizeModuleManager : IMogoAuthorizeModuleProvider {
|
||||
|
||||
override fun needAuthorize(): Boolean {
|
||||
return mogoAuth.needAuthorize()
|
||||
}
|
||||
|
||||
override fun invokeAuthorization(tag: String) {
|
||||
mogoAuth.invokeAuthorization(tag)
|
||||
}
|
||||
|
||||
override fun invokeAuthorizeContent(tag: String) {
|
||||
mogoAuth.invokeAuthorizeContent(tag)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.mogo.module.authorize.authprovider.module
|
||||
|
||||
import android.content.Context
|
||||
import com.alibaba.android.arouter.facade.template.IProvider
|
||||
import com.mogo.module.authorize.authprovider.invoke.IMogoAuthorizeInvoke
|
||||
|
||||
////仅提供给调用业务端(module)使用
|
||||
interface IMogoAuthorizeModuleProvider : IProvider, IMogoAuthorizeInvoke {
|
||||
|
||||
override fun init(context: Context) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 调用授权页面
|
||||
*/
|
||||
fun invokeAuthorization(tag: String)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.mogo.module.authorize.authprovider.module
|
||||
|
||||
import com.mogo.module.authorize.authprovider.biz.IMogoAuthorizeController
|
||||
|
||||
object MogoAuthorizeModuleController : IMogoAuthorizeController() {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.mogo.module.authorize.authprovider.module
|
||||
|
||||
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
|
||||
|
||||
class MogoModuleAuthorize private constructor() : MogoAuthorizeManagerImpl(), IMogoAuthorizeModuleProvider {
|
||||
|
||||
companion object {
|
||||
val mogoAuth by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
|
||||
MogoModuleAuthorize()
|
||||
}
|
||||
}
|
||||
|
||||
override fun invokeAuthorization(tag: String) {
|
||||
mogoAuthShow.showAuthorizeView(tag, {
|
||||
//todo SP存储状态
|
||||
}, { errorMsg ->
|
||||
val listener = MogoAuthorizeRegisterHandler.getAuthorizeListener(tag)
|
||||
listener?.authorizeFailed(errorMsg)
|
||||
})
|
||||
}
|
||||
|
||||
fun forbiddenVoiceWhenAuthorize(cmd: String) {
|
||||
val tmpMap = MogoAuthorizeRegisterHandler.getAllAuthorizeListener()
|
||||
if (tmpMap == null || tmpMap.size == 0) {
|
||||
return
|
||||
}
|
||||
tmpMap.forEach {
|
||||
val acquireListener = it.value
|
||||
acquireListener?.forbiddenVoiceWhenAuthorize(cmd)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.mogo.module.authorize.constant
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig
|
||||
|
||||
class HttpConstant {
|
||||
|
||||
companion object {
|
||||
const val HOST_DEV = "http://dzt-test.zhidaohulian.com"
|
||||
const val HOST_TEST = "http://dzt-test.zhidaohulian.com"
|
||||
const val HOST_PRODUCT = "https://dzt.zhidaohulian.com"
|
||||
|
||||
fun getNetHost(): String {
|
||||
return when (DebugConfig.getNetMode()) {
|
||||
DebugConfig.NET_MODE_DEV -> HOST_DEV
|
||||
DebugConfig.NET_MODE_QA -> HOST_TEST
|
||||
else -> HOST_PRODUCT
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.mogo.module.authorize.exception
|
||||
|
||||
|
||||
class ApiException : CommonException {
|
||||
|
||||
companion object {
|
||||
val NULL_REQUEST_DATA_API_EXCEPTION = ApiException(2, "request data is null")
|
||||
val ENTER_ROOM_API_EXCEPTION = ApiException(3, "roomId is null or already enter room")
|
||||
}
|
||||
|
||||
constructor(code: Int, msg: String) : super(code, msg)
|
||||
|
||||
fun getErrorMsg():String{
|
||||
return msg
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.mogo.module.authorize.exception
|
||||
|
||||
open class CommonException : Exception {
|
||||
|
||||
companion object {
|
||||
val NETWORK_EXCEPTION = CommonException(1, "network is error")
|
||||
}
|
||||
|
||||
protected var code: Int = 0
|
||||
protected var msg: String = ""
|
||||
|
||||
constructor(code: Int, msg: String) : super(msg) {
|
||||
this.code = code
|
||||
this.msg = msg
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.mogo.module.authorize.fragment
|
||||
|
||||
import com.mogo.commons.mvp.IView
|
||||
|
||||
class AuthorizeContract {
|
||||
|
||||
interface View : IView {
|
||||
|
||||
}
|
||||
|
||||
interface Biz {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.mogo.module.authorize.fragment
|
||||
|
||||
import android.view.View
|
||||
import com.mogo.commons.mvp.MvpFragment
|
||||
import com.mogo.module.authorize.R
|
||||
|
||||
class AuthorizeFragment : MvpFragment<AuthorizeContract.View, AuthorizePresenter>(), AuthorizeContract.View,View.OnClickListener {
|
||||
|
||||
companion object {
|
||||
const val TAG = "AuthorizeFragment"
|
||||
}
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.module_authorize_fragment
|
||||
}
|
||||
|
||||
override fun initViews() {
|
||||
|
||||
}
|
||||
|
||||
override fun createPresenter(): AuthorizePresenter {
|
||||
return AuthorizePresenter(this)
|
||||
}
|
||||
|
||||
override fun onClick(v: View) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.mogo.module.authorize.fragment
|
||||
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import com.mogo.commons.mvp.Presenter
|
||||
|
||||
class AuthorizePresenter : Presenter<AuthorizeContract.View>, AuthorizeContract.Biz {
|
||||
|
||||
constructor(view: AuthorizeContract.View?) : super(view)
|
||||
|
||||
override fun onCreate(owner: LifecycleOwner) {
|
||||
super.onCreate(owner)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.mogo.module.authorize.model
|
||||
|
||||
open class BaseRepository {
|
||||
|
||||
suspend fun <T : Any> apiCall(call: suspend () -> BaseResponse<T>): BaseResponse<T> {
|
||||
return call.invoke()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.mogo.module.authorize.model
|
||||
|
||||
|
||||
class BaseResponse<out T>(val code: Int, val msg: String, val result: T) {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.mogo.module.authorize.model
|
||||
|
||||
import com.google.gson.Gson
|
||||
import com.mogo.commons.network.Utils.getSn
|
||||
import com.mogo.module.authorize.model.bean.RequestUserAgreement
|
||||
import com.mogo.module.authorize.model.bean.UserAgreement
|
||||
import com.mogo.module.authorize.util.ServiceUtil.getNetWorkApi
|
||||
|
||||
open class IMogoAuthorizeModel : BaseRepository() {
|
||||
|
||||
companion object {
|
||||
const val TAG = "IMogoAuthorizeModel"
|
||||
}
|
||||
|
||||
suspend fun invokeAuthorizeContent(agreementType: Int): BaseResponse<UserAgreement> {
|
||||
val requestUserAgreement = Gson().toJson(RequestUserAgreement(agreementType))
|
||||
val map = mapOf("sn" to getSn(), "data" to requestUserAgreement)
|
||||
return apiCall { getNetWorkApi().getAuthorizeContent(map) }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.mogo.module.authorize.model.bean
|
||||
|
||||
class UpdateAuthorize {
|
||||
var agrId: Long
|
||||
var status: Int
|
||||
|
||||
constructor(agrId: Long, status: Int) {
|
||||
this.agrId = agrId
|
||||
this.status = status
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "UpdateAuthorize(agrId=$agrId, status=$status)"
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.mogo.module.authorize.model.bean
|
||||
|
||||
const val AGREEMENT_EFFECT = 1 //用户协议生效
|
||||
const val AGREEMENT_NOT_EFFECT = 2 //用户协议不生效
|
||||
|
||||
class RequestUserAgreement(val agreementType:Int)
|
||||
|
||||
data class UserAgreement(var agreementEntity: TUserAgreementEntity, var agreementContent: List<String>)
|
||||
|
||||
data class TUserAgreementEntity(
|
||||
val id: Int, //协议ID
|
||||
val title: String, //标题
|
||||
val subhead: String, //副标题
|
||||
val agreementButtonFirst: String, //底部标题1
|
||||
val agreementButtonSecond: String, //底部标题2
|
||||
val agreementType: Int, //协议类型
|
||||
val agreementVersion: String, //协议版本
|
||||
val agreementUserType: String, //协议适用用户
|
||||
val agreementStatus: Int, //协议状态 1:生效 2:未生效
|
||||
val createTime: String, //协议创建时间
|
||||
val updateTime: String) //协议更新时间
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.mogo.module.authorize.model.proxy
|
||||
|
||||
import com.mogo.module.authorize.authprovider.invoke.AuthorizeInvokerConstant.Companion.AUTHORIZE_TYPE_AUXILIARY_DRIVING
|
||||
import com.mogo.module.authorize.authprovider.invoke.AuthorizeInvokerConstant.Companion.AUTHORIZE_TYPE_CALL_CHAT
|
||||
import com.mogo.module.authorize.authprovider.invoke.AuthorizeInvokerConstant.Companion.AUTHORIZE_TYPE_LAUNCHER_MAIN
|
||||
import com.mogo.module.authorize.authprovider.invoke.AuthorizeInvokerConstant.Companion.AUTHORIZE_TYPE_LAUNCHER_SHARE
|
||||
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
|
||||
import java.util.*
|
||||
|
||||
class AuthorizeProxy {
|
||||
|
||||
companion object {
|
||||
var allAuthorizeTypes = HashMap<String, IAuthorizeOperation>()
|
||||
|
||||
fun getAuthorizeType(authorizeName: String): Int {
|
||||
if (authorizeName.isNullOrBlank()) {
|
||||
return -1
|
||||
}
|
||||
return allAuthorizeTypes[authorizeName]!!.getAcquireId()
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
for ((index, type) in AuthorizeEnum.values().withIndex()) {
|
||||
type.getOperationName()?.let {
|
||||
allAuthorizeTypes[it] = type
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum class AuthorizeEnum : IAuthorizeOperation {
|
||||
LAUNCHER_MAIN(0, AUTHORIZE_TYPE_LAUNCHER_MAIN),
|
||||
LAUNCHER_SHARE(0, AUTHORIZE_TYPE_LAUNCHER_SHARE),
|
||||
CALL_CHAT(1, AUTHORIZE_TYPE_TAN_LU),
|
||||
TANLU(2, AUTHORIZE_TYPE_CALL_CHAT),
|
||||
NOVELTY(3, AUTHORIZE_TYPE_NOVELTY),
|
||||
AUXILIARY_DRIVING(4, AUTHORIZE_TYPE_AUXILIARY_DRIVING);
|
||||
|
||||
private var authorizeType = 0
|
||||
private var authorizeName: String? = null
|
||||
|
||||
constructor(authorizeType: Int, authorizeName: String?) {
|
||||
this.authorizeType = authorizeType
|
||||
this.authorizeName = authorizeName
|
||||
}
|
||||
|
||||
override fun getOperationName(): String? {
|
||||
return authorizeName
|
||||
}
|
||||
|
||||
override fun getAcquireId(): Int {
|
||||
return authorizeType
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.mogo.module.authorize.model.proxy
|
||||
|
||||
interface IAuthorizeOperation {
|
||||
|
||||
fun getOperationName(): String?
|
||||
|
||||
fun getAcquireId(): Int
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.mogo.module.authorize.net
|
||||
|
||||
import com.mogo.module.authorize.model.BaseResponse
|
||||
import com.mogo.module.authorize.model.bean.UserAgreement
|
||||
import retrofit2.http.FieldMap
|
||||
import retrofit2.http.FormUrlEncoded
|
||||
import retrofit2.http.POST
|
||||
|
||||
interface AuthorizeApi {
|
||||
|
||||
//获取授权内容
|
||||
@FormUrlEncoded
|
||||
@POST("yycp-channelManager/agreement/findUserAgreement")
|
||||
suspend fun getAuthorizeContent(@FieldMap authorizeContent: Map<String, String>): BaseResponse<UserAgreement>
|
||||
|
||||
//更新授权状态
|
||||
@FormUrlEncoded
|
||||
@POST("yycp-channelManager/agreement/updateStatus")
|
||||
suspend fun updateAuthorize(@FieldMap updateStatus: Map<String, String>): BaseResponse<Any>
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.mogo.module.authorize.net
|
||||
|
||||
import com.mogo.module.authorize.exception.ApiException
|
||||
import com.mogo.module.authorize.exception.ApiException.Companion.NULL_REQUEST_DATA_API_EXCEPTION
|
||||
import com.mogo.module.authorize.exception.CommonException.Companion.NETWORK_EXCEPTION
|
||||
import com.mogo.module.authorize.model.BaseResponse
|
||||
import kotlinx.coroutines.*
|
||||
import java.net.SocketTimeoutException
|
||||
import java.net.UnknownHostException
|
||||
import java.util.concurrent.TimeoutException
|
||||
|
||||
class Request<T> {
|
||||
private lateinit var loader: suspend () -> T
|
||||
|
||||
private var start: (() -> Unit)? = null
|
||||
|
||||
private var onSuccess: ((T) -> Unit)? = null
|
||||
|
||||
private var onError: ((java.lang.Exception) -> Unit)? = null
|
||||
|
||||
private var onComplete: (() -> Unit)? = null
|
||||
|
||||
infix fun loader(loader: suspend () -> T) {
|
||||
this.loader = loader
|
||||
}
|
||||
|
||||
infix fun start(start: (() -> Unit)?) {
|
||||
this.start = start
|
||||
}
|
||||
|
||||
infix fun onSuccess(onSuccess: ((T) -> Unit)?) {
|
||||
this.onSuccess = onSuccess
|
||||
}
|
||||
|
||||
infix fun onError(onError: ((java.lang.Exception) -> Unit)?) {
|
||||
this.onError = onError
|
||||
}
|
||||
|
||||
infix fun onComplete(onComplete: (() -> Unit)?) {
|
||||
this.onComplete = onComplete
|
||||
}
|
||||
|
||||
fun request() {
|
||||
|
||||
GlobalScope.launch(context = Dispatchers.Main) {
|
||||
|
||||
start?.invoke()
|
||||
try {
|
||||
val deferred = GlobalScope.async(Dispatchers.IO, start = CoroutineStart.LAZY) {
|
||||
loader()
|
||||
}
|
||||
val result = deferred.await()
|
||||
if (result != null && result is BaseResponse<*>) {
|
||||
if (result.code == 0) {
|
||||
onSuccess?.invoke(result)
|
||||
} else {
|
||||
throw ApiException(result.code, result.msg)
|
||||
}
|
||||
} else {
|
||||
throw NULL_REQUEST_DATA_API_EXCEPTION
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
when (e) {
|
||||
is UnknownHostException -> onError?.invoke(NETWORK_EXCEPTION)
|
||||
is TimeoutException -> onError?.invoke(NETWORK_EXCEPTION)
|
||||
is SocketTimeoutException -> onError?.invoke(NETWORK_EXCEPTION)
|
||||
else -> onError?.invoke(java.lang.Exception(e.message))
|
||||
}
|
||||
} finally {
|
||||
onComplete?.invoke()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <T> request(buildRequest: Request<T>.() -> Unit) {
|
||||
Request<T>().apply(buildRequest).request()
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.mogo.module.authorize.util
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.mogo.module.authorize.constant.HttpConstant.Companion.getNetHost
|
||||
import com.mogo.module.authorize.net.AuthorizeApi
|
||||
import com.mogo.service.IMogoServiceApis
|
||||
import com.mogo.service.MogoServicePaths
|
||||
|
||||
object ServiceUtil {
|
||||
|
||||
private lateinit var serviceApi: IMogoServiceApis
|
||||
|
||||
init {
|
||||
initMogoService()
|
||||
}
|
||||
|
||||
private fun initMogoService() {
|
||||
if (serviceApi == null) {
|
||||
val mogoService = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation()
|
||||
if (mogoService is IMogoServiceApis) {
|
||||
this.serviceApi = mogoService
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getNetWorkApi(): AuthorizeApi {
|
||||
return serviceApi.networkApi.create(AuthorizeApi::class.java, getNetHost())
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.mogo.module.authorize.util
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.utils.storage.SharedPrefsMgr
|
||||
|
||||
object SharedPreferenceUtil {
|
||||
|
||||
const val HAS_AUTH = "HAS_AUTH"
|
||||
|
||||
fun hasAuth(): Boolean {
|
||||
return SharedPrefsMgr.getInstance(AbsMogoApplication.getApp()).getBoolean(HAS_AUTH, false)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#20ADEE">
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -0,0 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">mogo-module-authorize</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.mogo.module.authorize
|
||||
|
||||
import org.junit.Test
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
class ExampleUnitTest {
|
||||
@Test
|
||||
fun addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2)
|
||||
}
|
||||
}
|
||||
1
modules/mogo-module-guide/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
||||
67
modules/mogo-module-guide/build.gradle
Normal file
@@ -0,0 +1,67 @@
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
apply plugin: 'com.alibaba.arouter'
|
||||
|
||||
android {
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||
versionCode Integer.valueOf(VERSION_CODE)
|
||||
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles 'consumer-rules.pro'
|
||||
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
arguments = [AROUTER_MODULE_NAME: project.getName()]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation rootProject.ext.dependencies.kotlinstdlibjdk7
|
||||
implementation rootProject.ext.dependencies.androidxccorektx
|
||||
implementation rootProject.ext.dependencies.coroutinescore
|
||||
implementation rootProject.ext.dependencies.coroutinesandroid
|
||||
implementation rootProject.ext.dependencies.androidxappcompat
|
||||
implementation rootProject.ext.dependencies.androidxconstraintlayout
|
||||
implementation rootProject.ext.dependencies.androidxviewpager2
|
||||
implementation rootProject.ext.dependencies.arouter
|
||||
annotationProcessor rootProject.ext.dependencies.aroutercompiler
|
||||
|
||||
if (Boolean.valueOf(RELEASE)) {
|
||||
implementation rootProject.ext.dependencies.mogoutils
|
||||
implementation rootProject.ext.dependencies.mogocommons
|
||||
implementation rootProject.ext.dependencies.moduleservice
|
||||
implementation rootProject.ext.dependencies.mogoserviceapi
|
||||
} else {
|
||||
implementation project(":foudations:mogo-utils")
|
||||
implementation project(":foudations:mogo-commons")
|
||||
implementation project(":modules:mogo-module-service")
|
||||
implementation project(':services:mogo-service-api')
|
||||
}
|
||||
}
|
||||
|
||||
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
0
modules/mogo-module-guide/consumer-rules.pro
Normal file
3
modules/mogo-module-guide/gradle.properties
Normal file
@@ -0,0 +1,3 @@
|
||||
GROUP=com.mogo.module
|
||||
POM_ARTIFACT_ID=module-guide
|
||||
VERSION_CODE=1
|
||||
21
modules/mogo-module-guide/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.mogo.module.guide.agreement
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class ExampleInstrumentedTest {
|
||||
@Test
|
||||
fun useAppContext() {
|
||||
// Context of the app under test.
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
assertEquals("com.mogo.module.guide.agreement.test", appContext.packageName)
|
||||
}
|
||||
}
|
||||
1
modules/mogo-module-guide/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1 @@
|
||||
<manifest package="com.mogo.module.guide" />
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.mogo.module.guide
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.mogo.module.guide.fragment.GuideFragment
|
||||
import com.mogo.module.guide.util.SharedPreferenceUtil.hasGuide
|
||||
import com.mogo.service.IMogoServiceApis
|
||||
import com.mogo.service.MogoServicePaths
|
||||
import com.mogo.service.fragmentmanager.FragmentDescriptor
|
||||
|
||||
object GuideBizManager {
|
||||
|
||||
private var serviceApi: IMogoServiceApis? = null
|
||||
|
||||
fun init() {
|
||||
initService()
|
||||
// addGuideFragmentToStack()
|
||||
}
|
||||
|
||||
private fun initService() {
|
||||
val mogoService = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation()
|
||||
if (mogoService is IMogoServiceApis) {
|
||||
serviceApi = mogoService
|
||||
}
|
||||
}
|
||||
|
||||
private fun addGuideFragmentToStack() {
|
||||
if (!hasGuide()) {
|
||||
serviceApi?.let {
|
||||
val builderWrapper = FragmentDescriptor.Builder().fragment(GuideFragment()).build()
|
||||
it.fragmentManagerApi.push(builderWrapper)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.mogo.module.guide
|
||||
|
||||
class GuideConstant {
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* 展示用户引导或者用户协议模块地址
|
||||
*/
|
||||
const val PATH_GUIDE_AGREEMENT_FRAGMENT = "/guideAgreement/showFragment"
|
||||
|
||||
/**
|
||||
* provider模块实例名称(暂时仅有卡片用到)
|
||||
*/
|
||||
const val PATH_GUIDE_AGREEMENT_MODULE_NAME = "GUIDE_AND_AGREEMENT"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.mogo.module.guide
|
||||
|
||||
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.guide.GuideConstant.Companion.PATH_GUIDE_AGREEMENT_FRAGMENT
|
||||
import com.mogo.module.guide.GuideConstant.Companion.PATH_GUIDE_AGREEMENT_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)
|
||||
class MogoGuideProvider : IMogoModuleProvider {
|
||||
|
||||
/**
|
||||
* 卡片用到
|
||||
*/
|
||||
override fun createFragment(context: Context?, data: Bundle?): Fragment? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun createView(context: Context?): View? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun getModuleName(): String {
|
||||
return PATH_GUIDE_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?) {
|
||||
GuideBizManager.init()
|
||||
}
|
||||
|
||||
override fun getAppPackage(): String? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun getAppName(): String? {
|
||||
return null
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.mogo.module.guide.fragment
|
||||
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||
import com.mogo.module.guide.guide.*
|
||||
|
||||
class GuideAdapter(fragmentActivity: FragmentActivity) : FragmentStateAdapter(fragmentActivity) {
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return guideList.size
|
||||
}
|
||||
|
||||
override fun createFragment(position: Int): Fragment {
|
||||
return guideList[position]
|
||||
}
|
||||
|
||||
private val guideList: MutableList<Fragment> = mutableListOf()
|
||||
|
||||
companion object {
|
||||
const val GUIDE_PAGE_START = 0
|
||||
const val GUIDE_PAGE_CARD = 1
|
||||
const val GUIDE_PAGE_ONLINE_CAR = 2
|
||||
const val GUIDE_PAGE_NAVIGATION = 3
|
||||
const val GUIDE_PAGE_LOCATION = 4
|
||||
const val GUIDE_PAGE_APP_LIST = 5
|
||||
const val GUIDE_PAGE_ENTRY_MAIN = 6
|
||||
}
|
||||
|
||||
init {
|
||||
guideList.add(GUIDE_PAGE_START, GuideStartFragment())
|
||||
guideList.add(GUIDE_PAGE_CARD, GuideCardFragment())
|
||||
guideList.add(GUIDE_PAGE_ONLINE_CAR, GuideOnLineCarFragment())
|
||||
guideList.add(GUIDE_PAGE_NAVIGATION, GuideNavigationFragment())
|
||||
guideList.add(GUIDE_PAGE_LOCATION, GuideLocationFragment())
|
||||
guideList.add(GUIDE_PAGE_APP_LIST, GuideAppListFragment())
|
||||
guideList.add(GUIDE_PAGE_ENTRY_MAIN, GuideEntryMainFragment())
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.mogo.module.guide.fragment
|
||||
|
||||
import com.mogo.commons.mvp.IView
|
||||
|
||||
class GuideConstract {
|
||||
|
||||
interface View:IView{
|
||||
|
||||
}
|
||||
|
||||
interface Biz{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.mogo.module.guide.fragment
|
||||
|
||||
import com.mogo.commons.mvp.MvpFragment
|
||||
import com.mogo.module.guide.R
|
||||
import com.mogo.utils.logger.Logger
|
||||
import kotlinx.android.synthetic.main.module_guide_fragment.*
|
||||
|
||||
class GuideFragment : MvpFragment<GuideConstract.View, GuidePresenter>(), GuideConstract.View {
|
||||
|
||||
companion object {
|
||||
const val TAG = "GuideFragment"
|
||||
}
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.module_guide_fragment
|
||||
}
|
||||
|
||||
override fun createPresenter(): GuidePresenter {
|
||||
return GuidePresenter(this)
|
||||
}
|
||||
|
||||
override fun initViews() {
|
||||
Logger.d(TAG, "init Views")
|
||||
// val adapter = GuideAdapter(context!!)
|
||||
// moduleGuideViewPager.adapter = adapter
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.mogo.module.guide.fragment
|
||||
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import com.mogo.commons.mvp.Presenter
|
||||
|
||||
class GuidePresenter : Presenter<GuideConstract.View>, GuideConstract.Biz {
|
||||
|
||||
constructor(view: GuideConstract.View) : super(view)
|
||||
|
||||
companion object{
|
||||
const val TAG = "GuidePresenter"
|
||||
}
|
||||
|
||||
override fun onCreate(owner: LifecycleOwner) {
|
||||
super.onCreate(owner)
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.mogo.module.guide.guide
|
||||
|
||||
import com.mogo.commons.mvp.IView
|
||||
import com.mogo.commons.mvp.MvpFragment
|
||||
import com.mogo.commons.mvp.Presenter
|
||||
import com.mogo.module.guide.R
|
||||
|
||||
class GuideAppListFragment : MvpFragment<IView, Presenter<IView>>() {
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.module_guide_item_app_list
|
||||
}
|
||||
|
||||
override fun createPresenter(): Presenter<IView> {
|
||||
return GuideAppListPresenter(this)
|
||||
}
|
||||
|
||||
override fun initViews() {
|
||||
|
||||
}
|
||||
|
||||
class GuideAppListPresenter : Presenter<IView> {
|
||||
|
||||
constructor(view: IView?) : super(view)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.mogo.module.guide.guide
|
||||
|
||||
import com.mogo.commons.mvp.IView
|
||||
import com.mogo.commons.mvp.MvpFragment
|
||||
import com.mogo.commons.mvp.Presenter
|
||||
import com.mogo.module.guide.R
|
||||
|
||||
class GuideCardFragment : MvpFragment<IView, Presenter<IView>>() {
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.module_guide_item_card
|
||||
}
|
||||
|
||||
override fun createPresenter(): Presenter<IView> {
|
||||
return GuideCardPresenter(this)
|
||||
}
|
||||
|
||||
override fun initViews() {
|
||||
|
||||
}
|
||||
|
||||
class GuideCardPresenter : Presenter<IView> {
|
||||
|
||||
constructor(view: IView?) : super(view)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.mogo.module.guide.guide
|
||||
|
||||
import com.mogo.commons.mvp.IView
|
||||
import com.mogo.commons.mvp.MvpFragment
|
||||
import com.mogo.commons.mvp.Presenter
|
||||
import com.mogo.module.guide.R
|
||||
|
||||
class GuideEntryMainFragment : MvpFragment<IView, Presenter<IView>>() {
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.module_guide_item_entry_main
|
||||
}
|
||||
|
||||
override fun createPresenter(): Presenter<IView> {
|
||||
return GuideEntryPresenter(this)
|
||||
}
|
||||
|
||||
override fun initViews() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
class GuideEntryPresenter : Presenter<IView> {
|
||||
|
||||
constructor(view: IView?) : super(view)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.mogo.module.guide.guide
|
||||
|
||||
import com.mogo.commons.mvp.IView
|
||||
import com.mogo.commons.mvp.MvpFragment
|
||||
import com.mogo.commons.mvp.Presenter
|
||||
import com.mogo.module.guide.R
|
||||
|
||||
class GuideLocationFragment : MvpFragment<IView, Presenter<IView>>() {
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.module_guide_item_location
|
||||
}
|
||||
|
||||
override fun createPresenter(): Presenter<IView> {
|
||||
return GuideLocationPresenter(this)
|
||||
}
|
||||
|
||||
override fun initViews() {
|
||||
|
||||
}
|
||||
|
||||
class GuideLocationPresenter : Presenter<IView> {
|
||||
|
||||
constructor(view: IView?) : super(view)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.mogo.module.guide.guide
|
||||
|
||||
import com.mogo.commons.mvp.IView
|
||||
import com.mogo.commons.mvp.MvpFragment
|
||||
import com.mogo.commons.mvp.Presenter
|
||||
import com.mogo.module.guide.R
|
||||
|
||||
class GuideNavigationFragment : MvpFragment<IView, Presenter<IView>>() {
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.module_guide_item_navigation
|
||||
}
|
||||
|
||||
override fun createPresenter(): Presenter<IView> {
|
||||
return GuideNavigationPresenter(this)
|
||||
}
|
||||
|
||||
override fun initViews() {
|
||||
|
||||
}
|
||||
|
||||
class GuideNavigationPresenter : Presenter<IView> {
|
||||
|
||||
constructor(view: IView?) : super(view)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.mogo.module.guide.guide
|
||||
|
||||
import com.mogo.commons.mvp.IView
|
||||
import com.mogo.commons.mvp.MvpFragment
|
||||
import com.mogo.commons.mvp.Presenter
|
||||
import com.mogo.module.guide.R
|
||||
|
||||
class GuideOnLineCarFragment : MvpFragment<IView, Presenter<IView>>() {
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.module_guide_item_online_car
|
||||
}
|
||||
|
||||
override fun createPresenter(): Presenter<IView> {
|
||||
return GuideOnLineCarPresenter(this)
|
||||
}
|
||||
|
||||
override fun initViews() {
|
||||
|
||||
}
|
||||
|
||||
class GuideOnLineCarPresenter : Presenter<IView> {
|
||||
|
||||
constructor(view: IView?) : super(view)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.mogo.module.guide.guide
|
||||
|
||||
import com.mogo.commons.mvp.IView
|
||||
import com.mogo.commons.mvp.MvpFragment
|
||||
import com.mogo.commons.mvp.Presenter
|
||||
import com.mogo.module.guide.R
|
||||
|
||||
class GuideStartFragment : MvpFragment<IView, Presenter<IView>>() {
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.module_guide_item_start
|
||||
}
|
||||
|
||||
override fun createPresenter(): Presenter<IView> {
|
||||
return GuideStartPresenter(this)
|
||||
}
|
||||
|
||||
override fun initViews() {
|
||||
|
||||
}
|
||||
|
||||
class GuideStartPresenter : Presenter<IView> {
|
||||
|
||||
constructor(view: IView?) : super(view)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.mogo.module.guide.util
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.utils.storage.SharedPrefsMgr
|
||||
|
||||
object SharedPreferenceUtil {
|
||||
|
||||
const val HAS_GUIDE = "HAS_GUIDE"
|
||||
|
||||
fun hasGuide(): Boolean {
|
||||
return SharedPrefsMgr.getInstance(AbsMogoApplication.getApp()).getBoolean(HAS_GUIDE, false)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true">
|
||||
<shape>
|
||||
<corners android:radius="@dimen/dp_53" />
|
||||
<gradient android:endColor="#FF31A8AA" android:startColor="#FF0068CB" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape>
|
||||
<corners android:radius="@dimen/dp_53" />
|
||||
<gradient android:endColor="#5CC1FF" android:startColor="#3E7FFC" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?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:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/moduleGuideViewPager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,34 @@
|
||||
<?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:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@mipmap/module_guide_item_app_list">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/moduleGuideAppListNext"
|
||||
android:layout_width="@dimen/dp_299"
|
||||
android:layout_height="@dimen/dp_106"
|
||||
android:layout_marginRight="@dimen/dp_521"
|
||||
android:layout_marginBottom="@dimen/dp_132"
|
||||
android:background="@drawable/module_guide_selector_blue"
|
||||
android:gravity="center"
|
||||
android:text="@string/module_guide_item_next_step"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="@dimen/dp_44"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/moduleGuideAppListSkip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_77"
|
||||
android:layout_marginRight="@dimen/dp_77"
|
||||
android:gravity="center"
|
||||
android:text="@string/module_guide_skip"
|
||||
android:textColor="@color/module_guide_blue_3B91FF"
|
||||
android:textSize="@dimen/dp_44"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -0,0 +1,34 @@
|
||||
<?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:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@mipmap/module_guide_item_card">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/moduleGuideCardNext"
|
||||
android:layout_width="@dimen/dp_299"
|
||||
android:layout_height="@dimen/dp_106"
|
||||
android:layout_marginRight="@dimen/dp_592"
|
||||
android:layout_marginBottom="@dimen/dp_205"
|
||||
android:background="@drawable/module_guide_selector_blue"
|
||||
android:gravity="center"
|
||||
android:text="@string/module_guide_item_next_step"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="@dimen/dp_44"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/moduleGuideCardSkip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_77"
|
||||
android:layout_marginRight="@dimen/dp_77"
|
||||
android:gravity="center"
|
||||
android:text="@string/module_guide_skip"
|
||||
android:textColor="@color/module_guide_blue_3B91FF"
|
||||
android:textSize="@dimen/dp_44"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@mipmap/module_guide_item_entry_main">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/moduleGuideEntryMain"
|
||||
android:layout_width="@dimen/dp_299"
|
||||
android:layout_height="@dimen/dp_106"
|
||||
android:layout_marginBottom="@dimen/dp_132"
|
||||
android:background="@drawable/module_guide_selector_blue"
|
||||
android:gravity="center"
|
||||
android:text="@string/module_guide_item_entry_main"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="@dimen/dp_44"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -0,0 +1,34 @@
|
||||
<?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:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@mipmap/module_guide_item_location">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/moduleGuideLocationNext"
|
||||
android:layout_width="@dimen/dp_299"
|
||||
android:layout_height="@dimen/dp_106"
|
||||
android:layout_marginLeft="@dimen/dp_787"
|
||||
android:layout_marginBottom="@dimen/dp_125"
|
||||
android:background="@drawable/module_guide_selector_blue"
|
||||
android:gravity="center"
|
||||
android:text="@string/module_guide_item_next_step"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="@dimen/dp_44"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/moduleGuideLocationSkip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_77"
|
||||
android:layout_marginRight="@dimen/dp_77"
|
||||
android:gravity="center"
|
||||
android:text="@string/module_guide_skip"
|
||||
android:textColor="@color/module_guide_blue_3B91FF"
|
||||
android:textSize="@dimen/dp_44"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -0,0 +1,34 @@
|
||||
<?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:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@mipmap/module_guide_item_navigation">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/moduleGuideNavigationNext"
|
||||
android:layout_width="@dimen/dp_299"
|
||||
android:layout_height="@dimen/dp_106"
|
||||
android:layout_marginLeft="@dimen/dp_787"
|
||||
android:layout_marginBottom="@dimen/dp_125"
|
||||
android:background="@drawable/module_guide_selector_blue"
|
||||
android:gravity="center"
|
||||
android:text="@string/module_guide_item_next_step"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="@dimen/dp_44"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/moduleGuideNavigationSkip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_77"
|
||||
android:layout_marginRight="@dimen/dp_77"
|
||||
android:gravity="center"
|
||||
android:text="@string/module_guide_skip"
|
||||
android:textColor="@color/module_guide_blue_3B91FF"
|
||||
android:textSize="@dimen/dp_44"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -0,0 +1,34 @@
|
||||
<?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:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@mipmap/module_guide_item_online_car">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/moduleGuideOnLineCarNext"
|
||||
android:layout_width="@dimen/dp_299"
|
||||
android:layout_height="@dimen/dp_106"
|
||||
android:layout_marginLeft="@dimen/dp_850"
|
||||
android:layout_marginBottom="@dimen/dp_95"
|
||||
android:background="@drawable/module_guide_selector_blue"
|
||||
android:gravity="center"
|
||||
android:text="@string/module_guide_item_next_step"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="@dimen/dp_44"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/moduleGuideOnLineCarSkip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_77"
|
||||
android:layout_marginRight="@dimen/dp_77"
|
||||
android:gravity="center"
|
||||
android:text="@string/module_guide_skip"
|
||||
android:textColor="@color/module_guide_blue_3B91FF"
|
||||
android:textSize="@dimen/dp_44"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:background="@mipmap/module_guide_item_start"
|
||||
android:layout_height="match_parent"/>
|
||||
|
After Width: | Height: | Size: 322 KiB |
|
After Width: | Height: | Size: 423 KiB |
|
After Width: | Height: | Size: 329 KiB |
|
After Width: | Height: | Size: 386 KiB |
|
After Width: | Height: | Size: 320 KiB |
|
After Width: | Height: | Size: 335 KiB |
|
After Width: | Height: | Size: 311 KiB |
1046
modules/mogo-module-guide/src/main/res/values-ldpi-v4/dimens.xml
Normal file
1054
modules/mogo-module-guide/src/main/res/values-xhdpi-v4/dimens.xml
Normal file
4
modules/mogo-module-guide/src/main/res/values/color.xml
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="module_guide_blue_3B91FF">#3B91FF</color>
|
||||
</resources>
|
||||
@@ -0,0 +1,6 @@
|
||||
<resources>
|
||||
<string name="app_name">mogo-module-guide-agreement</string>
|
||||
<string name="module_guide_item_entry_main">进入首页</string>
|
||||
<string name="module_guide_item_next_step">下一步</string>
|
||||
<string name="module_guide_skip">跳过教程</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.mogo.module.guide.agreement
|
||||
|
||||
import org.junit.Test
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
class ExampleUnitTest {
|
||||
@Test
|
||||
fun addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2)
|
||||
}
|
||||
}
|
||||