plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'androidx.navigation.safeargs'
    id 'kotlin-kapt'
}

android {
    compileSdkVersion 33
    buildToolsVersion "33.0.1"

    defaultConfig {
        applicationId "org.ergoplatform.android"
        minSdkVersion 24
        targetSdkVersion 33
        versionCode 2305
        versionName "2.4.2305"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildFeatures {
        compose true
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }

    }

    flavorDimensions "nodetype"
    productFlavors {
        ergotestnet {
            // Assigns this product flavor to the "version" flavor dimension.
            // If you are using only one dimension, this property is optional,
            // and the plugin automatically assigns all the module's flavors to
            // that dimension.
            dimension "nodetype"
            applicationIdSuffix ".testnet"
            versionNameSuffix "-testnet"
        }
        ergomainnet {
            dimension "nodetype"
        }
    }

    buildFeatures {
        viewBinding true
    }

    compileOptions {
        coreLibraryDesugaringEnabled true
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }

    composeOptions {
        kotlinCompilerExtensionVersion compose_version
        kotlinCompilerVersion kotlin_version
    }
}

dependencies {
    implementation project(path: ':common-jvm')
    implementation project(path: ':common-compose')

    def room_version = "2.4.3"
    def lifecycle_version = "2.5.1"

    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.0'

    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.9.0'
    implementation 'androidx.appcompat:appcompat:1.5.1'
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
    implementation 'androidx.paging:paging-runtime:3.1.1'
    implementation 'com.google.android.material:material:1.7.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
    implementation "androidx.navigation:navigation-fragment:$nav_version"
    implementation "androidx.navigation:navigation-ui:$nav_version"
    implementation("androidx.cardview:cardview:1.0.0")
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
    implementation("androidx.biometric:biometric:1.1.0")
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"

    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation "androidx.room:room-runtime:$room_version"
    implementation("androidx.room:room-ktx:$room_version")
    kapt "androidx.room:room-compiler:$room_version"

    def work_version = "2.7.1"
    implementation "androidx.work:work-runtime:$work_version"
    implementation "androidx.work:work-runtime-ktx:$work_version"

    implementation('com.journeyapps:zxing-android-embedded:4.2.0')

    // newer okhttp version than pulled from dependencies to avoid StrictMode policy violation
    // defined here because causing errors on iOS
    implementation("com.squareup.okhttp3:okhttp:3.12.13")
    implementation("com.squareup.okhttp3:okhttp-urlconnection:3.12.13")

    // work around guava duplicate classes with guava 20.0 (fixed in 27+ but not usable)
    implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'

    // Compose
    implementation "androidx.compose.runtime:runtime:$compose_version"
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation "androidx.compose.foundation:foundation:$compose_version"
    implementation "androidx.compose.foundation:foundation-layout:$compose_version"
    implementation "androidx.compose.material:material:$compose_version"
    implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
    implementation "com.github.MrStahlfelge.mosaik:common-compose:$mosaik_version"

    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.4'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
    androidTestImplementation 'androidx.test:rules:1.5.0'
}

// Disable dependency verification on test classpaths
configurations {
    ergomainnetDebugAndroidTestRuntimeClasspath {
        resolutionStrategy {
            disableDependencyVerification()
        }
    }
    ergomainnetDebugAndroidTestCompileClasspath {
        resolutionStrategy {
            disableDependencyVerification()
        }
    }
    ergotestnetDebugAndroidTestRuntimeClasspath {
        resolutionStrategy {
            disableDependencyVerification()
        }
    }
    ergotestnetDebugAndroidTestCompileClasspath {
        resolutionStrategy {
            disableDependencyVerification()
        }
    }
}
