apply plugin: "org.jetbrains.kotlin.android"
android {
    defaultConfig {
        minSdkVersion 21

        if (project.hasProperty("tempBuild")) {
            externalNativeBuild {
                cmake {
                    cppFlags "-frtti -fexceptions"
                    abiFilters 'armeabi-v7a', "arm64-v8a", 'x86', 'x86_64'
                    if (project.hasProperty("withQRCode")) {
                        arguments "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON", "-DANDROID_TOOLCHAIN=clang", "-DANDROID_STL=c++_static", "-DWITH_QRCODE=1"
                    } else {
                        arguments "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON", "-DANDROID_TOOLCHAIN=clang", "-DANDROID_STL=c++_static"
                    }
                }
            }
        }
    }
    if (project.hasProperty("tempBuild")) {
        ndkVersion project.ndkVersion
        externalNativeBuild {
            cmake {
                path "src/main/cpp/CMakeLists.txt"
            }
        }
    }

    kotlin {
        jvmToolchain(17)
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
}
dependencies {
    def kotlinCoroutine =  project.hasProperty("kotlinCoroutine") ? project.kotlinCoroutine : "1.6.4"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinCoroutine"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinCoroutine"

    def androidXActivityVersion =  project.hasProperty("androidXActivityVersion") ? project.androidXActivityVersion : "1.8.2"
    implementation "androidx.activity:activity-ktx:$androidXActivityVersion"

    def androidXAppCompat =  project.hasProperty("androidXAppCompat") ? project.androidXAppCompat : "1.1.0"
	implementation "androidx.appcompat:appcompat:$androidXAppCompat"

    def androidXExifInterfaceVersion =  project.hasProperty("androidXExifInterfaceVersion") ? project.androidXExifInterfaceVersion : "1.3.3"
    implementation "androidx.exifinterface:exifinterface:$androidXExifInterfaceVersion"

    def androidXDocumentFileVersion =  project.hasProperty("androidXDocumentFileVersion") ? project.androidXDocumentFileVersion : "1.0.1"
    implementation "androidx.documentfile:documentfile:$androidXDocumentFileVersion"

    // def androidxVersion =  project.hasProperty("coreKtxVersion") ? project.coreKtxVersion : "1.12.0"
    // implementation "androidx.core:core-ktx:$coreKtxVersion"

    def itextpdfVersion = { -> project.hasProperty("itextpdfVersion") ? itextpdfVersion : "7.2.3" }
    implementation "com.itextpdf.android:kernel-android:$itextpdfVersion"
    implementation "com.itextpdf.android:layout-android:$itextpdfVersion"
}
