apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

def appName() {
    return "CubeZYAppStore"
}

def releaseTime() {
    return new Date().format("yyyyMMdd-HHmmss", TimeZone.getDefault())
}

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"
    defaultConfig {
        applicationId "com.uiui.zyappstore"
        minSdkVersion 26
        targetSdkVersion 29

        versionCode 1
        versionName "1.0.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        ndk {
            //选择要添加的对应 cpu 类型的 .so 库。
            abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a'
            // 还可以添加 'x86', 'x86_64', 'mips', 'mips64'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    lintOptions {
        checkReleaseBuilds false
    }

    //签名
    signingConfigs {
        MTK {
            storeFile file("keystore/TeclastMTK12.jks")
            storePassword "123456"
            keyAlias "TeclastMTK12"
            keyPassword "123456"
            v2SigningEnabled false
        }

        mtk12 {
            storeFile file("keystore/mtkAndroid12.keystore")
            storePassword "123456"
            keyAlias "mtk12"
            keyPassword "123456"
            v2SigningEnabled false
        }

        cube8183 {
            storeFile file("keystore/TeclastMTK12.jks")
            storePassword "123456"
            keyAlias "TeclastMTK12"
            keyPassword "123456"
            v2SigningEnabled false
        }

        teclast8183 {
            storeFile file("keystore/TeclastMTK12.jks")
            storePassword "123456"
            keyAlias "TeclastMTK12"
            keyPassword "123456"
            v2SigningEnabled false
        }

        Teclast8515 {
            storeFile file("keystore/Teclast8515.keystore")
            storePassword "123456"
            keyAlias "Teclast8515"
            keyPassword "123456"
            v1SigningEnabled true
            v2SigningEnabled true
        }

        iPlay50SE {
            storeFile file("keystore/iPlay50SE.keystore")
            storePassword "123456"
            keyAlias "iplay50se"
            keyPassword "123456"
            v1SigningEnabled true
            v2SigningEnabled true
        }

        zhanRui {
            storeFile file("keystore/zhanxun.keystore")
            storePassword "123456"
            keyAlias "zhanxun"
            keyPassword "123456"
            v1SigningEnabled true
            v2SigningEnabled false
        }

        //iPlay50 mini,iPlay50 android13 共用签名
        iPlay50mini {
            storeFile file("keystore/iPlay50Mini.keystore")
            storePassword "android"
            keyAlias "platform"
            keyPassword "android"
            v2SigningEnabled false
        }

        iPlay50miniPro {
            storeFile file("keystore/iPlay50miniPro.jks")
            storePassword "123456"
            keyAlias "iplay50minipro"
            keyPassword "123456"
            v2SigningEnabled false
        }

        iPlay40H {
            storeFile file("keystore/iPlay40h.keystore")
            storePassword "android"
            keyAlias "platform"
            keyPassword "android"
            v1SigningEnabled true
            v2SigningEnabled true
        }

        U807 {
            storeFile file("keystore/AllwinnerU807.jks")
            storePassword "123456"
            keyAlias "u807"
            keyPassword "123456"
            v2SigningEnabled false
        }

        iPlay50P {
            storeFile file("keystore/iPlay50P.jks")
            storePassword "123456"
            keyAlias "iplay50p"
            keyPassword "123456"
            v1SigningEnabled true
            v2SigningEnabled true
        }
    }

    buildTypes {
        iPlay50PDebug.initWith(debug)
        iPlay50PDebug {
            buildConfigField "String", "platform", '"T1102"'
            versionNameSuffix "-debug"
            debuggable true
            signingConfig signingConfigs.iPlay50P
        }

        iPlay50PRelease.initWith(release)
        iPlay50PRelease {
            buildConfigField "String", "platform", '"T1102"'
            signingConfig signingConfigs.iPlay50P
        }

        U807Debug.initWith(debug)
        U807Debug {
            buildConfigField "String", "platform", '"U807"'
            versionNameSuffix "-debug"
            debuggable true
            signingConfig signingConfigs.U807
        }

        U807Release.initWith(release)
        U807Release {
            buildConfigField "String", "platform", '"U807"'
            signingConfig signingConfigs.U807
        }

        Cube8183Debug.initWith(debug)
        Cube8183Debug {
            debuggable true
            versionNameSuffix "-debug"
            buildConfigField "String", "platform", '"cube8183"'
            signingConfig signingConfigs.cube8183
        }

        Cube8183Release.initWith(release)
        Cube8183Release {
            buildConfigField "String", "platform", '"cube8183"'
            signingConfig signingConfigs.cube8183
        }

        Teclast8183Debug.initWith(debug)
        Teclast8183Debug {
            debuggable true
            versionNameSuffix "-debug"
            buildConfigField "String", "platform", '"teclast8183"'
            signingConfig signingConfigs.teclast8183
        }

        Teclast8183Release.initWith(release)
        Teclast8183Release {
            buildConfigField "String", "platform", '"teclast8183"'
            signingConfig signingConfigs.teclast8183
        }

        Teclast8515Debug.initWith(debug)
        Teclast8515Debug {
            buildConfigField "String", "platform", '"8515"'
            versionNameSuffix "-debug"
            debuggable true
            signingConfig signingConfigs.Teclast8515
        }

        Teclast8515Release.initWith(release)
        Teclast8515Release {
            buildConfigField "String", "platform", '"8515"'
            signingConfig signingConfigs.Teclast8515
        }

        iPlay50ProDebug.initWith(debug)
        iPlay50ProDebug {
            buildConfigField "String", "platform", '"MTK"'
            versionNameSuffix "-debug"
            debuggable true
            signingConfig signingConfigs.mtk12
        }

        iPlay50ProRelease.initWith(release)
        iPlay50ProRelease {
            buildConfigField "String", "platform", '"MTK"'
            signingConfig signingConfigs.mtk12
        }

        iPlay50SEDebug.initWith(debug)
        iPlay50SEDebug {
            buildConfigField "String", "platform", '"ipaly50SE"'
            versionNameSuffix "-debug"
            debuggable true
            signingConfig signingConfigs.iPlay50SE
        }

        iPlay50SERelease.initWith(release)
        iPlay50SERelease {
            buildConfigField "String", "platform", '"ipaly50SE"'
            signingConfig signingConfigs.iPlay50SE
        }

        iPlay50miniDebug.initWith(debug)
        iPlay50miniDebug {
            buildConfigField "String", "platform", '"T811"'
            versionNameSuffix "-debug"
            debuggable true
            signingConfig signingConfigs.iPlay50mini
        }

        iPlay50miniRelease.initWith(release)
        iPlay50miniRelease {
            buildConfigField "String", "platform", '"T811"'
            signingConfig signingConfigs.iPlay50mini
        }

        iPlay5013Debug.initWith(debug)
        iPlay5013Debug {
            buildConfigField "String", "platform", '"iplay5013"'
            versionNameSuffix "-debug"
            debuggable true
            signingConfig signingConfigs.iPlay50mini
        }

        iPlay5013Release.initWith(release)
        iPlay5013Release {
            buildConfigField "String", "platform", '"iplay5013"'
            signingConfig signingConfigs.iPlay50mini
        }

        iPlay50miniProDebug.initWith(debug)
        iPlay50miniProDebug {
            buildConfigField "String", "platform", '"miniG99"'
            versionNameSuffix "-debug"
            debuggable true
            signingConfig signingConfigs.iPlay50miniPro
        }

        iPlay50miniProRelease.initWith(release)
        iPlay50miniProRelease {
            buildConfigField "String", "platform", '"miniG99"'
            signingConfig signingConfigs.iPlay50miniPro
        }

        iPlay40HDebug.initWith(debug)
        iPlay40HDebug {
            buildConfigField "String", "platform", '"iplay40h"'
            versionNameSuffix "-debug"
            debuggable true
            signingConfig signingConfigs.iPlay50mini
        }

        iPlay40HRelease.initWith(release)
        iPlay40HRelease {
            buildConfigField "String", "platform", '"iplay40h"'
            signingConfig signingConfigs.iPlay50mini
        }

        zhanRuiDebug.initWith(debug)
        zhanRuiDebug {
            debuggable true
            versionNameSuffix "-debug"
            buildConfigField "String", "platform", '"展锐"'
            signingConfig signingConfigs.zhanRui
        }

        zhanRuiRelease.initWith(release)
        zhanRuiRelease {
            buildConfigField "String", "platform", '"展锐"'
            signingConfig signingConfigs.zhanRui
        }

        debug {
            buildConfigField "String", "platform", '"MTK"'
            versionNameSuffix "-debug"
            minifyEnabled false
            //Zipalign优化
            zipAlignEnabled true
            signingConfig signingConfigs.MTK
            applicationVariants.all { variant ->
                variant.outputs.each { output ->
                    if (outputFile != null) {
                        def fileName = "${appName()}-${variant.versionCode}-V${variant.versionName}-${releaseTime()}-${buildType.name}.apk"
                        output.outputFileName = fileName
                    }
                }
            }
        }
        release {
            buildConfigField "String", "platform", '"MTK"'
            //混淆
            minifyEnabled false
            //Zipalign优化
            zipAlignEnabled true
            //前一部分代表系统默认的android程序的混淆文件，该文件已经包含了基本的混淆声明，后一个文件是自己的定义混淆文件
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            //签名
            signingConfig signingConfigs.MTK
//            将release版本的包名重命名，加上版本及日期
            applicationVariants.all { variant ->
                variant.outputs.each { output ->
                    def outputFile = ""
                    if (outputFile != null) {
                        def fileName = "${appName()}-${variant.versionCode}-V${variant.versionName}-${releaseTime()}-${buildType.name}.apk"
                        output.outputFileName = new File(outputFile, fileName)
                    }
                }
            }
        }
    }

    sourceSets {
        iPlay50PDebug { manifest.srcFile 'src/debug/AndroidManifest.xml' }
        U807Debug { manifest.srcFile 'src/debug/AndroidManifest.xml' }
        Cube8183Debug { manifest.srcFile 'src/debug/AndroidManifest.xml' }
        Teclast8183Debug { manifest.srcFile 'src/debug/AndroidManifest.xml' }
        Teclast8515Debug { manifest.srcFile 'src/debug/AndroidManifest.xml' }
        iPlay50ProDebug { manifest.srcFile 'src/debug/AndroidManifest.xml' }
        iPlay50SEDebug { manifest.srcFile 'src/debug/AndroidManifest.xml' }
        iPlay50miniDebug { manifest.srcFile 'src/debug/AndroidManifest.xml' }
        iPlay5013Debug { manifest.srcFile 'src/debug/AndroidManifest.xml' }
        iPlay50miniProDebug { manifest.srcFile 'src/debug/AndroidManifest.xml' }
        zhanRuiDebug { manifest.srcFile 'src/debug/AndroidManifest.xml' }
        debug { manifest.srcFile 'src/debug/AndroidManifest.xml' }

        iPlay50PRelease { manifest.srcFile 'src/main/AndroidManifest.xml' }
        U807Release { manifest.srcFile 'src/main/AndroidManifest.xml' }
        Cube8183Release { manifest.srcFile 'src/main/AndroidManifest.xml' }
        Teclast8183Release { manifest.srcFile 'src/main/AndroidManifest.xml' }
        Teclast8515Release { manifest.srcFile 'src/main/AndroidManifest.xml' }
        iPlay50ProRelease { manifest.srcFile 'src/main/AndroidManifest.xml' }
        iPlay50SERelease { manifest.srcFile 'src/main/AndroidManifest.xml' }
        iPlay50miniRelease { manifest.srcFile 'src/main/AndroidManifest.xml' }
        iPlay5013Release { manifest.srcFile 'src/main/AndroidManifest.xml' }
        iPlay50miniProRelease { manifest.srcFile 'src/main/AndroidManifest.xml' }
        zhanRuiRelease { manifest.srcFile 'src/main/AndroidManifest.xml' }
        release { manifest.srcFile 'src/main/AndroidManifest.xml' }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
    implementation 'androidx.cardview:cardview:1.0.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    implementation "androidx.core:core-ktx:1.6.0"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

    //butterknife
    implementation 'com.jakewharton:butterknife:10.2.3'
//    If you are using Kotlin, replace annotationProcessor with kapt.
//    annotationProcessor rootProject.ext.dependencies["butterknife-compiler"]
    annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3'
    //github第三方控件
    implementation 'io.github.h07000223:flycoTabLayout:3.0.0'
    //下拉刷新控件
    implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.3'  //1.0.5及以前版本的老用户升级需谨慎，API改动过大
    implementation 'com.scwang.smartrefresh:SmartRefreshHeader:1.1.3'  //没有使用特殊Header，可以不加这行
    //glide
    implementation 'com.github.bumptech.glide:glide:4.14.2'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.14.2'
    //磁盘缓存
    implementation 'com.jakewharton:disklrucache:2.0.2'
    //aria
    implementation 'com.arialyy.aria:core:3.8.15'
    annotationProcessor 'com.arialyy.aria:compiler:3.8.15'
    //动态权限框架
    implementation 'com.hjq:xxpermissions:6.0'
    //okhttp
    implementation 'com.squareup.okhttp3:okhttp:4.9.2'
    //Retrofit
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
//    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
    implementation 'com.squareup.retrofit2:adapter-rxjava3:2.9.0'
    //RxJava
    implementation 'io.reactivex.rxjava3:rxjava:3.0.0'
    implementation 'io.reactivex.rxjava3:rxandroid:3.0.0'
    //生命周期管理
    implementation 'com.trello.rxlifecycle4:rxlifecycle:4.0.2'
    implementation 'com.trello.rxlifecycle4:rxlifecycle-android:4.0.2'
    implementation 'com.trello.rxlifecycle4:rxlifecycle-components:4.0.2'
    implementation 'com.trello.rxlifecycle4:rxlifecycle-components-preference:4.0.2'
    implementation 'com.trello.rxlifecycle4:rxlifecycle-android-lifecycle:4.0.2'
    //google
    implementation 'com.google.code.gson:gson:2.9.0'
    implementation 'com.google.zxing:core:3.5.0'
    //MMKV
    implementation 'com.tencent:mmkv-static:1.2.13'
    //banner图
    implementation 'com.zhpan.library:bannerview:2.6.4'
    //更换字体框架
    implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
    //工具类
    implementation 'com.blankj:utilcodex:1.31.1'
    //沉浸状态栏
    implementation 'com.gitee.zackratos:UltimateBarX:0.8.0'
}