import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform

apply plugin: 'com.android.library'

repositories {
    mavenCentral()
    google()
}

configurations {
    compile.exclude module: 'support-v4'
    cleanedAnnotations
    implementation.exclude group: 'org.jetbrains', module:'annotations'
}

configurations.all {
//    exclude group: 'com.google.firebase', module: 'firebase-core'
    exclude group: 'androidx.recyclerview', module: 'recyclerview'
}

dependencies {
    implementation 'androidx.core:core:1.9.0'
    implementation 'androidx.palette:palette:1.0.0'
    implementation 'androidx.exifinterface:exifinterface:1.3.3'
    implementation 'androidx.dynamicanimation:dynamicanimation:1.0.0'
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation "androidx.sharetarget:sharetarget:1.2.0"

    compileOnly 'org.checkerframework:checker-qual:2.5.2'
    compileOnly 'org.checkerframework:checker-compat-qual:2.5.0'
//    implementation 'com.google.firebase:firebase-messaging:22.0.0'
//    implementation 'com.google.firebase:firebase-config:21.0.1'
//    implementation 'com.google.firebase:firebase-datatransport:18.1.0'
//    implementation 'com.google.firebase:firebase-appindexing:20.0.0'
    implementation 'com.google.android.gms:play-services-maps:18.1.0'
    implementation 'com.google.android.gms:play-services-auth:20.4.0'
    implementation 'com.google.android.gms:play-services-vision:20.1.3'
    implementation 'com.google.android.gms:play-services-wearable:18.0.0'
    implementation 'com.google.android.gms:play-services-location:21.0.1'
    implementation 'com.google.android.gms:play-services-wallet:19.1.0'
    implementation 'com.google.android.gms:play-services-safetynet:18.0.1'
    implementation 'com.googlecode.mp4parser:isoparser:1.0.6'
    implementation 'com.stripe:stripe-android:2.0.2'
    implementation 'com.google.mlkit:language-id:16.1.1'
    implementation 'com.android.billingclient:billing:6.0.1'
    implementation 'com.google.code.gson:gson:2.10'
    implementation 'com.google.guava:guava:31.1-android'

    api platform('com.google.firebase:firebase-bom:32.7.4')
    implementation 'com.google.firebase:firebase-messaging'
    implementation 'com.google.firebase:firebase-config'
    implementation 'com.google.firebase:firebase-datatransport'
//    implementation 'com.google.firebase:firebase-appindexing'
    api 'com.google.firebase:firebase-crashlytics'
    api 'com.google.firebase:firebase-analytics'

    implementation project(':openai_service')
    annotationProcessor 'org.projectlombok:lombok:1.18.30'

    implementation project(':markwon-core')
    implementation project(':markwon-ext-tables')
    implementation project(':markwon-ext-strikethrough')
    implementation project(':markwon-ext-tasklist')
    implementation project(':markwon-html')

//    implementation 'io.noties.markwon:ext-latex:4.6.2'
//    implementation 'io.noties.markwon:image:4.6.2'
//    implementation 'io.noties.markwon:image-glide:4.6.2'
//    implementation 'io.noties.markwon:inline-parser:4.6.2'
//    implementation 'io.noties.markwon:linkify:4.6.2'
//    implementation 'io.noties.markwon:recycler:4.6.2'
//    implementation 'io.noties.markwon:recycler-table:4.6.2'
//    implementation 'io.noties.markwon:syntax-highlight:4.6.2'
//    implementation 'io.noties.markwon:simple-ext:4.6.2'

    implementation 'org.apache.commons:commons-text:1.13.0'

    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
}

