/*
 * Aurora Store
 * Copyright (C) 2019, Rahul Kumar Patel <whyorean@gmail.com>
 *
 * Aurora Store is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * Aurora Store is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Aurora Store.  If not, see <http://www.gnu.org/licenses/>.
 *
 *
 */

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    defaultConfig {
        multiDexEnabled true

        applicationId "com.aurora.store"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 18
        versionName "3.1.8"

        resConfigs "ar-rSA", "b+ast", "bh-rIN", "bg-rBG", "ca-rES", "de-rDE", "es-rES", "el-rGR", "fr-rFR", "gl-rES", "hi-rIN", "hr-rHR", "hu-rHU", "in-rID", "it-rIT", "iw-rIL", "ja-rJP", "ko-rKR", "lt-rLT",
                "pl-rPL", "pt-rPT", "pt-rBR", "ro-rRO", "ru-rRU", "sc-rIT", "sk-rSK", "sr-rSR", "sv-rSE", "th-rTH", "tr-rTR", "uk-rUA", "vi-rVN", "zh-rCN", "zh-rTW", "nl-rNL", "be-rBY", "nb-rNO", "pa-rIN",
                "cy-rGB", "et-rEE"

        vectorDrawables.useSupportLibrary = true
    }
    signingConfigs {
        release
    }
    buildTypes {
        release {
            minifyEnabled true
            zipAlignEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
    }
    compileOptions {
        targetCompatibility 1.8
        sourceCompatibility 1.8
    }
    lintOptions {
        warning 'MissingTranslation', 'GetLocales', 'VectorDrawableCompat'
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'commons-io:commons-io:2.6'
    implementation 'org.apache.maven:maven-artifact:3.6.2'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'

    //UI-Libs
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4'
    implementation 'androidx.preference:preference:1.1.0'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0'
    implementation 'androidx.palette:palette:1.0.0'
    implementation 'androidx.navigation:navigation-fragment:2.1.0'
    implementation 'androidx.navigation:navigation-ui:2.1.0'
    implementation 'com.google.android.material:material:1.1.0-alpha10'
    implementation 'io.github.luizgrp.sectionedrecyclerviewadapter:sectionedrecyclerviewadapter:3.0.0'

    //Utils
    implementation 'androidx.annotation:annotation:1.1.0'
    implementation 'org.apache.commons:commons-text:1.8'
    implementation 'com.scottyab:rootbeer-lib:0.0.7'
    implementation 'com.google.code.gson:gson:2.8.6'
    compileOnly 'org.projectlombok:lombok:1.18.10'
    annotationProcessor 'org.projectlombok:lombok:1.18.10'

    //PlayStoreApi
    implementation 'com.github.whyorean:playstore-api-v2:2.5'

    //OkHTTP3
    implementation 'com.squareup.okhttp3:okhttp:4.2.2'
    implementation 'com.squareup.okhttp3:okhttp-urlconnection:4.2.2'

    //RX-Java2
    implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
    implementation 'io.reactivex.rxjava2:rxjava:2.2.14'
    implementation 'com.jakewharton.rxrelay2:rxrelay:2.1.1'

    //ButterKnife
    implementation 'com.jakewharton:butterknife:10.2.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.0'

    //Glide
    implementation 'com.github.bumptech.glide:glide:4.10.0'
    implementation "com.github.bumptech.glide:okhttp3-integration:4.10.0"
    annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'

    //Fetch - Downloader
    implementation 'androidx.tonyodev.fetch2:xfetch2:3.1.4'
    implementation 'androidx.tonyodev.fetch2okhttp:xfetch2okhttp:3.1.4'
}

repositories {
    mavenCentral()
}

def 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('STORE_PASSWORD') &&
            props.containsKey('KEY_ALIAS') && props.containsKey('KEY_PASSWORD')) {
        android.signingConfigs.release.storeFile = file(props['STORE_FILE'])
        android.signingConfigs.release.storePassword = props['STORE_PASSWORD']
        android.signingConfigs.release.keyAlias = props['KEY_ALIAS']
        android.signingConfigs.release.keyPassword = props['KEY_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
}
