chore: 重构项目版本状态逻辑,更改为打包时自动修改
This commit is contained in:
@ -9,8 +9,6 @@ import com.quyunshuo.androidbaseframemvvm.buildsrc.*
|
||||
android {
|
||||
|
||||
defaultConfig {
|
||||
// 相关自定义配置
|
||||
resValue "string", "VERSION_STATUS", ProjectBuildConfig.versionStatus
|
||||
resValue "string", "BUGLY_APP_ID", SDKKeyConfig.BUGLY_APP_ID
|
||||
}
|
||||
|
||||
|
||||
@ -27,11 +27,6 @@ import com.tencent.smtt.sdk.QbSdk.PreInitCallback
|
||||
@AutoService(ApplicationLifecycle::class)
|
||||
class CommonApplication : ApplicationLifecycle {
|
||||
|
||||
/**
|
||||
* 项目当前的版本状态
|
||||
*/
|
||||
val versionStatus: String by lazy { BaseApplication.context.getString(R.string.VERSION_STATUS) }
|
||||
|
||||
companion object {
|
||||
// 全局CommonApplication
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
@ -132,7 +127,7 @@ class CommonApplication : ApplicationLifecycle {
|
||||
*/
|
||||
private fun initARouter(): String {
|
||||
// 测试环境下打开ARouter的日志和调试模式 正式环境需要关闭
|
||||
if (versionStatus == VersionStatus.ALPHA || versionStatus == VersionStatus.BETA) {
|
||||
if (BuildConfig.VERSION_TYPE != VersionStatus.RELEASE) {
|
||||
ARouter.openLog() // 打印日志
|
||||
ARouter.openDebug() // 开启调试模式(如果在InstantRun模式下运行,必须开启调试模式!线上版本需要关闭,否则有安全风险)
|
||||
}
|
||||
@ -150,7 +145,7 @@ class CommonApplication : ApplicationLifecycle {
|
||||
CrashReport.initCrashReport(
|
||||
BaseApplication.context,
|
||||
BaseApplication.context.getString(R.string.BUGLY_APP_ID),
|
||||
versionStatus == VersionStatus.ALPHA || versionStatus == VersionStatus.BETA
|
||||
BuildConfig.VERSION_TYPE != VersionStatus.RELEASE
|
||||
)
|
||||
return "Bugly -->> init complete"
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.quyunshuo.androidbaseframemvvm.common.di
|
||||
|
||||
import com.quyunshuo.androidbaseframemvvm.base.BuildConfig
|
||||
import com.quyunshuo.androidbaseframemvvm.base.constant.VersionStatus
|
||||
import com.quyunshuo.androidbaseframemvvm.common.constant.NetBaseUrlConstant
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
@ -34,7 +35,7 @@ class DINetworkModule {
|
||||
@Provides
|
||||
fun provideOkHttpClient(): OkHttpClient {
|
||||
// 日志拦截器部分
|
||||
val level = if (BuildConfig.DEBUG) BODY else NONE
|
||||
val level = if (BuildConfig.VERSION_TYPE != VersionStatus.RELEASE) BODY else NONE
|
||||
val logInterceptor = HttpLoggingInterceptor().setLevel(level)
|
||||
|
||||
return OkHttpClient.Builder()
|
||||
|
||||
Reference in New Issue
Block a user