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

def getGitHash = { ->
    def stdout = new ByteArrayOutputStream()
    exec {
        commandLine 'git', 'rev-parse', '--short', 'HEAD'
        standardOutput = stdout
    }
    return stdout.toString().trim()
}

android {

    compileSdkVersion 35

    defaultConfig {
        applicationId "com.espressif.wifi_provisioning"
        minSdkVersion 26
        targetSdkVersion 35
        versionCode 29
        versionName "2.4.0 - ${getGitHash()}"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        consumerProguardFiles "consumer-proguard-rules.pro"
    }

    buildTypes {
        release {
            minifyEnabled true
            debuggable false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            resValue "string", "proof_of_possesion", "abcd1234"
            resValue "string", "wifi_base_url", "192.168.4.1:80"
            resValue "string", "wifi_device_name_prefix", "PROV_"
            resValue "string", "ble_device_name_prefix", "PROV_"
            buildConfigField "boolean", "isQrCodeSupported", "true"
            buildConfigField "boolean", "isSettingsAllowed", "true"
            buildConfigField "boolean", "isFilteringByPrefixAllowed", "true"
        }

        debug {
            debuggable true
            resValue "string", "proof_of_possesion", "abcd1234"
            resValue "string", "wifi_base_url", "192.168.4.1:80"
            resValue "string", "wifi_device_name_prefix", "PROV_"
            resValue "string", "ble_device_name_prefix", "PROV_"
            buildConfigField "boolean", "isQrCodeSupported", "true"
            buildConfigField "boolean", "isSettingsAllowed", "true"
            buildConfigField "boolean", "isFilteringByPrefixAllowed", "true"
        }
    }

    buildFeatures {
        viewBinding true
        buildConfig = true
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }

    kotlinOptions {
        jvmTarget = "17"
    }

    namespace 'com.espressif.wifi_provisioning'
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
    implementation 'com.google.android.material:material:1.12.0'
    implementation 'androidx.preference:preference:1.2.1'

    implementation 'com.google.protobuf:protobuf-javalite:3.18.0'
    implementation 'com.google.crypto.tink:tink-android:1.12.0'
    implementation project(path: ':provisioning')

    implementation 'org.greenrobot:eventbus:3.3.1'
    implementation 'com.github.yuriy-budiyev:code-scanner:2.1.2'
    implementation 'com.github.firdausmaulan:AVLoadingIndicatorView:2.3.0'

    implementation 'com.google.android.gms:play-services-threadnetwork:16.2.1'

    // CameraX
    def camerax_version = "1.2.3"
    implementation "androidx.camera:camera-core:${camerax_version}"
    implementation "androidx.camera:camera-camera2:${camerax_version}"
    implementation "androidx.camera:camera-lifecycle:${camerax_version}"
    implementation "androidx.camera:camera-view:${camerax_version}"

    // ML Kit for QR code scanning
    implementation 'com.google.mlkit:barcode-scanning:17.3.0'

    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.2.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'

    // Add Kotlin dependencies
    implementation "org.jetbrains.kotlin:kotlin-stdlib:2.0.0"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.0"
}
