def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
//if (flutterRoot == null) {
//    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
//}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

apply plugin: 'com.android.application'
apply plugin: 'com.huawei.agconnect'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'
//apply plugin: 'com.google.firebase.crashlytics'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"


configurations.all {
    c ->
        c.resolutionStrategy.eachDependency {
            DependencyResolveDetails dependency ->
                println dependency.requested.group
                if (dependency.requested.group == 'org.bouncycastle') {
                    dependency.useTarget 'org.bouncycastle:bcprov-jdk15to18:1.68'
                }
        }
}

//configurations.all {
//    resolutionStrategy {
//        force 'androidx.core:core-ktx:1.6.0'
//    }
//}

android {
    compileSdkVersion 34
//    ndkVersion "24.0.8215888"

    buildFeatures {
        viewBinding true
        dataBinding true
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'MissingTranslation'
        checkReleaseBuilds false
    }


    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.ejada.hmg"
        minSdkVersion 26
        targetSdkVersion 34
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        multiDexEnabled false
    }

    sourceSets.main {
        jniLibs.srcDir 'src/main/libs'
        jni.srcDirs = [] //disable automatic ndk-build call
    }

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword keystoreProperties['storePassword']
        }
    }

    buildTypes {
        debug {
            debuggable true
            signingConfig signingConfigs.debug
            shrinkResources false
            minifyEnabled false
//            ndk {
//                abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86_64'
//            }
        }
        release {
            debuggable false
            signingConfig signingConfigs.release
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        staging {
            // Specifies a sorted list of fallback build types that the
            // plugin should try to use when a dependency does not include a
            // "staging" build type. You may specify as many fallbacks as you
            // like, and the plugin selects the first build type that's
            // available in the dependency.
            matchingFallbacks = ['debug', 'qa', 'release']
        }
    }

    packagingOptions {
        exclude 'META-INF/proguard/androidx-annotations.pro'
        pickFirst 'lib/x86/libc++_shared.so'
        pickFirst 'lib/x86_64/libc++_shared.so'
        pickFirst 'lib/armeabi-v7a/libc++_shared.so'
        pickFirst 'lib/arm64-v8a/libc++_shared.so'
        pickFirst '**/*.so'
    }


    compileOptions {
//        coreLibraryDesugaringEnabled true
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

flutter {
    source '../..'
}

dependencies {
//    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'

    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation "com.google.firebase:firebase-messaging:21.0.0"
//    implementation ('com.google.firebase:firebase-inappmessaging-display:19.1.2',{
//        exclude group: 'com.google.protobuf',module: 'protobuf-javalite'
//        exclude group: 'com.google.protobuf',module: 'protobuf-lite'
//    })
    implementation 'pub.devrel:easypermissions:3.0.0'
//    implementation 'com.google.firebase:firebase-inappmessaging-display:17.2.0'
    // implementation 'com.google.firebase:firebase-inappmessaging-display:17.2.0'
    implementation 'com.google.guava:guava:27.0.1-android'
    // Dependency on local binaries
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.google.code.gson:gson:2.8.6'

    // Dependency on a remote binary
//    implementation 'com.example.android:app-magic:12.3'


    implementation "us.zoom.videosdk:zoomvideosdk-core:1.10.1"
    implementation "us.zoom.videosdk:zoomvideosdk-annotation:1.10.1"
    implementation "us.zoom.videosdk:zoomvideosdk-videoeffects:1.10.1"

    // Native Dependency

//    implementation "us.zoom.videosdk:ZoomVideoSDK:1.10.11"
//    implementation group: 'us.zoom.videosdk', name: 'zoomvideosdk-core', version: '1.10.11'

//    implementation "us.zoom.videosdk:zoomvideosdk-core:1.10.1"
//    implementation "us.zoom.videosdk:zoomvideosdk-annotation:1.10.1"
//    implementation "us.zoom.videosdk:zoomvideosdk-videoeffects:1.10.1"

    implementation 'com.squareup.okhttp3:logging-interceptor:4.9.3'
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
    implementation 'com.squareup.retrofit2:adapter-java8:2.4.0'
    implementation 'com.google.code.gson:gson:2.8.9'
    implementation 'com.google.android.gms:play-services-location:21.3.0'
    implementation 'com.squareup.okhttp3:okhttp:4.10.0'
    implementation 'androidx.test.ext:junit:1.1.5'
    implementation 'com.android.volley:volley:1.2.1'
    def room_version = "2.4.0-alpha04"
    implementation "androidx.room:room-runtime:$room_version"
    annotationProcessor "androidx.room:room-compiler:$room_version"
    implementation 'net.zetetic:android-database-sqlcipher:4.5.2'
    implementation 'com.intuit.ssp:ssp-android:1.1.0'
    implementation 'com.intuit.sdp:sdp-android:1.1.0'
    implementation 'com.github.bumptech.glide:glide:4.12.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'

//    implementation "com.mapbox.maps:android:10.16.6"
//    implementation 'com.mapbox.maps:android:11.3.1'

//    implementation files('libs/PenNavUI.aar')
//    implementation files('libs/Penguin.aar')
//    implementation files('libs/PenguinRenderer.aar')

//    implementation "org.jetbrains.anko:anko-commons:0.10.4"
    implementation 'com.github.kittinunf.fuel:fuel:2.3.0' //for JVM
    implementation 'com.github.kittinunf.fuel:fuel-android:2.3.0'
    implementation 'com.google.android.gms:play-services-location:17.1.0'//for Android
    implementation 'com.google.android.gms:play-services-basement:17.5.0'
    implementation "com.opentok.android:opentok-android-sdk:2.21.4"
    implementation 'com.facebook.stetho:stetho:1.5.1'
    implementation 'com.facebook.stetho:stetho-urlconnection:1.5.1'
    implementation 'androidx.core:core-ktx:1.6.0'
    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'com.google.android.material:material:1.9.0'
    implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.22'
    androidTestImplementation "androidx.test:core:1.4.0"
    implementation 'com.airbnb.android:lottie:5.2.0'
    implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.22'

}
