apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlin-kapt'

import com.android.build.OutputFile

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "net.mediaarea.mediainfo"
        minSdkVersion 14
        targetSdkVersion 28
        versionCode 10
        versionName "19.09"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary true
        }
        externalNativeBuild {
            cmake {
                cppFlags "-DUNICODE -D_UNICODE -DMEDIAINFO_ADVANCED_NO -DMEDIAINFO_REFERENCES_NO -DMEDIAINFO_FILTER_NO -DMEDIAINFO_DUPLICATE_NO -DMEDIAINFO_MACROBLOCKS_NO -DMEDIAINFO_TRACE_NO -DMEDIAINFO_TRACE_FFV1CONTENT_NO -DMEDIAINFO_IBI_NO -DMEDIAINFO_DIRECTORY_NO -DMEDIAINFO_LIBCURL_NO -DMEDIAINFO_LIBMMS_NO -DMEDIAINFO_DVDIF_ANALYZE_NO -DMEDIAINFO_MPEGTS_DUPLICATE_NO -DMEDIAINFO_READTHREAD_NO -DMEDIAINFO_MD5_NO -DMEDIAINFO_SHA1_NO -DMEDIAINFO_SHA2_NO -DMEDIAINFO_EVENTS_NO -DMEDIAINFO_DEMUX_NO -DMEDIAINFO_AES_NO -DMEDIAINFO_FIXITY_NO -DMEDIAINFO_READER_NO -DMEDIAINFO_NEXTPACKET_NO"
            }
        }
        if(project.hasProperty("RELEASE_STORE_FILE")) {
            signingConfigs {
                release {
                    storeFile file(RELEASE_STORE_FILE)
                    storePassword RELEASE_STORE_PASSWORD
                    keyAlias RELEASE_KEY_ALIAS
                    keyPassword RELEASE_KEY_PASSWORD
                }
            }
        }
    }
    buildTypes {
        release {
            if(project.hasProperty("RELEASE_STORE_FILE")) {
                signingConfig signingConfigs.release
            }
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
        }
    }
    splits {
        abi {
            enable true
            universalApk true
        }
    }

    def abiCodes = ['armeabi-v7a':1, 'arm64-v8a':2, 'x86':3, 'x86_64':4]
    android.applicationVariants.all { variant ->
        // Assigns a different version code for each output APK.
        variant.outputs.each {
            output ->
                def abiName = output.getFilter(OutputFile.ABI)
                output.versionCodeOverride = variant.versionCode * 10 + abiCodes.get(abiName, 0)
        }
    }

    buildToolsVersion '28.0.3'
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.google.android.material:material:1.1.0-alpha01'
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'com.android.support:design:28.2.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
    // Android Room
    implementation 'androidx.room:room-runtime:2.1.0-alpha02'
    implementation 'androidx.room:room-rxjava2:2.1.0-alpha02'
    kapt 'androidx.room:room-compiler:2.1.0-alpha02'
    //RxJava
    implementation 'io.reactivex.rxjava2:rxjava:2.1.14'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
    // Android Lifecycle
    implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
    kapt "androidx.lifecycle:lifecycle-compiler:2.0.0"
    // Legacy file picker
    implementation 'com.github.angads25:filepicker:1.1.1'
    // Google Billing
    implementation "com.android.billingclient:billing:1.2"
    // KotlinX Coroutines
    api "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.0.1"
    api "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.1"
}
