plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'org.jlleitschuh.gradle.ktlint' version "11.3.1"
}

android {
    namespace 'com.vitorpamplona.amethyst'
    compileSdk 33

    defaultConfig {
        applicationId "com.vitorpamplona.amethyst"
        minSdk 26
        targetSdk 33
        versionCode 90
        versionName "0.24.1"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary true
        }
    }

    buildTypes {
        release {
            //minifyEnabled true
            //proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            resValue "string", "app_name", "@string/app_name_release"
        }
        debug {
            applicationIdSuffix '.debug'
            versionNameSuffix '-DEBUG'
            resValue "string", "app_name", "@string/app_name_debug"
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }
    kotlinOptions {
        jvmTarget = '11'
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion "1.4.3"
    }
    packagingOptions {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}'
        }
    }
}

dependencies {
    implementation 'androidx.core:core-ktx:1.9.0'
    implementation 'androidx.activity:activity-compose:1.7.0-beta01'
    implementation "androidx.compose.ui:ui:$compose_ui_version"
    implementation "androidx.compose.ui:ui-tooling-preview:$compose_ui_version"

    // Needs this to open gallery / image upload
    implementation "androidx.fragment:fragment-ktx:$fragment_version"

    // Navigation
    implementation("androidx.navigation:navigation-compose:$nav_version")

    // Observe Live data as State
    implementation 'androidx.compose.runtime:runtime-livedata:1.4.0-beta02'

    implementation 'androidx.compose.material:material:1.4.0-beta02'
    implementation "androidx.compose.material:material-icons-extended:1.4.0-beta02"

    // Lifecycle
    implementation "androidx.lifecycle:lifecycle-runtime-compose:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-livedata:$lifecycle_version"

    // Biometrics
    implementation "androidx.biometric:biometric-ktx:1.2.0-alpha05"

    // Swipe Refresh
    implementation 'com.google.accompanist:accompanist-swiperefresh:0.29.1-alpha'

    // Bitcoin secp256k1 bindings to Android
    implementation 'fr.acinq.secp256k1:secp256k1-kmp-jni-android:0.7.1'

    // Nostr Base Protocol
    implementation('com.github.vitorpamplona.NostrPostr:nostrpostrlib:master-SNAPSHOT') {
        exclude group:'fr.acinq.secp256k1'
        exclude module: 'guava'
        exclude module: 'guava-testlib'
    }

    // Websockets API
    implementation 'com.squareup.okhttp3:okhttp:5.0.0-alpha.11'

    // Json Serialization TODO: We might need to converge between gson and Jackson (we are usin both)
    implementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.14.2'
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'

    // Robohash for Avatars
    implementation group: 'com.github.vitorpamplona', name: 'android-robohash', version: 'master-SNAPSHOT', ext: 'aar'

    // link preview
    implementation 'tw.com.oneup.www:Baha-UrlPreview:1.0.1'

    // Encrypted Key Storage
    implementation 'androidx.security:security-crypto-ktx:1.1.0-alpha05'

    // view videos
    implementation 'com.google.android.exoplayer:exoplayer:2.18.4'

    // Load images from the web.
    implementation "io.coil-kt:coil-compose:2.2.2"
    // view gifs
    implementation "io.coil-kt:coil-gif:2.2.2"
    // view svgs
    implementation("io.coil-kt:coil-svg:2.2.2")

    // Rendering clickable text
    implementation "com.google.accompanist:accompanist-flowlayout:$accompanist_version"
    // Permission to upload pictures:
    implementation "com.google.accompanist:accompanist-permissions:$accompanist_version"

    // tabs for user profiles
    implementation "com.google.accompanist:accompanist-pager:$accompanist_version" // Pager
    implementation "com.google.accompanist:accompanist-pager-indicators:$accompanist_version"

    // Parses URLs from Text:
    implementation "io.github.url-detector:url-detector:0.1.23"

    // For QR generation
    implementation 'com.google.zxing:core:3.5.1'
    implementation "androidx.camera:camera-camera2:1.2.1"
    implementation 'androidx.camera:camera-lifecycle:1.2.1'
    implementation 'androidx.camera:camera-view:1.2.1'

    // Markdown
    implementation "com.halilibo.compose-richtext:richtext-ui:0.16.0"
    implementation "com.halilibo.compose-richtext:richtext-ui-material:0.16.0"
    implementation "com.halilibo.compose-richtext:richtext-commonmark:0.16.0"

    // For QR Scanning
    implementation 'com.google.mlkit:vision-common:17.3.0'

    // Local Barcode Scanning model
    // The idea is to make it work for degoogled phones
    implementation 'com.google.mlkit:barcode-scanning:17.0.3'

    // Local model for language identification
    implementation 'com.google.mlkit:language-id:17.0.4'

    // Google services model the translate text
    implementation 'com.google.mlkit:translate:17.0.1'


    // Automatic memory leak detection
    debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.10'

    testImplementation 'junit:junit:4.13.2'
    testImplementation "io.mockk:mockk:1.13.4"
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
    androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_ui_version"
    debugImplementation "androidx.compose.ui:ui-tooling:$compose_ui_version"
    debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_ui_version"
}

ktlint {
    disabledRules.set(["no-wildcard-imports"])
}