apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'io.fabric'

def secretsFilename = "secrets.gradle.kts"
try {
    apply from: "$rootDir/$secretsFilename"
} catch (e) {
    throw new GradleException(
            "To build this project, you must make a `$secretsFilename` file that provides the " +
                    "required secrets keys.\n" +
                    "To get your secret keys, go here: " +
                    "https://app.put.io/settings/account/oauth/apps" +
                    """
Example `$secretsFilename`:

extra["secrets"] = PutioSecrets(
  putioClientId = "your put.io Client ID",
  putioApiKey = "your put.io API key"
)
""", e)
}

repositories {
    maven {
        url 'https://maven.fabric.io/public'
    }
}

android {
    compileSdkVersion 29
    defaultConfig {
        applicationId 'com.stevenschoen.putionew'
        minSdkVersion 21
        targetSdkVersion 27
        versionCode 137
        versionName '4.5.0'
        multiDexEnabled true

        kapt {
            arguments {
                arg("room.schemaLocation", "$projectDir/schemas")
            }
        }

        resValue "string", "putio_client_id", secrets.putioClientId
        resValue "string", "putio_api_key", secrets.putioApiKey
    }
    signingConfigs {
        if (secrets.keystorePath != null) {
            release {
                storeFile file(secrets.keystorePath)
                storePassword secrets.keystorePassword
                keyAlias secrets.keyAlias
                keyPassword secrets.keyPassword
            }
        }
    }
    buildTypes {
        debug {
            versionNameSuffix "-debug"
            manifestPlaceholders = [crashlyticsEnabled: false]
        }
        release {
            if (signingConfigs.findByName("release") != null) {
                signingConfig signingConfigs.release
            }
            manifestPlaceholders = [crashlyticsEnabled: true]
        }
    }
    lintOptions {
        disable 'ExtraTranslation'
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/ASL2.0'
    }
    compileOptions {
        sourceCompatibility = '1.8'
        targetCompatibility = '1.8'
    }
}

androidExtensions {
    experimental = true
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.1.0'
    implementation 'com.google.android.material:material:1.1.0-beta01'
    implementation 'androidx.leanback:leanback:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.mediarouter:mediarouter:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.firebase:firebase-core:17.2.0'
    implementation "com.google.android.gms:play-services-cast-framework:17.1.0"
    implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
    implementation 'com.jakewharton.timber:timber:4.7.1'
    implementation 'commons-io:commons-io:2.6'
    implementation 'net.danlew:android.joda:2.10.1'
    implementation 'io.reactivex.rxjava2:rxjava:2.2.5'
    def rxLifecycleVersion = "3.0.0"
    implementation "com.trello.rxlifecycle3:rxlifecycle-components:$rxLifecycleVersion"
    implementation "com.trello.rxlifecycle3:rxlifecycle-kotlin:$rxLifecycleVersion"
    implementation "com.trello.rxlifecycle3:rxlifecycle:$rxLifecycleVersion"
    def rxBindingVersion = "2.2.0"
    implementation "com.jakewharton.rxbinding2:rxbinding:$rxBindingVersion"
    implementation "com.jakewharton.rxbinding2:rxbinding-support-v4:$rxBindingVersion"
    implementation "com.jakewharton.rxbinding2:rxbinding-appcompat-v7:$rxBindingVersion"
    implementation "com.jakewharton.rxbinding2:rxbinding-design:$rxBindingVersion"
    implementation "com.jakewharton.rxbinding2:rxbinding-recyclerview-v7:$rxBindingVersion"
    implementation "com.jakewharton.rxbinding2:rxbinding-leanback-v17:$rxBindingVersion"
    def okHttpVersion = "3.12.1"
    implementation "com.squareup.okhttp3:okhttp:$okHttpVersion"
    implementation "com.squareup.okhttp3:logging-interceptor:$okHttpVersion"
    def retrofitVersion = "2.5.0"
    implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
    implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion"
    implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"
    implementation 'com.google.code.gson:gson:2.8.5'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'com.google.android.exoplayer:exoplayer:2.10.4'
    def roomVersion = '2.1.0'
    kapt "androidx.room:room-compiler:$roomVersion"
    implementation "androidx.room:room-runtime:$roomVersion"
    implementation "androidx.room:room-rxjava2:$roomVersion"
    implementation 'com.duolingo.open:rtl-viewpager:1.0.3'
}

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