apply plugin: 'com.android.application'
apply plugin: 'org.jetbrains.kotlin.android'

def sdkVersionFile = file("../gradle.properties")
def properties = new Properties()
sdkVersionFile.withInputStream { stream ->
    properties.load(stream)
}
def agoraSdkVersion = properties.getProperty("rtc_sdk_version")
println("${rootProject.project.name}   agoraSdkVersion: ${agoraSdkVersion}")
def localSdkPath= "${rootProject.projectDir.absolutePath}/../../sdk"

android {
    namespace "io.agora.api.example"
    compileSdk 35

    defaultConfig {
        applicationId "io.agora.api.example.audio"
        minSdkVersion 24
        targetSdkVersion 35
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    signingConfigs {
        myConfig {
            storeFile new File(rootProject.rootDir.absolutePath + "/keystore.key")
            storePassword "965606"
            keyAlias "agora"
            keyPassword "965606"
            v1SigningEnabled true
            v2SigningEnabled true
        }
    }

    buildTypes {
        debug {
            minifyEnabled false
            signingConfig signingConfigs.myConfig
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

        release {
            minifyEnabled true
            signingConfig signingConfigs.myConfig
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
    kotlinOptions {
        jvmTarget = "17"
    }

    sourceSets {
        main {
            jniLibs.srcDirs += 'src/main/jniLibs'
            if(new File("${localSdkPath}").exists()){
                jniLibs.srcDirs += "${localSdkPath}"
            }
        }
    }

    buildFeatures{
        viewBinding true
        buildConfig true
    }

    applicationVariants.all {
        variant ->
            variant.outputs.all { output ->
                outputFileName = new File(rootProject.name
                        + "_" + agoraSdkVersion
                        + "_" + new Date().format("yyyyMMddHHmm") + ".apk")
            }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
    if(new File("${localSdkPath}").exists()){
        implementation fileTree(dir: "${localSdkPath}", include: ['*.jar', '*.aar'])
    }
    else{
        // case 1: full single lib with voice only
        implementation "io.agora.rtc:voice-sdk:${agoraSdkVersion}"
        // case 2: partial libs with voice only
        // implementation "io.agora.rtc:voice-rtc-basic:${agoraSdkVersion}"
        // implementation "io.agora.rtc:spatial-audio:${agoraSdkVersion}"
        // implementation "io.agora.rtc:audio-beauty:${agoraSdkVersion}"
        // implementation "io.agora.rtc:aiaec:${agoraSdkVersion}"
        // implementation "io.agora.rtc:drm-loader:${agoraSdkVersion}"
        // implementation "io.agora.rtc:drm:${agoraSdkVersion}"
    }

    implementation 'androidx.appcompat:appcompat:1.7.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation "org.jetbrains.kotlin:kotlin-stdlib:1.8.22"

    // Java language implementation
    implementation "androidx.navigation:navigation-fragment:2.7.0"
    implementation "androidx.navigation:navigation-ui:2.7.0"

    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.3.2'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.2.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'

    implementation 'io.github.luizgrp.sectionedrecyclerviewadapter:sectionedrecyclerviewadapter:1.2.0'
    implementation 'de.javagl:obj:0.2.1'

    implementation "com.squareup.okhttp3:okhttp:4.10.0"
    implementation "com.squareup.okhttp3:logging-interceptor:4.10.0"
}
