import java.io.FileInputStream
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Properties

plugins {
    alias(libs.plugins.android.application)
    alias(libs.plugins.kotlin.android)
    id("kotlin-kapt")
    id("com.google.gms.google-services")
    id("com.google.firebase.crashlytics")
}
val timestamp = SimpleDateFormat("MM_dd_HH_mm").format(Date())
val keystorePropertiesFile = rootProject.file("keystore.properties")
val keystoreProperties = Properties().apply {
    load(FileInputStream(keystorePropertiesFile))
}
android {
    namespace = "com.gallery.free.wallpaper"
    compileSdk = 36

    defaultConfig {
        applicationId = "com.gallery.free.wallpaper"
        minSdk = 24
        targetSdk = 36
        versionCode = 3
        versionName = "1.2"

        setProperty("archivesBaseName", "WallpaperGallery_V" + versionName + "(${versionCode})_$timestamp")
        testInstrumentationRunner = "androidx.live.runner.AndroidJUnitRunner"
    }
    signingConfigs {
        create("release") {
            storeFile = file(keystoreProperties["keystoreFile"] as String)
            storePassword = keystoreProperties["key_store_password"] as String
            keyAlias = keystoreProperties["key_alias"] as String
            keyPassword = keystoreProperties["key_password"] as String
        }
    }
    buildTypes {
        release {
            isMinifyEnabled = true
            signingConfig = signingConfigs.getByName("release")
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )
        }
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_11
        targetCompatibility = JavaVersion.VERSION_11
    }
    kotlinOptions {
        jvmTarget = "11"
    }
    buildFeatures{
        viewBinding = true
        aidl = true
    }
}

dependencies {
    implementation("androidx.cardview:cardview:1.0.0")
    implementation("androidx.viewpager2:viewpager2:1.0.0")
    implementation("com.google.android.material:material:1.10.0")
    implementation("androidx.recyclerview:recyclerview:1.3.0")
    implementation("com.google.code.gson:gson:2.8.9")
    implementation ("com.github.bumptech.glide:glide:5.0.5")
    implementation ("jp.wasabeef:glide-transformations:4.3.0") // Glide Transformations
    implementation("androidx.core:core-ktx:1.12.0")
    implementation("androidx.lifecycle:lifecycle-process:2.6.2")// 添加生命周期扩展
    implementation("androidx.lifecycle:lifecycle-common-java8:2.6.2")
    implementation("androidx.work:work-runtime-ktx:2.8.1")// 添加 WorkManager（用于后台任务）

    // 添加协程依赖
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3")
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
    implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2")
    implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2")
    implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.6.2")

    implementation(libs.androidx.core.ktx)
    implementation(libs.androidx.appcompat)
    implementation(libs.material)
    implementation(libs.androidx.activity)
    implementation(libs.androidx.constraintlayout)
    implementation(libs.androidx.ui.graphics)
    testImplementation(libs.junit)
    androidTestImplementation(libs.androidx.junit)
    androidTestImplementation(libs.androidx.espresso.core)


    implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2")
    implementation("com.google.android.gms:play-services-ads-identifier:18.0.1")
    implementation("com.google.android.gms:play-services-location:21.0.1")
    implementation("com.google.android.gms:play-services-appset:16.0.1")
    // Import the Firebase BoM
    implementation(platform("com.google.firebase:firebase-bom:34.6.0"))
    implementation("com.google.firebase:firebase-crashlytics-ndk")
    implementation("com.google.firebase:firebase-analytics")
    // okhttp
    implementation ("com.squareup.okhttp3:okhttp:4.12.0")
    implementation("com.squareup.okhttp3:logging-interceptor:4.12.0")

    implementation(files("libs/magiclock-debug.aar"))
    implementation(files("libs/IronSourceLibrary_01_07_18_13-release.aar"))

    //---------------------------ironSource
    implementation("com.unity3d.ads-mediation:mediation-sdk:9.2.0")
// Add BIGO Ads Network
    implementation("com.unity3d.ads-mediation:bigo-adapter:5.2.0")
    implementation("com.bigossp:bigo-ads:5.6.2")
// Add Chartboost Network
    implementation("com.unity3d.ads-mediation:chartboost-adapter:5.2.0")
//    implementation("com.chartboost:chartboost-sdk:9.10.2")

    implementation("com.chartboost:chartboost-sdk:9.8.3")
// Add DT Exchange Network
    implementation("com.unity3d.ads-mediation:fyber-adapter:5.2.0")
    implementation("com.fyber:marketplace-sdk:8.4.1")
// Add InMobi Network
    implementation("com.unity3d.ads-mediation:inmobi-adapter:5.3.0")
    implementation("com.inmobi.monetization:inmobi-ads-kotlin:11.1.0")
// Add Liftoff Monetize Network
    implementation("com.unity3d.ads-mediation:vungle-adapter:5.2.0")
    implementation("com.vungle:vungle-ads:7.6.1")
// Add Mintegral Network
    implementation("com.unity3d.ads-mediation:mintegral-adapter:5.3.0")
    implementation("com.mbridge.msdk.oversea:mbridge_android_sdk:17.0.31")
// Add Moloco Network
    implementation("com.unity3d.ads-mediation:moloco-adapter:5.5.0")
    implementation("com.moloco.sdk:moloco-sdk:4.3.1")
// Add Pangle Network
    implementation("com.unity3d.ads-mediation:pangle-adapter:5.4.0")
    implementation("com.pangle.global:pag-sdk:7.8.0.7")
// Add Unity Ads Network
    implementation("com.unity3d.ads-mediation:unityads-adapter:5.3.0")
    implementation("com.unity3d.ads:unity-ads:4.16.4")


}