plugins {
    id 'com.android.application'
}

def releaseTime() {
    return new Date().format("yyyyMMddHHmmss", TimeZone.getTimeZone("CTT"))
}

android {
    compileSdkVersion 31

    defaultConfig {
        applicationId "com.edufound.reader"
        minSdkVersion 21 //>23导致无法直接签名
        targetSdkVersion 31
        versionCode 32
        versionName "3.2"
        flavorDimensions "versionCode"
        manifestPlaceholders = [UMENG_CHANNEL_VALUE: "2006"]//添加一个默认渠道号
        ndk {
            //只有联想pad需要arm64-v8a,小米音箱、天猫音箱、百度音箱、不需要arm64-v8a
            abiFilters "armeabi-v7a",  "armeabi","x86","x86_64"
        }
        multiDexEnabled true
    }
    signingConfigs {
        efunboxKey {
            keyAlias "edufound_key"
            keyPassword "edufound321"
            storeFile file("C:/Users/candy/Desktop/efunbox/edufound.keystore")
            storePassword "edufound123"
            v1SigningEnabled true
            v2SigningEnabled true


        }

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.efunboxKey
            applicationVariants.all { variant ->
                variant.outputs.each { output ->
                    def outputFile = output.outputFileName
                    if (outputFile != null && output.outputFileName.endsWith('.apk')) {
                        def fileName = "efunbox_reader_v${defaultConfig.versionCode}_${releaseTime()}_${variant.productFlavors[0].manifestPlaceholders.UMENG_CHANNEL_VALUE}_r.apk"
                        def channel = variant.productFlavors[0].manifestPlaceholders.UMENG_CHANNEL_VALUE;
                        def newoutputFile = "";
                        if (channel == ("2006")) {
                            newoutputFile = "\\义方\\"
                        } else if (channel == ("3002")) {
                            newoutputFile = "\\天猫精灵\\"
                        } else if (channel == ("3003")) {
                            newoutputFile = "\\小度音响\\"
                        } else if (channel == ("2016")) {
                            newoutputFile = "\\小爱音响\\"
                        } else if (channel == ("3004")) {
                            newoutputFile = "\\联想pad\\"
                        } else if (channel == ("3007")) {
                            newoutputFile = "\\京东方\\"
                        } else if (channel == ("3008")) {
                            newoutputFile = "\\华为pad联运\\"
                        } else if (channel == ("3009")) {
                            newoutputFile = "\\步步高\\"
                        }
                        output.outputFileName = new File(newoutputFile, fileName)
                    }
                }

            }

        }
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.efunboxKey
            zipAlignEnabled true
        }
    }
    packagingOptions {
        doNotStrip "*/armeabi/*.so"
        doNotStrip "*/armeabi-v7a/*.so"
        doNotStrip "*/arm64-v8a/*.so"
        doNotStrip "*/x86/*.so"
        doNotStrip "*/x86_64/*.so"
    }


    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
            res.srcDirs = [
                    'src/main/res', //默认只有这一个路径
                    'src/fragmentRecommend',   //首页推荐
                    'src/fragmentUser',//首页我的
                    'src/activityLoginAlert',//登录弹窗
                    'src/exception',//异常弹窗
                    'src/testimg'//测试图片
            ]
        }
    }

    productFlavors {
        //义方
        channel_efunbox {
            signingConfig signingConfigs.efunboxKey
            manifestPlaceholders = [
                    appCode: "3006",
                    appIcon: "@drawable/icon",
            ]
        }
        //百度(小度音响)
        channel_baidu {
            signingConfig signingConfigs.efunboxKey
            manifestPlaceholders = [
                    appCode: "3003",
                    appIcon: "@drawable/icon",
            ]
        }
        //天猫精灵
        channel_tmail {
            signingConfig signingConfigs.efunboxKey
            manifestPlaceholders = [
                    appCode: "3002",
                    appIcon: "@drawable/icon",
            ]
        }
        //小爱音响
        channel_xayx {
            applicationIdSuffix ".xiaoai"
            signingConfig signingConfigs.efunboxKey
            manifestPlaceholders = [
                    appCode: "2016",
                    appIcon: "@drawable/icon",
            ]
        }
        //联想渠道
        channel_lenovo {
            signingConfig signingConfigs.efunboxKey
            manifestPlaceholders = [
                    appCode: "3004",
                    appIcon: "@drawable/icon",
            ]
        }

        //京东方
        channel_jingdongfang {
            signingConfig signingConfigs.efunboxKey
            manifestPlaceholders = [
                    appCode: "3007",
                    appIcon: "@drawable/icon",
            ]
        }

        //华为Pad联运
        channel_huawei {
            applicationIdSuffix ".huawei"
            signingConfig signingConfigs.efunboxKey
            manifestPlaceholders = [
                    appCode: "3008",
                    appIcon: "@drawable/icon",
            ]
        }
        //华为Pad联运
        channel_bubugao {
            signingConfig signingConfigs.efunboxKey
            manifestPlaceholders = [
                    appCode: "3009",
                    appIcon: "@drawable/icon",
            ]
        }
    }
    productFlavors.all {
        flavor -> flavor.manifestPlaceholders = [UMENG_CHANNEL_VALUE: manifestPlaceholders.appCode, icon: manifestPlaceholders.appIcon]
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    aaptOptions {
        additionalParameters = ["--warn-manifest-validation"]

    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'com.github.bumptech.glide:glide:4.12.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
    implementation 'jp.wasabeef:glide-transformations:4.3.0'
    implementation('com.zhousf.lib:okhttp3:2.9.9') {
        exclude(module: 'support-annotations')
        exclude(module: 'gson')
    }
    //gson
    implementation 'com.google.code.gson:gson:2.8.9'
    //logger
    implementation 'com.orhanobut:logger:2.2.0'
    //mmkv
    implementation 'com.tencent:mmkv:1.2.11'
    implementation 'com.uber.autodispose2:autodispose:2.0.0'
    implementation 'com.uber.autodispose2:autodispose-android:2.0.0'
    implementation 'com.uber.autodispose2:autodispose-lifecycle:2.0.0'
    implementation 'com.uber.autodispose2:autodispose-androidx-lifecycle:2.0.0'
    // 友盟基础组件库(所有友盟业务SDK都依赖基础组件库)
    implementation 'com.umeng.umsdk:common:9.4.4'// (必选)
    implementation 'com.umeng.umsdk:asms:1.4.1'// asms包依赖必选

    // required, enough for most devices.
    implementation 'tv.danmaku.ijk.media:ijkplayer-java:0.8.8'
    // ExoPlayer as IMediaPlayer: optional, experimental
    implementation 'tv.danmaku.ijk.media:ijkplayer-exo:0.8.8'

    //JZ播放器
    implementation 'cn.jzvd:jiaozivideoplayer:7.7.0'

    //recyclerview
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    //驰声
    implementation 'io.github.ChivoxSupport:vox-sdk:2.2.23+2.0.8.1'


    //rxBind
    implementation 'com.jakewharton.rxbinding4:rxbinding:4.0.0'
    implementation 'com.trello.rxlifecycle4:rxlifecycle:4.0.2'
    implementation 'com.trello.rxlifecycle4:rxlifecycle-android:4.0.2'


    implementation "androidx.constraintlayout:constraintlayout:2.1.1"
    // To use constraintlayout in compose
    implementation "androidx.constraintlayout:constraintlayout-compose:1.0.0-rc01"


    //解除Android P 反射机制
    implementation 'com.github.tiann:FreeReflection:3.1.0'


    //百度(小度音响SDK)
    implementation 'com.baidu.duer.botsdk:bot-sdk-android:1.56.1'
    // 3rd Party
    implementation "com.alibaba:fastjson:${FASTJSON_VERSION}"

    //zxing
    implementation 'com.google.zxing:android-core:3.3.0'
    implementation 'com.google.zxing:core:3.3.2'

    implementation files('libs/gcs-authservice-1.0.0.21.jar')
    implementation files('libs/registry-api-1.1.16-20201203.085134-3.jar')
    implementation files('libs/aranger.jar')

    //小米音响
    implementation files('libs/thirdparty-payment-sdk-2.1.1-20200527.030546-1.jar')

    //超长图imageview
    implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.5.0'


    // 1. Use Guava in your implementation only:
    implementation("com.google.guava:guava:31.1-jre")
    implementation("com.google.guava:guava:31.1-android")

    //FloatingViewLib(https://github.com/UFreedom/FloatingView/blob/master/README_CN.md)
    implementation 'com.ufreedom.uikit:FloatingViewLib:1.0.2'

    //SimpleRatingBar(https://github.com/williamyyu/SimpleRatingBar)
    implementation 'com.github.ome450901:SimpleRatingBar:1.4.0'
}