plugins {
    id 'com.android.application'
    id 'dagger.hilt.android.plugin'
    id 'stringfog'
    id 'com.didi.dokit'
}

def LOCAL = "local", TEST = "test", PROD = "prod"

def getServerHost(String env) {
    switch (env) {
        case "local":
            return "$local_server_host";
        case "test":
            return "$test_server_host";
        case "prod":
            return "$prod_server_host";
        default:
            return "$prod_server_host";
    }
}


android {
    namespace 'com.datarecovery.master'
    compileSdk rootProject.compileSdkVersion

    defaultConfig {
        applicationId rootProject.applicationId
        minSdk rootProject.minSdkVersion
        targetSdk rootProject.targetSdkVersion
        versionCode rootProject.versionCode
        versionName rootProject.versionName

        ndk {
            //noinspection ChromeOsAbiSupport
            abiFilters "arm64-v8a"
        }
    }

    signingConfigs {
        debug {
            storeFile file("keystore/recover.jks")
            storePassword "recover888"
            keyAlias "recover"
            keyPassword "recover888"
        }
        release {
            storeFile file("keystore/recover.jks")
            storePassword "recover888"
            keyAlias "recover"
            keyPassword "recover888"
        }
    }


    def env_release = PROD
    def env_debug = PROD

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release

            buildConfigField "String", "ENV", "\"$env_release\""
            buildConfigField "String", "HOST", "\"${getServerHost(env_release)}\""
            buildConfigField "String", "LOCAL", "\"$LOCAL\""
            buildConfigField "String", "TEST", "\"$TEST\""
            buildConfigField "String", "PROD", "\"$PROD\""
            buildConfigField "String", "WECHAT_APP_ID", "\"$wechat_app_id\""
            buildConfigField "String", "WECHAT_KF_ID", "\"$wechat_kf_id\""
            buildConfigField "String", "WEWORK_CROP_ID", "\"$wework_crop_id\""
            buildConfigField "String", "GRAVITY_ACCESS_TOKEN", "\"$gravity_access_token\""
            buildConfigField "String", "BUGLY_APP_ID", "\"$bugly_app_id\""
            buildConfigField "String", "UMENG_APP_KEY", "\"$umeng_app_key\""
            buildConfigField "String", "QIYU_APP_KEY", "\"$qiyu_app_key\""
            buildConfigField "String", "ATMOB_CENTRAL_KEY", "\"$atmob_central_key\""
            buildConfigField "String", "QUICK_LOGIN_ID", "\"$quick_login_id\""
        }

        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.debug

            buildConfigField "String", "ENV", "\"$env_debug\""
            buildConfigField "String", "HOST", "\"${getServerHost(env_debug)}\""
            buildConfigField "String", "LOCAL", "\"$LOCAL\""
            buildConfigField "String", "TEST", "\"$TEST\""
            buildConfigField "String", "PROD", "\"$PROD\""
            buildConfigField "String", "WECHAT_APP_ID", "\"$wechat_app_id\""
            buildConfigField "String", "WECHAT_KF_ID", "\"$wechat_kf_id\""
            buildConfigField "String", "WEWORK_CROP_ID", "\"$wework_crop_id\""
            buildConfigField "String", "GRAVITY_ACCESS_TOKEN", "\"$gravity_access_token\""
            buildConfigField "String", "BUGLY_APP_ID", "\"$bugly_app_id\""
            buildConfigField "String", "UMENG_APP_KEY", "\"$umeng_app_key\""
            buildConfigField "String", "QIYU_APP_KEY", "\"$qiyu_app_key\""
            buildConfigField "String", "ATMOB_CENTRAL_KEY", "\"$atmob_central_key\""
            buildConfigField "String", "QUICK_LOGIN_ID", "\"$quick_login_id\""
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    buildFeatures {
        viewBinding true
        dataBinding true
    }

    applicationVariants.configureEach { variant ->
        def date = new Date().format("YYMMddHHmmss")
        def server = variant.buildType.name == "release" ? env_release : env_debug
        variant.outputs.configureEach {
            def fileName = "${defaultConfig.applicationId}" +
                    "-v${defaultConfig.versionName}" +
                    "-${variant.buildType.name}" +
                    "-${server}" +
                    "-${date}" +
                    ".apk"
            outputFileName = fileName
        }
    }

    sourceSets {
        main { jniLibs.srcDirs = ['libs'] }
    }

    configurations.configureEach {
        resolutionStrategy {
            // don't cache changing modules at all
            cacheChangingModulesFor 10, 'seconds'
        }
    }
}

