// Notice: Oreo builds are disabled by default until all problems are resolved!!!
//
// For Oreo compatibility we are forced to use supportLibVersion >= 26.1.0
// Unfortunately Android stopped supporting downloading libraries through the SDK Manager,
// @see https://developer.android.com/topic/libraries/support-library/setup.html
//
// You can enable oreo by adding following into root build.gradle:
//
// allprojects {
//   repositories {
//     maven { url 'https://maven.google.com' }
//   }
// }
//
// ext {
//   compileSdkVersion = 26
//   targetSdkVersion = 26
//   buildToolsVersion = "26.0.2"
//   supportLibVersion = "support-v4"
//   googlePlayServicesVersion = "11.8.0"
//   oreoEXPERIMENTAL = "hellyes"
// }
//
//
// If you don't like this please ask react guys nicely to add google maven repo into
// their templates.

apply plugin: 'com.android.library'

def DEFAULT_COMPILE_SDK_VERSION = 27
def DEFAULT_BUILD_TOOLS_VERSION = "27.0.3"
def DEFAULT_TARGET_SDK_VERSION = 27
def DEFAULT_PLAY_SERVICES_VERSION = "12+"
def DEFAULT_SUPPORT_LIB_VERSION = "27.0.3"

def applicationId = ""
if (findProject(':app') != null) {
    applicationId = project(':app').android.defaultConfig.applicationId
}


// Check for application-defined play-services version
def playServicesVersion = DEFAULT_PLAY_SERVICES_VERSION
if (rootProject.hasProperty('playServicesVersion')) {
    playServicesVersion = rootProject.playServicesVersion
} else if (rootProject.hasProperty('googlePlayServicesVersion')) {
    playServicesVersion = rootProject.googlePlayServicesVersion
}

def supportLibVersion = DEFAULT_SUPPORT_LIB_VERSION
if (rootProject.hasProperty('supportLibVersion')) {
    supportLibVersion = rootProject.supportLibVersion
}

repositories {
    jcenter()
    // Google dependencies are now hosted at Maven
    // unfortunately this is ignored when installing as react-native plugin
    maven {
        url 'https://maven.google.com'
    }
}

android {
    compileSdkVersion rootProject.hasProperty('compileSdkVersion') ? rootProject.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
    buildToolsVersion rootProject.hasProperty('buildToolsVersion') ? rootProject.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION

    defaultConfig {
        resValue "string", "content_authority", applicationId + '.provider'
        resValue "string", "account_type", applicationId
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        minSdkVersion 16
        targetSdkVersion rootProject.hasProperty('targetSdkVersion') ? rootProject.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION
        versionCode 1 // intentionally not updating version as we're not uploading to any java repository
        versionName "1.0"
    }

    lintOptions {
        abortOnError false
    }
}

dependencies {
    releaseImplementation project(path: ':react-native-vivekkiran-background-geolocation-common')
    debugImplementation project(path: ':react-native-vivekkiran-background-geolocation-common')
    implementation 'com.facebook.react:react-native:+'
    implementation "com.google.android.gms:play-services-location:12.0.1"
    implementation "com.android.support:support-compat:27.1.1"
    implementation 'com.github.tony19:logback-android:1.1.1-9'
    implementation 'org.slf4j:slf4j-api:1.7.21'
    implementation 'com.intentfilter:android-permissions:0.1.6'
}