def isWindows = String.valueOf(DefaultNativePlatform.currentOperatingSystem.toFamilyName() == OperatingSystemFamily.WINDOWS)
android {
    compileSdkVersion 34
    buildToolsVersion '34.0.0'
    ndkVersion "21.4.7075529"

    sourceSets.main.jniLibs.srcDirs = ['./jni/']

    externalNativeBuild {
        cmake {
            path 'jni/CMakeLists.txt'
        }
    }

    lintOptions {
        disable 'MissingTranslation'
        disable 'ExtraTranslation'
        disable 'BlockedPrivateApi'
    }

    dexOptions {
        jumboMode = true
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11

        coreLibraryDesugaringEnabled true
    }

    defaultConfig.versionCode = Integer.parseInt(APP_VERSION_CODE)

    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 34
        versionName "8.9.0"

        vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi']

        multiDexEnabled true

        externalNativeBuild {
            cmake {
                version '3.10.2'
                arguments '-DANDROID_STL=c++_static', '-DANDROID_PLATFORM=android-16'
            }
        }
    }

    buildTypes {
        debug {
            debuggable true
            jniDebuggable true
            minifyEnabled false
            shrinkResources false
            multiDexEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), '../TMessagesProj/proguard-rules.pro'
            ndk.debugSymbolLevel = 'FULL'
            buildConfigField "String", "APP_CENTER_HASH", "\"\""
            buildConfigField "boolean", "DEBUG_VERSION", "true"
            buildConfigField "boolean", "DEBUG_PRIVATE_VERSION", "true"
            buildConfigField "boolean", "BUILD_HOST_IS_WINDOWS", isWindows
        }

        HA_private {
            debuggable false
            jniDebuggable false
            minifyEnabled true
            multiDexEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), '../TMessagesProj/proguard-rules.pro'
            ndk.debugSymbolLevel = 'FULL'
            buildConfigField "String", "APP_CENTER_HASH", "\"" + getProps("APP_CENTER_HASH_PRIVATE") + "\""
            buildConfigField "boolean", "DEBUG_VERSION", "true"
            buildConfigField "boolean", "DEBUG_PRIVATE_VERSION", "true"
            buildConfigField "boolean", "BUILD_HOST_IS_WINDOWS", isWindows
        }

        HA_public {
            debuggable false
            jniDebuggable false
            minifyEnabled true
            multiDexEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), '../TMessagesProj/proguard-rules.pro'
            ndk.debugSymbolLevel = 'FULL'
            buildConfigField "String", "APP_CENTER_HASH", "\"" + getProps("APP_CENTER_HASH_PUBLIC") + "\""
            buildConfigField "boolean", "DEBUG_VERSION", "true"
            buildConfigField "boolean", "DEBUG_PRIVATE_VERSION", "false"
            buildConfigField "boolean", "BUILD_HOST_IS_WINDOWS", isWindows
        }

        standalone {
            debuggable false
            jniDebuggable false
            minifyEnabled true
            multiDexEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), '../TMessagesProj/proguard-rules.pro'
            ndk.debugSymbolLevel = 'FULL'
            buildConfigField "String", "APP_CENTER_HASH", "\"\""
            buildConfigField "boolean", "DEBUG_VERSION", "false"
            buildConfigField "boolean", "DEBUG_PRIVATE_VERSION", "false"
            buildConfigField "boolean", "BUILD_HOST_IS_WINDOWS", isWindows
        }

        release {
            debuggable false
            jniDebuggable false
            minifyEnabled true
            shrinkResources false
            multiDexEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), '../TMessagesProj/proguard-rules.pro'
            ndk.debugSymbolLevel = 'FULL'
            buildConfigField "String", "APP_CENTER_HASH", "\"\""
            buildConfigField "boolean", "DEBUG_VERSION", "false"
            buildConfigField "boolean", "DEBUG_PRIVATE_VERSION", "false"
            buildConfigField "boolean", "BUILD_HOST_IS_WINDOWS", isWindows
        }
    }
}


def getProps(String propName) {
    def propsFile = rootProject.file('local.properties')
    if (propsFile.exists()) {
        def props = new Properties()
        props.load(new FileInputStream(propsFile))
        return props[propName]
    } else {
        return "";
    }
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
