apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-parcelize'
apply plugin: 'kotlin-kapt'

android {
    namespace 'com.kunzisoft.keepass'
    compileSdkVersion 34

    defaultConfig {
        applicationId "com.kunzisoft.keepass"
        minSdkVersion 15
        targetSdkVersion 34
        versionCode = 133
        versionName = "4.1.1"
        multiDexEnabled true

        testApplicationId = "com.kunzisoft.keepass.tests"
        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

        buildConfigField "String[]", "ICON_PACKS", "{\"classic\",\"material\"}"
        manifestPlaceholders = [ googleAndroidBackupAPIKey:"unused" ]

        kapt {
            arguments {
                arg("room.incremental", "true")
                arg("room.schemaLocation", "$projectDir/schemas".toString())
            }
        }
    }

    buildTypes {
        release {
            minifyEnabled = false
        }
    }

    dependenciesInfo {
        // Disables dependency metadata when building APKs.
        includeInApk = false
        // Disables dependency metadata when building Android App Bundles.
        includeInBundle = false
    }

    flavorDimensions "version"
    productFlavors {
        libre {
            dimension "version"
            applicationIdSuffix = ".libre"
            buildConfigField "String", "BUILD_VERSION", "\"libre\""
            buildConfigField "boolean", "CLOSED_STORE", "false"
            buildConfigField "String[]", "STYLES_DISABLED",
                            "{\"KeepassDXStyle_Red\"," +
                            "\"KeepassDXStyle_Red_Night\"," +
                            "\"KeepassDXStyle_Reply\"," +
                            "\"KeepassDXStyle_Reply_Night\"," +
                            "\"KeepassDXStyle_Purple\"," +
                            "\"KeepassDXStyle_Purple_Dark\"," +
                            "\"KeepassDXStyle_Dynamic_Light\"," +
                            "\"KeepassDXStyle_Dynamic_Night\"}"
            buildConfigField "String[]", "ICON_PACKS_DISABLED", "{}"
        }
        free {
            dimension "version"
            applicationIdSuffix = ".free"
            buildConfigField "String", "BUILD_VERSION", "\"free\""
            buildConfigField "boolean", "CLOSED_STORE", "true"
            buildConfigField "String[]", "STYLES_DISABLED",
                            "{\"KeepassDXStyle_Blue\"," +
                            "\"KeepassDXStyle_Blue_Night\"," +
                            "\"KeepassDXStyle_Red\"," +
                            "\"KeepassDXStyle_Red_Night\"," +
                            "\"KeepassDXStyle_Reply\"," +
                            "\"KeepassDXStyle_Reply_Night\"," +
                            "\"KeepassDXStyle_Purple\"," +
                            "\"KeepassDXStyle_Purple_Dark\"," +
                            "\"KeepassDXStyle_Dynamic_Light\"," +
                            "\"KeepassDXStyle_Dynamic_Night\"}"
            buildConfigField "String[]", "ICON_PACKS_DISABLED", "{}"
            manifestPlaceholders = [ googleAndroidBackupAPIKey:"AEdPqrEAAAAIbRfbV8fHLItXo8OcHwrO0sSNblqhPwkc0DPTqg" ]
        }
    }

    sourceSets {
        libre.res.srcDir 'src/libre/res'
        free.res.srcDir 'src/free/res'
    }

    testOptions {
        unitTests.includeAndroidResources = true
    }

    compileOptions {
        targetCompatibility JavaVersion.VERSION_1_8
        sourceCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = "1.8"
    }
}

def room_version = "2.5.1"

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    implementation "com.android.support:multidex:1.0.3"
    implementation "androidx.appcompat:appcompat:$android_appcompat_version"
    implementation 'androidx.preference:preference-ktx:1.2.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'androidx.viewpager2:viewpager2:1.1.0-beta02'
    implementation 'androidx.documentfile:documentfile:1.0.1'
    implementation 'androidx.biometric:biometric:1.1.0'
    implementation 'androidx.media:media:1.6.0'
    // Lifecycle - LiveData - ViewModel - Coroutines
    implementation "androidx.core:core-ktx:$android_core_version"
    implementation 'androidx.fragment:fragment-ktx:1.6.0'
    implementation "com.google.android.material:material:$android_material_version"
    // Token auto complete
    // From sources until https://github.com/splitwise/TokenAutoComplete/pull/422 fixed
    implementation "com.splitwise:tokenautocomplete:4.0.0-beta05"
    // Database
    implementation "androidx.room:room-runtime:$room_version"
    kapt "androidx.room:room-compiler:$room_version"
    // Autofill
    implementation "androidx.autofill:autofill:1.1.0"
    // Time
    implementation 'joda-time:joda-time:2.13.0'
    // Color
    implementation 'com.github.Kunzisoft:AndroidClearChroma:2.6'
    // Education
    implementation 'com.getkeepsafe.taptargetview:taptargetview:1.13.3'
    // Apache Commons
    implementation 'commons-io:commons-io:2.8.0'
    implementation 'commons-codec:commons-codec:1.15'
    // Password generator
    implementation 'me.gosimple:nbvcxz:1.5.0'
    
    // Modules import
    implementation project(path: ':database')
    implementation project(path: ':icon-pack')

    // Tests
    androidTestImplementation "androidx.test:runner:$android_test_version"
    androidTestImplementation "androidx.test:rules:$android_test_version"
}