apply plugin: 'com.android.library'

dependencies {
}

task colouriseIcons(type: Copy) {
    from 'icons/'
    into 'build/generated/icons/drawable'
    includeEmptyDirs false
    eachFile { it.path = 'material_' + (name.replaceAll('_black_24dp.xml', '_24dp.xml')) }
    filter { line -> line.replaceAll(/android:fillColor="#(FF)?(0[01]){3}"/, 'android:fillColor="?android:attr/textColorPrimary"')}

    // Explicitly declare each icon we want to use
    include ([
            'arrow_downward',
            'content_copy',
            'replay',
            'share',
    ].collect { r ->
        '**/drawable-anydpi-v21/ic_' + r + '_black_24dp.xml'
    })
}

android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'

    defaultConfig {
        // We can go back to API 10, but AndProx only runs on API 21+
        minSdkVersion 21
        targetSdkVersion 28
        vectorDrawables {
            useSupportLibrary = true
            generatedDensities = []
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    preBuild.dependsOn colouriseIcons
    sourceSets.main.res.srcDirs = ['build/generated/icons']

    lintOptions {
        // We actually support these attributes in older API versions, with the support library.
        abortOnError false
        disable 'NewApi'
    }
}