plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-kapt'
    id 'com.google.gms.google-services'
}

android {
    compileSdk 33

    defaultConfig {
        applicationId "pt.whatsms.gateway"
        minSdk 21
        targetSdk 33
        versionCode 10
        versionName "3.0.0-branding"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        javaCompileOptions {
            annotationProcessorOptions {
                arguments += ["room.schemaLocation": "$projectDir/schemas".toString()]
            }
        }
    }
    buildFeatures {
        viewBinding true
    }
    signingConfigs {
        release {
            storeFile file("keystore.jks")
            storePassword System.getenv("SIGNING_STORE_PASSWORD")
            keyAlias System.getenv("SIGNING_KEY_ALIAS")
            keyPassword System.getenv("SIGNING_KEY_PASSWORD")
        }
    }
    buildTypes {
        debug {
            debuggable true
            manifestPlaceholders = [networkSecurityConfig: "@xml/network_security_config"]
        }
        debugInsecure {
            debuggable true
            manifestPlaceholders = [networkSecurityConfig: "@xml/network_security_config_insecure"]
            signingConfig signingConfigs.debug
        }
        insecure {
            initWith debug
            debuggable true
            signingConfig signingConfigs.release
            manifestPlaceholders = [networkSecurityConfig: "@xml/network_security_config_insecure"]
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
            manifestPlaceholders = [networkSecurityConfig: "@xml/network_security_config"]
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    packagingOptions {
        exclude 'META-INF/INDEX.LIST'
        exclude 'META-INF/io.netty.versions.properties'
    }
    namespace 'me.capcom.smsgateway'
}

dependencies {
    def ktor_version = "2.2.4"
    def okhttp_version = "4.10.0"
    def room_version = "2.4.3"
    def coroutines_version = "1.6.1"
    def work_version = "2.7.1"
    def koin_version = "3.4.0"
    def lifecycle_version = "2.6.2"

    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version")
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")

    implementation("io.ktor:ktor-serialization-gson:$ktor_version")

    implementation("io.ktor:ktor-server-core:$ktor_version")
    implementation("io.ktor:ktor-server-netty:$ktor_version")
    implementation("io.ktor:ktor-server-compression:$ktor_version")
    implementation("io.ktor:ktor-server-status-pages:$ktor_version")
    implementation("io.ktor:ktor-server-content-negotiation:$ktor_version")
    implementation("io.ktor:ktor-server-call-logging:$ktor_version")
    implementation("io.ktor:ktor-server-auth:$ktor_version")
    implementation("io.ktor:ktor-server-auth-jwt:$ktor_version")

    implementation("io.ktor:ktor-client-core:$ktor_version")
    implementation("io.ktor:ktor-client-content-negotiation:$ktor_version")
    implementation("io.ktor:ktor-client-okhttp:$ktor_version")

    implementation("com.squareup.okhttp3:okhttp:$okhttp_version")
    implementation("com.squareup.okhttp3:okhttp-sse:$okhttp_version")

    // Kotlin + coroutines
    implementation "androidx.work:work-runtime-ktx:$work_version"

    implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"

    implementation("androidx.preference:preference-ktx:1.2.0")

    implementation("androidx.core:core-ktx:1.8.0")
    implementation("androidx.appcompat:appcompat:1.4.2")
    implementation("com.google.android.material:material:1.6.1")
    implementation("androidx.constraintlayout:constraintlayout:2.1.4")
    implementation 'androidx.preference:preference-ktx:1.2.1'

    implementation("com.aventrix.jnanoid:jnanoid:2.0.0")

    implementation("androidx.room:room-ktx:$room_version")
    annotationProcessor("androidx.room:room-compiler:$room_version")
    kapt("androidx.room:room-compiler:$room_version")

    // Import the Firebase BoM
    implementation platform('com.google.firebase:firebase-bom:31.1.1')
    implementation 'com.google.firebase:firebase-messaging-ktx'

    implementation 'com.googlecode.libphonenumber:libphonenumber:9.0.22'

    // Koin for Android
    implementation "io.insert-koin:koin-android:$koin_version"

    testImplementation("junit:junit:4.13.2")
    androidTestImplementation("androidx.test.ext:junit:1.1.3")
    androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0")
}
