apply plugin: 'com.android.application'

android {
    //the compression of webp file during build causes problem with FileDescriptor in ContentProvider.
    aaptOptions {
        noCompress "webp"
    }
    signingConfigs {
        signing_config {
            keyAlias 'abc'
            keyPassword '123'
        }
    }
    compileSdkVersion 28
    defaultConfig {
        applicationId "stickeradmin.signalstickers.trending"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        def contentProviderAuthority = applicationId + ".stickermaker.WhatsAppBasedCode.stickercontentprovider"
        def contentProviderAuthority2 = applicationId + ".stickercontentprovider"
        // Creates a placeholder property to use in the manifest.
        manifestPlaceholders =
                [contentProviderAuthority: contentProviderAuthority, contentProviderAuthority2: contentProviderAuthority2]
        // Adds a new field for the authority to the BuildConfig class.
        buildConfigField("String",
                "CONTENT_PROVIDER_AUTHORITY",
                "\"${contentProviderAuthority}\"")

        buildConfigField("String",
                "CONTENT_PROVIDER_AUTHORITY2",
                "\"${contentProviderAuthority2}\"")
    }
    buildTypes {
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    dataBinding {
        enabled = true
    }
}

task checkDebug {
    doLast {
        println("checkDebug")


        checkApplicationIdInDebug()
    }
}

private void checkApplicationIdInDebug() {
    Properties properties = new Properties()
    properties.load(project.rootProject.file('local.properties').newDataInputStream())
    def ignoreApplicationIdCheck = properties.getProperty('ignoreApplicationIdCheck')
    if (ignoreApplicationIdCheck == null) {

    } else {
        println("application id check ignored")
    }
}


task checkRelease {
    doLast {
        println("checkRelease")
        if (android.defaultConfig.applicationId.startsWith("com.example")) {
            throw new GradleException("applicationId in defaultConfig cannot start with com.example, please change your applicationId in app/build.gradle");
        }
    }
}

tasks.whenTaskAdded { task ->
    println(task.name)
    if (task.name.contains("assembleDebug")) {
        task.dependsOn checkDebug
    }
    if (task.name.contains("assembleRelease")) {
        task.dependsOn checkRelease
    }
}


dependencies {
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'com.google.firebase:firebase-analytics:17.2.0'
    // implementation 'com.google.firebase:firebase-messaging:11.0.4'
    //testImplementation 'junit:junit:4.13-beta-3'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    androidTestImplementation 'androidx.test:runner:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.facebook.fresco:fresco:1.10.0'
    implementation 'com.facebook.fresco:webpsupport:1.10.0'
    implementation 'com.facebook.fresco:animated-webp:1.10.0'
    implementation 'com.facebook.fresco:webpsupport:1.10.0'
    //implementation 'com.google.android.gms:play-services-ads:19.1.0'
    implementation 'com.google.code.gson:gson:2.8.5'
    implementation 'com.heinrichreimersoftware:material-intro:1.6'
    //implementation 'com.github.iammert:MaterialIntroView:1.6.0'
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'com.google.firebase:firebase-messaging:20.0.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation("com.github.bumptech.glide:glide:4.11.0") {
        exclude group: "com.android.support"
    }
    implementation 'com.andrognito.flashbar:flashbar:1.0.2'
    implementation 'com.github.bumptech.glide:glide:4.11.0'
    implementation 'com.google.android.gms:play-services-ads:19.2.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
    implementation 'com.facebook.soloader:soloader:0.9.0+'
    implementation 'com.makeramen:roundedimageview:2.3.0'
    implementation 'com.facebook.android:audience-network-sdk:6.+'
    // implementation 'com.facebook.fresco:animated-base:1.13.0'
}


apply plugin: 'com.google.gms.google-services'
