apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

repositories {
    mavenCentral()
    maven { url "https://jitpack.io" }
    maven { url "https://s3.amazonaws.com/repo.commonsware.com" }
}

def keystorePropertiesFile = rootProject.file("keystore.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.alienpants.leafpicrevived"
        minSdkVersion 21
        targetSdkVersion 28
        versionName "v0.8.7"
        versionCode 25

        vectorDrawables.useSupportLibrary = true
        multiDexEnabled true
    }

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

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            resValue "string", "app_name", "LeafPic Revived"
            signingConfig signingConfigs.release
        }
        debug {
            applicationIdSuffix ".debug"
            resValue "string", "app_name", "LeafPic Revived (debug)"
        }
    }

    lintOptions {
        disable 'MissingTranslation', 'ExtraTranslation', 'RestrictedApi'
        abortOnError false
    }

    dexOptions {
        jumboMode = true
    }

    compileOptions {
        encoding = 'UTF-8'
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')

    // Kotlin
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

    // AndroidX
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.browser:browser:1.2.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.exifinterface:exifinterface:1.2.0'
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation 'androidx.palette:palette:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0'
    implementation 'com.google.android.material:material:1.2.0-alpha06'

    // Exoplayer
    def exoplayerVersion = "2.10.4"
    implementation "com.google.android.exoplayer:exoplayer-core:$exoplayerVersion"
    implementation "com.google.android.exoplayer:exoplayer-dash:$exoplayerVersion"
    implementation "com.google.android.exoplayer:exoplayer-smoothstreaming:$exoplayerVersion"
    implementation "com.google.android.exoplayer:exoplayer-ui:$exoplayerVersion"

    // Utils
    implementation 'com.github.bumptech.glide:glide:4.11.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
    implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.20'
    implementation 'io.noties.markwon:core:4.3.1'
    //noinspection AnnotationProcessorOnCompilePath
    implementation 'com.jakewharton:butterknife:10.2.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'
    implementation 'com.drewnoakes:metadata-extractor:2.13.0'
    //implementation 'com.github.apcro:metadata-extractor:master'
    implementation 'com.orhanobut:hawk:2.0.1'
    implementation 'com.commonsware.cwac:provider:0.5.3'

    // RxJava
    implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
    //it is recommended to keep the same version of rxAndroid
    implementation 'io.reactivex.rxjava2:rxjava:2.2.19'

    // Icons
    implementation "com.mikepenz:iconics-core:4.0.1-b01"
    implementation "com.mikepenz:iconics-views:4.0.1-b01"
    implementation 'com.mikepenz:google-material-typeface:3.0.1.4.original-kotlin@aar'
    implementation 'com.mikepenz:community-material-typeface:3.5.95.1-kotlin@aar'
    implementation 'com.mikepenz:fontawesome-typeface:5.9.0.0-kotlin@aar'

    // UI
    implementation project(':shiftcolorpicker')
    implementation 'com.github.jetradarmobile.desertplaceholder:desertplaceholder:1.2.4'
    implementation 'de.hdodenhof:circleimageview:3.1.0'
    implementation 'com.github.yalantis:ucrop:2.2.5'
    implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.10.0'
    implementation 'jp.wasabeef:recyclerview-animators:3.0.0'
    implementation 'com.github.lzyzsd:circleprogress:1.2.1'
    implementation 'com.github.apcro:Liz:0.6.1'

    // Debug only
    //implementation 'cat.ereza:customactivityoncrash:x.y.z'
}

Properties props = new Properties()
def propFile = new File('signing.properties')
if (propFile.canRead()) {
    props.load(new FileInputStream(propFile))

    if (props != null && props.containsKey('STORE_FILE') && props.containsKey('KEY_ALIAS') && props.containsKey('PASSWORD')) {
        android.signingConfigs.release.storeFile = file(props['STORE_FILE'])
        android.signingConfigs.release.storePassword = props['PASSWORD']
        android.signingConfigs.release.keyAlias = props['KEY_ALIAS']
        android.signingConfigs.release.keyPassword = props['PASSWORD']
    } else {
        println 'signing.properties found but some entries are missing'
        android.buildTypes.release.signingConfig = null
    }
} else {
    println 'signing.properties not found'
    android.buildTypes.release.signingConfig = null
}
