plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
}

// =====
var isDev = false        // add .dev to applicationId
var beta = false          // add .beta to applicationId
var appIdSuffix = ""      // add this to applicationId (E M P T Y   F O R   R E L E A S E S)
var verBuild = 160       // versionCode
var verName = "1.3"  // versionName...
var verBranch = "main"   // branch
var verReleaseTime = 1699198506 // releaseTime

android {
    compileSdk 34
    defaultConfig {
        applicationId "com.fazziclay.opentoday" + (isDev ? ".dev" : "") + (beta ? ".beta" : "") + appIdSuffix
        minSdk 26
        targetSdk 34
        versionCode verBuild
        versionName verName + " (build " + verBuild + (isDev ? " dev" : "") + ")"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        if (isDev) {
            verReleaseTime = (long) (new Date().time / 1000)
        }

        release {
            buildConfigField "long", "VERSION_RELEASE_TIME", verReleaseTime.toString()
            buildConfigField "String", "VERSION_BRANCH", "\"${verBranch}\""
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        debug {
            buildConfigField "long", "VERSION_RELEASE_TIME", verReleaseTime.toString()
            buildConfigField "String", "VERSION_BRANCH", "\"${verBranch}\""
            versionNameSuffix ' (debug)'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
    buildFeatures {
        viewBinding true
    }
    testOptions {
        unitTests.returnDefaultValues = true
    }
    packagingOptions {
        resources.excludes.add("META-INF/*") // fix build errors
    }
    namespace 'com.fazziclay.opentoday'
}

dependencies {
    // Application
    implementation files("./libs/OpenTodayTelemetry-v2-v11.jar")                     // telemetry library for OpenToday      SourceCode: https://github.com/FazziCLAY/OpenTodayTelemetry
    implementation files("./libs/NeoSocket-1.0.jar")                                 // for network (bad library...) uses by OpenTodayTelemetry   SourceCode: https://github.com/FazziCLAY/NeoSocket
    implementation files("./libs/JavaNeoUtil-1.1.jar")                               // java utils by FazziCLAY (uses FileUtil)    SourceCode: https://github.com/FazziCLAY/JavaNeoUtil
    implementation files("./libs/WarningRose-v0.4.1.jar")                            // for DebugTickCounter debug rose (only for developer)    SourceCode: https://github.com/FazziCLAY/WarningRose
    implementation 'com.github.leondzn:simple-analog-clock:1.0.1'                    // analog clock
    implementation 'com.github.martin-stone:hsv-alpha-color-picker-android:3.0.1'    // color picker
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.10.0'
    implementation 'androidx.navigation:navigation-fragment-ktx:2.7.4'
    implementation 'androidx.navigation:navigation-ui-ktx:2.7.4'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.core:core-ktx:1.12.0'
    implementation project(path: ':api')                     // api

    // Tests
    androidTestImplementation 'org.junit.jupiter:junit-jupiter:5.9.3'
    androidTestImplementation 'org.testng:testng:6.9.6'
    testImplementation 'junit:junit:4.13.2'
    testImplementation 'org.json:json:20220320'
    androidTestImplementation'org.robolectric:robolectric:3.0'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