import com.github.megatronking.stringfog.plugin.kg.RandomKeyGenerator

stringfog {
    implementation 'com.github.megatronking.stringfog.xor.StringFogImpl'
    fogPackages = ['com.datarecovery.master']
    debug false
    enable true
    kg new RandomKeyGenerator()
    mode base64
}

dependencies {
    //jar or aar
    implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')

    //Atmob SDK
    implementation 'extra.common:base:1.0.0-SNAPSHOT'
    implementation "extra.pack:channel:1.1.0-SNAPSHOT"
    implementation "extra.common:core:2.0.4-SNAPSHOT" //base utils
    implementation "extra.common:network:1.1.0-SNAPSHOT"
    implementation "extra.common:rxjava:1.1.0-SNAPSHOT"
    implementation("plus.pay:pay:1.1.0-SNAPSHOT") {
        exclude group: 'third.pay', module: 'ali'
    }
    api 'com.alipay.sdk:alipaysdk-android:15.8.16@aar'

    //中台sdk
    implementation "atmob.central:core:1.0.8-SNAPSHOT"
    //字节 融合归因
    implementation 'atmob.sdk:app-convert:2.0.0-SNAPSHOT'
    //引力引擎
    implementation 'atmob.sdk:gravity-engine:4.8.25-SNAPSHOT'

    //oaid
    implementation "extra.common:oaid:1.2.0-SNAPSHOT"

    //AppCompat
    implementation "androidx.appcompat:appcompat:$rootProject.appcompat_version"

    //Material
    implementation "com.google.android.material:material:$rootProject.material_version"

    //RecyclerView
    implementation "androidx.recyclerview:recyclerview:$rootProject.recyclerview_version"

    //ConstraintLayout
    implementation "androidx.constraintlayout:constraintlayout:$rootProject.constraintlayout_version"

    //Gson
    implementation "com.google.code.gson:gson:$rootProject.gson_version"

    //Lifecycle
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$rootProject.lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-livedata:$rootProject.lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-reactivestreams:$rootProject.lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-process:$rootProject.lifecycle_version"

    //Hilt
    implementation "com.google.dagger:hilt-android:$rootProject.hilt_version"
    annotationProcessor "com.google.dagger:hilt-compiler:$rootProject.hilt_version"

    //Glide
    implementation "com.github.bumptech.glide:glide:$rootProject.glide_version"
    annotationProcessor "com.github.bumptech.glide:compiler:$rootProject.glide_version"

    //MMKV
    implementation "com.tencent:mmkv:$rootProject.mmkv_version"

    //immersionbar
    implementation "com.gyf.immersionbar:immersionbar:$rootProject.immersionbar_version"
    implementation "com.gyf.immersionbar:immersionbar-components:$rootProject.immersionbar_version"

    //字符串加密算法
    implementation "com.github.megatronking.stringfog:xor:$rootProject.stringfog_verstion"

    //RefreshLayout
    implementation "androidx.swiperefreshlayout:swiperefreshlayout:$rootProject.swiperefreshlayout_version"

    //PhotoView
    implementation 'com.github.chrisbanes:PhotoView:2.3.0'

    //zxing
    implementation "third.zxing:zxing:3.5.1"

    //Umeng
    dependencies {
        // 友盟基础组件库（所有友盟业务SDK都依赖基础组件库）
        implementation 'com.umeng.umsdk:common:9.6.7'
        implementation 'com.umeng.umsdk:asms:1.8.0'
        implementation 'com.umeng.umsdk:apm:1.9.4'
    }

    //Bugly
    implementation "com.tencent.bugly:crashreport:$rootProject.bugly_version"

    //SVGA
    implementation 'com.github.svga:SVGAPlayer-Android:2.6.1'

    //网易七鱼客服
    implementation 'com.qiyukf.unicorn:unicorn:9.2.0'

    //dokit
    debugImplementation("io.github.didi.dokit:dokitx:$rootProject.dokit_version")
            {
                exclude group: 'com.google.zxing', module: 'core'
            }
    releaseImplementation("io.github.didi.dokit:dokitx-no-op:$rootProject.dokit_version")

    //网易一键登录
    implementation 'io.github.yidun:quicklogin:3.5.4'
}