plugins {
    id("com.android.application")
    id("org.jetbrains.kotlin.android")
}

val demoDomain = providers.gradleProperty("online.demo.domain").orElse("api-test.rokid.com")
val demoAk = providers.gradleProperty("online.demo.ak").orElse("")
val demoSk = providers.gradleProperty("online.demo.sk").orElse("")
val demoUid = providers.gradleProperty("online.demo.uid").orElse("demo-user")
val demoDeviceId = providers.gradleProperty("online.demo.deviceId").orElse("demo-device")
val demoAsrPath = providers.gradleProperty("online.demo.asrPath").orElse("/ar/audio/api/ws/asr/streaming")
val demoTtsPath = providers.gradleProperty("online.demo.ttsPath").orElse("/ar/audio/api/ws/tts")
val customKeystore = rootProject.file("demo-android/sdk_demo.jks")

android {
    namespace = "com.rokid.online.demo.android"
    compileSdk = 34

    defaultConfig {
        applicationId = "com.rokid.online.demo.android"
        minSdk = 26
        targetSdk = 34
        versionCode = 1
        versionName = "1.0"
        buildConfigField("String", "DEMO_DOMAIN", "\"${demoDomain.get()}\"")
        buildConfigField("String", "DEMO_AK", "\"${demoAk.get()}\"")
        buildConfigField("String", "DEMO_SK", "\"${demoSk.get()}\"")
        buildConfigField("String", "DEMO_UID", "\"${demoUid.get()}\"")
        buildConfigField("String", "DEMO_DEVICE_ID", "\"${demoDeviceId.get()}\"")
        buildConfigField("String", "DEMO_ASR_PATH", "\"${demoAsrPath.get()}\"")
        buildConfigField("String", "DEMO_TTS_PATH", "\"${demoTtsPath.get()}\"")
    }

    buildTypes {
        release {
            isMinifyEnabled = false
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro",
            )
        }
    }

    if (customKeystore.exists()) {
        signingConfigs {
            create("glassDemo") {
                storeFile = customKeystore
                storePassword = "rokid123"
                keyAlias = "rokid"
                keyPassword = "rokid123"
                enableV2Signing = true
            }
        }
        buildTypes {
            debug {
                signingConfig = signingConfigs.getByName("glassDemo")
            }
            release {
                signingConfig = signingConfigs.getByName("glassDemo")
            }
        }
    }

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

dependencies {
    implementation ("com.rokid.security.sdk:online-speech:0.1.1")
    implementation("androidx.core:core-ktx:1.13.1")
    implementation("androidx.appcompat:appcompat:1.7.0")
    implementation("androidx.viewpager2:viewpager2:1.1.0")
    implementation("com.google.android.material:material:1.12.0")
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1")
    implementation("com.rokid.security:glass3.open.sdk:2.1.6-E")
}
