import java.text.SimpleDateFormat
import java.util.Date

plugins {
    alias(libs.plugins.android.application)
    alias(libs.plugins.jetbrains.kotlin.android)
    // Make sure that you have the Google services Gradle plugin
    id("com.google.gms.google-services")
    // Add the Crashlytics Gradle plugin
    id("com.google.firebase.crashlytics")
}

android {
    namespace = "com.assimilate.alltrans"
    compileSdk = 34

    defaultConfig {
        applicationId = "com.assimilate.alltrans"
        minSdk = 23
        targetSdk = 34
        versionCode = 2
        versionName = "1.0.2"

        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
    }

    buildFeatures {
        buildConfig = true
        viewBinding = true
    }

    buildTypes {

        debug {
            isShrinkResources = true
            isMinifyEnabled = true
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )
        }

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


//    applicationVariants.all {
//        outputs.all {
//            val appName = "Translark" // 替换为你的应用名称
//            val versionName = versionName
//            val date = SimpleDateFormat("yyyyMMdd-HHmm").format(Date())
//            val newApkName = "${appName}-${date}-${versionName}.apk"
//            (this as com.android.build.gradle.internal.api.BaseVariantOutputImpl).outputFileName = newApkName
//        }
//    }


    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }
}

dependencies {

    // Import the BoM for the Firebase platform
    implementation(platform("com.google.firebase:firebase-bom:33.1.1"))

    // Add the dependencies for the Crashlytics and Analytics libraries
    // When using the BoM, you don't specify versions in Firebase library dependencies
    implementation("com.google.firebase:firebase-crashlytics")
    implementation("com.google.firebase:firebase-analytics")


    // To recognize Latin script
    implementation("com.google.mlkit:text-recognition:16.0.0")
    // To recognize Chinese script
    implementation("com.google.mlkit:text-recognition-chinese:16.0.0")
    // To recognize Devanagari script
    implementation("com.google.mlkit:text-recognition-devanagari:16.0.0")
    // To recognize Japanese script
    implementation("com.google.mlkit:text-recognition-japanese:16.0.0")
    // To recognize Korean script
    implementation("com.google.mlkit:text-recognition-korean:16.0.0")

    // CameraX core library

    implementation(libs.androidx.camera.core)

    // CameraX Camera2 extensions
    implementation(libs.androidx.camera.camera2)

    // CameraX Lifecycle library
    implementation(libs.androidx.camera.lifecycle)

    // CameraX View class
    implementation(libs.androidx.camera.view)


    // 文本识别
    // To recognize Latin script
//    implementation(libs.play.services.mlkit.text.recognition)
//    // To recognize Chinese script
//    implementation(libs.play.services.mlkit.text.recognition.chinese)
//    // To recognize Devanagari script
//    implementation(libs.play.services.mlkit.text.recognition.devanagari)
//    // To recognize Japanese script
//    implementation(libs.play.services.mlkit.text.recognition.japanese)
//    // To recognize Korean script
//    implementation(libs.play.services.mlkit.text.recognition.korean)


    // other
    implementation(libs.guava)
    implementation(libs.retrofit)
    implementation(libs.converter.gson)
    implementation(libs.gson)
    implementation(libs.lottie)
    implementation(libs.glide)


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