apply plugin: 'com.android.application'

repositories {
    google()

    maven {
        url "https://jitpack.io"
    }
}

android {
    compileSdk 34
    namespace "com.farmerbb.secondscreen"

    defaultConfig {
        applicationId "com.farmerbb.secondscreen"
        minSdkVersion 21

        //noinspection OldTargetApi
        targetSdkVersion 34

        versionCode 186
        versionName "2.9.4"

        resConfigs "en", "es", "fr", "sk", "nl", "it", "zh"
        vectorDrawables.useSupportLibrary = true

        buildConfigField "float", "TESTED_API_VERSION", "35.0f"
        buildConfigField "String", "SUPPORT_APPLICATION_ID", "\"com.farmerbb.secondscreen.support\""
        buildConfigField "long", "TIMESTAMP", "${System.currentTimeMillis()}L"
    }

    buildFeatures {
        buildConfig true
    }

    compileOptions {
        coreLibraryDesugaringEnabled true
        sourceCompatibility JavaVersion.VERSION_21
        targetCompatibility JavaVersion.VERSION_21
    }

    signingConfigs {
        release {
            if(System.getenv("KSTOREFILE") != null)
                storeFile file(System.getenv("KSTOREFILE"))

            storePassword System.getenv("KSTOREPWD")
            keyAlias System.getenv("KEYALIAS")
            keyPassword System.getenv("KEYPWD")
        }
    }

    buildTypes {
        debug {
            applicationIdSuffix ".debug"
            manifestPlaceholders = [appName: "@string/app_name_debug"]
        }

        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
            manifestPlaceholders = [appName: "@string/app_name"]

            applicationVariants.all { variant ->
                variant.outputs.all {
                    outputFileName = "${project.parent.name}-${defaultConfig.versionName}.apk"
                }
            }
        }
    }

    flavorDimensions "default"

    productFlavors {
        paid {
            applicationId "com.farmerbb.secondscreen"
        }

        free {
            applicationId "com.farmerbb.secondscreen.free"
        }
    }

    sourceSets {
        main {
            java { srcDirs('src/main/java', 'src/support/java') }
            res { srcDirs('src/main/res') }
            manifest.srcFile 'src/main/AndroidManifest.xml'
        }
    }

    lintOptions {
        abortOnError false
    }
}

dependencies {
    def shizuku_version = '12.1.0'

    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.appcompat:appcompat:1.7.0'
    implementation 'com.google.android.material:material:1.12.0'
    implementation "dev.rikka.shizuku:api:$shizuku_version"
    implementation "dev.rikka.shizuku:provider:$shizuku_version"
    implementation 'org.apache.commons:commons-lang3:3.17.0'
    implementation 'eu.chainfire:libsuperuser:1.1.1'
    implementation 'moe.banana:toast-compat:1.0.5'
    implementation 'org.lsposed.hiddenapibypass:hiddenapibypass:3.0'
    implementation group:'com.twofortyfouram', name:'android-plugin-api-for-locale', version:'[1.0.2,2.0['

    coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:2.1.2"
}
