plugins {
    id "com.android.application"
    id "org.jetbrains.kotlin.android"
    id "org.jetbrains.kotlin.plugin.compose"
    id "org.jetbrains.kotlin.plugin.serialization"
    id "kotlin-kapt"
    id "dagger.hilt.android.plugin"
}

def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(rootProject.file("keystore.properties")))

android {

    namespace "com.acszo.redomi"
    compileSdk = 36

    androidResources {
        generateLocaleConfig true
    }

    signingConfigs {
        release {
            storeFile file(keystoreProperties["storeFile"])
            storePassword keystoreProperties["storePassword"]
            keyAlias keystoreProperties["keyAlias"]
            keyPassword keystoreProperties["keyPassword"]
        }
    }

    defaultConfig {
        applicationId "com.acszo.redomi"
        minSdk 28
        targetSdk 36
        versionCode 10305
        versionName "1.3.5"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        signingConfig signingConfigs.release
    }

    buildTypes {
        debug {
            applicationIdSuffix ".debug"
        }

        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
        }
    }

    flavorDimensions += "version"
    productFlavors {
        create("github") {
            dimension = "version"
        }
        create("repo") {
            dimension = "version"
            applicationIdSuffix ".repo"
        }
    }

    applicationVariants.configureEach { variant ->
        variant.outputs.configureEach { output ->
            def flavorName = variant.flavorName
            def buildType = variant.buildType.name
            def suffix = flavorName == "github" ? "github" : "no-updater"

            outputFileName = "redomi-${buildType}-${suffix}.apk"
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }

    kotlinOptions {
        jvmTarget = "11"
    }

    buildFeatures {
        compose true
        buildConfig true
    }

    dependenciesInfo {
        includeInApk false
        includeInBundle false
    }

    packagingOptions {
        resources {
            excludes += "**"
        }
    }

}

dependencies {

    // Test
    testImplementation "junit:junit:4.13.2"
    androidTestImplementation "androidx.test.ext:junit:1.3.0"
    androidTestImplementation "androidx.test.espresso:espresso-core:3.7.0"
    androidTestImplementation platform("androidx.compose:compose-bom:2025.09.01")
    androidTestImplementation "androidx.compose.ui:ui-test-junit4"
    debugImplementation "androidx.compose.ui:ui-tooling"
    debugImplementation "androidx.compose.ui:ui-test-manifest"

    // Compose
    implementation platform("androidx.compose:compose-bom:2025.09.01")
    implementation "androidx.compose.ui:ui"
    implementation "androidx.compose.ui:ui-graphics"
    implementation "androidx.compose.material3:material3"
    implementation "androidx.compose.ui:ui-tooling-preview"
    implementation "androidx.compose.animation:animation-graphics"
    implementation "androidx.activity:activity-compose:1.11.0"

    // Splash Screen
    implementation "androidx.core:core-splashscreen:1.1.0-rc01"

    // Dagger Hilt
    implementation "androidx.hilt:hilt-lifecycle-viewmodel-compose:1.3.0"
    implementation "com.google.dagger:hilt-android:2.57.2"
    kapt "com.google.dagger:hilt-compiler:2.57.2"

    // Retrofit
    implementation "com.squareup.retrofit2:retrofit:3.0.0"
    implementation "com.squareup.retrofit2:converter-kotlinx-serialization:3.0.0"
    implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.9.0"

    // ViewModel Lifecycle
    implementation "androidx.lifecycle:lifecycle-runtime-compose:2.9.4"
    implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.9.4"

    // Coil
    implementation "io.coil-kt.coil3:coil-compose:3.3.0"
    implementation "io.coil-kt.coil3:coil-network-okhttp:3.3.0"

    // Data Store
    implementation "androidx.datastore:datastore-preferences:1.1.7"

    // Navigation
    implementation "androidx.navigation:navigation-compose:2.7.7"

    implementation project(":squircle")

}